ReactOS  0.4.14-dev-384-g5b37caa
debug.c File Reference
#include "usbport.h"
#include <debug.h>
#include "usbdebug.h"
Include dependency graph for debug.c:

Go to the source code of this file.

Macros

#define NDEBUG
 
#define NDEBUG_USBPORT_MINIPORT
 
#define NDEBUG_USBPORT_URB
 

Functions

ULONG NTAPI USBPORT_DbgPrint (IN PVOID MiniPortExtension, IN ULONG Level, IN PCH Format,...)
 
ULONG NTAPI USBPORT_TestDebugBreak (IN PVOID MiniPortExtension)
 
ULONG NTAPI USBPORT_AssertFailure (PVOID MiniPortExtension, PVOID FailedAssertion, PVOID FileName, ULONG LineNumber, PCHAR Message)
 
VOID NTAPI USBPORT_BugCheck (IN PVOID MiniPortExtension)
 
ULONG NTAPI USBPORT_LogEntry (IN PVOID MiniPortExtension, IN ULONG DriverTag, IN ULONG EnumTag, IN ULONG P1, IN ULONG P2, IN ULONG P3)
 
VOID NTAPI USBPORT_DumpingDeviceDescriptor (IN PUSB_DEVICE_DESCRIPTOR DeviceDescriptor)
 
VOID NTAPI USBPORT_DumpingConfiguration (IN PUSB_CONFIGURATION_DESCRIPTOR ConfigDescriptor)
 
VOID NTAPI USBPORT_DumpingCapabilities (IN PDEVICE_CAPABILITIES Capabilities)
 
VOID NTAPI USBPORT_DumpingSetupPacket (IN PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket)
 
VOID NTAPI USBPORT_DumpingURB (IN PURB Urb)
 
VOID NTAPI USBPORT_DumpingIDs (IN PVOID Buffer)
 
VOID NTAPI USBPORT_DumpingEndpointProperties (IN PUSBPORT_ENDPOINT_PROPERTIES EndpointProperties)
 
VOID NTAPI USBPORT_DumpingTtEndpoint (IN PUSB2_TT_ENDPOINT TtEndpoint)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 10 of file debug.c.

◆ NDEBUG_USBPORT_MINIPORT

#define NDEBUG_USBPORT_MINIPORT

Definition at line 13 of file debug.c.

◆ NDEBUG_USBPORT_URB

#define NDEBUG_USBPORT_URB

Definition at line 14 of file debug.c.

Function Documentation

◆ USBPORT_AssertFailure()

ULONG NTAPI USBPORT_AssertFailure ( PVOID  MiniPortExtension,
PVOID  FailedAssertion,
PVOID  FileName,
ULONG  LineNumber,
PCHAR  Message 
)

Definition at line 39 of file debug.c.

44 {
45  DPRINT("USBPORT_AssertFailure: ... \n");
46  RtlAssert(FailedAssertion, FileName, LineNumber, Message);
47  return 0;
48 }
VOID NTAPI RtlAssert(IN PVOID FailedAssertion, IN PVOID FileName, IN ULONG LineNumber, IN PCHAR Message OPTIONAL)
Definition: debug.c:480
void DPRINT(...)
Definition: polytest.cpp:61
CHAR Message[80]
Definition: alive.c:5
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:1212

Referenced by USBPORT_RegisterUSBPortDriver().

◆ USBPORT_BugCheck()

VOID NTAPI USBPORT_BugCheck ( IN PVOID  MiniPortExtension)

Definition at line 52 of file debug.c.

53 {
54  DPRINT1("USBPORT_BugCheck: FIXME \n");
55  //KeBugCheckEx(BUGCODE_USB_DRIVER, ...);
56  ASSERT(FALSE);
57 }
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define DPRINT1
Definition: precomp.h:8

Referenced by USBPORT_RegisterUSBPortDriver().

◆ USBPORT_DbgPrint()

