1 use fdt::node::FdtNode; 2 use log::error; 3 use system_error::SystemError; 4 5 use crate::driver::{ 6 open_firmware::fdt::open_firmware_fdt_driver, virtio::transport_mmio::VirtIOMmioTransport, 7 }; 8 9 use super::{transport::VirtIOTransport, virtio::virtio_device_init}; 10 11 pub(super) fn virtio_probe_mmio() { 12 if let Err(e) = do_probe_virtio_mmio() { 13 error!("virtio_probe_mmio failed: {:?}", e); 14 } 15 } 16 17 fn do_probe_virtio_mmio() -> Result<(), SystemError> { 18 let fdt = open_firmware_fdt_driver().fdt_ref()?; 19 20 let do_check = |node: FdtNode| -> Result<(), SystemError> { 21 let mmio_transport = VirtIOMmioTransport::new(node)?; 22 let device_id = mmio_transport.device_id(); 23 virtio_device_init(VirtIOTransport::Mmio(mmio_transport), device_id, None); 24 Ok(()) 25 }; 26 27 for node in open_firmware_fdt_driver().find_node_by_compatible(&fdt, "virtio,mmio") { 28 do_check(node).ok(); 29 } 30 Ok(()) 31 } 32