From 128078e9f967d7f2932c008b9df755c59d040729 Mon Sep 17 00:00:00 2001 From: pjht Date: Sun, 2 Jun 2024 10:58:18 -0500 Subject: [PATCH] Add stdout/stderr to mikros PAL --- library/std/src/sys/pal/mikros/stdio.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/library/std/src/sys/pal/mikros/stdio.rs b/library/std/src/sys/pal/mikros/stdio.rs index b5e3f5be988..067bac6d069 100644 --- a/library/std/src/sys/pal/mikros/stdio.rs +++ b/library/std/src/sys/pal/mikros/stdio.rs @@ -1,4 +1,5 @@ use crate::io; +use crate::arch::asm; pub struct Stdin; pub struct Stdout; @@ -24,6 +25,11 @@ pub const fn new() -> Stdout { impl io::Write for Stdout { fn write(&mut self, buf: &[u8]) -> io::Result { + for byte in buf { + unsafe { + asm!("int 0x80", in("rax") 0, in ("rcx") *byte as u64); + }; + } Ok(buf.len()) } @@ -40,6 +46,11 @@ pub const fn new() -> Stderr { impl io::Write for Stderr { fn write(&mut self, buf: &[u8]) -> io::Result { + for byte in buf { + unsafe { + asm!("int 0x80", in("rax") 0, in ("rcx") *byte as u64); + }; + } Ok(buf.len()) } @@ -54,6 +65,6 @@ pub fn is_ebadf(_err: &io::Error) -> bool { true } -pub fn panic_output() -> Option> { - None +pub fn panic_output() -> Option { + Some(Stderr::new()) }