xhcid: Fix a bunch of things to make usb storage work

configuration_value is not an index into config_descs, so scan for a
config_desc with the right configuration_value instead. And fix get_desc
getting confused by companion descriptors.
This commit is contained in:
bjorn3
2025-03-09 17:03:50 +01:00
parent 258ea4e6a5
commit 674b8c6724
4 changed files with 23 additions and 19 deletions
-1
View File
@@ -22,7 +22,6 @@
//! - USB2 - [Universal Serial Bus Specification](https://www.usb.org/document-library/usb-20-specification)
//! - USB32 - [Universal Serial Bus 3.2 Specification Revision 1.1](https://usb.org/document-library/usb-32-revision-11-june-2022)
//!
#![warn(missing_docs)]
pub extern crate plain;
mod driver_interface;
-1
View File
@@ -22,7 +22,6 @@
//! - USB2 - [Universal Serial Bus Specification](https://www.usb.org/document-library/usb-20-specification)
//! - USB32 - [Universal Serial Bus 3.2 Specification Revision 1.1](https://usb.org/document-library/usb-32-revision-11-june-2022)
//!
#![warn(missing_docs)]
#[macro_use]
extern crate bitflags;
+6 -1
View File
@@ -300,7 +300,12 @@ impl PortState {
//TODO: fetch using endpoint number instead
fn get_endp_desc(&self, endp_idx: u8) -> Option<&EndpDesc> {
let cfg_idx = self.cfg_idx?;
let config_desc = self.dev_desc.as_ref()?.config_descs.get(cfg_idx as usize)?;
let config_desc = self
.dev_desc
.as_ref()?
.config_descs
.iter()
.find(|desc| desc.configuration_value == cfg_idx)?;
let mut endp_count = 0;
for if_desc in config_desc.interface_descs.iter() {
for endp_desc in if_desc.endpoints.iter() {
+17 -16
View File
@@ -918,8 +918,10 @@ impl Xhci {
.as_ref()
.unwrap()
.config_descs
.get(usize::from(req.config_desc))
.ok_or(Error::new(EBADFD))?;
.iter()
.find(|desc| desc.configuration_value == req.config_desc)
.ok_or(Error::new(EBADFD))
.unwrap();
//TODO: USE ENDPOINTS FROM ALL INTERFACES
let mut endp_desc_count = 0;
@@ -1459,7 +1461,7 @@ impl Xhci {
}
let mut interface_descs = SmallVec::new();
let mut iter = descriptors.into_iter();
let mut iter = descriptors.into_iter().peekable();
while let Some(item) = iter.next() {
if let AnyDescriptor::Interface(idesc) = item {
@@ -1481,21 +1483,20 @@ impl Xhci {
};
let mut endp = EndpDesc::from(next);
if supports_superspeed {
let next = match iter.next() {
Some(AnyDescriptor::SuperSpeedCompanion(n)) => n,
loop {
match iter.peek() {
Some(AnyDescriptor::SuperSpeedCompanion(n)) => {
endp.ssc = Some(SuperSpeedCmp::from(n.clone()));
iter.next().unwrap();
}
Some(AnyDescriptor::SuperSpeedPlusCompanion(n)) => {
endp.sspc = Some(SuperSpeedPlusIsochCmp::from(n.clone()));
iter.next().unwrap();
}
_ => break,
};
endp.ssc = Some(SuperSpeedCmp::from(next));
if endp.has_ssp_companion() && supports_superspeedplus {
let next = match iter.next() {
Some(AnyDescriptor::SuperSpeedPlusCompanion(n)) => n,
_ => break,
};
endp.sspc = Some(SuperSpeedPlusIsochCmp::from(next));
}
}
endpoints.push(endp);
}
@@ -1506,7 +1507,7 @@ impl Xhci {
} else {
log::warn!("expected interface, got {:?}", item);
// TODO
break;
//break;
}
}