ReactOS 0.4.16-dev-297-gc569aee
debug.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS USB Port Driver
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: USBPort debugging functions
5 * COPYRIGHT: Copyright 2017 Vadim Galyant <vgal@rambler.ru>
6 */
7
8#include "usbport.h"
9
10#define NDEBUG
11#include <debug.h>
12
13#define NDEBUG_USBPORT_MINIPORT
14#define NDEBUG_USBPORT_URB
15//#define NDEBUG_USBPORT_USB2
16#include "usbdebug.h"
17
19USBPORT_DbgPrint(IN PVOID MiniPortExtension,
22 ...)
23{
24 DPRINT("USBPORT_DbgPrint: UNIMPLEMENTED. FIXME. \n");
25 return 0;
26}
27
31{
32 DPRINT("USBPORT_TestDebugBreak: UNIMPLEMENTED. FIXME. \n");
33 return 0;
34}
35
38USBPORT_AssertFailure(PVOID MiniPortExtension,
39 PVOID FailedAssertion,
43{
44 DPRINT("USBPORT_AssertFailure: ... \n");
45 RtlAssert(FailedAssertion, FileName, LineNumber, Message);
46 return 0;
47}
48
49VOID
51USBPORT_BugCheck(IN PVOID MiniPortExtension)
52{
53 DPRINT1("USBPORT_BugCheck: FIXME \n");
54 //KeBugCheckEx(BUGCODE_USB_DRIVER, ...);
56}
57
60USBPORT_LogEntry(IN PVOID MiniPortExtension,
61 IN ULONG DriverTag,
62 IN ULONG EnumTag,
63 IN ULONG P1,
64 IN ULONG P2,
65 IN ULONG P3)
66{
67 DPRINT_MINIPORT("USBPORT_LogEntry: MiniPortExtension - %p, EnumTag - %lx, P1 - %lx, P2 - %lx, P3 - %lx\n",
68 MiniPortExtension,
69 EnumTag,
70 P1,
71 P2,
72 P3);
73
74 return 0;
75}
76
77VOID
80{
82 {
83 return;
84 }
85
86 DPRINT_URB("Dumping Device Descriptor - %p\n", DeviceDescriptor);
87 DPRINT_URB("bLength - %x\n", DeviceDescriptor->bLength);
88 DPRINT_URB("bDescriptorType - %x\n", DeviceDescriptor->bDescriptorType);
89 DPRINT_URB("bcdUSB - %x\n", DeviceDescriptor->bcdUSB);
90 DPRINT_URB("bDeviceClass - %x\n", DeviceDescriptor->bDeviceClass);
91 DPRINT_URB("bDeviceSubClass - %x\n", DeviceDescriptor->bDeviceSubClass);
92 DPRINT_URB("bDeviceProtocol - %x\n", DeviceDescriptor->bDeviceProtocol);
93 DPRINT_URB("bMaxPacketSize0 - %x\n", DeviceDescriptor->bMaxPacketSize0);
94 DPRINT_URB("idVendor - %x\n", DeviceDescriptor->idVendor);
95 DPRINT_URB("idProduct - %x\n", DeviceDescriptor->idProduct);
96 DPRINT_URB("bcdDevice - %x\n", DeviceDescriptor->bcdDevice);
97 DPRINT_URB("iManufacturer - %x\n", DeviceDescriptor->iManufacturer);
98 DPRINT_URB("iProduct - %x\n", DeviceDescriptor->iProduct);
99 DPRINT_URB("iSerialNumber - %x\n", DeviceDescriptor->iSerialNumber);
100 DPRINT_URB("bNumConfigurations - %x\n", DeviceDescriptor->bNumConfigurations);
101}
102
103VOID
104NTAPI
106{
107 PUSB_INTERFACE_DESCRIPTOR iDescriptor;
109 ULONG ix;
110
111 if (!ConfigDescriptor ||
113 {
114 return;
115 }
116
117 DPRINT_URB("Dumping ConfigDescriptor - %p\n", ConfigDescriptor);
118 DPRINT_URB("bLength - %x\n", ConfigDescriptor->bLength);
119 DPRINT_URB("bDescriptorType - %x\n", ConfigDescriptor->bDescriptorType);
120 DPRINT_URB("wTotalLength - %x\n", ConfigDescriptor->wTotalLength);
121 DPRINT_URB("bNumInterfaces - %x\n", ConfigDescriptor->bNumInterfaces);
122 DPRINT_URB("bConfigurationValue - %x\n", ConfigDescriptor->bConfigurationValue);
123 DPRINT_URB("iConfiguration - %x\n", ConfigDescriptor->iConfiguration);
124 DPRINT_URB("bmAttributes - %x\n", ConfigDescriptor->bmAttributes);
125 DPRINT_URB("MaxPower - %x\n", ConfigDescriptor->MaxPower);
126
128 ConfigDescriptor->bLength);
129
130 if (iDescriptor->bLength < sizeof(USB_INTERFACE_DESCRIPTOR))
131 {
132 return;
133 }
134
135 DPRINT_URB("Dumping iDescriptor - %p\n", iDescriptor);
136 DPRINT_URB("bLength - %x\n", iDescriptor->bLength);
137 DPRINT_URB("bDescriptorType - %x\n", iDescriptor->bDescriptorType);
138 DPRINT_URB("bInterfaceNumber - %x\n", iDescriptor->bInterfaceNumber);
139 DPRINT_URB("bAlternateSetting - %x\n", iDescriptor->bAlternateSetting);
140 DPRINT_URB("bNumEndpoints - %x\n", iDescriptor->bNumEndpoints);
141 DPRINT_URB("bInterfaceClass - %x\n", iDescriptor->bInterfaceClass);
142 DPRINT_URB("bInterfaceSubClass - %x\n", iDescriptor->bInterfaceSubClass);
143 DPRINT_URB("bInterfaceProtocol - %x\n", iDescriptor->bInterfaceProtocol);
144 DPRINT_URB("iInterface - %x\n", iDescriptor->iInterface);
145
147 iDescriptor->bLength);
148
149 for (ix = 0; ix < iDescriptor->bNumEndpoints; ix++)
150 {
151 if (Descriptor->bLength < sizeof(USB_ENDPOINT_DESCRIPTOR))
152 {
153 return;
154 }
155
156 DPRINT_URB("Dumping Descriptor - %p\n", Descriptor);
157 DPRINT_URB("bLength - %x\n", Descriptor->bLength);
158 DPRINT_URB("bDescriptorType - %x\n", Descriptor->bDescriptorType);
159 DPRINT_URB("bEndpointAddress - %x\n", Descriptor->bEndpointAddress);
160 DPRINT_URB("bmAttributes - %x\n", Descriptor->bmAttributes);
161 DPRINT_URB("wMaxPacketSize - %x\n", Descriptor->wMaxPacketSize);
162 DPRINT_URB("bInterval - %x\n", Descriptor->bInterval);
163
164 Descriptor += 1;
165 }
166}
167
168VOID
169NTAPI
171{
172 if (!Capabilities)
173 {
174 return;
175 }
176
177 DPRINT("Capabilities->Size - %x\n", Capabilities->Size);
178 DPRINT("Capabilities->Version - %x\n", Capabilities->Version);
179
180 DPRINT("Capabilities->DeviceD1 - %x\n", Capabilities->DeviceD1);
181 DPRINT("Capabilities->DeviceD2 - %x\n", Capabilities->DeviceD2);
182 DPRINT("Capabilities->LockSupported - %x\n", Capabilities->LockSupported);
183 DPRINT("Capabilities->EjectSupported - %x\n", Capabilities->EjectSupported);
184 DPRINT("Capabilities->Removable - %x\n", Capabilities->Removable);
185 DPRINT("Capabilities->DockDevice - %x\n", Capabilities->DockDevice);
186 DPRINT("Capabilities->UniqueID - %x\n", Capabilities->UniqueID);
187 DPRINT("Capabilities->SilentInstall - %x\n", Capabilities->SilentInstall);
188 DPRINT("Capabilities->RawDeviceOK - %x\n", Capabilities->RawDeviceOK);
189 DPRINT("Capabilities->SurpriseRemovalOK - %x\n", Capabilities->SurpriseRemovalOK);
190
191 DPRINT("Capabilities->Address - %x\n", Capabilities->Address);
192 DPRINT("Capabilities->UINumber - %x\n", Capabilities->UINumber);
193
194 DPRINT("Capabilities->DeviceState[0] - %x\n", Capabilities->DeviceState[0]);
195 DPRINT("Capabilities->DeviceState[1] - %x\n", Capabilities->DeviceState[1]);
196 DPRINT("Capabilities->DeviceState[2] - %x\n", Capabilities->DeviceState[2]);
197 DPRINT("Capabilities->DeviceState[3] - %x\n", Capabilities->DeviceState[3]);
198 DPRINT("Capabilities->DeviceState[4] - %x\n", Capabilities->DeviceState[4]);
199 DPRINT("Capabilities->DeviceState[5] - %x\n", Capabilities->DeviceState[5]);
200 DPRINT("Capabilities->DeviceState[6] - %x\n", Capabilities->DeviceState[6]);
201
202 DPRINT("Capabilities->SystemWake - %x\n", Capabilities->SystemWake);
203 DPRINT("Capabilities->DeviceWake - %x\n", Capabilities->DeviceWake);
204
205 DPRINT("Capabilities->D1Latency - %x\n", Capabilities->D1Latency);
206 DPRINT("Capabilities->D2Latency - %x\n", Capabilities->D2Latency);
207 DPRINT("Capabilities->D3Latency - %x\n", Capabilities->D3Latency);
208}
209
210VOID
211NTAPI
213{
214 DPRINT("SetupPacket->bmRequestType.B - %x\n", SetupPacket->bmRequestType.B);
215 DPRINT("SetupPacket->bRequest - %x\n", SetupPacket->bRequest);
216 DPRINT("SetupPacket->wValue.LowByte - %x\n", SetupPacket->wValue.LowByte);
217 DPRINT("SetupPacket->wValue.HiByte - %x\n", SetupPacket->wValue.HiByte);
218 DPRINT("SetupPacket->wIndex.W - %x\n", SetupPacket->wIndex.W);
219 DPRINT("SetupPacket->wLength - %x\n", SetupPacket->wLength);
220}
221
222VOID
223NTAPI
225{
227
228 DPRINT_URB("UrbHeader.Length - %x\n", Urb->UrbHeader.Length);
229 DPRINT_URB("UrbHeader.Function - %x\n", Urb->UrbHeader.Function);
230 DPRINT_URB("UrbHeader.Status - %x\n", Urb->UrbHeader.Status);
231 DPRINT_URB("UrbHeader.UsbdDeviceHandle - %p\n", Urb->UrbHeader.UsbdDeviceHandle);
232 DPRINT_URB("UrbHeader.UsbdFlags - %x\n", Urb->UrbHeader.UsbdFlags);
233
234 if (Urb->UrbHeader.Length < 0x48)
235 {
236 return;
237 }
238
239 DPRINT_URB("PipeHandle - %p\n", Urb->UrbControlTransfer.PipeHandle);
240 DPRINT_URB("TransferFlags - %x\n", Urb->UrbControlTransfer.TransferFlags);
241 DPRINT_URB("TransferBufferLength - %x\n", Urb->UrbControlTransfer.TransferBufferLength);
242 DPRINT_URB("TransferBuffer - %p\n", Urb->UrbControlTransfer.TransferBuffer);
243 DPRINT_URB("TransferBufferMDL - %p\n", Urb->UrbControlTransfer.TransferBufferMDL);
244 DPRINT_URB("UrbLink - %p\n", Urb->UrbControlTransfer.UrbLink);
245
246 if (Urb->UrbHeader.Length < 0x50)
247 {
248 return;
249 }
250
251 SetupPacket = (PUSB_DEFAULT_PIPE_SETUP_PACKET)&Urb->UrbControlTransfer.SetupPacket;
253}
254
255VOID
256NTAPI
258{
259 PWSTR Ptr;
261 ULONG TotalLength = 0;
262
263 Ptr = (PWSTR)Buffer;
264
265 while (*Ptr)
266 {
267 DPRINT(" %S\n", Ptr);
268 Length = (ULONG)wcslen(Ptr) + 1;
269
270 Ptr += Length;
272 }
273
274 DPRINT("TotalLength: %hu\n", TotalLength);
275 DPRINT("\n");
276}
277
278VOID
279NTAPI
281{
282 DPRINT_USB2("DeviceAddress - %X\n", EndpointProperties->DeviceAddress);
283 DPRINT_USB2("EndpointAddress - %X\n", EndpointProperties->EndpointAddress);
284 DPRINT_USB2("TotalMaxPacketSize - %X\n", EndpointProperties->TotalMaxPacketSize);
285 DPRINT_USB2("Period - %X\n", EndpointProperties->Period);
286 DPRINT_USB2("DeviceSpeed - %X\n", EndpointProperties->DeviceSpeed);
287 DPRINT_USB2("UsbBandwidth - %X\n", EndpointProperties->UsbBandwidth);
288 DPRINT_USB2("ScheduleOffset - %X\n", EndpointProperties->ScheduleOffset);
289 DPRINT_USB2("TransferType - %X\n", EndpointProperties->TransferType);
290 DPRINT_USB2("MaxTransferSize - %X\n", EndpointProperties->MaxTransferSize);
291 DPRINT_USB2("HubAddr - %X\n", EndpointProperties->HubAddr);
292 DPRINT_USB2("PortNumber - %X\n", EndpointProperties->PortNumber);
293 DPRINT_USB2("InterruptScheduleMask - %X\n", EndpointProperties->InterruptScheduleMask);
294 DPRINT_USB2("SplitCompletionMask - %X\n", EndpointProperties->SplitCompletionMask);
295 DPRINT_USB2("MaxPacketSize - %X\n", EndpointProperties->MaxPacketSize);
296}
297
298VOID
299NTAPI
301{
302 DPRINT_USB2("MaxPacketSize - %X\n", TtEndpoint->MaxPacketSize);
303 DPRINT_USB2("Period - %X\n", TtEndpoint->Period);
304 DPRINT_USB2("TtEndpointParams- %X\n", TtEndpoint->TtEndpointParams.AsULONG);
305 DPRINT_USB2("CalcBusTime - %X\n", TtEndpoint->CalcBusTime);
306 DPRINT_USB2("StartTime - %X\n", TtEndpoint->StartTime);
307 DPRINT_USB2("ActualPeriod - %X\n", TtEndpoint->ActualPeriod);
308 DPRINT_USB2("StartFrame - %X\n", TtEndpoint->StartFrame);
309 DPRINT_USB2("StartMicroframe - %X\n", TtEndpoint->StartMicroframe);
310 DPRINT_USB2("Nums - %X\n", TtEndpoint->Nums.AsULONG);
311 DPRINT_USB2("nextTtEndpoint - %X\n", TtEndpoint->NextTtEndpoint);
312}
313
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 LineNumber
Definition: acpixf.h:1220
#define DPRINT1
Definition: precomp.h:8
VOID NTAPI RtlAssert(IN PVOID FailedAssertion, IN PVOID FileName, IN ULONG LineNumber, IN PCHAR Message OPTIONAL)
Definition: debug.c:492
Definition: bufpool.h:45
#define FALSE
Definition: types.h:117
static const WCHAR Message[]
Definition: register.c:74
VOID NTAPI USBPORT_DumpingEndpointProperties(IN PUSBPORT_ENDPOINT_PROPERTIES EndpointProperties)
Definition: debug.c:280
VOID NTAPI USBPORT_DumpingSetupPacket(IN PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket)
Definition: debug.c:212
VOID NTAPI USBPORT_DumpingDeviceDescriptor(IN PUSB_DEVICE_DESCRIPTOR DeviceDescriptor)
Definition: debug.c:79
VOID NTAPI USBPORT_DumpingURB(IN PURB Urb)
Definition: debug.c:224
ULONG NTAPI USBPORT_LogEntry(IN PVOID MiniPortExtension, IN ULONG DriverTag, IN ULONG EnumTag, IN ULONG P1, IN ULONG P2, IN ULONG P3)
Definition: debug.c:60
VOID NTAPI USBPORT_DumpingConfiguration(IN PUSB_CONFIGURATION_DESCRIPTOR ConfigDescriptor)
Definition: debug.c:105
VOID NTAPI USBPORT_DumpingTtEndpoint(IN PUSB2_TT_ENDPOINT TtEndpoint)
Definition: debug.c:300
VOID NTAPI USBPORT_BugCheck(IN PVOID MiniPortExtension)
Definition: debug.c:51
ULONG NTAPI USBPORT_AssertFailure(PVOID MiniPortExtension, PVOID FailedAssertion, PVOID FileName, ULONG LineNumber, PCHAR Message)
Definition: debug.c:38
VOID NTAPI USBPORT_DumpingIDs(IN PVOID Buffer)
Definition: debug.c:257
ULONG NTAPI USBPORT_TestDebugBreak(IN PVOID MiniPortExtension)
Definition: debug.c:30
VOID NTAPI USBPORT_DumpingCapabilities(IN PDEVICE_CAPABILITIES Capabilities)
Definition: debug.c:170
ULONG USBPORT_DbgPrint(IN PVOID MiniPortExtension, IN ULONG Level, IN PCH Format,...)
Definition: debug.c:19
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define ASSERT(a)
Definition: mode.c:44
CHAR * PCH
Definition: ntbasedef.h:399
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define DPRINT
Definition: sndvol32.h:73
const KSDEVICE_DESCRIPTOR DeviceDescriptor
Definition: splitter.c:257
Definition: usb.h:529
uint16_t * PWSTR
Definition: typedefs.h:56
#define NTAPI
Definition: typedefs.h:36
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
struct _USB_INTERFACE_DESCRIPTOR * PUSB_INTERFACE_DESCRIPTOR
struct _USB_ENDPOINT_DESCRIPTOR * PUSB_ENDPOINT_DESCRIPTOR
struct _USB_DEFAULT_PIPE_SETUP_PACKET * PUSB_DEFAULT_PIPE_SETUP_PACKET
#define DPRINT_USB2(...)
Definition: usbdebug.h:149
#define DPRINT_MINIPORT(...)
Definition: usbdebug.h:143
#define DPRINT_URB(...)
Definition: usbdebug.h:145
_In_ ULONG TotalLength
Definition: usbdlib.h:158
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342
_Must_inspect_result_ _In_ WDFUSBDEVICE _Out_writes_bytes_to_opt_ ConfigDescriptorLength PVOID ConfigDescriptor
Definition: wdfusb.h:1036
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _In_ PWDF_USB_CONTROL_SETUP_PACKET SetupPacket
Definition: wdfusb.h:1337
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:56
* PDEVICE_CAPABILITIES
Definition: iotypes.h:965