Function devices::pci::pci_device::find_bar_and_offset
source · fn find_bar_and_offset(
device: &impl PciDevice,
address: u64,
size: usize
) -> Option<(PciBarIndex, u64)>
Expand description
Find the BAR containing an access specified by address
and size
.
If found, returns the BAR index and offset in bytes within that BAR corresponding to address
.
The BAR must fully contain the access region; partial overlaps will return None
. Zero-sized
accesses should not normally happen, but in case one does, this function will return None
.
This function only finds memory BARs, not I/O BARs. If a device with a BAR in I/O address space
is ever added, address space information will need to be added to BusDevice::read()
and
BusDevice::write()
and passed along to this function.