Files
exectos/xtoskrnl/ke/crash.cc
Aiken Harris 537fbc8af4
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
Track kernel panic state
2026-06-06 18:52:05 +02:00

106 lines
2.5 KiB
C++

/**
* PROJECT: ExectOS
* COPYRIGHT: See COPYING.md in the top level directory
* FILE: xtoskrnl/ke/panic.cc
* DESCRIPTION: System shutdown and kernel panic mechanism
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
* Aiken Harris <harraiken91@gmail.com>
*/
#include <xtos.hh>
/**
* Halts the system.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTAPI
VOID
KE::Crash::HaltSystem(VOID)
{
/* Enter infinite loop */
for(;;)
{
/* Halt system */
AR::CpuFunctions::ClearInterruptFlag();
AR::CpuFunctions::Halt();
}
}
/**
* Crashes the system upon detecting a fatal error in which either it is unable to recover or continue to run system.
*
* @param Code
* Specifies the reason for the kernel panic.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTAPI
VOID
KE::Crash::Panic(IN ULONG Code)
{
/* Call panic function */
Panic(Code, 0, 0, 0, 0);
}
/**
* Crashes the system upon detecting a fatal error in which either it is unable to recover or continue to run system.
*
* @param Code
* Specifies the reason for the kernel panic.
*
* @param Parameter1
* Supplies additional information about the kernel panic.
*
* @param Parameter2
* Supplies additional information about the kernel panic.
*
* @param Parameter3
* Supplies additional information about the kernel panic.
*
* @param Parameter4
* Supplies additional information about the kernel panic.
*
* @return This routine does not return any value.
*
* @since XT 1.0
*/
XTAPI
VOID
KE::Crash::Panic(IN ULONG Code,
IN ULONG_PTR Parameter1,
IN ULONG_PTR Parameter2,
IN ULONG_PTR Parameter3,
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",
Code, Parameter1, Parameter2, Parameter3, Parameter4);
/* Halt system */
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;
}