1 /*
2 * PROJECT: ReactOS USB Hub Driver
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: USBHub debugging functions
5 * COPYRIGHT: Copyright 2017 Vadim Galyant <vgal@rambler.ru>
6 */
7
8 #include "usbhub.h"
9
10 #define NDEBUG
11 #include <debug.h>
12
13 VOID
14 NTAPI
USBHUB_DumpingDeviceDescriptor(IN PUSB_DEVICE_DESCRIPTOR DeviceDescriptor)15 USBHUB_DumpingDeviceDescriptor(IN PUSB_DEVICE_DESCRIPTOR DeviceDescriptor)
16 {
17 if (!DeviceDescriptor)
18 {
19 return;
20 }
21
22 DPRINT("Dumping Device Descriptor - %p\n", DeviceDescriptor);
23 DPRINT("bLength - %x\n", DeviceDescriptor->bLength);
24 DPRINT("bDescriptorType - %x\n", DeviceDescriptor->bDescriptorType);
25 DPRINT("bcdUSB - %x\n", DeviceDescriptor->bcdUSB);
26 DPRINT("bDeviceClass - %x\n", DeviceDescriptor->bDeviceClass);
27 DPRINT("bDeviceSubClass - %x\n", DeviceDescriptor->bDeviceSubClass);
28 DPRINT("bDeviceProtocol - %x\n", DeviceDescriptor->bDeviceProtocol);
29 DPRINT("bMaxPacketSize0 - %x\n", DeviceDescriptor->bMaxPacketSize0);
30 DPRINT("idVendor - %x\n", DeviceDescriptor->idVendor);
31 DPRINT("idProduct - %x\n", DeviceDescriptor->idProduct);
32 DPRINT("bcdDevice - %x\n", DeviceDescriptor->bcdDevice);
33 DPRINT("iManufacturer - %x\n", DeviceDescriptor->iManufacturer);
34 DPRINT("iProduct - %x\n", DeviceDescriptor->iProduct);
35 DPRINT("iSerialNumber - %x\n", DeviceDescriptor->iSerialNumber);
36 DPRINT("bNumConfigurations - %x\n", DeviceDescriptor->bNumConfigurations);
37 }
38
39 VOID
40 NTAPI
USBHUB_DumpingConfiguration(IN PUSB_CONFIGURATION_DESCRIPTOR ConfigDescriptor)41 USBHUB_DumpingConfiguration(IN PUSB_CONFIGURATION_DESCRIPTOR ConfigDescriptor)
42 {
43 PUSB_COMMON_DESCRIPTOR Descriptor;
44 PUSB_CONFIGURATION_DESCRIPTOR cDescriptor;
45 PUSB_INTERFACE_DESCRIPTOR iDescriptor;
46 PUSB_ENDPOINT_DESCRIPTOR eDescriptor;
47
48 if (!ConfigDescriptor)
49 {
50 return;
51 }
52
53 Descriptor = (PUSB_COMMON_DESCRIPTOR)ConfigDescriptor;
54
55 while ((ULONG_PTR)Descriptor <
56 ((ULONG_PTR)ConfigDescriptor + ConfigDescriptor->wTotalLength) &&
57 Descriptor->bLength)
58 {
59 if (Descriptor->bDescriptorType == USB_CONFIGURATION_DESCRIPTOR_TYPE)
60 {
61 cDescriptor = (PUSB_CONFIGURATION_DESCRIPTOR)Descriptor;
62
63 DPRINT("Dumping cDescriptor - %p\n", cDescriptor);
64 DPRINT("bLength - %x\n", cDescriptor->bLength);
65 DPRINT("bDescriptorType - %x\n", cDescriptor->bDescriptorType);
66 DPRINT("wTotalLength - %x\n", cDescriptor->wTotalLength);
67 DPRINT("bNumInterfaces - %x\n", cDescriptor->bNumInterfaces);
68 DPRINT("bConfigurationValue - %x\n", cDescriptor->bConfigurationValue);
69 DPRINT("iConfiguration - %x\n", cDescriptor->iConfiguration);
70 DPRINT("bmAttributes - %x\n", cDescriptor->bmAttributes);
71 DPRINT("MaxPower - %x\n", cDescriptor->MaxPower);
72 }
73 else if (Descriptor->bDescriptorType == USB_INTERFACE_DESCRIPTOR_TYPE)
74 {
75 iDescriptor = (PUSB_INTERFACE_DESCRIPTOR)Descriptor;
76
77 DPRINT("Dumping iDescriptor - %p\n", iDescriptor);
78 DPRINT("bLength - %x\n", iDescriptor->bLength);
79 DPRINT("bDescriptorType - %x\n", iDescriptor->bDescriptorType);
80 DPRINT("bInterfaceNumber - %x\n", iDescriptor->bInterfaceNumber);
81 DPRINT("bAlternateSetting - %x\n", iDescriptor->bAlternateSetting);
82 DPRINT("bNumEndpoints - %x\n", iDescriptor->bNumEndpoints);
83 DPRINT("bInterfaceClass - %x\n", iDescriptor->bInterfaceClass);
84 DPRINT("bInterfaceSubClass - %x\n", iDescriptor->bInterfaceSubClass);
85 DPRINT("bInterfaceProtocol - %x\n", iDescriptor->bInterfaceProtocol);
86 DPRINT("iInterface - %x\n", iDescriptor->iInterface);
87 }
88 else if (Descriptor->bDescriptorType == USB_ENDPOINT_DESCRIPTOR_TYPE)
89 {
90 eDescriptor = (PUSB_ENDPOINT_DESCRIPTOR)Descriptor;
91
92 DPRINT("Dumping Descriptor - %p\n", eDescriptor);
93 DPRINT("bLength - %x\n", eDescriptor->bLength);
94 DPRINT("bDescriptorType - %x\n", eDescriptor->bDescriptorType);
95 DPRINT("bEndpointAddress - %x\n", eDescriptor->bEndpointAddress);
96 DPRINT("bmAttributes - %x\n", eDescriptor->bmAttributes);
97 DPRINT("wMaxPacketSize - %x\n", eDescriptor->wMaxPacketSize);
98 DPRINT("bInterval - %x\n", eDescriptor->bInterval);
99 }
100 else
101 {
102 DPRINT("bDescriptorType - %x\n", Descriptor->bDescriptorType);
103 }
104
105 Descriptor = (PUSB_COMMON_DESCRIPTOR)((ULONG_PTR)Descriptor +
106 Descriptor->bLength);
107 }
108 }
109
110 VOID
111 NTAPI
USBHUB_DumpingIDs(IN PVOID Id)112 USBHUB_DumpingIDs(IN PVOID Id)
113 {
114 PWSTR Ptr;
115 size_t Length;
116 size_t TotalLength = 0;
117
118 Ptr = Id;
119 DPRINT("USBHUB_DumpingIDs:\n");
120
121 while (*Ptr)
122 {
123 DPRINT(" %S\n", Ptr);
124 Length = wcslen(Ptr) + 1;
125
126 Ptr += Length;
127 TotalLength += Length;
128 }
129
130 DPRINT("TotalLength: %Iu\n", TotalLength);
131 DPRINT("\n");
132 }
133