|
KallistiOS git master
Independent SDK for the Sega Dreamcast
|
API for handling IRQ contexts More...
Data Structures | |
| struct | irq_context_t |
| Architecture-specific structure for holding the processor state. More... | |
Macros | |
| #define | REG_BYTE_CNT 256 |
| The number of bytes required to save thread context. | |
Functions | |
| static void | irq_create_context (irq_context_t *context, uintptr_t stack_pointer, uintptr_t routine, const uintptr_t *args) |
| Fill a newly allocated context block. | |
| static void | irq_set_context (irq_context_t *cxt) |
| Switch out contexts (for interrupt return). | |
| static irq_context_t * | irq_get_context (void) |
| Get the current IRQ context. | |
Register Accessors | |
Convenience macros for accessing context registers | |
| #define | CONTEXT_PC(c) |
| Fetch the program counter from an irq_context_t. | |
| #define | CONTEXT_FP(c) |
| Fetch the frame pointer from an irq_context_t. | |
| #define | CONTEXT_SP(c) |
| Fetch the stack pointer from an irq_context_t. | |
| #define | CONTEXT_RET(c) |
| Fetch the return value from an irq_context_t. | |
API for handling IRQ contexts
Thread execution state and accessors
This API provides functions to create a new IRQ context, get a pointer to the current context, or set the context that will be used when returning from an exception.
This API includes the structure and accessors for a thread's context state, which contains the registers that are stored and loaded upon thread context switches, which are passed back to interrupt handlers.
| #define CONTEXT_FP | ( | c | ) |
Fetch the frame pointer from an irq_context_t.
| c | The context to read from. |
| #define CONTEXT_PC | ( | c | ) |
Fetch the program counter from an irq_context_t.
| c | The context to read from. |
Referenced by catchnull(), and on_break().
| #define CONTEXT_RET | ( | c | ) |
Fetch the return value from an irq_context_t.
| c | The context to read from. |
| #define CONTEXT_SP | ( | c | ) |
Fetch the stack pointer from an irq_context_t.
| c | The context to read from. |
| #define REG_BYTE_CNT 256 |
The number of bytes required to save thread context.
This should include all general CPU registers, FP registers, and status regs (even if not all of these are actually used).
228 bytes for all of that, but we round it up to a nicer number for sanity.
|
inlinestatic |
Fill a newly allocated context block.
The given parameters will be passed to the called routine (up to the architecture maximum). For the Dreamcast, this maximum is 4.
| context | The IRQ context to fill in. |
| stack_pointer | The value to set in the stack pointer. |
| routine | The address of the program counter for the context. |
| args | Any arguments to set in the registers. This cannot be NULL, and must have enough values to fill in up to the architecture maximum. |
References arch_irq_create_context().
|
inlinestatic |
Get the current IRQ context.
This will fetch the processor context prior to the exception handling during an IRQ service routine.
References arch_irq_get_context().
|
inlinestatic |
Switch out contexts (for interrupt return).
This function will set the processor state that will be restored when the exception returns.
| cxt | The IRQ context to restore. |
References arch_irq_set_context(), and cxt.