2023-01-09 14:56:20 +02:00
|
|
|
#pragma once
|
|
|
|
|
2023-01-25 21:39:03 +02:00
|
|
|
#include <kernel/Debug.h>
|
2023-01-09 14:56:20 +02:00
|
|
|
#include <kernel/kprint.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)
|
|
|
|
{
|
2023-01-25 22:28:18 +02:00
|
|
|
derrorln("Kernel panic at {}:{}", file, line);
|
2023-01-16 15:44:27 +02:00
|
|
|
derrorln(message, args...);
|
2023-01-25 22:28:18 +02:00
|
|
|
Debug::DumpStackTrace();
|
2023-01-23 18:25:48 +02:00
|
|
|
asm volatile("cli");
|
|
|
|
for (;;)
|
|
|
|
asm volatile("hlt");
|
2023-01-09 14:56:20 +02:00
|
|
|
__builtin_unreachable();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|