pub struct FakePci { /* private fields */ }Expand description
A fake implementation of the fpci::Device protocol for testing PCI drivers.
Implementations§
Source§impl FakePci
impl FakePci
Sourcepub fn set_device_info(&self, info: DeviceInfo)
pub fn set_device_info(&self, info: DeviceInfo)
Sets the [fpci::DeviceInfo] for the fake PCI device and populates header fields.
Sourcepub fn device_info(&self) -> DeviceInfo
pub fn device_info(&self) -> DeviceInfo
Returns the current [fpci::DeviceInfo].
Sourcepub fn bus_master_enabled(&self) -> Option<bool>
pub fn bus_master_enabled(&self) -> Option<bool>
Returns whether bus mastering has been enabled, or None if not set.
Sourcepub fn reset_count(&self) -> u32
pub fn reset_count(&self) -> u32
Returns the number of times the device has been reset.
Sourcepub fn add_vmo_bar(&self, bar_id: u32, size: u64, vmo: Vmo)
pub fn add_vmo_bar(&self, bar_id: u32, size: u64, vmo: Vmo)
Sourcepub fn create_vmo_bar(&self, bar_id: u32, size: u64)
pub fn create_vmo_bar(&self, bar_id: u32, size: u64)
Creates and configures a new VMO BAR with the given ID and size.
§Panics
Panics if VMO creation fails, or under the same conditions as
Self::add_vmo_bar.
Sourcepub fn vmo_bar(&self, bar_id: u32) -> Option<Vmo>
pub fn vmo_bar(&self, bar_id: u32) -> Option<Vmo>
Returns a duplicated handle to the zx::Vmo associated with bar_id, if present.
Sourcepub fn add_capability(&self, id: CapabilityId, position: u8, size: u8)
pub fn add_capability(&self, id: CapabilityId, position: u8, size: u8)
Adds a PCI capability at the specified offset in configuration space.
§Panics
Panics if:
idis an unknown capability ordinal.positionis in the configuration header or the capability exceeds configuration space bounds.- The capability overlaps with a previously added capability.
Sourcepub fn add_vendor_capability(&self, position: u8, size: u8)
pub fn add_vendor_capability(&self, position: u8, size: u8)
Adds a vendor-specific PCI capability at the specified offset.
§Panics
Panics if size <= 2, or under the same conditions as
Self::add_capability.
Sourcepub fn add_pci_express_capability(&self, position: u8)
pub fn add_pci_express_capability(&self, position: u8)
Adds a PCI Express capability at the specified offset.
§Panics
Panics under the same conditions as Self::add_capability.
Sourcepub fn add_legacy_interrupt(&self) -> Arc<VirtualInterrupt> ⓘ
pub fn add_legacy_interrupt(&self) -> Arc<VirtualInterrupt> ⓘ
Adds a legacy virtual interrupt and returns its zx::VirtualInterrupt.
§Panics
Panics if creation of the virtual interrupt fails, or if a legacy interrupt has already been added.
Sourcepub fn add_msi_interrupt(&self) -> Arc<VirtualInterrupt> ⓘ
pub fn add_msi_interrupt(&self) -> Arc<VirtualInterrupt> ⓘ
Adds an MSI virtual interrupt and returns its zx::VirtualInterrupt.
Subsequent calls populate interrupts at incrementing indices.
§Panics
Panics if creation of the virtual interrupt fails, or if the number of MSI interrupts exceeds the protocol maximum.
Sourcepub fn add_msix_interrupt(&self) -> Arc<VirtualInterrupt> ⓘ
pub fn add_msix_interrupt(&self) -> Arc<VirtualInterrupt> ⓘ
Adds an MSI-X virtual interrupt and returns its zx::VirtualInterrupt.
Subsequent calls populate interrupts at incrementing indices.
§Panics
Panics if creation of the virtual interrupt fails, or if the number of MSI-X interrupts exceeds the protocol maximum.
Sourcepub fn interrupt_mode(&self) -> InterruptMode
pub fn interrupt_mode(&self) -> InterruptMode
Returns the currently configured [fpci::InterruptMode].
Sourcepub fn requested_irq_count(&self) -> u32
pub fn requested_irq_count(&self) -> u32
Returns the number of requested interrupt vectors.
Sourcepub fn read_config8(&self, offset: u16) -> u8
pub fn read_config8(&self, offset: u16) -> u8
Reads an 8-bit value from configuration space at offset.
§Panics
Panics if the read exceeds configuration space bounds.
Sourcepub fn read_config16(&self, offset: u16) -> u16
pub fn read_config16(&self, offset: u16) -> u16
Reads a 16-bit value from configuration space at offset.
§Panics
Panics if the read exceeds configuration space bounds.
Sourcepub fn read_config32(&self, offset: u16) -> u32
pub fn read_config32(&self, offset: u16) -> u32
Reads a 32-bit value from configuration space at offset.
§Panics
Panics if the read exceeds configuration space bounds.
Sourcepub fn write_config8(&self, offset: u16, value: u8)
pub fn write_config8(&self, offset: u16, value: u8)
Writes an 8-bit value to configuration space at offset.
§Panics
Panics if offset is in the configuration header or the write
exceeds configuration space bounds.
Sourcepub fn write_config16(&self, offset: u16, value: u16)
pub fn write_config16(&self, offset: u16, value: u16)
Writes a 16-bit value to configuration space at offset.
§Panics
Panics if offset is in the configuration header or the write
exceeds configuration space bounds.
Sourcepub fn write_config32(&self, offset: u16, value: u32)
pub fn write_config32(&self, offset: u16, value: u32)
Writes a 32-bit value to configuration space at offset.
§Panics
Panics if offset is in the configuration header or the write
exceeds configuration space bounds.
Sourcepub fn serve<O: ServiceObjTrait>(
&self,
service_fs: &mut ServiceFs<O>,
scope: ScopeHandle,
instance_name: &str,
) -> Offer
pub fn serve<O: ServiceObjTrait>( &self, service_fs: &mut ServiceFs<O>, scope: ScopeHandle, instance_name: &str, ) -> Offer
Offers the fpci::Service to service_fs and returns the [fdf::Offer].
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for FakePci
impl !UnwindSafe for FakePci
impl Freeze for FakePci
impl Send for FakePci
impl Sync for FakePci
impl Unpin for FakePci
impl UnsafeUnpin for FakePci
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
impl<F, N> FidlIntoNative<Box<N>> for Fwhere
F: FidlIntoNative<N>,
fn fidl_into_native(self) -> Box<N>
§impl<T> InstanceFromServiceTransport<T> for T
impl<T> InstanceFromServiceTransport<T> for T
§fn from_service_transport(handle: T) -> T
fn from_service_transport(handle: T) -> T
T to [Self]§impl<T> IntoAny for T
impl<T> IntoAny for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more