15 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
16 &gEdkiiPeiUfsHostControllerPpiGuid,
17 &mUfsHostControllerPpi
35 IN UINT8 ControllerId,
41 if ((This ==
NULL) || (MmioBar ==
NULL)) {
42 return EFI_INVALID_PARAMETER;
45 Private = UFS_HC_PEI_PRIVATE_DATA_FROM_THIS (This);
47 if (ControllerId >= Private->TotalUfsHcs) {
48 return EFI_INVALID_PARAMETER;
51 *MmioBar = (
UINTN)Private->UfsHcPciAddr[ControllerId];
96 if (BootMode == BOOT_ON_S3_RESUME) {
101 if (Private ==
NULL) {
102 DEBUG ((DEBUG_ERROR,
"Failed to allocate memory for UFS_HC_PEI_PRIVATE_DATA! \n"));
103 return EFI_OUT_OF_RESOURCES;
106 Private->Signature = UFS_HC_PEI_SIGNATURE;
107 Private->UfsHostControllerPpi = mUfsHostControllerPpi;
108 Private->PpiList = mPpiList;
109 Private->PpiList.
Ppi = &Private->UfsHostControllerPpi;
111 BarAddr =
PcdGet32 (PcdUfsPciHostControllerMmioBase);
112 for (Bus = 0; Bus < 256; Bus++) {
113 for (Device = 0; Device < 32; Device++) {
114 for (Function = 0; Function < 8; Function++) {
118 if ((SubClass == 0x09) && (BaseClass == PCI_CLASS_MASS_STORAGE)) {
126 switch (Size & 0x07) {
131 MmioSize = (~(Size & 0xFFFFFFF0)) + 1;
137 MmioSize = Size & 0xFFFFFFF0;
149 MmioSize |=
LShiftU64 ((UINT64)Size, 32);
150 MmioSize = (~(MmioSize)) + 1;
174 Private->UfsHcPciAddr[Private->TotalUfsHcs] = BarAddr;
175 Private->TotalUfsHcs++;
176 BarAddr += (UINT32)MmioSize;
177 ASSERT (Private->TotalUfsHcs < MAX_UFS_HCS);
UINT64 EFIAPI LShiftU64(IN UINT64 Operand, IN UINTN Count)
INTN EFIAPI HighBitSet32(IN UINT32 Operand)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
EFI_STATUS EFIAPI PeiServicesGetBootMode(OUT EFI_BOOT_MODE *BootMode)
EFI_STATUS EFIAPI PeiServicesInstallPpi(IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList)
EFI_STATUS EFIAPI PeiServicesRegisterForShadow(IN EFI_PEI_FILE_HANDLE FileHandle)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
UINT32 EFIAPI PciRead32(IN UINTN Address)
UINT8 EFIAPI PciRead8(IN UINTN Address)
#define PCI_LIB_ADDRESS(Bus, Device, Function, Register)
UINT16 EFIAPI PciAnd16(IN UINTN Address, IN UINT16 AndData)
UINT32 EFIAPI PciWrite32(IN UINTN Address, IN UINT32 Value)
UINT16 EFIAPI PciOr16(IN UINTN Address, IN UINT16 OrData)
#define PcdGet32(TokenName)
#define EFI_PCI_COMMAND_MEMORY_SPACE
0x0002
#define EFI_PCI_COMMAND_BUS_MASTER
0x0004
VOID * EFI_PEI_FILE_HANDLE
EFI_STATUS EFIAPI GetUfsHcMmioBar(IN EDKII_UFS_HOST_CONTROLLER_PPI *This, IN UINT8 ControllerId, OUT UINTN *MmioBar)
EFI_STATUS EFIAPI InitializeUfsHcPeim(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)