/* Interrupt list caching and handling SH4 has a very flexible interrupt controller. In order to handle it efficiently, a sorted interrupt bitfield is build from the set interrupt priorities. Higher priorities get allocated into higher bits, and a simple mask is kept. In order to check for pending interrupts a simple !=0 test works, and to identify the pending interrupt bsr(pend) will give the sorted id. As this is a single cycle operation on most platforms, the interrupt checking/identification is very fast ! */ #include "types.h" #include "sh4_interrupts.h" #include "sh4_core.h" #include "sh4_mmr.h" #include "oslib/oslib.h" /* */ //these are fixed const u16 IRLPriority = 0x0246; #define IRLP9 &IRLPriority,0 #define IRLP11 &IRLPriority,4 #define IRLP13 &IRLPriority,8 #define GIPA(p) &INTC_IPRA.reg_data,4*p #define GIPB(p) &INTC_IPRB.reg_data,4*p #define GIPC(p) &INTC_IPRC.reg_data,4*p struct InterptSourceList_Entry { const u16* PrioReg; u32 Shift; u32 IntEvnCode; u32 GetPrLvl() const { return ((*PrioReg)>>Shift)&0xF; } }; //Can't be statically initialised because registers are dynamically allocated InterptSourceList_Entry InterruptSourceList[28]; //Maps siid -> EventID DECL_ALIGN(64) u16 InterruptEnvId[32] = { 0 }; //Maps piid -> 1<