Align to old BDS behavior (IntelFrameworkModulePkg/BDS) to always create
MemoryTypeInfo variable regardless of the PcdResetOnMemoryTypeInformationChange
value.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu...@intel.com>
Cc: Michael Kinney <michael.d.kin...@intel.com>
---
 MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c     |  8 +++-----
 MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c     | 15 ++++++++++-----
 MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h |  9 +++++++--
 3 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c 
b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
index 70ec216..e963458 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c
@@ -1765,11 +1765,9 @@ EfiBootManagerBoot (
   // 6. Adjust the different type memory page number just before booting
   //    and save the updated info into the variable for next boot to use
   //
-  if ((BootOption->Attributes & LOAD_OPTION_CATEGORY) == 
LOAD_OPTION_CATEGORY_BOOT) {
-    if (PcdGetBool (PcdResetOnMemoryTypeInformationChange)) {
-      BmSetMemoryTypeInformationVariable ();
-    }
-  }
+  BmSetMemoryTypeInformationVariable (
+    (BOOLEAN) ((BootOption->Attributes & LOAD_OPTION_CATEGORY) == 
LOAD_OPTION_CATEGORY_BOOT)
+    );
 
   DEBUG_CODE_BEGIN();
     if (BootOption->Description == NULL) {
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c 
b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
index cc2032c..1768781 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
+++ b/MdeModulePkg/Library/UefiBootManagerLib/BmMisc.c
@@ -122,11 +122,16 @@ BmMatchDevicePaths (
 
 /**
   This routine adjust the memory information for different memory type and 
-  save them into the variables for next boot.
+  save them into the variables for next boot. It resets the system when
+  memory information is updated and the current boot option belongs to
+  boot category instead of application category.
+
+  @param Boot  TRUE if current boot option belongs to boot category instead of
+               application category.
 **/
 VOID
 BmSetMemoryTypeInformationVariable (
-  VOID
+  IN BOOLEAN                    Boot
   )
 {
   EFI_STATUS                   Status;
@@ -267,11 +272,11 @@ BmSetMemoryTypeInformationVariable (
 
     if (!EFI_ERROR (Status)) {
       //
-      // If the Memory Type Information settings have been modified, then 
reset the platform
-      // so the new Memory Type Information setting will be used to guarantee 
that an S4
+      // If the Memory Type Information settings have been modified and the 
boot option belongs to boot category,
+      // then reset the platform so the new Memory Type Information setting 
will be used to guarantee that an S4
       // entry/resume cycle will not fail.
       //
-      if (MemoryTypeInformationModified) {
+      if (MemoryTypeInformationModified && Boot && PcdGetBool 
(PcdResetOnMemoryTypeInformationChange)) {
         DEBUG ((EFI_D_INFO, "Memory Type Information settings change. Warm 
Reset!!!\n"));
         gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);
       }
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h 
b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
index 6a888fa..fa4d5af 100644
--- a/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
+++ b/MdeModulePkg/Library/UefiBootManagerLib/InternalBm.h
@@ -245,11 +245,16 @@ BmGetImageHeader (
 
 /**
   This routine adjust the memory information for different memory type and 
-  save them into the variables for next boot.
+  save them into the variables for next boot. It resets the system when
+  memory information is updated and the current boot option belongs to
+  boot category instead of application category.
+
+  @param Boot  TRUE if current boot option belongs to boot category instead of
+               application category.
 **/
 VOID
 BmSetMemoryTypeInformationVariable (
-  VOID
+  IN BOOLEAN                    Boot
   );
 
 /**
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to