@@ -45,6 +45,7 @@ pub use self::net::VirtIoNetDev;
4545#[ cfg( feature = "v9p" ) ]
4646pub use self :: v9p:: VirtIo9pDev ;
4747
48+ use virtio_drivers:: transport:: pci:: bus:: ConfigurationAccess ;
4849pub use virtio_drivers:: transport:: pci:: bus as pci;
4950pub use virtio_drivers:: transport:: { mmio:: MmioTransport , pci:: PciTransport , Transport } ;
5051pub use virtio_drivers:: { BufferDirection , Hal as VirtIoHal , PhysAddr } ;
@@ -59,13 +60,13 @@ use virtio_drivers::transport::DeviceType as VirtIoDevType;
5960/// for later operations. Otherwise, returns [`None`].
6061pub fn probe_mmio_device (
6162 reg_base : * mut u8 ,
62- _reg_size : usize ,
63- ) -> Option < ( DeviceType , MmioTransport ) > {
63+ reg_size : usize ,
64+ ) -> Option < ( DeviceType , MmioTransport < ' static > ) > {
6465 use core:: ptr:: NonNull ;
6566 use virtio_drivers:: transport:: mmio:: VirtIOHeader ;
6667
6768 let header = NonNull :: new ( reg_base as * mut VirtIOHeader ) . unwrap ( ) ;
68- let transport = unsafe { MmioTransport :: new ( header) } . ok ( ) ?;
69+ let transport = unsafe { MmioTransport :: new ( header, reg_size ) } . ok ( ) ?;
6970 let dev_type = as_dev_type ( transport. device_type ( ) ) ?;
7071 Some ( ( dev_type, transport) )
7172}
@@ -74,18 +75,23 @@ pub fn probe_mmio_device(
7475///
7576/// If the device is recognized, returns the device type and a transport object
7677/// for later operations. Otherwise, returns [`None`].
77- pub fn probe_pci_device < H : VirtIoHal > (
78- root : & mut PciRoot ,
78+ pub fn probe_pci_device < H , C > (
79+ root : & mut PciRoot < C > ,
7980 bdf : DeviceFunction ,
8081 dev_info : & DeviceFunctionInfo ,
81- ) -> Option < ( DeviceType , PciTransport ) > {
82+ ) -> Option < ( DeviceType , PciTransport ) >
83+ where
84+ H : VirtIoHal ,
85+ C : ConfigurationAccess ,
86+ {
8287 use virtio_drivers:: transport:: pci:: virtio_device_type;
8388
8489 let dev_type = virtio_device_type ( dev_info) . and_then ( as_dev_type) ?;
85- let transport = PciTransport :: new :: < H > ( root, bdf) . ok ( ) ?;
90+ let transport = PciTransport :: new :: < H , C > ( root, bdf) . ok ( ) ?;
8691 Some ( ( dev_type, transport) )
8792}
8893
94+
8995const fn as_dev_type ( t : VirtIoDevType ) -> Option < DeviceType > {
9096 use VirtIoDevType :: * ;
9197 match t {
0 commit comments