![]() |
Choco OS
V.0.16.9.0
Join to the chocolate world
|
Module with machine core specific definitions. More...
Data Structures | |
struct | oC_StackData_t |
stores stack data More... | |
struct | oC_MCS_MemoryRegionConfig_t |
configuration structure for the memory region More... | |
Macros | |
#define | oC_MCS_IsStackPushDecrementPointer() |
returns true if stack push decrements SP More... | |
#define | oC_MCS_AlignStackPointer(Pointer) |
align pointer to the stack alignment More... | |
#define | oC_MCS_AlignPointer(Pointer) |
align pointer to the machine alignment More... | |
#define | oC_MCS_AlignSize(Size, Alignment) |
align size to the machine alignment More... | |
#define | oC_MCS_IsStackPointerAligned(Pointer) |
checks if stack pointer is aligned to the machine stack memory alignment | |
#define | oC_MCS_IsPointerAligned(Pointer) |
checks if pointer is aligned to the machine memory alignment | |
Typedefs | |
typedef void(* | oC_ContextHandler_t) (void *ContextParameter) |
stores handler of function, that handles context More... | |
typedef void(* | oC_ContextExitHandler_t) (void) |
stores handler of function called, when context handling is finished More... | |
typedef oC_StackData_t * | oC_Stack_t |
type for storing stack reference More... | |
typedef void(* | oC_FindNextStackHandler_t) (void) |
stores pointer to function for searching next stack More... | |
Enumerations |
Functions | |
bool | oC_MCS_InitializeModule (void) |
initializes module to work More... | |
void * | oC_MCS_GetHardFaultReason (void) |
returns address that cause a hard fault More... | |
void | oC_MCS_EnableInterrupts (void) |
Globally enables interrupts (always) More... | |
void | oC_MCS_DisableInterrupts (void) |
Globally disables interrupts (always) More... | |
bool | oC_MCS_AreInterruptsEnabled (void) |
Checks if interrupts are enabled in HW. More... | |
bool | oC_MCS_EnableInterrupt (IRQn_Type InterruptNumber) |
enables interrupt with specified number More... | |
bool | oC_MCS_DisableInterrupt (IRQn_Type InterruptNumber) |
disables interrupt with specified number More... | |
bool | oC_MCS_IsInterruptEnabled (IRQn_Type InterruptNumber) |
checks if interrupt is enabled More... | |
bool | oC_MCS_SetInterruptPriority (IRQn_Type InterruptNumber, oC_InterruptPriotity_t Priority) |
sets interrupt priority More... | |
oC_InterruptPriotity_t | oC_MCS_GetInterruptPriority (IRQn_Type InterruptNumber) |
returns interrupt priority More... | |
void | oC_MCS_Reboot (void) |
Software reboots of machine. More... | |
bool | oC_MCS_InitializeStack (oC_Stack_t *outStack, void *Buffer, oC_Int_t BufferSize, oC_ContextHandler_t ContextHandler, void *HandlerParameter, oC_ContextExitHandler_t ExitHandler) |
initializes stack for the system More... | |
void * | oC_MCS_GetCurrentProcessStackPointer (void) |
returns current value of PSP More... | |
void * | oC_MCS_GetCurrentMainStackPointer (void) |
returns current value of MSP More... | |
oC_Int_t | oC_MCS_GetStackSize (oC_Stack_t Stack) |
returns size of stack More... | |
oC_Int_t | oC_MCS_GetFreeStackSize (oC_Stack_t Stack) |
returns number of free stack More... | |
oC_Stack_t | oC_MCS_GetCurrentStack (void) |
returns current stack More... | |
oC_Int_t | oC_MCS_GetMinimumStackBufferSize (oC_Int_t StackSize) |
returns minimum stack buffer size More... | |
bool | oC_MCS_SetNextStack (oC_Stack_t Stack) |
sets next stack for context switching More... | |
bool | oC_MCS_ConfigureSystemTimer (oC_UInt_t Prescaler, oC_FindNextStackHandler_t FindNextStackHandler) |
configures system timer More... | |
oC_Stack_t | oC_MCS_GetSystemStack (void) |
returns pointer to the system stack More... | |
bool | oC_MCS_ReturnToSystemStack (void) |
sets next stack as system stack More... | |
void | oC_MCS_Delay (register oC_UInt_t Cycles) |
delays operations for cycles More... | |
oC_ErrorCode_t | oC_MCS_ConfigureMemoryRegion (const oC_MCS_MemoryRegionConfig_t *Config) |
configures memory region More... | |
uint32_t | oC_MCS_GetMaximumNumberOfRegions (void) |
returns maximum number of regions handled by the machine More... | |
uint32_t | oC_MCS_GetNumberOfRegions (void) |
returns number of regions that are currently configured More... | |
bool | oC_MCS_ReadFreeRegionNumber (uint32_t *outFreeRegionNumber) |
reads number of a free region More... | |
bool | oC_MCS_SetMemoryAccessMode (oC_MCS_MemoryAccessMode_t Mode) |
sets the memory access mode More... | |
oC_MCS_MemoryAccessMode_t | oC_MCS_GetMemoryAccessMode (void) |
reads memory access mode More... | |
This module is part of the Portable Space
The module MCS (Machine Core Specific) contains interface, that is specific for machine core. This is to not duplicate a code, that is common for all machines, that are based on the same core, for example uC of TI from the LM4F family are based on ARM Cortex M4, and the uC from ST in STM32F4 family are also based on the same core. We don't want to keep it separately so here is the module, that is designed for all machines based on the same core.
#define oC_MCS_AlignPointer | ( | Pointer | ) |
The macro is for alignment of pointer
#define oC_MCS_AlignSize | ( | Size, | |
Alignment | |||
) |
The macro is for alignment of size
#define oC_MCS_AlignStackPointer | ( | Pointer | ) |
The macro is for alignment of stack pointers
#define oC_MCS_IsStackPushDecrementPointer | ( | ) |
The macro returns true if operation stack push decrement stack pointer. This can be also used in "hash conditions".
typedef void(* oC_ContextExitHandler_t) (void) |
The function is called, when the oC_ContextHandler_t function finishes its work.
typedef void(* oC_ContextHandler_t) (void *ContextParameter) |
typedef void(* oC_FindNextStackHandler_t) (void) |
typedef oC_StackData_t* oC_Stack_t |
enum IRQn_Type |
The type is for storing priority of interrupts. Note, that you can store with it values from oC_InterruptPriority_Minimum to oC_InterruptPriority_Maximum. The highest priority has oC_InterruptPriority_Maximum value.
Enumerator | |
---|---|
oC_InterruptPriority_Error |
Value for functions, that returns priority to provide error handling. See oC_MCS_GetInterruptPriority for example |
oC_InterruptPriority_Minimum |
The lowest value for priority. |
oC_InterruptPriority_Maximum |
The most important interrupt priority, that is possible in the machine. |
The type is for storing mode of the memory access controlling
bool oC_MCS_AreInterruptsEnabled | ( | void | ) |
The function checks if interrupts are already enabled, by checking flag in a hardware.
oC_ErrorCode_t oC_MCS_ConfigureMemoryRegion | ( | const oC_MCS_MemoryRegionConfig_t * | Config | ) |
The function is for configuration of the memory region. It allows to enable it, configure protection of the sector, etc. See oC_MCS_MemoryRegionConfig_t for more info.
Config | Pointer to the configuration structure |
bool oC_MCS_ConfigureSystemTimer | ( | oC_UInt_t | Prescaler, |
oC_FindNextStackHandler_t | FindNextStackHandler | ||
) |
The function is for configuring system timer - special timer, that is designed for RTOS. The timer is periodically calling the special interrupt (usually called SysTick), that is incrementing system tick counter, and call changing context interrupt if it is required.
Prescaler | Prescaler from system clock to system timer |
FindNextStackHandler | Handler to call, when the changing current stack is required |
void oC_MCS_Delay | ( | register oC_UInt_t | Cycles | ) |
bool oC_MCS_DisableInterrupt | ( | IRQn_Type | InterruptNumber | ) |
The function is for disabling interrupt with specified number.
InterruptNumber | IRQ number to disable |
void oC_MCS_DisableInterrupts | ( | void | ) |
The functions is for disabling interrupts. It is not critical section - when this function is called, interrupts are always disabled
bool oC_MCS_EnableInterrupt | ( | IRQn_Type | InterruptNumber | ) |
The function is for enabling interrupt with specified number.
InterruptNumber | IRQ number to enable |
void oC_MCS_EnableInterrupts | ( | void | ) |
The function is for enabling interrupts. It is not critical section - when this function is called, interrupts are always enabled.
void* oC_MCS_GetCurrentMainStackPointer | ( | void | ) |
The function returns current main stack pointer
void* oC_MCS_GetCurrentProcessStackPointer | ( | void | ) |
The function returns current process stack pointer
oC_Stack_t oC_MCS_GetCurrentStack | ( | void | ) |
This returns stack of current thread.
oC_Int_t oC_MCS_GetFreeStackSize | ( | oC_Stack_t | Stack | ) |
The function is for checking how much stack is free. When Stack is set to NULL, then it will check current stack.
Stack | Initialized stack. Set it to NULL if you want current stack |
void* oC_MCS_GetHardFaultReason | ( | void | ) |
oC_InterruptPriotity_t oC_MCS_GetInterruptPriority | ( | IRQn_Type | InterruptNumber | ) |
Returns priority of interrupt specified by InterruptNumber. If error, it returns oC_InterruptPriority_Error
InterruptNumber | IRQ number |
uint32_t oC_MCS_GetMaximumNumberOfRegions | ( | void | ) |
oC_MCS_MemoryAccessMode_t oC_MCS_GetMemoryAccessMode | ( | void | ) |
The function returns memory access mode, that is currently set.
oC_Int_t oC_MCS_GetMinimumStackBufferSize | ( | oC_Int_t | StackSize | ) |
uint32_t oC_MCS_GetNumberOfRegions | ( | void | ) |
oC_Int_t oC_MCS_GetStackSize | ( | oC_Stack_t | Stack | ) |
oC_Stack_t oC_MCS_GetSystemStack | ( | void | ) |
bool oC_MCS_InitializeModule | ( | void | ) |
bool oC_MCS_InitializeStack | ( | oC_Stack_t * | outStack, |
void * | Buffer, | ||
oC_Int_t | BufferSize, | ||
oC_ContextHandler_t | ContextHandler, | ||
void * | HandlerParameter, | ||
oC_ContextExitHandler_t | ExitHandler | ||
) |
The function is initializing the stack for threads. It prepares machine general registers, such as stack pointers, returns pointers, etc to work with new thread. When the stack is switched, then the machine reads registers states from the stack. In this case from the stack, that was initialized by this function. Returns true if success
outStack | [out] Stack to initialize |
Buffer | Buffer for storing stack |
BufferSize | Size of the buffer, cannot be smaller than value returned by function oC_MCS_GetMinimumStackBufferSize |
ContextHandler | Handler of the function that should be called during this context execution |
HandlerParameter | Parameter to give to the context handler |
ExitHandler | Handler of the function that should be called when the task is return |
bool oC_MCS_IsInterruptEnabled | ( | IRQn_Type | InterruptNumber | ) |
Checks if an interrupt with specified number was enabled.
InterruptNumber | IRQ number |
bool oC_MCS_ReadFreeRegionNumber | ( | uint32_t * | outFreeRegionNumber | ) |
void oC_MCS_Reboot | ( | void | ) |
bool oC_MCS_ReturnToSystemStack | ( | void | ) |
bool oC_MCS_SetInterruptPriority | ( | IRQn_Type | InterruptNumber, |
oC_InterruptPriotity_t | Priority | ||
) |
Change priority of interrupt specified by InterruptNumber. Priority can be value between oC_InterruptPriority_Minimum and oC_InterruptPriority_Maximum. The maximum value is the highest priority.
InterruptNumber | IRQ number |
Priority | Priority of interrupt, see #oC_InterruptPriority_t for details |
bool oC_MCS_SetMemoryAccessMode | ( | oC_MCS_MemoryAccessMode_t | Mode | ) |
bool oC_MCS_SetNextStack | ( | oC_Stack_t | Stack | ) |
The function sets next stack for kernel. The stack will be changed in the next context switching interrupt.
Stack | Initialized stack |