From 2d11802ab7e1c0cf733880aaa005091b9906ccff Mon Sep 17 00:00:00 2001 From: Jonathan Klimt Date: Mon, 25 Nov 2024 18:17:05 +0100 Subject: [PATCH] Uhyve: Use the serial buffer hypercall instead of the byte-wise one --- src/arch/x86_64/kernel/serial.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/arch/x86_64/kernel/serial.rs b/src/arch/x86_64/kernel/serial.rs index 5db44653ca..3dd8314586 100644 --- a/src/arch/x86_64/kernel/serial.rs +++ b/src/arch/x86_64/kernel/serial.rs @@ -1,11 +1,16 @@ #[cfg(feature = "shell")] use alloc::collections::VecDeque; +use memory_addresses::VirtAddr; +use uhyve_interface::parameters::SerialWriteBufferParams; +use uhyve_interface::Hypercall; use x86_64::instructions::port::Port; +use crate::arch::mm::paging::virtual_to_physical; use crate::arch::x86_64::kernel::core_local::increment_irq_counter; use crate::arch::x86_64::kernel::interrupts::{self, IDT}; use crate::arch::x86_64::kernel::{apic, COM1}; +use crate::syscalls::interfaces::uhyve_hypercall; const SERIAL_IRQ: u8 = 36; @@ -66,12 +71,12 @@ impl SerialPort { pub fn send(&mut self, buf: &[u8]) { match &mut self.inner { - SerialInner::Uhyve(s) => { - for &data in buf { - unsafe { - s.write(data); - } - } + SerialInner::Uhyve(_s) => { + let p = SerialWriteBufferParams { + buf: virtual_to_physical(VirtAddr::from_ptr(buf as *const [u8])).unwrap(), + len: buf.len(), + }; + uhyve_hypercall(Hypercall::SerialWriteBuffer(&p)); } SerialInner::Uart(s) => { for &data in buf {