ReactOS  0.4.13-dev-242-g611e6d7
usbhub.h File Reference
#include <ntddk.h>
#include <windef.h>
#include <stdio.h>
#include <wmistr.h>
#include <wmilib.h>
#include <wdmguid.h>
#include <ntstrsafe.h>
#include <usb.h>
#include <usbioctl.h>
#include <hubbusif.h>
#include <usbbusif.h>
#include <usbdlib.h>
#include <ks.h>
#include <drivers/usbport/usbmport.h>
Include dependency graph for usbhub.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _USBHUB_PORT_DATA
 
struct  _USBHUB_IO_WORK_ITEM
 
struct  _COMMON_DEVICE_EXTENSION
 
struct  _USBHUB_FDO_EXTENSION
 
struct  _USBHUB_PORT_PDO_EXTENSION
 
struct  _USBHUB_URB_TIMEOUT_CONTEXT
 
struct  _USBHUB_STATUS_CHANGE_CONTEXT
 
struct  _USBHUB_IDLE_HUB_CONTEXT
 
struct  _USBHUB_IDLE_PORT_CONTEXT
 
struct  _USBHUB_IDLE_PORT_CANCEL_CONTEXT
 
struct  _USBHUB_RESET_PORT_CONTEXT
 

Macros

#define USB_HUB_TAG   'BUHU'
 
#define USBH_EXTENSION_TYPE_HUB   0x01
 
#define USBH_EXTENSION_TYPE_PORT   0x02
 
#define USBH_EXTENSION_TYPE_PARENT   0x04
 
#define USBH_EXTENSION_TYPE_FUNCTION   0x08
 
#define USBHUB_FDO_FLAG_DEVICE_STARTED   (1 << 0)
 
#define USBHUB_FDO_FLAG_DEVICE_STOPPING   (1 << 2)
 
#define USBHUB_FDO_FLAG_DEVICE_FAILED   (1 << 3)
 
#define USBHUB_FDO_FLAG_REMOTE_WAKEUP   (1 << 4)
 
#define USBHUB_FDO_FLAG_DEVICE_STOPPED   (1 << 5)
 
#define USBHUB_FDO_FLAG_HUB_BUSY   (1 << 6)
 
#define USBHUB_FDO_FLAG_PENDING_WAKE_IRP   (1 << 7)
 
#define USBHUB_FDO_FLAG_RESET_PORT_LOCK   (1 << 8)
 
#define USBHUB_FDO_FLAG_ESD_RECOVERING   (1 << 9)
 
#define USBHUB_FDO_FLAG_SET_D0_STATE   (1 << 10)
 
#define USBHUB_FDO_FLAG_NOT_D0_STATE   (1 << 11)
 
#define USBHUB_FDO_FLAG_WAIT_IDLE_REQUEST   (1 << 12)
 
#define USBHUB_FDO_FLAG_STATE_CHANGING   (1 << 13)
 
#define USBHUB_FDO_FLAG_DEVICE_REMOVED   (1 << 14)
 
#define USBHUB_FDO_FLAG_USB20_HUB   (1 << 15)
 
#define USBHUB_FDO_FLAG_DEFER_CHECK_IDLE   (1 << 16)
 
#define USBHUB_FDO_FLAG_WAKEUP_START   (1 << 17)
 
#define USBHUB_FDO_FLAG_MULTIPLE_TTS   (1 << 18)
 
#define USBHUB_FDO_FLAG_ENUM_POST_RECOVER   (1 << 19)
 
#define USBHUB_FDO_FLAG_DO_ENUMERATION   (1 << 20)
 
#define USBHUB_FDO_FLAG_CHECK_IDLE_LOCK   (1 << 21)
 
#define USBHUB_FDO_FLAG_HIBERNATE_STATE   (1 << 22)
 
#define USBHUB_FDO_FLAG_NOT_ENUMERATED   (1 << 23)
 
#define USBHUB_FDO_FLAG_DO_SUSPENSE   (1 << 24)
 
#define USBHUB_FDO_FLAG_GOING_IDLE   (1 << 25)
 
#define USBHUB_FDO_FLAG_DEVICE_SUSPENDED   (1 << 26)
 
#define USBHUB_FDO_FLAG_WITEM_INIT   (1 << 27)
 
#define USBHUB_PDO_FLAG_HUB_DEVICE   (1 << 0)
 
#define USBHUB_PDO_FLAG_MULTI_INTERFACE   (1 << 1)
 
#define USBHUB_PDO_FLAG_INIT_PORT_FAILED   (1 << 2)
 
#define USBHUB_PDO_FLAG_PORT_LOW_SPEED   (1 << 3)
 
#define USBHUB_PDO_FLAG_REMOTE_WAKEUP   (1 << 4)
 
#define USBHUB_PDO_FLAG_WAIT_WAKE   (1 << 5)
 
#define USBHUB_PDO_FLAG_NOT_CONNECTED   (1 << 6)
 
#define USBHUB_PDO_FLAG_DELETE_PENDING   (1 << 7)
 
#define USBHUB_PDO_FLAG_POWER_D3   (1 << 8)
 
#define USBHUB_PDO_FLAG_DEVICE_STARTED   (1 << 9)
 
#define USBHUB_PDO_FLAG_HS_USB1_DUALMODE   (1 << 10)
 
#define USBHUB_PDO_FLAG_REG_DEV_INTERFACE   (1 << 11)
 
#define USBHUB_PDO_FLAG_PORT_RESTORE_FAIL   (1 << 12)
 
#define USBHUB_PDO_FLAG_POWER_D1_OR_D2   (1 << 13)
 
#define USBHUB_PDO_FLAG_OVERCURRENT_PORT   (1 << 14)
 
#define USBHUB_PDO_FLAG_REMOVING_PORT_PDO   (1 << 15)
 
#define USBHUB_PDO_FLAG_INSUFFICIENT_PWR   (1 << 16)
 
#define USBHUB_PDO_FLAG_ALLOC_BNDW_FAILED   (1 << 18)
 
#define USBHUB_PDO_FLAG_PORT_RESSETING   (1 << 19)
 
#define USBHUB_PDO_FLAG_IDLE_NOTIFICATION   (1 << 22)
 
#define USBHUB_PDO_FLAG_PORT_HIGH_SPEED   (1 << 23)
 
#define USBHUB_PDO_FLAG_ENUMERATED   (1 << 26)
 
#define USBHUB_ENUM_FLAG_DEVICE_PRESENT   0x01
 
#define USBHUB_ENUM_FLAG_GHOST_DEVICE   0x02
 
#define USBHUB_FEATURE_USBHUB_FEATURE_C_HUB_LOCAL_POWER   0
 
#define USBHUB_FEATURE_C_HUB_OVER_CURRENT   1
 
#define USBHUB_FEATURE_PORT_CONNECTION   0
 
#define USBHUB_FEATURE_PORT_ENABLE   1
 
#define USBHUB_FEATURE_PORT_SUSPEND   2
 
#define USBHUB_FEATURE_PORT_OVER_CURRENT   3
 
#define USBHUB_FEATURE_PORT_RESET   4
 
#define USBHUB_FEATURE_PORT_POWER   8
 
#define USBHUB_FEATURE_PORT_LOW_SPEED   9
 
#define USBHUB_FEATURE_C_PORT_CONNECTION   16
 
#define USBHUB_FEATURE_C_PORT_ENABLE   17
 
#define USBHUB_FEATURE_C_PORT_SUSPEND   18
 
#define USBHUB_FEATURE_C_PORT_OVER_CURRENT   19
 
#define USBHUB_FEATURE_C_PORT_RESET   20
 
#define USBHUB_FEATURE_PORT_TEST   21
 
#define USBHUB_FEATURE_PORT_INDICATOR   22
 
#define USBHUB_MAX_CASCADE_LEVELS   6
 
#define USBHUB_RESET_PORT_MAX_RETRY   3
 
#define USBHUB_MAX_REQUEST_ERRORS   3
 
#define USBHUB_FAIL_NO_FAIL   5
 
#define USBHUB_FAIL_NESTED_TOO_DEEPLY   6
 
#define USBHUB_FAIL_OVERCURRENT   7
 

Typedefs

typedef struct _USBHUB_PORT_DATA USBHUB_PORT_DATA
 
typedef struct _USBHUB_PORT_DATAPUSBHUB_PORT_DATA
 
typedef struct _USBHUB_FDO_EXTENSIONPUSBHUB_FDO_EXTENSION
 
typedef VOID(NTAPIPUSBHUB_WORKER_ROUTINE) (IN PUSBHUB_FDO_EXTENSION HubExtension, IN PVOID Context)
 
typedef struct _USBHUB_IO_WORK_ITEM USBHUB_IO_WORK_ITEM
 
typedef struct _USBHUB_IO_WORK_ITEMPUSBHUB_IO_WORK_ITEM
 
typedef struct _COMMON_DEVICE_EXTENSION COMMON_DEVICE_EXTENSION
 
typedef struct _COMMON_DEVICE_EXTENSIONPCOMMON_DEVICE_EXTENSION
 
typedef struct _USBHUB_FDO_EXTENSION USBHUB_FDO_EXTENSION
 
typedef struct _USBHUB_PORT_PDO_EXTENSION USBHUB_PORT_PDO_EXTENSION
 
typedef struct _USBHUB_PORT_PDO_EXTENSIONPUSBHUB_PORT_PDO_EXTENSION
 
typedef struct _USBHUB_URB_TIMEOUT_CONTEXT USBHUB_URB_TIMEOUT_CONTEXT
 
typedef struct _USBHUB_URB_TIMEOUT_CONTEXTPUSBHUB_URB_TIMEOUT_CONTEXT
 
typedef struct _USBHUB_STATUS_CHANGE_CONTEXT USBHUB_STATUS_CHANGE_CONTEXT
 
typedef struct _USBHUB_STATUS_CHANGE_CONTEXTPUSBHUB_STATUS_CHANGE_CONTEXT
 
typedef struct _USBHUB_IDLE_HUB_CONTEXT USBHUB_IDLE_HUB_CONTEXT
 
typedef struct _USBHUB_IDLE_HUB_CONTEXTPUSBHUB_IDLE_HUB_CONTEXT
 
typedef struct _USBHUB_IDLE_PORT_CONTEXT USBHUB_IDLE_PORT_CONTEXT
 
typedef struct _USBHUB_IDLE_PORT_CONTEXTPUSBHUB_IDLE_PORT_CONTEXT
 
typedef struct _USBHUB_IDLE_PORT_CANCEL_CONTEXT USBHUB_IDLE_PORT_CANCEL_CONTEXT
 
typedef struct _USBHUB_IDLE_PORT_CANCEL_CONTEXTPUSBHUB_IDLE_PORT_CANCEL_CONTEXT
 
typedef struct _USBHUB_RESET_PORT_CONTEXT USBHUB_RESET_PORT_CONTEXT
 
typedef struct _USBHUB_RESET_PORT_CONTEXTPUSBHUB_RESET_PORT_CONTEXT
 

Functions

VOID NTAPI USBHUB_DumpingDeviceDescriptor (IN PUSB_DEVICE_DESCRIPTOR DeviceDescriptor)
 
VOID NTAPI USBHUB_DumpingConfiguration (IN PUSB_CONFIGURATION_DESCRIPTOR ConfigDescriptor)
 
VOID NTAPI USBHUB_DumpingIDs (IN PVOID Id)
 
