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::IPlatform Class Referenceabstract

Interface for a platform driver. More...

#include <stk_common.h>

Inheritance diagram for stk::IPlatform:

Classes

class  IEventHandler
 Interface for a back-end event handler. More...
class  IEventOverrider
 Interface for a platform event overrider. More...

Public Member Functions

virtual void Initialize (IEventHandler *event_handler, IKernelService *service, uint32_t resolution_us, Stack *exit_trap)=0
 Initialize scheduler's context.
virtual void Start ()=0
 Start scheduling.
virtual void Stop ()=0
 Stop scheduling.
virtual bool InitStack (EStackType stack_type, Stack *stack, IStackMemory *stack_memory, ITask *user_task)=0
 Initialize stack memory of the user task.
virtual uint32_t GetTickResolution () const =0
 Get resolution of the system tick timer in microseconds. Resolution means a number of microseconds between system tick timer ISRs.
virtual void SwitchToNext ()=0
 Switch to a next task.
virtual void Sleep (Timeout ticks)=0
 Put calling process into a sleep state.
virtual void SleepUntil (Ticks timestamp)=0
 Put calling process into a sleep state until the specified timestamp.
virtual void ProcessTick ()=0
 Process one tick.
virtual void ProcessHardFault ()=0
 Cause a hard fault of the system.
virtual void SetEventOverrider (IEventOverrider *overrider)=0
 Set platform event overrider.
virtual Word GetCallerSP () const =0
 Get caller's Stack Pointer (SP).
virtual TId GetTid () const =0
 Get thread Id.

Detailed Description

Interface for a platform driver.

Note
Bridge design pattern. Do not put implementation details in the header of the concrete class to avoid breaking this pattern.

Platform driver represents an underlying hardware and implements the following logic:

  • time tick
  • context switching
  • hardware access from the user task

All functions are called by the kernel implementation.

Definition at line 574 of file stk_common.h.

Member Function Documentation

◆ GetCallerSP()

virtual Word stk::IPlatform::GetCallerSP ( ) const
pure virtual

Get caller's Stack Pointer (SP).

Note
Valid for a Thread process only.
Returns
Current value of the Stack Pointer (SP) of the calling process.

Implemented in stk::PlatformArmCortexM, stk::PlatformRiscV, stk::PlatformX86Win32, and stk::test::PlatformTestMock.

◆ GetTickResolution()

virtual uint32_t stk::IPlatform::GetTickResolution ( ) const
pure virtual

Get resolution of the system tick timer in microseconds. Resolution means a number of microseconds between system tick timer ISRs.

Returns
Microseconds.

Implemented in stk::PlatformArmCortexM, stk::PlatformRiscV, stk::PlatformX86Win32, and stk::test::PlatformTestMock.

◆ GetTid()

virtual TId stk::IPlatform::GetTid ( ) const
pure virtual

Get thread Id.

Returns
Thread Id.

Implemented in stk::PlatformArmCortexM, stk::PlatformRiscV, stk::PlatformX86Win32, and stk::test::PlatformTestMock.

◆ Initialize()

virtual void stk::IPlatform::Initialize ( IEventHandler * event_handler,
IKernelService * service,
uint32_t resolution_us,
Stack * exit_trap )
pure virtual

Initialize scheduler's context.

Parameters
[in]event_handlerEvent handler.
[in]serviceKernel service.
[in]resolution_usTick resolution in microseconds (for example 1000 equals to 1 millisecond resolution).
[in]exit_trapStack of the Exit trap (optional, provided if kernel is operating in KERNEL_DYNAMIC mode).
Note
Must be called once before Start().

Implemented in stk::PlatformArmCortexM, stk::PlatformRiscV, stk::PlatformX86Win32, and stk::test::PlatformTestMock.

◆ InitStack()

virtual bool stk::IPlatform::InitStack ( EStackType stack_type,
Stack * stack,
IStackMemory * stack_memory,
ITask * user_task )
pure virtual

Initialize stack memory of the user task.

Parameters
[in]stack_typeStack type.
[in]stackStack descriptor.
[in]stack_memoryStack memory.
[in]user_taskUser task to which Stack belongs.
Returns
true on success, false if the stack memory is too small, misaligned, or the stack type is unsupported.

Implemented in stk::PlatformArmCortexM, stk::PlatformRiscV, stk::PlatformX86Win32, and stk::test::PlatformTestMock.

◆ ProcessHardFault()

virtual void stk::IPlatform::ProcessHardFault ( )
pure virtual

Cause a hard fault of the system.

Note
Normally called by the Kernel when one of the scheduled tasks missed its deadline (see stk::KERNEL_HRT).

Implemented in stk::PlatformArmCortexM, stk::PlatformRiscV, stk::PlatformX86Win32, and stk::test::PlatformTestMock.

Referenced by stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::HrtHardFailDeadline().

Here is the caller graph for this function:

◆ ProcessTick()

virtual void stk::IPlatform::ProcessTick ( )
pure virtual

Process one tick.

Note
Normally system tick is processed by the platform driver implementation. In case system tick handler is used by the application and should not be implemented by the driver then disable driver's handler in stk_config.h like this:
#define STK_SYSTICK_HANDLER _STK_SYSTICK_HANDLER_DISABLE
and then call ProcessTick() from your custom tick handler.

Implemented in stk::PlatformArmCortexM, stk::PlatformRiscV, stk::PlatformX86Win32, and stk::test::PlatformTestMock.

◆ SetEventOverrider()

virtual void stk::IPlatform::SetEventOverrider ( IEventOverrider * overrider)
pure virtual

Set platform event overrider.

Note
Must be set prior call to IKernel::Start.
Parameters
[in]overriderPlatform event overrider.

Implemented in stk::PlatformArmCortexM, stk::PlatformRiscV, stk::PlatformX86Win32, and stk::test::PlatformTestMock.

◆ Sleep()

virtual void stk::IPlatform::Sleep ( Timeout ticks)
pure virtual

Put calling process into a sleep state.

Note
Unlike Delay this function does not waste CPU cycles and allows kernel to put CPU into a low-power state.
Parameters
[in]ticksTime to sleep (ticks).

Implemented in stk::PlatformArmCortexM, stk::PlatformRiscV, stk::PlatformX86Win32, and stk::test::PlatformTestMock.

◆ SleepUntil()

virtual void stk::IPlatform::SleepUntil ( Ticks timestamp)
pure virtual

Put calling process into a sleep state until the specified timestamp.

Note
Unlike Delay this function does not waste CPU cycles and allows kernel to put CPU into a low-power state.
Unsupported in HRT mode (see stk::KERNEL_HRT); in HRT mode tasks sleep automatically according to their periodicity and workload.
Parameters
[in]timestampAbsolute timestamp (ticks).
Warning
ISR-unsafe. Calling from an ISR context is not permitted and will trigger an assertion.

Implemented in stk::PlatformArmCortexM, stk::PlatformRiscV, stk::PlatformX86Win32, and stk::test::PlatformTestMock.

◆ Start()

virtual void stk::IPlatform::Start ( )
pure virtual

Start scheduling.

Note
This function never returns if kernel is initialized as KERNEL_STATIC. Must be called after Initialize().

Implemented in stk::PlatformArmCortexM, stk::PlatformRiscV, stk::PlatformX86Win32, and stk::test::PlatformTestMock.

◆ Stop()

virtual void stk::IPlatform::Stop ( )
pure virtual

◆ SwitchToNext()

virtual void stk::IPlatform::SwitchToNext ( )
pure virtual

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