![]() |
SuperTinyKernel™ RTOS 1.06.x
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> | |
| static constexpr Word | PtrToWord (T *const ptr) noexcept |
| Cast a pointer to a CPU register-width integer. | |
| template<typename T> | |
| static constexpr 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). | |
| template<typename T> | |
| static __stk_forceinline T | ReadVolatile64 (volatile const T *addr) |
| Atomically read a 64-bit volatile value. | |
| template<typename T> | |
| static __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.
| 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. References __stk_forceinline.
Referenced by stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService::Delay(), IsIrqContext(), IsIrqContext(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService::Sleep(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService::SleepUntil(), stk_blockpool_alloc(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService::SwitchToNext(), stk::memory::BlockMemoryPool::TimedAlloc(), 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().
|
staticconstexprnoexcept |
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 106 of file stk_arch.h.
References STK_STATIC_ASSERT.
Referenced by stk::memory::MemoryAllocator::AllocateArrayT(), stk::memory::BlockMemoryPool::BuildFreeList(), stk::memory::BlockMemoryPool::Free(), stk::memory::MemoryAllocator::FreeArrayT(), stk::GetTidFromUserTask(), stk::PlatformContext::InitStackMemory(), stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelTask::IsMemoryOfSP(), ReadVolatile64(), STK_MEMCPY(), and WriteVolatile64().
|
static |
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 379 of file stk_arch.h.
References __stk_constexpr_cpp17, __stk_forceinline, PtrToWord(), STK_ENDIAN_IDX_HI, STK_ENDIAN_IDX_LO, STK_STATIC_ASSERT_N, and WordToPtr().
Referenced by stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService::GetTicks(), and stk::time::TimerHost::GetTimeNow().
|
staticconstexprnoexcept |
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 123 of file stk_arch.h.
References STK_STATIC_ASSERT.
Referenced by stk::memory::BlockMemoryPool::BuildFreeList(), stk::GetUserTaskFromTid(), ReadVolatile64(), and WriteVolatile64().
|
static |
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 444 of file stk_arch.h.
References __stk_constexpr_cpp17, __stk_forceinline, PtrToWord(), STK_ENDIAN_IDX_HI, STK_ENDIAN_IDX_LO, STK_STATIC_ASSERT_N, and WordToPtr().
Referenced by stk::Kernel< TMode, TSize, TStrategy, TPlatform >::KernelService::IncrementTicks(), and stk::time::TimerHost::UpdateTime().