mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 03:34:58 +00:00
48 lines
712 B
C++
48 lines
712 B
C++
/*
|
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/Types.h>
|
|
|
|
#include <Kernel/IO.h>
|
|
|
|
#include <Kernel/Arch/x86/ASM_wrapper.h>
|
|
|
|
namespace Kernel {
|
|
|
|
class InterruptDisabler {
|
|
public:
|
|
InterruptDisabler()
|
|
{
|
|
m_flags = cpu_flags();
|
|
cli();
|
|
}
|
|
|
|
~InterruptDisabler()
|
|
{
|
|
if (m_flags & 0x200)
|
|
sti();
|
|
}
|
|
|
|
private:
|
|
u32 m_flags;
|
|
};
|
|
|
|
class NonMaskableInterruptDisabler {
|
|
public:
|
|
NonMaskableInterruptDisabler()
|
|
{
|
|
IO::out8(0x70, IO::in8(0x70) | 0x80);
|
|
}
|
|
|
|
~NonMaskableInterruptDisabler()
|
|
{
|
|
IO::out8(0x70, IO::in8(0x70) & 0x7F);
|
|
}
|
|
};
|
|
|
|
}
|