From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web08.23865.1621866521176803399 for ; Mon, 24 May 2021 07:28:41 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: pranav.madhu@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C0D61139F; Mon, 24 May 2021 07:28:40 -0700 (PDT) Received: from usa.arm.com (a074742.blr.arm.com [10.162.16.32]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 96F843F719; Mon, 24 May 2021 07:28:39 -0700 (PDT) From: "Pranav Madhu" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Sami Mujawar Subject: [edk2-platforms][PATCH V4 08/11] Platform/Sgi: Add SMBIOS Type16 Table Date: Mon, 24 May 2021 19:58:13 +0530 Message-Id: <20210524142816.9967-9-pranav.madhu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210524142816.9967-1-pranav.madhu@arm.com> References: <20210524142816.9967-1-pranav.madhu@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Add the SMBIOS type 16 table (Physical Memory Array) describes a collection of memory devices that operate together to form a memory address. It includes information about number of devices, total memory installed, error correction mechanism used and other related information. Signed-off-by: Pranav Madhu Reviewed-by: Sami Mujawar --- Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf = | 4 + Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h = | 19 ++++ Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c = | 1 + Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type16PhysicalMemoryArray.= c | 106 ++++++++++++++++++++ 4 files changed, 130 insertions(+) diff --git a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatform= Dxe.inf b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe= .inf index ee00b773912b..ebd19c1882bb 100644 --- a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf +++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf @@ -20,6 +20,7 @@ Type3SystemEnclosure.c Type4ProcessorInformation.c Type7CacheInformation.c + Type16PhysicalMemoryArray.c =20 [Packages] ArmPkg/ArmPkg.dec @@ -44,6 +45,9 @@ gArmPlatformTokenSpaceGuid.PcdClusterCount gArmPlatformTokenSpaceGuid.PcdCoreCount gArmSgiTokenSpaceGuid.PcdChipCount + gArmSgiTokenSpaceGuid.PcdDramBlock2Size + gArmTokenSpaceGuid.PcdSystemMemoryBase + gArmTokenSpaceGuid.PcdSystemMemorySize gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareRevision =20 [Protocols] diff --git a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatform= Dxe.h b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h index 43f35ea0518f..95bb2c4bfc70 100644 --- a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h +++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h @@ -104,6 +104,24 @@ InstallType7CacheInformation ( IN EFI_SMBIOS_PROTOCOL *Smbios ); =20 +/** + Install SMBIOS physical memory array table. + + Install the SMBIOS physical memory array (type 16) table for Arm's Ref= erence + Design platforms. + + @param[in] Smbios SMBIOS protocol. + + @retval EFI_SUCCESS Record was added. + @retval EFI_OUT_OF_RESOURCES Record was not added. + @retval EFI_ALREADY_STARTED The SmbiosHandle passed is already in us= e. +**/ +EFI_STATUS +EFIAPI +InstallType16PhysicalMemoryArray ( + IN EFI_SMBIOS_PROTOCOL *Smbios + ); + typedef enum { SMBIOS_HANDLE_ENCLOSURE =3D 0x1000, SMBIOS_HANDLE_CLUSTER1, @@ -112,6 +130,7 @@ typedef enum { SMBIOS_HANDLE_L2_CACHE, SMBIOS_HANDLE_L3_CACHE, SMBIOS_HANDLE_L4_CACHE, + SMBIOS_HANDLE_PHYSICAL_MEMORY, } SMBIOS_REFRENCE_HANDLES; =20 #endif // SMBIOS_PLATFORM_DXE_H_ diff --git a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatform= Dxe.c b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c index d3b161b77550..4f14be165c94 100644 --- a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c +++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c @@ -31,6 +31,7 @@ ARM_RD_SMBIOS_TABLE_INSTALL_FPTR mSmbiosTableList[] =3D= { &InstallType3SystemEnclosure, &InstallType4ProcessorInformation, &InstallType7CacheInformation, + &InstallType16PhysicalMemoryArray, }; =20 /** diff --git a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type16Physical= MemoryArray.c b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type16Physi= calMemoryArray.c new file mode 100644 index 000000000000..b1b41bf405a2 --- /dev/null +++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type16PhysicalMemoryA= rray.c @@ -0,0 +1,106 @@ +/** @file + SMBIOS Type 16 (Physical Memory Array) table for ARM RD platforms. + + This file installs SMBIOS Type 16 (Physical Memory Array) table for Ar= m's + Reference Design platforms. It describes a collection of memory device= s that + operate together to form a memory address. It includes information abo= ut + number of devices, total memory installed, error correction mechanism = used + and other related information. + + Copyright (c) 2021, ARM Limited. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Specification Reference: + - SMBIOS Reference Specification 3.4.0, Chapter 7.17 +**/ + +#include +#include +#include + +#include "SmbiosPlatformDxe.h" + +#define TYPE16_STRINGS \ + "\0" /* Null string */ + +/* SMBIOS Type16 structure */ +#pragma pack(1) +typedef struct { + SMBIOS_TABLE_TYPE16 Base; + CHAR8 Strings[sizeof (TYPE16_STRINGS)]; +} ARM_RD_SMBIOS_TYPE16; +#pragma pack() + +/* Physical Memory Array */ +STATIC ARM_RD_SMBIOS_TYPE16 mArmRdSmbiosType16 =3D { + { + { + // SMBIOS header + EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY, // Type 16 + sizeof (SMBIOS_TABLE_TYPE16), // Length + SMBIOS_HANDLE_PHYSICAL_MEMORY + }, + MemoryArrayLocationSystemBoard, // Location + MemoryArrayUseSystemMemory, // Used as system memory + MemoryErrorCorrectionUnknown, // Error correction + 0x80000000, // Maximum capacity in KiB, uses Extended Maximum capaci= ty field + 0xFFFE, // Memory error info handle, does not provide this info + 0, // Num of memory devices, update dymamically + 0 // Extended Maximum capacity, update dymamically + }, + // Text strings (unformatted area) + TYPE16_STRINGS +}; + +/** + Install SMBIOS physical memory array table. + + Install the SMBIOS physical memory array (type 16) table for Arm's Ref= erence + Design platforms. + + @param[in] Smbios SMBIOS protocol. + + @retval EFI_SUCCESS Record was added. + @retval EFI_OUT_OF_RESOURCES Record was not added. + @retval EFI_ALREADY_STARTED The SmbiosHandle passed is already in us= e. +**/ +EFI_STATUS +InstallType16PhysicalMemoryArray ( + IN EFI_SMBIOS_PROTOCOL *Smbios + ) +{ + EFI_STATUS Status; + EFI_SMBIOS_HANDLE SmbiosHandle; + UINT16 NumOfMemoryDevices =3D 1; + UINT64 InstalledMemory; + + SmbiosHandle =3D ((EFI_SMBIOS_TABLE_HEADER *)&mArmRdSmbiosType16)->Han= dle; + + /* Include 16MB of Trusted DRAM as well */ + InstalledMemory =3D PcdGet64 (PcdSystemMemorySize) + SIZE_16MB; + if (PcdGet64 (PcdDramBlock2Size) !=3D 0) { + NumOfMemoryDevices++; + InstalledMemory +=3D PcdGet64 (PcdDramBlock2Size); + } + + mArmRdSmbiosType16.Base.ExtendedMaximumCapacity =3D + InstalledMemory * FixedPcdGet32 (PcdChipCount); + mArmRdSmbiosType16.Base.NumberOfMemoryDevices =3D + NumOfMemoryDevices * FixedPcdGet32 (PcdChipCount); + + /* Install type 16 table */ + Status =3D Smbios->Add ( + Smbios, + NULL, + &SmbiosHandle, + (EFI_SMBIOS_TABLE_HEADER *)&mArmRdSmbiosType16 + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "SMBIOS: Failed to install Type16 SMBIOS table.\n" + )); + } + + return Status; +} --=20 2.17.1