1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-25 23:35:07 +00:00
serenity/Kernel/Arch/riscv64/PowerState.cpp
Sönke Holz 8547813b6d Kernel/riscv64: Implement arch_specific_{reboot,shutdown} using the SBI
We first try to use the newer "SRST" extension for rebooting and
shutting down and if that fails, we try to shutdown using the legacy
"System Shutdown" extension (which can't reboot, so we always shutdown).
The kernel will halt, if we return from here due to all attempts at
rebooting / shutting down failing.
2024-01-12 16:25:46 -07:00

28 lines
826 B
C++

/*
* Copyright (c) 2023, Sönke Holz <sholz8530@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <Kernel/Arch/PowerState.h>
#include <Kernel/Arch/riscv64/SBI.h>
namespace Kernel {
void arch_specific_reboot()
{
auto ret = SBI::SystemReset::system_reset(SBI::SystemReset::ResetType::ColdReboot, SBI::SystemReset::ResetReason::NoReason);
dbgln("SBI: Failed to reboot: {}", ret);
dbgln("SBI: Attempting to shut down using the legacy extension...");
SBI::Legacy::shutdown();
}
void arch_specific_poweroff()
{
auto ret = SBI::SystemReset::system_reset(SBI::SystemReset::ResetType::Shutdown, SBI::SystemReset::ResetReason::NoReason);
dbgln("SBI: Failed to shut down: {}", ret);
dbgln("SBI: Attempting to shut down using the legacy extension...");
SBI::Legacy::shutdown();
}
}