summary refs log tree commit diff
path: root/resources
diff options
context:
space:
mode:
authorTomasz Jeznach <tjeznach@chromium.org>2020-04-29 12:58:11 -0700
committerCommit Bot <commit-bot@chromium.org>2020-05-01 05:49:39 +0000
commitda0e0f939b731d89d067fb9382bbdc05e47f4067 (patch)
tree1233cb599fb9aa82c004f77a42692a0fd8728b62 /resources
parenta4dd4af5de2d260b307eff873f5c5eb194f4ba57 (diff)
downloadcrosvm-da0e0f939b731d89d067fb9382bbdc05e47f4067.tar
crosvm-da0e0f939b731d89d067fb9382bbdc05e47f4067.tar.gz
crosvm-da0e0f939b731d89d067fb9382bbdc05e47f4067.tar.bz2
crosvm-da0e0f939b731d89d067fb9382bbdc05e47f4067.tar.lz
crosvm-da0e0f939b731d89d067fb9382bbdc05e47f4067.tar.xz
crosvm-da0e0f939b731d89d067fb9382bbdc05e47f4067.tar.zst
crosvm-da0e0f939b731d89d067fb9382bbdc05e47f4067.zip
devices: pci: refactor PCI devices to use PciAddress.
Simple refactor of PCI device addressing to use
PciAddress type providing bus:device.function number.

BUG=None
TEST=build_test & tast run crostini.Sanity

Change-Id: I7755ad6b31aa8c882475cd8212630e1cc86ef49e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2172766
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
Diffstat (limited to 'resources')
-rw-r--r--resources/src/lib.rs4
-rw-r--r--resources/src/system_allocator.rs5
2 files changed, 5 insertions, 4 deletions
diff --git a/resources/src/lib.rs b/resources/src/lib.rs
index a0c6c98..17e8b72 100644
--- a/resources/src/lib.rs
+++ b/resources/src/lib.rs
@@ -30,8 +30,8 @@ pub enum Alloc {
     /// Should only be instantiated through `SystemAllocator::get_anon_alloc()`.
     /// Avoid using these. Instead, use / create a more descriptive Alloc variant.
     Anon(usize),
-    /// A PCI BAR region with associated bus, device, and bar numbers.
-    PciBar { bus: u8, dev: u8, bar: u8 },
+    /// A PCI BAR region with associated bus, device, function and bar numbers.
+    PciBar { bus: u8, dev: u8, func: u8, bar: u8 },
     /// GPU render node region.
     GpuRenderNode,
     /// Pmem device region with associated device index.
diff --git a/resources/src/system_allocator.rs b/resources/src/system_allocator.rs
index 984bc51..889fe01 100644
--- a/resources/src/system_allocator.rs
+++ b/resources/src/system_allocator.rs
@@ -25,13 +25,14 @@ use crate::{Alloc, Error, Result};
 ///           a.mmio_allocator(MmioType::High)
 ///              .allocate(
 ///                  0x100,
-///                  Alloc::PciBar { bus: 0, dev: 0, bar: 0 },
+///                  Alloc::PciBar { bus: 0, dev: 0, func: 0, bar: 0 },
 ///                  "bar0".to_string()
 ///              ),
 ///           Ok(0x10000000)
 ///       );
 ///       assert_eq!(
-///           a.mmio_allocator(MmioType::High).get(&Alloc::PciBar { bus: 0, dev: 0, bar: 0 }),
+///           a.mmio_allocator(MmioType::High)
+///              .get(&Alloc::PciBar { bus: 0, dev: 0, func: 0, bar: 0 }),
 ///           Some(&(0x10000000, 0x100, "bar0".to_string()))
 ///       );
 ///   }