19 { PORTSC_ENABLED, USB_PORT_STAT_ENABLE },
20 { PORTSC_SUSPEND, USB_PORT_STAT_SUSPEND },
21 { PORTSC_OVERCUR, USB_PORT_STAT_OVERCURRENT },
22 { PORTSC_RESET, USB_PORT_STAT_RESET },
23 { PORTSC_POWER, USB_PORT_STAT_POWER },
24 { PORTSC_OWNER, USB_PORT_STAT_OWNER }
29 { PORTSC_ENABLE_CHANGE, USB_PORT_STAT_C_ENABLE },
30 { PORTSC_OVERCUR_CHANGE, USB_PORT_STAT_C_OVERCURRENT }
50 ASSERT (Ehc->CapLen != 0);
52 Data =
MmioRead32 (Ehc->UsbHostControllerBaseAddress + Ehc->CapLen + Offset);
72 ASSERT (Ehc->CapLen != 0);
74 MmioWrite32 (Ehc->UsbHostControllerBaseAddress + Ehc->CapLen + Offset, Data);
140 IN BOOLEAN WaitToSet,
146 for (Index = 0; Index < Timeout / EHC_SYNC_POLL_INTERVAL + 1; Index++) {
147 if (EHC_REG_BIT_IS_SET (Ehc, Offset, Bit) == WaitToSet) {
174 Data =
MmioRead32 (Ehc->UsbHostControllerBaseAddress + Offset);
208 Data &= ~USBSTS_INTACK_MASK;
294 return EHC_REG_BIT_IS_SET (Ehc, EHC_USBSTS_OFFSET, USBSTS_HALT);
311 return EHC_REG_BIT_IS_SET (Ehc, EHC_USBSTS_OFFSET, USBSTS_SYS_ERROR);
335 if (!EHC_REG_BIT_IS_SET (Ehc, EHC_USBSTS_OFFSET, USBSTS_HALT)) {
338 if (EFI_ERROR (Status)) {
409 PortNumber = (UINT8)(Ehc->HcStructParams & HCSP_NPORTS);
410 for (Index = 0; Index < PortNumber; Index++) {
415 RegVal =
EhcReadOpReg (Ehc, EHC_PORT_STAT_OFFSET + 4 * Index);
416 RegVal &= ~PORTSC_CHANGE_MASK;
417 RegVal |= PORTSC_POWER;
418 EhcWriteOpReg (Ehc, EHC_PORT_STAT_OFFSET + 4 * Index, RegVal);
452 if (Ehc->PeriodFrame !=
NULL) {
456 PageNumber =
sizeof (
PEI_URB)/PAGESIZE +1;
463 if (Ehc->Urb ==
NULL) {
472 if (EFI_ERROR (Status)) {
479 EhcWriteOpReg (Ehc, EHC_CTRLDSSEG_OFFSET, Ehc->High32bitAddr);
495 EhcSetOpRegBit (Ehc, EHC_CONFIG_FLAG_OFFSET, CONFIGFLAG_ROUTE_EHC);
504 if (EFI_ERROR (Status)) {
510 if (EFI_ERROR (Status)) {
554 IN UINT8 DeviceAddress,
555 IN UINT8 EndPointAddress,
556 IN UINT8 DeviceSpeed,
558 IN OUT VOID *Data[EFI_USB_MAX_BULK_BUFFER_NUM],
560 IN OUT UINT8 *DataToggle,
563 OUT UINT32 *TransferResult
573 if ((DataLength ==
NULL) || (*DataLength == 0) ||
574 (Data ==
NULL) || (Data[0] ==
NULL) || (TransferResult ==
NULL))
576 return EFI_INVALID_PARAMETER;
579 if ((*DataToggle != 0) && (*DataToggle != 1)) {
580 return EFI_INVALID_PARAMETER;
583 if ((DeviceSpeed == EFI_USB_SPEED_LOW) ||
584 ((DeviceSpeed == EFI_USB_SPEED_FULL) && (MaximumPacketLength > 64)) ||
585 ((EFI_USB_SPEED_HIGH == DeviceSpeed) && (MaximumPacketLength > 512)))
587 return EFI_INVALID_PARAMETER;
590 Ehc = PEI_RECOVERY_USB_EHC_DEV_FROM_EHCI_THIS (This);
591 *TransferResult = EFI_USB_ERR_SYSTEM;
592 Status = EFI_DEVICE_ERROR;
623 Status = EFI_OUT_OF_RESOURCES;
631 *TransferResult = Urb->Result;
632 *DataLength = Urb->Completed;
633 *DataToggle = Urb->DataToggle;
635 if (*TransferResult == EFI_USB_NOERROR) {
663 OUT UINT8 *PortNumber
668 EhcDev = PEI_RECOVERY_USB_EHC_DEV_FROM_EHCI_THIS (This);
670 if (PortNumber ==
NULL) {
671 return EFI_INVALID_PARAMETER;
674 *PortNumber = (UINT8)(EhcDev->HcStructParams & HCSP_NPORTS);
708 Ehc = PEI_RECOVERY_USB_EHC_DEV_FROM_EHCI_THIS (This);
711 TotalPort = (Ehc->HcStructParams & HCSP_NPORTS);
713 if (PortNumber >= TotalPort) {
714 Status = EFI_INVALID_PARAMETER;
718 Offset = EHC_PORT_STAT_OFFSET + (4 * PortNumber);
720 State &= ~PORTSC_CHANGE_MASK;
722 switch (PortFeature) {
723 case EfiUsbPortEnable:
727 State &= ~PORTSC_ENABLED;
731 case EfiUsbPortSuspend:
739 State &= ~PORSTSC_RESUME;
743 case EfiUsbPortReset:
747 State &= ~PORTSC_RESET;
751 case EfiUsbPortOwner:
755 State &= ~PORTSC_OWNER;
759 case EfiUsbPortConnectChange:
763 State |= PORTSC_CONN_CHANGE;
767 case EfiUsbPortEnableChange:
771 State |= PORTSC_ENABLE_CHANGE;
775 case EfiUsbPortOverCurrentChange:
779 State |= PORTSC_OVERCUR_CHANGE;
783 case EfiUsbPortPower:
784 case EfiUsbPortSuspendChange:
785 case EfiUsbPortResetChange:
792 Status = EFI_INVALID_PARAMETER;
828 Ehc = PEI_RECOVERY_USB_EHC_DEV_FROM_EHCI_THIS (This);
831 TotalPort = (Ehc->HcStructParams & HCSP_NPORTS);
833 if (PortNumber >= TotalPort) {
834 Status = EFI_INVALID_PARAMETER;
838 Offset = (UINT32)(EHC_PORT_STAT_OFFSET + (4 * PortNumber));
845 State &= ~PORTSC_CHANGE_MASK;
847 switch (PortFeature) {
848 case EfiUsbPortEnable:
853 State |= PORTSC_ENABLED;
857 case EfiUsbPortSuspend:
858 State |= PORTSC_SUSPEND;
862 case EfiUsbPortReset:
867 Status =
EhcRunHC (Ehc, EHC_GENERIC_TIMEOUT);
869 if (EFI_ERROR (Status)) {
877 State |= PORTSC_RESET;
878 State &= ~PORTSC_ENABLED;
882 case EfiUsbPortPower:
889 case EfiUsbPortOwner:
890 State |= PORTSC_OWNER;
895 Status = EFI_INVALID_PARAMETER;
932 if (PortStatus ==
NULL) {
933 return EFI_INVALID_PARAMETER;
936 Ehc = PEI_RECOVERY_USB_EHC_DEV_FROM_EHCI_THIS (This);
939 TotalPort = (Ehc->HcStructParams & HCSP_NPORTS);
941 if (PortNumber >= TotalPort) {
942 Status = EFI_INVALID_PARAMETER;
946 Offset = (UINT32)(EHC_PORT_STAT_OFFSET + (4 * PortNumber));
947 PortStatus->PortStatus = 0;
948 PortStatus->PortChangeStatus = 0;
958 if (EHC_BIT_IS_SET (State, PORTSC_LINESTATE_K)) {
959 PortStatus->PortStatus |= USB_PORT_STAT_LOW_SPEED;
960 }
else if (EHC_BIT_IS_SET (State, PORTSC_ENABLED)) {
961 PortStatus->PortStatus |= USB_PORT_STAT_HIGH_SPEED;
969 for (Index = 0; Index < MapSize; Index++) {
970 if (EHC_BIT_IS_SET (State, mUsbPortStateMap[Index].HwState)) {
971 PortStatus->PortStatus = (UINT16)(PortStatus->PortStatus | mUsbPortStateMap[Index].UefiState);
977 for (Index = 0; Index < MapSize; Index++) {
978 if (EHC_BIT_IS_SET (State, mUsbPortChangeMap[Index].HwState)) {
979 PortStatus->PortChangeStatus = (UINT16)(PortStatus->PortChangeStatus | mUsbPortChangeMap[Index].UefiState);
1018 IN UINT8 DeviceAddress,
1019 IN UINT8 DeviceSpeed,
1027 OUT UINT32 *TransferResult
1038 if ((Request ==
NULL) || (TransferResult ==
NULL)) {
1039 return EFI_INVALID_PARAMETER;
1042 if ((TransferDirection != EfiUsbDataIn) &&
1043 (TransferDirection != EfiUsbDataOut) &&
1044 (TransferDirection != EfiUsbNoData))
1046 return EFI_INVALID_PARAMETER;
1049 if ((TransferDirection == EfiUsbNoData) &&
1050 ((Data !=
NULL) || (*DataLength != 0)))
1052 return EFI_INVALID_PARAMETER;
1055 if ((TransferDirection != EfiUsbNoData) &&
1056 ((Data ==
NULL) || (*DataLength == 0)))
1058 return EFI_INVALID_PARAMETER;
1061 if ((MaximumPacketLength != 8) && (MaximumPacketLength != 16) &&
1062 (MaximumPacketLength != 32) && (MaximumPacketLength != 64))
1064 return EFI_INVALID_PARAMETER;
1067 if ((DeviceSpeed == EFI_USB_SPEED_LOW) ||
1068 ((DeviceSpeed == EFI_USB_SPEED_FULL) && (MaximumPacketLength > 64)) ||
1069 ((EFI_USB_SPEED_HIGH == DeviceSpeed) && (MaximumPacketLength > 512)))
1071 return EFI_INVALID_PARAMETER;
1074 Ehc = PEI_RECOVERY_USB_EHC_DEV_FROM_EHCI_THIS (This);
1076 Status = EFI_DEVICE_ERROR;
1077 *TransferResult = EFI_USB_ERR_SYSTEM;
1095 Endpoint = (UINT8)(0 | ((TransferDirection == EfiUsbDataIn) ? 0x80 : 0));
1102 MaximumPacketLength,
1114 Status = EFI_OUT_OF_RESOURCES;
1126 *TransferResult = Urb->Result;
1127 *DataLength = Urb->Completed;
1129 if (*TransferResult == EFI_USB_NOERROR) {
1161 Ehc = PEI_RECOVERY_USB_EHC_DEV_FROM_THIS_NOTIFY (NotifyDescriptor);
1187 UINTN ControllerType;
1201 &gPeiUsbControllerPpiGuid,
1204 (VOID **)&ChipSetUsbControllerPpi
1206 if (EFI_ERROR (Status)) {
1207 return EFI_UNSUPPORTED;
1212 Status = ChipSetUsbControllerPpi->GetUsbController (
1214 ChipSetUsbControllerPpi,
1222 if (EFI_ERROR (Status)) {
1240 if (EFI_ERROR (Status)) {
1241 return EFI_OUT_OF_RESOURCES;
1247 EhcDev->Signature = USB2_HC_DEV_SIGNATURE;
1251 EhcDev->UsbHostControllerBaseAddress = (UINT32)BaseAddress;
1260 if (EFI_ERROR (Status)) {
1271 EhcDev->PpiDescriptor.
Flags = (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST);
1272 EhcDev->PpiDescriptor.
Guid = &gPeiUsb2HostControllerPpiGuid;
1273 EhcDev->PpiDescriptor.
Ppi = &EhcDev->Usb2HostControllerPpi;
1276 if (EFI_ERROR (Status)) {
1281 EhcDev->EndOfPeiNotifyList.
Flags = (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST);
1282 EhcDev->EndOfPeiNotifyList.
Guid = &gEfiEndOfPeiSignalPpiGuid;
1311 if (EFI_ERROR (Status)) {
UINTN EFIAPI MicroSecondDelay(IN UINTN MicroSeconds)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
BOOLEAN EhcIsHalt(IN PEI_USB2_HC_DEV *Ehc)
EFI_STATUS InitializeUsbHC(IN PEI_USB2_HC_DEV *EhcDev)
EFI_STATUS EhcHaltHC(IN PEI_USB2_HC_DEV *Ehc, IN UINT32 Timeout)
EFI_STATUS EhcResetHC(IN PEI_USB2_HC_DEV *Ehc, IN UINT32 Timeout)
EFI_STATUS EFIAPI EhcGetRootHubPortStatus(IN EFI_PEI_SERVICES **PeiServices, IN PEI_USB2_HOST_CONTROLLER_PPI *This, IN UINT8 PortNumber, OUT EFI_USB_PORT_STATUS *PortStatus)
BOOLEAN EhcIsSysError(IN PEI_USB2_HC_DEV *Ehc)
EFI_STATUS EFIAPI EhcClearRootHubPortFeature(IN EFI_PEI_SERVICES **PeiServices, IN PEI_USB2_HOST_CONTROLLER_PPI *This, IN UINT8 PortNumber, IN EFI_USB_PORT_FEATURE PortFeature)
EFI_STATUS EhcEnablePeriodSchd(IN PEI_USB2_HC_DEV *Ehc, IN UINT32 Timeout)
EFI_STATUS EhcWaitOpRegBit(IN PEI_USB2_HC_DEV *Ehc, IN UINT32 Offset, IN UINT32 Bit, IN BOOLEAN WaitToSet, IN UINT32 Timeout)
VOID EhcAckAllInterrupt(IN PEI_USB2_HC_DEV *Ehc)
VOID EhcSetOpRegBit(IN PEI_USB2_HC_DEV *Ehc, IN UINT32 Offset, IN UINT32 Bit)
UINT32 EhcReadCapRegister(IN PEI_USB2_HC_DEV *Ehc, IN UINT32 Offset)
VOID EhcClearOpRegBit(IN PEI_USB2_HC_DEV *Ehc, IN UINT32 Offset, IN UINT32 Bit)
VOID EhcWriteOpReg(IN PEI_USB2_HC_DEV *Ehc, IN UINT32 Offset, IN UINT32 Data)
VOID EhcPowerOnAllPorts(IN PEI_USB2_HC_DEV *Ehc)
EFI_STATUS EhcSetAndWaitDoorBell(IN PEI_USB2_HC_DEV *Ehc, IN UINT32 Timeout)
EFI_STATUS EhcRunHC(IN PEI_USB2_HC_DEV *Ehc, IN UINT32 Timeout)
EFI_STATUS EhcInitHC(IN PEI_USB2_HC_DEV *Ehc)
EFI_STATUS EFIAPI EhcEndOfPei(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
EFI_STATUS EhcEnableAsyncSchd(IN PEI_USB2_HC_DEV *Ehc, IN UINT32 Timeout)
UINT32 EhcReadOpReg(IN PEI_USB2_HC_DEV *Ehc, IN UINT32 Offset)
EFI_STATUS EFIAPI EhcControlTransfer(IN EFI_PEI_SERVICES **PeiServices, IN PEI_USB2_HOST_CONTROLLER_PPI *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 EhcPeimEntry(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
EFI_STATUS EFIAPI EhcGetRootHubPortNumber(IN EFI_PEI_SERVICES **PeiServices, IN PEI_USB2_HOST_CONTROLLER_PPI *This, OUT UINT8 *PortNumber)
EFI_STATUS EFIAPI EhcBulkTransfer(IN EFI_PEI_SERVICES **PeiServices, IN PEI_USB2_HOST_CONTROLLER_PPI *This, IN UINT8 DeviceAddress, IN UINT8 EndPointAddress, IN UINT8 DeviceSpeed, IN UINTN MaximumPacketLength, 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 EhcSetRootHubPortFeature(IN EFI_PEI_SERVICES **PeiServices, IN PEI_USB2_HOST_CONTROLLER_PPI *This, IN UINT8 PortNumber, IN EFI_USB_PORT_FEATURE PortFeature)
EFI_STATUS EhcInitSched(IN USB2_HC_DEV *Ehc)
VOID EhcLinkQhToAsync(IN USB2_HC_DEV *Ehc, IN EHC_QH *Qh)
VOID EhcFreeSched(IN USB2_HC_DEV *Ehc)
EFI_STATUS EhcExecTransfer(IN USB2_HC_DEV *Ehc, IN URB *Urb, IN UINTN TimeOut)
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)
EFI_STATUS EFIAPI PeiServicesLocatePpi(IN CONST EFI_GUID *Guid, IN UINTN Instance, IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, IN OUT VOID **Ppi)
EFI_STATUS EFIAPI PeiServicesNotifyPpi(IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList)
EFI_STATUS EFIAPI PeiServicesAllocatePages(IN EFI_MEMORY_TYPE MemoryType, IN UINTN Pages, OUT EFI_PHYSICAL_ADDRESS *Memory)
EFI_STATUS EFIAPI PeiServicesInstallPpi(IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList)
EFI_STATUS EFIAPI PeiServicesRegisterForShadow(IN EFI_PEI_FILE_HANDLE FileHandle)
UINT32 EFIAPI MmioRead32(IN UINTN Address)
UINT32 EFIAPI MmioWrite32(IN UINTN Address, IN UINT32 Value)
#define USB_PORT_STAT_C_CONNECTION
#define USB_PORT_STAT_CONNECTION
VOID IoMmuInit(OUT EDKII_IOMMU_PPI **IoMmu)
VOID * EFI_PEI_FILE_HANDLE
UINT64 EFI_PHYSICAL_ADDRESS
#define PEI_EHCI_CONTROLLER
EFI_PEIM_NOTIFY_ENTRY_POINT Notify