Kernel: Improve kernel panic message and rename it 'panic'->'Panic'
This commit is contained in:
31
kernel/include/kernel/Panic.h
Normal file
31
kernel/include/kernel/Panic.h
Normal file
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include <kernel/kprint.h>
|
||||
#include <kernel/Serial.h>
|
||||
#include <kernel/VESA.h>
|
||||
|
||||
#define Panic(...) PanicImpl(__FILE__, __LINE__, __VA_ARGS__)
|
||||
|
||||
namespace Kernel
|
||||
{
|
||||
|
||||
template<typename... Args>
|
||||
__attribute__((__noreturn__))
|
||||
static void PanicImpl(const char* file, int line, const char* message, Args... args)
|
||||
{
|
||||
if (VESA::IsInitialized())
|
||||
{
|
||||
kprint("\e[31mKernel panic at {}:{}\n", file, line);
|
||||
kprint(message, args...);
|
||||
kprint("\e[m\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
derrorln("Kernel panic at {}:{}", file, line);
|
||||
derrorln(message, args...);
|
||||
}
|
||||
asm volatile("cli; hlt");
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -26,6 +26,7 @@ namespace VESA
|
||||
};
|
||||
|
||||
bool Initialize();
|
||||
bool IsInitialized();
|
||||
void PutBitmapAt(const uint8_t*, uint32_t, uint32_t, Color);
|
||||
void PutBitmapAt(const uint8_t*, uint32_t, uint32_t, Color, Color);
|
||||
void PutCharAt(uint16_t, uint32_t, uint32_t, Color, Color);
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
#include <BAN/Formatter.h>
|
||||
#include <kernel/TTY.h>
|
||||
|
||||
#define kprint(...) BAN::Formatter::print(TTY::PutCharCurrent, __VA_ARGS__)
|
||||
#define kprint(...) BAN::Formatter::print(TTY::PutCharCurrent, __VA_ARGS__)
|
||||
#define kprintln(...) BAN::Formatter::println(TTY::PutCharCurrent, __VA_ARGS__)
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <kernel/kprint.h>
|
||||
|
||||
namespace Kernel
|
||||
{
|
||||
|
||||
template<typename... Args>
|
||||
__attribute__((__noreturn__))
|
||||
static void panic(const char* message, Args... args)
|
||||
{
|
||||
kprint("\e[31mKernel panic: ");
|
||||
kprint(message, args...);
|
||||
kprint("\e[m\n");
|
||||
asm volatile("cli; hlt");
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user