mirror of
https://github.com/RGBCube/serenity
synced 2025-05-25 23:35:07 +00:00

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.
28 lines
826 B
C++
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();
|
|
}
|
|
|
|
}
|