strat9_kernel/hardware/usb/mod.rs
1// USB subsystem
2//
3// Supports:
4// - xHCI (USB 3.0)
5// - EHCI (USB 2.0)
6// - UHCI (USB 1.1)
7// - HID devices (keyboard, mouse)
8
9pub mod ehci;
10pub mod hid;
11pub mod uhci;
12pub mod xhci;
13
14/// Performs the init operation.
15pub fn init() {
16 // Initialize controllers in order: xHCI first (USB 3.0), then EHCI (USB 2.0), then UHCI (USB 1.1)
17 // This ensures we use the fastest available controller for each device
18
19 log::info!("[USB] Initializing USB subsystem...");
20
21 // xHCI (USB 3.0) - must be initialized first as it may control EHCI
22 xhci::init();
23
24 // EHCI (USB 2.0)
25 ehci::init();
26
27 // UHCI (USB 1.1) - for legacy devices
28 uhci::init();
29
30 // Initialize HID drivers after controllers are ready
31 hid::init();
32
33 let total_controllers = (if xhci::is_available() { 1 } else { 0 })
34 + (if ehci::is_available() { 1 } else { 0 })
35 + (if uhci::is_available() { 1 } else { 0 });
36
37 log::info!("[USB] Total USB controllers: {}", total_controllers);
38}