Add initial kernel panic mechanism
Some checks failed
ci/woodpecker/push/build Pipeline failed

This commit is contained in:
Rafal Kupiec 2023-03-23 22:34:28 +01:00
parent 6402a0d0a4
commit d5dd87b889
Signed by: belliash
GPG Key ID: 4E829243E0CFE6B4
2 changed files with 66 additions and 0 deletions

View File

@ -23,6 +23,7 @@ list(APPEND XTOSKRNL_SOURCE
${XTOSKRNL_SOURCE_DIR}/ke/kprocess.c ${XTOSKRNL_SOURCE_DIR}/ke/kprocess.c
${XTOSKRNL_SOURCE_DIR}/ke/krnlinit.c ${XTOSKRNL_SOURCE_DIR}/ke/krnlinit.c
${XTOSKRNL_SOURCE_DIR}/ke/kthread.c ${XTOSKRNL_SOURCE_DIR}/ke/kthread.c
${XTOSKRNL_SOURCE_DIR}/ke/panic.c
${XTOSKRNL_SOURCE_DIR}/ke/semphore.c ${XTOSKRNL_SOURCE_DIR}/ke/semphore.c
${XTOSKRNL_SOURCE_DIR}/ke/spinlock.c ${XTOSKRNL_SOURCE_DIR}/ke/spinlock.c
${XTOSKRNL_SOURCE_DIR}/ke/timer.c ${XTOSKRNL_SOURCE_DIR}/ke/timer.c

65
xtoskrnl/ke/panic.c Normal file
View File

@ -0,0 +1,65 @@
/**
* PROJECT: ExectOS
* COPYRIGHT: See COPYING.md in the top level directory
* FILE: xtoskrnl/ke/panic.c
* DESCRIPTION: System shutdown and kernel panic mechanism
* DEVELOPERS: Rafal Kupiec <belliash@codingworkshop.eu.org>
*/
#include <xtos.h>
/**
* 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
KePanic(IN ULONG Code)
{
KePanicEx(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
KePanicEx(IN ULONG Code,
IN ULONG_PTR Parameter1,
IN ULONG_PTR Parameter2,
IN ULONG_PTR Parameter3,
IN ULONG_PTR Parameter4)
{
KeDbgPrint(L"Fatal System Error: 0x%08lx\nKernel Panic!\n\n", Code);
for(;;)
{
ArClearInterruptFlag();
ArHalt();
}
}