From 3a0752f734f4370a05e45958499ddd9c3a4b3919 Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Mon, 22 Aug 2022 21:39:16 -0700 Subject: Modularize --- src/qemu/mod.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/qemu/mod.rs (limited to 'src/qemu') diff --git a/src/qemu/mod.rs b/src/qemu/mod.rs new file mode 100644 index 0000000..4c1ab37 --- /dev/null +++ b/src/qemu/mod.rs @@ -0,0 +1,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); + } +} -- cgit v1.2.1