26#ifndef SBL_HW_HAL_INTERRUPTS_CONTROL_HPP_
27#define SBL_HW_HAL_INTERRUPTS_CONTROL_HPP_
32#if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_8M_MAIN__)
33#define SBL_HAS_BASEPRI 1
35#if defined(__arm__) && !defined(__linux__)
36#define SBL_HAS_PRIMASK 1
49#if defined(SBL_HAS_BASEPRI)
51 __asm
volatile(
"mrs %0, basepri" :
"=r"(v));
60#if defined(SBL_HAS_BASEPRI)
61 __asm
volatile(
"msr basepri, %0" : :
"r"(encoded) :
"memory");
70#if defined(SBL_HAS_BASEPRI)
71 __asm
volatile(
"msr basepri_max, %0" : :
"r"(encoded) :
"memory");
112#if defined(SBL_HAS_PRIMASK)
114 __asm
volatile(
"mrs %0, primask" :
"=r"(saved));
115 __asm
volatile(
"cpsid i" : : :
"memory");
124#if defined(SBL_HAS_PRIMASK)
125 __asm
volatile(
"msr primask, %0" : :
"r"(saved_state) :
"memory");
133#if defined(SBL_HAS_PRIMASK)
135 __asm
volatile(
"mrs %0, primask" :
"=r"(v));
RAII critical section against the control tick and everything below.
ScopedControlCritical(const ScopedControlCritical &)=delete
ScopedControlCritical & operator=(const ScopedControlCritical &)=delete
Interrupt system types: execution levels and trigger kinds.
constexpr uint8_t encode(Level level)
Encode a level as the byte written to NVIC->IP[] / SCB->SHP[] / BASEPRI.
uint32_t get_basepri()
Read BASEPRI (0 = no ceiling).
void restore(uint32_t saved_state)
Restore PRIMASK from disable_and_save().
uint32_t disable_and_save()
Disable all configurable exceptions and return the previous PRIMASK.
void raise_basepri(uint32_t encoded)
constexpr Level kBasepriCeiling
The level a ScopedControlCritical raises BASEPRI to.
void set_basepri(uint32_t encoded)
Write BASEPRI unconditionally (used to restore a saved value).
uint32_t get_state()
Current PRIMASK (0 = enabled, 1 = disabled).
bool are_enabled()
True if configurable exceptions are enabled (PRIMASK clear).
Root namespace for all Sound Byte Libs code.