From 550ecbc95190cca1ceec5d7114927f8712daf92d Mon Sep 17 00:00:00 2001 From: Bananymous Date: Wed, 16 Nov 2022 19:47:19 +0200 Subject: [PATCH] Kernel panic uses kprint with parameters --- kernel/Makefile | 3 +-- kernel/include/kernel/panic.h | 12 +++++++++++- kernel/kernel/panic.cpp | 15 --------------- 3 files changed, 12 insertions(+), 18 deletions(-) delete mode 100644 kernel/kernel/panic.cpp diff --git a/kernel/Makefile b/kernel/Makefile index 552fa0d7b4..1c28f559ad 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -13,7 +13,7 @@ EXEC_PREFIX?=$(PREFIX) BOOTDIR?=$(EXEC_PREFIX)/boot INCLUDEDIR?=$(PREFIX)/include -CFLAGS:=$(CFLAGS) -fstack-protector -ffreestanding -Wall -Wextra +CFLAGS:=$(CFLAGS) -fstack-protector -ffreestanding -Wall -Wextra -Wno-unused-function CPPFLAGS:=$(CPPFLAGS) -D__is_kernel -Iinclude LDFLAGS:=$(LDFLAGS) LIBS:=$(LIBS) -nostdlib -lk -lgcc @@ -30,7 +30,6 @@ LIBS:=$(LIBS) $(KERNEL_ARCH_LIBS) KERNEL_OBJS=\ $(KERNEL_ARCH_OBJS) \ kernel/kernel.o \ -kernel/panic.o \ kernel/SSP.o \ OBJS=\ diff --git a/kernel/include/kernel/panic.h b/kernel/include/kernel/panic.h index f461ffeaab..8b28396205 100644 --- a/kernel/include/kernel/panic.h +++ b/kernel/include/kernel/panic.h @@ -1,9 +1,19 @@ #pragma once +#include + namespace Kernel { + template __attribute__((__noreturn__)) - void panic(const char* message); + static void panic(const char* message, Args... args) + { + kprint("Kernel panic: "); + kprint(message, args...); + kprint("\n"); + asm volatile("hlt"); + __builtin_unreachable(); + } } \ No newline at end of file diff --git a/kernel/kernel/panic.cpp b/kernel/kernel/panic.cpp deleted file mode 100644 index 65a8ce71fa..0000000000 --- a/kernel/kernel/panic.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include -#include - -namespace Kernel -{ - - __attribute__((__noreturn__)) - void panic(const char* message) - { - kprint("Kernel panic: {}", message); - asm volatile("hlt"); - __builtin_unreachable(); - } - -}