]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add additional reset when Memory Type Information settings change.
authorniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 16 Sep 2010 01:14:51 +0000 (01:14 +0000)
committerniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 16 Sep 2010 01:14:51 +0000 (01:14 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10879 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c

index a3d910c9b9f920783da9dc87b616616951bee11b..2a12f16879833ce1acc87a3e18c0fe17979232d7 100644 (file)
@@ -1117,18 +1117,23 @@ BdsSetMemoryTypeInformationVariable (
   EFI_MEMORY_TYPE_INFORMATION  *PreviousMemoryTypeInformation;\r
   EFI_MEMORY_TYPE_INFORMATION  *CurrentMemoryTypeInformation;\r
   UINTN                        VariableSize;\r
-  BOOLEAN                      UpdateRequired;\r
   UINTN                        Index;\r
   UINTN                        Index1;\r
   UINT32                       Previous;\r
   UINT32                       Current;\r
   UINT32                       Next;\r
   EFI_HOB_GUID_TYPE            *GuidHob;\r
+  BOOLEAN                      MemoryTypeInformationModified;\r
   BOOLEAN                      MemoryTypeInformationVariableExists;\r
 \r
-  UpdateRequired = TRUE;\r
+  MemoryTypeInformationModified       = FALSE;\r
   MemoryTypeInformationVariableExists = FALSE;\r
 \r
+  //\r
+  // Only get the the Memory Type Information variable in the boot mode \r
+  // other than BOOT_WITH_DEFAULT_SETTINGS because the Memory Type\r
+  // Information is not valid in this boot mode.\r
+  //\r
   if (GetBootModeHob () != BOOT_WITH_DEFAULT_SETTINGS) {\r
     VariableSize = 0;\r
     Status = gRT->GetVariable (\r
@@ -1140,7 +1145,6 @@ BdsSetMemoryTypeInformationVariable (
                     );\r
     if (Status == EFI_BUFFER_TOO_SMALL) {\r
       MemoryTypeInformationVariableExists = TRUE;\r
-      UpdateRequired = FALSE;\r
     }\r
   }\r
 \r
@@ -1210,23 +1214,34 @@ BdsSetMemoryTypeInformationVariable (
 \r
     if (Next != Previous) {\r
       PreviousMemoryTypeInformation[Index].NumberOfPages = Next;\r
-      UpdateRequired = TRUE;\r
+      MemoryTypeInformationModified = TRUE;\r
     }\r
 \r
     DEBUG ((EFI_D_INFO, "  %02x    %08x  %08x  %08x\n", PreviousMemoryTypeInformation[Index].Type, Previous, Current, Next));\r
   }\r
 \r
   //\r
-  // If any changes were made to the Memory Type Information settings, then set the new variable value\r
+  // If any changes were made to the Memory Type Information settings, then set the new variable value;\r
+  // Or create the variable in first boot.\r
   //\r
-  if (UpdateRequired || !MemoryTypeInformationVariableExists) {\r
+  if (MemoryTypeInformationModified || !MemoryTypeInformationVariableExists) {\r
     Status = gRT->SetVariable (\r
-          EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME,\r
-          &gEfiMemoryTypeInformationGuid,\r
-          EFI_VARIABLE_NON_VOLATILE  | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
-          VariableSize,\r
-          PreviousMemoryTypeInformation\r
-          );\r
+                    EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME,\r
+                    &gEfiMemoryTypeInformationGuid,\r
+                    EFI_VARIABLE_NON_VOLATILE  | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+                    VariableSize,\r
+                    PreviousMemoryTypeInformation\r
+                    );\r
+\r
+    //\r
+    // If the Memory Type Information settings have been modified, then reset the platform\r
+    // so the new Memory Type Information setting will be used to guarantee that an S4\r
+    // entry/resume cycle will not fail.\r
+    //\r
+    if (MemoryTypeInformationModified) {\r
+      DEBUG ((EFI_D_ERROR, "Memory Type Information settings change. Warm Reset!!!\n"));\r
+      gRT->ResetSystem (EfiResetWarm, EFI_SUCCESS, 0, NULL);\r
+    }\r
   }\r
 }\r
 \r