SuperTinyKernel™ RTOS 1.06.0
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
Loading...
Searching...
No Matches
stk::PlatformContext Class Reference

Base platform context for all platform implementations. More...

#include <stk_arch_common.h>

Collaboration diagram for stk::PlatformContext:

Public Member Functions

 PlatformContext ()
 ~PlatformContext ()
 Destructor.
virtual void Initialize (IPlatform::IEventHandler *handler, IKernelService *service, Stack *exit_trap, uint32_t resolution_us)
 Initialize context.

Static Public Member Functions

static WordInitStackMemory (IStackMemory *memory)
 Initialize stack memory by filling it with STK_STACK_MEMORY_FILLER.

Public Attributes

IPlatform::IEventHandlerm_handler
 kernel event handler
IKernelServicem_service
 kernel service
Stackm_stack_idle
 idle task stack
Stackm_stack_active
 active task stack
uint32_t m_tick_resolution
 system tick resolution (microseconds)

Protected Member Functions

 STK_NONCOPYABLE_CLASS (PlatformContext)

Detailed Description

Base platform context for all platform implementations.

Definition at line 24 of file stk_arch_common.h.

Constructor & Destructor Documentation

◆ PlatformContext()

stk::PlatformContext::PlatformContext ( )
inlineexplicit

Definition at line 27 of file stk_arch_common.h.

27 : m_handler(nullptr), m_service(nullptr), m_stack_idle(nullptr),
29 {}
IPlatform::IEventHandler * m_handler
kernel event handler
Stack * m_stack_active
active task stack
Stack * m_stack_idle
idle task stack
IKernelService * m_service
kernel service
uint32_t m_tick_resolution
system tick resolution (microseconds)

References m_handler, m_service, m_stack_active, m_stack_idle, and m_tick_resolution.

Referenced by STK_NONCOPYABLE_CLASS().

Here is the caller graph for this function:

◆ ~PlatformContext()

stk::PlatformContext::~PlatformContext ( )
inline

Destructor.

Note
MISRA deviation: [STK-DEV-005] Rule 10-3-2.

Definition at line 34 of file stk_arch_common.h.

35 {}

Member Function Documentation

◆ Initialize()

virtual void stk::PlatformContext::Initialize ( IPlatform::IEventHandler * handler,
IKernelService * service,
Stack * exit_trap,
uint32_t resolution_us )
inlinevirtual

Initialize context.

Parameters
[in]handlerEvent handler.
[in]exit_trapExit trap's stack.
[in]resolution_usTick resolution in microseconds (for example 1000 equals to 1 millisecond resolution).

Definition at line 42 of file stk_arch_common.h.

44 {
45 m_handler = handler;
46 m_service = service;
47 m_stack_idle = exit_trap;
48 m_stack_active = nullptr;
49 m_tick_resolution = resolution_us;
50 }

References m_handler, m_service, m_stack_active, m_stack_idle, and m_tick_resolution.

◆ InitStackMemory()

Word * stk::PlatformContext::InitStackMemory ( IStackMemory * memory)
inlinestatic

Initialize stack memory by filling it with STK_STACK_MEMORY_FILLER.

Note
Returned pointer is for a stack growing from top to down.
Parameters
[in]memoryStack memory to initialize.
Returns
Pointer to initialized stack memory.

Definition at line 57 of file stk_arch_common.h.

58 {
59 size_t stack_size = memory->GetStackSize();
60 Word *itr = memory->GetStack();
61 Word *stack_top = itr + stack_size;
62
63 STK_ASSERT(stack_size >= STACK_SIZE_MIN);
64
65 // initialization of the stack memory satisfies stack integrity check in Kernel::StateSwitch
66 while (itr < stack_top)
68
69 // expecting STK_STACK_MEMORY_ALIGN-byte aligned memory for a stack
70 STK_ASSERT((hw::PtrToWord(stack_top) & (STK_STACK_MEMORY_ALIGN - 1)) == 0U);
71
72 return stack_top;
73 }
#define STK_ASSERT(e)
Runtime assertion. Halts execution if the expression e evaluates to false.
Definition stk_defs.h:330
#define STK_STACK_MEMORY_ALIGN
Stack memory alignment.
Definition stk_defs.h:389
#define STK_STACK_MEMORY_FILLER
Sentinel value written to the entire stack region at initialization (stack watermark pattern).
Definition stk_defs.h:377
uintptr_t Word
Native processor word type.
Definition stk_common.h:113
@ STACK_SIZE_MIN
Minimum stack size in elements of Word. Used as a lower bound for all stack allocations (user task,...
Definition stk_common.h:83
__stk_forceinline Word PtrToWord(T *ptr) noexcept
Cast a pointer to a CPU register-width integer.
Definition stk_arch.h:94

References stk::hw::PtrToWord(), stk::STACK_SIZE_MIN, STK_ASSERT, STK_STACK_MEMORY_ALIGN, and STK_STACK_MEMORY_FILLER.

Here is the call graph for this function:

◆ STK_NONCOPYABLE_CLASS()

stk::PlatformContext::STK_NONCOPYABLE_CLASS ( PlatformContext )
protected

References PlatformContext().

Here is the call graph for this function:

Member Data Documentation

◆ m_handler

IPlatform::IEventHandler* stk::PlatformContext::m_handler

kernel event handler

Definition at line 75 of file stk_arch_common.h.

Referenced by Initialize(), and PlatformContext().

◆ m_service

IKernelService* stk::PlatformContext::m_service

kernel service

Definition at line 76 of file stk_arch_common.h.

Referenced by Initialize(), and PlatformContext().

◆ m_stack_active

Stack* stk::PlatformContext::m_stack_active

active task stack

Definition at line 78 of file stk_arch_common.h.

Referenced by Initialize(), and PlatformContext().

◆ m_stack_idle

Stack* stk::PlatformContext::m_stack_idle

idle task stack

Definition at line 77 of file stk_arch_common.h.

Referenced by Initialize(), and PlatformContext().

◆ m_tick_resolution

uint32_t stk::PlatformContext::m_tick_resolution

system tick resolution (microseconds)

Definition at line 79 of file stk_arch_common.h.

Referenced by Initialize(), and PlatformContext().


The documentation for this class was generated from the following file: