]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Allow gEfiMemoryTypeInformation bins to shrink if boot mode is BOOT_WITH_DEFAULT_SETT...
authormdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 14 Jun 2010 23:23:58 +0000 (23:23 +0000)
committermdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 14 Jun 2010 23:23:58 +0000 (23:23 +0000)
Update BdsSetMemoryTypeInformationVariable() to use DEBUG() prints to show the Previous, Current, and Next sizes of each memory bin type.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10580 6f19259b-4bc3-4df7-8a09-765794883524

IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c

index 487807b3018f2a394bbdf0c13c91e32d236428cc..9b727acbe2c9428179bbb5b07505d45c0aff8237 100644 (file)
@@ -1124,8 +1124,25 @@ BdsSetMemoryTypeInformationVariable (
   UINT32                       Current;\r
   UINT32                       Next;\r
   EFI_HOB_GUID_TYPE            *GuidHob;\r
-\r
-  UpdateRequired = FALSE;\r
+  BOOLEAN                      MemoryTypeInformationVariableExists;\r
+\r
+  UpdateRequired = TRUE;\r
+  MemoryTypeInformationVariableExists = FALSE;\r
+\r
+  if (GetBootModeHob () != BOOT_WITH_DEFAULT_SETTINGS) {\r
+    VariableSize = 0;\r
+    Status = gRT->GetVariable (\r
+                    EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME,\r
+                    &gEfiMemoryTypeInformationGuid,\r
+                    NULL, \r
+                    &VariableSize, \r
+                    NULL\r
+                    );\r
+    if (Status == EFI_BUFFER_TOO_SMALL) {\r
+      MemoryTypeInformationVariableExists = TRUE;\r
+      UpdateRequired = FALSE;\r
+    }\r
+  }\r
 \r
   //\r
   // Retrieve the current memory usage statistics.  If they are not found, then\r
@@ -1157,6 +1174,10 @@ BdsSetMemoryTypeInformationVariable (
   //\r
   // Use a heuristic to adjust the Memory Type Information for the next boot\r
   //\r
+  DEBUG ((EFI_D_INFO, "Memory  Previous  Current    Next   \n"));\r
+  DEBUG ((EFI_D_INFO, " Type    Pages     Pages     Pages  \n"));\r
+  DEBUG ((EFI_D_INFO, "======  ========  ========  ========\n"));\r
+\r
   for (Index = 0; PreviousMemoryTypeInformation[Index].Type != EfiMaxMemoryType; Index++) {\r
 \r
     Current = 0;\r
@@ -1176,7 +1197,9 @@ BdsSetMemoryTypeInformationVariable (
     //\r
     // Write next varible to 125% * current and Inconsistent Memory Reserved across bootings may lead to S4 fail\r
     //\r
-    if (Current > Previous) {\r
+    if (!MemoryTypeInformationVariableExists && Current < Previous) {\r
+      Next = Current + (Current >> 2);\r
+    } else if (Current > Previous) {\r
       Next = Current + (Current >> 2);\r
     } else {\r
       Next = Previous;\r
@@ -1190,12 +1213,13 @@ BdsSetMemoryTypeInformationVariable (
       UpdateRequired = 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
   //\r
-  if (UpdateRequired) {\r
+  if (UpdateRequired || !MemoryTypeInformationVariableExists) {\r
     Status = gRT->SetVariable (\r
           EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME,\r
           &gEfiMemoryTypeInformationGuid,\r
@@ -1204,8 +1228,6 @@ BdsSetMemoryTypeInformationVariable (
           PreviousMemoryTypeInformation\r
           );\r
   }\r
-\r
-  return;\r
 }\r
 \r
 /**\r
@@ -1231,7 +1253,6 @@ BdsLibSaveMemoryTypeInformation (
   if (EFI_ERROR (Status)) {\r
     DEBUG ((DEBUG_ERROR,"Bds Set Memory Type Informationa Variable Fails\n"));\r
   }\r
-\r
 }\r
 \r
 \r