mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-22 09:21:57 -05:00
Kernel: Share __assertion_failed() implementation between architectures
I put the generic implementation in Assertions.cpp, since the declaration is in Assertions.h. The only change needed to make the x86-64 implementation generic was replacing the cli with a Processor::disable_interrupts().
This commit is contained in:
parent
44c016eb47
commit
d033add27f
4 changed files with 7 additions and 55 deletions
|
@ -1,24 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Timon Kruiper <timonkruiper@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <Kernel/Arch/Processor.h>
|
||||
#include <Kernel/KSyms.h>
|
||||
#include <Kernel/Library/Panic.h>
|
||||
|
||||
// FIXME: Merge the code in this file with Kernel/Library/Panic.cpp once the proper abstractions are in place.
|
||||
|
||||
// Note: This is required here, since __assertion_failed should be out of the Kernel namespace,
|
||||
// but the PANIC macro uses functions that require the Kernel namespace.
|
||||
using namespace Kernel;
|
||||
|
||||
[[noreturn]] void __assertion_failed(char const* msg, char const* file, unsigned line, char const* func)
|
||||
{
|
||||
critical_dmesgln("ASSERTION FAILED: {}", msg);
|
||||
critical_dmesgln("{}:{} in {}", file, line, func);
|
||||
|
||||
// Used for printing a nice backtrace!
|
||||
PANIC("Aborted");
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Timon Kruiper <timonkruiper@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <Kernel/Arch/Processor.h>
|
||||
#include <Kernel/KSyms.h>
|
||||
#include <Kernel/Library/Panic.h>
|
||||
|
||||
// FIXME: Merge the code in this file with Kernel/Library/Panic.cpp once the proper abstractions are in place.
|
||||
|
||||
// Note: This is required here, since __assertion_failed should be out of the Kernel namespace,
|
||||
// but the PANIC macro uses functions that require the Kernel namespace.
|
||||
using namespace Kernel;
|
||||
|
||||
[[noreturn]] void __assertion_failed(char const* msg, char const* file, unsigned line, char const* func)
|
||||
{
|
||||
critical_dmesgln("ASSERTION FAILED: {}", msg);
|
||||
critical_dmesgln("{}:{} in {}", file, line, func);
|
||||
|
||||
// Used for printing a nice backtrace!
|
||||
PANIC("Aborted");
|
||||
}
|
|
@ -261,6 +261,7 @@ set(KERNEL_SOURCES
|
|||
Memory/VirtualRange.cpp
|
||||
Locking/LockRank.cpp
|
||||
Locking/Mutex.cpp
|
||||
Library/Assertions.cpp
|
||||
Library/DoubleBuffer.cpp
|
||||
Library/IOWindow.cpp
|
||||
Library/MiniStdLib.cpp
|
||||
|
@ -448,7 +449,6 @@ if ("${SERENITY_ARCH}" STREQUAL "x86_64")
|
|||
${KERNEL_SOURCES}
|
||||
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86_64/ASM_wrapper.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86_64/CPU.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86_64/CPUID.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86_64/InterruptManagement.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/Arch/x86_64/Interrupts.cpp
|
||||
|
@ -501,7 +501,6 @@ elseif("${SERENITY_ARCH}" STREQUAL "aarch64")
|
|||
Arch/aarch64/kprintf.cpp
|
||||
Arch/aarch64/MainIdRegister.cpp
|
||||
Arch/aarch64/PageDirectory.cpp
|
||||
Arch/aarch64/Panic.cpp
|
||||
Arch/aarch64/Processor.cpp
|
||||
Arch/aarch64/PowerState.cpp
|
||||
Arch/aarch64/SafeMem.cpp
|
||||
|
@ -545,7 +544,6 @@ elseif("${SERENITY_ARCH}" STREQUAL "riscv64")
|
|||
Arch/riscv64/Interrupts/PLIC.cpp
|
||||
Arch/riscv64/MMU.cpp
|
||||
Arch/riscv64/PageDirectory.cpp
|
||||
Arch/riscv64/Panic.cpp
|
||||
Arch/riscv64/PCI/Initializer.cpp
|
||||
Arch/riscv64/PowerState.cpp
|
||||
Arch/riscv64/pre_init.cpp
|
||||
|
|
|
@ -4,17 +4,19 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/Platform.h>
|
||||
#include <Kernel/Arch/CPU.h>
|
||||
#include <Kernel/Arch/Processor.h>
|
||||
#include <Kernel/Library/Assertions.h>
|
||||
#include <Kernel/Library/Panic.h>
|
||||
#include <Kernel/Tasks/Process.h>
|
||||
#include <Kernel/Tasks/Thread.h>
|
||||
|
||||
// Note: This is required here, since __assertion_failed should be out of the Kernel namespace,
|
||||
// but the PANIC macro uses functions that require the Kernel namespace.
|
||||
using namespace Kernel;
|
||||
|
||||
NO_SANITIZE_COVERAGE void __assertion_failed(char const* msg, char const* file, unsigned line, char const* func)
|
||||
{
|
||||
asm volatile("cli");
|
||||
Processor::disable_interrupts();
|
||||
critical_dmesgln("ASSERTION FAILED: {}", msg);
|
||||
critical_dmesgln("{}:{} in {}", file, line, func);
|
||||
|
Loading…
Reference in a new issue