ConfigSpaceCommonHeaderEmulator

Struct ConfigSpaceCommonHeaderEmulator 

Source
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>

Source

pub fn new( hardware_ids: HardwareIds, capabilities: Vec<Box<dyn PciCapability>>, bars: DeviceBars, ) -> Self

Create a new common header emulator

Source

pub const fn bar_count(&self) -> usize

Get the number of BARs supported by this emulator

Source

pub fn validate_header_type(&self, expected: HeaderType) -> bool

Validate that this emulator has the correct number of BARs for the given header type

Source

pub fn with_multi_function_bit(self, bit: bool) -> Self

If the device is multi-function, enable bit 7 in the Header register.

Source

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.

Source

pub fn reset(&mut self)

Reset the common header state

Source

pub fn hardware_ids(&self) -> &HardwareIds

Get hardware IDs

Source

pub fn capabilities(&self) -> &[Box<dyn PciCapability>]

Get capabilities

Source

pub fn capabilities_mut(&mut self) -> &mut [Box<dyn PciCapability>]

Get capabilities mutably

Source

pub fn multi_function_bit(&self) -> bool

Get multi-function bit

Source

pub const fn header_type(&self) -> HeaderType

Get the header type for this emulator

Source

pub fn command(&self) -> Command

Get current command register state

Source

pub fn base_addresses(&self) -> &[u32; N]

Get current base addresses

Source

pub fn interrupt_line(&self) -> u8

Get current interrupt line

Source

pub fn interrupt_pin(&self) -> u8

Get current interrupt pin (returns the pin number + 1, or 0 if no pin configured)

Source

pub fn set_interrupt_line(&mut self, interrupt_line: u8)

Set interrupt line (for save/restore)

Source

pub fn set_base_addresses(&mut self, base_addresses: &[u32; N])

Set base addresses (for save/restore)

Source

pub fn set_command(&mut self, command: Command)

Set command register (for save/restore)

Source

pub fn sync_command_register(&mut self, command: Command)

Sync command register changes by updating both interrupt and MMIO state

Source

pub fn update_intx_disable(&mut self, disabled: bool)

Update interrupt disable setting

Source

pub fn update_mmio_enabled(&mut self, enabled: bool)

Update MMIO enabled setting and handle BAR mapping

Source

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.

Source

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.

Source

pub fn find_bar(&self, address: u64) -> Option<(u8, u16)>

Finds a BAR + offset by address.

Source

pub fn is_pcie_device(&self) -> bool

Check if this device is a PCIe device by looking for the PCI Express capability.

Trait Implementations§

Source§

impl<const N: usize> Inspect for ConfigSpaceCommonHeaderEmulator<N>

Source§

fn inspect(&self, req: Request<'_>)

Inspects the object.
Source§

impl<const N: usize> SaveRestore for ConfigSpaceCommonHeaderEmulator<N>

Source§

type SavedState = SavedState

The concrete saved state type.
Source§

fn save(&mut self) -> Result<Self::SavedState, SaveError>

Saves the object’s state.
Source§

fn restore(&mut self, state: Self::SavedState) -> Result<(), RestoreError>

Restores the object’s state.

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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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>,

Source§

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>,

Source§

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<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more