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

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

NTSTATUS NTAPI USBSTOR_SyncForwardIrpCompletionRoutine (PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context)
 
NTSTATUS NTAPI USBCCGP_SyncForwardIrp (PDEVICE_OBJECT DeviceObject, PIRP Irp)
 
NTSTATUS USBCCGP_SyncUrbRequest (IN PDEVICE_OBJECT DeviceObject, OUT PURB UrbRequest)
 
PVOID AllocateItem (IN POOL_TYPE PoolType, IN ULONG ItemSize)
 
VOID FreeItem (IN PVOID Item)
 
VOID DumpFunctionDescriptor (IN PUSBC_FUNCTION_DESCRIPTOR FunctionDescriptor, IN ULONG FunctionDescriptorCount)
 

Variables

IO_COMPLETION_ROUTINE SyncForwardIrpCompletionRoutine
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 14 of file misc.c.

Function Documentation

◆ AllocateItem()

PVOID AllocateItem ( IN POOL_TYPE  PoolType,
IN ULONG  ItemSize 
)

Definition at line 134 of file misc.c.

137 {
138  /* Allocate item */
140 
141  if (Item)
142  {
143  /* Zero item */
144  RtlZeroMemory(Item, ItemSize);
145  }
146 
147  /* Return element */
148  return Item;
149 }
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
static UCHAR ItemSize[4]
Definition: parser.c:16
#define USBCCPG_TAG
Definition: usbccgp.h:39
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE _In_ SIZE_T _In_ POOL_TYPE PoolType
Definition: fltkernel.h:1444

◆ DumpFunctionDescriptor()

VOID DumpFunctionDescriptor ( IN PUSBC_FUNCTION_DESCRIPTOR  FunctionDescriptor,
IN ULONG  FunctionDescriptorCount 
)

Definition at line 160 of file misc.c.

163 {
164  ULONG Index, SubIndex;
165 
166 
167  DPRINT1("FunctionCount %lu\n", FunctionDescriptorCount);
168  for (Index = 0; Index < FunctionDescriptorCount; Index++)
169  {
170  DPRINT1("Function %lu\n", Index);
171  DPRINT1("FunctionNumber %lu\n", FunctionDescriptor[Index].FunctionNumber);
172  DPRINT1("HardwareId %S\n", FunctionDescriptor[Index].HardwareId.Buffer);
173  DPRINT1("CompatibleId %S\n", FunctionDescriptor[Index].CompatibleId.Buffer);
174  DPRINT1("FunctionDescription %wZ\n", &FunctionDescriptor[Index].FunctionDescription);
175  DPRINT1("NumInterfaces %lu\n", FunctionDescriptor[Index].NumberOfInterfaces);
176 
177  for(SubIndex = 0; SubIndex < FunctionDescriptor[Index].NumberOfInterfaces; SubIndex++)
178  {
179  DPRINT1(" Index %lu Interface %p\n", SubIndex, FunctionDescriptor[Index].InterfaceDescriptorList[SubIndex]);
180  DPRINT1(" Index %lu Interface InterfaceNumber %x\n", SubIndex, FunctionDescriptor[Index].InterfaceDescriptorList[SubIndex]->bInterfaceNumber);
181  DPRINT1(" Index %lu Interface Alternate %x\n", SubIndex, FunctionDescriptor[Index].InterfaceDescriptorList[SubIndex]->bAlternateSetting );
182  DPRINT1(" Index %lu bLength %x\n", SubIndex, FunctionDescriptor[Index].InterfaceDescriptorList[SubIndex]->bLength);
183  DPRINT1(" Index %lu bDescriptorType %x\n", SubIndex, FunctionDescriptor[Index].InterfaceDescriptorList[SubIndex]->bDescriptorType);
184  DPRINT1(" Index %lu bInterfaceNumber %x\n", SubIndex, FunctionDescriptor[Index].InterfaceDescriptorList[SubIndex]->bInterfaceNumber);
185  DPRINT1(" Index %lu bAlternateSetting %x\n", SubIndex, FunctionDescriptor[Index].InterfaceDescriptorList[SubIndex]->bAlternateSetting);
186  DPRINT1(" Index %lu bNumEndpoints %x\n", SubIndex, FunctionDescriptor[Index].InterfaceDescriptorList[SubIndex]->bNumEndpoints);
187  DPRINT1(" Index %lu bInterfaceClass %x\n", SubIndex, FunctionDescriptor[Index].InterfaceDescriptorList[SubIndex]->bInterfaceClass);
188  DPRINT1(" Index %lu bInterfaceSubClass %x\n", SubIndex, FunctionDescriptor[Index].InterfaceDescriptorList[SubIndex]->bInterfaceSubClass);
189  DPRINT1(" Index %lu bInterfaceProtocol %x\n", SubIndex, FunctionDescriptor[Index].InterfaceDescriptorList[SubIndex]->bInterfaceProtocol);
190  DPRINT1(" Index %lu iInterface %x\n", SubIndex, FunctionDescriptor[Index].InterfaceDescriptorList[SubIndex]->iInterface);
191  }
192  }
193 }
static const UCHAR Index[8]
Definition: usbohci.c:18
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1

