pub struct UsbPort {
ty: BackendType,
port_id: u8,
portsc: Register<u32>,
usbsts: Register<u32>,
interrupter: Arc<Mutex<Interrupter>>,
backend_device: Mutex<Option<Arc<Mutex<BackendDeviceType>>>>,
}
Expand description
A port on usb hub. It could have a device connected to it.
Fields§
§ty: BackendType
§port_id: u8
§portsc: Register<u32>
§usbsts: Register<u32>
§interrupter: Arc<Mutex<Interrupter>>
§backend_device: Mutex<Option<Arc<Mutex<BackendDeviceType>>>>
Implementations§
source§impl UsbPort
impl UsbPort
sourcepub fn new(
ty: BackendType,
port_id: u8,
portsc: Register<u32>,
usbsts: Register<u32>,
interrupter: Arc<Mutex<Interrupter>>
) -> UsbPort
pub fn new( ty: BackendType, port_id: u8, portsc: Register<u32>, usbsts: Register<u32>, interrupter: Arc<Mutex<Interrupter>> ) -> UsbPort
Create a new usb port that has nothing connected to it.
fn port_id(&self) -> u8
sourcepub fn detach(&self) -> Result<(), Error>
pub fn detach(&self) -> Result<(), Error>
Detach current connected backend. Returns an error when there is no backend connected.
sourcepub fn backend_device(
&self
) -> MutexGuard<'_, Option<Arc<Mutex<BackendDeviceType>>>>
pub fn backend_device( &self ) -> MutexGuard<'_, Option<Arc<Mutex<BackendDeviceType>>>>
Get current connected backend.
fn is_attached(&self) -> bool
fn reset(&self) -> Result<(), InterrupterError>
fn attach( &self, device: Arc<Mutex<BackendDeviceType>> ) -> Result<(), InterrupterError>
sourcepub fn send_device_connected_event(&self) -> Result<(), InterrupterError>
pub fn send_device_connected_event(&self) -> Result<(), InterrupterError>
Inform the guest kernel there is device connected to this port. It combines first few steps of USB device initialization process in xHCI spec 4.3.
sourcepub fn send_device_disconnected_event(&self) -> Result<(), InterrupterError>
pub fn send_device_disconnected_event(&self) -> Result<(), InterrupterError>
Inform the guest kernel that device has been detached.
Auto Trait Implementations§
impl RefUnwindSafe for UsbPort
impl Send for UsbPort
impl Sync for UsbPort
impl Unpin for UsbPort
impl UnwindSafe for UsbPort
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
Mutably borrows from an owned value. Read more
§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>
Convert
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>
Convert
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)
Convert
&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)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.