2021-02-14 09:01:52 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2021-02-14 09:01:52 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <AK/Format.h>
|
2021-06-21 17:34:09 +02:00
|
|
|
#include <Kernel/Arch/x86/Processor.h>
|
2021-07-26 00:10:41 +04:30
|
|
|
#include <Kernel/CommandLine.h>
|
2021-02-14 09:01:52 +01:00
|
|
|
#include <Kernel/KSyms.h>
|
|
|
|
|
#include <Kernel/Panic.h>
|
|
|
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
2021-07-26 00:10:41 +04:30
|
|
|
[[noreturn]] static void __reset()
|
|
|
|
|
{
|
|
|
|
|
// FIXME: This works for i686/x86_64, but needs to be ported to any other arch when needed.
|
|
|
|
|
asm(
|
|
|
|
|
"lidt 0\n"
|
|
|
|
|
"movl $0, 0\n");
|
|
|
|
|
|
|
|
|
|
__builtin_unreachable();
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-14 09:01:52 +01:00
|
|
|
void __panic(const char* file, unsigned int line, const char* function)
|
|
|
|
|
{
|
2021-04-16 22:58:51 +03:00
|
|
|
critical_dmesgln("at {}:{} in {}", file, line, function);
|
2021-02-14 09:01:52 +01:00
|
|
|
dump_backtrace();
|
2021-07-26 00:10:41 +04:30
|
|
|
if (kernel_command_line().boot_mode() == BootMode::SelfTest)
|
|
|
|
|
__reset();
|
|
|
|
|
else
|
|
|
|
|
Processor::halt();
|
2021-02-14 09:01:52 +01:00
|
|
|
}
|
|
|
|
|
}
|