]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Sd/EmmcBlockIoPei/EmmcBlockIoPei.c
MdeModulePkg/EmmcBlockIoPei: Support IoMmu
[mirror_edk2.git] / MdeModulePkg / Bus / Sd / EmmcBlockIoPei / EmmcBlockIoPei.c
index 004670cb28c7ae6cb858f99838aecc39c7fe4475..9ed4e8f95ae960d7bb735e2207840a146565a3a0 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-  Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -136,6 +136,11 @@ EMMC_PEIM_HC_PRIVATE_DATA gEmmcHcPrivateTemplate = {
     &gEfiPeiVirtualBlockIo2PpiGuid,\r
     NULL\r
   },\r
+  {                               // EndOfPeiNotifyList\r
+    (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+    &gEfiEndOfPeiSignalPpiGuid,\r
+    EmmcBlockIoPeimEndOfPei\r
+  },\r
   {                               // Slot\r
     {\r
       0,\r
@@ -618,6 +623,36 @@ EmmcBlockIoPeimReadBlocks2 (
   return Status;\r
 }\r
 \r
+/**\r
+  One notified function to cleanup the allocated DMA buffers at the end of PEI.\r
+\r
+  @param[in]  PeiServices        Pointer to PEI Services Table.\r
+  @param[in]  NotifyDescriptor   Pointer to the descriptor for the Notification\r
+                                 event that caused this function to execute.\r
+  @param[in]  Ppi                Pointer to the PPI data associated with this function.\r
+\r
+  @retval     EFI_SUCCESS  The function completes successfully\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EmmcBlockIoPeimEndOfPei (\r
+  IN EFI_PEI_SERVICES           **PeiServices,\r
+  IN EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyDescriptor,\r
+  IN VOID                       *Ppi\r
+  )\r
+{\r
+  EMMC_PEIM_HC_PRIVATE_DATA       *Private;\r
+\r
+  Private = GET_EMMC_PEIM_HC_PRIVATE_DATA_FROM_THIS_NOTIFY (NotifyDescriptor);\r
+\r
+  if ((Private->Pool != NULL) && (Private->Pool->Head != NULL)) {\r
+    EmmcPeimFreeMemPool (Private->Pool);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
 /**\r
   The user code starts with this function.\r
 \r
@@ -672,6 +707,8 @@ InitializeEmmcBlockIoPeim (
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
+  IoMmuInit ();\r
+\r
   Controller = 0;\r
   MmioBase   = NULL;\r
   while (TRUE) {\r
@@ -800,6 +837,11 @@ InitializeEmmcBlockIoPeim (
 \r
     if (!EFI_ERROR (Status)) {\r
       PeiServicesInstallPpi (&Private->BlkIoPpiList);\r
+      PeiServicesNotifyPpi (&Private->EndOfPeiNotifyList);\r
+    } else {\r
+      if (Private->Pool->Head != NULL) {\r
+        EmmcPeimFreeMemPool (Private->Pool);\r
+      }\r
     }\r
   }\r
 \r