ULONG NTAPI USBPORT_DbgPrint ( IN PVOID  MiniPortExtension,
IN ULONG  Level,
IN PCH  Format,
  ... 
)

Definition at line 20 of file debug.c.

24 {
25  DPRINT("USBPORT_DbgPrint: UNIMPLEMENTED. FIXME. \n");
26  return 0;
27 }
void DPRINT(...)
Definition: polytest.cpp:61

Referenced by USBPORT_RegisterUSBPortDriver().

◆ USBPORT_DumpingCapabilities()

VOID NTAPI USBPORT_DumpingCapabilities ( IN PDEVICE_CAPABILITIES  Capabilities)

Definition at line 171 of file debug.c.

172 {
173  if (!Capabilities)
174  {
175  return;
176  }
177 
178  DPRINT("Capabilities->Size - %x\n", Capabilities->Size);
179  DPRINT("Capabilities->Version - %x\n", Capabilities->Version);
180 
181  DPRINT("Capabilities->DeviceD1 - %x\n", Capabilities->DeviceD1);
182  DPRINT("Capabilities->DeviceD2 - %x\n", Capabilities->DeviceD2);
183  DPRINT("Capabilities->LockSupported - %x\n", Capabilities->LockSupported);
184  DPRINT("Capabilities->EjectSupported - %x\n", Capabilities->EjectSupported);
185  DPRINT("Capabilities->Removable - %x\n", Capabilities->Removable);
186  DPRINT("Capabilities->DockDevice - %x\n", Capabilities->DockDevice);
187  DPRINT("Capabilities->UniqueID - %x\n", Capabilities->UniqueID);
188  DPRINT("Capabilities->SilentInstall - %x\n", Capabilities->SilentInstall);
189  DPRINT("Capabilities->RawDeviceOK - %x\n", Capabilities->RawDeviceOK);
190  DPRINT("Capabilities->SurpriseRemovalOK - %x\n", Capabilities->SurpriseRemovalOK);
191 
192  DPRINT("Capabilities->Address - %x\n", Capabilities->Address);
193  DPRINT("Capabilities->UINumber - %x\n", Capabilities->UINumber);
194 
195  DPRINT("Capabilities->DeviceState[0] - %x\n", Capabilities->DeviceState[0]);
196  DPRINT("Capabilities->DeviceState[1] - %x\n", Capabilities->DeviceState[1]);
197  DPRINT("Capabilities->DeviceState[2] - %x\n", Capabilities->DeviceState[2]);
198  DPRINT("Capabilities->DeviceState[3] - %x\n", Capabilities->DeviceState[3]);
199  DPRINT("Capabilities->DeviceState[4] - %x\n", Capabilities->DeviceState[4]);
200  DPRINT("Capabilities->DeviceState[5] - %x\n", Capabilities->DeviceState[5]);
201  DPRINT("Capabilities->DeviceState[6] - %x\n", Capabilities->DeviceState[6]);
202 
203  DPRINT("Capabilities->SystemWake - %x\n", Capabilities->SystemWake);
204  DPRINT("Capabilities->DeviceWake - %x\n", Capabilities->DeviceWake);
205 
206  DPRINT("Capabilities->D1Latency - %x\n", Capabilities->D1Latency);
207  DPRINT("Capabilities->D2Latency - %x\n", Capabilities->D2Latency);
208  DPRINT("Capabilities->D3Latency - %x\n", Capabilities->D3Latency);
209 }
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
void DPRINT(...)
Definition: polytest.cpp:61

Referenced by USBPORT_QueryCapabilities().

◆ USBPORT_DumpingConfiguration()

VOID NTAPI USBPORT_DumpingConfiguration ( IN PUSB_CONFIGURATION_DESCRIPTOR  ConfigDescriptor)

Definition at line 106 of file debug.c.

