15#ifdef _STK_CORTEX_M_TRUSTZONE_NON_SECURE
16 #include "arch/arm/cortex-m/stk_arch_arm-tz.h"
45#if STK_MPU_STACK_GUARD
91template <
size_t _StackSize, EAccessMode _AccessMode>
93#ifdef _STK_CORTEX_M_TRUSTZONE_NON_SECURE
94 :
public tz::nsec::NsTask
143template <Weight _Weight,
size_t _StackSize, EAccessMode _AccessMode>
145#ifdef _STK_CORTEX_M_TRUSTZONE_NON_SECURE
146 :
public tz::nsec::NsTask
187template <
size_t _StackSize>
244#ifdef _STK_CORTEX_M_TRUSTZONE_NON_SECURE
245 :
public tz::nsec::NsSyncObject
312#if (STK_ARCH_CPU_COUNT > 1)
318 while (itr !=
nullptr)
322 if (!itr->
Tick(elapsed_ticks))
339 while (itr !=
nullptr)
350 return ((max_weight > comp) ? max_weight :
NO_WEIGHT);
382 return static_cast<Time>((tick_count *
static_cast<Time>(resolution)) / 1000LL);
393 Ticks tick_count = 0LL;
395 if (resolution != 0U)
397 tick_count =
static_cast<Ticks>((ms * 1000LL) /
static_cast<Time>(resolution));
422 const Time time_ms =
static_cast<Time>(ms);
428 return static_cast<Timeout>(final_ticks);
452 return ((resolution == 1000U) ? tick_count :
453 ((tick_count *
static_cast<Ticks>(resolution)) / 1000LL));
Hardware Abstraction Layer (HAL) declarations for the stk::hw namespace.
Contains interface definitions of the library.
#define __stk_forceinline
Forces compiler to always inline the decorated function, regardless of optimisation level.
#define __stk_aligned(x)
Specifies minimum alignment in bytes for the decorated variable or struct member (data instance prefi...
#define STK_NONCOPYABLE_CLASS(TYPE)
Disables copy construction and assignment for a class.
#define STK_STACK_MEMORY_ALIGN
Stack memory alignment.
#define STK_STATIC_ASSERT(X)
Compile-time assertion. Produces a compilation error if X is false.
#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 Time GetMsFromTicks(Ticks tick_count, uint32_t resolution)
Convert ticks to milliseconds.
static void Yield()
Notify scheduler to switch to the next runnable task.
static void Sleep(Timeout tick_count)
Put calling process into a sleep state.
static void SleepCancel(TId task_id)
Cancel sleep of the task.
static void SleepMs(Timeout ms)
Put calling process into a sleep state.
EAccessMode
Hardware access modes by the task.
static constexpr ITask * GetUserTaskFromTid(TId task_id) noexcept
Get task instance from its identifier.
static Time GetTimeNowMs()
Get current time in milliseconds since kernel start.
@ STACK_SIZE_MIN
Minimum stack size in elements of Word. Used as a lower bound for all stack allocations (user task,...
int64_t Ticks
Ticks value.
static void DelayMs(Timeout ms)
Delay calling process by busy-waiting until the deadline expires.
int32_t Timeout
Timeout time (ticks).
static bool SleepUntil(Ticks timestamp)
Put calling process into a sleep state until the specified timestamp.
static Ticks GetTicksFromMs(Time ms, uint32_t resolution)
Convert milliseconds to ticks.
static uint32_t GetTickResolution()
Get number of microseconds in one tick.
static uint32_t GetSysTimerFrequency()
Get system timer frequency.
static void Delay(Timeout tick_count)
Delay calling process by busy-waiting until the deadline expires.
static constexpr Weight NO_WEIGHT
Weight value: weight is not set.
static Ticks GetTicks()
Get number of ticks elapsed since kernel start.
static constexpr Timeout WAIT_INFINITE
Timeout value: block indefinitely until the synchronization object is signaled.
static TId GetTid()
Get task/thread Id of the calling task.
static Timeout GetTicksFromMsClampedToTimeout(Timeout ms)
Convert milliseconds to ticks and clamp the result to a Timeout type.
static Cycles GetSysTimerCount()
Get system timer count value.
uint64_t Cycles
Cycles value.
Word TId
Task (thread) id.
int32_t Weight
Weight value (aka priority).
RAII instance that enters the critical section on construction and exits it on destruction.
Interface for a stack memory region.
DLHeadType ListHeadType
List head type for IWaitObject elements.
virtual TId GetTid() const =0
Get thread Id of the task owning .
virtual void Wake(bool timeout)=0
Wake task.
virtual bool Tick(Timeout elapsed_ticks)=0
Update wait object's waiting time.
Synchronization object interface.
virtual bool Tick(Timeout elapsed_ticks)
Called by kernel on every system tick to handle timeout logic of waiting tasks.
static void AddWaitObject(IWaitObject::ListHeadType &wlist, IWaitObject *wobj)
Called by kernel when a new task starts waiting on this event.
static void RemoveWaitObject(IWaitObject::ListHeadType &wlist, IWaitObject *wobj)
Called by kernel when a waiting task is being removed (timeout expired, wait aborted,...
virtual const IWaitObject::ListHeadType & GetWaitList() const =0
Get list of tasks blocked on this object.
Weight FindWeightHigherThan(Weight comp) const
Find higher weight within linked wait objects.
Interface for a user task.
virtual Weight GetWeight() const
Get static base weight of the task.
Interface for the kernel services exposed to the user processes during run-time when Kernel started s...
virtual TId GetTid() const =0
Get thread Id of the currently running task.
virtual void Wake(ISyncObject *sobj, bool all)=0
Wake one or all tasks currently waiting on a synchronization object.
virtual void SleepCancel(TId task_id)=0
Cancel sleep of the task.
static IKernelService * GetInstance()
Get CPU-local instance of the kernel service.
virtual uint32_t GetTickResolution() const =0
Get number of microseconds in one tick.
virtual bool SleepUntil(Ticks timestamp)=0
Put calling process into a sleep state until the specified timestamp.
virtual Ticks GetTicks() const =0
Get number of ticks elapsed since kernel start.
virtual void SwitchToNext()=0
Notify scheduler to switch to the next task (yield).
virtual void Sleep(Timeout ticks)=0
Put calling process into a sleep state.
virtual Cycles GetSysTimerCount() const =0
Get system timer count value.
virtual uint32_t GetSysTimerFrequency() const =0
Get system timer frequency.
virtual void Delay(Timeout ticks)=0
Delay calling process.
Stack memory type definition.
Word Type[SIZE]
Stack memory type.
Task()
Initializes task instance and zero-initializes its internal stack memory.
Task(const Task &)=delete
~Task()=default
Destructor.
size_t GetStackSize() const override
Get number of elements of the stack memory array.
const Word * GetStack() const override
Get pointer to the stack memory.
StackMemoryDef< _StackSize >::Type m_stack
Stack memory region, STK_STACK_MEMORY_ALIGN-byte aligned.
EAccessMode GetAccessMode() const override
Get hardware access mode of the user task.
Weight GetWeight() const override
Get static base weight of the task.
TaskW(const TaskW &)=delete
const Word * GetStack() const override
Get pointer to the stack memory.
~TaskW()=default
Destructor.
EAccessMode GetAccessMode() const override
Get hardware access mode of the user task.
size_t GetStackSize() const override
Get number of elements of the stack memory array.
TaskW()
Initializes task instance and zero-initializes its internal stack memory.
StackMemoryDef< _StackSize >::Type m_stack
Stack memory region, 16-byte aligned.
size_t GetStackSize() const override
Get number of elements in the wrapped stack array.
~StackMemoryWrapper()=default
Destructor.
const Word * GetStack() const override
Get pointer to the first element of the wrapped stack array.
StackMemoryDef< _StackSize >::Type MemoryType
StackMemoryWrapper(MemoryType *stack)
Construct a wrapper around an existing stack memory array.
~SyncObjectBase()=default
Destructor.
void WakeAll() override
Wake all tasks currently in the wait list.
SyncObjectBase()
Constructor.
void RemoveWaitObject(IWaitObject *wobj) override
Called by kernel when a waiting task is being removed (timeout expired, wait aborted,...
IWaitObject::ListHeadType m_wait_list
Tasks blocked on this object.
void WakeOne() override
Wake the first task in the wait list (FIFO order).
const IWaitObject::ListHeadType & GetWaitList() const override
Get list of tasks blocked on this object.
IWaitObject::ListHeadType & GetWaitList() override
Get list of tasks blocked on this object.
friend class IKernelService
void AddWaitObject(IWaitObject *wobj) override
Called by kernel when a new task starts waiting on this event.
DLEntryType * GetFirst()
Get the first (front) entry without removing it.
bool IsEmpty() const
Check whether the list contains no entries.
DLEntryType * GetNext()
Get the next entry in the list.
static __stk_forceinline TTargetType * ListEntryToParent(TSourceType *const lentry)
Safely casts an intrusive list entry to its concrete parent container object type.