Add stdout/stderr to mikros PAL
This commit is contained in:
parent
219022ccb6
commit
128078e9f9
@ -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<usize> {
|
||||
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<usize> {
|
||||
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<Vec<u8>> {
|
||||
None
|
||||
pub fn panic_output() -> Option<impl io::Write> {
|
||||
Some(Stderr::new())
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user