107 {
108  PUSB_INTERFACE_DESCRIPTOR iDescriptor;
110  ULONG ix;
111 
112  if (!ConfigDescriptor ||
113  ConfigDescriptor->bLength < sizeof(USB_CONFIGURATION_DESCRIPTOR))
114  {
115  return;
116  }
117 
118  DPRINT_URB("Dumping ConfigDescriptor - %p\n", ConfigDescriptor);
119  DPRINT_URB("bLength - %x\n", ConfigDescriptor->bLength);
120  DPRINT_URB("bDescriptorType - %x\n", ConfigDescriptor->bDescriptorType);
121  DPRINT_URB("wTotalLength - %x\n", ConfigDescriptor->wTotalLength);
122  DPRINT_URB("bNumInterfaces - %x\n", ConfigDescriptor->bNumInterfaces);
123  DPRINT_URB("bConfigurationValue - %x\n", ConfigDescriptor->bConfigurationValue);
124  DPRINT_URB("iConfiguration - %x\n", ConfigDescriptor->iConfiguration);
125  DPRINT_URB("bmAttributes - %x\n", ConfigDescriptor->bmAttributes);
126  DPRINT_URB("MaxPower - %x\n", ConfigDescriptor->MaxPower);
127 
128  iDescriptor = (PUSB_INTERFACE_DESCRIPTOR)((ULONG_PTR)ConfigDescriptor +
129  ConfigDescriptor->bLength);
130 
131  if (iDescriptor->bLength < sizeof(USB_INTERFACE_DESCRIPTOR))
132  {
133  return;
134  }
135 
136  DPRINT_URB("Dumping iDescriptor - %p\n", iDescriptor);
137  DPRINT_URB("bLength - %x\n", iDescriptor->bLength);
138  DPRINT_URB("bDescriptorType - %x\n", iDescriptor->bDescriptorType);
139  DPRINT_URB("bInterfaceNumber - %x\n", iDescriptor->bInterfaceNumber);
140  DPRINT_URB("bAlternateSetting - %x\n", iDescriptor->bAlternateSetting);
141  DPRINT_URB("bNumEndpoints - %x\n", iDescriptor->bNumEndpoints);
142  DPRINT_URB("bInterfaceClass - %x\n", iDescriptor->bInterfaceClass);
143  DPRINT_URB("bInterfaceSubClass - %x\n", iDescriptor->bInterfaceSubClass);
144  DPRINT_URB("bInterfaceProtocol - %x\n", iDescriptor->bInterfaceProtocol);
145  DPRINT_URB("iInterface - %x\n", iDescriptor->iInterface);
146 
148  iDescriptor->bLength);
149 
150  for (ix = 0; ix < iDescriptor->bNumEndpoints; ix++)
151  {
152  if (Descriptor->bLength < sizeof(USB_ENDPOINT_DESCRIPTOR))
153  {
154  return;
155  }
156 
157  DPRINT_URB("Dumping Descriptor - %p\n", Descriptor);
158  DPRINT_URB("bLength - %x\n", Descriptor->bLength);
159  DPRINT_URB("bDescriptorType - %x\n", Descriptor->bDescriptorType);
160  DPRINT_URB("bEndpointAddress - %x\n", Descriptor->bEndpointAddress);
161  DPRINT_URB("bmAttributes - %x\n", Descriptor->bmAttributes);
162  DPRINT_URB("wMaxPacketSize - %x\n", Descriptor->wMaxPacketSize);
163  DPRINT_URB("bInterval - %x\n", Descriptor->bInterval);
164 
165  Descriptor += 1;
166  }
167 }
#define DPRINT_URB(...)
Definition: usbdebug.h:145
struct _USB_INTERFACE_DESCRIPTOR * PUSB_INTERFACE_DESCRIPTOR
uint32_t ULONG_PTR
Definition: typedefs.h:63
struct _USB_ENDPOINT_DESCRIPTOR * PUSB_ENDPOINT_DESCRIPTOR
unsigned int ULONG
Definition: retypes.h:1
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966

