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

Go to the source code of this file.

Macros

#define NDEBUG
 
#define XFER_STD_TO_DEVICE   0x00
 
#define XFER_STD_TO_INTERFACE   0x01
 
#define XFER_STD_TO_ENDPOINT   0x02
 
#define XFER_STD_FROM_DEVICE   0x80
 
#define XFER_VENDOR_TO_DEVICE   0x40
 
#define XFER_VENDOR_FROM_DEVICE   0xC0
 
#define XFER_VENDOR_FROM_INTERFACE   0xC1
 
#define XFER_CLASS_FROM_PORT   0xA3
 
#define XFER_TYPE(RequestType)   (((RequestType) >> 5) & 3)
 
#define XFER_TYPE_STANDARD   0
 
#define XFER_TYPE_VENDOR   2
 
#define XFER_HEADER_READ   255
 
#define XFER_EXT_PROPERTIES_HEADER   10
 
#define XFER_SERIAL_LANGUAGE   0x0409
 
#define XFER_FUNCTION_SUSPEND_WAKE   0x0300
 
#define XFER_LOW_POWER_PORT   100
 

Functions

 C_ASSERT (sizeof(((HubChild *) 0) ->m_Sel)==6)
 
 C_ASSERT (sizeof(((HubChild *) 0) ->m_Qualifier)==10)
 
static VOID NTAPI HubDeviceStringFailed (_In_ HubChild *Child, _In_ UCHAR Index)
 
static BOOLEAN NTAPI HubDeviceFailureExpected (_In_ UCHAR Type, _In_ UCHAR Request, _In_ USHORT Value, _In_ USHORT Index)
 
static DsmEvent NTAPI HubDeviceTransferFailed (_In_ HubChild *Child, _In_ NTSTATUS Status)
 
static VOID NTAPI HubDeviceControlComplete (_In_ WDFREQUEST Request, _In_ WDFIOTARGET Target, _In_ PWDF_REQUEST_COMPLETION_PARAMS Params, _In_ WDFCONTEXT Context)
 
BOOLEAN NTAPI HubDeviceSend (_In_ HubChild *Child, _In_reads_bytes_opt_(Length) PVOID Buffer, _In_ ULONG Length, _In_ BOOLEAN ShortTransferOk)
 
static BOOLEAN NTAPI HubDeviceTrySend (_In_ HubChild *Child, _In_ UCHAR RequestType, _In_ UCHAR Request, _In_ USHORT Value, _In_ USHORT Index, _In_reads_bytes_opt_(Length) PVOID Buffer, _In_ ULONG Length, _In_ BOOLEAN ShortTransferOk)
 
static BOOLEAN NTAPI HubDeviceRequest (_In_ HubChild *Child, _In_ UCHAR RequestType, _In_ UCHAR Request, _In_ USHORT Value, _In_ USHORT Index, _In_reads_bytes_opt_(Length) PVOID Buffer, _In_ ULONG Length, _In_ BOOLEAN ShortTransferOk)
 
static VOID NTAPI HubDeviceGetDescriptor (_In_ HubChild *Child, _In_ UCHAR Type, _In_ UCHAR Index, _In_ USHORT LanguageId, _Out_writes_bytes_(Length) PVOID Buffer, _In_ ULONG Length)
 
static VOID NTAPI HubDeviceGetString (_In_ HubChild *Child, _In_ UCHAR Index, _In_ USHORT LanguageId)
 
static VOID NTAPI HubDeviceMsOsRead (_In_ HubChild *Child, _In_ UCHAR RequestType, _In_ USHORT Index, _Out_writes_bytes_(Length) PVOID Buffer, _In_ ULONG Length)
 
static VOID NTAPI HubDeviceFeature (_In_ HubChild *Child, _In_ BOOLEAN Set, _In_ USHORT Feature)
 
static VOID NTAPI HubFreeDevicePool (_Inout_ PVOID *Buffer)
 
HubPipe *NTAPI HubFindPipeByHandle (_In_opt_ HubConfiguration *Config, _In_ USBD_PIPE_HANDLE Handle)
 
static USHORT NTAPI HubSelPathLatency (_In_ USHORT DeviceLatency, _In_ USHORT UpstreamLatency, _In_ USHORT SlowestLatency, _In_ UCHAR SlowestDepth, _In_ LONG Depth, _Out_ PUSHORT Link, _Inout_ PBOOLEAN Slowest)
 
static VOID NTAPI HubFdoDescriptorComplete (_In_ WDFREQUEST Request, _In_ WDFIOTARGET Target, _In_ PWDF_REQUEST_COMPLETION_PARAMS Params, _In_ WDFCONTEXT Context)
 
