[pvmfw][virtio] Refactor PCI initialisation
This cl refactors PCI initialisation by:
- Introducing a new error type specifically for PCI.
- Replacing the pvmfw-specific error type with the new PCIError
to facilitate moving this module to vmbase for reuse later.
- Setting the static PCI_INFO before mapping the PCI CAM and
BAR ranges.
Bug: 284462758
Test: m pvmfw_img
Change-Id: I66a653f4c9d404e7655919e89acf9bb93bb6aaaa
diff --git a/pvmfw/src/main.rs b/pvmfw/src/main.rs
index 6a5151c..c6baf6d 100644
--- a/pvmfw/src/main.rs
+++ b/pvmfw/src/main.rs
@@ -98,7 +98,10 @@
// Set up PCI bus for VirtIO devices.
let pci_info = PciInfo::from_fdt(fdt).map_err(handle_pci_error)?;
debug!("PCI: {:#x?}", pci_info);
- let mut pci_root = pci::initialise(pci_info, MEMORY.lock().as_mut().unwrap())?;
+ let mut pci_root = pci::initialise(pci_info, MEMORY.lock().as_mut().unwrap()).map_err(|e| {
+ error!("Failed to initialise PCI: {e}");
+ RebootReason::InternalError
+ })?;
let verified_boot_data = verify_payload(signed_kernel, ramdisk, PUBLIC_KEY).map_err(|e| {
error!("Failed to verify the payload: {e}");