ReactOS 0.4.17-dev-1281-g065abb3
hostqueues.cpp File Reference
#include "ucx01000.h"
#include <debug.h>
Include dependency graph for hostqueues.cpp:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static NTSTATUS NTAPI UcxCreateControllerQueue (_In_ UcxController *Controller, _In_ WDF_IO_QUEUE_DISPATCH_TYPE Dispatch, _In_ ULONG PresentedRequests, _In_opt_ PFN_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL Handler, _In_opt_ PCWDF_OBJECT_CONTEXT_TYPE_INFO ContextType, _In_opt_ PWDF_IO_QUEUE_FORWARD_PROGRESS_POLICY Policy, _Out_ WDFQUEUE *Queue)
 
VOID NTAPI UcxEvtAddress0IoInternalDeviceControl (_In_ WDFQUEUE Queue, _In_ WDFREQUEST Request, _In_ size_t OutputBufferLength, _In_ size_t InputBufferLength, _In_ ULONG IoControlCode)
 
static VOID NTAPI UcxApplyStreamCountOverride (_In_ UcxUsbdHandle *Handle, _Inout_ PUSHORT StreamCount)
 
static NTSTATUS NTAPI UcxQueryUsbCapability (_In_ UcxController *Controller, _Inout_ PUCXHUB_QUERY_CAPABILITY Query, _Out_writes_bytes_opt_(Query->OutputBufferLength) PVOID OutputBuffer)
 
static VOID NTAPI UcxDispatchGetDumpData (_In_ UcxController *Controller, _In_ WDFREQUEST Request)
 
static VOID NTAPI UcxDispatchFreeDumpData (_In_ UcxController *Controller, _In_ WDFREQUEST Request)
 
static VOID NTAPI UcxDispatchRootHubQuery (_In_ UcxController *Controller, _In_ WDFREQUEST Request, _In_ ULONG IoControlCode)
 
VOID NTAPI UcxEvtDefaultIoInternalDeviceControl (_In_ WDFQUEUE Queue, _In_ WDFREQUEST Request, _In_ size_t OutputBufferLength, _In_ size_t InputBufferLength, _In_ ULONG IoControlCode)
 
WDF_IO_FORWARD_PROGRESS_ACTION NTAPI UcxEvtDefaultQueueExamineIrp (_In_ WDFQUEUE Queue, _In_ PIRP Irp)
 
VOID NTAPI UcxCsqInsertAbortIrp (_In_ PIO_CSQ Csq, _In_ PIRP Irp)
 
VOID NTAPI UcxCsqRemoveAbortIrp (_In_ PIO_CSQ Csq, _In_ PIRP Irp)
 
