ReactOS 0.4.15-dev-8116-gf69e256
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:73
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::@1568::@1569 DeviceIoControl
union _IO_STACK_LOCATION::@1568 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::@3983::@4008 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