use core::sync::atomic::AtomicU16;
use core::sync::atomic::Ordering;
use x86::io;
pub static SERIAL_PRINT_PORT: AtomicU16 = AtomicU16::new(0x3f8);
pub unsafe fn puts(s: &str) {
let port = SERIAL_PRINT_PORT.load(Ordering::Relaxed);
for b in s.bytes() {
putb(port, b);
}
}
pub unsafe fn putc(c: char) {
let port = SERIAL_PRINT_PORT.load(Ordering::Relaxed);
putb(port, c as u8);
}
unsafe fn putb(port: u16, b: u8) {
while (io::inb(port + 5) & 0x20) == 0 {}
io::outb(port, b);
}
pub fn set_output(port: u16) {
SERIAL_PRINT_PORT.store(port, Ordering::Relaxed);
}