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§

source

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

source

fn read_mask(&self) -> &'static [u32]

Returns the read mask used by read_reg.

source

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§

source

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.

source

fn num_regs(&self) -> usize

Implementations on Foreign Types§

source§

impl<T: PciCapConfig + ?Sized> PciCapConfig for Arc<Mutex<T>>

source§

fn read_mask(&self) -> &'static [u32]

source§

fn read_reg(&self, reg_idx: usize) -> u32

source§

fn write_reg( &mut self, reg_idx: usize, offset: u64, data: &[u8] ) -> Option<Box<dyn PciCapConfigWriteResult>>

source§

fn set_cap_mapping(&mut self, mapping: PciCapMapping)

Implementors§