Skip to content

Commit

Permalink
Uhyve: Use the serial buffer hypercall instead of the byte-wise one
Browse files Browse the repository at this point in the history
  • Loading branch information
jounathaen committed Nov 25, 2024
1 parent 9a16274 commit 2d11802
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/arch/x86_64/kernel/serial.rs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 2d11802

Please sign in to comment.