Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
google
GitHub Repository: google/crosvm
Path: blob/main/devices/src/usb/xhci/xhci_backend_device.rs
5394 views
1
// Copyright 2019 The ChromiumOS Authors
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
use usb_util::DeviceSpeed;
6
7
use crate::usb::backend::error::Result;
8
9
/// Address of this usb device, as in Set Address standard usb device request.
10
pub type UsbDeviceAddress = u32;
11
12
/// The type USB device provided by the backend device.
13
#[derive(PartialEq, Eq)]
14
pub enum BackendType {
15
Usb2,
16
Usb3,
17
}
18
19
/// Xhci backend device is a virtual device connected to xHCI controller. It handles xhci transfers.
20
pub trait XhciBackendDevice: Send + Sync {
21
/// Returns the type of USB device provided by this device.
22
fn get_backend_type(&self) -> BackendType;
23
/// Get vendor id of this device.
24
fn get_vid(&self) -> u16;
25
/// Get product id of this device.
26
fn get_pid(&self) -> u16;
27
/// Set address of this backend.
28
fn set_address(&mut self, address: UsbDeviceAddress);
29
/// Reset the backend device.
30
fn reset(&mut self) -> Result<()>;
31
/// Get speed of this device.
32
fn get_speed(&self) -> Option<DeviceSpeed>;
33
/// Allocate streams for the endpoint
34
fn alloc_streams(&self, ep: u8, num_streams: u16) -> Result<()>;
35
/// Free streams for the endpoint
36
fn free_streams(&self, ep: u8) -> Result<()>;
37
/// Stop the backend device, allowing it to execute cleanup routines.
38
fn stop(&mut self);
39
}
40
41