1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 13:57:35 +00:00

Kernel: Simplify reboot & poweroff code flow a bit

Instead of using ifdefs to use the correct platform-specific methods, we
can just use the same pattern we use for the microseconds_delay function
which has specific implementations for each Arch CPU subdirectory.

When linking a kernel image, the actual correct and platform-specific
power-state changing methods will be called in Firmware/PowerState.cpp
file.
This commit is contained in:
Liav A 2023-06-09 22:13:04 +03:00 committed by Jelle Raaijmakers
parent 5c8405c455
commit 9b8b8c0e04
8 changed files with 138 additions and 53 deletions

16
Kernel/Arch/PowerState.h Normal file
View file

@ -0,0 +1,16 @@
/*
* Copyright (c) 2023, Liav A. <liavalb@hotmail.co.il>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Types.h>
namespace Kernel {
void arch_specific_reboot();
void arch_specific_poweroff();
}

View file

@ -0,0 +1,21 @@
/*
* Copyright (c) 2023, Liav A. <liavalb@hotmail.co.il>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/Arch/PowerState.h>
#include <Kernel/Arch/aarch64/RPi/Watchdog.h>
namespace Kernel {
void arch_specific_reboot()
{
}
void arch_specific_poweroff()
{
RPi::Watchdog::the().system_shutdown();
}
}

View file

@ -0,0 +1,24 @@
/*
* Copyright (c) 2023, Liav A. <liavalb@hotmail.co.il>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/Arch/PowerState.h>
#include <Kernel/Arch/x86_64/I8042Reboot.h>
#include <Kernel/Arch/x86_64/Shutdown.h>
namespace Kernel {
void arch_specific_reboot()
{
i8042_reboot();
}
void arch_specific_poweroff()
{
qemu_shutdown();
virtualbox_shutdown();
}
}