mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:17:35 +00:00
Kernel: Add an InterruptFlagSaver helper class.
This is useful instead of InterruptDisabler in some cases.
This commit is contained in:
parent
cd1bbdf052
commit
b782055b96
5 changed files with 28 additions and 18 deletions
|
@ -106,6 +106,25 @@ inline bool are_interrupts_enabled()
|
|||
return cpu_flags() & 0x200;
|
||||
}
|
||||
|
||||
class InterruptFlagSaver {
|
||||
public:
|
||||
InterruptFlagSaver()
|
||||
{
|
||||
m_flags = cpu_flags();
|
||||
}
|
||||
|
||||
~InterruptFlagSaver()
|
||||
{
|
||||
if (m_flags & 0x200)
|
||||
sti();
|
||||
else
|
||||
cli();
|
||||
}
|
||||
|
||||
private:
|
||||
dword m_flags;
|
||||
};
|
||||
|
||||
class InterruptDisabler {
|
||||
public:
|
||||
InterruptDisabler()
|
||||
|
@ -120,16 +139,6 @@ public:
|
|||
sti();
|
||||
}
|
||||
|
||||
void temporarily_cli()
|
||||
{
|
||||
cli();
|
||||
}
|
||||
|
||||
void temporarily_sti()
|
||||
{
|
||||
sti();
|
||||
}
|
||||
|
||||
private:
|
||||
dword m_flags;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue