Update for version 0.2.0 of virtio-drivers crate.
Bug: 237249743
Test: m vmbase_example_bin pvmfw_bin
Change-Id: I5a4d5b37f40885d466bd741ed9897df5ee8581aa
diff --git a/libs/fdtpci/src/lib.rs b/libs/fdtpci/src/lib.rs
index a63e05b..1ddda9f 100644
--- a/libs/fdtpci/src/lib.rs
+++ b/libs/fdtpci/src/lib.rs
@@ -23,7 +23,7 @@
};
use libfdt::{AddressRange, Fdt, FdtError, FdtNode};
use log::debug;
-use virtio_drivers::pci::bus::{Cam, PciRoot};
+use virtio_drivers::transport::pci::bus::{Cam, PciRoot};
/// PCI MMIO configuration region size.
const PCI_CFG_SIZE: usize = 0x100_0000;
diff --git a/pvmfw/src/pci.rs b/pvmfw/src/pci.rs
index e9ac45b..2b81772 100644
--- a/pvmfw/src/pci.rs
+++ b/pvmfw/src/pci.rs
@@ -17,7 +17,7 @@
use crate::{entry::RebootReason, memory::MemoryTracker};
use fdtpci::{PciError, PciInfo};
use log::{debug, error};
-use virtio_drivers::pci::{bus::PciRoot, virtio_device_type};
+use virtio_drivers::transport::pci::{bus::PciRoot, virtio_device_type};
/// Maps the CAM and BAR range in the page table and MMIO guard.
pub fn map_mmio(pci_info: &PciInfo, memory: &mut MemoryTracker) -> Result<(), RebootReason> {
diff --git a/vmbase/example/src/pci.rs b/vmbase/example/src/pci.rs
index a204b90..438ff9e 100644
--- a/vmbase/example/src/pci.rs
+++ b/vmbase/example/src/pci.rs
@@ -16,12 +16,16 @@
use aarch64_paging::paging::MemoryRegion;
use alloc::alloc::{alloc, dealloc, Layout};
-use core::mem::size_of;
+use core::{mem::size_of, ptr::NonNull};
use fdtpci::PciInfo;
use log::{debug, info};
use virtio_drivers::{
- pci::{bus::PciRoot, virtio_device_type, PciTransport},
- DeviceType, Hal, PhysAddr, Transport, VirtAddr, VirtIOBlk, PAGE_SIZE,
+ device::blk::VirtIOBlk,
+ transport::{
+ pci::{bus::PciRoot, virtio_device_type, PciTransport},
+ DeviceType, Transport,
+ },
+ BufferDirection, Hal, PhysAddr, VirtAddr, PAGE_SIZE,
};
/// The standard sector size of a VirtIO block device, in bytes.
@@ -88,7 +92,7 @@
let layout = Layout::from_size_align(pages * PAGE_SIZE, PAGE_SIZE).unwrap();
// Safe because the layout has a non-zero size.
let vaddr = unsafe { alloc(layout) } as VirtAddr;
- Self::virt_to_phys(vaddr)
+ virt_to_phys(vaddr)
}
fn dma_dealloc(paddr: PhysAddr, pages: usize) -> i32 {
@@ -107,7 +111,18 @@
paddr
}
- fn virt_to_phys(vaddr: VirtAddr) -> PhysAddr {
- vaddr
+ fn share(buffer: NonNull<[u8]>, _direction: BufferDirection) -> PhysAddr {
+ let vaddr = buffer.as_ptr() as *mut u8 as usize;
+ // Nothing to do, as the host already has access to all memory.
+ virt_to_phys(vaddr)
}
+
+ fn unshare(_paddr: PhysAddr, _buffer: NonNull<[u8]>, _direction: BufferDirection) {
+ // Nothing to do, as the host already has access to all memory and we didn't copy the buffer
+ // anywhere else.
+ }
+}
+
+fn virt_to_phys(vaddr: VirtAddr) -> PhysAddr {
+ vaddr
}