27 { PORTSC_ENABLED, USB_PORT_STAT_ENABLE },
28 { PORTSC_SUSPEND, USB_PORT_STAT_SUSPEND },
29 { PORTSC_OVERCUR, USB_PORT_STAT_OVERCURRENT },
30 { PORTSC_RESET, USB_PORT_STAT_RESET },
31 { PORTSC_POWER, USB_PORT_STAT_POWER },
32 { PORTSC_OWNER, USB_PORT_STAT_OWNER }
37 { PORTSC_ENABLE_CHANGE, USB_PORT_STAT_C_ENABLE },
38 { PORTSC_OVERCUR_CHANGE, USB_PORT_STAT_C_OVERCURRENT }
42 gEhciDriverBinding = {
69 OUT UINT8 *PortNumber,
70 OUT UINT8 *Is64BitCapable
76 if ((MaxSpeed ==
NULL) || (PortNumber ==
NULL) || (Is64BitCapable ==
NULL)) {
77 return EFI_INVALID_PARAMETER;
80 OldTpl =
gBS->RaiseTPL (EHC_TPL);
81 Ehc = EHC_FROM_THIS (This);
83 *MaxSpeed = EFI_USB_SPEED_HIGH;
84 *PortNumber = (UINT8)(Ehc->HcStructParams & HCSP_NPORTS);
85 *Is64BitCapable = (UINT8)Ehc->Support64BitDma;
87 DEBUG ((DEBUG_INFO,
"EhcGetCapability: %d ports, 64 bit %d\n", *PortNumber, *Is64BitCapable));
89 gBS->RestoreTPL (OldTpl);
117 Ehc = EHC_FROM_THIS (This);
119 if (Ehc->DevicePath !=
NULL) {
125 (EFI_IO_BUS_USB | EFI_IOB_PC_RESET),
130 OldTpl =
gBS->RaiseTPL (EHC_TPL);
132 switch (Attributes) {
133 case EFI_USB_HC_RESET_GLOBAL:
137 case EFI_USB_HC_RESET_HOST_CONTROLLER:
147 Status =
EhcHaltHC (Ehc, EHC_GENERIC_TIMEOUT);
149 if (EFI_ERROR (Status)) {
150 Status = EFI_DEVICE_ERROR;
165 if (EFI_ERROR (Status)) {
172 case EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG:
173 case EFI_USB_HC_RESET_HOST_WITH_DEBUG:
174 Status = EFI_UNSUPPORTED;
178 Status = EFI_INVALID_PARAMETER;
182 DEBUG ((DEBUG_INFO,
"EhcReset: exit status %r\n", Status));
183 gBS->RestoreTPL (OldTpl);
211 return EFI_INVALID_PARAMETER;
214 OldTpl =
gBS->RaiseTPL (EHC_TPL);
215 Ehc = EHC_FROM_THIS (This);
217 if (EHC_REG_BIT_IS_SET (Ehc, EHC_USBSTS_OFFSET, USBSTS_HALT)) {
223 gBS->RestoreTPL (OldTpl);
225 DEBUG ((DEBUG_INFO,
"EhcGetState: current state %d\n", *State));
255 if (EFI_ERROR (Status)) {
256 return EFI_DEVICE_ERROR;
259 if (CurState == State) {
263 OldTpl =
gBS->RaiseTPL (EHC_TPL);
264 Ehc = EHC_FROM_THIS (This);
268 Status =
EhcHaltHC (Ehc, EHC_GENERIC_TIMEOUT);
272 if (EHC_REG_BIT_IS_SET (Ehc, EHC_USBSTS_OFFSET, USBSTS_SYS_ERROR)) {
273 Status = EFI_DEVICE_ERROR;
282 if (!EHC_REG_BIT_IS_SET (Ehc, EHC_USBSTS_OFFSET, USBSTS_HALT)) {
283 Status = EFI_DEVICE_ERROR;
287 Status =
EhcRunHC (Ehc, EHC_GENERIC_TIMEOUT);
291 Status = EFI_UNSUPPORTED;
295 Status = EFI_INVALID_PARAMETER;
298 DEBUG ((DEBUG_INFO,
"EhcSetState: exit status %r\n", Status));
299 gBS->RestoreTPL (OldTpl);
334 if (PortStatus ==
NULL) {
335 return EFI_INVALID_PARAMETER;
338 OldTpl =
gBS->RaiseTPL (EHC_TPL);
340 Ehc = EHC_FROM_THIS (This);
343 TotalPort = (Ehc->HcStructParams & HCSP_NPORTS);
345 if (PortNumber >= TotalPort) {
346 Status = EFI_INVALID_PARAMETER;
350 Offset = (UINT32)(EHC_PORT_STAT_OFFSET + (4 * PortNumber));
351 PortStatus->PortStatus = 0;
352 PortStatus->PortChangeStatus = 0;
366 if (EHC_BIT_IS_SET (State, PORTSC_LINESTATE_K)) {
367 PortStatus->PortStatus |= USB_PORT_STAT_LOW_SPEED;
368 }
else if (EHC_BIT_IS_SET (State, PORTSC_ENABLED)) {
369 PortStatus->PortStatus |= USB_PORT_STAT_HIGH_SPEED;
377 for (Index = 0; Index < MapSize; Index++) {
378 if (EHC_BIT_IS_SET (State, mUsbPortStateMap[Index].HwState)) {
379 PortStatus->PortStatus = (UINT16)(PortStatus->PortStatus | mUsbPortStateMap[Index].UefiState);
385 for (Index = 0; Index < MapSize; Index++) {
386 if (EHC_BIT_IS_SET (State, mUsbPortChangeMap[Index].HwState)) {
387 PortStatus->PortChangeStatus = (UINT16)(PortStatus->PortChangeStatus | mUsbPortChangeMap[Index].UefiState);
392 gBS->RestoreTPL (OldTpl);
423 OldTpl =
gBS->RaiseTPL (EHC_TPL);
424 Ehc = EHC_FROM_THIS (This);
427 TotalPort = (Ehc->HcStructParams & HCSP_NPORTS);
429 if (PortNumber >= TotalPort) {
430 Status = EFI_INVALID_PARAMETER;
434 Offset = (UINT32)(EHC_PORT_STAT_OFFSET + (4 * PortNumber));
441 State &= ~PORTSC_CHANGE_MASK;
443 switch (PortFeature) {
444 case EfiUsbPortEnable:
449 State |= PORTSC_ENABLED;
453 case EfiUsbPortSuspend:
454 State |= PORTSC_SUSPEND;
458 case EfiUsbPortReset:
463 Status =
EhcRunHC (Ehc, EHC_GENERIC_TIMEOUT);
465 if (EFI_ERROR (Status)) {
466 DEBUG ((DEBUG_INFO,
"EhcSetRootHubPortFeature :failed to start HC - %r\n", Status));
474 State |= PORTSC_RESET;
475 State &= ~PORTSC_ENABLED;
479 case EfiUsbPortPower:
483 if ((Ehc->HcCapParams & HCSP_PPC) == HCSP_PPC) {
484 State |= PORTSC_POWER;
490 case EfiUsbPortOwner:
491 State |= PORTSC_OWNER;
496 Status = EFI_INVALID_PARAMETER;
500 DEBUG ((DEBUG_INFO,
"EhcSetRootHubPortFeature: exit status %r\n", Status));
502 gBS->RestoreTPL (OldTpl);
536 OldTpl =
gBS->RaiseTPL (EHC_TPL);
537 Ehc = EHC_FROM_THIS (This);
540 TotalPort = (Ehc->HcStructParams & HCSP_NPORTS);
542 if (PortNumber >= TotalPort) {
543 Status = EFI_INVALID_PARAMETER;
547 Offset = EHC_PORT_STAT_OFFSET + (4 * PortNumber);
549 State &= ~PORTSC_CHANGE_MASK;
551 switch (PortFeature) {
552 case EfiUsbPortEnable:
556 State &= ~PORTSC_ENABLED;
560 case EfiUsbPortSuspend:
568 State &= ~PORSTSC_RESUME;
572 case EfiUsbPortReset:
576 State &= ~PORTSC_RESET;
580 case EfiUsbPortOwner:
584 State &= ~PORTSC_OWNER;
588 case EfiUsbPortConnectChange:
592 State |= PORTSC_CONN_CHANGE;
596 case EfiUsbPortEnableChange:
600 State |= PORTSC_ENABLE_CHANGE;
604 case EfiUsbPortOverCurrentChange:
608 State |= PORTSC_OVERCUR_CHANGE;
612 case EfiUsbPortPower:
616 if ((Ehc->HcCapParams & HCSP_PPC) == HCSP_PPC) {
617 State &= ~PORTSC_POWER;
622 case EfiUsbPortSuspendChange:
623 case EfiUsbPortResetChange:
630 Status = EFI_INVALID_PARAMETER;
635 DEBUG ((DEBUG_INFO,
"EhcClearRootHubPortFeature: exit status %r\n", Status));
636 gBS->RestoreTPL (OldTpl);
668 IN UINT8 DeviceAddress,
669 IN UINT8 DeviceSpeed,
677 OUT UINT32 *TransferResult
689 if ((Request ==
NULL) || (TransferResult ==
NULL)) {
690 return EFI_INVALID_PARAMETER;
693 if ((TransferDirection != EfiUsbDataIn) &&
694 (TransferDirection != EfiUsbDataOut) &&
695 (TransferDirection != EfiUsbNoData))
697 return EFI_INVALID_PARAMETER;
700 if ((TransferDirection == EfiUsbNoData) &&
701 ((Data !=
NULL) || (*DataLength != 0)))
703 return EFI_INVALID_PARAMETER;
706 if ((TransferDirection != EfiUsbNoData) &&
707 ((Data ==
NULL) || (*DataLength == 0)))
709 return EFI_INVALID_PARAMETER;
712 if ((MaximumPacketLength != 8) && (MaximumPacketLength != 16) &&
713 (MaximumPacketLength != 32) && (MaximumPacketLength != 64))
715 return EFI_INVALID_PARAMETER;
718 if ((DeviceSpeed == EFI_USB_SPEED_LOW) && (MaximumPacketLength != 8)) {
719 return EFI_INVALID_PARAMETER;
722 OldTpl =
gBS->RaiseTPL (EHC_TPL);
723 Ehc = EHC_FROM_THIS (This);
725 Status = EFI_DEVICE_ERROR;
726 *TransferResult = EFI_USB_ERR_SYSTEM;
729 DEBUG ((DEBUG_ERROR,
"EhcControlTransfer: HC halted at entrance\n"));
746 Endpoint = (UINT8)(0 | ((TransferDirection == EfiUsbDataIn) ? 0x80 : 0));
765 DEBUG ((DEBUG_ERROR,
"EhcControlTransfer: failed to create URB"));
767 Status = EFI_OUT_OF_RESOURCES;
779 *TransferResult = Urb->Result;
780 *DataLength = Urb->Completed;
782 if (*TransferResult == EFI_USB_NOERROR) {
790 Ehc->PciIo->Flush (Ehc->PciIo);
791 gBS->RestoreTPL (OldTpl);
793 if (EFI_ERROR (Status)) {
794 DEBUG ((DEBUG_ERROR,
"EhcControlTransfer: error - %r, transfer - %x\n", Status, *TransferResult));
834 IN UINT8 DeviceAddress,
835 IN UINT8 EndPointAddress,
836 IN UINT8 DeviceSpeed,
838 IN UINT8 DataBuffersNumber,
839 IN OUT VOID *Data[EFI_USB_MAX_BULK_BUFFER_NUM],
841 IN OUT UINT8 *DataToggle,
844 OUT UINT32 *TransferResult
851 UINTN DebugErrorLevel;
856 if ((DataLength ==
NULL) || (*DataLength == 0) ||
857 (Data ==
NULL) || (Data[0] ==
NULL) || (TransferResult ==
NULL))
859 return EFI_INVALID_PARAMETER;
862 if ((*DataToggle != 0) && (*DataToggle != 1)) {
863 return EFI_INVALID_PARAMETER;
866 if ((DeviceSpeed == EFI_USB_SPEED_LOW) ||
867 ((DeviceSpeed == EFI_USB_SPEED_FULL) && (MaximumPacketLength > 64)) ||
868 ((EFI_USB_SPEED_HIGH == DeviceSpeed) && (MaximumPacketLength > 512)))
870 return EFI_INVALID_PARAMETER;
873 OldTpl =
gBS->RaiseTPL (EHC_TPL);
874 Ehc = EHC_FROM_THIS (This);
876 *TransferResult = EFI_USB_ERR_SYSTEM;
877 Status = EFI_DEVICE_ERROR;
880 DEBUG ((DEBUG_ERROR,
"EhcBulkTransfer: HC is halted\n"));
910 DEBUG ((DEBUG_ERROR,
"EhcBulkTransfer: failed to create URB\n"));
912 Status = EFI_OUT_OF_RESOURCES;
920 *TransferResult = Urb->Result;
921 *DataLength = Urb->Completed;
922 *DataToggle = Urb->DataToggle;
924 if (*TransferResult == EFI_USB_NOERROR) {
932 Ehc->PciIo->Flush (Ehc->PciIo);
933 gBS->RestoreTPL (OldTpl);
935 if (EFI_ERROR (Status)) {
936 if (Status == EFI_TIMEOUT) {
937 DebugErrorLevel = DEBUG_VERBOSE;
939 DebugErrorLevel = DEBUG_ERROR;
942 DEBUG ((DebugErrorLevel,
"EhcBulkTransfer: error - %r, transfer - %x\n", Status, *TransferResult));
981 IN UINT8 DeviceAddress,
982 IN UINT8 EndPointAddress,
983 IN UINT8 DeviceSpeed,
985 IN BOOLEAN IsNewTransfer,
986 IN OUT UINT8 *DataToggle,
991 IN VOID *Context OPTIONAL
1002 if (!EHCI_IS_DATAIN (EndPointAddress)) {
1003 return EFI_INVALID_PARAMETER;
1006 if (IsNewTransfer) {
1007 if (DataLength == 0) {
1008 return EFI_INVALID_PARAMETER;
1011 if ((*DataToggle != 1) && (*DataToggle != 0)) {
1012 return EFI_INVALID_PARAMETER;
1015 if ((PollingInterval > 255) || (PollingInterval < 1)) {
1016 return EFI_INVALID_PARAMETER;
1020 OldTpl =
gBS->RaiseTPL (EHC_TPL);
1021 Ehc = EHC_FROM_THIS (This);
1027 if (!IsNewTransfer) {
1030 DEBUG ((DEBUG_INFO,
"EhcAsyncInterruptTransfer: remove old transfer - %r\n", Status));
1037 DEBUG ((DEBUG_ERROR,
"EhcAsyncInterruptTransfer: HC is halt\n"));
1040 Status = EFI_DEVICE_ERROR;
1052 MaximumPacketLength,
1061 Status = EFI_OUT_OF_RESOURCES;
1066 Ehc->PciIo->Flush (Ehc->PciIo);
1067 gBS->RestoreTPL (OldTpl);
1103 IN UINT8 DeviceAddress,
1104 IN UINT8 EndPointAddress,
1105 IN UINT8 DeviceSpeed,
1109 IN OUT UINT8 *DataToggle,
1112 OUT UINT32 *TransferResult
1123 if ((DataLength ==
NULL) || (*DataLength == 0) ||
1124 (Data ==
NULL) || (TransferResult ==
NULL))
1126 return EFI_INVALID_PARAMETER;
1129 if ((*DataToggle != 1) && (*DataToggle != 0)) {
1130 return EFI_INVALID_PARAMETER;
1133 if (((DeviceSpeed == EFI_USB_SPEED_LOW) && (MaximumPacketLength != 8)) ||
1134 ((DeviceSpeed == EFI_USB_SPEED_FULL) && (MaximumPacketLength > 64)) ||
1135 ((DeviceSpeed == EFI_USB_SPEED_HIGH) && (MaximumPacketLength > 3072)))
1137 return EFI_INVALID_PARAMETER;
1140 OldTpl =
gBS->RaiseTPL (EHC_TPL);
1141 Ehc = EHC_FROM_THIS (This);
1143 *TransferResult = EFI_USB_ERR_SYSTEM;
1144 Status = EFI_DEVICE_ERROR;
1147 DEBUG ((DEBUG_ERROR,
"EhcSyncInterruptTransfer: HC is halt\n"));
1161 MaximumPacketLength,
1163 EHC_INT_TRANSFER_SYNC,
1173 DEBUG ((DEBUG_ERROR,
"EhcSyncInterruptTransfer: failed to create URB\n"));
1175 Status = EFI_OUT_OF_RESOURCES;
1183 *TransferResult = Urb->Result;
1184 *DataLength = Urb->Completed;
1185 *DataToggle = Urb->DataToggle;
1187 if (*TransferResult == EFI_USB_NOERROR) {
1193 Ehc->PciIo->Flush (Ehc->PciIo);
1194 gBS->RestoreTPL (OldTpl);
1196 if (EFI_ERROR (Status)) {
1197 DEBUG ((DEBUG_ERROR,
"EhcSyncInterruptTransfer: error - %r, transfer - %x\n", Status, *TransferResult));
1228 IN UINT8 DeviceAddress,
1229 IN UINT8 EndPointAddress,
1230 IN UINT8 DeviceSpeed,
1232 IN UINT8 DataBuffersNumber,
1233 IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
1236 OUT UINT32 *TransferResult
1239 return EFI_UNSUPPORTED;
1269 IN UINT8 DeviceAddress,
1270 IN UINT8 EndPointAddress,
1271 IN UINT8 DeviceSpeed,
1273 IN UINT8 DataBuffersNumber,
1274 IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
1281 return EFI_UNSUPPORTED;
1304 &gEhciDriverBinding,
1306 &gEhciComponentName,
1307 &gEhciComponentName2
1339 Status =
gBS->OpenProtocol (
1341 &gEfiPciIoProtocolGuid,
1343 This->DriverBindingHandle,
1345 EFI_OPEN_PROTOCOL_BY_DRIVER
1348 if (EFI_ERROR (Status)) {
1349 return EFI_UNSUPPORTED;
1352 Status = PciIo->Pci.
Read (
1355 PCI_CLASSCODE_OFFSET,
1360 if (EFI_ERROR (Status)) {
1361 Status = EFI_UNSUPPORTED;
1368 if ( (UsbClassCReg.BaseCode != PCI_CLASS_SERIAL) || (UsbClassCReg.SubClassCode != PCI_CLASS_SERIAL_USB)
1369 || ((UsbClassCReg.ProgInterface !=
PCI_IF_EHCI) && (UsbClassCReg.ProgInterface != PCI_IF_UHCI) && (UsbClassCReg.ProgInterface != PCI_IF_OHCI)))
1371 Status = EFI_UNSUPPORTED;
1375 gBS->CloseProtocol (
1377 &gEfiPciIoProtocolGuid,
1378 This->DriverBindingHandle,
1401 UINT8 CapabilityPtr;
1406 ASSERT (Ehc->PciIo !=
NULL);
1412 Status = PciIo->Pci.
Read (
1415 PCI_PRIMARY_STATUS_OFFSET,
1420 if (EFI_ERROR (Status)) {
1428 return EFI_UNSUPPORTED;
1434 Status = PciIo->Pci.
Read (
1437 PCI_CAPBILITY_POINTER_OFFSET,
1442 if (EFI_ERROR (Status)) {
1449 while (CapabilityPtr != 0) {
1450 Status = PciIo->Pci.
Read (
1458 if (EFI_ERROR (Status)) {
1462 if (CapabilityId == EHC_DEBUG_PORT_CAP_ID) {
1466 Status = PciIo->Pci.
Read (
1474 if (EFI_ERROR (Status)) {
1482 if (CapabilityPtr == 0) {
1483 return EFI_UNSUPPORTED;
1489 Status = PciIo->Pci.
Read (
1497 if (EFI_ERROR (Status)) {
1501 Ehc->DebugPortOffset = DebugPort & 0x1FFF;
1502 Ehc->DebugPortBarNum = (UINT8)((DebugPort >> 13) - 1);
1503 Ehc->DebugPortNum = (UINT8)((Ehc->HcStructParams & 0x00F00000) >> 20);
1523 IN UINT64 OriginalPciAttributes
1538 Ehc->Signature = USB2_HC_DEV_SIGNATURE;
1557 Ehc->DevicePath = DevicePath;
1558 Ehc->OriginalPciAttributes = OriginalPciAttributes;
1566 DEBUG ((DEBUG_INFO,
"EhcCreateUsb2Hc: capability length %d\n", Ehc->CapLen));
1571 if (Ehc->CapLen == 0) {
1572 gBS->FreePool (Ehc);
1581 Status =
gBS->CreateEvent (
1582 EVT_TIMER | EVT_NOTIFY_SIGNAL,
1589 if (EFI_ERROR (Status)) {
1590 gBS->FreePool (Ehc);
1648 UINT64 OriginalPciAttributes;
1649 BOOLEAN PciAttributesSaved;
1652 UINTN NumberOfHandles;
1654 UINTN CompanionSegmentNumber;
1655 UINTN CompanionBusNumber;
1656 UINTN CompanionDeviceNumber;
1657 UINTN CompanionFunctionNumber;
1658 UINTN EhciSegmentNumber;
1659 UINTN EhciBusNumber;
1660 UINTN EhciDeviceNumber;
1661 UINTN EhciFunctionNumber;
1667 Status =
gBS->OpenProtocol (
1669 &gEfiPciIoProtocolGuid,
1671 This->DriverBindingHandle,
1673 EFI_OPEN_PROTOCOL_BY_DRIVER
1676 if (EFI_ERROR (Status)) {
1683 HcDevicePath =
NULL;
1684 Status =
gBS->OpenProtocol (
1686 &gEfiDevicePathProtocolGuid,
1687 (VOID **)&HcDevicePath,
1688 This->DriverBindingHandle,
1690 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1693 PciAttributesSaved =
FALSE;
1697 Status = PciIo->Attributes (
1701 &OriginalPciAttributes
1704 if (EFI_ERROR (Status)) {
1708 PciAttributesSaved =
TRUE;
1710 Status = PciIo->Attributes (
1716 if (!EFI_ERROR (Status)) {
1717 Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;
1718 Status = PciIo->Attributes (
1726 if (EFI_ERROR (Status)) {
1727 DEBUG ((DEBUG_ERROR,
"EhcDriverBindingStart: failed to enable controller\n"));
1734 Status = PciIo->Pci.
Read (
1737 PCI_CLASSCODE_OFFSET,
1742 if (EFI_ERROR (Status)) {
1743 Status = EFI_UNSUPPORTED;
1752 if (((UsbClassCReg.ProgInterface == PCI_IF_UHCI) || (UsbClassCReg.ProgInterface == PCI_IF_OHCI)) &&
1753 (UsbClassCReg.BaseCode == PCI_CLASS_SERIAL) &&
1754 (UsbClassCReg.SubClassCode == PCI_CLASS_SERIAL_USB))
1756 Status = PciIo->GetLocation (
1758 &CompanionSegmentNumber,
1759 &CompanionBusNumber,
1760 &CompanionDeviceNumber,
1761 &CompanionFunctionNumber
1763 if (EFI_ERROR (Status)) {
1767 Status =
gBS->LocateHandleBuffer (
1769 &gEfiPciIoProtocolGuid,
1774 if (EFI_ERROR (Status)) {
1778 for (Index = 0; Index < NumberOfHandles; Index++) {
1782 Status =
gBS->HandleProtocol (
1783 HandleBuffer[Index],
1784 &gEfiPciIoProtocolGuid,
1789 Status = Instance->Pci.Read (
1792 PCI_CLASSCODE_OFFSET,
1797 if (EFI_ERROR (Status)) {
1798 Status = EFI_UNSUPPORTED;
1802 if ((UsbClassCReg.ProgInterface ==
PCI_IF_EHCI) &&
1803 (UsbClassCReg.BaseCode == PCI_CLASS_SERIAL) &&
1804 (UsbClassCReg.SubClassCode == PCI_CLASS_SERIAL_USB))
1806 Status = Instance->GetLocation (
1813 if (EFI_ERROR (Status)) {
1821 if (EhciBusNumber == CompanionBusNumber) {
1822 gBS->CloseProtocol (
1824 &gEfiPciIoProtocolGuid,
1825 This->DriverBindingHandle,
1833 Status = EFI_NOT_FOUND;
1843 DEBUG ((DEBUG_ERROR,
"EhcDriverBindingStart: failed to create USB2_HC\n"));
1845 Status = EFI_OUT_OF_RESOURCES;
1853 if (EHC_BIT_IS_SET (Ehc->HcCapParams, HCCP_64BIT)) {
1854 Status = PciIo->Attributes (
1860 if (!EFI_ERROR (Status)) {
1861 Ehc->Support64BitDma =
TRUE;
1865 "%a: failed to enable 64-bit DMA on 64-bit capable controller @ %p (%r)\n",
1873 Status =
gBS->InstallProtocolInterface (
1875 &gEfiUsb2HcProtocolGuid,
1880 if (EFI_ERROR (Status)) {
1881 DEBUG ((DEBUG_ERROR,
"EhcDriverBindingStart: failed to install USB2_HC Protocol\n"));
1899 if (EFI_ERROR (Status)) {
1900 DEBUG ((DEBUG_ERROR,
"EhcDriverBindingStart: failed to init host controller\n"));
1901 goto UNINSTALL_USBHC;
1907 Status =
gBS->SetTimer (Ehc->PollTimer,
TimerPeriodic, EHC_ASYNC_POLL_INTERVAL);
1909 if (EFI_ERROR (Status)) {
1910 DEBUG ((DEBUG_ERROR,
"EhcDriverBindingStart: failed to start async interrupt monitor\n"));
1913 goto UNINSTALL_USBHC;
1919 Status =
gBS->CreateEventEx (
1924 &gEfiEventExitBootServicesGuid,
1925 &Ehc->ExitBootServiceEvent
1927 if (EFI_ERROR (Status)) {
1928 goto UNINSTALL_USBHC;
1938 &Ehc->ControllerNameTable,
1939 L
"Enhanced Host Controller (USB 2.0)",
1945 &Ehc->ControllerNameTable,
1946 L
"Enhanced Host Controller (USB 2.0)",
1950 DEBUG ((DEBUG_INFO,
"EhcDriverBindingStart: EHCI started for controller @ %p\n", Controller));
1954 gBS->UninstallProtocolInterface (
1956 &gEfiUsb2HcProtocolGuid,
1962 gBS->CloseEvent (Ehc->PollTimer);
1963 gBS->FreePool (Ehc);
1966 if (PciAttributesSaved) {
1973 OriginalPciAttributes,
1978 gBS->CloseProtocol (
1980 &gEfiPciIoProtocolGuid,
1981 This->DriverBindingHandle,
2020 Status =
gBS->OpenProtocol (
2022 &gEfiUsb2HcProtocolGuid,
2024 This->DriverBindingHandle,
2026 EFI_OPEN_PROTOCOL_GET_PROTOCOL
2029 if (EFI_ERROR (Status)) {
2033 Ehc = EHC_FROM_THIS (Usb2Hc);
2036 Status =
gBS->UninstallProtocolInterface (
2038 &gEfiUsb2HcProtocolGuid,
2042 if (EFI_ERROR (Status)) {
2050 gBS->SetTimer (Ehc->PollTimer,
TimerCancel, EHC_ASYNC_POLL_INTERVAL);
2053 if (Ehc->PollTimer !=
NULL) {
2054 gBS->CloseEvent (Ehc->PollTimer);
2057 if (Ehc->ExitBootServiceEvent !=
NULL) {
2058 gBS->CloseEvent (Ehc->ExitBootServiceEvent);
2063 if (Ehc->ControllerNameTable !=
NULL) {
2079 Ehc->OriginalPciAttributes,
2083 gBS->CloseProtocol (
2085 &gEfiPciIoProtocolGuid,
2086 This->DriverBindingHandle,
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
EFI_STATUS EFIAPI EhcControlTransfer(IN EFI_USB2_HC_PROTOCOL *This, IN UINT8 DeviceAddress, IN UINT8 DeviceSpeed, IN UINTN MaximumPacketLength, IN EFI_USB_DEVICE_REQUEST *Request, IN EFI_USB_DATA_DIRECTION TransferDirection, IN OUT VOID *Data, IN OUT UINTN *DataLength, IN UINTN TimeOut, IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, OUT UINT32 *TransferResult)
EFI_STATUS EFIAPI EhcGetRootHubPortStatus(IN EFI_USB2_HC_PROTOCOL *This, IN UINT8 PortNumber, OUT EFI_USB_PORT_STATUS *PortStatus)
EFI_STATUS EFIAPI EhcReset(IN EFI_USB2_HC_PROTOCOL *This, IN UINT16 Attributes)
VOID EFIAPI EhcExitBootService(EFI_EVENT Event, VOID *Context)
EFI_STATUS EFIAPI EhcGetState(IN EFI_USB2_HC_PROTOCOL *This, OUT EFI_USB_HC_STATE *State)
EFI_STATUS EFIAPI EhcBulkTransfer(IN EFI_USB2_HC_PROTOCOL *This, IN UINT8 DeviceAddress, IN UINT8 EndPointAddress, IN UINT8 DeviceSpeed, IN UINTN MaximumPacketLength, IN UINT8 DataBuffersNumber, IN OUT VOID *Data[EFI_USB_MAX_BULK_BUFFER_NUM], IN OUT UINTN *DataLength, IN OUT UINT8 *DataToggle, IN UINTN TimeOut, IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, OUT UINT32 *TransferResult)
EFI_STATUS EFIAPI EhcSyncInterruptTransfer(IN EFI_USB2_HC_PROTOCOL *This, IN UINT8 DeviceAddress, IN UINT8 EndPointAddress, IN UINT8 DeviceSpeed, IN UINTN MaximumPacketLength, IN OUT VOID *Data, IN OUT UINTN *DataLength, IN OUT UINT8 *DataToggle, IN UINTN TimeOut, IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, OUT UINT32 *TransferResult)
EFI_STATUS EFIAPI EhcDriverBindingSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_STATUS EFIAPI EhcDriverEntryPoint(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
USB2_HC_DEV * EhcCreateUsb2Hc(IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN UINT64 OriginalPciAttributes)
EFI_STATUS EFIAPI EhcDriverBindingStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
EFI_STATUS EFIAPI EhcSetState(IN EFI_USB2_HC_PROTOCOL *This, IN EFI_USB_HC_STATE State)
EFI_STATUS EhcGetUsbDebugPortInfo(IN USB2_HC_DEV *Ehc)
EFI_STATUS EFIAPI EhcIsochronousTransfer(IN EFI_USB2_HC_PROTOCOL *This, IN UINT8 DeviceAddress, IN UINT8 EndPointAddress, IN UINT8 DeviceSpeed, IN UINTN MaximumPacketLength, IN UINT8 DataBuffersNumber, IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM], IN UINTN DataLength, IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, OUT UINT32 *TransferResult)
EFI_STATUS EFIAPI EhcGetCapability(IN EFI_USB2_HC_PROTOCOL *This, OUT UINT8 *MaxSpeed, OUT UINT8 *PortNumber, OUT UINT8 *Is64BitCapable)
EFI_STATUS EFIAPI EhcDriverBindingStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
EFI_STATUS EFIAPI EhcAsyncIsochronousTransfer(IN EFI_USB2_HC_PROTOCOL *This, IN UINT8 DeviceAddress, IN UINT8 EndPointAddress, IN UINT8 DeviceSpeed, IN UINTN MaximumPacketLength, IN UINT8 DataBuffersNumber, IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM], IN UINTN DataLength, IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack, IN VOID *Context)
EFI_STATUS EFIAPI EhcAsyncInterruptTransfer(IN EFI_USB2_HC_PROTOCOL *This, IN UINT8 DeviceAddress, IN UINT8 EndPointAddress, IN UINT8 DeviceSpeed, IN UINTN MaximumPacketLength, IN BOOLEAN IsNewTransfer, IN OUT UINT8 *DataToggle, IN UINTN PollingInterval, IN UINTN DataLength, IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, IN EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunction, IN VOID *Context OPTIONAL)
EFI_STATUS EFIAPI EhcSetRootHubPortFeature(IN EFI_USB2_HC_PROTOCOL *This, IN UINT8 PortNumber, IN EFI_USB_PORT_FEATURE PortFeature)
EFI_STATUS EFIAPI EhcClearRootHubPortFeature(IN EFI_USB2_HC_PROTOCOL *This, IN UINT8 PortNumber, IN EFI_USB_PORT_FEATURE PortFeature)
URB * EhciInsertAsyncIntTransfer(IN USB2_HC_DEV *Ehc, IN UINT8 DevAddr, IN UINT8 EpAddr, IN UINT8 DevSpeed, IN UINT8 Toggle, IN UINTN MaxPacket, IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Hub, IN UINTN DataLen, IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback, IN VOID *Context, IN UINTN Interval)
EFI_STATUS EhciDelAsyncIntTransfer(IN USB2_HC_DEV *Ehc, IN UINT8 DevAddr, IN UINT8 EpNum, OUT UINT8 *DataToggle)
VOID EhcLinkQhToAsync(IN USB2_HC_DEV *Ehc, IN EHC_QH *Qh)
VOID EhcFreeSched(IN USB2_HC_DEV *Ehc)
VOID EFIAPI EhcMonitorAsyncRequests(IN EFI_EVENT Event, IN VOID *Context)
EFI_STATUS EhcExecTransfer(IN USB2_HC_DEV *Ehc, IN URB *Urb, IN UINTN TimeOut)
VOID EhcUnlinkQhFromPeriod(IN USB2_HC_DEV *Ehc, IN EHC_QH *Qh)
VOID EhciDelAllAsyncIntTransfers(IN USB2_HC_DEV *Ehc)
VOID EhcLinkQhToPeriod(IN USB2_HC_DEV *Ehc, IN EHC_QH *Qh)
VOID EhcUnlinkQhFromAsync(IN USB2_HC_DEV *Ehc, IN EHC_QH *Qh)
URB * EhcCreateUrb(IN USB2_HC_DEV *Ehc, IN UINT8 DevAddr, IN UINT8 EpAddr, IN UINT8 DevSpeed, IN UINT8 Toggle, IN UINTN MaxPacket, IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Hub, IN UINTN Type, IN EFI_USB_DEVICE_REQUEST *Request, IN VOID *Data, IN UINTN DataLen, IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback, IN VOID *Context, IN UINTN Interval)
VOID EhcFreeUrb(IN USB2_HC_DEV *Ehc, IN URB *Urb)
VOID EhcClearOpRegBit(IN USB2_HC_DEV *Ehc, IN UINT32 Offset, IN UINT32 Bit)
EFI_STATUS EhcResetHC(IN USB2_HC_DEV *Ehc, IN UINT32 Timeout)
VOID EhcWriteOpReg(IN USB2_HC_DEV *Ehc, IN UINT32 Offset, IN UINT32 Data)
EFI_STATUS EhcInitHC(IN USB2_HC_DEV *Ehc)
BOOLEAN EhcIsHalt(IN USB2_HC_DEV *Ehc)
EFI_STATUS EhcHaltHC(IN USB2_HC_DEV *Ehc, IN UINT32 Timeout)
VOID EhcClearLegacySupport(IN USB2_HC_DEV *Ehc)
UINT32 EhcReadCapRegister(IN USB2_HC_DEV *Ehc, IN UINT32 Offset)
BOOLEAN EhcIsSysError(IN USB2_HC_DEV *Ehc)
EFI_STATUS EhcRunHC(IN USB2_HC_DEV *Ehc, IN UINT32 Timeout)
UINT32 EhcReadOpReg(IN USB2_HC_DEV *Ehc, IN UINT32 Offset)
VOID EhcAckAllInterrupt(IN USB2_HC_DEV *Ehc)
BOOLEAN EhcIsDebugPortInUse(IN CONST USB2_HC_DEV *Ehc, IN CONST UINT8 *PortNumber OPTIONAL)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define REPORT_STATUS_CODE_WITH_DEVICE_PATH(Type, Value, DevicePathParameter)
#define EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE
Clear for PCI controllers that can not genrate a DAC.
@ EfiPciIoAttributeOperationGet
@ EfiPciIoAttributeOperationEnable
@ EfiPciIoAttributeOperationSet
@ EfiPciIoAttributeOperationSupported
#define USB_PORT_STAT_C_CONNECTION
@ EfiUsbHcStateOperational
#define USB_PORT_STAT_CONNECTION
EFI_STATUS(EFIAPI * EFI_ASYNC_USB_TRANSFER_CALLBACK)(IN VOID *Data, IN UINTN DataLength, IN VOID *Context, IN UINT32 Status)
#define FeaturePcdGet(TokenName)
#define EFI_PCI_STATUS_CAPABILITY
0x0010
#define EFI_PROGRESS_CODE
EFI_STATUS EFIAPI AddUnicodeString2(IN CONST CHAR8 *Language, IN CONST CHAR8 *SupportedLanguages, IN OUT EFI_UNICODE_STRING_TABLE **UnicodeStringTable, IN CONST CHAR16 *UnicodeString, IN BOOLEAN Iso639Language)
EFI_STATUS EFIAPI EfiLibInstallDriverBindingComponentName2(IN CONST EFI_HANDLE ImageHandle, IN CONST EFI_SYSTEM_TABLE *SystemTable, IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding, IN EFI_HANDLE DriverBindingHandle, IN CONST EFI_COMPONENT_NAME_PROTOCOL *ComponentName OPTIONAL, IN CONST EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2 OPTIONAL)
EFI_STATUS EFIAPI FreeUnicodeStringTable(IN EFI_UNICODE_STRING_TABLE *UnicodeStringTable)
CHAR8 * SupportedLanguages
CHAR8 * SupportedLanguages
EFI_PCI_IO_PROTOCOL_CONFIG Read