Kernel: Simplify the Interrupt management initialization

This commit is contained in:
Liav A 2020-04-09 20:16:51 +03:00 committed by Andreas Kling
parent caa7a6c2fb
commit 8139688ef1
Notes: sideshowbarker 2024-07-19 07:46:30 +09:00
2 changed files with 7 additions and 24 deletions

View file

@ -28,6 +28,7 @@
#include <AK/StringView.h>
#include <Kernel/ACPI/MultiProcessorParser.h>
#include <Kernel/Arch/i386/CPU.h>
#include <Kernel/CommandLine.h>
#include <Kernel/Interrupts/APIC.h>
#include <Kernel/Interrupts/IOAPIC.h>
#include <Kernel/Interrupts/InterruptManagement.h>
@ -59,6 +60,11 @@ void InterruptManagement::initialize()
{
ASSERT(!InterruptManagement::initialized());
s_interrupt_management = new InterruptManagement();
if (kernel_command_line().lookup("smp").value_or("off") == "on")
InterruptManagement::the().switch_to_ioapic_mode();
else
InterruptManagement::the().switch_to_pic_mode();
}
void InterruptManagement::enumerate_interrupt_handlers(Function<void(GenericInterruptHandler&)> callback)

View file

@ -85,7 +85,6 @@ namespace Kernel {
[[noreturn]] static void init_stage2();
static void setup_serial_debug();
static void setup_interrupts();
static void setup_time_management();
VirtualConsole* tty0;
@ -121,7 +120,7 @@ extern "C" [[noreturn]] void init()
for (ctor_func_t* ctor = &start_ctors; ctor < &end_ctors; ctor++)
(*ctor)();
setup_interrupts();
InterruptManagement::initialize();
ACPI::initialize();
new VFS;
@ -358,28 +357,6 @@ extern "C" int __cxa_atexit(void (*)(void*), void*, void*)
return 0;
}
void setup_interrupts()
{
InterruptManagement::initialize();
if (!kernel_command_line().contains("smp")) {
InterruptManagement::the().switch_to_pic_mode();
return;
}
auto smp = kernel_command_line().get("smp");
if (smp == "off") {
InterruptManagement::the().switch_to_pic_mode();
return;
}
if (smp == "on") {
InterruptManagement::the().switch_to_ioapic_mode();
return;
}
klog() << "smp boot argmuent has an invalid value.";
hang();
}
void setup_time_management()
{
if (!kernel_command_line().contains("time")) {