Jeremy,
On 2016/2/19 5:07, Jeremy Linton wrote:
Update the BDS frontpage to pull the RAM ranges from the
smbios extended size fields when applicable. The RAM calculation
also needs to take into account all the RAM ranges being provided
as many machines have multiple physical address ranges.
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeremy Linton <[email protected]>
---
.../Universal/BdsDxe/FrontPage.c | 45 +++++++++++-----------
1 file changed, 23 insertions(+), 22 deletions(-)
diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c
b/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c
index 0a9238c..451eeac 100644
--- a/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c
+++ b/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c
@@ -720,7 +720,6 @@ UpdateFrontPageStrings (
{
UINT8 StrIndex;
CHAR16 *NewString;
- BOOLEAN Find[5];
EFI_STATUS Status;
EFI_STRING_ID TokenToUpdate;
EFI_SMBIOS_HANDLE SmbiosHandle;
@@ -730,8 +729,9 @@ UpdateFrontPageStrings (
SMBIOS_TABLE_TYPE4 *Type4Record;
SMBIOS_TABLE_TYPE19 *Type19Record;
EFI_SMBIOS_TABLE_HEADER *Record;
-
- ZeroMem (Find, sizeof (Find));
+ UINT64 InstalledMemory;
+
+ InstalledMemory=0;
//
// Update Front Page strings
@@ -743,12 +743,8 @@ UpdateFrontPageStrings (
);
if (!EFI_ERROR (Status)) {
SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
- do {
- Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
- if (EFI_ERROR(Status)) {
- break;
- }
-
+ Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
+ while (!EFI_ERROR(Status)) {
if (Record->Type == EFI_SMBIOS_TYPE_BIOS_INFORMATION) {
Type0Record = (SMBIOS_TABLE_TYPE0 *) Record;
StrIndex = Type0Record->BiosVersion;
@@ -756,7 +752,6 @@ UpdateFrontPageStrings (
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION);
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString,
NULL);
FreePool (NewString);
- Find[0] = TRUE;
}
if (Record->Type == EFI_SMBIOS_TYPE_SYSTEM_INFORMATION) {
@@ -766,7 +761,6 @@ UpdateFrontPageStrings (
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL);
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString,
NULL);
FreePool (NewString);
- Find[1] = TRUE;
}
if (Record->Type == EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION) {
@@ -776,7 +770,6 @@ UpdateFrontPageStrings (
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL);
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString,
NULL);
FreePool (NewString);
- Find[2] = TRUE;
}
if (Record->Type == EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION) {
@@ -785,22 +778,30 @@ UpdateFrontPageStrings (
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED);
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString,
NULL);
FreePool (NewString);
- Find[3] = TRUE;
}
if ( Record->Type == EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS ) {
Type19Record = (SMBIOS_TABLE_TYPE19 *) Record;
- ConvertMemorySizeToString (
- (UINT32)(RShiftU64((Type19Record->EndingAddress -
Type19Record->StartingAddress + 1), 10)),
- &NewString
- );
- TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE);
- HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString,
NULL);
- FreePool (NewString);
- Find[4] = TRUE;
+ if (Type19Record->StartingAddress != 0xFFFFFFFF ) {
+ InstalledMemory += Type19Record->EndingAddress -
+ Type19Record->StartingAddress;
According to SMBIOS spec, the EndingAddress is Physical ending address
of the *last kilobyte*, and the unit is kilobyte. So the code should be
InstalledMemory += RShiftU64((Type19Record->EndingAddress -
Type19Record->StartingAddress + 1), 10);
+ } else {
+ InstalledMemory += Type19Record->ExtendedEndingAddress -
+ Type19Record->ExtendedStartingAddress;
According to SMBIOS spec, the ExtendedEndingAddress is Physical ending
address, in bytes. So similar with above, the code should be
InstalledMemory +=
RShiftU64((Type19Record->ExtendedEndingAddress -
Type19Record->ExtendedStartingAddress + 1), 20);
+ }
}
- } while ( !(Find[0] && Find[1] && Find[2] && Find[3] && Find[4]));
+
+ Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
+ }
+
+ // now update the total installed RAM size
+ InstalledMemory >>= 20;
Remove this code line and comments since the installed memory has been
translated to XXX MB above. In fact, directly >= operation with 64 bits
operand at 32 bits build will involve intrinsic function of compiler
that may cause build failure (at lease for IA32), RShiftU64() could be used.
+ ConvertMemorySizeToString ((UINT32)InstalledMemory, &NewString );
+ TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE);
+ HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, NewString, NULL);
+ FreePool (NewString);
}
+
return ;
}
More generic comments below.
1. Could you remove the trailing white space for new added code lines?
2. Could you sync the change to
MdeModulePkg/Application/UiApp/FrontPage.c after this patch finalized?
Thanks,
Star
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel