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::PlatformX86Win32 Class Reference

Concrete implementation of IPlatform driver for the x86 Win32 platform. More...

#include <stk_arch_x86-win32.h>

Inheritance diagram for stk::PlatformX86Win32:
Collaboration diagram for stk::PlatformX86Win32:

Public Member Functions

 ~PlatformX86Win32 ()
 Destructor.
void Initialize (IEventHandler *event_handler, IKernelService *service, uint32_t resolution_us, Stack *exit_trap)
 Initialize scheduler's context.
void Start ()
 Start scheduling.
void Stop ()
 Stop scheduling.
bool InitStack (EStackType stack_type, Stack *stack, IStackMemory *stack_memory, ITask *user_task)
 Initialize stack memory of the user task.
uint32_t GetTickResolution () const
 Get resolution of the system tick timer in microseconds. Resolution means a number of microseconds between system tick timer ISRs.
Cycles GetSysTimerCount () const
 Get system timer count value.
uint32_t GetSysTimerFrequency () const
 Get system timer frequency.
void SwitchToNext ()
 Switch to a next task.
void Sleep (Timeout ticks)
 Put calling process into a sleep state.
void SleepUntil (Ticks timestamp)
 Put calling process into a sleep state until the specified timestamp.
IWaitObjectWait (ISyncObject *sync_obj, IMutex *mutex, Timeout timeout)
void ProcessTick ()
 Process one tick.
void ProcessHardFault ()
 Cause a hard fault of the system.
void SetEventOverrider (IEventOverrider *overrider)
 Set platform event overrider.
Word GetCallerSP () const
 Get caller's Stack Pointer (SP).
TId GetTid () const
 Get thread Id.
Timeout Suspend ()
 Suspend scheduling.
void Resume (Timeout elapsed_ticks)
 Resume scheduling after a prior Suspend() call.

Detailed Description

Concrete implementation of IPlatform driver for the x86 Win32 platform.

Note
Implemented for simulation purpose on Windows platform.

Definition at line 25 of file stk_arch_x86-win32.h.

Constructor & Destructor Documentation

◆ ~PlatformX86Win32()

stk::PlatformX86Win32::~PlatformX86Win32 ( )
inline

Destructor.

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

Definition at line 31 of file stk_arch_x86-win32.h.

32 {}

Member Function Documentation

◆ GetCallerSP()

Word stk::PlatformX86Win32::GetCallerSP ( ) const
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.

Implements stk::IPlatform.

◆ GetSysTimerCount()

Cycles stk::PlatformX86Win32::GetSysTimerCount ( ) const
virtual

Get system timer count value.

Note
ISR-safe.
Returns
64-bit count value.

Implements stk::IPlatform.

◆ GetSysTimerFrequency()

uint32_t stk::PlatformX86Win32::GetSysTimerFrequency ( ) const
virtual

Get system timer frequency.

Note
ISR-safe.
Returns
Frequency (Hz).

Implements stk::IPlatform.

◆ GetTickResolution()

uint32_t stk::PlatformX86Win32::GetTickResolution ( ) const
virtual

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

Returns
Microseconds.

Implements stk::IPlatform.

◆ GetTid()

TId stk::PlatformX86Win32::GetTid ( ) const
virtual

Get thread Id.

Returns
Thread Id.
Warning
ISR-safe.
See also
TID_ISR_N, TID_NONE, IsIsrTid

Implements stk::IPlatform.

◆ Initialize()

void stk::PlatformX86Win32::Initialize ( IEventHandler * event_handler,
IKernelService * service,
uint32_t resolution_us,
Stack * exit_trap )
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().

Implements stk::IPlatform.

◆ InitStack()

bool stk::PlatformX86Win32::InitStack ( EStackType stack_type,
Stack * stack,
IStackMemory * stack_memory,
ITask * user_task )
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.

Implements stk::IPlatform.

◆ ProcessHardFault()

void stk::PlatformX86Win32::ProcessHardFault ( )
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).

Implements stk::IPlatform.

◆ ProcessTick()

void stk::PlatformX86Win32::ProcessTick ( )
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.

Implements stk::IPlatform.

◆ Resume()

void stk::PlatformX86Win32::Resume ( Timeout elapsed_ticks)
virtual

Resume scheduling after a prior Suspend() call.

Parameters
[in]elapsed_ticksNumber of ticks that elapsed during the suspended period. The kernel uses this value to advance internal time counters.
Note
ISR-safe.

Implements stk::IPlatform.

◆ SetEventOverrider()

void stk::PlatformX86Win32::SetEventOverrider ( IEventOverrider * overrider)
virtual

Set platform event overrider.

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

Implements stk::IPlatform.

◆ Sleep()

void stk::PlatformX86Win32::Sleep ( Timeout ticks)
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).

Implements stk::IPlatform.

◆ SleepUntil()

void stk::PlatformX86Win32::SleepUntil ( Ticks timestamp)
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.

Implements stk::IPlatform.

◆ Start()

void stk::PlatformX86Win32::Start ( )
virtual

Start scheduling.

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

Implements stk::IPlatform.

◆ Stop()

void stk::PlatformX86Win32::Stop ( )
virtual

Stop scheduling.

Implements stk::IPlatform.

◆ Suspend()

Timeout stk::PlatformX86Win32::Suspend ( )
virtual

Suspend scheduling.

Returns
Number of ticks available for the suspension period, as determined by the nearest pending wake-up. The caller may use this value to program a hardware timer for the tickless sleep interval.
Note
ISR-safe. Pair with Resume().

Implements stk::IPlatform.

◆ SwitchToNext()

void stk::PlatformX86Win32::SwitchToNext ( )
virtual

Switch to a next task.

Implements stk::IPlatform.

◆ Wait()

IWaitObject * stk::PlatformX86Win32::Wait ( ISyncObject * sync_obj,
IMutex * mutex,
Timeout timeout )

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