From 62e9d7b9c94ca79c41f0dc6f99080a1cb98c7f69 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 24 Feb 2023 10:15:05 +0200 Subject: [PATCH] fixme --- .../amd64/cpu/InterruptDescriptorTable.cpp | 2 +- Core/Crash/CrashHandler.cpp | 43 ++++++++++++------- Core/Interrupts/IntManager.cpp | 7 ++- Core/Time.cpp | 1 - 4 files changed, 33 insertions(+), 20 deletions(-) diff --git a/Architecture/amd64/cpu/InterruptDescriptorTable.cpp b/Architecture/amd64/cpu/InterruptDescriptorTable.cpp index 737d261..e14f2ab 100644 --- a/Architecture/amd64/cpu/InterruptDescriptorTable.cpp +++ b/Architecture/amd64/cpu/InterruptDescriptorTable.cpp @@ -284,7 +284,7 @@ namespace InterruptDescriptorTable INTERRUPT_HANDLER(0x3a) INTERRUPT_HANDLER(0x3b) INTERRUPT_HANDLER(0x3c) - EXCEPTION_HANDLER(0x3d) + INTERRUPT_HANDLER(0x3d) /* Free */ diff --git a/Core/Crash/CrashHandler.cpp b/Core/Crash/CrashHandler.cpp index cfe958c..1bd15c7 100644 --- a/Core/Crash/CrashHandler.cpp +++ b/Core/Crash/CrashHandler.cpp @@ -724,19 +724,33 @@ namespace CrashHandler SafeFunction void StopAllCores() { #if defined(__amd64__) || defined(__i386__) - if (SMP::CPUCores > 1) - { - CPU::Interrupts(CPU::Enable); - for (int i = 1; i < SMP::CPUCores; i++) - { - APIC::InterruptCommandRegisterLow icr; - icr.Vector = CPU::x86::IRQ29; - icr.Level = APIC::APICLevel::Assert; - ((APIC::APIC *)Interrupts::apic[0])->IPI(i, icr); - __sync; - } - CPU::Interrupts(CPU::Disable); - } + /* FIXME: Can't send IPIs to other cores + * because it causes another exception on + * the other cores. + * + * Also it makes every core to stay at 100% usage for some reason. + */ + + // if (SMP::CPUCores > 1) + // { + // for (int i = 1; i < SMP::CPUCores; i++) + // { + // APIC::InterruptCommandRegisterLow icr; + // icr.Vector = CPU::x86::IRQ29; + // icr.Level = APIC::APICLevel::Assert; + // ((APIC::APIC *)Interrupts::apic[i])->IPI(i, icr); + // __sync; + // } + // } + // APIC::InterruptCommandRegisterLow icr; + // icr.Vector = CPU::x86::IRQ29; + // icr.Level = APIC::APICLevel::Assert; + // icr.DestinationShorthand = APIC::APICDestinationShorthand::AllExcludingSelf; + // ((APIC::APIC *)Interrupts::apic[0])->IPI(0, icr); + // CPU::Interrupts(CPU::Enable); + __sync; + CPU::Interrupts(CPU::Disable); + // } #elif defined(__aarch64__) #endif } @@ -748,9 +762,6 @@ namespace CrashHandler SBIdx = 255; CHArchTrapFrame *Frame = (CHArchTrapFrame *)Data; #if defined(__amd64__) - if (Frame->InterruptNumber == CPU::x86::IRQ29) - CPU::Stop(); - error("An exception occurred!"); error("Exception: %#llx", Frame->InterruptNumber); for (size_t i = 0; i < INT_FRAMES_MAX; i++) diff --git a/Core/Interrupts/IntManager.cpp b/Core/Interrupts/IntManager.cpp index ec4a2f4..c99fa89 100644 --- a/Core/Interrupts/IntManager.cpp +++ b/Core/Interrupts/IntManager.cpp @@ -107,7 +107,7 @@ namespace Interrupts SafeFunction void RemoveAll() { for (int i = 0; i < CPU::x86::IRQ223; i++) - RegisteredEvents->DeleteNode(i); + RegisteredEvents->DeleteNode(i); } extern "C" SafeFunction void MainInterruptHandler(void *Data) @@ -117,7 +117,7 @@ namespace Interrupts memmove(InterruptFrames + 1, InterruptFrames, sizeof(InterruptFrames) - sizeof(InterruptFrames[0])); InterruptFrames[0] = (void *)Frame->rip; - + CPUData *CoreData = GetCurrentCPU(); int Core = 0; if (likely(CoreData != nullptr)) @@ -126,6 +126,9 @@ namespace Interrupts // If this is false, we have a big problem. if (likely(Frame->InterruptNumber < CPU::x86::IRQ223 && Frame->InterruptNumber > CPU::x86::ISR0)) { + if (Frame->InterruptNumber == CPU::x86::IRQ29) // Halt core interrupt + CPU::Stop(); + Handler *handler = (Handler *)RegisteredEvents->Get(Frame->InterruptNumber); if (likely(handler != (Handler *)HASHMAP_ERROR)) handler->OnInterruptReceived(Frame); diff --git a/Core/Time.cpp b/Core/Time.cpp index 142c711..5be77b5 100644 --- a/Core/Time.cpp +++ b/Core/Time.cpp @@ -42,7 +42,6 @@ namespace Time Clock ConvertFromUnix(int Timestamp) { - Clock result; if (Timestamp == 0) return result;