static VOID NTAPI HubBootStatusComplete (_In_ WDFREQUEST Request, _In_ WDFIOTARGET Target, _In_ PWDF_REQUEST_COMPLETION_PARAMS Params, _In_ WDFCONTEXT Context)
 
 _IRQL_requires_ (PASSIVE_LEVEL) NTSTATUS NTAPI HubReadPortStatusForBootDevice(_In_ HubChild *Child
 Sends a synchronous IOCTL to the specified device object.
 
 PAGED_CODE ()
 
 if (Control->Request==NULL)
 
Control SetSetup (XFER_CLASS_FROM_PORT, HUB_REQUEST_GET_STATUS, 0, Child->m_Port->Number(), sizeof(*PortStatus))
 
 if (!NT_SUCCESS(Status))
 
Child m_Port Number ()
 

Variables

static EVT_WDF_REQUEST_COMPLETION_ROUTINE HubDeviceControlComplete
 
static EVT_WDF_REQUEST_COMPLETION_ROUTINE HubFdoDescriptorComplete
 
static EVT_WDF_REQUEST_COMPLETION_ROUTINE HubBootStatusComplete
 
_Out_ PULONG PortStatus
 
HubControlRequest * Control = &Child->m_BootControl
 
KEVENT Done
 
NTSTATUS Status
 
 else
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 11 of file devreq.cpp.

◆ XFER_CLASS_FROM_PORT

#define XFER_CLASS_FROM_PORT   0xA3

Definition at line 22 of file devreq.cpp.

◆ XFER_EXT_PROPERTIES_HEADER

#define XFER_EXT_PROPERTIES_HEADER   10

Definition at line 33 of file devreq.cpp.

◆ XFER_FUNCTION_SUSPEND_WAKE

#define XFER_FUNCTION_SUSPEND_WAKE   0x0300

Definition at line 39 of file devreq.cpp.

◆ XFER_HEADER_READ

#define XFER_HEADER_READ   255

Definition at line 30 of file devreq.cpp.

◆ XFER_LOW_POWER_PORT

#define XFER_LOW_POWER_PORT   100

Definition at line 42 of file devreq.cpp.

◆ XFER_SERIAL_LANGUAGE

#define XFER_SERIAL_LANGUAGE   0x0409

Definition at line 36 of file devreq.cpp.

◆ XFER_STD_FROM_DEVICE

#define XFER_STD_FROM_DEVICE   0x80

Definition at line 18 of file devreq.cpp.

◆ XFER_STD_TO_DEVICE

#define XFER_STD_TO_DEVICE   0x00

Definition at line 15 of file devreq.cpp.

◆ XFER_STD_TO_ENDPOINT

#define XFER_STD_TO_ENDPOINT   0x02

Definition at line 17 of file devreq.cpp.

◆ XFER_STD_TO_INTERFACE

#define XFER_STD_TO_INTERFACE   0x01

Definition at line 16 of file devreq.cpp.

◆ XFER_TYPE

#define XFER_TYPE (   RequestType)    (((RequestType) >> 5) & 3)

Definition at line 25 of file devreq.cpp.

◆ XFER_TYPE_STANDARD

#define XFER_TYPE_STANDARD   0

Definition at line 26 of file devreq.cpp.

◆ XFER_TYPE_VENDOR

#define XFER_TYPE_VENDOR   2

Definition at line 27 of file devreq.cpp.

◆ XFER_VENDOR_FROM_DEVICE

#define XFER_VENDOR_FROM_DEVICE   0xC0

Definition at line 20 of file devreq.cpp.

◆ XFER_VENDOR_FROM_INTERFACE

#define XFER_VENDOR_FROM_INTERFACE   0xC1

Definition at line 21 of file devreq.cpp.

◆ XFER_VENDOR_TO_DEVICE

#define XFER_VENDOR_TO_DEVICE   0x40

Definition at line 19 of file devreq.cpp.

Function Documentation

◆ _IRQL_requires_()

_IRQL_requires_ ( PASSIVE_LEVEL  )

Sends a synchronous IOCTL to the specified device object.

Parameters
[in]IoControlCodeThe IOCTL to send to the device.
[in]DeviceObjectPointer to the device object that will handle the IOCTL.
[in]InputBufferOptional pointer to a buffer containing input data for the IOCTL. When specified, the buffer should be at least of InputBufferLength size.
[in]InputBufferLengthSize in bytes, of the buffer pointed by InputBuffer.
[out]OutputBufferOptional pointer to a buffer that will receive output data from the IOCTL. When specified, the buffer should be at least of OutputBufferLength size.
[in]OutputBufferLengthSize in bytes, of the buffer pointed by OutputBuffer.
[in]FileObjectOptional pointer to a file object that may be necessary for the IOCTL.
Returns
An NTSTATUS code indicating success or failure of this function.
Note
Must be called at PASSIVE_LEVEL with all APCs enabled.

Nothing is found unless the PCI bus driver publishes the properties.

The root hub name without its prefix; NULL when the PDO has no name.

Grows a private buffer to what the helper asks for.

Lets KMDF handle the IRP, then hands it back here still uncompleted.

Waits for the device machine to answer a PnP or power event; returns the PnP status.

Deletes the UCX endpoints of the disabled pipes, then the interface record.

Definition at line 2121 of file class.c.

13175{
13177
13178 PAGED_CODE();
13179
13180 TracePrint((TRACE_LEVEL_VERBOSE,
13181 TRACE_FLAG_PNP,
13182 "ClassDetermineTokenOperationCommandSupport (%p): Entering function.\n",
13183 DeviceObject));
13184
13185 //
13186 // Send down Inquiry for VPD_THIRD_PARTY_COPY_PAGE and cache away the device parameters
13187 // from WINDOWS_BLOCK_DEVICE_TOKEN_LIMITS_DESCRIPTOR.
13188 //
13190
13191 if (NT_SUCCESS(status)) {
13192
13193 ULONG maxListIdentifier = MaxTokenOperationListIdentifier;
13194
13195 //
13196 // Query the maximum list identifier to use for TokenOperation commands.
13197 //
13198 if (NT_SUCCESS(ClasspGetMaximumTokenListIdentifier(DeviceObject, REG_DISK_CLASS_CONTROL, &maxListIdentifier))) {
13199 if (maxListIdentifier >= MIN_TOKEN_LIST_IDENTIFIERS) {
13200
13201 NT_ASSERT(maxListIdentifier <= MAX_TOKEN_LIST_IDENTIFIERS);
13202 MaxTokenOperationListIdentifier = maxListIdentifier;
13203 }
13204 }
13205
13206 }
13207
13208 TracePrint((TRACE_LEVEL_VERBOSE,
13209 TRACE_FLAG_PNP,
13210 "ClassDetermineTokenOperationCommandSupport (%p): Exiting function with status %x.\n",
13212 status));
13213
13214 return status;
13215}
#define PAGED_CODE()
LONG NTSTATUS
Definition: precomp.h:26
#define REG_DISK_CLASS_CONTROL
Definition: classp.h:218
#define MAX_TOKEN_LIST_IDENTIFIERS
Definition: classp.h:215
#define MIN_TOKEN_LIST_IDENTIFIERS
Definition: classp.h:214
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
ULONG MaxTokenOperationListIdentifier
Definition: class.c:107
_IRQL_requires_same_ NTSTATUS ClasspGetBlockDeviceTokenLimitsInfo(_Inout_ PDEVICE_OBJECT DeviceObject)
Definition: class.c:13220
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
Definition: ps.c:97
uint32_t ULONG
Definition: typedefs.h:59
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2061
#define NT_ASSERT
Definition: rtlfuncs.h:3334

◆ C_ASSERT() [1/2]

C_ASSERT ( sizeof(((HubChild *) 0) ->m_Qualifier)  = =10)

◆ C_ASSERT() [2/2]

C_ASSERT ( sizeof(((HubChild *) 0) ->m_Sel)  = =6)

◆ HubBootStatusComplete()

static VOID NTAPI HubBootStatusComplete ( _In_ WDFREQUEST  Request,
_In_ WDFIOTARGET  Target,
_In_ PWDF_REQUEST_COMPLETION_PARAMS  Params,
_In_ WDFCONTEXT  Context 
)
static

Definition at line 1136 of file devreq.cpp.

1141{
1145
1147}
#define FALSE
Definition: types.h:117
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
Definition: kse.h:81
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFREQUEST Request
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:308
#define IO_NO_INCREMENT
Definition: iotypes.h:598

◆ HubDeviceControlComplete()

static VOID NTAPI HubDeviceControlComplete ( _In_ WDFREQUEST  Request,
_In_ WDFIOTARGET  Target,
_In_ PWDF_REQUEST_COMPLETION_PARAMS  Params,
_In_ WDFCONTEXT  Context 
)
static

Definition at line 236 of file devreq.cpp.

241{
243 NTSTATUS Status = Params->IoStatus.Status;
245
248
249 Child->m_Control.UsbdFlags = 0;
250
251 if (!NT_SUCCESS(Status))
253
254 Child->m_Control.Reuse();
255 Child->Post(Event);
256}
static DsmEvent NTAPI HubDeviceTransferFailed(_In_ HubChild *Child, _In_ NTSTATUS Status)
Definition: devreq.cpp:131
DsmEvent
Definition: devsm.h:15
_Check_return_ _In_ DXGK_EVENT_TYPE _In_ ULONG Event
Definition: dispmprt.h:1287
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
Definition: wdffdo.h:536

◆ HubDeviceFailureExpected()

static BOOLEAN NTAPI HubDeviceFailureExpected ( _In_ UCHAR  Type,
_In_ UCHAR  Request,
_In_ USHORT  Value,
_In_ USHORT  Index 
)
static

Requests a device may refuse without anything being wrong with it.

Definition at line 105 of file devreq.cpp.

110{
112 return FALSE;
113
115 return TRUE;
116
118 return TRUE;
119
121 return FALSE;
122
125}
Type
Definition: Type.h:7
#define XFER_TYPE_STANDARD
Definition: devreq.cpp:26
#define HUB_MSOS_STRING_INDEX
Definition: devreq.h:20
#define TRUE
Definition: types.h:120
#define USB_FEATURE_REMOTE_WAKEUP
Definition: usb100.h:103
#define USB_REQUEST_GET_DESCRIPTOR
Definition: usb100.h:82
#define USB_REQUEST_SET_FEATURE
Definition: usb100.h:80
#define USB_STRING_DESCRIPTOR_TYPE
Definition: usb100.h:51
#define USB_REQUEST_CLEAR_FEATURE
Definition: usb100.h:79
#define USB_DEVICE_QUALIFIER_DESCRIPTOR_TYPE
Definition: usb200.h:94
#define USB_FEATURE_FUNCTION_SUSPEND
Definition: usb300.h:333
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by HubDeviceTransferFailed().

◆ HubDeviceFeature()

static VOID NTAPI HubDeviceFeature ( _In_ HubChild *  Child,
_In_ BOOLEAN  Set,
_In_ USHORT  Feature 
)
static

Definition at line 377 of file devreq.cpp.

381{
385 Feature,
386 0,
387 NULL,
388 0,
389 TRUE);
390}
_In_ ULONG const _In_ FEATURE_NUMBER const Feature
Definition: cdrom.h:1077
#define XFER_STD_TO_DEVICE
Definition: devreq.cpp:15
static BOOLEAN NTAPI HubDeviceRequest(_In_ HubChild *Child, _In_ UCHAR RequestType, _In_ UCHAR Request, _In_ USHORT Value, _In_ USHORT Index, _In_reads_bytes_opt_(Length) PVOID Buffer, _In_ ULONG Length, _In_ BOOLEAN ShortTransferOk)
Definition: devreq.cpp:307
#define NULL
Definition: types.h:112
static BOOL Set
Definition: pageheap.c:10

Referenced by DeviceMachine::ArmForWake(), DeviceMachine::DisableU1(), DeviceMachine::DisableU2(), DeviceMachine::DisarmWake(), DeviceMachine::EnableLtm(), DeviceMachine::EnableU1(), and DeviceMachine::EnableU2().

◆ HubDeviceGetDescriptor()

static VOID NTAPI HubDeviceGetDescriptor ( _In_ HubChild *  Child,
_In_ UCHAR  Type,
_In_ UCHAR  Index,
_In_ USHORT  LanguageId,
_Out_writes_bytes_(Length) PVOID  Buffer,
_In_ ULONG  Length 
)
static

◆ HubDeviceGetString()

static VOID NTAPI HubDeviceGetString ( _In_ HubChild *  Child,
_In_ UCHAR  Index,
_In_ USHORT  LanguageId 
)
static

Definition at line 348 of file devreq.cpp.

352{
355 Index,
356 LanguageId,
357 Child->m_ScratchBuffer,
359}
static VOID NTAPI HubDeviceGetDescriptor(_In_ HubChild *Child, _In_ UCHAR Type, _In_ UCHAR Index, _In_ USHORT LanguageId, _Out_writes_bytes_(Length) PVOID Buffer, _In_ ULONG Length)
Definition: devreq.cpp:327
#define MAXIMUM_USB_STRING_LENGTH
Definition: usb100.h:43

