summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Kernel/Bus/USB/SysFSUSB.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/Kernel/Bus/USB/SysFSUSB.cpp b/Kernel/Bus/USB/SysFSUSB.cpp
index b9c62d6c98..568bda9b6a 100644
--- a/Kernel/Bus/USB/SysFSUSB.cpp
+++ b/Kernel/Bus/USB/SysFSUSB.cpp
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
+ * Copyright (c) 2022, Jesse Buhagiar <jesse.buhagiar@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@@ -41,6 +42,53 @@ ErrorOr<void> SysFSUSBDeviceInformation::try_generate(KBufferBuilder& builder)
TRY(obj.add("product_string_descriptor_index", m_device->device_descriptor().product_string_descriptor_index));
TRY(obj.add("serial_number_descriptor_index", m_device->device_descriptor().serial_number_descriptor_index));
TRY(obj.add("num_configurations", m_device->device_descriptor().num_configurations));
+ TRY(obj.add("length", m_device->device_descriptor().descriptor_header.length));
+ TRY(obj.add("descriptor_type", m_device->device_descriptor().descriptor_header.descriptor_type));
+
+ auto configuration_array = TRY(obj.add_array("configurations"));
+ for (auto const& configuration : m_device->configurations()) {
+ auto configuration_object = TRY(configuration_array.add_object());
+ auto const& configuration_descriptor = configuration.descriptor();
+ TRY(configuration_object.add("length", configuration_descriptor.descriptor_header.length));
+ TRY(configuration_object.add("descriptor_type", configuration_descriptor.descriptor_header.descriptor_type));
+ TRY(configuration_object.add("total_length", configuration_descriptor.total_length));
+ TRY(configuration_object.add("number_of_interfaces", configuration_descriptor.number_of_interfaces));
+ TRY(configuration_object.add("attributes_bitmap", configuration_descriptor.attributes_bitmap));
+ TRY(configuration_object.add("max_power", configuration_descriptor.max_power_in_ma));
+
+ auto interface_array = TRY(configuration_object.add_array("interfaces"));
+ for (auto const& interface : configuration.interfaces()) {
+ auto interface_object = TRY(interface_array.add_object());
+ auto const& interface_descriptor = interface.descriptor();
+ TRY(interface_object.add("length", interface_descriptor.descriptor_header.length));
+ TRY(interface_object.add("descriptor_type", interface_descriptor.descriptor_header.descriptor_type));
+ TRY(interface_object.add("interface_number", interface_descriptor.interface_id));
+ TRY(interface_object.add("alternate_setting", interface_descriptor.alternate_setting));
+ TRY(interface_object.add("num_endpoints", interface_descriptor.number_of_endpoints));
+ TRY(interface_object.add("interface_class_code", interface_descriptor.interface_class_code));
+ TRY(interface_object.add("interface_sub_class_code", interface_descriptor.interface_sub_class_code));
+ TRY(interface_object.add("interface_protocol", interface_descriptor.interface_protocol));
+ TRY(interface_object.add("interface_string_desc_index", interface_descriptor.interface_string_descriptor_index));
+
+ auto endpoint_array = TRY(interface_object.add_array("endpoints"));
+ for (auto const& endpoint : interface.endpoints()) {
+ auto endpoint_object = TRY(endpoint_array.add_object());
+ TRY(endpoint_object.add("length", endpoint.descriptor_header.length));
+ TRY(endpoint_object.add("descriptor_length", endpoint.descriptor_header.descriptor_type));
+ TRY(endpoint_object.add("endpoint_address", endpoint.endpoint_address));
+ TRY(endpoint_object.add("attribute_bitmap", endpoint.endpoint_attributes_bitmap));
+ TRY(endpoint_object.add("max_packet_size", endpoint.max_packet_size));
+ TRY(endpoint_object.add("polling_interval", endpoint.poll_interval_in_frames));
+ TRY(endpoint_object.finish());
+ }
+ TRY(endpoint_array.finish());
+ TRY(interface_object.finish());
+ }
+ TRY(interface_array.finish());
+ TRY(configuration_object.finish());
+ }
+ TRY(configuration_array.finish());
+
TRY(obj.finish());
TRY(array.finish());
return {};