pub struct PciConfiguration {
    registers: [u32; 64],
    writable_bits: [u32; 64],
    bar_used: [bool; 7],
    bar_configs: [Option<PciBarConfiguration>; 7],
    last_capability: Option<(usize, usize)>,
    capability_configs: BTreeMap<usize, Box<dyn PciCapConfig>>,
    mmio_mapping: Option<(Arc<Mutex<MemoryMapping>>, usize)>,
}
Expand description

Contains the configuration space of a PCI node. See the specification. The configuration space is accessed with DWORD reads and writes from the guest.

Fields§

§registers: [u32; 64]§writable_bits: [u32; 64]§bar_used: [bool; 7]§bar_configs: [Option<PciBarConfiguration>; 7]§last_capability: Option<(usize, usize)>§capability_configs: BTreeMap<usize, Box<dyn PciCapConfig>>§mmio_mapping: Option<(Arc<Mutex<MemoryMapping>>, usize)>

Implementations§

source§

impl PciConfiguration

source

pub fn new( vendor_id: u16, device_id: u16, class_code: PciClassCode, subclass: &dyn PciSubclass, programming_interface: Option<&dyn PciProgrammingInterface>, header_type: PciHeaderType, subsystem_vendor_id: u16, subsystem_id: u16, revision_id: u8 ) -> Self

source

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

Reads a 32bit register from reg_idx in the register map.

source

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

Writes data to PciConfiguration.registers. 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.

source

fn write_dword(&mut self, offset: usize, value: u32)

Writes a 32bit dword to offset. offset must be 32bit aligned.

source

fn write_word(&mut self, offset: usize, value: u16)

Writes a 16bit word to offset. offset must be 16bit aligned.

source

fn write_byte(&mut self, offset: usize, value: u8)

Writes a byte to offset.

source

fn write_byte_internal( &mut self, offset: usize, value: u8, apply_writable_mask: bool )

Writes a byte to offset, optionally enforcing read-only bits.

source

pub fn set_reg(&mut self, reg_idx: usize, data: u32, mask: u32)

Sets the value of a PciConfiguration register. This should be used when device-internal events require changing the configuration space - as such, the writable bits masks do not apply. reg_idx - index into PciConfiguration.registers. data - The data to write. mask - The mask of which bits to modify.

source

pub fn add_pci_bar( &mut self, config: PciBarConfiguration ) -> Result<PciBarIndex, Error>

Adds a region specified by config. Configures the specified BAR(s) to report this region and size to the guest kernel. Enforces a few constraints (i.e, region size must be power of two, register not already used). Returns ‘None’ on failure all, Some(BarIndex) on success.

source

pub fn get_bars(&self) -> PciBarIter<'_>

Returns an iterator of the currently configured base address registers.

source

pub fn get_bar_configuration( &self, bar_num: usize ) -> Option<PciBarConfiguration>

Returns the configuration of a base address register, if present.

source

pub fn get_bar_type(&self, bar_num: PciBarIndex) -> Option<PciBarRegionType>

Returns the type of the given BAR region.

source

pub fn get_bar_addr(&self, bar_num: PciBarIndex) -> u64

Returns the address of the given BAR region.

source

pub fn set_irq(&mut self, line: u8, pin: PciInterruptPin)

Configures the IRQ line and pin used by this device.

source

pub fn add_capability( &mut self, cap_data: &dyn PciCapability, cap_config: Option<Box<dyn PciCapConfig>> ) -> Result<(), Error>

Adds the capability cap_data to the list of capabilities. cap_data should include the two-byte PCI capability header (type, next), but not populate it. Correct values will be generated automatically based on cap_data.id().

source

fn next_dword(offset: usize, len: usize) -> usize

source

fn do_write(&mut self, reg_idx: usize, value: u32)

source

pub fn snapshot(&mut self) -> Result<Value>

source

pub fn restore(&mut self, data: Value) -> Result<()>

source

pub fn setup_mapping( &mut self, shmem: &SharedMemory, base: usize, len: usize ) -> Result<()>

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V