Referenced by DeviceMachine::ReadBillboardString(), DeviceMachine::ReadLanguageIds(), DeviceMachine::ReadProductName(), and DeviceMachine::ReadSerialNumber().

◆ HubDeviceMsOsRead()

static VOID NTAPI HubDeviceMsOsRead ( _In_ HubChild *  Child,
_In_ UCHAR  RequestType,
_In_ USHORT  Index,
_Out_writes_bytes_(Length) PVOID  Buffer,
_In_ ULONG  Length 
)
static

◆ HubDeviceRequest()

static BOOLEAN NTAPI HubDeviceRequest ( _In_ HubChild *  Child,
_In_ UCHAR  RequestType,
_In_ UCHAR  Request,
_In_ USHORT  Value,
_In_ USHORT  Index,
_In_reads_bytes_opt_(Length) PVOID  Buffer,
_In_ ULONG  Length,
_In_ BOOLEAN  ShortTransferOk 
)
static

Definition at line 307 of file devreq.cpp.

316{
317 if (HubDeviceTrySend(Child, RequestType, Request, Value, Index, Buffer, Length, ShortTransferOk))
318 return TRUE;
319
321 return FALSE;
322}
static BOOLEAN NTAPI HubDeviceTrySend(_In_ HubChild *Child, _In_ UCHAR RequestType, _In_ UCHAR Request, _In_ USHORT Value, _In_ USHORT Index, _In_reads_bytes_opt_(Length) PVOID Buffer, _In_ ULONG Length, _In_ BOOLEAN ShortTransferOk)
Definition: devreq.cpp:290
@ TransferFailed

Referenced by DeviceMachine::ArmForWake(), DeviceMachine::ClearEndpointHalt(), DeviceMachine::DisarmWake(), HubDeviceFeature(), HubDeviceGetDescriptor(), HubDeviceMsOsRead(), DeviceMachine::SendAltEnumCommand(), DeviceMachine::SendUsbFeatures(), DeviceMachine::SetConfiguration(), DeviceMachine::SetIsochDelay(), DeviceMachine::SetNullConfiguration(), DeviceMachine::SetPdChargingPolicy(), and DeviceMachine::SetSel().

◆ HubDeviceSend()

BOOLEAN NTAPI HubDeviceSend ( _In_ HubChild *  Child,
_In_reads_bytes_opt_(Length) PVOID  Buffer,
_In_ ULONG  Length,
_In_ BOOLEAN  ShortTransferOk 
)

Sends the setup packet in Child->m_Control; on FALSE the caller posts TransferFailed.

Definition at line 262 of file devreq.cpp.

267{
269
270 Status = Child->m_Control.Send(Child->m_Hub->m_RootHubTarget,
271 Child->m_UsbDevice,
273 Child,
274 Buffer,
275 Length,
276 ShortTransferOk,
277 Child->m_NeedsForwardProgress);
278 if (NT_SUCCESS(Status))
279 return TRUE;
280
281 Child->m_Control.UsbdFlags = 0;
282 DPRINT1("Device %p transfer refused 0x%lx\n", Child, Status);
283 return FALSE;
284}
#define DPRINT1
Definition: precomp.h:8
static EVT_WDF_REQUEST_COMPLETION_ROUTINE HubDeviceControlComplete
Definition: devreq.cpp:47
NTSTATUS Status
Definition: devreq.cpp:1163

Referenced by HubDeviceTrySend(), DeviceMachine::ReadAltModeString(), and DeviceMachine::SetInterface().

◆ HubDeviceStringFailed()

static VOID NTAPI HubDeviceStringFailed ( _In_ HubChild *  Child,
_In_ UCHAR  Index 
)
static

Definition at line 57 of file devreq.cpp.

