Allow SBI system_reset to fail

This commit is contained in:
Zejun Zhao 2025-11-16 23:14:52 +08:00 committed by Junyang Zhang
parent 2f568d5e73
commit 902106eb2e
1 changed files with 10 additions and 2 deletions

View File

@ -14,9 +14,17 @@ pub enum QemuExitCode {
/// Exit QEMU with the given exit code.
pub fn exit_qemu(exit_code: QemuExitCode) -> ! {
log::debug!("exit qemu with exit code {exit_code:?}");
match exit_code {
let error_code = match exit_code {
QemuExitCode::Success => sbi_rt::system_reset(sbi_rt::Shutdown, sbi_rt::NoReason),
QemuExitCode::Failed => sbi_rt::system_reset(sbi_rt::Shutdown, sbi_rt::SystemFailure),
};
unreachable!("qemu does not exit");
log::error!(
"SBI system_reset cannot shut down the underlying machine, error code: {:#?}",
error_code
);
loop {
riscv::asm::wfi();
}
}