Referenced by USBPORT_HandleSelectConfiguration().

◆ USBPORT_DumpingDeviceDescriptor()

VOID NTAPI USBPORT_DumpingDeviceDescriptor ( IN PUSB_DEVICE_DESCRIPTOR  DeviceDescriptor)

Definition at line 80 of file debug.c.

81 {
82  if (!DeviceDescriptor)
83  {
84  return;
85  }
86 
87  DPRINT_URB("Dumping Device Descriptor - %p\n", DeviceDescriptor);
88  DPRINT_URB("bLength - %x\n", DeviceDescriptor->bLength);
89  DPRINT_URB("bDescriptorType - %x\n", DeviceDescriptor->bDescriptorType);
90  DPRINT_URB("bcdUSB - %x\n", DeviceDescriptor->bcdUSB);
91  DPRINT_URB("bDeviceClass - %x\n", DeviceDescriptor->bDeviceClass);
92  DPRINT_URB("bDeviceSubClass - %x\n", DeviceDescriptor->bDeviceSubClass);
93  DPRINT_URB("bDeviceProtocol - %x\n", DeviceDescriptor->bDeviceProtocol);
94  DPRINT_URB("bMaxPacketSize0 - %x\n", DeviceDescriptor->bMaxPacketSize0);
95  DPRINT_URB("idVendor - %x\n", DeviceDescriptor->idVendor);
96  DPRINT_URB("idProduct - %x\n", DeviceDescriptor->idProduct);
97  DPRINT_URB("bcdDevice - %x\n", DeviceDescriptor->bcdDevice);
98  DPRINT_URB("iManufacturer - %x\n", DeviceDescriptor->iManufacturer);
99  DPRINT_URB("iProduct - %x\n", DeviceDescriptor->iProduct);
100  DPRINT_URB("iSerialNumber - %x\n", DeviceDescriptor->iSerialNumber);
101  DPRINT_URB("bNumConfigurations - %x\n", DeviceDescriptor->bNumConfigurations);
102 }
#define DPRINT_URB(...)
Definition: usbdebug.h:145
const KSDEVICE_DESCRIPTOR DeviceDescriptor
Definition: splitter.c:257

Referenced by USBHI_GetUsbDescriptors(), and USBHI_QueryDeviceInformation().

◆ USBPORT_DumpingEndpointProperties()

VOID NTAPI USBPORT_DumpingEndpointProperties ( IN PUSBPORT_ENDPOINT_PROPERTIES  EndpointProperties)

Definition at line 281 of file debug.c.

282 {
283  DPRINT_USB2("DeviceAddress - %X\n", EndpointProperties->DeviceAddress);
284  DPRINT_USB2("EndpointAddress - %X\n", EndpointProperties->EndpointAddress);
285  DPRINT_USB2("TotalMaxPacketSize - %X\n", EndpointProperties->TotalMaxPacketSize);
286  DPRINT_USB2("Period - %X\n", EndpointProperties->Period);
287  DPRINT_USB2("DeviceSpeed - %X\n", EndpointProperties->DeviceSpeed);
288  DPRINT_USB2("UsbBandwidth - %X\n", EndpointProperties->UsbBandwidth);
289  DPRINT_USB2("ScheduleOffset - %X\n", EndpointProperties->ScheduleOffset);
290  DPRINT_USB2("TransferType - %X\n", EndpointProperties->TransferType);
291  DPRINT_USB2("MaxTransferSize - %X\n", EndpointProperties->MaxTransferSize);
292  DPRINT_USB2("HubAddr - %X\n", EndpointProperties->HubAddr);
293  DPRINT_USB2("PortNumber - %X\n", EndpointProperties->PortNumber);
294  DPRINT_USB2("InterruptScheduleMask - %X\n", EndpointProperties->InterruptScheduleMask);
295  DPRINT_USB2("SplitCompletionMask - %X\n", EndpointProperties->SplitCompletionMask);
296  DPRINT_USB2("MaxPacketSize - %X\n", EndpointProperties->MaxPacketSize);
297 }
#define DPRINT_USB2(...)
Definition: usbdebug.h:149

