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 Dec 12, 2024
1 parent b2405ef commit a56f541
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/fd/stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use alloc::boxed::Box;
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
use core::ptr;

use async_lock::Mutex;
use async_trait::async_trait;
#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
use memory_addresses::VirtAddr;
Expand All @@ -11,13 +10,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};
use crate::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 +89,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 +111,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 a56f541

Please sign in to comment.