Struct devices::usb::xhci::device_slot::DeviceSlot
source · pub struct DeviceSlot {
slot_id: u8,
port_id: PortId,
dcbaap: Register<u64>,
hub: Arc<UsbHub>,
interrupter: Arc<Mutex<Interrupter>>,
event_loop: Arc<EventLoop>,
mem: GuestMemory,
enabled: AtomicBool,
transfer_ring_controllers: Mutex<Vec<Option<TransferRingControllers>>>,
}
Fields§
§slot_id: u8
§port_id: PortId
§dcbaap: Register<u64>
§hub: Arc<UsbHub>
§interrupter: Arc<Mutex<Interrupter>>
§event_loop: Arc<EventLoop>
§mem: GuestMemory
§enabled: AtomicBool
§transfer_ring_controllers: Mutex<Vec<Option<TransferRingControllers>>>
Implementations§
source§impl DeviceSlot
impl DeviceSlot
sourcepub fn new(
slot_id: u8,
dcbaap: Register<u64>,
hub: Arc<UsbHub>,
interrupter: Arc<Mutex<Interrupter>>,
event_loop: Arc<EventLoop>,
mem: GuestMemory
) -> Self
pub fn new( slot_id: u8, dcbaap: Register<u64>, hub: Arc<UsbHub>, interrupter: Arc<Mutex<Interrupter>>, event_loop: Arc<EventLoop>, mem: GuestMemory ) -> Self
Create a new device slot.
fn get_trc( &self, i: usize, stream_id: u16 ) -> Option<Arc<RingBufferController<TransferRingTrbHandler>>>
fn get_trcs(&self, i: usize) -> Option<TransferRingControllers>
fn set_trcs(&self, i: usize, trc: Option<TransferRingControllers>)
fn trc_len(&self) -> usize
sourcepub fn ring_doorbell(&self, target: u8, stream_id: u16) -> Result<bool, Error>
pub fn ring_doorbell(&self, target: u8, stream_id: u16) -> Result<bool, Error>
The arguments are identical to the fields in each doorbell register. The target value: 1: Reserved 2: Control endpoint 3: Endpoint 1 out 4: Endpoint 1 in 5: Endpoint 2 out … 32: Endpoint 15 in
Steam ID will be useful when host controller support streams. The stream ID must be zero for endpoints that do not have streams configured. This function will return false if it fails to trigger transfer ring start.
sourcepub fn enable(&self) -> bool
pub fn enable(&self) -> bool
Enable the slot. This function returns false if it’s already enabled.
sourcepub fn disable<C: FnMut(TrbCompletionCode) -> Result<(), ()> + 'static + Send>(
fail_handle: Arc<dyn FailHandle>,
slot: &Arc<DeviceSlot>,
callback: C
) -> Result<(), Error>
pub fn disable<C: FnMut(TrbCompletionCode) -> Result<(), ()> + 'static + Send>( fail_handle: Arc<dyn FailHandle>, slot: &Arc<DeviceSlot>, callback: C ) -> Result<(), Error>
Disable this device slot. If the slot is not enabled, callback will be invoked immediately with error. Otherwise, callback will be invoked when all trc is stopped.
pub fn set_address( self: &Arc<Self>, trb: &AddressDeviceCommandTrb ) -> Result<TrbCompletionCode, Error>
pub fn configure_endpoint( self: &Arc<Self>, trb: &ConfigureEndpointCommandTrb ) -> Result<TrbCompletionCode, Error>
pub fn evaluate_context( &self, trb: &EvaluateContextCommandTrb ) -> Result<TrbCompletionCode, Error>
sourcepub fn reset_slot<C: FnMut(TrbCompletionCode) -> Result<(), ()> + 'static + Send>(
fail_handle: Arc<dyn FailHandle>,
slot: &Arc<DeviceSlot>,
callback: C
) -> Result<(), Error>
pub fn reset_slot<C: FnMut(TrbCompletionCode) -> Result<(), ()> + 'static + Send>( fail_handle: Arc<dyn FailHandle>, slot: &Arc<DeviceSlot>, callback: C ) -> Result<(), Error>
Reset the device slot to default state and deconfigures all but the control endpoint.
sourcepub fn stop_all_trc(&self, auto_callback: RingBufferStopCallback)
pub fn stop_all_trc(&self, auto_callback: RingBufferStopCallback)
Stop all transfer ring controllers.
sourcepub fn stop_endpoint<C: FnMut(TrbCompletionCode) -> Result<(), ()> + 'static + Send>(
&self,
fail_handle: Arc<dyn FailHandle>,
endpoint_id: u8,
cb: C
) -> Result<(), Error>
pub fn stop_endpoint<C: FnMut(TrbCompletionCode) -> Result<(), ()> + 'static + Send>( &self, fail_handle: Arc<dyn FailHandle>, endpoint_id: u8, cb: C ) -> Result<(), Error>
Stop an endpoint.
sourcepub fn reset_endpoint<C: FnMut(TrbCompletionCode) -> Result<(), ()> + 'static + Send>(
&self,
fail_handle: Arc<dyn FailHandle>,
endpoint_id: u8,
cb: C
) -> Result<(), Error>
pub fn reset_endpoint<C: FnMut(TrbCompletionCode) -> Result<(), ()> + 'static + Send>( &self, fail_handle: Arc<dyn FailHandle>, endpoint_id: u8, cb: C ) -> Result<(), Error>
Reset an endpoint.
sourcepub fn set_tr_dequeue_ptr(
&self,
endpoint_id: u8,
stream_id: u16,
ptr: u64
) -> Result<TrbCompletionCode, Error>
pub fn set_tr_dequeue_ptr( &self, endpoint_id: u8, stream_id: u16, ptr: u64 ) -> Result<TrbCompletionCode, Error>
Set transfer ring dequeue pointer.
fn reset(&self)
fn create_stream_trcs( self: &Arc<Self>, stream_context_array_addr: GuestAddress, max_pstreams: u8, device_context_index: u8 ) -> Result<TransferRingControllers, Error>
fn add_one_endpoint( self: &Arc<Self>, device_context_index: u8 ) -> Result<(), Error>
fn drop_one_endpoint( self: &Arc<Self>, device_context_index: u8 ) -> Result<(), Error>
fn get_device_context(&self) -> Result<DeviceContext, Error>
fn set_device_context(&self, device_context: DeviceContext) -> Result<(), Error>
fn copy_context( &self, input_context_ptr: GuestAddress, device_context_index: u8 ) -> Result<(), Error>
fn get_device_context_addr(&self) -> Result<GuestAddress, Error>
fn set_state(&self, state: DeviceSlotState) -> Result<(), Error>
pub fn halt_endpoint(&self, endpoint_id: u8) -> Result<(), Error>
Auto Trait Implementations§
impl !RefUnwindSafe for DeviceSlot
impl Send for DeviceSlot
impl Sync for DeviceSlot
impl Unpin for DeviceSlot
impl !UnwindSafe for DeviceSlot
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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.