]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg PeiCore: Handle notification PPI from SEC
authorStar Zeng <star.zeng@intel.com>
Wed, 26 Jul 2017 07:55:26 +0000 (15:55 +0800)
committerStar Zeng <star.zeng@intel.com>
Tue, 1 Aug 2017 09:48:53 +0000 (17:48 +0800)
InstallPpi() will be used for normal PPI in PPI list from SEC,
and NotifyPpi() will be used for notification PPI in PPI list from SEC.

Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
MdeModulePkg/Core/Pei/PeiMain.h
MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
MdeModulePkg/Core/Pei/Ppi/Ppi.c

index 8b58916e65b37dd76d6b276fcb3461c2ebeff2a4..e95b1c3d8cd77057a1646d9c516b2227d7c00001 100644 (file)
@@ -557,6 +557,20 @@ DispatchNotify (
   IN INTN                NotifyStopIndex\r
   );\r
 \r
+/**\r
+  Process PpiList from SEC phase.\r
+\r
+  @param PeiServices    An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param PpiList        Points to a list of one or more PPI descriptors to be installed initially by the PEI core.\r
+                        These PPI's will be installed and/or immediately signaled if they are notification type.\r
+\r
+**/\r
+VOID\r
+ProcessPpiListFromSec (\r
+  IN CONST EFI_PEI_SERVICES         **PeiServices,\r
+  IN CONST EFI_PEI_PPI_DESCRIPTOR   *PpiList\r
+  );\r
+\r
 //\r
 // Boot mode support functions\r
 //\r
index 27484bafc575390feeded22d53e0f274011a3e1e..d2897437d776b3bfb8e24d1699850004cbb7d1f1 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Pei Core Main Entry Point\r
   \r
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 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
@@ -380,11 +380,10 @@ PeiCore (
       );\r
       \r
     //\r
