From da0e0f939b731d89d067fb9382bbdc05e47f4067 Mon Sep 17 00:00:00 2001 From: Tomasz Jeznach Date: Wed, 29 Apr 2020 12:58:11 -0700 Subject: 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 Tested-by: kokoro Commit-Queue: Tomasz Jeznach --- resources/src/lib.rs | 4 ++-- resources/src/system_allocator.rs | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'resources') 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())) /// ); /// } -- cgit 1.4.1