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