(TEST) PlatformSmbiosDxe: PlatformSmbiosDxe.c: get memory size and serial number...
authorBigfootACA <bigfoot@classfun.cn>
星期三, 9 Feb 2022 18:36:32 +0000 (02:36 +0800)
committerBigfootACA <bigfoot@classfun.cn>
星期四, 10 Feb 2022 08:45:00 +0000 (16:45 +0800)
sdm845Pkg/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c
sdm845Pkg/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf

index 434df15fc559781d4dc0a713fe042e0301d1c8f0..c191fa1834ad83018580911b91cb581a12a32857 100644 (file)
@@ -29,6 +29,7 @@
 #include <Library/UefiDriverEntryPoint.h>\r
 #include <Library/UefiLib.h>\r
 #include <Library/UefiRuntimeServicesTableLib.h>\r
+#include <Library/FdtParserLib.h>\r
 #include <Protocol/Smbios.h>\r
 \r
 /***********************************************************************\r
@@ -843,8 +844,8 @@ SMBIOS_TABLE_TYPE19 mMemArrMapInfoType19 = {
     0, // MemoryArrayHandle; // Should match SMBIOS_TABLE_TYPE16.Handle,\r
        // initialized at runtime, refer to PhyMemArrayInfoUpdateSmbiosType16()\r
     1, // PartitionWidth;\r
-    0x080000000, // ExtendedStartingAddress;  // not used\r
-    0x100000000, // ExtendedEndingAddress;    // not used\r
+    0, // ExtendedStartingAddress;  // not used\r
+    0, // ExtendedEndingAddress;    // not used\r
 };\r
 CHAR8 *mMemArrMapInfoType19Strings[] = {NULL};\r
 \r
@@ -971,6 +972,14 @@ PlatformSmbiosDriverEntryPoint(
     IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)\r
 {\r
   EFI_SMBIOS_HANDLE SmbiosHandle;\r
+  UINTN Node = 0;\r
+  UINTN MemoryBase = 0;\r
+  UINTN MemorySize = 0;\r
+  VOID *Fdt;\r
+  CHAR8 *Serial;\r
+\r
+  Fdt = GetFdt ();\r
+  ASSERT(Fdt != NULL);\r
 \r
   // TYPE0 BIOS Information\r
   AsciiSPrint(\r
@@ -989,6 +998,14 @@ PlatformSmbiosDriverEntryPoint(
   AsciiStrCpyS(\r
       mSysInfoVersionName, sizeof(mSysInfoVersionName),\r
       (CHAR8 *)PcdGetPtr(PcdDeviceCodeName));\r
+  Serial = param_get_android_serial_number (fdt_get_cmdline_items (Fdt, NULL));\r
+  if (Serial != NULL) {\r
+    DEBUG((EFI_D_INFO, "Android Serial Number: %a\n", Serial));\r
+    ZeroMem(mSysInfoSerial, sizeof(mSysInfoSerial));\r
+    AsciiStrCpyS(\r
+        mSysInfoSerial, sizeof(mSysInfoSerial),\r
+        Serial);\r
+  }\r
   LogSmbiosData(\r
       (EFI_SMBIOS_TABLE_HEADER *)&mSysInfoType1, mSysInfoType1Strings, NULL);\r
 \r
@@ -1071,12 +1088,15 @@ PlatformSmbiosDriverEntryPoint(
       NULL);\r
 \r
   // TYPE19 Memory Array Map Information\r
-  mMemArrMapInfoType19.ExtendedStartingAddress = PcdGet64(PcdSystemMemoryBase);\r
-  mMemArrMapInfoType19.ExtendedEndingAddress =\r
-      PcdGet64(PcdSystemMemoryBase) + PcdGet64(PcdSystemMemorySize);\r
-  LogSmbiosData(\r
-      (EFI_SMBIOS_TABLE_HEADER *)&mMemArrMapInfoType19,\r
-      mMemArrMapInfoType19Strings, NULL);\r
+\r
+  while (fdt_get_memory(Fdt, (int)Node, (uint64_t*)&MemoryBase, (uint64_t*)&MemorySize)) {\r
+    mMemArrMapInfoType19.StartingAddress = MemoryBase;\r
+    mMemArrMapInfoType19.EndingAddress = MemorySize;\r
+    LogSmbiosData(\r
+        (EFI_SMBIOS_TABLE_HEADER *)&mMemArrMapInfoType19,\r
+        mMemArrMapInfoType19Strings, NULL);\r
+    Node++;\r
+  }\r
 \r
   // TYPE32 Boot Information\r
   LogSmbiosData(\r
index 27d7e03f5cf7aebfe313696dea59844564c38c28..cf4d0142ba56eadb669628223d80bac3f772dadc 100644 (file)
@@ -29,6 +29,7 @@
   ArmPkg/ArmPkg.dec\r
   EmbeddedPkg/EmbeddedPkg.dec\r
   sdm845Pkg/sdm845Pkg.dec\r
+  SimpleInit.dec\r
 \r
 [LibraryClasses]\r
   ArmLib\r
   DebugLib\r
   PrintLib\r
   TimeBaseLib\r
+  SimpleInitLib\r
 \r
 [Guids]\r
   gEfiGlobalVariableGuid\r
 \r
 [FixedPcd]\r
   gArmTokenSpaceGuid.PcdSystemMemoryBase\r
-  gArmTokenSpaceGuid.PcdSystemMemorySize\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareRevision\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString\r
   gsdm845PkgTokenSpaceGuid.PcdDeviceVendor\r
   gsdm845PkgTokenSpaceGuid.PcdDeviceProduct\r
   gsdm845PkgTokenSpaceGuid.PcdDeviceCodeName\r
+  gsdm845PkgTokenSpaceGuid.DeviceTreeStore\r
 \r
 [Protocols]\r
   gEfiSmbiosProtocolGuid                      # PROTOCOL ALWAYS_CONSUMED\r