Procházet zdrojové kódy

Make config space pointer part of Transport trait.

Andrew Walbran před 2 roky
rodič
revize
271b8d104f
2 změnil soubory, kde provedl 7 přidání a 5 odebrání
  1. 4 5
      src/transport/mmio.rs
  2. 3 0
      src/transport/mod.rs

+ 4 - 5
src/transport/mmio.rs

@@ -166,11 +166,6 @@ impl VirtIOHeader {
         self.vendor_id.read()
     }
 
-    /// Get the pointer to config space (at offset 0x100)
-    pub fn config_space(&self) -> *mut u64 {
-        (self as *const _ as usize + CONFIG_SPACE_OFFSET) as _
-    }
-
     /// Constructs a fake virtio header for use in unit tests.
     #[cfg(test)]
     pub fn make_fake_header(
@@ -272,4 +267,8 @@ impl Transport for VirtIOHeader {
             false
         }
     }
+
+    fn config_space(&self) -> *mut u64 {
+        (self as *const _ as usize + CONFIG_SPACE_OFFSET) as _
+    }
 }

+ 3 - 0
src/transport/mod.rs

@@ -57,6 +57,9 @@ pub trait Transport {
     fn queue_used(&mut self, queue: u32) -> bool {
         self.queue_physical_page_number(queue) != 0
     }
+
+    /// Gets the pointer to the config space.
+    fn config_space(&self) -> *mut u64;
 }
 
 bitflags! {