Track kernel panic state
Some checks failed
Builds / ExectOS (i686, release) (push) Failing after 31s
Builds / ExectOS (amd64, debug) (push) Failing after 41s
Builds / ExectOS (i686, debug) (push) Failing after 33s
Builds / ExectOS (amd64, release) (push) Failing after 39s

This commit is contained in:
2026-06-06 18:52:05 +02:00
parent cf25af23d1
commit 537fbc8af4
2 changed files with 27 additions and 0 deletions

View File

@@ -17,6 +17,9 @@ namespace KE
{ {
class Crash class Crash
{ {
private:
STATIC BOOLEAN KernelPanic;
public: public:
STATIC XTAPI VOID HaltSystem(VOID); STATIC XTAPI VOID HaltSystem(VOID);
STATIC XTAPI VOID Panic(IN ULONG Code); STATIC XTAPI VOID Panic(IN ULONG Code);
@@ -25,6 +28,7 @@ namespace KE
IN ULONG_PTR Parameter2, IN ULONG_PTR Parameter2,
IN ULONG_PTR Parameter3, IN ULONG_PTR Parameter3,
IN ULONG_PTR Parameter4); IN ULONG_PTR Parameter4);
STATIC XTAPI BOOLEAN SystemCrashed(VOID);
}; };
} }

View File

@@ -4,6 +4,7 @@
* FILE: xtoskrnl/ke/panic.cc * FILE: xtoskrnl/ke/panic.cc
* DESCRIPTION: System shutdown and kernel panic mechanism * DESCRIPTION: System shutdown and kernel panic mechanism
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org> * DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
* Aiken Harris <harraiken91@gmail.com>
*/ */
#include <xtos.hh> #include <xtos.hh>
@@ -43,6 +44,7 @@ XTAPI
VOID VOID
KE::Crash::Panic(IN ULONG Code) KE::Crash::Panic(IN ULONG Code)
{ {
/* Call panic function */
Panic(Code, 0, 0, 0, 0); Panic(Code, 0, 0, 0, 0);
} }
@@ -76,7 +78,28 @@ KE::Crash::Panic(IN ULONG Code,
IN ULONG_PTR Parameter3, IN ULONG_PTR Parameter3,
IN ULONG_PTR Parameter4) IN ULONG_PTR Parameter4)
{ {
/* Set kernel panic state */
KernelPanic = TRUE;
/* Print error message to debug console */
KD::DebugIo::KdPrint(L"Fatal System Error: 0x%08lx (0x%zx 0x%zx 0x%zx 0x%zx)\nKernel Panic!\n\n", KD::DebugIo::KdPrint(L"Fatal System Error: 0x%08lx (0x%zx 0x%zx 0x%zx 0x%zx)\nKernel Panic!\n\n",
Code, Parameter1, Parameter2, Parameter3, Parameter4); Code, Parameter1, Parameter2, Parameter3, Parameter4);
/* Halt system */
HaltSystem(); HaltSystem();
} }
/**
* Determines whether the system has experienced a fatal error and entered a kernel panic state.
*
* @return This routine returns TRUE if the system has halted due to a kernel panic, or FALSE otherwise.
*
* @since XT 1.0
*/
XTAPI
BOOLEAN
KE::Crash::SystemCrashed(VOID)
{
/* Return kernel panic state */
return KernelPanic;
}