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
|
|
|
|
2023-02-01 21:05:44 +02:00
|
|
|
#define panic(...) detail::panic_impl(__FILE__, __LINE__, __VA_ARGS__)
|
2023-01-09 14:56:20 +02:00
|
|
|
|
|
|
|
namespace Kernel
|
|
|
|
{
|
|
|
|
|
2023-02-01 21:05:44 +02:00
|
|
|
namespace detail
|
2023-01-09 14:56:20 +02:00
|
|
|
{
|
2023-02-01 21:05:44 +02:00
|
|
|
template<typename... Args>
|
|
|
|
__attribute__((__noreturn__))
|
|
|
|
static void panic_impl(const char* file, int line, const char* message, Args... args)
|
|
|
|
{
|
2023-03-01 20:16:26 +02:00
|
|
|
asm volatile("cli");
|
2023-02-01 21:05:44 +02:00
|
|
|
derrorln("Kernel panic at {}:{}", file, line);
|
|
|
|
derrorln(message, args...);
|
|
|
|
Debug::dump_stack_trace();
|
|
|
|
for (;;)
|
|
|
|
asm volatile("hlt");
|
|
|
|
__builtin_unreachable();
|
|
|
|
}
|
2023-01-09 14:56:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|