コード例 #1
0
ファイル: irq.c プロジェクト: cirline/ct
static int irq_set_timer(unsigned int minor, irq_func_t func)
{
	pr_info("timer interrupt minor = %p\n", minor);
	if(0 <= minor && minor <=4) {
		region_write(TINT_CSTAT, 0x1, minor, 0x1);
		region_write(VICxINTENABLE(0), 0x1, 21 + minor, 0x1);
		__raw_write(VICxVECTADDRx(0, 21 + minor), (addr_t)func);
	} else if(minor == MINOR_RTCALM){
		region_write(VICxINTENABLE(0), 0x1, 28, 0x1);
		__raw_write(VICxVECTADDRx(0, 28), (addr_t)func);
	} else {
		pr_err("error irq timer minor 0x%p\n", minor);
	}

	return 0;
}
コード例 #2
0
ファイル: timer.c プロジェクト: mercurycc/cs452
int ui_timer_update()
{
	static Timespec last = { 0 };
	Timespec current = { 0 };
	uchar timeOut[] = "DD:HH:MM:SS:MS";
	uint length = 0;
	int status = 0;

	status = time_convert( &current );
	ASSERT( status == ERR_NONE );

#define UI_TIMER_ASSIGN( field, index )		\
	do {					\
		length = utos( current.field, (char*)(timeOut + 3 * index) ); \
		if( length == 1 ){					\
			timeOut[ 3 * index + 1 ] = timeOut[ 3 * index ]; \
			timeOut[ 3 * index ] = '0';			\
		}							\
		timeOut[ 3 * index + 2 ] = ':';				\
	} while( 0 )

	last = current;
	UI_TIMER_ASSIGN( day, 0 );
	UI_TIMER_ASSIGN( hour, 1 );
	UI_TIMER_ASSIGN( min, 2 );
	UI_TIMER_ASSIGN( sec, 3 );
	UI_TIMER_ASSIGN( msec, 4 );
	timeOut[ 14 ] = '\0';

	region_write( cons, ( char* )timeOut );
	region_flush( cons );
	
	return ERR_NONE;
}
コード例 #3
0
ファイル: switches.c プロジェクト: mercurycc/cs452
int ui_switch_update( uint switchId, uint state )
{
	char* stateName = 0;

	switch( state ){
	case SWITCH_CURVE:
		stateName = "C";
		break;
	case SWITCH_STRAIGHT:
		stateName = "S";
		break;
	}
	
	region_write( switches + switchId, stateName );
	
	return ERR_NONE;
}
コード例 #4
0
ファイル: irq.c プロジェクト: cirline/ct
static int irq_set_ext(unsigned int minor, irq_func_t func)
{
	pr_info("external interrupt minor ... 0x%p \n", minor);
	if(0 <= minor && minor < 8) {
		region_write(GPHxCON(0), 0xf, minor<<2, 0xf);
		region_write(EXT_INT_x_CON(0), 0x7, minor<<2, 0x2);
		region_write(EXT_INT_x_MASK(0), 0x1, minor, 0x0);
		region_write(VICxINTENABLE(0), 0x1, minor, 0x1);
		__raw_write(VICxVECTADDRx(0, minor), (addr_t)func);
	} else if (16 <= minor && minor < 24){
		minor -= 16;
		region_write(GPHxCON(2), 0xf, minor<<2, 0xf);
		region_write(EXT_INT_x_CON(2), 0x7, minor<<2, 0x2);
		region_write(EXT_INT_x_MASK(2), 0x1, minor, 0x0);
		region_write(VICxINTENABLE(0), 0x1, 16, 0x1);
		__raw_write(VICxVECTADDRx(0, 16), (addr_t)func);
	} else {
		printf("error irq minor 0x%p\n", minor);
	}
	return 0;
}
コード例 #5
0
ファイル: switches.c プロジェクト: mercurycc/cs452
int ui_switch_init( Console* cons )
{
	int status = 0;

	/* Initialize switchio body */
	/* Notice an Iobuf is only needed to point to the console.  No
	   io should be done in this frame */
	switchFrameio = &switchFrameiobody;
	status = iobuf_init( switchFrameio, cons );
	ASSERT( status == ERR_NONE );
	
	switchFrame = &switchFramebody;
	buffers[ 0 ] = buffersbody;
	buffers[ 1 ] = buffersbody + UI_SWITCH_WIDTH;
	
	status = region_setup( switchFrame, 0,
			       UI_SWITCH_COLUMN, UI_SWITCH_ROW,
			       UI_SWITCH_WIDTH, UI_SWITCH_HEIGHT,
			       UI_SWITCH_HORIZONTAL_MARGIN, UI_SWITCH_VERTICAL_MARGIN,
			       UI_SWITCH_BOUNDRY, switchFrameio, buffers );
	ASSERT( status == ERR_NONE );

	status = region_init( switchFrame );
	ASSERT( status == ERR_NONE );

	status = region_write( switchFrame, UI_SWITCH_TITLE );
	ASSERT( status == ERR_NONE );

	while( ! region_flushed( switchFrame ) ){
		status = region_flush( switchFrame );
		ASSERT( status == ERR_NONE );
	}

	/* Print switch names */
	status = ui_switch_names( cons );
	ASSERT( status == ERR_NONE );

	/* Init switch individual states */
	status = ui_switch_state_init( cons );
	ASSERT( status == ERR_NONE );

	return ERR_NONE;
}
コード例 #6
0
ファイル: irq.c プロジェクト: cirline/ct
static inline void timer_clear_pending(unsigned int minor)
{
	set2clear(TINT_CSTAT, 0x1, 5 + minor);
	region_write(TINT_CSTAT, 0x1, minor, 0x1);
}
コード例 #7
0
ファイル: switches.c プロジェクト: mercurycc/cs452
static inline int ui_switch_names( Console* cons )
{
	/* Switch name */
	Iobuf switchNameIobody;
	Iobuf* switchNameIo;
	Region switchNamebody;
	Region* switchName;
	uchar switchNameBuffer[ UI_SWITCH_NAME_SIZE * 2 ];
	uchar* switchNamebuffers[ 2 ];

	int status = 0;
	int i = 1;
	int switchId = 1;
	uchar curname[ UI_SWITCH_NAME_SIZE ] = UI_SWITCH_NAME;
	uint convSize = 0;

	switchNameIo = &switchNameIobody;
	switchName = &switchNamebody;
	switchNamebuffers[ 0 ] = switchNameBuffer;
	switchNamebuffers[ 1 ] = switchNameBuffer + UI_SWITCH_NAME_SIZE;

	while( 1 ){
		status = iobuf_init( switchNameIo, cons );
		ASSERT( status == ERR_NONE );
	
		status = region_setup( switchName, switchFrame,
				       ( ( ( i - 1 ) % UI_SWITCH_NAME_PER_LINE ) * UI_SWITCH_NAME_SIZE ),
				       ( i - 1 ) / UI_SWITCH_NAME_PER_LINE + 2,
				       UI_SWITCH_NAME_SIZE, 1,
				       0, 0,
				       0, switchNameIo, switchNamebuffers );
		ASSERT( status == ERR_NONE );

		status = region_init( switchName );
		ASSERT( status == ERR_NONE );

		if( i > 18 ){
			switchId = 153 + i - 19;
		} else {
			switchId = i;
		}

		convSize = utos( switchId, (char*)(curname + UI_SWITCH_NAME_NUMBER_OFFSET) );

		switch( convSize ){
		case 1:
			curname[ UI_SWITCH_NAME_NUMBER_OFFSET + 2 ] = curname[ UI_SWITCH_NAME_NUMBER_OFFSET ];
			curname[ UI_SWITCH_NAME_NUMBER_OFFSET ] = ' ';
			curname[ UI_SWITCH_NAME_NUMBER_OFFSET + 1 ] = ' ';
			break;
		case 2:
			curname[ UI_SWITCH_NAME_NUMBER_OFFSET + 2 ] = curname[ UI_SWITCH_NAME_NUMBER_OFFSET + 1 ];
			curname[ UI_SWITCH_NAME_NUMBER_OFFSET + 1 ] = curname[ UI_SWITCH_NAME_NUMBER_OFFSET ];
			curname[ UI_SWITCH_NAME_NUMBER_OFFSET ] = ' ';
		}
		
		curname[ UI_SWITCH_NAME_NUMBER_OFFSET + 3 ] = ' ';
		curname[ UI_SWITCH_NAME_SIZE - 1 ] = '\0';

		status = region_write( switchName, (char*)curname );
		ASSERT( status == ERR_NONE );

		while( ! region_flushed( switchName ) ){
			status = region_flush( switchName );
			ASSERT( status == ERR_NONE );
		}

		i += 1;
		if( i > SWITCHES_COUNT ){
			break;
		}
	}

	return ERR_NONE;
}