pub trait PciDevice:
Debug
+ Send
+ Sync
+ Sealed {
// Required methods
fn config(&self) -> PciConfig<'_>;
fn bar(&self, index: usize) -> Option<OwningPciRegion>;
fn rom(&self) -> Option<OwningPciRegion>;
fn iommu(&self) -> PciIommu<'_>;
fn interrupts(&self) -> PciInterrupts<'_>;
fn reset(&self) -> Result<()>;
}
Expand description
Represents a PCI function.
This trait is sealed for forward-compatibility reasons, and thus cannot be implemented by users of the crate.
Required Methods§
Sourcefn config(&self) -> PciConfig<'_>
fn config(&self) -> PciConfig<'_>
Returns a thing that lets you access the PCI configuration space.
The returned value borrows the PciDevice
.
Sourcefn bar(&self, index: usize) -> Option<OwningPciRegion>
fn bar(&self, index: usize) -> Option<OwningPciRegion>
Returns a region that corresponds to the Base Address Register (BAR) with the given index,
or None
if there is no such BAR or it is unused by the device.
Unused BARs appear as None
. Also, if you want to refer to a 64-bit BAR, use the lower
index (of the underlying, consecutive 32-bit BARs); the higher index is None
in that
case.
Note that PCI allows used BARs to be interspersed with unused BARs. Also, 64-bit BARs don’t need to be “aligned”. For instance, it is possible for a device to use BAR 0 as a 32-bit BAR, leave BARs 1 and 2 unused, used 3 and 4 for a 64-bit BAR, and use BAR 5 for another 32-bit BAR.
The returned value does not borrow the PciDevice
, instead sharing ownership of its
internal resources, so take care to drop it when you want to fully let go of the device.
Sourcefn rom(&self) -> Option<OwningPciRegion>
fn rom(&self) -> Option<OwningPciRegion>
Returns a region that is the PCI Expansion ROM, or None
if the device doesn’t have one.
The returned value does not borrow the PciDevice
, instead sharing ownership of its
internal resources, so take care to drop it when you want to fully let go of the device.
Sourcefn iommu(&self) -> PciIommu<'_>
fn iommu(&self) -> PciIommu<'_>
Returns a thing that lets you manage IOMMU mappings for DMA.
NOTE: Depending on the backend and on how the PciDevice
was instantiated, this may also
affect IOMMU mappings for other PCI functions.
The returned value borrows the PciDevice
.
Sourcefn interrupts(&self) -> PciInterrupts<'_>
fn interrupts(&self) -> PciInterrupts<'_>
Returns a thing that lets you manage interrupts.
The returned value borrows the PciDevice
.
Sourcefn reset(&self) -> Result<()>
fn reset(&self) -> Result<()>
Reset this function, and only it.
This will fail if it would be necessary to reset other functions or devices as well to get this one to be reset (probably can only happen with multi-function devices that don’t support Function-Level Reset).
This can also fail for other unspecified reasons.
TODO: Should probably advertise whether this granularity of reset is supported, so the user doesn’t have to try resetting to find out.