This commit is contained in:
Alex 2023-02-24 10:15:05 +02:00
parent f767d950c4
commit 62e9d7b9c9
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
4 changed files with 33 additions and 20 deletions

View File

@ -284,7 +284,7 @@ namespace InterruptDescriptorTable
INTERRUPT_HANDLER(0x3a) INTERRUPT_HANDLER(0x3a)
INTERRUPT_HANDLER(0x3b) INTERRUPT_HANDLER(0x3b)
INTERRUPT_HANDLER(0x3c) INTERRUPT_HANDLER(0x3c)
EXCEPTION_HANDLER(0x3d) INTERRUPT_HANDLER(0x3d)
/* Free */ /* Free */

View File

@ -724,19 +724,33 @@ namespace CrashHandler
SafeFunction void StopAllCores() SafeFunction void StopAllCores()
{ {
#if defined(__amd64__) || defined(__i386__) #if defined(__amd64__) || defined(__i386__)
if (SMP::CPUCores > 1) /* FIXME: Can't send IPIs to other cores
{ * because it causes another exception on
CPU::Interrupts(CPU::Enable); * the other cores.
for (int i = 1; i < SMP::CPUCores; i++) *
{ * Also it makes every core to stay at 100% usage for some reason.
APIC::InterruptCommandRegisterLow icr; */
icr.Vector = CPU::x86::IRQ29;
icr.Level = APIC::APICLevel::Assert; // if (SMP::CPUCores > 1)
((APIC::APIC *)Interrupts::apic[0])->IPI(i, icr); // {
__sync; // for (int i = 1; i < SMP::CPUCores; i++)
} // {
CPU::Interrupts(CPU::Disable); // 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__) #elif defined(__aarch64__)
#endif #endif
} }
@ -748,9 +762,6 @@ namespace CrashHandler
SBIdx = 255; SBIdx = 255;
CHArchTrapFrame *Frame = (CHArchTrapFrame *)Data; CHArchTrapFrame *Frame = (CHArchTrapFrame *)Data;
#if defined(__amd64__) #if defined(__amd64__)
if (Frame->InterruptNumber == CPU::x86::IRQ29)
CPU::Stop();
error("An exception occurred!"); error("An exception occurred!");
error("Exception: %#llx", Frame->InterruptNumber); error("Exception: %#llx", Frame->InterruptNumber);
for (size_t i = 0; i < INT_FRAMES_MAX; i++) for (size_t i = 0; i < INT_FRAMES_MAX; i++)

View File

@ -107,7 +107,7 @@ namespace Interrupts
SafeFunction void RemoveAll() SafeFunction void RemoveAll()
{ {
for (int i = 0; i < CPU::x86::IRQ223; i++) for (int i = 0; i < CPU::x86::IRQ223; i++)
RegisteredEvents->DeleteNode(i); RegisteredEvents->DeleteNode(i);
} }
extern "C" SafeFunction void MainInterruptHandler(void *Data) extern "C" SafeFunction void MainInterruptHandler(void *Data)
@ -117,7 +117,7 @@ namespace Interrupts
memmove(InterruptFrames + 1, InterruptFrames, sizeof(InterruptFrames) - sizeof(InterruptFrames[0])); memmove(InterruptFrames + 1, InterruptFrames, sizeof(InterruptFrames) - sizeof(InterruptFrames[0]));
InterruptFrames[0] = (void *)Frame->rip; InterruptFrames[0] = (void *)Frame->rip;
CPUData *CoreData = GetCurrentCPU(); CPUData *CoreData = GetCurrentCPU();
int Core = 0; int Core = 0;
if (likely(CoreData != nullptr)) if (likely(CoreData != nullptr))
@ -126,6 +126,9 @@ namespace Interrupts
// If this is false, we have a big problem. // If this is false, we have a big problem.
if (likely(Frame->InterruptNumber < CPU::x86::IRQ223 && Frame->InterruptNumber > CPU::x86::ISR0)) 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); Handler *handler = (Handler *)RegisteredEvents->Get(Frame->InterruptNumber);
if (likely(handler != (Handler *)HASHMAP_ERROR)) if (likely(handler != (Handler *)HASHMAP_ERROR))
handler->OnInterruptReceived(Frame); handler->OnInterruptReceived(Frame);

View File

@ -42,7 +42,6 @@ namespace Time
Clock ConvertFromUnix(int Timestamp) Clock ConvertFromUnix(int Timestamp)
{ {
Clock result; Clock result;
if (Timestamp == 0) if (Timestamp == 0)
return result; return result;