From 0cd3a6b797a7450128d44aaa54e1949e91233ad0 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Mon, 14 Feb 2022 09:38:31 -0700 Subject: [PATCH] Fix scheme name for xhcid and launch drivers --- xhcid/src/main.rs | 5 +++-- xhcid/src/xhci/mod.rs | 13 +++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/xhcid/src/main.rs b/xhcid/src/main.rs index 26c57fc349..30c30049f5 100644 --- a/xhcid/src/main.rs +++ b/xhcid/src/main.rs @@ -231,8 +231,9 @@ fn main() { format!(" + XHCI {} on: {} IRQ: {}\n", name, bar, irq) ); + let scheme_name = format!("usb/{}", name); let socket_fd = syscall::open( - format!(":usb/{}", name), + format!(":{}", scheme_name), syscall::O_RDWR | syscall::O_CREAT, ) .expect("xhcid: failed to create usb scheme"); @@ -240,7 +241,7 @@ fn main() { File::from_raw_fd(socket_fd as RawFd) })); - let hci = Arc::new(Xhci::new(name, address, interrupt_method, pcid_handle).expect("xhcid: failed to allocate device")); + let hci = Arc::new(Xhci::new(scheme_name, address, interrupt_method, pcid_handle).expect("xhcid: failed to allocate device")); xhci::start_irq_reactor(&hci, irq_file); futures::executor::block_on(hci.probe()).expect("xhcid: failed to probe"); diff --git a/xhcid/src/xhci/mod.rs b/xhcid/src/xhci/mod.rs index 3fc5d75a46..083cd281bc 100644 --- a/xhcid/src/xhci/mod.rs +++ b/xhcid/src/xhci/mod.rs @@ -524,11 +524,10 @@ impl Xhci { self.update_default_control_pipe(&mut *input, slot, dev_desc).await?; } - /*match self.spawn_drivers(i, &mut port_state) { + match self.spawn_drivers(i) { Ok(()) => (), Err(err) => error!("Failed to spawn driver for port {}: `{}`", i, err), - }*/ - + } } } @@ -712,15 +711,17 @@ impl Xhci { } } - fn spawn_drivers(&self, port: usize, ps: &mut PortState) -> Result<()> { + fn spawn_drivers(&self, port: usize) -> Result<()> { // TODO: There should probably be a way to select alternate interfaces, and not just the // first one. // TODO: Now that there are some good error crates, I don't think errno.h error codes are // suitable here. + let ps = self.port_states.get(&port).unwrap(); + let ifdesc = &ps .dev_desc - .as_ref().unwrap() + .as_ref().ok_or(Error::new(EBADF))? .config_descs .first() .ok_or(Error::new(EBADF))? @@ -737,7 +738,7 @@ impl Xhci { .map(|subclass| subclass == ifdesc.sub_class) .unwrap_or(true) }) { - info!("Loading subdriver\"{}\"", driver.name); + info!("Loading subdriver \"{}\"", driver.name); let (command, args) = driver.command.split_first().ok_or(Error::new(EBADMSG))?; let if_proto = ifdesc.protocol;