Эх сурвалжийг харах

Merge pull request #55 from rcore-os/reset

Reset device when the transport is dropped.
chyyuu 2 жил өмнө
parent
commit
66829b6363

+ 7 - 0
src/transport/mmio.rs

@@ -490,3 +490,10 @@ impl Transport for MmioTransport {
         Ok(NonNull::new((self.header.as_ptr() as usize + CONFIG_SPACE_OFFSET) as _).unwrap())
         Ok(NonNull::new((self.header.as_ptr() as usize + CONFIG_SPACE_OFFSET) as _).unwrap())
     }
     }
 }
 }
+
+impl Drop for MmioTransport {
+    fn drop(&mut self) {
+        // Reset the device when the transport is dropped.
+        self.set_status(DeviceStatus::empty())
+    }
+}

+ 7 - 0
src/transport/pci.rs

@@ -338,6 +338,13 @@ impl Transport for PciTransport {
     }
     }
 }
 }
 
 
+impl Drop for PciTransport {
+    fn drop(&mut self) {
+        // Reset the device when the transport is dropped.
+        self.set_status(DeviceStatus::empty())
+    }
+}
+
 /// `virtio_pci_common_cfg`, see 4.1.4.3 "Common configuration structure layout".
 /// `virtio_pci_common_cfg`, see 4.1.4.3 "Common configuration structure layout".
 #[repr(C)]
 #[repr(C)]
 struct CommonCfg {
 struct CommonCfg {