13#define NDEBUG_USBHUB_SCE
14#define NDEBUG_USBHUB_PNP
27 DPRINT(
"USBH_Wait: Milliseconds - %x\n", Milliseconds);
43 DPRINT(
"USBHUB_GetConfigValue: ... \n");
68 DPRINT1(
"USBH_CompleteIrp: Irp - %p, CompleteStatus - %X\n",
73 Irp->IoStatus.Status = CompleteStatus;
82 DPRINT_PNP(
"USBH_PassIrp: DeviceObject - %p, Irp - %p\n",
100 DPRINT(
"USBH_SyncIrpComplete: ... \n");
126 IsSet = (BitMapAddress[Bit / 8] & (1 << (Bit & 7))) != 0;
127 DPRINT(
"IsBitSet: Bit - %lX, IsSet - %x\n", Bit, IsSet);
160 DPRINT(
"USBH_WriteFailReason: ID - %x\n", FailReason);
193 DPRINT(
"USBH_TimeoutDPC ... \n");
224 DPRINT(
"USBH_SetPdoRegistryParameter ... \n");
262 DPRINT(
"USBH_SyncSubmitUrb: ... \n");
264 Urb->UrbHeader.UsbdDeviceHandle =
NULL;
290 if (HubTimeoutContext)
294 HubTimeoutContext->
Irp =
Irp;
308 DueTime.QuadPart = -5000 * 10000;
321 IsWaitTimeout =
TRUE;
360 DPRINT(
"USBH_FdoSyncSubmitUrb: FdoDevice - %p, Urb - %p\n",
364 HubExtension = FdoDevice->DeviceExtension;
386 DPRINT(
"USBH_Transact: ... \n");
439 Urb->
Hdr.UsbdDeviceHandle =
NULL;
449 Urb->
Value = RequestValue;
450 Urb->
Index = RequestIndex;
454 if (IsDeviceToHost && BufferLen)
477 ULONG ResetRetry = 0;
480 DPRINT(
"USBH_SyncResetPort: Port - %x\n",
Port);
496 (
PortStatus.PortStatus.Usb20PortStatus.CurrentConnectStatus == 0))
528 Timeout.QuadPart = -5000 * 10000;
536 HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_RESET_PORT_LOCK;
558 (
PortStatus.PortStatus.Usb20PortStatus.CurrentConnectStatus == 0) ||
565 HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_RESET_PORT_LOCK;
579 if ((
PortStatus.PortStatus.Usb20PortStatus.CurrentConnectStatus == 0) &&
587 HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_RESET_PORT_LOCK;
598 KeSetEvent(&HubExtension->PendingRequestEvent,
619 DPRINT(
"USBH_GetDeviceType: ... \n");
625 DPRINT1(
"USBH_GetDeviceType: no QueryDeviceInformation()\n");
639 DPRINT1(
"USBH_GetDeviceType: ExAllocatePoolWithTag() failed\n");
686 DPRINT(
"USBHUB_GetExtendedHubInfo: ... \n");
688 GetExtendedHubInformation = HubExtension->BusInterface.GetExtendedHubInformation;
690 return GetExtendedHubInformation(HubExtension->BusInterface.BusContext,
691 HubExtension->LowerPDO,
704 DPRINT(
"USBH_GetRootHubExtension: HubExtension - %p\n", HubExtension);
706 RootHubExtension = HubExtension;
708 if (HubExtension->LowerPDO != HubExtension->RootHubPdo)
716 while (
Device->DriverObject != HubExtension->Common.SelfDevice->DriverObject);
718 RootHubExtension =
Device->DeviceExtension;
721 DPRINT(
"USBH_GetRootHubExtension: RootHubExtension - %p\n", RootHubExtension);
723 return RootHubExtension;
738 DPRINT(
"USBH_SyncGetRootHubPdo: ... \n");
790 DPRINT(
"USBH_SyncGetHubCount: *OutHubCount - %x\n", *OutHubCount);
840 DPRINT(
"USBH_SyncGetDeviceHandle: ... \n");
856 DPRINT1(
"USBH_SyncGetDeviceHandle: Irp - NULL!\n");
883 DPRINT(
"USBH_GetDeviceDescriptor: ... \n");
891 DPRINT1(
"USBH_SyncGetDeviceHandle: Urb - NULL!\n");
922 DPRINT(
"USBH_SyncGetDeviceConfigurationDescriptor: ... \n");
982 DPRINT(
"USBH_GetConfigurationDescriptor: ... \n");
1023 *OutDescriptor =
NULL;
1028 if (ReturnedLen < ConfigDescriptor->wTotalLength)
1040 *OutDescriptor =
NULL;
1060 DPRINT(
"USBH_SyncGetHubDescriptor: ... \n");
1066 if (!ExtendedHubInfo)
1079 ExtendedHubInfo =
NULL;
1125 RequestValue = 0x2900;
1141 HubDescriptor =
NULL;
1160 if (HubExtension->PortData)
1162 PortData = HubExtension->PortData;
1164 for (ix = 0; ix < NumberPorts; ix++)
1168 if (ExtendedHubInfo)
1204 for (ix = 0; ix < NumberPorts; ix++)
1208 if (ExtendedHubInfo)
1220 HubExtension->HubDescriptor = HubDescriptor;
1222 HubExtension->PortData = PortData;
1224 if (ExtendedHubInfo)
1238 if (ExtendedHubInfo)
1257 ULONG TransferedLength;
1260 DPRINT(
"USBH_SyncGetStringDescriptor: Index - %x, LanguageId - %x\n",
1308 *OutLength = TransferedLength;
1311 if (IsValidateLength && TransferedLength !=
Descriptor->bLength)
1332 DPRINT(
"USBH_SyncGetStatus: ... \n");
1350 Urb->
Index = RequestIndex;
1354 *OutStatus = UsbStatus;
1369 DPRINT(
"USBH_SyncGetHubStatus\n");
1394 DPRINT(
"USBH_SyncClearHubStatus: RequestValue - %x\n", RequestValue);
1421 DPRINT(
"USBH_SyncGetPortStatus: Port - %x\n",
Port);
1448 DPRINT(
"USBH_SyncClearPortStatus: Port - %x, RequestValue - %x\n",
1480 DPRINT(
"USBH_SyncPowerOnPort: Port - %x, IsWait - %x\n",
Port, IsWait);
1483 PortData = &HubExtension->PortData[
Port - 1];
1486 if (
PortStatus->PortStatus.Usb20PortStatus.CurrentConnectStatus == 1)
1510 HubDescriptor = HubExtension->HubDescriptor;
1514 PortStatus->PortStatus.Usb20PortStatus.CurrentConnectStatus = 1;
1529 DPRINT(
"USBH_SyncPowerOnPorts: ... \n");
1531 HubDescriptor = HubExtension->HubDescriptor;
1540 DPRINT1(
"USBH_SyncPowerOnPorts: USBH_SyncPowerOnPort() failed - %lX\n",
1560 DPRINT(
"USBH_SyncDisablePort ... \n");
1562 PortData = &HubExtension->PortData[
Port - 1];
1596 DPRINT(
"USBH_HubIsBusPowered: ... \n");
1628 DPRINT_SCE(
"USBH_ChangeIndicationAckChangeComplete: ... \n");
1666 DPRINT_SCE(
"USBH_ChangeIndicationAckChange: ... \n");
1670 Urb->Hdr.UsbdDeviceHandle =
NULL;
1673 Urb->TransferBufferLength = 0;
1674 Urb->TransferBuffer =
NULL;
1675 Urb->TransferBufferMDL =
NULL;
1676 Urb->UrbLink =
NULL;
1686 Urb->Value = RequestValue;
1689 IoSizeOfIrp(HubExtension->LowerDevice->StackSize),
1690 HubExtension->LowerDevice->StackSize);
1720 DPRINT_SCE(
"USBH_ChangeIndicationProcessChange: PortStatus - %lX\n",
1779 DPRINT_SCE(
"USBH_ChangeIndicationQueryChange: Port - %x\n",
Port);
1785 ASSERT(HubExtension->WorkItemToQueue !=
NULL);
1787 WorkItem = HubExtension->WorkItemToQueue;
1788 HubExtension->WorkItemToQueue =
NULL;
1796 Urb->Hdr.UsbdDeviceHandle =
NULL;
1800 Urb->TransferBuffer = &HubExtension->PortStatus;
1801 Urb->TransferBufferLength =
sizeof(HubExtension->PortStatus);
1802 Urb->TransferBufferMDL =
NULL;
1803 Urb->UrbLink =
NULL;
1815 HubExtension->Port =
Port;
1818 IoSizeOfIrp(HubExtension->LowerDevice->StackSize),
1819 HubExtension->LowerDevice->StackSize);
1846 DPRINT_SCE(
"USBH_ProcessHubStateChange: HubStatus - %lx\n", HubStatus->AsUlong32);
1848 HubStatusChange = HubStatus->HubChange;
1852 DPRINT1(
"USBH_ProcessHubStateChange: LocalPowerChange\n");
1860 if (HubStatus->HubStatus.OverCurrent)
1862 DPRINT1(
"USBH_ProcessHubStateChange: OverCurrent UNIMPLEMENTED. FIXME\n");
1883 DPRINT_SCE(
"USBH_ProcessPortStateChange ... \n");
1886 PortData = &HubExtension->PortData[
Port - 1];
1888 PortStatusChange =
PortStatus->PortChange.Usb20PortChange;
1898 PortData = &HubExtension->PortData[
Port - 1];
1961 DPRINT1(
"USBH_ProcessPortStateChange: SuspendChange UNIMPLEMENTED. FIXME\n");
1966 DPRINT1(
"USBH_ProcessPortStateChange: OverCurrentIndicatorChange UNIMPLEMENTED. FIXME\n");
1988 DPRINT(
"USBH_GetPortStatus ... \n");
1995 HubExtension->LowerDevice,
2039 DPRINT(
"USBH_EnableParentPort ... \n");
2044 HubExtension->LowerDevice,
2083 DPRINT(
"USBH_ResetInterruptPipe ... \n");
2095 Urb->
PipeHandle = HubExtension->PipeInfo.PipeHandle;
2109 HubExtension->RequestErrors = 0;
2120 ULONG PortStatusFlags = 0;
2122 DPRINT(
"USBH_ResetHub: ... \n");
2157 DPRINT_SCE(
"USBH_ChangeIndicationWorker ... \n");
2176 if (!HubExtension->RequestErrors)
2181 DPRINT_SCE(
"USBH_ChangeIndicationWorker: RequestErrors - %x\n",
2182 HubExtension->RequestErrors);
2184 if (HubExtension->LowerPDO == HubExtension->RootHubPdo)
2189 LowerPortExtension = HubExtension->LowerPDO->DeviceExtension;
2198 if (!LowerHubExtension)
2209 !
PortStatus.PortStatus.Usb20PortStatus.CurrentConnectStatus)
2224 DPRINT1(
"USBH_ChangeIndicationWorker: USBHUB_FDO_FLAG_ESD_RECOVERING FIXME\n");
2239 Port < HubExtension->HubDescriptor->bNumberOfPorts;
2278 HubExtension->RequestErrors++;
2299 KeSetEvent(&HubExtension->PendingRequestEvent,
2337 DPRINT_SCE(
"USBH_ChangeIndication: IrpStatus - %x, UrbStatus - %x, HubFlags - %lX\n",
2338 Irp->IoStatus.Status,
2359 DPRINT_SCE(
"USBH_ChangeIndication: HubExtension->RequestErrors - %x\n",
2365 DPRINT_SCE(
"USBH_ChangeIndication: HubExtension->RequestErrors - %x\n",
2380 (
PVOID *)&HubWorkItemBuffer,
2406 Bitmap = HubWorkItemBuffer + 1;
2422 if (
Port > NumPorts)
2449 DPRINT_SCE(
"USBH_SubmitStatusChangeTransfer: HubExtension - %p, SCEIrp - %p\n",
2451 HubExtension->SCEIrp);
2455 DPRINT_SCE(
"USBH_SubmitStatusChangeTransfer: USBHUB_FDO_FLAG_NOT_D0_STATE\n");
2456 DPRINT_SCE(
"USBH_SubmitStatusChangeTransfer: HubFlags - %lX\n",
2457 HubExtension->HubFlags);
2462 Irp = HubExtension->SCEIrp;
2473 Urb->
Hdr.UsbdDeviceHandle =
NULL;
2475 Urb->
PipeHandle = HubExtension->PipeInfo.PipeHandle;
2483 IoSizeOfIrp(HubExtension->LowerDevice->StackSize),
2484 HubExtension->LowerDevice->StackSize);
2516 DPRINT(
"USBD_CreateDeviceEx: Port - %x, UsbPortStatus - 0x%04X\n",
2518 UsbPortStatus.AsUshort16);
2520 CreateUsbDevice = HubExtension->BusInterface.CreateUsbDevice;
2522 if (!CreateUsbDevice)
2529 return CreateUsbDevice(HubExtension->BusInterface.BusContext,
2532 UsbPortStatus.AsUshort16,
2544 DPRINT(
"USBD_RemoveDeviceEx: DeviceHandle - %p, Flags - %X\n",
2548 RemoveUsbDevice = HubExtension->BusInterface.RemoveUsbDevice;
2550 if (!RemoveUsbDevice)
2555 return RemoveUsbDevice(HubExtension->BusInterface.BusContext,
2573 DPRINT(
"USBD_InitializeDeviceEx: ... \n");
2575 InitializeUsbDevice = HubExtension->BusInterface.InitializeUsbDevice;
2576 GetUsbDescriptors = HubExtension->BusInterface.GetUsbDescriptors;
2578 if (!InitializeUsbDevice || !GetUsbDescriptors)
2583 Status = InitializeUsbDevice(HubExtension->BusInterface.BusContext,
2591 return GetUsbDescriptors(HubExtension->BusInterface.BusContext,
2607 DPRINT(
"USBHUB_SetDeviceHandleData ... \n");
2609 SetDeviceHandleData = HubExtension->BusInterface.SetDeviceHandleData;
2611 if (!SetDeviceHandleData)
2616 SetDeviceHandleData(HubExtension->BusInterface.BusContext,
2627 DPRINT(
"USBHUB_FlushAllTransfers ... \n");
2629 FlushTransfers = HubExtension->BusInterface.FlushTransfers;
2633 FlushTransfers(HubExtension->BusInterface.BusContext,
NULL);
2641 IN PUSB_NODE_CONNECTION_INFORMATION_EX
Info,
2648 PUSB_NODE_CONNECTION_INFORMATION_EX NodeInfo;
2654 DPRINT(
"USBD_GetDeviceInformationEx ... \n");
2702 NodeInfoLength = (
sizeof(USB_NODE_CONNECTION_INFORMATION_EX) -
sizeof(
USB_PIPE_INFO)) +
2715 NodeInfo->ConnectionIndex =
Info->ConnectionIndex;
2721 NodeInfo->CurrentConfigurationValue =
DeviceInfo->CurrentConfigurationValue;
2724 NodeInfo->DeviceAddress =
DeviceInfo->DeviceAddress;
2725 NodeInfo->NumberOfOpenPipes =
DeviceInfo->NumberOfOpenPipes;
2726 NodeInfo->ConnectionStatus =
Info->ConnectionStatus;
2728 for (PipeNumber = 0;
2742 if (NodeInfoLength <=
Length)
2768 DPRINT(
"USBD_RestoreDeviceEx: HubExtension - %p, OldDeviceHandle - %p, NewDeviceHandle - %p\n",
2773 RestoreUsbDevice = HubExtension->BusInterface.RestoreUsbDevice;
2775 if (RestoreUsbDevice)
2777 Status = RestoreUsbDevice(HubExtension->BusInterface.BusContext,
2795 PVOID * OutHubWorkItemBuffer,
2800 PVOID WorkItemBuffer;
2802 DPRINT(
"USBH_AllocateWorkItem: ... \n");
2838 if (!WorkItemBuffer)
2857 if (OutHubIoWorkItem)
2859 *OutHubIoWorkItem = HubIoWorkItem;
2862 if (OutHubWorkItemBuffer)
2912 DPRINT(
"USBH_Worker: HubIoWorkItem %p complete\n",
Context);
2920 DPRINT(
"USBH_QueueWorkItem: ... \n");
2926 &HubIoWorkItem->HubWorkItemLink,
2927 &HubExtension->WorkItemSpinLock);
2931 HubIoWorkItem->HubWorkItemType,
2941 DPRINT(
"USBH_FreeWorkItem: ... \n");
2943 WorkItem = HubIoWorkItem->HubWorkItem;
2945 if (HubIoWorkItem->HubWorkItemBuffer)
2961 DPRINT(
"USBHUB_RootHubCallBack: ... \n");
2965 if (HubExtension->
SCEIrp)
2990 DPRINT(
"USBD_RegisterRootHubCallBack: ... \n");
2992 RootHubInitNotification = HubExtension->BusInterface.RootHubInitNotification;
2994 if (!RootHubInitNotification)
3001 return RootHubInitNotification(HubExtension->BusInterface.BusContext,
3013 DPRINT(
"USBD_UnRegisterRootHubCallBack ... \n");
3015 RootHubInitNotification = HubExtension->BusInterface.RootHubInitNotification;
3017 if (!RootHubInitNotification)
3022 Status = RootHubInitNotification(HubExtension->BusInterface.BusContext,
3046 DPRINT(
"USBH_HubSetDWakeCompletion: ... \n");
3063 DPRINT(
"USBH_HubQueuePortIdleIrps ... \n");
3069 NumPorts = HubExtension->HubDescriptor->bNumberOfPorts;
3073 PortDevice = HubExtension->PortData[
Port].DeviceObject;
3084 DPRINT1(
"USBH_HubQueuePortIdleIrps: IdleIrp != NULL. FIXME\n");
3092 HubIdleIrp = HubExtension->PendingIdleIrp;
3093 HubExtension->PendingIdleIrp =
NULL;
3114 DPRINT(
"USBH_HubCompleteQueuedPortIdleIrps ... \n");
3118 DPRINT1(
"USBH_HubCompleteQueuedPortIdleIrps: IdleList not Empty. FIXME\n");
3132 DPRINT(
"USBH_FlushPortPwrList ... \n");
3142 for (
Port = 0;
Port < HubExtension->HubDescriptor->bNumberOfPorts; ++
Port)
3144 PortDevice = HubExtension->PortData[
Port].DeviceObject;
3165 DPRINT1(
"USBH_FlushPortPwrList: PortPowerList FIXME\n");
3177 KeSetEvent(&HubExtension->PendingRequestEvent,
3190 DPRINT(
"USBH_HubCompletePortIdleIrps ... \n");
3209 DPRINT(
"USBH_HubCancelIdleIrp ... \n");
3231 DPRINT(
"USBH_CheckIdleAbort: ... \n");
3244 PortData = HubExtension->PortData;
3246 for (
Port = 0;
Port < HubExtension->HubDescriptor->bNumberOfPorts;
Port++)
3262 if (IsExtCheck ==
TRUE)
3264 PortData = HubExtension->PortData;
3267 Port < HubExtension->HubDescriptor->bNumberOfPorts;
3292 KeSetEvent(&HubExtension->PendingRequestEvent,
3308 DPRINT(
"USBH_FdoWaitWakeIrpCompletion ... \n");
3320 DPRINT(
"USBH_FdoSubmitWaitWakeIrp: ... \n");
3322 PowerState.SystemState = HubExtension->SystemWake;
3341 HubExtension->PendingWakeIrp =
Irp;
3342 DPRINT(
"USBH_FdoSubmitWaitWakeIrp: PendingWakeIrp - %p\n",
3343 HubExtension->PendingWakeIrp);
3348 HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_PENDING_WAKE_IRP;
3352 KeSetEvent(&HubExtension->PendingRequestEvent,
3377 PUSB_IDLE_CALLBACK_INFO CallbackInfo;
3384 DPRINT(
"USBH_FdoIdleNotificationCallback: HubExtension - %p, HubFlags - %lX\n",
3408 DPRINT(
"Status != STATUS_PENDING. DbgBreakPoint()\n");
3410 HubExtension->
HubFlags &= ~USBHUB_FDO_FLAG_GOING_IDLE;
3454 if (!CallbackInfo->IdleCallback)
3474 DPRINT(
"USBH_FdoIdleNotificationCallback: IdleContext - %p\n",
3475 CallbackInfo->IdleContext);
3477 CallbackInfo->IdleCallback(CallbackInfo->IdleContext);
3510 DPRINT1(
"USBH_FdoIdleNotificationCallback: HubFlags - %lX\n",
3545 HubExtension->
HubFlags &= ~USBHUB_FDO_FLAG_GOING_IDLE;
3550 DPRINT(
"USBH_FdoIdleNotificationCallback: LowerPdo - %p\n",
3553 DPRINT(
"USBH_FdoIdleNotificationCallback: PowerState.DeviceState - %x\n",
3584 DPRINT(
"USBH_CompletePortIdleIrpsWorker ... \n");
3587 NtStatus = IdlePortContext->
Status;
3593 DPRINT1(
"USBH_CompletePortIdleIrpsWorker: USBH_RegQueryFlushPortPowerIrpsFlag() UNIMPLEMENTED. FIXME\n");
3612 DPRINT(
"USBH_IdleCompletePowerHubWorker ... \n");
3615 HubExtension->CurrentPowerState.DeviceState !=
PowerDeviceD0 &&
3643 HubExtension->
HubFlags &= ~USBHUB_FDO_FLAG_WAIT_IDLE_REQUEST;
3648 DPRINT(
"USBH_FdoIdleNotificationRequestComplete: IdleIrp - %p\n", IdleIrp);
3657 NtStatus =
Irp->IoStatus.Status;
3659 DPRINT(
"USBH_FdoIdleNotificationRequestComplete: NtStatus - %lX\n",
3667 DPRINT(
"USBH_FdoIdleNotificationRequestComplete: DeviceState - %x\n",
3678 (
PVOID *)&HubWorkItemBuffer,
3683 HubWorkItemBuffer->
Status = NtStatus;
3699 (
PVOID *)&HubWorkItemBuffer,
3704 HubWorkItemBuffer->
Status = NtStatus;
3713 DPRINT(
"USBH_FdoIdleNotificationRequestComplete: Irp - %p\n",
Irp);
3731 DPRINT(
"USBH_FdoSubmitIdleRequestIrp: HubExtension - %p, PendingIdleIrp - %p\n",
3733 HubExtension->PendingIdleIrp);
3735 if (HubExtension->PendingIdleIrp)
3742 HubFlags = HubExtension->HubFlags;
3747 HubExtension->HubFlags = HubFlags & ~USBHUB_FDO_FLAG_WAIT_IDLE_REQUEST;
3752 LowerPDO = HubExtension->LowerPDO;
3755 HubExtension->IdleCallbackInfo.IdleContext = HubExtension;
3761 HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_WAIT_IDLE_REQUEST;
3796 HubExtension->PendingIdleIrp =
Irp;
3820 DPRINT(
"USBH_CheckHubIdle: FIXME !!! HubExtension - %p\n", HubExtension);
3838 HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_CHECK_IDLE_LOCK;
3843 HubFlags = HubExtension->HubFlags;
3844 DPRINT(
"USBH_CheckHubIdle: HubFlags - %lX\n", HubFlags);
3864 if (HubExtension->ResetRequestCount)
3870 HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_DEFER_CHECK_IDLE;
3882 IsAllPortsIdle =
TRUE;
3884 PortData = HubExtension->PortData;
3887 Port < HubExtension->HubDescriptor->bNumberOfPorts;
3898 DPRINT(
"USBH_CheckHubIdle: PortExtension - %p\n",
3901 IsAllPortsIdle =
FALSE;
3926 KeSetEvent(&HubExtension->PendingRequestEvent,
3931 DPRINT(
"USBH_CheckHubIdle: IsAllPortsIdle - %x, IsHubIdle - %x\n",
3935 if (IsAllPortsIdle && IsHubIdle)
3942 HubExtension->HubFlags &= ~USBHUB_FDO_FLAG_CHECK_IDLE_LOCK;
3951 DPRINT(
"USBH_CheckIdleWorker: ... \n");
3962 DPRINT(
"USBH_CheckIdleDeferred: HubExtension - %p\n", HubExtension);
3971 DPRINT(
"USBH_CheckIdleDeferred: HubIoWorkItem - %p\n", HubIoWorkItem);
3988 DPRINT(
"USBH_PdoSetCapabilities ... \n");
3990 HubExtension = PortExtension->HubExtension;
3992 PortExtension->Capabilities.Size = 64;
3993 PortExtension->Capabilities.Version = 1;
3995 PortExtension->Capabilities.Removable = 1;
3996 PortExtension->Capabilities.Address = PortExtension->PortNumber;
3998 if (PortExtension->SerialNumber)
4000 PortExtension->Capabilities.UniqueID = 1;
4004 PortExtension->Capabilities.UniqueID = 0;
4007 PortExtension->Capabilities.RawDeviceOK = 0;
4019 PortExtension->Capabilities.DeviceD1 = 1;
4020 PortExtension->Capabilities.DeviceD2 = 1;
4022 PortExtension->Capabilities.WakeFromD0 = 1;
4023 PortExtension->Capabilities.WakeFromD1 = 1;
4024 PortExtension->Capabilities.WakeFromD2 = 1;
4026 pDeviceState = &PortExtension->Capabilities.DeviceState[2];
4062 DPRINT(
"USBH_ProcessDeviceInformation ... \n");
4067 sizeof(PortExtension->InterfaceDescriptor));
4069 PortExtension->PortPdoFlags &= ~USBHUB_PDO_FLAG_HUB_DEVICE;
4084 PortExtension->PortPdoFlags &= ~USBHUB_PDO_FLAG_REMOTE_WAKEUP;
4095 DPRINT_PNP(
"USBH_ProcessDeviceInformation: Class - %x, SubClass - %x, Protocol - %x\n",
4096 PortExtension->DeviceDescriptor.bDeviceClass,
4097 PortExtension->DeviceDescriptor.bDeviceSubClass,
4098 PortExtension->DeviceDescriptor.bDeviceProtocol);
4100 DPRINT_PNP(
"USBH_ProcessDeviceInformation: bNumConfigurations - %x, bNumInterfaces - %x\n",
4101 PortExtension->DeviceDescriptor.bNumConfigurations,
4116 PortExtension->DeviceDescriptor.bDeviceSubClass == 0x02 &&
4117 PortExtension->DeviceDescriptor.bDeviceProtocol == 0x01)) &&
4119 (PortExtension->DeviceDescriptor.bNumConfigurations < 2))
4121 DPRINT(
"USBH_ProcessDeviceInformation: Multi-Interface configuration\n");
4144 sizeof(PortExtension->InterfaceDescriptor));
4178 DPRINT(
"USBH_CheckDeviceIDUnique: idVendor - 0x%04X, idProduct - 0x%04X\n",
4182 if (!HubExtension->HubDescriptor->bNumberOfPorts)
4187 for (
Port = 0;
Port < HubExtension->HubDescriptor->bNumberOfPorts;
Port++)
4189 PortDevice = HubExtension->PortData[
Port].DeviceObject;
4203 SN_DescriptorLength);
4205 if (NumberBytes == SN_DescriptorLength)
4224 DPRINT(
"USBH_ValidateSerialNumberString: ... \n");
4226 for (ix = 0; SerialNumberString[ix] !=
UNICODE_NULL; ix++)
4228 Symbol = SerialNumberString[ix];
4230 if (Symbol < 0x20 || Symbol > 0x7F ||
Symbol == 0x2C)
4252 DPRINT(
"USBH_CheckDeviceLanguage: LanguageId - 0x%04X\n", LanguageId);
4284 for (ix = 1; ix < NumSymbols; ix++)
4286 if (*pSymbol == (
WCHAR)LanguageId)
4316 DPRINT(
"USBH_GetSerialNumberString: ... \n");
4318 *OutSerialNumber =
NULL;
4319 *OutDescriptorLength = 0;
4361 if (!SerialNumberBuffer)
4369 *OutSerialNumber = SerialNumberBuffer;
4370 *OutDescriptorLength =
Length;
4384 ULONG PdoNumber = 0;
4385 WCHAR CharDeviceName[64];
4390 LPWSTR SerialNumberBuffer;
4397 DPRINT(
"USBH_CreateDevice: Port - %x, UsbPortStatus - %lX\n",
4399 UsbPortStatus.AsUshort16);
4404 sizeof(CharDeviceName),
4405 L"\\Device\\USBPDO-%d",
4429 DeviceObject->StackSize = HubExtension->RootHubPdo2->StackSize;
4434 DPRINT(
"USBH_CreateDevice: PortExtension - %p\n", PortExtension);
4458 SerialNumberBuffer =
NULL;
4460 IsHsDevice = UsbPortStatus.Usb20PortStatus.HighSpeedDeviceAttached;
4461 IsLsDevice = UsbPortStatus.Usb20PortStatus.LowSpeedDeviceAttached;
4463 if (IsLsDevice == 0)
4485 DPRINT1(
"USBH_CreateDevice: IoCreateDevice() failed - %lX\n",
Status);
4496 DPRINT1(
"USBH_CreateDevice: USBD_CreateDeviceEx() failed - %lX\n",
Status);
4504 DPRINT1(
"USBH_CreateDevice: USBH_SyncResetPort() failed - %lX\n",
Status);
4522 DPRINT1(
"USBH_CreateDevice: USBD_InitializeDeviceEx() failed - %lX\n",
Status);
4527 DPRINT1(
"USBH_RegQueryDeviceIgnoreHWSerNumFlag UNIMPLEMENTED. FIXME\n");
4534 IgnoringHwSerial =
FALSE;
4537 if (IgnoringHwSerial)
4548 &SerialNumberBuffer,
4553 if (SerialNumberBuffer)
4558 SerialNumberBuffer =
NULL;
4561 if (SerialNumberBuffer &&
4569 SerialNumberBuffer =
NULL;
4574 SerialNumberBuffer);
4601 if (SerialNumberBuffer)
4630 DPRINT(
"USBH_ResetDevice: HubExtension - %p, Port - %x, IsKeepDeviceData - %x, IsWait - %x\n",
4642 !(
PortStatus.PortStatus.Usb20PortStatus.CurrentConnectStatus))
4656 PortData = &HubExtension->PortData[
Port-1];
4671 KeSetEvent(&HubExtension->PendingRequestEvent,
4754 if (IsKeepDeviceData)
4772 PortExtension->
PortPdoFlags &= ~USBHUB_PDO_FLAG_REMOVING_PORT_PDO;
4799 KeSetEvent(&HubExtension->PendingRequestEvent,
4825 DPRINT(
"USBH_PdoDispatch: IRP_MJ_CREATE / IRP_MJ_CLOSE (%d)\n",
4833 DPRINT(
"USBH_PdoDispatch: IRP_MJ_DEVICE_CONTROL ControlCode - %x\n",
4845 DPRINT1(
"USBH_PdoDispatch: IOCTL_KS_PROPERTY FIXME\n");