Kernel: Implement InterruptDisabler using generic Processor functions

Now that the code does not use architectural specific code, it is moved
to the generic Arch directory and the paths are modified accordingly.
This commit is contained in:
Timon Kruiper 2022-05-16 14:42:49 +02:00 committed by Linus Groh
parent ea9cf8b6ab
commit a4534678f9
Notes: sideshowbarker 2024-07-17 10:31:22 +09:00
28 changed files with 58 additions and 64 deletions

View File

@ -0,0 +1,32 @@
/*
* Copyright (c) 2022, Timon Kruiper <timonkruiper@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Types.h>
#include <Kernel/Arch/Processor.h>
namespace Kernel {
class InterruptDisabler {
public:
InterruptDisabler()
: m_interrupts_were_enabled(Processor::are_interrupts_enabled())
{
Processor::disable_interrupts();
}
~InterruptDisabler()
{
if (m_interrupts_were_enabled)
Processor::enable_interrupts();
}
private:
bool m_interrupts_were_enabled;
};
}

View File

@ -1,38 +0,0 @@
/*
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Types.h>
#include <Kernel/Arch/x86/IO.h>
#include <Kernel/Arch/x86/ASM_wrapper.h>
#include <AK/Platform.h>
VALIDATE_IS_X86()
namespace Kernel {
class InterruptDisabler {
public:
InterruptDisabler()
{
m_flags = cpu_flags();
cli();
}
~InterruptDisabler()
{
if ((m_flags & 0x200) != 0)
sti();
}
private:
u32 m_flags;
};
}

View File

@ -19,12 +19,12 @@
#include <Kernel/StdLib.h>
#include <Kernel/Thread.h>
#include <Kernel/Arch/InterruptDisabler.h>
#include <Kernel/Arch/Interrupts.h>
#include <Kernel/Arch/Processor.h>
#include <Kernel/Arch/SafeMem.h>
#include <Kernel/Arch/ScopedCritical.h>
#include <Kernel/Arch/x86/CPUID.h>
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Arch/x86/MSR.h>
#include <Kernel/Arch/x86/ProcessorInfo.h>
#include <Kernel/Arch/x86/TrapFrame.h>

View File

@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/Arch/InterruptDisabler.h>
#include <Kernel/Arch/Processor.h>
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Arch/x86/TrapFrame.h>
namespace Kernel {

View File

@ -5,7 +5,7 @@
*/
#include <AK/StringView.h>
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Arch/InterruptDisabler.h>
#include <Kernel/DoubleBuffer.h>
namespace Kernel {

View File

@ -7,7 +7,7 @@
#include <AK/HashMap.h>
#include <AK/Singleton.h>
#include <AK/StringView.h>
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Arch/InterruptDisabler.h>
#include <Kernel/FileSystem/FileSystem.h>
#include <Kernel/FileSystem/Inode.h>
#include <Kernel/Memory/MemoryManager.h>

View File

@ -9,8 +9,8 @@
#include <AK/Format.h>
#include <AK/StringView.h>
#include <AK/Try.h>
#include <Kernel/Arch/InterruptDisabler.h>
#include <Kernel/Arch/x86/IO.h>
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Bus/PCI/API.h>
#include <Kernel/Debug.h>
#include <Kernel/Firmware/ACPI/Parser.h>

View File

@ -7,7 +7,7 @@
#include <AK/OwnPtr.h>
#include <AK/Singleton.h>
#include <Kernel/API/MousePacket.h>
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Arch/InterruptDisabler.h>
#include <Kernel/CommandLine.h>
#include <Kernel/Debug.h>
#include <Kernel/Firmware/Hypervisor/VMWareBackdoor.h>

View File

@ -8,7 +8,7 @@
#include <AK/JsonObjectSerializer.h>
#include <AK/Try.h>
#include <AK/UBSanitizer.h>
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Arch/InterruptDisabler.h>
#include <Kernel/Arch/x86/ProcessorInfo.h>
#include <Kernel/Bus/PCI/API.h>
#include <Kernel/Bus/PCI/Access.h>

View File

@ -5,7 +5,7 @@
*/
#include <AK/Optional.h>
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Arch/InterruptDisabler.h>
#include <Kernel/Debug.h>
#include <Kernel/Interrupts/APIC.h>
#include <Kernel/Interrupts/IOAPIC.h>

View File

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Arch/InterruptDisabler.h>
#include <Kernel/Debug.h>
#include <Kernel/Interrupts/IRQHandler.h>
#include <Kernel/Interrupts/InterruptManagement.h>

View File

@ -6,8 +6,8 @@
#include <AK/ByteReader.h>
#include <Kernel/API/Syscall.h>
#include <Kernel/Arch/InterruptDisabler.h>
#include <Kernel/Arch/Interrupts.h>
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/CommandLine.h>
#include <Kernel/Firmware/MultiProcessor/Parser.h>
#include <Kernel/Interrupts/APIC.h>

View File

@ -6,8 +6,8 @@
#include <AK/Assertions.h>
#include <AK/Types.h>
#include <Kernel/Arch/InterruptDisabler.h>
#include <Kernel/Arch/x86/IO.h>
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Interrupts/GenericInterruptHandler.h>
#include <Kernel/Interrupts/PIC.h>
#include <Kernel/Sections.h>

View File

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Arch/InterruptDisabler.h>
#include <Kernel/Memory/MemoryManager.h>
#include <Kernel/Memory/ScopedAddressSpaceSwitcher.h>

View File

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Arch/InterruptDisabler.h>
#include <Kernel/Heap/kmalloc.h>
#include <Kernel/Net/EtherType.h>
#include <Kernel/Net/NetworkAdapter.h>

View File

@ -9,7 +9,7 @@
#include <AK/Time.h>
#include <AK/Types.h>
#include <Kernel/API/Syscall.h>
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Arch/InterruptDisabler.h>
#include <Kernel/Coredump.h>
#include <Kernel/Debug.h>
#include <Kernel/Devices/DeviceManagement.h>

View File

@ -7,7 +7,7 @@
#include <AK/JsonArraySerializer.h>
#include <AK/JsonObjectSerializer.h>
#include <AK/JsonValue.h>
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Arch/InterruptDisabler.h>
#include <Kernel/FileSystem/Custody.h>
#include <Kernel/FileSystem/ProcFS.h>
#include <Kernel/KBufferBuilder.h>

View File

@ -8,7 +8,7 @@
#include <AK/ScopeGuard.h>
#include <AK/Singleton.h>
#include <AK/Time.h>
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Arch/InterruptDisabler.h>
#include <Kernel/Arch/x86/TrapFrame.h>
#include <Kernel/Debug.h>
#include <Kernel/Panic.h>

View File

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Arch/InterruptDisabler.h>
#include <Kernel/Process.h>
namespace Kernel {

View File

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Arch/InterruptDisabler.h>
#include <Kernel/Process.h>
#include <Kernel/TTY/TTY.h>

View File

@ -5,8 +5,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/Arch/InterruptDisabler.h>
#include <Kernel/Arch/SmapDisabler.h>
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Process.h>
namespace Kernel {

View File

@ -5,7 +5,7 @@
*/
#include <Kernel/API/POSIX/errno.h>
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Arch/InterruptDisabler.h>
#include <Kernel/Debug.h>
#include <Kernel/Process.h>
#include <Kernel/TTY/MasterPTY.h>

View File

@ -8,7 +8,7 @@
#include <AK/ScopeGuard.h>
#include <AK/StringView.h>
#include <Kernel/API/POSIX/errno.h>
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Arch/InterruptDisabler.h>
#include <Kernel/Debug.h>
#include <Kernel/Process.h>
#include <Kernel/TTY/TTY.h>

View File

@ -9,8 +9,8 @@
#include <AK/StringBuilder.h>
#include <AK/TemporaryChange.h>
#include <AK/Time.h>
#include <Kernel/Arch/InterruptDisabler.h>
#include <Kernel/Arch/SmapDisabler.h>
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Arch/x86/TrapFrame.h>
#include <Kernel/Debug.h>
#include <Kernel/Devices/KCOVDevice.h>

View File

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Arch/InterruptDisabler.h>
#include <Kernel/Assertions.h>
#include <Kernel/Debug.h>
#include <Kernel/Sections.h>

View File

@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/Arch/InterruptDisabler.h>
#include <Kernel/Arch/x86/IO.h>
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Interrupts/GenericInterruptHandler.h>
#include <Kernel/Scheduler.h>
#include <Kernel/Sections.h>

View File

@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/Arch/InterruptDisabler.h>
#include <Kernel/Arch/x86/IO.h>
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Arch/x86/NonMaskableInterruptDisabler.h>
#include <Kernel/CMOS.h>
#include <Kernel/Time/RTC.h>

View File

@ -7,7 +7,7 @@
#include <AK/Singleton.h>
#include <AK/StdLibExtras.h>
#include <AK/Time.h>
#include <Kernel/Arch/x86/InterruptDisabler.h>
#include <Kernel/Arch/InterruptDisabler.h>
#include <Kernel/CommandLine.h>
#include <Kernel/Firmware/ACPI/Parser.h>
#include <Kernel/Interrupts/APIC.h>