kernel/src/panic.c

31 lines
590 B
C
Raw Normal View History

2017-11-08 04:49:30 +00:00
#include "panic.h"
2021-12-20 06:14:07 +00:00
#include <kernaux/asm/i386.h>
2022-06-23 10:51:42 +00:00
#include <kernaux/drivers/console.h>
2017-11-08 04:49:30 +00:00
2022-01-15 10:51:16 +00:00
static void poweroff()
{
kernaux_asm_i386_outportw(0x604, 0x2000);
}
2017-11-08 04:49:30 +00:00
void panic(const char *const s)
{
2022-06-23 10:51:42 +00:00
kernaux_drivers_console_printf("[FAIL] panic: %s\n", s);
2022-01-15 10:51:16 +00:00
poweroff();
2017-11-08 04:49:30 +00:00
}
void halt()
{
panic("Kernel main function returned.");
}
2021-12-14 23:53:05 +00:00
void kernaux_assert_fn(
const char *const file,
const int line,
const char *const str
) {
2022-06-23 10:51:42 +00:00
kernaux_drivers_console_printf("[FAIL] assertion failed: %s:%u: \"%s\"\n",
file, line, str);
2022-01-15 10:51:16 +00:00
poweroff();
2021-12-14 23:53:05 +00:00
}