ModusToolbox Safety Test Library
Loading...
Searching...
No Matches

General Description

Functions

void SelfTests_Init_Stack_Range (uint16_t *stack_address, uint16_t stack_length, uint8_t stack_pattern_blk_size)
 This function initializes the upper and lower stack areas with the 0xAA and 0x55 patterns.
uint8_t SelfTests_Stack_Check_Range (uint16_t *stack_address, uint16_t stack_length)
 This function performs the stack self test.

Function Documentation

◆ SelfTests_Init_Stack_Range()

void SelfTests_Init_Stack_Range ( uint16_t * stack_address,
uint16_t stack_length,
uint8_t stack_pattern_blk_size )

This function initializes the upper and lower stack areas with the 0xAA and 0x55 patterns.

Parameters
stack_addressThe pointer to the stack.
stack_lengthThe length of the stack.
stack_pattern_blk_sizeThe number of bytes to fill the pattern. Must be 2^n where n=1 to n=8. (Recommended value for n = 3).
Note
Ensure sufficient stack space is available before calling this function. The stack must not be overflowed or near overflow. Guard zones provide backup protection but should not be the primary defense mechanism. Proper stack sizing and monitoring are essential for safe operation.

◆ SelfTests_Stack_Check_Range()

uint8_t SelfTests_Stack_Check_Range ( uint16_t * stack_address,
uint16_t stack_length )

This function performs the stack self test.

It checks the upper and lower stack areas for the 0xAA and 0x55 patterns.

Parameters
stack_addressThe pointer to the stack.
stack_lengthThe length of the stack.
Returns
Stack range bitmask flags:
OK_STATUS (0) - Pass: both guard zones intact
ERROR_STACK_OVERFLOW (1) - Fail: bottom guard corrupted
ERROR_STACK_UNDERFLOW (2) - Fail: top guard corrupted
ERROR_STACK_OVERFLOW | ERROR_STACK_UNDERFLOW (3) - Fail: both guard zones corrupted