summaryrefslogtreecommitdiff
path: root/kernel/panic.c
blob: 333be0de6b40cc53faeea914e700ccbae3e3a1aa (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
#include "panic.h"
#include "kprint.h"

#include <stdbool.h>

static char const *reason_strings[] = {
    "general panic",
    "unhandled fault",
};

noreturn void panic(enum panic_reason reason)
{
    // TODO: kprintf() and friends
    kputs("kernel panic: ");
    kputs(reason_strings[reason]);
    kputs("\n");
    halt();
}

noreturn void halt(void)
{
    __asm__ ("cli\n\t");
    while (true) __asm__ ("hlt\n\t");
}