/* * Copyright (c) 2021, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #include #include #include #include #include #include #include namespace Kernel { void __panic(char const* file, unsigned int line, char const* function) { // Avoid lock ranking checks on crashing paths, just try to get some debugging messages out. auto* thread = Thread::current(); if (thread) thread->set_crashing(); critical_dmesgln("at {}:{} in {}", file, line, function); dump_backtrace(PrintToScreen::Yes); if (!CommandLine::was_initialized()) Processor::halt(); switch (kernel_command_line().panic_mode()) { case PanicMode::Shutdown: arch_specific_poweroff(PowerOffOrRebootReason::SystemFailure); // Note: If we failed to invoke platform shutdown, we need to halt afterwards // to ensure no further execution on any CPU still happens. [[fallthrough]]; case PanicMode::Halt: default: Processor::halt(); } } }