[edk2-devel] [PATCH] MdeModulePkg PeiCore: Install SEC PPIs before library constructor call

Pankaj Bansal posted 1 patch 4 years, 2 months ago
Failed in applying to current master (apply log)
MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 24 ++++++++++++-----------
1 file changed, 13 insertions(+), 11 deletions(-)
[edk2-devel] [PATCH] MdeModulePkg PeiCore: Install SEC PPIs before library constructor call
Posted by Pankaj Bansal 4 years, 2 months ago
Install PPIs received from SEC phase before library constructor call, so
that any platform specific library can make use of the PPIs exposed by SEC
phase.

Since SEC phase can expose HOBs also in PPI list, we need to Initialize
memory service before installing SEC PPIs.

Therefore, the sequence becomes:
Initialize memory -> install SEC PPIs -> Call libraries' constructors

Signed-off-by: Pankaj Bansal <pankaj.bansal@nxp.com>

Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
---
 MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 24 ++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
index 025d7f98ec..3dd69ddde0 100644
--- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
+++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
@@ -366,14 +366,23 @@ PeiCore (
   SetPeiServicesTablePointer ((CONST EFI_PEI_SERVICES **)&PrivateData.Ps);
 
   //
-  // Initialize libraries that the PEI Core is linked against
+  // Initialize PEI Core Services
   //
-  ProcessLibraryConstructorList (NULL, (CONST EFI_PEI_SERVICES **)&PrivateData.Ps);
+  InitializeMemoryServices   (&PrivateData, SecCoreData, OldCoreData);
+
+  if (OldCoreData == NULL) {
+    //
+    // If SEC provided the PpiList, process it.
+    //
+    if (PpiList != NULL) {
+      ProcessPpiListFromSec ((CONST EFI_PEI_SERVICES **) &PrivateData.Ps, PpiList);
+    }
+  }
 
   //
-  // Initialize PEI Core Services
+  // Initialize libraries that the PEI Core is linked against
   //
-  InitializeMemoryServices   (&PrivateData, SecCoreData, OldCoreData);
+  ProcessLibraryConstructorList (NULL, (CONST EFI_PEI_SERVICES **)&PrivateData.Ps);
 
   //
   // Update performance measurements
@@ -410,13 +419,6 @@ PeiCore (
       EFI_PROGRESS_CODE,
       (EFI_SOFTWARE_PEI_CORE | EFI_SW_PC_INIT)
       );
-
-    //
-    // If SEC provided the PpiList, process it.
-    //
-    if (PpiList != NULL) {
-      ProcessPpiListFromSec ((CONST EFI_PEI_SERVICES **) &PrivateData.Ps, PpiList);
-    }
   } else {
     //
     // Try to locate Temporary RAM Done Ppi.
-- 
2.17.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#52600): https://edk2.groups.io/g/devel/message/52600
Mute This Topic: https://groups.io/mt/69312521/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH] MdeModulePkg PeiCore: Install SEC PPIs before library constructor call
Posted by Liming Gao 4 years, 2 months ago
This change looks good. What functionality test have been done? 

-----Original Message-----
From: Pankaj Bansal <pankaj.bansal@nxp.com> 
Sent: 2019年12月29日 12:54
To: devel@edk2.groups.io
Cc: Pankaj Bansal <pankaj.bansal@nxp.com>; Bi, Dandan <dandan.bi@intel.com>; Gao, Liming <liming.gao@intel.com>
Subject: [PATCH] MdeModulePkg PeiCore: Install SEC PPIs before library constructor call

Install PPIs received from SEC phase before library constructor call, so that any platform specific library can make use of the PPIs exposed by SEC phase.

Since SEC phase can expose HOBs also in PPI list, we need to Initialize memory service before installing SEC PPIs.

Therefore, the sequence becomes:
Initialize memory -> install SEC PPIs -> Call libraries' constructors

Signed-off-by: Pankaj Bansal <pankaj.bansal@nxp.com>

Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
---
 MdeModulePkg/Core/Pei/PeiMain/PeiMain.c | 24 ++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
index 025d7f98ec..3dd69ddde0 100644
--- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
+++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c
@@ -366,14 +366,23 @@ PeiCore (
   SetPeiServicesTablePointer ((CONST EFI_PEI_SERVICES **)&PrivateData.Ps);
 
   //
-  // Initialize libraries that the PEI Core is linked against
+  // Initialize PEI Core Services
   //
-  ProcessLibraryConstructorList (NULL, (CONST EFI_PEI_SERVICES **)&PrivateData.Ps);
+  InitializeMemoryServices   (&PrivateData, SecCoreData, OldCoreData);
+
+  if (OldCoreData == NULL) {
+    //
+    // If SEC provided the PpiList, process it.
+    //
+    if (PpiList != NULL) {
+      ProcessPpiListFromSec ((CONST EFI_PEI_SERVICES **) &PrivateData.Ps, PpiList);
+    }
+  }
 
   //
-  // Initialize PEI Core Services
+  // Initialize libraries that the PEI Core is linked against
   //
-  InitializeMemoryServices   (&PrivateData, SecCoreData, OldCoreData);
+  ProcessLibraryConstructorList (NULL, (CONST EFI_PEI_SERVICES 
+ **)&PrivateData.Ps);
 
   //
   // Update performance measurements
@@ -410,13 +419,6 @@ PeiCore (
       EFI_PROGRESS_CODE,
       (EFI_SOFTWARE_PEI_CORE | EFI_SW_PC_INIT)
       );
-
-    //
-    // If SEC provided the PpiList, process it.
-    //
-    if (PpiList != NULL) {
-      ProcessPpiListFromSec ((CONST EFI_PEI_SERVICES **) &PrivateData.Ps, PpiList);
-    }
   } else {
     //
     // Try to locate Temporary RAM Done Ppi.
--
2.17.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#52730): https://edk2.groups.io/g/devel/message/52730
Mute This Topic: https://groups.io/mt/69312521/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-