summaryrefslogtreecommitdiff
path: root/IntelFrameworkModulePkg/Library/GenericBdsLib
diff options
context:
space:
mode:
authormdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2010-06-14 23:23:58 +0000
committermdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>2010-06-14 23:23:58 +0000
commita4e9b4f6e3a06ab21c434787714ce5fa5755492b (patch)
tree7c65f0f16bbfa3a304a3bb26602efdbc39d8cca9 /IntelFrameworkModulePkg/Library/GenericBdsLib
parent2345e7d4a4926209e97485e5e689e13f32d4c14d (diff)
downloadedk2-platforms-a4e9b4f6e3a06ab21c434787714ce5fa5755492b.tar.xz
Allow gEfiMemoryTypeInformation bins to shrink if boot mode is BOOT_WITH_DEFAULT_SETTINGS or the gEfiMemoryTypeInformation variable does not exist.
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
Diffstat (limited to 'IntelFrameworkModulePkg/Library/GenericBdsLib')
-rw-r--r--IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c35
1 files changed, 28 insertions, 7 deletions
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c
index 487807b301..9b727acbe2 100644
--- a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c
+++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c
@@ -1124,8 +1124,25 @@ BdsSetMemoryTypeInformationVariable (
UINT32 Current;
UINT32 Next;
EFI_HOB_GUID_TYPE *GuidHob;
-
- UpdateRequired = FALSE;
+ BOOLEAN MemoryTypeInformationVariableExists;
+
+ UpdateRequired = TRUE;
+ MemoryTypeInformationVariableExists = FALSE;
+
+ if (GetBootModeHob () != BOOT_WITH_DEFAULT_SETTINGS) {
+ VariableSize = 0;
+ Status = gRT->GetVariable (
+ EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME,
+ &gEfiMemoryTypeInformationGuid,
+ NULL,
+ &VariableSize,
+ NULL
+ );
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ MemoryTypeInformationVariableExists = TRUE;
+ UpdateRequired = FALSE;
+ }
+ }
//
// Retrieve the current memory usage statistics. If they are not found, then
@@ -1157,6 +1174,10 @@ BdsSetMemoryTypeInformationVariable (
//
// Use a heuristic to adjust the Memory Type Information for the next boot
//
+ DEBUG ((EFI_D_INFO, "Memory Previous Current Next \n"));
+ DEBUG ((EFI_D_INFO, " Type Pages Pages Pages \n"));
+ DEBUG ((EFI_D_INFO, "====== ======== ======== ========\n"));
+
for (Index = 0; PreviousMemoryTypeInformation[Index].Type != EfiMaxMemoryType; Index++) {
Current = 0;
@@ -1176,7 +1197,9 @@ BdsSetMemoryTypeInformationVariable (
//
// Write next varible to 125% * current and Inconsistent Memory Reserved across bootings may lead to S4 fail
//
- if (Current > Previous) {
+ if (!MemoryTypeInformationVariableExists && Current < Previous) {
+ Next = Current + (Current >> 2);
+ } else if (Current > Previous) {
Next = Current + (Current >> 2);
} else {
Next = Previous;
@@ -1190,12 +1213,13 @@ BdsSetMemoryTypeInformationVariable (
UpdateRequired = TRUE;
}
+ DEBUG ((EFI_D_INFO, " %02x %08x %08x %08x\n", PreviousMemoryTypeInformation[Index].Type, Previous, Current, Next));
}
//
// If any changes were made to the Memory Type Information settings, then set the new variable value
//
- if (UpdateRequired) {
+ if (UpdateRequired || !MemoryTypeInformationVariableExists) {
Status = gRT->SetVariable (
EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME,
&gEfiMemoryTypeInformationGuid,
@@ -1204,8 +1228,6 @@ BdsSetMemoryTypeInformationVariable (
PreviousMemoryTypeInformation
);
}
-
- return;
}
/**
@@ -1231,7 +1253,6 @@ BdsLibSaveMemoryTypeInformation (
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR,"Bds Set Memory Type Informationa Variable Fails\n"));
}
-
}