diff options
author | Jesse Buhagiar <jooster669@gmail.com> | 2022-04-18 22:20:08 +1000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-04-22 15:16:56 +0200 |
commit | 48c3c01de49756bc4aff5e32c009d7bc60028ec5 (patch) | |
tree | 92cc300d9cdae143a0c7139f3fa46970c4a80f38 /Kernel | |
parent | 300dcb6f5e2c548fa3339947ff531d3fa17cbd38 (diff) | |
download | serenity-48c3c01de49756bc4aff5e32c009d7bc60028ec5.zip |
Kernel/USB: Send correct data for Root Hub Configuration Descriptor
A request of `GET_DESCRIPTOR` should be sending the entire configuration
chain, and not just the configuration descriptor.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/Bus/USB/UHCI/UHCIRootHub.cpp | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/Kernel/Bus/USB/UHCI/UHCIRootHub.cpp b/Kernel/Bus/USB/UHCI/UHCIRootHub.cpp index 1b1dc1d7b9..2f3632c178 100644 --- a/Kernel/Bus/USB/UHCI/UHCIRootHub.cpp +++ b/Kernel/Bus/USB/UHCI/UHCIRootHub.cpp @@ -38,12 +38,12 @@ static USBConfigurationDescriptor uhci_root_hub_configuration_descriptor = { sizeof(USBConfigurationDescriptor), // 9 bytes long DESCRIPTOR_TYPE_CONFIGURATION, }, - sizeof(USBConfigurationDescriptor) + sizeof(USBInterfaceDescriptor) + sizeof(USBEndpointDescriptor) + sizeof(USBHubDescriptor), // Combined length of configuration, interface, endpoint and hub descriptors. - 1, // One interface descriptor - 1, // Configuration #1 - 0, // Index of configuration string. FIXME: There is currently no support for string descriptors. - (1 << 7) | (1 << 6), // Bit 6 is set to indicate that the root hub is self powered. Bit 7 must always be 1. - 0, // 0 mA required from the bus (self-powered) + sizeof(USBConfigurationDescriptor) + sizeof(USBInterfaceDescriptor) + sizeof(USBEndpointDescriptor), // Combined length of configuration, interface and endpoint and descriptors. + 1, // One interface descriptor + 1, // Configuration #1 + 0, // Index of configuration string. FIXME: There is currently no support for string descriptors. + (1 << 7) | (1 << 6), // Bit 6 is set to indicate that the root hub is self powered. Bit 7 must always be 1. + 0, // 0 mA required from the bus (self-powered) }; static USBInterfaceDescriptor uhci_root_hub_interface_descriptor = { @@ -153,11 +153,19 @@ ErrorOr<size_t> UHCIRootHub::handle_control_transfer(Transfer& transfer) VERIFY(length <= sizeof(USBDeviceDescriptor)); memcpy(request_data, (void*)&uhci_root_hub_device_descriptor, length); break; - case DESCRIPTOR_TYPE_CONFIGURATION: - length = min(transfer.transfer_data_size(), sizeof(USBConfigurationDescriptor)); - VERIFY(length <= sizeof(USBConfigurationDescriptor)); - memcpy(request_data, (void*)&uhci_root_hub_configuration_descriptor, length); + case DESCRIPTOR_TYPE_CONFIGURATION: { + auto index = 0u; + + // Send over the whole descriptor chain + length = uhci_root_hub_configuration_descriptor.total_length; + VERIFY(length <= sizeof(USBConfigurationDescriptor) + sizeof(USBInterfaceDescriptor) + sizeof(USBEndpointDescriptor)); + memcpy(request_data, (void*)&uhci_root_hub_configuration_descriptor, sizeof(USBConfigurationDescriptor)); + index += sizeof(uhci_root_hub_configuration_descriptor); + memcpy(request_data + index, (void*)&uhci_root_hub_interface_descriptor, sizeof(USBInterfaceDescriptor)); + index += sizeof(uhci_root_hub_interface_descriptor); + memcpy(request_data + index, (void*)&uhci_root_hub_endpoint_descriptor, sizeof(USBEndpointDescriptor)); break; + } case DESCRIPTOR_TYPE_INTERFACE: length = min(transfer.transfer_data_size(), sizeof(USBInterfaceDescriptor)); VERIFY(length <= sizeof(USBInterfaceDescriptor)); |