summaryrefslogtreecommitdiff
path: root/src/qemu/mod.rs
diff options
context:
space:
mode:
authorChristian Cunningham <c@localhost>2022-08-22 21:39:16 -0700
committerChristian Cunningham <c@localhost>2022-08-22 21:39:16 -0700
commit3a0752f734f4370a05e45958499ddd9c3a4b3919 (patch)
tree5ee9794f7f9804ef961b9d5126ea0171b8739668 /src/qemu/mod.rs
parentc238b2ea1dff60a5be6a796f44e533e89a346199 (diff)
Modularize
Diffstat (limited to 'src/qemu/mod.rs')
-rw-r--r--src/qemu/mod.rs31
1 files changed, 31 insertions, 0 deletions
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);
+ }
+}