From b47731c6fd99d80b1023d906dd4b3bb377e49438 Mon Sep 17 00:00:00 2001 From: Dennis Kobert Date: Sun, 3 Nov 2019 01:22:02 +0100 Subject: Merge: 41bff6a a2d6311 --- kernel/src/io/serial.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 kernel/src/io/serial.rs (limited to 'kernel/src/io/serial.rs') diff --git a/kernel/src/io/serial.rs b/kernel/src/io/serial.rs new file mode 100644 index 0000000..e1d4660 --- /dev/null +++ b/kernel/src/io/serial.rs @@ -0,0 +1,25 @@ +#[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); + } +} + +fn trivial_assertion() { + use crate::io::vga_text::OStream; + let mut stdout = OStream::new(); + stdout.clear(); + + stdout.print(b"trivial assertion... "); + assert_eq!(0, 1); + stdout.print(b"[ok]"); +} -- cgit v1.2.3-70-g09d2