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