60{
61 const USB_DEVICE_DESCRIPTOR* Device = &Child->m_DeviceDescriptor;
62 HubBillboardInfo* Billboard = Child->m_Billboard;
64
65 if (Device->iSerialNumber != 0 && Index == Device->iSerialNumber)
66 {
67 Child->m_EnumMessageId = HUB_ENUM_SERIAL_NUMBER_FAILED;
68 return;
69 }
70
71 if (Index == 0)
72 {
73 Child->m_EnumMessageId = HUB_ENUM_LANGUAGE_IDS_FAILED;
74 return;
75 }
76
77 if (Device->iProduct != 0 && Index == Device->iProduct)
78 {
79 Child->m_EnumMessageId = HUB_ENUM_PRODUCT_STRING_FAILED;
80 return;
81 }
82
83 if (Billboard == NULL)
84 return;
85
86 Caps = Billboard->Descriptor;
87 if (Caps->iAddtionalInfoURL != 0 && Index == Caps->iAddtionalInfoURL)
88 {
89 Child->m_EnumMessageId = HUB_ENUM_PRODUCT_STRING_FAILED;
90 return;
91 }
92
93 if (Billboard->CurrentMode != HUB_BILLBOARD_NO_MODE &&
94 Caps->AlternateMode[Billboard->CurrentMode].iAlternateModeSetting != 0 &&
95 Index == Caps->AlternateMode[Billboard->CurrentMode].iAlternateModeSetting)
96 {
97 Child->m_EnumMessageId = HUB_ENUM_PRODUCT_STRING_FAILED;
98 }
99}
#define HUB_BILLBOARD_NO_MODE
Definition: hubchild.h:227
#define HUB_ENUM_PRODUCT_STRING_FAILED
Definition: hubid.h:22
#define HUB_ENUM_LANGUAGE_IDS_FAILED
Definition: hubid.h:21
#define HUB_ENUM_SERIAL_NUMBER_FAILED
Definition: hubid.h:20
_Must_inspect_result_ _In_ PUCXHUB_DEVICE_CREATE_INFO _Out_ UCXUSBDEVICE * Device
Definition: hubucx.h:258
PUSB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR Descriptor
Definition: hubchild.h:232
UCHAR CurrentMode
Definition: hubchild.h:233
struct _USB_DEVICE_CAPABILITY_BILLBOARD_DESCRIPTOR::@4127 AlternateMode[1]

Referenced by HubDeviceTransferFailed().

◆ HubDeviceTransferFailed()

static DsmEvent NTAPI HubDeviceTransferFailed ( _In_ HubChild *  Child,
_In_ NTSTATUS  Status 
)
static

Records why the transfer failed and picks the event to post.

Definition at line 131 of file devreq.cpp.

