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.web09.36.1621355650703880906 for ; Tue, 18 May 2021 09:34:10 -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 62FB76D; Tue, 18 May 2021 09:34:10 -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 3946D3F73B; Tue, 18 May 2021 09:34:09 -0700 (PDT) From: "Pranav Madhu" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Sami Mujawar Subject: [edk2-platforms][PATCH V3 09/11] Platform/Sgi: Add SMBIOS Type17 Table Date: Tue, 18 May 2021 22:03:46 +0530 Message-Id: <20210518163348.16618-10-pranav.madhu@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210518163348.16618-1-pranav.madhu@arm.com> References: <20210518163348.16618-1-pranav.madhu@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Add the SMBIOS type 17 table (Memory Device) that includes the specification of each installed memory device such as size of each device, bank locator, memory device type, and other related information. Signed-off-by: Pranav Madhu Reviewed-by: Sami Mujawar --- Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf | = 1 + Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h | 2= 6 ++ Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c | = 1 + Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type17MemoryDevice.c | 29= 8 ++++++++++++++++++++ 4 files changed, 326 insertions(+) diff --git a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatform= Dxe.inf b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe= .inf index ebd19c1882bb..9061c491d461 100644 --- a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf +++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf @@ -21,6 +21,7 @@ Type4ProcessorInformation.c Type7CacheInformation.c Type16PhysicalMemoryArray.c + Type17MemoryDevice.c =20 [Packages] ArmPkg/ArmPkg.dec diff --git a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatform= Dxe.h b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h index 95bb2c4bfc70..4e663033d515 100644 --- a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h +++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h @@ -122,6 +122,24 @@ InstallType16PhysicalMemoryArray ( IN EFI_SMBIOS_PROTOCOL *Smbios ); =20 + +/** + Install SMBIOS memory device table. + + Install the SMBIOS memory device (type 17) table for RD 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 +InstallType17MemoryDevice ( + IN EFI_SMBIOS_PROTOCOL *Smbios + ); + typedef enum { SMBIOS_HANDLE_ENCLOSURE =3D 0x1000, SMBIOS_HANDLE_CLUSTER1, @@ -131,6 +149,14 @@ typedef enum { SMBIOS_HANDLE_L3_CACHE, SMBIOS_HANDLE_L4_CACHE, SMBIOS_HANDLE_PHYSICAL_MEMORY, + SMBIOS_HANDLE_MEMORY_DEVICE0000, // Chip 0 Bank 0 + SMBIOS_HANDLE_MEMORY_DEVICE0001, // Chip 0 Bank 1 + SMBIOS_HANDLE_MEMORY_DEVICE0100, // Chip 1 Bank 0 + SMBIOS_HANDLE_MEMORY_DEVICE0101, // Chip 1 Bank 1 + SMBIOS_HANDLE_MEMORY_DEVICE0200, // Chip 2 Bank 0 + SMBIOS_HANDLE_MEMORY_DEVICE0201, // Chip 2 Bank 1 + SMBIOS_HANDLE_MEMORY_DEVICE0300, // Chip 3 Bank 0 + SMBIOS_HANDLE_MEMORY_DEVICE0301, // Chip 3 Bank 1 } 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 4f14be165c94..4e6a6b250813 100644 --- a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c +++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c @@ -32,6 +32,7 @@ ARM_RD_SMBIOS_TABLE_INSTALL_FPTR mSmbiosTableList[] =3D= { &InstallType4ProcessorInformation, &InstallType7CacheInformation, &InstallType16PhysicalMemoryArray, + &InstallType17MemoryDevice, }; =20 /** diff --git a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type17MemoryDe= vice.c b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type17MemoryDevice= .c new file mode 100644 index 000000000000..7ed004bc7f15 --- /dev/null +++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type17MemoryDevice.c @@ -0,0 +1,298 @@ +/** @file + SMBIOS Type 17 (Memory Device) table for ARM RD platforms. + + This file installs SMBIOS Type 17 (Memory Device) table for Arm's Refe= rence + Design platforms. It includes the specification of each installed memo= ry + device such as size of each device, bank locator, memory device type, = 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.18 +**/ + +#include +#include +#include + +#include "SmbiosPlatformDxe.h" + +#define TYPE17_STRINGS \ + "Chip 0 Bank 0\0" \ + "Chip 1 Bank 0\0" \ + "Chip 2 Bank 0\0" \ + "Chip 3 Bank 0\0" \ + "Chip 0 Bank 1\0" \ + "Chip 1 Bank 1\0" \ + "Chip 2 Bank 1\0" \ + "Chip 3 Bank 1\0" + +typedef enum { + Chip0Bank0 =3D 1, + Chip1Bank0, + Chip2Bank0, + Chip3Bank0, + Chip0Bank1, + Chip1Bank1, + Chip2Bank1, + Chip3Bank1 +} TYPE17_STRING_ELEMENTS; + +/* SMBIOS Type17 structure */ +#pragma pack(1) +typedef struct { + SMBIOS_TABLE_TYPE17 Base; + CHAR8 Strings[sizeof (TYPE17_STRINGS)]; +} ARM_RD_SMBIOS_TYPE17; +#pragma pack() + +/* Memory Device */ +STATIC ARM_RD_SMBIOS_TYPE17 mArmRdSmbiosType17[] =3D { + { + { + { + // SMBIOS header + EFI_SMBIOS_TYPE_MEMORY_DEVICE, // Type 17 + sizeof (SMBIOS_TABLE_TYPE17), // Length + SMBIOS_HANDLE_MEMORY_DEVICE0000 + }, + SMBIOS_HANDLE_PHYSICAL_MEMORY, // Physical memory array handle + 0xFFFE, // Memory error info handle + 0xFFFF, // Total width unknown + 0xFFFF, // Data width unknown + 0, // Size, Update dynamically + MemoryFormFactorOther, // Form Factor + 0, // Device set, not part of a set + 0, // Device locator + Chip0Bank0, // Chip 0 Bank 0 + MemoryTypeDram, // Memory type + {0, 1}, // Type details others + }, + // Text strings (unformatted area) + TYPE17_STRINGS + }, + { + { + { + // SMBIOS header + EFI_SMBIOS_TYPE_MEMORY_DEVICE, // Type 17 + sizeof (SMBIOS_TABLE_TYPE17), // Length + SMBIOS_HANDLE_MEMORY_DEVICE0001 + }, + SMBIOS_HANDLE_PHYSICAL_MEMORY, // Physical memory array handle + 0xFFFE, // Memory error info handle + 0xFFFF, // Total width unknown + 0xFFFF, // Data width unknown + 0, // Size, Update dynamically + MemoryFormFactorOther, // Form Factor + 0, // Device set, not part of a set + 0, // Device locator + Chip0Bank1, // Chip 0 Bank 1 + MemoryTypeDram, // Memory type + {0, 1}, // Type details others + }, + // Text strings (unformatted area) + TYPE17_STRINGS + }, + { + { + { + // SMBIOS header + EFI_SMBIOS_TYPE_MEMORY_DEVICE, // Type 17 + sizeof (SMBIOS_TABLE_TYPE17), // Length + SMBIOS_HANDLE_MEMORY_DEVICE0100 + }, + SMBIOS_HANDLE_PHYSICAL_MEMORY, // Physical memory array handle + 0xFFFE, // Memory error info handle + 0xFFFF, // Total width unknown + 0xFFFF, // Data width unknown + 0, // Size, Update dynamically + MemoryFormFactorOther, // Form Factor + 0, // Device set, not part of a set + 0, // Device locator + Chip1Bank0, // Chip 1 Bank 0 + MemoryTypeDram, // Memory type + {0, 1}, // Type details others + }, + // Text strings (unformatted area) + TYPE17_STRINGS + }, + { + { + { + // SMBIOS header + EFI_SMBIOS_TYPE_MEMORY_DEVICE, // Type 17 + sizeof (SMBIOS_TABLE_TYPE17), // Length + SMBIOS_HANDLE_MEMORY_DEVICE0101 + }, + SMBIOS_HANDLE_PHYSICAL_MEMORY, // Physical memory array handle + 0xFFFE, // Memory error info handle + 0xFFFF, // Total width unknown + 0xFFFF, // Data width unknown + 0, // Size, Update dynamically + MemoryFormFactorOther, // Form Factor + 0, // Device set, not part of a set + 0, // Device locator + Chip1Bank1, // Chip 1 Bank 1 + MemoryTypeDram, // Memory type + {0, 1}, // Type details others + }, + // Text strings (unformatted area) + TYPE17_STRINGS + }, + { + { + { + // SMBIOS header + EFI_SMBIOS_TYPE_MEMORY_DEVICE, // Type 17 + sizeof (SMBIOS_TABLE_TYPE17), // Length + SMBIOS_HANDLE_MEMORY_DEVICE0200 + }, + SMBIOS_HANDLE_PHYSICAL_MEMORY, // Physical memory array handle + 0xFFFE, // Memory error info handle + 0xFFFF, // Total width unknown + 0xFFFF, // Data width unknown + 0, // Size, Update dynamically + MemoryFormFactorOther, // Form Factor + 0, // Device set, not part of a set + 0, // Device locator + Chip2Bank0, // Chip 2 Bank 0 + MemoryTypeDram, // Memory type + {0, 1}, // Type details others + }, + // Text strings (unformatted area) + TYPE17_STRINGS + }, + { + { + { + // SMBIOS header + EFI_SMBIOS_TYPE_MEMORY_DEVICE, // Type 17 + sizeof (SMBIOS_TABLE_TYPE17), // Length + SMBIOS_HANDLE_MEMORY_DEVICE0201 + }, + SMBIOS_HANDLE_PHYSICAL_MEMORY, // Physical memory array handle + 0xFFFE, // Memory error info handle + 0xFFFF, // Total width unknown + 0xFFFF, // Data width unknown + 0, // Size, Update dynamically + MemoryFormFactorOther, // Form Factor + 0, // Device set, not part of a set + 0, // Device locator + Chip2Bank1, // Chip 2 Bank 1 + MemoryTypeDram, // Memory type + {0, 1}, // Type details others + }, + // Text strings (unformatted area) + TYPE17_STRINGS + }, + { + { + { + // SMBIOS header + EFI_SMBIOS_TYPE_MEMORY_DEVICE, // Type 17 + sizeof (SMBIOS_TABLE_TYPE17), // Length + SMBIOS_HANDLE_MEMORY_DEVICE0300 + }, + SMBIOS_HANDLE_PHYSICAL_MEMORY, // Physical memory array handle + 0xFFFE, // Memory error info handle + 0xFFFF, // Total width unknown + 0xFFFF, // Data width unknown + 0, // Size, Update dynamically + MemoryFormFactorOther, // Form Factor + 0, // Device set, not part of a set + 0, // Device locator + Chip3Bank0, // Chip 3 Bank 0 + MemoryTypeDram, // Memory type + {0, 1}, // Type details others + }, + // Text strings (unformatted area) + TYPE17_STRINGS + }, + { + { + { + // SMBIOS header + EFI_SMBIOS_TYPE_MEMORY_DEVICE, // Type 17 + sizeof (SMBIOS_TABLE_TYPE17), // Length + SMBIOS_HANDLE_MEMORY_DEVICE0301 + }, + SMBIOS_HANDLE_PHYSICAL_MEMORY, // Physical memory array handle + 0xFFFE, // Memory error info handle + 0xFFFF, // Total width unknown + 0xFFFF, // Data width unknown + 0, // Size, Update dynamically + MemoryFormFactorOther, // Form Factor + 0, // Device set, not part of a set + 0, // Device locator + Chip3Bank1, // Chip 3 Bank 1 + MemoryTypeDram, // Memory type + {0, 1}, // Type details others + }, + // Text strings (unformatted area) + TYPE17_STRINGS + }, +}; + +/** + Install SMBIOS memory device Table. + + Install the SMBIOS memory device (type 17) table for RD 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 +InstallType17MemoryDevice ( + IN EFI_SMBIOS_PROTOCOL *Smbios + ) +{ + EFI_STATUS Status; + EFI_SMBIOS_HANDLE SmbiosHandle; + UINT8 Idx; + + /* Get system memory information */ + for (Idx =3D 0; Idx < (FixedPcdGet32 (PcdChipCount) * 2); Idx +=3D 2) = { + mArmRdSmbiosType17[Idx].Base.Size =3D 0x7FFF; + mArmRdSmbiosType17[Idx].Base.ExtendedSize =3D + (PcdGet64 (PcdSystemMemorySize) + SIZE_16MB) / SIZE_1MB; + mArmRdSmbiosType17[Idx].Base.MemoryTechnology =3D MemoryTechnologyDr= am; + mArmRdSmbiosType17[Idx].Base.MemoryOperatingModeCapability.Bits.Vola= tileMemory =3D 1; + + if (PcdGet64 (PcdDramBlock2Size) !=3D 0) { + mArmRdSmbiosType17[Idx + 1].Base.Size =3D 0x7FFF; + mArmRdSmbiosType17[Idx + 1].Base.ExtendedSize =3D + PcdGet64 (PcdDramBlock2Size) / SIZE_1MB; + mArmRdSmbiosType17[Idx + 1].Base.MemoryTechnology =3D MemoryTechno= logyDram; + mArmRdSmbiosType17[Idx + 1].Base.MemoryOperatingModeCapability.Bit= s.VolatileMemory =3D 1; + } + } + + /* Install valid entries */ + for (Idx =3D 0; Idx < ARRAY_SIZE (mArmRdSmbiosType17); Idx++) { + if (mArmRdSmbiosType17[Idx].Base.ExtendedSize !=3D 0) { + SmbiosHandle =3D + ((EFI_SMBIOS_TABLE_HEADER *)&mArmRdSmbiosType17[Idx])->Handle; + Status =3D Smbios->Add ( + Smbios, + NULL, + &SmbiosHandle, + (EFI_SMBIOS_TABLE_HEADER *)&mArmRdSmbiosType17[= Idx] + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "SMBIOS: Failed to install Type17 SMBIOS table.\n" + )); + break; + } + } + } + + return Status; +} --=20 2.17.1