Referenced by USBPORT_AllocateBandwidthUSB2().

◆ USBPORT_DumpingIDs()

VOID NTAPI USBPORT_DumpingIDs ( IN PVOID  Buffer)

Definition at line 258 of file debug.c.

259 {
260  PWSTR Ptr;
261  ULONG Length;
262  ULONG TotalLength = 0;
263 
264  Ptr = (PWSTR)Buffer;
265 
266  while (*Ptr)
267  {
268  DPRINT(" %S\n", Ptr);
269  Length = (ULONG)wcslen(Ptr) + 1;
270 
271  Ptr += Length;
272  TotalLength += Length;
273  }
274 
275  DPRINT("TotalLength: %hu\n", TotalLength);
276  DPRINT("\n");
277 }
uint16_t * PWSTR
Definition: typedefs.h:54
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
_In_ ULONG TotalLength
Definition: usbdlib.h:145
void DPRINT(...)
Definition: polytest.cpp:61
Definition: bufpool.h:45
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
unsigned int ULONG
Definition: retypes.h:1
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)

Referenced by USBPORT_GetDeviceHwIds().

◆ USBPORT_DumpingSetupPacket()

VOID NTAPI USBPORT_DumpingSetupPacket ( IN PUSB_DEFAULT_PIPE_SETUP_PACKET  SetupPacket)

Definition at line 213 of file debug.c.

214 {
215  DPRINT("SetupPacket->bmRequestType.B - %x\n", SetupPacket->bmRequestType.B);
216  DPRINT("SetupPacket->bRequest - %x\n", SetupPacket->bRequest);
217  DPRINT("SetupPacket->wValue.LowByte - %x\n", SetupPacket->wValue.LowByte);
218  DPRINT("SetupPacket->wValue.HiByte - %x\n", SetupPacket->wValue.HiByte);
219  DPRINT("SetupPacket->wIndex.W - %x\n", SetupPacket->wIndex.W);
220  DPRINT("SetupPacket->wLength - %x\n", SetupPacket->wLength);
221 }
void DPRINT(...)
Definition: polytest.cpp:61

Referenced by USBPORT_DumpingURB(), USBPORT_HandleGetConfiguration(), USBPORT_HandleGetSetDescriptor(), USBPORT_HandleGetStatus(), USBPORT_HandleSetOrClearFeature(), and USBPORT_HandleVendorOrClass().

◆ USBPORT_DumpingTtEndpoint()

VOID NTAPI USBPORT_DumpingTtEndpoint ( IN PUSB2_TT_ENDPOINT  TtEndpoint)

Definition at line 301 of file debug.c.

302 {
303  DPRINT_USB2("MaxPacketSize - %X\n", TtEndpoint->MaxPacketSize);
304  DPRINT_USB2("Period - %X\n", TtEndpoint->Period);
305  DPRINT_USB2("TtEndpointParams- %X\n", TtEndpoint->TtEndpointParams.AsULONG);
306  DPRINT_USB2("CalcBusTime - %X\n", TtEndpoint->CalcBusTime);
307  DPRINT_USB2("StartTime - %X\n", TtEndpoint->StartTime);
308  DPRINT_USB2("ActualPeriod - %X\n", TtEndpoint->ActualPeriod);
309  DPRINT_USB2("StartFrame - %X\n", TtEndpoint->StartFrame);
310  DPRINT_USB2("StartMicroframe - %X\n", TtEndpoint->StartMicroframe);
311  DPRINT_USB2("Nums - %X\n", TtEndpoint->Nums.AsULONG);
312  DPRINT_USB2("nextTtEndpoint - %X\n", TtEndpoint->NextTtEndpoint);
313 }
#define DPRINT_USB2(...)
Definition: usbdebug.h:149