134{
135 const UCHAR* Setup = Child->m_Control.Urb.SetupPacket;
136 USBD_STATUS UrbStatus = Child->m_Control.Urb.Hdr.Status;
138 UCHAR Request = Setup[1];
139 USHORT Value = Setup[2] | (Setup[3] << 8);
140 USHORT Index = Setup[4] | (Setup[5] << 8);
141
143 {
144 DPRINT("Device %p port %u request 0x%02x/0x%02x value 0x%04x failed 0x%lx usbd 0x%lx\n",
145 Child, Child->m_Port->Number(), Setup[0], Request, Value, Status, UrbStatus);
146 }
147 else
148 {
149 DPRINT1("Device %p port %u request 0x%02x/0x%02x value 0x%04x index 0x%04x failed 0x%lx usbd 0x%lx\n",
150 Child, Child->m_Port->Number(), Setup[0], Request, Value, Index, Status, UrbStatus);
151 }
152
153 /* Every failed nonzero SET_CONFIGURATION reports the same codes */
155 {
156 Child->m_LastNtStatus = STATUS_UNSUCCESSFUL;
157 Child->m_LastUsbdStatus = USBD_STATUS_SET_CONFIG_FAILED;
158 }
159 else
160 {
161 Child->m_LastNtStatus = Status;
162 Child->m_LastUsbdStatus = UrbStatus;
163 }
164
166 {
167 Child->m_EnumMessageId = HUB_ENUM_SET_SEL_FAILED;
169 }
170
173
175 {
176 switch (Setup[3])
177 {
179 Child->m_EnumMessageId = HUB_ENUM_DEVICE_DESCRIPTOR_FAILED;
180 break;
181
183 Child->m_EnumMessageId = HUB_ENUM_CONFIG_DESCRIPTOR_FAILED;
184 break;
185
187 Child->m_EnumMessageId = HUB_ENUM_BOS_FAILED;
188 break;
189
191 Child->m_EnumMessageId = HUB_ENUM_QUALIFIER_FAILED;
192 break;
193
196 break;
197
198 default:
199 break;
200 }
202 }
203
204 if (Type == XFER_TYPE_VENDOR && Request == Child->m_MsOsVendorCode)
205 {
206 switch (Index)
207 {
209 Child->m_EnumMessageId = HUB_ENUM_MSOS_EXT_CONFIG_FAILED;
210 break;
211
213 Child->m_EnumMessageId = HUB_ENUM_MSOS_CONTAINER_ID_FAILED;
214 break;
215
217 Child->m_EnumMessageId = HUB_ENUM_MSOS20_SET_FAILED;
218 break;
219
221 Child->m_EnumMessageId = HUB_ENUM_ALT_ENUM_FAILED;
222 break;
223
224 default:
225 break;
226 }
228 }
229
231}
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 void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE ACPI_HANDLE ACPI_HANDLE *OutHandle ACPI_HANDLE *OutHandle void *Context void *Context ACPI_EVENT_HANDLER Handler UINT32 UINT32 ACPI_GPE_HANDLER void *Context UINT32 ACPI_NOTIFY_HANDLER void *Context ACPI_ADR_SPACE_TYPE ACPI_ADR_SPACE_HANDLER ACPI_ADR_SPACE_SETUP Setup
Definition: acpixf.h:834
static VOID NTAPI HubDeviceStringFailed(_In_ HubChild *Child, _In_ UCHAR Index)
Definition: devreq.cpp:57
#define XFER_TYPE_VENDOR
Definition: devreq.cpp:27
static BOOLEAN NTAPI HubDeviceFailureExpected(_In_ UCHAR Type, _In_ UCHAR Request, _In_ USHORT Value, _In_ USHORT Index)
Definition: devreq.cpp:105
#define XFER_TYPE(RequestType)
Definition: devreq.cpp:25
#define HUB_MSOS_INDEX_EXT_CONFIG
Definition: devreq.h:13
#define HUB_MSOS20_INDEX_ALT_ENUM
Definition: devreq.h:17
#define HUB_MSOS20_INDEX_SET
Definition: devreq.h:16
#define HUB_MSOS_INDEX_CONTAINER_ID
Definition: devreq.h:15
@ TransferStalled
#define HUB_ENUM_QUALIFIER_FAILED
Definition: hubid.h:19
#define HUB_ENUM_MSOS_CONTAINER_ID_FAILED
Definition: hubid.h:24
#define HUB_ENUM_MSOS20_SET_FAILED
Definition: hubid.h:35
#define HUB_ENUM_DEVICE_DESCRIPTOR_FAILED
Definition: hubid.h:11
#define HUB_ENUM_MSOS_EXT_CONFIG_FAILED
Definition: hubid.h:23
#define HUB_ENUM_ALT_ENUM_FAILED
Definition: hubid.h:37
#define HUB_ENUM_SET_SEL_FAILED
Definition: hubid.h:17
#define HUB_ENUM_BOS_FAILED
Definition: hubid.h:18
#define HUB_ENUM_CONFIG_DESCRIPTOR_FAILED
Definition: hubid.h:16
#define DPRINT
Definition: sndvol32.h:73
unsigned char UCHAR
Definition: typedefs.h:53
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define USB_CONFIGURATION_DESCRIPTOR_TYPE
Definition: usb100.h:50
#define USB_DEVICE_DESCRIPTOR_TYPE
Definition: usb100.h:49
#define USB_REQUEST_SET_CONFIGURATION
Definition: usb100.h:85
#define USB_REQUEST_SET_SEL
Definition: usb300.h:329
#define USB_BOS_DESCRIPTOR_TYPE
Definition: usb300.h:17
#define USB_FEATURE_U1_ENABLE
Definition: usb300.h:337
#define USB_FEATURE_U2_ENABLE
Definition: usb300.h:338
#define USBD_STATUS_SET_CONFIG_FAILED
Definition: usb.h:216
#define USBD_STATUS_STALL_PID
Definition: usb.h:183
LONG USBD_STATUS
Definition: usb.h:172

Referenced by HubDeviceControlComplete().

◆ HubDeviceTrySend()

static BOOLEAN NTAPI HubDeviceTrySend ( _In_ HubChild *  Child,
_In_ UCHAR  RequestType,
_In_ UCHAR  Request,
_In_ USHORT  Value,
_In_ USHORT  Index,
_In_reads_bytes_opt_(Length) PVOID  Buffer,
_In_ ULONG  Length,
_In_ BOOLEAN  ShortTransferOk 
)
static

Definition at line 290 of file devreq.cpp.

299{
300 Child->m_Control.SetSetup(RequestType, Request, Value, Index, (USHORT)Length);
301 return HubDeviceSend(Child, Buffer, Length, ShortTransferOk);
302}
BOOLEAN NTAPI HubDeviceSend(_In_ HubChild *Child, _In_reads_bytes_opt_(Length) PVOID Buffer, _In_ ULONG Length, _In_ BOOLEAN ShortTransferOk)
Definition: devreq.cpp:262

Referenced by HubDeviceRequest().

◆ HubFdoDescriptorComplete()

static VOID NTAPI HubFdoDescriptorComplete ( _In_ WDFREQUEST  Request,
_In_ WDFIOTARGET  Target,
_In_ PWDF_REQUEST_COMPLETION_PARAMS  Params,
_In_ WDFCONTEXT  Context 
)
static

Definition at line 1087 of file devreq.cpp.

1092{
1094 HubQueueContext* Queue = HubGetQueueContext(WdfRequestGetIoQueue(Request));
1095 ULONG Size = Queue->Urb.TransferBufferLength;
1096
1098
1099 if (!NT_SUCCESS(Params->IoStatus.Status))
1100 DPRINT1("Device %p descriptor read for the hub failed 0x%lx\n", Child, Params->IoStatus.Status);
1101
1103 HubCompleteFdoDescriptorRequest(Child, Request, WdfRequestGetStatus(Request), Size);
1104}
VOID NTAPI HubCompleteFdoDescriptorRequest(_In_ HubChild *Child, _In_ WDFREQUEST Request, _In_ NTSTATUS Status, _In_ ULONG Size)
Definition: hubioctl.cpp:372
_Must_inspect_result_ _In_ WDFDEVICE _In_ PIRP _In_ WDFQUEUE Queue
Definition: wdfdevice.h:2231
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539

