mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-28 14:02:51 +00:00
Everywhere: Move global Kernel pattern code to Kernel/Library directory
This has KString, KBuffer, DoubleBuffer, KBufferBuilder, IOWindow, UserOrKernelBuffer and ScopedCritical classes being moved to the Kernel/Library subdirectory. Also, move the panic and assertions handling code to that directory.
This commit is contained in:
parent
f1cbfc5a6e
commit
7c0540a229
Notes:
sideshowbarker
2024-07-17 00:53:02 +09:00
Author: https://github.com/supercomputer7
Commit: 7c0540a229
Pull-request: https://github.com/SerenityOS/serenity/pull/17604
Reviewed-by: https://github.com/gmta ✅
Reviewed-by: https://github.com/kleinesfilmroellchen ✅
193 changed files with 238 additions and 240 deletions
54
Kernel/Library/Panic.cpp
Normal file
54
Kernel/Library/Panic.cpp
Normal file
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/Format.h>
|
||||
#include <Kernel/Arch/Processor.h>
|
||||
#if ARCH(X86_64)
|
||||
# include <Kernel/Arch/x86_64/Shutdown.h>
|
||||
#elif ARCH(AARCH64)
|
||||
# include <Kernel/Arch/aarch64/RPi/Watchdog.h>
|
||||
#endif
|
||||
#include <Kernel/CommandLine.h>
|
||||
#include <Kernel/KSyms.h>
|
||||
#include <Kernel/Library/Panic.h>
|
||||
#include <Kernel/Tasks/Thread.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
[[noreturn]] static void __shutdown()
|
||||
{
|
||||
#if ARCH(X86_64)
|
||||
qemu_shutdown();
|
||||
virtualbox_shutdown();
|
||||
#elif ARCH(AARCH64)
|
||||
RPi::Watchdog::the().system_shutdown();
|
||||
#endif
|
||||
// Note: If we failed to invoke platform shutdown, we need to halt afterwards
|
||||
// to ensure no further execution on any CPU still happens.
|
||||
Processor::halt();
|
||||
}
|
||||
|
||||
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:
|
||||
__shutdown();
|
||||
case PanicMode::Halt:
|
||||
[[fallthrough]];
|
||||
default:
|
||||
Processor::halt();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue