• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 The Chromium OS Authors. All rights reserved.
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 super::xhci_transfer::XhciTransfer;
6 
7 /// Address of this usb device, as in Set Address standard usb device request.
8 pub type UsbDeviceAddress = u32;
9 
10 /// The type USB device provided by the backend device.
11 #[derive(PartialEq, Eq)]
12 pub enum BackendType {
13     Usb2,
14     Usb3,
15 }
16 
17 /// Xhci backend device is a virtual device connected to xHCI controller. It handles xhci transfers.
18 pub trait XhciBackendDevice: Send {
19     /// Returns the type of USB device provided by this device.
get_backend_type(&self) -> BackendType20     fn get_backend_type(&self) -> BackendType;
21     /// Returns host bus number of this device.
host_bus(&self) -> u822     fn host_bus(&self) -> u8;
23     /// Returns host address of this device.
host_address(&self) -> u824     fn host_address(&self) -> u8;
25     /// Get vendor id of this device.
get_vid(&self) -> u1626     fn get_vid(&self) -> u16;
27     /// Get product id of this device.
get_pid(&self) -> u1628     fn get_pid(&self) -> u16;
29     /// Submit a xhci transfer to backend.
submit_transfer(&mut self, transfer: XhciTransfer) -> std::result::Result<(), ()>30     fn submit_transfer(&mut self, transfer: XhciTransfer) -> std::result::Result<(), ()>;
31     /// Set address of this backend.
set_address(&mut self, address: UsbDeviceAddress)32     fn set_address(&mut self, address: UsbDeviceAddress);
33     /// Reset the backend device.
reset(&mut self) -> std::result::Result<(), ()>34     fn reset(&mut self) -> std::result::Result<(), ()>;
35 }
36