13#define NDEBUG_USBPORT_CORE
47 ULONG NumController = 0;
49 DPRINT(
"USBPORT_RootHub_PowerUsb2Port: FdoDevice - %p, Port - %p\n",
60 if (!CompanionControllersList)
68 while (NumController < CompanionControllersList->
Count)
70 CompanionFdoDevice = *
Entry;
79 ix < PdoExtension->RootHubDescriptors->Descriptor.bNumberOfPorts;
92 if (CompanionControllersList)
116 DPRINT(
"USBPORT_RootHubClassCommand: USB command - %x, *BufferLength - %x\n",
236 DPRINT1(
"USBPORT_RootHubClassCommand: Not supported feature - %x\n",
283 DPRINT1(
"USBPORT_RootHubClassCommand: Not supported feature - %x\n",
298 DescriptorLength =
PdoExtension->RootHubDescriptors->Descriptor.bDescriptorLength;
314 DPRINT1(
"USBPORT_RootHubClassCommand: Not supported USB request - %x\n",
346 DPRINT(
"USBPORT_RootHubStandardCommand: USB command - %x, TransferLength - %p\n",
378 DPRINT1(
"USBPORT_RootHubStandardCommand: Not supported Descriptor Type - %x\n",
388 if (*TransferLength >= DescriptorLength)
389 Length = DescriptorLength;
412 *TransferLength =
sizeof(
USHORT);
429 if (*TransferLength >= 1)
447 PdoExtension->RootHubDescriptors->ConfigDescriptor.bConfigurationValue)
469 DPRINT1(
"USBPORT_RootHubStandardCommand: Not supported USB request - %x\n",
488 ULONG TransferLength;
495 DPRINT(
"USBPORT_RootHubEndpoint0: Transfer - %p\n", Transfer);
497 TransferLength = Transfer->TransferParameters.TransferBufferLength;
499 FdoDevice = Transfer->Endpoint->FdoDevice;
501 if (TransferLength > 0)
530 Transfer->CompletedTransferLen = TransferLength;
543 ULONG TransferLength;
554 DPRINT(
"USBPORT_RootHubSCE: Transfer - %p\n", Transfer);
556 Endpoint = Transfer->Endpoint;
562 HubDescriptor = &
PdoExtension->RootHubDescriptors->Descriptor;
569 TransferLength = Transfer->TransferParameters.TransferBufferLength;
585 DPRINT1(
"USBPORT_RootHubSCE: Error! Buffer is NULL\n");
592 DPRINT1(
"USBPORT_RootHubSCE: Error! TransferLength - %x, NumberOfPorts - %x\n",
614 DPRINT1(
"USBPORT_RootHubSCE: RH_GetPortStatus failed\n");
618 if (
PortStatus.PortChange.Usb20PortChange.ConnectStatusChange ||
619 PortStatus.PortChange.Usb20PortChange.PortEnableDisableChange ||
620 PortStatus.PortChange.Usb20PortChange.SuspendChange ||
621 PortStatus.PortChange.Usb20PortChange.OverCurrentIndicatorChange ||
622 PortStatus.PortChange.Usb20PortChange.ResetChange)
625 AddressBitMap[
Port >> 5] |= 1 << (
Port & 0x1F);
637 AddressBitMap[0] |= 1;
658 DPRINT1(
"USBPORT_RootHubSCE: RH_GetHubStatus failed\n");
674 DPRINT_CORE(
"USBPORT_RootHubEndpointWorker: Endpoint - %p\n", Endpoint);
676 FdoDevice = Endpoint->FdoDevice;
694 Endpoint->TransferList.Flink ==
NULL ||
700 &Endpoint->CloseLink,
756 ULONG DescriptorsLength;
767 DPRINT(
"USBPORT_RootHubCreateDevice: FdoDevice - %p, PdoDevice - %p\n",
807 RH_DeviceDescriptor = &
PdoExtension->RootHubDescriptors->DeviceDescriptor;
811 RH_DeviceDescriptor->
bcdUSB = 0x100;
820 RH_DeviceDescriptor->
iProduct = 0x00;
824 RH_ConfigurationDescriptor = &
PdoExtension->RootHubDescriptors->ConfigDescriptor;
837 RH_ConfigurationDescriptor->
MaxPower = 0x00;
839 RH_InterfaceDescriptor = &
PdoExtension->RootHubDescriptors->InterfaceDescriptor;
851 RH_EndPointDescriptor = &
PdoExtension->RootHubDescriptors->EndPointDescriptor;
860 RH_HubDescriptor = &
PdoExtension->RootHubDescriptors->Descriptor;
876 DPRINT1(
"USBPORT_RootHubCreateDevice: Unknown MiniPortVersion - %x\n",
887 for (ix = 0; ix < NumMaskByte; ix += 2)
893 EndpointDescriptor = &
DeviceHandle->PipeHandle.EndpointDescriptor;
925 DPRINT(
"USBPORT_InvalidateRootHub ... \n");
972 ULONG CompanionPorts;
977 DPRINT(
"USBPORT_RootHub_PowerAndChirpAllCcPorts: FdoDevice - %p\n",
1002 if (CompanionControllersList)
1006 for (NumController = 0;
1007 NumController < CompanionControllersList->
Count;
1010 CompanionPacket = &
FdoExtension->MiniPortInterface->Packet;
1012 CompanionFdoExtension = (*Entry)->DeviceExtension;
#define InterlockedIncrement
#define InterlockedDecrement
_In_ ULONG const _In_ FEATURE_NUMBER const Feature
VOID NTAPI USBPORT_AddDeviceHandle(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_DEVICE_HANDLE DeviceHandle)
VOID NTAPI USBPORT_HcQueueWakeDpc(IN PDEVICE_OBJECT FdoDevice)
VOID NTAPI USBPORT_FlushCancelList(IN PUSBPORT_ENDPOINT Endpoint)
VOID NTAPI USBPORT_InvalidateEndpointHandler(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_ENDPOINT Endpoint, IN ULONG Type)
NTSTATUS NTAPI USBPORT_OpenPipe(IN PDEVICE_OBJECT FdoDevice, IN PUSBPORT_DEVICE_HANDLE DeviceHandle, IN PUSBPORT_PIPE_HANDLE PipeHandle, IN OUT PUSBD_STATUS UsbdStatus)
#define RemoveEntryList(Entry)
#define InsertTailList(ListHead, Entry)
#define ExAllocatePoolWithTag(hernya, size, tag)
#define IsListEmpty(ListHead)
#define KeReleaseSpinLock(sl, irql)
#define KeAcquireSpinLock(sl, irql)
#define InitializeListHead(ListHead)
_Inout_ PUSB_DEVICE_HANDLE DeviceHandle
_Outptr_ PUSB_DEVICE_HANDLE _In_ PUSB_DEVICE_HANDLE _In_ USHORT PortStatus
NTSYSAPI void WINAPI DbgBreakPoint(void)
PLIST_ENTRY NTAPI ExInterlockedInsertTailList(IN OUT PLIST_ENTRY ListHead, IN OUT PLIST_ENTRY ListEntry, IN OUT PKSPIN_LOCK Lock)
#define ExFreePoolWithTag(_P, _T)
_In_ NDIS_HANDLE _In_ PNDIS_PACKET Packet
_In_ ULONG _In_ ULONG _In_ ULONG Length
base of all file and directory entries
PDEVICE_OBJECT Objects[1]
struct _URB_CONTROL_TRANSFER UrbControlTransfer
PUSBPORT_MINIPORT_INTERFACE MiniPortInterface
PDEVICE_OBJECT RootHubPdo
USBPORT_REGISTRATION_PACKET Packet
PHCI_RH_GET_ROOT_HUB_DATA RH_GetRootHubData
PHCI_RH_SET_FEATURE_PORT_POWER RH_SetFeaturePortPower
USBPORT_HUB_CHARACTERISTICS HubCharacteristics
UCHAR bConfigurationValue
USHORT wHubCharacteristics
UCHAR bRemoveAndPowerMask[64]
UCHAR bPowerOnToPowerGood
#define FIELD_OFFSET(t, f)
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define CONTAINING_RECORD(address, type, field)
#define STATUS_INSUFFICIENT_RESOURCES
#define USB_REQUEST_GET_STATUS
struct _USB_CONFIGURATION_DESCRIPTOR USB_CONFIGURATION_DESCRIPTOR
#define USB_ENDPOINT_TYPE_INTERRUPT
#define USB_REQUEST_GET_CONFIGURATION
#define USB_REQUEST_GET_DESCRIPTOR
#define USB_CONFIGURATION_DESCRIPTOR_TYPE
#define USB_ENDPOINT_DESCRIPTOR_TYPE
struct _USB_ENDPOINT_DESCRIPTOR USB_ENDPOINT_DESCRIPTOR
#define USB_ENDPOINT_TYPE_CONTROL
struct _USB_HUB_DESCRIPTOR USB_HUB_DESCRIPTOR
#define USB_DEVICE_DESCRIPTOR_TYPE
#define BMREQUEST_TO_OTHER
struct _USB_DEVICE_DESCRIPTOR USB_DEVICE_DESCRIPTOR
#define USB_CONFIG_SELF_POWERED
#define USB_REQUEST_SET_FEATURE
#define BMREQUEST_HOST_TO_DEVICE
#define USB_REQUEST_SET_CONFIGURATION
#define BMREQUEST_STANDARD
#define USB_DEVICE_CLASS_HUB
#define USB_REQUEST_CLEAR_FEATURE
#define USB_REQUEST_SET_ADDRESS
struct _USB_INTERFACE_DESCRIPTOR USB_INTERFACE_DESCRIPTOR
#define USB_INTERFACE_DESCRIPTOR_TYPE
#define BMREQUEST_DEVICE_TO_HOST
struct _USB_DEFAULT_PIPE_SETUP_PACKET * PUSB_DEFAULT_PIPE_SETUP_PACKET
#define USB_20_HUB_DESCRIPTOR_TYPE
#define USB_30_HUB_DESCRIPTOR_TYPE
#define USBD_STATUS_STALL_PID
#define USBD_STATUS_SUCCESS
#define USBPORT_ENDPOINT_REMOVE
#define USB_MINIPORT_FLAGS_USB2
#define RH_STATUS_UNSUCCESSFUL
#define USB_MINIPORT_VERSION_EHCI
#define RH_STATUS_NO_CHANGES
#define USB_MINIPORT_VERSION_XHCI
#define RH_STATUS_SUCCESS
#define USBPORT_TRANSFER_TYPE_CONTROL
#define USB_MINIPORT_VERSION_UHCI
#define USB_MINIPORT_VERSION_OHCI
#define MP_STATUS_FAILURE
#define MP_STATUS_SUCCESS
RHSTATUS NTAPI USBPORT_RootHubEndpoint0(IN PUSBPORT_TRANSFER Transfer)
RHSTATUS NTAPI USBPORT_MPStatusToRHStatus(IN MPSTATUS MPStatus)
MPSTATUS NTAPI USBPORT_RH_SetFeatureUSB2PortPower(IN PDEVICE_OBJECT FdoDevice, IN USHORT Port)
ULONG NTAPI USBPORT_InvalidateRootHub(PVOID MiniPortExtension)
RHSTATUS NTAPI USBPORT_RootHubSCE(IN PUSBPORT_TRANSFER Transfer)
RHSTATUS NTAPI USBPORT_RootHubStandardCommand(IN PDEVICE_OBJECT FdoDevice, IN PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket, IN PVOID Buffer, IN OUT PULONG TransferLength)
NTSTATUS NTAPI USBPORT_RootHubCreateDevice(IN PDEVICE_OBJECT FdoDevice, IN PDEVICE_OBJECT PdoDevice)
VOID NTAPI USBPORT_RootHubEndpointWorker(IN PUSBPORT_ENDPOINT Endpoint)
RHSTATUS NTAPI USBPORT_RootHubClassCommand(IN PDEVICE_OBJECT FdoDevice, IN PUSB_DEFAULT_PIPE_SETUP_PACKET SetupPacket, IN PVOID Buffer, IN PULONG BufferLength)
VOID NTAPI USBPORT_RootHubPowerAndChirpAllCcPorts(IN PDEVICE_OBJECT FdoDevice)
BOOLEAN NTAPI USBPORT_QueueDoneTransfer(IN PUSBPORT_TRANSFER Transfer, IN USBD_STATUS USBDStatus)
PDEVICE_RELATIONS NTAPI USBPORT_FindCompanionControllers(IN PDEVICE_OBJECT USB2FdoDevice, IN BOOLEAN IsObRefer, IN BOOLEAN IsFDOsReturned)
NTSTATUS NTAPI USBPORT_Wait(IN PVOID MiniPortExtension, IN ULONG Milliseconds)
#define FEATURE_C_PORT_ENABLE
#define USBPORT_FLAG_HC_WAKE_SUPPORT
#define FEATURE_PORT_SUSPEND
#define USBPORT_RECIPIENT_PORT
#define USBPORT_TMFLAG_WAKE
#define TRANSFER_FLAG_CANCELED
#define FEATURE_C_HUB_OVER_CURRENT
#define DEVICE_HANDLE_FLAG_ROOTHUB
#define FEATURE_C_PORT_RESET
struct _USBPORT_DEVICE_EXTENSION * PUSBPORT_DEVICE_EXTENSION
#define INVALIDATE_ENDPOINT_WORKER_THREAD
#define USBPORT_FLAG_HC_SUSPEND
struct _USBPORT_DEVICE_EXTENSION USBPORT_DEVICE_EXTENSION
#define FEATURE_C_PORT_OVER_CURRENT
#define FEATURE_C_PORT_SUSPEND
#define USBPORT_PNP_STATE_STARTED
#define USBPORT_MPFLAG_SUSPENDED
#define FEATURE_PORT_ENABLE
#define FEATURE_C_HUB_LOCAL_POWER
#define FEATURE_PORT_RESET
#define FEATURE_PORT_POWER
#define FEATURE_C_PORT_CONNECTION
#define TRANSFER_FLAG_ABORTED
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
_Must_inspect_result_ _In_ WDFIORESLIST _In_ PIO_RESOURCE_DESCRIPTOR Descriptor
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _In_ PWDF_USB_CONTROL_SETUP_PACKET SetupPacket
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql