75#define REG_BYTE_CNT 256
86typedef __attribute__((aligned(32))) struct irq_context {
109#define CONTEXT_PC(c) ((c).pc)
115#define CONTEXT_FP(c) ((c).r[14])
121#define CONTEXT_SP(c) ((c).r[15])
127#define CONTEXT_RET(c) ((c).r[0])
167 uint32_t routine,
const uint32_t *args,
bool usermode);
189typedef enum irq_exception {
268#define EXC_OFFSET_000 0
269#define EXC_OFFSET_100 1
270#define EXC_OFFSET_400 2
271#define EXC_OFFSET_600 3
277#define TIMER_IRQ EXC_TMU0_TUNI0
469void irq_shutdown(
void);
471static inline void __irq_scoped_cleanup(
int *state) {
475#define ___irq_disable_scoped(l) \
476 int __scoped_irq_##l __attribute__((cleanup(__irq_scoped_cleanup))) = irq_disable()
478#define __irq_disable_scoped(l) ___irq_disable_scoped(l)
487#define irq_disable_scoped() __irq_disable_scoped(__LINE__)
irq_context_t * irq_get_context(void)
Get the current IRQ context.
void irq_create_context(irq_context_t *context, uint32_t stack_pointer, uint32_t routine, const uint32_t *args, bool usermode)
Fill a newly allocated context block.
void irq_set_context(irq_context_t *regbank)
Switch out contexts (for interrupt return).
void irq_force_return(void)
Resume normal execution from IRQ context.
irq_handler irq_get_global_handler(void)
Get the global exception handler.
int irq_set_global_handler(irq_handler hnd, void *data)
Set a global exception handler.
irq_handler irq_get_handler(irq_t code)
Get the address of the current handler for the IRQ type.
int irq_set_handler(irq_t code, irq_handler hnd, void *data)
Set or remove an IRQ handler.
void(* irq_handler)(irq_t code, irq_context_t *context, void *data)
The type of an IRQ handler.
Definition irq.h:384
void irq_enable(void)
Enable all interrupts.
void irq_restore(irq_mask_t v)
Restore IRQ state.
irq_mask_t irq_disable(void)
Disable interrupts.
uint32_t irq_mask_t
Type representing an interrupt mask state.
Definition irq.h:311
int irq_inside_int(void)
Returns whether inside of an interrupt context.
irq_t
Interrupt exception codes.
Definition irq.h:189
@ EXC_SCIF_TXI
[POST ] SCIF Transmit ready
Definition irq.h:253
@ EXC_TMU1_TUNI1
[POST ] TMU1 underflow
Definition irq.h:230
@ EXC_UNHANDLED_EXC
[SOFT ] Exception went unhandled
Definition irq.h:255
@ EXC_DTLB_MISS_READ
[REEXEC] Data TLB miss (read)
Definition irq.h:205
@ EXC_TMU2_TUNI2
[POST ] TMU2 underflow
Definition irq.h:231
@ EXC_DATA_ADDRESS_READ
[REEXEC] Data address (read)
Definition irq.h:203
@ EXC_DMAC_DMTE2
[POST ] DMAC transfer end (channel 2)
Definition irq.h:247
@ EXC_DTLB_MULTIPLE
[RESET ] Data TLB multiple hit
Definition irq.h:194
@ EXC_DTLB_PV_READ
[REEXEC] Data TLB protection violation (read)
Definition irq.h:207
@ EXC_ITLB_MISS
[REEXEC] Instruction TLB miss
Definition irq.h:197
@ EXC_SCI_ERI
[UNUSED] SCI Error receive
Definition irq.h:236
@ EXC_DMAC_DMTE1
[POST ] DMAC transfer end (channel 1)
Definition irq.h:246
@ EXC_IRQ9
[POST ] External IRQ request (level 9)
Definition irq.h:223
@ EXC_IRQ0
[POST ] External IRQ request (level 0)
Definition irq.h:214
@ EXC_INSTR_ADDRESS
[REEXEC] Instruction address
Definition irq.h:196
@ EXC_REF_RCMI
[POST ] Memory refresh compare-match interrupt
Definition irq.h:241
@ EXC_DMAC_DMTE0
[POST ] DMAC transfer end (channel 0)
Definition irq.h:245
@ EXC_ITLB_MULTIPLE
[RESET ] Instruction TLB multiple hit
Definition irq.h:193
@ EXC_IRQ7
[POST ] External IRQ request (level 7)
Definition irq.h:221
@ EXC_INITIAL_PAGE_WRITE
[REEXEC] Initial page write exception
Definition irq.h:210
@ EXC_DTLB_MISS_WRITE
[REEXEC] Data TLB miss (write)
Definition irq.h:206
@ EXC_SLOT_FPU
[REEXEC] Slot FPU exception
Definition irq.h:202
@ EXC_IRQA
[POST ] External IRQ request (level 10)
Definition irq.h:224
@ EXC_RESET_POWERON
[RESET ] Power-on reset
Definition irq.h:190
@ EXC_IRQ4
[POST ] External IRQ request (level 4)
Definition irq.h:218
@ EXC_IRQD
[POST ] External IRQ request (level 13)
Definition irq.h:227
@ EXC_RTC_ATI
[UNUSED] RTC alarm interrupt
Definition irq.h:233
@ EXC_RESET_MANUAL
[RESET ] Manual reset
Definition irq.h:191
@ EXC_DOUBLE_FAULT
[SOFT ] Exception happened in an ISR
Definition irq.h:254
@ EXC_DMAC_DMTE3
[POST ] DMAC transfer end (channel 3)
Definition irq.h:248
@ EXC_ILLEGAL_INSTR
[REEXEC] Illegal instruction
Definition irq.h:199
@ EXC_FPU
[REEXEC] FPU exception
Definition irq.h:209
@ EXC_IRQ8
[POST ] External IRQ request (level 8)
Definition irq.h:222
@ EXC_IRQC
[POST ] External IRQ request (level 12)
Definition irq.h:226
@ EXC_TMU0_TUNI0
[POST ] TMU0 underflow
Definition irq.h:229
@ EXC_IRQ1
[POST ] External IRQ request (level 1)
Definition irq.h:215
@ EXC_RTC_PRI
[UNUSED] RTC periodic interrupt
Definition irq.h:234
@ EXC_GPIO_GPIOI
[POST ] I/O port interrupt
Definition irq.h:244
@ EXC_DATA_ADDRESS_WRITE
[REEXEC] Data address (write)
Definition irq.h:204
@ EXC_IRQ6
[POST ] External IRQ request (level 6)
Definition irq.h:220
@ EXC_DMA_DMAE
[POST ] DMAC address error
Definition irq.h:249
@ EXC_REF_ROVI
[POST ] Memory refresh counter overflow interrupt
Definition irq.h:242
@ EXC_IRQ5
[POST ] External IRQ request (level 5)
Definition irq.h:219
@ EXC_SLOT_ILLEGAL_INSTR
[REEXEC] Slot illegal instruction
Definition irq.h:200
@ EXC_WDT_ITI
[POST ] Watchdog timer
Definition irq.h:240
@ EXC_IRQ2
[POST ] External IRQ request (level 2)
Definition irq.h:216
@ EXC_SCI_TXI
[UNUSED] SCI Transmit ready
Definition irq.h:238
@ EXC_ITLB_PV
[REEXEC] Instruction TLB protection violation
Definition irq.h:198
@ EXC_SCIF_BRI
[POST ] SCIF break
Definition irq.h:252
@ EXC_IRQB
[POST ] External IRQ request (level 11)
Definition irq.h:225
@ EXC_USER_BREAK_PRE
[REEXEC] User break before instruction
Definition irq.h:195
@ EXC_NMI
[POST ] Nonmaskable interrupt
Definition irq.h:213
@ EXC_RESET_UDI
[RESET ] Hitachi UDI reset
Definition irq.h:192
@ EXC_USER_BREAK_POST
[POST ] User break after instruction
Definition irq.h:212
@ EXC_SCIF_RXI
[POST ] SCIF Receive ready
Definition irq.h:251
@ EXC_DTLB_PV_WRITE
[REEXEC] Data TLB protection violation (write)
Definition irq.h:208
@ EXC_IRQ3
[POST ] External IRQ request (level 3)
Definition irq.h:217
@ EXC_TMU2_TICPI2
[UNUSED] TMU2 input capture
Definition irq.h:232
@ EXC_GENERAL_FPU
[REEXEC] General FPU exception
Definition irq.h:201
@ EXC_TRAPA
[POST ] Unconditional trap (TRAPA)
Definition irq.h:211
@ EXC_SCIF_ERI
[POST ] SCIF Error receive
Definition irq.h:250
@ EXC_SCI_RXI
[UNUSED] SCI Receive ready
Definition irq.h:237
@ EXC_UDI
[POST ] Hitachi UDI
Definition irq.h:243
@ EXC_SCI_TEI
[UNUSED] SCI Transmit error
Definition irq.h:239
@ EXC_IRQE
[POST ] External IRQ request (level 14)
Definition irq.h:228
@ EXC_RTC_CUI
[UNUSED] RTC carry interrupt
Definition irq.h:235
Architecture-specific structure for holding the processor state.
Definition irq.h:86
uint32_t fpul
Floating-point communication register.
Definition irq.h:94
uint32_t sr
Status register.
Definition irq.h:93
uint32_t mach
Multiply-and-accumulate register (high)
Definition irq.h:91
uint32_t fpscr
Floating-point status/control register.
Definition irq.h:98
uint32_t macl
Multiply-and-accumulate register (low)
Definition irq.h:92
uint32_t vbr
Vector base register.
Definition irq.h:90
uint32_t pc
Program counter.
Definition irq.h:87
uint32_t gbr
Global base register (TLS segment ptr)
Definition irq.h:89
uint32_t pr
Procedure register (aka return address)
Definition irq.h:88