diff --git a/xtoskrnl/CMakeLists.txt b/xtoskrnl/CMakeLists.txt index 7e7bef9..61c28b3 100644 --- a/xtoskrnl/CMakeLists.txt +++ b/xtoskrnl/CMakeLists.txt @@ -23,6 +23,7 @@ list(APPEND XTOSKRNL_SOURCE ${XTOSKRNL_SOURCE_DIR}/ke/kprocess.c ${XTOSKRNL_SOURCE_DIR}/ke/krnlinit.c ${XTOSKRNL_SOURCE_DIR}/ke/kthread.c + ${XTOSKRNL_SOURCE_DIR}/ke/panic.c ${XTOSKRNL_SOURCE_DIR}/ke/semphore.c ${XTOSKRNL_SOURCE_DIR}/ke/spinlock.c ${XTOSKRNL_SOURCE_DIR}/ke/timer.c diff --git a/xtoskrnl/ke/panic.c b/xtoskrnl/ke/panic.c new file mode 100644 index 0000000..cca6f62 --- /dev/null +++ b/xtoskrnl/ke/panic.c @@ -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 + */ + +#include + + +/** + * 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(); + } +}