crab_usb/backend/kmod/
mod.rs1use crate::{
2 Mmio, USBHost,
3 backend::kmod::hub::{HubId, HubInfo},
4};
5
6mod dwc;
7mod dwc2;
8mod ehci;
9mod hub;
10mod kcore;
11pub mod osal;
12pub(crate) mod queue;
13mod transfer;
14mod xhci;
15
16use alloc::{boxed::Box, collections::btree_map::BTreeMap};
17
18use dwc::Dwc;
19pub use dwc::{
20 DwcNewParams, DwcParams, NamedResetLine, ResetLine, UdphyParam, Usb2PhyParam,
21 UsbPhyInterfaceMode, usb2phy::Usb2PhyPortId,
22};
23use dwc2::Dwc2;
24pub use dwc2::{
25 Dwc2FifoSizes, Dwc2HostParams, Dwc2NewParams, Dwc2Quirks, Dwc2TransferStats, Dwc2UtmiWidth,
26};
27use ehci::Ehci;
28pub use ehci::EhciNewParams;
29use kcore::*;
30pub use osal::*;
31use usb_if::Speed;
32use xhci::Xhci;
33
34use crate::err::*;
35
36impl USBHost {
37 pub fn new_xhci(
38 mmio: Mmio,
39 coherency: DmaCoherency,
40 kernel: &'static dyn KernelOp,
41 ) -> Result<USBHost> {
42 Ok(USBHost::new(Xhci::new(mmio, coherency, kernel)?))
43 }
44
45 pub fn new_dwc(params: DwcNewParams<'_>) -> Result<USBHost> {
46 Ok(USBHost::new(Dwc::new(params)?))
47 }
48
49 pub fn new_dwc2(params: Dwc2NewParams) -> Result<USBHost> {
50 Ok(USBHost::new(Dwc2::new(params)?))
51 }
52
53 pub fn new_ehci(params: EhciNewParams) -> Result<USBHost> {
54 Ok(USBHost::new(Ehci::new(params)?))
55 }
56
57 pub(crate) fn new(backend: impl CoreOp) -> Self {
58 let b = Core::new(backend);
59 Self {
60 backend: Box::new(b),
61 initialized: false,
62 }
63 }
64}
65
66pub struct DeviceAddressInfo {
67 pub root_port_id: u8,
68 pub parent_hub: Option<HubId>,
69 pub port_speed: Speed,
70 pub port_id: u8,
71 pub infos: BTreeMap<HubId, HubInfo>,
72}