ReactOS  0.4.14-dev-358-gbef841c
misc.c File Reference
#include "usbhub.h"
#include <debug.h>
Include dependency graph for misc.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOID DumpDeviceDescriptor (PUSB_DEVICE_DESCRIPTOR DeviceDescriptor)
 
VOID DumpConfigurationDescriptor (PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor)
 
VOID DumpFullConfigurationDescriptor (PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor)
 
NTSTATUS NTAPI ForwardIrpAndWaitCompletion (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
 
NTSTATUS ForwardIrpAndWait (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS ForwardIrpAndForget (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS SubmitRequestToRootHub (IN PDEVICE_OBJECT RootHubDeviceObject, IN ULONG IoControlCode, OUT PVOID OutParameter1, OUT PVOID OutParameter2)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file misc.c.

Function Documentation

◆ DumpConfigurationDescriptor()

VOID DumpConfigurationDescriptor ( PUSB_CONFIGURATION_DESCRIPTOR  ConfigurationDescriptor)

Definition at line 38 of file misc.c.

39 {
40  DPRINT1("Dumping ConfigurationDescriptor %x\n", ConfigurationDescriptor);
41  DPRINT1("bLength %x\n", ConfigurationDescriptor->bLength);
42  DPRINT1("bDescriptorType %x\n", ConfigurationDescriptor->bDescriptorType);
43  DPRINT1("wTotalLength %x\n", ConfigurationDescriptor->wTotalLength);
44  DPRINT1("bNumInterfaces %x\n", ConfigurationDescriptor->bNumInterfaces);
45  DPRINT1("bConfigurationValue %x\n", ConfigurationDescriptor->bConfigurationValue);
46  DPRINT1("iConfiguration %x\n", ConfigurationDescriptor->iConfiguration);
47  DPRINT1("bmAttributes %x\n", ConfigurationDescriptor->bmAttributes);
48  DPRINT1("MaxPower %x\n", ConfigurationDescriptor->MaxPower);
49 }
#define DPRINT1
Definition: precomp.h:8

◆ DumpDeviceDescriptor()

VOID DumpDeviceDescriptor ( PUSB_DEVICE_DESCRIPTOR  DeviceDescriptor)

Definition at line 17 of file misc.c.

18 {
19  DPRINT1("Dumping Device Descriptor %x\n", DeviceDescriptor);
20  DPRINT1("bLength %x\n", DeviceDescriptor->bLength);
21  DPRINT1("bDescriptorType %x\n", DeviceDescriptor->bDescriptorType);
22  DPRINT1("bcdUSB %x\n", DeviceDescriptor->bcdUSB);
23  DPRINT1("bDeviceClass %x\n", DeviceDescriptor->bDeviceClass);
24  DPRINT1("bDeviceSubClass %x\n", DeviceDescriptor->bDeviceSubClass);
25  DPRINT1("bDeviceProtocol %x\n", DeviceDescriptor->bDeviceProtocol);
26  DPRINT1("bMaxPacketSize0 %x\n", DeviceDescriptor->bMaxPacketSize0);
27  DPRINT1("idVendor %x\n", DeviceDescriptor->idVendor);
28  DPRINT1("idProduct %x\n", DeviceDescriptor->idProduct);
29  DPRINT1("bcdDevice %x\n", DeviceDescriptor->bcdDevice);
30  DPRINT1("iManufacturer %x\n", DeviceDescriptor->iManufacturer);
31  DPRINT1("iProduct %x\n", DeviceDescriptor->iProduct);
32  DPRINT1("iSerialNumber %x\n", DeviceDescriptor->iSerialNumber);
33  DPRINT1("bNumConfigurations %x\n", DeviceDescriptor->bNumConfigurations);
34 }
const KSDEVICE_DESCRIPTOR DeviceDescriptor
Definition: splitter.c:257
#define DPRINT1
Definition: precomp.h:8

◆ DumpFullConfigurationDescriptor()

VOID DumpFullConfigurationDescriptor ( PUSB_CONFIGURATION_DESCRIPTOR  ConfigurationDescriptor)

Definition at line 52 of file misc.c.

53 {
54  PUSB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
55  PUSB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
56  LONG i, j;
57 
58  DPRINT1("Dumping ConfigurationDescriptor %x\n", ConfigurationDescriptor);
59  DPRINT1("bLength %x\n", ConfigurationDescriptor->bLength);
60  DPRINT1("bDescriptorType %x\n", ConfigurationDescriptor->bDescriptorType);
61  DPRINT1("wTotalLength %x\n", ConfigurationDescriptor->wTotalLength);
62  DPRINT1("bNumInterfaces %x\n", ConfigurationDescriptor->bNumInterfaces);
63  DPRINT1("bConfigurationValue %x\n", ConfigurationDescriptor->bConfigurationValue);
64  DPRINT1("iConfiguration %x\n", ConfigurationDescriptor->iConfiguration);
65  DPRINT1("bmAttributes %x\n", ConfigurationDescriptor->bmAttributes);
66  DPRINT1("MaxPower %x\n", ConfigurationDescriptor->MaxPower);
67 
68  InterfaceDescriptor = (PUSB_INTERFACE_DESCRIPTOR) ((ULONG_PTR)ConfigurationDescriptor + sizeof(USB_CONFIGURATION_DESCRIPTOR));
69 
70  for (i=0; i < ConfigurationDescriptor->bNumInterfaces; i++)
71  {
72  DPRINT1("- Dumping InterfaceDescriptor %x\n", InterfaceDescriptor);
73  DPRINT1(" bLength %x\n", InterfaceDescriptor->bLength);
74  DPRINT1(" bDescriptorType %x\n", InterfaceDescriptor->bDescriptorType);
75  DPRINT1(" bInterfaceNumber %x\n", InterfaceDescriptor->bInterfaceNumber);
76  DPRINT1(" bAlternateSetting %x\n", InterfaceDescriptor->bAlternateSetting);
77  DPRINT1(" bNumEndpoints %x\n", InterfaceDescriptor->bNumEndpoints);
78  DPRINT1(" bInterfaceClass %x\n", InterfaceDescriptor->bInterfaceClass);
79  DPRINT1(" bInterfaceSubClass %x\n", InterfaceDescriptor->bInterfaceSubClass);
80  DPRINT1(" bInterfaceProtocol %x\n", InterfaceDescriptor->bInterfaceProtocol);
81  DPRINT1(" iInterface %x\n", InterfaceDescriptor->iInterface);
82 
83  EndpointDescriptor = (PUSB_ENDPOINT_DESCRIPTOR) ((ULONG_PTR)InterfaceDescriptor + sizeof(USB_INTERFACE_DESCRIPTOR));
84 
85  for (j=0; j < InterfaceDescriptor->bNumEndpoints; j++)
86  {
87  DPRINT1(" bLength %x\n", EndpointDescriptor->bLength);
88  DPRINT1(" bDescriptorType %x\n", EndpointDescriptor->bDescriptorType);
89  DPRINT1(" bEndpointAddress %x\n", EndpointDescriptor->bEndpointAddress);
90  DPRINT1(" bmAttributes %x\n", EndpointDescriptor->bmAttributes);
91  DPRINT1(" wMaxPacketSize %x\n", EndpointDescriptor->wMaxPacketSize);
92  DPRINT1(" bInterval %x\n", EndpointDescriptor->bInterval);
93  EndpointDescriptor = (PUSB_ENDPOINT_DESCRIPTOR) ((ULONG_PTR)EndpointDescriptor + sizeof(USB_ENDPOINT_DESCRIPTOR));
94  }
95  InterfaceDescriptor = (PUSB_INTERFACE_DESCRIPTOR)(ULONG_PTR)EndpointDescriptor;
96  }
97 }
struct _USB_INTERFACE_DESCRIPTOR * PUSB_INTERFACE_DESCRIPTOR
uint32_t ULONG_PTR
Definition: typedefs.h:63
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
long LONG
Definition: pedump.c:60
struct _USB_INTERFACE_DESCRIPTOR USB_INTERFACE_DESCRIPTOR
struct _USB_ENDPOINT_DESCRIPTOR * PUSB_ENDPOINT_DESCRIPTOR
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
struct _USB_ENDPOINT_DESCRIPTOR USB_ENDPOINT_DESCRIPTOR
struct _USB_CONFIGURATION_DESCRIPTOR USB_CONFIGURATION_DESCRIPTOR
#define DPRINT1
Definition: precomp.h:8

◆ ForwardIrpAndForget()

NTSTATUS ForwardIrpAndForget ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 137 of file misc.c.

140 {
141  PDEVICE_OBJECT LowerDevice = ((PHUB_DEVICE_EXTENSION)DeviceObject->DeviceExtension)->LowerDeviceObject;
142 
143  ASSERT(LowerDevice);
144 
146  return IoCallDriver(LowerDevice, Irp);
147 }
_In_ PIRP Irp
Definition: csq.h:116
struct _HUB_DEVICE_EXTENSION * PHUB_DEVICE_EXTENSION
PVOID DeviceExtension
Definition: env_spec_w32.h:418
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421

◆ ForwardIrpAndWait()

NTSTATUS ForwardIrpAndWait ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 113 of file misc.c.

116 {
117  KEVENT Event;
119 
122 
124 
126  if (Status == STATUS_PENDING)
127  {
129  if (NT_SUCCESS(Status))
130  Status = Irp->IoStatus.Status;
131  }
132 
133  return Status;
134 }
#define TRUE
Definition: types.h:120
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
NTSTATUS NTAPI ForwardIrpAndWaitCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: misc.c:101
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2820
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218

◆ ForwardIrpAndWaitCompletion()

NTSTATUS NTAPI ForwardIrpAndWaitCompletion ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PVOID  Context 
)

Definition at line 101 of file misc.c.

105 {
106  if (Irp->PendingReturned)
108 
110 }
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68
_In_ PIRP Irp
Definition: csq.h:116
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
#define IO_NO_INCREMENT
Definition: iotypes.h:566

Referenced by ForwardIrpAndWait().

◆ SubmitRequestToRootHub()

NTSTATUS SubmitRequestToRootHub ( IN PDEVICE_OBJECT  RootHubDeviceObject,
IN ULONG  IoControlCode,
OUT PVOID  OutParameter1,
OUT PVOID  OutParameter2 
)

Definition at line 150 of file misc.c.

155 {
156  KEVENT Event;
157  PIRP Irp;
160  PIO_STACK_LOCATION Stack = NULL;
161 
163 
164  //
165  // Build Control Request
166  //
168  RootHubDeviceObject,
169  NULL, 0,
170  NULL, 0,
171  TRUE,
172  &Event,
173  &IoStatus);
174 
175  if (Irp == NULL)
176  {
177  DPRINT("Usbhub: IoBuildDeviceIoControlRequest() failed\n");
179  }
180 
181  //
182  // Initialize the status block before sending the IRP
183  //
185  IoStatus.Information = 0;
186 
187  //
188  // Get Next Stack Location and Initialize it
189  //
191  Stack->Parameters.Others.Argument1 = OutParameter1;
192  Stack->Parameters.Others.Argument2 = OutParameter2;
193 
194  //
195  // Call RootHub
196  //
197  Status = IoCallDriver(RootHubDeviceObject, Irp);
198 
199  //
200  // Its ok to block here as this function is called in an nonarbitrary thread
201  //
202  if (Status == STATUS_PENDING)
203  {
205  Status = IoStatus.Status;
206  }
207 
208  //
209  // The IO Manager will free the IRP
210  //
211 
212  return Status;
213 }
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ PFILE_OBJECT _In_ ULONG IoControlCode
Definition: fltkernel.h:1383
IN PLARGE_INTEGER IN ULONG IN BOOLEAN IN ULONG IN BOOLEAN OUT PIO_STATUS_BLOCK IoStatus
Definition: fatprocs.h:2650
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define STATUS_PENDING
Definition: ntstatus.h:82
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
Status
Definition: gdiplustypes.h:24
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
Definition: irp.c:881
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772

Referenced by ClearPortFeature(), GetPortStatusAndChange(), GetUsbDeviceDescriptor(), SetPortFeature(), USBHUB_FdoStartDevice(), USBHUB_IsRootHubFDO(), and USBHUB_ParentFDOStartDevice().