OS  v1.8.0
Documentation
Loading...
Searching...
No Matches
critical.hpp
1#ifndef QOS_CPP_CRITICAL
2#define QOS_CPP_CRITICAL
3
4#include "include/types.hpp"
5
6namespace qOS {
7
12
30 using int_restorer_t = void (*)( uint32_t );
31
51 using int_disabler_t = uint32_t (*)( void );
52
56 namespace critical {
57
62
76 inline void scope( void ) noexcept {}
77
94 class lock final : private nonCopyable {
95 private:
96 static void enter( void ) noexcept;
97 static void exit( void ) noexcept;
98 static int_disabler_t disable; // skipcq: CXX-W2009
99 static int_restorer_t restore; // skipcq: CXX-W2009
100 static volatile uint32_t flags; // skipcq: CXX-W2009
101 static volatile int nestingLevel; // skipcq: CXX-W2009
102 bool entered{ true };
103 friend bool setInterruptsED( const int_restorer_t rFcn, const int_disabler_t dFcn ) noexcept;
104 public:
105 lock() noexcept;
106 ~lock() noexcept;
107 explicit operator bool() noexcept;
108 };
109
120 bool setInterruptsED( const int_restorer_t rFcn, const int_disabler_t dFcn ) noexcept;
121
123 }
124
125}
126
128/*============================================================================*/
129#define scope \
130scope(); \
131for ( critical::lock critical_lock; critical_lock; ) \
132/*============================================================================*/
134
135#endif /*QOS_CPP_CRITICAL*/
friend bool setInterruptsED(const int_restorer_t rFcn, const int_disabler_t dFcn) noexcept
Set the hardware-specific code for global interrupt enable/disable. Setting this allows you to commun...
void scope(void) noexcept
Enables a scoped critical section with minimal syntax overhead.
Definition critical.hpp:76
uint32_t(*)(void) int_disabler_t
Function called by critical::enter() to disable interrupts.
Definition critical.hpp:51
bool setInterruptsED(const int_restorer_t rFcn, const int_disabler_t dFcn) noexcept
Set the hardware-specific code for global interrupt enable/disable. Setting this allows you to commun...
void(*)(uint32_t) int_restorer_t
Function called by critical::exit() to restore interrupts.
Definition critical.hpp:30
OS Critical interfaces.
Definition critical.hpp:56
OS/Kernel interfaces.
Definition bytebuffer.hpp:7