Skip to content

Commit

Permalink
refactor(stdio): use Console::write
Browse files Browse the repository at this point in the history
  • Loading branch information
mkroening committed Nov 25, 2024
1 parent 7c2106b commit 6dab556
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/fd/stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ use x86::io::*;

#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
use crate::arch::mm::paging;
use crate::console::CONSOLE;
use crate::fd::{ObjectInterface, PollEvent, STDERR_FILENO, STDOUT_FILENO};
use crate::{arch, io};

const UHYVE_PORT_WRITE: u16 = 0x400;

static IO_LOCK: Mutex<()> = Mutex::new(());

#[repr(C, packed)]
struct SysWrite {
fd: i32,
Expand Down Expand Up @@ -91,9 +90,7 @@ impl ObjectInterface for GenericStdout {
}

async fn write(&self, buf: &[u8]) -> io::Result<usize> {
let _guard = IO_LOCK.lock().await;
arch::output_message_buf(buf);

CONSOLE.lock().write(buf);
Ok(buf.len())
}
}
Expand All @@ -115,9 +112,7 @@ impl ObjectInterface for GenericStderr {
}

async fn write(&self, buf: &[u8]) -> io::Result<usize> {
let _guard = IO_LOCK.lock().await;
arch::output_message_buf(buf);

CONSOLE.lock().write(buf);
Ok(buf.len())
}
}
Expand Down

0 comments on commit 6dab556

Please sign in to comment.