60 lines
1.4 KiB
C
60 lines
1.4 KiB
C
//----------------------------------------------------------------------------//
|
|
// GNU GPL OS/K //
|
|
// //
|
|
// Authors: spectral` //
|
|
// NeoX //
|
|
// //
|
|
// Desc: How NOT to panic 101 //
|
|
//----------------------------------------------------------------------------//
|
|
|
|
#include "kernel/ke/panic.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
|
|
cli();
|
|
|
|
(void)file; (void)line; (void)func;
|
|
|
|
// XXX sprintf() to create a proper panicstr
|
|
panic(msg);
|
|
}
|
|
|
|
//
|
|
// Your best boy panic()
|
|
//
|
|
void panic(const char *str)
|
|
{
|
|
cli();
|
|
|
|
ktclear();
|
|
|
|
if (str == NULL) {
|
|
str = "(no message given)";
|
|
}
|
|
|
|
if (panicstr) {
|
|
// shouldn't be possible
|
|
ktprint("double panic!\n");
|
|
hlt();
|
|
}
|
|
|
|
panicstr = str;
|
|
|
|
ktprint("panic! - ");
|
|
ktprint(str);
|
|
|
|
while (TRUE) {
|
|
hlt();
|
|
}
|
|
}
|
|
|