#![allow(dead_code)]
use tracing::error;
use crate::cpu;
const EXIT_FAILURE: u32 = 0; const EXIT_SUCCESS: u32 = 1; const IO_BASE: u16 = 0xf4;
pub enum ExitStatus {
Success,
Failure,
Custom(u32),
}
pub fn exit(status: ExitStatus) -> ! {
let code = match status {
ExitStatus::Success => EXIT_SUCCESS,
ExitStatus::Failure => EXIT_FAILURE,
ExitStatus::Custom(code) => code,
};
unsafe {
cpu::io_out(IO_BASE, code);
}
error!("Qemu did not exit, halting.");
loop {
unsafe {
cpu::clear_interrupts();
cpu::halt();
}
}
}