This commit is contained in:
trimill 2024-01-29 16:27:03 -05:00
parent 00bc8cdb97
commit e57c64c0e9
No known key found for this signature in database
GPG key ID: 4F77A16E17E10BCB
2 changed files with 26 additions and 0 deletions

8
include/panic.h Normal file
View file

@ -0,0 +1,8 @@
#pragma once
#define _PANIC_STR(x) _PANIC_STR2(x)
#define _PANIC_STR2(x) #x
#define panic(msg) _panic_impl(_PANIC_STR(__LINE__), __FILE__, msg)
_Noreturn void _panic_impl(char *line, char *file, char *msg);

18
src/arch/amd64/panic.c Normal file
View file

@ -0,0 +1,18 @@
#include <panic.h>
#include "serial.h"
#include "bindings.h"
_Noreturn void _panic_impl(char *line, char *file, char *msg) {
cli();
serial_out_str("\n\n!!! PANIC !!!\n");
serial_out_str(msg);
serial_out_str("\nin file ");
serial_out_str(file);
serial_out_str(" at line ");
serial_out_str(line);
serial_out('\n');
while (1) {
halt();
}
}