From 1fa6e90439bc4b8371e412f67898f263b78289ec Mon Sep 17 00:00:00 2001 From: Aiken Harris Date: Wed, 8 Apr 2026 23:16:03 +0200 Subject: [PATCH] Hook up profile interrupt handler --- xtoskrnl/hl/amd64/irq.cc | 66 +++++++++++++++++++++++-------------- xtoskrnl/hl/i686/irq.cc | 66 +++++++++++++++++++++++-------------- xtoskrnl/hl/x86/pic.cc | 1 + xtoskrnl/includes/hl/irq.hh | 3 +- 4 files changed, 87 insertions(+), 49 deletions(-) diff --git a/xtoskrnl/hl/amd64/irq.cc b/xtoskrnl/hl/amd64/irq.cc index 5d3ffdb..963b3ba 100644 --- a/xtoskrnl/hl/amd64/irq.cc +++ b/xtoskrnl/hl/amd64/irq.cc @@ -10,6 +10,48 @@ #include +/** + * Handles profiling interrupt. + * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common interrupt handler. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTCDECL +VOID +HL::Irq::HandleProfileInterrupt(IN PKTRAP_FRAME TrapFrame) +{ + /* Send EOI*/ + HL::Pic::SendEoi(); +} + +/** + * Handles unexpected or unmapped system interrupts. + * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common interrupt handler. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTCDECL +VOID +HL::Irq::HandleUnexpectedInterrupt(IN PKTRAP_FRAME TrapFrame) +{ + UNIMPLEMENTED; + + /* Disable interrupts */ + AR::CpuFunc::ClearInterruptFlag(); + + /* Print debug message and raise kernel panic */ + DebugPrint(L"ERROR: Caught unexpected interrupt (0x%.2llX)!\n", TrapFrame->Vector); + KE::Crash::Panic(0x47, TrapFrame->Vector, 0, 0, 0); +} + /** * Returns the registered interrupt handler for the specified IDT vector. * @@ -118,27 +160,3 @@ HL::Irq::RegisterSystemInterruptHandler(IN ULONG Vector, /* Update interrupt handler in the processor's interrupt dispatch table */ ProcessorBlock->InterruptDispatchTable[Vector] = Handler; } - -/** - * Handles unexpected or unmapped system interrupts. - * - * @param TrapFrame - * Supplies a kernel trap frame pushed by common interrupt handler. - * - * @return This routine does not return any value. - * - * @since XT 1.0 - */ -XTCDECL -VOID -HL::Irq::HandleUnexpectedInterrupt(IN PKTRAP_FRAME TrapFrame) -{ - UNIMPLEMENTED; - - /* Disable interrupts */ - AR::CpuFunc::ClearInterruptFlag(); - - /* Print debug message and raise kernel panic */ - DebugPrint(L"ERROR: Caught unexpected interrupt (0x%.2llX)!\n", TrapFrame->Vector); - KE::Crash::Panic(0x47, TrapFrame->Vector, 0, 0, 0); -} diff --git a/xtoskrnl/hl/i686/irq.cc b/xtoskrnl/hl/i686/irq.cc index b7111ec..03b95df 100644 --- a/xtoskrnl/hl/i686/irq.cc +++ b/xtoskrnl/hl/i686/irq.cc @@ -10,6 +10,48 @@ #include +/** + * Handles profiling interrupt. + * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common interrupt handler. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTCDECL +VOID +HL::Irq::HandleProfileInterrupt(IN PKTRAP_FRAME TrapFrame) +{ + /* Send EOI*/ + HL::Pic::SendEoi(); +} + +/** + * Handles unexpected or unmapped system interrupts. + * + * @param TrapFrame + * Supplies a kernel trap frame pushed by common interrupt handler. + * + * @return This routine does not return any value. + * + * @since XT 1.0 + */ +XTCDECL +VOID +HL::Irq::HandleUnexpectedInterrupt(IN PKTRAP_FRAME TrapFrame) +{ + UNIMPLEMENTED; + + /* Disable interrupts */ + AR::CpuFunc::ClearInterruptFlag(); + + /* Print debug message and raise kernel panic */ + DebugPrint(L"ERROR: Caught unexpected interrupt (0x%.2lX)!\n", TrapFrame->Vector); + KE::Crash::Panic(0x47, TrapFrame->Vector, 0, 0, 0); +} + /** * Returns the registered interrupt handler for the specified IDT vector. * @@ -116,27 +158,3 @@ HL::Irq::RegisterSystemInterruptHandler(IN ULONG Vector, /* Update interrupt handler in the processor's interrupt dispatch table */ ProcessorBlock->InterruptDispatchTable[Vector] = Handler; } - -/** - * Handles unexpected or unmapped system interrupts. - * - * @param TrapFrame - * Supplies a kernel trap frame pushed by common interrupt handler. - * - * @return This routine does not return any value. - * - * @since XT 1.0 - */ -XTCDECL -VOID -HL::Irq::HandleUnexpectedInterrupt(IN PKTRAP_FRAME TrapFrame) -{ - UNIMPLEMENTED; - - /* Disable interrupts */ - AR::CpuFunc::ClearInterruptFlag(); - - /* Print debug message and raise kernel panic */ - DebugPrint(L"ERROR: Caught unexpected interrupt (0x%.2lX)!\n", TrapFrame->Vector); - KE::Crash::Panic(0x47, TrapFrame->Vector, 0, 0, 0); -} diff --git a/xtoskrnl/hl/x86/pic.cc b/xtoskrnl/hl/x86/pic.cc index d20abb1..c785e03 100644 --- a/xtoskrnl/hl/x86/pic.cc +++ b/xtoskrnl/hl/x86/pic.cc @@ -224,6 +224,7 @@ HL::Pic::InitializeApic(VOID) /* Register interrupt handlers */ HL::Irq::RegisterInterruptHandler(APIC_VECTOR_SPURIOUS, (PVOID)ArHandleSpuriousInterrupt); + HL::Irq::RegisterSystemInterruptHandler(APIC_VECTOR_PROFILE, HL::Irq::HandleProfileInterrupt); /* Clear any pre-existing errors */ WriteApicRegister(APIC_ESR, 0); diff --git a/xtoskrnl/includes/hl/irq.hh b/xtoskrnl/includes/hl/irq.hh index c1398ce..a6ed759 100644 --- a/xtoskrnl/includes/hl/irq.hh +++ b/xtoskrnl/includes/hl/irq.hh @@ -18,9 +18,10 @@ namespace HL class Irq { public: + STATIC XTCDECL VOID HandleProfileInterrupt(IN PKTRAP_FRAME TrapFrame); + STATIC XTCDECL VOID HandleUnexpectedInterrupt(IN PKTRAP_FRAME TrapFrame); STATIC XTAPI PVOID QueryInterruptHandler(IN ULONG Vector); STATIC XTAPI PVOID QuerySystemInterruptHandler(IN ULONG Vector); - STATIC XTCDECL VOID HandleUnexpectedInterrupt(IN PKTRAP_FRAME TrapFrame); STATIC XTAPI VOID RegisterInterruptHandler(IN ULONG Vector, IN PVOID Handler); STATIC XTAPI VOID RegisterSystemInterruptHandler(IN ULONG Vector,