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

Go to the source code of this file.

Classes

struct  HubTtClear
 

Macros

#define NDEBUG
 
#define USB3_URB_RESERVED_RESOURCES   0x00000010
 
#define HUB_USER_PORT_STATUS_OFFSET   4
 
#define HUB_USER_PORT_STATUS_SIZE   8
 

Functions

static NTSTATUS NTAPI HubTtClearValue (_In_ HubChild *Child, _In_ UCXENDPOINT Endpoint, _In_ ULONG EndpointAddress, _Out_ PUSHORT Value)
 
static VOID NTAPI HubTtClearComplete (_In_ WDFREQUEST Request, _In_ WDFIOTARGET Target, _In_ PWDF_REQUEST_COMPLETION_PARAMS Params, _In_ WDFCONTEXT Context)
 
VOID NTAPI HubClearTtBuffer (_In_ UCXHUB_HUB_CONTEXT HubContext, _In_ UCXHUB_DEVICE_CONTEXT DeviceContext, _In_ UCXENDPOINT Endpoint, _In_ ULONG EndpointNumber, _In_ ULONG TtPortNumber)
 
static VOID NTAPI HubControlComplete (_In_ WDFREQUEST Request, _In_ WDFIOTARGET Target, _In_ PWDF_REQUEST_COMPLETION_PARAMS Params, _In_ WDFCONTEXT Context)
 
static VOID NTAPI HubSendControl (_In_ HubFdo *Hub, _In_reads_bytes_opt_(Length) PVOID Buffer, _In_ ULONG Length, _In_ BOOLEAN ShortOk)
 
static VOID NTAPI HubInterruptComplete (_In_ WDFREQUEST Request, _In_ WDFIOTARGET Target, _In_ PWDF_REQUEST_COMPLETION_PARAMS Params, _In_ WDFCONTEXT Context)
 
static WDFREQUEST NTAPI HubTakePortStatusRequest (_In_ HubFdo *Hub, _Out_ PWDF_REQUEST_PARAMETERS Params)
 

Variables

static const char HubTagClearTt [] = "hub TT clear"
 
static EVT_WDF_REQUEST_COMPLETION_ROUTINE HubControlComplete
 
static EVT_WDF_REQUEST_COMPLETION_ROUTINE HubInterruptComplete
 

Macro Definition Documentation

◆ HUB_USER_PORT_STATUS_OFFSET

#define HUB_USER_PORT_STATUS_OFFSET   4

Definition at line 286 of file hubreq.cpp.

◆ HUB_USER_PORT_STATUS_SIZE

#define HUB_USER_PORT_STATUS_SIZE   8

Definition at line 287 of file hubreq.cpp.

◆ NDEBUG

#define NDEBUG

Definition at line 10 of file hubreq.cpp.

◆ USB3_URB_RESERVED_RESOURCES

#define USB3_URB_RESERVED_RESOURCES   0x00000010

Definition at line 15 of file hubreq.cpp.

Function Documentation

◆ HubClearTtBuffer()

VOID NTAPI HubClearTtBuffer ( _In_ UCXHUB_HUB_CONTEXT  HubContext,
_In_ UCXHUB_DEVICE_CONTEXT  DeviceContext,
_In_ UCXENDPOINT  Endpoint,
_In_ ULONG  EndpointNumber,
_In_ ULONG  TtPortNumber 
)

Definition at line 220 of file hubreq.cpp.

