blob: 7844487cacec24e712ab31cca2d4b4cdfdf07dab (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#include "panic.h"
#include <lib/kstdio.h>
#include <stdbool.h>
static char const *reason_strings[] = {
"general panic",
"unhandled fault",
"out of memory",
"dead-end routine"
};
noreturn void panic(const char *file, int line, enum panic_reason reason)
{
// TODO: kprintf() and friends
if (reason > sizeof(reason_strings) / sizeof(*reason_strings))
{
reason = 0;
}
kprintf(
"kernel panic:%s:%u %s\n",
file,
line,
reason_strings[reason]);
halt();
}
noreturn void halt(void)
{
__asm__ ("cli\n\t");
while (true) __asm__ ("hlt\n\t");
}
|