◆ HubFindPipeByHandle()

HubPipe *NTAPI HubFindPipeByHandle ( _In_opt_ HubConfiguration *  Config,
_In_ USBD_PIPE_HANDLE  Handle 
)

Pipe of Config whose USBD pipe handle is Handle, or NULL. The caller protects Config.

Definition at line 858 of file devreq.cpp.

861{
864 ULONG Index;
865
866 if (Config == NULL)
867 return NULL;
868
869 for (Entry = Config->Interfaces.Flink; Entry != &Config->Interfaces; Entry = Entry->Flink)
870 {
872
873 for (Index = 0; Index < Interface->PipeCount; Index++)
874 {
875 if (Interface->Pipes[Index].PipeHandle == Handle)
876 return &Interface->Pipes[Index];
877 }
878 }
879
880 return NULL;
881}
PLIST_ENTRY Entry
Definition: devhcd.cpp:1262
ULONG Handle
Definition: gdb_input.c:15
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
_Must_inspect_result_ _In_ WDFDEVICE _In_ PUCX_CONTROLLER_CONFIG Config
_In_ UCXUSBDEVICE _In_ ULONG Interface
Definition: ucxusbdevice.h:428

Referenced by DeviceMachine::FindClientPipe().

◆ HubFreeDevicePool()

static VOID NTAPI HubFreeDevicePool ( _Inout_ PVOID *  Buffer)
static

◆ HubSelPathLatency()

static USHORT NTAPI HubSelPathLatency ( _In_ USHORT  DeviceLatency,
_In_ USHORT  UpstreamLatency,
_In_ USHORT  SlowestLatency,
_In_ UCHAR  SlowestDepth,
_In_ LONG  Depth,
_Out_ PUSHORT  Link,
_Inout_ PBOOLEAN  Slowest 
)
static

Path exit latency for one link state; Slowest is set when Link exceeds it.

Definition at line 988 of file devreq.cpp.

996{
997 USHORT Path;
998
999 *Link = max(DeviceLatency, UpstreamLatency);
1000 Path = (USHORT)(SlowestLatency + ((Depth - SlowestDepth) * 1000 + 500) / 1000);
1001
1002 if (*Link <= Path)
1003 return Path;
1004
1005 *Slowest = TRUE;
1006 return *Link;
1007}
UINT Depth
Definition: d3d12.idl:4644
UNICODE_STRING Path
#define max(a, b)
Definition: svc.c:63

Referenced by DeviceMachine::SetSel().

◆ if() [1/2]

if ( !  NT_SUCCESSStatus)

Definition at line 1199 of file devreq.cpp.

1200 {
1201 DPRINT1("Port %u boot status read not sent 0x%lx\n", Child->m_Port->Number(), Status);
1202 return Status;
1203 }

◆ if() [2/2]

if ( Control->  Request = = NULL)

Definition at line 1169 of file devreq.cpp.

1170 {
1171 Status = Control->Create(Child->m_Object, WdfDeviceGetIoTarget(Hub->m_Device));
1172 if (!NT_SUCCESS(Status))
1173 {
1174 DPRINT1("Device %p boot status request not created 0x%lx\n", Child, Status);
1175 return Status;
1176 }
1177 }
HubFdo * Hub
Definition: bootdev.cpp:261
WDFDEVICE m_Device
Definition: fdo.h:349
_In_ WDF_WMI_PROVIDER_CONTROL Control
Definition: wdfwmi.h:166

◆ Number()

Child m_Port Number ( )

◆ PAGED_CODE()

PAGED_CODE ( )

◆ SetSetup()

Control SetSetup ( XFER_CLASS_FROM_PORT  ,
HUB_REQUEST_GET_STATUS  ,
0  ,
Child->m_Port->  Number(),
sizeof *  PortStatus 
)

Variable Documentation

◆ Control

HubControlRequest* Control = &Child->m_BootControl

Definition at line 1161 of file devreq.cpp.

◆ Done

HubWaitForPnpEvent & Done

Definition at line 1162 of file devreq.cpp.

