[USBPORT] Implement USBPORT_FreeBandwidthUSB2().
[reactos.git] / drivers / usb / usbport / usbport.h
1 /*
2 * PROJECT: ReactOS USB Port Driver
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: USBPort declarations
5 * COPYRIGHT: Copyright 2017 Vadim Galyant <vgal@rambler.ru>
6 */
7
8 #ifndef USBPORT_H__
9 #define USBPORT_H__
10
11 #include <ntddk.h>
12 #include <windef.h>
13 #include <stdio.h>
14 #include <wdmguid.h>
15 #include <ntstrsafe.h>
16 #include <usb.h>
17 #include <hubbusif.h>
18 #include <usbbusif.h>
19 #include <usbdlib.h>
20 #include <usbuser.h>
21 #include <drivers/usbport/usbmport.h>
22
23 #define PCI_INTERFACE_USB_ID_UHCI 0x00
24 #define PCI_INTERFACE_USB_ID_OHCI 0x10
25 #define PCI_INTERFACE_USB_ID_EHCI 0x20
26 #define PCI_INTERFACE_USB_ID_XHCI 0x30
27
28 #ifdef USBD_TRANSFER_DIRECTION // due hubbusif.h included usbdi.h (Which overwrites...)
29 #undef USBD_TRANSFER_DIRECTION
30 #define USBD_TRANSFER_DIRECTION 0x00000001
31 #endif
32
33 #define USBPORT_RECIPIENT_HUB BMREQUEST_TO_DEVICE
34 #define USBPORT_RECIPIENT_PORT BMREQUEST_TO_OTHER
35
36 #define INVALIDATE_ENDPOINT_ONLY 0
37 #define INVALIDATE_ENDPOINT_WORKER_THREAD 1
38 #define INVALIDATE_ENDPOINT_WORKER_DPC 2
39 #define INVALIDATE_ENDPOINT_INT_NEXT_SOF 3
40
41 #define USBPORT_DMA_DIRECTION_FROM_DEVICE 1
42 #define USBPORT_DMA_DIRECTION_TO_DEVICE 2
43
44 #define USB_PORT_TAG 'pbsu'
45 #define URB_FUNCTION_MAX 0x31
46
47 /* Hub Class Feature Selectors (Recipient - Port) */
48 #define FEATURE_PORT_CONNECTION 0
49 #define FEATURE_PORT_ENABLE 1
50 #define FEATURE_PORT_SUSPEND 2
51 #define FEATURE_PORT_OVER_CURRENT 3
52 #define FEATURE_PORT_RESET 4
53 #define FEATURE_PORT_POWER 8
54 #define FEATURE_PORT_LOW_SPEED 9
55 #define FEATURE_C_PORT_CONNECTION 16
56 #define FEATURE_C_PORT_ENABLE 17
57 #define FEATURE_C_PORT_SUSPEND 18
58 #define FEATURE_C_PORT_OVER_CURRENT 19
59 #define FEATURE_C_PORT_RESET 20
60
61 /* Hub Class Feature Selectors (Recipient - Hub) */
62 #define FEATURE_C_HUB_LOCAL_POWER 0
63 #define FEATURE_C_HUB_OVER_CURRENT 1
64
65 /* Flags */
66 #define USBPORT_FLAG_INT_CONNECTED 0x00000001
67 #define USBPORT_FLAG_HC_STARTED 0x00000002
68 #define USBPORT_FLAG_HC_POLLING 0x00000004
69 #define USBPORT_FLAG_WORKER_THREAD_ON 0x00000008
70 #define USBPORT_FLAG_HC_SUSPEND 0x00000100
71 #define USBPORT_FLAG_INTERRUPT_ENABLED 0x00000400
72 #define USBPORT_FLAG_SELECTIVE_SUSPEND 0x00000800
73 #define USBPORT_FLAG_DOS_SYMBOLIC_NAME 0x00010000
74 #define USBPORT_FLAG_LEGACY_SUPPORT 0x00080000
75 #define USBPORT_FLAG_HC_WAKE_SUPPORT 0x00200000
76 #define USBPORT_FLAG_DIAGNOSTIC_MODE 0x00800000 //IOCTL_USB_DIAGNOSTIC_MODE_ON
77 #define USBPORT_FLAG_COMPANION_HC 0x01000000
78 #define USBPORT_FLAG_REGISTERED_FDO 0x02000000
79 #define USBPORT_FLAG_NO_HACTION 0x04000000
80 #define USBPORT_FLAG_BIOS_DISABLE_SS 0x08000000 //Selective Suspend
81 #define USBPORT_FLAG_PWR_AND_CHIRP_LOCK 0x10000000
82 #define USBPORT_FLAG_POWER_AND_CHIRP_OK 0x40000000
83 #define USBPORT_FLAG_RH_INIT_CALLBACK 0x80000000
84
85 /* PnP state Flags */
86 #define USBPORT_PNP_STATE_NOT_INIT 0x00000001
87 #define USBPORT_PNP_STATE_STARTED 0x00000002
88 #define USBPORT_PNP_STATE_FAILED 0x00000004
89 #define USBPORT_PNP_STATE_STOPPED 0x00000008
90
91 /* Timer Flags */
92 #define USBPORT_TMFLAG_TIMER_QUEUED 0x00000001
93 #define USBPORT_TMFLAG_HC_SUSPENDED 0x00000002
94 #define USBPORT_TMFLAG_HC_RESUME 0x00000004
95 #define USBPORT_TMFLAG_RH_SUSPENDED 0x00000008
96 #define USBPORT_TMFLAG_TIMER_STARTED 0x00000010
97 #define USBPORT_TMFLAG_WAKE 0x00000020
98 #define USBPORT_TMFLAG_IDLE_QUEUEITEM_ON 0x00000040
99
100 /* Miniport Flags */
101 #define USBPORT_MPFLAG_INTERRUPTS_ENABLED 0x00000001
102 #define USBPORT_MPFLAG_SUSPENDED 0x00000002
103
104 /* Device handle Flags (USBPORT_DEVICE_HANDLE) */
105 #define DEVICE_HANDLE_FLAG_ROOTHUB 0x00000002
106 #define DEVICE_HANDLE_FLAG_REMOVED 0x00000008
107 #define DEVICE_HANDLE_FLAG_USB2HUB 0x00000010
108
109 /* Endpoint Flags (USBPORT_ENDPOINT) */
110 #define ENDPOINT_FLAG_DMA_TYPE 0x00000001
111 #define ENDPOINT_FLAG_ROOTHUB_EP0 0x00000002
112 #define ENDPOINT_FLAG_NUKE 0x00000008
113 #define ENDPOINT_FLAG_QUEUENE_EMPTY 0x00000010
114 #define ENDPOINT_FLAG_ABORTING 0x00000020
115 #define ENDPOINT_FLAG_IDLE 0x00000100
116 #define ENDPOINT_FLAG_OPENED 0x00000200
117 #define ENDPOINT_FLAG_CLOSED 0x00000400
118
119 /* UsbdFlags Flags (URB) */
120 #define USBD_FLAG_ALLOCATED_MDL 0x00000002
121 #define USBD_FLAG_NOT_ISO_TRANSFER 0x00000010
122 #define USBD_FLAG_ALLOCATED_TRANSFER 0x00000020
123
124 /* Pipe handle Flags (USBPORT_PIPE_HANDLE) */
125 #define PIPE_HANDLE_FLAG_CLOSED 0x00000001
126 #define PIPE_HANDLE_FLAG_NULL_PACKET_SIZE 0x00000002
127
128 /* Transfer Flags (USBPORT_TRANSFER) */
129 #define TRANSFER_FLAG_CANCELED 0x00000001
130 #define TRANSFER_FLAG_DMA_MAPPED 0x00000002
131 #define TRANSFER_FLAG_HIGH_SPEED 0x00000004
132 #define TRANSFER_FLAG_SUBMITED 0x00000008
133 #define TRANSFER_FLAG_ABORTED 0x00000010
134 #define TRANSFER_FLAG_ISO 0x00000020
135 #define TRANSFER_FLAG_DEVICE_GONE 0x00000080
136 #define TRANSFER_FLAG_SPLITED 0x00000100
137 #define TRANSFER_FLAG_COMPLETED 0x00000200
138 #define TRANSFER_FLAG_PARENT 0x00000400
139
140 extern KSPIN_LOCK USBPORT_SpinLock;
141 extern LIST_ENTRY USBPORT_MiniPortDrivers;
142
143 typedef USBD_STATUS* PUSBD_STATUS;
144
145 typedef struct _USBPORT_COMMON_BUFFER_HEADER {
146 ULONG Length;
147 ULONG_PTR BaseVA;
148 PHYSICAL_ADDRESS LogicalAddress;
149 SIZE_T BufferLength;
150 ULONG_PTR VirtualAddress;
151 ULONG_PTR PhysicalAddress;
152 } USBPORT_COMMON_BUFFER_HEADER, *PUSBPORT_COMMON_BUFFER_HEADER;
153
154 typedef struct _USBPORT_ENDPOINT *PUSBPORT_ENDPOINT;
155
156 typedef struct _USB2_HC_EXTENSION *PUSB2_HC_EXTENSION;
157 typedef struct _USB2_TT_EXTENSION *PUSB2_TT_EXTENSION;
158 typedef struct _USB2_TT *PUSB2_TT;
159 typedef struct _USB2_TT_ENDPOINT *PUSB2_TT_ENDPOINT;
160
161 typedef struct _USBPORT_PIPE_HANDLE {
162 ULONG Flags;
163 ULONG PipeFlags;
164 USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
165 UCHAR Padded;
166 PUSBPORT_ENDPOINT Endpoint;
167 LIST_ENTRY PipeLink;
168 } USBPORT_PIPE_HANDLE, *PUSBPORT_PIPE_HANDLE;
169
170 typedef struct _USBPORT_CONFIGURATION_HANDLE {
171 PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor;
172 LIST_ENTRY InterfaceHandleList;
173 //USB_CONFIGURATION_DESCRIPTOR CfgDescriptor; // Body.
174 } USBPORT_CONFIGURATION_HANDLE, *PUSBPORT_CONFIGURATION_HANDLE;
175
176 typedef struct _USBPORT_INTERFACE_HANDLE {
177 LIST_ENTRY InterfaceLink;
178 UCHAR AlternateSetting;
179 UCHAR Pad1[3];
180 USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
181 UCHAR Pad2[3];
182 USBPORT_PIPE_HANDLE PipeHandle[1];
183 } USBPORT_INTERFACE_HANDLE, *PUSBPORT_INTERFACE_HANDLE;
184
185 typedef struct _USBPORT_DEVICE_HANDLE {
186 ULONG Flags;
187 USHORT DeviceAddress;
188 USHORT PortNumber;
189 USBPORT_PIPE_HANDLE PipeHandle;
190 ULONG DeviceSpeed;
191 BOOL IsRootHub;
192 LIST_ENTRY PipeHandleList;
193 PUSBPORT_CONFIGURATION_HANDLE ConfigHandle;
194 struct _USBPORT_DEVICE_HANDLE *HubDeviceHandle;
195 USB_DEVICE_DESCRIPTOR DeviceDescriptor;
196 LIST_ENTRY DeviceHandleLink;
197 LONG DeviceHandleLock;
198 ULONG TtCount;
199 PUSB2_TT_EXTENSION TtExtension; // Transaction Translator
200 LIST_ENTRY TtList;
201 } USBPORT_DEVICE_HANDLE, *PUSBPORT_DEVICE_HANDLE;
202
203 typedef struct _USBPORT_ENDPOINT {
204 ULONG Flags;
205 PDEVICE_OBJECT FdoDevice;
206 PUSBPORT_COMMON_BUFFER_HEADER HeaderBuffer;
207 PUSBPORT_DEVICE_HANDLE DeviceHandle;
208 PUSB2_TT_EXTENSION TtExtension; // Transaction Translator
209 PUSB2_TT_ENDPOINT TtEndpoint;
210 USBPORT_ENDPOINT_PROPERTIES EndpointProperties;
211 ULONG EndpointWorker;
212 ULONG FrameNumber;
213 /* Locks */
214 KSPIN_LOCK EndpointSpinLock;
215 KIRQL EndpointOldIrql;
216 KIRQL EndpointStateOldIrql;
217 UCHAR Padded[2];
218 LONG LockCounter;
219 LONG FlushPendingLock;
220 /* State */
221 ULONG StateLast;
222 ULONG StateNext;
223 LIST_ENTRY StateChangeLink;
224 KSPIN_LOCK StateChangeSpinLock;
225 /* Transfer lists */
226 LIST_ENTRY PendingTransferList;
227 LIST_ENTRY TransferList;
228 LIST_ENTRY CancelList;
229 LIST_ENTRY AbortList;
230 /* Links */
231 LIST_ENTRY EndpointLink;
232 LIST_ENTRY WorkerLink;
233 LIST_ENTRY CloseLink;
234 LIST_ENTRY DispatchLink;
235 LIST_ENTRY FlushLink;
236 LIST_ENTRY FlushControllerLink;
237 LIST_ENTRY FlushAbortLink;
238 LIST_ENTRY TtLink;
239 LIST_ENTRY RebalanceLink;
240 } USBPORT_ENDPOINT, *PUSBPORT_ENDPOINT;
241
242 typedef struct _USBPORT_ISO_BLOCK *PUSBPORT_ISO_BLOCK;
243
244 typedef struct _USBPORT_TRANSFER {
245 ULONG Flags;
246 PIRP Irp;
247 PURB Urb;
248 PRKEVENT Event;
249 PVOID MiniportTransfer;
250 SIZE_T PortTransferLength; // Only port part
251 SIZE_T FullTransferLength; // Port + miniport
252 PUSBPORT_ENDPOINT Endpoint;
253 USBPORT_TRANSFER_PARAMETERS TransferParameters;
254 PMDL TransferBufferMDL;
255 ULONG Direction;
256 LIST_ENTRY TransferLink;
257 USBD_STATUS USBDStatus;
258 ULONG CompletedTransferLen;
259 ULONG NumberOfMapRegisters;
260 PVOID MapRegisterBase;
261 ULONG TimeOut;
262 LARGE_INTEGER Time;
263 struct _USBPORT_TRANSFER * ParentTransfer;
264 KSPIN_LOCK TransferSpinLock;
265 LIST_ENTRY SplitTransfersList; // for parent transfers
266 LIST_ENTRY SplitLink; // for splitted transfers
267 ULONG Period;
268 PUSBPORT_ISO_BLOCK IsoBlockPtr; // pointer on IsoBlock
269 // SgList should be LAST field
270 USBPORT_SCATTER_GATHER_LIST SgList; // variable length
271 //USBPORT_ISO_BLOCK IsoBlock; // variable length
272 } USBPORT_TRANSFER, *PUSBPORT_TRANSFER;
273
274 typedef struct _USBPORT_IRP_TABLE {
275 struct _USBPORT_IRP_TABLE * LinkNextTable;
276 PIRP irp[0X200];
277 } USBPORT_IRP_TABLE, *PUSBPORT_IRP_TABLE;
278
279 typedef struct _USBPORT_COMMON_DEVICE_EXTENSION {
280 PDEVICE_OBJECT SelfDevice;
281 PDEVICE_OBJECT LowerPdoDevice; // PhysicalDeviceObject
282 PDEVICE_OBJECT LowerDevice; // TopOfStackDeviceObject
283 ULONG IsPDO;
284 UNICODE_STRING SymbolicLinkName;
285 BOOL IsInterfaceEnabled;
286 DEVICE_POWER_STATE DevicePowerState;
287 ULONG PnpStateFlags;
288 } USBPORT_COMMON_DEVICE_EXTENSION, *PUSBPORT_COMMON_DEVICE_EXTENSION;
289
290 typedef struct _USBPORT_DEVICE_EXTENSION {
291 USBPORT_COMMON_DEVICE_EXTENSION CommonExtension;
292 ULONG Flags;
293 PDEVICE_OBJECT RootHubPdo; // RootHubDeviceObject
294 KSPIN_LOCK RootHubCallbackSpinLock;
295 LONG RHInitCallBackLock;
296 LONG ChirpRootPortLock;
297 KSEMAPHORE ControllerSemaphore;
298 ULONG FdoNameNumber;
299 UNICODE_STRING DosDeviceSymbolicName;
300 ULONG UsbBIOSx;
301 LIST_ENTRY ControllerLink;
302 ULONG CommonBufferLimit;
303 /* Miniport */
304 ULONG MiniPortFlags;
305 PVOID MiniPortExt;
306 PUSBPORT_MINIPORT_INTERFACE MiniPortInterface;
307 USBPORT_RESOURCES UsbPortResources;
308 PUSBPORT_COMMON_BUFFER_HEADER MiniPortCommonBuffer;
309 KSPIN_LOCK MiniportSpinLock;
310 /* Bus Interface */
311 BUS_INTERFACE_STANDARD BusInterface;
312 USHORT VendorID;
313 USHORT DeviceID;
314 UCHAR RevisionID;
315 UCHAR ProgIf;
316 UCHAR SubClass;
317 UCHAR BaseClass;
318 /* Dma Adapter */
319 PDMA_ADAPTER DmaAdapter;
320 ULONG NumberMapRegs;
321 /* Interrupt */
322 PKINTERRUPT InterruptObject;
323 KDPC IsrDpc;
324 LONG IsrDpcCounter;
325 LONG IsrDpcHandlerCounter;
326 KSPIN_LOCK MiniportInterruptsSpinLock;
327 KTIMER TimerSoftInterrupt;
328 KDPC SoftInterruptDpc;
329 /* Endpoints */
330 ULONG PeriodicEndpoints;
331 LIST_ENTRY EndpointList;
332 KSPIN_LOCK EndpointListSpinLock;
333 LIST_ENTRY EpStateChangeList;
334 KSPIN_LOCK EpStateChangeSpinLock;
335 LIST_ENTRY EndpointClosedList;
336 KSPIN_LOCK EndpointClosedSpinLock;
337 LIST_ENTRY WorkerList;
338 /* Transfers */
339 LIST_ENTRY MapTransferList;
340 KSPIN_LOCK MapTransferSpinLock;
341 LIST_ENTRY DoneTransferList;
342 KSPIN_LOCK DoneTransferSpinLock;
343 KDPC TransferFlushDpc;
344 KSPIN_LOCK FlushTransferSpinLock;
345 KSPIN_LOCK FlushPendingTransferSpinLock;
346 /* Timer */
347 ULONG TimerValue; // Timer period (500) msec. default
348 ULONG TimerFlags;
349 KTIMER TimerObject;
350 KDPC TimerDpc;
351 KSPIN_LOCK TimerFlagsSpinLock;
352 /* Worker Thread */
353 PRKTHREAD WorkerThread;
354 HANDLE WorkerThreadHandle;
355 KEVENT WorkerThreadEvent;
356 KSPIN_LOCK WorkerThreadEventSpinLock;
357 /* Usb Devices */
358 ULONG UsbAddressBitMap[4];
359 LIST_ENTRY DeviceHandleList;
360 KSPIN_LOCK DeviceHandleSpinLock;
361 KSEMAPHORE DeviceSemaphore;
362 /* Device Capabilities */
363 DEVICE_CAPABILITIES Capabilities;
364 ULONG BusNumber;
365 ULONG PciDeviceNumber;
366 ULONG PciFunctionNumber;
367 ULONG TotalBusBandwidth;
368 /* Idle */
369 LARGE_INTEGER IdleTime;
370 IO_CSQ IdleIoCsq;
371 KSPIN_LOCK IdleIoCsqSpinLock;
372 LIST_ENTRY IdleIrpList;
373 LONG IdleLockCounter;
374 /* Bad Requests */
375 IO_CSQ BadRequestIoCsq;
376 KSPIN_LOCK BadRequestIoCsqSpinLock;
377 LIST_ENTRY BadRequestList;
378 LONG BadRequestLockCounter;
379 /* Irp Queues */
380 PUSBPORT_IRP_TABLE PendingIrpTable;
381 PUSBPORT_IRP_TABLE ActiveIrpTable;
382 /* Power */
383 LONG SetPowerLockCounter;
384 KSPIN_LOCK PowerWakeSpinLock;
385 KSPIN_LOCK SetPowerD0SpinLock;
386 KDPC WorkerRequestDpc;
387 KDPC HcWakeDpc;
388 /* Usb 2.0 HC Extension */
389 PUSB2_HC_EXTENSION Usb2Extension;
390 ULONG Bandwidth[32];
391 KSPIN_LOCK TtSpinLock;
392
393 /* Miniport extension should be aligned on 0x100 */
394 #if !defined(_M_X64)
395 ULONG Padded[64];
396 #else
397 ULONG Padded[0];
398 #endif
399
400 } USBPORT_DEVICE_EXTENSION, *PUSBPORT_DEVICE_EXTENSION;
401
402 #if !defined(_M_X64)
403 C_ASSERT(sizeof(USBPORT_DEVICE_EXTENSION) == 0x500);
404 #else
405 C_ASSERT(sizeof(USBPORT_DEVICE_EXTENSION) == 0x600);
406 #endif
407
408 typedef struct _USBPORT_RH_DESCRIPTORS {
409 USB_DEVICE_DESCRIPTOR DeviceDescriptor;
410 USB_CONFIGURATION_DESCRIPTOR ConfigDescriptor;
411 USB_INTERFACE_DESCRIPTOR InterfaceDescriptor;
412 USB_ENDPOINT_DESCRIPTOR EndPointDescriptor;
413 USB_HUB_DESCRIPTOR Descriptor; // Size may be: 7 + 2[1..32] (7 + 2..64)
414 } USBPORT_RH_DESCRIPTORS, *PUSBPORT_RH_DESCRIPTORS;
415
416 typedef struct _USBPORT_RHDEVICE_EXTENSION {
417 USBPORT_COMMON_DEVICE_EXTENSION CommonExtension;
418 ULONG Flags;
419 PDEVICE_OBJECT FdoDevice;
420 ULONG PdoNameNumber;
421 USBPORT_DEVICE_HANDLE DeviceHandle;
422 PUSBPORT_RH_DESCRIPTORS RootHubDescriptors;
423 PUSBPORT_ENDPOINT Endpoint;
424 ULONG ConfigurationValue;
425 PRH_INIT_CALLBACK RootHubInitCallback;
426 PVOID RootHubInitContext;
427 DEVICE_CAPABILITIES Capabilities;
428 PIRP WakeIrp;
429 } USBPORT_RHDEVICE_EXTENSION, *PUSBPORT_RHDEVICE_EXTENSION;
430
431 typedef struct _USBPORT_ASYNC_CALLBACK_DATA {
432 ULONG Reserved;
433 PDEVICE_OBJECT FdoDevice;
434 KTIMER AsyncTimer;
435 KDPC AsyncTimerDpc;
436 ASYNC_TIMER_CALLBACK *CallbackFunction;
437 ULONG CallbackContext;
438 } USBPORT_ASYNC_CALLBACK_DATA, *PUSBPORT_ASYNC_CALLBACK_DATA;
439
440 C_ASSERT(sizeof(USBPORT_ASYNC_CALLBACK_DATA) == 16 + 18 * sizeof(PVOID));
441
442 typedef struct _TIMER_WORK_QUEUE_ITEM {
443 WORK_QUEUE_ITEM WqItem;
444 PDEVICE_OBJECT FdoDevice;
445 ULONG Context;
446 } TIMER_WORK_QUEUE_ITEM, *PTIMER_WORK_QUEUE_ITEM;
447
448 /* Transaction Translator */
449 /* See Chapter 5 - USB Data Flow Model and Chapter 11 - Hub Specification */
450
451 #define USB2_FRAMES 32
452 #define USB2_MICROFRAMES 8
453 #define USB2_MAX_MICROFRAMES (USB2_FRAMES * USB2_MICROFRAMES)
454
455 #define USB2_MAX_MICROFRAME_ALLOCATION 7000 // bytes
456 #define USB2_CONTROLLER_DELAY 100
457 #define USB2_FS_MAX_PERIODIC_ALLOCATION 1157 // ((12000 / 8 bits) * 0.9) / (7/6) - 90% max, and bits stuffing
458 #define USB2_FS_SOF_TIME 6
459 #define USB2_HUB_DELAY 30
460 #define USB2_MAX_FS_LS_TRANSACTIONS_IN_UFRAME 16
461 #define USB2_FS_RAW_BYTES_IN_MICROFRAME 188 // (12000 / 8 bits / USB2_MICROFRAMES) = 187,5. But we use "best case budget"
462
463 /* Overheads */
464 #define USB2_LS_INTERRUPT_OVERHEAD 117 // FS-bytes
465 #define USB2_FS_INTERRUPT_OVERHEAD 13
466 #define USB2_HS_INTERRUPT_OUT_OVERHEAD 45
467 #define USB2_HS_INTERRUPT_IN_OVERHEAD 25
468 #define USB2_FS_ISOCHRONOUS_OVERHEAD 9
469 #define USB2_HS_ISOCHRONOUS_OUT_OVERHEAD 38
470 #define USB2_HS_ISOCHRONOUS_IN_OVERHEAD 18
471
472 #define USB2_HS_SS_INTERRUPT_OUT_OVERHEAD 58
473 #define USB2_HS_CS_INTERRUPT_OUT_OVERHEAD 36
474 #define USB2_HS_SS_INTERRUPT_IN_OVERHEAD 39
475 #define USB2_HS_CS_INTERRUPT_IN_OVERHEAD 38
476
477 #define USB2_HS_SS_ISOCHRONOUS_OUT_OVERHEAD 58
478 #define USB2_HS_SS_ISOCHRONOUS_IN_OVERHEAD 39
479 #define USB2_HS_CS_ISOCHRONOUS_IN_OVERHEAD 38
480
481 typedef union _USB2_TT_ENDPOINT_PARAMS {
482 struct {
483 ULONG TransferType : 4;
484 ULONG Direction : 1;
485 USB_DEVICE_SPEED DeviceSpeed : 2;
486 BOOL EndpointMoved : 1;
487 ULONG Reserved : 24;
488 };
489 ULONG AsULONG;
490 } USB2_TT_ENDPOINT_PARAMS;
491
492 C_ASSERT(sizeof(USB2_TT_ENDPOINT_PARAMS) == sizeof(ULONG));
493
494 typedef union _USB2_TT_ENDPOINT_NUMS {
495 struct {
496 ULONG NumStarts : 4;
497 ULONG NumCompletes : 4;
498 ULONG Reserved : 24;
499 };
500 ULONG AsULONG;
501 } USB2_TT_ENDPOINT_NUMS;
502
503 C_ASSERT(sizeof(USB2_TT_ENDPOINT_NUMS) == sizeof(ULONG));
504
505 typedef struct _USB2_TT_ENDPOINT {
506 PUSB2_TT Tt;
507 PUSBPORT_ENDPOINT Endpoint;
508 struct _USB2_TT_ENDPOINT * NextTtEndpoint;
509 USB2_TT_ENDPOINT_PARAMS TtEndpointParams;
510 USB2_TT_ENDPOINT_NUMS Nums;
511 BOOL IsPromoted;
512 USHORT MaxPacketSize;
513 USHORT PreviosPeriod;
514 USHORT Period;
515 USHORT ActualPeriod;
516 USHORT CalcBusTime;
517 USHORT StartTime;
518 USHORT Reserved2;
519 UCHAR StartFrame;
520 UCHAR StartMicroframe;
521 } USB2_TT_ENDPOINT, *PUSB2_TT_ENDPOINT;
522
523 typedef struct _USB2_FRAME_BUDGET {
524 PUSB2_TT_ENDPOINT IsoEndpoint;
525 PUSB2_TT_ENDPOINT IntEndpoint;
526 PUSB2_TT_ENDPOINT AltEndpoint;
527 USHORT TimeUsed;
528 USHORT Reserved2;
529 } USB2_FRAME_BUDGET, *PUSB2_FRAME_BUDGET;
530
531 typedef struct _USB2_TT {
532 PUSB2_HC_EXTENSION HcExtension;
533 ULONG DelayTime;
534 ULONG MaxTime;
535 USB2_TT_ENDPOINT IntEndpoint[USB2_FRAMES];
536 USB2_TT_ENDPOINT IsoEndpoint[USB2_FRAMES];
537 USB2_FRAME_BUDGET FrameBudget[USB2_FRAMES];
538 ULONG NumStartSplits[USB2_FRAMES][USB2_MICROFRAMES];
539 ULONG TimeCS[USB2_FRAMES][USB2_MICROFRAMES];
540 } USB2_TT, *PUSB2_TT;
541
542 #define USB2_TT_EXTENSION_FLAG_DELETED 1
543
544 typedef struct _USB2_TT_EXTENSION {
545 PDEVICE_OBJECT RootHubPdo;
546 ULONG Flags;
547 ULONG BusBandwidth;
548 ULONG Bandwidth[USB2_FRAMES];
549 ULONG MaxBandwidth;
550 ULONG MinBandwidth;
551 USHORT DeviceAddress;
552 USHORT TtNumber;
553 LIST_ENTRY EndpointList;
554 LIST_ENTRY Link;
555 USB2_TT Tt;
556 } USB2_TT_EXTENSION, *PUSB2_TT_EXTENSION;
557
558 typedef struct _USB2_HC_EXTENSION {
559 ULONG MaxHsBusAllocation;
560 ULONG HcDelayTime;
561 ULONG TimeUsed[USB2_FRAMES][USB2_MICROFRAMES];
562 USB2_TT HcTt;
563 } USB2_HC_EXTENSION, *PUSB2_HC_EXTENSION;
564
565 typedef struct _USB2_REBALANCE {
566 PUSB2_TT_ENDPOINT RebalanceEndpoint[USB2_FRAMES - 2];
567 } USB2_REBALANCE, *PUSB2_REBALANCE;
568
569 /* usbport.c */
570 NTSTATUS
571 NTAPI
572 USBPORT_USBDStatusToNtStatus(
573 IN PURB Urb,
574 IN USBD_STATUS USBDStatus);
575
576 NTSTATUS
577 NTAPI
578 USBPORT_Wait(
579 IN PVOID MiniPortExtension,
580 IN ULONG Milliseconds);
581
582 VOID
583 NTAPI
584 USBPORT_TransferFlushDpc(
585 IN PRKDPC Dpc,
586 IN PVOID DeferredContext,
587 IN PVOID SystemArgument1,
588 IN PVOID SystemArgument2);
589
590 NTSTATUS
591 NTAPI
592 USBPORT_CreateWorkerThread(
593 IN PDEVICE_OBJECT FdoDevice);
594
595 BOOLEAN
596 NTAPI
597 USBPORT_StartTimer(
598 IN PDEVICE_OBJECT FdoDevice,
599 IN ULONG Time);
600
601 PUSBPORT_COMMON_BUFFER_HEADER
602 NTAPI
603 USBPORT_AllocateCommonBuffer(
604 IN PDEVICE_OBJECT FdoDevice,
605 IN SIZE_T BufferLength);
606
607 VOID
608 NTAPI
609 USBPORT_FreeCommonBuffer(
610 IN PDEVICE_OBJECT FdoDevice,
611 IN PUSBPORT_COMMON_BUFFER_HEADER HeaderBuffer);
612
613 USBD_STATUS
614 NTAPI
615 USBPORT_AllocateTransfer(
616 IN PDEVICE_OBJECT FdoDevice,
617 IN PURB Urb,
618 IN PUSBPORT_DEVICE_HANDLE DeviceHandle,
619 IN PIRP Irp,
620 IN PRKEVENT Event);
621
622 VOID
623 NTAPI
624 USBPORT_FlushMapTransfers(
625 IN PDEVICE_OBJECT FdoDevice);
626
627 VOID
628 NTAPI
629 USBPORT_IsrDpc(
630 IN PRKDPC Dpc,
631 IN PVOID DeferredContext,
632 IN PVOID SystemArgument1,
633 IN PVOID SystemArgument2);
634
635 BOOLEAN
636 NTAPI
637 USBPORT_InterruptService(
638 IN PKINTERRUPT Interrupt,
639 IN PVOID ServiceContext);
640
641 VOID
642 NTAPI
643 USBPORT_SignalWorkerThread(
644 IN PDEVICE_OBJECT FdoDevice);
645
646 VOID
647 NTAPI
648 USBPORT_CompleteTransfer(
649 IN PURB Urb,
650 IN USBD_STATUS TransferStatus);
651
652 VOID
653 NTAPI
654 USBPORT_DpcHandler(
655 IN PDEVICE_OBJECT FdoDevice);
656
657 VOID
658 NTAPI
659 USBPORT_WorkerRequestDpc(
660 IN PRKDPC Dpc,
661 IN PVOID DeferredContext,
662 IN PVOID SystemArgument1,
663 IN PVOID SystemArgument2);
664
665 BOOLEAN
666 NTAPI
667 USBPORT_QueueDoneTransfer(
668 IN PUSBPORT_TRANSFER Transfer,
669 IN USBD_STATUS USBDStatus);
670
671 VOID
672 NTAPI
673 USBPORT_MiniportInterrupts(
674 IN PDEVICE_OBJECT FdoDevice,
675 IN BOOLEAN IsEnable);
676
677 NTSTATUS
678 NTAPI
679 USBPORT_SetRegistryKeyValue(
680 IN PDEVICE_OBJECT DeviceObject,
681 IN BOOL UseDriverKey,
682 IN ULONG Type,
683 IN PCWSTR ValueNameString,
684 IN PVOID Data,
685 IN ULONG DataSize);
686
687 NTSTATUS
688 NTAPI
689 USBPORT_GetRegistryKeyValueFullInfo(
690 IN PDEVICE_OBJECT FdoDevice,
691 IN PDEVICE_OBJECT PdoDevice,
692 IN BOOL UseDriverKey,
693 IN PCWSTR SourceString,
694 IN ULONG LengthStr,
695 IN PVOID Buffer,
696 IN ULONG NumberOfBytes);
697
698 VOID
699 NTAPI
700 USBPORT_AddUSB1Fdo(
701 IN PDEVICE_OBJECT FdoDevice);
702
703 VOID
704 NTAPI
705 USBPORT_AddUSB2Fdo(
706 IN PDEVICE_OBJECT FdoDevice);
707
708 VOID
709 NTAPI
710 USBPORT_RemoveUSBxFdo(
711 IN PDEVICE_OBJECT FdoDevice);
712
713 PDEVICE_OBJECT
714 NTAPI
715 USBPORT_FindUSB2Controller(
716 IN PDEVICE_OBJECT FdoDevice);
717
718 PDEVICE_RELATIONS
719 NTAPI
720 USBPORT_FindCompanionControllers(
721 IN PDEVICE_OBJECT USB2FdoDevice,
722 IN BOOLEAN IsObRefer,
723 IN BOOLEAN IsFDOsReturned);
724
725 VOID
726 NTAPI
727 USBPORT_InvalidateControllerHandler(
728 IN PDEVICE_OBJECT FdoDevice,
729 IN ULONG Type);
730
731 VOID
732 NTAPI
733 USBPORT_DoneTransfer(
734 IN PUSBPORT_TRANSFER Transfer);
735
736 /* debug.c */
737 ULONG
738 NTAPI
739 USBPORT_DbgPrint(
740 IN PVOID MiniPortExtension,
741 IN ULONG Level,
742 IN PCH Format,
743 ...);
744
745 ULONG
746 NTAPI
747 USBPORT_TestDebugBreak(
748 IN PVOID MiniPortExtension);
749
750 ULONG
751 NTAPI
752 USBPORT_AssertFailure(
753 PVOID MiniPortExtension,
754 PVOID FailedAssertion,
755 PVOID FileName,
756 ULONG LineNumber,
757 PCHAR Message);
758
759 VOID
760 NTAPI
761 USBPORT_BugCheck(
762 IN PVOID MiniPortExtension);
763
764 ULONG
765 NTAPI
766 USBPORT_LogEntry(
767 IN PVOID MiniPortExtension,
768 IN ULONG DriverTag,
769 IN ULONG EnumTag,
770 IN ULONG P1,
771 IN ULONG P2,
772 IN ULONG P3);
773
774 VOID
775 NTAPI
776 USBPORT_DumpingDeviceDescriptor(
777 IN PUSB_DEVICE_DESCRIPTOR DeviceDescriptor);
778
779 VOID
780 NTAPI
781 USBPORT_DumpingConfiguration(
782 IN PUSB_CONFIGURATION_DESCRIPTOR ConfigDescriptor);
783
784 VOID
785 NTAPI
786 USBPORT_DumpingCapabilities(
787 IN PDEVICE_CAPABILITIES Capabilities);
788
789 VOID
790 NTAPI
791 USBPORT_DumpingSetupPacket(
792 IN PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket);
793
794 VOID
795 NTAPI
796 USBPORT_DumpingURB(
797 IN PURB Urb);
798
799 VOID
800 NTAPI
801 USBPORT_DumpingIDs(
802 IN PVOID Buffer);
803
804 /* device.c */
805 NTSTATUS
806 NTAPI
807 USBPORT_HandleSelectConfiguration(
808 IN PDEVICE_OBJECT FdoDevice,
809 IN PIRP Irp,
810 IN PURB Urb);
811
812 VOID
813 NTAPI
814 USBPORT_AddDeviceHandle(
815 IN PDEVICE_OBJECT FdoDevice,
816 IN PUSBPORT_DEVICE_HANDLE DeviceHandle);
817
818 VOID
819 NTAPI
820 USBPORT_RemoveDeviceHandle(
821 IN PDEVICE_OBJECT FdoDevice,
822 IN PUSBPORT_DEVICE_HANDLE DeviceHandle);
823
824 BOOLEAN
825 NTAPI
826 USBPORT_ValidateDeviceHandle(
827 IN PDEVICE_OBJECT FdoDevice,
828 IN PUSBPORT_DEVICE_HANDLE DeviceHandle);
829
830 NTSTATUS
831 NTAPI
832 USBPORT_CreateDevice(
833 IN OUT PUSB_DEVICE_HANDLE *pUsbdDeviceHandle,
834 IN PDEVICE_OBJECT FdoDevice,
835 IN PUSBPORT_DEVICE_HANDLE HubDeviceHandle,
836 IN USHORT PortStatus,
837 IN USHORT Port);
838
839 NTSTATUS
840 NTAPI
841 USBPORT_InitializeDevice(
842 IN PUSBPORT_DEVICE_HANDLE DeviceHandle,
843 IN PDEVICE_OBJECT FdoDevice);
844
845 NTSTATUS
846 NTAPI
847 USBPORT_GetUsbDescriptor(
848 IN PUSBPORT_DEVICE_HANDLE DeviceHandle,
849 IN PDEVICE_OBJECT FdoDevice,
850 IN UCHAR Type,
851 IN PUCHAR ConfigDesc,
852 IN PULONG ConfigDescSize);
853
854 NTSTATUS
855 NTAPI
856 USBPORT_HandleSelectInterface(
857 IN PDEVICE_OBJECT FdoDevice,
858 IN PIRP Irp,
859 IN PURB Urb);
860
861 NTSTATUS
862 NTAPI
863 USBPORT_RemoveDevice(
864 IN PDEVICE_OBJECT FdoDevice,
865 IN OUT PUSBPORT_DEVICE_HANDLE DeviceHandle,
866 IN ULONG Flags);
867
868 NTSTATUS
869 NTAPI
870 USBPORT_SendSetupPacket(
871 IN PUSBPORT_DEVICE_HANDLE DeviceHandle,
872 IN PDEVICE_OBJECT FdoDevice,
873 IN PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket,
874 IN PVOID Buffer,
875 IN ULONG Length,
876 IN OUT PULONG TransferedLen,
877 IN OUT PUSBD_STATUS pUSBDStatus);
878
879 NTSTATUS
880 NTAPI
881 USBPORT_RestoreDevice(
882 IN PDEVICE_OBJECT FdoDevice,
883 IN OUT PUSBPORT_DEVICE_HANDLE OldDeviceHandle,
884 IN OUT PUSBPORT_DEVICE_HANDLE NewDeviceHandle);
885
886 NTSTATUS
887 NTAPI
888 USBPORT_Initialize20Hub(
889 IN PDEVICE_OBJECT FdoDevice,
890 IN PUSBPORT_DEVICE_HANDLE HubDeviceHandle,
891 IN ULONG TtCount);
892
893 /* endpoint.c */
894 NTSTATUS
895 NTAPI
896 USBPORT_OpenPipe(
897 IN PDEVICE_OBJECT FdoDevice,
898 IN PUSBPORT_DEVICE_HANDLE DeviceHandle,
899 IN PUSBPORT_PIPE_HANDLE PipeHandle,
900 IN PUSBD_STATUS UsbdStatus);
901
902 MPSTATUS
903 NTAPI
904 MiniportOpenEndpoint(
905 IN PDEVICE_OBJECT FdoDevice,
906 IN PUSBPORT_ENDPOINT Endpoint);
907
908 NTSTATUS
909 NTAPI
910 USBPORT_ReopenPipe(
911 IN PDEVICE_OBJECT FdoDevice,
912 IN PUSBPORT_ENDPOINT Endpoint);
913
914 VOID
915 NTAPI
916 USBPORT_ClosePipe(
917 IN PUSBPORT_DEVICE_HANDLE DeviceHandle,
918 IN PDEVICE_OBJECT FdoDevice,
919 IN PUSBPORT_PIPE_HANDLE PipeHandle);
920
921 VOID
922 NTAPI
923 MiniportCloseEndpoint(
924 IN PDEVICE_OBJECT FdoDevice,
925 IN PUSBPORT_ENDPOINT Endpoint);
926
927 VOID
928 NTAPI
929 USBPORT_AddPipeHandle(
930 IN PUSBPORT_DEVICE_HANDLE DeviceHandle,
931 IN PUSBPORT_PIPE_HANDLE PipeHandle);
932
933 VOID
934 NTAPI
935 USBPORT_RemovePipeHandle(
936 IN PUSBPORT_DEVICE_HANDLE DeviceHandle,
937 IN PUSBPORT_PIPE_HANDLE PipeHandle);
938
939 BOOLEAN
940 NTAPI
941 USBPORT_ValidatePipeHandle(
942 IN PUSBPORT_DEVICE_HANDLE DeviceHandle,
943 IN PUSBPORT_PIPE_HANDLE PipeHandle);
944
945 VOID
946 NTAPI
947 USBPORT_FlushClosedEndpointList(
948 IN PDEVICE_OBJECT FdoDevice);
949
950 VOID
951 NTAPI
952 USBPORT_SetEndpointState(
953 IN PUSBPORT_ENDPOINT Endpoint,
954 IN ULONG State);
955
956 ULONG
957 NTAPI
958 USBPORT_GetEndpointState(
959 IN PUSBPORT_ENDPOINT Endpoint);
960
961 VOID
962 NTAPI
963 USBPORT_InvalidateEndpointHandler(
964 IN PDEVICE_OBJECT FdoDevice,
965 IN PUSBPORT_ENDPOINT Endpoint,
966 IN ULONG Type);
967
968 BOOLEAN
969 NTAPI
970 USBPORT_EndpointWorker(
971 IN PUSBPORT_ENDPOINT Endpoint,
972 IN BOOLEAN Flag);
973
974 VOID
975 NTAPI
976 USBPORT_NukeAllEndpoints(
977 IN PDEVICE_OBJECT FdoDevice);
978
979 BOOLEAN
980 NTAPI
981 USBPORT_EndpointHasQueuedTransfers(
982 IN PDEVICE_OBJECT FdoDevice,
983 IN PUSBPORT_ENDPOINT Endpoint,
984 IN PULONG TransferCount);
985
986 /* iface.c */
987 NTSTATUS
988 NTAPI
989 USBPORT_PdoQueryInterface(
990 IN PDEVICE_OBJECT FdoDevice,
991 IN PDEVICE_OBJECT PdoDevice,
992 IN PIRP Irp);
993
994 /* ioctl.c */
995 NTSTATUS
996 NTAPI
997 USBPORT_PdoDeviceControl(
998 PDEVICE_OBJECT PdoDevice,
999 PIRP Irp);
1000
1001 NTSTATUS
1002 NTAPI
1003 USBPORT_FdoDeviceControl(
1004 PDEVICE_OBJECT FdoDevice,
1005 PIRP Irp);
1006
1007 NTSTATUS
1008 NTAPI
1009 USBPORT_FdoInternalDeviceControl(
1010 IN PDEVICE_OBJECT FdoDevice,
1011 IN PIRP Irp);
1012
1013 NTSTATUS
1014 NTAPI
1015 USBPORT_PdoInternalDeviceControl(
1016 IN PDEVICE_OBJECT FdoDevice,
1017 IN PIRP Irp);
1018
1019 NTSTATUS
1020 NTAPI
1021 USBPORT_GetSymbolicName(
1022 IN PDEVICE_OBJECT RootHubPdo,
1023 IN PUNICODE_STRING DestinationString);
1024
1025 /* iso.c */
1026 USBD_STATUS
1027 NTAPI
1028 USBPORT_InitializeIsoTransfer(
1029 IN PDEVICE_OBJECT FdoDevice,
1030 IN struct _URB_ISOCH_TRANSFER * Urb,
1031 IN PUSBPORT_TRANSFER Transfer);
1032
1033 ULONG
1034 NTAPI
1035 USBPORT_CompleteIsoTransfer(
1036 IN PVOID MiniPortExtension,
1037 IN PVOID MiniPortEndpoint,
1038 IN PVOID TransferParameters,
1039 IN ULONG TransferLength);
1040
1041 /* pnp.c */
1042 NTSTATUS
1043 NTAPI
1044 USBPORT_FdoPnP(
1045 IN PDEVICE_OBJECT FdoDevice,
1046 IN PIRP Irp);
1047
1048 NTSTATUS
1049 NTAPI
1050 USBPORT_PdoPnP(
1051 IN PDEVICE_OBJECT FdoDevice,
1052 IN PIRP Irp);
1053
1054 /* power.c */
1055 NTSTATUS
1056 NTAPI
1057 USBPORT_PdoPower(
1058 IN PDEVICE_OBJECT PdoDevice,
1059 IN PIRP Irp);
1060
1061 NTSTATUS
1062 NTAPI
1063 USBPORT_FdoPower(
1064 IN PDEVICE_OBJECT FdoDevice,
1065 IN PIRP Irp);
1066
1067 NTSTATUS
1068 NTAPI
1069 USBPORT_IdleNotification(
1070 IN PDEVICE_OBJECT PdoDevice,
1071 IN PIRP Irp);
1072
1073 VOID
1074 NTAPI
1075 USBPORT_AdjustDeviceCapabilities(
1076 IN PDEVICE_OBJECT FdoDevice,
1077 IN PDEVICE_OBJECT PdoDevice);
1078
1079 VOID
1080 NTAPI
1081 USBPORT_DoIdleNotificationCallback(
1082 IN PVOID Context);
1083
1084 VOID
1085 NTAPI
1086 USBPORT_CompletePdoWaitWake(
1087 IN PDEVICE_OBJECT FdoDevice);
1088
1089 VOID
1090 NTAPI
1091 USBPORT_DoSetPowerD0(
1092 IN PDEVICE_OBJECT FdoDevice);
1093
1094 VOID
1095 NTAPI
1096 USBPORT_HcWakeDpc(
1097 IN PRKDPC Dpc,
1098 IN PVOID DeferredContext,
1099 IN PVOID SystemArgument1,
1100 IN PVOID SystemArgument2);
1101
1102 VOID
1103 NTAPI
1104 USBPORT_HcQueueWakeDpc(
1105 IN PDEVICE_OBJECT FdoDevice);
1106
1107 /* queue.c */
1108 VOID
1109 NTAPI
1110 USBPORT_InsertIdleIrp(
1111 IN PIO_CSQ Csq,
1112 IN PIRP Irp);
1113
1114 VOID
1115 NTAPI
1116 USBPORT_RemoveIdleIrp(
1117 IN PIO_CSQ Csq,
1118 IN PIRP Irp);
1119
1120 PIRP
1121 NTAPI
1122 USBPORT_PeekNextIdleIrp(
1123 IN PIO_CSQ Csq,
1124 IN PIRP Irp,
1125 IN PVOID PeekContext);
1126
1127 VOID
1128 NTAPI
1129 USBPORT_AcquireIdleLock(
1130 IN PIO_CSQ Csq,
1131 IN PKIRQL Irql);
1132
1133 VOID
1134 NTAPI
1135 USBPORT_ReleaseIdleLock(
1136 IN PIO_CSQ Csq,
1137 IN KIRQL Irql);
1138
1139 VOID
1140 NTAPI
1141 USBPORT_CompleteCanceledIdleIrp(
1142 IN PIO_CSQ Csq,
1143 IN PIRP Irp);
1144
1145 VOID
1146 NTAPI
1147 USBPORT_InsertBadRequest(
1148 IN PIO_CSQ Csq,
1149 IN PIRP Irp);
1150
1151 VOID
1152 NTAPI
1153 USBPORT_RemoveBadRequest(
1154 IN PIO_CSQ Csq,
1155 IN PIRP Irp);
1156
1157 PIRP
1158 NTAPI
1159 USBPORT_PeekNextBadRequest(
1160 IN PIO_CSQ Csq,
1161 IN PIRP Irp,
1162 IN PVOID PeekContext);
1163
1164 VOID
1165 NTAPI
1166 USBPORT_AcquireBadRequestLock(
1167 IN PIO_CSQ Csq,
1168 IN PKIRQL Irql);
1169
1170 VOID
1171 NTAPI
1172 USBPORT_ReleaseBadRequestLock(
1173 IN PIO_CSQ Csq,
1174 IN KIRQL Irql);
1175
1176 VOID
1177 NTAPI
1178 USBPORT_CompleteCanceledBadRequest(
1179 IN PIO_CSQ Csq,
1180 IN PIRP Irp);
1181
1182 VOID
1183 NTAPI
1184 USBPORT_InsertIrpInTable(
1185 IN PUSBPORT_IRP_TABLE IrpTable,
1186 IN PIRP Irp);
1187
1188 PIRP
1189 NTAPI
1190 USBPORT_RemovePendingTransferIrp(
1191 IN PDEVICE_OBJECT FdoDevice,
1192 IN PIRP Irp);
1193
1194 PIRP
1195 NTAPI
1196 USBPORT_RemoveActiveTransferIrp(
1197 IN PDEVICE_OBJECT FdoDevice,
1198 IN PIRP Irp);
1199
1200 VOID
1201 NTAPI
1202 USBPORT_FindUrbInIrpTable(
1203 IN PUSBPORT_IRP_TABLE IrpTable,
1204 IN PURB Urb,
1205 IN PIRP Irp);
1206
1207 VOID
1208 NTAPI
1209 USBPORT_CancelActiveTransferIrp(
1210 IN PDEVICE_OBJECT DeviceObject,
1211 IN PIRP Irp);
1212
1213 VOID
1214 NTAPI
1215 USBPORT_FlushAbortList(
1216 IN PUSBPORT_ENDPOINT Endpoint);
1217
1218 VOID
1219 NTAPI
1220 USBPORT_FlushCancelList(
1221 IN PUSBPORT_ENDPOINT Endpoint);
1222
1223 VOID
1224 NTAPI
1225 USBPORT_QueueTransferUrb(
1226 IN PURB Urb);
1227
1228 VOID
1229 NTAPI
1230 USBPORT_FlushAllEndpoints(
1231 IN PDEVICE_OBJECT FdoDevice);
1232
1233 VOID
1234 NTAPI
1235 USBPORT_FlushPendingTransfers(
1236 IN PUSBPORT_ENDPOINT Endpoint);
1237
1238 BOOLEAN
1239 NTAPI
1240 USBPORT_QueueActiveUrbToEndpoint(
1241 IN PUSBPORT_ENDPOINT Endpoint,
1242 IN PURB Urb);
1243
1244 VOID
1245 NTAPI
1246 USBPORT_FlushController(
1247 IN PDEVICE_OBJECT FdoDevice);
1248
1249 VOID
1250 NTAPI
1251 USBPORT_BadRequestFlush(
1252 IN PDEVICE_OBJECT FdoDevice);
1253
1254 VOID
1255 NTAPI
1256 USBPORT_AbortEndpoint(
1257 IN PDEVICE_OBJECT FdoDevice,
1258 IN PUSBPORT_ENDPOINT Endpoint,
1259 IN PIRP Irp);
1260
1261 /* roothub.c */
1262 VOID
1263 NTAPI
1264 USBPORT_RootHubEndpointWorker(
1265 PUSBPORT_ENDPOINT Endpoint);
1266
1267 NTSTATUS
1268 NTAPI
1269 USBPORT_RootHubCreateDevice(
1270 IN PDEVICE_OBJECT FdoDevice,
1271 IN PDEVICE_OBJECT PdoDevice);
1272
1273 ULONG
1274 NTAPI
1275 USBPORT_InvalidateRootHub(
1276 PVOID MiniPortExtension);
1277
1278 VOID
1279 NTAPI
1280 USBPORT_RootHubPowerAndChirpAllCcPorts(
1281 IN PDEVICE_OBJECT FdoDevice);
1282
1283 /* trfsplit.c */
1284 VOID
1285 NTAPI
1286 USBPORT_SplitTransfer(
1287 IN PDEVICE_OBJECT FdoDevice,
1288 IN PUSBPORT_ENDPOINT Endpoint,
1289 IN PUSBPORT_TRANSFER Transfer,
1290 IN PLIST_ENTRY List);
1291
1292 VOID
1293 NTAPI
1294 USBPORT_DoneSplitTransfer(
1295 IN PUSBPORT_TRANSFER SplitTransfer);
1296
1297 VOID
1298 NTAPI
1299 USBPORT_CancelSplitTransfer(
1300 IN PUSBPORT_TRANSFER SplitTransfer);
1301
1302 /* urb.c */
1303 NTSTATUS
1304 NTAPI
1305 USBPORT_HandleSubmitURB(
1306 IN PDEVICE_OBJECT PdoDevice,
1307 IN PIRP Irp,
1308 IN PURB Urb);
1309
1310 /* usb2.c */
1311 BOOLEAN
1312 NTAPI
1313 USBPORT_AllocateBandwidthUSB2(
1314 IN PDEVICE_OBJECT FdoDevice,
1315 IN PUSBPORT_ENDPOINT Endpoint);
1316
1317 VOID
1318 NTAPI
1319 USBPORT_FreeBandwidthUSB2(
1320 IN PDEVICE_OBJECT FdoDevice,
1321 IN PUSBPORT_ENDPOINT Endpoint);
1322
1323 VOID
1324 NTAPI
1325 USBPORT_UpdateAllocatedBwTt(
1326 IN PUSB2_TT_EXTENSION TtExtension);
1327
1328 VOID
1329 NTAPI
1330 USB2_InitTT(
1331 IN PUSB2_HC_EXTENSION HcExtension,
1332 IN PUSB2_TT Tt);
1333
1334 VOID
1335 NTAPI
1336 USB2_InitController(
1337 IN PUSB2_HC_EXTENSION HcExtension);
1338
1339 VOID
1340 NTAPI
1341 USBPORT_DumpingEndpointProperties(
1342 IN PUSBPORT_ENDPOINT_PROPERTIES EndpointProperties);
1343
1344 VOID
1345 NTAPI
1346 USBPORT_DumpingTtEndpoint(
1347 IN PUSB2_TT_ENDPOINT TtEndpoint);
1348
1349 #endif /* USBPORT_H__ */