SuperTinyKernel™ RTOS 1.05.3
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
Loading...
Searching...
No Matches
stk::StackMemoryWrapper< _StackSize > Class Template Reference

Adapts an externally-owned stack memory array to the IStackMemory interface. More...

#include <stk_helper.h>

Inheritance diagram for stk::StackMemoryWrapper< _StackSize >:
Collaboration diagram for stk::StackMemoryWrapper< _StackSize >:

Public Types

typedef StackMemoryDef< _StackSize >::Type MemoryType
 The concrete array type that this wrapper accepts, equivalent to StackMemoryDef<_StackSize>::Type.

Public Member Functions

 StackMemoryWrapper (MemoryType *stack)
 Construct a wrapper around an existing stack memory array.
 ~StackMemoryWrapper ()
 Destructor.
WordGetStack () const
 Get pointer to the first element of the wrapped stack array.
size_t GetStackSize () const
 Get number of elements in the wrapped stack array.
size_t GetStackSizeBytes () const
 Get size of the wrapped stack array in bytes.

Private Attributes

MemoryTypem_stack
 Pointer to the externally-owned stack memory array.

Detailed Description

template<size_t _StackSize>
class stk::StackMemoryWrapper< _StackSize >

Adapts an externally-owned stack memory array to the IStackMemory interface.

Note
Wrapper (Adapter) design pattern. Use when the stack memory is declared separately from the task object (e.g. in a linker section or shared buffer) and needs to be passed to the kernel via the IStackMemory interface.
Template Parameters
_StackSizeStack size in elements of Word. Must be >= STACK_SIZE_MIN.

Definition at line 173 of file stk_helper.h.

Member Typedef Documentation

◆ MemoryType

template<size_t _StackSize>
typedef StackMemoryDef<_StackSize>::Type stk::StackMemoryWrapper< _StackSize >::MemoryType

The concrete array type that this wrapper accepts, equivalent to StackMemoryDef<_StackSize>::Type.

Definition at line 179 of file stk_helper.h.

Constructor & Destructor Documentation

◆ StackMemoryWrapper()

template<size_t _StackSize>
stk::StackMemoryWrapper< _StackSize >::StackMemoryWrapper ( MemoryType * stack)
inlineexplicit

Construct a wrapper around an existing stack memory array.

Parameters
[in]stackPointer to the externally-owned memory array. Must remain valid for the lifetime of this wrapper and of any kernel task using it.
Note
_StackSize must be >= STACK_SIZE_MIN; enforced by a compile-time assertion.

Definition at line 186 of file stk_helper.h.

186 : m_stack(stack)
187 {
189 }
#define STK_STATIC_ASSERT(X)
Compile-time assertion. Produces a compilation error if X is false.
Definition stk_defs.h:367
Adapts an externally-owned stack memory array to the IStackMemory interface.
Definition stk_helper.h:174
MemoryType * m_stack
Pointer to the externally-owned stack memory array.
Definition stk_helper.h:210

◆ ~StackMemoryWrapper()

template<size_t _StackSize>
stk::StackMemoryWrapper< _StackSize >::~StackMemoryWrapper ( )
inline

Destructor.

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

Definition at line 194 of file stk_helper.h.

195 {}

Member Function Documentation

◆ GetStack()

template<size_t _StackSize>
Word * stk::StackMemoryWrapper< _StackSize >::GetStack ( ) const
inlinevirtual

Get pointer to the first element of the wrapped stack array.

Implements stk::IStackMemory.

Definition at line 199 of file stk_helper.h.

199{ return (*m_stack); }

Referenced by stk::test::TEST().

Here is the caller graph for this function:

◆ GetStackSize()

template<size_t _StackSize>
size_t stk::StackMemoryWrapper< _StackSize >::GetStackSize ( ) const
inlinevirtual

Get number of elements in the wrapped stack array.

Implements stk::IStackMemory.

Definition at line 203 of file stk_helper.h.

203{ return _StackSize; }

Referenced by stk::test::TEST().

Here is the caller graph for this function:

◆ GetStackSizeBytes()

template<size_t _StackSize>
size_t stk::StackMemoryWrapper< _StackSize >::GetStackSizeBytes ( ) const
inlinevirtual

Get size of the wrapped stack array in bytes.

Implements stk::IStackMemory.

Definition at line 207 of file stk_helper.h.

207{ return _StackSize * sizeof(Word); }

Referenced by stk::test::TEST().

Here is the caller graph for this function:

Member Data Documentation

◆ m_stack

template<size_t _StackSize>
MemoryType* stk::StackMemoryWrapper< _StackSize >::m_stack
private

Pointer to the externally-owned stack memory array.

Definition at line 210 of file stk_helper.h.


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