Kernel scheduler internals. More...
Macros | |
#define | STATIC static |
Functions | |
uint32_t * | os_thread_populate_stack (int stack_id, unsigned stack_size, entrypoint_t *entrypoint, void *data) |
Populate stack of new thread so it can be executed. | |
int | os_process_create (Process_t process_id, const struct OS_process_definition_t *definition) |
Create process using process definition. | |
void | os_boot_thread (Thread_t boot_thread) |
Start executing thread. | |
void | os_reset_cpu () |
Reset the CPU. | |
void | cmrx_shutdown_handler (void) |
Default CMRX shutdown handler for ARM CPUs This is default action after for when the CMRX kernel is shutdown. | |
void | os_kernel_shutdown () |
Perform the kernel shutdown. | |
int | os_set_syscall_return_value (Thread_t thread_id, int32_t retval) |
Set return value of syscall for given thread. | |
Kernel scheduler internals.
#define STATIC static |
void cmrx_shutdown_handler | ( | void | ) |
Default CMRX shutdown handler for ARM CPUs This is default action after for when the CMRX kernel is shutdown.
It will reset the CPU. If you want to perform different action, then provide your function called `cmrx_shutdown_handler. It will override this one.
void os_boot_thread | ( | Thread_t | boot_thread | ) |
Start executing thread.
Used to actually start executing in thread mode just after the kernel has been initialized and is ready to start the first thread. This function has to perform CPU switch from privileged mode in which kernel runs into unprivileged mode in which threads are supposed to run. Thread passed to this function is in state ready to be executed by normal kernel thread switching mechanism on this platform.
boot_thread | ID of thread that shall be started |
void os_kernel_shutdown | ( | ) |
Perform the kernel shutdown.
Stop running the kernel.
This is platform-specific way of how to shutdown the kernel. In this case an interrupt frame is forged on stack that will resemble a frame returning back to the cmrx_shutdown_handler function. The result of running this function will be that the processor leaves the handler mode, enters privileged thread mode and will be using MSP.
int os_process_create | ( | Process_t | process_id, |
const struct OS_process_definition_t * | definition | ||
) |
Create process using process definition.
Takes process definition and initializes MPU regions for process out of it.
process_id | ID of process to be initialized |
definition | process definition. This is constructed at compile time using OS_APPLICATION macros |
void os_reset_cpu | ( | ) |
Reset the CPU.
This is architecture- (and possibly HAL-) specific way to reset the CPU. This function can be used before the kernel has been started or after it has been shut down. If there is no shutdown handler provided by the integrator then the default handler will call this function to reset the CPU automatically.
int os_set_syscall_return_value | ( | Thread_t | thread_id, |
int32_t | retval | ||
) |
Set return value of syscall for given thread.
thread_id | Id of the thread whose exception handler is being modified |
retval | value to store on the stack |
uint32_t * os_thread_populate_stack | ( | int | stack_id, |
unsigned | stack_size, | ||
entrypoint_t * | entrypoint, | ||
void * | data | ||
) |
Populate stack of new thread so it can be executed.
Populates stack of new thread so that it can be executed with no other actions required. Returns the address where SP shall point to.
stack_id | ID of stack to be populated |
stack_size | size of stack in 32-bit quantities |
entrypoint | address of thread entrypoint function |
data | address of data passed to the thread as its 1st argument |