Add SMBIOS type 19 - memory array mapped address
Current UEFI payload showed 0 KB RAM size in setup screen because of missing SMBIOS memory type information. This patch added SMBIOS type 19 to provide memory array mapped address information. With this change, UEFI setup screen can show correct memory size. Signed-off-by: Maurice Ma <maurice.ma@intel.com>
This commit is contained in:
parent
22ba6209a6
commit
b87d67c1fc
|
@ -46,6 +46,22 @@ GetFspReservedMemoryFromGuid (
|
|||
EFI_GUID *OwnerGuid
|
||||
);
|
||||
|
||||
/**
|
||||
This function retrieves a top of low and high memory address.
|
||||
|
||||
@param HobListPtr A HOB list pointer.
|
||||
@param TopOfHighMem A pointer to receive the top of high memory.
|
||||
|
||||
@retval Top of low memory.
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
GetSystemTopOfMemeory (
|
||||
CONST VOID *HobListPtr,
|
||||
UINT64 *TopOfHighMem OPTIONAL
|
||||
);
|
||||
|
||||
/**
|
||||
This function traverses each memory resource hob type and calls the handler.
|
||||
|
||||
|
|
|
@ -78,6 +78,58 @@ GetFspReservedMemoryFromGuid (
|
|||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
This function retrieves a top of low and high memory address.
|
||||
|
||||
@param HobListPtr A HOB list pointer.
|
||||
@param TopOfHighMem A pointer to receive the top of high memory.
|
||||
|
||||
@retval Top of low memory.
|
||||
|
||||
**/
|
||||
UINT32
|
||||
EFIAPI
|
||||
GetSystemTopOfMemeory (
|
||||
CONST VOID *HobListPtr,
|
||||
UINT64 *TopOfHighMem OPTIONAL
|
||||
)
|
||||
{
|
||||
EFI_PEI_HOB_POINTERS Hob;
|
||||
UINT32 Tolm;
|
||||
UINT64 Tohm;
|
||||
EFI_PHYSICAL_ADDRESS EndAddr;
|
||||
|
||||
// Get the HOB list for processing
|
||||
Hob.Raw = (VOID *)HobListPtr;
|
||||
|
||||
// Collect memory ranges
|
||||
Tolm = 0;
|
||||
Tohm = SIZE_4GB;
|
||||
while (!END_OF_HOB_LIST (Hob)) {
|
||||
if (Hob.Header->HobType == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
|
||||
if (Hob.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) {
|
||||
EndAddr = Hob.ResourceDescriptor->PhysicalStart + Hob.ResourceDescriptor->ResourceLength;
|
||||
if (EndAddr < SIZE_4GB) {
|
||||
if (EndAddr > Tolm) {
|
||||
Tolm = (UINT32) EndAddr;
|
||||
}
|
||||
} else {
|
||||
if (EndAddr > Tohm) {
|
||||
Tohm = EndAddr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Hob.Raw = GET_NEXT_HOB (Hob);
|
||||
}
|
||||
|
||||
if (TopOfHighMem != NULL) {
|
||||
*TopOfHighMem = Tohm;
|
||||
}
|
||||
|
||||
return Tolm;
|
||||
}
|
||||
|
||||
/**
|
||||
This function traverses each memory resource hob type and calls the handler.
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
**/
|
||||
|
||||
#include <PiPei.h>
|
||||
#include <IndustryStandard/SmBios.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/DebugLib.h>
|
||||
|
@ -14,6 +15,7 @@
|
|||
#include <Library/SmbiosInitLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/BootloaderCommonLib.h>
|
||||
#include <Library/FspSupportLib.h>
|
||||
#include "SmbiosTables.h"
|
||||
|
||||
VOID *mType127Ptr = NULL;
|
||||
|
@ -254,7 +256,6 @@ AppendSmbiosType (
|
|||
// After appending, update with Typ127 and patch entry point
|
||||
//
|
||||
Status = FinalizeSmbios (TypeLength);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -451,10 +452,9 @@ InitSmbiosStringPtr (
|
|||
Length = sizeof (mDefaultSmbiosStrings);
|
||||
if(Length <= (PcdGet16(PcdSmbiosStringsCnt) * sizeof (SMBIOS_TYPE_STRINGS))) {
|
||||
CopyMem (SmbiosStringsPtr, mDefaultSmbiosStrings, Length);
|
||||
}
|
||||
else {
|
||||
DEBUG ((DEBUG_INFO, "SmbiosStringsPtr Not Sufficient 0x%x", Length));
|
||||
ASSERT_EFI_ERROR(EFI_OUT_OF_RESOURCES);
|
||||
} else {
|
||||
DEBUG ((DEBUG_INFO, "SmbiosStringsPtr Not Sufficient 0x%x", Length));
|
||||
ASSERT_EFI_ERROR(EFI_OUT_OF_RESOURCES);
|
||||
}
|
||||
//
|
||||
// Initialize SMBIOS String Ptr, Update Length
|
||||
|
@ -463,6 +463,46 @@ InitSmbiosStringPtr (
|
|||
ASSERT_EFI_ERROR (Status);
|
||||
}
|
||||
|
||||
/**
|
||||
This function is called to build some common Smbios types dynamically.
|
||||
|
||||
@retval EFI_SUCCESS SMBIOS type was added successfully.
|
||||
Others Failed to add SMBIOS type.
|
||||
**/
|
||||
STATIC
|
||||
EFI_STATUS
|
||||
BuildCommonSmbiosType (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
SMBIOS_TABLE_TYPE19 SmbiosType19;
|
||||
UINT32 Tolm;
|
||||
UINT64 Tohm;
|
||||
VOID *FspHob;
|
||||
|
||||
// Build memory array mapped address information.
|
||||
FspHob = GetFspHobListPtr ();
|
||||
if (FspHob != NULL) {
|
||||
GetSystemTopOfMemeory (FspHob, &Tohm);
|
||||
} else {
|
||||
Tohm = SIZE_4GB;
|
||||
}
|
||||
Tolm = GetUsableMemoryTop ();
|
||||
SmbiosType19.Hdr.Type = SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS;
|
||||
SmbiosType19.Hdr.Length = sizeof(SMBIOS_TABLE_TYPE19);
|
||||
SmbiosType19.Hdr.Handle = 0;
|
||||
SmbiosType19.StartingAddress = 0xFFFFFFFF;
|
||||
SmbiosType19.EndingAddress = 0xFFFFFFFF;
|
||||
SmbiosType19.MemoryArrayHandle = SMBIOS_HANDLE_PI_RESERVED;
|
||||
SmbiosType19.PartitionWidth = 1;
|
||||
SmbiosType19.ExtendedStartingAddress = 0x0;
|
||||
SmbiosType19.ExtendedEndingAddress = Tolm + (Tohm - SIZE_4GB);
|
||||
Status = AppendSmbiosType (&SmbiosType19, sizeof(SmbiosType19));
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**
|
||||
This function is called to initialize the SMBIOS tables.
|
||||
|
||||
|
@ -513,5 +553,9 @@ SmbiosInit (
|
|||
//
|
||||
Status = FinalizeSmbios (MaxLength);
|
||||
|
||||
if (!EFI_ERROR(Status)) {
|
||||
Status = BuildCommonSmbiosType ();
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue