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_arch_arm-cortex-m.h
Go to the documentation of this file.
1/*
2 * SuperTinyKernel(TM) RTOS: Lightweight High-Performance Deterministic C++ RTOS for Embedded Systems.
3 *
4 * Source: https://github.com/SuperTinyKernel-RTOS
5 *
6 * Copyright (c) 2022-2026 Neutron Code Limited <stk@neutroncode.com>. All Rights Reserved.
7 * License: MIT License, see LICENSE for a full text.
8 */
9
10#ifndef STK_ARCH_ARM_CORTEX_M_H_
11#define STK_ARCH_ARM_CORTEX_M_H_
12
13#include "stk_common.h"
14
18
19namespace stk {
20
25{
26public:
32
33 void Initialize(IEventHandler *event_handler, IKernelService *service, uint32_t resolution_us, Stack *exit_trap);
34 void Start();
35 void Stop();
36 bool InitStack(EStackType stack_type, Stack *stack, IStackMemory *stack_memory, ITask *user_task);
37 uint32_t GetTickResolution() const;
39 uint32_t GetSysTimerFrequency() const;
41 void Sleep(Timeout ticks);
42 void SleepUntil(Ticks timestamp);
43 IWaitObject *Wait(ISyncObject *sync_obj, IMutex *mutex, Timeout timeout);
48 TId GetTid() const;
50 void Resume(Timeout elapsed_ticks);
51};
52
57
63{
64 Word tp;
65 __asm volatile("MOV %0, r9" : "=r"(tp) : /* input: none */ : /* clobbers: none */);
66 return tp;
67}
68
74{
75 __asm volatile("MOV r9, %0" : /* output: none */ : "r"(tp) : /* clobbers: none */);
76}
77
78// Notify stk_arch.h that we defined inline versions of GetTls/SetTls.
79#define _STK_INLINE_TLS_DEFINED 1
80
81} // namespace stk
82
86#define __stk_dmb() __asm volatile("dmb sy" ::: "memory")
87
88#endif /* STK_ARCH_ARM_CORTEX_M_H_ */
Contains interface definitions of the library.
#define __stk_forceinline
Forces compiler to always inline the decorated function, regardless of optimisation level.
Definition stk_defs.h:104
Namespace of STK package.
uintptr_t Word
Native processor word type.
Definition stk_common.h:113
int64_t Ticks
Ticks value.
Definition stk_common.h:128
int32_t Timeout
Timeout time (ticks).
Definition stk_common.h:123
void SetTls(Word tp)
Set thread-local storage (TLS).
EStackType
Stack type.
Definition stk_common.h:70
Word GetTls()
Get thread-local storage (TLS).
PlatformArmCortexM PlatformDefault
Default platform implementation.
uint64_t Cycles
Cycles value.
Definition stk_common.h:133
Word TId
Definition stk_common.h:118
Concrete implementation of IPlatform driver for the Arm Cortex-M0, M3, M4, M7 processors.
void SleepUntil(Ticks timestamp)
Put calling process into a sleep state until the specified timestamp.
uint32_t GetTickResolution() const
Get resolution of the system tick timer in microseconds. Resolution means a number of microseconds be...
void ProcessTick()
Process one tick.
void Initialize(IEventHandler *event_handler, IKernelService *service, uint32_t resolution_us, Stack *exit_trap)
Initialize scheduler's context.
TId GetTid() const
Get thread Id.
void Sleep(Timeout ticks)
Put calling process into a sleep state.
Word GetCallerSP() const
Get caller's Stack Pointer (SP).
void Start()
Start scheduling.
void SwitchToNext()
Switch to a next task.
void Stop()
Stop scheduling.
Cycles GetSysTimerCount() const
Get system timer count value.
bool InitStack(EStackType stack_type, Stack *stack, IStackMemory *stack_memory, ITask *user_task)
Initialize stack memory of the user task.
void SetEventOverrider(IEventOverrider *overrider)
Set platform event overrider.
uint32_t GetSysTimerFrequency() const
Get system timer frequency.
void Resume(Timeout elapsed_ticks)
Resume scheduling after a prior Suspend() call.
Timeout Suspend()
Suspend scheduling.
IWaitObject * Wait(ISyncObject *sync_obj, IMutex *mutex, Timeout timeout)
void ProcessHardFault()
Cause a hard fault of the system.
Stack descriptor.
Definition stk_common.h:219
Interface for a stack memory region.
Definition stk_common.h:231
Wait object.
Definition stk_common.h:270
Synchronization object.
Definition stk_common.h:355
Interface for mutex synchronization primitive.
Definition stk_common.h:439
Interface for a user task.
Definition stk_common.h:491
Interface for a platform driver.
Definition stk_common.h:648
Interface for a back-end event handler.
Definition stk_common.h:656
Interface for a platform event overrider.
Definition stk_common.h:737
Interface for the kernel services exposed to the user processes during run-time when Kernel started s...