Referenced by FDO_StartDevice().

◆ FreeItem()

VOID FreeItem ( IN PVOID  Item)

Definition at line 152 of file misc.c.

154 {
155  /* Free item */
157 }
#define USBCCPG_TAG
Definition: usbccgp.h:39
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

◆ USBCCGP_SyncForwardIrp()

NTSTATUS NTAPI USBCCGP_SyncForwardIrp ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp 
)

Definition at line 36 of file misc.c.

39 {
40  KEVENT Event;
42 
43  /* Initialize event */
45 
46  /* Copy irp stack location */
48 
49  /* Set completion routine */
52  &Event,
53  TRUE,
54  TRUE,
55  TRUE);
56 
57  /* Call driver */
59 
60  /* Check if pending */
61  if (Status == STATUS_PENDING)
62  {
63  /* Wait for the request to finish */
65 
66  /* Copy status code */
67  Status = Irp->IoStatus.Status;
68  }
69 
70  /* Done */
71  return Status;
72 }
#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
#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
NTSTATUS NTAPI USBSTOR_SyncForwardIrpCompletionRoutine(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context)
Definition: misc.c:22
#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

Referenced by FDO_DeviceRelations(), FDO_HandlePnp(), FDO_HandleResetCyclePort(), FDO_StartDevice(), and USBCCGP_PdoHandleQueryId().

◆ USBCCGP_SyncUrbRequest()

NTSTATUS USBCCGP_SyncUrbRequest ( IN PDEVICE_OBJECT  DeviceObject,
OUT PURB  UrbRequest 
)

Definition at line 75 of file misc.c.

78 {
79  PIRP Irp;
80  PIO_STACK_LOCATION IoStack;
81  KEVENT Event;
83 
84  /* Allocate irp */
86  if (!Irp)
87  {
88  /* No memory */
90  }
91 
92  /* Initialize event */
94 
95  /* Get next stack location */
96  IoStack = IoGetNextIrpStackLocation(Irp);
97 
98  /* Initialize stack location */
100  IoStack->Parameters.DeviceIoControl.IoControlCode = IOCTL_INTERNAL_USB_SUBMIT_URB;
101  IoStack->Parameters.Others.Argument1 = (PVOID)UrbRequest;
102  IoStack->Parameters.DeviceIoControl.InputBufferLength = UrbRequest->UrbHeader.Length;
103  Irp->IoStatus.Status = STATUS_SUCCESS;
104 
105  /* Setup completion routine */
108  &Event,
109  TRUE,
110  TRUE,
111  TRUE);
112 
113  /* Call driver */
115 
116  /* Check if request is pending */
117  if (Status == STATUS_PENDING)
118  {
119  /* Wait for completion */
121 
122  /* Update status */
123  Status = Irp->IoStatus.Status;
124  }
125 
126  /* Free irp */
127  IoFreeIrp(Irp);
128 
129  /* Done */
130  return Status;
131 }
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define IOCTL_INTERNAL_USB_SUBMIT_URB
Definition: usbioctl.h:32
_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
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:435
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI USBSTOR_SyncForwardIrpCompletionRoutine(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context)
Definition: misc.c:22
#define STATUS_PENDING
Definition: ntstatus.h:82
#define IRP_MJ_INTERNAL_DEVICE_CONTROL
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
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
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
static PVOID
Definition: misc.c:50
PIRP NTAPI IoAllocateIrp(IN CCHAR StackSize, IN BOOLEAN ChargeQuota)
Definition: irp.c:615
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by FDO_CloseConfiguration(), USBCCGP_GetDescriptor(), USBCCGP_PDOSelectConfiguration(), USBCCGP_SelectConfiguration(), and USBCCGP_SelectInterface().

◆ USBSTOR_SyncForwardIrpCompletionRoutine()

NTSTATUS NTAPI USBSTOR_SyncForwardIrpCompletionRoutine ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp,
PVOID  Context 
)

Definition at line 22 of file misc.c.

26 {
27  if (Irp->PendingReturned)
28  {
30  }
32 }
#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 USBCCGP_SyncForwardIrp(), USBCCGP_SyncUrbRequest(), USBSTOR_SyncForwardIrp(), and USBSTOR_SyncUrbRequest().

Variable Documentation

◆ SyncForwardIrpCompletionRoutine

IO_COMPLETION_ROUTINE SyncForwardIrpCompletionRoutine

Definition at line 18 of file misc.c.