NTSTATUS NTAPI USBH_DeviceControl (IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
 
NTSTATUS NTAPI USBH_PdoInternalControl (IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PIRP Irp)
 
NTSTATUS NTAPI USBH_PdoRemoveDevice (IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PUSBHUB_FDO_EXTENSION HubExtension)
 
NTSTATUS NTAPI USBH_FdoPnP (IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp, IN UCHAR Minor)
 
NTSTATUS NTAPI USBH_PdoPnP (IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PIRP Irp, IN UCHAR Minor, OUT BOOLEAN *IsCompleteIrp)
 
VOID NTAPI USBH_CompletePowerIrp (IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp, IN NTSTATUS NtStatus)
 
NTSTATUS NTAPI USBH_HubSetD0 (IN PUSBHUB_FDO_EXTENSION HubExtension)
 
NTSTATUS NTAPI USBH_FdoPower (IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp, IN UCHAR Minor)
 
NTSTATUS NTAPI USBH_PdoPower (IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PIRP Irp, IN UCHAR Minor)
 
VOID NTAPI USBH_HubCompletePortWakeIrps (IN PUSBHUB_FDO_EXTENSION HubExtension, IN NTSTATUS NtStatus)
 
VOID NTAPI USBH_HubCancelWakeIrp (IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
 
VOID NTAPI USBH_IdleCancelPowerHubWorker (IN PUSBHUB_FDO_EXTENSION HubExtension, IN PVOID Context)
 
NTSTATUS NTAPI USBH_Wait (IN ULONG Milliseconds)
 
VOID NTAPI USBH_CompleteIrp (IN PIRP Irp, IN NTSTATUS CompleteStatus)
 
NTSTATUS NTAPI USBH_PassIrp (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
PUSBHUB_PORT_PDO_EXTENSION NTAPI PdoExt (IN PDEVICE_OBJECT DeviceObject)
 
NTSTATUS NTAPI USBH_WriteFailReasonID (IN PDEVICE_OBJECT DeviceObject, IN ULONG Data)
 
NTSTATUS NTAPI USBH_SetPdoRegistryParameter (IN PDEVICE_OBJECT DeviceObject, IN PCWSTR SourceString, IN PVOID Data, IN ULONG DataSize, IN ULONG Type, IN ULONG DevInstKeyType)
 
NTSTATUS NTAPI USBH_SyncSubmitUrb (IN PDEVICE_OBJECT DeviceObject, IN PURB Urb)
 
NTSTATUS NTAPI USBH_FdoSyncSubmitUrb (IN PDEVICE_OBJECT FdoDevice, IN PURB Urb)
 
NTSTATUS NTAPI USBH_SyncResetPort (IN PUSBHUB_FDO_EXTENSION HubExtension, IN USHORT Port)
 
NTSTATUS NTAPI USBH_GetDeviceType (IN PUSBHUB_FDO_EXTENSION HubExtension, IN PUSB_DEVICE_HANDLE DeviceHandle, OUT USB_DEVICE_TYPE *OutDeviceType)
 
PUSBHUB_FDO_EXTENSION NTAPI USBH_GetRootHubExtension (IN PUSBHUB_FDO_EXTENSION HubExtension)
 
NTSTATUS NTAPI USBH_SyncGetRootHubPdo (IN PDEVICE_OBJECT DeviceObject, IN OUT PDEVICE_OBJECT *OutPdo1, IN OUT PDEVICE_OBJECT *OutPdo2)
 
NTSTATUS NTAPI USBH_SyncGetHubCount (IN PDEVICE_OBJECT DeviceObject, IN OUT PULONG OutHubCount)
 
PUSB_DEVICE_HANDLE NTAPI USBH_SyncGetDeviceHandle (IN PDEVICE_OBJECT DeviceObject)
 
NTSTATUS NTAPI USBH_GetDeviceDescriptor (IN PDEVICE_OBJECT DeviceObject, IN PUSB_DEVICE_DESCRIPTOR HubDeviceDescriptor)
 
NTSTATUS NTAPI USBH_GetConfigurationDescriptor (IN PDEVICE_OBJECT DeviceObject, IN PUSB_CONFIGURATION_DESCRIPTOR *pConfigurationDescriptor)
 
NTSTATUS NTAPI USBH_SyncGetHubDescriptor (IN PUSBHUB_FDO_EXTENSION HubExtension)
 
NTSTATUS NTAPI USBH_SyncGetStringDescriptor (IN PDEVICE_OBJECT DeviceObject, IN UCHAR Index, IN USHORT LanguageId, IN PUSB_STRING_DESCRIPTOR Descriptor, IN ULONG NumberOfBytes, IN PULONG OutLength, IN BOOLEAN IsValidateLength)
 
NTSTATUS NTAPI USBH_SyncGetPortStatus (IN PUSBHUB_FDO_EXTENSION HubExtension, IN USHORT Port, IN PUSB_PORT_STATUS_AND_CHANGE PortStatus, IN ULONG Length)
 
NTSTATUS NTAPI USBH_SyncClearPortStatus (IN PUSBHUB_FDO_EXTENSION HubExtension, IN USHORT Port, IN USHORT RequestValue)
 
NTSTATUS NTAPI USBH_SyncPowerOnPorts (IN PUSBHUB_FDO_EXTENSION HubExtension)
 
NTSTATUS NTAPI USBH_SyncDisablePort (IN PUSBHUB_FDO_EXTENSION HubExtension, IN USHORT Port)
 
BOOLEAN NTAPI USBH_HubIsBusPowered (IN PDEVICE_OBJECT DeviceObject, IN PUSB_CONFIGURATION_DESCRIPTOR HubConfigDescriptor)
 
NTSTATUS NTAPI USBH_SubmitStatusChangeTransfer (IN PUSBHUB_FDO_EXTENSION HubExtension)
 
NTSTATUS NTAPI USBD_CreateDeviceEx (IN PUSBHUB_FDO_EXTENSION HubExtension, IN PUSB_DEVICE_HANDLE *OutDeviceHandle, IN USB_PORT_STATUS UsbPortStatus, IN USHORT Port)
 
NTSTATUS NTAPI USBD_RemoveDeviceEx (IN PUSBHUB_FDO_EXTENSION HubExtension, IN PUSB_DEVICE_HANDLE DeviceHandle, IN ULONG Flags)
 
NTSTATUS NTAPI USBD_InitializeDeviceEx (IN PUSBHUB_FDO_EXTENSION HubExtension, IN PUSB_DEVICE_HANDLE DeviceHandle, IN PUCHAR DeviceDescriptorBuffer, IN ULONG DeviceDescriptorBufferLength, IN PUCHAR ConfigDescriptorBuffer, IN ULONG ConfigDescriptorBufferLength)
 
VOID NTAPI USBHUB_SetDeviceHandleData (IN PUSBHUB_FDO_EXTENSION HubExtension, IN PDEVICE_OBJECT UsbDevicePdo, IN PVOID DeviceHandle)
 
VOID NTAPI USBHUB_FlushAllTransfers (IN PUSBHUB_FDO_EXTENSION HubExtension)
 
NTSTATUS NTAPI USBD_GetDeviceInformationEx (IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PUSBHUB_FDO_EXTENSION HubExtension, IN PUSB_NODE_CONNECTION_INFORMATION_EX Info, IN ULONG Length, IN PUSB_DEVICE_HANDLE DeviceHandle)
 
NTSTATUS NTAPI USBD_RestoreDeviceEx (IN PUSBHUB_FDO_EXTENSION HubExtension, IN OUT PUSB_DEVICE_HANDLE OldDeviceHandle, IN OUT PUSB_DEVICE_HANDLE NewDeviceHandle)
 
NTSTATUS NTAPI USBH_AllocateWorkItem (IN PUSBHUB_FDO_EXTENSION HubExtension, OUT PUSBHUB_IO_WORK_ITEM *OutHubIoWorkItem, IN PUSBHUB_WORKER_ROUTINE WorkerRoutine, IN SIZE_T BufferLength, OUT PVOID *OutHubWorkItemBuffer, IN WORK_QUEUE_TYPE Type)
 
VOID NTAPI USBH_QueueWorkItem (IN PUSBHUB_FDO_EXTENSION HubExtension, IN PUSBHUB_IO_WORK_ITEM HubIoWorkItem)
 
VOID NTAPI USBH_FreeWorkItem (IN PUSBHUB_IO_WORK_ITEM HubIoWorkItem)
 
NTSTATUS NTAPI USBD_RegisterRootHubCallBack (IN PUSBHUB_FDO_EXTENSION HubExtension)
 
NTSTATUS NTAPI USBD_UnRegisterRootHubCallBack (IN PUSBHUB_FDO_EXTENSION HubExtension)
 
VOID NTAPI USBH_HubCancelIdleIrp (IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP IdleIrp)
 
BOOLEAN NTAPI USBH_CheckIdleAbort (IN PUSBHUB_FDO_EXTENSION HubExtension, IN BOOLEAN IsWait, IN BOOLEAN IsExtCheck)
 
VOID NTAPI USBH_CheckHubIdle (IN PUSBHUB_FDO_EXTENSION HubExtension)
 
VOID NTAPI USBH_CheckIdleDeferred (IN PUSBHUB_FDO_EXTENSION HubExtension)
 
NTSTATUS NTAPI USBH_CheckDeviceLanguage (IN PDEVICE_OBJECT DeviceObject, IN USHORT LanguageId)
 
NTSTATUS NTAPI USBH_CreateDevice (IN PUSBHUB_FDO_EXTENSION HubExtension, IN USHORT Port, IN USB_PORT_STATUS UsbPortStatus, IN ULONG IsWait)
 
NTSTATUS NTAPI USBH_ResetDevice (IN PUSBHUB_FDO_EXTENSION HubExtension, IN USHORT Port, IN BOOLEAN IsKeepDeviceData, IN BOOLEAN IsWait)
 
NTSTATUS NTAPI DriverEntry (IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
 

Variables

PWSTR GenericUSBDeviceString
 

Macro Definition Documentation

◆ USB_HUB_TAG

#define USB_HUB_TAG   'BUHU'

Definition at line 26 of file usbhub.h.

◆ USBH_EXTENSION_TYPE_FUNCTION

#define USBH_EXTENSION_TYPE_FUNCTION   0x08

Definition at line 31 of file usbhub.h.

◆ USBH_EXTENSION_TYPE_HUB

#define USBH_EXTENSION_TYPE_HUB   0x01

Definition at line 28 of file usbhub.h.

◆ USBH_EXTENSION_TYPE_PARENT

#define USBH_EXTENSION_TYPE_PARENT   0x04

Definition at line 30 of file usbhub.h.

◆ USBH_EXTENSION_TYPE_PORT

#define USBH_EXTENSION_TYPE_PORT   0x02

Definition at line 29 of file usbhub.h.

◆ USBHUB_ENUM_FLAG_DEVICE_PRESENT

#define USBHUB_ENUM_FLAG_DEVICE_PRESENT   0x01

Definition at line 84 of file usbhub.h.

◆ USBHUB_ENUM_FLAG_GHOST_DEVICE

#define USBHUB_ENUM_FLAG_GHOST_DEVICE   0x02

Definition at line 85 of file usbhub.h.

◆ USBHUB_FAIL_NESTED_TOO_DEEPLY

#define USBHUB_FAIL_NESTED_TOO_DEEPLY   6

Definition at line 112 of file usbhub.h.

◆ USBHUB_FAIL_NO_FAIL

#define USBHUB_FAIL_NO_FAIL   5

Definition at line 111 of file usbhub.h.

◆ USBHUB_FAIL_OVERCURRENT

#define USBHUB_FAIL_OVERCURRENT   7

Definition at line 113 of file usbhub.h.

◆ USBHUB_FDO_FLAG_CHECK_IDLE_LOCK

#define USBHUB_FDO_FLAG_CHECK_IDLE_LOCK   (1 << 21)

Definition at line 53 of file usbhub.h.

◆ USBHUB_FDO_FLAG_DEFER_CHECK_IDLE

#define USBHUB_FDO_FLAG_DEFER_CHECK_IDLE   (1 << 16)

Definition at line 48 of file usbhub.h.

◆ USBHUB_FDO_FLAG_DEVICE_FAILED

#define USBHUB_FDO_FLAG_DEVICE_FAILED   (1 << 3)

Definition at line 35 of file usbhub.h.

◆ USBHUB_FDO_FLAG_DEVICE_REMOVED

#define USBHUB_FDO_FLAG_DEVICE_REMOVED   (1 << 14)

Definition at line 46 of file usbhub.h.

◆ USBHUB_FDO_FLAG_DEVICE_STARTED

#define USBHUB_FDO_FLAG_DEVICE_STARTED   (1 << 0)

Definition at line 33 of file usbhub.h.

◆ USBHUB_FDO_FLAG_DEVICE_STOPPED

#define USBHUB_FDO_FLAG_DEVICE_STOPPED   (1 << 5)

Definition at line 37 of file usbhub.h.

◆ USBHUB_FDO_FLAG_DEVICE_STOPPING

#define USBHUB_FDO_FLAG_DEVICE_STOPPING   (1 << 2)

Definition at line 34 of file usbhub.h.

◆ USBHUB_FDO_FLAG_DEVICE_SUSPENDED

#define USBHUB_FDO_FLAG_DEVICE_SUSPENDED   (1 << 26)

Definition at line 58 of file usbhub.h.

◆ USBHUB_FDO_FLAG_DO_ENUMERATION

#define USBHUB_FDO_FLAG_DO_ENUMERATION   (1 << 20)

Definition at line 52 of file usbhub.h.

◆ USBHUB_FDO_FLAG_DO_SUSPENSE

#define USBHUB_FDO_FLAG_DO_SUSPENSE   (1 << 24)

Definition at line 56 of file usbhub.h.

◆ USBHUB_FDO_FLAG_ENUM_POST_RECOVER

#define USBHUB_FDO_FLAG_ENUM_POST_RECOVER   (1 << 19)

Definition at line 51 of file usbhub.h.

◆ USBHUB_FDO_FLAG_ESD_RECOVERING

#define USBHUB_FDO_FLAG_ESD_RECOVERING   (1 << 9)

Definition at line 41 of file usbhub.h.

◆ USBHUB_FDO_FLAG_GOING_IDLE

#define USBHUB_FDO_FLAG_GOING_IDLE   (1 << 25)

Definition at line 57 of file usbhub.h.

◆ USBHUB_FDO_FLAG_HIBERNATE_STATE

#define USBHUB_FDO_FLAG_HIBERNATE_STATE   (1 << 22)

Definition at line 54 of file usbhub.h.

◆ USBHUB_FDO_FLAG_HUB_BUSY

#define USBHUB_FDO_FLAG_HUB_BUSY   (1 << 6)

Definition at line 38 of file usbhub.h.

◆ USBHUB_FDO_FLAG_MULTIPLE_TTS

#define USBHUB_FDO_FLAG_MULTIPLE_TTS   (1 << 18)

Definition at line 50 of file usbhub.h.

◆ USBHUB_FDO_FLAG_NOT_D0_STATE

#define USBHUB_FDO_FLAG_NOT_D0_STATE   (1 << 11)

Definition at line 43 of file usbhub.h.

◆ USBHUB_FDO_FLAG_NOT_ENUMERATED

#define USBHUB_FDO_FLAG_NOT_ENUMERATED   (1 << 23)

Definition at line 55 of file usbhub.h.

◆ USBHUB_FDO_FLAG_PENDING_WAKE_IRP

#define USBHUB_FDO_FLAG_PENDING_WAKE_IRP   (1 << 7)

Definition at line 39 of file usbhub.h.

◆ USBHUB_FDO_FLAG_REMOTE_WAKEUP

#define USBHUB_FDO_FLAG_REMOTE_WAKEUP   (1 << 4)

Definition at line 36 of file usbhub.h.

◆ USBHUB_FDO_FLAG_RESET_PORT_LOCK

#define USBHUB_FDO_FLAG_RESET_PORT_LOCK   (1 << 8)

Definition at line 40 of file usbhub.h.

◆ USBHUB_FDO_FLAG_SET_D0_STATE

#define USBHUB_FDO_FLAG_SET_D0_STATE   (1 << 10)

Definition at line 42 of file usbhub.h.

◆ USBHUB_FDO_FLAG_STATE_CHANGING

#define USBHUB_FDO_FLAG_STATE_CHANGING   (1 << 13)

Definition at line 45 of file usbhub.h.

◆ USBHUB_FDO_FLAG_USB20_HUB

#define USBHUB_FDO_FLAG_USB20_HUB   (1 << 15)

Definition at line 47 of file usbhub.h.

◆ USBHUB_FDO_FLAG_WAIT_IDLE_REQUEST

#define USBHUB_FDO_FLAG_WAIT_IDLE_REQUEST   (1 << 12)

Definition at line 44 of file usbhub.h.

◆ USBHUB_FDO_FLAG_WAKEUP_START

#define USBHUB_FDO_FLAG_WAKEUP_START   (1 << 17)

Definition at line 49 of file usbhub.h.

◆ USBHUB_FDO_FLAG_WITEM_INIT

#define USBHUB_FDO_FLAG_WITEM_INIT   (1 << 27)

Definition at line 59 of file usbhub.h.

◆ USBHUB_FEATURE_C_HUB_OVER_CURRENT

#define USBHUB_FEATURE_C_HUB_OVER_CURRENT   1

Definition at line 89 of file usbhub.h.

◆ USBHUB_FEATURE_C_PORT_CONNECTION

#define USBHUB_FEATURE_C_PORT_CONNECTION   16

Definition at line 98 of file usbhub.h.

◆ USBHUB_FEATURE_C_PORT_ENABLE

#define USBHUB_FEATURE_C_PORT_ENABLE   17

Definition at line 99 of file usbhub.h.

◆ USBHUB_FEATURE_C_PORT_OVER_CURRENT

#define USBHUB_FEATURE_C_PORT_OVER_CURRENT   19

Definition at line 101 of file usbhub.h.

◆ USBHUB_FEATURE_C_PORT_RESET

#define USBHUB_FEATURE_C_PORT_RESET   20

Definition at line 102 of file usbhub.h.

◆ USBHUB_FEATURE_C_PORT_SUSPEND

#define USBHUB_FEATURE_C_PORT_SUSPEND   18

Definition at line 100 of file usbhub.h.

◆ USBHUB_FEATURE_PORT_CONNECTION

#define USBHUB_FEATURE_PORT_CONNECTION   0

Definition at line 91 of file usbhub.h.

◆ USBHUB_FEATURE_PORT_ENABLE

#define USBHUB_FEATURE_PORT_ENABLE   1

Definition at line 92 of file usbhub.h.

◆ USBHUB_FEATURE_PORT_INDICATOR

#define USBHUB_FEATURE_PORT_INDICATOR   22

Definition at line 104 of file usbhub.h.

◆ USBHUB_FEATURE_PORT_LOW_SPEED

#define USBHUB_FEATURE_PORT_LOW_SPEED   9

Definition at line 97 of file usbhub.h.

◆ USBHUB_FEATURE_PORT_OVER_CURRENT

#define USBHUB_FEATURE_PORT_OVER_CURRENT   3

Definition at line 94 of file usbhub.h.

◆ USBHUB_FEATURE_PORT_POWER

#define USBHUB_FEATURE_PORT_POWER   8

Definition at line 96 of file usbhub.h.

◆ USBHUB_FEATURE_PORT_RESET

#define USBHUB_FEATURE_PORT_RESET   4

Definition at line 95 of file usbhub.h.

◆ USBHUB_FEATURE_PORT_SUSPEND

#define USBHUB_FEATURE_PORT_SUSPEND   2

Definition at line 93 of file usbhub.h.

◆ USBHUB_FEATURE_PORT_TEST

#define USBHUB_FEATURE_PORT_TEST   21

Definition at line 103 of file usbhub.h.

◆ USBHUB_FEATURE_USBHUB_FEATURE_C_HUB_LOCAL_POWER

#define USBHUB_FEATURE_USBHUB_FEATURE_C_HUB_LOCAL_POWER   0

Definition at line 88 of file usbhub.h.

◆ USBHUB_MAX_CASCADE_LEVELS

#define USBHUB_MAX_CASCADE_LEVELS   6

Definition at line 106 of file usbhub.h.

◆ USBHUB_MAX_REQUEST_ERRORS

#define USBHUB_MAX_REQUEST_ERRORS   3

Definition at line 108 of file usbhub.h.

◆ USBHUB_PDO_FLAG_ALLOC_BNDW_FAILED

#define USBHUB_PDO_FLAG_ALLOC_BNDW_FAILED   (1 << 18)

Definition at line 78 of file usbhub.h.

◆ USBHUB_PDO_FLAG_DELETE_PENDING

#define USBHUB_PDO_FLAG_DELETE_PENDING   (1 << 7)

Definition at line 68 of file usbhub.h.

◆ USBHUB_PDO_FLAG_DEVICE_STARTED

#define USBHUB_PDO_FLAG_DEVICE_STARTED   (1 << 9)

Definition at line 70 of file usbhub.h.

◆ USBHUB_PDO_FLAG_ENUMERATED

#define USBHUB_PDO_FLAG_ENUMERATED   (1 << 26)

Definition at line 82 of file usbhub.h.

◆ USBHUB_PDO_FLAG_HS_USB1_DUALMODE

#define USBHUB_PDO_FLAG_HS_USB1_DUALMODE   (1 << 10)

Definition at line 71 of file usbhub.h.

◆ USBHUB_PDO_FLAG_HUB_DEVICE

#define USBHUB_PDO_FLAG_HUB_DEVICE   (1 << 0)

Definition at line 61 of file usbhub.h.

◆ USBHUB_PDO_FLAG_IDLE_NOTIFICATION

#define USBHUB_PDO_FLAG_IDLE_NOTIFICATION   (1 << 22)

Definition at line 80 of file usbhub.h.

◆ USBHUB_PDO_FLAG_INIT_PORT_FAILED

#define USBHUB_PDO_FLAG_INIT_PORT_FAILED   (1 << 2)

Definition at line 63 of file usbhub.h.

◆ USBHUB_PDO_FLAG_INSUFFICIENT_PWR

#define USBHUB_PDO_FLAG_INSUFFICIENT_PWR   (1 << 16)

Definition at line 77 of file usbhub.h.

◆ USBHUB_PDO_FLAG_MULTI_INTERFACE

#define USBHUB_PDO_FLAG_MULTI_INTERFACE   (1 << 1)

Definition at line 62 of file usbhub.h.

◆ USBHUB_PDO_FLAG_NOT_CONNECTED

#define USBHUB_PDO_FLAG_NOT_CONNECTED   (1 << 6)

Definition at line 67 of file usbhub.h.

◆ USBHUB_PDO_FLAG_OVERCURRENT_PORT

#define USBHUB_PDO_FLAG_OVERCURRENT_PORT   (1 << 14)

Definition at line 75 of file usbhub.h.

◆ USBHUB_PDO_FLAG_PORT_HIGH_SPEED

#define USBHUB_PDO_FLAG_PORT_HIGH_SPEED   (1 << 23)

Definition at line 81 of file usbhub.h.

◆ USBHUB_PDO_FLAG_PORT_LOW_SPEED

#define USBHUB_PDO_FLAG_PORT_LOW_SPEED   (1 << 3)

Definition at line 64 of file usbhub.h.

◆ USBHUB_PDO_FLAG_PORT_RESSETING

#define USBHUB_PDO_FLAG_PORT_RESSETING   (1 << 19)

Definition at line 79 of file usbhub.h.

◆ USBHUB_PDO_FLAG_PORT_RESTORE_FAIL

#define USBHUB_PDO_FLAG_PORT_RESTORE_FAIL   (1 << 12)

Definition at line 73 of file usbhub.h.

◆ USBHUB_PDO_FLAG_POWER_D1_OR_D2

#define USBHUB_PDO_FLAG_POWER_D1_OR_D2   (1 << 13)

Definition at line 74 of file usbhub.h.

◆ USBHUB_PDO_FLAG_POWER_D3

#define USBHUB_PDO_FLAG_POWER_D3   (1 << 8)

Definition at line 69 of file usbhub.h.

◆ USBHUB_PDO_FLAG_REG_DEV_INTERFACE

#define USBHUB_PDO_FLAG_REG_DEV_INTERFACE   (1 << 11)

Definition at line 72 of file usbhub.h.

◆ USBHUB_PDO_FLAG_REMOTE_WAKEUP

#define USBHUB_PDO_FLAG_REMOTE_WAKEUP   (1 << 4)

Definition at line 65 of file usbhub.h.

◆ USBHUB_PDO_FLAG_REMOVING_PORT_PDO

#define USBHUB_PDO_FLAG_REMOVING_PORT_PDO   (1 << 15)

Definition at line 76 of file usbhub.h.

◆ USBHUB_PDO_FLAG_WAIT_WAKE

#define USBHUB_PDO_FLAG_WAIT_WAKE   (1 << 5)

Definition at line 66 of file usbhub.h.

◆ USBHUB_RESET_PORT_MAX_RETRY

#define USBHUB_RESET_PORT_MAX_RETRY   3

Definition at line 107 of file usbhub.h.

Typedef Documentation

◆ COMMON_DEVICE_EXTENSION

◆ PCOMMON_DEVICE_EXTENSION

◆ PUSBHUB_FDO_EXTENSION

Definition at line 124 of file usbhub.h.

◆ PUSBHUB_IDLE_HUB_CONTEXT

◆ PUSBHUB_IDLE_PORT_CANCEL_CONTEXT

◆ PUSBHUB_IDLE_PORT_CONTEXT

◆ PUSBHUB_IO_WORK_ITEM

◆ PUSBHUB_PORT_DATA

◆ PUSBHUB_PORT_PDO_EXTENSION

◆ PUSBHUB_RESET_PORT_CONTEXT

◆ PUSBHUB_STATUS_CHANGE_CONTEXT

◆ PUSBHUB_URB_TIMEOUT_CONTEXT

◆ PUSBHUB_WORKER_ROUTINE

typedef VOID(NTAPI * PUSBHUB_WORKER_ROUTINE) (IN PUSBHUB_FDO_EXTENSION HubExtension, IN PVOID Context)

Definition at line 127 of file usbhub.h.

◆ USBHUB_FDO_EXTENSION

◆ USBHUB_IDLE_HUB_CONTEXT

◆ USBHUB_IDLE_PORT_CANCEL_CONTEXT

◆ USBHUB_IDLE_PORT_CONTEXT

◆ USBHUB_IO_WORK_ITEM

◆ USBHUB_PORT_DATA

◆ USBHUB_PORT_PDO_EXTENSION

◆ USBHUB_RESET_PORT_CONTEXT

◆ USBHUB_STATUS_CHANGE_CONTEXT

◆ USBHUB_URB_TIMEOUT_CONTEXT

Function Documentation

◆ DriverEntry()

NTSTATUS NTAPI DriverEntry ( IN PDRIVER_OBJECT  DriverObject,
IN PUNICODE_STRING  RegistryPath 
)

Definition at line 367 of file beep.c.

369 {
370  PDEVICE_EXTENSION DeviceExtension;
372  UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\Device\\Beep");
374 
376 
377  /* Create the device */
379  sizeof(DEVICE_EXTENSION),
380  &DeviceName,
382  0,
383  FALSE,
384  &DeviceObject);
385  if (!NT_SUCCESS(Status)) return Status;
386 
387  /* Make it use buffered I/O */
389 
390  /* Setup the Driver Object */
397 
398  /* Set up device extension */
399  DeviceExtension = DeviceObject->DeviceExtension;
400  DeviceExtension->ReferenceCount = 0;
401  DeviceExtension->TimerActive = FALSE;
403  KeInitializeTimer(&DeviceExtension->Timer);
404  ExInitializeFastMutex(&DeviceExtension->Mutex);
405 
406  /* Page the entire driver */
408  return STATUS_SUCCESS;
409 }
DRIVER_DISPATCH BeepClose
Definition: beep.c:78
FORCEINLINE VOID IoInitializeDpcRequest(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIO_DPC_ROUTINE DpcRoutine)
Definition: iofuncs.h:2792
DRIVER_STARTIO BeepStartIo
Definition: beep.c:295
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
LONG NTSTATUS
Definition: precomp.h:26
WCHAR DeviceName[]
Definition: adapter.cpp:21
#define FILE_DEVICE_BEEP
Definition: winioctl.h:106
DRIVER_DISPATCH BeepDeviceControl
Definition: beep.c:206
NTSTATUS NTAPI DriverEntry(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath)
Definition: beep.c:367
PVOID DeviceExtension
Definition: env_spec_w32.h:418
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
VOID NTAPI KeInitializeTimer(OUT PKTIMER Timer)
Definition: timerobj.c:233
DRIVER_DISPATCH BeepCreate
Definition: beep.c:52
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define DO_BUFFERED_IO
Definition: env_spec_w32.h:394
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
Definition: exfuncs.h:274
PVOID NTAPI MmPageEntireDriver(IN PVOID AddressWithinSection)
Definition: sysldr.c:3322
IO_DPC_ROUTINE * PIO_DPC_ROUTINE
Definition: iotypes.h:2491
VOID NTAPI BeepDPC(IN PKDPC Dpc, IN PDEVICE_OBJECT DeviceObject, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
Definition: beep.c:34
#define IRP_MJ_CLOSE
Definition: rdpdr.c:45
static const WCHAR L[]
Definition: oid.c:1250
PDRIVER_UNLOAD DriverUnload
Definition: iotypes.h:2179
DRIVER_DISPATCH BeepCleanup
Definition: beep.c:145
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
FAST_MUTEX Mutex
Definition: beep.c:24
DRIVER_UNLOAD BeepUnload
Definition: beep.c:268
#define IRP_MJ_CLEANUP
PDRIVER_DISPATCH MajorFunction[IRP_MJ_MAXIMUM_FUNCTION+1]
Definition: iotypes.h:2180
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
PDRIVER_STARTIO DriverStartIo
Definition: iotypes.h:2178
return STATUS_SUCCESS
Definition: btrfs.c:2745
#define IRP_MJ_DEVICE_CONTROL
Definition: rdpdr.c:52
#define RTL_CONSTANT_STRING(s)
Definition: tunneltest.c:14

◆ PdoExt()

Definition at line 133 of file usbhub.c.

134 {
136 
137  DPRINT("PdoExt: DeviceObject - %p\n", DeviceObject);
138 
139  if (DeviceObject)
140  {
142  }
143  else
144  {
145  PdoExtension = NULL;
146  }
147 
149 }
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560

Referenced by PcmciaPdoPlugPlay(), PcmciaPdoSetPowerState(), USBH_FdoQueryBusRelations(), USBH_FdoSurpriseRemoveDevice(), and USBH_PdoRemoveDevice().

◆ USBD_CreateDeviceEx()

NTSTATUS NTAPI USBD_CreateDeviceEx ( IN PUSBHUB_FDO_EXTENSION  HubExtension,
IN PUSB_DEVICE_HANDLE OutDeviceHandle,
IN USB_PORT_STATUS  UsbPortStatus,
IN USHORT  Port 
)

Definition at line 2427 of file usbhub.c.

2431 {
2433  PUSB_BUSIFFN_CREATE_USB_DEVICE CreateUsbDevice;
2434 
2435  DPRINT("USBD_CreateDeviceEx: Port - %x, UsbPortStatus - 0x%04X\n",
2436  Port,
2437  UsbPortStatus.AsUshort16);
2438 
2439  CreateUsbDevice = HubExtension->BusInterface.CreateUsbDevice;
2440 
2441  if (!CreateUsbDevice)
2442  {
2443  return STATUS_NOT_IMPLEMENTED;
2444  }
2445 
2446  HubDeviceHandle = USBH_SyncGetDeviceHandle(HubExtension->LowerDevice);
2447 
2448  return CreateUsbDevice(HubExtension->BusInterface.BusContext,
2449  OutDeviceHandle,
2451  UsbPortStatus.AsUshort16,
2452  Port);
2453 }
CPPORT Port[4]
Definition: headless.c:34
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
_Outptr_ PUSB_DEVICE_HANDLE _In_ PUSB_DEVICE_HANDLE HubDeviceHandle
Definition: hubbusif.h:40
void DPRINT(...)
Definition: polytest.cpp:61
USB_BUSIFFN_CREATE_USB_DEVICE * PUSB_BUSIFFN_CREATE_USB_DEVICE
Definition: hubbusif.h:44
PUSB_DEVICE_HANDLE NTAPI USBH_SyncGetDeviceHandle(IN PDEVICE_OBJECT DeviceObject)
Definition: usbhub.c:832

Referenced by USBH_CreateDevice(), and USBH_ResetDevice().

◆ USBD_GetDeviceInformationEx()

NTSTATUS NTAPI USBD_GetDeviceInformationEx ( IN PUSBHUB_PORT_PDO_EXTENSION  PortExtension,
IN PUSBHUB_FDO_EXTENSION  HubExtension,
IN PUSB_NODE_CONNECTION_INFORMATION_EX  Info,
IN ULONG  Length,
IN PUSB_DEVICE_HANDLE  DeviceHandle 
)

Definition at line 2558 of file usbhub.c.

2563 {
2566  SIZE_T DeviceInfoLength;
2567  PUSB_NODE_CONNECTION_INFORMATION_EX NodeInfo;
2568  SIZE_T NodeInfoLength;
2569  ULONG PipeNumber;
2570  ULONG dummy;
2571  NTSTATUS Status;
2572 
2573  DPRINT("USBD_GetDeviceInformationEx ... \n");
2574 
2575  QueryDeviceInformation = HubExtension->BusInterface.QueryDeviceInformation;
2576 
2578  {
2580  return Status;
2581  }
2582 
2583  DeviceInfoLength = sizeof(USB_DEVICE_INFORMATION_0);
2584 
2585  while (TRUE)
2586  {
2588  DeviceInfoLength,
2589  USB_HUB_TAG);
2590 
2591  if (!DeviceInfo)
2592  {
2594  }
2595 
2596  RtlZeroMemory(DeviceInfo, DeviceInfoLength);
2597 
2598  DeviceInfo->InformationLevel = 0;
2599 
2600  Status = QueryDeviceInformation(HubExtension->BusInterface.BusContext,
2601  DeviceHandle,
2602  DeviceInfo,
2603  DeviceInfoLength,
2604  &dummy);
2605 
2607  {
2608  break;
2609  }
2610 
2611  DeviceInfoLength = DeviceInfo->ActualLength;
2612 
2614  }
2615 
2616  NodeInfo = NULL;
2617  NodeInfoLength = 0;
2618 
2619  if (NT_SUCCESS(Status))
2620  {
2621  NodeInfoLength = (sizeof(USB_NODE_CONNECTION_INFORMATION_EX) - sizeof(USB_PIPE_INFO)) +
2622  DeviceInfo->NumberOfOpenPipes * sizeof(USB_PIPE_INFO);
2623 
2624  NodeInfo = ExAllocatePoolWithTag(PagedPool, NodeInfoLength, USB_HUB_TAG);
2625 
2626  if (!NodeInfo)
2627  {
2630  }
2631 
2632  RtlZeroMemory(NodeInfo, NodeInfoLength);
2633 
2634  NodeInfo->ConnectionIndex = Info->ConnectionIndex;
2635 
2636  RtlCopyMemory(&NodeInfo->DeviceDescriptor,
2637  &DeviceInfo->DeviceDescriptor,
2638  sizeof(USB_DEVICE_DESCRIPTOR));
2639 
2640  NodeInfo->CurrentConfigurationValue = DeviceInfo->CurrentConfigurationValue;
2641  NodeInfo->Speed = DeviceInfo->DeviceSpeed;
2642  NodeInfo->DeviceIsHub = PortExtension->PortPdoFlags & USBHUB_PDO_FLAG_HUB_DEVICE;
2643  NodeInfo->DeviceAddress = DeviceInfo->DeviceAddress;
2644  NodeInfo->NumberOfOpenPipes = DeviceInfo->NumberOfOpenPipes;
2645  NodeInfo->ConnectionStatus = Info->ConnectionStatus;
2646 
2647  for (PipeNumber = 0;
2648  PipeNumber < DeviceInfo->NumberOfOpenPipes;
2649  PipeNumber++)
2650  {
2651  RtlCopyMemory(&NodeInfo->PipeList[PipeNumber],
2652  &DeviceInfo->PipeList[PipeNumber],
2653  sizeof(USB_PIPE_INFO));
2654  }
2655  }
2656 
2658 
2659  if (NodeInfo)
2660  {
2661  if (NodeInfoLength <= Length)
2662  {
2663  Length = NodeInfoLength;
2664  }
2665  else
2666  {
2668  }
2669 
2670  RtlCopyMemory(Info, NodeInfo, Length);
2671 
2672  ExFreePoolWithTag(NodeInfo, USB_HUB_TAG);
2673  }
2674 
2675  return Status;
2676 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
LONG NTSTATUS
Definition: precomp.h:26
struct TraceInfo Info
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
struct _USB_DEVICE_INFORMATION_0 USB_DEVICE_INFORMATION_0
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define USB_HUB_TAG
Definition: usbhub.h:9
#define USBHUB_PDO_FLAG_HUB_DEVICE
Definition: usbhub.h:61
NTSTATUS QueryDeviceInformation(IN PUNICODE_STRING SymbolicName, OUT PUNICODE_STRING DeviceName OPTIONAL, OUT PMOUNTDEV_UNIQUE_ID *UniqueId OPTIONAL, OUT PBOOLEAN Removable OPTIONAL, OUT PBOOLEAN GptDriveLetter OPTIONAL, OUT PBOOLEAN HasGuid OPTIONAL, IN OUT LPGUID StableGuid OPTIONAL, OUT PBOOLEAN Valid OPTIONAL)
Definition: mountmgr.c:204
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _DeviceInfo DeviceInfo
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Status
Definition: gdiplustypes.h:24
ULONG_PTR SIZE_T
Definition: typedefs.h:78
unsigned char dummy
Definition: maze.c:118
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
USB_BUSIFFN_GET_DEVICE_INFORMATION * PUSB_BUSIFFN_GET_DEVICE_INFORMATION
Definition: hubbusif.h:183

Referenced by USBH_IoctlGetNodeConnectionInformation().

◆ USBD_InitializeDeviceEx()

NTSTATUS NTAPI USBD_InitializeDeviceEx ( IN PUSBHUB_FDO_EXTENSION  HubExtension,
IN PUSB_DEVICE_HANDLE  DeviceHandle,
IN PUCHAR  DeviceDescriptorBuffer,
IN ULONG  DeviceDescriptorBufferLength,
IN PUCHAR  ConfigDescriptorBuffer,
IN ULONG  ConfigDescriptorBufferLength 
)

Definition at line 2481 of file usbhub.c.

2487 {
2488  NTSTATUS Status;
2489  PUSB_BUSIFFN_INITIALIZE_USB_DEVICE InitializeUsbDevice;
2490  PUSB_BUSIFFN_GET_USB_DESCRIPTORS GetUsbDescriptors;
2491 
2492  DPRINT("USBD_InitializeDeviceEx: ... \n");
2493 
2494  InitializeUsbDevice = HubExtension->BusInterface.InitializeUsbDevice;
2495  GetUsbDescriptors = HubExtension->BusInterface.GetUsbDescriptors;
2496 
2497  if (!InitializeUsbDevice || !GetUsbDescriptors)
2498  {
2499  return STATUS_NOT_IMPLEMENTED;
2500  }
2501 
2502  Status = InitializeUsbDevice(HubExtension->BusInterface.BusContext,
2503  DeviceHandle);
2504 
2505  if (!NT_SUCCESS(Status))
2506  {
2507  return Status;
2508  }
2509 
2510  return GetUsbDescriptors(HubExtension->BusInterface.BusContext,
2511  DeviceHandle,
2516 }
_Inout_ PUSB_DEVICE_HANDLE _Out_writes_bytes_to_ DeviceDescriptorBufferLength PUCHAR _Inout_ PULONG _Out_writes_bytes_to_ ConfigDescriptorBufferLength PUCHAR ConfigDescriptorBuffer
Definition: hubbusif.h:151
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
LONG NTSTATUS
Definition: precomp.h:26
USB_BUSIFFN_GET_USB_DESCRIPTORS * PUSB_BUSIFFN_GET_USB_DESCRIPTORS
Definition: hubbusif.h:154
_Inout_ PUSB_DEVICE_HANDLE _Out_writes_bytes_to_ DeviceDescriptorBufferLength PUCHAR DeviceDescriptorBuffer
Definition: hubbusif.h:148
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Inout_ PUSB_DEVICE_HANDLE _Out_writes_bytes_to_ DeviceDescriptorBufferLength PUCHAR _Inout_ PULONG DeviceDescriptorBufferLength
Definition: hubbusif.h:148
_Inout_ PUSB_DEVICE_HANDLE _Out_writes_bytes_to_ DeviceDescriptorBufferLength PUCHAR _Inout_ PULONG _Out_writes_bytes_to_ ConfigDescriptorBufferLength PUCHAR _Inout_ PULONG ConfigDescriptorBufferLength
Definition: hubbusif.h:151
USB_BUSIFFN_INITIALIZE_USB_DEVICE * PUSB_BUSIFFN_INITIALIZE_USB_DEVICE
Definition: hubbusif.h:122
Status
Definition: gdiplustypes.h:24

Referenced by USBH_CreateDevice(), and USBH_ResetDevice().

◆ USBD_RegisterRootHubCallBack()

NTSTATUS NTAPI USBD_RegisterRootHubCallBack ( IN PUSBHUB_FDO_EXTENSION  HubExtension)

Definition at line 2905 of file usbhub.c.

2906 {
2907  PUSB_BUSIFFN_ROOTHUB_INIT_NOTIFY RootHubInitNotification;
2908 
2909  DPRINT("USBD_RegisterRootHubCallBack: ... \n");
2910 
2911  RootHubInitNotification = HubExtension->BusInterface.RootHubInitNotification;
2912 
2913  if (!RootHubInitNotification)
2914  {
2915  return STATUS_NOT_IMPLEMENTED;
2916  }
2917 
2918  KeClearEvent(&HubExtension->RootHubNotificationEvent);
2919 
2920  return RootHubInitNotification(HubExtension->BusInterface.BusContext,
2921  HubExtension,
2923 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
void DPRINT(...)
Definition: polytest.cpp:61
USB_BUSIFFN_ROOTHUB_INIT_NOTIFY * PUSB_BUSIFFN_ROOTHUB_INIT_NOTIFY
Definition: hubbusif.h:279
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
VOID NTAPI USBHUB_RootHubCallBack(IN PVOID Context)
Definition: usbhub.c:2876

Referenced by USBH_StartHubFdoDevice().

◆ USBD_RemoveDeviceEx()

NTSTATUS NTAPI USBD_RemoveDeviceEx ( IN PUSBHUB_FDO_EXTENSION  HubExtension,
IN PUSB_DEVICE_HANDLE  DeviceHandle,
IN ULONG  Flags 
)

Definition at line 2457 of file usbhub.c.

2460 {
2461  PUSB_BUSIFFN_REMOVE_USB_DEVICE RemoveUsbDevice;
2462 
2463  DPRINT("USBD_RemoveDeviceEx: DeviceHandle - %p, Flags - %X\n",
2464  DeviceHandle,
2465  Flags);
2466 
2467  RemoveUsbDevice = HubExtension->BusInterface.RemoveUsbDevice;
2468 
2469  if (!RemoveUsbDevice)
2470  {
2471  return STATUS_NOT_IMPLEMENTED;
2472  }
2473 
2474  return RemoveUsbDevice(HubExtension->BusInterface.BusContext,
2475  DeviceHandle,
2476  Flags);
2477 }
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121
USB_BUSIFFN_REMOVE_USB_DEVICE * PUSB_BUSIFFN_REMOVE_USB_DEVICE
Definition: hubbusif.h:140
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
void DPRINT(...)
Definition: polytest.cpp:61

Referenced by USBH_CreateDevice(), USBH_FdoCleanup(), USBH_FdoQueryBusRelations(), USBH_PdoRemoveDevice(), USBH_ProcessPortStateChange(), USBH_ResetDevice(), and USBH_ResetPortWorker().

◆ USBD_RestoreDeviceEx()

NTSTATUS NTAPI USBD_RestoreDeviceEx ( IN PUSBHUB_FDO_EXTENSION  HubExtension,
IN OUT PUSB_DEVICE_HANDLE  OldDeviceHandle,
IN OUT PUSB_DEVICE_HANDLE  NewDeviceHandle 
)

Definition at line 2680 of file usbhub.c.

2683 {
2684  PUSB_BUSIFFN_RESTORE_DEVICE RestoreUsbDevice;
2685  NTSTATUS Status;
2686 
2687  DPRINT("USBD_RestoreDeviceEx: HubExtension - %p, OldDeviceHandle - %p, NewDeviceHandle - %p\n",
2688  HubExtension,
2690  NewDeviceHandle);
2691 
2692  RestoreUsbDevice = HubExtension->BusInterface.RestoreUsbDevice;
2693 
2694  if (RestoreUsbDevice)
2695  {
2696  Status = RestoreUsbDevice(HubExtension->BusInterface.BusContext,
2698  NewDeviceHandle);
2699  }
2700  else
2701  {
2703  }
2704 
2705  return Status;
2706 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
LONG NTSTATUS
Definition: precomp.h:26
USB_BUSIFFN_RESTORE_DEVICE * PUSB_BUSIFFN_RESTORE_DEVICE
Definition: hubbusif.h:163
_Inout_ PUSB_DEVICE_HANDLE OldDeviceHandle
Definition: hubbusif.h:161
void DPRINT(...)
Definition: polytest.cpp:61
Status
Definition: gdiplustypes.h:24
_Outptr_ PUSB_DEVICE_HANDLE * NewDeviceHandle
Definition: hubbusif.h:40

Referenced by USBH_ResetDevice().

◆ USBD_UnRegisterRootHubCallBack()

NTSTATUS NTAPI USBD_UnRegisterRootHubCallBack ( IN PUSBHUB_FDO_EXTENSION  HubExtension)

Definition at line 2927 of file usbhub.c.

2928 {
2929  PUSB_BUSIFFN_ROOTHUB_INIT_NOTIFY RootHubInitNotification;
2930  NTSTATUS Status;
2931 
2932  DPRINT("USBD_UnRegisterRootHubCallBack ... \n");
2933 
2934  RootHubInitNotification = HubExtension->BusInterface.RootHubInitNotification;
2935 
2936  if (!RootHubInitNotification)
2937  {
2938  return STATUS_NOT_IMPLEMENTED;
2939  }
2940 
2941  Status = RootHubInitNotification(HubExtension->BusInterface.BusContext,
2942  NULL,
2943  NULL);
2944 
2945  if (!NT_SUCCESS(Status))
2946  {
2947  KeWaitForSingleObject(&HubExtension->RootHubNotificationEvent,
2948  Executive,
2949  KernelMode,
2950  FALSE,
2951  NULL);
2952  }
2953 
2954  return Status;
2955 }
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24
USB_BUSIFFN_ROOTHUB_INIT_NOTIFY * PUSB_BUSIFFN_ROOTHUB_INIT_NOTIFY
Definition: hubbusif.h:279

Referenced by USBH_FdoCleanup().

◆ USBH_AllocateWorkItem()

NTSTATUS NTAPI USBH_AllocateWorkItem ( IN PUSBHUB_FDO_EXTENSION  HubExtension,
OUT PUSBHUB_IO_WORK_ITEM OutHubIoWorkItem,
IN PUSBHUB_WORKER_ROUTINE  WorkerRoutine,
IN SIZE_T  BufferLength,
OUT PVOID OutHubWorkItemBuffer,
IN WORK_QUEUE_TYPE  Type 
)

◆ USBH_CheckDeviceLanguage()

NTSTATUS NTAPI USBH_CheckDeviceLanguage ( IN PDEVICE_OBJECT  DeviceObject,
IN USHORT  LanguageId 
)

Definition at line 4161 of file usbhub.c.

4163 {
4165  NTSTATUS Status;
4166  ULONG NumSymbols;
4167  ULONG ix;
4168  PWCHAR pSymbol;
4169  ULONG Length;
4170 
4171  DPRINT("USBH_CheckDeviceLanguage: LanguageId - 0x%04X\n", LanguageId);
4172 
4175  USB_HUB_TAG);
4176 
4177  if (!Descriptor)
4178  {
4180  }
4181 
4183 
4185  0,
4186  0,
4187  Descriptor,
4189  &Length,
4190  TRUE);
4191 
4192  if (!NT_SUCCESS(Status) ||
4193  Length < sizeof(USB_COMMON_DESCRIPTOR))
4194  {
4195  goto Exit;
4196  }
4197 
4198  NumSymbols = (Length -
4199  FIELD_OFFSET(USB_STRING_DESCRIPTOR, bString)) / sizeof(WCHAR);
4200 
4201  pSymbol = Descriptor->bString;
4202 
4203  for (ix = 1; ix < NumSymbols; ix++)
4204  {
4205  if (*pSymbol == (WCHAR)LanguageId)
4206  {
4208  goto Exit;
4209  }
4210 
4211  pSymbol++;
4212  }
4213 
4215 
4216 Exit:
4218  return Status;
4219 }
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
LONG NTSTATUS
Definition: precomp.h:26
uint16_t * PWCHAR
Definition: typedefs.h:54
void DPRINT(...)
Definition: polytest.cpp:61
#define USB_HUB_TAG
Definition: usbhub.h:9
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static void Exit(void)
Definition: sock.c:1331
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define MAXIMUM_USB_STRING_LENGTH
Definition: usb100.h:43
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
NTSTATUS NTAPI USBH_SyncGetStringDescriptor(IN PDEVICE_OBJECT DeviceObject, IN UCHAR Index, IN USHORT LanguageId, IN PUSB_STRING_DESCRIPTOR Descriptor, IN ULONG NumberOfBytes, IN PULONG OutLength, IN BOOLEAN IsValidateLength)
Definition: usbhub.c:1248
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
return STATUS_SUCCESS
Definition: btrfs.c:2745
_In_ PSTORAGE_PROPERTY_ID _Outptr_ PSTORAGE_DESCRIPTOR_HEADER * Descriptor
Definition: classpnp.h:966

Referenced by USBH_GetSerialNumberString(), and USBH_PdoQueryDeviceText().

◆ USBH_CheckHubIdle()

VOID NTAPI USBH_CheckHubIdle ( IN PUSBHUB_FDO_EXTENSION  HubExtension)

Definition at line 3727 of file usbhub.c.

3728 {
3729  PDEVICE_OBJECT PdoDevice;
3730  PUSBHUB_PORT_PDO_EXTENSION PortExtension;
3731  PUSBHUB_PORT_DATA PortData;
3732  ULONG HubFlags;
3733  ULONG Port;
3734  KIRQL Irql;
3735  BOOLEAN IsHubIdle = FALSE;
3736  BOOLEAN IsAllPortsIdle;
3737  BOOLEAN IsHubCheck = TRUE;
3738 
3739  DPRINT("USBH_CheckHubIdle: FIXME !!! HubExtension - %p\n", HubExtension);
3740 
3741 return; //HACK: delete it line after fixing Power Manager!!!
3742 
3743  KeAcquireSpinLock(&HubExtension->CheckIdleSpinLock, &Irql);
3744 
3745  if (HubExtension->HubFlags & USBHUB_FDO_FLAG_CHECK_IDLE_LOCK)
3746  {
3747  KeReleaseSpinLock(&HubExtension->CheckIdleSpinLock, Irql);
3748  return;
3749  }
3750 
3751  HubExtension->HubFlags |= USBHUB_FDO_FLAG_CHECK_IDLE_LOCK;
3752  KeReleaseSpinLock(&HubExtension->CheckIdleSpinLock, Irql);
3753 
3754  if (USBH_GetRootHubExtension(HubExtension)->SystemPowerState.SystemState != PowerSystemWorking)
3755  {
3756  KeAcquireSpinLock(&HubExtension->CheckIdleSpinLock, &Irql);
3757  HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_CHECK_IDLE_LOCK;
3758  KeReleaseSpinLock(&HubExtension->CheckIdleSpinLock, Irql);
3759  return;
3760  }
3761 
3762  HubFlags = HubExtension->HubFlags;
3763  DPRINT("USBH_CheckHubIdle: HubFlags - %lX\n", HubFlags);
3764 
3765  if (!(HubFlags & USBHUB_FDO_FLAG_DEVICE_STARTED) ||
3766  !(HubFlags & USBHUB_FDO_FLAG_DO_ENUMERATION))
3767  {
3768  goto Exit;
3769  }
3770 
3771  if (HubFlags & USBHUB_FDO_FLAG_NOT_ENUMERATED ||
3772  HubFlags & USBHUB_FDO_FLAG_ENUM_POST_RECOVER ||
3773  HubFlags & USBHUB_FDO_FLAG_DEVICE_FAILED ||
3774  HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPING ||
3775  HubFlags & USBHUB_FDO_FLAG_DEVICE_REMOVED ||
3776  HubFlags & USBHUB_FDO_FLAG_STATE_CHANGING ||
3777  HubFlags & USBHUB_FDO_FLAG_WAKEUP_START ||
3778  HubFlags & USBHUB_FDO_FLAG_ESD_RECOVERING)
3779  {
3780  goto Exit;
3781  }
3782 
3783  if (HubExtension->ResetRequestCount)
3784  {
3785  HubExtension->HubFlags |= USBHUB_FDO_FLAG_DEFER_CHECK_IDLE;
3786  goto Exit;
3787  }
3788 
3789  HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_DEFER_CHECK_IDLE;
3790 
3791  InterlockedIncrement(&HubExtension->PendingRequestCount);
3792 
3793  KeWaitForSingleObject(&HubExtension->ResetDeviceSemaphore,
3794  Executive,
3795  KernelMode,
3796  FALSE,
3797  NULL);
3798 
3800 
3801  IsAllPortsIdle = TRUE;
3802 
3803  PortData = HubExtension->PortData;
3804 
3805  for (Port = 0;
3806  Port < HubExtension->HubDescriptor->bNumberOfPorts;
3807  Port++)
3808  {
3809  PdoDevice = PortData[Port].DeviceObject;
3810 
3811  if (PdoDevice)
3812  {
3813  PortExtension = PdoDevice->DeviceExtension;
3814 
3815  if (!PortExtension->IdleNotificationIrp)
3816  {
3817  DPRINT("USBH_CheckHubIdle: PortExtension - %p\n",
3818  PortExtension);
3819 
3820  IsAllPortsIdle = FALSE;
3821  IsHubCheck = FALSE;
3822 
3823  break;
3824  }
3825  }
3826  }
3827 
3828  if (IsHubCheck &&
3829  !(HubExtension->HubFlags & USBHUB_FDO_FLAG_WAIT_IDLE_REQUEST))
3830  {
3831  KeClearEvent(&HubExtension->IdleEvent);
3832  HubExtension->HubFlags |= USBHUB_FDO_FLAG_WAIT_IDLE_REQUEST;
3833  IsHubIdle = TRUE;
3834  }
3835 
3837 
3838  KeReleaseSemaphore(&HubExtension->ResetDeviceSemaphore,
3840  1,
3841  FALSE);
3842 
3843  if (!InterlockedDecrement(&HubExtension->PendingRequestCount))
3844  {
3845  KeSetEvent(&HubExtension->PendingRequestEvent,
3847  FALSE);
3848  }
3849 
3850  DPRINT("USBH_CheckHubIdle: IsAllPortsIdle - %x, IsHubIdle - %x\n",
3851  IsAllPortsIdle,
3852  IsHubIdle);
3853 
3854  if (IsAllPortsIdle && IsHubIdle)
3855  {
3856  USBH_FdoSubmitIdleRequestIrp(HubExtension);
3857  }
3858 
3859 Exit:
3860  KeAcquireSpinLock(&HubExtension->CheckIdleSpinLock, &Irql);
3861  HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_CHECK_IDLE_LOCK;
3862  KeReleaseSpinLock(&HubExtension->CheckIdleSpinLock, Irql);
3863 }
CPPORT Port[4]
Definition: headless.c:34
#define TRUE
Definition: types.h:120
#define USBHUB_FDO_FLAG_WAKEUP_START
Definition: usbhub.h:49
VOID NTAPI IoAcquireCancelSpinLock(OUT PKIRQL Irql)
Definition: util.c:56
#define USBHUB_FDO_FLAG_CHECK_IDLE_LOCK
Definition: usbhub.h:53
#define LOW_REALTIME_PRIORITY
#define USBHUB_FDO_FLAG_DEVICE_REMOVED
Definition: usbhub.h:46
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
_Out_ PKIRQL Irql
Definition: csq.h:179
#define USBHUB_FDO_FLAG_WAIT_IDLE_REQUEST
Definition: usbhub.h:44
PDEVICE_OBJECT DeviceObject
Definition: usbhub.h:119
UCHAR KIRQL
Definition: env_spec_w32.h:591
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
PUSBHUB_FDO_EXTENSION NTAPI USBH_GetRootHubExtension(IN PUSBHUB_FDO_EXTENSION HubExtension)
Definition: usbhub.c:699
smooth NULL
Definition: ftsmooth.c:416
#define USBHUB_FDO_FLAG_STATE_CHANGING
Definition: usbhub.h:45
void DPRINT(...)
Definition: polytest.cpp:61
#define USBHUB_FDO_FLAG_DO_ENUMERATION
Definition: usbhub.h:52
#define USBHUB_FDO_FLAG_NOT_ENUMERATED
Definition: usbhub.h:55
static void Exit(void)
Definition: sock.c:1331
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define USBHUB_FDO_FLAG_ESD_RECOVERING
Definition: usbhub.h:41
#define USBHUB_FDO_FLAG_DEVICE_STARTED
Definition: usbhub.h:33
#define InterlockedDecrement
Definition: armddk.h:52
VOID NTAPI IoReleaseCancelSpinLock(IN KIRQL Irql)
Definition: util.c:150
#define USBHUB_FDO_FLAG_ENUM_POST_RECOVER
Definition: usbhub.h:51
#define USBHUB_FDO_FLAG_DEFER_CHECK_IDLE
Definition: usbhub.h:48
#define EVENT_INCREMENT
Definition: iotypes.h:564
#define InterlockedIncrement
Definition: armddk.h:53
#define USBHUB_FDO_FLAG_DEVICE_STOPPING
Definition: usbhub.h:34
LONG NTAPI KeReleaseSemaphore(IN PKSEMAPHORE Semaphore, IN KPRIORITY Increment, IN LONG Adjustment, IN BOOLEAN Wait)
Definition: semphobj.c:54
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define USBHUB_FDO_FLAG_DEVICE_FAILED
Definition: usbhub.h:35
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI KeClearEvent(IN PKEVENT Event)
Definition: eventobj.c:22
NTSTATUS NTAPI USBH_FdoSubmitIdleRequestIrp(IN PUSBHUB_FDO_EXTENSION HubExtension)
Definition: usbhub.c:3641

Referenced by USBH_ChangeIndicationWorker(), USBH_CheckIdleWorker(), and USBH_DeviceControl().

◆ USBH_CheckIdleAbort()

BOOLEAN NTAPI USBH_CheckIdleAbort ( IN PUSBHUB_FDO_EXTENSION  HubExtension,
IN BOOLEAN  IsWait,
IN BOOLEAN  IsExtCheck 
)

Definition at line 3140 of file usbhub.c.

3143 {
3144  PDEVICE_OBJECT PdoDevice;
3145  PUSBHUB_PORT_PDO_EXTENSION PortExtension;
3146  PUSBHUB_PORT_DATA PortData;
3147  ULONG Port;
3148  BOOLEAN Result = FALSE;
3149 
3150  DPRINT("USBH_CheckIdleAbort: ... \n");
3151 
3152  InterlockedIncrement(&HubExtension->PendingRequestCount);
3153 
3154  if (IsWait == TRUE)
3155  {
3156  KeWaitForSingleObject(&HubExtension->ResetDeviceSemaphore,
3157  Executive,
3158  KernelMode,
3159  FALSE,
3160  NULL);
3161  }
3162 
3163  PortData = HubExtension->PortData;
3164 
3165  for (Port = 0; Port < HubExtension->HubDescriptor->bNumberOfPorts; Port++)
3166  {
3167  PdoDevice = PortData[Port].DeviceObject;
3168 
3169  if (PdoDevice)
3170  {
3171  PortExtension = PdoDevice->DeviceExtension;
3172 
3173  if (PortExtension->PoRequestCounter)
3174  {
3175  Result = TRUE;
3176  goto Wait;
3177  }
3178  }
3179  }
3180 
3181  if (IsExtCheck == TRUE)
3182  {
3183  PortData = HubExtension->PortData;
3184 
3185  for (Port = 0;
3186  Port < HubExtension->HubDescriptor->bNumberOfPorts;
3187  Port++)
3188  {
3189  PdoDevice = PortData[Port].DeviceObject;
3190 
3191  if (PdoDevice)
3192  {
3193  PortExtension = PdoDevice->DeviceExtension;
3194  InterlockedExchange(&PortExtension->StateBehindD2, 0);
3195  }
3196  }
3197  }
3198 
3199 Wait:
3200 
3201  if (IsWait == TRUE)
3202  {
3203  KeReleaseSemaphore(&HubExtension->ResetDeviceSemaphore,
3205  1,
3206  FALSE);
3207  }
3208 
3209  if (!InterlockedDecrement(&HubExtension->PendingRequestCount))
3210  {
3211  KeSetEvent(&HubExtension->PendingRequestEvent,
3213  FALSE);
3214  }
3215 
3216  return Result;
3217 }
CPPORT Port[4]
Definition: headless.c:34
#define TRUE
Definition: types.h:120
#define LOW_REALTIME_PRIORITY
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
PDEVICE_OBJECT DeviceObject
Definition: usbhub.h:119
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
_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:426
void DPRINT(...)
Definition: polytest.cpp:61
#define InterlockedDecrement
Definition: armddk.h:52
#define InterlockedExchange
Definition: armddk.h:54
#define EVENT_INCREMENT
Definition: iotypes.h:564
#define InterlockedIncrement
Definition: armddk.h:53
LONG NTAPI KeReleaseSemaphore(IN PKSEMAPHORE Semaphore, IN KPRIORITY Increment, IN LONG Adjustment, IN BOOLEAN Wait)
Definition: semphobj.c:54
unsigned int ULONG
Definition: retypes.h:1
IN BOOLEAN Wait
Definition: fatprocs.h:1529

Referenced by USBH_FdoIdleNotificationCallback(), and USBH_FdoPower().

◆ USBH_CheckIdleDeferred()

VOID NTAPI USBH_CheckIdleDeferred ( IN PUSBHUB_FDO_EXTENSION  HubExtension)

Definition at line 3876 of file usbhub.c.

3877 {
3878  PUSBHUB_IO_WORK_ITEM HubIoWorkItem;
3879  NTSTATUS Status;
3880 
3881  DPRINT("USBH_CheckIdleDeferred: HubExtension - %p\n", HubExtension);
3882 
3883  Status = USBH_AllocateWorkItem(HubExtension,
3884  &HubIoWorkItem,
3886  0,
3887  NULL,
3889 
3890  DPRINT("USBH_CheckIdleDeferred: HubIoWorkItem - %p\n", HubIoWorkItem);
3891 
3892  if (NT_SUCCESS(Status))
3893  {
3894  USBH_QueueWorkItem(HubExtension, HubIoWorkItem);
3895  }
3896 }
LONG NTSTATUS
Definition: precomp.h:26
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI USBH_AllocateWorkItem(PUSBHUB_FDO_EXTENSION HubExtension, PUSBHUB_IO_WORK_ITEM *OutHubIoWorkItem, PUSBHUB_WORKER_ROUTINE WorkerRoutine, SIZE_T BufferLength, PVOID *OutHubWorkItemBuffer, WORK_QUEUE_TYPE Type)
Definition: usbhub.c:2710
VOID NTAPI USBH_QueueWorkItem(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PUSBHUB_IO_WORK_ITEM HubIoWorkItem)
Definition: usbhub.c:2836
VOID NTAPI USBH_CheckIdleWorker(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PVOID Context)
Definition: usbhub.c:3867
Status
Definition: gdiplustypes.h:24

Referenced by USBH_FdoDeferPoRequestCompletion(), USBH_FdoPnP(), USBH_FdoPower(), USBH_PdoRemoveDevice(), and USBH_PortIdleNotificationRequest().

◆ USBH_CompleteIrp()

VOID NTAPI USBH_CompleteIrp ( IN PIRP  Irp,
IN NTSTATUS  CompleteStatus 
)

Definition at line 63 of file usbhub.c.

65 {
66  if (CompleteStatus != STATUS_SUCCESS)
67  {
68  DPRINT1("USBH_CompleteIrp: Irp - %p, CompleteStatus - %X\n",
69  Irp,
70  CompleteStatus);
71  }
72 
73  Irp->IoStatus.Status = CompleteStatus;
75 }
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
#define DPRINT1
Definition: precomp.h:8
#define IO_NO_INCREMENT
Definition: iotypes.h:565
return STATUS_SUCCESS
Definition: btrfs.c:2745

Referenced by USBH_DeviceControl(), USBH_FdoDispatch(), USBH_FdoQueryBusRelations(), USBH_FdoStartDevice(), USBH_IoctlGetDescriptor(), USBH_IoctlGetHubCapabilities(), USBH_IoctlGetNodeConnectionAttributes(), USBH_IoctlGetNodeConnectionDriverKeyName(), USBH_IoctlGetNodeConnectionInformation(), USBH_IoctlGetNodeInformation(), USBH_IoctlGetNodeName(), USBH_PdoDispatch(), USBH_PdoInternalControl(), USBH_PdoIoctlGetPortStatus(), USBH_PdoIoctlResetPort(), USBH_PdoUrbFilter(), USBH_ResetPortWorker(), and USBH_StartHubFdoDevice().

◆ USBH_CompletePowerIrp()

VOID NTAPI USBH_CompletePowerIrp ( IN PUSBHUB_FDO_EXTENSION  HubExtension,
IN PIRP  Irp,
IN NTSTATUS  NtStatus 
)

Definition at line 18 of file power.c.

21 {
22  DPRINT("USBH_CompletePowerIrp: HubExtension - %p, Irp - %p, NtStatus - %lX\n",
23  HubExtension,
24  Irp,
25  NtStatus);
26 
27  Irp->IoStatus.Status = NtStatus;
28 
30 
31  if (!InterlockedDecrement(&HubExtension->PendingRequestCount))
32  {
33  KeSetEvent(&HubExtension->PendingRequestEvent,
35  FALSE);
36  }
37 
39 }
_In_ PIRP Irp
Definition: csq.h:116
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
#define InterlockedDecrement
Definition: armddk.h:52
#define EVENT_INCREMENT
Definition: iotypes.h:564
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:626
#define IO_NO_INCREMENT
Definition: iotypes.h:565

Referenced by USBH_FdoCleanup(), and USBH_PdoRemoveDevice().

◆ USBH_CreateDevice()

NTSTATUS NTAPI USBH_CreateDevice ( IN PUSBHUB_FDO_EXTENSION  HubExtension,
IN USHORT  Port,
IN USB_PORT_STATUS  UsbPortStatus,
IN ULONG  IsWait 
)

Definition at line 4298 of file usbhub.c.

4302 {
4303  ULONG PdoNumber = 0;
4304  WCHAR CharDeviceName[64];
4307  PUSBHUB_PORT_PDO_EXTENSION PortExtension;
4309  LPWSTR SerialNumberBuffer;
4310  BOOLEAN IsHsDevice;
4311  BOOLEAN IsLsDevice;
4312  BOOLEAN IgnoringHwSerial = FALSE;
4313  NTSTATUS Status;
4315 
4316  DPRINT("USBH_CreateDevice: Port - %x, UsbPortStatus - %lX\n",
4317  Port,
4318  UsbPortStatus.AsUshort16);
4319 
4320  do
4321  {
4322  RtlStringCbPrintfW(CharDeviceName,
4323  sizeof(CharDeviceName),
4324  L"\\Device\\USBPDO-%d",
4325  PdoNumber);
4326 
4327  RtlInitUnicodeString(&DeviceName, CharDeviceName);
4328 
4329  Status = IoCreateDevice(HubExtension->Common.SelfDevice->DriverObject,
4330  sizeof(USBHUB_PORT_PDO_EXTENSION),
4331  &DeviceName,
4333  0,
4334  FALSE,
4335  &DeviceObject);
4336 
4337  ++PdoNumber;
4338  }
4340 
4341  if (!NT_SUCCESS(Status))
4342  {
4343  ASSERT(Port > 0);
4344  HubExtension->PortData[Port-1].DeviceObject = DeviceObject;
4345  return Status;
4346  }
4347 
4348  DeviceObject->StackSize = HubExtension->RootHubPdo2->StackSize;
4349 
4350  PortExtension = DeviceObject->DeviceExtension;
4351 
4352  DPRINT("USBH_CreateDevice: PortDevice - %p, <%wZ>\n", DeviceObject, &DeviceName);
4353  DPRINT("USBH_CreateDevice: PortExtension - %p\n", PortExtension);
4354 
4355  RtlZeroMemory(PortExtension, sizeof(USBHUB_PORT_PDO_EXTENSION));
4356 
4357  PortExtension->Common.ExtensionType = USBH_EXTENSION_TYPE_PORT;
4358  PortExtension->Common.SelfDevice = DeviceObject;
4359 
4360  PortExtension->HubExtension = HubExtension;
4361  PortExtension->RootHubExtension = HubExtension;
4362 
4363  PortExtension->PortNumber = Port;
4364  PortExtension->CurrentPowerState.DeviceState = PowerDeviceD0;
4365  PortExtension->IgnoringHwSerial = FALSE;
4366 
4367  KeInitializeSpinLock(&PortExtension->PortTimeoutSpinLock);
4368 
4369  InitializeListHead(&PortExtension->PortPowerList);
4371 
4372  PortExtension->PoRequestCounter = 0;
4373  PortExtension->PendingSystemPoRequest = 0;
4374  PortExtension->PendingDevicePoRequest = 0;
4375  PortExtension->StateBehindD2 = 0;
4376 
4377  SerialNumberBuffer = NULL;
4378 
4379  IsHsDevice = UsbPortStatus.Usb20PortStatus.HighSpeedDeviceAttached;
4380  IsLsDevice = UsbPortStatus.Usb20PortStatus.LowSpeedDeviceAttached;
4381 
4382  if (IsLsDevice == 0)
4383  {
4384  if (IsHsDevice)
4385  {
4387  }
4388  }
4389  else
4390  {
4392  }
4393 
4394  /* Initialize PortExtension->InstanceID */
4396  DestinationString.MaximumLength = 4 * sizeof(WCHAR);
4398 
4401 
4402  if (!NT_SUCCESS(Status))
4403  {
4404  DPRINT1("USBH_CreateDevice: IoCreateDevice() failed - %lX\n", Status);
4405  goto ErrorExit;
4406  }
4407 
4408  Status = USBD_CreateDeviceEx(HubExtension,
4409  &PortExtension->DeviceHandle,
4410  UsbPortStatus,
4411  Port);
4412 
4413  if (!NT_SUCCESS(Status))
4414  {
4415  DPRINT1("USBH_CreateDevice: USBD_CreateDeviceEx() failed - %lX\n", Status);
4416  goto ErrorExit;
4417  }
4418 
4419  Status = USBH_SyncResetPort(HubExtension, Port);
4420 
4421  if (!NT_SUCCESS(Status))
4422  {
4423  DPRINT1("USBH_CreateDevice: USBH_SyncResetPort() failed - %lX\n", Status);
4424  goto ErrorExit;
4425  }
4426 
4427  if (IsWait)
4428  {
4429  USBH_Wait(50);
4430  }
4431 
4432  Status = USBD_InitializeDeviceEx(HubExtension,
4433  PortExtension->DeviceHandle,
4434  (PUCHAR)&PortExtension->DeviceDescriptor,
4435  sizeof(USB_DEVICE_DESCRIPTOR),
4436  (PUCHAR)&PortExtension->ConfigDescriptor,
4438 
4439  if (!NT_SUCCESS(Status))
4440  {
4441  DPRINT1("USBH_CreateDevice: USBD_InitializeDeviceEx() failed - %lX\n", Status);
4442  PortExtension->DeviceHandle = NULL;
4443  goto ErrorExit;
4444  }
4445 
4446  DPRINT1("USBH_RegQueryDeviceIgnoreHWSerNumFlag UNIMPLEMENTED. FIXME\n");
4447  //Status = USBH_RegQueryDeviceIgnoreHWSerNumFlag(PortExtension->DeviceDescriptor.idVendor,
4448  // PortExtension->DeviceDescriptor.idProduct,
4449  // &IgnoringHwSerial);
4450 
4451  if (TRUE)//Status == STATUS_OBJECT_NAME_NOT_FOUND)
4452  {
4453  IgnoringHwSerial = FALSE;
4454  }
4455 
4456  if (IgnoringHwSerial)
4457  {
4458  PortExtension->IgnoringHwSerial = TRUE;
4459  }
4460 
4461  if (PortExtension->DeviceDescriptor.iSerialNumber &&
4462  !PortExtension->IgnoringHwSerial)
4463  {
4465 
4466  USBH_GetSerialNumberString(PortExtension->Common.SelfDevice,
4467  &SerialNumberBuffer,
4468  &PortExtension->SN_DescriptorLength,
4470  PortExtension->DeviceDescriptor.iSerialNumber);
4471 
4472  if (SerialNumberBuffer)
4473  {
4474  if (!USBH_ValidateSerialNumberString((PUSHORT)SerialNumberBuffer))
4475  {
4476  ExFreePoolWithTag(SerialNumberBuffer, USB_HUB_TAG);
4477  SerialNumberBuffer = NULL;
4478  }
4479 
4480  if (SerialNumberBuffer &&
4481  !USBH_CheckDeviceIDUnique(HubExtension,
4482  PortExtension->DeviceDescriptor.idVendor,
4483  PortExtension->DeviceDescriptor.idProduct,
4484  SerialNumberBuffer,
4485  PortExtension->SN_DescriptorLength))
4486  {
4487  ExFreePoolWithTag(SerialNumberBuffer, USB_HUB_TAG);
4488  SerialNumberBuffer = NULL;
4489  }
4490  }
4491 
4493  SerialNumberBuffer);
4494  }
4495 
4496  Status = USBH_ProcessDeviceInformation(PortExtension);
4497 
4498  USBH_PdoSetCapabilities(PortExtension);
4499 
4500  if (NT_SUCCESS(Status))
4501  {
4502  goto Exit;
4503  }
4504 
4505 ErrorExit:
4506 
4508 
4510  NULL);
4511 
4512  if (DeviceHandle)
4513  {
4514  USBD_RemoveDeviceEx(HubExtension, DeviceHandle, 0);
4515  }
4516 
4517  SerialNumberBuffer = InterlockedExchangePointer((PVOID)&PortExtension->SerialNumber,
4518  NULL);
4519 
4520  if (SerialNumberBuffer)
4521  {
4522  ExFreePoolWithTag(SerialNumberBuffer, USB_HUB_TAG);
4523  }
4524 
4525 Exit:
4526 
4527  ASSERT(Port > 0);
4528  HubExtension->PortData[Port-1].DeviceObject = DeviceObject;
4529  return Status;
4530 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define STATUS_OBJECT_NAME_COLLISION
Definition: udferr_usr.h:150
#define DO_POWER_PAGABLE
#define USBH_EXTENSION_TYPE_PORT
Definition: usbhub.h:29
CPPORT Port[4]
Definition: headless.c:34
const uint16_t * PCWSTR
Definition: typedefs.h:55
PUSB_DEVICE_HANDLE DeviceHandle
Definition: usbhub.h:211
#define USBHUB_PDO_FLAG_INIT_PORT_FAILED
Definition: usbhub.h:63
#define TRUE
Definition: types.h:120
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121
NTSTATUS NTAPI USBH_GetSerialNumberString(IN PDEVICE_OBJECT DeviceObject, IN LPWSTR *OutSerialNumber, IN PUSHORT OutDescriptorLength, IN USHORT LanguageId, IN UCHAR Index)
Definition: usbhub.c:4223
unsigned char * PUCHAR
Definition: retypes.h:3
#define FILE_DEVICE_USB
Definition: usbiodef.h:71
PUSBHUB_FDO_EXTENSION HubExtension
Definition: usbhub.h:209
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI USBH_Wait(IN ULONG Milliseconds)
Definition: usbhub.c:23
USB_CONFIGURATION_DESCRIPTOR ConfigDescriptor
Definition: usbhub.h:218
WCHAR DeviceName[]
Definition: adapter.cpp:21
#define SUBLANG_ENGLISH_US
Definition: nls.h:222
POWER_STATE CurrentPowerState
Definition: usbhub.h:222
#define USBHUB_PDO_FLAG_PORT_HIGH_SPEED
Definition: usbhub.h:81
COMMON_DEVICE_EXTENSION Common
Definition: usbhub.h:204
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
NTSTATUS NTAPI USBD_InitializeDeviceEx(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PUSB_DEVICE_HANDLE DeviceHandle, IN PUCHAR DeviceDescriptorBuffer, IN ULONG DeviceDescriptorBufferLength, IN PUCHAR ConfigDescriptorBuffer, IN ULONG ConfigDescriptorBufferLength)
Definition: usbhub.c:2481
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1869
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI USBH_SyncResetPort(IN PUSBHUB_FDO_EXTENSION HubExtension, IN USHORT Port)
Definition: usbhub.c:471
void DPRINT(...)
Definition: polytest.cpp:61
#define USB_HUB_TAG
Definition: usbhub.h:9
KSPIN_LOCK PortPowerListSpinLock
Definition: usbhub.h:234
USB_DEVICE_DESCRIPTOR DeviceDescriptor
Definition: usbhub.h:216
NTSYSAPI NTSTATUS NTAPI RtlIntegerToUnicodeString(ULONG Value, ULONG Base, PUNICODE_STRING String)
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static void Exit(void)
Definition: sock.c:1331
DEVICE_POWER_STATE DeviceState
Definition: ntpoapi.h:58
NTSTATUS NTAPI USBD_RemoveDeviceEx(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PUSB_DEVICE_HANDLE DeviceHandle, IN ULONG Flags)
Definition: usbhub.c:2457
#define LANG_ENGLISH
Definition: nls.h:52
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR L[]
Definition: oid.c:1250
BOOLEAN NTAPI USBH_CheckDeviceIDUnique(IN PUSBHUB_FDO_EXTENSION HubExtension, IN USHORT idVendor, IN USHORT idProduct, IN PVOID SerialNumber, IN USHORT SN_DescriptorLength)
Definition: usbhub.c:4086
static __inline NTSTATUS RtlStringCbPrintfW(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1120
Status
Definition: gdiplustypes.h:24
KSPIN_LOCK PortTimeoutSpinLock
Definition: usbhub.h:226
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
LIST_ENTRY PortPowerList
Definition: usbhub.h:233
NTSTATUS NTAPI USBD_CreateDeviceEx(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PUSB_DEVICE_HANDLE *OutDeviceHandle, IN USB_PORT_STATUS UsbPortStatus, IN USHORT Port)
Definition: usbhub.c:2427
static VOID ErrorExit(LPTSTR lpszMessage)
Definition: telnetd.c:647
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define USBHUB_PDO_FLAG_PORT_LOW_SPEED
Definition: usbhub.h:64
#define DPRINT1
Definition: precomp.h:8
BOOLEAN NTAPI USBH_ValidateSerialNumberString(IN PUSHORT SerialNumberString)
Definition: usbhub.c:4138
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS NTAPI IoCreateDevice(IN PDRIVER_OBJECT DriverObject, IN ULONG DeviceExtensionSize, IN PUNICODE_STRING DeviceName, IN DEVICE_TYPE DeviceType, IN ULONG DeviceCharacteristics, IN BOOLEAN Exclusive, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1031
#define MAKELANGID(p, s)
Definition: nls.h:15
PUSBHUB_FDO_EXTENSION RootHubExtension
Definition: usbhub.h:210
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
WCHAR * LPWSTR
Definition: xmlstorage.h:184
unsigned short MaximumLength
Definition: sprintf.c:452
VOID NTAPI USBH_PdoSetCapabilities(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension)
Definition: usbhub.c:3900
unsigned short * PUSHORT
Definition: retypes.h:2
NTSTATUS NTAPI USBH_ProcessDeviceInformation(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension)
Definition: usbhub.c:3975

Referenced by USBH_FdoQueryBusRelations().

◆ USBH_DeviceControl()

NTSTATUS NTAPI USBH_DeviceControl ( IN PUSBHUB_FDO_EXTENSION  HubExtension,
IN PIRP  Irp 
)

Definition at line 1130 of file ioctl.c.

1132 {
1134  PIO_STACK_LOCATION IoStack;
1136  BOOLEAN IsCheckHubIdle = FALSE;
1137 
1138  DPRINT("USBH_DeviceControl: HubExtension - %p, Irp - %p\n",
1139  HubExtension,
1140  Irp);
1141 
1142  IoStack = IoGetCurrentIrpStackLocation(Irp);
1143  ControlCode = IoStack->Parameters.DeviceIoControl.IoControlCode;
1144  DPRINT("USBH_DeviceControl: ControlCode - %lX\n", ControlCode);
1145 
1146  if ((HubExtension->CurrentPowerState.DeviceState != PowerDeviceD0) &&
1147  (HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STARTED))
1148  {
1149  IsCheckHubIdle = TRUE;
1150  USBH_HubSetD0(HubExtension);
1151  }
1152 
1153  switch (ControlCode)
1154  {
1155  case IOCTL_USB_GET_HUB_CAPABILITIES:
1156  DPRINT("USBH_DeviceControl: IOCTL_USB_GET_HUB_CAPABILITIES\n");
1157  if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED))
1158  {
1159  Status = USBH_IoctlGetHubCapabilities(HubExtension, Irp);
1160  break;
1161  }
1162 
1164  break;
1165 
1166  case IOCTL_USB_HUB_CYCLE_PORT:
1167  DPRINT1("USBH_DeviceControl: IOCTL_USB_HUB_CYCLE_PORT UNIMPLEMENTED. FIXME\n");
1168  DbgBreakPoint();
1169  break;
1170 
1172  DPRINT("USBH_DeviceControl: IOCTL_USB_GET_NODE_INFORMATION\n");
1173  if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED))
1174  {
1175  Status = USBH_IoctlGetNodeInformation(HubExtension, Irp);
1176  break;
1177  }
1178 
1180  break;
1181 
1183  DPRINT("USBH_DeviceControl: IOCTL_USB_GET_NODE_CONNECTION_INFORMATION\n");
1184  if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED))
1185  {
1187  Irp,
1188  FALSE);
1189  break;
1190  }
1191 
1193  break;
1194 
1195  case IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX:
1196  DPRINT("USBH_DeviceControl: IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX\n");
1197  if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED))
1198  {
1200  Irp,
1201  TRUE);
1202  break;
1203  }
1204 
1206  break;
1207 
1208  case IOCTL_USB_GET_NODE_CONNECTION_ATTRIBUTES:
1209  DPRINT("USBH_DeviceControl: IOCTL_USB_GET_NODE_CONNECTION_ATTRIBUTES\n");
1210  if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED))
1211  {
1213  break;
1214  }
1215 
1217  break;
1218 
1220  DPRINT("USBH_DeviceControl: IOCTL_USB_GET_NODE_CONNECTION_NAME\n");
1221  if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED))
1222  {
1223  Status = USBH_IoctlGetNodeName(HubExtension, Irp);
1224  break;
1225  }
1226 
1228  break;
1229 
1231  DPRINT("USBH_DeviceControl: IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME\n");
1232  if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED))
1233  {
1235  break;
1236  }
1237 
1239  break;
1240 
1242  DPRINT("USBH_DeviceControl: IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION\n");
1243  if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED))
1244  {
1245  Status = USBH_IoctlGetDescriptor(HubExtension, Irp);
1246  break;
1247  }
1248 
1250  break;
1251 
1252  case IOCTL_KS_PROPERTY:
1253  DPRINT("USBH_DeviceControl: IOCTL_KS_PROPERTY\n");
1256  break;
1257 
1258  default:
1259  DPRINT1("USBH_DeviceControl: Unhandled IOCTL_ - %lX\n", ControlCode);
1260  Status = USBH_PassIrp(HubExtension->RootHubPdo, Irp);
1261  break;
1262  }
1263 
1264  if (IsCheckHubIdle)
1265  {
1266  USBH_CheckHubIdle(HubExtension);
1267  }
1268 
1269  return Status;
1270 }
NTSTATUS NTAPI USBH_PassIrp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: usbhub.c:79
#define IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION
Definition: usbioctl.h:175
#define IOCTL_KS_PROPERTY
Definition: ks.h:150
#define IOCTL_USB_GET_NODE_CONNECTION_INFORMATION
Definition: usbioctl.h:172
#define TRUE
Definition: types.h:120
#define USBHUB_FDO_FLAG_DEVICE_STOPPED
Definition: usbhub.h:37
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME
Definition: usbioctl.h:187
void DbgBreakPoint()
Definition: mach.c:558
NTSTATUS NTAPI USBH_IoctlGetNodeName(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
Definition: ioctl.c:557
NTSTATUS NTAPI USBH_IoctlGetDescriptor(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
Definition: ioctl.c:1018
VOID NTAPI USBH_CompleteIrp(IN PIRP Irp, IN NTSTATUS CompleteStatus)
Definition: usbhub.c:63
unsigned char BOOLEAN
#define IOCTL_USB_GET_NODE_CONNECTION_NAME
Definition: usbioctl.h:178
void DPRINT(...)
Definition: polytest.cpp:61
_IRQL_requires_same_ typedef _In_ ULONG ControlCode
Definition: wmitypes.h:55
NTSTATUS NTAPI USBH_IoctlGetNodeConnectionAttributes(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
Definition: ioctl.c:773
NTSTATUS NTAPI USBH_IoctlGetNodeConnectionDriverKeyName(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
Definition: ioctl.c:941
#define USBHUB_FDO_FLAG_DEVICE_STARTED
Definition: usbhub.h:33
Status
Definition: gdiplustypes.h:24
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
#define STATUS_DEVICE_BUSY
Definition: udferr_usr.h:129
NTSTATUS NTAPI USBH_IoctlGetNodeConnectionInformation(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp, IN BOOLEAN IsExt)
Definition: ioctl.c:828
NTSTATUS NTAPI USBH_IoctlGetHubCapabilities(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
Definition: ioctl.c:725
#define DPRINT1
Definition: precomp.h:8
NTSTATUS NTAPI USBH_IoctlGetNodeInformation(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
Definition: ioctl.c:678
NTSTATUS NTAPI USBH_HubSetD0(IN PUSBHUB_FDO_EXTENSION HubExtension)
Definition: power.c:77
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI USBH_CheckHubIdle(IN PUSBHUB_FDO_EXTENSION HubExtension)
Definition: usbhub.c:3727
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
#define IOCTL_USB_GET_NODE_INFORMATION
Definition: usbioctl.h:169

Referenced by USBH_FdoDispatch().

◆ USBH_FdoPnP()

NTSTATUS NTAPI USBH_FdoPnP ( IN PUSBHUB_FDO_EXTENSION  HubExtension,
IN PIRP  Irp,
IN UCHAR  Minor 
)

Definition at line 2355 of file pnp.c.

2358 {
2359  NTSTATUS Status;
2360  PIO_STACK_LOCATION IoStack;
2361  DEVICE_RELATION_TYPE RelationsType;
2362  BOOLEAN IsCheckIdle;
2363 
2364  DPRINT_PNP("USBH_FdoPnP: HubExtension - %p, Irp - %p, Minor - %X\n",
2365  HubExtension,
2366  Irp,
2367  Minor);
2368 
2369  if (HubExtension->HubFlags & USBHUB_FDO_FLAG_WAIT_IDLE_REQUEST &&
2371  {
2372  HubExtension->HubFlags |= USBHUB_FDO_FLAG_DEVICE_SUSPENDED;
2373  }
2374 
2375  KeWaitForSingleObject(&HubExtension->IdleSemaphore,
2376  Executive,
2377  KernelMode,
2378  FALSE,
2379  NULL);
2380 
2381  DPRINT_PNP("USBH_FdoPnP: HubFlags - %lX\n", HubExtension->HubFlags);
2382 
2383  if (HubExtension->HubFlags & USBHUB_FDO_FLAG_GOING_IDLE)
2384  {
2385  HubExtension->HubFlags |= USBHUB_FDO_FLAG_DEVICE_SUSPENDED;
2386  }
2387 
2388  IoStack = IoGetCurrentIrpStackLocation(Irp);
2389  RelationsType = IoStack->Parameters.QueryDeviceRelations.Type;
2390 
2391  if ((HubExtension->CurrentPowerState.DeviceState == PowerDeviceD0) ||
2392  !(HubExtension->HubFlags & (USBHUB_FDO_FLAG_DEVICE_STOPPED | USBHUB_FDO_FLAG_DEVICE_STARTED)) ||
2393  (Minor == IRP_MN_QUERY_DEVICE_RELATIONS && RelationsType == TargetDeviceRelation))
2394  {
2395  IsCheckIdle = FALSE;
2396  }
2397  else
2398  {
2399  DPRINT_PNP("USBH_FdoPnP: IsCheckIdle - TRUE\n");
2400  IsCheckIdle = TRUE;
2401  USBH_HubSetD0(HubExtension);
2402  }
2403 
2404  switch (Minor)
2405  {
2406  case IRP_MN_START_DEVICE:
2407  DPRINT_PNP("FDO IRP_MN_START_DEVICE\n");
2408  IsCheckIdle = FALSE;
2409  Irp->IoStatus.Status = STATUS_SUCCESS;
2410  Status = USBH_FdoStartDevice(HubExtension, Irp);
2411  break;
2412 
2414  DPRINT_PNP("FDO IRP_MN_QUERY_REMOVE_DEVICE\n");
2415  Irp->IoStatus.Status = STATUS_SUCCESS;
2416  Status = USBH_PassIrp(HubExtension->LowerDevice, Irp);
2417  break;
2418 
2419  case IRP_MN_REMOVE_DEVICE:
2420  DPRINT_PNP("FDO IRP_MN_REMOVE_DEVICE\n");
2421  IsCheckIdle = FALSE;
2422  HubExtension->HubFlags |= USBHUB_FDO_FLAG_DEVICE_REMOVED;
2423  Irp->IoStatus.Status = STATUS_SUCCESS;
2424  Status = USBH_FdoRemoveDevice(HubExtension, Irp);
2425  break;
2426 
2428  DPRINT_PNP("FDO IRP_MN_CANCEL_REMOVE_DEVICE\n");
2429  Irp->IoStatus.Status = STATUS_SUCCESS;
2430  Status = USBH_PassIrp(HubExtension->LowerDevice, Irp);
2431  break;
2432 
2433  case IRP_MN_STOP_DEVICE:
2434  DPRINT_PNP("FDO IRP_MN_STOP_DEVICE\n");
2435  IsCheckIdle = FALSE;
2436  Irp->IoStatus.Status = STATUS_SUCCESS;
2437  Status = USBH_FdoStopDevice(HubExtension, Irp);
2438  break;
2439 
2441  DPRINT_PNP("FDO IRP_MN_QUERY_STOP_DEVICE\n");
2442  Irp->IoStatus.Status = STATUS_SUCCESS;
2443  Status = USBH_PassIrp(HubExtension->LowerDevice, Irp);
2444  break;
2445 
2447  DPRINT_PNP("FDO IRP_MN_CANCEL_STOP_DEVICE\n");
2448  Irp->IoStatus.Status = STATUS_SUCCESS;
2449  Status = USBH_PassIrp(HubExtension->LowerDevice, Irp);
2450  break;
2451 
2453  DPRINT_PNP("FDO IRP_MN_QUERY_DEVICE_RELATIONS\n");
2454 
2455  if (RelationsType != BusRelations)
2456  {
2457  Status = USBH_PassIrp(HubExtension->LowerDevice, Irp);
2458  break;
2459  }
2460 
2461  HubExtension->HubFlags |= USBHUB_FDO_FLAG_HUB_BUSY;
2462 
2463  IsCheckIdle = TRUE;
2464  DPRINT_PNP("USBH_FdoPnP: IsCheckIdle - TRUE\n");
2465 
2466  Status = USBH_FdoQueryBusRelations(HubExtension, Irp);
2467 
2468  HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_HUB_BUSY;
2469  break;
2470 
2472  DPRINT_PNP("FDO IRP_MN_QUERY_INTERFACE\n");
2473  Status = USBH_PassIrp(HubExtension->LowerDevice, Irp);
2474  break;
2475 
2477  DPRINT_PNP("FDO IRP_MN_QUERY_CAPABILITIES\n");
2479 
2482  HubExtension,
2483  TRUE,
2484  FALSE,
2485  FALSE);
2486 
2487  Status = IoCallDriver(HubExtension->LowerDevice, Irp);
2488  break;
2489 
2491  DPRINT_PNP("FDO IRP_MN_QUERY_RESOURCES\n");
2492  Status = USBH_PassIrp(HubExtension->LowerDevice, Irp);
2493  break;
2494 
2496  DPRINT_PNP("FDO IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n");
2497  Status = USBH_PassIrp(HubExtension->LowerDevice, Irp);
2498  break;
2499 
2501  DPRINT_PNP("FDO IRP_MN_QUERY_DEVICE_TEXT\n");
2502  Status = USBH_PassIrp(HubExtension->LowerDevice, Irp);
2503  break;
2504 
2506  DPRINT_PNP("FDO IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n");
2507  Status = USBH_PassIrp(HubExtension->LowerDevice, Irp);
2508  break;
2509 
2510  case IRP_MN_READ_CONFIG:
2511  DPRINT_PNP("FDO IRP_MN_READ_CONFIG\n");
2512  Status = USBH_PassIrp(HubExtension->LowerDevice, Irp);
2513  break;
2514 
2515  case IRP_MN_WRITE_CONFIG:
2516  DPRINT_PNP("FDO IRP_MN_WRITE_CONFIG\n");
2517  Status = USBH_PassIrp(HubExtension->LowerDevice, Irp);
2518  break;
2519 
2520  case IRP_MN_EJECT:
2521  DPRINT_PNP("FDO IRP_MN_EJECT\n");
2522  Status = USBH_PassIrp(HubExtension->LowerDevice, Irp);
2523  break;
2524 
2525  case IRP_MN_SET_LOCK:
2526  DPRINT_PNP("FDO IRP_MN_SET_LOCK\n");
2527  Status = USBH_PassIrp(HubExtension->LowerDevice, Irp);
2528  break;
2529 
2530  case IRP_MN_QUERY_ID:
2531  DPRINT_PNP("FDO IRP_MN_QUERY_ID\n");
2532  Status = USBH_PassIrp(HubExtension->LowerDevice, Irp);
2533  break;
2534 
2536  DPRINT_PNP("FDO IRP_MN_QUERY_PNP_DEVICE_STATE\n");
2537 
2538  if (HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_FAILED)
2539  {
2540  Irp->IoStatus.Information |= PNP_DEVICE_FAILED;
2541  }
2542 
2543  Status = USBH_PassIrp(HubExtension->LowerDevice, Irp);
2544  break;
2545 
2547  DPRINT_PNP("FDO IRP_MN_QUERY_BUS_INFORMATION\n");
2548  Status = USBH_PassIrp(HubExtension->LowerDevice, Irp);
2549  break;
2550 
2552  DPRINT_PNP("FDO IRP_MN_DEVICE_USAGE_NOTIFICATION\n");
2553  Irp->IoStatus.Status = STATUS_SUCCESS;
2554  Status = USBH_PassIrp(HubExtension->LowerDevice, Irp);
2555  break;
2556 
2558  DPRINT_PNP("FDO IRP_MN_SURPRISE_REMOVAL\n");
2559  USBH_FdoSurpriseRemoveDevice(HubExtension, Irp);
2560  Status = USBH_PassIrp(HubExtension->LowerDevice, Irp);
2561  break;
2562 
2563  default:
2564  DPRINT_PNP("FDO unknown IRP_MN_???\n");
2565  Status = USBH_PassIrp(HubExtension->LowerDevice, Irp);
2566  break;
2567  }
2568 
2569  KeReleaseSemaphore(&HubExtension->IdleSemaphore,
2571  1,
2572  FALSE);
2573 
2574  if (IsCheckIdle)
2575  {
2576  DPRINT_PNP("USBH_FdoPnP: call USBH_CheckIdleDeferred()\n");
2577  USBH_CheckIdleDeferred(HubExtension);
2578  }
2579 
2580  HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_STATE_CHANGING;
2581 
2582  return Status;
2583 }
NTSTATUS NTAPI USBH_PassIrp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: usbhub.c:79
NTSTATUS NTAPI USBH_FdoStartDevice(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
Definition: pnp.c:988
_Out_opt_ PULONG Minor
Definition: cmfuncs.h:44
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define TRUE
Definition: types.h:120
#define IRP_MN_QUERY_RESOURCES
#define IRP_MN_REMOVE_DEVICE
#define IRP_MN_QUERY_ID
#define USBHUB_FDO_FLAG_DEVICE_STOPPED
Definition: usbhub.h:37
_In_ PIRP Irp
Definition: csq.h:116
#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS
#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS
#define IRP_MN_WRITE_CONFIG
LONG NTSTATUS
Definition: precomp.h:26
#define LOW_REALTIME_PRIORITY
#define USBHUB_FDO_FLAG_DEVICE_REMOVED
Definition: usbhub.h:46
#define IRP_MN_EJECT
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define USBHUB_FDO_FLAG_WAIT_IDLE_REQUEST
Definition: usbhub.h:44
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2820
#define IRP_MN_QUERY_REMOVE_DEVICE
#define USBHUB_FDO_FLAG_GOING_IDLE
Definition: usbhub.h:57
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI USBH_CheckIdleDeferred(IN PUSBHUB_FDO_EXTENSION HubExtension)
Definition: usbhub.c:3876
#define USBHUB_FDO_FLAG_STATE_CHANGING
Definition: usbhub.h:45
#define IRP_MN_READ_CONFIG
enum _DEVICE_RELATION_TYPE DEVICE_RELATION_TYPE
#define IRP_MN_QUERY_STOP_DEVICE
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
#define IRP_MN_STOP_DEVICE
#define USBHUB_FDO_FLAG_DEVICE_SUSPENDED
Definition: usbhub.h:58
#define IRP_MN_START_DEVICE
#define IRP_MN_QUERY_DEVICE_TEXT
#define IRP_MN_QUERY_INTERFACE
VOID NTAPI USBH_FdoSurpriseRemoveDevice(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
Definition: pnp.c:1517
#define IRP_MN_QUERY_BUS_INFORMATION
#define USBHUB_FDO_FLAG_HUB_BUSY
Definition: usbhub.h:38
#define USBHUB_FDO_FLAG_DEVICE_STARTED
Definition: usbhub.h:33
#define PNP_DEVICE_FAILED
Definition: iotypes.h:965
NTSTATUS NTAPI USBH_QueryCapsComplete(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: pnp.c:59
Status
Definition: gdiplustypes.h:24
#define DPRINT_PNP(...)
Definition: dbg_uhub.h:109
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
NTSTATUS NTAPI USBH_FdoQueryBusRelations(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
Definition: pnp.c:1027
NTSTATUS NTAPI USBH_FdoStopDevice(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
Definition: pnp.c:1446
LONG NTAPI KeReleaseSemaphore(IN PKSEMAPHORE Semaphore, IN KPRIORITY Increment, IN LONG Adjustment, IN BOOLEAN Wait)
Definition: semphobj.c:54
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IRP_MN_QUERY_DEVICE_RELATIONS
NTSTATUS NTAPI USBH_HubSetD0(IN PUSBHUB_FDO_EXTENSION HubExtension)
Definition: power.c:77
#define IRP_MN_SET_LOCK
#define USBHUB_FDO_FLAG_DEVICE_FAILED
Definition: usbhub.h:35
#define IRP_MN_CANCEL_STOP_DEVICE
#define IRP_MN_DEVICE_USAGE_NOTIFICATION
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
return STATUS_SUCCESS
Definition: btrfs.c:2745
#define IRP_MN_QUERY_PNP_DEVICE_STATE
#define IRP_MN_QUERY_CAPABILITIES
NTSTATUS NTAPI USBH_FdoRemoveDevice(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PIRP Irp)
Definition: pnp.c:1456

Referenced by USBH_FdoDispatch().

◆ USBH_FdoPower()

NTSTATUS NTAPI USBH_FdoPower ( IN PUSBHUB_FDO_EXTENSION  HubExtension,
IN PIRP  Irp,
IN UCHAR  Minor 
)

Definition at line 460 of file power.c.

463 {
465  PIO_STACK_LOCATION IoStack;
467  POWER_STATE DevicePwrState;
468  BOOLEAN IsAllPortsD3;
469  PUSBHUB_PORT_DATA PortData;
470  PDEVICE_OBJECT PdoDevice;
471  PUSBHUB_PORT_PDO_EXTENSION PortExtension;
472  ULONG Port;
473 
474  DPRINT_PWR("USBH_FdoPower: HubExtension - %p, Irp - %p, Minor - %X\n",
475  HubExtension,
476  Irp,
477  Minor);
478 
479  switch (Minor)
480  {
481  case IRP_MN_WAIT_WAKE:
482  DPRINT_PWR("USBH_FdoPower: IRP_MN_WAIT_WAKE\n");
483 
485 
488  HubExtension,
489  TRUE,
490  TRUE,
491  TRUE);
492 
495  PoCallDriver(HubExtension->LowerDevice, Irp);
496 
497  return STATUS_PENDING;
498 
500  DPRINT_PWR("USBH_FdoPower: IRP_MN_POWER_SEQUENCE\n");
501  break;
502 
503  case IRP_MN_SET_POWER:
504  DPRINT_PWR("USBH_FdoPower: IRP_MN_SET_POWER\n");
505 
507  DPRINT_PWR("USBH_FdoPower: IRP_MN_SET_POWER/DevicePowerState\n");
508  PowerState = IoStack->Parameters.Power.State;
509 
510  if (IoStack->Parameters.Power.Type == DevicePowerState)
511  {
512  DPRINT_PWR("USBH_FdoPower: PowerState - %x\n",
514 
515  if (HubExtension->CurrentPowerState.DeviceState == PowerState.DeviceState)
516  {
518 
521  PoCallDriver(HubExtension->LowerDevice, Irp);
522 
523  return STATUS_PENDING;
524  }
525 
526  switch (PowerState.DeviceState)
527  {
528  case PowerDeviceD0:
529  if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_SET_D0_STATE))
530  {
531  HubExtension->HubFlags &= ~(USBHUB_FDO_FLAG_NOT_D0_STATE |
533 
534  HubExtension->HubFlags |= USBHUB_FDO_FLAG_SET_D0_STATE;
535 
537 
540  HubExtension,
541  TRUE,
542  TRUE,
543  TRUE);
544  }
545  else
546  {
549  }
550 
552  PoCallDriver(HubExtension->LowerDevice, Irp);
553  return STATUS_PENDING;
554 
555  case PowerDeviceD1:
556  case PowerDeviceD2:
557  case PowerDeviceD3:
558  if (HubExtension->ResetRequestCount)
559  {
560  IoCancelIrp(HubExtension->ResetPortIrp);
561 
562  KeWaitForSingleObject(&HubExtension->ResetEvent,
563  Executive,
564  KernelMode,
565  FALSE,
566  NULL);
567  }
568 
569  if (!(HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STOPPED))
570  {
571  HubExtension->HubFlags |= (USBHUB_FDO_FLAG_NOT_D0_STATE |
573 
574  IoCancelIrp(HubExtension->SCEIrp);
575 
576  KeWaitForSingleObject(&HubExtension->StatusChangeEvent,
577  Executive,
578  KernelMode,
579  FALSE,
580  NULL);
581  }
582 
583  HubExtension->CurrentPowerState.DeviceState = PowerState.DeviceState;
584 
585  if (HubExtension->HubFlags & USBHUB_FDO_FLAG_DO_SUSPENSE &&
586  USBH_CheckIdleAbort(HubExtension, TRUE, TRUE) == TRUE)
587  {
588  HubExtension->HubFlags &= ~(USBHUB_FDO_FLAG_NOT_D0_STATE |
590 
591  HubExtension->CurrentPowerState.DeviceState = PowerDeviceD0;
592 
593  USBH_SubmitStatusChangeTransfer(HubExtension);
594 
596 
597  Irp->IoStatus.Status = STATUS_UNSUCCESSFUL;
599 
600  HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_DO_SUSPENSE;
601 
602  KeReleaseSemaphore(&HubExtension->IdleSemaphore,
604  1,
605  FALSE);
606 
607  return STATUS_UNSUCCESSFUL;
608  }
609 
611 
614  HubExtension,
615  TRUE,
616  TRUE,
617  TRUE);
618 
621  PoCallDriver(HubExtension->LowerDevice, Irp);
622 
623  if (HubExtension->HubFlags & USBHUB_FDO_FLAG_DO_SUSPENSE)
624  {
625  HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_DO_SUSPENSE;
626 
627  KeReleaseSemaphore(&HubExtension->IdleSemaphore,
629  1,
630  FALSE);
631  }
632 
633  return STATUS_PENDING;
634 
635  default:
636  DPRINT1("USBH_FdoPower: Unsupported PowerState.DeviceState\n");
637  DbgBreakPoint();
638  break;
639  }
640  }
641  else
642  {
644  {
647  }
648 
650  {
651  HubExtension->HubFlags |= USBHUB_FDO_FLAG_HIBERNATE_STATE;
652  }
653 
654  PortData = HubExtension->PortData;
655 
656  IsAllPortsD3 = TRUE;
657 
658  if (PortData && HubExtension->HubDescriptor)
659  {
660  for (Port = 0;
661  Port < HubExtension->HubDescriptor->bNumberOfPorts;
662  Port++)
663  {
664  PdoDevice = PortData[Port].DeviceObject;
665 
666  if (PdoDevice)
667  {
668  PortExtension = PdoDevice->DeviceExtension;
669 
670  if (PortExtension->CurrentPowerState.DeviceState != PowerDeviceD3)
671  {
672  IsAllPortsD3 = FALSE;
673  break;
674  }
675  }
676  }
677  }
678 
680  {
681  DevicePwrState.DeviceState = PowerDeviceD0;
682  }
683  else if (HubExtension->HubFlags & USBHUB_FDO_FLAG_PENDING_WAKE_IRP ||
684  !IsAllPortsD3)
685  {
686  DevicePwrState.DeviceState = HubExtension->DeviceState[PowerState.SystemState];
687 
688  if (DevicePwrState.DeviceState == PowerDeviceUnspecified)
689  {
690  goto Exit;
691  }
692  }
693  else
694  {
695  DevicePwrState.DeviceState = PowerDeviceD3;
696  }
697 
698  if (DevicePwrState.DeviceState != HubExtension->CurrentPowerState.DeviceState &&
699  HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STARTED)
700  {
701  HubExtension->PowerIrp = Irp;
702 
704 
705  if (PoRequestPowerIrp(HubExtension->LowerPDO,
707  DevicePwrState,
709  (PVOID)HubExtension,
710  NULL) == STATUS_PENDING)
711  {
712  return STATUS_PENDING;
713  }
714 
717  PoCallDriver(HubExtension->LowerDevice, Irp);
718 
719  return STATUS_PENDING;
720  }
721 
722  Exit:
723 
724  HubExtension->SystemPowerState.SystemState = PowerState.SystemState;
725 
727  {
728  USBH_CheckIdleDeferred(HubExtension);
729  }
730 
733 
734  return PoCallDriver(HubExtension->LowerDevice, Irp);
735  }
736 
737  break;
738 
739  case IRP_MN_QUERY_POWER:
740  DPRINT_PWR("USBH_FdoPower: IRP_MN_QUERY_POWER\n");
741  break;
742 
743  default:
744  DPRINT1("USBH_FdoPower: unknown IRP_MN_POWER!\n");
745  break;
746  }
747 
750  Status = PoCallDriver(HubExtension->LowerDevice, Irp);
751 
752  return Status;
753 }
#define USBHUB_FDO_FLAG_DO_SUSPENSE
Definition: usbhub.h:56
_Out_opt_ PULONG Minor
Definition: cmfuncs.h:44
CPPORT Port[4]
Definition: headless.c:34
#define TRUE
Definition: types.h:120
_In_ UCHAR _In_ POWER_STATE PowerState
Definition: pofuncs.h:42
#define USBHUB_FDO_FLAG_PENDING_WAKE_IRP
Definition: usbhub.h:39
#define IRP_MN_POWER_SEQUENCE
#define IRP_MN_QUERY_POWER
NTSTATUS NTAPI USBH_FdoWWIrpIoCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: power.c:271
NTSTATUS NTAPI PoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
Definition: power.c:485
#define USBHUB_FDO_FLAG_DEVICE_STOPPED
Definition: usbhub.h:37
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define LOW_REALTIME_PRIORITY
void DbgBreakPoint()
Definition: mach.c:558
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define USBHUB_FDO_FLAG_HIBERNATE_STATE
Definition: usbhub.h:54
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
PDEVICE_OBJECT DeviceObject
Definition: usbhub.h:119
SYSTEM_POWER_STATE SystemState
Definition: ntpoapi.h:57
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2820
POWER_STATE CurrentPowerState
Definition: usbhub.h:222
NTSTATUS NTAPI USBH_PowerIrpCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: power.c:349
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
PUSBHUB_FDO_EXTENSION NTAPI USBH_GetRootHubExtension(IN PUSBHUB_FDO_EXTENSION HubExtension)
Definition: usbhub.c:699
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI USBH_CheckIdleDeferred(IN PUSBHUB_FDO_EXTENSION HubExtension)
Definition: usbhub.c:3876
#define IoCompleteRequest
Definition: irp.c:1240
#define USBHUB_FDO_FLAG_NOT_D0_STATE
Definition: usbhub.h:43
#define STATUS_PENDING
Definition: ntstatus.h:82
POWER_STATE SystemPowerState
Definition: usbhub.h:161
static void Exit(void)
Definition: sock.c:1331
VOID NTAPI USBH_FdoDeferPoRequestCompletion(IN PDEVICE_OBJECT DeviceObject, IN UCHAR MinorFunction, IN POWER_STATE PowerState, IN PVOID Context, IN PIO_STATUS_BLOCK IoStatus)
Definition: power.c:422
DEVICE_POWER_STATE DeviceState
Definition: ntpoapi.h:58
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define USBHUB_FDO_FLAG_DEVICE_STARTED
Definition: usbhub.h:33
#define IRP_MN_SET_POWER
#define DPRINT_PWR(...)
Definition: dbg_uhub.h:108
#define USBHUB_FDO_FLAG_SET_D0_STATE
Definition: usbhub.h:42
Status
Definition: gdiplustypes.h:24
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
#define USBHUB_FDO_FLAG_DEVICE_STOPPING
Definition: usbhub.h:34
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:626
LONG NTAPI KeReleaseSemaphore(IN PKSEMAPHORE Semaphore, IN KPRIORITY Increment, IN LONG Adjustment, IN BOOLEAN Wait)
Definition: semphobj.c:54
NTSTATUS NTAPI USBH_SubmitStatusChangeTransfer(IN PUSBHUB_FDO_EXTENSION HubExtension)
Definition: usbhub.c:2361
#define DPRINT1
Definition: precomp.h:8
BOOLEAN NTAPI IoCancelIrp(IN PIRP Irp)
Definition: irp.c:1101
BOOLEAN NTAPI USBH_CheckIdleAbort(IN PUSBHUB_FDO_EXTENSION HubExtension, IN BOOLEAN IsWait, IN BOOLEAN IsExtCheck)
Definition: usbhub.c:3140
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:565
#define IRP_MN_WAIT_WAKE
NTSTATUS NTAPI PoRequestPowerIrp(IN PDEVICE_OBJECT DeviceObject, IN UCHAR MinorFunction, IN POWER_STATE PowerState, IN PREQUEST_POWER_COMPLETE CompletionFunction, IN PVOID Context, OUT PIRP *pIrp OPTIONAL)
Definition: power.c:528
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
IoMarkIrpPending(Irp)

Referenced by USBH_FdoDispatch().

◆ USBH_FdoSyncSubmitUrb()

NTSTATUS NTAPI USBH_FdoSyncSubmitUrb ( IN PDEVICE_OBJECT  FdoDevice,
IN PURB  Urb 
)

Definition at line 355 of file usbhub.c.

357 {
358  PUSBHUB_FDO_EXTENSION HubExtension;
359 
360  DPRINT("USBH_FdoSyncSubmitUrb: FdoDevice - %p, Urb - %p\n",
361  FdoDevice,
362  Urb);
363 
364  HubExtension = FdoDevice->DeviceExtension;
365  return USBH_SyncSubmitUrb(HubExtension->LowerDevice, Urb);
366 }
void DPRINT(...)
Definition: polytest.cpp:61
PDEVICE_OBJECT LowerDevice
Definition: usbhub.h:150
NTSTATUS NTAPI USBH_SyncSubmitUrb(IN PDEVICE_OBJECT DeviceObject, IN PURB Urb)
Definition: usbhub.c:250

Referenced by USBH_AbortInterruptPipe(), USBH_GetDeviceDescriptor(), USBH_OpenConfiguration(), USBH_ResetInterruptPipe(), USBH_SyncGetDeviceConfigurationDescriptor(), USBH_SyncGetStatus(), and USBH_Transact().

◆ USBH_FreeWorkItem()

VOID NTAPI USBH_FreeWorkItem ( IN PUSBHUB_IO_WORK_ITEM  HubIoWorkItem)

Definition at line 2856 of file usbhub.c.

2857 {
2858  PIO_WORKITEM WorkItem;
2859 
2860  DPRINT("USBH_FreeWorkItem: ... \n");
2861 
2862  WorkItem = HubIoWorkItem->HubWorkItem;
2863 
2864  if (HubIoWorkItem->HubWorkItemBuffer)
2865  {
2866  ExFreePoolWithTag(HubIoWorkItem->HubWorkItemBuffer, USB_HUB_TAG);
2867  }
2868 
2869  ExFreePoolWithTag(HubIoWorkItem, USB_HUB_TAG);
2870 
2871  IoFreeWorkItem(WorkItem);
2872 }
VOID NTAPI IoFreeWorkItem(IN PIO_WORKITEM IoWorkItem)
Definition: iowork.c:64
void DPRINT(...)
Definition: polytest.cpp:61
#define USB_HUB_TAG
Definition: usbhub.h:9
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

Referenced by USBH_ChangeIndicationProcessChange().

◆ USBH_GetConfigurationDescriptor()

NTSTATUS NTAPI USBH_GetConfigurationDescriptor ( IN PDEVICE_OBJECT  DeviceObject,
IN PUSB_CONFIGURATION_DESCRIPTOR pConfigurationDescriptor 
)

Definition at line 974 of file usbhub.c.

976 {
977  PUSB_CONFIGURATION_DESCRIPTOR ConfigDescriptor;
978  ULONG ReturnedLen;
979  SIZE_T DescriptorLen;
981 
982  DPRINT("USBH_GetConfigurationDescriptor: ... \n");
983 
984  DescriptorLen = MAXUCHAR;
985 
986  while (TRUE)
987  {
988  ConfigDescriptor = ExAllocatePoolWithTag(NonPagedPool,
989  DescriptorLen,
990  USB_HUB_TAG);
991 
992  if (!ConfigDescriptor)
993  {
995  break;
996  }
997 
999  ConfigDescriptor,
1000  DescriptorLen,
1001  &ReturnedLen);
1002 
1003  if (ReturnedLen < sizeof(USB_CONFIGURATION_DESCRIPTOR))
1004  {
1006  }
1007 
1008  if (!NT_SUCCESS(Status))
1009  {
1010  break;
1011  }
1012 
1013  *OutDescriptor = ConfigDescriptor;
1014 
1015  if (ConfigDescriptor->wTotalLength <= DescriptorLen)
1016  {
1017  break;
1018  }
1019 
1020  DescriptorLen = ConfigDescriptor->wTotalLength;
1021 
1022  ExFreePool(ConfigDescriptor);
1023  *OutDescriptor = NULL;
1024  }
1025 
1026  if (NT_SUCCESS(Status))
1027  {
1028  if (ReturnedLen < ConfigDescriptor->wTotalLength)
1029  {
1031  }
1032  }
1033  else
1034  {
1035  if (ConfigDescriptor)
1036  {
1037  ExFreePool(ConfigDescriptor);
1038  }
1039 
1040  *OutDescriptor = NULL;
1041  }
1042 
1043  return Status;
1044 }
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
LONG NTSTATUS
Definition: precomp.h:26
#define MAXUCHAR
Definition: umtypes.h:117
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define USB_HUB_TAG
Definition: usbhub.h:9
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
ULONG_PTR SIZE_T
Definition: typedefs.h:78
NTSTATUS NTAPI USBH_SyncGetDeviceConfigurationDescriptor(IN PDEVICE_OBJECT DeviceObject, IN PUSB_CONFIGURATION_DESCRIPTOR ConfigDescriptor, IN ULONG NumberOfBytes, IN PULONG OutLength)
Definition: usbhub.c:913
unsigned int ULONG
Definition: retypes.h:1
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
#define STATUS_DEVICE_DATA_ERROR
Definition: udferr_usr.h:159

Referenced by USBH_ProcessDeviceInformation(), and USBH_StartHubFdoDevice().

◆ USBH_GetDeviceDescriptor()

NTSTATUS NTAPI USBH_GetDeviceDescriptor ( IN PDEVICE_OBJECT  DeviceObject,
IN PUSB_DEVICE_DESCRIPTOR  HubDeviceDescriptor 
)

Definition at line 877 of file usbhub.c.

879 {
880  struct _URB_CONTROL_DESCRIPTOR_REQUEST * Urb;
882 
883  DPRINT("USBH_GetDeviceDescriptor: ... \n");
884 
886  sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST),
887  USB_HUB_TAG);
888 
889  if (!Urb)
890  {
891  DPRINT1("USBH_SyncGetDeviceHandle: Urb - NULL!\n");
893  }
894 
895  RtlZeroMemory(Urb, sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST));
896 
898  Urb->Hdr.Length = sizeof(struct _URB_CONTROL_DESCRIPTOR_REQUEST);
899 
901  Urb->TransferBuffer = HubDeviceDescriptor;
903 
905 
907 
908  return Status;
909 }
struct _USB_DEVICE_DESCRIPTOR USB_DEVICE_DESCRIPTOR
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
LONG NTSTATUS
Definition: precomp.h:26
#define USB_DEVICE_DESCRIPTOR_TYPE
Definition: usb100.h:49
struct _URB_HEADER Hdr
Definition: usb.h:341
void DPRINT(...)
Definition: polytest.cpp:61
#define USB_HUB_TAG
Definition: usbhub.h:9
NTSTATUS NTAPI USBH_FdoSyncSubmitUrb(IN PDEVICE_OBJECT FdoDevice, IN PURB Urb)
Definition: usbhub.c:355
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE
Definition: usb.h:97
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
Definition: usb.h:529
#define DPRINT1
Definition: precomp.h:8
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099

Referenced by USBH_StartHubFdoDevice().

◆ USBH_GetDeviceType()

NTSTATUS NTAPI USBH_GetDeviceType ( IN PUSBHUB_FDO_EXTENSION  HubExtension,
IN PUSB_DEVICE_HANDLE  DeviceHandle,
OUT USB_DEVICE_TYPE OutDeviceType 
)

Definition at line 608 of file usbhub.c.

611 {
616  ULONG dummy;
618 
619  DPRINT("USBH_GetDeviceType: ... \n");
620 
621  QueryDeviceInformation = HubExtension->BusInterface.QueryDeviceInformation;
622 
624  {
625  DPRINT1("USBH_GetDeviceType: no QueryDeviceInformation()\n");
626  return STATUS_NOT_IMPLEMENTED;
627  }
628 
630 
631  while (TRUE)
632  {
635  USB_HUB_TAG);
636 
637  if (!DeviceInfo)
638  {
639  DPRINT1("USBH_GetDeviceType: ExAllocatePoolWithTag() failed\n");
641  break;
642  }
643 
645 
646  DeviceInfo->InformationLevel = 0;
647 
648  Status = QueryDeviceInformation(HubExtension->BusInterface.BusContext,
649  DeviceHandle,
650  DeviceInfo,
652  &dummy);
653 
655  {
656  if (NT_SUCCESS(Status))
657  {
658  DeviceType = DeviceInfo->DeviceType;
659  }
660 
662  break;
663  }
664 
667  }
668 
669  if (OutDeviceType)
670  {
671  *OutDeviceType = DeviceType;
672  DPRINT("USBH_GetDeviceType: DeviceType - %x\n", DeviceType);
673  }
674 
675  return Status;
676 }
enum _USB_DEVICE_TYPE USB_DEVICE_TYPE
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
Definition: hubbusif.h:121
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
DeviceType
Definition: mmdrv.h:41
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:64
struct _USB_DEVICE_INFORMATION_0 USB_DEVICE_INFORMATION_0
void DPRINT(...)
Definition: polytest.cpp:61
#define USB_HUB_TAG
Definition: usbhub.h:9
NTSTATUS QueryDeviceInformation(IN PUNICODE_STRING SymbolicName, OUT PUNICODE_STRING DeviceName OPTIONAL, OUT PMOUNTDEV_UNIQUE_ID *UniqueId OPTIONAL, OUT PBOOLEAN Removable OPTIONAL, OUT PBOOLEAN GptDriveLetter OPTIONAL, OUT PBOOLEAN HasGuid OPTIONAL, IN OUT LPGUID StableGuid OPTIONAL, OUT PBOOLEAN Valid OPTIONAL)
Definition: mountmgr.c:204
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _DeviceInfo DeviceInfo
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
Status
Definition: gdiplustypes.h:24
ULONG_PTR SIZE_T
Definition: typedefs.h:78
unsigned char dummy
Definition: maze.c:118
_In_ PUSB_DEVICE_HANDLE _In_ ULONG DeviceInformationBufferLength
Definition: hubbusif.h:181
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
USB_BUSIFFN_GET_DEVICE_INFORMATION * PUSB_BUSIFFN_GET_DEVICE_INFORMATION
Definition: hubbusif.h:183

Referenced by USBH_StartHubFdoDevice().

◆ USBH_GetRootHubExtension()

PUSBHUB_FDO_EXTENSION NTAPI USBH_GetRootHubExtension ( IN PUSBHUB_FDO_EXTENSION  HubExtension)

Definition at line 699 of file usbhub.c.

700 {
702  PUSBHUB_FDO_EXTENSION RootHubExtension;
703 
704  DPRINT("USBH_GetRootHubExtension: HubExtension - %p\n", HubExtension);
705 
706  RootHubExtension = HubExtension;
707 
708  if (HubExtension->LowerPDO != HubExtension->RootHubPdo)
709  {
710  Device = HubExtension->RootHubPdo;
711 
712  do
713  {
714  Device = Device->AttachedDevice;
715  }
716  while (Device->DriverObject != HubExtension->Common.SelfDevice->DriverObject);
717 
718  RootHubExtension = Device->DeviceExtension;
719  }
720 
721  DPRINT("USBH_GetRootHubExtension: RootHubExtension - %p\n", RootHubExtension);
722 
723  return RootHubExtension;
724 }
_In_ PIRP _In_ PDEVICE_OBJECT Device
Definition: fatprocs.h:2020
void DPRINT(...)
Definition: polytest.cpp:61

Referenced by USBH_CheckHubIdle(), USBH_FdoPower(), and USBH_HubSetD0().

◆ USBH_HubCancelIdleIrp()

VOID NTAPI USBH_HubCancelIdleIrp ( IN PUSBHUB_FDO_EXTENSION  HubExtension,
IN PIRP  IdleIrp 
)

Definition at line 3125 of file usbhub.c.

3127 {
3128  DPRINT("USBH_HubCancelIdleIrp ... \n");
3129 
3130  IoCancelIrp(IdleIrp);
3131 
3132  if (InterlockedExchange(&HubExtension->IdleRequestLock, 1))
3133  {
3134  IoFreeIrp(IdleIrp);
3135  }
3136 }
void DPRINT(...)
Definition: polytest.cpp:61
#define InterlockedExchange
Definition: armddk.h:54
BOOLEAN NTAPI IoCancelIrp(IN PIRP Irp)
Definition: irp.c:1101
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666

Referenced by USBH_FdoCleanup(), USBH_FdoIdleNotificationCallback(), USBH_HubQueuePortIdleIrps(), and USBH_PortIdleNotificationCancelRoutine().

◆ USBH_HubCancelWakeIrp()

VOID NTAPI USBH_HubCancelWakeIrp ( IN PUSBHUB_FDO_EXTENSION  HubExtension,
IN PIRP  Irp 
)

Definition at line 43 of file power.c.

45 {
46  DPRINT("USBH_HubCancelWakeIrp: HubExtension - %p, Irp - %p\n",
47  HubExtension,
48  Irp);
49 
51 
52  if (InterlockedExchange((PLONG)&HubExtension->FdoWaitWakeLock, 1))
53  {
55  Irp->IoStatus.Status = STATUS_CANCELLED;
57  }
58 }
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
#define InterlockedExchange
Definition: armddk.h:54
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:626
BOOLEAN NTAPI IoCancelIrp(IN PIRP Irp)
Definition: irp.c:1101
#define IO_NO_INCREMENT
Definition: iotypes.h:565
signed int * PLONG
Definition: retypes.h:5

Referenced by USBH_FdoCleanup().

◆ USBH_HubCompletePortWakeIrps()

VOID NTAPI USBH_HubCompletePortWakeIrps ( IN PUSBHUB_FDO_EXTENSION  HubExtension,
IN NTSTATUS  NtStatus 
)

Definition at line 217 of file power.c.

219 {
220  LIST_ENTRY ListIrps;
221 
222  DPRINT("USBH_HubCompletePortWakeIrps: NtStatus - %x\n", NtStatus);
223 
224  if (HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STARTED)
225  {
226  USBH_HubQueuePortWakeIrps(HubExtension, &ListIrps);
227 
229  &ListIrps,
230  NtStatus);
231  }
232 }
VOID NTAPI USBH_HubCompleteQueuedPortWakeIrps(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PLIST_ENTRY ListIrps, IN NTSTATUS NtStatus)
Definition: power.c:202
void DPRINT(...)
Definition: polytest.cpp:61
#define USBHUB_FDO_FLAG_DEVICE_STARTED
Definition: usbhub.h:33
Definition: typedefs.h:117
VOID NTAPI USBH_HubQueuePortWakeIrps(IN PUSBHUB_FDO_EXTENSION HubExtension, IN PLIST_ENTRY ListIrps)
Definition: power.c:160

Referenced by USBH_FdoCleanup(), and USBH_FdoPoRequestD0Completion().

◆ USBH_HubIsBusPowered()

BOOLEAN NTAPI USBH_HubIsBusPowered ( IN PDEVICE_OBJECT  DeviceObject,
IN PUSB_CONFIGURATION_DESCRIPTOR  HubConfigDescriptor 
)

Definition at line 1538 of file usbhub.c.

1540 {
1541  BOOLEAN Result;
1542  USHORT UsbStatus;
1543  NTSTATUS Status;
1544 
1545  DPRINT("USBH_HubIsBusPowered: ... \n");
1546 
1548  &UsbStatus,
1550  0);
1551 
1552  if (!NT_SUCCESS(Status))
1553  {
1554  Result = (HubConfigDescriptor->bmAttributes & USB_CONFIG_POWERED_MASK)
1556  }
1557  else
1558  {
1559  Result = (UsbStatus & USB_GETSTATUS_SELF_POWERED) == 0;
1560  }
1561 
1562  return Result;
1563 }
NTSTATUS NTAPI USBH_SyncGetStatus(IN PDEVICE_OBJECT DeviceObject, IN PUSHORT OutStatus, IN USHORT Function, IN USHORT RequestIndex)
Definition: usbhub.c:1323
LONG NTSTATUS
Definition: precomp.h:26
unsigned char BOOLEAN
_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:426
void DPRINT(...)
Definition: polytest.cpp:61
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define USB_CONFIG_BUS_POWERED
Definition: usb100.h:69
#define USB_GETSTATUS_SELF_POWERED
Definition: usb100.h:45
Status
Definition: gdiplustypes.h:24
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
unsigned short USHORT
Definition: pedump.c:61
#define URB_FUNCTION_GET_STATUS_FROM_DEVICE
Definition: usb.h:105
#define USB_CONFIG_POWERED_MASK
Definition: usb100.h:68

Referenced by USBH_IoctlGetNodeInformation(), and USBH_StartHubFdoDevice().

◆ USBH_HubSetD0()

NTSTATUS NTAPI USBH_HubSetD0 ( IN PUSBHUB_FDO_EXTENSION  HubExtension)

Definition at line 77 of file power.c.

78 {
79  PUSBHUB_FDO_EXTENSION RootHubDevExt;
81  KEVENT Event;
83 
84  DPRINT("USBH_HubSetD0: HubExtension - %p\n", HubExtension);
85 
86  RootHubDevExt = USBH_GetRootHubExtension(HubExtension);
87 
88  if (RootHubDevExt->SystemPowerState.SystemState != PowerSystemWorking)
89  {
91  return Status;
92  }
93 
94  if (HubExtension->HubFlags & USBHUB_FDO_FLAG_WAIT_IDLE_REQUEST)
95  {
96  DPRINT("USBH_HubSetD0: HubFlags - %lX\n", HubExtension->HubFlags);
97 
98  KeWaitForSingleObject(&HubExtension->IdleEvent,
99  Suspended,
100  KernelMode,
101  FALSE,
102  NULL);
103  }
104 
106 
108 
109  Status = PoRequestPowerIrp(HubExtension->LowerPDO,
111  PowerState,
113  &Event,
114  NULL);
115 
116  if (Status == STATUS_PENDING)
117  {
119  Suspended,
120  KernelMode,
121  FALSE,
122  NULL);
123  }
124 
125  while (HubExtension->HubFlags & USBHUB_FDO_FLAG_WAKEUP_START)
126  {
127  USBH_Wait(10);
128  }
129 
130  return Status;
131 }
_In_ UCHAR _In_ POWER_STATE PowerState
Definition: pofuncs.h:42
#define USBHUB_FDO_FLAG_WAKEUP_START
Definition: usbhub.h:49
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI USBH_Wait(IN ULONG Milliseconds)
Definition: usbhub.c:23
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define USBHUB_FDO_FLAG_WAIT_IDLE_REQUEST
Definition: usbhub.h:44
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
SYSTEM_POWER_STATE SystemState
Definition: ntpoapi.h:57
_In_ PVOID _In_ ULONG Event
Definition: iotypes.h:434
PUSBHUB_FDO_EXTENSION NTAPI USBH_GetRootHubExtension(IN PUSBHUB_FDO_EXTENSION HubExtension)
Definition: usbhub.c:699
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
#define STATUS_PENDING
Definition: ntstatus.h:82
POWER_STATE SystemPowerState
Definition: usbhub.h:161
DEVICE_POWER_STATE DeviceState
Definition: ntpoapi.h:58
#define IRP_MN_SET_POWER
Status
Definition: gdiplustypes.h:24
VOID NTAPI USBH_HubESDRecoverySetD3Completion(IN PDEVICE_OBJECT DeviceObject, IN UCHAR MinorFunction, IN POWER_STATE PowerState, IN PVOID Context, IN PIO_STATUS_BLOCK IoStatus)
Definition: power.c:62
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
NTSTATUS NTAPI PoRequestPowerIrp(IN PDEVICE_OBJECT DeviceObject, IN UCHAR MinorFunction, IN POWER_STATE PowerState, IN PREQUEST_POWER_COMPLETE CompletionFunction, IN PVOID Context, OUT PIRP *pIrp OPTIONAL)
Definition: power.c:528

Referenced by USBH_DeviceControl(), USBH_FdoPnP(), USBH_IdleCancelPowerHubWorker(), USBH_IdleCompletePowerHubWorker(), and USBH_PdoRemoveDevice().

◆ USBH_IdleCancelPowerHubWorker()

VOID NTAPI USBH_IdleCancelPowerHubWorker ( IN PUSBHUB_FDO_EXTENSION  HubExtension,
IN PVOID  Context 
)

Definition at line 135 of file power.c.

137 {
138  PUSBHUB_IDLE_PORT_CANCEL_CONTEXT WorkItemIdlePower;
139  PIRP Irp;
140 
141  DPRINT("USBH_IdleCancelPowerHubWorker: ... \n");
142 
143  WorkItemIdlePower = Context;
144 
145  if (HubExtension &&
146  HubExtension->CurrentPowerState.DeviceState != PowerDeviceD0 &&
147  HubExtension->HubFlags & USBHUB_FDO_FLAG_DEVICE_STARTED)
148  {
149  USBH_HubSetD0(HubExtension);
150  }
151 
152  Irp = WorkItemIdlePower->Irp;
153  Irp->IoStatus.Status = STATUS_CANCELLED;
154 
156 }
_In_ PIRP Irp
Definition: csq.h:116
#define IoCompleteRequest
Definition: irp.c:1240
void DPRINT(...)
Definition: polytest.cpp:61
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
#define USBHUB_FDO_FLAG_DEVICE_STARTED
Definition: usbhub.h:33
NTSTATUS NTAPI USBH_HubSetD0(IN PUSBHUB_FDO_EXTENSION HubExtension)
Definition: power.c:77
struct tagContext Context
Definition: acpixf.h:1012
#define IO_NO_INCREMENT
Definition: iotypes.h:565

Referenced by USBH_PortIdleNotificationCancelRoutine().

◆ USBH_PassIrp()

NTSTATUS NTAPI USBH_PassIrp ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 79 of file usbhub.c.

81 {
82  DPRINT_PNP("USBH_PassIrp: DeviceObject - %p, Irp - %p\n",
84  Irp);
85 
87  return IoCallDriver(DeviceObject, Irp);
88 }
_In_ PIRP Irp
Definition: csq.h:116
#define DPRINT_PNP(...)
Definition: dbg_uhub.h:109
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421

Referenced by USBH_DeviceControl(), USBH_FdoDispatch(), USBH_FdoPnP(), USBH_FdoQueryBusRelations(), USBH_FdoRemoveDevice(), USBH_PdoInternalControl(), USBH_PdoIoctlSubmitUrb(), USBH_PdoPnP(), and USBH_PdoUrbFilter().

◆ USBH_PdoInternalControl()

NTSTATUS NTAPI USBH_PdoInternalControl ( IN PUSBHUB_PORT_PDO_EXTENSION  PortExtension,
IN PIRP  Irp 
)

Definition at line 1274 of file ioctl.c.

1276 {
1277  PUSBHUB_FDO_EXTENSION HubExtension;
1280  PIO_STACK_LOCATION IoStack;
1281  PULONG HubCount;
1282 
1283  DPRINT_IOCTL("USBH_PdoInternalControl: PortExtension - %p, Irp - %p\n",
1284  PortExtension,
1285  Irp);
1286 
1287  HubExtension = PortExtension->HubExtension;
1288 
1289  if (PortExtension->PortPdoFlags & USBHUB_PDO_FLAG_NOT_CONNECTED)
1290  {
1292  goto Exit;
1293  }
1294 
1295  if (PortExtension->CurrentPowerState.DeviceState != PowerDeviceD0)
1296  {
1298  goto Exit;
1299  }
1300 
1301  IoStack = IoGetCurrentIrpStackLocation(Irp);
1302  ControlCode = IoStack->Parameters.DeviceIoControl.IoControlCode;
1303 
1305  {
1306  HubExtension = PortExtension->RootHubExtension;
1307  DPRINT("USBH_PdoInternalControl: HubExtension - %p\n", HubExtension);
1308  }
1309 
1310  if (!HubExtension)
1311  {
1313  goto Exit;
1314  }
1315 
1316  switch (ControlCode)
1317  {
1319  return USBH_PdoIoctlSubmitUrb(PortExtension, Irp);
1320 
1321  case IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION:
1322  DPRINT1("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_SUBMIT_IDLE_NOTIFICATION\n");
1323  return USBH_PortIdleNotificationRequest(PortExtension, Irp);
1324 
1326  DPRINT("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_GET_PORT_STATUS\n");
1327  return USBH_PdoIoctlGetPortStatus(PortExtension, Irp);
1328 
1330  DPRINT1("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_RESET_PORT\n");
1331  return USBH_PdoIoctlResetPort(PortExtension, Irp);
1332 
1334  DPRINT1("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_ENABLE_PORT\n");
1335  DbgBreakPoint();
1336  break;
1337 
1339  DPRINT1("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_CYCLE_PORT\n");
1340  DbgBreakPoint();
1341  break;
1342 
1343  case IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE:
1344  DPRINT("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_GET_DEVICE_HANDLE\n");
1345  *(PVOID *)IoStack->Parameters.Others.Argument1 = PortExtension->DeviceHandle;
1347  break;
1348 
1350  DPRINT("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_GET_HUB_COUNT. PortPdoFlags - %lX\n",
1351  PortExtension->PortPdoFlags);
1352 
1353  if (!(PortExtension->PortPdoFlags & USBHUB_PDO_FLAG_HUB_DEVICE))
1354  {
1356  break;
1357  }
1358 
1359  HubCount = IoStack->Parameters.Others.Argument1;
1360 
1361  ++*HubCount;
1362 
1363  Status = USBH_SyncGetHubCount(HubExtension->LowerDevice,
1364  HubCount);
1365 
1366  DPRINT("USBH_PdoInternalControl: *HubCount - %x\n", *HubCount);
1367  break;
1368 
1370  DPRINT("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_GET_ROOTHUB_PDO. PortPdoFlags - %lX\n",
1371  PortExtension->PortPdoFlags);
1372 
1373  if (!(PortExtension->PortPdoFlags & USBHUB_PDO_FLAG_HUB_DEVICE))
1374  {
1375  DbgBreakPoint();
1377 
1378  *(PVOID *)IoStack->Parameters.Others.Argument1 = NULL;
1379 
1381  break;
1382  }
1383 
1384  ASSERT(HubExtension->RootHubPdo);
1385  return USBH_PassIrp(HubExtension->RootHubPdo, Irp);
1386 
1388  DPRINT1("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_GET_HUB_NAME\n");
1389  DbgBreakPoint();
1390  break;
1391 
1393  DPRINT1("USBH_PdoInternalControl: IOCTL_GET_HCD_DRIVERKEY_NAME\n");
1394  DbgBreakPoint();
1395  break;
1396 
1398  DPRINT1("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_GET_BUS_INFO\n");
1399  DbgBreakPoint();
1400  break;
1401 
1403  DPRINT1("USBH_PdoInternalControl: IOCTL_INTERNAL_USB_GET_PARENT_HUB_INFO\n");
1404  DbgBreakPoint();
1405  break;
1406 
1407  default:
1408  DPRINT1("USBH_PdoInternalControl: unhandled IOCTL_ - %lX\n", ControlCode);
1409  break;
1410  }
1411 
1412 Exit:
1414  return Status;
1415 }
NTSTATUS NTAPI USBH_PassIrp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: usbhub.c:79
#define IOCTL_INTERNAL_USB_SUBMIT_URB
Definition: usbioctl.h:32
#define IOCTL_GET_HCD_DRIVERKEY_NAME
Definition: usbioctl.h:165
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define IOCTL_INTERNAL_USB_GET_PARENT_HUB_INFO
Definition: usbioctl.h:68
#define IOCTL_INTERNAL_USB_ENABLE_PORT
Definition: usbioctl.h:47
#define IOCTL_INTERNAL_USB_GET_HUB_NAME
Definition: usbioctl.h:56
LONG NTSTATUS
Definition: precomp.h:26
#define IOCTL_INTERNAL_USB_GET_BUS_INFO
Definition: usbioctl.h:59
void DbgBreakPoint()
Definition: mach.c:558
#define USBHUB_PDO_FLAG_NOT_CONNECTED
Definition: usbhub.h:67
#define DPRINT_IOCTL(...)
Definition: dbg_uhub.h:107
#define STATUS_DEVICE_POWERED_OFF
Definition: ntstatus.h:183
VOID NTAPI USBH_CompleteIrp(IN PIRP Irp, IN NTSTATUS CompleteStatus)
Definition: usbhub.c:63
smooth NULL
Definition: ftsmooth.c:416
void DPRINT(...)
Definition: polytest.cpp:61
_IRQL_requires_same_ typedef _In_ ULONG ControlCode
Definition: wmitypes.h:55
#define IOCTL_INTERNAL_USB_CYCLE_PORT
Definition: usbioctl.h:53
#define USBHUB_PDO_FLAG_HUB_DEVICE
Definition: usbhub.h:61
#define STATUS_DEVICE_NOT_CONNECTED
Definition: udferr_usr.h:160
static void Exit(void)
Definition: sock.c:1331
PDEVICE_OBJECT LowerDevice
Definition: usbhub.h:150
#define IOCTL_INTERNAL_USB_GET_HUB_COUNT
Definition: usbioctl.h:50
NTSTATUS NTAPI USBH_PdoIoctlResetPort(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PIRP Irp)
Definition: ioctl.c:373
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define IOCTL_INTERNAL_USB_GET_ROOTHUB_PDO
Definition: usbioctl.h:38
Status
Definition: gdiplustypes.h:24
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
#define STATUS_DEVICE_BUSY
Definition: udferr_usr.h:129
unsigned int * PULONG
Definition: retypes.h:1
PDEVICE_OBJECT RootHubPdo
Definition: usbhub.h:151
NTSTATUS NTAPI USBH_PdoIoctlSubmitUrb(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PIRP Irp)
Definition: ioctl.c:204
#define IOCTL_INTERNAL_USB_RESET_PORT
Definition: usbioctl.h:35
#define IOCTL_INTERNAL_USB_GET_PORT_STATUS
Definition: usbioctl.h:44
NTSTATUS NTAPI USBH_SyncGetHubCount(IN PDEVICE_OBJECT DeviceObject, IN OUT PULONG OutHubCount)
Definition: usbhub.c:781
#define DPRINT1
Definition: precomp.h:8
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
unsigned int ULONG
Definition: retypes.h:1
NTSTATUS NTAPI USBH_PdoIoctlGetPortStatus(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PIRP Irp)
Definition: ioctl.c:233
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
return STATUS_SUCCESS
Definition: btrfs.c:2745
NTSTATUS NTAPI USBH_PortIdleNotificationRequest(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PIRP Irp)
Definition: ioctl.c:481

Referenced by USBH_PdoDispatch().

◆ USBH_PdoPnP()

NTSTATUS NTAPI USBH_PdoPnP ( IN PUSBHUB_PORT_PDO_EXTENSION  PortExtension,
IN PIRP  Irp,
IN UCHAR  Minor,
OUT BOOLEAN IsCompleteIrp 
)

Definition at line 2587 of file pnp.c.

2591 {
2592  NTSTATUS Status;
2593  PIO_STACK_LOCATION IoStack;
2594  PPNP_BUS_INFORMATION BusInfo;
2596  USHORT Size;
2597  USHORT Version;
2598  PUSBHUB_FDO_EXTENSION HubExtension;
2599  PDEVICE_RELATIONS DeviceRelation;
2600 
2601  DPRINT_PNP("USBH_PdoPnP: PortExtension - %p, Irp - %p, Minor - %X\n",
2602  PortExtension,
2603  Irp,
2604  Minor);
2605 
2606  IoStack = IoGetCurrentIrpStackLocation(Irp);
2607 
2608  *IsCompleteIrp = TRUE;
2609 
2610  switch (Minor)
2611  {
2612  case IRP_MN_START_DEVICE:
2613  DPRINT_PNP("PDO IRP_MN_START_DEVICE\n");
2614  return USBH_PdoStartDevice(PortExtension, Irp);
2615 
2617  DPRINT_PNP("PDO IRP_MN_QUERY_REMOVE_DEVICE\n");
2618  return STATUS_SUCCESS;
2619 
2620  case IRP_MN_REMOVE_DEVICE:
2621  DPRINT_PNP("PDO IRP_MN_REMOVE_DEVICE\n");
2622  return USBH_PdoRemoveDevice(PortExtension, PortExtension->HubExtension);
2623 
2625  DPRINT_PNP("PDO IRP_MN_CANCEL_REMOVE_DEVICE\n");
2626  return STATUS_SUCCESS;
2627 
2628  case IRP_MN_STOP_DEVICE:
2629  DPRINT_PNP("PDO IRP_MN_STOP_DEVICE\n");
2630  return USBH_PdoStopDevice(PortExtension, Irp);
2631 
2633  DPRINT_PNP("PDO IRP_MN_QUERY_STOP_DEVICE\n");
2634  return STATUS_SUCCESS;
2635 
2637  DPRINT_PNP("PDO IRP_MN_CANCEL_STOP_DEVICE\n");
2638  return STATUS_SUCCESS;
2639 
2641  DPRINT_PNP("PDO IRP_MN_QUERY_DEVICE_RELATIONS\n");
2642 
2643  if (IoStack->Parameters.QueryDeviceRelations.Type != TargetDeviceRelation)
2644  {
2645  return Irp->IoStatus.Status;
2646  }
2647 
2648  DeviceRelation = ExAllocatePoolWithTag(PagedPool,
2649  sizeof(DEVICE_RELATIONS),
2650  USB_HUB_TAG);
2651 
2652  if (DeviceRelation)
2653  {
2654  RtlZeroMemory(DeviceRelation, sizeof(DEVICE_RELATIONS));
2655 
2656  DeviceRelation->Count = 1;
2657  DeviceRelation->Objects[0] = PortExtension->Common.SelfDevice;
2658 
2659  ObReferenceObject(DeviceRelation->Objects[0]);
2660 
2662  }
2663  else
2664  {
2666  }
2667 
2668  Irp->IoStatus.Information = (ULONG_PTR)DeviceRelation;
2669  break;
2670 
2672  DPRINT_PNP("PDO IRP_MN_QUERY_INTERFACE\n");
2673 
2674  *IsCompleteIrp = 0;
2675 
2676  if (IsEqualGUIDAligned(IoStack->Parameters.QueryInterface.InterfaceType,
2677  &USB_BUS_INTERFACE_USBDI_GUID))
2678  {
2679  IoStack->Parameters.QueryInterface.InterfaceSpecificData = PortExtension->DeviceHandle;
2680  }
2681 
2682  HubExtension = PortExtension->HubExtension;
2683 
2684  if (!HubExtension)
2685  {
2686  HubExtension = PortExtension->RootHubExtension;
2687  }
2688 
2689  Status = USBH_PassIrp(HubExtension->RootHubPdo, Irp);
2690  break;
2691 
2693  DPRINT_PNP("PDO IRP_MN_QUERY_CAPABILITIES\n");
2694 
2695  DeviceCapabilities = IoStack->Parameters.DeviceCapabilities.Capabilities;
2696 
2697  Size = DeviceCapabilities->Size;
2698  Version = DeviceCapabilities->Version;
2699 
2701  &PortExtension->Capabilities,
2702  sizeof(DEVICE_CAPABILITIES));
2703 
2704  DeviceCapabilities->Size = Size;
2705  DeviceCapabilities->Version = Version;
2706 
2708  break;
2709 
2711  DPRINT_PNP("PDO IRP_MN_QUERY_RESOURCES\n");
2712  Status = Irp->IoStatus.Status;
2713  break;
2714 
2716  DPRINT_PNP("PDO IRP_MN_QUERY_RESOURCE_REQUIREMENTS\n");
2717  PortExtension->PortPdoFlags |= USBHUB_PDO_FLAG_ENUMERATED;
2718 
2719  /* FIXME HKEY_LOCAL_MACHINE\SYSTEM\ControlSetXXX\Enum\USB\
2720  Vid_????&Pid_????\????????????\Device Parameters\
2721  if (ExtPropDescSemaphore)
2722  */
2723 
2725  break;
2726 
2728  DPRINT_PNP("PDO IRP_MN_QUERY_DEVICE_TEXT\n");
2729  return USBH_PdoQueryDeviceText(PortExtension, Irp);
2730 
2732  DPRINT_PNP("PDO IRP_MN_FILTER_RESOURCE_REQUIREMENTS\n");
2733  Status = Irp->IoStatus.Status;
2734  break;
2735 
2736  case IRP_MN_READ_CONFIG:
2737  DPRINT_PNP("PDO IRP_MN_READ_CONFIG\n");
2738  DbgBreakPoint();
2739  Status = Irp->IoStatus.Status;
2740  break;
2741 
2742  case IRP_MN_WRITE_CONFIG:
2743  DPRINT_PNP("PDO IRP_MN_WRITE_CONFIG\n");
2744  DbgBreakPoint();
2745  Status = Irp->IoStatus.Status;
2746  break;
2747 
2748  case IRP_MN_EJECT:
2749  DPRINT_PNP("PDO IRP_MN_EJECT\n");
2750  DbgBreakPoint();
2751  Status = Irp->IoStatus.Status;
2752  break;
2753 
2754  case IRP_MN_SET_LOCK:
2755  DPRINT_PNP("PDO IRP_MN_SET_LOCK\n");
2756  DbgBreakPoint();
2757  Status = Irp->IoStatus.Status;
2758  break;
2759 
2760  case IRP_MN_QUERY_ID:
2761  DPRINT_PNP("PDO IRP_MN_QUERY_ID\n");
2762  return USBH_PdoQueryId(PortExtension, Irp);
2763 
2765  DPRINT_PNP("PDO IRP_MN_QUERY_PNP_DEVICE_STATE\n");
2766  if (PortExtension->PortPdoFlags & (USBHUB_PDO_FLAG_INSUFFICIENT_PWR |
2770  {
2771  Irp->IoStatus.Information |= PNP_DEVICE_FAILED;
2772  }
2773 
2775  break;
2776 
2778  DPRINT_PNP("PDO IRP_MN_QUERY_BUS_INFORMATION\n");
2779 
2780  BusInfo = ExAllocatePoolWithTag(PagedPool,
2781  sizeof(PNP_BUS_INFORMATION),
2782  USB_HUB_TAG);
2783 
2784  if (!BusInfo)
2785  {
2787  }
2788 
2789  RtlZeroMemory(BusInfo, sizeof(PNP_BUS_INFORMATION));
2790 
2791  RtlCopyMemory(&BusInfo->BusTypeGuid,
2792  &GUID_BUS_TYPE_USB,
2793  sizeof(BusInfo->BusTypeGuid));
2794 
2795  BusInfo->LegacyBusType = PNPBus;
2796  BusInfo->BusNumber = 0;
2797 
2798  Irp->IoStatus.Information = (ULONG_PTR)BusInfo;
2800  break;
2801 
2803  DPRINT_PNP("PDO IRP_MN_DEVICE_USAGE_NOTIFICATION\n");
2804  DbgBreakPoint();
2805  Status = Irp->IoStatus.Status;
2806  break;
2807 
2809  DPRINT_PNP("PDO IRP_MN_SURPRISE_REMOVAL\n");
2810  if (PortExtension->PortPdoFlags & USBHUB_PDO_FLAG_REG_DEV_INTERFACE)
2811  {
2812  Status = USBH_SymbolicLink(PortExtension, NULL, FALSE);
2813 
2814  if (NT_SUCCESS(Status))
2815  {
2816  PortExtension->PortPdoFlags &= ~USBHUB_PDO_FLAG_REG_DEV_INTERFACE;
2817  }
2818  }
2819 
2821  break;
2822 
2823  default:
2824  DPRINT_PNP("PDO unknown IRP_MN_???\n");
2825  Status = Irp->IoStatus.Status;
2826  break;
2827  }
2828 
2829  return Status;
2830 }
NTSTATUS NTAPI USBH_PassIrp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: usbhub.c:79
_Out_opt_ PULONG Minor
Definition: cmfuncs.h:44
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define USBHUB_PDO_FLAG_INIT_PORT_FAILED
Definition: usbhub.h:63
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define USBHUB_PDO_FLAG_INSUFFICIENT_PWR
Definition: usbhub.h:77
IN PVOID IN PVOID IN USHORT Version
Definition: pci.h:359
#define IRP_MN_QUERY_RESOURCES
#define IRP_MN_REMOVE_DEVICE
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define IRP_MN_QUERY_ID
NTSTATUS NTAPI USBH_SymbolicLink(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN const GUID *InterfaceClassGuid, IN BOOLEAN IsEnable)
Definition: pnp.c:2001
_In_ PIRP Irp
Definition: csq.h:116
#define IRP_MN_FILTER_RESOURCE_REQUIREMENTS
#define USBHUB_PDO_FLAG_ENUMERATED
Definition: usbhub.h:82
#define IRP_MN_QUERY_RESOURCE_REQUIREMENTS
#define IRP_MN_WRITE_CONFIG
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2054
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI USBH_PdoQueryDeviceText(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PIRP Irp)
Definition: pnp.c:1846
DEVICE_CAPABILITIES
Definition: iotypes.h:927
NTSTATUS NTAPI USBH_PdoStopDevice(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PIRP Irp)
Definition: pnp.c:2345
#define IRP_MN_EJECT
void DbgBreakPoint()
Definition: mach.c:558
#define IsEqualGUIDAligned(guid1, guid2)
Definition: wdm.template.h:233
#define IRP_MN_QUERY_REMOVE_DEVICE
smooth NULL
Definition: ftsmooth.c:416
#define DeviceCapabilities
Definition: wingdi.h:4427
#define USB_HUB_TAG
Definition: usbhub.h:9
#define IRP_MN_READ_CONFIG
#define IRP_MN_QUERY_STOP_DEVICE
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
#define IRP_MN_STOP_DEVICE
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define USBHUB_PDO_FLAG_REG_DEV_INTERFACE
Definition: usbhub.h:72
#define IRP_MN_START_DEVICE
#define IRP_MN_QUERY_DEVICE_TEXT
#define IRP_MN_QUERY_INTERFACE
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define IRP_MN_QUERY_BUS_INFORMATION
#define USBHUB_PDO_FLAG_PORT_RESTORE_FAIL
Definition: usbhub.h:73
#define PNP_DEVICE_FAILED
Definition: iotypes.h:965
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
* PDEVICE_CAPABILITIES
Definition: iotypes.h:927
NTSTATUS NTAPI USBH_PdoRemoveDevice(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PUSBHUB_FDO_EXTENSION HubExtension)
Definition: pnp.c:2173
Status
Definition: gdiplustypes.h:24
#define DPRINT_PNP(...)
Definition: dbg_uhub.h:109
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
NTSTATUS NTAPI USBH_PdoQueryId(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PIRP Irp)
Definition: pnp.c:1554
unsigned short USHORT
Definition: pedump.c:61
NTSTATUS NTAPI USBH_PdoStartDevice(IN PUSBHUB_PORT_PDO_EXTENSION PortExtension, IN PIRP Irp)
Definition: pnp.c:2117
PDEVICE_OBJECT RootHubPdo
Definition: usbhub.h:151
#define IRP_MN_QUERY_DEVICE_RELATIONS
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
#define ObReferenceObject
Definition: obfuncs.h:204
#define IRP_MN_SET_LOCK
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ULONG_PTR
Definition: config.h:101
#define IRP_MN_CANCEL_STOP_DEVICE
#define IRP_MN_DEVICE_USAGE_NOTIFICATION
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2771
return STATUS_SUCCESS
Definition: btrfs.c:2745
INTERFACE_TYPE LegacyBusType
Definition: cmtypes.h:363
#define IRP_MN_QUERY_PNP_DEVICE_STATE
#define IRP_MN_QUERY_CAPABILITIES
#define USBHUB_PDO_FLAG_OVERCURRENT_PORT
Definition: usbhub.h:75

Referenced by USBH_PdoDispatch().

◆ USBH_PdoPower()

NTSTATUS NTAPI USBH_PdoPower ( IN PUSBHUB_PORT_PDO_EXTENSION  PortExtension,
IN PIRP  Irp,
IN UCHAR  Minor 
)

Definition at line 757 of file power.c.

760 {
761  NTSTATUS Status = Irp->IoStatus.Status;
762 
763  DPRINT_PWR("USBH_FdoPower: PortExtension - %p, Irp - %p, Minor - %X\n",
764  PortExtension,
765  Irp,