mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 13:00:29 +03:00
Kernel: Move QEMU shutdown code to the x86 subdirectory
QEMU VM shutdown code is really x86 specific, so let's ensure we only use it when compiling a Kernel for x86 machines.
This commit is contained in:
parent
d3601aedc5
commit
4555cac639
Notes:
sideshowbarker
2024-07-17 06:48:30 +09:00
Author: https://github.com/supercomputer7 Commit: https://github.com/SerenityOS/serenity/commit/4555cac639 Pull-request: https://github.com/SerenityOS/serenity/pull/15173 Reviewed-by: https://github.com/linusg
21
Kernel/Arch/x86/common/QEMUShutdown.cpp
Normal file
21
Kernel/Arch/x86/common/QEMUShutdown.cpp
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <Kernel/Arch/x86/IO.h>
|
||||
#include <Kernel/Arch/x86/common/QEMUShutdown.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
void qemu_shutdown()
|
||||
{
|
||||
// Note: This will invoke QEMU Shutdown, but for other platforms (or emulators),
|
||||
// this has no effect on the system.
|
||||
// We also try the Bochs/Old QEMU shutdown method, if the first didn't work.
|
||||
IO::out16(0x604, 0x2000);
|
||||
IO::out16(0xb004, 0x2000);
|
||||
}
|
||||
|
||||
}
|
13
Kernel/Arch/x86/common/QEMUShutdown.h
Normal file
13
Kernel/Arch/x86/common/QEMUShutdown.h
Normal file
@ -0,0 +1,13 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
void qemu_shutdown();
|
||||
|
||||
}
|
@ -335,6 +335,7 @@ if ("${SERENITY_ARCH}" STREQUAL "i686" OR "${SERENITY_ARCH}" STREQUAL "x86_64")
|
||||
|
||||
Arch/x86/common/ScopedCritical.cpp
|
||||
Arch/x86/common/SmapDisabler.cpp
|
||||
Arch/x86/common/QEMUShutdown.cpp
|
||||
)
|
||||
|
||||
set(KERNEL_SOURCES
|
||||
|
@ -6,7 +6,9 @@
|
||||
|
||||
#include <AK/Format.h>
|
||||
#include <Kernel/Arch/Processor.h>
|
||||
#include <Kernel/Arch/x86/IO.h>
|
||||
#if ARCH(I386) || ARCH(X86_64)
|
||||
# include <Kernel/Arch/x86/common/QEMUShutdown.h>
|
||||
#endif
|
||||
#include <Kernel/CommandLine.h>
|
||||
#include <Kernel/KSyms.h>
|
||||
#include <Kernel/Panic.h>
|
||||
@ -16,11 +18,11 @@ namespace Kernel {
|
||||
|
||||
[[noreturn]] static void __shutdown()
|
||||
{
|
||||
// Note: This will invoke QEMU Shutdown, but for other platforms (or emulators),
|
||||
// this has no effect on the system, so we still need to halt afterwards.
|
||||
// We also try the Bochs/Old QEMU shutdown method, if the first didn't work.
|
||||
IO::out16(0x604, 0x2000);
|
||||
IO::out16(0xb004, 0x2000);
|
||||
#if ARCH(I386) || ARCH(X86_64)
|
||||
qemu_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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user