SMBIOS Implementation - Adding SMBIOS Default Table.

- Default SMBIOS Table initialized when SMBIOS is enabled.
- If required, Every Platform can override platform specific information.
- Enable SMBIOS in Qemu platform.
- Update Memory allocation for SmbiosStringsPtr for 32 entries.

Signed-off-by: Sm NARAYANAN <s.m.narayanan@intel.com>
This commit is contained in:
Sm NARAYANAN 2020-05-18 17:06:22 +05:30 committed by Guo Dong
parent e0c4326b81
commit 64f27c41c3
5 changed files with 93 additions and 2 deletions

View File

@ -279,7 +279,7 @@
gPlatformModuleTokenSpaceGuid.PcdSmbiosTablesBase | 0x00000000
gPlatformModuleTokenSpaceGuid.PcdSmbiosStringsPtr | 0x00000000
gPlatformModuleTokenSpaceGuid.PcdSmbiosStringsCnt | 0x0000
gPlatformModuleTokenSpaceGuid.PcdSmbiosStringsCnt | 0x40
gPlatformModuleTokenSpaceGuid.PcdFuncCpuInitHook | 0x00000000
[PcdsFeatureFlag]

View File

@ -53,6 +53,15 @@ AppendSmbiosType (
IN UINT16 TypeLength
);
/**
This function is called to initialize the SmbiosStringsPtr.
**/
VOID
EFIAPI
InitSmbiosStringPtr (
VOID
);
/**
This function is called to initialize the SMBIOS tables.
@ -66,5 +75,4 @@ SmbiosInit (
VOID
);
#endif

View File

@ -18,6 +18,37 @@
VOID *mType127Ptr = NULL;
#define SMBIOS_STRING_UNKNOWN "Unknown"
#define SMBIOS_STRING_UNKNOWN_VERSION "XXXX.XXX.XXX.XXX"
#define SMBIOS_STRING_VENDOR "Intel Corporation"
#define SMBIOS_STRING_PLATFORM "Client Platform"
//
// Add more platform specific strings
// in the following format
//
CONST SMBIOS_TYPE_STRINGS mDefaultSmbiosStrings[] = {
// Type StrId String
// Type 0
{ SMBIOS_TYPE_BIOS_INFORMATION , 1, SMBIOS_STRING_VENDOR }, // Vendor
{ SMBIOS_TYPE_BIOS_INFORMATION , 2, SMBIOS_STRING_UNKNOWN_VERSION }, // BIOS Version
{ SMBIOS_TYPE_BIOS_INFORMATION , 3, SMBIOS_STRING_UNKNOWN }, // BIOS Release Date
// Type 1
{ SMBIOS_TYPE_SYSTEM_INFORMATION , 1, SMBIOS_STRING_VENDOR }, // Manufacturer
{ SMBIOS_TYPE_SYSTEM_INFORMATION , 2, SMBIOS_STRING_UNKNOWN }, // Product Name
{ SMBIOS_TYPE_SYSTEM_INFORMATION , 3, SMBIOS_STRING_UNKNOWN_VERSION }, // Version
{ SMBIOS_TYPE_SYSTEM_INFORMATION , 4, SMBIOS_STRING_UNKNOWN }, // Serial Number
{ SMBIOS_TYPE_SYSTEM_INFORMATION , 5, SMBIOS_STRING_UNKNOWN }, // SKU Variant
{ SMBIOS_TYPE_SYSTEM_INFORMATION , 6, SMBIOS_STRING_PLATFORM }, // Serial Number
// Type 2
{ SMBIOS_TYPE_BASEBOARD_INFORMATION , 1, SMBIOS_STRING_UNKNOWN }, // Manufacturer
{ SMBIOS_TYPE_BASEBOARD_INFORMATION , 2, SMBIOS_STRING_UNKNOWN }, // Product Name
{ SMBIOS_TYPE_BASEBOARD_INFORMATION , 3, SMBIOS_STRING_UNKNOWN_VERSION }, // Version
{ SMBIOS_TYPE_BASEBOARD_INFORMATION , 4, SMBIOS_STRING_UNKNOWN }, // Serial Number
// Type 127 - End of strings
{ SMBIOS_TYPE_END_OF_TABLE, 0, "" }
};
/**
Check if the Smbios types (including the entry point struct)
have crossed the statically allocated size for Smbios init
@ -248,6 +279,9 @@ GetSmbiosString (
}
for (Index = 0; Index < PcdGet16 (PcdSmbiosStringsCnt); ++Index) {
if (SmbiosStrings[Index].Type == SMBIOS_TYPE_END_OF_TABLE) {
return "Unknown";
}
if (Type == SmbiosStrings[Index].Type && StringId == SmbiosStrings[Index].Idx) {
if (SmbiosStrings[Index].String != NULL && AsciiStrLen (SmbiosStrings[Index].String) != 0) {
return SmbiosStrings[Index].String;
@ -375,6 +409,49 @@ AddSmbiosType (
}
/**
This function is called to initialize the SmbiosStringsPtr.
**/
VOID
EFIAPI
InitSmbiosStringPtr (
VOID
)
{
EFI_STATUS Status;
UINT16 Length;
VOID *SmbiosStringsPtr;
//
// Allocate the memmory for SMBIOS String Ptr,
//
SmbiosStringsPtr = AllocateZeroPool (PcdGet16(PcdSmbiosStringsCnt) * sizeof (SMBIOS_TYPE_STRINGS));
if (SmbiosStringsPtr == NULL) {
DEBUG ((DEBUG_INFO, "SmbiosStringsPtr Memory allocation failed"));
ASSERT_EFI_ERROR(EFI_OUT_OF_RESOURCES);
}
//
// Copy contents from Default String Array
//
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);
}
//
// Initialize SMBIOS String Ptr, Update Length
//
Status = PcdSet32S (PcdSmbiosStringsPtr, (UINT32)(UINTN)SmbiosStringsPtr);
ASSERT_EFI_ERROR (Status);
}
/**
This function is called to initialize the SMBIOS tables.

View File

@ -391,6 +391,10 @@ SecStartup (
FspResetHandler (Status);
ASSERT_EFI_ERROR (Status);
if (FixedPcdGetBool (PcdSmbiosEnabled)) {
InitSmbiosStringPtr ();
}
BoardInit (PostSiliconInit);
AddMeasurePoint (0x3040);

View File

@ -60,6 +60,8 @@ class Board(BaseBoard):
self.ENABLE_LINUX_PAYLOAD = 1
self.ENABLE_CRYPTO_SHA_OPT = 0
self.ENABLE_SMBIOS = 1
self.CPU_MAX_LOGICAL_PROCESSOR_NUMBER = 255
# To enable source debug, set 1 to self.ENABLE_SOURCE_DEBUG