aboutsummaryrefslogtreecommitdiff
path: root/src/machine/serial.rs
blob: edb18c04f2d70bc4f6f41d8be60e8bb5fe43409e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use crate::machine::device_io::IOPort;
use core::{fmt, str};
/// serial output through port 3f8 (qemu), stateless, not thread safe.
pub struct Serial {}
impl Serial {
	const PORT: IOPort = IOPort::new(0x3f8);
	pub fn putchar(ch: char) {
		Self::PORT.outb(ch as u8);
	}

	pub fn print(s: &str) {
		for c in s.bytes() {
			Self::putchar(c as char);
		}
	}
}