diff options
author | Qi Zhou <atmgnd@outlook.com> | 2022-11-14 20:55:44 +0800 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2022-11-23 11:31:15 -0500 |
commit | 645a64b4911d7cadf5749d7375544fc2384e70ba (patch) | |
tree | e8d01f3c4ced5fc4858eb1d8e473ef5b11c73eae /src/hw/usb.c | |
parent | 3208b098f51a9ef96d0dfa71d5ec3a3eaec88f0a (diff) | |
download | seabios-645a64b4911d7cadf5749d7375544fc2384e70ba.tar.gz |
usb: fix wrong init of keyboard/mouse's if first interface is not boot protocol
There is always some endpoint descriptors after each interface descriptor, We
should only decrement num_iface if interface type is USB_DT_INTERFACE, see
https://www.beyondlogic.org/usbnutshell/usb5.shtml#ConfigurationDescriptors
Signed-off-by: Qi Zhou <atmgnd@outlook.com>
Diffstat (limited to 'src/hw/usb.c')
-rw-r--r-- | src/hw/usb.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/hw/usb.c b/src/hw/usb.c index 38a866ad..409da8c5 100644 --- a/src/hw/usb.c +++ b/src/hw/usb.c @@ -372,17 +372,19 @@ configure_usb_device(struct usbdevice_s *usbdev) void *config_end = (void*)config + config->wTotalLength; struct usb_interface_descriptor *iface = (void*)(&config[1]); for (;;) { - if (!num_iface-- || (void*)iface + iface->bLength > config_end) + if (!num_iface || (void*)iface + iface->bLength > config_end) // Not a supported device. goto fail; - if (iface->bDescriptorType == USB_DT_INTERFACE - && (iface->bInterfaceClass == USB_CLASS_HUB + if (iface->bDescriptorType == USB_DT_INTERFACE) { + num_iface--; + if (iface->bInterfaceClass == USB_CLASS_HUB || (iface->bInterfaceClass == USB_CLASS_MASS_STORAGE && (iface->bInterfaceProtocol == US_PR_BULK || iface->bInterfaceProtocol == US_PR_UAS)) || (iface->bInterfaceClass == USB_CLASS_HID - && iface->bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT))) - break; + && iface->bInterfaceSubClass == USB_INTERFACE_SUBCLASS_BOOT)) + break; + } iface = (void*)iface + iface->bLength; } |