Trait devices::pci::pci_configuration::PciCapConfig
source · pub trait PciCapConfig: Send {
// Required methods
fn read_reg(&self, reg_idx: usize) -> u32;
fn read_mask(&self) -> &'static [u32];
fn write_reg(
&mut self,
reg_idx: usize,
offset: u64,
data: &[u8]
) -> Option<Box<dyn PciCapConfigWriteResult>>;
// Provided methods
fn set_cap_mapping(&mut self, _mapping: PciCapMapping) { ... }
fn num_regs(&self) -> usize { ... }
}
Expand description
A trait for implementing complex PCI capabilities.
Required Methods§
sourcefn read_reg(&self, reg_idx: usize) -> u32
fn read_reg(&self, reg_idx: usize) -> u32
Reads a 32bit register from the capability. Only the bits set in the
read mask will be used, while the rest of the bits will be taken from
the PciConfiguration
’s register data.
reg_idx
- index into the capability
sourcefn write_reg(
&mut self,
reg_idx: usize,
offset: u64,
data: &[u8]
) -> Option<Box<dyn PciCapConfigWriteResult>>
fn write_reg( &mut self, reg_idx: usize, offset: u64, data: &[u8] ) -> Option<Box<dyn PciCapConfigWriteResult>>
Writes data to the capability.
reg_idx
- index into PciConfiguration.registers.
offset
- PciConfiguration.registers is in unit of DWord, offset define byte
offset in the DWord.
data
- The data to write.
Provided Methods§
sourcefn set_cap_mapping(&mut self, _mapping: PciCapMapping)
fn set_cap_mapping(&mut self, _mapping: PciCapMapping)
Used to pass the mmio region for the capability to the implementation.
If any external events update the capability’s registers, then
PciCapMapping.set_reg
must be called to make the changes visible
to the guest.