pub struct ConfigSpaceCommonHeaderEmulator<const N: usize> { /* private fields */ }Expand description
Common emulator for shared PCI configuration space functionality. Generic over the number of BARs (6 for Type 0, 2 for Type 1).
Implementations§
Source§impl<const N: usize> ConfigSpaceCommonHeaderEmulator<N>
impl<const N: usize> ConfigSpaceCommonHeaderEmulator<N>
Sourcepub fn new(
hardware_ids: HardwareIds,
capabilities: Vec<Box<dyn PciCapability>>,
bars: DeviceBars,
) -> Self
pub fn new( hardware_ids: HardwareIds, capabilities: Vec<Box<dyn PciCapability>>, bars: DeviceBars, ) -> Self
Create a new common header emulator
Sourcepub fn validate_header_type(&self, expected: HeaderType) -> bool
pub fn validate_header_type(&self, expected: HeaderType) -> bool
Validate that this emulator has the correct number of BARs for the given header type
Sourcepub fn with_multi_function_bit(self, bit: bool) -> Self
pub fn with_multi_function_bit(self, bit: bool) -> Self
If the device is multi-function, enable bit 7 in the Header register.
Sourcepub fn set_interrupt_pin(
&mut self,
pin: PciInterruptPin,
line: LineInterrupt,
) -> Arc<IntxInterrupt>
pub fn set_interrupt_pin( &mut self, pin: PciInterruptPin, line: LineInterrupt, ) -> Arc<IntxInterrupt>
If using legacy INT#x interrupts: wire a LineInterrupt to one of the 4 INT#x pins, returning an object that manages configuration space bits when the device sets the interrupt level.
Sourcepub fn hardware_ids(&self) -> &HardwareIds
pub fn hardware_ids(&self) -> &HardwareIds
Get hardware IDs
Sourcepub fn capabilities(&self) -> &[Box<dyn PciCapability>]
pub fn capabilities(&self) -> &[Box<dyn PciCapability>]
Get capabilities
Sourcepub fn capabilities_mut(&mut self) -> &mut [Box<dyn PciCapability>]
pub fn capabilities_mut(&mut self) -> &mut [Box<dyn PciCapability>]
Get capabilities mutably
Sourcepub fn multi_function_bit(&self) -> bool
pub fn multi_function_bit(&self) -> bool
Get multi-function bit
Sourcepub const fn header_type(&self) -> HeaderType
pub const fn header_type(&self) -> HeaderType
Get the header type for this emulator
Sourcepub fn base_addresses(&self) -> &[u32; N]
pub fn base_addresses(&self) -> &[u32; N]
Get current base addresses
Sourcepub fn interrupt_line(&self) -> u8
pub fn interrupt_line(&self) -> u8
Get current interrupt line
Sourcepub fn interrupt_pin(&self) -> u8
pub fn interrupt_pin(&self) -> u8
Get current interrupt pin (returns the pin number + 1, or 0 if no pin configured)
Sourcepub fn set_interrupt_line(&mut self, interrupt_line: u8)
pub fn set_interrupt_line(&mut self, interrupt_line: u8)
Set interrupt line (for save/restore)
Sourcepub fn set_base_addresses(&mut self, base_addresses: &[u32; N])
pub fn set_base_addresses(&mut self, base_addresses: &[u32; N])
Set base addresses (for save/restore)
Sourcepub fn set_command(&mut self, command: Command)
pub fn set_command(&mut self, command: Command)
Set command register (for save/restore)
Sourcepub fn sync_command_register(&mut self, command: Command)
pub fn sync_command_register(&mut self, command: Command)
Sync command register changes by updating both interrupt and MMIO state
Sourcepub fn update_intx_disable(&mut self, disabled: bool)
pub fn update_intx_disable(&mut self, disabled: bool)
Update interrupt disable setting
Sourcepub fn update_mmio_enabled(&mut self, enabled: bool)
pub fn update_mmio_enabled(&mut self, enabled: bool)
Update MMIO enabled setting and handle BAR mapping
Sourcepub fn read_u32(&self, offset: u16, value: &mut u32) -> CommonHeaderResult
pub fn read_u32(&self, offset: u16, value: &mut u32) -> CommonHeaderResult
Read from the config space. offset must be 32-bit aligned.
Returns CommonHeaderResult indicating if handled, unhandled, or failed.
Sourcepub fn write_u32(&mut self, offset: u16, val: u32) -> CommonHeaderResult
pub fn write_u32(&mut self, offset: u16, val: u32) -> CommonHeaderResult
Write to the config space. offset must be 32-bit aligned.
Returns CommonHeaderResult indicating if handled, unhandled, or failed.
Sourcepub fn is_pcie_device(&self) -> bool
pub fn is_pcie_device(&self) -> bool
Check if this device is a PCIe device by looking for the PCI Express capability.