summaryrefslogtreecommitdiff
path: root/kernel/src/io/qemu.rs
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/src/io/qemu.rs')
-rw-r--r--kernel/src/io/qemu.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/kernel/src/io/qemu.rs b/kernel/src/io/qemu.rs
new file mode 100644
index 0000000..8b01885
--- /dev/null
+++ b/kernel/src/io/qemu.rs
@@ -0,0 +1,15 @@
+#[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);
+ }
+}