pub struct VirtioPciDeviceBuilder { /* private fields */ }Expand description
Builder pattern instantiation for VirtioPciDevice.
The builder implements virtio initialization. This is a multi-step process because it mixes logic specific to each virtio device type with logic applicable to all devices that use the PCI transport.
Implementations§
Source§impl VirtioPciDeviceBuilder
impl VirtioPciDeviceBuilder
Sourcepub async fn new(
pci: ClientEnd<Device>,
) -> Result<VirtioPciDeviceBuilder, Status>
pub async fn new( pci: ClientEnd<Device>, ) -> Result<VirtioPciDeviceBuilder, Status>
Returns a builder ready for feature bits negotiation.
See [offered_features()] for the next initialization step.
Sourcepub fn offered_features(&self) -> VirtioFeatureBits
pub fn offered_features(&self) -> VirtioFeatureBits
Returns the features offered by the device.
Use the result to compute device type-specific accepted features, and
then call [accept_features()].
Sourcepub async fn accept_features(
&mut self,
accepted_features: VirtioFeatureBits,
) -> Result<(), Status>
pub async fn accept_features( &mut self, accepted_features: VirtioFeatureBits, ) -> Result<(), Status>
Leaves the virtio device ready for device type-specific initialization.
accepted_features must be a subset of the bits returned by
[offered_features()].
After this method succeeds, perform device-specific initialization and
then call [build()].
The directions above entail that the method completes feature negotiation, performs transport-specific initialization, and automatically configures all discovered virtqueues.
On failure, sets DeviceStatus::driver_terminated to true, signaling
that the driver will abandon this device.
Sourcepub fn bti(&self) -> &Bti
pub fn bti(&self) -> &Bti
Returns a BTI that can pin VMOs in device-addressable memory.
Intended to be used during device type-specific initialization.
Sourcepub fn take_device_configuration(&mut self) -> Option<MmioRegion<VmoMemory>>
pub fn take_device_configuration(&mut self) -> Option<MmioRegion<VmoMemory>>
Returns the memory area that holds device-specific configuration.
The device must present at least one
[PciCapabilityType::DEVICE_CONFIGURATION] capability for any device
type that has a device type-specific configuration.
Returns None if the device does not expose any device-specific
configuration, or if the method is called more than once.
Sourcepub fn build(self) -> Result<VirtioPciDevice, Status>
pub fn build(self) -> Result<VirtioPciDevice, Status>
Consumes the builder and produces an initialized device.
Must be called after device-specific initialization is completed, which
must follow a successful call to [accept_features()].
On failure, sets DeviceStatus::driver_terminated to true, signaling
that the driver will abandon this device.
Auto Trait Implementations§
impl !RefUnwindSafe for VirtioPciDeviceBuilder
impl !Sync for VirtioPciDeviceBuilder
impl !UnwindSafe for VirtioPciDeviceBuilder
impl Freeze for VirtioPciDeviceBuilder
impl Send for VirtioPciDeviceBuilder
impl Unpin for VirtioPciDeviceBuilder
impl UnsafeUnpin for VirtioPciDeviceBuilder
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
§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]