mmio.rs 937 B

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