TianoCore EDK2 master
Loading...
Searching...
No Matches
EhcPeim.c File Reference
#include "EhcPeim.h"

Go to the source code of this file.

Functions

UINT32 EhcReadOpReg (IN PEI_USB2_HC_DEV *Ehc, IN UINT32 Offset)
 
VOID EhcWriteOpReg (IN PEI_USB2_HC_DEV *Ehc, IN UINT32 Offset, IN UINT32 Data)
 
VOID EhcSetOpRegBit (IN PEI_USB2_HC_DEV *Ehc, IN UINT32 Offset, IN UINT32 Bit)
 
VOID EhcClearOpRegBit (IN PEI_USB2_HC_DEV *Ehc, IN UINT32 Offset, IN UINT32 Bit)
 
EFI_STATUS EhcWaitOpRegBit (IN PEI_USB2_HC_DEV *Ehc, IN UINT32 Offset, IN UINT32 Bit, IN BOOLEAN WaitToSet, IN UINT32 Timeout)
 
UINT32 EhcReadCapRegister (IN PEI_USB2_HC_DEV *Ehc, IN UINT32 Offset)
 
EFI_STATUS EhcSetAndWaitDoorBell (IN PEI_USB2_HC_DEV *Ehc, IN UINT32 Timeout)
 
VOID EhcAckAllInterrupt (IN PEI_USB2_HC_DEV *Ehc)
 
EFI_STATUS EhcEnablePeriodSchd (IN PEI_USB2_HC_DEV *Ehc, IN UINT32 Timeout)
 
EFI_STATUS EhcEnableAsyncSchd (IN PEI_USB2_HC_DEV *Ehc, IN UINT32 Timeout)
 
BOOLEAN EhcIsHalt (IN PEI_USB2_HC_DEV *Ehc)
 
BOOLEAN EhcIsSysError (IN PEI_USB2_HC_DEV *Ehc)
 
EFI_STATUS EhcResetHC (IN PEI_USB2_HC_DEV *Ehc, IN UINT32 Timeout)
 
EFI_STATUS EhcHaltHC (IN PEI_USB2_HC_DEV *Ehc, IN UINT32 Timeout)
 
EFI_STATUS EhcRunHC (IN PEI_USB2_HC_DEV *Ehc, IN UINT32 Timeout)
 
VOID EhcPowerOnAllPorts (IN PEI_USB2_HC_DEV *Ehc)
 