PIRP NTAPI UcxCsqPeekAbortIrp (_In_ PIO_CSQ Csq, _In_opt_ PIRP Irp, _In_opt_ PVOID PeekContext)
 
 _IRQL_raises_ (DISPATCH_LEVEL) VOID NTAPI UcxCsqAcquireAbortLock(_In_ PIO_CSQ Csq
 
VOID NTAPI UcxCsqReleaseAbortLock (_In_ PIO_CSQ Csq, _In_ KIRQL Irql)
 
VOID NTAPI UcxCsqCompleteCanceledAbortIrp (_In_ PIO_CSQ Csq, _In_ PIRP Irp)
 

Variables

_Out_ PKIRQL Irql
 
KeAcquireSpinLock & Controller
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 10 of file hostqueues.cpp.

Function Documentation

◆ _IRQL_raises_()

_IRQL_raises_ ( DISPATCH_LEVEL  )

◆ UcxApplyStreamCountOverride()

static VOID NTAPI UcxApplyStreamCountOverride ( _In_ UcxUsbdHandle *  Handle,
_Inout_ PUSHORT  StreamCount 
)
static

Definition at line 157 of file hostqueues.cpp.

160{
161 ULONG Override = Handle->m_VerifierStaticStreamCountOverride;
162 ULONG Count = *StreamCount;
163
164 if (Override == 0)
165 return;
166
167 if (Handle->m_GrantedStreams != 0)
168 Count = min(Handle->m_GrantedStreams, (ULONG)*StreamCount);
169 else if (Override == MAXULONG)
170 Count = UcxRandomInRange(*StreamCount);
171 else if (Override < *StreamCount)
172 Count = Override;
173
174 *StreamCount = (USHORT)Count;
175}
ULONG Handle
Definition: gdb_input.c:15
#define min(a, b)
Definition: monoChain.cc:55
unsigned short USHORT
Definition: pedump.c:61
#define MAXULONG
Definition: typedefs.h:251
uint32_t ULONG
Definition: typedefs.h:59
ULONG NTAPI UcxRandomInRange(_In_ ULONG Max)
Definition: ucxutil.cpp:85
USHORT Count
Definition: userreq.cpp:200

Referenced by UcxQueryUsbCapability().

◆ UcxCreateControllerQueue()

static NTSTATUS NTAPI UcxCreateControllerQueue ( _In_ UcxController *  Controller,
_In_ WDF_IO_QUEUE_DISPATCH_TYPE  Dispatch,
_In_ ULONG  PresentedRequests,
_In_opt_ PFN_WDF_IO_QUEUE_IO_INTERNAL_DEVICE_CONTROL  Handler,
_In_opt_ PCWDF_OBJECT_CONTEXT_TYPE_INFO  ContextType,
_In_opt_ PWDF_IO_QUEUE_FORWARD_PROGRESS_POLICY  Policy,
_Out_ WDFQUEUE *  Queue 
)
static

Creates one of the five queues the root hub PDO dispatches into.

Definition at line 17 of file hostqueues.cpp.

25{
29
31 Config.PowerManaged = WdfFalse;
32 Config.EvtIoInternalDeviceControl = Handler;
34 Config.Settings.Parallel.NumberOfPresentedRequests = PresentedRequests;
35
37 Attributes.ParentObject = Controller->m_Handle;
38 Attributes.ContextTypeInfo = ContextType;
39
40 Status = WdfIoQueueCreate(Controller->m_Fdo, &Config, &Attributes, Queue);
41 if (!NT_SUCCESS(Status))
42 {
43 DPRINT1("Controller %p queue create failed 0x%lx\n", Controller, Status);
44 return Status;
45 }
46
47 if (Policy != NULL)
48 {
49 Status = WdfIoQueueAssignForwardProgressPolicy(*Queue, Policy);
50 if (!NT_SUCCESS(Status))
51 DPRINT1("Controller %p queue %p forward progress policy failed 0x%lx\n", Controller, *Queue, Status);
52 }
53
54 return Status;
55}
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn UINT32 *TableIdx UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER Handler
Definition: acpixf.h:672
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
_In_ ULONG Attributes
Definition: dispmprt.h:1077
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE ContextType
Definition: fltkernel.h:1443
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ WDFDEVICE _In_ PUCX_CONTROLLER_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ UCXCONTROLLER * Controller
_Must_inspect_result_ _In_ WDFDEVICE _In_ PUCX_CONTROLLER_CONFIG Config
_Must_inspect_result_ _In_ WDFDEVICE _In_ PIRP _In_ WDFQUEUE Queue
Definition: wdfdevice.h:2231
_In_ WDFINTERRUPT _In_ WDF_INTERRUPT_POLICY Policy
Definition: wdfinterrupt.h:653
FORCEINLINE VOID WDF_IO_QUEUE_CONFIG_INIT(_Out_ PWDF_IO_QUEUE_CONFIG Config, _In_ WDF_IO_QUEUE_DISPATCH_TYPE DispatchType)
Definition: wdfio.h:426
@ WdfIoQueueDispatchParallel
Definition: wdfio.h:79
FORCEINLINE VOID WDF_OBJECT_ATTRIBUTES_INIT(_Out_ PWDF_OBJECT_ATTRIBUTES Attributes)
Definition: wdfobject.h:147
@ WdfFalse
Definition: wdftypes.h:87
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH * Dispatch
Definition: wsk.h:188

Referenced by UcxController::CreateQueues().

◆ UcxCsqCompleteCanceledAbortIrp()

VOID NTAPI UcxCsqCompleteCanceledAbortIrp ( _In_ PIO_CSQ  Csq,
_In_ PIRP  Irp 
)

Definition at line 545 of file hostqueues.cpp.

548{
550
552
553 DPRINT("Abort pipe IRP %p canceled\n", Irp);
554
555 /* The mixed status pair is what USBPORT reported */
557}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
VOID NTAPI UcxCompleteUrbAtDispatch(_In_ PIRP Irp, _In_ PURB Urb, _In_ NTSTATUS Status, _In_ USBD_STATUS UsbdStatus)
Definition: clientxrb.cpp:42
IO_CSQ Csq
Definition: csqrtns.c:46
_In_ PIRP Irp
Definition: kse.h:79
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
#define DPRINT
Definition: sndvol32.h:73
struct _IO_STACK_LOCATION::@5100::@5139 Others
union _IO_STACK_LOCATION::@1823 Parameters
Definition: usb.h:565
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
#define USBD_STATUS_DEVICE_GONE
Definition: usb.h:222
struct _URB * PURB
_In_opt_ PUSB_CONFIGURATION_DESCRIPTOR _Inout_ PUSBD_INTERFACE_LIST_ENTRY _Outptr_ PURB * Urb
Definition: usbdlib.h:333

◆ UcxCsqInsertAbortIrp()

VOID NTAPI UcxCsqInsertAbortIrp ( _In_ PIO_CSQ  Csq,
_In_ PIRP  Irp 
)

Definition at line 487 of file hostqueues.cpp.

◆ UcxCsqPeekAbortIrp()

PIRP NTAPI UcxCsqPeekAbortIrp ( _In_ PIO_CSQ  Csq,
_In_opt_ PIRP  Irp,
_In_opt_ PVOID  PeekContext 
)

Definition at line 507 of file hostqueues.cpp.

511{
515
517 return NULL;
518}
_In_opt_ PIRP _In_opt_ PVOID PeekContext
Definition: csq.h:160
#define FALSE
Definition: types.h:117
#define NT_ASSERT
Definition: rtlfuncs.h:3334

◆ UcxCsqReleaseAbortLock()

VOID NTAPI UcxCsqReleaseAbortLock ( _In_ PIO_CSQ  Csq,
_In_ KIRQL  Irql 
)

Definition at line 534 of file hostqueues.cpp.

537{
539
540 KeReleaseSpinLock(&Controller->m_AbortPipeCsqLock, Irql);
541}
_Out_ PKIRQL Irql
Definition: csq.h:179
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

◆ UcxCsqRemoveAbortIrp()

VOID NTAPI UcxCsqRemoveAbortIrp ( _In_ PIO_CSQ  Csq,
_In_ PIRP  Irp 
)

Definition at line 497 of file hostqueues.cpp.

◆ UcxDispatchFreeDumpData()

static VOID NTAPI UcxDispatchFreeDumpData ( _In_ UcxController *  Controller,
_In_ WDFREQUEST  Request 
)
static

Definition at line 332 of file hostqueues.cpp.

335{
336 PFN_UCX_HCD_FREE_DUMP_DATA FreeDumpData = Controller->HcdFreeDumpData();
337 PIRP Irp = WdfRequestWdmGetIrp(Request);
338
339 if (FreeDumpData == NULL)
340 {
341 DPRINT1("Controller %p has no free dump data callback\n", Controller);
342 WdfRequestComplete(Request, STATUS_NOT_SUPPORTED);
343 return;
344 }
345
346 FreeDumpData(Controller->m_Handle, Irp->AssociatedIrp.SystemBuffer);
347 WdfRequestComplete(Request, STATUS_SUCCESS);
348}
#define STATUS_NOT_SUPPORTED
Definition: d3dkmdt.h:48
#define STATUS_SUCCESS
Definition: shellext.h:65
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFREQUEST Request

Referenced by UcxEvtDefaultIoInternalDeviceControl().

◆ UcxDispatchGetDumpData()

static VOID NTAPI UcxDispatchGetDumpData ( _In_ UcxController *  Controller,
_In_ WDFREQUEST  Request 
)
static

Definition at line 305 of file hostqueues.cpp.

308{
309 PFN_UCX_HCD_GET_DUMP_DATA GetDumpData = Controller->HcdGetDumpData();
311 PIRP Irp = WdfRequestWdmGetIrp(Request);
313
314 if (GetDumpData == NULL)
315 {
316 DPRINT1("Controller %p has no dump data callback\n", Controller);
317 WdfRequestComplete(Request, STATUS_NOT_SUPPORTED);
318 return;
319 }
320
321 DeviceInfo = (PUCXHUB_DUMP_DEVICE_INFO)Irp->AssociatedIrp.SystemBuffer;
322 Status = GetDumpData(Controller->m_Handle, DeviceInfo->Device, DeviceInfo, Irp->UserBuffer);
323 if (!NT_SUCCESS(Status))
324 DPRINT1("Controller %p get dump data failed 0x%lx\n", Controller, Status);
325
327}
struct _UCXHUB_DUMP_DEVICE_INFO * PUCXHUB_DUMP_DEVICE_INFO
WdfRequestCompleteWithInformation(Request, STATUS_SUCCESS, ActualLength)

Referenced by UcxEvtDefaultIoInternalDeviceControl().

◆ UcxDispatchRootHubQuery()

static VOID NTAPI UcxDispatchRootHubQuery ( _In_ UcxController *  Controller,
_In_ WDFREQUEST  Request,
_In_ ULONG  IoControlCode 
)
static

Root hub information IOCTLs, each guarded by a reset reference while the HCD sees it.

Definition at line 354 of file hostqueues.cpp.

358{
359 UcxRootHub* RootHub = Controller->m_RootHub;
360
361 if (!Controller->BlockReset())
362 {
363 DPRINT1("Controller %p unavailable, failing root hub IOCTL 0x%lx\n", Controller, IoControlCode);
364 WdfRequestComplete(Request, STATUS_NO_SUCH_DEVICE);
365 return;
366 }
367
368 switch (IoControlCode)
369 {
372 break;
373
375 RootHub->m_Config.EvtRootHubGet20PortInfo(RootHub->m_Handle, Request);
376 break;
377
378 default:
379 RootHub->m_Config.EvtRootHubGet30PortInfo(RootHub->m_Handle, Request);
380 break;
381 }
382
383 /* The HCD may still own the request; that does not need the reference */
384 Controller->UnblockReset();
385}
#define IOCTL_UCXHUB_ROOTHUB_GET_20PORT_INFO
Definition: hubucx.h:51
#define IOCTL_UCXHUB_ROOTHUB_GET_INFO
Definition: hubucx.h:50
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
_Must_inspect_result_ _In_ UCXCONTROLLER _In_ PUCX_ROOTHUB_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ UCXROOTHUB * RootHub
Definition: ucxroothub.h:299
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136

Referenced by UcxEvtDefaultIoInternalDeviceControl().

◆ UcxEvtAddress0IoInternalDeviceControl()

VOID NTAPI UcxEvtAddress0IoInternalDeviceControl ( _In_ WDFQUEUE  Queue,
_In_ WDFREQUEST  Request,
_In_ size_t  OutputBufferLength,
_In_ size_t  InputBufferLength,
_In_ ULONG  IoControlCode 
)

Definition at line 122 of file hostqueues.cpp.

128{
129 UcxAddress0QueueContext* Context = UcxGetAddress0QueueContext(Queue);
131
134
136 {
137 DPRINT1("Address 0 queue got unexpected IOCTL 0x%lx\n", IoControlCode);
138 WdfRequestComplete(Request, STATUS_INVALID_DEVICE_REQUEST);
139 return;
140 }
141
142 WdfIoQueueStop(Queue, NULL, NULL);
143
145 Context->OwnerHub = Acquire->Header.Hub;
146 Context->OwnerDevice = Acquire->Header.UsbDevice;
147 DPRINT("Address 0 owned by hub %p device %p\n", Context->OwnerHub, Context->OwnerDevice);
148
149 WdfRequestComplete(Request, STATUS_SUCCESS);
150}
#define IOCTL_UCXHUB_ADDRESS0_OWNERSHIP_ACQUIRE
Definition: hubucx.h:49
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
Definition: kse.h:81
PVOID Arg1
Definition: ucxutil.h:103
_In_ PGUID _In_ ULONG OutputBufferLength
Definition: ucxcontroller.h:81
_In_ WDFREQUEST _In_ size_t _In_ size_t InputBufferLength
struct _ADDRESS0_OWNERSHIP_ACQUIRE * PADDRESS0_OWNERSHIP_ACQUIRE
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138

◆ UcxEvtDefaultIoInternalDeviceControl()

VOID NTAPI UcxEvtDefaultIoInternalDeviceControl ( _In_ WDFQUEUE  Queue,
_In_ WDFREQUEST  Request,
_In_ size_t  OutputBufferLength,
_In_ size_t  InputBufferLength,
_In_ ULONG  IoControlCode 
)

Definition at line 389 of file hostqueues.cpp.

395{
396 UcxController* Controller = UcxController::FromFdo(WdfIoQueueGetDevice(Queue));
401
404
405 DPRINT("Controller %p request %p IOCTL 0x%lx\n", Controller, Request, IoControlCode);
406
407 switch (IoControlCode)
408 {
413 break;
414
416 Device = UcxUsbDevice::FromHandle((UCXUSBDEVICE)Args.Arg2);
417 Device->RegisterComposite(Request);
418 break;
419
421 Device = UcxUsbDevice::FromHandle((UCXUSBDEVICE)Args.Arg2);
422 Device->UnregisterComposite(Request);
423 break;
424
426 Device = UcxUsbDevice::FromHandle((UCXUSBDEVICE)Args.Arg2);
427 Device->SetFunctionData(Request);
428 break;
429
431 Device = UcxUsbDevice::FromHandle((UCXUSBDEVICE)Args.Arg2);
432 Device->RequestRemoteWakeNotification(Request);
433 break;
434
438 Query,
439 WdfRequestWdmGetIrp(Request)->AssociatedIrp.SystemBuffer);
440 WdfRequestComplete(Request, Status);
441 break;
442
445 break;
446
449 break;
450
452 Status = Controller->EnableForwardProgress((PUCXHUB_FORWARD_PROGRESS_INFO)Args.Arg1);
453 WdfRequestComplete(Request, Status);
454 break;
455
456 default:
457 DPRINT1("Controller %p default queue got unexpected IOCTL 0x%lx\n", Controller, IoControlCode);
459 WdfRequestComplete(Request, STATUS_INVALID_DEVICE_REQUEST);
460 break;
461 }
462}
char ** Args
Definition: acdebug.h:353
static UcxController * FromFdo(_In_ WDFDEVICE Fdo)
Definition: hostctl.cpp:21
static UcxUsbDevice * FromHandle(_In_ UCXUSBDEVICE Handle)
Definition: devobj.cpp:18
static VOID NTAPI UcxDispatchGetDumpData(_In_ UcxController *Controller, _In_ WDFREQUEST Request)
Definition: hostqueues.cpp:305
static VOID NTAPI UcxDispatchRootHubQuery(_In_ UcxController *Controller, _In_ WDFREQUEST Request, _In_ ULONG IoControlCode)
Definition: hostqueues.cpp:354
static NTSTATUS NTAPI UcxQueryUsbCapability(_In_ UcxController *Controller, _Inout_ PUCXHUB_QUERY_CAPABILITY Query, _Out_writes_bytes_opt_(Query->OutputBufferLength) PVOID OutputBuffer)
Definition: hostqueues.cpp:180
static VOID NTAPI UcxDispatchFreeDumpData(_In_ UcxController *Controller, _In_ WDFREQUEST Request)
Definition: hostqueues.cpp:332
_Must_inspect_result_ _In_ PUCXHUB_DEVICE_CREATE_INFO _Out_ UCXUSBDEVICE * Device
Definition: hubucx.h:258
#define IOCTL_UCXHUB_ROOTHUB_GET_30PORT_INFO
Definition: hubucx.h:52
#define IOCTL_UCXHUB_FREE_DUMP_DATA
Definition: hubucx.h:74
struct _UCXHUB_QUERY_CAPABILITY * PUCXHUB_QUERY_CAPABILITY
#define IOCTL_UCXHUB_QUERY_USB_CAPABILITY
Definition: hubucx.h:65
#define IOCTL_UCXHUB_SET_FUNCTION_HANDLE_DATA
Definition: hubucx.h:66
#define IOCTL_UCXHUB_GET_DUMP_DATA
Definition: hubucx.h:72
#define IOCTL_UCXHUB_NOTIFY_FORWARD_PROGRESS
Definition: hubucx.h:69
_In_ const GUID _In_ ULONG _In_opt_ PFN_WDF_WMI_INSTANCE_QUERY_INSTANCE Query
Definition: hubwmi.cpp:114
#define IOCTL_INTERNAL_USB_REGISTER_COMPOSITE_DEVICE
Definition: usbioctl.h:760
#define IOCTL_INTERNAL_USB_REQUEST_REMOTE_WAKE_NOTIFICATION
Definition: usbioctl.h:766
#define IOCTL_INTERNAL_USB_UNREGISTER_COMPOSITE_DEVICE
Definition: usbioctl.h:763

