summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>2011-07-06 03:23:15 +0000
committerniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>2011-07-06 03:23:15 +0000
commita97a859621e2f480b4cd12e32162ac60305ede22 (patch)
tree86fe786f20ea111faf38fbeb8c8609cab6a230f9
parentc3342aa81fabe01d70520a987bd15b018eb117ce (diff)
downloadedk2-platforms-a97a859621e2f480b4cd12e32162ac60305ede22.tar.xz
Enhance BDS to avoid the additional reset when the platform pre-allocated memory is large enough.
Signed-off-by: niruiyu Reviewed-by: mdkinney Reviewed-by: lgao4 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11983 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c
index bd0a5f4237..68ddfc334f 100644
--- a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c
+++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsMisc.c
@@ -1,7 +1,7 @@
/** @file
Misc BDS library function
-Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -1096,8 +1096,10 @@ BdsLibGetImageHeader (
}
/**
- This routine adjust the memory information for different memory type and
- save them into the variables for next boot.
+ This routine adjusts the memory information for different memory type and
+ saves them into the variables for next boot. It conditionally resets the
+ system when the memory information changes. Platform can reserve memory
+ large enough (125% of actual requirement) to avoid the reset in the first boot.
**/
VOID
BdsSetMemoryTypeInformationVariable (
@@ -1131,7 +1133,7 @@ BdsSetMemoryTypeInformationVariable (
}
//
- // Only get the the Memory Type Information variable in the boot mode
+ // Only check the the Memory Type Information variable in the boot mode
// other than BOOT_WITH_DEFAULT_SETTINGS because the Memory Type
// Information is not valid in this boot mode.
//
@@ -1185,29 +1187,34 @@ BdsSetMemoryTypeInformationVariable (
for (Index = 0; PreviousMemoryTypeInformation[Index].Type != EfiMaxMemoryType; Index++) {
- Current = 0;
for (Index1 = 0; CurrentMemoryTypeInformation[Index1].Type != EfiMaxMemoryType; Index1++) {
if (PreviousMemoryTypeInformation[Index].Type == CurrentMemoryTypeInformation[Index1].Type) {
- Current = CurrentMemoryTypeInformation[Index1].NumberOfPages;
break;
}
}
-
if (CurrentMemoryTypeInformation[Index1].Type == EfiMaxMemoryType) {
continue;
}
+ //
+ // Previous is the number of pages pre-allocated
+ // Current is the number of pages actually needed
+ //
Previous = PreviousMemoryTypeInformation[Index].NumberOfPages;
+ Current = CurrentMemoryTypeInformation[Index1].NumberOfPages;
+ Next = Previous;
//
// Write next varible to 125% * current and Inconsistent Memory Reserved across bootings may lead to S4 fail
//
- if (!MemoryTypeInformationVariableExists && Current < Previous) {
- Next = Current + (Current >> 2);
+ if (Current < Previous) {
+ if (BootMode == BOOT_WITH_DEFAULT_SETTINGS) {
+ Next = Current + (Current >> 2);
+ } else if (!MemoryTypeInformationVariableExists) {
+ Next = MAX (Current + (Current >> 2), Previous);
+ }
} else if (Current > Previous) {
Next = Current + (Current >> 2);
- } else {
- Next = Previous;
}
if (Next > 0 && Next < 4) {
Next = 4;