23 #include <sys/cdefs.h>
36 #define REG_BYTE_CNT 256
66 #define CONTEXT_PC(c) ((c).pc)
72 #define CONTEXT_FP(c) ((c).r[14])
78 #define CONTEXT_SP(c) ((c).r[15])
84 #define CONTEXT_RET(c) ((c).r[0])
104 #define EXC_RESET_POWERON 0x0000
105 #define EXC_RESET_MANUAL 0x0020
106 #define EXC_RESET_UDI 0x0000
107 #define EXC_ITLB_MULTIPLE 0x0140
108 #define EXC_DTLB_MULTIPLE 0x0140
120 #define EXC_USER_BREAK_PRE 0x01e0
121 #define EXC_INSTR_ADDRESS 0x00e0
122 #define EXC_ITLB_MISS 0x0040
123 #define EXC_ITLB_PV 0x00a0
124 #define EXC_ILLEGAL_INSTR 0x0180
125 #define EXC_SLOT_ILLEGAL_INSTR 0x01a0
126 #define EXC_GENERAL_FPU 0x0800
127 #define EXC_SLOT_FPU 0x0820
128 #define EXC_DATA_ADDRESS_READ 0x00e0
129 #define EXC_DATA_ADDRESS_WRITE 0x0100
130 #define EXC_DTLB_MISS_READ 0x0040
131 #define EXC_DTLB_MISS_WRITE 0x0060
132 #define EXC_DTLB_PV_READ 0x00a0
133 #define EXC_DTLB_PV_WRITE 0x00c0
134 #define EXC_FPU 0x0120
135 #define EXC_INITIAL_PAGE_WRITE 0x0080
146 #define EXC_TRAPA 0x0160
147 #define EXC_USER_BREAK_POST 0x01e0
160 #define EXC_NMI 0x01c0
161 #define EXC_IRQ0 0x0200
162 #define EXC_IRQ1 0x0220
163 #define EXC_IRQ2 0x0240
164 #define EXC_IRQ3 0x0260
165 #define EXC_IRQ4 0x0280
166 #define EXC_IRQ5 0x02a0
167 #define EXC_IRQ6 0x02c0
168 #define EXC_IRQ7 0x02e0
169 #define EXC_IRQ8 0x0300
170 #define EXC_IRQ9 0x0320
171 #define EXC_IRQA 0x0340
172 #define EXC_IRQB 0x0360
173 #define EXC_IRQC 0x0380
174 #define EXC_IRQD 0x03a0
175 #define EXC_IRQE 0x03c0
176 #define EXC_TMU0_TUNI0 0x0400
177 #define EXC_TMU1_TUNI1 0x0420
178 #define EXC_TMU2_TUNI2 0x0440
179 #define EXC_TMU2_TICPI2 0x0460
180 #define EXC_RTC_ATI 0x0480
181 #define EXC_RTC_PRI 0x04a0
182 #define EXC_RTC_CUI 0x04c0
183 #define EXC_SCI_ERI 0x04e0
184 #define EXC_SCI_RXI 0x0500
185 #define EXC_SCI_TXI 0x0520
186 #define EXC_SCI_TEI 0x0540
187 #define EXC_WDT_ITI 0x0560
188 #define EXC_REF_RCMI 0x0580
189 #define EXC_REF_ROVI 0x05a0
190 #define EXC_UDI 0x0600
191 #define EXC_GPIO_GPIOI 0x0620
192 #define EXC_DMAC_DMTE0 0x0640
193 #define EXC_DMAC_DMTE1 0x0660
194 #define EXC_DMAC_DMTE2 0x0680
195 #define EXC_DMAC_DMTE3 0x06a0
196 #define EXC_DMA_DMAE 0x06c0
197 #define EXC_SCIF_ERI 0x0700
198 #define EXC_SCIF_RXI 0x0720
199 #define EXC_SCIF_BRI 0x0740
200 #define EXC_SCIF_TXI 0x0760
208 #define EXC_DOUBLE_FAULT 0x0ff0
215 #define EXC_UNHANDLED_EXC 0x0fe0
225 #define EXC_OFFSET_000 0
226 #define EXC_OFFSET_100 1
227 #define EXC_OFFSET_400 2
228 #define EXC_OFFSET_600 3
232 #define TIMER_IRQ EXC_TMU0_TUNI0
uint32 vbr
Vector base register.
Definition: irq.h:51
int irq_init()
Initialize interrupts.
int trapa_set_handler(irq_t code, irq_handler hnd)
Set or remove a handler for a trapa code.
uint32 fpscr
Floating-point status/control register.
Definition: irq.h:57
uint32 macl
Multiply-and-accumulate register (low)
Definition: irq.h:53
Architecture-specific structure for holding the processor state.
Definition: irq.h:46
uint32 irq_t
The type of an interrupt identifier.
Definition: irq.h:235
uint32 sr
Status register.
Definition: irq.h:54
int irq_inside_int()
Are we inside an interrupt handler?
uint32 pr
Procedure register (aka return address)
Definition: irq.h:49
uint32 r[16]
16 general purpose (integer) registers
Definition: irq.h:47
void irq_set_context(irq_context_t *regbank)
Switch out contexts (for interrupt return).
void irq_create_context(irq_context_t *context, uint32 stack_pointer, uint32 routine, uint32 *args, int usermode)
Fill a newly allocated context block for usage with supervisor or user mode.
void irq_shutdown()
Shutdown interrupts, restoring the state to how it was before irq_init() was called.
uint32 mach
Multiply-and-accumulate register (high)
Definition: irq.h:52
uint32 gbr
Global base register.
Definition: irq.h:50
irq_handler irq_get_global_handler()
Get the global exception handler.
struct irq_context irq_context_t
Architecture-specific structure for holding the processor state.
int irq_set_handler(irq_t source, irq_handler hnd)
Set or remove an IRQ handler.
uint32 fr[16]
Primary floating point registers.
Definition: irq.h:56
void(* irq_handler)(irq_t source, irq_context_t *context)
The type of an IRQ handler.
Definition: irq.h:241
irq_context_t * irq_get_context()
Get the current IRQ context.
unsigned long uint32
32-bit unsigned integer
Definition: types.h:28
irq_handler irq_get_handler(irq_t source)
Get the address of the current handler for the IRQ type.
void irq_enable()
Enable all interrupts.
void irq_force_return()
Pretend like we just came in from an interrupt and force a context switch back to the "current" conte...
void irq_restore(int v)
Restore IRQ state.
uint32 pc
Program counter.
Definition: irq.h:48
int irq_set_global_handler(irq_handler hnd)
Set a global exception handler.
uint32 fpul
Floatint-point communication register.
Definition: irq.h:58
uint32 frbank[16]
Secondary floating poing registers.
Definition: irq.h:55
int irq_disable()
Disable interrupts.