EFI_STATUS EhcInitHC (IN PEI_USB2_HC_DEV *Ehc)
 
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 EhcGetRootHubPortNumber (IN EFI_PEI_SERVICES **PeiServices, IN PEI_USB2_HOST_CONTROLLER_PPI *This, OUT UINT8 *PortNumber)
 
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 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 EFIAPI EhcGetRootHubPortStatus (IN EFI_PEI_SERVICES **PeiServices, IN PEI_USB2_HOST_CONTROLLER_PPI *This, IN UINT8 PortNumber, OUT EFI_USB_PORT_STATUS *PortStatus)
 
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 EhcEndOfPei (IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
 
EFI_STATUS EFIAPI EhcPeimEntry (IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
 
EFI_STATUS InitializeUsbHC (IN PEI_USB2_HC_DEV *EhcDev)
 

Variables

USB_PORT_STATE_MAP mUsbPortStateMap []
 
USB_PORT_STATE_MAP mUsbPortChangeMap []
 

Detailed Description

PEIM to produce gPeiUsb2HostControllerPpiGuid based on gPeiUsbControllerPpiGuid which is used to enable recovery function from USB Drivers.

Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file EhcPeim.c.

Function Documentation

◆ EhcAckAllInterrupt()

VOID EhcAckAllInterrupt ( IN PEI_USB2_HC_DEV Ehc)

Clear all the interrutp status bits, these bits are Write-Clean.

Parameters
EhcThe EHCI device.

Definition at line 224 of file EhcPeim.c.

◆ EhcBulkTransfer()

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 
)

Submits bulk transfer to a bulk endpoint of a USB device.

Parameters
PeiServicesThe pointer of EFI_PEI_SERVICES.
ThisThe pointer of PEI_USB2_HOST_CONTROLLER_PPI.
DeviceAddressTarget device address.
EndPointAddressEndpoint number and its direction in bit 7.
DeviceSpeedDevice speed, Low speed device doesn't support bulk transfer.
MaximumPacketLengthMaximum packet size the endpoint is capable of sending or receiving.
DataArray of pointers to the buffers of data to transmit from or receive into.
DataLengthThe lenght of the data buffer.
DataToggleOn input, the initial data toggle for the transfer; On output, it is updated to to next data toggle to use of the subsequent bulk transfer.
TimeOutIndicates the maximum time, in millisecond, which the transfer is allowed to complete. If Timeout is 0, then the caller must wait for the function to be completed until EFI_SUCCESS or EFI_DEVICE_ERROR is returned.
TranslatorA pointr to the transaction translator data.
TransferResultA pointer to the detailed result information of the bulk transfer.
Return values
EFI_SUCCESSThe transfer was completed successfully.
EFI_OUT_OF_RESOURCESThe transfer failed due to lack of resource.
EFI_INVALID_PARAMETERParameters are invalid.
EFI_TIMEOUTThe transfer failed due to timeout.
EFI_DEVICE_ERRORThe transfer failed due to host controller error.

Definition at line 551 of file EhcPeim.c.

◆ EhcClearOpRegBit()

VOID EhcClearOpRegBit ( IN PEI_USB2_HC_DEV Ehc,
IN UINT32  Offset,
IN UINT32  Bit 
)

Clear one bit of the operational register while keeping other bits.

Parameters
EhcThe EHCI device.
OffsetThe offset of the operational register.
BitThe bit mask of the register to clear.

Definition at line 108 of file EhcPeim.c.

◆ EhcClearRootHubPortFeature()

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 
)

Clears a feature for the specified root hub port.

Parameters
PeiServicesThe pointer of EFI_PEI_SERVICES.
ThisThe pointer of PEI_USB2_HOST_CONTROLLER_PPI.
PortNumberSpecifies the root hub port whose feature is requested to be cleared.
PortFeatureIndicates the feature selector associated with the feature clear request.
Return values
EFI_SUCCESSThe feature specified by PortFeature was cleared for the USB root hub port specified by PortNumber.
EFI_INVALID_PARAMETERPortNumber is invalid or PortFeature is invalid.

Definition at line 695 of file EhcPeim.c.

◆ EhcControlTransfer()

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 
)

Submits control transfer to a target USB device.

Parameters
PeiServicesThe pointer of EFI_PEI_SERVICES.
ThisThe pointer of PEI_USB2_HOST_CONTROLLER_PPI.
DeviceAddressThe target device address.
DeviceSpeedTarget device speed.
MaximumPacketLengthMaximum packet size the default control transfer endpoint is capable of sending or receiving.
RequestUSB device request to send.
TransferDirectionSpecifies the data direction for the data stage.
DataData buffer to be transmitted or received from USB device.
DataLengthThe size (in bytes) of the data buffer.
TimeOutIndicates the maximum timeout, in millisecond. If Timeout is 0, then the caller must wait for the function to be completed until EFI_SUCCESS or EFI_DEVICE_ERROR is returned.
TranslatorTransaction translator to be used by this device.
TransferResultReturn the result of this control transfer.
Return values
EFI_SUCCESSTransfer was completed successfully.
EFI_OUT_OF_RESOURCESThe transfer failed due to lack of resources.
EFI_INVALID_PARAMETERSome parameters are invalid.
EFI_TIMEOUTTransfer failed due to timeout.
EFI_DEVICE_ERRORTransfer failed due to host controller or device error.

Definition at line 1015 of file EhcPeim.c.

◆ EhcEnableAsyncSchd()

EFI_STATUS EhcEnableAsyncSchd ( IN PEI_USB2_HC_DEV Ehc,
IN UINT32  Timeout 
)

Enable asynchrounous schedule.

Parameters
EhcThe EHCI device.
TimeoutTime to wait before abort.
Return values
EFI_SUCCESSThe EHCI asynchronous schedule is enabled.
OthersFailed to enable the asynchronous scheudle.

Definition at line 267 of file EhcPeim.c.

◆ EhcEnablePeriodSchd()

EFI_STATUS EhcEnablePeriodSchd ( IN PEI_USB2_HC_DEV Ehc,
IN UINT32  Timeout 
)

Enable the periodic schedule then wait EHC to actually enable it.

Parameters
EhcThe EHCI device.
TimeoutThe time to wait before abort (in millisecond, ms).
Return values
EFI_TIMEOUTTime out happened while enabling periodic schedule.
EFI_SUCCESSThe periodical schedule is enabled.

Definition at line 243 of file EhcPeim.c.

◆ EhcEndOfPei()

EFI_STATUS EFIAPI EhcEndOfPei ( IN EFI_PEI_SERVICES **  PeiServices,
IN EFI_PEI_NOTIFY_DESCRIPTOR NotifyDescriptor,
IN VOID *  Ppi 
)

One notified function to stop the Host Controller at the end of PEI

Parameters
[in]PeiServicesPointer to PEI Services Table.
[in]NotifyDescriptorPointer to the descriptor for the Notification event that caused this function to execute.
[in]PpiPointer to the PPI data associated with this function.
Return values
EFI_SUCCESSThe function completes successfully
others

Definition at line 1153 of file EhcPeim.c.

◆ EhcGetRootHubPortNumber()

EFI_STATUS EFIAPI EhcGetRootHubPortNumber ( IN EFI_PEI_SERVICES **  PeiServices,
IN PEI_USB2_HOST_CONTROLLER_PPI This,
OUT UINT8 *  PortNumber 
)

Retrieves the number of root hub ports.

Parameters
[in]PeiServicesThe pointer to the PEI Services Table.
[in]ThisThe pointer to this instance of the PEI_USB2_HOST_CONTROLLER_PPI.
[out]PortNumberThe pointer to the number of the root hub ports.
Return values
EFI_SUCCESSThe port number was retrieved successfully.
EFI_INVALID_PARAMETERPortNumber is NULL.

Definition at line 660 of file EhcPeim.c.

◆ EhcGetRootHubPortStatus()

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 
)

Retrieves the current status of a USB root hub port.

Parameters
PeiServicesThe pointer of EFI_PEI_SERVICES.
ThisThe pointer of PEI_USB2_HOST_CONTROLLER_PPI.
PortNumberThe root hub port to retrieve the state from.
PortStatusVariable to receive the port state.
Return values
EFI_SUCCESSThe status of the USB root hub port specified. by PortNumber was returned in PortStatus.
EFI_INVALID_PARAMETERPortNumber is invalid.

Definition at line 917 of file EhcPeim.c.

◆ EhcHaltHC()

EFI_STATUS EhcHaltHC ( IN PEI_USB2_HC_DEV Ehc,
IN UINT32  Timeout 
)

Halt the host controller.

Parameters
EhcThe EHCI device.
TimeoutTime to wait before abort.
Return values
EFI_TIMEOUTFailed to halt the controller before Timeout.
EFI_SUCCESSThe EHCI is halt.

Definition at line 359 of file EhcPeim.c.

◆ EhcInitHC()

EFI_STATUS EhcInitHC ( IN PEI_USB2_HC_DEV Ehc)

Initialize the HC hardware. EHCI spec lists the five things to do to initialize the hardware.

  1. Program CTRLDSSEGMENT.
  2. Set USBINTR to enable interrupts.
  3. Set periodic list base.
  4. Set USBCMD, interrupt threshold, frame list size etc.
  5. Write 1 to CONFIGFLAG to route all ports to EHCI.
Parameters
EhcThe EHCI device.
Return values
EFI_SUCCESSThe EHCI has come out of halt state.
EFI_TIMEOUTTime out happened.

Definition at line 438 of file EhcPeim.c.

◆ EhcIsHalt()

BOOLEAN EhcIsHalt ( IN PEI_USB2_HC_DEV Ehc)

Check whether Ehc is halted.

Parameters
EhcThe EHCI device.
Return values
TRUEThe controller is halted.
FALSEThe controller isn't halted.

Definition at line 290 of file EhcPeim.c.

◆ EhcIsSysError()

BOOLEAN EhcIsSysError ( IN PEI_USB2_HC_DEV Ehc)

Check whether system error occurred.

Parameters
EhcThe EHCI device.
Return values
TRUESystem error happened.
FALSENo system error.

Definition at line 307 of file EhcPeim.c.

◆ EhcPeimEntry()

EFI_STATUS EFIAPI EhcPeimEntry ( IN EFI_PEI_FILE_HANDLE  FileHandle,
IN CONST EFI_PEI_SERVICES **  PeiServices 
)
Parameters
FileHandleHandle of the file being invoked.
PeiServicesDescribes the list of possible PEI Services.
Return values
EFI_SUCCESSPPI successfully installed.

Definition at line 1179 of file EhcPeim.c.

◆ EhcPowerOnAllPorts()

VOID EhcPowerOnAllPorts ( IN PEI_USB2_HC_DEV Ehc)

Power On All EHCI Ports.

Parameters
EhcThe EHCI device.

Definition at line 401 of file EhcPeim.c.

◆ EhcReadCapRegister()

UINT32 EhcReadCapRegister ( IN PEI_USB2_HC_DEV Ehc,
IN UINT32  Offset 
)

Read EHCI capability register.

Parameters
EhcThe EHCI device.
OffsetCapability register address.
Return values
theregister content read.

Definition at line 167 of file EhcPeim.c.

◆ EhcReadOpReg()

UINT32 EhcReadOpReg ( IN PEI_USB2_HC_DEV Ehc,
IN UINT32  Offset 
)

Read Ehc Operation register.

Parameters
EhcThe EHCI device.
OffsetThe operation register offset.
Return values
theregister content read.

Definition at line 43 of file EhcPeim.c.

◆ EhcResetHC()

EFI_STATUS EhcResetHC ( IN PEI_USB2_HC_DEV Ehc,
IN UINT32  Timeout 
)

Reset the host controller.

Parameters
EhcThe EHCI device.
TimeoutTime to wait before abort (in millisecond, ms).
Return values
EFI_TIMEOUTThe transfer failed due to time out.
OthersFailed to reset the host.

Definition at line 325 of file EhcPeim.c.

◆ EhcRunHC()

EFI_STATUS EhcRunHC ( IN PEI_USB2_HC_DEV Ehc,
IN UINT32  Timeout 
)

Set the EHCI to run.

Parameters
EhcThe EHCI device.
TimeoutTime to wait before abort.
Return values
EFI_SUCCESSThe EHCI is running.
OthersFailed to set the EHCI to run.

Definition at line 382 of file EhcPeim.c.

◆ EhcSetAndWaitDoorBell()

EFI_STATUS EhcSetAndWaitDoorBell ( IN PEI_USB2_HC_DEV Ehc,
IN UINT32  Timeout 
)

Set door bell and wait it to be ACKed by host controller. This function is used to synchronize with the hardware.

Parameters
EhcThe EHCI device.
TimeoutThe time to wait before abort (in millisecond, ms).
Return values
EFI_TIMEOUTTime out happened while waiting door bell to set.
EFI_SUCCESSSynchronized with the hardware.

Definition at line 191 of file EhcPeim.c.

