mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-30 00:54:06 +02:00
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
This commit is contained in:
parent
2345e7d4a4
commit
a4e9b4f6e3
@ -1124,8 +1124,25 @@ BdsSetMemoryTypeInformationVariable (
|
|||||||
UINT32 Current;
|
UINT32 Current;
|
||||||
UINT32 Next;
|
UINT32 Next;
|
||||||
EFI_HOB_GUID_TYPE *GuidHob;
|
EFI_HOB_GUID_TYPE *GuidHob;
|
||||||
|
BOOLEAN MemoryTypeInformationVariableExists;
|
||||||
|
|
||||||
UpdateRequired = FALSE;
|
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
|
// 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
|
// 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++) {
|
for (Index = 0; PreviousMemoryTypeInformation[Index].Type != EfiMaxMemoryType; Index++) {
|
||||||
|
|
||||||
Current = 0;
|
Current = 0;
|
||||||
@ -1176,7 +1197,9 @@ BdsSetMemoryTypeInformationVariable (
|
|||||||
//
|
//
|
||||||
// Write next varible to 125% * current and Inconsistent Memory Reserved across bootings may lead to S4 fail
|
// 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);
|
Next = Current + (Current >> 2);
|
||||||
} else {
|
} else {
|
||||||
Next = Previous;
|
Next = Previous;
|
||||||
@ -1190,12 +1213,13 @@ BdsSetMemoryTypeInformationVariable (
|
|||||||
UpdateRequired = TRUE;
|
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 any changes were made to the Memory Type Information settings, then set the new variable value
|
||||||
//
|
//
|
||||||
if (UpdateRequired) {
|
if (UpdateRequired || !MemoryTypeInformationVariableExists) {
|
||||||
Status = gRT->SetVariable (
|
Status = gRT->SetVariable (
|
||||||
EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME,
|
EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME,
|
||||||
&gEfiMemoryTypeInformationGuid,
|
&gEfiMemoryTypeInformationGuid,
|
||||||
@ -1204,8 +1228,6 @@ BdsSetMemoryTypeInformationVariable (
|
|||||||
PreviousMemoryTypeInformation
|
PreviousMemoryTypeInformation
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1231,7 +1253,6 @@ BdsLibSaveMemoryTypeInformation (
|
|||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR,"Bds Set Memory Type Informationa Variable Fails\n"));
|
DEBUG ((DEBUG_ERROR,"Bds Set Memory Type Informationa Variable Fails\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user