![]() |
SuperTinyKernel™ RTOS 1.06.0
Lightweight, high-performance, deterministic, bare-metal C++ RTOS for resource-constrained embedded systems. MIT Open Source License.
|
Hardware Abstraction Layer (HAL) for architecture-specific operations. More...
Classes | |
| class | CriticalSection |
| Nestable, SMP-safe critical section that combines local interrupt masking with a global cross-core spinlock. More... | |
| class | SpinLock |
| Atomic busy-wait lock used as the global cross-core synchronisation primitive inside CriticalSection. More... | |
| class | HiResClock |
| High-resolution clock for high-precision measurements. More... | |
Functions | |
| template<typename T> | |
| __stk_forceinline Word | PtrToWord (T *ptr) noexcept |
| Cast a pointer to a CPU register-width integer. | |
| template<typename T> | |
| __stk_forceinline T * | WordToPtr (Word value) noexcept |
| Cast a CPU register-width integer back to a pointer. | |
| bool | IsInsideISR () |
| Check whether the CPU is currently executing inside a hardware interrupt service routine (ISR). | |
| Word | GetTls () |
| Read raw thread-pointer (TP) register used as per-task TLS storage. | |
| void | SetTls (Word tp) |
| Write raw thread-pointer (TP) register used as per-task TLS storage. | |
| template<class _TyTls> | |
| __stk_forceinline _TyTls * | GetTlsPtr () |
| Type-safe wrapper around GetTls() that casts the raw TP value to a typed pointer. | |
| template<class _TyTls> | |
| __stk_forceinline void | SetTlsPtr (const _TyTls *tp) |
| Type-safe wrapper around SetTls() that stores a typed pointer as the raw TP value. | |
| template<typename T> | |
| __stk_forceinline T | ReadVolatile64 (volatile const T *addr) |
| Atomically read a 64-bit volatile value. | |
| template<typename T> | |
| __stk_forceinline void | WriteVolatile64 (volatile T *addr, T value) |
| Atomically write a 64-bit volatile value. | |
Hardware Abstraction Layer (HAL) for architecture-specific operations.
This namespace contains low-level functions that interface directly with the CPU registers and hardware state. Implementations live in the architecture back-end headers included above and are typically written in assembly or using compiler intrinsics for maximum performance and minimum latency.
| Word stk::hw::GetTls | ( | ) |
Read raw thread-pointer (TP) register used as per-task TLS storage.
Word. tp register. Referenced by GetTlsPtr().
| __stk_forceinline _TyTls * stk::hw::GetTlsPtr | ( | ) |
Type-safe wrapper around GetTls() that casts the raw TP value to a typed pointer.
| _TyTls | The type pointed to by the TLS register (typically the per-task kernel context struct). |
nullptr if TLS has not been set. reinterpret_cast<_TyTls*>(GetTls()). Prefer this over calling GetTls() directly to avoid scattered reinterpret_casts throughout the codebase. Definition at line 158 of file stk_arch.h.
References __stk_forceinline, GetTls(), and WordToPtr().
Referenced by stk_tls_get().
| bool stk::hw::IsInsideISR | ( | ) |
Check whether the CPU is currently executing inside a hardware interrupt service routine (ISR).
true if called from an ISR context; false if called from a normal task/thread context. Referenced by stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService::Delay(), IsIrqContext(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService::Sleep(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService::SleepUntil(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService::SwitchToNext(), stk::sync::Mutex::TimedLock(), stk::sync::SpinLock::Unlock(), stk::sync::ConditionVariable::Wait(), stk::sync::Event::Wait(), stk::sync::EventFlags::Wait(), and stk::sync::Semaphore::Wait().
|
noexcept |
Cast a pointer to a CPU register-width integer.
| T | The type of the object pointed to. |
| [in] | ptr | The pointer to be converted. |
Definition at line 94 of file stk_arch.h.
References __stk_forceinline, and STK_STATIC_ASSERT.
Referenced by stk::Task< _StackSize, _AccessMode >::GetId(), stk::TaskW< _Weight, _StackSize, _AccessMode >::GetId(), stk::time::TimerHost::TimerWorkerTask::GetId(), StkThread::GetId(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::GetTid(), stk::PlatformContext::InitStackMemory(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::IsMemoryOfSP(), and SetTlsPtr().
| __stk_forceinline T stk::hw::ReadVolatile64 | ( | volatile const T * | addr | ) |
Atomically read a 64-bit volatile value.
| T | Must be exactly 8 bytes wide and at least 4-byte aligned (enforced by static assertions). |
| [in] | addr | Pointer to the volatile 64-bit memory location. |
Definition at line 357 of file stk_arch.h.
References __stk_forceinline, STK_ENDIAN_IDX_HI, STK_ENDIAN_IDX_LO, and STK_STATIC_ASSERT_N.
Referenced by stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService::GetTicks(), and stk::time::TimerHost::GetTimeNow().
| void stk::hw::SetTls | ( | Word | tp | ) |
Write raw thread-pointer (TP) register used as per-task TLS storage.
| [in] | tp | New TP value to store. |
Referenced by SetTlsPtr().
| __stk_forceinline void stk::hw::SetTlsPtr | ( | const _TyTls * | tp | ) |
Type-safe wrapper around SetTls() that stores a typed pointer as the raw TP value.
| _TyTls | The type pointed to by the TLS register (typically the per-task kernel context struct). |
| [in] | tp | Pointer to the new task's TLS object. |
SetTls(reinterpret_cast<Word>(tp)). Called by the scheduler during context switches to install the incoming task's TLS pointer. Definition at line 170 of file stk_arch.h.
References __stk_forceinline, PtrToWord(), and SetTls().
Referenced by stk_tls_set().
|
noexcept |
Cast a CPU register-width integer back to a pointer.
| T | The type of the object the resulting pointer will address. |
| [in] | value | The register-width integer (Word) to be converted. |
Definition at line 111 of file stk_arch.h.
References __stk_forceinline, and STK_STATIC_ASSERT.
Referenced by GetTlsPtr().
| __stk_forceinline void stk::hw::WriteVolatile64 | ( | volatile T * | addr, |
| T | value ) |
Atomically write a 64-bit volatile value.
| T | Must be exactly 8 bytes wide and at least 4-byte aligned (enforced by static assertions). |
| [in] | addr | Pointer to the volatile 64-bit memory location. |
| [in] | value | Value to write. |
Definition at line 411 of file stk_arch.h.
References __stk_forceinline, STK_ENDIAN_IDX_HI, STK_ENDIAN_IDX_LO, and STK_STATIC_ASSERT_N.
Referenced by stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService::IncrementTicks(), and stk::time::TimerHost::UpdateTime().