mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:17:44 +00:00
Kernel: Add enum InterruptsState and helper functions
This commit adds the concept of an InterruptsState to the kernel. This will be used to make the Spinlock code architecture independent. A new Processor.cpp file is added such that we don't have to duplicate the code.
This commit is contained in:
parent
c1b0d254fd
commit
6432f3eee8
3 changed files with 42 additions and 0 deletions
25
Kernel/Arch/Processor.cpp
Normal file
25
Kernel/Arch/Processor.cpp
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Timon Kruiper <timonkruiper@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <Kernel/Arch/Processor.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
// FIXME: Move the InterruptsState related functions inside the Processor class, when we have a generic Processor base class.
|
||||
InterruptsState processor_interrupts_state()
|
||||
{
|
||||
return Processor::are_interrupts_enabled() ? InterruptsState::Enabled : InterruptsState::Disabled;
|
||||
}
|
||||
|
||||
void restore_processor_interrupts_state(InterruptsState interrupts_state)
|
||||
{
|
||||
if (interrupts_state == InterruptsState::Enabled)
|
||||
Processor::enable_interrupts();
|
||||
else
|
||||
Processor::disable_interrupts();
|
||||
}
|
||||
|
||||
}
|
|
@ -10,6 +10,19 @@
|
|||
#include <AK/Function.h>
|
||||
#include <Kernel/Arch/DeferredCallEntry.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
// FIXME: Move the InterruptsState enum and related functions inside the Processor class.
|
||||
enum class InterruptsState {
|
||||
Enabled,
|
||||
Disabled
|
||||
};
|
||||
|
||||
InterruptsState processor_interrupts_state();
|
||||
void restore_processor_interrupts_state(InterruptsState);
|
||||
|
||||
}
|
||||
|
||||
#if ARCH(X86_64) || ARCH(I386)
|
||||
# include <Kernel/Arch/x86/Processor.h>
|
||||
#elif ARCH(AARCH64)
|
||||
|
|
|
@ -329,6 +329,8 @@ set(KERNEL_SOURCES
|
|||
if ("${SERENITY_ARCH}" STREQUAL "i686" OR "${SERENITY_ARCH}" STREQUAL "x86_64")
|
||||
set(KERNEL_SOURCES
|
||||
${KERNEL_SOURCES}
|
||||
Arch/Processor.cpp
|
||||
|
||||
Arch/x86/common/ScopedCritical.cpp
|
||||
Arch/x86/common/SmapDisabler.cpp
|
||||
Arch/x86/common/Spinlock.cpp
|
||||
|
@ -443,6 +445,8 @@ else()
|
|||
${AK_SOURCES}
|
||||
${RPI_SOURCES}
|
||||
|
||||
Arch/Processor.cpp
|
||||
|
||||
Arch/aarch64/boot.S
|
||||
Arch/aarch64/BootPPMParser.cpp
|
||||
Arch/aarch64/CrashHandler.cpp
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue