summaryrefslogtreecommitdiff
path: root/kernel/src/io/qemu.rs
blob: cf673da91d17803ad3b97ccdf06cafc440ea9c3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u32)]
pub enum QemuExitCode {
    Success = 0x10, // The actual exit code is (value << 1) | 1.
    Failed = 0x11,
}

pub fn exit_qemu(exit_code: QemuExitCode) -> ! {
    use x86_64::instructions::port::Port;

    unsafe {
        let mut port = Port::new(0xf4);
        port.write(exit_code as u32);
        unreachable!("qemu should have quitted")
    }
}