226{
230 WDFREQUEST Request = NULL;
234
236 goto Done;
237
238 /* Computed even for RESET_TT, which does not use it */
242 if (!NT_SUCCESS(Status))
243 goto Done;
244
246 if (Clear == NULL)
247 {
248 DPRINT1("Hub %p no memory for a TT clear\n", Hub);
249 goto Done;
250 }
251
252 Clear->Hub = Hub;
253 Clear->Endpoint = Endpoint;
254
255 if (!NT_SUCCESS(Clear->Control.Create(Hub->m_Device, WdfDeviceGetIoTarget(Hub->m_Device))))
256 goto Done;
257 Request = Clear->Control.Request;
258
259 Clear->Control.SetSetup(0x23,
261 ResetTt ? 0 : Value,
263 0);
264
265 Status = Clear->Control.Send(Hub->m_RootHubTarget,
266 Hub->UsbDevice(),
268 Clear,
269 NULL,
270 0,
271 FALSE,
273 if (NT_SUCCESS(Status))
274 return;
275
276Done:
277 if (Request != NULL)
279 if (Clear != NULL)
281
283}
unsigned char BOOLEAN
Definition: actypes.h:127
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
HubFdo * Hub
Definition: bootdev.cpp:261
Definition: fdo.h:132
WDFDEVICE m_Device
Definition: fdo.h:349
static HubFdo * FromContext(_In_ UCXHUB_HUB_CONTEXT Context)
Definition: fdo.h:144
WDFIOTARGET m_RootHubTarget
Definition: fdo.h:368
UCXHUB_STACK_INTERFACE m_Stack
Definition: fdo.h:356
BOOLEAN HasFlag(_In_ HubFlag Flag) const
Definition: fdo.h:153
UCXUSBDEVICE UsbDevice() const
Definition: fdo.h:180
BOOLEAN NeedsForwardProgress() const
Definition: fdo.h:208
KEVENT Done
Definition: devreq.cpp:1162
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define NonPagedPool
Definition: env_spec_w32.h:307
Status
Definition: gdiplustypes.h:24
static NTSTATUS NTAPI HubTtClearValue(_In_ HubChild *Child, _In_ UCXENDPOINT Endpoint, _In_ ULONG EndpointAddress, _Out_ PUSHORT Value)
Definition: hubreq.cpp:130
static const char HubTagClearTt[]
Definition: hubreq.cpp:116
static VOID NTAPI HubTtClearComplete(_In_ WDFREQUEST Request, _In_ WDFIOTARGET Target, _In_ PWDF_REQUEST_COMPLETION_PARAMS Params, _In_ WDFCONTEXT Context)
Definition: hubreq.cpp:194
#define HUB_REQUEST_CLEAR_TT_BUFFER
Definition: hubreq.h:89
#define HUB_REQUEST_RESET_TT
Definition: hubreq.h:90
_In_ UCXHUB_DEVICE_CONTEXT _In_ UCXENDPOINT _In_ ULONG _In_ ULONG TtPortNumber
Definition: hubucx.h:240
_In_ UCXHUB_DEVICE_CONTEXT DeviceContext
Definition: hubucx.h:237
_In_ UCXHUB_DEVICE_CONTEXT _In_ UCXENDPOINT Endpoint
Definition: hubucx.h:238
_In_ UCXHUB_DEVICE_CONTEXT _In_ UCXENDPOINT _In_ ULONG EndpointNumber
Definition: hubucx.h:239
#define HUB_TAG_HUB
Definition: hubutil.h:12
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
static PVOID ExAllocatePoolZero(ULONG PoolType, SIZE_T NumberOfBytes, ULONG Tag)
Definition: precomp.h:45
static void Clear(void)
Definition: treeview.c:388
unsigned short USHORT
Definition: pedump.c:61
UCXUSBDEVICE Hub
Definition: hubucx.h:430
PFN_UCXHUB_CLEAR_TT_BUFFER_COMPLETE ClearTtBufferComplete
Definition: hubucx.h:450
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFREQUEST Request
@ ResetTtOnCancel
@ NoClearTtOnCancel
_In_opt_ PVOID HubContext
Definition: usbdhub.h:41
WdfObjectDelete(String)
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFDEVICE Child
Definition: wdffdo.h:536
#define WdfObjectDereferenceWithTag(Handle, Tag)
Definition: wdfobject.h:829
#define WdfObjectReferenceWithTag(Handle, Tag)
Definition: wdfobject.h:806
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

◆ HubControlComplete()

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

Definition at line 297 of file hubreq.cpp.

302{
304 NTSTATUS Status = Params->IoStatus.Status;
305
308
310
311 if (!NT_SUCCESS(Status))
312 {
313 DPRINT1("Hub %p control request 0x%x failed 0x%lx, URB status 0x%lx\n",
314 Hub, Hub->m_Control.Urb.SetupPacket[1], Status, Hub->m_Control.Urb.Hdr.Status);
317 return;
318 }
319
321}
VOID Post(_In_ HubEvent Event)
Definition: fdo.h:194
HubControlRequest m_Control
Definition: fdo.h:413
ULONG m_FailureMessageId
Definition: fdo.h:402
#define HUB_MSG_CONTROL_TRANSFER_FAILED
Definition: hubreq.h:151
@ TransferFailed
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
Definition: kse.h:81
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
struct _URB_CONTROL_TRANSFER_EX Urb
Definition: hubreq.h:21
_In_ WDFIOTARGET Target
Definition: wdfrequest.h:306
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:308

◆ HubInterruptComplete()

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

Definition at line 661 of file hubreq.cpp.

666{
669 NTSTATUS Status = Params->IoStatus.Status;
670
673
674 /* Built by hand; the bitmap helper that initializes it is pageable */
675 Interrupt->BitmapBytes = (USHORT)Interrupt->Urb.TransferBufferLength;
676 Interrupt->Bitmap.SizeOfBitMap = Interrupt->BitmapBytes * 8;
677 Interrupt->Bitmap.Buffer = (PULONG)Interrupt->BitmapBuffer;
678
679 if (!NT_SUCCESS(Status))
680 {
681 /* The hub cancels its own read when it powers down */
683 {
684 DPRINT("Hub %p status change read canceled\n", Hub);
685 }
686 else
687 {
688 DPRINT1("Hub %p status change read failed 0x%lx, URB status 0x%lx\n",
689 Hub, Status, Interrupt->Urb.Hdr.Status);
691 }
692
694 return;
695 }
696
698}
HubInterruptRequest m_Interrupt
Definition: fdo.h:414
#define HUB_MSG_INTERRUPT_FAILED
Definition: hubreq.h:152
@ InterruptFailed
#define DPRINT
Definition: sndvol32.h:73
uint32_t * PULONG
Definition: typedefs.h:59
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_INTERRUPT_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFINTERRUPT * Interrupt
Definition: wdfinterrupt.h:379

◆ HubSendControl()

static VOID NTAPI HubSendControl ( _In_ HubFdo *  Hub,
_In_reads_bytes_opt_(Length) PVOID  Buffer,
_In_ ULONG  Length,
_In_ BOOLEAN  ShortOk 
)
static

Definition at line 327 of file hubreq.cpp.

332{
334
336 Hub->UsbDevice(),
338 Hub,
339 Buffer,
340 Length,
341 ShortOk,
343 if (!NT_SUCCESS(Status))
345}
Definition: bufpool.h:45
static EVT_WDF_REQUEST_COMPLETION_ROUTINE HubControlComplete
Definition: hubreq.cpp:289
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
NTSTATUS Send(_In_ WDFIOTARGET Target, _In_opt_ UCXUSBDEVICE Device, _In_ PFN_WDF_REQUEST_COMPLETION_ROUTINE Completion, _In_ WDFCONTEXT Context, _In_reads_bytes_opt_(Length) PVOID Buffer, _In_ ULONG Length, _In_ BOOLEAN ShortTransferOk, _In_ BOOLEAN ForwardProgress)
Definition: hubreq.cpp:62

Referenced by HubMachine::AckHubChange(), HubMachine::GetHubDescriptor(), HubMachine::GetHubStatus(), HubMachine::GetPortStatus(), HubMachine::GetStandardStatus(), and HubMachine::SetHubDepth().

◆ HubTakePortStatusRequest()

static WDFREQUEST NTAPI HubTakePortStatusRequest ( _In_ HubFdo *  Hub,
_Out_ PWDF_REQUEST_PARAMETERS  Params 
)
static

Definition at line 803 of file hubreq.cpp.

806{
807 WDFREQUEST Request = Hub->m_PortStatusRequest;
808
810
812 WdfRequestGetParameters(Request, Params);
813 return Request;
814}
WDFREQUEST m_PortStatusRequest
Definition: fdo.h:392
FORCEINLINE VOID WDF_REQUEST_PARAMETERS_INIT(_Out_ PWDF_REQUEST_PARAMETERS Parameters)
Definition: wdfrequest.h:211

Referenced by HubMachine::FailPortStatus(), and HubMachine::ReplyPortStatus().

◆ HubTtClearComplete()

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

Definition at line 194 of file hubreq.cpp.

199{
201 HubFdo* Hub = Clear->Hub;
202
204
205 if (!NT_SUCCESS(Params->IoStatus.Status))
206 {
207 DPRINT1("Hub %p TT clear for endpoint %p failed 0x%lx, URB status 0x%lx\n",
208 Hub, Clear->Endpoint, Params->IoStatus.Status, Clear->Control.Urb.Hdr.Status);
209 }
210
212
215}

Referenced by HubClearTtBuffer().

◆ HubTtClearValue()

static NTSTATUS NTAPI HubTtClearValue ( _In_ HubChild *  Child,
_In_ UCXENDPOINT  Endpoint,
_In_ ULONG  EndpointAddress,
_Out_ PUSHORT  Value 
)
static

Definition at line 130 of file hubreq.cpp.

135{
136 HubConfiguration* Config = Child->m_CurrentConfig;
139 HubPipe* Pipe;
140 ULONG Index;
141 USHORT Type;
142
143 *Value = 0;
144
145 if (Child->Speed() != UsbLowSpeed && Child->Speed() != UsbFullSpeed)
146 return STATUS_UNSUCCESSFUL;
147
148 if (Endpoint == Child->m_DefaultEndpoint)
149 {
150 *Value = (USHORT)((EndpointAddress & 0x0F) | ((Child->m_Address & 0x7F) << 4));
151 return STATUS_SUCCESS;
152 }
153
154 if (Config == NULL)
155 return STATUS_UNSUCCESSFUL;
156
157 for (Entry = Config->Interfaces.Flink; Entry != &Config->Interfaces; Entry = Entry->Flink)
158 {
160
161 for (Index = 0; Index < Interface->PipeCount; Index++)
162 {
163 Pipe = &Interface->Pipes[Index];
164 if (Pipe->Endpoint != Endpoint)
165 continue;
166
167 switch (Pipe->Descriptor->bmAttributes & USB_ENDPOINT_TYPE_MASK)
168 {
170 Type = 2;
171 break;
172
174 Type = 0;
175 break;
176
177 default:
178 return STATUS_UNSUCCESSFUL;
179 }
180
181 *Value = (USHORT)((EndpointAddress & 0x0F) | ((Child->m_Address & 0x7F) << 4) | (Type << 11));
182 if (EndpointAddress & USB_ENDPOINT_DIRECTION_MASK)
183 *Value |= 0x8000;
184 return STATUS_SUCCESS;
185 }
186 }
187
188 return STATUS_UNSUCCESSFUL;
189}
Type
Definition: Type.h:7
PLIST_ENTRY Entry
Definition: devhcd.cpp:1262
#define STATUS_SUCCESS
Definition: shellext.h:65
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ PUCX_CONTROLLER_CONFIG Config
_In_ UCXUSBDEVICE _In_ ULONG Interface
Definition: ucxusbdevice.h:428
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define USB_ENDPOINT_TYPE_CONTROL
Definition: usb100.h:62
#define USB_ENDPOINT_DIRECTION_MASK
Definition: usb100.h:73
#define USB_ENDPOINT_TYPE_MASK
Definition: usb100.h:61
#define USB_ENDPOINT_TYPE_BULK
Definition: usb100.h:64
@ UsbLowSpeed
Definition: usb200.h:42
@ UsbFullSpeed
Definition: usb200.h:43
_In_ WDFCOLLECTION _In_ ULONG Index
_In_ WDFUSBPIPE Pipe
Definition: wdfusb.h:1741

Referenced by HubClearTtBuffer().

Variable Documentation

◆ HubControlComplete

EVT_WDF_REQUEST_COMPLETION_ROUTINE HubControlComplete
static

Definition at line 289 of file hubreq.cpp.

Referenced by HubMachine::GetConfigDescriptor(), and HubSendControl().

◆ HubInterruptComplete

EVT_WDF_REQUEST_COMPLETION_ROUTINE HubInterruptComplete
static

Definition at line 290 of file hubreq.cpp.

Referenced by HubMachine::StartStatusChangeRead().

◆ HubTagClearTt

const char HubTagClearTt[] = "hub TT clear"
static

Definition at line 116 of file hubreq.cpp.

Referenced by HubClearTtBuffer().