mirror of
https://gitlab.os-k.eu/os-k-team/os-k.git
synced 2023-08-25 14:03:10 +02:00
70 lines
1.7 KiB
C
70 lines
1.7 KiB
C
//----------------------------------------------------------------------------//
|
|
// GNU GPL OS/K //
|
|
// //
|
|
// Authors: spectral` //
|
|
// NeoX //
|
|
// //
|
|
// Desc: How NOT to panic 101 //
|
|
//----------------------------------------------------------------------------//
|
|
|
|
#define _UNLOCKED_IO
|
|
#include <kaleid.h>
|
|
|
|
//
|
|
// Failed assert() handler
|
|
//
|
|
noreturn void _assert_handler(const char *msg,
|
|
const char *file,
|
|
int line,
|
|
const char *func)
|
|
{
|
|
DisableIRQs();
|
|
|
|
(void)file; (void)line; (void)func;
|
|
|
|
// XXX sprintf() to create a proper panicstr
|
|
StartPanic(msg);
|
|
}
|
|
|
|
//
|
|
// Your best boy panic()
|
|
// This is CPU local...
|
|
//
|
|
noreturn void StartPanic(const char *str)
|
|
{
|
|
DisableIRQs();
|
|
|
|
SetKernState(KSTATE_PANIC);
|
|
|
|
if (GetCurProc()) __CurProc[GetCurCPU()] = NULL;
|
|
if (GetStdOut() == NULL) CrashSystem();
|
|
|
|
GetStdOut()->ClearTermUnlocked(GetStdOut());
|
|
|
|
if (str == NULL) {
|
|
str = "(no message given)";
|
|
}
|
|
|
|
if (GetPanicStr()) {
|
|
GetStdOut()->PrintOnTermUnlocked(GetStdOut(), "double panic!\n");
|
|
HaltCPU();
|
|
}
|
|
|
|
SetPanicStr(str);
|
|
|
|
GetStdOut()->PrintOnTermUnlocked(GetStdOut(), "PANIC! - ");
|
|
GetStdOut()->PrintOnTermUnlocked(GetStdOut(), str);
|
|
|
|
HaltCPU();
|
|
}
|
|
|
|
//
|
|
// Oh well
|
|
//
|
|
noreturn void CrashSystem(void)
|
|
{
|
|
DisableIRQs();
|
|
HaltCPU();
|
|
}
|
|
|