forked from Bananymous/banan-os
Add kernel panic function
This commit is contained in:
parent
b185ed4fd3
commit
9e933a5ec5
|
@ -30,6 +30,7 @@ LIBS:=$(LIBS) $(KERNEL_ARCH_LIBS)
|
|||
KERNEL_OBJS=\
|
||||
$(KERNEL_ARCH_OBJS) \
|
||||
kernel/kernel.o \
|
||||
kernel/panic.o \
|
||||
kernel/ssp.o \
|
||||
|
||||
OBJS=\
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
namespace Kernel
|
||||
{
|
||||
|
||||
__attribute__((__noreturn__))
|
||||
void panic(const char* message);
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
#include <kernel/panic.h>
|
||||
#include <kernel/tty.h>
|
||||
|
||||
namespace Kernel
|
||||
{
|
||||
|
||||
__attribute__((__noreturn__))
|
||||
void panic(const char* message)
|
||||
{
|
||||
terminal_writestring("Kernel panic: ");
|
||||
terminal_writestring(message);
|
||||
asm volatile("hlt");
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,12 +1,15 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined(__is_libk)
|
||||
#include <kernel/panic.h>
|
||||
#endif
|
||||
|
||||
__attribute__((__noreturn__))
|
||||
void abort(void)
|
||||
{
|
||||
#if defined(__is_libk)
|
||||
printf("Kernel panic: abort()\n");
|
||||
asm volatile("hlt");
|
||||
Kernel::panic("abort()");
|
||||
#else
|
||||
printf("abort()\n");
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue