R_RTOS  0.1
DistributedRealTimeOperatingSystemfortheARMCortexMArchitecture
Stack Management

Functions for creating, initializing, maintaining and handling a task's stack. More...

Macros

#define portINITIAL_XPSR   ( (uint32_t)0x01000000u )
 initial XPSR value for a task.
 
#define MY_STACK_SIZE   ((StackSize)0x80u)
 Default value for a task's stack size.
 
#define IDLE_TSK_STACK_SIZE   ((StackSize)0x60u)
 Stack size for the IDLE Task.
 
#define STACK_BLOCK_SIZE   ((uint8_t)0x4u)
 Size of one stack element in byte.
 

Typedefs

typedef uint16_t StackSize
 Used to describe the size of a stack.
 
typedef uint32_t StackTypeT
 Base type of a stack element.
 
typedef StackTypeTStackPtrT
 Pointer to a StackTypeT. More...
 

Functions

RetCode stk_StackCreate (register PTskTCB tsk, register StackSize desiredStackSize)
 Creates a stack for a task with the size of desiredStackSize. More...
 
RetCode stk_StackInit (register PTskTCB tsk, void *fktParam)
 Initializes the initial stack frame according to the given input parameters. More...
 
RetCode stk_StackDestroy (register PTskTCB tsk)
 Destroys the stack of the task indicated by the tsk input parameter. More...
 
RetCode stk_TSTStck (PTskTCB const tsk)
 fill the task's stack with a distinctive pattern. More...
 
RetCode stk_StackClear (PTskTCB const tsk)
 Clears the provided task's stack. More...
 

Detailed Description

Functions for creating, initializing, maintaining and handling a task's stack.

Typedef Documentation

Pointer to a StackTypeT.

Also used to point to the current, the top and the bottom StackTypeT.

Function Documentation

RetCode stk_StackClear ( PTskTCB const  tsk)

Clears the provided task's stack.

//ToDO IMPLEMENT FUNCTION

Parameters
[in]tskPointer to the task's TskTCB
Returns
Return the success of the operation

Sets all stack elements to zero regardless of the current stack pointer's position.

RetCode stk_StackCreate ( register PTskTCB  tsk,
register StackSize  desiredStackSize 
)

Creates a stack for a task with the size of desiredStackSize.

Parameters
[in]tskPointer to the task's TskTCB
[in]desiredStackSizeSize of the stack to be created
Returns
Return the success of the operation

Allocates memory and creates the stack for the task and sets all pointers for stack management in the TskTCB.

RetCode stk_StackDestroy ( register PTskTCB  tsk)

Destroys the stack of the task indicated by the tsk input parameter.

Parameters
[in]tskPointer to the task's TskTCB whose stack shall be destroyed
Returns
Return the success of the operation

Destroys the given stack and frees all resources. //ToDO Also checks for stack overflow and underflow.

RetCode stk_StackInit ( register PTskTCB  tsk,
void *  fktParam 
)

Initializes the initial stack frame according to the given input parameters.

Parameters
[in]tskPointer to the task's TskTCB, which contains all needed parameters
[in]fktParamPointer to the input parameter that shall be passed to the task ( NULL means no input parameter )
Returns
Return the success of the operation

Builds the initial stack frame needed for switching the context to the task's beginning according to the provided input parameters. Adjusts the task's stack pointer accordingly.

RetCode stk_TSTStck ( PTskTCB const  tsk)

fill the task's stack with a distinctive pattern.

Parameters
tskPointer to the task's TskTCB whose stack shall be marked.
Returns
Returns the success of the operation.