summaryrefslogtreecommitdiff
path: root/src/qemu/mod.rs
blob: 2a0e9908b06b37cb72be8755a7a4fecc99177cda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//! # QEMU Crate
//!
//! Provide QEMU bindings

/// # QEMU Exit Codes
///
/// Provides QEMU exit codes
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[repr(u32)]
pub enum QemuExitCode {
    /// # Success
    ///
    /// Exit QEMU successfully
    Success = 0x10,
    /// # Failure
    ///
    /// Exit QEMU with error
    Failed = 0x11,
}

/// # Exit QEMU
///
/// Exit QEMU with an exit code
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);
    }
}