//----------------------------------------------------------------------------// // GNU GPL OS/K // // // // Authors: spectral` // // NeoX // // // // Desc: How NOT to panic 101 // //----------------------------------------------------------------------------// #include #include #define _UNLOCKED_IO #include // // Panic message // const char *__panicmsg = 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_Unlocked(stdout); if (str == NULL) { str = "(no message given)"; } if (DosGetPanicStr()) { DosPrintOnTerm_Unlocked(stdout, "double panic!\n"); DosHaltCPU(); } DosSetPanicStr(str); // we cannot lock anything when panicking DosPrintOnTerm_Unlocked(stdout, "panic! - "); DosPrintOnTerm_Unlocked(stdout, str); while (TRUE) { DosHaltCPU(); } }