--- a/src/sh4/intc.c Tue Jan 01 05:08:38 2008 +0000 +++ b/src/sh4/intc.c Fri Oct 31 03:24:49 2008 +0000 @@ -26,21 +26,21 @@ char *name; uint32_t code; } intc_sources[INT_NUM_SOURCES] = { - { "IRQ0", 0x200 }, { "IRQ1", 0x220 }, { "IRQ2", 0x240 }, - { "IRQ3", 0x260 }, { "IRQ4", 0x280 }, { "IRQ5", 0x2A0 }, - { "IRQ6", 0x2C0 }, { "IRQ7", 0x2E0 }, { "IRQ8", 0x300 }, - { "IRQ9", 0x320 }, { "IRQ10",0x340 }, { "IRQ11",0x360 }, - { "IRQ12",0x380 }, { "IRQ13",0x3A0 }, { "IRQ14",0x3C0 }, - { "NMI", 0x1C0 }, { "H-UDI",0x600 }, { "GPIOI",0x620 }, - { "DMTE0",0x640 }, { "DMTE1",0x660 }, { "DMTE2",0x680 }, - { "DMTE3",0x6A0 }, { "DMTAE",0x6C0 }, { "TUNI0",0x400 }, - { "TUNI1",0x420 }, { "TUNI2",0x440 }, { "TICPI2",0x460 }, - { "RTC_ATI",0x480 },{ "RTC_PRI",0x4A0 },{ "RTC_CUI",0x4C0 }, - { "SCI_ERI",0x4E0 },{ "SCI_RXI",0x500 },{ "SCI_TXI",0x520 }, - { "SCI_TEI",0x540 }, - { "SCIF_ERI",0x700 },{ "SCIF_RXI",0x720 },{ "SCIF_BRI",0x740 }, - { "SCIF_TXI",0x760 }, - { "WDT_ITI",0x560 },{ "RCMI",0x580 }, { "ROVI",0x5A0 } }; + { "IRQ0", 0x200 }, { "IRQ1", 0x220 }, { "IRQ2", 0x240 }, + { "IRQ3", 0x260 }, { "IRQ4", 0x280 }, { "IRQ5", 0x2A0 }, + { "IRQ6", 0x2C0 }, { "IRQ7", 0x2E0 }, { "IRQ8", 0x300 }, + { "IRQ9", 0x320 }, { "IRQ10",0x340 }, { "IRQ11",0x360 }, + { "IRQ12",0x380 }, { "IRQ13",0x3A0 }, { "IRQ14",0x3C0 }, + { "NMI", 0x1C0 }, { "H-UDI",0x600 }, { "GPIOI",0x620 }, + { "DMTE0",0x640 }, { "DMTE1",0x660 }, { "DMTE2",0x680 }, + { "DMTE3",0x6A0 }, { "DMTAE",0x6C0 }, { "TUNI0",0x400 }, + { "TUNI1",0x420 }, { "TUNI2",0x440 }, { "TICPI2",0x460 }, + { "RTC_ATI",0x480 },{ "RTC_PRI",0x4A0 },{ "RTC_CUI",0x4C0 }, + { "SCI_ERI",0x4E0 },{ "SCI_RXI",0x500 },{ "SCI_TXI",0x520 }, + { "SCI_TEI",0x540 }, + { "SCIF_ERI",0x700 },{ "SCIF_RXI",0x720 },{ "SCIF_BRI",0x740 }, + { "SCIF_TXI",0x760 }, + { "WDT_ITI",0x560 },{ "RCMI",0x580 }, { "ROVI",0x5A0 } }; static int intc_default_priority[INT_NUM_SOURCES] = { 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 16 }; @@ -57,40 +57,40 @@ { /* Well it saves having to use an intermediate table... */ switch( reg ) { - case ICR: /* care about this later */ - break; - case IPRA: - PRIORITY(INT_TMU_TUNI0) = (val>>12)&0x000F; - PRIORITY(INT_TMU_TUNI1) = (val>>8)&0x000F; - PRIORITY(INT_TMU_TUNI2) = - PRIORITY(INT_TMU_TICPI2) = (val>>4)&0x000F; - PRIORITY(INT_RTC_ATI) = - PRIORITY(INT_RTC_PRI) = + case ICR: /* care about this later */ + break; + case IPRA: + PRIORITY(INT_TMU_TUNI0) = (val>>12)&0x000F; + PRIORITY(INT_TMU_TUNI1) = (val>>8)&0x000F; + PRIORITY(INT_TMU_TUNI2) = + PRIORITY(INT_TMU_TICPI2) = (val>>4)&0x000F; + PRIORITY(INT_RTC_ATI) = + PRIORITY(INT_RTC_PRI) = PRIORITY(INT_RTC_CUI) = val&0x000F; - break; - case IPRB: - PRIORITY(INT_WDT_ITI) = (val>>12)&0x000F; - PRIORITY(INT_REF_RCMI) = - PRIORITY(INT_REF_ROVI) = (val>>8)&0x000F; - PRIORITY(INT_SCI_ERI) = - PRIORITY(INT_SCI_RXI) = + break; + case IPRB: + PRIORITY(INT_WDT_ITI) = (val>>12)&0x000F; + PRIORITY(INT_REF_RCMI) = + PRIORITY(INT_REF_ROVI) = (val>>8)&0x000F; + PRIORITY(INT_SCI_ERI) = + PRIORITY(INT_SCI_RXI) = PRIORITY(INT_SCI_TXI) = - PRIORITY(INT_SCI_TEI) = (val>>4)&0x000F; - /* Bits 0-3 reserved */ - break; - case IPRC: - PRIORITY(INT_GPIO) = (val>>12)&0x000F; - PRIORITY(INT_DMA_DMTE0) = - PRIORITY(INT_DMA_DMTE1) = + PRIORITY(INT_SCI_TEI) = (val>>4)&0x000F; + /* Bits 0-3 reserved */ + break; + case IPRC: + PRIORITY(INT_GPIO) = (val>>12)&0x000F; + PRIORITY(INT_DMA_DMTE0) = + PRIORITY(INT_DMA_DMTE1) = PRIORITY(INT_DMA_DMTE2) = - PRIORITY(INT_DMA_DMTE3) = - PRIORITY(INT_DMA_DMAE) = (val>>8)&0x000F; - PRIORITY(INT_SCIF_ERI) = - PRIORITY(INT_SCIF_RXI) = + PRIORITY(INT_DMA_DMTE3) = + PRIORITY(INT_DMA_DMAE) = (val>>8)&0x000F; + PRIORITY(INT_SCIF_ERI) = + PRIORITY(INT_SCIF_RXI) = PRIORITY(INT_SCIF_BRI) = - PRIORITY(INT_SCIF_TXI) = (val>>4)&0x000F; - PRIORITY(INT_HUDI) = val&0x000F; - break; + PRIORITY(INT_SCIF_TXI) = (val>>4)&0x000F; + PRIORITY(INT_HUDI) = val&0x000F; + break; } MMIO_WRITE( INTC, reg, val ); } @@ -106,7 +106,7 @@ intc_state.num_pending = 0; for( i=0; i pri || - (PRIORITY(intc_state.pending[i]) == pri && - intc_state.pending[i] < which)) + (PRIORITY(intc_state.pending[i]) == pri && + intc_state.pending[i] < which)) break; } /* i == insertion point */ @@ -152,7 +152,7 @@ if( i == intc_state.num_pending && (sh4r.sr&SR_BL)==0 && SH4_INTMASK() < pri ) { sh4r.event_pending = 0; - sh4r.event_types |= PENDING_IRQ; + sh4r.event_types |= PENDING_IRQ; } intc_state.num_pending++; @@ -162,18 +162,18 @@ { int i; for( i=intc_state.num_pending-1; i>=0; i-- ) { - if( intc_state.pending[i] == which ) { - /* Shift array contents down */ - while( i < intc_state.num_pending-1 ) { - intc_state.pending[i] = intc_state.pending[i+1]; - i++; - } - intc_state.num_pending--; - intc_mask_changed(); - break; - } + if( intc_state.pending[i] == which ) { + /* Shift array contents down */ + while( i < intc_state.num_pending-1 ) { + intc_state.pending[i] = intc_state.pending[i+1]; + i++; + } + intc_state.num_pending--; + intc_mask_changed(); + break; + } } - + } uint32_t intc_accept_interrupt( void ) @@ -185,16 +185,16 @@ void intc_mask_changed( void ) { if( intc_state.num_pending > 0 && (sh4r.sr&SR_BL)==0 && - SH4_INTMASK() < PRIORITY(intc_state.pending[intc_state.num_pending-1]) ) { + SH4_INTMASK() < PRIORITY(intc_state.pending[intc_state.num_pending-1]) ) { sh4r.event_pending = 0; - sh4r.event_types |= PENDING_IRQ ; + sh4r.event_types |= PENDING_IRQ ; } else { - sh4r.event_pending = event_get_next_time(); - sh4r.event_types &= (~PENDING_IRQ); + sh4r.event_pending = event_get_next_time(); + sh4r.event_types &= (~PENDING_IRQ); } } - + char *intc_get_interrupt_name( int code ) {