◆ UcxEvtDefaultQueueExamineIrp()

WDF_IO_FORWARD_PROGRESS_ACTION NTAPI UcxEvtDefaultQueueExamineIrp ( _In_ WDFQUEUE  Queue,
_In_ PIRP  Irp 
)

Definition at line 467 of file hostqueues.cpp.

470{
472
475 {
476 DPRINT1("No reserved request for remote wake IRP %p\n", Irp);
478 }
479
481}
_In_ HANDLE _In_ CONST PDXGKMDT_OPM_GET_INFO_PARAMETERS Parameters
Definition: dispmprt.h:321
struct _IO_STACK_LOCATION::@1823::@1824 DeviceIoControl
@ WdfIoForwardProgressActionUseReservedRequest
Definition: wdfio.h:462
@ WdfIoForwardProgressActionFailRequest
Definition: wdfio.h:461

◆ UcxQueryUsbCapability()

static NTSTATUS NTAPI UcxQueryUsbCapability ( _In_ UcxController *  Controller,
_Inout_ PUCXHUB_QUERY_CAPABILITY  Query,
_Out_writes_bytes_opt_(Query->OutputBufferLength) PVOID  OutputBuffer 
)
static

Definition at line 180 of file hostqueues.cpp.

184{
186 BOOLEAN IsChainedMdl;
187 BOOLEAN IsStreams;
189
190 if (Query->Size != sizeof(*Query) ||
192 Query->UsbdHandle == NULL)
193 {
194 DPRINT1("Capability query %p malformed, size %u version %u\n", Query, Query->Size, Query->Version);
196 }
197
198 Handle = (UcxUsbdHandle*)Query->UsbdHandle;
199 Query->ResultLength = 0;
200
201 if ((Query->OutputBufferLength != 0) != (OutputBuffer != NULL))
202 {
203 DPRINT1("Capability query %p length %lu does not match buffer %p\n",
204 Query, Query->OutputBufferLength, OutputBuffer);
206 }
207
208 IsChainedMdl = IsEqualGUID(Query->CapabilityType, GUID_USB_CAPABILITY_CHAINED_MDLS);
209 IsStreams = IsEqualGUID(Query->CapabilityType, GUID_USB_CAPABILITY_STATIC_STREAMS);
210
211 if (IsChainedMdl)
212 {
213 if (OutputBuffer != NULL)
214 {
215 DPRINT1("Chained MDL query %p must not have a buffer\n", Query);
217 }
218
219 if (!Handle->m_ChainedMdlGranted &&
220 UcxVerifierWantsFailure(Handle->m_VerifierFailChainedMdl))
221 {
223 DPRINT1("Verifier fails chained MDL query %p with 0x%lx\n", Query, Status);
224 return Status;
225 }
226 }
227 else if (IsEqualGUID(Query->CapabilityType, GUID_USB_CAPABILITY_SELECTIVE_SUSPEND))
228 {
229 if (OutputBuffer != NULL)
230 {
231 DPRINT1("Selective suspend query %p must not have a buffer\n", Query);
233 }
234 }
235 else if (IsEqualGUID(Query->CapabilityType, GUID_USB_CAPABILITY_HIGH_BANDWIDTH_ISOCH))
236 {
237 if (Query->OutputBufferLength != sizeof(ULONG))
238 {
239 DPRINT1("High bandwidth isoch query %p bad length %lu\n", Query, Query->OutputBufferLength);
241 }
242 }
243 else if (IsStreams)
244 {
245 if (Query->OutputBufferLength != sizeof(USHORT))
246 {
247 DPRINT1("Static streams query %p bad length %lu\n", Query, Query->OutputBufferLength);
249 }
250
251 if (UcxVerifierWantsFailure(Handle->m_VerifierFailStaticStreamSupport))
252 {
254 DPRINT1("Verifier fails static streams query %p with 0x%lx\n", Query, Status);
255 return Status;
256 }
257 }
258 else
259 {
260 DPRINT("Capability query %p has unknown type %08lx\n", Query, Query->CapabilityType.Data1);
261 }
262
263 /* Unknown capabilities still go to the HCD, which decides */
264 if (Controller->m_Config.EvtControllerQueryUsbCapability == NULL)
265 {
266 DPRINT1("Controller %p has no capability query callback\n", Controller);
268 }
269
270 Status = Controller->m_Config.EvtControllerQueryUsbCapability(Controller->m_Handle,
271 &Query->CapabilityType,
272 Query->OutputBufferLength,
274 &Query->ResultLength);
275 if (!NT_SUCCESS(Status))
276 {
277 /* An unsupported capability is a normal answer, not a failure */
279 DPRINT("Controller %p capability %p not supported\n", Controller, Query);
280 else
281 DPRINT1("Controller %p capability query %p failed 0x%lx\n", Controller, Query, Status);
282 return Status;
283 }
284
285 if (IsStreams)
286 {
288 Handle->m_StreamsGranted = TRUE;
289 Handle->m_GrantedStreams = *(PUSHORT)OutputBuffer;
290 DPRINT("Granted %u static streams to handle %p\n", *(PUSHORT)OutputBuffer, Handle);
291 }
292 else if (IsChainedMdl)
293 {
294 Handle->m_ChainedMdlGranted = TRUE;
295 }
296
297 return Status;
298}
unsigned char BOOLEAN
Definition: actypes.h:127
#define TRUE
Definition: types.h:120
static VOID NTAPI UcxApplyStreamCountOverride(_In_ UcxUsbdHandle *Handle, _Inout_ PUSHORT StreamCount)
Definition: hostqueues.cpp:157
#define UCXHUB_QUERY_CAPABILITY_VERSION
Definition: hubucx.h:156
if(dx< 0)
Definition: linetemp.h:194
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
uint16_t * PUSHORT
Definition: typedefs.h:56
BOOLEAN NTAPI UcxVerifierWantsFailure(_In_ ULONG Setting)
Definition: ucxutil.cpp:71
NTSTATUS NTAPI UcxRandomErrorStatus(VOID)
Definition: ucxutil.cpp:93
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR OutputBuffer
Definition: wdfiotarget.h:863

Referenced by UcxEvtDefaultIoInternalDeviceControl().

Variable Documentation

◆ Controller

Definition at line 529 of file hostqueues.cpp.

◆ Irql

Initial value:

Definition at line 525 of file hostqueues.cpp.