ReactOS  0.4.14-dev-604-gcfdd483
debug.c
Go to the documentation of this file.
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
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
42 {
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  {
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  {
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 
106  Descriptor->bLength);
107  }
108 }
109 
110 VOID
111 NTAPI
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 }
#define IN
Definition: typedefs.h:38
VOID NTAPI USBHUB_DumpingIDs(IN PVOID Id)
Definition: debug.c:112
uint16_t * PWSTR
Definition: typedefs.h:54
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
VOID NTAPI USBHUB_DumpingConfiguration(IN PUSB_CONFIGURATION_DESCRIPTOR ConfigDescriptor)
Definition: debug.c:41
struct _USB_INTERFACE_DESCRIPTOR * PUSB_INTERFACE_DESCRIPTOR
_In_ ULONG TotalLength
Definition: usbdlib.h:145
DWORD Id
uint32_t ULONG_PTR
Definition: typedefs.h:63
struct _USB_CONFIGURATION_DESCRIPTOR * PUSB_CONFIGURATION_DESCRIPTOR
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define USB_CONFIGURATION_DESCRIPTOR_TYPE
Definition: usb100.h:50
#define USB_INTERFACE_DESCRIPTOR_TYPE
Definition: usb100.h:52
void DPRINT(...)
Definition: polytest.cpp:61
struct _USB_ENDPOINT_DESCRIPTOR * PUSB_ENDPOINT_DESCRIPTOR
const KSDEVICE_DESCRIPTOR DeviceDescriptor
Definition: splitter.c:257
struct _USB_COMMON_DESCRIPTOR * PUSB_COMMON_DESCRIPTOR
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define USB_ENDPOINT_DESCRIPTOR_TYPE
Definition: usb100.h:53
VOID NTAPI USBHUB_DumpingDeviceDescriptor(IN PUSB_DEVICE_DESCRIPTOR DeviceDescriptor)
Definition: debug.c:15
#define ULONG_PTR
Definition: config.h:101
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966