Referenced by FxIoQueue::_Create(), FxDevice::_Create(), FxMessageDispatch::_CreateAndInitialize(), FxWmiIrpHandler::_EnableDisableEventsAndCollection(), FxUsbPipe::_FormatTransfer(), _IRQL_requires_(), FxWmiIrpHandler::_QueryAllData(), FxWmiIrpHandler::_RegInfo(), _Releases_lock_(), acpi_bus_match(), FxPkgGeneral::AcquireRemoveLockForClose(), AddInputEvents(), FxWmiIrpHandler::AddPowerPolicyProviderAndInstance(), FxDeviceBase::AllocateTarget(), FxUsbDeviceControlContext::AllocateUrb(), FxUsbDeviceStringContext::AllocateUrb(), FxUsbPipeTransferContext::AllocateUrb(), FxUsbPipeRequestContext::AllocateUrb(), ApplyConsoleInfo(), ArcOpen(), AtaAhciHandleFatalError(), AtaAhciPostRequestPolled(), BT958HwResetBus(), XhciEndpoint::BuildEndpointConfigure(), XhciEndpoint::BuildSetDequeue(), BusLogic_Command(), BusLogic_SendBusDeviceReset(), CM_Get_Device_ID_List_ExA(), CM_Get_Device_Interface_Alias_ExA(), CM_Get_Device_Interface_List_ExA(), CM_Register_Device_Interface_ExA(), UcxUsbDevice::CompleteHubOperation(), ConDrvCreateController(), FxPkgGeneral::ConfigureConstraints(), FxDeviceBase::ConfigureConstraints(), FxPkgIo::ConfigureDynamicDispatching(), FxPkgGeneral::ConfigureFileObjectClass(), FxUsbDevice::CreateInterfaces(), FxUsbDevice::CreateIsochUrb(), FxUsbDevice::CreateUrb(), DcResetWorker(), DirPrintf(), FxWmiIrpHandler::Dispatch(), FxDevice::DispatchPreprocessedIrp(), DosAllocateMemory(), DosResizeMemory(), DosTerminateProcess(), DrvCopyBits(), ElfCreateBackupLogHandle(), ElfCreateEventLogHandle(), ElfrReportEventA(), FX_VF_METHOD(), FxCacheBugCheckDriverInfo(), FxInitializeBugCheckDriverInfo(), FxLibraryCommonRegisterClient(), FxObjectAllocateContext(), FxpLibraryBugCheckCallback(), FxPurgeBugCheckDriverInfo(), FxRegisterBugCheckCallback(), FxUninitializeBugCheckDriverInfo(), FxUnregisterBugCheckCallback(), FxRequest::GetDeviceControlOutputMemoryObject(), FxRequest::GetMemoryObject(), FxChildList::GetNextDevice(), FxChildList::GetNextStaticDevice(), GetServiceInstanceList(), GetServiceInstanceListSize(), GetStackCapabilities(), FxUsbDevice::GetString(), GetSystemUserInfo(), FxPkgPnp::HandleQueryDeviceRelations(), FxPkgPnp::HandleQueryInterface(), HubClearTtBuffer(), if(), FxUsbDevice::InitDevice(), FxPkgGeneral::Initialize(), FxNPagedLookasideList::Initialize(), KdbpDoCommand(), LsapCreateDatabaseKeys(), LsapGetObjectAttribute(), LsarQueryAccountDomain(), LsarQueryPrimaryDomain(), FxUsbInterface::MakeAndConfigurePipes(), MmUnloadSystemImage(), NtfsCachedRead(), FxIoTargetRemote::Open(), PagePrompt(), PNP_AddID(), PNP_GetRootDeviceInstance(), PNP_ValidateDeviceInstance(), FxPkgPnp::PnpMatchResources(), FxRequest::ProbeAndLockForRead(), FxRequest::ProbeAndLockForWrite(), FxChildList::ProcessBusRelations(), PS2PortQueueRead(), PS2QueuePush(), RDeleteService(), _FX_DRIVER_TRACKER_CACHE_AWARE::Register(), REnumDependentServicesA(), REnumDependentServicesW(), REnumServiceGroupW(), REnumServicesStatusA(), REnumServicesStatusExA(), REnumServicesStatusExW(), ROpenServiceW(), RQueryServiceConfigA(), RQueryServiceConfigW(), RSetServiceObjectSecurity(), ScmSendControlPacket(), FxTransactionedList::SearchForAndRemove(), FxUsbDevice::SelectConfig(), FxUsbDevice::SelectConfigMulti(), FxUsbInterface::SelectSetting(), FxUsbDevice::SendSyncRequest(), SRomReadSRom(), START_TEST(), UcxUsbDevice::StartOperation(), FxIoTarget::SubmitLocked(), switch(), UsbdexCallAndWait(), FxPkgPnp::ValidateCmResource(), FxPkgPnp::ValidateInterruptResourceCm(), VerifyWdfDeviceWdmDispatchIrpToIoQueue(), and VerifyWdfRequestForwardToParentDeviceIoQueue().

◆ else

else
Initial value:
{
Control->Reuse()

Definition at line 1178 of file devreq.cpp.

◆ HubBootStatusComplete

EVT_WDF_REQUEST_COMPLETION_ROUTINE HubBootStatusComplete
static

Definition at line 49 of file devreq.cpp.

◆ HubDeviceControlComplete

EVT_WDF_REQUEST_COMPLETION_ROUTINE HubDeviceControlComplete
static

Definition at line 47 of file devreq.cpp.

Referenced by HubDeviceSend().

◆ HubFdoDescriptorComplete

EVT_WDF_REQUEST_COMPLETION_ROUTINE HubFdoDescriptorComplete
static

Definition at line 48 of file devreq.cpp.

Referenced by DeviceMachine::GetDescriptorForHub().

◆ PortStatus

* PortStatus
Initial value:
{
HubFdo* Hub = Child->m_Hub
Definition: fdo.h:132

Definition at line 1158 of file devreq.cpp.

◆ Status

Initial value:
&Done,
sizeof(*PortStatus),
WDFIOTARGET m_RootHubTarget
Definition: fdo.h:368
UCXUSBDEVICE UsbDevice() const
Definition: fdo.h:180
KEVENT Done
Definition: devreq.cpp:1162
static EVT_WDF_REQUEST_COMPLETION_ROUTINE HubBootStatusComplete
Definition: devreq.cpp:49
_Out_ PULONG PortStatus
Definition: devreq.cpp:1159

Definition at line 1163 of file devreq.cpp.

Referenced by HubDeviceSend(), HubDeviceTransferFailed(), and if().