summaryrefslogtreecommitdiff
path: root/kernel/src/print/panic.c
blob: 58ffe40ceb9b04fcaa304790694e0345139f0cbc (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
#include <sys.h>
#include <stdarg.h>
#include <stdlib.h>
#include <panic.h>
#include <print.h>

#include "tty/color.h"
#include "tty/term.h"

__attribute__((noreturn))
void _panic_impl(char* msg, int line, char* file, ...) {
	int_disable();
	va_list args;
	va_start(args, file);
	term_clear();
	term_setpos(0, 0);
    term_setfg(VGA_LIGHT_RED);
	puts("!!!PANIC!!!\n");
    term_setfg(VGA_WHITE);
	vprintk(msg, args);
    if (!term_newline()) putchar('\n');
	printk("\nin %s at line %d\n", file, line);
    term_flush();
	while(1) {
		halt();
	}
}