Skip to content

Commit

Permalink
Add new UART syscall port and handler function
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanwhyte authored and jounathaen committed Jun 2, 2023
1 parent 3c332ea commit 6a49418
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,13 @@ pub trait VirtualCPU {
fn uart(&self, buf: &[u8]) -> io::Result<()> {
io::stdout().write_all(buf)
}

/// Handles a UART syscall by contructing a buffer from parameter
fn uart_buffer(&self, sysuart: &SysUart) -> io::Result<()> {
let buf_addr = self.virt_to_phys(sysuart.buf as usize) as *const u8;
let buf = unsafe { std::slice::from_raw_parts(buf_addr, sysuart.len) };
io::stdout().write_all(buf)
}
}

pub trait Vm {
Expand Down

0 comments on commit 6a49418

Please sign in to comment.