Line data Source code
1 : // Copyright 2024 Accenture. 2 : 3 : #ifndef GUARD_8C7D3DB7_0C72_4F76_BCDF_27393CF5DDF0 4 : #define GUARD_8C7D3DB7_0C72_4F76_BCDF_27393CF5DDF0 5 : 6 : #include "interrupts/suspendResumeAllInterrupts.h" 7 : 8 : namespace interrupts 9 : { 10 : class SuspendResumeAllInterruptsScopedLock 11 : { 12 : public: 13 : // [PUBLICAPI_START] 14 : /** 15 : * Create a lock object instance with disabling of all interrupts 16 : * Store the current interrupt state on instance creation in a private member variable 17 : */ 18 8361 : SuspendResumeAllInterruptsScopedLock() 19 8361 : : fOldMachineStateRegisterValue(getMachineStateRegisterValueAndSuspendAllInterrupts()) 20 : {} 21 : 22 : /** 23 : * Destroy the lock object instance and restore the internally stored interrupt state from 24 : * before this object instance has been created 25 : */ 26 8361 : ~SuspendResumeAllInterruptsScopedLock() { resumeAllInterrupts(fOldMachineStateRegisterValue); } 27 : 28 : // [PUBLICAPI_END] 29 : 30 : private: 31 : uint32_t fOldMachineStateRegisterValue; 32 : }; 33 : 34 : } /* namespace interrupts */ 35 : 36 : #endif /* GUARD_8C7D3DB7_0C72_4F76_BCDF_27393CF5DDF0 */