◆ EhcSetOpRegBit()

VOID EhcSetOpRegBit ( IN PEI_USB2_HC_DEV Ehc,
IN UINT32  Offset,
IN UINT32  Bit 
)

Set one bit of the operational register while keeping other bits.

Parameters
EhcThe EHCI device.
OffsetThe offset of the operational register.
BitThe bit mask of the register to set.

Definition at line 86 of file EhcPeim.c.

◆ EhcSetRootHubPortFeature()

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 
)

Sets a feature for the specified root hub port.

Parameters
PeiServicesThe pointer of EFI_PEI_SERVICES
ThisThe pointer of PEI_USB2_HOST_CONTROLLER_PPI
PortNumberRoot hub port to set.
PortFeatureFeature to set.
Return values
EFI_SUCCESSThe feature specified by PortFeature was set.
EFI_INVALID_PARAMETERPortNumber is invalid or PortFeature is invalid.
EFI_TIMEOUTThe time out occurred.

Definition at line 815 of file EhcPeim.c.

◆ EhcWaitOpRegBit()

EFI_STATUS EhcWaitOpRegBit ( IN PEI_USB2_HC_DEV Ehc,
IN UINT32  Offset,
IN UINT32  Bit,
IN BOOLEAN  WaitToSet,
IN UINT32  Timeout 
)

Wait the operation register's bit as specified by Bit to become set (or clear).

Parameters
EhcThe EHCI device.
OffsetThe offset of the operational register.
BitThe bit mask of the register to wait for.
WaitToSetWait the bit to set or clear.
TimeoutThe time to wait before abort (in millisecond).
Return values
EFI_SUCCESSThe bit successfully changed by host controller.
EFI_TIMEOUTThe time out occurred.

Definition at line 136 of file EhcPeim.c.

◆ EhcWriteOpReg()

VOID EhcWriteOpReg ( IN PEI_USB2_HC_DEV Ehc,
IN UINT32  Offset,
IN UINT32  Data 
)

Write the data to the EHCI operation register.

Parameters
EhcThe EHCI device.
OffsetEHCI operation register offset.
DataThe data to write.

Definition at line 66 of file EhcPeim.c.

◆ InitializeUsbHC()

EFI_STATUS InitializeUsbHC ( IN PEI_USB2_HC_DEV EhcDev)
Parameters
EhcDevEHCI Device.
Return values
EFI_SUCCESSEHCI successfully initialized.
EFI_ABORTEDEHCI was failed to be initialized.

Definition at line 1301 of file EhcPeim.c.

Variable Documentation

◆ mUsbPortChangeMap

USB_PORT_STATE_MAP mUsbPortChangeMap[]
Initial value:
= {
{ PORTSC_CONN_CHANGE, USB_PORT_STAT_C_CONNECTION },
{ PORTSC_ENABLE_CHANGE, USB_PORT_STAT_C_ENABLE },
{ PORTSC_OVERCUR_CHANGE, USB_PORT_STAT_C_OVERCURRENT }
}
#define USB_PORT_STAT_C_CONNECTION

Definition at line 27 of file EhcPeim.c.

◆ mUsbPortStateMap

USB_PORT_STATE_MAP mUsbPortStateMap[]
Initial value:
= {
{ PORTSC_CONN, USB_PORT_STAT_CONNECTION },
{ PORTSC_ENABLED, USB_PORT_STAT_ENABLE },
{ PORTSC_SUSPEND, USB_PORT_STAT_SUSPEND },
{ PORTSC_OVERCUR, USB_PORT_STAT_OVERCURRENT },
{ PORTSC_RESET, USB_PORT_STAT_RESET },
{ PORTSC_POWER, USB_PORT_STAT_POWER },
{ PORTSC_OWNER, USB_PORT_STAT_OWNER }
}
#define USB_PORT_STAT_CONNECTION

Definition at line 17 of file EhcPeim.c.