17#include <CppUTest/TestHarness.h>
30#ifndef _STK_UNDER_TEST
31 #define _STK_UNDER_TEST
33#define __stk_relax_cpu __stktest_relax_cpu
34#include <stk_config.h>
35#undef _STK_ARCH_ARM_CORTEX_M
36#undef _STK_ARCH_RISC_V
37#undef _STK_ARCH_X86_WIN32
68 const char *
what() const noexcept {
return "STK test suite exception (TestAssertPassed) thrown!"; }
330template <EAccessMode _AccessMode>
355template <
int32_t _Weight, EAccessMode _AccessMode>
Contains common inventory for platform implementation.
Top-level STK include. Provides the Kernel class template and all built-in task-switching strategies.
#define STK_TICKLESS_IDLE
Enables tickless (dynamic-tick) low-power operation during idle periods.
#define STK_ASSERT(e)
Runtime assertion. Halts execution if the expression e evaluates to false.
Collection of synchronization primitives (stk::sync namespace).
Collection of time-related primitives (stk::time namespace).
void(* g_RelaxCpuHandler)()
__stk_relax_cpu handler.
void(* g_RelaxCpuHandler)()
__stk_relax_cpu handler.
static void __stktest_relax_cpu()
__stk_relax_cpu interceptor.
Namespace of STK package.
int64_t Ticks
Ticks value.
int32_t Timeout
Timeout time (ticks).
@ STACK_EXIT_TRAP
Stack of the Exit trap.
EKernelPanicId
Identifies the source of a kernel panic.
IKernelService * g_KernelService
int32_t g_CriticalSectionState
Critical section state.
EKernelPanicId g_PanicValue
Panic value.
bool g_InsideISR
ISR state.
static Word * InitStackMemory(IStackMemory *memory)
Initialize stack memory by filling it with STK_STACK_MEMORY_FILLER.
Word SP
Stack Pointer (SP) register (note: must be the first entry in this struct).
Interface for a stack memory region.
virtual Word * GetStack() const =0
Get pointer to the stack memory.
void WakeOne()
Wake the first task in the wait list (FIFO order).
ISyncObject()
Constructor.
void WakeAll()
Wake all tasks currently in the wait list.
Interface for mutex synchronization primitive.
Interface for a user task.
Interface for a platform driver.
Interface for a back-end event handler.
Interface for a platform event overrider.
Interface for the kernel services exposed to the user processes during run-time when Kernel started s...
Task(const Task &)=delete
virtual void OnDeadlineMissed(uint32_t duration)
Default no-op handler. Override in subclass to log or handle missed deadlines.
TaskW(const TaskW &)=delete
Throwable class for catching assertions from STK_ASSERT_HANDLER().
const char * what() const noexcept
void Initialize(IEventHandler *event_handler, IKernelService *service, uint32_t resolution_us, Stack *exit_trap)
Initialize scheduler's context.
size_t GetCallerSP() const
Get caller's Stack Pointer (SP).
IEventHandler * m_event_handler
void EventTaskSwitch(size_t caller_SP)
void ProcessTick()
Process one tick.
void EventTaskExit(Stack *stack)
bool InitStack(EStackType type, Stack *stack, IStackMemory *stack_memory, ITask *user_task)
Initialize stack memory of the user task.
IWaitObject * EventTaskWait(size_t caller_SP, ISyncObject *sync_obj, IMutex *mutex, Timeout timeout)
void Sleep(Timeout ticks)
Put calling process into a sleep state.
IKernelService * m_service
IEventOverrider * m_overrider
void EventTaskSleep(size_t caller_SP, uint32_t sleep_ticks)
uint32_t m_context_switch_nr
void Start()
Start scheduling.
void SleepUntil(Ticks timestamp)
Put calling process into a sleep state until the specified timestamp.
IWaitObject * Wait(ISyncObject *sobj, IMutex *mutex, Timeout timeout)
virtual ~PlatformTestMock()
virtual TId GetTid() const
Get thread Id.
void SetEventOverrider(IEventOverrider *overrider)
Set platform event overrider.
void ProcessHardFault()
Cause a hard fault of the system.
void Stop()
Stop scheduling.
void SwitchToNext()
Switch to a next task.
StackInfo m_stack_info[STACK_EXIT_TRAP+1]
uint32_t GetTickResolution() const
Get resolution of the system tick timer in microseconds. Resolution means a number of microseconds be...
uint32_t m_switch_to_next_nr
int32_t GetTickResolution() const
Get number of microseconds in one tick.
size_t GetTid() const
Get thread Id of the currently running task.
void Sleep(Timeout ticks)
Put calling process into a sleep state.
void Delay(Timeout ticks)
Delay calling process.
void SwitchToNext()
Notify scheduler to switch to the next task (yield).
void SleepUntil(Ticks timestamp)
Put calling process into a sleep state until the specified timestamp.
int64_t GetTicks() const
Get number of ticks elapsed since kernel start.
virtual ~KernelServiceMock()
IWaitObject * Wait(ISyncObject *sobj, IMutex *mutex, Timeout timeout)
Put calling process into a waiting state until synchronization object is signaled or timeout occurs.
void OnDeadlineMissed(uint32_t duration)
Default no-op handler. Override in subclass to log or handle missed deadlines.
void Run()
Entry point of the user task.
uint32_t m_deadline_missed
duration of workload if deadline is missed in HRT mode
Task mock for SwitchStrategySmoothWeightedRoundRobin and similar algorithms.
void Run()
Entry point of the user task.
void Lock()
Lock the mutex.
void Unlock()
Unlock the mutex.