Skip to main content

FakePci

Struct FakePci 

Source
pub struct FakePci { /* private fields */ }
Expand description

A fake implementation of the fpci::Device protocol for testing PCI drivers.

Implementations§

Source§

impl FakePci

Source

pub fn new() -> Self

Creates a new empty FakePci instance.

Source

pub fn set_device_info(&self, info: DeviceInfo)

Sets the [fpci::DeviceInfo] for the fake PCI device and populates header fields.

Source

pub fn device_info(&self) -> DeviceInfo

Returns the current [fpci::DeviceInfo].

Source

pub fn bus_master_enabled(&self) -> Option<bool>

Returns whether bus mastering has been enabled, or None if not set.

Source

pub fn reset_count(&self) -> u32

Returns the number of times the device has been reset.

Source

pub fn add_vmo_bar(&self, bar_id: u32, size: u64, vmo: Vmo)

Configures a VMO BAR with the given ID and size using an existing zx::Vmo.

§Panics

Panics if bar_id is invalid (>= fpci::MAX_BAR_COUNT), or if a BAR has already been set for bar_id.

Source

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.

Source

pub fn vmo_bar(&self, bar_id: u32) -> Option<Vmo>

Returns a duplicated handle to the zx::Vmo associated with bar_id, if present.

Source

pub fn add_bti(&self, index: u32, bti: Bti)

Registers a zx::Bti handle at the given index.

§Panics

Panics if a BTI is already registered at index.

Source

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:

  • id is an unknown capability ordinal.
  • position is in the configuration header or the capability exceeds configuration space bounds.
  • The capability overlaps with a previously added capability.
Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn interrupt_mode(&self) -> InterruptMode

Returns the currently configured [fpci::InterruptMode].

Source

pub fn requested_irq_count(&self) -> u32

Returns the number of requested interrupt vectors.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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§

Source§

impl Clone for FakePci

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for FakePci

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
§

impl<T, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
§

impl<F, N> FidlIntoNative<Box<N>> for F
where F: FidlIntoNative<N>,

§

fn fidl_into_native(self) -> Box<N>

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> InstanceFromServiceTransport<T> for T

§

fn from_service_transport(handle: T) -> T

Converts the given service transport handle of type T to [Self]
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.

§

impl<T> IntoAny for T
where T: 'static + Send + Sync,

§

fn into_any(self: Arc<T>) -> Arc<dyn Any + Send + Sync> ⓘ

Cast the given object into a dyn std::any::Any.
Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

§

impl<E> RunsTransport<Mpsc> for E

§

impl<E> RunsTransport<Mpsc> for E
where E: RunsTransport<Mpsc>,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.