Referenced by USBPORT_AllocateBandwidthUSB2().

◆ USBPORT_DumpingURB()

VOID NTAPI USBPORT_DumpingURB ( IN PURB  Urb)

Definition at line 225 of file debug.c.

226 {
227  PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket;
228 
229  DPRINT_URB("UrbHeader.Length - %x\n", Urb->UrbHeader.Length);
230  DPRINT_URB("UrbHeader.Function - %x\n", Urb->UrbHeader.Function);
231  DPRINT_URB("UrbHeader.Status - %x\n", Urb->UrbHeader.Status);
232  DPRINT_URB("UrbHeader.UsbdDeviceHandle - %p\n", Urb->UrbHeader.UsbdDeviceHandle);
233  DPRINT_URB("UrbHeader.UsbdFlags - %x\n", Urb->UrbHeader.UsbdFlags);
234 
235  if (Urb->UrbHeader.Length < 0x48)
236  {
237  return;
238  }
239 
240  DPRINT_URB("PipeHandle - %p\n", Urb->UrbControlTransfer.PipeHandle);
241  DPRINT_URB("TransferFlags - %x\n", Urb->UrbControlTransfer.TransferFlags);
242  DPRINT_URB("TransferBufferLength - %x\n", Urb->UrbControlTransfer.TransferBufferLength);
243  DPRINT_URB("TransferBuffer - %p\n", Urb->UrbControlTransfer.TransferBuffer);
244  DPRINT_URB("TransferBufferMDL - %p\n", Urb->UrbControlTransfer.TransferBufferMDL);
245  DPRINT_URB("UrbLink - %p\n", Urb->UrbControlTransfer.UrbLink);
246 
247  if (Urb->UrbHeader.Length < 0x50)
248  {
249  return;
250  }
251 
252  SetupPacket = (PUSB_DEFAULT_PIPE_SETUP_PACKET)&Urb->UrbControlTransfer.SetupPacket;
253  USBPORT_DumpingSetupPacket(SetupPacket);
254 }
VOID NTAPI USBPORT_DumpingSetupPacket(IN PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket)
Definition: debug.c:213
#define DPRINT_URB(...)
Definition: usbdebug.h:145
struct _USB_DEFAULT_PIPE_SETUP_PACKET * PUSB_DEFAULT_PIPE_SETUP_PACKET

Referenced by USBPORT_CompleteTransfer(), USBPORT_ValidateTransferParametersURB(), and USBPORT_ValidateURB().

◆ USBPORT_LogEntry()

ULONG NTAPI USBPORT_LogEntry ( IN PVOID  MiniPortExtension,
IN ULONG  DriverTag,
IN ULONG  EnumTag,
IN ULONG  P1,
IN ULONG  P2,
IN ULONG  P3 
)

Definition at line 61 of file debug.c.

67 {
68  DPRINT_MINIPORT("USBPORT_LogEntry: MiniPortExtension - %p, EnumTag - %lx, P1 - %lx, P2 - %lx, P3 - %lx\n",
69  MiniPortExtension,
70  EnumTag,
71  P1,
72  P2,
73  P3);
74 
75  return 0;
76 }
#define DPRINT_MINIPORT(...)
Definition: usbdebug.h:143

Referenced by USBPORT_RegisterUSBPortDriver().

◆ USBPORT_TestDebugBreak()

ULONG NTAPI USBPORT_TestDebugBreak ( IN PVOID  MiniPortExtension)

Definition at line 31 of file debug.c.

32 {
33  DPRINT("USBPORT_TestDebugBreak: UNIMPLEMENTED. FIXME. \n");
34  return 0;
35 }
void DPRINT(...)
Definition: polytest.cpp:61

Referenced by USBPORT_RegisterUSBPortDriver().