ReactOS 0.4.15-dev-7958-gcd0bb1a
usbport.h File Reference
#include <ntifs.h>
#include <windef.h>
#include <stdio.h>
#include <wdmguid.h>
#include <ntstrsafe.h>
#include <usb.h>
#include <hubbusif.h>
#include <usbbusif.h>
#include <usbdlib.h>
#include <usbuser.h>
#include <drivers/usbport/usbmport.h>
Include dependency graph for usbport.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _USBPORT_COMMON_BUFFER_HEADER
 
struct  _USBPORT_PIPE_HANDLE
 
struct  _USBPORT_CONFIGURATION_HANDLE
 
struct  _USBPORT_INTERFACE_HANDLE
 
struct  _USBPORT_DEVICE_HANDLE
 
struct  _USBPORT_ENDPOINT
 
struct  _USBPORT_TRANSFER
 
struct  _USBPORT_IRP_TABLE
 
struct  _USBPORT_COMMON_DEVICE_EXTENSION
 
struct  _USBPORT_DEVICE_EXTENSION
 
struct  _USBPORT_RH_DESCRIPTORS
 
struct  _USBPORT_RHDEVICE_EXTENSION
 
struct  _USBPORT_ASYNC_CALLBACK_DATA
 
struct  _TIMER_WORK_QUEUE_ITEM
 
union  _USB2_TT_ENDPOINT_PARAMS
 
union  _USB2_TT_ENDPOINT_NUMS
 
struct  _USB2_TT_ENDPOINT
 
struct  _USB2_FRAME_BUDGET
 
struct  _USB2_TT
 
struct  _USB2_TT_EXTENSION
 
struct  _USB2_HC_EXTENSION
 
struct  _USB2_REBALANCE
 

Macros

#define PCI_INTERFACE_USB_ID_UHCI   0x00
 
#define PCI_INTERFACE_USB_ID_OHCI   0x10
 
#define PCI_INTERFACE_USB_ID_EHCI   0x20
 
#define PCI_INTERFACE_USB_ID_XHCI   0x30
 
#define USBPORT_RECIPIENT_HUB   BMREQUEST_TO_DEVICE
 
#define USBPORT_RECIPIENT_PORT   BMREQUEST_TO_OTHER
 
#define INVALIDATE_ENDPOINT_ONLY   0
 
#define INVALIDATE_ENDPOINT_WORKER_THREAD   1
 
#define INVALIDATE_ENDPOINT_WORKER_DPC   2
 
#define INVALIDATE_ENDPOINT_INT_NEXT_SOF   3
 
#define USBPORT_DMA_DIRECTION_FROM_DEVICE   1
 
#define USBPORT_DMA_DIRECTION_TO_DEVICE   2
 
#define USB_PORT_TAG   'pbsu'
 
#define URB_FUNCTION_MAX   0x31
 
#define FEATURE_PORT_CONNECTION   0
 
#define FEATURE_PORT_ENABLE   1
 
#define FEATURE_PORT_SUSPEND   2
 
#define FEATURE_PORT_OVER_CURRENT   3
 
#define FEATURE_PORT_RESET   4
 
#define FEATURE_PORT_POWER   8
 
#define FEATURE_PORT_LOW_SPEED   9
 
#define FEATURE_C_PORT_CONNECTION   16
 
#define FEATURE_C_PORT_ENABLE   17
 
#define FEATURE_C_PORT_SUSPEND   18
 
#define FEATURE_C_PORT_OVER_CURRENT   19
 
#define FEATURE_C_PORT_RESET   20
 
#define FEATURE_C_HUB_LOCAL_POWER   0
 
#define FEATURE_C_HUB_OVER_CURRENT   1
 
#define USBPORT_FLAG_INT_CONNECTED   0x00000001
 
#define USBPORT_FLAG_HC_STARTED   0x00000002
 
#define USBPORT_FLAG_HC_POLLING   0x00000004
 
#define USBPORT_FLAG_WORKER_THREAD_ON   0x00000008
 
#define USBPORT_FLAG_WORKER_THREAD_EXIT   0x00000010
 
#define USBPORT_FLAG_HC_SUSPEND   0x00000100
 
#define USBPORT_FLAG_INTERRUPT_ENABLED   0x00000400
 
#define USBPORT_FLAG_SELECTIVE_SUSPEND   0x00000800
 
#define USBPORT_FLAG_DOS_SYMBOLIC_NAME   0x00010000
 
#define USBPORT_FLAG_LEGACY_SUPPORT   0x00080000
 
#define USBPORT_FLAG_HC_WAKE_SUPPORT   0x00200000
 
#define USBPORT_FLAG_DIAGNOSTIC_MODE   0x00800000
 
#define USBPORT_FLAG_COMPANION_HC   0x01000000
 
#define USBPORT_FLAG_REGISTERED_FDO   0x02000000
 
#define USBPORT_FLAG_NO_HACTION   0x04000000
 
#define USBPORT_FLAG_BIOS_DISABLE_SS   0x08000000
 
#define USBPORT_FLAG_PWR_AND_CHIRP_LOCK   0x10000000
 
#define USBPORT_FLAG_POWER_AND_CHIRP_OK   0x40000000
 
#define USBPORT_FLAG_RH_INIT_CALLBACK   0x80000000
 
#define USBPORT_PNP_STATE_NOT_INIT   0x00000001
 
#define USBPORT_PNP_STATE_STARTED   0x00000002
 
#define USBPORT_PNP_STATE_FAILED   0x00000004
 
#define USBPORT_PNP_STATE_STOPPED   0x00000008
 
#define USBPORT_TMFLAG_TIMER_QUEUED   0x00000001
 
#define USBPORT_TMFLAG_HC_SUSPENDED   0x00000002
 
#define USBPORT_TMFLAG_HC_RESUME   0x00000004
 
#define USBPORT_TMFLAG_RH_SUSPENDED   0x00000008
 
#define USBPORT_TMFLAG_TIMER_STARTED   0x00000010
 
#define USBPORT_TMFLAG_WAKE   0x00000020
 
#define USBPORT_TMFLAG_IDLE_QUEUEITEM_ON   0x00000040
 
#define USBPORT_MPFLAG_INTERRUPTS_ENABLED   0x00000001
 
#define USBPORT_MPFLAG_SUSPENDED   0x00000002
 
#define DEVICE_HANDLE_FLAG_ROOTHUB   0x00000002
 
#define DEVICE_HANDLE_FLAG_REMOVED   0x00000008
 
#define DEVICE_HANDLE_FLAG_USB2HUB   0x00000010
 
#define ENDPOINT_FLAG_DMA_TYPE   0x00000001
 
#define ENDPOINT_FLAG_ROOTHUB_EP0   0x00000002
 
#define ENDPOINT_FLAG_NUKE   0x00000008
 
#define ENDPOINT_FLAG_QUEUENE_EMPTY   0x00000010
 
#define ENDPOINT_FLAG_ABORTING   0x00000020
 
#define ENDPOINT_FLAG_IDLE   0x00000100
 
#define ENDPOINT_FLAG_OPENED   0x00000200
 
#define ENDPOINT_FLAG_CLOSED   0x00000400
 
#define USBD_FLAG_ALLOCATED_MDL   0x00000002
 
#define USBD_FLAG_NOT_ISO_TRANSFER   0x00000010
 
#define USBD_FLAG_ALLOCATED_TRANSFER   0x00000020
 
#define PIPE_HANDLE_FLAG_CLOSED   0x00000001
 
#define PIPE_HANDLE_FLAG_NULL_PACKET_SIZE   0x00000002
 
#define TRANSFER_FLAG_CANCELED   0x00000001
 
#define TRANSFER_FLAG_DMA_MAPPED   0x00000002
 
#define TRANSFER_FLAG_HIGH_SPEED   0x00000004
 
#define TRANSFER_FLAG_SUBMITED   0x00000008
 
#define TRANSFER_FLAG_ABORTED   0x00000010
 
#define TRANSFER_FLAG_ISO   0x00000020
 
#define TRANSFER_FLAG_DEVICE_GONE   0x00000080
 
#define TRANSFER_FLAG_SPLITED   0x00000100
 
#define TRANSFER_FLAG_COMPLETED   0x00000200
 
#define TRANSFER_FLAG_PARENT   0x00000400
 
#define USB2_FRAMES   32
 
#define USB2_MICROFRAMES   8
 
#define USB2_MAX_MICROFRAMES   (USB2_FRAMES * USB2_MICROFRAMES)
 
#define USB2_PREV_MICROFRAME   0xFF
 
#define USB2_MAX_MICROFRAME_ALLOCATION   7000
 
#define USB2_CONTROLLER_DELAY   100
 
#define USB2_FS_MAX_PERIODIC_ALLOCATION   1157
 
#define USB2_FS_SOF_TIME   6
 
#define USB2_HUB_DELAY   30
 
#define USB2_MAX_FS_LS_TRANSACTIONS_IN_UFRAME   16
 
#define USB2_FS_RAW_BYTES_IN_MICROFRAME   188
 
#define USB2_LS_INTERRUPT_OVERHEAD   117
 
#define USB2_FS_INTERRUPT_OVERHEAD   13
 
#define USB2_HS_INTERRUPT_OUT_OVERHEAD   45
 
#define USB2_HS_INTERRUPT_IN_OVERHEAD   25
 
#define USB2_FS_ISOCHRONOUS_OVERHEAD   9
 
#define USB2_HS_ISOCHRONOUS_OUT_OVERHEAD   38
 
#define USB2_HS_ISOCHRONOUS_IN_OVERHEAD   18
 
#define USB2_HS_SS_INTERRUPT_OUT_OVERHEAD   58
 
#define USB2_HS_CS_INTERRUPT_OUT_OVERHEAD   36
 
#define USB2_HS_SS_INTERRUPT_IN_OVERHEAD   39
 
#define USB2_HS_CS_INTERRUPT_IN_OVERHEAD   38
 
#define USB2_HS_SS_ISOCHRONOUS_OUT_OVERHEAD   58
 
#define USB2_HS_SS_ISOCHRONOUS_IN_OVERHEAD   39
 
#define USB2_HS_CS_ISOCHRONOUS_IN_OVERHEAD   38
 
#define USB2_BIT_STUFFING_OVERHEAD   (8 * (7/6))
 
#define USB2_TT_EXTENSION_FLAG_DELETED   1
 

Typedefs

typedef USBD_STATUSPUSBD_STATUS
 
typedef struct _USBPORT_COMMON_BUFFER_HEADER USBPORT_COMMON_BUFFER_HEADER
 
typedef struct _USBPORT_COMMON_BUFFER_HEADERPUSBPORT_COMMON_BUFFER_HEADER
 
typedef struct _USBPORT_ENDPOINTPUSBPORT_ENDPOINT
 
typedef struct _USB2_HC_EXTENSIONPUSB2_HC_EXTENSION
 
typedef struct _USB2_TT_EXTENSIONPUSB2_TT_EXTENSION
 
typedef struct _USB2_TTPUSB2_TT
 
typedef struct _USB2_TT_ENDPOINTPUSB2_TT_ENDPOINT
 
typedef struct _USBPORT_PIPE_HANDLE USBPORT_PIPE_HANDLE
 
typedef struct _USBPORT_PIPE_HANDLEPUSBPORT_PIPE_HANDLE
 
typedef struct _USBPORT_CONFIGURATION_HANDLE USBPORT_CONFIGURATION_HANDLE
 
typedef struct _USBPORT_CONFIGURATION_HANDLEPUSBPORT_CONFIGURATION_HANDLE
 
typedef struct _USBPORT_INTERFACE_HANDLE USBPORT_INTERFACE_HANDLE
 
typedef struct _USBPORT_INTERFACE_HANDLEPUSBPORT_INTERFACE_HANDLE
 
typedef struct _USBPORT_DEVICE_HANDLE USBPORT_DEVICE_HANDLE
 
typedef struct _USBPORT_DEVICE_HANDLEPUSBPORT_DEVICE_HANDLE
 
typedef struct _USBPORT_ENDPOINT USBPORT_ENDPOINT
 
typedef struct _USBPORT_ISO_BLOCK * PUSBPORT_ISO_BLOCK
 
typedef struct _USBPORT_TRANSFER USBPORT_TRANSFER
 
typedef struct _USBPORT_TRANSFERPUSBPORT_TRANSFER
 
typedef struct _USBPORT_IRP_TABLE USBPORT_IRP_TABLE
 
typedef struct _USBPORT_IRP_TABLEPUSBPORT_IRP_TABLE
 
typedef struct _USBPORT_COMMON_DEVICE_EXTENSION USBPORT_COMMON_DEVICE_EXTENSION
 
typedef struct _USBPORT_COMMON_DEVICE_EXTENSIONPUSBPORT_COMMON_DEVICE_EXTENSION
 
typedef struct _USBPORT_DEVICE_EXTENSION USBPORT_DEVICE_EXTENSION
 
typedef struct _USBPORT_DEVICE_EXTENSIONPUSBPORT_DEVICE_EXTENSION
 
typedef struct _USBPORT_RH_DESCRIPTORS USBPORT_RH_DESCRIPTORS
 
typedef struct _USBPORT_RH_DESCRIPTORSPUSBPORT_RH_DESCRIPTORS
 
typedef struct _USBPORT_RHDEVICE_EXTENSION USBPORT_RHDEVICE_EXTENSION
 
typedef struct _USBPORT_RHDEVICE_EXTENSIONPUSBPORT_RHDEVICE_EXTENSION
 
typedef struct _USBPORT_ASYNC_CALLBACK_DATA USBPORT_ASYNC_CALLBACK_DATA
 
typedef struct _USBPORT_ASYNC_CALLBACK_DATAPUSBPORT_ASYNC_CALLBACK_DATA
 
typedef struct _TIMER_WORK_QUEUE_ITEM TIMER_WORK_QUEUE_ITEM
 
typedef struct _TIMER_WORK_QUEUE_ITEMPTIMER_WORK_QUEUE_ITEM
 
typedef union _USB2_TT_ENDPOINT_PARAMS USB2_TT_ENDPOINT_PARAMS
 
typedef union _USB2_TT_ENDPOINT_NUMS USB2_TT_ENDPOINT_NUMS
 
typedef struct _USB2_TT_ENDPOINT USB2_TT_ENDPOINT
 
typedef struct _USB2_FRAME_BUDGET USB2_FRAME_BUDGET
 
typedef struct _USB2_FRAME_BUDGETPUSB2_FRAME_BUDGET
 
typedef struct _USB2_TT USB2_TT
 
typedef struct _USB2_TT_EXTENSION USB2_TT_EXTENSION
 
typedef struct _USB2_HC_EXTENSION USB2_HC_EXTENSION
 
typedef struct _USB2_REBALANCE USB2_REBALANCE
 
typedef struct _USB2_REBALANCEPUSB2_REBALANCE
 

Functions

 C_ASSERT (sizeof(USBPORT_DEVICE_EXTENSION)==0x500)
 
 C_ASSERT (sizeof(USBPORT_ASYNC_CALLBACK_DATA)==16+18 *sizeof(PVOID))
 
 C_ASSERT (sizeof(USB2_TT_ENDPOINT_PARAMS)==sizeof(ULONG))
 
 C_ASSERT (sizeof(USB2_TT_ENDPOINT_NUMS)==sizeof(ULONG))
 
NTSTATUS NTAPI USBPORT_USBDStatusToNtStatus (IN PURB Urb, IN USBD_STATUS USBDStatus)
 
NTSTATUS NTAPI USBPORT_Wait (IN PVOID MiniPortExtension, IN ULONG Milliseconds)
 
VOID NTAPI USBPORT_TransferFlushDpc (IN PRKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
 
NTSTATUS NTAPI USBPORT_CreateWorkerThread (IN PDEVICE_OBJECT FdoDevice)
 
VOID NTAPI USBPORT_StopWorkerThread (IN PDEVICE_OBJECT FdoDevice)
 
BOOLEAN NTAPI USBPORT_StartTimer (IN PDEVICE_OBJECT FdoDevice, IN ULONG Time)
 
PUSBPORT_COMMON_BUFFER_HEADER NTAPI USBPORT_AllocateCommonBuffer (IN PDEVICE_OBJECT FdoDevice, IN SIZE_T BufferLength)
 
VOID NTAPI USBPORT_FreeCommonBuffer (IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_COMMON_BUFFER_HEADER HeaderBuffer)
 
USBD_STATUS NTAPI USBPORT_AllocateTransfer (IN PDEVICE_OBJECT FdoDevice, IN PURB Urb, IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PIRP Irp, IN PRKEVENT Event)
 
VOID NTAPI USBPORT_FlushMapTransfers (IN PDEVICE_OBJECT FdoDevice)
 
VOID NTAPI USBPORT_IsrDpc (IN PRKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
 
BOOLEAN NTAPI USBPORT_InterruptService (IN PKINTERRUPT Interrupt, IN PVOID ServiceContext)
 
VOID NTAPI USBPORT_SignalWorkerThread (IN PDEVICE_OBJECT FdoDevice)
 
VOID NTAPI USBPORT_CompleteTransfer (IN PURB Urb, IN USBD_STATUS TransferStatus)
 
VOID NTAPI USBPORT_DpcHandler (IN PDEVICE_OBJECT FdoDevice)
 
VOID NTAPI USBPORT_WorkerRequestDpc (IN PRKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
 
BOOLEAN NTAPI USBPORT_QueueDoneTransfer (IN PUSBPORT_TRANSFER Transfer, IN USBD_STATUS USBDStatus)
 
VOID NTAPI USBPORT_MiniportInterrupts (IN PDEVICE_OBJECT FdoDevice, IN BOOLEAN IsEnable)
 
NTSTATUS NTAPI USBPORT_SetRegistryKeyValue (IN PDEVICE_OBJECT DeviceObject, IN BOOL UseDriverKey, IN ULONG Type, IN PCWSTR ValueNameString, IN PVOID Data, IN ULONG DataSize)
 
NTSTATUS NTAPI USBPORT_GetRegistryKeyValueFullInfo (IN PDEVICE_OBJECT FdoDevice, IN PDEVICE_OBJECT PdoDevice, IN BOOL UseDriverKey, IN PCWSTR SourceString, IN ULONG LengthStr, IN PVOID Buffer, IN ULONG NumberOfBytes)
 
VOID NTAPI USBPORT_AddUSB1Fdo (IN PDEVICE_OBJECT FdoDevice)
 
VOID NTAPI USBPORT_AddUSB2Fdo (IN PDEVICE_OBJECT FdoDevice)
 
VOID NTAPI USBPORT_RemoveUSBxFdo (IN PDEVICE_OBJECT FdoDevice)
 
PDEVICE_OBJECT NTAPI USBPORT_FindUSB2Controller (IN PDEVICE_OBJECT FdoDevice)
 
PDEVICE_RELATIONS NTAPI USBPORT_FindCompanionControllers (IN PDEVICE_OBJECT USB2FdoDevice, IN BOOLEAN IsObRefer, IN BOOLEAN IsFDOsReturned)
 
VOID NTAPI USBPORT_InvalidateControllerHandler (IN PDEVICE_OBJECT FdoDevice, IN ULONG Type)
 
VOID NTAPI USBPORT_DoneTransfer (IN PUSBPORT_TRANSFER Transfer)
 
ULONG USBPORT_DbgPrint (IN PVOID MiniPortExtension, IN ULONG Level, IN PCH Format,...)
 
ULONG NTAPI USBPORT_TestDebugBreak (IN PVOID MiniPortExtension)
 
ULONG NTAPI USBPORT_AssertFailure (PVOID MiniPortExtension, PVOID FailedAssertion, PVOID FileName, ULONG LineNumber, PCHAR Message)
 
VOID NTAPI USBPORT_BugCheck (IN PVOID MiniPortExtension)
 
ULONG NTAPI USBPORT_LogEntry (IN PVOID MiniPortExtension, IN ULONG DriverTag, IN ULONG EnumTag, IN ULONG P1, IN ULONG P2, IN ULONG P3)
 
VOID NTAPI USBPORT_DumpingDeviceDescriptor (IN PUSB_DEVICE_DESCRIPTOR DeviceDescriptor)
 
VOID NTAPI USBPORT_DumpingConfiguration (IN PUSB_CONFIGURATION_DESCRIPTOR ConfigDescriptor)
 
VOID NTAPI USBPORT_DumpingCapabilities (IN PDEVICE_CAPABILITIES Capabilities)
 
VOID NTAPI USBPORT_DumpingSetupPacket (IN PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket)
 
VOID NTAPI USBPORT_DumpingURB (IN PURB Urb)
 
VOID NTAPI USBPORT_DumpingIDs (IN PVOID Buffer)
 
NTSTATUS NTAPI USBPORT_HandleSelectConfiguration (IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp, IN PURB Urb)
 
VOID NTAPI USBPORT_AddDeviceHandle (IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_DEVICE_HANDLE DeviceHandle)
 
VOID NTAPI USBPORT_RemoveDeviceHandle (IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_DEVICE_HANDLE DeviceHandle)
 
BOOLEAN NTAPI USBPORT_ValidateDeviceHandle (IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_DEVICE_HANDLE DeviceHandle)
 
NTSTATUS NTAPI USBPORT_CreateDevice (IN OUT PUSB_DEVICE_HANDLE *pUsbdDeviceHandle, IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_DEVICE_HANDLE HubDeviceHandle, IN USHORT PortStatus, IN USHORT Port)
 
NTSTATUS NTAPI USBPORT_InitializeDevice (IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PDEVICE_OBJECT FdoDevice)
 
NTSTATUS NTAPI USBPORT_GetUsbDescriptor (IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PDEVICE_OBJECT FdoDevice, IN UCHAR Type, IN PUCHAR ConfigDesc, IN PULONG ConfigDescSize)
 
NTSTATUS NTAPI USBPORT_HandleSelectInterface (IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp, IN PURB Urb)
 
NTSTATUS NTAPI USBPORT_RemoveDevice (IN PDEVICE_OBJECT FdoDevice, IN OUT PUSBPORT_DEVICE_HANDLE DeviceHandle, IN ULONG Flags)
 
NTSTATUS NTAPI USBPORT_SendSetupPacket (IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PDEVICE_OBJECT FdoDevice, IN PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket, IN PVOID Buffer, IN ULONG Length, IN OUT PULONG TransferedLen, IN OUT PUSBD_STATUS pUSBDStatus)
 
NTSTATUS NTAPI USBPORT_RestoreDevice (IN PDEVICE_OBJECT FdoDevice, IN OUT PUSBPORT_DEVICE_HANDLE OldDeviceHandle, IN OUT PUSBPORT_DEVICE_HANDLE NewDeviceHandle)
 
NTSTATUS NTAPI USBPORT_Initialize20Hub (IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_DEVICE_HANDLE HubDeviceHandle, IN ULONG TtCount)
 
NTSTATUS NTAPI USBPORT_OpenPipe (IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PUSBPORT_PIPE_HANDLE PipeHandle, IN PUSBD_STATUS UsbdStatus)
 
MPSTATUS NTAPI MiniportOpenEndpoint (IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint)
 
NTSTATUS NTAPI USBPORT_ReopenPipe (IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint)
 
VOID NTAPI USBPORT_ClosePipe (IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_PIPE_HANDLE PipeHandle)
 
VOID NTAPI MiniportCloseEndpoint (IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint)
 
VOID NTAPI USBPORT_AddPipeHandle (IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PUSBPORT_PIPE_HANDLE PipeHandle)
 
VOID NTAPI USBPORT_RemovePipeHandle (IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PUSBPORT_PIPE_HANDLE PipeHandle)
 
BOOLEAN NTAPI USBPORT_ValidatePipeHandle (IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PUSBPORT_PIPE_HANDLE PipeHandle)
 
VOID NTAPI USBPORT_FlushClosedEndpointList (IN PDEVICE_OBJECT FdoDevice)
 
VOID NTAPI USBPORT_SetEndpointState (IN PUSBPORT_ENDPOINT Endpoint, IN ULONG State)
 
ULONG NTAPI USBPORT_GetEndpointState (IN PUSBPORT_ENDPOINT Endpoint)
 
VOID NTAPI USBPORT_InvalidateEndpointHandler (IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint, IN ULONG Type)
 
BOOLEAN NTAPI USBPORT_EndpointWorker (IN PUSBPORT_ENDPOINT Endpoint, IN BOOLEAN Flag)
 
VOID NTAPI USBPORT_NukeAllEndpoints (IN PDEVICE_OBJECT FdoDevice)
 
BOOLEAN NTAPI USBPORT_EndpointHasQueuedTransfers (IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint, IN PULONG TransferCount)
 
NTSTATUS NTAPI USBPORT_PdoQueryInterface (IN PDEVICE_OBJECT FdoDevice, IN PDEVICE_OBJECT PdoDevice, IN PIRP Irp)
 
NTSTATUS NTAPI USBPORT_PdoDeviceControl (PDEVICE_OBJECT PdoDevice, PIRP Irp)
 
NTSTATUS NTAPI USBPORT_FdoDeviceControl (PDEVICE_OBJECT FdoDevice, PIRP Irp)
 
NTSTATUS NTAPI USBPORT_FdoInternalDeviceControl (IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp)
 
NTSTATUS NTAPI USBPORT_PdoInternalDeviceControl (IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp)
 
NTSTATUS NTAPI USBPORT_GetSymbolicName (IN PDEVICE_OBJECT RootHubPdo, IN PUNICODE_STRING DestinationString)
 
USBD_STATUS NTAPI USBPORT_InitializeIsoTransfer (IN PDEVICE_OBJECT FdoDevice, IN struct _URB_ISOCH_TRANSFER *Urb, IN PUSBPORT_TRANSFER Transfer)
 
ULONG NTAPI USBPORT_CompleteIsoTransfer (IN PVOID MiniPortExtension, IN PVOID MiniPortEndpoint, IN PVOID TransferParameters, IN ULONG TransferLength)
 
NTSTATUS NTAPI USBPORT_FdoPnP (IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp)
 
NTSTATUS NTAPI USBPORT_PdoPnP (IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp)
 
NTSTATUS NTAPI USBPORT_PdoPower (IN PDEVICE_OBJECT PdoDevice, IN PIRP Irp)
 
NTSTATUS NTAPI USBPORT_FdoPower (IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp)
 
NTSTATUS NTAPI USBPORT_IdleNotification (IN PDEVICE_OBJECT PdoDevice, IN PIRP Irp)
 
VOID NTAPI USBPORT_AdjustDeviceCapabilities (IN PDEVICE_OBJECT FdoDevice, IN PDEVICE_OBJECT PdoDevice)
 
VOID NTAPI USBPORT_DoIdleNotificationCallback (IN PVOID Context)
 
VOID NTAPI USBPORT_CompletePdoWaitWake (IN PDEVICE_OBJECT FdoDevice)
 
VOID NTAPI USBPORT_DoSetPowerD0 (IN PDEVICE_OBJECT FdoDevice)
 
VOID NTAPI USBPORT_HcWakeDpc (IN PRKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
 
VOID NTAPI USBPORT_HcQueueWakeDpc (IN PDEVICE_OBJECT FdoDevice)
 
VOID NTAPI USBPORT_InsertIdleIrp (IN PIO_CSQ Csq, IN PIRP Irp)
 
VOID NTAPI USBPORT_RemoveIdleIrp (IN PIO_CSQ Csq, IN PIRP Irp)
 
PIRP NTAPI USBPORT_PeekNextIdleIrp (IN PIO_CSQ Csq, IN PIRP Irp, IN PVOID PeekContext)
 
VOID NTAPI USBPORT_AcquireIdleLock (IN PIO_CSQ Csq, IN PKIRQL Irql)
 
VOID NTAPI USBPORT_ReleaseIdleLock (IN PIO_CSQ Csq, IN KIRQL Irql)
 
VOID NTAPI USBPORT_CompleteCanceledIdleIrp (IN PIO_CSQ Csq, IN PIRP Irp)
 
VOID NTAPI USBPORT_InsertBadRequest (IN PIO_CSQ Csq, IN PIRP Irp)
 
VOID NTAPI USBPORT_RemoveBadRequest (IN PIO_CSQ Csq, IN PIRP Irp)
 
PIRP NTAPI USBPORT_PeekNextBadRequest (IN PIO_CSQ Csq, IN PIRP Irp, IN PVOID PeekContext)
 
VOID NTAPI USBPORT_AcquireBadRequestLock (IN PIO_CSQ Csq, IN PKIRQL Irql)
 
VOID NTAPI USBPORT_ReleaseBadRequestLock (IN PIO_CSQ Csq, IN KIRQL Irql)
 
VOID NTAPI USBPORT_CompleteCanceledBadRequest (IN PIO_CSQ Csq, IN PIRP Irp)
 
VOID NTAPI USBPORT_InsertIrpInTable (IN PUSBPORT_IRP_TABLE IrpTable, IN PIRP Irp)
 
PIRP NTAPI USBPORT_RemovePendingTransferIrp (IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp)
 
PIRP NTAPI USBPORT_RemoveActiveTransferIrp (IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp)
 
VOID NTAPI USBPORT_FindUrbInIrpTable (IN PUSBPORT_IRP_TABLE IrpTable, IN PURB Urb, IN PIRP Irp)
 
VOID NTAPI USBPORT_CancelActiveTransferIrp (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
VOID NTAPI USBPORT_FlushAbortList (IN PUSBPORT_ENDPOINT Endpoint)
 
VOID NTAPI USBPORT_FlushCancelList (IN PUSBPORT_ENDPOINT Endpoint)
 
VOID NTAPI USBPORT_QueueTransferUrb (IN PURB Urb)
 
VOID NTAPI USBPORT_FlushAllEndpoints (IN PDEVICE_OBJECT FdoDevice)
 
VOID NTAPI USBPORT_FlushPendingTransfers (IN PUSBPORT_ENDPOINT Endpoint)
 
BOOLEAN NTAPI USBPORT_QueueActiveUrbToEndpoint (IN PUSBPORT_ENDPOINT Endpoint, IN PURB Urb)
 
VOID NTAPI USBPORT_FlushController (IN PDEVICE_OBJECT FdoDevice)
 
VOID NTAPI USBPORT_BadRequestFlush (IN PDEVICE_OBJECT FdoDevice)
 
VOID NTAPI USBPORT_AbortEndpoint (IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint, IN PIRP Irp)
 
VOID NTAPI USBPORT_RootHubEndpointWorker (PUSBPORT_ENDPOINT Endpoint)
 
NTSTATUS NTAPI USBPORT_RootHubCreateDevice (IN PDEVICE_OBJECT FdoDevice, IN PDEVICE_OBJECT PdoDevice)
 
ULONG NTAPI USBPORT_InvalidateRootHub (PVOID MiniPortExtension)
 
VOID NTAPI USBPORT_RootHubPowerAndChirpAllCcPorts (IN PDEVICE_OBJECT FdoDevice)
 
VOID NTAPI USBPORT_SplitTransfer (IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint, IN PUSBPORT_TRANSFER Transfer, IN PLIST_ENTRY List)
 
VOID NTAPI USBPORT_DoneSplitTransfer (IN PUSBPORT_TRANSFER SplitTransfer)
 
VOID NTAPI USBPORT_CancelSplitTransfer (IN PUSBPORT_TRANSFER SplitTransfer)
 
NTSTATUS NTAPI USBPORT_HandleSubmitURB (IN PDEVICE_OBJECT PdoDevice, IN PIRP Irp, IN PURB Urb)
 
BOOLEAN NTAPI USBPORT_AllocateBandwidthUSB2 (IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint)
 
VOID NTAPI USBPORT_FreeBandwidthUSB2 (IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint)
 
VOID NTAPI USBPORT_UpdateAllocatedBwTt (IN PUSB2_TT_EXTENSION TtExtension)
 
VOID NTAPI USB2_InitTT (IN PUSB2_HC_EXTENSION HcExtension, IN PUSB2_TT Tt)
 
VOID NTAPI USB2_InitController (IN PUSB2_HC_EXTENSION HcExtension)
 
VOID NTAPI USBPORT_DumpingEndpointProperties (IN PUSBPORT_ENDPOINT_PROPERTIES EndpointProperties)
 
VOID NTAPI USBPORT_DumpingTtEndpoint (IN PUSB2_TT_ENDPOINT TtEndpoint)
 

Variables

KSPIN_LOCK USBPORT_SpinLock
 
LIST_ENTRY USBPORT_MiniPortDrivers
 

Macro Definition Documentation

◆ DEVICE_HANDLE_FLAG_REMOVED

#define DEVICE_HANDLE_FLAG_REMOVED   0x00000008

Definition at line 107 of file usbport.h.

◆ DEVICE_HANDLE_FLAG_ROOTHUB

#define DEVICE_HANDLE_FLAG_ROOTHUB   0x00000002

Definition at line 106 of file usbport.h.

◆ DEVICE_HANDLE_FLAG_USB2HUB

#define DEVICE_HANDLE_FLAG_USB2HUB   0x00000010

Definition at line 108 of file usbport.h.

◆ ENDPOINT_FLAG_ABORTING

#define ENDPOINT_FLAG_ABORTING   0x00000020

Definition at line 115 of file usbport.h.

◆ ENDPOINT_FLAG_CLOSED

#define ENDPOINT_FLAG_CLOSED   0x00000400

Definition at line 118 of file usbport.h.

◆ ENDPOINT_FLAG_DMA_TYPE

#define ENDPOINT_FLAG_DMA_TYPE   0x00000001

Definition at line 111 of file usbport.h.

◆ ENDPOINT_FLAG_IDLE

#define ENDPOINT_FLAG_IDLE   0x00000100

Definition at line 116 of file usbport.h.

◆ ENDPOINT_FLAG_NUKE

#define ENDPOINT_FLAG_NUKE   0x00000008

Definition at line 113 of file usbport.h.

◆ ENDPOINT_FLAG_OPENED

#define ENDPOINT_FLAG_OPENED   0x00000200

Definition at line 117 of file usbport.h.

◆ ENDPOINT_FLAG_QUEUENE_EMPTY

#define ENDPOINT_FLAG_QUEUENE_EMPTY   0x00000010

Definition at line 114 of file usbport.h.

◆ ENDPOINT_FLAG_ROOTHUB_EP0

#define ENDPOINT_FLAG_ROOTHUB_EP0   0x00000002

Definition at line 112 of file usbport.h.

◆ FEATURE_C_HUB_LOCAL_POWER

#define FEATURE_C_HUB_LOCAL_POWER   0

Definition at line 62 of file usbport.h.

◆ FEATURE_C_HUB_OVER_CURRENT

#define FEATURE_C_HUB_OVER_CURRENT   1

Definition at line 63 of file usbport.h.

◆ FEATURE_C_PORT_CONNECTION

#define FEATURE_C_PORT_CONNECTION   16

Definition at line 55 of file usbport.h.

◆ FEATURE_C_PORT_ENABLE

#define FEATURE_C_PORT_ENABLE   17

Definition at line 56 of file usbport.h.

◆ FEATURE_C_PORT_OVER_CURRENT

#define FEATURE_C_PORT_OVER_CURRENT   19

Definition at line 58 of file usbport.h.

◆ FEATURE_C_PORT_RESET

#define FEATURE_C_PORT_RESET   20

Definition at line 59 of file usbport.h.

◆ FEATURE_C_PORT_SUSPEND

#define FEATURE_C_PORT_SUSPEND   18

Definition at line 57 of file usbport.h.

◆ FEATURE_PORT_CONNECTION

#define FEATURE_PORT_CONNECTION   0

Definition at line 48 of file usbport.h.

◆ FEATURE_PORT_ENABLE

#define FEATURE_PORT_ENABLE   1

Definition at line 49 of file usbport.h.

◆ FEATURE_PORT_LOW_SPEED

#define FEATURE_PORT_LOW_SPEED   9

Definition at line 54 of file usbport.h.

◆ FEATURE_PORT_OVER_CURRENT

#define FEATURE_PORT_OVER_CURRENT   3

Definition at line 51 of file usbport.h.

◆ FEATURE_PORT_POWER

#define FEATURE_PORT_POWER   8

Definition at line 53 of file usbport.h.

◆ FEATURE_PORT_RESET

#define FEATURE_PORT_RESET   4

Definition at line 52 of file usbport.h.

◆ FEATURE_PORT_SUSPEND

#define FEATURE_PORT_SUSPEND   2

Definition at line 50 of file usbport.h.

◆ INVALIDATE_ENDPOINT_INT_NEXT_SOF

#define INVALIDATE_ENDPOINT_INT_NEXT_SOF   3

Definition at line 39 of file usbport.h.

◆ INVALIDATE_ENDPOINT_ONLY

#define INVALIDATE_ENDPOINT_ONLY   0

Definition at line 36 of file usbport.h.

◆ INVALIDATE_ENDPOINT_WORKER_DPC

#define INVALIDATE_ENDPOINT_WORKER_DPC   2

Definition at line 38 of file usbport.h.

◆ INVALIDATE_ENDPOINT_WORKER_THREAD

#define INVALIDATE_ENDPOINT_WORKER_THREAD   1

Definition at line 37 of file usbport.h.

◆ PCI_INTERFACE_USB_ID_EHCI

#define PCI_INTERFACE_USB_ID_EHCI   0x20

Definition at line 25 of file usbport.h.

◆ PCI_INTERFACE_USB_ID_OHCI

#define PCI_INTERFACE_USB_ID_OHCI   0x10

Definition at line 24 of file usbport.h.

◆ PCI_INTERFACE_USB_ID_UHCI

#define PCI_INTERFACE_USB_ID_UHCI   0x00

Definition at line 23 of file usbport.h.

◆ PCI_INTERFACE_USB_ID_XHCI

#define PCI_INTERFACE_USB_ID_XHCI   0x30

Definition at line 26 of file usbport.h.

◆ PIPE_HANDLE_FLAG_CLOSED

#define PIPE_HANDLE_FLAG_CLOSED   0x00000001

Definition at line 126 of file usbport.h.

◆ PIPE_HANDLE_FLAG_NULL_PACKET_SIZE

#define PIPE_HANDLE_FLAG_NULL_PACKET_SIZE   0x00000002

Definition at line 127 of file usbport.h.

◆ TRANSFER_FLAG_ABORTED

#define TRANSFER_FLAG_ABORTED   0x00000010

Definition at line 134 of file usbport.h.

◆ TRANSFER_FLAG_CANCELED

#define TRANSFER_FLAG_CANCELED   0x00000001

Definition at line 130 of file usbport.h.

◆ TRANSFER_FLAG_COMPLETED

#define TRANSFER_FLAG_COMPLETED   0x00000200

Definition at line 138 of file usbport.h.

◆ TRANSFER_FLAG_DEVICE_GONE

#define TRANSFER_FLAG_DEVICE_GONE   0x00000080

Definition at line 136 of file usbport.h.

◆ TRANSFER_FLAG_DMA_MAPPED

#define TRANSFER_FLAG_DMA_MAPPED   0x00000002

Definition at line 131 of file usbport.h.

◆ TRANSFER_FLAG_HIGH_SPEED

#define TRANSFER_FLAG_HIGH_SPEED   0x00000004

Definition at line 132 of file usbport.h.

◆ TRANSFER_FLAG_ISO

#define TRANSFER_FLAG_ISO   0x00000020

Definition at line 135 of file usbport.h.

◆ TRANSFER_FLAG_PARENT

#define TRANSFER_FLAG_PARENT   0x00000400

Definition at line 139 of file usbport.h.

◆ TRANSFER_FLAG_SPLITED

#define TRANSFER_FLAG_SPLITED   0x00000100

Definition at line 137 of file usbport.h.

◆ TRANSFER_FLAG_SUBMITED

#define TRANSFER_FLAG_SUBMITED   0x00000008

Definition at line 133 of file usbport.h.

◆ URB_FUNCTION_MAX

#define URB_FUNCTION_MAX   0x31

Definition at line 45 of file usbport.h.

◆ USB2_BIT_STUFFING_OVERHEAD

#define USB2_BIT_STUFFING_OVERHEAD   (8 * (7/6))

Definition at line 483 of file usbport.h.

◆ USB2_CONTROLLER_DELAY

#define USB2_CONTROLLER_DELAY   100

Definition at line 458 of file usbport.h.

◆ USB2_FRAMES

#define USB2_FRAMES   32

Definition at line 452 of file usbport.h.

◆ USB2_FS_INTERRUPT_OVERHEAD

#define USB2_FS_INTERRUPT_OVERHEAD   13

Definition at line 467 of file usbport.h.

◆ USB2_FS_ISOCHRONOUS_OVERHEAD

#define USB2_FS_ISOCHRONOUS_OVERHEAD   9

Definition at line 470 of file usbport.h.

◆ USB2_FS_MAX_PERIODIC_ALLOCATION

#define USB2_FS_MAX_PERIODIC_ALLOCATION   1157

Definition at line 459 of file usbport.h.

◆ USB2_FS_RAW_BYTES_IN_MICROFRAME

#define USB2_FS_RAW_BYTES_IN_MICROFRAME   188

Definition at line 463 of file usbport.h.

◆ USB2_FS_SOF_TIME

#define USB2_FS_SOF_TIME   6

Definition at line 460 of file usbport.h.

◆ USB2_HS_CS_INTERRUPT_IN_OVERHEAD

#define USB2_HS_CS_INTERRUPT_IN_OVERHEAD   38

Definition at line 477 of file usbport.h.

◆ USB2_HS_CS_INTERRUPT_OUT_OVERHEAD

#define USB2_HS_CS_INTERRUPT_OUT_OVERHEAD   36

Definition at line 475 of file usbport.h.

◆ USB2_HS_CS_ISOCHRONOUS_IN_OVERHEAD

#define USB2_HS_CS_ISOCHRONOUS_IN_OVERHEAD   38

Definition at line 481 of file usbport.h.

◆ USB2_HS_INTERRUPT_IN_OVERHEAD

#define USB2_HS_INTERRUPT_IN_OVERHEAD   25

Definition at line 469 of file usbport.h.

◆ USB2_HS_INTERRUPT_OUT_OVERHEAD

#define USB2_HS_INTERRUPT_OUT_OVERHEAD   45

Definition at line 468 of file usbport.h.

◆ USB2_HS_ISOCHRONOUS_IN_OVERHEAD

#define USB2_HS_ISOCHRONOUS_IN_OVERHEAD   18

Definition at line 472 of file usbport.h.

◆ USB2_HS_ISOCHRONOUS_OUT_OVERHEAD

#define USB2_HS_ISOCHRONOUS_OUT_OVERHEAD   38

Definition at line 471 of file usbport.h.

◆ USB2_HS_SS_INTERRUPT_IN_OVERHEAD

#define USB2_HS_SS_INTERRUPT_IN_OVERHEAD   39

Definition at line 476 of file usbport.h.

◆ USB2_HS_SS_INTERRUPT_OUT_OVERHEAD

#define USB2_HS_SS_INTERRUPT_OUT_OVERHEAD   58

Definition at line 474 of file usbport.h.

◆ USB2_HS_SS_ISOCHRONOUS_IN_OVERHEAD

#define USB2_HS_SS_ISOCHRONOUS_IN_OVERHEAD   39

Definition at line 480 of file usbport.h.

◆ USB2_HS_SS_ISOCHRONOUS_OUT_OVERHEAD

#define USB2_HS_SS_ISOCHRONOUS_OUT_OVERHEAD   58

Definition at line 479 of file usbport.h.

◆ USB2_HUB_DELAY

#define USB2_HUB_DELAY   30

Definition at line 461 of file usbport.h.

◆ USB2_LS_INTERRUPT_OVERHEAD

#define USB2_LS_INTERRUPT_OVERHEAD   117

Definition at line 466 of file usbport.h.

◆ USB2_MAX_FS_LS_TRANSACTIONS_IN_UFRAME

#define USB2_MAX_FS_LS_TRANSACTIONS_IN_UFRAME   16

Definition at line 462 of file usbport.h.

◆ USB2_MAX_MICROFRAME_ALLOCATION

#define USB2_MAX_MICROFRAME_ALLOCATION   7000

Definition at line 457 of file usbport.h.

◆ USB2_MAX_MICROFRAMES

#define USB2_MAX_MICROFRAMES   (USB2_FRAMES * USB2_MICROFRAMES)

Definition at line 454 of file usbport.h.

◆ USB2_MICROFRAMES

#define USB2_MICROFRAMES   8

Definition at line 453 of file usbport.h.

◆ USB2_PREV_MICROFRAME

#define USB2_PREV_MICROFRAME   0xFF

Definition at line 455 of file usbport.h.

◆ USB2_TT_EXTENSION_FLAG_DELETED

#define USB2_TT_EXTENSION_FLAG_DELETED   1

Definition at line 546 of file usbport.h.

◆ USB_PORT_TAG

#define USB_PORT_TAG   'pbsu'

Definition at line 44 of file usbport.h.

◆ USBD_FLAG_ALLOCATED_MDL

#define USBD_FLAG_ALLOCATED_MDL   0x00000002

Definition at line 121 of file usbport.h.

◆ USBD_FLAG_ALLOCATED_TRANSFER

#define USBD_FLAG_ALLOCATED_TRANSFER   0x00000020

Definition at line 123 of file usbport.h.

◆ USBD_FLAG_NOT_ISO_TRANSFER

#define USBD_FLAG_NOT_ISO_TRANSFER   0x00000010

Definition at line 122 of file usbport.h.

◆ USBPORT_DMA_DIRECTION_FROM_DEVICE

#define USBPORT_DMA_DIRECTION_FROM_DEVICE   1

Definition at line 41 of file usbport.h.

◆ USBPORT_DMA_DIRECTION_TO_DEVICE

#define USBPORT_DMA_DIRECTION_TO_DEVICE   2

Definition at line 42 of file usbport.h.

◆ USBPORT_FLAG_BIOS_DISABLE_SS

#define USBPORT_FLAG_BIOS_DISABLE_SS   0x08000000

Definition at line 81 of file usbport.h.

◆ USBPORT_FLAG_COMPANION_HC

#define USBPORT_FLAG_COMPANION_HC   0x01000000

Definition at line 78 of file usbport.h.

◆ USBPORT_FLAG_DIAGNOSTIC_MODE

#define USBPORT_FLAG_DIAGNOSTIC_MODE   0x00800000

Definition at line 77 of file usbport.h.

◆ USBPORT_FLAG_DOS_SYMBOLIC_NAME

#define USBPORT_FLAG_DOS_SYMBOLIC_NAME   0x00010000

Definition at line 74 of file usbport.h.

◆ USBPORT_FLAG_HC_POLLING

#define USBPORT_FLAG_HC_POLLING   0x00000004

Definition at line 68 of file usbport.h.

◆ USBPORT_FLAG_HC_STARTED

#define USBPORT_FLAG_HC_STARTED   0x00000002

Definition at line 67 of file usbport.h.

◆ USBPORT_FLAG_HC_SUSPEND

#define USBPORT_FLAG_HC_SUSPEND   0x00000100

Definition at line 71 of file usbport.h.

◆ USBPORT_FLAG_HC_WAKE_SUPPORT

#define USBPORT_FLAG_HC_WAKE_SUPPORT   0x00200000

Definition at line 76 of file usbport.h.

◆ USBPORT_FLAG_INT_CONNECTED

#define USBPORT_FLAG_INT_CONNECTED   0x00000001

Definition at line 66 of file usbport.h.

◆ USBPORT_FLAG_INTERRUPT_ENABLED

#define USBPORT_FLAG_INTERRUPT_ENABLED   0x00000400

Definition at line 72 of file usbport.h.

◆ USBPORT_FLAG_LEGACY_SUPPORT

#define USBPORT_FLAG_LEGACY_SUPPORT   0x00080000

Definition at line 75 of file usbport.h.

◆ USBPORT_FLAG_NO_HACTION

#define USBPORT_FLAG_NO_HACTION   0x04000000

Definition at line 80 of file usbport.h.

◆ USBPORT_FLAG_POWER_AND_CHIRP_OK

#define USBPORT_FLAG_POWER_AND_CHIRP_OK   0x40000000

Definition at line 83 of file usbport.h.

◆ USBPORT_FLAG_PWR_AND_CHIRP_LOCK

#define USBPORT_FLAG_PWR_AND_CHIRP_LOCK   0x10000000

Definition at line 82 of file usbport.h.

◆ USBPORT_FLAG_REGISTERED_FDO

#define USBPORT_FLAG_REGISTERED_FDO   0x02000000

Definition at line 79 of file usbport.h.

◆ USBPORT_FLAG_RH_INIT_CALLBACK

#define USBPORT_FLAG_RH_INIT_CALLBACK   0x80000000

Definition at line 84 of file usbport.h.

◆ USBPORT_FLAG_SELECTIVE_SUSPEND

#define USBPORT_FLAG_SELECTIVE_SUSPEND   0x00000800

Definition at line 73 of file usbport.h.

◆ USBPORT_FLAG_WORKER_THREAD_EXIT

#define USBPORT_FLAG_WORKER_THREAD_EXIT   0x00000010

Definition at line 70 of file usbport.h.

◆ USBPORT_FLAG_WORKER_THREAD_ON

#define USBPORT_FLAG_WORKER_THREAD_ON   0x00000008

Definition at line 69 of file usbport.h.

◆ USBPORT_MPFLAG_INTERRUPTS_ENABLED

#define USBPORT_MPFLAG_INTERRUPTS_ENABLED   0x00000001

Definition at line 102 of file usbport.h.

◆ USBPORT_MPFLAG_SUSPENDED

#define USBPORT_MPFLAG_SUSPENDED   0x00000002

Definition at line 103 of file usbport.h.

◆ USBPORT_PNP_STATE_FAILED

#define USBPORT_PNP_STATE_FAILED   0x00000004

Definition at line 89 of file usbport.h.

◆ USBPORT_PNP_STATE_NOT_INIT

#define USBPORT_PNP_STATE_NOT_INIT   0x00000001

Definition at line 87 of file usbport.h.

◆ USBPORT_PNP_STATE_STARTED

#define USBPORT_PNP_STATE_STARTED   0x00000002

Definition at line 88 of file usbport.h.

◆ USBPORT_PNP_STATE_STOPPED

#define USBPORT_PNP_STATE_STOPPED   0x00000008

Definition at line 90 of file usbport.h.

◆ USBPORT_RECIPIENT_HUB

#define USBPORT_RECIPIENT_HUB   BMREQUEST_TO_DEVICE

Definition at line 33 of file usbport.h.

◆ USBPORT_RECIPIENT_PORT

#define USBPORT_RECIPIENT_PORT   BMREQUEST_TO_OTHER

Definition at line 34 of file usbport.h.

◆ USBPORT_TMFLAG_HC_RESUME

#define USBPORT_TMFLAG_HC_RESUME   0x00000004

Definition at line 95 of file usbport.h.

◆ USBPORT_TMFLAG_HC_SUSPENDED

#define USBPORT_TMFLAG_HC_SUSPENDED   0x00000002

Definition at line 94 of file usbport.h.

◆ USBPORT_TMFLAG_IDLE_QUEUEITEM_ON

#define USBPORT_TMFLAG_IDLE_QUEUEITEM_ON   0x00000040

Definition at line 99 of file usbport.h.

◆ USBPORT_TMFLAG_RH_SUSPENDED

#define USBPORT_TMFLAG_RH_SUSPENDED   0x00000008

Definition at line 96 of file usbport.h.

◆ USBPORT_TMFLAG_TIMER_QUEUED

#define USBPORT_TMFLAG_TIMER_QUEUED   0x00000001

Definition at line 93 of file usbport.h.

◆ USBPORT_TMFLAG_TIMER_STARTED

#define USBPORT_TMFLAG_TIMER_STARTED   0x00000010

Definition at line 97 of file usbport.h.

◆ USBPORT_TMFLAG_WAKE

#define USBPORT_TMFLAG_WAKE   0x00000020

Definition at line 98 of file usbport.h.

Typedef Documentation

◆ PTIMER_WORK_QUEUE_ITEM

◆ PUSB2_FRAME_BUDGET

◆ PUSB2_HC_EXTENSION

Definition at line 157 of file usbport.h.

◆ PUSB2_REBALANCE

◆ PUSB2_TT

Definition at line 159 of file usbport.h.

◆ PUSB2_TT_ENDPOINT

Definition at line 160 of file usbport.h.

◆ PUSB2_TT_EXTENSION

Definition at line 158 of file usbport.h.

◆ PUSBD_STATUS

Definition at line 144 of file usbport.h.

◆ PUSBPORT_ASYNC_CALLBACK_DATA

◆ PUSBPORT_COMMON_BUFFER_HEADER

◆ PUSBPORT_COMMON_DEVICE_EXTENSION

◆ PUSBPORT_CONFIGURATION_HANDLE

◆ PUSBPORT_DEVICE_EXTENSION

◆ PUSBPORT_DEVICE_HANDLE

◆ PUSBPORT_ENDPOINT

Definition at line 155 of file usbport.h.

◆ PUSBPORT_INTERFACE_HANDLE

◆ PUSBPORT_IRP_TABLE

◆ PUSBPORT_ISO_BLOCK

typedef struct _USBPORT_ISO_BLOCK* PUSBPORT_ISO_BLOCK

Definition at line 243 of file usbport.h.

◆ PUSBPORT_PIPE_HANDLE

◆ PUSBPORT_RH_DESCRIPTORS

◆ PUSBPORT_RHDEVICE_EXTENSION

◆ PUSBPORT_TRANSFER

◆ TIMER_WORK_QUEUE_ITEM

◆ USB2_FRAME_BUDGET

◆ USB2_HC_EXTENSION

◆ USB2_REBALANCE

◆ USB2_TT

◆ USB2_TT_ENDPOINT

◆ USB2_TT_ENDPOINT_NUMS

◆ USB2_TT_ENDPOINT_PARAMS

◆ USB2_TT_EXTENSION

◆ USBPORT_ASYNC_CALLBACK_DATA

◆ USBPORT_COMMON_BUFFER_HEADER

◆ USBPORT_COMMON_DEVICE_EXTENSION

◆ USBPORT_CONFIGURATION_HANDLE

◆ USBPORT_DEVICE_EXTENSION

◆ USBPORT_DEVICE_HANDLE

◆ USBPORT_ENDPOINT

◆ USBPORT_INTERFACE_HANDLE

◆ USBPORT_IRP_TABLE

◆ USBPORT_PIPE_HANDLE

◆ USBPORT_RH_DESCRIPTORS

◆ USBPORT_RHDEVICE_EXTENSION

◆ USBPORT_TRANSFER

Function Documentation

◆ C_ASSERT() [1/4]

◆ C_ASSERT() [2/4]

◆ C_ASSERT() [3/4]

C_ASSERT ( sizeof(USBPORT_ASYNC_CALLBACK_DATA = =16+18 *sizeof(PVOID))

◆ C_ASSERT() [4/4]

C_ASSERT ( sizeof(USBPORT_DEVICE_EXTENSION = =0x500)

◆ MiniportCloseEndpoint()

VOID NTAPI MiniportCloseEndpoint ( IN PDEVICE_OBJECT  FdoDevice,
IN PUSBPORT_ENDPOINT  Endpoint 
)

Definition at line 549 of file endpoint.c.

551{
554 BOOLEAN IsDoDisablePeriodic;
555 ULONG TransferType;
557
558 DPRINT("MiniportCloseEndpoint: Endpoint - %p\n", Endpoint);
559
560 FdoExtension = FdoDevice->DeviceExtension;
561 Packet = &FdoExtension->MiniPortInterface->Packet;
562
563 KeAcquireSpinLock(&FdoExtension->MiniportSpinLock, &OldIrql);
564
565 if (Endpoint->Flags & ENDPOINT_FLAG_OPENED)
566 {
567 TransferType = Endpoint->EndpointProperties.TransferType;
568
569 if (TransferType == USBPORT_TRANSFER_TYPE_INTERRUPT ||
570 TransferType == USBPORT_TRANSFER_TYPE_ISOCHRONOUS)
571 {
572 --FdoExtension->PeriodicEndpoints;
573 }
574
575 IsDoDisablePeriodic = FdoExtension->PeriodicEndpoints == 0;
576
577 Packet->CloseEndpoint(FdoExtension->MiniPortExt,
578 Endpoint + 1,
579 IsDoDisablePeriodic);
580
581 Endpoint->Flags &= ~ENDPOINT_FLAG_OPENED;
582 Endpoint->Flags |= ENDPOINT_FLAG_CLOSED;
583 }
584
585 KeReleaseSpinLock(&FdoExtension->MiniportSpinLock, OldIrql);
586}
unsigned char BOOLEAN
@ FdoExtension
Definition: precomp.h:48
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
Definition: ndis.h:1549
#define DPRINT
Definition: sndvol32.h:71
uint32_t ULONG
Definition: typedefs.h:59
#define USBPORT_TRANSFER_TYPE_INTERRUPT
Definition: usbmport.h:10
#define USBPORT_TRANSFER_TYPE_ISOCHRONOUS
Definition: usbmport.h:7
#define ENDPOINT_FLAG_CLOSED
Definition: usbport.h:118
#define ENDPOINT_FLAG_OPENED
Definition: usbport.h:117
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778

Referenced by USBPORT_DeleteEndpoint(), USBPORT_ReopenPipe(), and USBPORT_RestoreDevice().

◆ MiniportOpenEndpoint()

MPSTATUS NTAPI MiniportOpenEndpoint ( IN PDEVICE_OBJECT  FdoDevice,
IN PUSBPORT_ENDPOINT  Endpoint 
)

Definition at line 722 of file endpoint.c.

724{
728 ULONG TransferType;
729 MPSTATUS MpStatus;
730
731 DPRINT("MiniportOpenEndpoint: Endpoint - %p\n", Endpoint);
732
733 FdoExtension = FdoDevice->DeviceExtension;
734 Packet = &FdoExtension->MiniPortInterface->Packet;
735
736 KeAcquireSpinLock(&FdoExtension->MiniportSpinLock, &OldIrql);
737
738 Endpoint->Flags &= ~ENDPOINT_FLAG_CLOSED;
739
740 MpStatus = Packet->OpenEndpoint(FdoExtension->MiniPortExt,
741 &Endpoint->EndpointProperties,
742 Endpoint + 1);
743
744 if (!MpStatus)
745 {
746 TransferType = Endpoint->EndpointProperties.TransferType;
747
748 if (TransferType == USBPORT_TRANSFER_TYPE_INTERRUPT ||
749 TransferType == USBPORT_TRANSFER_TYPE_ISOCHRONOUS)
750 {
751 ++FdoExtension->PeriodicEndpoints;
752 }
753
754 Endpoint->Flags |= ENDPOINT_FLAG_OPENED;
755 }
756
757 KeReleaseSpinLock(&FdoExtension->MiniportSpinLock, OldIrql);
758 return MpStatus;
759}
ULONG MPSTATUS
Definition: usbmport.h:131

Referenced by USBPORT_OpenPipe(), USBPORT_ReopenPipe(), and USBPORT_RestoreDevice().

◆ USB2_InitController()

VOID NTAPI USB2_InitController ( IN PUSB2_HC_EXTENSION  HcExtension)

Definition at line 2217 of file usb2.c.

2218{
2219 ULONG ix;
2220 ULONG jx;
2221
2222 DPRINT("USB2_InitController: HcExtension - %p\n", HcExtension);
2223
2224 HcExtension->MaxHsBusAllocation = USB2_MAX_MICROFRAME_ALLOCATION;
2225
2226 for (ix = 0; ix < USB2_FRAMES; ix++)
2227 {
2228 for (jx = 0; jx < USB2_MICROFRAMES; jx++)
2229 {
2230 HcExtension->TimeUsed[ix][jx] = 0;
2231 }
2232 }
2233
2234 HcExtension->HcDelayTime = USB2_CONTROLLER_DELAY;
2235
2236 USB2_InitTT(HcExtension, &HcExtension->HcTt);
2237}
VOID NTAPI USB2_InitTT(IN PUSB2_HC_EXTENSION HcExtension, IN PUSB2_TT Tt)
Definition: usb2.c:2160
#define USB2_CONTROLLER_DELAY
Definition: usbport.h:458
#define USB2_MAX_MICROFRAME_ALLOCATION
Definition: usbport.h:457
#define USB2_MICROFRAMES
Definition: usbport.h:453
#define USB2_FRAMES
Definition: usbport.h:452

Referenced by USBPORT_AddDevice().

◆ USB2_InitTT()

VOID NTAPI USB2_InitTT ( IN PUSB2_HC_EXTENSION  HcExtension,
IN PUSB2_TT  Tt 
)

Definition at line 2160 of file usb2.c.

2162{
2163 ULONG ix;
2164 ULONG jx;
2165
2166 DPRINT("USB2_InitTT: HcExtension - %p, Tt - %p\n", HcExtension, Tt);
2167
2168 Tt->HcExtension = HcExtension;
2169 Tt->DelayTime = 1;
2170 Tt->MaxTime = USB2_FS_MAX_PERIODIC_ALLOCATION;
2171
2172 for (ix = 0; ix < USB2_FRAMES; ix++)
2173 {
2174 Tt->FrameBudget[ix].TimeUsed = USB2_MAX_MICROFRAMES;
2175 Tt->FrameBudget[ix].AltEndpoint = NULL;
2176
2177 for (jx = 0; jx < USB2_MICROFRAMES; jx++)
2178 {
2179 Tt->TimeCS[ix][jx] = 0;
2180 Tt->NumStartSplits[ix][jx] = 0;
2181 }
2182
2183 Tt->FrameBudget[ix].IsoEndpoint = &Tt->IsoEndpoint[ix];
2184
2185 USB2_InitTtEndpoint(&Tt->IsoEndpoint[ix],
2190 0,
2191 Tt);
2192
2193 Tt->IsoEndpoint[ix].ActualPeriod = USB2_FRAMES;
2194 Tt->IsoEndpoint[ix].CalcBusTime = USB2_FS_SOF_TIME + USB2_HUB_DELAY;
2195 Tt->IsoEndpoint[ix].StartFrame = ix;
2196 Tt->IsoEndpoint[ix].StartMicroframe = USB2_PREV_MICROFRAME;
2197
2198 Tt->FrameBudget[ix].IntEndpoint = &Tt->IntEndpoint[ix];
2199
2200 USB2_InitTtEndpoint(&Tt->IntEndpoint[ix],
2205 0,
2206 Tt);
2207
2208 Tt->IntEndpoint[ix].ActualPeriod = USB2_FRAMES;
2209 Tt->IntEndpoint[ix].CalcBusTime = USB2_FS_SOF_TIME + USB2_HUB_DELAY;
2210 Tt->IntEndpoint[ix].StartFrame = ix;
2211 Tt->IntEndpoint[ix].StartMicroframe = USB2_PREV_MICROFRAME;
2212 }
2213}
#define NULL
Definition: types.h:112
@ UsbFullSpeed
Definition: usb200.h:43
VOID NTAPI USB2_InitTtEndpoint(IN PUSB2_TT_ENDPOINT TtEndpoint, IN UCHAR TransferType, IN UCHAR Direction, IN UCHAR DeviceSpeed, IN USHORT Period, IN USHORT MaxPacketSize, IN PUSB2_TT Tt)
Definition: usb2.c:279
#define USBPORT_TRANSFER_DIRECTION_OUT
Definition: usbmport.h:649
#define USB2_HUB_DELAY
Definition: usbport.h:461
#define USB2_PREV_MICROFRAME
Definition: usbport.h:455
#define USB2_MAX_MICROFRAMES
Definition: usbport.h:454
#define USB2_FS_MAX_PERIODIC_ALLOCATION
Definition: usbport.h:459
#define USB2_FS_SOF_TIME
Definition: usbport.h:460

Referenced by USB2_InitController(), and USBPORT_InitializeTT().

◆ USBPORT_AbortEndpoint()

VOID NTAPI USBPORT_AbortEndpoint ( IN PDEVICE_OBJECT  FdoDevice,
IN PUSBPORT_ENDPOINT  Endpoint,
IN PIRP  Irp 
)

Definition at line 1354 of file queue.c.

1357{
1358 PLIST_ENTRY PendingList;
1359 PUSBPORT_TRANSFER PendingTransfer;
1360 PLIST_ENTRY ActiveList;
1361 PUSBPORT_TRANSFER ActiveTransfer;
1362
1363 DPRINT_CORE("USBPORT_AbortEndpoint: Irp - %p\n", Irp);
1364
1365 KeAcquireSpinLock(&Endpoint->EndpointSpinLock, &Endpoint->EndpointOldIrql);
1366
1367 if (Irp)
1368 {
1369 InsertTailList(&Endpoint->AbortList, &Irp->Tail.Overlay.ListEntry);
1370 }
1371
1372 PendingList = Endpoint->PendingTransferList.Flink;
1373
1374 while (PendingList && PendingList != &Endpoint->PendingTransferList)
1375 {
1376 PendingTransfer = CONTAINING_RECORD(PendingList,
1378 TransferLink);
1379
1380 DPRINT_CORE("USBPORT_AbortEndpoint: Abort PendingTransfer - %p\n",
1381 PendingTransfer);
1382
1383 PendingTransfer->Flags |= TRANSFER_FLAG_ABORTED;
1384
1385 PendingList = PendingTransfer->TransferLink.Flink;
1386 }
1387
1388 ActiveList = Endpoint->TransferList.Flink;
1389
1390 while (ActiveList && ActiveList != &Endpoint->TransferList)
1391 {
1392 ActiveTransfer = CONTAINING_RECORD(ActiveList,
1394 TransferLink);
1395
1396 DPRINT_CORE("USBPORT_AbortEndpoint: Abort ActiveTransfer - %p\n",
1397 ActiveTransfer);
1398
1399 ActiveTransfer->Flags |= TRANSFER_FLAG_ABORTED;
1400
1401 if (Endpoint->Flags & ENDPOINT_FLAG_ABORTING)
1402 {
1403 ActiveTransfer->Flags |= TRANSFER_FLAG_DEVICE_GONE;
1404 }
1405
1406 ActiveList = ActiveTransfer->TransferLink.Flink;
1407 }
1408
1409 KeReleaseSpinLock(&Endpoint->EndpointSpinLock, Endpoint->EndpointOldIrql);
1410
1412 Endpoint,
1414
1416 USBPORT_FlushCancelList(Endpoint);
1417}
_In_ PIRP Irp
Definition: csq.h:116
VOID NTAPI USBPORT_FlushPendingTransfers(IN PUSBPORT_ENDPOINT Endpoint)
Definition: queue.c:785
VOID NTAPI USBPORT_FlushCancelList(IN PUSBPORT_ENDPOINT Endpoint)
Definition: queue.c:714
VOID NTAPI USBPORT_InvalidateEndpointHandler(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint, IN ULONG Type)
Definition: endpoint.c:1317
#define InsertTailList(ListHead, Entry)
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LIST_ENTRY TransferLink
Definition: usbport.h:257
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define DPRINT_CORE(...)
Definition: usbdebug.h:144
#define ENDPOINT_FLAG_ABORTING
Definition: usbport.h:115
#define INVALIDATE_ENDPOINT_INT_NEXT_SOF
Definition: usbport.h:39
#define TRANSFER_FLAG_DEVICE_GONE
Definition: usbport.h:136
#define TRANSFER_FLAG_ABORTED
Definition: usbport.h:134

Referenced by USBPORT_AbortPipe(), and USBPORT_AbortTransfers().

◆ USBPORT_AcquireBadRequestLock()

VOID NTAPI USBPORT_AcquireBadRequestLock ( IN PIO_CSQ  Csq,
IN PKIRQL  Irql 
)

Definition at line 214 of file queue.c.

216{
218
219 DPRINT_QUEUE("USBPORT_AcquireBadRequestLock: ... \n");
220
223 BadRequestIoCsq);
224
225 KeAcquireSpinLock(&FdoExtension->BadRequestIoCsqSpinLock, Irql);
226}
_Out_ PKIRQL Irql
Definition: csq.h:179
IO_CSQ Csq
Definition: csqrtns.c:46
#define DPRINT_QUEUE(...)
Definition: usbdebug.h:148

Referenced by USBPORT_StartDevice().

◆ USBPORT_AcquireIdleLock()

VOID NTAPI USBPORT_AcquireIdleLock ( IN PIO_CSQ  Csq,
IN PKIRQL  Irql 
)

Definition at line 91 of file queue.c.

93{
95
96 DPRINT_QUEUE("USBPORT_AcquireIdleLock: ... \n");
97
100 IdleIoCsq);
101
102 KeAcquireSpinLock(&FdoExtension->IdleIoCsqSpinLock, Irql);
103}

Referenced by USBPORT_StartDevice().

◆ USBPORT_AddDeviceHandle()

VOID NTAPI USBPORT_AddDeviceHandle ( IN PDEVICE_OBJECT  FdoDevice,
IN PUSBPORT_DEVICE_HANDLE  DeviceHandle 
)

Definition at line 769 of file device.c.

771{
773
774 DPRINT("USBPORT_AddDeviceHandle: ... \n");
775
776 FdoExtension = FdoDevice->DeviceExtension;
777
778 InsertTailList(&FdoExtension->DeviceHandleList,
779 &DeviceHandle->DeviceHandleLink);
780}
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121

Referenced by USBPORT_CreateDevice(), and USBPORT_RootHubCreateDevice().

◆ USBPORT_AddPipeHandle()

VOID NTAPI USBPORT_AddPipeHandle ( IN PUSBPORT_DEVICE_HANDLE  DeviceHandle,
IN PUSBPORT_PIPE_HANDLE  PipeHandle 
)

Definition at line 444 of file endpoint.c.

446{
447 DPRINT("USBPORT_AddPipeHandle: DeviceHandle - %p, PipeHandle - %p\n",
449 PipeHandle);
450
451 InsertTailList(&DeviceHandle->PipeHandleList, &PipeHandle->PipeLink);
452}
static HANDLE PipeHandle
Definition: dhcpcsvc.c:22

Referenced by USBPORT_OpenPipe(), and USBPORT_RestoreDevice().

◆ USBPORT_AddUSB1Fdo()

VOID NTAPI USBPORT_AddUSB1Fdo ( IN PDEVICE_OBJECT  FdoDevice)

Definition at line 66 of file usbport.c.

67{
69
70 DPRINT("USBPORT_AddUSB1Fdo: FdoDevice - %p\n", FdoDevice);
71
72 FdoExtension = FdoDevice->DeviceExtension;
74
76 &FdoExtension->ControllerLink,
78}
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
Definition: interlocked.c:140
KSPIN_LOCK USBPORT_SpinLock
Definition: usbport.c:22
LIST_ENTRY USBPORT_USB1FdoList
Definition: usbport.c:19
#define USBPORT_FLAG_REGISTERED_FDO
Definition: usbport.h:79

Referenced by USBPORT_FdoPnP().

◆ USBPORT_AddUSB2Fdo()

VOID NTAPI USBPORT_AddUSB2Fdo ( IN PDEVICE_OBJECT  FdoDevice)

Definition at line 82 of file usbport.c.

83{
85
86 DPRINT("USBPORT_AddUSB2Fdo: FdoDevice - %p\n", FdoDevice);
87
88 FdoExtension = FdoDevice->DeviceExtension;
90
92 &FdoExtension->ControllerLink,
94}
LIST_ENTRY USBPORT_USB2FdoList
Definition: usbport.c:20

Referenced by USBPORT_FdoPnP().

◆ USBPORT_AdjustDeviceCapabilities()

VOID NTAPI USBPORT_AdjustDeviceCapabilities ( IN PDEVICE_OBJECT  FdoDevice,
IN PDEVICE_OBJECT  PdoDevice 
)

Definition at line 668 of file power.c.

670{
674
675 DPRINT("USBPORT_AdjustDeviceCapabilities: ... \n");
676
677 FdoExtension = FdoDevice->DeviceExtension;
678 PdoExtension = PdoDevice->DeviceExtension;
679 Capabilities = &PdoExtension->Capabilities;
680
682 &FdoExtension->Capabilities,
683 sizeof(DEVICE_CAPABILITIES));
684
685 Capabilities->DeviceD1 = FALSE;
686 Capabilities->DeviceD2 = TRUE;
687
688 Capabilities->Removable = FALSE;
689 Capabilities->UniqueID = FALSE;
690
691 Capabilities->WakeFromD0 = TRUE;
692 Capabilities->WakeFromD1 = FALSE;
693 Capabilities->WakeFromD2 = TRUE;
694 Capabilities->WakeFromD3 = FALSE;
695
696 Capabilities->Address = 0;
697 Capabilities->UINumber = 0;
698
699 if (Capabilities->SystemWake == PowerSystemUnspecified)
700 Capabilities->SystemWake = PowerSystemWorking;
701
702 Capabilities->DeviceWake = PowerDeviceD2;
703
708}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
@ PdoExtension
Definition: precomp.h:49
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
@ PowerSystemUnspecified
Definition: ntpoapi.h:35
@ PowerSystemSleeping1
Definition: ntpoapi.h:37
@ PowerSystemSleeping2
Definition: ntpoapi.h:38
@ PowerSystemSleeping3
Definition: ntpoapi.h:39
@ PowerSystemWorking
Definition: ntpoapi.h:36
@ PowerSystemHibernate
Definition: ntpoapi.h:40
@ PowerDeviceD2
Definition: ntpoapi.h:51
@ PowerDeviceD3
Definition: ntpoapi.h:52
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
DEVICE_CAPABILITIES
Definition: iotypes.h:965
* PDEVICE_CAPABILITIES
Definition: iotypes.h:965

Referenced by USBPORT_CreatePdo().

◆ USBPORT_AllocateBandwidthUSB2()

BOOLEAN NTAPI USBPORT_AllocateBandwidthUSB2 ( IN PDEVICE_OBJECT  FdoDevice,
IN PUSBPORT_ENDPOINT  Endpoint 
)

Definition at line 1799 of file usb2.c.

1801{
1803 PUSBPORT_ENDPOINT_PROPERTIES EndpointProperties;
1804 PUSB2_TT_EXTENSION TtExtension;
1805 ULONG TransferType;
1806 PUSB2_REBALANCE Rebalance;
1807 LIST_ENTRY RebalanceList;
1808 ULONG RebalanceListEntries;
1809 PUSB2_TT_ENDPOINT TtEndpoint;
1810 PUSB2_TT_ENDPOINT RebalanceTtEndpoint;
1811 PUSB2_TT Tt;
1813 ULONG Period;
1814 ULONG AllocedBusTime;
1815 ULONG EndpointBandwidth;
1816 ULONG ScheduleOffset;
1817 ULONG Factor;
1818 ULONG ix;
1819 ULONG n;
1821 UCHAR SMask;
1822 UCHAR CMask;
1823 UCHAR ActualPeriod;
1825
1826 DPRINT("USBPORT_AllocateBandwidthUSB2: FdoDevice - %p, Endpoint - %p\n",
1827 FdoDevice,
1828 Endpoint);
1829
1830 EndpointProperties = &Endpoint->EndpointProperties;
1831 EndpointProperties->ScheduleOffset = 0;
1832
1833 if (Endpoint->Flags & ENDPOINT_FLAG_ROOTHUB_EP0)
1834 {
1835 DPRINT("USBPORT_AllocateBandwidthUSB2: ENDPOINT_FLAG_ROOTHUB_EP0\n");
1836 return TRUE;
1837 }
1838
1839 FdoExtension = FdoDevice->DeviceExtension;
1840
1841 TransferType = EndpointProperties->TransferType;
1842 DPRINT("USBPORT_AllocateBandwidthUSB2: TransferType - %X\n", TransferType);
1843
1844 if (TransferType == USBPORT_TRANSFER_TYPE_CONTROL ||
1845 TransferType == USBPORT_TRANSFER_TYPE_BULK)
1846 {
1847 return TRUE;
1848 }
1849
1850 if (Endpoint->TtExtension)
1851 TtExtension = Endpoint->TtExtension;
1852 else
1853 TtExtension = NULL;
1854
1855 InitializeListHead(&RebalanceList);
1856
1858 sizeof(USB2_REBALANCE),
1859 USB_PORT_TAG);
1860
1861 DPRINT("USBPORT_AllocateBandwidthUSB2: Rebalance - %p, TtExtension - %p\n",
1862 Rebalance,
1863 TtExtension);
1864
1865 if (Rebalance)
1866 {
1867 RtlZeroMemory(Rebalance, sizeof(USB2_REBALANCE));
1868
1869 TtEndpoint = Endpoint->TtEndpoint;
1870 TtEndpoint->Endpoint = Endpoint;
1871
1872 Direction = EndpointProperties->Direction == USBPORT_TRANSFER_DIRECTION_OUT;
1873 DeviceSpeed = EndpointProperties->DeviceSpeed;
1874
1875 switch (DeviceSpeed)
1876 {
1877 case UsbLowSpeed:
1878 case UsbFullSpeed:
1879 {
1880 Tt = &TtExtension->Tt;
1882
1883 while (Period > 0 && Period > EndpointProperties->Period)
1884 {
1885 Period >>= 1;
1886 }
1887
1888 DPRINT("USBPORT_AllocateBandwidthUSB2: Period - %X\n", Period);
1889 break;
1890 }
1891
1892 case UsbHighSpeed:
1893 {
1894 Tt = &FdoExtension->Usb2Extension->HcTt;
1895 Period = EndpointProperties->Period;
1896
1897 break;
1898 }
1899
1900 default:
1901 {
1902 DPRINT1("USBPORT_AllocateBandwidthUSB2: DeviceSpeed - %X!\n",
1903 DeviceSpeed);
1904
1905 DbgBreakPoint();
1906
1907 Tt = &TtExtension->Tt;
1908 break;
1909 }
1910 }
1911
1912 USB2_InitTtEndpoint(TtEndpoint,
1913 TransferType,
1914 Direction,
1916 Period,
1917 EndpointProperties->MaxPacketSize,
1918 Tt);
1919
1920 RebalanceListEntries = USB2_FRAMES - 2;
1921
1923 Rebalance,
1924 &RebalanceListEntries);
1925
1926 if (Result)
1927 {
1928 Result = USB2_PromotePeriods(TtEndpoint,
1929 Rebalance,
1930 &RebalanceListEntries);
1931 }
1932
1933 RebalanceListEntries = 0;
1934
1935 for (ix = 0; Rebalance->RebalanceEndpoint[ix]; ix++)
1936 {
1937 RebalanceListEntries = ix + 1;
1938 }
1939 }
1940 else
1941 {
1942 RebalanceListEntries = 0;
1943 Result = FALSE;
1944 }
1945
1946 DPRINT("USBPORT_AllocateBandwidthUSB2: RebalanceListEntries - %X, Result - %X\n",
1947 RebalanceListEntries,
1948 Result);
1949
1950 for (ix = 0; ix < RebalanceListEntries; ix++)
1951 {
1952 RebalanceTtEndpoint = Rebalance->RebalanceEndpoint[ix];
1953
1954 DPRINT("USBPORT_AllocateBandwidthUSB2: RebalanceTtEndpoint[%X] - %p, RebalanceTtEndpoint - %p, RebalanceLink - %p\n",
1955 ix,
1956 RebalanceTtEndpoint,
1957 &RebalanceTtEndpoint->Endpoint->RebalanceLink);
1958
1959 InsertTailList(&RebalanceList,
1960 &RebalanceTtEndpoint->Endpoint->RebalanceLink);
1961 }
1962
1963 if (Rebalance)
1964 ExFreePoolWithTag(Rebalance, USB_PORT_TAG);
1965
1966 if (Result)
1967 {
1968 SMask = USB2_GetSMASK(Endpoint->TtEndpoint);
1969 EndpointProperties->InterruptScheduleMask = SMask;
1970
1971 CMask = USB2_GetCMASK(Endpoint->TtEndpoint);
1972 EndpointProperties->SplitCompletionMask = CMask;
1973
1974 AllocedBusTime = TtEndpoint->CalcBusTime;
1975
1976 EndpointBandwidth = USB2_MICROFRAMES * AllocedBusTime;
1977 EndpointProperties->UsbBandwidth = EndpointBandwidth;
1978
1979 ActualPeriod = Endpoint->TtEndpoint->ActualPeriod;
1980 EndpointProperties->Period = ActualPeriod;
1981
1982 ScheduleOffset = Endpoint->TtEndpoint->StartFrame;
1983 EndpointProperties->ScheduleOffset = ScheduleOffset;
1984
1985 ASSERT(ActualPeriod);
1986 Factor = USB2_FRAMES / ActualPeriod;
1987 n = ScheduleOffset * Factor;
1988
1989 if (TtExtension)
1990 {
1991 for (ix = 0; ix < Factor; ix++)
1992 {
1993 TtExtension->Bandwidth[n + ix] -= EndpointBandwidth;
1994 }
1995 }
1996 else
1997 {
1998 for (ix = 1; ix < Factor; ix++)
1999 {
2000 FdoExtension->Bandwidth[n + ix] -= EndpointBandwidth;
2001 }
2002 }
2003
2004 USBPORT_DumpingEndpointProperties(EndpointProperties);
2005 USBPORT_DumpingTtEndpoint(Endpoint->TtEndpoint);
2006
2007 if (AllocedBusTime >= (USB2_FS_MAX_PERIODIC_ALLOCATION / 2))
2008 {
2009 DPRINT1("USBPORT_AllocateBandwidthUSB2: AllocedBusTime >= 0.5 * MAX_ALLOCATION \n");
2010 }
2011 }
2012
2013 USB2_Rebalance(FdoDevice, &RebalanceList);
2014
2015 if (!TtExtension)
2016 {
2017 DPRINT("USBPORT_AllocateBandwidthUSB2: Result - %X\n", Result);
2018 return Result;
2019 }
2020
2021 for (ix = 0; ix < USB2_FRAMES; ix++)
2022 {
2023 FdoExtension->Bandwidth[ix] += TtExtension->MaxBandwidth;
2024 }
2025
2026 USBPORT_UpdateAllocatedBwTt(TtExtension);
2027
2028 for (ix = 0; ix < USB2_FRAMES; ix++)
2029 {
2030 FdoExtension->Bandwidth[ix] -= TtExtension->MaxBandwidth;
2031 }
2032
2033 DPRINT("USBPORT_AllocateBandwidthUSB2: Result - %X\n", Result);
2034
2035 return Result;
2036}
#define DPRINT1
Definition: precomp.h:8
VOID NTAPI USBPORT_DumpingEndpointProperties(IN PUSBPORT_ENDPOINT_PROPERTIES EndpointProperties)
Definition: debug.c:280
VOID NTAPI USBPORT_DumpingTtEndpoint(IN PUSB2_TT_ENDPOINT TtEndpoint)
Definition: debug.c:300
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define NonPagedPool
Definition: env_spec_w32.h:307
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
GLdouble n
Definition: glext.h:7729
_In_ PUSBD_PIPE_INFORMATION _In_ USB_DEVICE_SPEED DeviceSpeed
Definition: hubbusif.h:295
NTSYSAPI void WINAPI DbgBreakPoint(void)
#define ASSERT(a)
Definition: mode.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
PUSB2_TT_ENDPOINT RebalanceEndpoint[USB2_FRAMES - 2]
Definition: usbport.h:570
PUSBPORT_ENDPOINT Endpoint
Definition: usbport.h:511
USHORT CalcBusTime
Definition: usbport.h:520
ULONG MaxBandwidth
Definition: usbport.h:553
ULONG Bandwidth[USB2_FRAMES]
Definition: usbport.h:552
USB_DEVICE_SPEED DeviceSpeed
Definition: usbmport.h:73
LIST_ENTRY RebalanceLink
Definition: usbport.h:240
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
@ UsbHighSpeed
Definition: usb200.h:44
@ UsbLowSpeed
Definition: usb200.h:42
enum _USB_DEVICE_SPEED USB_DEVICE_SPEED
UCHAR NTAPI USB2_GetSMASK(IN PUSB2_TT_ENDPOINT TtEndpoint)
Definition: usb2.c:757
UCHAR NTAPI USB2_GetCMASK(IN PUSB2_TT_ENDPOINT TtEndpoint)
Definition: usb2.c:787
BOOLEAN NTAPI USB2_AllocateTimeForEndpoint(IN PUSB2_TT_ENDPOINT TtEndpoint, IN PUSB2_REBALANCE Rebalance, IN PULONG RebalanceListEntries)
Definition: usb2.c:1290
VOID NTAPI USBPORT_UpdateAllocatedBwTt(IN PUSB2_TT_EXTENSION TtExtension)
Definition: usb2.c:1768
VOID NTAPI USB2_Rebalance(IN PDEVICE_OBJECT FdoDevice, IN PLIST_ENTRY RebalanceList)
Definition: usb2.c:942
BOOLEAN NTAPI USB2_PromotePeriods(IN PUSB2_TT_ENDPOINT TtEndpoint, IN PUSB2_REBALANCE Rebalance, IN PULONG RebalanceListEntries)
Definition: usb2.c:1665
#define USBPORT_TRANSFER_TYPE_CONTROL
Definition: usbmport.h:8
#define USBPORT_TRANSFER_TYPE_BULK
Definition: usbmport.h:9
#define ENDPOINT_FLAG_ROOTHUB_EP0
Definition: usbport.h:112
#define USB_PORT_TAG
Definition: usbport.h:44
WDF_EXTERN_C_START typedef _In_ WDFDEVICE _In_ WDFCONTEXT _In_ WDF_DMA_DIRECTION Direction
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
_In_ LARGE_INTEGER _In_ ULONG Period
Definition: kefuncs.h:1313
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by USBPORT_OpenPipe().

◆ USBPORT_AllocateCommonBuffer()

PUSBPORT_COMMON_BUFFER_HEADER NTAPI USBPORT_AllocateCommonBuffer ( IN PDEVICE_OBJECT  FdoDevice,
IN SIZE_T  BufferLength 
)

Definition at line 1708 of file usbport.c.

1710{
1711 PUSBPORT_COMMON_BUFFER_HEADER HeaderBuffer = NULL;
1713 PDMA_ADAPTER DmaAdapter;
1714 PDMA_OPERATIONS DmaOperations;
1715 SIZE_T HeaderSize;
1716 ULONG Length = 0;
1717 ULONG LengthPadded;
1718 PHYSICAL_ADDRESS LogicalAddress;
1719 ULONG_PTR BaseVA;
1720 ULONG_PTR StartBufferVA;
1721 ULONG StartBufferPA;
1722
1723 DPRINT("USBPORT_AllocateCommonBuffer: FdoDevice - %p, BufferLength - %p\n",
1724 FdoDevice,
1725 BufferLength);
1726
1727 if (BufferLength == 0)
1728 goto Exit;
1729
1730 FdoExtension = FdoDevice->DeviceExtension;
1731
1732 DmaAdapter = FdoExtension->DmaAdapter;
1733 DmaOperations = DmaAdapter->DmaOperations;
1734
1735 HeaderSize = sizeof(USBPORT_COMMON_BUFFER_HEADER);
1736 Length = ROUND_TO_PAGES(BufferLength + HeaderSize);
1737 LengthPadded = Length - (BufferLength + HeaderSize);
1738
1739 BaseVA = (ULONG_PTR)DmaOperations->AllocateCommonBuffer(DmaAdapter,
1740 Length,
1741 &LogicalAddress,
1742 TRUE);
1743
1744 if (!BaseVA)
1745 goto Exit;
1746
1747 StartBufferVA = BaseVA & ~(PAGE_SIZE - 1);
1748 StartBufferPA = LogicalAddress.LowPart & ~(PAGE_SIZE - 1);
1749
1750 HeaderBuffer = (PUSBPORT_COMMON_BUFFER_HEADER)(StartBufferVA +
1751 BufferLength +
1752 LengthPadded);
1753
1754 HeaderBuffer->Length = Length;
1755 HeaderBuffer->BaseVA = BaseVA;
1756 HeaderBuffer->LogicalAddress = LogicalAddress;
1757
1758 HeaderBuffer->BufferLength = BufferLength + LengthPadded;
1759 HeaderBuffer->VirtualAddress = StartBufferVA;
1760 HeaderBuffer->PhysicalAddress = StartBufferPA;
1761
1762 RtlZeroMemory((PVOID)StartBufferVA, BufferLength + LengthPadded);
1763
1764Exit:
1765 return HeaderBuffer;
1766}
#define ULONG_PTR
Definition: config.h:101
#define PAGE_SIZE
Definition: env_spec_w32.h:49
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
static void Exit(void)
Definition: sock.c:1330
struct _DMA_OPERATIONS * DmaOperations
Definition: iotypes.h:2295
PALLOCATE_COMMON_BUFFER AllocateCommonBuffer
Definition: iotypes.h:2635
PHYSICAL_ADDRESS LogicalAddress
Definition: usbport.h:149
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG_PTR
Definition: typedefs.h:65
ULONG LowPart
Definition: typedefs.h:106
struct _USBPORT_COMMON_BUFFER_HEADER * PUSBPORT_COMMON_BUFFER_HEADER
struct _USBPORT_COMMON_BUFFER_HEADER USBPORT_COMMON_BUFFER_HEADER
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771
#define ROUND_TO_PAGES(Size)

Referenced by USBPORT_OpenPipe(), USBPORT_ReopenPipe(), and USBPORT_StartDevice().

◆ USBPORT_AllocateTransfer()

USBD_STATUS NTAPI USBPORT_AllocateTransfer ( IN PDEVICE_OBJECT  FdoDevice,
IN PURB  Urb,
IN PUSBPORT_DEVICE_HANDLE  DeviceHandle,
IN PIRP  Irp,
IN PRKEVENT  Event 
)

Definition at line 2543 of file usbport.c.

2548{
2550 SIZE_T TransferLength;
2551 PMDL Mdl;
2552 ULONG_PTR VirtualAddr;
2553 ULONG PagesNeed = 0;
2554 SIZE_T PortTransferLength;
2555 SIZE_T FullTransferLength;
2556 PUSBPORT_TRANSFER Transfer;
2558 USBD_STATUS USBDStatus;
2559 SIZE_T IsoBlockLen = 0;
2560
2561 DPRINT_CORE("USBPORT_AllocateTransfer: FdoDevice - %p, Urb - %p, DeviceHandle - %p, Irp - %p, Event - %p\n",
2562 FdoDevice,
2563 Urb,
2565 Irp,
2566 Event);
2567
2568 FdoExtension = FdoDevice->DeviceExtension;
2569
2570 TransferLength = Urb->UrbControlTransfer.TransferBufferLength;
2571 PipeHandle = Urb->UrbControlTransfer.PipeHandle;
2572
2573 if (TransferLength)
2574 {
2575 Mdl = Urb->UrbControlTransfer.TransferBufferMDL;
2576 VirtualAddr = (ULONG_PTR)MmGetMdlVirtualAddress(Mdl);
2577
2578 PagesNeed = ADDRESS_AND_SIZE_TO_SPAN_PAGES(VirtualAddr,
2579 TransferLength);
2580 if (PagesNeed > 0)
2581 {
2582 PagesNeed--;
2583 }
2584 }
2585
2586 if (Urb->UrbHeader.Function == URB_FUNCTION_ISOCH_TRANSFER)
2587 {
2588 DPRINT1("USBPORT_AllocateTransfer: ISOCH_TRANSFER UNIMPLEMENTED. FIXME\n");
2589
2590 //IsoBlockLen = sizeof(USBPORT_ISO_BLOCK) +
2591 // Urb->UrbIsochronousTransfer.NumberOfPackets *
2592 // sizeof(USBPORT_ISO_BLOCK_PACKET);
2593 }
2594
2595 PortTransferLength = sizeof(USBPORT_TRANSFER) +
2596 PagesNeed * sizeof(USBPORT_SCATTER_GATHER_ELEMENT) +
2597 IsoBlockLen;
2598
2599 FullTransferLength = PortTransferLength +
2600 FdoExtension->MiniPortInterface->Packet.MiniPortTransferSize;
2601
2603 FullTransferLength,
2604 USB_PORT_TAG);
2605
2606 if (!Transfer)
2607 {
2608 DPRINT1("USBPORT_AllocateTransfer: Transfer not allocated!\n");
2610 }
2611
2612 RtlZeroMemory(Transfer, FullTransferLength);
2613
2614 Transfer->Irp = Irp;
2615 Transfer->Urb = Urb;
2616 Transfer->Endpoint = PipeHandle->Endpoint;
2617 Transfer->Event = Event;
2618 Transfer->PortTransferLength = PortTransferLength;
2619 Transfer->FullTransferLength = FullTransferLength;
2620 Transfer->IsoBlockPtr = NULL;
2621 Transfer->Period = 0;
2622 Transfer->ParentTransfer = Transfer;
2623
2624 if (IsoBlockLen)
2625 {
2626 Transfer->IsoBlockPtr = (PVOID)((ULONG_PTR)Transfer +
2627 PortTransferLength - IsoBlockLen);
2628
2629 Transfer->Period = PipeHandle->Endpoint->EndpointProperties.Period;
2630 Transfer->Flags |= TRANSFER_FLAG_ISO;
2631 }
2632
2633 Transfer->MiniportTransfer = (PVOID)((ULONG_PTR)Transfer +
2634 PortTransferLength);
2635
2637
2638 Urb->UrbControlTransfer.hca.Reserved8[0] = Transfer;
2639 Urb->UrbHeader.UsbdFlags |= USBD_FLAG_ALLOCATED_TRANSFER;
2640
2641 USBDStatus = USBD_STATUS_SUCCESS;
2642
2643 DPRINT_CORE("USBPORT_AllocateTransfer: return USBDStatus - %x\n",
2644 USBDStatus);
2645
2646 return USBDStatus;
2647}
#define KeInitializeSpinLock(sl)
Definition: env_spec_w32.h:604
SIZE_T PortTransferLength
Definition: usbport.h:251
PUSBPORT_ISO_BLOCK IsoBlockPtr
Definition: usbport.h:269
PRKEVENT Event
Definition: usbport.h:249
KSPIN_LOCK TransferSpinLock
Definition: usbport.h:265
struct _USBPORT_TRANSFER * ParentTransfer
Definition: usbport.h:264
PVOID MiniportTransfer
Definition: usbport.h:250
PUSBPORT_ENDPOINT Endpoint
Definition: usbport.h:253
SIZE_T FullTransferLength
Definition: usbport.h:252
void * PVOID
Definition: typedefs.h:50
#define USBD_STATUS_SUCCESS
Definition: usb.h:170
#define USBD_STATUS_INSUFFICIENT_RESOURCES
Definition: usb.h:204
LONG USBD_STATUS
Definition: usb.h:165
#define URB_FUNCTION_ISOCH_TRANSFER
Definition: usb.h:96
struct _USBPORT_TRANSFER USBPORT_TRANSFER
#define USBD_FLAG_ALLOCATED_TRANSFER
Definition: usbport.h:123
#define TRANSFER_FLAG_ISO
Definition: usbport.h:135
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
#define MmGetMdlVirtualAddress(_Mdl)
#define ADDRESS_AND_SIZE_TO_SPAN_PAGES(_Va, _Size)

Referenced by USBPORT_SendSetupPacket(), and USBPORT_ValidateURB().

◆ USBPORT_AssertFailure()

ULONG NTAPI USBPORT_AssertFailure ( PVOID  MiniPortExtension,
PVOID  FailedAssertion,
PVOID  FileName,
ULONG  LineNumber,
PCHAR  Message 
)

Definition at line 38 of file debug.c.

43{
44 DPRINT("USBPORT_AssertFailure: ... \n");
45 RtlAssert(FailedAssertion, FileName, LineNumber, Message);
46 return 0;
47}
ACPI_BUFFER *RetBuffer ACPI_BUFFER *RetBuffer char ACPI_WALK_RESOURCE_CALLBACK void *Context ACPI_BUFFER *RetBuffer UINT16 ACPI_RESOURCE **ResourcePtr ACPI_GENERIC_ADDRESS *Reg UINT32 *ReturnValue UINT8 UINT8 *Slp_TypB ACPI_PHYSICAL_ADDRESS PhysicalAddress64 UINT32 UINT32 *TimeElapsed UINT32 LineNumber
Definition: acpixf.h:1220
static const WCHAR Message[]
Definition: register.c:74
VOID NTAPI RtlAssert(IN PVOID FailedAssertion, IN PVOID FileName, IN ULONG LineNumber, IN PCHAR Message OPTIONAL)
Definition: rtlcompat.c:68

Referenced by USBPORT_RegisterUSBPortDriver().

◆ USBPORT_BadRequestFlush()

VOID NTAPI USBPORT_BadRequestFlush ( IN PDEVICE_OBJECT  FdoDevice)

Definition at line 1328 of file queue.c.

1329{
1331 PIRP Irp;
1332
1333 DPRINT_QUEUE("USBPORT_BadRequestFlush: ... \n");
1334
1335 FdoExtension = FdoDevice->DeviceExtension;
1336
1337 while (TRUE)
1338 {
1339 Irp = IoCsqRemoveNextIrp(&FdoExtension->BadRequestIoCsq, 0);
1340
1341 if (!Irp)
1342 break;
1343
1344 DPRINT1("USBPORT_BadRequestFlush: Irp - %p\n", Irp);
1345
1346 Irp->IoStatus.Status = STATUS_DEVICE_NOT_CONNECTED;
1347 Irp->IoStatus.Information = 0;
1349 }
1350}
NTKERNELAPI PIRP NTAPI IoCsqRemoveNextIrp(_Inout_ PIO_CSQ Csq, _In_opt_ PVOID PeekContext)
IoCsqRemoveNextIrp - Removes the next IRP from the queue.
Definition: csq.c:398
#define IoCompleteRequest
Definition: irp.c:1240
#define STATUS_DEVICE_NOT_CONNECTED
Definition: udferr_usr.h:160
#define IO_NO_INCREMENT
Definition: iotypes.h:598

Referenced by USBHI_FlushTransfers(), and USBPORT_TimerDpc().

◆ USBPORT_BugCheck()

VOID NTAPI USBPORT_BugCheck ( IN PVOID  MiniPortExtension)

Definition at line 51 of file debug.c.

52{
53 DPRINT1("USBPORT_BugCheck: FIXME \n");
54 //KeBugCheckEx(BUGCODE_USB_DRIVER, ...);
56}

Referenced by USBPORT_RegisterUSBPortDriver().

◆ USBPORT_CancelActiveTransferIrp()

VOID NTAPI USBPORT_CancelActiveTransferIrp ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 529 of file queue.c.

531{
533 PDEVICE_OBJECT FdoDevice;
535 PURB Urb;
536 PUSBPORT_TRANSFER Transfer;
537 PUSBPORT_ENDPOINT Endpoint;
538 PIRP irp;
539 PUSBPORT_TRANSFER SplitTransfer;
542
543 DPRINT_CORE("USBPORT_CancelActiveTransferIrp: Irp - %p\n", Irp);
544
545 PdoExtension = DeviceObject->DeviceExtension;
546 FdoDevice = PdoExtension->FdoDevice;
547 FdoExtension = FdoDevice->DeviceExtension;
548
549 IoReleaseCancelSpinLock(Irp->CancelIrql);
550
551 KeAcquireSpinLock(&FdoExtension->FlushTransferSpinLock, &OldIrql);
552
554
555 if (!irp)
556 {
557 KeReleaseSpinLock(&FdoExtension->FlushTransferSpinLock, OldIrql);
558 return;
559 }
560
561 Urb = URB_FROM_IRP(irp);
562 Transfer = Urb->UrbControlTransfer.hca.Reserved8[0];
563 Endpoint = Transfer->Endpoint;
564
565 DPRINT_CORE("USBPORT_CancelActiveTransferIrp: irp - %p, Urb - %p, Transfer - %p\n",
566 irp,
567 Urb,
568 Transfer);
569
571
572 Transfer->Flags |= TRANSFER_FLAG_CANCELED;
573
574 if (Transfer->Flags & TRANSFER_FLAG_PARENT)
575 {
577
578 Entry = Transfer->SplitTransfersList.Flink;
579
580 while (Entry && Entry != &Transfer->SplitTransfersList)
581 {
582 SplitTransfer = CONTAINING_RECORD(Entry,
584 SplitLink);
585
586 SplitTransfer->Flags |= TRANSFER_FLAG_CANCELED;
587
588 Entry = Entry->Flink;
589 }
590
592 }
593
595 KeReleaseSpinLock(&FdoExtension->FlushTransferSpinLock, OldIrql);
596
598 Endpoint,
600 return;
601}
PIRP NTAPI USBPORT_FindActiveTransferIrp(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp)
Definition: queue.c:467
FxIrp * irp
VOID NTAPI IoReleaseCancelSpinLock(IN KIRQL Irql)
Definition: util.c:150
#define KeAcquireSpinLockAtDpcLevel(SpinLock)
Definition: ke.h:125
#define KeReleaseSpinLockFromDpcLevel(SpinLock)
Definition: ke.h:135
base of all file and directory entries
Definition: entries.h:83
PVOID DeviceExtension
Definition: env_spec_w32.h:418
Definition: usb.h:529
struct _URB_CONTROL_TRANSFER UrbControlTransfer
Definition: usb.h:539
KSPIN_LOCK EndpointSpinLock
Definition: usbport.h:215
LIST_ENTRY SplitTransfersList
Definition: usbport.h:266
#define URB_FROM_IRP(Irp)
Definition: usb.h:85
#define TRANSFER_FLAG_CANCELED
Definition: usbport.h:130
#define TRANSFER_FLAG_PARENT
Definition: usbport.h:139
#define INVALIDATE_ENDPOINT_WORKER_THREAD
Definition: usbport.h:37
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055

Referenced by USBPORT_FlushPendingTransfers().

◆ USBPORT_CancelSplitTransfer()

VOID NTAPI USBPORT_CancelSplitTransfer ( IN PUSBPORT_TRANSFER  SplitTransfer)

Definition at line 314 of file trfsplit.c.

315{
316 PUSBPORT_TRANSFER ParentTransfer;
317 PUSBPORT_ENDPOINT Endpoint;
319
320 DPRINT("USBPORT_CancelSplitTransfer \n");
321
322 Endpoint = SplitTransfer->Endpoint;
323 ParentTransfer = SplitTransfer->ParentTransfer;
324 ParentTransfer->CompletedTransferLen += SplitTransfer->CompletedTransferLen;
325
326 KeAcquireSpinLock(&ParentTransfer->TransferSpinLock, &OldIrql);
327 RemoveEntryList(&SplitTransfer->SplitLink);
328 KeReleaseSpinLock(&ParentTransfer->TransferSpinLock, OldIrql);
329
330 ExFreePool(SplitTransfer);
331
332 if (IsListEmpty(&ParentTransfer->SplitTransfersList))
333 {
334 InsertTailList(&Endpoint->CancelList, &ParentTransfer->TransferLink);
335 }
336}
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
LIST_ENTRY CancelList
Definition: usbport.h:229
ULONG CompletedTransferLen
Definition: usbport.h:259

Referenced by USBPORT_DmaEndpointPaused().

◆ USBPORT_ClosePipe()

VOID NTAPI USBPORT_ClosePipe ( IN PUSBPORT_DEVICE_HANDLE  DeviceHandle,
IN PDEVICE_OBJECT  FdoDevice,
IN PUSBPORT_PIPE_HANDLE  PipeHandle 
)

Definition at line 590 of file endpoint.c.

593{
596 PUSBPORT_ENDPOINT Endpoint;
598 PUSB2_TT_EXTENSION TtExtension;
599 ULONG ix;
600 BOOLEAN IsReady;
602
603 DPRINT1("USBPORT_ClosePipe \n");
604
605 FdoExtension = FdoDevice->DeviceExtension;
606
608 return;
609
611
613
615 {
616 PipeHandle->Flags &= ~PIPE_HANDLE_FLAG_NULL_PACKET_SIZE;
617 return;
618 }
619
620 Endpoint = PipeHandle->Endpoint;
621
622 KeAcquireSpinLock(&FdoExtension->EndpointListSpinLock, &OldIrql);
623
624 if ((Endpoint->Flags & ENDPOINT_FLAG_ROOTHUB_EP0) &&
626 {
627 PdoExtension = FdoExtension->RootHubPdo->DeviceExtension;
628 PdoExtension->Endpoint = NULL;
629 }
630
631 KeReleaseSpinLock(&FdoExtension->EndpointListSpinLock, OldIrql);
632
633 while (TRUE)
634 {
635 IsReady = TRUE;
636
638 &Endpoint->EndpointOldIrql);
639
640 if (!IsListEmpty(&Endpoint->PendingTransferList))
641 IsReady = FALSE;
642
643 if (!IsListEmpty(&Endpoint->TransferList))
644 IsReady = FALSE;
645
646 if (!IsListEmpty(&Endpoint->CancelList))
647 IsReady = FALSE;
648
649 if (!IsListEmpty(&Endpoint->AbortList))
650 IsReady = FALSE;
651
653 if (Endpoint->StateLast != Endpoint->StateNext)
654 IsReady = FALSE;
656
658 Endpoint->EndpointOldIrql);
659
660 if (InterlockedIncrement(&Endpoint->LockCounter))
661 IsReady = FALSE;
663
664 if (IsReady == TRUE)
665 break;
666
667 USBPORT_Wait(FdoDevice, 1);
668 }
669
670 Endpoint->DeviceHandle = NULL;
671 Packet = &FdoExtension->MiniPortInterface->Packet;
672
673 if (Packet->MiniPortFlags & USB_MINIPORT_FLAGS_USB2)
674 {
675 USBPORT_FreeBandwidthUSB2(FdoDevice, Endpoint);
676
677 KeAcquireSpinLock(&FdoExtension->TtSpinLock, &OldIrql);
678
679 TtExtension = Endpoint->TtExtension;
680 DPRINT1("USBPORT_ClosePipe: TtExtension - %p\n", TtExtension);
681
682 if (TtExtension)
683 {
684 RemoveEntryList(&Endpoint->TtLink);
685
686 Endpoint->TtLink.Flink = NULL;
687 Endpoint->TtLink.Blink = NULL;
688
689 if (TtExtension->Flags & USB2_TT_EXTENSION_FLAG_DELETED)
690 {
691 if (IsListEmpty(&TtExtension->EndpointList))
692 {
693 USBPORT_UpdateAllocatedBwTt(TtExtension);
694
695 for (ix = 0; ix < USB2_FRAMES; ix++)
696 {
697 FdoExtension->Bandwidth[ix] += TtExtension->MaxBandwidth;
698 }
699
700 DPRINT1("USBPORT_ClosePipe: ExFreePoolWithTag TtExtension - %p\n", TtExtension);
701 ExFreePoolWithTag(TtExtension, USB_PORT_TAG);
702 }
703 }
704 }
705
707 }
708 else
709 {
710 USBPORT_FreeBandwidth(FdoDevice, Endpoint);
711 }
712
713 KeAcquireSpinLock(&Endpoint->EndpointSpinLock, &Endpoint->EndpointOldIrql);
716
718}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
VOID NTAPI USBPORT_RemovePipeHandle(IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PUSBPORT_PIPE_HANDLE PipeHandle)
Definition: endpoint.c:456
VOID NTAPI USBPORT_FreeBandwidth(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint)
Definition: endpoint.c:171
VOID NTAPI USBPORT_SetEndpointState(IN PUSBPORT_ENDPOINT Endpoint, IN ULONG State)
Definition: endpoint.c:363
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
LIST_ENTRY EndpointList
Definition: usbport.h:557
KIRQL EndpointOldIrql
Definition: usbport.h:216
PUSBPORT_DEVICE_HANDLE DeviceHandle
Definition: usbport.h:208
KSPIN_LOCK StateChangeSpinLock
Definition: usbport.h:225
LIST_ENTRY PendingTransferList
Definition: usbport.h:227
LIST_ENTRY TransferList
Definition: usbport.h:228
LIST_ENTRY TtLink
Definition: usbport.h:239
PUSB2_TT_EXTENSION TtExtension
Definition: usbport.h:209
LIST_ENTRY AbortList
Definition: usbport.h:230
USBPORT_ENDPOINT_PROPERTIES EndpointProperties
Definition: usbport.h:211
VOID NTAPI USBPORT_FreeBandwidthUSB2(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint)
Definition: usb2.c:2040
#define USBPORT_ENDPOINT_REMOVE
Definition: usbmport.h:16
#define USB_MINIPORT_FLAGS_USB2
Definition: usbmport.h:534
VOID NTAPI USBPORT_SignalWorkerThread(IN PDEVICE_OBJECT FdoDevice)
Definition: usbport.c:1111
NTSTATUS NTAPI USBPORT_Wait(IN PVOID MiniPortExtension, IN ULONG Milliseconds)
Definition: usbport.c:543
#define PIPE_HANDLE_FLAG_CLOSED
Definition: usbport.h:126
#define PIPE_HANDLE_FLAG_NULL_PACKET_SIZE
Definition: usbport.h:127
#define USB2_TT_EXTENSION_FLAG_DELETED
Definition: usbport.h:546

Referenced by USBPORT_CloseConfiguration(), USBPORT_CreateDevice(), USBPORT_HandleSelectInterface(), USBPORT_RemoveDevice(), and USBPORT_RestoreDevice().

◆ USBPORT_CompleteCanceledBadRequest()

VOID NTAPI USBPORT_CompleteCanceledBadRequest ( IN PIO_CSQ  Csq,
IN PIRP  Irp 
)

Definition at line 246 of file queue.c.

248{
250
251 DPRINT_QUEUE("USBPORT_CompleteCanceledBadRequest: Irp - %p\n", Irp);
252
255 BadRequestIoCsq);
256
257 InterlockedDecrement(&FdoExtension->BadRequestLockCounter);
258
259 Irp->IoStatus.Status = STATUS_CANCELLED;
260 Irp->IoStatus.Information = 0;
262}
#define STATUS_CANCELLED
Definition: udferr_usr.h:170

Referenced by USBPORT_StartDevice().

◆ USBPORT_CompleteCanceledIdleIrp()

VOID NTAPI USBPORT_CompleteCanceledIdleIrp ( IN PIO_CSQ  Csq,
IN PIRP  Irp 
)

Definition at line 123 of file queue.c.

125{
127
128 DPRINT_QUEUE("USBPORT_CompleteCanceledIdleIrp: ... \n");
129
132 IdleIoCsq);
133
134 InterlockedDecrement(&FdoExtension->IdleLockCounter);
135
136 Irp->IoStatus.Status = STATUS_CANCELLED;
137 Irp->IoStatus.Information = 0;
139}

Referenced by USBPORT_StartDevice().

◆ USBPORT_CompleteIsoTransfer()

ULONG NTAPI USBPORT_CompleteIsoTransfer ( IN PVOID  MiniPortExtension,
IN PVOID  MiniPortEndpoint,
IN PVOID  TransferParameters,
IN ULONG  TransferLength 
)

Definition at line 25 of file iso.c.

29{
30 DPRINT1("USBPORT_CompleteIsoTransfer: UNIMPLEMENTED. FIXME.\n");
31 return 0;
32}

Referenced by USBPORT_RegisterUSBPortDriver().

◆ USBPORT_CompletePdoWaitWake()

VOID NTAPI USBPORT_CompletePdoWaitWake ( IN PDEVICE_OBJECT  FdoDevice)

Definition at line 15 of file power.c.

16{
18 PDEVICE_OBJECT PdoDevice;
20 PIRP Irp;
22
23 DPRINT("USBPORT_CompletePdoWaitWake: ... \n");
24
25 FdoExtension = FdoDevice->DeviceExtension;
26 PdoDevice = FdoExtension->RootHubPdo;
27 PdoExtension = PdoDevice->DeviceExtension;
28
29 KeAcquireSpinLock(&FdoExtension->PowerWakeSpinLock, &OldIrql);
30
31 Irp = PdoExtension->WakeIrp;
32
34 {
35 PdoExtension->WakeIrp = NULL;
36 KeReleaseSpinLock(&FdoExtension->PowerWakeSpinLock, OldIrql);
37
38 DPRINT("USBPORT_CompletePdoWaitWake: Complete Irp - %p\n", Irp);
39
40 Irp->IoStatus.Status = STATUS_SUCCESS;
41 Irp->IoStatus.Information = 0;
43
44 return;
45 }
46
47 KeReleaseSpinLock(&FdoExtension->PowerWakeSpinLock, OldIrql);
48}
IoSetCancelRoutine(Irp, CancelRoutine)
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by USBPORT_HcWakeDpc(), USBPORT_IsrDpc(), and USBPORT_PdoDevicePowerState().

◆ USBPORT_CompleteTransfer()

VOID NTAPI USBPORT_CompleteTransfer ( IN PURB  Urb,
IN USBD_STATUS  TransferStatus 
)

Definition at line 2198 of file usbport.c.

2200{
2201 struct _URB_CONTROL_TRANSFER *UrbTransfer;
2202 PUSBPORT_TRANSFER Transfer;
2204 PIRP Irp;
2205 KIRQL OldIrql;
2208 BOOLEAN IsFlushSuccess;
2209 PMDL Mdl;
2210 ULONG_PTR CurrentVa;
2211 SIZE_T TransferLength;
2212 PUSBPORT_ENDPOINT Endpoint;
2213 PDEVICE_OBJECT FdoDevice;
2215 PDMA_OPERATIONS DmaOperations;
2216
2217 DPRINT("USBPORT_CompleteTransfer: Urb - %p, TransferStatus - %X\n",
2218 Urb,
2219 TransferStatus);
2220
2221 UrbTransfer = &Urb->UrbControlTransfer;
2222 Transfer = UrbTransfer->hca.Reserved8[0];
2223
2224 Transfer->USBDStatus = TransferStatus;
2225 Status = USBPORT_USBDStatusToNtStatus(Urb, TransferStatus);
2226
2227 UrbTransfer->TransferBufferLength = Transfer->CompletedTransferLen;
2228
2229 if (Transfer->Flags & TRANSFER_FLAG_DMA_MAPPED)
2230 {
2231 Endpoint = Transfer->Endpoint;
2232 FdoDevice = Endpoint->FdoDevice;
2233 FdoExtension = FdoDevice->DeviceExtension;
2234 DmaOperations = FdoExtension->DmaAdapter->DmaOperations;
2235
2237 Mdl = UrbTransfer->TransferBufferMDL;
2238 CurrentVa = (ULONG_PTR)MmGetMdlVirtualAddress(Mdl);
2239 TransferLength = UrbTransfer->TransferBufferLength;
2240
2241 IsFlushSuccess = DmaOperations->FlushAdapterBuffers(FdoExtension->DmaAdapter,
2242 Mdl,
2243 Transfer->MapRegisterBase,
2244 (PVOID)CurrentVa,
2245 TransferLength,
2247
2248 if (!IsFlushSuccess)
2249 {
2250 DPRINT("USBPORT_CompleteTransfer: no FlushAdapterBuffers !!!\n");
2251 ASSERT(FALSE);
2252 }
2253
2255
2256 DmaOperations->FreeMapRegisters(FdoExtension->DmaAdapter,
2257 Transfer->MapRegisterBase,
2258 Transfer->NumberOfMapRegisters);
2259
2261 }
2262
2263 if (Urb->UrbHeader.UsbdFlags & USBD_FLAG_ALLOCATED_MDL)
2264 {
2265 IoFreeMdl(Transfer->TransferBufferMDL);
2266 Urb->UrbHeader.UsbdFlags |= ~USBD_FLAG_ALLOCATED_MDL;
2267 }
2268
2269 Urb->UrbControlTransfer.hca.Reserved8[0] = NULL;
2270 Urb->UrbHeader.UsbdFlags |= ~USBD_FLAG_ALLOCATED_TRANSFER;
2271
2272 Irp = Transfer->Irp;
2273
2274 if (Irp)
2275 {
2276 if (!NT_SUCCESS(Status))
2277 {
2278 //DbgBreakPoint();
2279 DPRINT1("USBPORT_CompleteTransfer: Irp - %p complete with Status - %lx\n",
2280 Irp,
2281 Status);
2282
2283 USBPORT_DumpingURB(Urb);
2284 }
2285
2286 Irp->IoStatus.Status = Status;
2287 Irp->IoStatus.Information = 0;
2288
2292 }
2293
2294 Event = Transfer->Event;
2295
2296 if (Event)
2297 {
2299 }
2300
2302
2303 DPRINT_CORE("USBPORT_CompleteTransfer: exit\n");
2304}
LONG NTSTATUS
Definition: precomp.h:26
_In_ PSCSI_REQUEST_BLOCK _In_opt_ PVOID _In_ ULONG _In_ BOOLEAN WriteToDevice
Definition: cdrom.h:992
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID NTAPI USBPORT_DumpingURB(IN PURB Urb)
Definition: debug.c:224
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
#define IoFreeMdl
Definition: fxmdl.h:89
Status
Definition: gdiplustypes.h:25
PFLUSH_ADAPTER_BUFFERS FlushAdapterBuffers
Definition: iotypes.h:2638
PFREE_MAP_REGISTERS FreeMapRegisters
Definition: iotypes.h:2640
PMDL TransferBufferMDL
Definition: usb.h:472
struct _URB_HCD_AREA hca
Definition: usb.h:474
ULONG TransferBufferLength
Definition: usb.h:470
PDEVICE_OBJECT FdoDevice
Definition: usbport.h:206
PMDL TransferBufferMDL
Definition: usbport.h:255
ULONG NumberOfMapRegisters
Definition: usbport.h:260
USBD_STATUS USBDStatus
Definition: usbport.h:258
PVOID MapRegisterBase
Definition: usbport.h:261
NTSTATUS NTAPI USBPORT_USBDStatusToNtStatus(IN PURB Urb, IN USBD_STATUS USBDStatus)
Definition: usbport.c:485
#define TRANSFER_FLAG_DMA_MAPPED
Definition: usbport.h:131
#define USBPORT_DMA_DIRECTION_TO_DEVICE
Definition: usbport.h:42
#define USBD_FLAG_ALLOCATED_MDL
Definition: usbport.h:121
#define EVENT_INCREMENT
Definition: iotypes.h:597

Referenced by USBPORT_CancelPendingTransferIrp(), USBPORT_DoneTransfer(), USBPORT_FlushCancelList(), USBPORT_FlushPendingTransfers(), and USBPORT_QueuePendingTransferIrp().

◆ USBPORT_CreateDevice()

NTSTATUS NTAPI USBPORT_CreateDevice ( IN OUT PUSB_DEVICE_HANDLE pUsbdDeviceHandle,
IN PDEVICE_OBJECT  FdoDevice,
IN PUSBPORT_DEVICE_HANDLE  HubDeviceHandle,
IN USHORT  PortStatus,
IN USHORT  Port 
)

Definition at line 982 of file device.c.

987{
988 PUSBPORT_DEVICE_HANDLE TtDeviceHandle = NULL;
989 PUSB2_TT_EXTENSION TtExtension = NULL;
990 USHORT port;
993 BOOL IsOpenedPipe;
996 ULONG TransferedLen;
997 ULONG DescriptorMinSize;
998 UCHAR MaxPacketSize;
1002
1003 DPRINT("USBPORT_CreateDevice: PortStatus - %p, Port - %x\n",
1004 PortStatus,
1005 Port);
1006
1007 FdoExtension = FdoDevice->DeviceExtension;
1008 Packet = &FdoExtension->MiniPortInterface->Packet;
1009
1010 KeWaitForSingleObject(&FdoExtension->DeviceSemaphore,
1011 Executive,
1012 KernelMode,
1013 FALSE,
1014 NULL);
1015
1017 {
1018 KeReleaseSemaphore(&FdoExtension->DeviceSemaphore,
1020 1,
1021 FALSE);
1022
1023 DPRINT1("USBPORT_CreateDevice: Not valid hub DeviceHandle\n");
1025 }
1026
1027 port = Port;
1028
1029 if (Packet->MiniPortFlags & USB_MINIPORT_FLAGS_USB2 &&
1031 {
1032 DPRINT1("USBPORT_CreateDevice: USB1 device connected to USB2 port\n");
1033
1034 TtExtension = USBPORT_GetTt(FdoDevice,
1036 &port,
1037 &TtDeviceHandle);
1038
1039 DPRINT("USBPORT_CreateDevice: TtDeviceHandle - %p, port - %x\n",
1040 TtDeviceHandle,
1041 port);
1042 }
1043
1044 KeReleaseSemaphore(&FdoExtension->DeviceSemaphore,
1046 1,
1047 FALSE);
1048
1050 sizeof(USBPORT_DEVICE_HANDLE),
1051 USB_PORT_TAG);
1052
1053 if (!DeviceHandle)
1054 {
1055 DPRINT1("USBPORT_CreateDevice: Not allocated DeviceHandle\n");
1057 }
1058
1060
1061 *pUsbdDeviceHandle = NULL;
1062
1063 DeviceHandle->TtExtension = TtExtension;
1064 DeviceHandle->PortNumber = Port;
1065 DeviceHandle->HubDeviceHandle = HubDeviceHandle;
1066
1068 {
1069 DeviceHandle->DeviceSpeed = UsbLowSpeed;
1070 }
1072 {
1073 DeviceHandle->DeviceSpeed = UsbHighSpeed;
1074 }
1075 else
1076 {
1077 DeviceHandle->DeviceSpeed = UsbFullSpeed;
1078 }
1079
1080 KeWaitForSingleObject(&FdoExtension->DeviceSemaphore,
1081 Executive,
1082 KernelMode,
1083 FALSE,
1084 NULL);
1085
1086 PipeHandle = &DeviceHandle->PipeHandle;
1087
1089
1090 PipeHandle->EndpointDescriptor.bLength = sizeof(PipeHandle->EndpointDescriptor);
1091 PipeHandle->EndpointDescriptor.bDescriptorType = USB_ENDPOINT_DESCRIPTOR_TYPE;
1092
1093 if (DeviceHandle->DeviceSpeed == UsbLowSpeed)
1094 {
1095 PipeHandle->EndpointDescriptor.wMaxPacketSize = 8;
1096 }
1097 else
1098 {
1099 PipeHandle->EndpointDescriptor.wMaxPacketSize = USB_DEFAULT_MAX_PACKET;
1100 }
1101
1102 InitializeListHead(&DeviceHandle->PipeHandleList);
1104
1105 Status = USBPORT_OpenPipe(FdoDevice,
1107 PipeHandle,
1108 NULL);
1109
1110 IsOpenedPipe = NT_SUCCESS(Status);
1111
1112 if (NT_ERROR(Status))
1113 {
1114 DPRINT1("USBPORT_CreateDevice: USBPORT_OpenPipe return - %lx\n", Status);
1115
1116 KeReleaseSemaphore(&FdoExtension->DeviceSemaphore,
1118 1,
1119 FALSE);
1120
1122
1123 return Status;
1124 }
1125
1128 USB_PORT_TAG);
1129
1130 if (!DeviceDescriptor)
1131 {
1132 DPRINT1("USBPORT_CreateDevice: Not allocated DeviceDescriptor\n");
1133 goto ErrorExit;
1134 }
1135
1138
1139 SetupPacket.bmRequestType.Dir = BMREQUEST_DEVICE_TO_HOST;
1143
1144 TransferedLen = 0;
1145
1147 FdoDevice,
1148 &SetupPacket,
1151 &TransferedLen,
1152 NULL);
1153
1154 RtlCopyMemory(&DeviceHandle->DeviceDescriptor,
1156 sizeof(USB_DEVICE_DESCRIPTOR));
1157
1159
1161 bMaxPacketSize0);
1162
1163 if ((TransferedLen == DescriptorMinSize) && !NT_SUCCESS(Status))
1164 {
1166 }
1167
1168 if (NT_SUCCESS(Status) && (TransferedLen >= DescriptorMinSize))
1169 {
1170 if ((DeviceHandle->DeviceDescriptor.bLength >= sizeof(USB_DEVICE_DESCRIPTOR)) &&
1171 (DeviceHandle->DeviceDescriptor.bDescriptorType == USB_DEVICE_DESCRIPTOR_TYPE))
1172 {
1173 MaxPacketSize = DeviceHandle->DeviceDescriptor.bMaxPacketSize0;
1174
1175 if (MaxPacketSize == 8 ||
1176 MaxPacketSize == 16 ||
1177 MaxPacketSize == 32 ||
1178 MaxPacketSize == 64)
1179 {
1181
1182 *pUsbdDeviceHandle = DeviceHandle;
1183
1184 KeReleaseSemaphore(&FdoExtension->DeviceSemaphore,
1186 1,
1187 FALSE);
1188
1189 return Status;
1190 }
1191 }
1192 }
1193
1194 DPRINT1("USBPORT_CreateDevice: ERROR!!! TransferedLen - %x, Status - %lx\n",
1195 TransferedLen,
1196 Status);
1197
1198ErrorExit:
1199
1200 if (TtExtension && TtDeviceHandle)
1201 {
1202 SetupPacket.bmRequestType.Recipient = BMREQUEST_TO_OTHER;
1203 SetupPacket.bmRequestType.Reserved = 0;
1204 SetupPacket.bmRequestType.Type = BMREQUEST_CLASS;
1205 SetupPacket.bmRequestType.Dir = BMREQUEST_HOST_TO_DEVICE;
1206
1207 /* Table 11-15. Hub Class Requests */
1208 if (TtDeviceHandle == HubDeviceHandle)
1209 {
1211 }
1212 else
1213 {
1215 }
1216
1217 SetupPacket.wValue.LowByte = 0;
1218 SetupPacket.wValue.HiByte = 0;
1219 SetupPacket.wIndex.W = port;
1220 SetupPacket.wLength = 0;
1221
1222 USBPORT_SendSetupPacket(TtDeviceHandle,
1223 FdoDevice,
1224 &SetupPacket,
1225 NULL,
1226 0,
1227 NULL,
1228 NULL);
1229 }
1230
1232
1233 if (IsOpenedPipe)
1234 {
1236 }
1237
1238 KeReleaseSemaphore(&FdoExtension->DeviceSemaphore,
1240 1,
1241 FALSE);
1242
1244
1245 return Status;
1246}
USHORT port
Definition: uri.c:228
BOOLEAN NTAPI USBPORT_ValidateDeviceHandle(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_DEVICE_HANDLE DeviceHandle)
Definition: device.c:801
PUSB2_TT_EXTENSION NTAPI USBPORT_GetTt(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_DEVICE_HANDLE HubDeviceHandle, OUT PUSHORT OutPort, OUT PUSBPORT_DEVICE_HANDLE *OutHubDeviceHandle)
Definition: device.c:912
VOID NTAPI USBPORT_AddDeviceHandle(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_DEVICE_HANDLE DeviceHandle)
Definition: device.c:769
NTSTATUS NTAPI USBPORT_SendSetupPacket(IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PDEVICE_OBJECT FdoDevice, IN PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket, IN PVOID Buffer, IN ULONG Length, IN OUT PULONG TransferedLen, IN OUT PUSBD_STATUS pUSBDStatus)
Definition: device.c:15
VOID NTAPI USBPORT_ClosePipe(IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_PIPE_HANDLE PipeHandle)
Definition: endpoint.c:590
NTSTATUS NTAPI USBPORT_OpenPipe(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PUSBPORT_PIPE_HANDLE PipeHandle, IN OUT PUSBD_STATUS UsbdStatus)
Definition: endpoint.c:763
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
unsigned int BOOL
Definition: ntddk_ex.h:94
CPPORT Port[4]
Definition: headless.c:35
_Outptr_ PUSB_DEVICE_HANDLE _In_ PUSB_DEVICE_HANDLE HubDeviceHandle
Definition: hubbusif.h:41
_Outptr_ PUSB_DEVICE_HANDLE _In_ PUSB_DEVICE_HANDLE _In_ USHORT PortStatus
Definition: hubbusif.h:42
#define LOW_REALTIME_PRIORITY
#define KernelMode
Definition: asm.h:34
#define RTL_SIZEOF_THROUGH_FIELD(type, field)
Definition: ntbasedef.h:672
unsigned short USHORT
Definition: pedump.c:61
LONG NTAPI KeReleaseSemaphore(IN PKSEMAPHORE Semaphore, IN KPRIORITY Increment, IN LONG Adjustment, IN BOOLEAN Wait)
Definition: semphobj.c:54
const KSDEVICE_DESCRIPTOR DeviceDescriptor
Definition: splitter.c:257
static VOID ErrorExit(LPTSTR lpszMessage)
Definition: telnetd.c:647
#define STATUS_DEVICE_DATA_ERROR
Definition: udferr_usr.h:159
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define NT_ERROR(Status)
Definition: umtypes.h:106
#define USB_REQUEST_GET_DESCRIPTOR
Definition: usb100.h:82
#define BMREQUEST_CLASS
Definition: usb100.h:35
#define USB_ENDPOINT_DESCRIPTOR_TYPE
Definition: usb100.h:53
#define USB_DEVICE_DESCRIPTOR_TYPE
Definition: usb100.h:49
#define BMREQUEST_TO_OTHER
Definition: usb100.h:41
#define BMREQUEST_HOST_TO_DEVICE
Definition: usb100.h:31
#define BMREQUEST_DEVICE_TO_HOST
Definition: usb100.h:32
#define USB_PORT_STATUS_HIGH_SPEED
Definition: usb200.h:158
#define USB_PORT_STATUS_LOW_SPEED
Definition: usb200.h:157
#define USB_REQUEST_RESET_TT
Definition: usb200.h:283
#define USB_REQUEST_CLEAR_TT_BUFFER
Definition: usb200.h:282
#define USB_DEFAULT_MAX_PACKET
Definition: usb.h:84
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _In_ PWDF_USB_CONTROL_SETUP_PACKET SetupPacket
Definition: wdfusb.h:1337
@ Executive
Definition: ketypes.h:415

Referenced by USBHI_CreateUsbDevice().

◆ USBPORT_CreateWorkerThread()

NTSTATUS NTAPI USBPORT_CreateWorkerThread ( IN PDEVICE_OBJECT  FdoDevice)

Definition at line 1427 of file usbport.c.

1428{
1431
1432 DPRINT("USBPORT_CreateWorkerThread ...\n");
1433
1434 FdoExtension = FdoDevice->DeviceExtension;
1435
1436 FdoExtension->Flags &= ~USBPORT_FLAG_WORKER_THREAD_ON;
1437
1438 KeInitializeEvent(&FdoExtension->WorkerThreadEvent,
1440 FALSE);
1441
1442 Status = PsCreateSystemThread(&FdoExtension->WorkerThreadHandle,
1444 NULL,
1445 NULL,
1446 NULL,
1448 (PVOID)FdoDevice);
1449
1450 return Status;
1451}
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
@ NotificationEvent
NTSTATUS NTAPI PsCreateSystemThread(OUT PHANDLE ThreadHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN HANDLE ProcessHandle, IN PCLIENT_ID ClientId, IN PKSTART_ROUTINE StartRoutine, IN PVOID StartContext)
Definition: thread.c:602
VOID NTAPI USBPORT_WorkerThread(IN PVOID StartContext)
Definition: usbport.c:1368

Referenced by USBPORT_StartDevice().

◆ USBPORT_DbgPrint()

ULONG USBPORT_DbgPrint ( IN PVOID  MiniPortExtension,
IN ULONG  Level,
IN PCH  Format,
  ... 
)

Definition at line 19 of file debug.c.

23{
24 DPRINT("USBPORT_DbgPrint: UNIMPLEMENTED. FIXME. \n");
25 return 0;
26}

Referenced by USBPORT_RegisterUSBPortDriver().

◆ USBPORT_DoIdleNotificationCallback()

VOID NTAPI USBPORT_DoIdleNotificationCallback ( IN PVOID  Context)

Definition at line 545 of file power.c.

546{
547 PIO_STACK_LOCATION IoStack;
548 PDEVICE_OBJECT FdoDevice;
551 PIRP NextIrp;
552 LARGE_INTEGER CurrentTime = {{0, 0}};
553 PTIMER_WORK_QUEUE_ITEM IdleQueueItem;
554 PDEVICE_OBJECT PdoDevice;
555 PUSB_IDLE_CALLBACK_INFO IdleCallbackInfo;
557
558 DPRINT("USBPORT_DoIdleNotificationCallback \n");
559
560 IdleQueueItem = Context;
561
562 FdoDevice = IdleQueueItem->FdoDevice;
563 FdoExtension = FdoDevice->DeviceExtension;
564 PdoDevice = FdoExtension->RootHubPdo;
565 PdoExtension = PdoDevice->DeviceExtension;
566
567 KeQuerySystemTime(&CurrentTime);
568
569 if ((FdoExtension->IdleTime.QuadPart == 0) ||
570 (((CurrentTime.QuadPart - FdoExtension->IdleTime.QuadPart) / 10000) >= 500))
571 {
572 if (PdoExtension->CommonExtension.DevicePowerState == PowerDeviceD0 &&
573 FdoExtension->CommonExtension.DevicePowerState == PowerDeviceD0)
574 {
575 NextIrp = IoCsqRemoveNextIrp(&FdoExtension->IdleIoCsq, NULL);
576
577 if (NextIrp)
578 {
579 IoStack = IoGetCurrentIrpStackLocation(NextIrp);
580 IdleCallbackInfo = IoStack->Parameters.DeviceIoControl.Type3InputBuffer;
581
582 if (IdleCallbackInfo && IdleCallbackInfo->IdleCallback)
583 {
584 IdleCallbackInfo->IdleCallback(IdleCallbackInfo->IdleContext);
585 }
586
587 if (NextIrp->Cancel)
588 {
589 InterlockedDecrement(&FdoExtension->IdleLockCounter);
590
592 NextIrp->IoStatus.Information = 0;
594 }
595 else
596 {
597 IoCsqInsertIrp(&FdoExtension->IdleIoCsq, NextIrp, NULL);
598 }
599 }
600 }
601 }
602
603 KeAcquireSpinLock(&FdoExtension->TimerFlagsSpinLock, &OldIrql);
604 FdoExtension->TimerFlags &= ~USBPORT_TMFLAG_IDLE_QUEUEITEM_ON;
605 KeReleaseSpinLock(&FdoExtension->TimerFlagsSpinLock, OldIrql);
606
607 ExFreePoolWithTag(IdleQueueItem, USB_PORT_TAG);
608}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
NTKERNELAPI VOID NTAPI IoCsqInsertIrp(_Inout_ PIO_CSQ Csq, _Inout_ PIRP Irp, _Out_opt_ PIO_CSQ_IRP_CONTEXT Context)
Insert an IRP into the CSQ.
Definition: csq.c:177
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
@ PowerDeviceD0
Definition: ntpoapi.h:49
struct _IO_STACK_LOCATION::@1564::@1565 DeviceIoControl
union _IO_STACK_LOCATION::@1564 Parameters
IO_STATUS_BLOCK IoStatus
PDEVICE_OBJECT FdoDevice
Definition: usbport.h:445
LONGLONG QuadPart
Definition: typedefs.h:114

Referenced by USBPORT_TimerDpc().

◆ USBPORT_DoneSplitTransfer()

VOID NTAPI USBPORT_DoneSplitTransfer ( IN PUSBPORT_TRANSFER  SplitTransfer)

Definition at line 278 of file trfsplit.c.

279{
280 PUSBPORT_TRANSFER ParentTransfer;
282
283 DPRINT("USBPORT_DoneSplitTransfer: ... \n");
284
285 ParentTransfer = SplitTransfer->ParentTransfer;
286 ParentTransfer->CompletedTransferLen += SplitTransfer->CompletedTransferLen;
287
288 if (SplitTransfer->USBDStatus != USBD_STATUS_SUCCESS)
289 {
290 DPRINT1("USBPORT_DoneSplitTransfer: SplitTransfer->USBDStatus - %X\n",
291 SplitTransfer->USBDStatus);
292
293 ParentTransfer->USBDStatus = SplitTransfer->USBDStatus;
294 }
295
296 KeAcquireSpinLock(&ParentTransfer->TransferSpinLock, &OldIrql);
297
298 RemoveEntryList(&SplitTransfer->SplitLink);
299 ExFreePoolWithTag(SplitTransfer, USB_PORT_TAG);
300
301 if (IsListEmpty(&ParentTransfer->SplitTransfersList))
302 {
303 KeReleaseSpinLock(&ParentTransfer->TransferSpinLock, OldIrql);
304 USBPORT_DoneTransfer(ParentTransfer);
305 }
306 else
307 {
308 KeReleaseSpinLock(&ParentTransfer->TransferSpinLock, OldIrql);
309 }
310}
VOID NTAPI USBPORT_DoneTransfer(IN PUSBPORT_TRANSFER Transfer)
Definition: usbport.c:724

Referenced by USBPORT_FlushDoneTransfers().

◆ USBPORT_DoneTransfer()

VOID NTAPI USBPORT_DoneTransfer ( IN PUSBPORT_TRANSFER  Transfer)

Definition at line 724 of file usbport.c.

725{
726 PUSBPORT_ENDPOINT Endpoint;
727 PDEVICE_OBJECT FdoDevice;
729 PURB Urb;
730 PIRP Irp;
731 KIRQL CancelIrql;
733
734 DPRINT_CORE("USBPORT_DoneTransfer: Transfer - %p\n", Transfer);
735
736 Endpoint = Transfer->Endpoint;
737 FdoDevice = Endpoint->FdoDevice;
738 FdoExtension = FdoDevice->DeviceExtension;
739
740 Urb = Transfer->Urb;
741 Irp = Transfer->Irp;
742
743 KeAcquireSpinLock(&FdoExtension->FlushTransferSpinLock, &OldIrql);
744
745 if (Irp)
746 {
747 IoAcquireCancelSpinLock(&CancelIrql);
749 IoReleaseCancelSpinLock(CancelIrql);
750
752 }
753
754 KeReleaseSpinLock(&FdoExtension->FlushTransferSpinLock, OldIrql);
755
756 USBPORT_USBDStatusToNtStatus(Transfer->Urb, Transfer->USBDStatus);
757 USBPORT_CompleteTransfer(Urb, Urb->UrbHeader.Status);
758
759 DPRINT_CORE("USBPORT_DoneTransfer: exit\n");
760}
PIRP NTAPI USBPORT_RemoveActiveTransferIrp(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp)
Definition: queue.c:357
VOID NTAPI IoAcquireCancelSpinLock(OUT PKIRQL Irql)
Definition: util.c:56
struct _URB_HEADER UrbHeader
Definition: usb.h:531
VOID NTAPI USBPORT_CompleteTransfer(IN PURB Urb, IN USBD_STATUS TransferStatus)
Definition: usbport.c:2198

Referenced by USBPORT_DoneSplitTransfer(), and USBPORT_FlushDoneTransfers().

◆ USBPORT_DoSetPowerD0()

VOID NTAPI USBPORT_DoSetPowerD0 ( IN PDEVICE_OBJECT  FdoDevice)

Definition at line 104 of file power.c.

105{
106 DPRINT("USBPORT_DoSetPowerD0: FIXME!\n");
107 return;
108}

Referenced by USBPORT_WorkerThread().

◆ USBPORT_DpcHandler()

VOID NTAPI USBPORT_DpcHandler ( IN PDEVICE_OBJECT  FdoDevice)

Definition at line 864 of file usbport.c.

865{
867 PUSBPORT_ENDPOINT Endpoint;
870 LONG LockCounter;
871
872 DPRINT_CORE("USBPORT_DpcHandler: ...\n");
873
874 FdoExtension = FdoDevice->DeviceExtension;
875
877
878 KeAcquireSpinLockAtDpcLevel(&FdoExtension->EndpointListSpinLock);
879 Entry = FdoExtension->EndpointList.Flink;
880
881 while (Entry && Entry != &FdoExtension->EndpointList)
882 {
883 Endpoint = CONTAINING_RECORD(Entry,
885 EndpointLink);
886
887 LockCounter = InterlockedIncrement(&Endpoint->LockCounter);
888
890 LockCounter ||
892 {
894 }
895 else
896 {
897 InsertTailList(&List, &Endpoint->DispatchLink);
898
899 if (Endpoint->WorkerLink.Flink && Endpoint->WorkerLink.Blink)
900 {
901 RemoveEntryList(&Endpoint->WorkerLink);
902
903 Endpoint->WorkerLink.Flink = NULL;
904 Endpoint->WorkerLink.Blink = NULL;
905 }
906 }
907
908 Entry = Endpoint->EndpointLink.Flink;
909 }
910
911 KeReleaseSpinLockFromDpcLevel(&FdoExtension->EndpointListSpinLock);
912
913 while (!IsListEmpty(&List))
914 {
915 Endpoint = CONTAINING_RECORD(List.Flink,
917 DispatchLink);
918
919 RemoveEntryList(List.Flink);
920 Endpoint->DispatchLink.Flink = NULL;
921 Endpoint->DispatchLink.Blink = NULL;
922
923 USBPORT_EndpointWorker(Endpoint, TRUE);
925 }
926
927 KeAcquireSpinLockAtDpcLevel(&FdoExtension->EndpointListSpinLock);
928
929 if (!IsListEmpty(&FdoExtension->WorkerList))
930 {
932 }
933
934 KeReleaseSpinLockFromDpcLevel(&FdoExtension->EndpointListSpinLock);
935
937}
BOOLEAN NTAPI USBPORT_EndpointWorker(IN PUSBPORT_ENDPOINT Endpoint, IN BOOLEAN LockNotChecked)
Definition: endpoint.c:1656
ULONG NTAPI USBPORT_GetEndpointState(IN PUSBPORT_ENDPOINT Endpoint)
Definition: endpoint.c:332
long LONG
Definition: pedump.c:60
LIST_ENTRY EndpointLink
Definition: usbport.h:232
LIST_ENTRY DispatchLink
Definition: usbport.h:235
LIST_ENTRY WorkerLink
Definition: usbport.h:233
#define USBPORT_ENDPOINT_ACTIVE
Definition: usbmport.h:15
VOID NTAPI USBPORT_FlushDoneTransfers(IN PDEVICE_OBJECT FdoDevice)
Definition: usbport.c:764
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550

Referenced by USBPORT_IsrDpcHandler(), and USBPORT_WorkerRequestDpc().

◆ USBPORT_DumpingCapabilities()

VOID NTAPI USBPORT_DumpingCapabilities ( IN PDEVICE_CAPABILITIES  Capabilities)

Definition at line 170 of file debug.c.

171{
172 if (!Capabilities)
173 {
174 return;
175 }
176
177 DPRINT("Capabilities->Size - %x\n", Capabilities->Size);
178 DPRINT("Capabilities->Version - %x\n", Capabilities->Version);
179
180 DPRINT("Capabilities->DeviceD1 - %x\n", Capabilities->DeviceD1);
181 DPRINT("Capabilities->DeviceD2 - %x\n", Capabilities->DeviceD2);
182 DPRINT("Capabilities->LockSupported - %x\n", Capabilities->LockSupported);
183 DPRINT("Capabilities->EjectSupported - %x\n", Capabilities->EjectSupported);
184 DPRINT("Capabilities->Removable - %x\n", Capabilities->Removable);
185 DPRINT("Capabilities->DockDevice - %x\n", Capabilities->DockDevice);
186 DPRINT("Capabilities->UniqueID - %x\n", Capabilities->UniqueID);
187 DPRINT("Capabilities->SilentInstall - %x\n", Capabilities->SilentInstall);
188 DPRINT("Capabilities->RawDeviceOK - %x\n", Capabilities->RawDeviceOK);
189 DPRINT("Capabilities->SurpriseRemovalOK - %x\n", Capabilities->SurpriseRemovalOK);
190
191 DPRINT("Capabilities->Address - %x\n", Capabilities->Address);
192 DPRINT("Capabilities->UINumber - %x\n", Capabilities->UINumber);
193
194 DPRINT("Capabilities->DeviceState[0] - %x\n", Capabilities->DeviceState[0]);
195 DPRINT("Capabilities->DeviceState[1] - %x\n", Capabilities->DeviceState[1]);
196 DPRINT("Capabilities->DeviceState[2] - %x\n", Capabilities->DeviceState[2]);
197 DPRINT("Capabilities->DeviceState[3] - %x\n", Capabilities->DeviceState[3]);
198 DPRINT("Capabilities->DeviceState[4] - %x\n", Capabilities->DeviceState[4]);
199 DPRINT("Capabilities->DeviceState[5] - %x\n", Capabilities->DeviceState[5]);
200 DPRINT("Capabilities->DeviceState[6] - %x\n", Capabilities->DeviceState[6]);
201
202 DPRINT("Capabilities->SystemWake - %x\n", Capabilities->SystemWake);
203 DPRINT("Capabilities->DeviceWake - %x\n", Capabilities->DeviceWake);
204
205 DPRINT("Capabilities->D1Latency - %x\n", Capabilities->D1Latency);
206 DPRINT("Capabilities->D2Latency - %x\n", Capabilities->D2Latency);
207 DPRINT("Capabilities->D3Latency - %x\n", Capabilities->D3Latency);
208}

Referenced by USBPORT_QueryCapabilities().

◆ USBPORT_DumpingConfiguration()

VOID NTAPI USBPORT_DumpingConfiguration ( IN PUSB_CONFIGURATION_DESCRIPTOR  ConfigDescriptor)

Definition at line 105 of file debug.c.

106{
107 PUSB_INTERFACE_DESCRIPTOR iDescriptor;
109 ULONG ix;
110
111 if (!ConfigDescriptor ||
113 {
114 return;
115 }
116
117 DPRINT_URB("Dumping ConfigDescriptor - %p\n", ConfigDescriptor);
118 DPRINT_URB("bLength - %x\n", ConfigDescriptor->bLength);
119 DPRINT_URB("bDescriptorType - %x\n", ConfigDescriptor->bDescriptorType);
120 DPRINT_URB("wTotalLength - %x\n", ConfigDescriptor->wTotalLength);
121 DPRINT_URB("bNumInterfaces - %x\n", ConfigDescriptor->bNumInterfaces);
122 DPRINT_URB("bConfigurationValue - %x\n", ConfigDescriptor->bConfigurationValue);
123 DPRINT_URB("iConfiguration - %x\n", ConfigDescriptor->iConfiguration);
124 DPRINT_URB("bmAttributes - %x\n", ConfigDescriptor->bmAttributes);
125 DPRINT_URB("MaxPower - %x\n", ConfigDescriptor->MaxPower);
126
128 ConfigDescriptor->bLength);
129
130 if (iDescriptor->bLength < sizeof(USB_INTERFACE_DESCRIPTOR))
131 {
132 return;
133 }
134
135 DPRINT_URB("Dumping iDescriptor - %p\n", iDescriptor);
136 DPRINT_URB("bLength - %x\n", iDescriptor->bLength);
137 DPRINT_URB("bDescriptorType - %x\n", iDescriptor->bDescriptorType);
138 DPRINT_URB("bInterfaceNumber - %x\n", iDescriptor->bInterfaceNumber);
139 DPRINT_URB("bAlternateSetting - %x\n", iDescriptor->bAlternateSetting);
140 DPRINT_URB("bNumEndpoints - %x\n", iDescriptor->bNumEndpoints);
141 DPRINT_URB("bInterfaceClass - %x\n", iDescriptor->bInterfaceClass);
142 DPRINT_URB("bInterfaceSubClass - %x\n", iDescriptor->bInterfaceSubClass);
143 DPRINT_URB("bInterfaceProtocol - %x\n", iDescriptor->bInterfaceProtocol);
144 DPRINT_URB("iInterface - %x\n", iDescriptor->iInterface);
145
147 iDescriptor->bLength);
148
149 for (ix = 0; ix < iDescriptor->bNumEndpoints; ix++)
150 {
151 if (Descriptor->bLength < sizeof(USB_ENDPOINT_DESCRIPTOR))
152 {
153 return;
154 }
155
156 DPRINT_URB("Dumping Descriptor - %p\n", Descriptor);
157 DPRINT_URB("bLength - %x\n", Descriptor->bLength);
158 DPRINT_URB("bDescriptorType - %x\n", Descriptor->bDescriptorType);
159 DPRINT_URB("bEndpointAddress - %x\n", Descriptor->bEndpointAddress);
160 DPRINT_URB("bmAttributes - %x\n", Descriptor->bmAttributes);
161 DPRINT_URB("wMaxPacketSize - %x\n", Descriptor->wMaxPacketSize);
162 DPRINT_URB("bInterval - %x\n", Descriptor->bInterval);
163
164 Descriptor += 1;
165 }
166}
struct _USB_INTERFACE_DESCRIPTOR * PUSB_INTERFACE_DESCRIPTOR
struct _USB_ENDPOINT_DESCRIPTOR * PUSB_ENDPOINT_DESCRIPTOR
#define DPRINT_URB(...)
Definition: usbdebug.h:145
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
Definition: wdfresource.h:342
_Must_inspect_result_ _In_ WDFUSBDEVICE _Out_writes_bytes_to_opt_ ConfigDescriptorLength PVOID ConfigDescriptor
Definition: wdfusb.h:1036

Referenced by USBPORT_HandleSelectConfiguration().

◆ USBPORT_DumpingDeviceDescriptor()

VOID NTAPI USBPORT_DumpingDeviceDescriptor ( IN PUSB_DEVICE_DESCRIPTOR  DeviceDescriptor)

Definition at line 79 of file debug.c.

80{
82 {
83 return;
84 }
85
86 DPRINT_URB("Dumping Device Descriptor - %p\n", DeviceDescriptor);
87 DPRINT_URB("bLength - %x\n", DeviceDescriptor->bLength);
88 DPRINT_URB("bDescriptorType - %x\n", DeviceDescriptor->bDescriptorType);
89 DPRINT_URB("bcdUSB - %x\n", DeviceDescriptor->bcdUSB);
90 DPRINT_URB("bDeviceClass - %x\n", DeviceDescriptor->bDeviceClass);
91 DPRINT_URB("bDeviceSubClass - %x\n", DeviceDescriptor->bDeviceSubClass);
92 DPRINT_URB("bDeviceProtocol - %x\n", DeviceDescriptor->bDeviceProtocol);
93 DPRINT_URB("bMaxPacketSize0 - %x\n", DeviceDescriptor->bMaxPacketSize0);
94 DPRINT_URB("idVendor - %x\n", DeviceDescriptor->idVendor);
95 DPRINT_URB("idProduct - %x\n", DeviceDescriptor->idProduct);
96 DPRINT_URB("bcdDevice - %x\n", DeviceDescriptor->bcdDevice);
97 DPRINT_URB("iManufacturer - %x\n", DeviceDescriptor->iManufacturer);
98 DPRINT_URB("iProduct - %x\n", DeviceDescriptor->iProduct);
99 DPRINT_URB("iSerialNumber - %x\n", DeviceDescriptor->iSerialNumber);
100 DPRINT_URB("bNumConfigurations - %x\n", DeviceDescriptor->bNumConfigurations);
101}

Referenced by USBHI_GetUsbDescriptors(), and USBHI_QueryDeviceInformation().

◆ USBPORT_DumpingEndpointProperties()

VOID NTAPI USBPORT_DumpingEndpointProperties ( IN PUSBPORT_ENDPOINT_PROPERTIES  EndpointProperties)

Definition at line 280 of file debug.c.

281{
282 DPRINT_USB2("DeviceAddress - %X\n", EndpointProperties->DeviceAddress);
283 DPRINT_USB2("EndpointAddress - %X\n", EndpointProperties->EndpointAddress);
284 DPRINT_USB2("TotalMaxPacketSize - %X\n", EndpointProperties->TotalMaxPacketSize);
285 DPRINT_USB2("Period - %X\n", EndpointProperties->Period);
286 DPRINT_USB2("DeviceSpeed - %X\n", EndpointProperties->DeviceSpeed);
287 DPRINT_USB2("UsbBandwidth - %X\n", EndpointProperties->UsbBandwidth);
288 DPRINT_USB2("ScheduleOffset - %X\n", EndpointProperties->ScheduleOffset);
289 DPRINT_USB2("TransferType - %X\n", EndpointProperties->TransferType);
290 DPRINT_USB2("MaxTransferSize - %X\n", EndpointProperties->MaxTransferSize);
291 DPRINT_USB2("HubAddr - %X\n", EndpointProperties->HubAddr);
292 DPRINT_USB2("PortNumber - %X\n", EndpointProperties->PortNumber);
293 DPRINT_USB2("InterruptScheduleMask - %X\n", EndpointProperties->InterruptScheduleMask);
294 DPRINT_USB2("SplitCompletionMask - %X\n", EndpointProperties->SplitCompletionMask);
295 DPRINT_USB2("MaxPacketSize - %X\n", EndpointProperties->MaxPacketSize);
296}
#define DPRINT_USB2(...)
Definition: usbdebug.h:149

Referenced by USBPORT_AllocateBandwidthUSB2().

◆ USBPORT_DumpingIDs()

VOID NTAPI USBPORT_DumpingIDs ( IN PVOID  Buffer)

Definition at line 257 of file debug.c.

258{
259 PWSTR Ptr;
261 ULONG TotalLength = 0;
262
263 Ptr = (PWSTR)Buffer;
264
265 while (*Ptr)
266 {
267 DPRINT(" %S\n", Ptr);
268 Length = (ULONG)wcslen(Ptr) + 1;
269
270 Ptr += Length;
272 }
273
274 DPRINT("TotalLength: %hu\n", TotalLength);
275 DPRINT("\n");
276}
Definition: bufpool.h:45
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
uint16_t * PWSTR
Definition: typedefs.h:56
_In_ ULONG TotalLength
Definition: usbdlib.h:158

Referenced by USBPORT_GetDeviceHwIds().

◆ USBPORT_DumpingSetupPacket()

VOID NTAPI USBPORT_DumpingSetupPacket ( IN PUSB_DEFAULT_PIPE_SETUP_PACKET  SetupPacket)

Definition at line 212 of file debug.c.

213{
214 DPRINT("SetupPacket->bmRequestType.B - %x\n", SetupPacket->bmRequestType.B);
215 DPRINT("SetupPacket->bRequest - %x\n", SetupPacket->bRequest);
216 DPRINT("SetupPacket->wValue.LowByte - %x\n", SetupPacket->wValue.LowByte);
217 DPRINT("SetupPacket->wValue.HiByte - %x\n", SetupPacket->wValue.HiByte);
218 DPRINT("SetupPacket->wIndex.W - %x\n", SetupPacket->wIndex.W);
219 DPRINT("SetupPacket->wLength - %x\n", SetupPacket->wLength);
220}

Referenced by USBPORT_DumpingURB(), USBPORT_HandleGetConfiguration(), USBPORT_HandleGetSetDescriptor(), USBPORT_HandleGetStatus(), USBPORT_HandleSetOrClearFeature(), and USBPORT_HandleVendorOrClass().

◆ USBPORT_DumpingTtEndpoint()

VOID NTAPI USBPORT_DumpingTtEndpoint ( IN PUSB2_TT_ENDPOINT  TtEndpoint)

Definition at line 300 of file debug.c.

301{
302 DPRINT_USB2("MaxPacketSize - %X\n", TtEndpoint->MaxPacketSize);
303 DPRINT_USB2("Period - %X\n", TtEndpoint->Period);
304 DPRINT_USB2("TtEndpointParams- %X\n", TtEndpoint->TtEndpointParams.AsULONG);
305 DPRINT_USB2("CalcBusTime - %X\n", TtEndpoint->CalcBusTime);
306 DPRINT_USB2("StartTime - %X\n", TtEndpoint->StartTime);
307 DPRINT_USB2("ActualPeriod - %X\n", TtEndpoint->ActualPeriod);
308 DPRINT_USB2("StartFrame - %X\n", TtEndpoint->StartFrame);
309 DPRINT_USB2("StartMicroframe - %X\n", TtEndpoint->StartMicroframe);
310 DPRINT_USB2("Nums - %X\n", TtEndpoint->Nums.AsULONG);
311 DPRINT_USB2("nextTtEndpoint - %X\n", TtEndpoint->NextTtEndpoint);
312}

Referenced by USBPORT_AllocateBandwidthUSB2().

◆ USBPORT_DumpingURB()

VOID NTAPI USBPORT_DumpingURB ( IN PURB  Urb)

Definition at line 224 of file debug.c.

225{
227
228 DPRINT_URB("UrbHeader.Length - %x\n", Urb->UrbHeader.Length);
229 DPRINT_URB("UrbHeader.Function - %x\n", Urb->UrbHeader.Function);
230 DPRINT_URB("UrbHeader.Status - %x\n", Urb->UrbHeader.Status);
231 DPRINT_URB("UrbHeader.UsbdDeviceHandle - %p\n", Urb->UrbHeader.UsbdDeviceHandle);
232 DPRINT_URB("UrbHeader.UsbdFlags - %x\n", Urb->UrbHeader.UsbdFlags);
233
234 if (Urb->UrbHeader.Length < 0x48)
235 {
236 return;
237 }
238
239 DPRINT_URB("PipeHandle - %p\n", Urb->UrbControlTransfer.PipeHandle);
240 DPRINT_URB("TransferFlags - %x\n", Urb->UrbControlTransfer.TransferFlags);
241 DPRINT_URB("TransferBufferLength - %x\n", Urb->UrbControlTransfer.TransferBufferLength);
242 DPRINT_URB("TransferBuffer - %p\n", Urb->UrbControlTransfer.TransferBuffer);
243 DPRINT_URB("TransferBufferMDL - %p\n", Urb->UrbControlTransfer.TransferBufferMDL);
244 DPRINT_URB("UrbLink - %p\n", Urb->UrbControlTransfer.UrbLink);
245
246 if (Urb->UrbHeader.Length < 0x50)
247 {
248 return;
249 }
250
251 SetupPacket = (PUSB_DEFAULT_PIPE_SETUP_PACKET)&Urb->UrbControlTransfer.SetupPacket;
253}
VOID NTAPI USBPORT_DumpingSetupPacket(IN PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket)
Definition: debug.c:212
struct _USB_DEFAULT_PIPE_SETUP_PACKET * PUSB_DEFAULT_PIPE_SETUP_PACKET

Referenced by USBPORT_CompleteTransfer(), USBPORT_ValidateTransferParametersURB(), and USBPORT_ValidateURB().

◆ USBPORT_EndpointHasQueuedTransfers()

BOOLEAN NTAPI USBPORT_EndpointHasQueuedTransfers ( IN PDEVICE_OBJECT  FdoDevice,
IN PUSBPORT_ENDPOINT  Endpoint,
IN PULONG  TransferCount 
)

Definition at line 254 of file endpoint.c.

257{
259 PUSBPORT_TRANSFER Transfer;
261
262 DPRINT_CORE("USBPORT_EndpointHasQueuedTransfers: ... \n");
263
264 KeAcquireSpinLock(&Endpoint->EndpointSpinLock, &Endpoint->EndpointOldIrql);
265
266 if (!IsListEmpty(&Endpoint->PendingTransferList))
267 Result = TRUE;
268
269 if (!IsListEmpty(&Endpoint->TransferList))
270 {
271 Result = TRUE;
272
273 if (TransferCount)
274 {
275 *TransferCount = 0;
276
277 for (Entry = Endpoint->TransferList.Flink;
278 Entry && Entry != &Endpoint->TransferList;
279 Entry = Transfer->TransferLink.Flink)
280 {
281 Transfer = CONTAINING_RECORD(Entry,
283 TransferLink);
284
285 if (Transfer->Flags & TRANSFER_FLAG_SUBMITED)
286 {
287 ++*TransferCount;
288 }
289 }
290 }
291 }
292
293 KeReleaseSpinLock(&Endpoint->EndpointSpinLock, Endpoint->EndpointOldIrql);
294
295 return Result;
296}
#define TRANSFER_FLAG_SUBMITED
Definition: usbport.h:133

Referenced by USBPORT_DeviceHasTransfers(), and USBPORT_FlushDoneTransfers().

◆ USBPORT_EndpointWorker()

BOOLEAN NTAPI USBPORT_EndpointWorker ( IN PUSBPORT_ENDPOINT  Endpoint,
IN BOOLEAN  Flag 
)

Definition at line 1656 of file endpoint.c.

1658{
1659 PDEVICE_OBJECT FdoDevice;
1662 ULONG EndpointState;
1663
1664 DPRINT_CORE("USBPORT_EndpointWorker: Endpoint - %p, LockNotChecked - %x\n",
1665 Endpoint,
1666 LockNotChecked);
1667
1668 FdoDevice = Endpoint->FdoDevice;
1669 FdoExtension = FdoDevice->DeviceExtension;
1670 Packet = &FdoExtension->MiniPortInterface->Packet;
1671
1672 if (LockNotChecked == FALSE)
1673 {
1674 if (InterlockedIncrement(&Endpoint->LockCounter))
1675 {
1676 InterlockedDecrement(&Endpoint->LockCounter);
1677 DPRINT_CORE("USBPORT_EndpointWorker: LockCounter > 0\n");
1678 return TRUE;
1679 }
1680 }
1681
1683
1684 KeAcquireSpinLockAtDpcLevel(&Endpoint->EndpointSpinLock);
1685
1687 {
1688 KeReleaseSpinLockFromDpcLevel(&Endpoint->EndpointSpinLock);
1689 InterlockedDecrement(&Endpoint->LockCounter);
1690 DPRINT_CORE("USBPORT_EndpointWorker: State == USBPORT_ENDPOINT_CLOSED. return FALSE\n");
1691 return FALSE;
1692 }
1693
1694 if ((Endpoint->Flags & (ENDPOINT_FLAG_ROOTHUB_EP0 | ENDPOINT_FLAG_NUKE)) == 0)
1695 {
1696 KeAcquireSpinLockAtDpcLevel(&FdoExtension->MiniportSpinLock);
1697 Packet->PollEndpoint(FdoExtension->MiniPortExt, Endpoint + 1);
1698 KeReleaseSpinLockFromDpcLevel(&FdoExtension->MiniportSpinLock);
1699 }
1700
1701 EndpointState = USBPORT_GetEndpointState(Endpoint);
1702
1703 if (EndpointState == USBPORT_ENDPOINT_REMOVE)
1704 {
1705 KeAcquireSpinLockAtDpcLevel(&Endpoint->StateChangeSpinLock);
1706 Endpoint->StateLast = USBPORT_ENDPOINT_CLOSED;
1707 Endpoint->StateNext = USBPORT_ENDPOINT_CLOSED;
1708 KeReleaseSpinLockFromDpcLevel(&Endpoint->StateChangeSpinLock);
1709
1710 KeReleaseSpinLockFromDpcLevel(&Endpoint->EndpointSpinLock);
1711
1712 KeAcquireSpinLockAtDpcLevel(&FdoExtension->EndpointListSpinLock);
1713
1714 ExInterlockedInsertTailList(&FdoExtension->EndpointClosedList,
1715 &Endpoint->CloseLink,
1716 &FdoExtension->EndpointClosedSpinLock);
1717
1718 KeReleaseSpinLockFromDpcLevel(&FdoExtension->EndpointListSpinLock);
1719
1720 InterlockedDecrement(&Endpoint->LockCounter);
1721 DPRINT_CORE("USBPORT_EndpointWorker: State == USBPORT_ENDPOINT_REMOVE. return FALSE\n");
1722 return FALSE;
1723 }
1724
1725 if (!IsListEmpty(&Endpoint->PendingTransferList) ||
1726 !IsListEmpty(&Endpoint->TransferList) ||
1727 !IsListEmpty(&Endpoint->CancelList))
1728 {
1729 KeReleaseSpinLockFromDpcLevel(&Endpoint->EndpointSpinLock);
1730
1731 EndpointState = USBPORT_GetEndpointState(Endpoint);
1732
1733 KeAcquireSpinLockAtDpcLevel(&Endpoint->StateChangeSpinLock);
1734 if (EndpointState == Endpoint->StateNext)
1735 {
1736 KeReleaseSpinLockFromDpcLevel(&Endpoint->StateChangeSpinLock);
1737
1738 if (Endpoint->EndpointWorker)
1739 {
1740 USBPORT_DmaEndpointWorker(Endpoint);
1741 }
1742 else
1743 {
1745 }
1746
1747 USBPORT_FlushAbortList(Endpoint);
1748
1749 InterlockedDecrement(&Endpoint->LockCounter);
1750 DPRINT_CORE("USBPORT_EndpointWorker: return FALSE\n");
1751 return FALSE;
1752 }
1753
1754 KeReleaseSpinLockFromDpcLevel(&Endpoint->StateChangeSpinLock);
1755 InterlockedDecrement(&Endpoint->LockCounter);
1756
1757 DPRINT_CORE("USBPORT_EndpointWorker: return TRUE\n");
1758 return TRUE;
1759 }
1760
1761 KeReleaseSpinLockFromDpcLevel(&Endpoint->EndpointSpinLock);
1762
1763 USBPORT_FlushAbortList(Endpoint);
1764
1765 InterlockedDecrement(&Endpoint->LockCounter);
1766 DPRINT_CORE("USBPORT_EndpointWorker: return FALSE\n");
1767 return FALSE;
1768}
VOID NTAPI USBPORT_FlushAbortList(IN PUSBPORT_ENDPOINT Endpoint)
Definition: queue.c:605
VOID NTAPI USBPORT_DmaEndpointWorker(IN PUSBPORT_ENDPOINT Endpoint)
Definition: endpoint.c:1591
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define USBPORT_ENDPOINT_CLOSED
Definition: usbmport.h:17
VOID NTAPI USBPORT_RootHubEndpointWorker(IN PUSBPORT_ENDPOINT Endpoint)
Definition: roothub.c:664
#define ENDPOINT_FLAG_NUKE
Definition: usbport.h:113

Referenced by USBPORT_DpcHandler(), USBPORT_FlushPendingTransfers(), USBPORT_MapTransfer(), and USBPORT_WorkerThreadHandler().

◆ USBPORT_FdoDeviceControl()

NTSTATUS NTAPI USBPORT_FdoDeviceControl ( PDEVICE_OBJECT  FdoDevice,
PIRP  Irp 
)

◆ USBPORT_FdoInternalDeviceControl()

NTSTATUS NTAPI USBPORT_FdoInternalDeviceControl ( IN PDEVICE_OBJECT  FdoDevice,
IN PIRP  Irp 
)

Definition at line 454 of file ioctl.c.

456{
457 DPRINT1("USBPORT_FdoInternalDeviceControl: UNIMPLEMENTED. FIXME. \n");
458 return 0;
459}

Referenced by USBPORT_Dispatch().

◆ USBPORT_FdoPnP()

NTSTATUS NTAPI USBPORT_FdoPnP ( IN PDEVICE_OBJECT  FdoDevice,
IN PIRP  Irp 
)

Definition at line 1110 of file pnp.c.

1112{
1114 PUSBPORT_COMMON_DEVICE_EXTENSION FdoCommonExtension;
1116 PUSBPORT_RESOURCES UsbPortResources;
1117 PIO_STACK_LOCATION IoStack;
1118 UCHAR Minor;
1119 KEVENT Event;
1122 PDEVICE_RELATIONS DeviceRelations;
1123 PDEVICE_OBJECT RootHubPdo;
1124
1125 FdoExtension = FdoDevice->DeviceExtension;
1126 FdoCommonExtension = &FdoExtension->CommonExtension;
1127 UsbPortResources = &FdoExtension->UsbPortResources;
1128 Packet = &FdoExtension->MiniPortInterface->Packet;
1129
1131 Minor = IoStack->MinorFunction;
1132
1133 DPRINT("USBPORT_FdoPnP: FdoDevice - %p, Minor - %x\n", FdoDevice, Minor);
1134
1136
1137 switch (Minor)
1138 {
1140 DPRINT("IRP_MN_START_DEVICE\n");
1141
1143
1145
1148 &Event,
1149 TRUE,
1150 TRUE,
1151 TRUE);
1152
1153 Status = IoCallDriver(FdoCommonExtension->LowerDevice,
1154 Irp);
1155
1156 if (Status == STATUS_PENDING)
1157 {
1159 Suspended,
1160 KernelMode,
1161 FALSE,
1162 NULL);
1163
1164 Status = Irp->IoStatus.Status;
1165 }
1166
1167 if (!NT_SUCCESS(Status))
1168 {
1169 goto Exit;
1170 }
1171
1172 Status = USBPORT_ParseResources(FdoDevice,
1173 Irp,
1174 UsbPortResources);
1175
1176 if (!NT_SUCCESS(Status))
1177 {
1178 FdoCommonExtension->PnpStateFlags |= USBPORT_PNP_STATE_STOPPED;
1179 goto Exit;
1180 }
1181
1182 Status = USBPORT_StartDevice(FdoDevice, UsbPortResources);
1183
1184 if (!NT_SUCCESS(Status))
1185 {
1186 FdoCommonExtension->PnpStateFlags |= USBPORT_PNP_STATE_STOPPED;
1187 goto Exit;
1188 }
1189
1190 FdoCommonExtension->PnpStateFlags &= ~USBPORT_PNP_STATE_NOT_INIT;
1191 FdoCommonExtension->PnpStateFlags |= USBPORT_PNP_STATE_STARTED;
1192
1193 FdoCommonExtension->DevicePowerState = PowerDeviceD0;
1194
1195 if (Packet->MiniPortFlags & USB_MINIPORT_FLAGS_USB2)
1196 {
1197 USBPORT_AddUSB2Fdo(FdoDevice);
1198 }
1199 else
1200 {
1201 USBPORT_AddUSB1Fdo(FdoDevice);
1202 }
1203
1204Exit:
1205 Irp->IoStatus.Status = Status;
1207 return Status;
1208
1210 DPRINT("IRP_MN_QUERY_REMOVE_DEVICE\n");
1211 if (Packet->MiniPortFlags & USB_MINIPORT_FLAGS_USB2)
1212 {
1213 DPRINT1("USBPORT_FdoPnP: Haction registry write FIXME\n");
1214 }
1215
1216 Irp->IoStatus.Status = STATUS_SUCCESS;
1217 goto ForwardIrp;
1218
1220 DPRINT("USBPORT_FdoPnP: IRP_MN_REMOVE_DEVICE\n");
1221 FdoCommonExtension->PnpStateFlags |= USBPORT_PNP_STATE_FAILED;
1222
1223 if (FdoCommonExtension->PnpStateFlags & USBPORT_PNP_STATE_STARTED &&
1224 !(FdoCommonExtension->PnpStateFlags & USBPORT_PNP_STATE_NOT_INIT))
1225 {
1226 DPRINT1("USBPORT_FdoPnP: stop fdo FIXME\n");
1227 FdoCommonExtension->PnpStateFlags |= USBPORT_PNP_STATE_NOT_INIT;
1228 }
1229
1230 Irp->IoStatus.Status = STATUS_SUCCESS;
1232 Status = IoCallDriver(FdoCommonExtension->LowerDevice, Irp);
1233
1234 IoDetachDevice(FdoCommonExtension->LowerDevice);
1235
1236 RootHubPdo = FdoExtension->RootHubPdo;
1237
1238 IoDeleteDevice(FdoDevice);
1239
1240 if (RootHubPdo)
1241 {
1242 IoDeleteDevice(RootHubPdo);
1243 }
1244
1245 return Status;
1246
1248 DPRINT("IRP_MN_CANCEL_REMOVE_DEVICE\n");
1249 Irp->IoStatus.Status = STATUS_SUCCESS;
1250 goto ForwardIrp;
1251
1252 case IRP_MN_STOP_DEVICE:
1253 DPRINT("IRP_MN_STOP_DEVICE\n");
1254 if (FdoCommonExtension->PnpStateFlags & USBPORT_PNP_STATE_STARTED)
1255 {
1256 DPRINT1("USBPORT_FdoPnP: stop fdo FIXME\n");
1257
1258 FdoCommonExtension->PnpStateFlags &= ~USBPORT_PNP_STATE_STARTED;
1259 FdoCommonExtension->PnpStateFlags |= USBPORT_PNP_STATE_NOT_INIT;
1260 }
1261
1262 Irp->IoStatus.Status = STATUS_SUCCESS;
1263 goto ForwardIrp;
1264
1266 DPRINT("IRP_MN_QUERY_STOP_DEVICE\n");
1267 Irp->IoStatus.Status = STATUS_SUCCESS;
1268 goto ForwardIrp;
1269
1271 DPRINT("IRP_MN_CANCEL_STOP_DEVICE\n");
1272 Irp->IoStatus.Status = STATUS_SUCCESS;
1273 goto ForwardIrp;
1274
1276 DPRINT("IRP_MN_QUERY_DEVICE_RELATIONS\n");
1278 {
1279 DeviceRelations = ExAllocatePoolWithTag(PagedPool,
1280 sizeof(DEVICE_RELATIONS),
1281 USB_PORT_TAG);
1282
1283 if (!DeviceRelations)
1284 {
1286 Irp->IoStatus.Status = Status;
1288 return Status;
1289 }
1290
1291 DeviceRelations->Count = 0;
1292 DeviceRelations->Objects[0] = NULL;
1293
1294 if (!FdoExtension->RootHubPdo)
1295 {
1296 Status = USBPORT_CreatePdo(FdoDevice,
1297 &FdoExtension->RootHubPdo);
1298
1299 if (!NT_SUCCESS(Status))
1300 {
1301 ExFreePoolWithTag(DeviceRelations, USB_PORT_TAG);
1302 goto ForwardIrp;
1303 }
1304 }
1305 else
1306 {
1308 }
1309
1310 DeviceRelations->Count = 1;
1311 DeviceRelations->Objects[0] = FdoExtension->RootHubPdo;
1312
1313 ObReferenceObject(FdoExtension->RootHubPdo);
1314 Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
1315 }
1316 else
1317 {
1319 {
1320 DPRINT1("USBPORT_FdoPnP: FIXME IRP_MN_QUERY_DEVICE_RELATIONS/RemovalRelations\n");
1321 }
1322
1323 goto ForwardIrp;
1324 }
1325
1326 Irp->IoStatus.Status = Status;
1327 goto ForwardIrp;
1328
1330 DPRINT("IRP_MN_QUERY_INTERFACE\n");
1331 goto ForwardIrp;
1332
1334 DPRINT("IRP_MN_QUERY_CAPABILITIES\n");
1335 goto ForwardIrp;
1336
1338 DPRINT("IRP_MN_QUERY_RESOURCES\n");
1339 goto ForwardIrp;
1340
1342 DPRINT("IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n");
1343 goto ForwardIrp;
1344
1346 DPRINT("IRP_MN_QUERY_DEVICE_TEXT\n");
1347 goto ForwardIrp;
1348
1350 DPRINT("IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n");
1351 goto ForwardIrp;
1352
1353 case IRP_MN_READ_CONFIG:
1354 DPRINT("IRP_MN_READ_CONFIG\n");
1355 goto ForwardIrp;
1356
1358 DPRINT("IRP_MN_WRITE_CONFIG\n");
1359 goto ForwardIrp;
1360
1361 case IRP_MN_EJECT:
1362 DPRINT("IRP_MN_EJECT\n");
1363 goto ForwardIrp;
1364
1365 case IRP_MN_SET_LOCK:
1366 DPRINT("IRP_MN_SET_LOCK\n");
1367 goto ForwardIrp;
1368
1369 case IRP_MN_QUERY_ID:
1370 DPRINT("IRP_MN_QUERY_ID\n");
1371 goto ForwardIrp;
1372
1374 DPRINT("IRP_MN_QUERY_PNP_DEVICE_STATE\n");
1375 goto ForwardIrp;
1376
1378 DPRINT("IRP_MN_QUERY_BUS_INFORMATION\n");
1379 goto ForwardIrp;
1380
1382 DPRINT("IRP_MN_DEVICE_USAGE_NOTIFICATION\n");
1383 goto ForwardIrp;
1384
1386 DPRINT1("IRP_MN_SURPRISE_REMOVAL\n");
1387 if (!(FdoCommonExtension->PnpStateFlags & USBPORT_PNP_STATE_FAILED))
1388 {
1391 }
1392 goto ForwardIrp;
1393
1394 default:
1395 DPRINT("unknown IRP_MN_???\n");
1396ForwardIrp:
1397 /* forward irp to next device object */
1399 break;
1400 }
1401
1402 return IoCallDriver(FdoCommonExtension->LowerDevice, Irp);
1403}
NTSTATUS NTAPI USBPORT_StartDevice(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_RESOURCES UsbPortResources)
Definition: pnp.c:498
NTSTATUS NTAPI USBPORT_ParseResources(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp, IN PUSBPORT_RESOURCES UsbPortResources)
Definition: pnp.c:912
NTSTATUS NTAPI USBPORT_CreatePdo(IN PDEVICE_OBJECT FdoDevice, OUT PDEVICE_OBJECT *RootHubPdo)
Definition: pnp.c:1028
IO_COMPLETION_ROUTINE USBPORT_FdoStartCompletion
Definition: pnp.c:16
#define PagedPool
Definition: env_spec_w32.h:308
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:490
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IoCopyCurrentIrpStackLocationToNext(Irp)
Definition: ntifs_ex.h:413
VOID NTAPI IoDetachDevice(IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:1296
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
#define IoCallDriver
Definition: irp.c:1225
#define STATUS_PENDING
Definition: ntstatus.h:82
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2163
struct _IO_STACK_LOCATION::@3978::@4003 QueryDeviceRelations
DEVICE_POWER_STATE DevicePowerState
Definition: usbport.h:287
#define USBPORT_INVALIDATE_CONTROLLER_SURPRISE_REMOVE
Definition: usbmport.h:490
VOID NTAPI USBPORT_AddUSB2Fdo(IN PDEVICE_OBJECT FdoDevice)
Definition: usbport.c:82
VOID NTAPI USBPORT_AddUSB1Fdo(IN PDEVICE_OBJECT FdoDevice)
Definition: usbport.c:66
VOID NTAPI USBPORT_InvalidateControllerHandler(IN PDEVICE_OBJECT FdoDevice, IN ULONG Type)
Definition: usbport.c:635
#define USBPORT_PNP_STATE_STARTED
Definition: usbport.h:88
#define USBPORT_PNP_STATE_FAILED
Definition: usbport.h:89
#define USBPORT_PNP_STATE_STOPPED
Definition: usbport.h:90
#define USBPORT_PNP_STATE_NOT_INIT
Definition: usbport.h:87
_In_ DEVICE_RELATION_TYPE RelationType
Definition: wdfdevice.h:1059
_Out_opt_ PULONG Minor
Definition: cmfuncs.h:44
#define IRP_MN_CANCEL_STOP_DEVICE
@ RemovalRelations
Definition: iotypes.h:2155
@ BusRelations
Definition: iotypes.h:2152
#define IRP_MN_QUERY_PNP_DEVICE_STATE
#define IRP_MN_EJECT
#define IRP_MN_QUERY_INTERFACE
#define IRP_MN_START_DEVICE
#define IRP_MN_DEVICE_USAGE_NOTIFICATION
#define IRP_MN_READ_CONFIG
#define IRP_MN_WRITE_CONFIG
#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS
#define IRP_MN_QUERY_ID
#define IRP_MN_REMOVE_DEVICE
#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS
#define IRP_MN_QUERY_DEVICE_RELATIONS
#define IRP_MN_QUERY_STOP_DEVICE
#define IRP_MN_QUERY_DEVICE_TEXT
#define IRP_MN_QUERY_CAPABILITIES
#define IRP_MN_QUERY_RESOURCES
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define IRP_MN_STOP_DEVICE
#define IRP_MN_SET_LOCK
enum _DEVICE_RELATION_TYPE DEVICE_RELATION_TYPE
#define IRP_MN_QUERY_BUS_INFORMATION
#define IRP_MN_QUERY_REMOVE_DEVICE
@ Suspended
Definition: ketypes.h:420
#define ObReferenceObject
Definition: obfuncs.h:204

Referenced by USBPORT_Dispatch().

◆ USBPORT_FdoPower()

NTSTATUS NTAPI USBPORT_FdoPower ( IN PDEVICE_OBJECT  FdoDevice,
IN PIRP  Irp 
)

Definition at line 489 of file power.c.

491{
493 PIO_STACK_LOCATION IoStack;
495
496 DPRINT("USBPORT_FdoPower: ... \n");
497
498 FdoExtension = FdoDevice->DeviceExtension;
500
501 switch (IoStack->MinorFunction)
502 {
503 case IRP_MN_WAIT_WAKE:
504 DPRINT("USBPORT_FdoPower: IRP_MN_WAIT_WAKE\n");
505 Status = USBPORT_HcWake(FdoDevice, Irp);
506 return Status;
507
509 DPRINT("USBPORT_FdoPower: IRP_MN_POWER_SEQUENCE\n");
510 break;
511
512 case IRP_MN_SET_POWER:
513 DPRINT("USBPORT_FdoPower: IRP_MN_SET_POWER\n");
514 if (IoStack->Parameters.Power.Type == DevicePowerState)
515 {
516 Status = USBPORT_DevicePowerState(FdoDevice, Irp);
517 }
518 else
519 {
520 Status = USBPORT_SystemPowerState(FdoDevice, Irp);
521 }
522
523 if (Status != STATUS_PENDING)
524 break;
525
526 return Status;
527
529 DPRINT("USBPORT_FdoPower: IRP_MN_QUERY_POWER\n");
530 Irp->IoStatus.Status = STATUS_SUCCESS;
531 break;
532
533 default:
534 DPRINT1("USBPORT_FdoPower: unknown IRP_MN_POWER!\n");
535 break;
536 }
537
540 return PoCallDriver(FdoExtension->CommonExtension.LowerDevice, Irp);
541}
NTSTATUS NTAPI USBPORT_SystemPowerState(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp)
Definition: power.c:480
NTSTATUS NTAPI USBPORT_DevicePowerState(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp)
Definition: power.c:471
NTSTATUS NTAPI USBPORT_HcWake(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp)
Definition: power.c:462
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:758
@ DevicePowerState
Definition: ntpoapi.h:63
struct _IO_STACK_LOCATION::@3978::@4014 Power
#define IRP_MN_WAIT_WAKE
#define IRP_MN_POWER_SEQUENCE
#define IRP_MN_SET_POWER
#define IRP_MN_QUERY_POWER

Referenced by USBPORT_Dispatch().

◆ USBPORT_FindCompanionControllers()

PDEVICE_RELATIONS NTAPI USBPORT_FindCompanionControllers ( IN PDEVICE_OBJECT  USB2FdoDevice,
IN BOOLEAN  IsObRefer,
IN BOOLEAN  IsFDOsReturned 
)

Definition at line 136 of file usbport.c.

139{
140 PLIST_ENTRY USB1FdoList;
141 PUSBPORT_DEVICE_EXTENSION USB1FdoExtension;
142 ULONG NumControllers = 0;
144 PDEVICE_RELATIONS ControllersList = NULL;
146
147 DPRINT("USBPORT_FindCompanionControllers: USB2Fdo - %p, IsObRefer - %x, IsFDOs - %x\n",
148 USB2FdoDevice,
149 IsObRefer,
150 IsFDOsReturned);
151
153
154 USB1FdoList = USBPORT_USB1FdoList.Flink;
155
156 while (USB1FdoList && USB1FdoList != &USBPORT_USB1FdoList)
157 {
158 USB1FdoExtension = CONTAINING_RECORD(USB1FdoList,
160 ControllerLink);
161
162 if (USB1FdoExtension->Flags & USBPORT_FLAG_COMPANION_HC &&
163 USBPORT_IsCompanionFdoExtension(USB2FdoDevice, USB1FdoExtension))
164 {
165 ++NumControllers;
166 }
167
168 USB1FdoList = USB1FdoExtension->ControllerLink.Flink;
169 }
170
171 DPRINT("USBPORT_FindCompanionControllers: NumControllers - %x\n",
172 NumControllers);
173
174 if (!NumControllers)
175 {
176 goto Exit;
177 }
178
179 ControllersList = ExAllocatePoolWithTag(NonPagedPool,
180 NumControllers * sizeof(DEVICE_RELATIONS),
182
183 if (!ControllersList)
184 {
185 goto Exit;
186 }
187
188 RtlZeroMemory(ControllersList, NumControllers * sizeof(DEVICE_RELATIONS));
189
190 ControllersList->Count = NumControllers;
191
192 USB1FdoList = USBPORT_USB1FdoList.Flink;
193
194 Entry = &ControllersList->Objects[0];
195
196 while (USB1FdoList && USB1FdoList != &USBPORT_USB1FdoList)
197 {
198 USB1FdoExtension = CONTAINING_RECORD(USB1FdoList,
200 ControllerLink);
201
202 if (USB1FdoExtension->Flags & USBPORT_FLAG_COMPANION_HC &&
203 USBPORT_IsCompanionFdoExtension(USB2FdoDevice, USB1FdoExtension))
204 {
205 *Entry = USB1FdoExtension->CommonExtension.LowerPdoDevice;
206
207 if (IsObRefer)
208 {
210 }
211
212 if (IsFDOsReturned)
213 {
214 *Entry = USB1FdoExtension->CommonExtension.SelfDevice;
215 }
216
217 ++Entry;
218 }
219
220 USB1FdoList = USB1FdoExtension->ControllerLink.Flink;
221 }
222
223Exit:
224
226
227 return ControllersList;
228}
PDEVICE_OBJECT LowerPdoDevice
Definition: usbport.h:282
USBPORT_COMMON_DEVICE_EXTENSION CommonExtension
Definition: usbport.h:292
LIST_ENTRY ControllerLink
Definition: usbport.h:302
BOOLEAN NTAPI USBPORT_IsCompanionFdoExtension(IN PDEVICE_OBJECT USB2FdoDevice, IN PUSBPORT_DEVICE_EXTENSION USB1FdoExtension)
Definition: usbport.c:119
#define USBPORT_FLAG_COMPANION_HC
Definition: usbport.h:78

Referenced by USBPORT_RH_SetFeatureUSB2PortPower(), USBPORT_RootHubPowerAndChirpAllCcPorts(), and USBPORT_SynchronizeRootHubCallback().

◆ USBPORT_FindUrbInIrpTable()

VOID NTAPI USBPORT_FindUrbInIrpTable ( IN PUSBPORT_IRP_TABLE  IrpTable,
IN PURB  Urb,
IN PIRP  Irp 
)

Definition at line 381 of file queue.c.

384{
385 ULONG ix;
386 PIRP irp;
387 PURB urbIn;
388
389 DPRINT_CORE("USBPORT_FindUrbInIrpTable: IrpTable - %p, Urb - %p, Irp - %p\n",
390 IrpTable,
391 Urb,
392 Irp);
393
394 ASSERT(IrpTable != NULL);
395
396 do
397 {
398 for (ix = 0; ix < 0x200; ix++)
399 {
400 irp = IrpTable->irp[ix];
401
402 if (irp)
403 {
404 urbIn = URB_FROM_IRP(irp);
405
406 if (urbIn == Urb)
407 {
408 if (irp == Irp)
409 {
410 KeBugCheckEx(BUGCODE_USB_DRIVER,
411 4,
412 (ULONG_PTR)irp,
413 (ULONG_PTR)urbIn,
414 0);
415 }
416
417 KeBugCheckEx(BUGCODE_USB_DRIVER,
418 2,
419 (ULONG_PTR)irp,
420 (ULONG_PTR)Irp,
421 (ULONG_PTR)urbIn);
422 }
423 }
424 }
425
426 IrpTable = IrpTable->LinkNextTable;
427 }
428 while (IrpTable);
429}
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:108

Referenced by USBPORT_FlushPendingTransfers().

◆ USBPORT_FindUSB2Controller()

PDEVICE_OBJECT NTAPI USBPORT_FindUSB2Controller ( IN PDEVICE_OBJECT  FdoDevice)

Definition at line 27 of file usbport.c.

28{
30 PUSBPORT_DEVICE_EXTENSION USB2FdoExtension;
32 PLIST_ENTRY USB2FdoEntry;
33 PDEVICE_OBJECT USB2FdoDevice = NULL;
34
35 DPRINT("USBPORT_FindUSB2Controller: FdoDevice - %p\n", FdoDevice);
36
37 FdoExtension = FdoDevice->DeviceExtension;
38
40
41 USB2FdoEntry = USBPORT_USB2FdoList.Flink;
42
43 while (USB2FdoEntry && USB2FdoEntry != &USBPORT_USB2FdoList)
44 {
45 USB2FdoExtension = CONTAINING_RECORD(USB2FdoEntry,
47 ControllerLink);
48
49 if (USB2FdoExtension->BusNumber == FdoExtension->BusNumber &&
50 USB2FdoExtension->PciDeviceNumber == FdoExtension->PciDeviceNumber)
51 {
52 USB2FdoDevice = USB2FdoExtension->CommonExtension.SelfDevice;
53 break;
54 }
55
56 USB2FdoEntry = USB2FdoEntry->Flink;
57 }
58
60
61 return USB2FdoDevice;
62}

Referenced by USBHI_GetExtendedHubInformation(), USBPORT_SynchronizeControllersStart(), and USBPORT_WorkerThread().

◆ USBPORT_FlushAbortList()

VOID NTAPI USBPORT_FlushAbortList ( IN PUSBPORT_ENDPOINT  Endpoint)

Definition at line 605 of file queue.c.

606{
608 PUSBPORT_TRANSFER Transfer;
609 PLIST_ENTRY AbortList;
612 PIRP Irp;
613 PURB Urb;
615
616 DPRINT_CORE("USBPORT_FlushAbortList: Endpoint - %p\n", Endpoint);
617
619
620 KeAcquireSpinLock(&Endpoint->EndpointSpinLock, &Endpoint->EndpointOldIrql);
621
622 if (IsListEmpty(&Endpoint->AbortList))
623 {
624 KeReleaseSpinLock(&Endpoint->EndpointSpinLock,
625 Endpoint->EndpointOldIrql);
626 return;
627 }
628
629 Entry = Endpoint->PendingTransferList.Flink;
630
631 while (Entry && Entry != &Endpoint->PendingTransferList)
632 {
633 Transfer = CONTAINING_RECORD(Entry,
635 TransferLink);
636
637 if (Transfer->Flags & TRANSFER_FLAG_ABORTED)
638 {
639 DPRINT_CORE("USBPORT_FlushAbortList: Aborted PendingTransfer - %p\n",
640 Transfer);
641
642 KeReleaseSpinLock(&Endpoint->EndpointSpinLock,
643 Endpoint->EndpointOldIrql);
644 return;
645 }
646
647 Entry = Transfer->TransferLink.Flink;
648 }
649
650 Entry = Endpoint->TransferList.Flink;
651
652 while (Entry && Entry != &Endpoint->TransferList)
653 {
654 Transfer = CONTAINING_RECORD(Entry,
656 TransferLink);
657
658 if (Transfer->Flags & TRANSFER_FLAG_ABORTED)
659 {
660 DPRINT_CORE("USBPORT_FlushAbortList: Aborted ActiveTransfer - %p\n",
661 Transfer);
662
663 KeReleaseSpinLock(&Endpoint->EndpointSpinLock,
664 Endpoint->EndpointOldIrql);
665 return;
666 }
667
668 Entry = Transfer->TransferLink.Flink;
669 }
670
671 AbortList = &Endpoint->AbortList;
672
673 while (!IsListEmpty(AbortList))
674 {
675 //DbgBreakPoint();
676
677 Irp = CONTAINING_RECORD(AbortList->Flink,
678 IRP,
679 Tail.Overlay.ListEntry);
680
681 RemoveHeadList(AbortList);
682 InsertTailList(&List, &Irp->Tail.Overlay.ListEntry);
683 }
684
685 KeReleaseSpinLock(&Endpoint->EndpointSpinLock, Endpoint->EndpointOldIrql);
686
687 while (!IsListEmpty(&List))
688 {
689 //DbgBreakPoint();
690
691 Irp = CONTAINING_RECORD(List.Flink,
692 IRP,
693 Tail.Overlay.ListEntry);
694
696
697 Urb = URB_FROM_IRP(Irp);
698
699 DeviceHandle = Urb->UrbHeader.UsbdDeviceHandle;
700 InterlockedDecrement(&DeviceHandle->DeviceHandleLock);
701
703
704 DPRINT_CORE("USBPORT_FlushAbortList: complete Irp - %p\n", Irp);
705
706 Irp->IoStatus.Status = Status;
707 Irp->IoStatus.Information = 0;
709 }
710}
#define RemoveHeadList(ListHead)
Definition: env_spec_w32.h:964

Referenced by USBPORT_EndpointWorker(), and USBPORT_FlushCancelList().

◆ USBPORT_FlushAllEndpoints()

VOID NTAPI USBPORT_FlushAllEndpoints ( IN PDEVICE_OBJECT  FdoDevice)

Definition at line 1171 of file queue.c.

1172{
1175 PUSBPORT_ENDPOINT Endpoint;
1177 KIRQL OldIrql;
1178
1179 DPRINT_CORE("USBPORT_FlushAllEndpoints: ... \n");
1180
1181 FdoExtension = FdoDevice->DeviceExtension;
1182
1183 KeAcquireSpinLock(&FdoExtension->EndpointListSpinLock, &OldIrql);
1184
1186
1187 Entry = FdoExtension->EndpointList.Flink;
1188
1189 while (Entry && Entry != &FdoExtension->EndpointList)
1190 {
1191 Endpoint = CONTAINING_RECORD(Entry,
1193 EndpointLink);
1194
1196 {
1197 InsertTailList(&List, &Endpoint->FlushLink);
1198 }
1199
1200 Entry = Endpoint->EndpointLink.Flink;
1201 }
1202
1203 KeReleaseSpinLock(&FdoExtension->EndpointListSpinLock, OldIrql);
1204
1205 while (!IsListEmpty(&List))
1206 {
1207 Endpoint = CONTAINING_RECORD(List.Flink,
1209 FlushLink);
1210
1212
1213 Endpoint->FlushLink.Flink = NULL;
1214 Endpoint->FlushLink.Blink = NULL;
1215
1216 if (!IsListEmpty(&Endpoint->PendingTransferList))
1217 {
1219 }
1220 }
1221
1222 DPRINT_CORE("USBPORT_FlushAllEndpoints: exit\n");
1223}
LIST_ENTRY FlushLink
Definition: usbport.h:236

Referenced by USBPORT_WorkerThreadHandler().

◆ USBPORT_FlushCancelList()

VOID NTAPI USBPORT_FlushCancelList ( IN PUSBPORT_ENDPOINT  Endpoint)

Definition at line 714 of file queue.c.

715{
716 PDEVICE_OBJECT FdoDevice;
718 PUSBPORT_TRANSFER Transfer;
719 PIRP Irp;
721 KIRQL PrevIrql;
722
723 DPRINT_CORE("USBPORT_FlushCancelList: ... \n");
724
725 FdoDevice = Endpoint->FdoDevice;
726 FdoExtension = FdoDevice->DeviceExtension;
727
728 KeAcquireSpinLock(&FdoExtension->FlushTransferSpinLock, &OldIrql);
729 KeAcquireSpinLockAtDpcLevel(&Endpoint->EndpointSpinLock);
730
731 while (!IsListEmpty(&Endpoint->CancelList))
732 {
733 Transfer = CONTAINING_RECORD(Endpoint->CancelList.Flink,
735 TransferLink);
736
737 RemoveHeadList(&Endpoint->CancelList);
738
739 Irp = Transfer->Irp;
740
741 if (Irp)
742 {
743 DPRINT("USBPORT_FlushCancelList: Irp - %p\n", Irp);
744
745 IoAcquireCancelSpinLock(&PrevIrql);
747 IoReleaseCancelSpinLock(PrevIrql);
748
750 }
751
752 KeReleaseSpinLockFromDpcLevel(&Endpoint->EndpointSpinLock);
753 KeReleaseSpinLock(&FdoExtension->FlushTransferSpinLock, OldIrql);
754
755 if (Endpoint->Flags & ENDPOINT_FLAG_NUKE)
756 {
758 }
759 else
760 {
761 if (Transfer->Flags & TRANSFER_FLAG_DEVICE_GONE)
762 {
765 }
766 else
767 {
770 }
771 }
772
773 KeAcquireSpinLock(&FdoExtension->FlushTransferSpinLock, &OldIrql);
774 KeAcquireSpinLockAtDpcLevel(&Endpoint->EndpointSpinLock);
775 }
776
777 KeReleaseSpinLockFromDpcLevel(&Endpoint->EndpointSpinLock);
778 KeReleaseSpinLock(&FdoExtension->FlushTransferSpinLock, OldIrql);
779
780 USBPORT_FlushAbortList(Endpoint);
781}
#define USBD_STATUS_DEVICE_GONE
Definition: usb.h:210
#define USBD_STATUS_CANCELED
Definition: usb.h:213

Referenced by USBPORT_AbortEndpoint(), USBPORT_DmaEndpointWorker(), USBPORT_KillEndpointActiveTransfers(), and USBPORT_RootHubEndpointWorker().

◆ USBPORT_FlushClosedEndpointList()

VOID NTAPI USBPORT_FlushClosedEndpointList ( IN PDEVICE_OBJECT  FdoDevice)

Definition at line 1281 of file endpoint.c.

1282{
1284 KIRQL OldIrql;
1285 PLIST_ENTRY ClosedList;
1286 PUSBPORT_ENDPOINT Endpoint;
1287
1288 DPRINT_CORE("USBPORT_FlushClosedEndpointList: ... \n");
1289
1290 FdoExtension = FdoDevice->DeviceExtension;
1291
1292 KeAcquireSpinLock(&FdoExtension->EndpointClosedSpinLock, &OldIrql);
1293 ClosedList = &FdoExtension->EndpointClosedList;
1294
1295 while (!IsListEmpty(ClosedList))
1296 {
1297 Endpoint = CONTAINING_RECORD(ClosedList->Flink,
1299 CloseLink);
1300
1301 RemoveHeadList(ClosedList);
1302 Endpoint->CloseLink.Flink = NULL;
1303 Endpoint->CloseLink.Blink = NULL;
1304
1305 KeReleaseSpinLock(&FdoExtension->EndpointClosedSpinLock, OldIrql);
1306
1307 USBPORT_DeleteEndpoint(FdoDevice, Endpoint);
1308
1309 KeAcquireSpinLock(&FdoExtension->EndpointClosedSpinLock, &OldIrql);
1310 }
1311
1312 KeReleaseSpinLock(&FdoExtension->EndpointClosedSpinLock, OldIrql);
1313}
BOOLEAN NTAPI USBPORT_DeleteEndpoint(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint)
Definition: endpoint.c:498
LIST_ENTRY CloseLink
Definition: usbport.h:234

Referenced by USBPORT_WorkerThreadHandler().

◆ USBPORT_FlushController()

VOID NTAPI USBPORT_FlushController ( IN PDEVICE_OBJECT  FdoDevice)

Definition at line 1259 of file queue.c.

1260{
1263 PUSBPORT_ENDPOINT Endpoint;
1264 ULONG KilledTransfers;
1265 PLIST_ENTRY EndpointList;
1266 KIRQL OldIrql;
1268
1269 DPRINT_CORE("USBPORT_FlushController \n");
1270
1271 FdoExtension = FdoDevice->DeviceExtension;
1272
1273 EndpointList = &FdoExtension->EndpointList;
1274
1275 while (TRUE)
1276 {
1277 KeAcquireSpinLock(&FdoExtension->EndpointListSpinLock, &OldIrql);
1278
1280
1281 Entry = EndpointList->Flink;
1282
1283 if (!IsListEmpty(EndpointList))
1284 {
1285 while (Entry && Entry != EndpointList)
1286 {
1287 Endpoint = CONTAINING_RECORD(Entry,
1289 EndpointLink);
1290
1291 if (Endpoint->StateLast != USBPORT_ENDPOINT_REMOVE &&
1293 {
1296 }
1297
1298 Entry = Endpoint->EndpointLink.Flink;
1299 }
1300 }
1301
1302 KeReleaseSpinLock(&FdoExtension->EndpointListSpinLock, OldIrql);
1303
1304 KilledTransfers = 0;
1305 while (!IsListEmpty(&FlushList))
1306 {
1307 Endpoint = CONTAINING_RECORD(FlushList.Flink,
1309 FlushControllerLink);
1310
1312
1313 KilledTransfers += USBPORT_KillEndpointActiveTransfers(FdoDevice,
1314 Endpoint);
1315
1317 }
1318
1319 if (!KilledTransfers)
1320 break;
1321
1322 USBPORT_Wait(FdoDevice, 100);
1323 }
1324}
PSINGLE_LIST_ENTRY FlushList(PSINGLE_LIST_ENTRY ListHead)
Definition: ExSingleList.c:24
ULONG NTAPI USBPORT_KillEndpointActiveTransfers(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint)
Definition: queue.c:1227
LIST_ENTRY FlushControllerLink
Definition: usbport.h:237

Referenced by USBPORT_SuspendController().

◆ USBPORT_FlushMapTransfers()

VOID NTAPI USBPORT_FlushMapTransfers ( IN PDEVICE_OBJECT  FdoDevice)

Definition at line 2483 of file usbport.c.

2484{
2486 PLIST_ENTRY MapTransferList;
2487 PUSBPORT_TRANSFER Transfer;
2488 ULONG NumMapRegisters;
2489 PMDL Mdl;
2490 SIZE_T TransferBufferLength;
2491 ULONG_PTR VirtualAddr;
2492 KIRQL OldIrql;
2494 PDMA_OPERATIONS DmaOperations;
2495
2496 DPRINT_CORE("USBPORT_FlushMapTransfers: ...\n");
2497
2498 FdoExtension = FdoDevice->DeviceExtension;
2499 DmaOperations = FdoExtension->DmaAdapter->DmaOperations;
2500
2502
2503 while (TRUE)
2504 {
2505 MapTransferList = &FdoExtension->MapTransferList;
2506
2507 if (IsListEmpty(&FdoExtension->MapTransferList))
2508 {
2510 return;
2511 }
2512
2513 Transfer = CONTAINING_RECORD(MapTransferList->Flink,
2515 TransferLink);
2516
2517 RemoveHeadList(MapTransferList);
2518
2519 Mdl = Transfer->Urb->UrbControlTransfer.TransferBufferMDL;
2520 TransferBufferLength = Transfer->TransferParameters.TransferBufferLength;
2521 VirtualAddr = (ULONG_PTR)MmGetMdlVirtualAddress(Mdl);
2522
2523 NumMapRegisters = ADDRESS_AND_SIZE_TO_SPAN_PAGES(VirtualAddr,
2524 TransferBufferLength);
2525
2526 Transfer->NumberOfMapRegisters = NumMapRegisters;
2527
2528 Status = DmaOperations->AllocateAdapterChannel(FdoExtension->DmaAdapter,
2529 FdoDevice,
2530 NumMapRegisters,
2532 Transfer);
2533
2534 if (!NT_SUCCESS(Status))
2535 ASSERT(FALSE);
2536 }
2537
2539}
PALLOCATE_ADAPTER_CHANNEL AllocateAdapterChannel
Definition: iotypes.h:2637
USBPORT_TRANSFER_PARAMETERS TransferParameters
Definition: usbport.h:254
IO_ALLOCATION_ACTION NTAPI USBPORT_MapTransfer(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp, IN PVOID MapRegisterBase, IN PVOID Context)
Definition: usbport.c:2308

Referenced by USBPORT_AbortTransfers(), and USBPORT_FlushPendingTransfers().

◆ USBPORT_FlushPendingTransfers()

VOID NTAPI USBPORT_FlushPendingTransfers ( IN PUSBPORT_ENDPOINT  Endpoint)

Definition at line 785 of file queue.c.

786{
787 PDEVICE_OBJECT FdoDevice;
789 BOOLEAN IsMapTransfer;
790 BOOLEAN IsEnd = FALSE;
792 PUSBPORT_TRANSFER Transfer;
793 PURB Urb;
794 PIRP Irp;
797
798 DPRINT_CORE("USBPORT_FlushPendingTransfers: Endpoint - %p\n", Endpoint);
799
800 FdoDevice = Endpoint->FdoDevice;
801 FdoExtension = FdoDevice->DeviceExtension;
802
803 if (InterlockedCompareExchange(&Endpoint->FlushPendingLock, 1, 0))
804 {
805 DPRINT_CORE("USBPORT_FlushPendingTransfers: Endpoint Locked \n");
806 return;
807 }
808
809 while (TRUE)
810 {
811 IsMapTransfer = 0;
812
813 KeAcquireSpinLock(&FdoExtension->FlushPendingTransferSpinLock,
814 &OldIrql);
815
816 KeAcquireSpinLockAtDpcLevel(&Endpoint->EndpointSpinLock);
817
819 {
820 IsEnd = TRUE;
821
822 KeReleaseSpinLockFromDpcLevel(&Endpoint->EndpointSpinLock);
823 KeReleaseSpinLock(&FdoExtension->FlushPendingTransferSpinLock,
824 OldIrql);
825 goto Next;
826 }
827
828 if (!(Endpoint->Flags & ENDPOINT_FLAG_ROOTHUB_EP0))
829 {
830 if (!IsListEmpty(&Endpoint->TransferList))
831 {
832 List = Endpoint->TransferList.Flink;
833
834 while (List && List != &Endpoint->TransferList)
835 {
836 Transfer = CONTAINING_RECORD(List,
838 TransferLink);
839
840 if (!(Transfer->Flags & TRANSFER_FLAG_SUBMITED))
841 {
842 KeReleaseSpinLockFromDpcLevel(&Endpoint->EndpointSpinLock);
843 KeReleaseSpinLock(&FdoExtension->FlushPendingTransferSpinLock,
844 OldIrql);
845
846 IsEnd = TRUE;
847 goto Worker;
848 }
849
850 List = Transfer->TransferLink.Flink;
851 }
852 }
853 }
854
855 List = Endpoint->PendingTransferList.Flink;
856
857 if (List == NULL || IsListEmpty(&Endpoint->PendingTransferList))
858 {
859 KeReleaseSpinLockFromDpcLevel(&Endpoint->EndpointSpinLock);
860 KeReleaseSpinLock(&FdoExtension->FlushPendingTransferSpinLock,
861 OldIrql);
862
863 IsEnd = TRUE;
864 goto Worker;
865 }
866
867 Transfer = CONTAINING_RECORD(List,
869 TransferLink);
870
871 if (Transfer->Irp)
872 {
873 DPRINT_CORE("USBPORT_FlushPendingTransfers: Transfer->Irp->CancelRoutine - %p\n",
874 Transfer->Irp->CancelRoutine);
875 }
876
877 if (Transfer->Irp &&
878 (IoSetCancelRoutine(Transfer->Irp, NULL) == NULL))
879 {
880 DPRINT_CORE("USBPORT_FlushPendingTransfers: Transfer->Irp - %p\n",
881 Transfer->Irp);
882
883 Transfer = NULL;
884 IsEnd = TRUE;
885 }
886
887 if (!Transfer)
888 {
889 KeReleaseSpinLockFromDpcLevel(&Endpoint->EndpointSpinLock);
890 KeReleaseSpinLock(&FdoExtension->FlushPendingTransferSpinLock,
891 OldIrql);
892
893 if (IsMapTransfer)
894 {
895 USBPORT_FlushMapTransfers(FdoDevice);
896 goto Next;
897 }
898
899 goto Worker;
900 }
901
902 Irp = Transfer->Irp;
903 Urb = Transfer->Urb;
904
905 RemoveEntryList(&Transfer->TransferLink);
906 Transfer->TransferLink.Flink = NULL;
907 Transfer->TransferLink.Blink = NULL;
908
909 if (Irp)
910 {
912 }
913
914 KeReleaseSpinLockFromDpcLevel(&Endpoint->EndpointSpinLock);
915 KeReleaseSpinLock(&FdoExtension->FlushPendingTransferSpinLock,
916 OldIrql);
917
918 KeAcquireSpinLock(&FdoExtension->FlushTransferSpinLock, &OldIrql);
919
920 if (Irp)
921 {
923
924 if (Irp->Cancel && IoSetCancelRoutine(Irp, NULL))
925 {
926 DPRINT_CORE("USBPORT_FlushPendingTransfers: irp - %p\n", Irp);
927
928 KeReleaseSpinLock(&FdoExtension->FlushTransferSpinLock,
929 OldIrql);
930
932 goto Worker;
933 }
934
935 USBPORT_FindUrbInIrpTable(FdoExtension->ActiveIrpTable, Urb, Irp);
936 USBPORT_InsertIrpInTable(FdoExtension->ActiveIrpTable, Irp);
937 }
938
939 IsMapTransfer = USBPORT_QueueActiveUrbToEndpoint(Endpoint, Urb);
940
941 KeReleaseSpinLock(&FdoExtension->FlushTransferSpinLock, OldIrql);
942
943 if (IsMapTransfer)
944 {
945 USBPORT_FlushMapTransfers(FdoDevice);
946 goto Next;
947 }
948
949Worker:
953
954 if (Result)
956 Endpoint,
958
959Next:
960 if (IsEnd)
961 {
962 InterlockedDecrement(&Endpoint->FlushPendingLock);
963 DPRINT_CORE("USBPORT_FlushPendingTransfers: Endpoint Unlocked. Exit\n");
964 return;
965 }
966 }
967}
VOID NTAPI USBPORT_CancelActiveTransferIrp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: queue.c:529
VOID NTAPI USBPORT_InsertIrpInTable(IN PUSBPORT_IRP_TABLE IrpTable, IN PIRP Irp)
Definition: queue.c:266
PIRP NTAPI USBPORT_RemovePendingTransferIrp(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp)
Definition: queue.c:369
VOID NTAPI USBPORT_FindUrbInIrpTable(IN PUSBPORT_IRP_TABLE IrpTable, IN PURB Urb, IN PIRP Irp)
Definition: queue.c:381
BOOLEAN NTAPI USBPORT_QueueActiveUrbToEndpoint(IN PUSBPORT_ENDPOINT Endpoint, IN PURB Urb)
Definition: queue.c:988
#define InterlockedCompareExchange
Definition: interlocked.h:104
VOID NTAPI USBPORT_FlushMapTransfers(IN PDEVICE_OBJECT FdoDevice)
Definition: usbport.c:2483
#define USBPORT_FLAG_HC_SUSPEND
Definition: usbport.h:71

Referenced by USBPORT_AbortEndpoint(), USBPORT_DpcHandler(), USBPORT_FlushAllEndpoints(), USBPORT_KillEndpointActiveTransfers(), and USBPORT_QueueTransferUrb().

◆ USBPORT_FreeBandwidthUSB2()

VOID NTAPI USBPORT_FreeBandwidthUSB2 ( IN PDEVICE_OBJECT  FdoDevice,
IN PUSBPORT_ENDPOINT  Endpoint 
)

Definition at line 2040 of file usb2.c.

2042{
2044 ULONG Period;
2045 ULONG ScheduleOffset;
2046 ULONG EndpointBandwidth;
2047 LIST_ENTRY RebalanceList;
2048 ULONG TransferType;
2049 PUSB2_REBALANCE Rebalance;
2050 ULONG RebalanceListEntries;
2051 ULONG Factor;
2052 ULONG ix;
2053 ULONG n;
2054 PUSB2_TT_EXTENSION TtExtension;
2055 PUSB2_TT_ENDPOINT RebalanceTtEndpoint;
2056
2057 DPRINT("USBPORT_FreeBandwidthUSB2: Endpoint - %p\n", Endpoint);
2058
2059 FdoExtension = FdoDevice->DeviceExtension;
2060
2061 Period = Endpoint->EndpointProperties.Period;
2062 ScheduleOffset = Endpoint->EndpointProperties.ScheduleOffset;
2063 EndpointBandwidth = Endpoint->EndpointProperties.UsbBandwidth;
2064
2065 InitializeListHead(&RebalanceList);
2066
2067 TransferType = Endpoint->EndpointProperties.TransferType;
2068
2069 if (TransferType == USBPORT_TRANSFER_TYPE_CONTROL ||
2070 TransferType == USBPORT_TRANSFER_TYPE_BULK ||
2071 (Endpoint->Flags & ENDPOINT_FLAG_ROOTHUB_EP0))
2072 {
2073 return;
2074 }
2075
2077 sizeof(USB2_REBALANCE),
2078 USB_PORT_TAG);
2079
2080 if (!Rebalance)
2081 {
2082 DPRINT1("USBPORT_FreeBandwidthUSB2: Rebalance == NULL!\n");
2083 return;
2084 }
2085
2086 RtlZeroMemory(Rebalance, sizeof(USB2_REBALANCE));
2087
2088 ASSERT(Period != 0);
2089 Factor = USB2_FRAMES / Period;
2090 n = ScheduleOffset * Factor;
2091
2092 TtExtension = Endpoint->TtExtension;
2093
2094 if (TtExtension)
2095 {
2096 for (ix = 0; ix < Factor; ix++)
2097 {
2098 TtExtension->Bandwidth[n + ix] += EndpointBandwidth;
2099 }
2100 }
2101 else
2102 {
2103 for (ix = 1; ix < Factor; ix++)
2104 {
2105 FdoExtension->Bandwidth[n + ix] += EndpointBandwidth;
2106 }
2107 }
2108
2109 RebalanceListEntries = USB2_FRAMES - 2;
2110
2111 USB2_DeallocateEndpointBudget(Endpoint->TtEndpoint,
2112 Rebalance,
2113 &RebalanceListEntries,
2114 USB2_FRAMES);
2115
2116 RebalanceListEntries = 0;
2117
2118 for (ix = 0; Rebalance->RebalanceEndpoint[ix]; ix++)
2119 {
2120 RebalanceListEntries = ix + 1;
2121 }
2122
2123 for (ix = 0; ix < RebalanceListEntries; ix++)
2124 {
2125 RebalanceTtEndpoint = Rebalance->RebalanceEndpoint[ix];
2126
2127 DPRINT("USBPORT_AllocateBandwidthUSB2: RebalanceTtEndpoint[%X] - %p, RebalanceTtEndpoint - %p, RebalanceLink - %p\n",
2128 ix,
2129 RebalanceTtEndpoint,
2130 &RebalanceTtEndpoint->Endpoint->RebalanceLink);
2131
2132 InsertTailList(&RebalanceList,
2133 &RebalanceTtEndpoint->Endpoint->RebalanceLink);
2134 }
2135
2136 ExFreePoolWithTag(Rebalance, USB_PORT_TAG);
2137
2138 USB2_Rebalance(FdoDevice, &RebalanceList);
2139
2140 if (!TtExtension)
2141 return;
2142
2143 for (ix = 0; ix < USB2_FRAMES; ix++)
2144 {
2145 FdoExtension->Bandwidth[ix] += TtExtension->MaxBandwidth;
2146 }
2147
2148 USBPORT_UpdateAllocatedBwTt(TtExtension);
2149
2150 for (ix = 0; ix < USB2_FRAMES; ix++)
2151 {
2152 FdoExtension->Bandwidth[ix] -= TtExtension->MaxBandwidth;
2153 }
2154
2155 DPRINT1("USBPORT_FreeBandwidthUSB2: exit\n");
2156}
BOOLEAN NTAPI USB2_DeallocateEndpointBudget(IN PUSB2_TT_ENDPOINT TtEndpoint, IN PUSB2_REBALANCE Rebalance, IN PULONG RebalanceListEntries, IN ULONG MaxFrames)
Definition: usb2.c:1026

Referenced by USBPORT_ClosePipe(), and USBPORT_OpenPipe().

◆ USBPORT_FreeCommonBuffer()

VOID NTAPI USBPORT_FreeCommonBuffer ( IN PDEVICE_OBJECT  FdoDevice,
IN PUSBPORT_COMMON_BUFFER_HEADER  HeaderBuffer 
)

Definition at line 1770 of file usbport.c.

1772{
1774 PDMA_ADAPTER DmaAdapter;
1775 PDMA_OPERATIONS DmaOperations;
1776
1777 DPRINT("USBPORT_FreeCommonBuffer: ...\n");
1778
1779 FdoExtension = FdoDevice->DeviceExtension;
1780
1781 DmaAdapter = FdoExtension->DmaAdapter;
1782 DmaOperations = DmaAdapter->DmaOperations;
1783
1784 DmaOperations->FreeCommonBuffer(FdoExtension->DmaAdapter,
1785 HeaderBuffer->Length,
1786 HeaderBuffer->LogicalAddress,
1787 (PVOID)HeaderBuffer->VirtualAddress,
1788 TRUE);
1789}
PFREE_COMMON_BUFFER FreeCommonBuffer
Definition: iotypes.h:2636

Referenced by USBPORT_DeleteEndpoint(), USBPORT_ReopenPipe(), and USBPORT_StartDevice().

◆ USBPORT_GetEndpointState()

ULONG NTAPI USBPORT_GetEndpointState ( IN PUSBPORT_ENDPOINT  Endpoint)

Definition at line 332 of file endpoint.c.

333{
334 ULONG State;
335
336 //DPRINT("USBPORT_GetEndpointState \n");
337
338 KeAcquireSpinLockAtDpcLevel(&Endpoint->StateChangeSpinLock);
339
340 if (Endpoint->StateLast != Endpoint->StateNext)
341 {
343 }
344 else
345 {
346 State = Endpoint->StateLast;
347 }
348
349 KeReleaseSpinLockFromDpcLevel(&Endpoint->StateChangeSpinLock);
350
352 {
353 DPRINT("USBPORT_GetEndpointState: Endpoint - %p, State - %x\n",
354 Endpoint,
355 State);
356 }
357
358 return State;
359}
#define USBPORT_ENDPOINT_UNKNOWN
Definition: usbmport.h:13

Referenced by USBPORT_DmaEndpointPaused(), USBPORT_DmaEndpointWorker(), USBPORT_DpcHandler(), USBPORT_EndpointWorker(), USBPORT_FlushAllEndpoints(), USBPORT_InvalidateEndpointHandler(), USBPORT_OpenPipe(), and USBPORT_SyncResetPipeAndClearStall().

◆ USBPORT_GetRegistryKeyValueFullInfo()

NTSTATUS NTAPI USBPORT_GetRegistryKeyValueFullInfo ( IN PDEVICE_OBJECT  FdoDevice,
IN PDEVICE_OBJECT  PdoDevice,
IN BOOL  UseDriverKey,
IN PCWSTR  SourceString,
IN ULONG  LengthStr,
IN PVOID  Buffer,
IN ULONG  NumberOfBytes 
)

Definition at line 296 of file usbport.c.

303{
308 ULONG LengthKey;
309
310 DPRINT("USBPORT_GetRegistryKeyValue: UseDriverKey - %x, SourceString - %S, LengthStr - %x, Buffer - %p, BufferLength - %x\n",
311 UseDriverKey,
313 LengthStr,
314 Buffer,
316
317 if (UseDriverKey)
318 {
322 &KeyHandle);
323 }
324 else
325 {
329 &KeyHandle);
330 }
331
332 if (NT_SUCCESS(Status))
333 {
335
336 LengthKey = sizeof(KEY_VALUE_FULL_INFORMATION) +
337 LengthStr +
339
341 LengthKey,
343
344 if (KeyValue)
345 {
346 RtlZeroMemory(KeyValue, LengthKey);
347
348 Status = ZwQueryValueKey(KeyHandle,
349 &ValueName,
351 KeyValue,
352 LengthKey,
353 &LengthKey);
354
355 if (NT_SUCCESS(Status))
356 {
358 (PUCHAR)KeyValue + KeyValue->DataOffset,
360 }
361
363 }
364
366 }
367
368 return Status;
369}
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4715
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
_Out_ _Inout_ POEM_STRING _In_ PCUNICODE_STRING SourceString
Definition: rtlfuncs.h:1910
struct _KEY_VALUE_FULL_INFORMATION KEY_VALUE_FULL_INFORMATION
@ KeyValueFullInformation
Definition: nt_native.h:1181
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define STANDARD_RIGHTS_ALL
Definition: nt_native.h:69
NTSTATUS NTAPI IoOpenDeviceRegistryKey(IN PDEVICE_OBJECT DeviceObject, IN ULONG DevInstKeyType, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DevInstRegKey)
Definition: pnpmgr.c:1621
unsigned char * PUCHAR
Definition: typedefs.h:53
#define PLUGPLAY_REGKEY_DRIVER
Definition: usbd.c:42
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
Definition: wdfregistry.h:243
#define PLUGPLAY_REGKEY_DEVICE
Definition: iofuncs.h:2786

Referenced by USBHI_GetExtendedHubInformation(), USBPORT_GetMiniportRegistryKeyValue(), USBPORT_IsSelectiveSuspendEnabled(), and USBPORT_StartDevice().

◆ USBPORT_GetSymbolicName()

NTSTATUS NTAPI USBPORT_GetSymbolicName ( IN PDEVICE_OBJECT  RootHubPdo,
IN PUNICODE_STRING  DestinationString 
)

Definition at line 62 of file ioctl.c.

64{
66 PUNICODE_STRING RootHubName;
68 SIZE_T LengthName;
71 WCHAR Character;
72
73 DPRINT("USBPORT_GetSymbolicName: ... \n");
74
75 PdoExtension = RootHubPdo->DeviceExtension;
76 RootHubName = &PdoExtension->CommonExtension.SymbolicLinkName;
77 Buffer = RootHubName->Buffer;
78
79 if (!Buffer)
80 {
82 }
83
84 LengthName = RootHubName->Length;
85
87
88 if (!SourceString)
89 {
92 }
93
94 RtlZeroMemory(SourceString, LengthName);
95
96 if (*Buffer == L'\\')
97 {
98 Buffer += 1;
99
100 if (*Buffer == L'\\')
101 {
102 Buffer += 1;
103 goto Exit;
104 }
105
106 Character = *Buffer;
107
108 do
109 {
110 if (Character == UNICODE_NULL)
111 {
112 break;
113 }
114
115 Buffer += 1;
116 Character = *Buffer;
117 }
118 while (*Buffer != L'\\');
119
120 if (*Buffer == L'\\')
121 {
122 Buffer += 1;
123 }
124
125Exit:
126 Length = (ULONG_PTR)Buffer - (ULONG_PTR)RootHubName->Buffer;
127 }
128 else
129 {
130 Length = 0;
131 }
132
134 (PVOID)((ULONG_PTR)RootHubName->Buffer + Length),
135 RootHubName->Length - Length);
136
138
139 DPRINT("USBPORT_RegisterDeviceInterface: DestinationString - %wZ\n",
141
142 return STATUS_SUCCESS;
143}
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1909
#define UNICODE_NULL
#define L(x)
Definition: ntvdm.h:50
uint16_t * PWCHAR
Definition: typedefs.h:56
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by USBHI_GetRootHubSymbolicName(), and USBPORT_UserGetRootHubName().

◆ USBPORT_GetUsbDescriptor()

NTSTATUS NTAPI USBPORT_GetUsbDescriptor ( IN PUSBPORT_DEVICE_HANDLE  DeviceHandle,
IN PDEVICE_OBJECT  FdoDevice,
IN UCHAR  Type,
IN PUCHAR  ConfigDesc,
IN PULONG  ConfigDescSize 
)

Definition at line 1425 of file device.c.

1430{
1432
1433 DPRINT("USBPORT_GetUsbDescriptor: Type - %x\n");
1434
1436
1437 SetupPacket.bmRequestType.Dir = BMREQUEST_DEVICE_TO_HOST;
1439 SetupPacket.wValue.HiByte = Type;
1440 SetupPacket.wLength = (USHORT)*ConfigDescSize;
1441
1443 FdoDevice,
1444 &SetupPacket,
1445 ConfigDesc,
1446 *ConfigDescSize,
1447 ConfigDescSize,
1448 NULL);
1449}
Type
Definition: Type.h:7

Referenced by USBHI_GetUsbDescriptors().

◆ USBPORT_HandleSelectConfiguration()

NTSTATUS NTAPI USBPORT_HandleSelectConfiguration ( IN PDEVICE_OBJECT  FdoDevice,
IN PIRP  Irp,
IN PURB  Urb 
)

Definition at line 574 of file device.c.

577{
580 PUSBPORT_CONFIGURATION_HANDLE ConfigHandle = NULL;
581 PUSBD_INTERFACE_INFORMATION InterfaceInfo;
582 PUSBPORT_INTERFACE_HANDLE InterfaceHandle;
583 ULONG iNumber;
584 ULONG ix;
587 USBD_STATUS USBDStatus;
589
590 DPRINT("USBPORT_HandleSelectConfiguration: ConfigDescriptor %p\n",
591 Urb->UrbSelectConfiguration.ConfigurationDescriptor);
592
593 FdoExtension = FdoDevice->DeviceExtension;
594
595 KeWaitForSingleObject(&FdoExtension->DeviceSemaphore,
596 Executive,
598 FALSE,
599 NULL);
600
601 DeviceHandle = Urb->UrbHeader.UsbdDeviceHandle;
602 ConfigDescriptor = Urb->UrbSelectConfiguration.ConfigurationDescriptor;
603
604 if (!ConfigDescriptor)
605 {
606 DPRINT("USBPORT_HandleSelectConfiguration: ConfigDescriptor == NULL\n");
607
609
610 SetupPacket.bmRequestType.B = 0;
612 SetupPacket.wValue.W = 0;
613 SetupPacket.wIndex.W = 0;
614 SetupPacket.wLength = 0;
615
617 FdoDevice,
619 NULL,
620 0,
621 NULL,
622 NULL);
623
625 goto Exit;
626 }
627
629
630 InterfaceInfo = &Urb->UrbSelectConfiguration.Interface;
631
632 iNumber = 0;
633
634 do
635 {
636 ++iNumber;
637 InterfaceInfo = (PUSBD_INTERFACE_INFORMATION)
638 ((ULONG_PTR)InterfaceInfo +
639 InterfaceInfo->Length);
640 }
641 while ((ULONG_PTR)InterfaceInfo < (ULONG_PTR)Urb + Urb->UrbHeader.Length);
642
643 if ((iNumber <= 0) || (iNumber != ConfigDescriptor->bNumInterfaces))
644 {
647 goto Exit;
648 }
649
650 ConfigHandle = ExAllocatePoolWithTag(NonPagedPool,
651 ConfigDescriptor->wTotalLength + sizeof(USBPORT_CONFIGURATION_HANDLE),
653
654 if (!ConfigHandle)
655 {
658 goto Exit;
659 }
660
661 RtlZeroMemory(ConfigHandle,
662 ConfigDescriptor->wTotalLength + sizeof(USBPORT_CONFIGURATION_HANDLE));
663
665
666 ConfigHandle->ConfigurationDescriptor = (PUSB_CONFIGURATION_DESCRIPTOR)(ConfigHandle + 1);
667
671
673
674 SetupPacket.bmRequestType.B = 0;
676 SetupPacket.wValue.W = ConfigDescriptor->bConfigurationValue;
677 SetupPacket.wIndex.W = 0;
678 SetupPacket.wLength = 0;
679
681 FdoDevice,
683 NULL,
684 0,
685 NULL,
686 &USBDStatus);
687
688 if (USBD_ERROR(USBDStatus))
689 {
692 goto Exit;
693 }
694
695 if (iNumber <= 0)
696 {
699
700 goto Exit;
701 }
702
703 InterfaceInfo = &Urb->UrbSelectConfiguration.Interface;
704
705 for (ix = 0; ix < iNumber; ++ix)
706 {
707 USBDStatus = USBPORT_InitInterfaceInfo(InterfaceInfo,
708 ConfigHandle);
709
710 InterfaceHandle = NULL;
711
712 if (USBD_SUCCESS(USBDStatus))
713 {
714 USBDStatus = USBPORT_OpenInterface(Urb,
716 FdoDevice,
717 ConfigHandle,
718 InterfaceInfo,
719 &InterfaceHandle,
720 TRUE);
721 }
722
723 if (InterfaceHandle)
724 {
725 InsertTailList(&ConfigHandle->InterfaceHandleList,
726 &InterfaceHandle->InterfaceLink);
727 }
728
729 if (USBD_ERROR(USBDStatus))
730 break;
731
732 InterfaceInfo = (PUSBD_INTERFACE_INFORMATION)
733 ((ULONG_PTR)InterfaceInfo +
734 InterfaceInfo->Length);
735 }
736
737 if (ix >= iNumber)
738 {
741 }
742 else
743 {
744 Status = USBPORT_USBDStatusToNtStatus(Urb, USBDStatus);
745 }
746
747Exit:
748
749 if (NT_SUCCESS(Status))
750 {
751 Urb->UrbSelectConfiguration.ConfigurationHandle = ConfigHandle;
752 DeviceHandle->ConfigHandle = ConfigHandle;
753 }
754 else
755 {
756 DPRINT1("USBPORT_HandleSelectConfiguration: Status %x\n", Status);
757 }
758
759 KeReleaseSemaphore(&FdoExtension->DeviceSemaphore,
761 1,
762 FALSE);
763
764 return Status;
765}
VOID NTAPI USBPORT_DumpingConfiguration(IN PUSB_CONFIGURATION_DESCRIPTOR ConfigDescriptor)
Definition: debug.c:105
NTSTATUS NTAPI USBPORT_InitInterfaceInfo(IN PUSBD_INTERFACE_INFORMATION InterfaceInfo, IN PUSBPORT_CONFIGURATION_HANDLE ConfigHandle)
Definition: device.c:499
USBD_STATUS NTAPI USBPORT_OpenInterface(IN PURB Urb, IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_CONFIGURATION_HANDLE ConfigHandle, IN PUSBD_INTERFACE_INFORMATION InterfaceInfo, IN OUT PUSBPORT_INTERFACE_HANDLE *iHandle, IN BOOLEAN SendSetInterface)
Definition: device.c:246
PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor
Definition: usbport.h:172
LIST_ENTRY InterfaceHandleList
Definition: usbport.h:173
LIST_ENTRY InterfaceLink
Definition: usbport.h:178
struct _USB_CONFIGURATION_DESCRIPTOR * PUSB_CONFIGURATION_DESCRIPTOR
#define USB_REQUEST_SET_CONFIGURATION
Definition: usb100.h:85
struct _USBD_INTERFACE_INFORMATION * PUSBD_INTERFACE_INFORMATION
#define USBD_STATUS_SET_CONFIG_FAILED
Definition: usb.h:205
#define USBD_ERROR(Status)
Definition: usb.h:169
#define USBD_SUCCESS(Status)
Definition: usb.h:167
#define USBD_STATUS_INVALID_CONFIGURATION_DESCRIPTOR
Definition: usb.h:203

Referenced by USBPORT_HandleSubmitURB().

◆ USBPORT_HandleSelectInterface()

NTSTATUS NTAPI USBPORT_HandleSelectInterface ( IN PDEVICE_OBJECT  FdoDevice,
IN PIRP  Irp,
IN PURB  Urb 
)

Definition at line 1486 of file device.c.

1489{
1493 PUSBPORT_INTERFACE_HANDLE InterfaceHandle;
1496 USBD_STATUS USBDStatus;
1497 USHORT Length;
1498 ULONG ix;
1500
1501 DPRINT("USBPORT_HandleSelectInterface: ... \n");
1502
1503 FdoExtension = FdoDevice->DeviceExtension;
1504
1505 KeWaitForSingleObject(&FdoExtension->DeviceSemaphore,
1506 Executive,
1507 KernelMode,
1508 FALSE,
1509 NULL);
1510
1511 ConfigurationHandle = Urb->UrbSelectInterface.ConfigurationHandle;
1512
1513 Interface = &Urb->UrbSelectInterface.Interface;
1514
1515 Length = Interface->Length + sizeof(USBD_PIPE_INFORMATION);
1516 Urb->UrbHeader.Length = Length;
1517
1519
1520 if (USBDStatus)
1521 {
1522 Interface->InterfaceHandle = (USBD_INTERFACE_HANDLE)-1;
1523 return USBPORT_USBDStatusToNtStatus(Urb, USBDStatus);
1524 }
1525
1526 DeviceHandle = Urb->UrbHeader.UsbdDeviceHandle;
1527
1529 Interface->InterfaceNumber);
1530
1531 if (InterfaceHandle)
1532 {
1533 RemoveEntryList(&InterfaceHandle->InterfaceLink);
1534
1535 if (InterfaceHandle->InterfaceDescriptor.bNumEndpoints)
1536 {
1537 PipeHandle = &InterfaceHandle->PipeHandle[0];
1538
1539 for (ix = 0;
1540 ix < InterfaceHandle->InterfaceDescriptor.bNumEndpoints;
1541 ix++)
1542 {
1544 PipeHandle += 1;
1545 }
1546 }
1547 }
1548
1549 iHandle = 0;
1550
1551 USBDStatus = USBPORT_OpenInterface(Urb,
1553 FdoDevice,
1555 Interface,
1556 &iHandle,
1557 TRUE);
1558
1559 if (USBDStatus)
1560 {
1561 Interface->InterfaceHandle = (USBD_INTERFACE_HANDLE)-1;
1562 }
1563 else
1564 {
1565 if (InterfaceHandle)
1566 ExFreePoolWithTag(InterfaceHandle, USB_PORT_TAG);
1567
1568 Interface->InterfaceHandle = iHandle;
1569
1570 InsertTailList(&ConfigurationHandle->InterfaceHandleList,
1571 &iHandle->InterfaceLink);
1572 }
1573
1574 KeReleaseSemaphore(&FdoExtension->DeviceSemaphore,
1576 1,
1577 FALSE);
1578
1579 return USBPORT_USBDStatusToNtStatus(Urb, USBDStatus);
1580}
PUSBPORT_INTERFACE_HANDLE NTAPI USBPORT_GetInterfaceHandle(IN PUSBPORT_CONFIGURATION_HANDLE ConfigurationHandle, IN UCHAR InterfaceNumber)
Definition: device.c:1453
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE ConfigurationHandle
Definition: ndis.h:3945
USBPORT_PIPE_HANDLE PipeHandle[1]
Definition: usbport.h:183
USB_INTERFACE_DESCRIPTOR InterfaceDescriptor
Definition: usbport.h:181
struct _USBD_PIPE_INFORMATION USBD_PIPE_INFORMATION
PVOID USBD_INTERFACE_HANDLE
Definition: usb.h:231
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
Definition: wdffdo.h:465

Referenced by USBPORT_HandleSubmitURB().

◆ USBPORT_HandleSubmitURB()

NTSTATUS NTAPI USBPORT_HandleSubmitURB ( IN PDEVICE_OBJECT  PdoDevice,
IN PIRP  Irp,
IN PURB  Urb 
)

Definition at line 791 of file urb.c.

794{
796 PDEVICE_OBJECT FdoDevice;
801
802 ASSERT(Urb);
803
804 PdoExtension = PdoDevice->DeviceExtension;
805 FdoDevice = PdoExtension->FdoDevice;
806 FdoExtension = FdoDevice->DeviceExtension;
807
808 Urb->UrbHeader.Status = USBD_STATUS_SUCCESS;
809 Urb->UrbHeader.UsbdFlags = 0;
810
811 Function = Urb->UrbHeader.Function;
812
814 {
817
818 DPRINT1("USBPORT_HandleSubmitURB: Unknown URB function - %x !!!\n",
819 Function);
820
821 return Status;
822 }
823
825 {
826 DPRINT1("USBPORT_HandleSubmitURB: Bad Request\n");
827
829
830 Irp->IoStatus.Status = STATUS_PENDING;
832 IoCsqInsertIrp(&FdoExtension->BadRequestIoCsq, Irp, NULL);
833
834 return STATUS_PENDING;
835 }
836
837 DeviceHandle = Urb->UrbHeader.UsbdDeviceHandle;
838
839 if (!DeviceHandle)
840 {
841 DeviceHandle = &PdoExtension->DeviceHandle;
842 Urb->UrbHeader.UsbdDeviceHandle = DeviceHandle;
843 }
844
847 {
848 DPRINT1("USBPORT_HandleSubmitURB: Not valid device handle\n");
849
850 Irp->IoStatus.Status = STATUS_PENDING;
852 IoCsqInsertIrp(&FdoExtension->BadRequestIoCsq, Irp, NULL);
853
854 return STATUS_PENDING;
855 }
856
857 InterlockedIncrement(&DeviceHandle->DeviceHandleLock);
858
859 DPRINT_URB("USBPORT_HandleSubmitURB: Function - 0x%02X, DeviceHandle - %p\n",
860 Function,
861 Urb->UrbHeader.UsbdDeviceHandle);
862
863 switch (Function)
864 {
866 DPRINT1("USBPORT_HandleSubmitURB: URB_FUNCTION_ISOCH_TRANSFER UNIMPLEMENTED. FIXME. \n");
867 break;
868
871 Status = USBPORT_ValidateURB(FdoDevice, Irp, Urb, FALSE, FALSE);
872
873 if (!NT_SUCCESS(Status))
874 {
875 DPRINT1("USBPORT_HandleSubmitURB: Not valid URB\n");
876 break;
877 }
878
880 break;
881
890 Status = USBPORT_ValidateURB(FdoDevice, Irp, Urb, TRUE, FALSE);
891
892 if (!NT_SUCCESS(Status))
893 {
894 DPRINT1("USBPORT_HandleSubmitURB: Not valid URB\n");
895 break;
896 }
897
899 break;
900
907 Status = USBPORT_ValidateURB(FdoDevice, Irp, Urb, TRUE, FALSE);
908
909 if (!NT_SUCCESS(Status))
910 {
911 DPRINT1("USBPORT_HandleSubmitURB: Not valid URB\n");
912 break;
913 }
914
916 break;
917
918 case URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR:
919 DPRINT1("USBPORT_HandleSubmitURB: URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR (0x2A) NOT_SUPPORTED\n");
922
927 Status = USBPORT_ValidateURB(FdoDevice, Irp, Urb, TRUE, FALSE);
928
929 if (!NT_SUCCESS(Status))
930 {
931 DPRINT1("USBPORT_HandleSubmitURB: Not valid URB\n");
932 break;
933 }
934
936 break;
937
940 Irp,
941 Urb);
942 break;
943
946 Irp,
947 Urb);
948 break;
949
951 Status = USBPORT_ValidateURB(FdoDevice, Irp, Urb, TRUE, FALSE);
952
953 if (!NT_SUCCESS(Status))
954 {
955 DPRINT1("USBPORT_HandleSubmitURB: Not valid URB\n");
956 break;
957 }
958
960 break;
961
963 DPRINT1("USBPORT_HandleSubmitURB: URB_FUNCTION_GET_INTERFACE (0x27) NOT_SUPPORTED\n");
966
969 Irp,
970 Urb);
971 break;
972
973 case URB_FUNCTION_SYNC_RESET_PIPE:
975 Irp,
976 Urb);
977 break;
978
979 case URB_FUNCTION_SYNC_CLEAR_STALL:
981 Irp,
982 Urb);
983 break;
984
987 Irp,
988 Urb);
989 break;
990
998 Status = USBPORT_ValidateURB(FdoDevice, Irp, Urb, TRUE, TRUE);
999
1000 if (!NT_SUCCESS(Status))
1001 {
1002 DPRINT1("USBPORT_HandleSubmitURB: Not valid URB\n");
1003 break;
1004 }
1005
1007 break;
1008
1011 Irp,
1012 Urb);
1013 break;
1014
1016 DPRINT1("USBPORT_HandleSubmitURB: URB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL (0x03) NOT_SUPPORTED\n");
1018
1020 DPRINT1("USBPORT_HandleSubmitURB: URB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL (0x04) NOT_SUPPORTED\n");
1022
1024 DPRINT1("USBPORT_HandleSubmitURB: URB_FUNCTION_GET_FRAME_LENGTH (0x05) NOT_SUPPORTED\n");
1026
1028 DPRINT1("USBPORT_HandleSubmitURB: URB_FUNCTION_SET_FRAME_LENGTH (0x06) NOT_SUPPORTED\n");
1030
1031 default:
1032 DPRINT1("USBPORT_HandleSubmitURB: Unknown URB Function - %x\n",
1033 Function);
1034 //URB_FUNCTION_RESERVED_0X0016
1035 //URB_FUNCTION_RESERVE_0X001D
1036 //URB_FUNCTION_RESERVE_0X002B
1037 //URB_FUNCTION_RESERVE_0X002C
1038 //URB_FUNCTION_RESERVE_0X002D
1039 //URB_FUNCTION_RESERVE_0X002E
1040 //URB_FUNCTION_RESERVE_0X002F
1041 break;
1042 }
1043
1044 if (Status == STATUS_PENDING)
1045 {
1046 return Status;
1047 }
1048
1049 if (Urb->UrbHeader.UsbdFlags & USBD_FLAG_ALLOCATED_TRANSFER)
1050 {
1051 PUSBPORT_TRANSFER Transfer;
1052
1053 Transfer = Urb->UrbControlTransfer.hca.Reserved8[0];
1054 Urb->UrbControlTransfer.hca.Reserved8[0] = NULL;
1055 Urb->UrbHeader.UsbdFlags |= ~USBD_FLAG_ALLOCATED_TRANSFER;
1057 }
1058
1059 InterlockedDecrement(&DeviceHandle->DeviceHandleLock);
1060
1061 Irp->IoStatus.Status = Status;
1063
1064 return Status;
1065}
_In_ CDROM_SCAN_FOR_SPECIAL_INFO _In_ PCDROM_SCAN_FOR_SPECIAL_HANDLER Function
Definition: cdrom.h:1156
NTSTATUS NTAPI USBPORT_HandleSelectConfiguration(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp, IN PURB Urb)
Definition: device.c:574
NTSTATUS NTAPI USBPORT_HandleSelectInterface(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp, IN PURB Urb)
Definition: device.c:1486
IoMarkIrpPending(Irp)
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
NTSTATUS NTAPI USBPORT_HandleVendorOrClass(IN PIRP Irp, IN PURB Urb)
Definition: urb.c:479
NTSTATUS NTAPI USBPORT_HandleGetCurrentFrame(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp, IN PURB Urb)
Definition: urb.c:45
NTSTATUS NTAPI USBPORT_ClearStall(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp, IN PURB Urb)
Definition: urb.c:177
NTSTATUS NTAPI USBPORT_ResetPipe(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp, IN PURB Urb)
Definition: urb.c:114
NTSTATUS NTAPI USBPORT_AbortPipe(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp, IN PURB Urb)
Definition: urb.c:71
NTSTATUS NTAPI USBPORT_SyncResetPipeAndClearStall(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp, IN PURB Urb)
Definition: urb.c:224
NTSTATUS NTAPI USBPORT_HandleGetStatus(IN PIRP Irp, IN PURB Urb)
Definition: urb.c:412
NTSTATUS NTAPI USBPORT_HandleGetSetDescriptor(IN PIRP Irp, IN PURB Urb)
Definition: urb.c:560
NTSTATUS NTAPI USBPORT_ValidateURB(IN PDEVICE_OBJECT FdoDevice, IN PIRP Irp, IN PURB Urb, IN BOOLEAN IsControlTransfer, IN BOOLEAN IsNullTransfer)
Definition: urb.c:693
NTSTATUS NTAPI USBPORT_HandleDataTransfers(IN PURB Urb)
Definition: urb.c:384
NTSTATUS NTAPI USBPORT_HandleGetConfiguration(IN PURB Urb)
Definition: urb.c:18
NTSTATUS NTAPI USBPORT_HandleSetOrClearFeature(IN PURB Urb)
Definition: urb.c:307
#define URB_FUNCTION_CLASS_INTERFACE
Definition: usb.h:113
#define URB_FUNCTION_GET_FRAME_LENGTH
Definition: usb.h:91
#define URB_FUNCTION_SELECT_INTERFACE
Definition: usb.h:87
#define URB_FUNCTION_ABORT_PIPE
Definition: usb.h:88
#define URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT
Definition: usb.h:123
#define URB_FUNCTION_SET_FEATURE_TO_INTERFACE
Definition: usb.h:100
#define URB_FUNCTION_VENDOR_ENDPOINT
Definition: usb.h:111
#define URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE
Definition: usb.h:98
#define URB_FUNCTION_CONTROL_TRANSFER
Definition: usb.h:94
#define URB_FUNCTION_GET_STATUS_FROM_ENDPOINT
Definition: usb.h:107
#define USBD_STATUS_NOT_SUPPORTED
Definition: usb.h:202
#define URB_FUNCTION_VENDOR_DEVICE
Definition: usb.h:109
#define URB_FUNCTION_SET_FEATURE_TO_OTHER
Definition: usb.h:121
#define URB_FUNCTION_GET_CURRENT_FRAME_NUMBER
Definition: usb.h:93
#define URB_FUNCTION_SELECT_CONFIGURATION
Definition: usb.h:86
#define URB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL
Definition: usb.h:90
#define URB_FUNCTION_SET_FEATURE_TO_ENDPOINT
Definition: usb.h:101
#define URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE
Definition: usb.h:126
#define URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT
Definition: usb.h:104
#define URB_FUNCTION_CLASS_DEVICE
Definition: usb.h:112
#define URB_FUNCTION_SET_FRAME_LENGTH
Definition: usb.h:92
#define URB_FUNCTION_SET_FEATURE_TO_DEVICE
Definition: usb.h:99
#define URB_FUNCTION_GET_STATUS_FROM_INTERFACE
Definition: usb.h:106
#define URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT
Definition: usb.h:122
#define URB_FUNCTION_CLASS_OTHER
Definition: usb.h:117
#define URB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL
Definition: usb.h:89
#define URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER
Definition: usb.h:95
#define URB_FUNCTION_GET_STATUS_FROM_OTHER
Definition: usb.h:119
#define URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE
Definition: usb.h:127
#define URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL
Definition: usb.h:116
#define URB_FUNCTION_GET_CONFIGURATION
Definition: usb.h:124
#define URB_FUNCTION_CLEAR_FEATURE_TO_OTHER
Definition: usb.h:120
#define URB_FUNCTION_CLASS_ENDPOINT
Definition: usb.h:114
#define USBD_STATUS_INVALID_URB_FUNCTION
Definition: usb.h:191
#define URB_FUNCTION_GET_STATUS_FROM_DEVICE
Definition: usb.h:105
#define URB_FUNCTION_VENDOR_INTERFACE
Definition: usb.h:110
#define URB_FUNCTION_VENDOR_OTHER
Definition: usb.h:118
#define URB_FUNCTION_GET_INTERFACE
Definition: usb.h:125
#define URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE
Definition: usb.h:97
#define URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE
Definition: usb.h:103
#define USBPORT_TMFLAG_RH_SUSPENDED
Definition: usbport.h:96
#define URB_FUNCTION_MAX
Definition: usbport.h:45

Referenced by USBPORT_PdoInternalDeviceControl().

◆ USBPORT_HcQueueWakeDpc()

VOID NTAPI USBPORT_HcQueueWakeDpc ( IN PDEVICE_OBJECT  FdoDevice)

Definition at line 63 of file power.c.

64{
66
67 DPRINT("USBPORT_HcQueueWakeDpc: ... \n");
68
69 FdoExtension = FdoDevice->DeviceExtension;
71}
BOOLEAN NTAPI KeInsertQueueDpc(IN PKDPC Dpc, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: dpc.c:725

Referenced by USBPORT_InvalidateRootHub().

◆ USBPORT_HcWakeDpc()

VOID NTAPI USBPORT_HcWakeDpc ( IN PRKDPC  Dpc,
IN PVOID  DeferredContext,
IN PVOID  SystemArgument1,
IN PVOID  SystemArgument2 
)

Definition at line 52 of file power.c.

56{
57 DPRINT("USBPORT_HcWakeDpc: ... \n");
59}
VOID NTAPI USBPORT_CompletePdoWaitWake(IN PDEVICE_OBJECT FdoDevice)
Definition: power.c:15
_In_opt_ PVOID DeferredContext
Definition: ketypes.h:687

Referenced by USBPORT_StartDevice().

◆ USBPORT_IdleNotification()

NTSTATUS NTAPI USBPORT_IdleNotification ( IN PDEVICE_OBJECT  PdoDevice,
IN PIRP  Irp 
)

Definition at line 612 of file power.c.

614{
616 PDEVICE_OBJECT FdoDevice;
618 LONG LockCounter;
620
621 DPRINT("USBPORT_IdleNotification: Irp - %p\n", Irp);
622
623 PdoExtension = PdoDevice->DeviceExtension;
624 FdoDevice = PdoExtension->FdoDevice;
625 FdoExtension = FdoDevice->DeviceExtension;
626
627 LockCounter = InterlockedIncrement(&FdoExtension->IdleLockCounter);
628
629 if (LockCounter != 0)
630 {
631 if (Status != STATUS_PENDING)
632 {
633 InterlockedDecrement(&FdoExtension->IdleLockCounter);
634
635 Irp->IoStatus.Status = Status;
636 Irp->IoStatus.Information = 0;
638
639 return Status;
640 }
641
643 }
644
645 if (Status != STATUS_PENDING)
646 {
647 InterlockedDecrement(&FdoExtension->IdleLockCounter);
648
649 Irp->IoStatus.Status = Status;
650 Irp->IoStatus.Information = 0;
652
653 return Status;
654 }
655
656 Irp->IoStatus.Status = STATUS_PENDING;
658
660
661 IoCsqInsertIrp(&FdoExtension->IdleIoCsq, Irp, 0);
662
663 return Status;
664}
#define STATUS_DEVICE_BUSY
Definition: udferr_usr.h:129

Referenced by USBPORT_PdoInternalDeviceControl().

◆ USBPORT_Initialize20Hub()

NTSTATUS NTAPI USBPORT_Initialize20Hub ( IN PDEVICE_OBJECT  FdoDevice,
IN PUSBPORT_DEVICE_HANDLE  HubDeviceHandle,
IN ULONG  TtCount 
)

Definition at line 2012 of file device.c.

2015{
2017 ULONG ix;
2018
2019 DPRINT("USBPORT_Initialize20Hub: TtCount - %X\n", TtCount);
2020
2021 if (!HubDeviceHandle)
2022 {
2024 }
2025
2027 {
2028 return STATUS_SUCCESS;
2029 }
2030
2031 if (TtCount == 0)
2032 {
2033 HubDeviceHandle->TtCount = 0;
2034 return STATUS_SUCCESS;
2035 }
2036
2037 for (ix = 0; ix < TtCount; ++ix)
2038 {
2039 Status = USBPORT_InitializeTT(FdoDevice, HubDeviceHandle, ix + 1);
2040
2041 if (!NT_SUCCESS(Status))
2042 break;
2043 }
2044
2045 HubDeviceHandle->TtCount = TtCount;
2046
2047 return Status;
2048}
NTSTATUS NTAPI USBPORT_InitializeTT(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_DEVICE_HANDLE HubDeviceHandle, IN ULONG TtNumber)
Definition: device.c:1954
_In_ PUSB_DEVICE_HANDLE _In_ ULONG TtCount
Definition: hubbusif.h:240
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define DEVICE_HANDLE_FLAG_ROOTHUB
Definition: usbport.h:106

Referenced by USBHI_Initialize20Hub().

◆ USBPORT_InitializeDevice()

NTSTATUS NTAPI USBPORT_InitializeDevice ( IN PUSBPORT_DEVICE_HANDLE  DeviceHandle,
IN PDEVICE_OBJECT  FdoDevice 
)

Definition at line 1316 of file device.c.

1318{
1319 PUSBPORT_ENDPOINT Endpoint;
1321 ULONG TransferedLen;
1323 UCHAR MaxPacketSize;
1326
1327 DPRINT("USBPORT_InitializeDevice: ... \n");
1328
1330
1331 FdoExtension = FdoDevice->DeviceExtension;
1332
1333 KeWaitForSingleObject(&FdoExtension->DeviceSemaphore,
1334 Executive,
1335 KernelMode,
1336 FALSE,
1337 NULL);
1338
1341
1342 RtlZeroMemory(&CtrlSetup, sizeof(USB_DEFAULT_PIPE_SETUP_PACKET));
1343
1345 CtrlSetup.wValue.W = DeviceAddress;
1346
1348 FdoDevice,
1349 &CtrlSetup,
1350 NULL,
1351 0,
1352 NULL,
1353 NULL);
1354
1355 DPRINT("USBPORT_InitializeDevice: DeviceAddress - %x. SendSetupPacket Status - %x\n",
1357 Status);
1358
1359 if (!NT_SUCCESS(Status))
1360 goto ExitError;
1361
1362 DeviceHandle->DeviceAddress = DeviceAddress;
1363 Endpoint = DeviceHandle->PipeHandle.Endpoint;
1364
1365 Endpoint->EndpointProperties.TotalMaxPacketSize = DeviceHandle->DeviceDescriptor.bMaxPacketSize0;
1367
1368 Status = USBPORT_ReopenPipe(FdoDevice, Endpoint);
1369
1370 if (!NT_SUCCESS(Status))
1371 goto ExitError;
1372
1373 USBPORT_Wait(FdoDevice, 10);
1374
1375 RtlZeroMemory(&CtrlSetup, sizeof(USB_DEFAULT_PIPE_SETUP_PACKET));
1376
1379 CtrlSetup.wLength = sizeof(USB_DEVICE_DESCRIPTOR);
1380 CtrlSetup.bmRequestType.B = 0x80;
1381
1383 FdoDevice,
1384 &CtrlSetup,
1385 &DeviceHandle->DeviceDescriptor,
1386 sizeof(USB_DEVICE_DESCRIPTOR),
1387 &TransferedLen,
1388 NULL);
1389
1390 if (NT_SUCCESS(Status))
1391 {
1392 ASSERT(TransferedLen == sizeof(USB_DEVICE_DESCRIPTOR));
1393 ASSERT(DeviceHandle->DeviceDescriptor.bLength >= sizeof(USB_DEVICE_DESCRIPTOR));
1394 ASSERT(DeviceHandle->DeviceDescriptor.bDescriptorType == USB_DEVICE_DESCRIPTOR_TYPE);
1395
1396 MaxPacketSize = DeviceHandle->DeviceDescriptor.bMaxPacketSize0;
1397
1398 ASSERT((MaxPacketSize == 8) ||
1399 (MaxPacketSize == 16) ||
1400 (MaxPacketSize == 32) ||
1401 (MaxPacketSize == 64));
1402
1403 if (DeviceHandle->DeviceSpeed == UsbHighSpeed &&
1404 DeviceHandle->DeviceDescriptor.bDeviceClass == USB_DEVICE_CLASS_HUB)
1405 {
1407 }
1408 }
1409 else
1410 {
1411ExitError:
1412 DPRINT1("USBPORT_InitializeDevice: ExitError. Status - %x\n", Status);
1413 }
1414
1415 KeReleaseSemaphore(&FdoExtension->DeviceSemaphore,
1417 1,
1418 FALSE);
1419
1420 return Status;
1421}
ULONG NTAPI USBPORT_AllocateUsbAddress(IN PDEVICE_OBJECT FdoDevice)
Definition: device.c:1250
NTSTATUS NTAPI USBPORT_ReopenPipe(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint)
Definition: endpoint.c:1165
_In_ PUSB_DEVICE_HANDLE _Out_ PUSHORT DeviceAddress
Definition: hubbusif.h:360
union _USB_DEFAULT_PIPE_SETUP_PACKET::_wValue wValue
BM_REQUEST_TYPE bmRequestType
Definition: usb200.h:72
struct _USB_DEVICE_DESCRIPTOR USB_DEVICE_DESCRIPTOR
#define USB_DEVICE_CLASS_HUB
Definition: usb100.h:99
#define USB_REQUEST_SET_ADDRESS
Definition: usb100.h:81
#define USB_DEFAULT_DEVICE_ADDRESS
Definition: usb.h:82
#define DEVICE_HANDLE_FLAG_USB2HUB
Definition: usbport.h:108

Referenced by USBHI_InitializeUsbDevice().

◆ USBPORT_InitializeIsoTransfer()

USBD_STATUS NTAPI USBPORT_InitializeIsoTransfer ( IN PDEVICE_OBJECT  FdoDevice,
IN struct _URB_ISOCH_TRANSFER Urb,
IN PUSBPORT_TRANSFER  Transfer 
)

◆ USBPORT_InsertBadRequest()

VOID NTAPI USBPORT_InsertBadRequest ( IN PIO_CSQ  Csq,
IN PIRP  Irp 
)

Definition at line 143 of file queue.c.

145{
147
148 DPRINT_QUEUE("USBPORT_InsertBadRequest: Irp - %p\n", Irp);
149
152 BadRequestIoCsq);
153
154 InsertTailList(&FdoExtension->BadRequestList,
155 &Irp->Tail.Overlay.ListEntry);
156}

Referenced by USBPORT_StartDevice().

◆ USBPORT_InsertIdleIrp()

VOID NTAPI USBPORT_InsertIdleIrp ( IN PIO_CSQ  Csq,
IN PIRP  Irp 
)

Definition at line 20 of file queue.c.

22{
24
25 DPRINT_QUEUE("USBPORT_InsertIdleIrp: Irp - %p\n", Irp);
26
29 IdleIoCsq);
30
31 InsertTailList(&FdoExtension->IdleIrpList,
32 &Irp->Tail.Overlay.ListEntry);
33}

Referenced by USBPORT_StartDevice().

◆ USBPORT_InsertIrpInTable()

VOID NTAPI USBPORT_InsertIrpInTable ( IN PUSBPORT_IRP_TABLE  IrpTable,
IN PIRP  Irp 
)

Definition at line 266 of file queue.c.

268{
269 ULONG ix;
270
271 DPRINT_CORE("USBPORT_InsertIrpInTable: IrpTable - %p, Irp - %p\n",
272 IrpTable,
273 Irp);
274
275 ASSERT(IrpTable != NULL);
276
277 while (TRUE)
278 {
279 for (ix = 0; ix < 0x200; ix++)
280 {
281 if (IrpTable->irp[ix] == NULL)
282 {
283 IrpTable->irp[ix] = Irp;
284
285 if (ix > 0)
286 {
287 DPRINT_CORE("USBPORT_InsertIrpInTable: ix - %x\n", ix);
288 }
289
290 return;
291 }
292 }
293
294 if (ix != 0x200)
295 {
296 KeBugCheckEx(BUGCODE_USB_DRIVER, 1, 0, 0, 0);
297 }
298
299 IrpTable->LinkNextTable = ExAllocatePoolWithTag(NonPagedPool,
300 sizeof(USBPORT_IRP_TABLE),
302
303 if (IrpTable->LinkNextTable == NULL)
304 {
305 KeBugCheckEx(BUGCODE_USB_DRIVER, 1, 0, 0, 0);
306 }
307
308 RtlZeroMemory(IrpTable->LinkNextTable, sizeof(USBPORT_IRP_TABLE));
309
310 IrpTable = IrpTable->LinkNextTable;
311 }
312}

Referenced by USBPORT_FlushPendingTransfers(), and USBPORT_QueuePendingTransferIrp().

◆ USBPORT_InterruptService()

BOOLEAN NTAPI USBPORT_InterruptService ( IN PKINTERRUPT  Interrupt,
IN PVOID  ServiceContext 
)

Definition at line 1077 of file usbport.c.

1079{
1080 PDEVICE_OBJECT FdoDevice;
1084
1085 FdoDevice = ServiceContext;
1086 FdoExtension = FdoDevice->DeviceExtension;
1087 Packet = &FdoExtension->MiniPortInterface->Packet;
1088
1089 DPRINT_INT("USBPORT_InterruptService: FdoExtension[%p]->Flags - %08X\n",
1091 FdoExtension->Flags);
1092
1095 {
1096 Result = Packet->InterruptService(FdoExtension->MiniPortExt);
1097
1098 if (Result)
1099 {
1101 }
1102 }
1103
1104 DPRINT_INT("USBPORT_InterruptService: return - %x\n", Result);
1105
1106 return Result;
1107}
#define DPRINT_INT(...)
Definition: usbdebug.h:146
#define USBPORT_MPFLAG_INTERRUPTS_ENABLED
Definition: usbport.h:102
#define USBPORT_FLAG_INTERRUPT_ENABLED
Definition: usbport.h:72
_In_ PKSERVICE_ROUTINE _In_opt_ PVOID ServiceContext
Definition: iofuncs.h:801

Referenced by USBPORT_StartDevice().

◆ USBPORT_InvalidateControllerHandler()

VOID NTAPI USBPORT_InvalidateControllerHandler ( IN PDEVICE_OBJECT  FdoDevice,
IN ULONG  Type 
)

Definition at line 635 of file usbport.c.

637{
639
640 DPRINT_CORE("USBPORT_InvalidateControllerHandler: Invalidate Type - %x\n",
641 Type);
642
643 FdoExtension = FdoDevice->DeviceExtension;
644
645 switch (Type)
646 {
648 DPRINT1("USBPORT_InvalidateControllerHandler: INVALIDATE_CONTROLLER_RESET UNIMPLEMENTED. FIXME.\n");
649 break;
650
652 DPRINT1("USBPORT_InvalidateControllerHandler: INVALIDATE_CONTROLLER_SURPRISE_REMOVE UNIMPLEMENTED. FIXME.\n");
653 break;
654
656 if (InterlockedIncrement(&FdoExtension->IsrDpcCounter))
657 {
658 InterlockedDecrement(&FdoExtension->IsrDpcCounter);
659 }
660 else
661 {
662 USBPORT_SoftInterrupt(FdoDevice);
663 }
664 break;
665 }
666}
#define USBPORT_INVALIDATE_CONTROLLER_RESET
Definition: usbmport.h:489
#define USBPORT_INVALIDATE_CONTROLLER_SOFT_INTERRUPT
Definition: usbmport.h:491
VOID NTAPI USBPORT_SoftInterrupt(IN PDEVICE_OBJECT FdoDevice)
Definition: usbport.c:611

Referenced by USBPORT_FdoPnP(), and USBPORT_InvalidateController().

◆ USBPORT_InvalidateEndpointHandler()

VOID NTAPI USBPORT_InvalidateEndpointHandler ( IN PDEVICE_OBJECT  FdoDevice,
IN PUSBPORT_ENDPOINT  Endpoint,
IN ULONG  Type 
)

Definition at line 1317 of file endpoint.c.

1320{
1324 PLIST_ENTRY WorkerLink;
1326 KIRQL OldIrql;
1327 BOOLEAN IsAddEntry = FALSE;
1328
1329 DPRINT_CORE("USBPORT_InvalidateEndpointHandler: Endpoint - %p, Type - %x\n",
1330 Endpoint,
1331 Type);
1332
1333 FdoExtension = FdoDevice->DeviceExtension;
1334 Packet = &FdoExtension->MiniPortInterface->Packet;
1335
1336 if (Endpoint)
1337 {
1338 WorkerLink = &Endpoint->WorkerLink;
1339 KeAcquireSpinLock(&FdoExtension->EndpointListSpinLock, &OldIrql);
1340 DPRINT_CORE("USBPORT_InvalidateEndpointHandler: KeAcquireSpinLock \n");
1341
1342 if ((!WorkerLink->Flink || !WorkerLink->Blink) &&
1343 !(Endpoint->Flags & ENDPOINT_FLAG_IDLE) &&
1345 {
1346 DPRINT_CORE("USBPORT_InvalidateEndpointHandler: InsertTailList \n");
1347 InsertTailList(&FdoExtension->WorkerList, WorkerLink);
1348 IsAddEntry = TRUE;
1349 }
1350
1351 KeReleaseSpinLock(&FdoExtension->EndpointListSpinLock, OldIrql);
1352
1353 if (Endpoint->Flags & ENDPOINT_FLAG_ROOTHUB_EP0)
1355 }
1356 else
1357 {
1358 KeAcquireSpinLock(&FdoExtension->EndpointListSpinLock, &OldIrql);
1359
1360 for (Entry = FdoExtension->EndpointList.Flink;
1361 Entry && Entry != &FdoExtension->EndpointList;
1362 Entry = Entry->Flink)
1363 {
1366 EndpointLink);
1367
1368 if (!endpoint->WorkerLink.Flink || !endpoint->WorkerLink.Blink)
1369 {
1370 if (!(endpoint->Flags & ENDPOINT_FLAG_IDLE) &&
1371 !(endpoint->Flags & ENDPOINT_FLAG_ROOTHUB_EP0) &&
1373 {
1374 DPRINT_CORE("USBPORT_InvalidateEndpointHandler: InsertTailList \n");
1375 InsertTailList(&FdoExtension->WorkerList, &endpoint->WorkerLink);
1376 IsAddEntry = TRUE;
1377 }
1378 }
1379 }
1380
1381 KeReleaseSpinLock(&FdoExtension->EndpointListSpinLock, OldIrql);
1382 }
1383
1385 {
1387 }
1388 else if (IsAddEntry == FALSE && Type == INVALIDATE_ENDPOINT_INT_NEXT_SOF)
1389 {
1391 }
1392
1393 switch (Type)
1394 {
1396 USBPORT_SignalWorkerThread(FdoDevice);
1397 break;
1398
1400 KeInsertQueueDpc(&FdoExtension->WorkerRequestDpc, NULL, NULL);
1401 break;
1402
1404 KeAcquireSpinLock(&FdoExtension->MiniportSpinLock, &OldIrql);
1405 Packet->InterruptNextSOF(FdoExtension->MiniPortExt);
1406 KeReleaseSpinLock(&FdoExtension->MiniportSpinLock, OldIrql);
1407 break;
1408 }
1409}
Definition: nis.h:10
#define ENDPOINT_FLAG_IDLE
Definition: usbport.h:116
#define INVALIDATE_ENDPOINT_ONLY
Definition: usbport.h:36
#define INVALIDATE_ENDPOINT_WORKER_DPC
Definition: usbport.h:38

Referenced by USBPORT_AbortEndpoint(), USBPORT_CancelActiveTransferIrp(), USBPORT_DmaEndpointWorker(), USBPORT_FlushDoneTransfers(), USBPORT_FlushPendingTransfers(), USBPORT_InvalidateEndpoint(), USBPORT_InvalidateRootHub(), USBPORT_IsrDpcHandler(), USBPORT_MapTransfer(), and USBPORT_SetEndpointState().

◆ USBPORT_InvalidateRootHub()

ULONG NTAPI USBPORT_InvalidateRootHub ( PVOID  MiniPortExtension)

Definition at line 917 of file roothub.c.

918{
920 PDEVICE_OBJECT FdoDevice;
921 PDEVICE_OBJECT PdoDevice;
923 PUSBPORT_ENDPOINT Endpoint = NULL;
924
925 DPRINT("USBPORT_InvalidateRootHub ... \n");
926
927 FdoExtension = (PUSBPORT_DEVICE_EXTENSION)((ULONG_PTR)MiniPortExtension -
929
930 FdoDevice = FdoExtension->CommonExtension.SelfDevice;
931
934 FdoExtension->MiniPortFlags & USBPORT_MPFLAG_SUSPENDED &&
935 FdoExtension->TimerFlags & USBPORT_TMFLAG_WAKE)
936 {
937 USBPORT_HcQueueWakeDpc(FdoDevice);
938 return 0;
939 }
940
941 FdoExtension->MiniPortInterface->Packet.RH_DisableIrq(FdoExtension->MiniPortExt);
942
943 PdoDevice = FdoExtension->RootHubPdo;
944
945 if (PdoDevice)
946 {
947 PdoExtension = PdoDevice->DeviceExtension;
948 Endpoint = PdoExtension->Endpoint;
949
950 if (Endpoint)
951 {
953 PdoExtension->Endpoint,
955 }
956 }
957
958 return 0;
959}
VOID NTAPI USBPORT_HcQueueWakeDpc(IN PDEVICE_OBJECT FdoDevice)
Definition: power.c:63
#define USBPORT_FLAG_HC_WAKE_SUPPORT
Definition: usbport.h:76
#define USBPORT_TMFLAG_WAKE
Definition: usbport.h:98
struct _USBPORT_DEVICE_EXTENSION * PUSBPORT_DEVICE_EXTENSION
struct _USBPORT_DEVICE_EXTENSION USBPORT_DEVICE_EXTENSION
#define USBPORT_MPFLAG_SUSPENDED
Definition: usbport.h:103

Referenced by USBPORT_RegisterUSBPortDriver().

◆ USBPORT_IsrDpc()

VOID NTAPI USBPORT_IsrDpc ( IN PRKDPC  Dpc,
IN PVOID  DeferredContext,
IN PVOID  SystemArgument1,
IN PVOID  SystemArgument2 
)

Definition at line 1031 of file usbport.c.

1035{
1036 PDEVICE_OBJECT FdoDevice;
1039 BOOLEAN InterruptEnable;
1040
1041 DPRINT_INT("USBPORT_IsrDpc: DeferredContext - %p, SystemArgument2 - %p\n",
1044
1045 FdoDevice = DeferredContext;
1046 FdoExtension = FdoDevice->DeviceExtension;
1047 Packet = &FdoExtension->MiniPortInterface->Packet;
1048
1049 if (SystemArgument2)
1050 {
1051 InterlockedDecrement(&FdoExtension->IsrDpcCounter);
1052 }
1053
1054 KeAcquireSpinLockAtDpcLevel(&FdoExtension->MiniportInterruptsSpinLock);
1055 InterruptEnable = (FdoExtension->Flags & USBPORT_FLAG_INTERRUPT_ENABLED) ==
1057
1058 Packet->InterruptDpc(FdoExtension->MiniPortExt, InterruptEnable);
1059
1060 KeReleaseSpinLockFromDpcLevel(&FdoExtension->MiniportInterruptsSpinLock);
1061
1063 FdoExtension->TimerFlags & USBPORT_TMFLAG_WAKE)
1064 {
1065 USBPORT_CompletePdoWaitWake(FdoDevice);
1066 }
1067 else
1068 {
1069 USBPORT_IsrDpcHandler(FdoDevice, TRUE);
1070 }
1071
1072 DPRINT_INT("USBPORT_IsrDpc: exit\n");
1073}
VOID NTAPI USBPORT_IsrDpcHandler(IN PDEVICE_OBJECT FdoDevice, IN BOOLEAN IsDpcHandler)
Definition: usbport.c:941
_In_opt_ PVOID _In_opt_ PVOID _In_opt_ PVOID SystemArgument2
Definition: ketypes.h:689

Referenced by USBPORT_StartDevice().

◆ USBPORT_LogEntry()

ULONG NTAPI USBPORT_LogEntry ( IN PVOID  MiniPortExtension,
IN ULONG  DriverTag,
IN ULONG  EnumTag,
IN ULONG  P1,
IN ULONG  P2,
IN ULONG  P3 
)

Definition at line 60 of file debug.c.

66{
67 DPRINT_MINIPORT("USBPORT_LogEntry: MiniPortExtension - %p, EnumTag - %lx, P1 - %lx, P2 - %lx, P3 - %lx\n",
68 MiniPortExtension,
69 EnumTag,
70 P1,
71 P2,
72 P3);
73
74 return 0;
75}
#define DPRINT_MINIPORT(...)
Definition: usbdebug.h:143

Referenced by USBPORT_RegisterUSBPortDriver().

◆ USBPORT_MiniportInterrupts()

VOID NTAPI USBPORT_MiniportInterrupts ( IN PDEVICE_OBJECT  FdoDevice,
IN BOOLEAN  IsEnable 
)

Definition at line 555 of file usbport.c.

557{
560 BOOLEAN IsLock;
562
563 DPRINT_INT("USBPORT_MiniportInterrupts: IsEnable - %p\n", IsEnable);
564
565 FdoExtension = FdoDevice->DeviceExtension;
566 Packet = &FdoExtension->MiniPortInterface->Packet;
567
568 IsLock = (Packet->MiniPortFlags & USB_MINIPORT_FLAGS_NOT_LOCK_INT) == 0;
569
570 if (IsLock)
571 KeAcquireSpinLock(&FdoExtension->MiniportSpinLock, &OldIrql);
572
573 if (IsEnable)
574 {
576 Packet->EnableInterrupts(FdoExtension->MiniPortExt);
577 }
578 else
579 {
580 Packet->DisableInterrupts(FdoExtension->MiniPortExt);
581 FdoExtension->Flags &= ~USBPORT_FLAG_INTERRUPT_ENABLED;
582 }
583
584 if (IsLock)
585 KeReleaseSpinLock(&FdoExtension->MiniportSpinLock, OldIrql);
586}
#define USB_MINIPORT_FLAGS_NOT_LOCK_INT
Definition: usbmport.h:536

Referenced by USBPORT_ResumeController(), and USBPORT_StartDevice().

◆ USBPORT_NukeAllEndpoints()

VOID NTAPI USBPORT_NukeAllEndpoints ( IN PDEVICE_OBJECT  FdoDevice)

Definition at line 300 of file endpoint.c.

301{
303 PLIST_ENTRY EndpointList;
304 PUSBPORT_ENDPOINT Endpoint;
306
307 DPRINT("USBPORT_NukeAllEndpoints \n");
308
309 FdoExtension = FdoDevice->DeviceExtension;
310
311 KeAcquireSpinLock(&FdoExtension->EndpointListSpinLock, &OldIrql);
312
313 EndpointList = FdoExtension->EndpointList.Flink;
314
315 while (EndpointList && (EndpointList != &FdoExtension->EndpointList))
316 {
317 Endpoint = CONTAINING_RECORD(EndpointList,
319 EndpointLink);
320
321 if (!(Endpoint->Flags & ENDPOINT_FLAG_ROOTHUB_EP0))
322 Endpoint->Flags |= ENDPOINT_FLAG_NUKE;
323
324 EndpointList = Endpoint->EndpointLink.Flink;
325 }
326
327 KeReleaseSpinLock(&FdoExtension->EndpointListSpinLock, OldIrql);
328}

Referenced by USBPORT_ResumeController().

◆ USBPORT_OpenPipe()

NTSTATUS NTAPI USBPORT_OpenPipe ( IN PDEVICE_OBJECT  FdoDevice,
IN PUSBPORT_DEVICE_HANDLE  DeviceHandle,
IN PUSBPORT_PIPE_HANDLE  PipeHandle,
IN PUSBD_STATUS  UsbdStatus 
)

◆ USBPORT_PdoDeviceControl()

NTSTATUS NTAPI USBPORT_PdoDeviceControl ( PDEVICE_OBJECT  PdoDevice,
PIRP  Irp 
)

◆ USBPORT_PdoInternalDeviceControl()

NTSTATUS NTAPI USBPORT_PdoInternalDeviceControl ( IN PDEVICE_OBJECT  FdoDevice,
IN PIRP  Irp 
)

Definition at line 317 of file ioctl.c.

319{
321 PIO_STACK_LOCATION IoStack;
322 ULONG IoCtl;
324
325 PdoExtension = PdoDevice->DeviceExtension;
327 IoCtl = IoStack->Parameters.DeviceIoControl.IoControlCode;
328
329 //DPRINT("USBPORT_PdoInternalDeviceControl: PdoDevice - %p, Irp - %p, IoCtl - %x\n",
330 // PdoDevice,
331 // Irp,
332 // IoCtl);
333
335 {
336 return USBPORT_HandleSubmitURB(PdoDevice, Irp, URB_FROM_IRP(Irp));
337 }
338
340 {
341 DPRINT("USBPORT_PdoInternalDeviceControl: IOCTL_INTERNAL_USB_GET_ROOTHUB_PDO\n");
342
343 if (IoStack->Parameters.Others.Argument1)
344 *(PVOID *)IoStack->Parameters.Others.Argument1 = PdoDevice;
345
346 if (IoStack->Parameters.Others.Argument2)
347 *(PVOID *)IoStack->Parameters.Others.Argument2 = PdoDevice;
348
350 goto Exit;
351 }
352
354 {
355 DPRINT("USBPORT_PdoInternalDeviceControl: IOCTL_INTERNAL_USB_GET_HUB_COUNT\n");
356
357 if (IoStack->Parameters.Others.Argument1)
358 {
359 ++*(PULONG)IoStack->Parameters.Others.Argument1;
360 }
361
363 goto Exit;
364 }
365
366 if (IoCtl == IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE)
367 {
368 DPRINT("USBPORT_PdoInternalDeviceControl: IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE\n");
369
370 if (IoStack->Parameters.Others.Argument1)
371 {
372 *(PVOID *)IoStack->Parameters.Others.Argument1 = &PdoExtension->DeviceHandle;
373 }
374
376 goto Exit;
377 }
378
379 if (IoCtl == IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION)
380 {
381 DPRINT("USBPORT_PdoInternalDeviceControl: IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION\n");
382 return USBPORT_IdleNotification(PdoDevice, Irp);
383 }
384
385 DPRINT("USBPORT_PdoInternalDeviceControl: INVALID INTERNAL DEVICE CONTROL\n");
387
388Exit:
389 Irp->IoStatus.Status = Status;
391 return Status;
392}
NTSTATUS NTAPI USBPORT_IdleNotification(IN PDEVICE_OBJECT PdoDevice, IN PIRP Irp)
Definition: power.c:612
if(dx< 0)
Definition: linetemp.h:194
struct _IO_STACK_LOCATION::@3978::@4017 Others
uint32_t * PULONG
Definition: typedefs.h:59
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
NTSTATUS NTAPI USBPORT_HandleSubmitURB(IN PDEVICE_OBJECT PdoDevice, IN PIRP Irp, IN PURB Urb)
Definition: urb.c:791
#define IOCTL_INTERNAL_USB_SUBMIT_URB
Definition: usbioctl.h:32
#define IOCTL_INTERNAL_USB_GET_HUB_COUNT
Definition: usbioctl.h:50
#define IOCTL_INTERNAL_USB_GET_ROOTHUB_PDO
Definition: usbioctl.h:38

Referenced by USBPORT_Dispatch().

◆ USBPORT_PdoPnP()

NTSTATUS NTAPI USBPORT_PdoPnP ( IN PDEVICE_OBJECT  FdoDevice,
IN PIRP  Irp 
)

Definition at line 1517 of file pnp.c.

1519{
1521 PUSBPORT_COMMON_DEVICE_EXTENSION PdoCommonExtension;
1522 PDEVICE_OBJECT FdoDevice;
1524 PIO_STACK_LOCATION IoStack;
1525 UCHAR Minor;
1529
1530 PdoExtension = PdoDevice->DeviceExtension;
1531 PdoCommonExtension = &PdoExtension->CommonExtension;
1532
1533 FdoDevice = PdoExtension->FdoDevice;
1534 FdoExtension = FdoDevice->DeviceExtension;
1535
1537 Minor = IoStack->MinorFunction;
1538
1539 Status = Irp->IoStatus.Status;
1540
1541 DPRINT("USBPORT_PdoPnP: PdoDevice - %p, Minor - %x\n", PdoDevice, Minor);
1542
1543 switch (Minor)
1544 {
1546 DPRINT("IRP_MN_START_DEVICE\n");
1547
1548 Status = USBPORT_RootHubCreateDevice(FdoDevice, PdoDevice);
1549
1550 if (NT_SUCCESS(Status))
1551 {
1553 PdoDevice,
1554 &GUID_DEVINTERFACE_USB_HUB,
1555 TRUE);
1556
1557 if (NT_SUCCESS(Status))
1558 {
1559 PdoCommonExtension->DevicePowerState = PowerDeviceD0;
1560 PdoCommonExtension->PnpStateFlags = USBPORT_PNP_STATE_STARTED;
1561 }
1562 }
1563
1564 break;
1565
1567 DPRINT("USBPORT_PdoPnP: IRP_MN_QUERY_REMOVE_DEVICE\n");
1569 break;
1570
1572 DPRINT1("USBPORT_PdoPnP: IRP_MN_REMOVE_DEVICE UNIMPLEMENTED. FIXME. \n");
1573 //USBPORT_StopRootHub();
1575 break;
1576
1578 DPRINT("IRP_MN_CANCEL_REMOVE_DEVICE\n");
1580 break;
1581
1582 case IRP_MN_STOP_DEVICE:
1583 DPRINT1("USBPORT_PdoPnP: IRP_MN_STOP_DEVICE UNIMPLEMENTED. FIXME. \n");
1584 //USBPORT_StopRootHub();
1586 break;
1587
1589 DPRINT("IRP_MN_QUERY_STOP_DEVICE\n");
1591 break;
1592
1594 DPRINT("IRP_MN_CANCEL_STOP_DEVICE\n");
1596 break;
1597
1599 {
1600 PDEVICE_RELATIONS DeviceRelations;
1601
1602 DPRINT("IRP_MN_QUERY_DEVICE_RELATIONS\n");
1604 {
1605 break;
1606 }
1607
1608 DeviceRelations = ExAllocatePoolWithTag(PagedPool,
1609 sizeof(DEVICE_RELATIONS),
1610 USB_PORT_TAG);
1611
1612 if (!DeviceRelations)
1613 {
1615 Irp->IoStatus.Information = 0;
1616 break;
1617 }
1618
1619 DeviceRelations->Count = 1;
1620 DeviceRelations->Objects[0] = PdoDevice;
1621
1622 ObReferenceObject(PdoDevice);
1623
1625 Irp->IoStatus.Information = (ULONG_PTR)DeviceRelations;
1626 break;
1627 }
1628
1630 DPRINT("IRP_MN_QUERY_INTERFACE\n");
1631 Status = USBPORT_PdoQueryInterface(FdoDevice, PdoDevice, Irp);
1632 break;
1633
1635 DPRINT("IRP_MN_QUERY_CAPABILITIES\n");
1636
1637 DeviceCapabilities = IoStack->Parameters.DeviceCapabilities.Capabilities;
1638
1640 &PdoExtension->Capabilities,
1641 sizeof(DEVICE_CAPABILITIES));
1642
1644 break;
1645
1647 DPRINT("USBPORT_PdoPnP: IRP_MN_QUERY_RESOURCES\n");
1648 break;
1649
1651 DPRINT("IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n");
1652 break;
1653
1655 DPRINT("IRP_MN_QUERY_DEVICE_TEXT\n");
1656 break;
1657
1659 DPRINT("IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n");
1660 break;
1661
1662 case IRP_MN_READ_CONFIG:
1663 DPRINT("IRP_MN_READ_CONFIG\n");
1664 ASSERT(FALSE);
1665 break;
1666
1668 DPRINT("IRP_MN_WRITE_CONFIG\n");
1669 ASSERT(FALSE);
1670 break;
1671
1672 case IRP_MN_EJECT:
1673 DPRINT("IRP_MN_EJECT\n");
1674 ASSERT(FALSE);
1675 break;
1676
1677 case IRP_MN_SET_LOCK:
1678 DPRINT("IRP_MN_SET_LOCK\n");
1679 ASSERT(FALSE);
1680 break;
1681
1682 case IRP_MN_QUERY_ID:
1683 {
1684 ULONG IdType;
1685 LONG Length;
1686 WCHAR Buffer[64] = {0};
1687 PVOID Id;
1688
1690 IdType = IoStack->Parameters.QueryId.IdType;
1691
1692 DPRINT("IRP_MN_QUERY_ID/Type %x\n", IdType);
1693
1694 if (IdType == BusQueryDeviceID)
1695 {
1697 Packet = &FdoExtension->MiniPortInterface->Packet;
1698
1699 if (Packet->MiniPortFlags & USB_MINIPORT_FLAGS_USB2)
1700 {
1702 sizeof(Buffer),
1703 L"USB\\ROOT_HUB20");
1704 }
1705 else
1706 {
1708 sizeof(Buffer),
1709 L"USB\\ROOT_HUB");
1710 }
1711
1712 Length = (LONG)(wcslen(Buffer) + 1);
1713
1715 Length * sizeof(WCHAR),
1716 USB_PORT_TAG);
1717
1718 if (Id)
1719 {
1720 RtlZeroMemory(Id, Length * sizeof(WCHAR));
1721 RtlStringCbCopyW(Id, Length * sizeof(WCHAR), Buffer);
1722
1723 DPRINT("BusQueryDeviceID - %S, TotalLength - %hu\n",
1724 Id,
1725 Length);
1726 }
1727
1728 Irp->IoStatus.Information = (ULONG_PTR)Id;
1729 break;
1730 }
1731
1733 {
1734 Id = USBPORT_GetDeviceHwIds(FdoDevice,
1735 FdoExtension->VendorID,
1736 FdoExtension->DeviceID,
1737 FdoExtension->RevisionID);
1738
1739 Irp->IoStatus.Information = (ULONG_PTR)Id;
1740 break;
1741 }
1742
1745 {
1746 Irp->IoStatus.Information = 0;
1747 break;
1748 }
1749
1750 /* IdType == BusQueryDeviceSerialNumber */
1751 Status = Irp->IoStatus.Status;
1752 break;
1753 }
1754
1756 DPRINT("IRP_MN_QUERY_PNP_DEVICE_STATE\n");
1758 break;
1759
1761 DPRINT("IRP_MN_QUERY_BUS_INFORMATION\n");
1762
1763 /* Allocate buffer for bus information */
1765 sizeof(PNP_BUS_INFORMATION),
1766 USB_PORT_TAG);
1767
1768 if (!BusInformation)
1769 {
1770 /* No memory */
1772 break;
1773 }
1774
1776
1777 /* Copy BUS GUID */
1778 RtlMoveMemory(&BusInformation->BusTypeGuid,
1779 &GUID_BUS_TYPE_USB,
1780 sizeof(GUID));
1781
1782 /* Set bus type */
1783 BusInformation->LegacyBusType = PNPBus;
1784 BusInformation->BusNumber = 0;
1785
1787 Irp->IoStatus.Information = (ULONG_PTR)BusInformation;
1788 break;
1789
1791 DPRINT("IRP_MN_DEVICE_USAGE_NOTIFICATION\n");
1792 break;
1793
1795 DPRINT("USBPORT_PdoPnP: IRP_MN_SURPRISE_REMOVAL\n");
1797 break;
1798
1799 default:
1800 DPRINT("unknown IRP_MN_???\n");
1801 break;
1802 }
1803
1804 Irp->IoStatus.Status = Status;
1806 return Status;
1807}
DWORD Id
_In_ BUS_QUERY_ID_TYPE IdType
Definition: classpnp.h:374
PVOID NTAPI USBPORT_GetDeviceHwIds(IN PDEVICE_OBJECT FdoDevice, IN USHORT VendorID, IN USHORT DeviceID, IN USHORT RevisionID)
Definition: pnp.c:1407
NTSTATUS NTAPI USBPORT_RegisterDeviceInterface(IN PDEVICE_OBJECT PdoDevice, IN PDEVICE_OBJECT DeviceObject, IN CONST GUID *InterfaceClassGuid, IN BOOLEAN Enable)
Definition: pnp.c:30
@ PNPBus
Definition: hwresource.cpp:152
NTSTRSAFEAPI RtlStringCbCopyW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:174
NTSTRSAFEVAPI RtlStringCbPrintfW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1173
struct _IO_STACK_LOCATION::@3978::@4005 DeviceCapabilities
struct _IO_STACK_LOCATION::@3978::@4009 QueryId
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
NTSTATUS NTAPI USBPORT_PdoQueryInterface(IN PDEVICE_OBJECT FdoDevice, IN PDEVICE_OBJECT PdoDevice, IN PIRP Irp)
Definition: iface.c:782
NTSTATUS NTAPI USBPORT_RootHubCreateDevice(IN PDEVICE_OBJECT FdoDevice, IN PDEVICE_OBJECT PdoDevice)
Definition: roothub.c:747
_In_ WDFDEVICE _In_ PPNP_BUS_INFORMATION BusInformation
Definition: wdfdevice.h:3915
#define DeviceCapabilities
Definition: wingdi.h:4449
@ TargetDeviceRelation
Definition: iotypes.h:2156
@ BusQueryCompatibleIDs
Definition: iotypes.h:2938
@ BusQueryInstanceID
Definition: iotypes.h:2939
@ BusQueryDeviceID
Definition: iotypes.h:2936
@ BusQueryHardwareIDs
Definition: iotypes.h:2937

Referenced by USBPORT_Dispatch().

◆ USBPORT_PdoPower()

NTSTATUS NTAPI USBPORT_PdoPower ( IN PDEVICE_OBJECT  PdoDevice,
IN PIRP  Irp 
)

Definition at line 322 of file power.c.

324{
326 PDEVICE_OBJECT FdoDevice;
327 PIO_STACK_LOCATION IoStack;
331
332 DPRINT("USBPORT_PdoPower: Irp - %p\n", Irp);
333
334 PdoExtension = PdoDevice->DeviceExtension;
335 FdoDevice = PdoExtension->FdoDevice;
336 FdoExtension = FdoDevice->DeviceExtension;
338
339 Status = Irp->IoStatus.Status;
340
341 switch (IoStack->MinorFunction)
342 {
343 case IRP_MN_WAIT_WAKE:
344 DPRINT("USBPORT_PdoPower: IRP_MN_WAIT_WAKE\n");
345
347 {
348 /* The device does not support wake-up */
350 break;
351 }
352
353 KeAcquireSpinLock(&FdoExtension->PowerWakeSpinLock, &OldIrql);
354
356
357 /* Check if the IRP has been cancelled */
358 if (Irp->Cancel)
359 {
361 {
362 /* IRP has been cancelled, release cancel spinlock */
363 KeReleaseSpinLock(&FdoExtension->PowerWakeSpinLock, OldIrql);
364
365 DPRINT("USBPORT_PdoPower: IRP_MN_WAIT_WAKE - STATUS_CANCELLED\n");
366
367 /* IRP is cancelled */
369 break;
370 }
371 }
372
373 if (!PdoExtension->WakeIrp)
374 {
375 /* The driver received the IRP
376 and is waiting for the device to signal wake-up. */
377
378 DPRINT("USBPORT_PdoPower: IRP_MN_WAIT_WAKE - No WakeIrp\n");
379
381 PdoExtension->WakeIrp = Irp;
382
383 KeReleaseSpinLock(&FdoExtension->PowerWakeSpinLock, OldIrql);
384 return STATUS_PENDING;
385 }
386 else
387 {
388 /* An IRP_MN_WAIT_WAKE request is already pending and must be
389 completed or canceled before another IRP_MN_WAIT_WAKE request
390 can be issued. */
391
393 {
394 DPRINT("USBPORT_PdoPower: IRP_MN_WAIT_WAKE - STATUS_DEVICE_BUSY\n");
395
396 KeReleaseSpinLock(&FdoExtension->PowerWakeSpinLock, OldIrql);
399 break;
400 }
401 else
402 {
403 ASSERT(FALSE);
404 KeReleaseSpinLock(&FdoExtension->PowerWakeSpinLock, OldIrql);
405 return Status;
406 }
407 }
408
410 DPRINT("USBPORT_PdoPower: IRP_MN_POWER_SEQUENCE\n");
412 break;
413
414 case IRP_MN_SET_POWER:
415 DPRINT("USBPORT_PdoPower: IRP_MN_SET_POWER\n");
416
417 if (IoStack->Parameters.Power.Type == DevicePowerState)
418 {
419 DPRINT("USBPORT_PdoPower: IRP_MN_SET_POWER/DevicePowerState\n");
422 break;
423 }
424
425 DPRINT("USBPORT_PdoPower: IRP_MN_SET_POWER/SystemPowerState \n");
426
427 if (IoStack->Parameters.Power.State.SystemState == PowerSystemWorking)
428 {
429 FdoExtension->TimerFlags |= USBPORT_TMFLAG_WAKE;
430 }
431 else
432 {
433 FdoExtension->TimerFlags &= ~USBPORT_TMFLAG_WAKE;
434 }
435
437
439 break;
440
442 DPRINT("USBPORT_PdoPower: IRP_MN_QUERY_POWER\n");
445 break;
446
447 default:
448 DPRINT1("USBPORT_PdoPower: unknown IRP_MN_POWER!\n");
450 break;
451 }
452
453 Irp->IoStatus.Status = Status;
454 Irp->IoStatus.Information = 0;
456
457 return Status;
458}
NTSTATUS NTAPI USBPORT_PdoDevicePowerState(IN PDEVICE_OBJECT PdoDevice, IN PIRP Irp)
Definition: power.c:232
VOID NTAPI USBPORT_CancelPendingWakeIrp(IN PDEVICE_OBJECT PdoDevice, IN PIRP Irp)
Definition: power.c:293
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:423
#define USBPORT_FLAG_HC_STARTED
Definition: usbport.h:67

Referenced by USBPORT_Dispatch().

◆ USBPORT_PdoQueryInterface()

NTSTATUS NTAPI USBPORT_PdoQueryInterface ( IN PDEVICE_OBJECT  FdoDevice,
IN PDEVICE_OBJECT  PdoDevice,
IN PIRP  Irp 
)

Definition at line 782 of file iface.c.

785{
787 PUSB_BUS_INTERFACE_HUB_V5 InterfaceHub;
788 PUSB_BUS_INTERFACE_USBDI_V2 InterfaceDI;
789 UNICODE_STRING GuidBuffer;
791
792 DPRINT("USBPORT_PdoQueryInterface: ...\n");
793
794 if (IsEqualGUIDAligned(IoStack->Parameters.QueryInterface.InterfaceType,
795 &USB_BUS_INTERFACE_HUB_GUID))
796 {
797 /* Get request parameters */
798 InterfaceHub = (PUSB_BUS_INTERFACE_HUB_V5)IoStack->Parameters.QueryInterface.Interface;
799 InterfaceHub->Version = IoStack->Parameters.QueryInterface.Version;
800
801 /* Check version */
802 if (IoStack->Parameters.QueryInterface.Version >= 6)
803 {
804 DPRINT1("USB_BUS_INTERFACE_HUB_GUID version %x not supported!\n",
805 IoStack->Parameters.QueryInterface.Version);
806
807 return Irp->IoStatus.Status; // Version not supported
808 }
809
810 /* Interface version 0 */
811 InterfaceHub->Size = IoStack->Parameters.QueryInterface.Size;
812 InterfaceHub->BusContext = PdoDevice;
813
816
817 /* Interface version 1 */
818 if (IoStack->Parameters.QueryInterface.Version >= 1)
819 {
826 }
827
828 /* Interface version 2 */
829 if (IoStack->Parameters.QueryInterface.Version >= 2)
830 {
837 }
838
839 /* Interface version 3 */
840 if (IoStack->Parameters.QueryInterface.Version >= 3)
842
843 /* Interface version 4 */
844 if (IoStack->Parameters.QueryInterface.Version >= 4)
845 InterfaceHub->FlushTransfers = USBHI_FlushTransfers;
846
847 /* Interface version 5 */
848 if (IoStack->Parameters.QueryInterface.Version >= 5)
850
851 /* Request completed */
852 return STATUS_SUCCESS;
853 }
854 else if (IsEqualGUIDAligned(IoStack->Parameters.QueryInterface.InterfaceType,
855 &USB_BUS_INTERFACE_USBDI_GUID))
856 {
857 /* Get request parameters */
858 InterfaceDI = (PUSB_BUS_INTERFACE_USBDI_V2)IoStack->Parameters.QueryInterface.Interface;
859 InterfaceDI->Version = IoStack->Parameters.QueryInterface.Version;
860
861 /* Check version */
862 if (IoStack->Parameters.QueryInterface.Version >= 3)
863 {
864 DPRINT1("USB_BUS_INTERFACE_USBDI_GUID version %x not supported!\n",
865 IoStack->Parameters.QueryInterface.Version);
866
867 return Irp->IoStatus.Status; // Version not supported
868 }
869
870 /* Interface version 0 */
871 InterfaceDI->Size = IoStack->Parameters.QueryInterface.Size;
872 InterfaceDI->BusContext = PdoDevice;
876 InterfaceDI->QueryBusTime = USBDI_QueryBusTime;
879
880 /* Interface version 1 */
881 if (IoStack->Parameters.QueryInterface.Version >= 1)
883
884 /* Interface version 2 */
885 if (IoStack->Parameters.QueryInterface.Version >= 2)
886 InterfaceDI->EnumLogEntry = USBDI_EnumLogEntry;
887
888 return STATUS_SUCCESS;
889 }
890 else
891 {
892 /* Convert GUID to string */
893 Status = RtlStringFromGUID(IoStack->Parameters.QueryInterface.InterfaceType,
894 &GuidBuffer);
895
896 if (NT_SUCCESS(Status))
897 {
898 /* Print interface */
899 DPRINT1("HandleQueryInterface UNKNOWN INTERFACE GUID: %wZ Version %x\n",
900 &GuidBuffer,
901 IoStack->Parameters.QueryInterface.Version);
902
903 RtlFreeUnicodeString(&GuidBuffer); // Free GUID buffer
904 }
905 }
906
907 return Irp->IoStatus.Status;
908}
struct _USB_BUS_INTERFACE_HUB_V5 * PUSB_BUS_INTERFACE_HUB_V5
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
struct _IO_STACK_LOCATION::@3978::@4004 QueryInterface
PUSB_BUSIFFN_GET_DEVICE_BUSCONTEXT GetDeviceBusContext
Definition: hubbusif.h:552
PUSB_BUSIFFN_GET_EXTENDED_HUB_INFO GetExtendedHubInformation
Definition: hubbusif.h:550
PUSB_BUSIFFN_INITIALIZE_USB_DEVICE InitializeUsbDevice
Definition: hubbusif.h:542
PUSB_BUSIFFN_GET_USB_DESCRIPTORS GetUsbDescriptors
Definition: hubbusif.h:543
PUSB_BUSIFFN_FLUSH_TRANSFERS FlushTransfers
Definition: hubbusif.h:555
PUSB_BUSIFFN_GET_DEVICE_INFORMATION QueryDeviceInformation
Definition: hubbusif.h:547
PUSB_BUSIFFN_SET_DEVHANDLE_DATA SetDeviceHandleData
Definition: hubbusif.h:556
PUSB_BUSIFFN_INITIALIZE_20HUB Initialize20Hub
Definition: hubbusif.h:553
PUSB_BUSIFFN_GET_CONTROLLER_INFORMATION GetControllerInformation
Definition: hubbusif.h:548
PUSB_BUSIFFN_CONTROLLER_SELECTIVE_SUSPEND ControllerSelectiveSuspend
Definition: hubbusif.h:549
PUSB_BUSIFFN_REMOVE_USB_DEVICE RemoveUsbDevice
Definition: hubbusif.h:544
PINTERFACE_DEREFERENCE InterfaceDereference
Definition: hubbusif.h:540
PUSB_BUSIFFN_CREATE_USB_DEVICE CreateUsbDevice
Definition: hubbusif.h:541
PUSB_BUSIFFN_RESTORE_DEVICE RestoreUsbDevice
Definition: hubbusif.h:545
PINTERFACE_REFERENCE InterfaceReference
Definition: hubbusif.h:539
PUSB_BUSIFFN_ROOTHUB_INIT_NOTIFY RootHubInitNotification
Definition: hubbusif.h:554
PUSB_BUSIFFN_GET_ROOTHUB_SYM_NAME GetRootHubSymbolicName
Definition: hubbusif.h:551
PUSB_BUSIFFN_IS_DEVICE_HIGH_SPEED IsDeviceHighSpeed
Definition: usbbusif.h:116
PINTERFACE_REFERENCE InterfaceReference
Definition: usbbusif.h:110
PUSB_BUSIFFN_QUERY_BUS_TIME QueryBusTime
Definition: usbbusif.h:113
PUSB_BUSIFFN_ENUM_LOG_ENTRY EnumLogEntry
Definition: usbbusif.h:117
PUSB_BUSIFFN_SUBMIT_ISO_OUT_URB SubmitIsoOutUrb
Definition: usbbusif.h:114
PUSB_BUSIFFN_GETUSBDI_VERSION GetUSBDIVersion
Definition: usbbusif.h:112
PINTERFACE_DEREFERENCE InterfaceDereference
Definition: usbbusif.h:111
PUSB_BUSIFFN_QUERY_BUS_INFORMATION QueryBusInformation
Definition: usbbusif.h:115
NTSTATUS USB_BUSIFFN USBHI_RootHubInitNotification(IN PVOID BusContext, IN PVOID CallbackContext, IN PRH_INIT_CALLBACK CallbackFunction)
Definition: iface.c:589
NTSTATUS USB_BUSIFFN USBHI_InitializeUsbDevice(IN PVOID BusContext, OUT PUSB_DEVICE_HANDLE UsbdDeviceHandle)
Definition: iface.c:60
NTSTATUS USB_BUSIFFN USBHI_GetControllerInformation(IN PVOID BusContext, OUT PVOID ControllerInfoBuffer, IN ULONG ControllerInfoBufferLen, OUT PULONG LenDataReturned)
Definition: iface.c:307
NTSTATUS USB_BUSIFFN USBDI_SubmitIsoOutUrb(IN PVOID BusContext, IN PURB Urb)
Definition: iface.c:661
NTSTATUS USB_BUSIFFN USBHI_GetExtendedHubInformation(IN PVOID BusContext, IN PDEVICE_OBJECT HubPhysicalDeviceObject, IN OUT PVOID HubInformationBuffer, IN ULONG HubInfoLen, IN OUT PULONG LenDataReturned)
Definition: iface.c:417
NTSTATUS USB_BUSIFFN USBHI_QueryDeviceInformation(IN PVOID BusContext, IN PUSB_DEVICE_HANDLE UsbdDeviceHandle, OUT PVOID DeviceInfoBuffer, IN ULONG DeviceInfoBufferLen, OUT PULONG LenDataReturned)
Definition: iface.c:161
VOID USB_BUSIFFN USBHI_FlushTransfers(IN PVOID BusContext, OUT PUSB_DEVICE_HANDLE UsbdDeviceHandle)
Definition: iface.c:616
VOID USB_BUSIFFN USBI_InterfaceDereference(IN PVOID BusContext)
Definition: iface.c:22
NTSTATUS USB_BUSIFFN USBHI_GetRootHubSymbolicName(IN PVOID BusContext, IN OUT PVOID HubInfoBuffer, IN ULONG HubInfoBufferLen, OUT PULONG HubNameActualLen)
Definition: iface.c:523
NTSTATUS USB_BUSIFFN USBHI_ControllerSelectiveSuspend(IN PVOID BusContext, IN BOOLEAN Enable)
Definition: iface.c:361
NTSTATUS USB_BUSIFFN USBHI_GetUsbDescriptors(IN PVOID BusContext, IN PUSB_DEVICE_HANDLE UsbdDeviceHandle, IN PUCHAR DeviceDescBuffer, IN PULONG DeviceDescBufferLen, IN PUCHAR ConfigDescBuffer, IN PULONG ConfigDescBufferLen)
Definition: iface.c:77
VOID USB_BUSIFFN USBDI_GetUSBDIVersion(IN PVOID BusContext, OUT PUSBD_VERSION_INFORMATION VersionInfo, OUT PULONG HcdCapabilities)
Definition: iface.c:643
NTSTATUS USB_BUSIFFN USBHI_RemoveUsbDevice(IN PVOID BusContext, IN OUT PUSB_DEVICE_HANDLE UsbdDeviceHandle, IN ULONG Flags)
Definition: iface.c:119
VOID USB_BUSIFFN USBHI_SetDeviceHandleData(IN PVOID BusContext, IN PVOID DeviceHandle, IN PDEVICE_OBJECT UsbDevicePdo)
Definition: iface.c:632
NTSTATUS USB_BUSIFFN USBHI_Initialize20Hub(IN PVOID BusContext, IN PUSB_DEVICE_HANDLE UsbdHubDeviceHandle, IN ULONG TtCount)
Definition: iface.c:568
NTSTATUS USB_BUSIFFN USBDI_EnumLogEntry(IN PVOID BusContext, IN ULONG DriverTag, IN ULONG EnumTag, IN ULONG P1, IN ULONG P2)
Definition: iface.c:770
VOID USB_BUSIFFN USBI_InterfaceReference(IN PVOID BusContext)
Definition: iface.c:15
NTSTATUS USB_BUSIFFN USBHI_CreateUsbDevice(IN PVOID BusContext, IN OUT PUSB_DEVICE_HANDLE *UsbdDeviceHandle, IN PUSB_DEVICE_HANDLE UsbdHubDeviceHandle, IN USHORT PortStatus, IN USHORT PortNumber)
Definition: iface.c:31
NTSTATUS USB_BUSIFFN USBDI_QueryBusTime(IN PVOID BusContext, OUT PULONG CurrentFrame)
Definition: iface.c:652
PVOID USB_BUSIFFN USBHI_GetDeviceBusContext(IN PVOID BusContext, IN PVOID DeviceHandle)
Definition: iface.c:559
NTSTATUS USB_BUSIFFN USBDI_QueryBusInformation(IN PVOID BusContext, IN ULONG Level, OUT PVOID BusInfoBuffer, OUT PULONG BusInfoBufferLen, OUT PULONG BusInfoActualLen)
Definition: iface.c:670
BOOLEAN USB_BUSIFFN USBDI_IsDeviceHighSpeed(IN PVOID BusContext)
Definition: iface.c:749
NTSTATUS USB_BUSIFFN USBHI_RestoreUsbDevice(IN PVOID BusContext, OUT PUSB_DEVICE_HANDLE OldUsbdDeviceHandle, OUT PUSB_DEVICE_HANDLE NewUsbdDeviceHandle)
Definition: iface.c:140
struct _USB_BUS_INTERFACE_USBDI_V2 * PUSB_BUS_INTERFACE_USBDI_V2
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:235

Referenced by USBPORT_PdoPnP().

◆ USBPORT_PeekNextBadRequest()

PIRP NTAPI USBPORT_PeekNextBadRequest ( IN PIO_CSQ  Csq,
IN PIRP  Irp,
IN PVOID  PeekContext 
)

Definition at line 169 of file queue.c.

172{
174 PLIST_ENTRY NextEntry;
175 PLIST_ENTRY ListHead;
176 PIRP NextIrp = NULL;
177
178 DPRINT_QUEUE("USBPORT_PeekNextBadRequest: Irp - %p, PeekContext - %p\n",
179 Irp,
181
184 BadRequestIoCsq);
185
186 ListHead = &FdoExtension->BadRequestList;
187
188 if (Irp)
189 {
190 NextEntry = Irp->Tail.Overlay.ListEntry.Flink;
191 }
192 else
193 {
194 NextEntry = ListHead->Flink;
195 }
196
197 while (NextEntry != ListHead)
198 {
199 NextIrp = CONTAINING_RECORD(NextEntry,
200 IRP,
201 Tail.Overlay.ListEntry);
202
203 if (!PeekContext)
204 break;
205
206 NextEntry = NextEntry->Flink;
207 }
208
209 return NextIrp;
210}
_In_opt_ PIRP _In_opt_ PVOID PeekContext
Definition: csq.h:160

Referenced by USBPORT_StartDevice().

◆ USBPORT_PeekNextIdleIrp()

PIRP NTAPI USBPORT_PeekNextIdleIrp ( IN PIO_CSQ  Csq,
IN PIRP  Irp,
IN PVOID  PeekContext 
)

Definition at line 46 of file queue.c.

49{
51 PLIST_ENTRY NextEntry;
52 PLIST_ENTRY ListHead;
53 PIRP NextIrp = NULL;
54
55 DPRINT_QUEUE("USBPORT_PeekNextIdleIrp: Irp - %p, PeekContext - %p\n",
56 Irp,
58
61 IdleIoCsq);
62
63 ListHead = &FdoExtension->IdleIrpList;
64
65 if (Irp)
66 {
67 NextEntry = Irp->Tail.Overlay.ListEntry.Flink;
68 }
69 else
70 {
71 NextEntry = ListHead->Flink;
72 }
73
74 while (NextEntry != ListHead)
75 {
76 NextIrp = CONTAINING_RECORD(NextEntry,
77 IRP,
78 Tail.Overlay.ListEntry);
79
80 if (!PeekContext)
81 break;
82
83 NextEntry = NextEntry->Flink;
84 }
85
86 return NextIrp;
87}

Referenced by USBPORT_StartDevice().

◆ USBPORT_QueueActiveUrbToEndpoint()

BOOLEAN NTAPI USBPORT_QueueActiveUrbToEndpoint ( IN PUSBPORT_ENDPOINT  Endpoint,
IN PURB  Urb 
)

Definition at line 988 of file queue.c.

990{
991 PUSBPORT_TRANSFER Transfer;
992 PDEVICE_OBJECT FdoDevice;
996
997 DPRINT_CORE("USBPORT_QueueActiveUrbToEndpoint: Endpoint - %p, Urb - %p\n",
998 Endpoint,
999 Urb);
1000
1001 Transfer = Urb->UrbControlTransfer.hca.Reserved8[0];
1002 FdoDevice = Endpoint->FdoDevice;
1003 FdoExtension = FdoDevice->DeviceExtension;
1004
1005 KeAcquireSpinLock(&Endpoint->EndpointSpinLock,
1006 &Endpoint->EndpointOldIrql);
1007
1008 if ((Endpoint->Flags & ENDPOINT_FLAG_NUKE) ||
1009 (Transfer->Flags & TRANSFER_FLAG_ABORTED))
1010 {
1011 InsertTailList(&Endpoint->CancelList, &Transfer->TransferLink);
1012
1013 KeReleaseSpinLock(&Endpoint->EndpointSpinLock,
1014 Endpoint->EndpointOldIrql);
1015
1016 //DPRINT_CORE("USBPORT_QueueActiveUrbToEndpoint: return FALSE\n");
1017 return FALSE;
1018 }
1019
1020 if (Transfer->TransferParameters.TransferBufferLength == 0 ||
1021 !(Endpoint->Flags & ENDPOINT_FLAG_DMA_TYPE))
1022 {
1023 InsertTailList(&Endpoint->TransferList, &Transfer->TransferLink);
1024
1025 KeReleaseSpinLock(&Endpoint->EndpointSpinLock,
1026 Endpoint->EndpointOldIrql);
1027
1028 //DPRINT_CORE("USBPORT_QueueActiveUrbToEndpoint: return FALSE\n");
1029 return FALSE;
1030 }
1031
1032 KeReleaseSpinLock(&Endpoint->EndpointSpinLock, Endpoint->EndpointOldIrql);
1033
1034 KeAcquireSpinLock(&FdoExtension->MapTransferSpinLock, &OldIrql);
1035
1036 InsertTailList(&FdoExtension->MapTransferList, &Transfer->TransferLink);
1037
1038 DeviceHandle = Transfer->Urb->UrbHeader.UsbdDeviceHandle;
1039 InterlockedIncrement(&DeviceHandle->DeviceHandleLock);
1040
1041 KeReleaseSpinLock(&FdoExtension->MapTransferSpinLock, OldIrql);
1042
1043 //DPRINT_CORE("USBPORT_QueueActiveUrbToEndpoint: return TRUE\n");
1044 return TRUE;
1045}
#define ENDPOINT_FLAG_DMA_TYPE
Definition: usbport.h:111

Referenced by USBPORT_FlushPendingTransfers().

◆ USBPORT_QueueDoneTransfer()

BOOLEAN NTAPI USBPORT_QueueDoneTransfer ( IN PUSBPORT_TRANSFER  Transfer,
IN USBD_STATUS  USBDStatus 
)

Definition at line 839 of file usbport.c.

841{
842 PDEVICE_OBJECT FdoDevice;
844
845 DPRINT_CORE("USBPORT_QueueDoneTransfer: Transfer - %p, USBDStatus - %p\n",
846 Transfer,
847 USBDStatus);
848
849 FdoDevice = Transfer->Endpoint->FdoDevice;
850 FdoExtension = FdoDevice->DeviceExtension;
851
852 RemoveEntryList(&Transfer->TransferLink);
853 Transfer->USBDStatus = USBDStatus;
854
855 ExInterlockedInsertTailList(&FdoExtension->DoneTransferList,
856 &Transfer->TransferLink,
857 &FdoExtension->DoneTransferSpinLock);
858
859 return KeInsertQueueDpc(&FdoExtension->TransferFlushDpc, NULL, NULL);
860}

Referenced by USBPORT_MapTransfer(), USBPORT_MiniportCompleteTransfer(), and USBPORT_RootHubEndpointWorker().

◆ USBPORT_QueueTransferUrb()

VOID NTAPI USBPORT_QueueTransferUrb ( IN PURB  Urb)

Definition at line 1085 of file queue.c.

1086{
1087 PUSBPORT_TRANSFER Transfer;
1088 PUSBPORT_ENDPOINT Endpoint;
1089 PIRP Irp;
1092
1093 DPRINT_CORE("USBPORT_QueueTransferUrb: Urb - %p\n", Urb);
1094
1095 if (Urb->UrbControlTransfer.TransferFlags & USBD_DEFAULT_PIPE_TRANSFER)
1096 Urb->UrbHeader.Function = URB_FUNCTION_CONTROL_TRANSFER;
1097
1098 Transfer = Urb->UrbControlTransfer.hca.Reserved8[0];
1099 Parameters = &Transfer->TransferParameters;
1100
1101 Endpoint = Transfer->Endpoint;
1102 Endpoint->Flags &= ~ENDPOINT_FLAG_QUEUENE_EMPTY;
1103
1104 Parameters->TransferBufferLength = Urb->UrbControlTransfer.TransferBufferLength;
1105 Parameters->TransferFlags = Urb->UrbControlTransfer.TransferFlags;
1106
1107 Transfer->TransferBufferMDL = Urb->UrbControlTransfer.TransferBufferMDL;
1108
1109 if (Urb->UrbControlTransfer.TransferFlags & USBD_TRANSFER_DIRECTION_IN)
1110 {
1112 }
1113 else
1114 {
1116 }
1117
1119 {
1120 RtlCopyMemory(&Parameters->SetupPacket,
1121 Urb->UrbControlTransfer.SetupPacket,
1123 }
1124
1125 DPRINT_URB("... URB TransferBufferLength - %x\n",
1126 Urb->UrbControlTransfer.TransferBufferLength);
1127
1128 Urb->UrbControlTransfer.TransferBufferLength = 0;
1129
1130 Irp = Transfer->Irp;
1131
1132 if (Irp)
1133 {
1135 }
1136 else
1137 {
1138 USBPORT_QueuePendingUrbToEndpoint(Endpoint, Urb);
1139 }
1140
1141 DeviceHandle = Urb->UrbHeader.UsbdDeviceHandle;
1142 InterlockedDecrement(&DeviceHandle->DeviceHandleLock);
1143
1145
1146 DPRINT_URB("... URB TransferBufferLength - %x\n",
1147 Urb->UrbControlTransfer.TransferBufferLength);
1148
1149 if (Urb->UrbControlTransfer.TransferBufferLength)
1150 {
1151 PULONG Buffer;
1154 ULONG ix;
1155
1156 Buffer = Urb->UrbControlTransfer.TransferBuffer;
1157 BufferLength = Urb->UrbControlTransfer.TransferBufferLength;
1159
1160 DPRINT_URB("URB TransferBuffer - %p\n", Buffer);
1161
1162 for (ix = 0; (ULONG_PTR)(Buffer + ix) < BufferEnd; ix++)
1163 {
1164 DPRINT_URB("Buffer[%02X] - %p\n", ix, Buffer[ix]);
1165 }
1166 }
1167}
VOID NTAPI USBPORT_QueuePendingUrbToEndpoint(IN PUSBPORT_ENDPOINT Endpoint, IN PURB Urb)
Definition: queue.c:971
VOID NTAPI USBPORT_QueuePendingTransferIrp(IN PIRP Irp)
Definition: queue.c:1049
#define USBD_TRANSFER_DIRECTION_IN
Definition: usb.h:160
#define USBD_DEFAULT_PIPE_TRANSFER
Definition: usb.h:156
_In_ PUCHAR BufferEnd
Definition: usbdlib.h:189
#define USBPORT_DMA_DIRECTION_FROM_DEVICE
Definition: usbport.h:41
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:869

Referenced by USBPORT_HandleDataTransfers(), USBPORT_HandleGetConfiguration(), USBPORT_HandleGetSetDescriptor(), USBPORT_HandleGetStatus(), USBPORT_HandleSetOrClearFeature(), USBPORT_HandleVendorOrClass(), and USBPORT_SendSetupPacket().

◆ USBPORT_ReleaseBadRequestLock()

VOID NTAPI USBPORT_ReleaseBadRequestLock ( IN PIO_CSQ  Csq,
IN KIRQL  Irql 
)

Definition at line 230 of file queue.c.

232{
234
235 DPRINT_QUEUE("USBPORT_ReleaseBadRequestLock: ... \n");
236
239 BadRequestIoCsq);
240
241 KeReleaseSpinLock(&FdoExtension->BadRequestIoCsqSpinLock, Irql);
242}

Referenced by USBPORT_StartDevice().

◆ USBPORT_ReleaseIdleLock()

VOID NTAPI USBPORT_ReleaseIdleLock ( IN PIO_CSQ  Csq,
IN KIRQL  Irql 
)

Definition at line 107 of file queue.c.

109{
111
112 DPRINT_QUEUE("USBPORT_ReleaseIdleLock: ... \n");
113
116 IdleIoCsq);
117
118 KeReleaseSpinLock(&FdoExtension->IdleIoCsqSpinLock, Irql);
119}

Referenced by USBPORT_StartDevice().

◆ USBPORT_RemoveActiveTransferIrp()

PIRP NTAPI USBPORT_RemoveActiveTransferIrp ( IN PDEVICE_OBJECT  FdoDevice,
IN PIRP  Irp 
)

Definition at line 357 of file queue.c.

359{
361
362 DPRINT_CORE("USBPORT_RemoveActiveTransferIrp: Irp - %p\n", Irp);
363 FdoExtension = FdoDevice->DeviceExtension;
364 return USBPORT_RemoveIrpFromTable(FdoExtension->ActiveIrpTable, Irp);
365}
PIRP NTAPI USBPORT_RemoveIrpFromTable(IN PUSBPORT_IRP_TABLE IrpTable, IN PIRP Irp)
Definition: queue.c:316

Referenced by USBPORT_DoneTransfer(), and USBPORT_FlushCancelList().

◆ USBPORT_RemoveBadRequest()

VOID NTAPI USBPORT_RemoveBadRequest ( IN PIO_CSQ  Csq,
IN PIRP  Irp 
)

Definition at line 160 of file queue.c.

162{
163 DPRINT_QUEUE("USBPORT_RemoveBadRequest: Irp - %p\n", Irp);
164 RemoveEntryList(&Irp->Tail.Overlay.ListEntry);
165}

Referenced by USBPORT_StartDevice().

◆ USBPORT_RemoveDevice()

NTSTATUS NTAPI USBPORT_RemoveDevice ( IN PDEVICE_OBJECT  FdoDevice,
IN OUT PUSBPORT_DEVICE_HANDLE  DeviceHandle,
IN ULONG  Flags 
)

Definition at line 1584 of file device.c.

1587{
1589 PUSB2_TT_EXTENSION TtExtension;
1590 ULONG ix;
1591 KIRQL OldIrql;
1592
1593 DPRINT("USBPORT_RemoveDevice: DeviceHandle - %p, Flags - %x\n",
1595 Flags);
1596
1597 FdoExtension = FdoDevice->DeviceExtension;
1598
1599 if ((Flags & USBD_KEEP_DEVICE_DATA) ||
1601 {
1602 return STATUS_SUCCESS;
1603 }
1604
1605 KeWaitForSingleObject(&FdoExtension->DeviceSemaphore,
1606 Executive,
1607 KernelMode,
1608 FALSE,
1609 NULL);
1610
1612 {
1613 KeReleaseSemaphore(&FdoExtension->DeviceSemaphore,
1615 1,
1616 FALSE);
1617
1618 DPRINT1("USBPORT_RemoveDevice: Not valid device handle\n");
1620 }
1621
1623
1625
1627
1628 DPRINT("USBPORT_RemoveDevice: DeviceHandleLock - %x\n",
1629 DeviceHandle->DeviceHandleLock);
1630
1631 while (InterlockedDecrement(&DeviceHandle->DeviceHandleLock) >= 0)
1632 {
1633 InterlockedIncrement(&DeviceHandle->DeviceHandleLock);
1634 USBPORT_Wait(FdoDevice, 100);
1635 }
1636
1637 DPRINT("USBPORT_RemoveDevice: DeviceHandleLock ok\n");
1638
1639 if (DeviceHandle->ConfigHandle)
1640 {
1642 }
1643
1644 USBPORT_ClosePipe(DeviceHandle, FdoDevice, &DeviceHandle->PipeHandle);
1645
1646 if (DeviceHandle->DeviceAddress)
1647 {
1648 USBPORT_FreeUsbAddress(FdoDevice, DeviceHandle->DeviceAddress);
1649 }
1650
1651 if (!IsListEmpty(&DeviceHandle->TtList))
1652 {
1653 DPRINT1("USBPORT_RemoveDevice: DeviceHandle->TtList not empty\n");
1654 }
1655
1656 while (!IsListEmpty(&DeviceHandle->TtList))
1657 {
1658 TtExtension = CONTAINING_RECORD(DeviceHandle->TtList.Flink,
1660 Link);
1661
1662 RemoveHeadList(&DeviceHandle->TtList);
1663
1664 DPRINT("USBPORT_RemoveDevice: TtExtension - %p\n", TtExtension);
1665
1666 KeAcquireSpinLock(&FdoExtension->TtSpinLock, &OldIrql);
1667
1668 TtExtension->Flags |= USB2_TT_EXTENSION_FLAG_DELETED;
1669
1670 if (IsListEmpty(&TtExtension->EndpointList))
1671 {
1672 USBPORT_UpdateAllocatedBwTt(TtExtension);
1673
1674 for (ix = 0; ix < USB2_FRAMES; ix++)
1675 {
1676 FdoExtension->Bandwidth[ix] += TtExtension->MaxBandwidth;
1677 }
1678
1679 DPRINT("USBPORT_RemoveDevice: ExFreePoolWithTag TtExtension - %p\n", TtExtension);
1680 ExFreePoolWithTag(TtExtension, USB_PORT_TAG);
1681 }
1682
1683 KeReleaseSpinLock(&FdoExtension->TtSpinLock, OldIrql);
1684 }
1685
1686 KeReleaseSemaphore(&FdoExtension->DeviceSemaphore,
1688 1,
1689 FALSE);
1690
1692 {
1694 }
1695
1696 return STATUS_SUCCESS;
1697}
VOID NTAPI USBPORT_CloseConfiguration(IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PDEVICE_OBJECT FdoDevice)
Definition: device.c:451
VOID NTAPI USBPORT_AbortTransfers(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_DEVICE_HANDLE DeviceHandle)
Definition: device.c:871
VOID NTAPI USBPORT_FreeUsbAddress(IN PDEVICE_OBJECT FdoDevice, IN USHORT DeviceAddress)
Definition: device.c:1282
VOID NTAPI USBPORT_RemoveDeviceHandle(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_DEVICE_HANDLE DeviceHandle)
Definition: device.c:784
#define USBD_MARK_DEVICE_BUSY
Definition: hubbusif.h:30
#define USBD_KEEP_DEVICE_DATA
Definition: hubbusif.h:29
#define DEVICE_HANDLE_FLAG_REMOVED
Definition: usbport.h:107
static int Link(const char **args)
Definition: vfdcmd.c:2414
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170

Referenced by USBHI_RemoveUsbDevice().

◆ USBPORT_RemoveDeviceHandle()

VOID NTAPI USBPORT_RemoveDeviceHandle ( IN PDEVICE_OBJECT  FdoDevice,
IN PUSBPORT_DEVICE_HANDLE  DeviceHandle 
)

Definition at line 784 of file device.c.

786{
789
790 DPRINT("USBPORT_RemoveDeviceHandle \n");
791
792 FdoExtension = FdoDevice->DeviceExtension;
793
794 KeAcquireSpinLock(&FdoExtension->DeviceHandleSpinLock, &OldIrql);
795 RemoveEntryList(&DeviceHandle->DeviceHandleLink);
796 KeReleaseSpinLock(&FdoExtension->DeviceHandleSpinLock, OldIrql);
797}

Referenced by USBPORT_RemoveDevice(), and USBPORT_RestoreDevice().

◆ USBPORT_RemoveIdleIrp()

VOID NTAPI USBPORT_RemoveIdleIrp ( IN PIO_CSQ  Csq,
IN PIRP  Irp 
)

Definition at line 37 of file queue.c.

39{
40 DPRINT_QUEUE("USBPORT_RemoveIdleIrp: Irp - %p\n", Irp);
41 RemoveEntryList(&Irp->Tail.Overlay.ListEntry);
42}

Referenced by USBPORT_StartDevice().

◆ USBPORT_RemovePendingTransferIrp()

PIRP NTAPI USBPORT_RemovePendingTransferIrp ( IN PDEVICE_OBJECT  FdoDevice,
IN PIRP  Irp 
)

Definition at line 369 of file queue.c.

371{
373
374 DPRINT_CORE("USBPORT_RemovePendingTransferIrp: Irp - %p\n", Irp);
375 FdoExtension = FdoDevice->DeviceExtension;
376 return USBPORT_RemoveIrpFromTable(FdoExtension->PendingIrpTable, Irp);
377}

Referenced by USBPORT_CancelPendingTransferIrp(), and USBPORT_FlushPendingTransfers().

◆ USBPORT_RemovePipeHandle()

VOID NTAPI USBPORT_RemovePipeHandle ( IN PUSBPORT_DEVICE_HANDLE  DeviceHandle,
IN PUSBPORT_PIPE_HANDLE  PipeHandle 
)

Definition at line 456 of file endpoint.c.

458{
459 DPRINT("USBPORT_RemovePipeHandle: PipeHandle - %p\n", PipeHandle);
460
461 RemoveEntryList(&PipeHandle->PipeLink);
462
463 PipeHandle->PipeLink.Flink = NULL;
464 PipeHandle->PipeLink.Blink = NULL;
465}

Referenced by USBPORT_ClosePipe(), and USBPORT_RestoreDevice().

◆ USBPORT_RemoveUSBxFdo()

VOID NTAPI USBPORT_RemoveUSBxFdo ( IN PDEVICE_OBJECT  FdoDevice)

Definition at line 98 of file usbport.c.

99{
102
103 DPRINT("USBPORT_RemoveUSBxFdo: FdoDevice - %p\n", FdoDevice);
104
105 FdoExtension = FdoDevice->DeviceExtension;
106
108 RemoveEntryList(&FdoExtension->ControllerLink);
110
111 FdoExtension->Flags &= ~USBPORT_FLAG_REGISTERED_FDO;
112
113 FdoExtension->ControllerLink.Flink = NULL;
114 FdoExtension->ControllerLink.Blink = NULL;
115}

◆ USBPORT_ReopenPipe()

NTSTATUS NTAPI USBPORT_ReopenPipe ( IN PDEVICE_OBJECT  FdoDevice,
IN PUSBPORT_ENDPOINT  Endpoint 
)

Definition at line 1165 of file endpoint.c.

1167{
1169 PUSBPORT_COMMON_BUFFER_HEADER HeaderBuffer;
1170 USBPORT_ENDPOINT_REQUIREMENTS EndpointRequirements = {0};
1172 KIRQL MiniportOldIrql;
1174
1175 DPRINT1("USBPORT_ReopenPipe ... \n");
1176
1177 FdoExtension = FdoDevice->DeviceExtension;
1178 Packet = &FdoExtension->MiniPortInterface->Packet;
1179
1180 while (TRUE)
1181 {
1182 if (!InterlockedIncrement(&Endpoint->LockCounter))
1183 break;
1184
1185 InterlockedDecrement(&Endpoint->LockCounter);
1186 USBPORT_Wait(FdoDevice, 1);
1187 }
1188
1189 KeAcquireSpinLock(&Endpoint->EndpointSpinLock, &Endpoint->EndpointOldIrql);
1190 KeAcquireSpinLockAtDpcLevel(&FdoExtension->MiniportSpinLock);
1191
1192 Packet->SetEndpointState(FdoExtension->MiniPortExt,
1193 Endpoint + 1,
1195
1196 KeReleaseSpinLockFromDpcLevel(&FdoExtension->MiniportSpinLock);
1197 KeReleaseSpinLock(&Endpoint->EndpointSpinLock, Endpoint->EndpointOldIrql);
1198
1199 USBPORT_Wait(FdoDevice, 2);
1200
1201 MiniportCloseEndpoint(FdoDevice, Endpoint);
1202
1203 RtlZeroMemory(Endpoint + 1,
1204 Packet->MiniPortEndpointSize);
1205
1206 if (Endpoint->HeaderBuffer)
1207 {
1208 USBPORT_FreeCommonBuffer(FdoDevice, Endpoint->HeaderBuffer);
1209 Endpoint->HeaderBuffer = NULL;
1210 }
1211
1212 KeAcquireSpinLock(&FdoExtension->MiniportSpinLock, &MiniportOldIrql);
1213
1214 Packet->QueryEndpointRequirements(FdoExtension->MiniPortExt,
1215 &Endpoint->EndpointProperties,
1216 &EndpointRequirements);
1217
1218 KeReleaseSpinLock(&FdoExtension->MiniportSpinLock, MiniportOldIrql);
1219
1220 if (EndpointRequirements.HeaderBufferSize)
1221 {
1222 HeaderBuffer = USBPORT_AllocateCommonBuffer(FdoDevice,
1223 EndpointRequirements.HeaderBufferSize);
1224 }
1225 else
1226 {
1227 HeaderBuffer = NULL;
1228 }
1229
1230 if (HeaderBuffer || EndpointRequirements.HeaderBufferSize == 0)
1231 {
1232 Endpoint->HeaderBuffer = HeaderBuffer;
1234 }
1235 else
1236 {
1237 Endpoint->HeaderBuffer = 0;
1239 }
1240
1241 if (Endpoint->HeaderBuffer && HeaderBuffer)
1242 {
1243 Endpoint->EndpointProperties.BufferVA = HeaderBuffer->VirtualAddress;
1244 Endpoint->EndpointProperties.BufferPA = HeaderBuffer->PhysicalAddress;
1245 Endpoint->EndpointProperties.BufferLength = HeaderBuffer->BufferLength;
1246 }
1247
1248 if (NT_SUCCESS(Status))
1249 {
1250 MiniportOpenEndpoint(FdoDevice, Endpoint);
1251
1252 KeAcquireSpinLock(&Endpoint->EndpointSpinLock, &Endpoint->EndpointOldIrql);
1253 KeAcquireSpinLockAtDpcLevel(&Endpoint->StateChangeSpinLock);
1254
1255 if (Endpoint->StateLast == USBPORT_ENDPOINT_ACTIVE)
1256 {
1257 KeReleaseSpinLockFromDpcLevel(&Endpoint->StateChangeSpinLock);
1258 KeAcquireSpinLockAtDpcLevel(&FdoExtension->MiniportSpinLock);
1259
1260 Packet->SetEndpointState(FdoExtension->MiniPortExt,
1261 Endpoint + 1,
1263
1264 KeReleaseSpinLockFromDpcLevel(&FdoExtension->MiniportSpinLock);
1265 }
1266 else
1267 {
1268 KeReleaseSpinLockFromDpcLevel(&Endpoint->StateChangeSpinLock);
1269 }
1270
1271 KeReleaseSpinLock(&Endpoint->EndpointSpinLock, Endpoint->EndpointOldIrql);
1272 }
1273
1274 InterlockedDecrement(&Endpoint->LockCounter);
1275
1276 return Status;
1277}
MPSTATUS NTAPI MiniportOpenEndpoint(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint)
Definition: endpoint.c:722
VOID NTAPI MiniportCloseEndpoint(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint)
Definition: endpoint.c:549
PUSBPORT_COMMON_BUFFER_HEADER NTAPI USBPORT_AllocateCommonBuffer(IN PDEVICE_OBJECT FdoDevice, IN SIZE_T BufferLength)
Definition: usbport.c:1708
VOID NTAPI USBPORT_FreeCommonBuffer(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_COMMON_BUFFER_HEADER HeaderBuffer)
Definition: usbport.c:1770

Referenced by USBPORT_InitializeDevice().

◆ USBPORT_RestoreDevice()

NTSTATUS NTAPI USBPORT_RestoreDevice ( IN PDEVICE_OBJECT  FdoDevice,
IN OUT PUSBPORT_DEVICE_HANDLE  OldDeviceHandle,
IN OUT PUSBPORT_DEVICE_HANDLE  NewDeviceHandle 
)

Definition at line 1701 of file device.c.

1704{
1706 PLIST_ENTRY iHandleList;
1707 PUSBPORT_ENDPOINT Endpoint;
1708 USBPORT_ENDPOINT_REQUIREMENTS EndpointRequirements = {0};
1711 USBD_STATUS USBDStatus;
1712 KIRQL OldIrql;
1713 PUSBPORT_INTERFACE_HANDLE InterfaceHandle;
1716
1717 DPRINT("USBPORT_RestoreDevice: OldDeviceHandle - %p, NewDeviceHandle - %p\n",
1720
1721 FdoExtension = FdoDevice->DeviceExtension;
1722
1723 KeWaitForSingleObject(&FdoExtension->DeviceSemaphore,
1724 Executive,
1725 KernelMode,
1726 FALSE,
1727 NULL);
1728
1730 {
1731 KeReleaseSemaphore(&FdoExtension->DeviceSemaphore,
1733 1,
1734 FALSE);
1735
1736#ifndef NDEBUG
1737 DPRINT("USBPORT_RestoreDevice: OldDeviceHandle not valid\n");
1738 DbgBreakPoint();
1739#endif
1741 }
1742
1744 {
1745 KeReleaseSemaphore(&FdoExtension->DeviceSemaphore,
1747 1,
1748 FALSE);
1749#ifndef NDEBUG
1750 DPRINT("USBPORT_RestoreDevice: NewDeviceHandle not valid\n");
1751 DbgBreakPoint();
1752#endif
1754 }
1755
1758
1759 while (InterlockedDecrement(&OldDeviceHandle->DeviceHandleLock) >= 0)
1760 {
1761 InterlockedIncrement(&OldDeviceHandle->DeviceHandleLock);
1762 USBPORT_Wait(FdoDevice, 100);
1763 }
1764
1765 if (sizeof(USB_DEVICE_DESCRIPTOR) == RtlCompareMemory(&NewDeviceHandle->DeviceDescriptor,
1766 &OldDeviceHandle->DeviceDescriptor,
1767 sizeof(USB_DEVICE_DESCRIPTOR)))
1768 {
1769 NewDeviceHandle->ConfigHandle = OldDeviceHandle->ConfigHandle;
1770
1771 if (OldDeviceHandle->ConfigHandle)
1772 {
1774
1775 SetupPacket.bmRequestType.Dir = BMREQUEST_HOST_TO_DEVICE;
1777 SetupPacket.wValue.W = OldDeviceHandle->ConfigHandle->ConfigurationDescriptor->bConfigurationValue;
1778 SetupPacket.wIndex.W = 0;
1779 SetupPacket.wLength = 0;
1780
1782 FdoDevice,
1783 &SetupPacket,
1784 NULL,
1785 0,
1786 NULL,
1787 &USBDStatus);
1788
1789 if (USBD_ERROR(USBDStatus))
1791
1792 if (NT_SUCCESS(Status))
1793 {
1794 iHandleList = NewDeviceHandle->ConfigHandle->InterfaceHandleList.Flink;
1795
1796 while (iHandleList &&
1797 iHandleList != &NewDeviceHandle->ConfigHandle->InterfaceHandleList)
1798 {
1799 InterfaceHandle = CONTAINING_RECORD(iHandleList,
1801 InterfaceLink);
1802
1803 if (InterfaceHandle->AlternateSetting)
1804 {
1806
1807 SetupPacket.bmRequestType.Dir = BMREQUEST_HOST_TO_DEVICE;
1808 SetupPacket.bmRequestType.Type = BMREQUEST_STANDARD;
1809 SetupPacket.bmRequestType.Recipient = BMREQUEST_TO_INTERFACE;
1810
1812 SetupPacket.wValue.W = InterfaceHandle->InterfaceDescriptor.bAlternateSetting;
1813 SetupPacket.wIndex.W = InterfaceHandle->InterfaceDescriptor.bInterfaceNumber;
1814 SetupPacket.wLength = 0;
1815
1817 FdoDevice,
1818 &SetupPacket,
1819 NULL,
1820 0,
1821 NULL,
1822 &USBDStatus);
1823 }
1824
1825 iHandleList = iHandleList->Flink;
1826 }
1827 }
1828 }
1829
1831 {
1832 DPRINT1("USBPORT_RestoreDevice: FIXME Transaction Translator\n");
1833 NewDeviceHandle->TtCount = OldDeviceHandle->TtCount;
1834
1835#ifndef NDEBUG
1836 DbgBreakPoint();
1837#endif
1838 }
1839
1840 while (!IsListEmpty(&OldDeviceHandle->PipeHandleList))
1841 {
1842 PipeHandle = CONTAINING_RECORD(OldDeviceHandle->PipeHandleList.Flink,
1844 PipeLink);
1845
1846 DPRINT("USBPORT_RestoreDevice: PipeHandle - %p\n", PipeHandle);
1847
1849
1850 if (PipeHandle != &OldDeviceHandle->PipeHandle)
1851 {
1853
1855 {
1856 Endpoint = PipeHandle->Endpoint;
1857 Endpoint->DeviceHandle = NewDeviceHandle;
1858 Endpoint->EndpointProperties.DeviceAddress = NewDeviceHandle->DeviceAddress;
1859
1860 Packet = &FdoExtension->MiniPortInterface->Packet;
1861
1862 if (!(Endpoint->Flags & ENDPOINT_FLAG_NUKE))
1863 {
1864 KeAcquireSpinLock(&FdoExtension->MiniportSpinLock,
1865 &OldIrql);
1866
1867 Packet->ReopenEndpoint(FdoExtension->MiniPortExt,
1868 &Endpoint->EndpointProperties,
1869 Endpoint + 1);
1870
1871 Packet->SetEndpointDataToggle(FdoExtension->MiniPortExt,
1872 Endpoint + 1,
1873 0);
1874
1875 Packet->SetEndpointStatus(FdoExtension->MiniPortExt,
1876 Endpoint + 1,
1878
1879 KeReleaseSpinLock(&FdoExtension->MiniportSpinLock,
1880 OldIrql);
1881 }
1882 else
1883 {
1884 MiniportCloseEndpoint(FdoDevice, Endpoint);
1885
1886 RtlZeroMemory(Endpoint + 1, Packet->MiniPortEndpointSize);
1887
1890
1891 KeAcquireSpinLock(&FdoExtension->MiniportSpinLock, &OldIrql);
1892
1893 Packet->QueryEndpointRequirements(FdoExtension->MiniPortExt,
1894 &Endpoint->EndpointProperties,
1895 &EndpointRequirements);
1896
1897 KeReleaseSpinLock(&FdoExtension->MiniportSpinLock,
1898 OldIrql);
1899
1900 MiniportOpenEndpoint(FdoDevice, Endpoint);
1901
1902 Endpoint->Flags &= ~(ENDPOINT_FLAG_NUKE |
1904
1906 &Endpoint->EndpointOldIrql);
1907
1908 if (Endpoint->StateLast == USBPORT_ENDPOINT_ACTIVE)
1909 {
1910 KeAcquireSpinLockAtDpcLevel(&FdoExtension->MiniportSpinLock);
1911
1912 Packet->SetEndpointState(FdoExtension->MiniPortExt,
1913 Endpoint + 1,
1915
1916 KeReleaseSpinLockFromDpcLevel(&FdoExtension->MiniportSpinLock);
1917 }
1918
1920 Endpoint->EndpointOldIrql);
1921 }
1922 }
1923 }
1924 }
1925
1927 }
1928 else
1929 {
1930#ifndef NDEBUG
1931 DPRINT("USBPORT_RestoreDevice: New DeviceDescriptor != Old DeviceDescriptor\n");
1932 DbgBreakPoint();
1933#endif
1935 }
1936
1937 USBPORT_ClosePipe(OldDeviceHandle, FdoDevice, &OldDeviceHandle->PipeHandle);
1938
1939 if (OldDeviceHandle->DeviceAddress != 0)
1940 USBPORT_FreeUsbAddress(FdoDevice, OldDeviceHandle->DeviceAddress);
1941
1942 KeReleaseSemaphore(&FdoExtension->DeviceSemaphore,
1944 1,
1945 FALSE);
1946
1948
1949 return Status;
1950}
VOID NTAPI USBPORT_AddPipeHandle(IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PUSBPORT_PIPE_HANDLE PipeHandle)
Definition: endpoint.c:444
#define RtlCompareMemory(s1, s2, l)
Definition: env_spec_w32.h:465
_Outptr_ PUSB_DEVICE_HANDLE * NewDeviceHandle
Definition: hubbusif.h:40
_Inout_ PUSB_DEVICE_HANDLE OldDeviceHandle
Definition: hubbusif.h:161
#define BMREQUEST_TO_INTERFACE
Definition: usb100.h:39
#define BMREQUEST_STANDARD
Definition: usb100.h:34
#define USB_REQUEST_SET_INTERFACE
Definition: usb100.h:87
#define USBPORT_ENDPOINT_RUN
Definition: usbmport.h:20

Referenced by USBHI_RestoreUsbDevice().

◆ USBPORT_RootHubCreateDevice()

NTSTATUS NTAPI USBPORT_RootHubCreateDevice ( IN PDEVICE_OBJECT  FdoDevice,
IN PDEVICE_OBJECT  PdoDevice 
)

Definition at line 747 of file roothub.c.

749{
754 USBPORT_ROOT_HUB_DATA RootHubData;
755 ULONG NumMaskByte;
756 ULONG DescriptorsLength;
757 PUSBPORT_RH_DESCRIPTORS Descriptors;
758 PUSB_DEVICE_DESCRIPTOR RH_DeviceDescriptor;
759 PUSB_CONFIGURATION_DESCRIPTOR RH_ConfigurationDescriptor;
760 PUSB_INTERFACE_DESCRIPTOR RH_InterfaceDescriptor;
761 PUSB_ENDPOINT_DESCRIPTOR RH_EndPointDescriptor;
762 PUSB_HUB_DESCRIPTOR RH_HubDescriptor;
763 ULONG ix;
764 PUSB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
766
767 DPRINT("USBPORT_RootHubCreateDevice: FdoDevice - %p, PdoDevice - %p\n",
768 FdoDevice,
769 PdoDevice);
770
771 FdoExtension = FdoDevice->DeviceExtension;
772 PdoExtension = PdoDevice->DeviceExtension;
773 Packet = &FdoExtension->MiniPortInterface->Packet;
774
775 DeviceHandle = &PdoExtension->DeviceHandle;
777
778 InitializeListHead(&DeviceHandle->PipeHandleList);
779
780 DeviceHandle->IsRootHub = TRUE;
781 DeviceHandle->DeviceSpeed = UsbFullSpeed;
783
784 RtlZeroMemory(&RootHubData, sizeof(RootHubData));
785
786 Packet->RH_GetRootHubData(FdoExtension->MiniPortExt, &RootHubData);
787
788 ASSERT(RootHubData.NumberOfPorts != 0);
789 NumMaskByte = (RootHubData.NumberOfPorts - 1) / 8 + 1;
790
791 DescriptorsLength = sizeof(USB_DEVICE_DESCRIPTOR) +
795 (sizeof(USB_HUB_DESCRIPTOR) + 2 * NumMaskByte);
796
798 DescriptorsLength,
800
801 if (Descriptors)
802 {
803 RtlZeroMemory(Descriptors, DescriptorsLength);
804
805 PdoExtension->RootHubDescriptors = Descriptors;
806
807 RH_DeviceDescriptor = &PdoExtension->RootHubDescriptors->DeviceDescriptor;
808
809 RH_DeviceDescriptor->bLength = sizeof(USB_DEVICE_DESCRIPTOR);
810 RH_DeviceDescriptor->bDescriptorType = USB_DEVICE_DESCRIPTOR_TYPE;
811 RH_DeviceDescriptor->bcdUSB = 0x100;
812 RH_DeviceDescriptor->bDeviceClass = USB_DEVICE_CLASS_HUB;
813 RH_DeviceDescriptor->bDeviceSubClass = 0x01;
814 RH_DeviceDescriptor->bDeviceProtocol = 0x00;
815 RH_DeviceDescriptor->bMaxPacketSize0 = 0x08;
816 RH_DeviceDescriptor->idVendor = FdoExtension->VendorID;
817 RH_DeviceDescriptor->idProduct = FdoExtension->DeviceID;
818 RH_DeviceDescriptor->bcdDevice = FdoExtension->RevisionID;
819 RH_DeviceDescriptor->iManufacturer = 0x00;
820 RH_DeviceDescriptor->iProduct = 0x00;
821 RH_DeviceDescriptor->iSerialNumber = 0x00;
822 RH_DeviceDescriptor->bNumConfigurations = 0x01;
823
824 RH_ConfigurationDescriptor = &PdoExtension->RootHubDescriptors->ConfigDescriptor;
825
826 RH_ConfigurationDescriptor->bLength = sizeof(USB_CONFIGURATION_DESCRIPTOR);
827 RH_ConfigurationDescriptor->bDescriptorType = USB_CONFIGURATION_DESCRIPTOR_TYPE;
828
829 RH_ConfigurationDescriptor->wTotalLength = sizeof(USB_CONFIGURATION_DESCRIPTOR) +
832
833 RH_ConfigurationDescriptor->bNumInterfaces = 0x01;
834 RH_ConfigurationDescriptor->bConfigurationValue = 0x01;
835 RH_ConfigurationDescriptor->iConfiguration = 0x00;
836 RH_ConfigurationDescriptor->bmAttributes = USB_CONFIG_SELF_POWERED;
837 RH_ConfigurationDescriptor->MaxPower = 0x00;
838
839 RH_InterfaceDescriptor = &PdoExtension->RootHubDescriptors->InterfaceDescriptor;
840
841 RH_InterfaceDescriptor->bLength = sizeof(USB_INTERFACE_DESCRIPTOR);
842 RH_InterfaceDescriptor->bDescriptorType = USB_INTERFACE_DESCRIPTOR_TYPE;
843 RH_InterfaceDescriptor->bInterfaceNumber = 0x00;
844 RH_InterfaceDescriptor->bAlternateSetting = 0x00;
845 RH_InterfaceDescriptor->bNumEndpoints = 0x01;
846 RH_InterfaceDescriptor->bInterfaceClass = USB_DEVICE_CLASS_HUB;
847 RH_InterfaceDescriptor->bInterfaceSubClass = 0x01;
848 RH_InterfaceDescriptor->bInterfaceProtocol = 0x00;
849 RH_InterfaceDescriptor->iInterface = 0x00;
850
851 RH_EndPointDescriptor = &PdoExtension->RootHubDescriptors->EndPointDescriptor;
852
853 RH_EndPointDescriptor->bLength = sizeof(USB_ENDPOINT_DESCRIPTOR);
854 RH_EndPointDescriptor->bDescriptorType = USB_ENDPOINT_DESCRIPTOR_TYPE;
855 RH_EndPointDescriptor->bEndpointAddress = 0x81;
856 RH_EndPointDescriptor->bmAttributes = USB_ENDPOINT_TYPE_INTERRUPT; // SCE endpoint
857 RH_EndPointDescriptor->wMaxPacketSize = 0x0008;
858 RH_EndPointDescriptor->bInterval = 0x0C; // 12 msec
859
860 RH_HubDescriptor = &PdoExtension->RootHubDescriptors->Descriptor;
861
862 RH_HubDescriptor->bDescriptorLength = FIELD_OFFSET(USB_HUB_DESCRIPTOR, bRemoveAndPowerMask) + 2 * NumMaskByte;
863
864 if (Packet->MiniPortVersion == USB_MINIPORT_VERSION_OHCI ||
865 Packet->MiniPortVersion == USB_MINIPORT_VERSION_UHCI ||
866 Packet->MiniPortVersion == USB_MINIPORT_VERSION_EHCI)
867 {
869 }
870 else if (Packet->MiniPortVersion == USB_MINIPORT_VERSION_XHCI)
871 {
873 }
874 else
875 {
876 DPRINT1("USBPORT_RootHubCreateDevice: Unknown MiniPortVersion - %x\n",
877 Packet->MiniPortVersion);
878
880 }
881
882 RH_HubDescriptor->bNumberOfPorts = RootHubData.NumberOfPorts;
883 RH_HubDescriptor->wHubCharacteristics = RootHubData.HubCharacteristics.AsUSHORT;
884 RH_HubDescriptor->bPowerOnToPowerGood = RootHubData.PowerOnToPowerGood;
885 RH_HubDescriptor->bHubControlCurrent = RootHubData.HubControlCurrent;
886
887 for (ix = 0; ix < NumMaskByte; ix += 2)
888 {
889 RH_HubDescriptor->bRemoveAndPowerMask[ix] = 0;
890 RH_HubDescriptor->bRemoveAndPowerMask[ix + 1] = -1;
891 }
892
893 EndpointDescriptor = &DeviceHandle->PipeHandle.EndpointDescriptor;
894
895 EndpointDescriptor->bLength = sizeof(USB_ENDPOINT_DESCRIPTOR);
896 EndpointDescriptor->bDescriptorType = USB_ENDPOINT_DESCRIPTOR_TYPE;
897 EndpointDescriptor->bEndpointAddress = 0x00;
898 EndpointDescriptor->bmAttributes = USB_ENDPOINT_TYPE_CONTROL;
899 EndpointDescriptor->wMaxPacketSize = 0x0040;
900 EndpointDescriptor->bInterval = 0x00;
901
902 Status = USBPORT_OpenPipe(FdoDevice,
904 &DeviceHandle->PipeHandle,
905 NULL);
906 }
907 else
908 {
910 }
911
912 return Status;
913}
USBPORT_HUB_CHARACTERISTICS HubCharacteristics
Definition: usbmport.h:697
UCHAR bNumConfigurations
Definition: usb100.h:124
USHORT wHubCharacteristics
Definition: usb100.h:174
UCHAR bNumberOfPorts
Definition: usb100.h:173
UCHAR bHubControlCurrent
Definition: usb100.h:176
UCHAR bRemoveAndPowerMask[64]
Definition: usb100.h:177
UCHAR bDescriptorType
Definition: usb100.h:172
UCHAR bDescriptorLength
Definition: usb100.h:171
UCHAR bPowerOnToPowerGood
Definition: usb100.h:175
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
struct _USB_CONFIGURATION_DESCRIPTOR USB_CONFIGURATION_DESCRIPTOR
#define USB_ENDPOINT_TYPE_INTERRUPT
Definition: usb100.h:65
#define USB_CONFIGURATION_DESCRIPTOR_TYPE
Definition: usb100.h:50
struct _USB_ENDPOINT_DESCRIPTOR USB_ENDPOINT_DESCRIPTOR
#define USB_ENDPOINT_TYPE_CONTROL
Definition: usb100.h:62
struct _USB_HUB_DESCRIPTOR USB_HUB_DESCRIPTOR
#define USB_CONFIG_SELF_POWERED
Definition: usb100.h:70
struct _USB_INTERFACE_DESCRIPTOR USB_INTERFACE_DESCRIPTOR
#define USB_INTERFACE_DESCRIPTOR_TYPE
Definition: usb100.h:52
#define USB_20_HUB_DESCRIPTOR_TYPE
Definition: usb200.h:279
#define USB_30_HUB_DESCRIPTOR_TYPE
Definition: usb200.h:280
#define USB_MINIPORT_VERSION_EHCI
Definition: usbmport.h:528
#define USB_MINIPORT_VERSION_XHCI
Definition: usbmport.h:529
#define USB_MINIPORT_VERSION_UHCI
Definition: usbmport.h:527
#define USB_MINIPORT_VERSION_OHCI
Definition: usbmport.h:526

Referenced by USBPORT_PdoPnP().

◆ USBPORT_RootHubEndpointWorker()

VOID NTAPI USBPORT_RootHubEndpointWorker ( PUSBPORT_ENDPOINT  Endpoint)

◆ USBPORT_RootHubPowerAndChirpAllCcPorts()

VOID NTAPI USBPORT_RootHubPowerAndChirpAllCcPorts ( IN PDEVICE_OBJECT  FdoDevice)

Definition at line 963 of file roothub.c.

964{
967 USBPORT_ROOT_HUB_DATA RootHubData;
968 ULONG Port;
969 PDEVICE_RELATIONS CompanionControllersList;
970 PUSBPORT_DEVICE_EXTENSION CompanionFdoExtension;
971 PUSBPORT_REGISTRATION_PACKET CompanionPacket;
972 ULONG CompanionPorts;
973 ULONG NumController;
975 ULONG NumPorts;
976
977 DPRINT("USBPORT_RootHub_PowerAndChirpAllCcPorts: FdoDevice - %p\n",
978 FdoDevice);
979
980 FdoExtension = FdoDevice->DeviceExtension;
981
982 Packet = &FdoExtension->MiniPortInterface->Packet;
983
984 RtlZeroMemory(&RootHubData, sizeof(RootHubData));
985
986 Packet->RH_GetRootHubData(FdoExtension->MiniPortExt,
987 &RootHubData);
988
989 NumPorts = RootHubData.NumberOfPorts;
990
991 for (Port = 1; Port <= NumPorts; ++Port)
992 {
993 Packet->RH_SetFeaturePortPower(FdoExtension->MiniPortExt, Port);
994 }
995
996 USBPORT_Wait(FdoDevice, 10);
997
998 CompanionControllersList = USBPORT_FindCompanionControllers(FdoDevice,
999 FALSE,
1000 TRUE);
1001
1002 if (CompanionControllersList)
1003 {
1004 Entry = &CompanionControllersList->Objects[0];
1005
1006 for (NumController = 0;
1007 NumController < CompanionControllersList->Count;
1008 NumController++)
1009 {
1010 CompanionPacket = &FdoExtension->MiniPortInterface->Packet;
1011
1012 CompanionFdoExtension = (*Entry)->DeviceExtension;
1013
1014 CompanionPacket->RH_GetRootHubData(CompanionFdoExtension->MiniPortExt,
1015 &RootHubData);
1016
1017 CompanionPorts = RootHubData.NumberOfPorts;
1018
1019 for (Port = 1; Port <= CompanionPorts; ++Port)
1020 {
1021 CompanionPacket->RH_SetFeaturePortPower(CompanionFdoExtension->MiniPortExt,
1022 Port);
1023 }
1024
1025 ++Entry;
1026 }
1027
1028 ExFreePoolWithTag(CompanionControllersList, USB_PORT_TAG);
1029 }
1030
1031 USBPORT_Wait(FdoDevice, 100);
1032
1033 for (Port = 1; Port <= NumPorts; ++Port)
1034 {
1035 if (FdoExtension->MiniPortInterface->Version < 200)
1036 {
1037 break;
1038 }
1039
1040 InterlockedIncrement((PLONG)&FdoExtension->ChirpRootPortLock);
1041 Packet->RH_ChirpRootPort(FdoExtension->MiniPortExt, Port);
1042 InterlockedDecrement((PLONG)&FdoExtension->ChirpRootPortLock);
1043 }
1044}
PHCI_RH_GET_ROOT_HUB_DATA RH_GetRootHubData
Definition: usbmport.h:585
PHCI_RH_SET_FEATURE_PORT_POWER RH_SetFeaturePortPower
Definition: usbmport.h:590
int32_t * PLONG
Definition: typedefs.h:58
PDEVICE_RELATIONS NTAPI USBPORT_FindCompanionControllers(IN PDEVICE_OBJECT USB2FdoDevice, IN BOOLEAN IsObRefer, IN BOOLEAN IsFDOsReturned)
Definition: usbport.c:136

Referenced by USBPORT_SynchronizeRootHubCallback().

◆ USBPORT_SendSetupPacket()

NTSTATUS NTAPI USBPORT_SendSetupPacket ( IN PUSBPORT_DEVICE_HANDLE  DeviceHandle,
IN PDEVICE_OBJECT  FdoDevice,
IN PUSB_DEFAULT_PIPE_SETUP_PACKET  SetupPacket,
IN PVOID  Buffer,
IN ULONG  Length,
IN OUT PULONG  TransferedLen,
IN OUT PUSBD_STATUS  pUSBDStatus 
)

Definition at line 15 of file device.c.

22{
23 PURB Urb;
24 PMDL Mdl;
25 USBD_STATUS USBDStatus;
28
29 DPRINT("USBPORT_SendSetupPacket: DeviceHandle - %p, FdoDevice - %p, SetupPacket - %p, Buffer - %p, Length - %x, TransferedLen - %x, pUSBDStatus - %x\n",
31 FdoDevice,
33 Buffer,
34 Length,
35 TransferedLen,
36 pUSBDStatus);
37
39
41 sizeof(struct _URB_CONTROL_TRANSFER),
43
44 if (Urb)
45 {
46 InterlockedIncrement(&DeviceHandle->DeviceHandleLock);
47
48 RtlZeroMemory(Urb, sizeof(struct _URB_CONTROL_TRANSFER));
49
50 RtlCopyMemory(Urb->UrbControlTransfer.SetupPacket,
53
54 Urb->UrbHeader.Length = sizeof(struct _URB_CONTROL_TRANSFER);
56 Urb->UrbHeader.UsbdDeviceHandle = DeviceHandle;
57 Urb->UrbHeader.UsbdFlags = 0;
58
59 Urb->UrbControlTransfer.PipeHandle = &DeviceHandle->PipeHandle;
60 Urb->UrbControlTransfer.TransferBufferLength = Length;
61 Urb->UrbControlTransfer.TransferBuffer = Buffer;
62 Urb->UrbControlTransfer.TransferBufferMDL = NULL;
63
64 Urb->UrbControlTransfer.TransferFlags = USBD_SHORT_TRANSFER_OK |
66
67 if (SetupPacket->bmRequestType.Dir != BMREQUEST_DEVICE_TO_HOST)
68 {
69 Urb->UrbControlTransfer.TransferFlags &= ~USBD_TRANSFER_DIRECTION_IN;
70 }
71
73
74 if (Length)
75 {
77
78 Urb->UrbControlTransfer.TransferBufferMDL = Mdl;
79
80 if (Mdl)
81 {
82 Urb->UrbHeader.UsbdFlags |= USBD_FLAG_ALLOCATED_MDL;
84 }
85 else
86 {
89 }
90 }
91
92 if (NT_SUCCESS(Status))
93 {
94 USBDStatus = USBPORT_AllocateTransfer(FdoDevice,
95 Urb,
96 NULL,
97 NULL,
98 &Event);
99
100 if (USBD_SUCCESS(USBDStatus))
101 {
102 InterlockedIncrement(&DeviceHandle->DeviceHandleLock);
103
105
107 Suspended,
109 FALSE,
110 NULL);
111
112 USBDStatus = Urb->UrbHeader.Status;
113 }
114
115 Status = USBPORT_USBDStatusToNtStatus(Urb, USBDStatus);
116
117 if (TransferedLen)
118 *TransferedLen = Urb->UrbControlTransfer.TransferBufferLength;
119
120 if (pUSBDStatus)
121 *pUSBDStatus = USBDStatus;
122 }
123
124 InterlockedDecrement(&DeviceHandle->DeviceHandleLock);
126 }
127 else
128 {
129 if (pUSBDStatus)
131
134 }
135
136 DPRINT("USBPORT_SendSetupPacket: Status - %x\n", Status);
137 return Status;
138}
VOID NTAPI USBPORT_QueueTransferUrb(IN PURB Urb)
Definition: queue.c:1085
#define IoAllocateMdl
Definition: fxmdl.h:88
VOID NTAPI MmBuildMdlForNonPagedPool(IN PMDL Mdl)
Definition: mdlsup.c:424
#define USBD_TRANSFER_DIRECTION
Definition: usb.h:153
#define USBD_SHORT_TRANSFER_OK
Definition: usb.h:154
USBD_STATUS NTAPI USBPORT_AllocateTransfer(IN PDEVICE_OBJECT FdoDevice, IN PURB Urb, IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PIRP Irp, IN PRKEVENT Event)
Definition: usbport.c:2543

Referenced by USBPORT_ClearStall(), USBPORT_CreateDevice(), USBPORT_GetUsbDescriptor(), USBPORT_HandleSelectConfiguration(), USBPORT_InitializeDevice(), USBPORT_OpenInterface(), and USBPORT_RestoreDevice().

◆ USBPORT_SetEndpointState()

VOID NTAPI USBPORT_SetEndpointState ( IN PUSBPORT_ENDPOINT  Endpoint,
IN ULONG  State 
)

Definition at line 363 of file endpoint.c.

365{
366 PDEVICE_OBJECT FdoDevice;
370
371 DPRINT("USBPORT_SetEndpointState: Endpoint - %p, State - %x\n",
372 Endpoint,
373 State);
374
375 FdoDevice = Endpoint->FdoDevice;
376 FdoExtension = FdoDevice->DeviceExtension;
377 Packet = &FdoExtension->MiniPortInterface->Packet;
378
379 KeAcquireSpinLock(&Endpoint->StateChangeSpinLock,
380 &Endpoint->EndpointStateOldIrql);
381
382 if (!(Endpoint->Flags & ENDPOINT_FLAG_ROOTHUB_EP0))
383 {
384 if (Endpoint->Flags & ENDPOINT_FLAG_NUKE)
385 {
386 Endpoint->StateLast = State;
387 Endpoint->StateNext = State;
388
389 KeReleaseSpinLock(&Endpoint->StateChangeSpinLock,
390 Endpoint->EndpointStateOldIrql);
391
393 Endpoint,
395 return;
396 }
397
398 KeReleaseSpinLock(&Endpoint->StateChangeSpinLock,
399 Endpoint->EndpointStateOldIrql);
400
401 KeAcquireSpinLock(&FdoExtension->MiniportSpinLock, &OldIrql);
402 Packet->SetEndpointState(FdoExtension->MiniPortExt,
403 Endpoint + 1,
404 State);
405 KeReleaseSpinLock(&FdoExtension->MiniportSpinLock, OldIrql);
406
407 Endpoint->StateNext = State;
408
409 KeAcquireSpinLock(&FdoExtension->MiniportSpinLock, &OldIrql);
410 Endpoint->FrameNumber = Packet->Get32BitFrameNumber(FdoExtension->MiniPortExt);
411 KeReleaseSpinLock(&FdoExtension->MiniportSpinLock, OldIrql);
412
413 ExInterlockedInsertTailList(&FdoExtension->EpStateChangeList,
414 &Endpoint->StateChangeLink,
415 &FdoExtension->EpStateChangeSpinLock);
416
417 KeAcquireSpinLock(&FdoExtension->MiniportSpinLock, &OldIrql);
418 Packet->InterruptNextSOF(FdoExtension->MiniPortExt);
419 KeReleaseSpinLock(&FdoExtension->MiniportSpinLock, OldIrql);
420 }
421 else
422 {
423 Endpoint->StateLast = State;
424 Endpoint->StateNext = State;
425
427 {
428 KeReleaseSpinLock(&Endpoint->StateChangeSpinLock,
429 Endpoint->EndpointStateOldIrql);
430
432 Endpoint,
434 return;
435 }
436
437 KeReleaseSpinLock(&Endpoint->StateChangeSpinLock,
438 Endpoint->EndpointStateOldIrql);
439 }
440}

Referenced by USBPORT_ClosePipe(), USBPORT_DmaEndpointWorker(), USBPORT_OpenPipe(), and USBPORT_SyncResetPipeAndClearStall().

◆ USBPORT_SetRegistryKeyValue()

NTSTATUS NTAPI USBPORT_SetRegistryKeyValue ( IN PDEVICE_OBJECT  DeviceObject,
IN BOOL  UseDriverKey,
IN ULONG  Type,
IN PCWSTR  ValueNameString,
IN PVOID  Data,
IN ULONG  DataSize 
)

Definition at line 248 of file usbport.c.

254{
258
259 DPRINT("USBPORT_SetRegistryKeyValue: ValueNameString - %S\n",
260 ValueNameString);
261
262 if (UseDriverKey)
263 {
267 &KeyHandle);
268 }
269 else
270 {
274 &KeyHandle);
275 }
276
277 if (NT_SUCCESS(Status))
278 {
279 RtlInitUnicodeString(&ValueName, ValueNameString);
280
281 Status = ZwSetValueKey(KeyHandle,
282 &ValueName,
283 0,
284 Type,
285 Data,
286 DataSize);
287
289 }
290
291 return Status;
292}
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4755

Referenced by USBHI_ControllerSelectiveSuspend(), USBPORT_RegisterDeviceInterface(), and USBPORT_StartDevice().

◆ USBPORT_SignalWorkerThread()

VOID NTAPI USBPORT_SignalWorkerThread ( IN PDEVICE_OBJECT  FdoDevice)

Definition at line 1111 of file usbport.c.

1112{
1114 KIRQL OldIrql;
1115
1116 DPRINT_CORE("USBPORT_SignalWorkerThread ...\n");
1117
1118 FdoExtension = FdoDevice->DeviceExtension;
1119
1120 KeAcquireSpinLock(&FdoExtension->WorkerThreadEventSpinLock, &OldIrql);
1121 KeSetEvent(&FdoExtension->WorkerThreadEvent, EVENT_INCREMENT, FALSE);
1122 KeReleaseSpinLock(&FdoExtension->WorkerThreadEventSpinLock, OldIrql);
1123}

Referenced by USBPORT_ClosePipe(), USBPORT_DpcHandler(), USBPORT_InvalidateEndpointHandler(), USBPORT_StopWorkerThread(), USBPORT_SynchronizeControllersStart(), USBPORT_SynchronizeRootHubCallback(), and USBPORT_WorkerThreadHandler().

◆ USBPORT_SplitTransfer()

VOID NTAPI USBPORT_SplitTransfer ( IN PDEVICE_OBJECT  FdoDevice,
IN PUSBPORT_ENDPOINT  Endpoint,
IN PUSBPORT_TRANSFER  Transfer,
IN PLIST_ENTRY  List 
)

Definition at line 232 of file trfsplit.c.

236{
237 ULONG TransferType;
238
239 DPRINT("USBPORT_SplitTransfer ... \n");
240
242 InitializeListHead(&Transfer->SplitTransfersList);
243
244 Transfer->USBDStatus = USBD_STATUS_SUCCESS;
245
246 if (Transfer->TransferParameters.TransferBufferLength >
247 Endpoint->EndpointProperties.MaxTransferSize)
248 {
249 TransferType = Endpoint->EndpointProperties.TransferType;
250
251 if (TransferType == USBPORT_TRANSFER_TYPE_BULK ||
252 TransferType == USBPORT_TRANSFER_TYPE_INTERRUPT)
253 {
255 Endpoint,
256 Transfer,
257 List);
258 }
259 else if (TransferType == USBPORT_TRANSFER_TYPE_ISOCHRONOUS ||
260 TransferType == USBPORT_TRANSFER_TYPE_CONTROL)
261 {
262 KeBugCheckEx(BUGCODE_USB_DRIVER, 1, 0, 0, 0);
263 }
264 else
265 {
266 DPRINT1("USBPORT_SplitTransfer: Unknown TransferType - %x\n",
267 TransferType);
268 }
269 }
270 else
271 {
272 InsertTailList(List, &Transfer->TransferLink);
273 }
274}
VOID NTAPI USBPORT_SplitBulkInterruptTransfer(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint, IN PUSBPORT_TRANSFER Transfer, IN PLIST_ENTRY List)
Definition: trfsplit.c:117

Referenced by USBPORT_MapTransfer().

◆ USBPORT_StartTimer()

BOOLEAN NTAPI USBPORT_StartTimer ( IN PDEVICE_OBJECT  FdoDevice,
IN ULONG  Time 
)

Definition at line 1675 of file usbport.c.

1677{
1679 LARGE_INTEGER DueTime = {{0, 0}};
1680 ULONG TimeIncrement;
1682
1683 DPRINT_TIMER("USBPORT_StartTimer: FdoDevice - %p, Time - %x\n",
1684 FdoDevice,
1685 Time);
1686
1687 FdoExtension = FdoDevice->DeviceExtension;
1688
1689 TimeIncrement = KeQueryTimeIncrement();
1690
1692 FdoExtension->TimerValue = Time;
1693
1694 KeInitializeTimer(&FdoExtension->TimerObject);
1695 KeInitializeDpc(&FdoExtension->TimerDpc, USBPORT_TimerDpc, FdoDevice);
1696
1697 DueTime.QuadPart -= 10000 * Time + (TimeIncrement - 1);
1698
1699 Result = KeSetTimer(&FdoExtension->TimerObject,
1700 DueTime,
1701 &FdoExtension->TimerDpc);
1702
1703 return Result;
1704}
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:712
static PLARGE_INTEGER Time
Definition: time.c:105
ULONG NTAPI KeQueryTimeIncrement(VOID)
Definition: clock.c:153
BOOLEAN NTAPI KeSetTimer(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:281
VOID NTAPI KeInitializeTimer(OUT PKTIMER Timer)
Definition: timerobj.c:233
#define DPRINT_TIMER(...)
Definition: usbdebug.h:147
VOID NTAPI USBPORT_TimerDpc(IN PRKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: usbport.c:1556
#define USBPORT_TMFLAG_TIMER_QUEUED
Definition: usbport.h:93
_In_ WDFTIMER _In_ LONGLONG DueTime
Definition: wdftimer.h:190

Referenced by USBPORT_StartDevice().

◆ USBPORT_StopWorkerThread()

VOID NTAPI USBPORT_StopWorkerThread ( IN PDEVICE_OBJECT  FdoDevice)

Definition at line 1455 of file usbport.c.

1456{
1459
1460 DPRINT("USBPORT_StopWorkerThread ...\n");
1461
1462 FdoExtension = FdoDevice->DeviceExtension;
1463
1465 USBPORT_SignalWorkerThread(FdoDevice);
1466 Status = ZwWaitForSingleObject(FdoExtension->WorkerThreadHandle, FALSE, NULL);
1468}
#define USBPORT_FLAG_WORKER_THREAD_EXIT
Definition: usbport.h:70
#define NT_ASSERT
Definition: rtlfuncs.h:3310

Referenced by USBPORT_StartDevice().

◆ USBPORT_TestDebugBreak()

ULONG NTAPI USBPORT_TestDebugBreak ( IN PVOID  MiniPortExtension)

Definition at line 30 of file debug.c.

31{
32 DPRINT("USBPORT_TestDebugBreak: UNIMPLEMENTED. FIXME. \n");
33 return 0;
34}

Referenced by USBPORT_RegisterUSBPortDriver().

◆ USBPORT_TransferFlushDpc()

VOID NTAPI USBPORT_TransferFlushDpc ( IN PRKDPC  Dpc,
IN PVOID  DeferredContext,
IN PVOID  SystemArgument1,
IN PVOID  SystemArgument2 
)

Definition at line 825 of file usbport.c.

829{
830 PDEVICE_OBJECT FdoDevice;
831
832 DPRINT_CORE("USBPORT_TransferFlushDpc: ...\n");
833 FdoDevice = DeferredContext;
835}

Referenced by USBPORT_StartDevice().

◆ USBPORT_UpdateAllocatedBwTt()

VOID NTAPI USBPORT_UpdateAllocatedBwTt ( IN PUSB2_TT_EXTENSION  TtExtension)

Definition at line 1768 of file usb2.c.

1769{
1770 ULONG BusBandwidth;
1771 ULONG NewBusBandwidth;
1772 ULONG MaxBusBandwidth = 0;
1773 ULONG MinBusBandwidth;
1774 ULONG ix;
1775
1776 DPRINT("USBPORT_UpdateAllocatedBwTt: TtExtension - %p\n", TtExtension);
1777
1778 BusBandwidth = TtExtension->BusBandwidth;
1779 MinBusBandwidth = BusBandwidth;
1780
1781 for (ix = 0; ix < USB2_FRAMES; ix++)
1782 {
1783 NewBusBandwidth = BusBandwidth - TtExtension->Bandwidth[ix];
1784
1785 MaxBusBandwidth = max(MaxBusBandwidth, NewBusBandwidth);
1786 MinBusBandwidth = min(MinBusBandwidth, NewBusBandwidth);
1787 }
1788
1789 TtExtension->MaxBandwidth = MaxBusBandwidth;
1790
1791 if (MinBusBandwidth == BusBandwidth)
1792 TtExtension->MinBandwidth = 0;
1793 else
1794 TtExtension->MinBandwidth = MinBusBandwidth;
1795}
#define min(a, b)
Definition: monoChain.cc:55
#define max(a, b)
Definition: svc.c:63

Referenced by USBPORT_AllocateBandwidthUSB2(), USBPORT_ClosePipe(), USBPORT_FreeBandwidthUSB2(), USBPORT_InitializeTT(), and USBPORT_RemoveDevice().

◆ USBPORT_USBDStatusToNtStatus()

NTSTATUS NTAPI USBPORT_USBDStatusToNtStatus ( IN PURB  Urb,
IN USBD_STATUS  USBDStatus 
)

Definition at line 485 of file usbport.c.

487{
489
490 if (USBD_ERROR(USBDStatus))
491 {
492 DPRINT1("USBPORT_USBDStatusToNtStatus: Urb - %p, USBDStatus - %x\n",
493 Urb,
494 USBDStatus);
495 }
496
497 if (Urb)
498 Urb->UrbHeader.Status = USBDStatus;
499
500 switch (USBDStatus)
501 {
504 break;
505
508 break;
509
512 break;
513
516 break;
517
520 break;
521
527 break;
528
529 default:
530 if (USBD_ERROR(USBDStatus))
532 else
534
535 break;
536 }
537
538 return Status;
539}
#define USBD_STATUS_INVALID_PIPE_HANDLE
Definition: usb.h:194
#define USBD_STATUS_INVALID_PARAMETER
Definition: usb.h:192
#define USBD_STATUS_BAD_START_FRAME
Definition: usb.h:198

Referenced by USBPORT_AbortPipe(), USBPORT_ClearStall(), USBPORT_CompleteTransfer(), USBPORT_DoneTransfer(), USBPORT_FlushAbortList(), USBPORT_HandleGetCurrentFrame(), USBPORT_HandleGetStatus(), USBPORT_HandleSelectConfiguration(), USBPORT_HandleSelectInterface(), USBPORT_HandleSubmitURB(), USBPORT_OpenInterface(), USBPORT_OpenPipe(), USBPORT_ResetPipe(), USBPORT_RestoreDevice(), USBPORT_SendSetupPacket(), USBPORT_SyncResetPipeAndClearStall(), and USBPORT_ValidateURB().

◆ USBPORT_ValidateDeviceHandle()

BOOLEAN NTAPI USBPORT_ValidateDeviceHandle ( IN PDEVICE_OBJECT  FdoDevice,
IN PUSBPORT_DEVICE_HANDLE  DeviceHandle 
)

Definition at line 801 of file device.c.

803{
806 PLIST_ENTRY HandleList;
807 PUSBPORT_DEVICE_HANDLE CurrentHandle;
809
810 //DPRINT("USBPORT_ValidateDeviceHandle: DeviceHandle - %p\n", DeviceHandle \n");
811
812 FdoExtension = FdoDevice->DeviceExtension;
813
814 KeAcquireSpinLock(&FdoExtension->DeviceHandleSpinLock, &OldIrql);
815 if (DeviceHandle)
816 {
817 HandleList = FdoExtension->DeviceHandleList.Flink;
818
819 while (HandleList != &FdoExtension->DeviceHandleList)
820 {
821 CurrentHandle = CONTAINING_RECORD(HandleList,
823 DeviceHandleLink);
824
825 if (CurrentHandle == DeviceHandle)
826 {
827 Result = TRUE;
828 break;
829 }
830
831 HandleList = HandleList->Flink;
832 }
833 }
834 KeReleaseSpinLock(&FdoExtension->DeviceHandleSpinLock, OldIrql);
835
836 return Result;
837}

Referenced by USBPORT_CreateDevice(), USBPORT_HandleSubmitURB(), USBPORT_RemoveDevice(), and USBPORT_RestoreDevice().

◆ USBPORT_ValidatePipeHandle()

BOOLEAN NTAPI USBPORT_ValidatePipeHandle ( IN PUSBPORT_DEVICE_HANDLE  DeviceHandle,
IN PUSBPORT_PIPE_HANDLE  PipeHandle 
)

Definition at line 469 of file endpoint.c.

471{
472 PLIST_ENTRY HandleList;
473 PUSBPORT_PIPE_HANDLE CurrentHandle;
474
475 //DPRINT("USBPORT_ValidatePipeHandle: DeviceHandle - %p, PipeHandle - %p\n",
476 // DeviceHandle,
477 // PipeHandle);
478
479 HandleList = DeviceHandle->PipeHandleList.Flink;
480
481 while (HandleList != &DeviceHandle->PipeHandleList)
482 {
483 CurrentHandle = CONTAINING_RECORD(HandleList,
485 PipeLink);
486
487 HandleList = HandleList->Flink;
488
489 if (CurrentHandle == PipeHandle)
490 return TRUE;
491 }
492
493 return FALSE;
494}

Referenced by USBPORT_AbortPipe(), USBPORT_ClearStall(), USBPORT_ResetPipe(), USBPORT_SyncResetPipeAndClearStall(), and USBPORT_ValidateURB().

◆ USBPORT_Wait()

◆ USBPORT_WorkerRequestDpc()

VOID NTAPI USBPORT_WorkerRequestDpc ( IN PRKDPC  Dpc,
IN PVOID  DeferredContext,
IN PVOID  SystemArgument1,
IN PVOID  SystemArgument2 
)

Definition at line 701 of file usbport.c.

705{
706 PDEVICE_OBJECT FdoDevice;
708
709 DPRINT("USBPORT_WorkerRequestDpc: ...\n");
710
711 FdoDevice = DeferredContext;
712 FdoExtension = FdoDevice->DeviceExtension;
713
714 if (!InterlockedIncrement(&FdoExtension->IsrDpcHandlerCounter))
715 {
716 USBPORT_DpcHandler(FdoDevice);
717 }
718
719 InterlockedDecrement(&FdoExtension->IsrDpcHandlerCounter);
720}
VOID NTAPI USBPORT_DpcHandler(IN PDEVICE_OBJECT FdoDevice)
Definition: usbport.c:864

Referenced by USBPORT_StartDevice().

Variable Documentation

◆ USBPORT_MiniPortDrivers

LIST_ENTRY USBPORT_MiniPortDrivers
extern

Definition at line 18 of file usbport.c.

Referenced by USBPORT_FindMiniPort(), and USBPORT_RegisterUSBPortDriver().

◆ USBPORT_SpinLock