//----------------------------------------------------------------------------// // GNU GPL OS/K // // // // Authors: spectral` // // NeoX // // // // Desc: How NOT to panic 101 // //----------------------------------------------------------------------------// #include "kernel/ke/panic.h" #include "kernel/ke/state.h" #include "kernel/io/terminal.h" // // Panic message // const char *panicstr = NULL; // // Failed assert() handler // noreturn void ___assert_handler(const char *msg, const char *file, int line, const char *func) { // not getting out of here DosDisableInterrupts(); (void)file; (void)line; (void)func; // XXX sprintf() to create a proper panicstr DosPanic(msg); } // // Your best boy panic() // void DosPanic(const char *str) { DosDisableInterrupts(); DosSetKernState(KSTATE_PANIC); DosClearTerm(stdout); if (str == NULL) { str = "(no message given)"; } if (panicstr) { // shouldn't be possible DosPrintOnTerm(stdout, "double panic!\n"); DosHaltCPU(); } panicstr = str; DosPrintOnTerm(stdout, "panic! - "); DosPrintOnTerm(stdout, str); while (TRUE) { DosHaltCPU(); } }