-    // If SEC provided any PPI services to PEI, install them.\r
+    // If SEC provided the PpiList, process it.\r
     //\r
     if (PpiList != NULL) {\r
-      Status = PeiServicesInstallPpi (PpiList);\r
-      ASSERT_EFI_ERROR (Status);\r
+      ProcessPpiListFromSec ((CONST EFI_PEI_SERVICES **) &PrivateData.Ps, PpiList);\r
     }\r
   } else {\r
     //\r
index db6eded6d6eddd4cf0cdb21402148abdbec1c27f..b2ab3fbd208617359e5ffafdc6b3cca2e620cfa7 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   EFI PEI Core PPI services\r
   \r
-Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 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
@@ -171,6 +171,9 @@ ConvertPpiPointers (
 \r
   @param PeiServices                An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
   @param PpiList                    Pointer to a list of PEI PPI Descriptors.\r
+  @param Single                     TRUE if only single entry in the PpiList.\r
+                                    FALSE if the PpiList is ended with an entry which has the\r
+                                    EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST flag set in its Flags field.\r
 \r
   @retval EFI_SUCCESS              if all PPIs in PpiList are successfully installed.\r
   @retval EFI_INVALID_PARAMETER    if PpiList is NULL pointer\r
@@ -179,10 +182,10 @@ ConvertPpiPointers (
 \r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
-PeiInstallPpi (\r
+InternalPeiInstallPpi (\r
   IN CONST EFI_PEI_SERVICES        **PeiServices,\r
-  IN CONST EFI_PEI_PPI_DESCRIPTOR  *PpiList\r
+  IN CONST EFI_PEI_PPI_DESCRIPTOR  *PpiList,\r
+  IN BOOLEAN                       Single\r
   )\r
 {\r
   PEI_CORE_INSTANCE *PrivateData;\r
@@ -229,11 +232,16 @@ PeiInstallPpi (
     PrivateData->PpiData.PpiListPtrs[Index].Ppi = (EFI_PEI_PPI_DESCRIPTOR*) PpiList;\r
     PrivateData->PpiData.PpiListEnd++;\r
 \r
-    //\r
-    // Continue until the end of the PPI List.\r
-    //\r
-    if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) ==\r
-        EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {\r
+    if (Single) {\r
+      //\r
+      // Only single entry in the PpiList.\r
+      //\r
+      break;\r
+    } else if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) ==\r
+               EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {\r
+      //\r
+      // Continue until the end of the PPI List.\r
+      //\r
       break;\r
     }\r
     PpiList++;\r
@@ -256,6 +264,31 @@ PeiInstallPpi (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+\r
+  This function installs an interface in the PEI PPI database by GUID. \r
+  The purpose of the service is to publish an interface that other parties\r
+  can use to call additional PEIMs.\r
+\r
+  @param PeiServices                An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param PpiList                    Pointer to a list of PEI PPI Descriptors.\r
+\r
+  @retval EFI_SUCCESS              if all PPIs in PpiList are successfully installed.\r
+  @retval EFI_INVALID_PARAMETER    if PpiList is NULL pointer\r
+                                   if any PPI in PpiList is not valid\r
+  @retval EFI_OUT_OF_RESOURCES     if there is no more memory resource to install PPI\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiInstallPpi (\r
+  IN CONST EFI_PEI_SERVICES        **PeiServices,\r
+  IN CONST EFI_PEI_PPI_DESCRIPTOR  *PpiList\r
+  )\r
+{\r
+  return InternalPeiInstallPpi (PeiServices, PpiList, FALSE);\r
+}\r
+\r
 /**\r
 \r
   This function reinstalls an interface in the PEI PPI database by GUID. \r
@@ -409,17 +442,20 @@ PeiLocatePpi (
 \r
   @param PeiServices        An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
   @param NotifyList         Pointer to list of Descriptors to notify upon.\r
+  @param Single             TRUE if only single entry in the NotifyList.\r
+                            FALSE if the NotifyList is ended with an entry which has the\r
+                            EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST flag set in its Flags field.\r
 \r
   @retval EFI_SUCCESS           if successful\r
   @retval EFI_OUT_OF_RESOURCES  if no space in the database\r
-  @retval EFI_INVALID_PARAMETER if not a good decriptor\r
+  @retval EFI_INVALID_PARAMETER if not a good descriptor\r
 \r
 **/\r
 EFI_STATUS\r
-EFIAPI\r
-PeiNotifyPpi (\r
+InternalPeiNotifyPpi (\r
   IN CONST EFI_PEI_SERVICES           **PeiServices,\r
-  IN CONST EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyList\r
+  IN CONST EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyList,\r
+  IN BOOLEAN                          Single\r
   )\r
 {\r
   PEI_CORE_INSTANCE                *PrivateData;\r
@@ -474,8 +510,16 @@ PeiNotifyPpi (
 \r
     PrivateData->PpiData.NotifyListEnd--;\r
     DEBUG((EFI_D_INFO, "Register PPI Notify: %g\n", NotifyList->Guid));\r
-    if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) ==\r
-        EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {\r
+    if (Single) {\r
+      //\r
+      // Only single entry in the NotifyList.\r
+      //\r
+      break;\r
+    } else if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) ==\r
+               EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {\r
+      //\r
+      // Continue until the end of the Notify List.\r
+      //\r
       break;\r
     }\r
     //\r
@@ -519,6 +563,30 @@ PeiNotifyPpi (
   return  EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+\r
+  This function installs a notification service to be called back when a given \r
+  interface is installed or reinstalled. The purpose of the service is to publish \r
+  an interface that other parties can use to call additional PPIs that may materialize later.\r
+\r
+  @param PeiServices        An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param NotifyList         Pointer to list of Descriptors to notify upon.\r
+\r
+  @retval EFI_SUCCESS           if successful\r
+  @retval EFI_OUT_OF_RESOURCES  if no space in the database\r
+  @retval EFI_INVALID_PARAMETER if not a good descriptor\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PeiNotifyPpi (\r
+  IN CONST EFI_PEI_SERVICES           **PeiServices,\r
+  IN CONST EFI_PEI_NOTIFY_DESCRIPTOR  *NotifyList\r
+  )\r
+{\r
+  return InternalPeiNotifyPpi (PeiServices, NotifyList, FALSE);\r
+}\r
+\r
 \r
 /**\r
 \r
@@ -644,3 +712,45 @@ DispatchNotify (
   }\r
 }\r
 \r
+/**\r
+  Process PpiList from SEC phase.\r
+\r
+  @param PeiServices    An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param PpiList        Points to a list of one or more PPI descriptors to be installed initially by the PEI core.\r
+                        These PPI's will be installed and/or immediately signaled if they are notification type.\r
+\r
+**/\r
+VOID\r
+ProcessPpiListFromSec (\r
+  IN CONST EFI_PEI_SERVICES         **PeiServices,\r
+  IN CONST EFI_PEI_PPI_DESCRIPTOR   *PpiList\r
+  )\r
+{\r
+  EFI_STATUS    Status;\r
+\r
+  for (;;) {\r
+    if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES) != 0) {\r
+      //\r
+      // It is a notification PPI.\r
+      //\r
+      Status = InternalPeiNotifyPpi (PeiServices, (CONST EFI_PEI_NOTIFY_DESCRIPTOR *) PpiList, TRUE);\r
+      ASSERT_EFI_ERROR (Status);\r
+    } else {\r
+      //\r
+      // It is a normal PPI.\r
+      //\r
+      Status = InternalPeiInstallPpi (PeiServices, PpiList, TRUE);\r
+      ASSERT_EFI_ERROR (Status);\r
+    }\r
+\r
+    if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) == EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {\r
+      //\r
+      // Continue until the end of the PPI List.\r
+      //\r
+      break;\r
+    }\r
+\r
+    PpiList++;\r
+  }\r
+}\r
+\r