C Microkernel Realtime eXecutive
Realtime Operating System for Cortex-M based microcontrollers
 
Loading...
Searching...
No Matches

Kernel scheduler internals. More...

Macros

#define STATIC   static
 

Functions

void os_thread_initialize_arch (struct OS_thread_t *thread, unsigned stack_size, entrypoint_t *entrypoint, void *data)
 Perform architecture-specific thread initialization This function should perform the following actions:
 
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.
 

Detailed Description

Kernel scheduler internals.

Macro Definition Documentation

◆ STATIC

#define STATIC   static

Function Documentation

◆ cmrx_shutdown_handler()

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.

Note
Your function should not return nor try to restart CMRX kernel. If you want to restart the kernel, then perform CPU reset first.

◆ os_boot_thread()

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.

Parameters
boot_threadID of thread that shall be started

◆ os_kernel_shutdown()

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.

◆ os_process_create()

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.

Parameters
process_idID of process to be initialized
definitionprocess definition. This is constructed at compile time using OS_APPLICATION macros
Returns
E_OK if process was contructed properly, E_INVALID if process ID is already used or if process definition contains invalid section boundaries. E_OUT_OF_RANGE is returned if process ID requested is out of limits given by the size of process table.

◆ os_reset_cpu()

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.

◆ os_set_syscall_return_value()

int os_set_syscall_return_value ( Thread_t  thread_id,
int32_t  retval 
)

Set return value of syscall for given thread.

Parameters
thread_idId of the thread whose exception handler is being modified
retvalvalue to store on the stack

◆ os_thread_initialize_arch()

void os_thread_initialize_arch ( struct OS_thread_t thread,
unsigned  stack_size,
entrypoint_t *  entrypoint,
void *  data 
)

Perform architecture-specific thread initialization This function should perform the following actions:

  • Configure thread state so it can be executed immediately after this function is done
  • Set valid value into SP member, so the stack pointer can be set to valid value
  • Perform any architecture-specific steps needed to make thread executable
  • Set any architecture-specific settings
    Parameters
    threadpointer to structure describing the thread just being created
    stack_sizesize of stack in 32-bit quantities
    entrypointaddress of thread entrypoint function
    dataaddress of data passed to the thread as its 1st argument
    Returns
    Address to which the SP shall be set.