10#ifndef STK_ARCH_ARM_CORTEX_M_H_
11#define STK_ARCH_ARM_CORTEX_M_H_
14#if defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE != 0)
65#if STK_TLS && STK_TLS_PREFER_REGISTER
83 __asm
volatile(
"MOV %0, r9" :
"=r"(tp) : : );
97 __asm
volatile(
"MOV r9, %0" : :
"r"(tp) : );
101#define STK_INLINE_TLS 1
114#if defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)
115 #define STK_TZ_SECURE (1)
117 #define STK_TZ_SECURE (0)
123#if defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 1)
124 #define STK_TZ_NON_SECURE (1)
126 #define STK_TZ_NON_SECURE (0)
133#if defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)
134 #define __stk_tz_nsc_entry __attribute__((cmse_nonsecure_entry))
136 #define __stk_tz_nsc_entry
142#if defined(__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3)
143 #define __stk_tz_ns_call __attribute__((cmse_nonsecure_call))
145 #define __stk_tz_ns_call
151#define STK_TZ_NSC_GATEWAY extern "C" __stk_tz_nsc_entry
154#ifdef _STK_CORTEX_M_TRUSTZONE_NON_SECURE
155#if !STK_TZ_NON_SECURE
156 #error "Switch of -cmse compiler flag for Non-Secure binary!"
static void __stk_dmb()
Hardware memory barrier: ensures visibility across cores and bus masters.
Contains interface definitions of the library.
#define __stk_forceinline
Forces compiler to always inline the decorated function, regardless of optimisation level.
#define STK_VIRT_DTOR
Makes destructors virtual and compliant to strict rules if STK_STRICT_COMPLIANCY=0.
Namespace of STK package.
uintptr_t Word
Native processor word type.
static __stk_forceinline void SetTls(Word tp)
Set thread-local storage (TLS).
int64_t Ticks
Ticks value.
int32_t Timeout
Timeout time (ticks).
static __stk_forceinline Word GetTls()
Get thread-local storage (TLS).
EWaitResult
Wait result (see IKernelService::Wait).
PlatformArmCortexM PlatformDefault
Default platform implementation.
uint64_t Cycles
Cycles value.
Word TId
Task (thread) id.
Concrete implementation of IPlatform driver for the Arm Cortex-M0, M3, M4, M7 processors.
void SwitchToNext() override
Switch to a next task.
void Sleep(Timeout ticks) override
Put calling process into a sleep state.
void ProcessTick() override
Process one tick.
Word GetCallerSP() const override
Get caller's Stack Pointer (SP).
void ProcessHardFault() override
Cause a hard fault of the system.
uint32_t GetTickResolution() const override
Get resolution of the system tick timer in microseconds. Resolution means a number of microseconds be...
Timeout Suspend() override
Suspend scheduling.
void Start() override
Start scheduling.
void Stop() override
Stop scheduling.
TId GetTid() const override
Get thread Id.
uint32_t GetSysTimerFrequency() const override
Get system timer frequency.
Cycles GetSysTimerCount() const override
Get system timer count value.
void InitStack(EStackType stack_type, Stack *stack, IStackMemory *stack_memory, ITask *user_task) override
Initialize stack memory of the user task.
EWaitResult Wait(ISyncObject *sync_obj, IMutex *mutex, Timeout timeout) override
Put calling process into a waiting state until synchronization object is signaled or timeout occurs.
void Resume(Timeout elapsed_ticks) override
Resume scheduling after a prior Suspend() call.
void SetEventOverrider(IEventOverrider *overrider) override
Set platform event overrider.
void Initialize(IEventHandler *event_handler, IKernelService *service, uint32_t resolution_us, Stack *exit_trap) override
Initialize scheduler's context.
~PlatformArmCortexM()=default
Destructor.
bool SleepUntil(Ticks timestamp) override
Put calling process into a sleep state until the specified timestamp.
Interface for a stack memory region.
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...