From 8139688ef171b9826dba3ace4ea06592b60be390 Mon Sep 17 00:00:00 2001 From: Liav A Date: Thu, 9 Apr 2020 20:16:51 +0300 Subject: [PATCH] Kernel: Simplify the Interrupt management initialization --- Kernel/Interrupts/InterruptManagement.cpp | 6 ++++++ Kernel/init.cpp | 25 +---------------------- 2 files changed, 7 insertions(+), 24 deletions(-) diff --git a/Kernel/Interrupts/InterruptManagement.cpp b/Kernel/Interrupts/InterruptManagement.cpp index da597beb32..85bd0d489c 100644 --- a/Kernel/Interrupts/InterruptManagement.cpp +++ b/Kernel/Interrupts/InterruptManagement.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -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 callback) diff --git a/Kernel/init.cpp b/Kernel/init.cpp index 2f474b85cd..1fc2689dc8 100644 --- a/Kernel/init.cpp +++ b/Kernel/init.cpp @@ -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")) {