(TEST) PlatformSmbiosDxe: PlatformSmbiosDxe.c: get memory size and serial number from fdt

This commit is contained in:
BigfootACA 2022-02-10 02:36:32 +08:00
parent 6fc6656b7b
commit 3e996e0dd7
2 changed files with 31 additions and 9 deletions

View File

@ -29,6 +29,7 @@
#include <Library/UefiDriverEntryPoint.h>
#include <Library/UefiLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/FdtParserLib.h>
#include <Protocol/Smbios.h>
/***********************************************************************
@ -843,8 +844,8 @@ SMBIOS_TABLE_TYPE19 mMemArrMapInfoType19 = {
0, // MemoryArrayHandle; // Should match SMBIOS_TABLE_TYPE16.Handle,
// initialized at runtime, refer to PhyMemArrayInfoUpdateSmbiosType16()
1, // PartitionWidth;
0x080000000, // ExtendedStartingAddress; // not used
0x100000000, // ExtendedEndingAddress; // not used
0, // ExtendedStartingAddress; // not used
0, // ExtendedEndingAddress; // not used
};
CHAR8 *mMemArrMapInfoType19Strings[] = {NULL};
@ -971,6 +972,14 @@ PlatformSmbiosDriverEntryPoint(
IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
{
EFI_SMBIOS_HANDLE SmbiosHandle;
UINTN Node = 0;
UINTN MemoryBase = 0;
UINTN MemorySize = 0;
VOID *Fdt;
CHAR8 *Serial;
Fdt = GetFdt ();
ASSERT(Fdt != NULL);
// TYPE0 BIOS Information
AsciiSPrint(
@ -989,6 +998,14 @@ PlatformSmbiosDriverEntryPoint(
AsciiStrCpyS(
mSysInfoVersionName, sizeof(mSysInfoVersionName),
(CHAR8 *)PcdGetPtr(PcdDeviceCodeName));
Serial = param_get_android_serial_number (fdt_get_cmdline_items (Fdt, NULL));
if (Serial != NULL) {
DEBUG((EFI_D_INFO, "Android Serial Number: %a\n", Serial));
ZeroMem(mSysInfoSerial, sizeof(mSysInfoSerial));
AsciiStrCpyS(
mSysInfoSerial, sizeof(mSysInfoSerial),
Serial);
}
LogSmbiosData(
(EFI_SMBIOS_TABLE_HEADER *)&mSysInfoType1, mSysInfoType1Strings, NULL);
@ -1071,12 +1088,15 @@ PlatformSmbiosDriverEntryPoint(
NULL);
// TYPE19 Memory Array Map Information
mMemArrMapInfoType19.ExtendedStartingAddress = PcdGet64(PcdSystemMemoryBase);
mMemArrMapInfoType19.ExtendedEndingAddress =
PcdGet64(PcdSystemMemoryBase) + PcdGet64(PcdSystemMemorySize);
LogSmbiosData(
(EFI_SMBIOS_TABLE_HEADER *)&mMemArrMapInfoType19,
mMemArrMapInfoType19Strings, NULL);
while (fdt_get_memory(Fdt, (int)Node, (uint64_t*)&MemoryBase, (uint64_t*)&MemorySize)) {
mMemArrMapInfoType19.StartingAddress = MemoryBase;
mMemArrMapInfoType19.EndingAddress = MemorySize;
LogSmbiosData(
(EFI_SMBIOS_TABLE_HEADER *)&mMemArrMapInfoType19,
mMemArrMapInfoType19Strings, NULL);
Node++;
}
// TYPE32 Boot Information
LogSmbiosData(

View File

@ -29,6 +29,7 @@
ArmPkg/ArmPkg.dec
EmbeddedPkg/EmbeddedPkg.dec
sdm845Pkg/sdm845Pkg.dec
SimpleInit.dec
[LibraryClasses]
ArmLib
@ -41,18 +42,19 @@
DebugLib
PrintLib
TimeBaseLib
SimpleInitLib
[Guids]
gEfiGlobalVariableGuid
[FixedPcd]
gArmTokenSpaceGuid.PcdSystemMemoryBase
gArmTokenSpaceGuid.PcdSystemMemorySize
gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareRevision
gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString
gsdm845PkgTokenSpaceGuid.PcdDeviceVendor
gsdm845PkgTokenSpaceGuid.PcdDeviceProduct
gsdm845PkgTokenSpaceGuid.PcdDeviceCodeName
gsdm845PkgTokenSpaceGuid.DeviceTreeStore
[Protocols]
gEfiSmbiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED