Functions | |
uint32_t * | get_exception_arg_addr (ExceptionFrame *frame, unsigned argno, bool fp_active) |
Retrieve address of n-th argument from exception frame. | |
void | os_request_context_switch (bool activate) |
Request context switch. | |
uint32_t | os_perform_thread_switch (uint32_t LR) |
Handle task switch. | |
void | PendSV_Handler (void) |
Wrapper for for Pending service interrupt handler. | |
uint32_t * get_exception_arg_addr | ( | ExceptionFrame * | frame, |
unsigned | argno, | ||
bool | fp_active | ||
) |
Retrieve address of n-th argument from exception frame.
This function calculates address of n-th argument of function call from exception frame. This is used whenever it is known, that exception frame was stored as an effect of __SVC() call. It will automatically handle exception frame padding.
frame | exception frame base address (usually value of SP) |
argno | number of argument retrieved |
uint32_t os_perform_thread_switch | ( | uint32_t | LR | ) |
Handle task switch.
This function performs the heavy lifting of context switching when CPU is switched from one task to another. It saves the SP of suspended thread, then modifies the PSP to match the saved value of incoming thread and if needed it performs signal handler injection and/or MPU register reconfiguration. Saving and restoring of registers is performed by the wrapper to avoid C function preamble interference.
[in] | LR | copy of the LR value of the PendSV_Handler |
|
inline |
Request context switch.
This function is called by the platform independent part of the kernel when cpu_context structure is filled with valid data and context switch shall happen. The implementation of this function should configure the hardware in a way that context switch will happen as soon as kernel finishes its work and is ready to return the CPU back to the userspace code.
void PendSV_Handler | ( | void | ) |
Wrapper for for Pending service interrupt handler.
CMRX uses pending service to handle heavy lifting of thread switching. At the time PendSV is scheduled, the decision on which thread to run next has already been made. This code just performs the switch.
This assembly stub makes sure that all thread registers are properly saved and restored during thread switch, so the actual implementation may be written as plain C function without involving surprises.