Thread execution state and accessors
More...
|
#define | REG_BYTE_CNT 256 |
| The number of bytes required to save thread context.
|
|
Thread execution state and accessors
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.
◆ CONTEXT_FP
Value:
Fetch the frame pointer from an irq_context_t.
- Parameters
-
c | The context to read from. |
- Returns
- The frame pointer value.
◆ CONTEXT_PC
Value:
Fetch the program counter from an irq_context_t.
- Parameters
-
c | The context to read from. |
- Returns
- The program counter value.
◆ CONTEXT_RET
Value:
Fetch the return value from an irq_context_t.
- Parameters
-
c | The context to read from. |
- Returns
- The return value.
◆ CONTEXT_SP
Value:
Fetch the stack pointer from an irq_context_t.
- Parameters
-
c | The context to read from. |
- Returns
- The stack pointer value.
◆ REG_BYTE_CNT
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).
- Note
- On the Dreamcast, we need
228
bytes for all of that, but we round it up to a nicer number for sanity.
◆ irq_create_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.
The given parameters will be passed to the called routine (up to the architecture maximum). For the Dreamcast, this maximum is 4.
- Parameters
-
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. |
usermode | true to run the routine in user mode, false for supervisor. |
◆ irq_get_context()
Get the current IRQ context.
This will fetch the processor context prior to the exception handling during an IRQ service routine.
- Returns
- The current IRQ context.
- See also
- irq_set_context()
◆ irq_set_context()
Switch out contexts (for interrupt return).
This function will set the processor state that will be restored when the exception returns.
- Parameters
-
regbank | The values of all registers to be restored. |
- See also
- irq_get_context()