15 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
16 &gEdkiiPeiSdMmcHostControllerPpiGuid,
17 &mSdMmcHostControllerPpi
38 IN UINT8 ControllerId,
45 if ((This ==
NULL) || (MmioBar ==
NULL) || (BarNum ==
NULL)) {
46 return EFI_INVALID_PARAMETER;
49 Private = SD_MMC_HC_PEI_PRIVATE_DATA_FROM_THIS (This);
51 if (ControllerId >= Private->TotalSdMmcHcs) {
52 return EFI_INVALID_PARAMETER;
55 *MmioBar = &Private->MmioBar[ControllerId].MmioBarAddr[0];
56 *BarNum = (UINT8)Private->MmioBar[ControllerId].SlotNum;
105 if (BootMode == BOOT_ON_S3_RESUME) {
110 if (Private ==
NULL) {
111 DEBUG ((DEBUG_ERROR,
"Failed to allocate memory for SD_MMC_HC_PEI_PRIVATE_DATA! \n"));
112 return EFI_OUT_OF_RESOURCES;
115 Private->Signature = SD_MMC_HC_PEI_SIGNATURE;
116 Private->SdMmcHostControllerPpi = mSdMmcHostControllerPpi;
117 Private->PpiList = mPpiList;
118 Private->PpiList.
Ppi = &Private->SdMmcHostControllerPpi;
120 BarAddr =
PcdGet32 (PcdSdMmcPciHostControllerMmioBase);
121 for (Bus = 0; Bus < 256; Bus++) {
122 for (Device = 0; Device < 32; Device++) {
123 for (Function = 0; Function < 8; Function++) {
127 if ((SubClass == PCI_SUBCLASS_SD_HOST_CONTROLLER) && (BaseClass == PCI_CLASS_SYSTEM_PERIPHERAL)) {
134 ASSERT ((FirstBar + SlotNum) < MAX_SD_MMC_SLOTS);
136 for (Index = 0, Slot = FirstBar; Slot < (FirstBar + SlotNum); Index++, Slot++) {
144 switch (Size & 0x07) {
149 MmioSize = (~(Size & 0xFFFFFFF0)) + 1;
155 MmioSize = Size & 0xFFFFFFF0;
165 MmioSize |=
LShiftU64 ((UINT64)Size, 32);
166 MmioSize = (~(MmioSize)) + 1;
189 Private->MmioBar[Private->TotalSdMmcHcs].SlotNum++;
190 Private->MmioBar[Private->TotalSdMmcHcs].MmioBarAddr[Index] = BarAddr;
191 BarAddr += (UINT32)MmioSize;
194 Private->TotalSdMmcHcs++;
195 ASSERT (Private->TotalSdMmcHcs < MAX_SD_MMC_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 GetSdMmcHcMmioBar(IN EDKII_SD_MMC_HOST_CONTROLLER_PPI *This, IN UINT8 ControllerId, IN OUT UINTN **MmioBar, OUT UINT8 *BarNum)
EFI_STATUS EFIAPI InitializeSdMmcHcPeim(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)