From 0b8396b1a627d83fb31d465c040fb00d92703f57 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Wed, 9 Aug 2023 09:57:02 +0300 Subject: [PATCH] Kernel: IDT now sends EOI for every interrupt EOI is sent before calling the interrupt handler. This should be fine since all interrupts are processed with interrupts disabled --- kernel/arch/x86_64/IDT.cpp | 21 ++++++++------------- kernel/kernel/Scheduler.cpp | 3 --- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/kernel/arch/x86_64/IDT.cpp b/kernel/arch/x86_64/IDT.cpp index 72216b9a35..980d086bee 100644 --- a/kernel/arch/x86_64/IDT.cpp +++ b/kernel/arch/x86_64/IDT.cpp @@ -213,7 +213,7 @@ namespace IDT extern "C" void cpp_irq_handler(uint64_t irq, Kernel::InterruptStack& interrupt_stack) { - bool from_userspace = (interrupt_stack.cs & 0b11) & 0b11; + bool from_userspace = (interrupt_stack.cs & 0b11) == 0b11; if (from_userspace) Kernel::Thread::current().save_sse(); @@ -224,21 +224,16 @@ namespace IDT Kernel::Thread::current().set_return_rip(interrupt_stack.rip); } - if (s_irq_handlers[irq]) - s_irq_handlers[irq](); + if (!InterruptController::get().is_in_service(irq)) + dprintln("spurious irq 0x{2H}", irq); else { - if (!InterruptController::get().is_in_service(irq)) - { - dprintln("spurious irq 0x{2H}", irq); - return; - } - dprintln("no handler for irq 0x{2H}\n", irq); - } - - // NOTE: Scheduler sends PIT eoi's - if (irq != PIT_IRQ) InterruptController::get().eoi(irq); + if (s_irq_handlers[irq]) + s_irq_handlers[irq](); + else + dprintln("no handler for irq 0x{2H}\n", irq); + } Kernel::Scheduler::get().reschedule_if_idling(); diff --git a/kernel/kernel/Scheduler.cpp b/kernel/kernel/Scheduler.cpp index e9849ffc49..b67ce3f281 100644 --- a/kernel/kernel/Scheduler.cpp +++ b/kernel/kernel/Scheduler.cpp @@ -69,9 +69,6 @@ namespace Kernel { VERIFY_CLI(); - ASSERT(InterruptController::get().is_in_service(PIT_IRQ)); - InterruptController::get().eoi(PIT_IRQ); - wake_threads(); if (save_current_thread())