From: "Pranav Madhu" <pranav.madhu@arm.com>
To: devel@edk2.groups.io
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>,
Leif Lindholm <leif@nuviainc.com>
Subject: [edk2-platforms][PATCH V1 07/11] Platform/ARM/SgiPkg: Add SMBIOS Type7 Table
Date: Fri, 15 Jan 2021 23:56:44 +0530 [thread overview]
Message-ID: <20210115182648.20938-8-pranav.madhu@arm.com> (raw)
In-Reply-To: <20210115182648.20938-1-pranav.madhu@arm.com>
Add the SMBIOS type 7 table (Cache Information) that includes
information about cache levels implemented, cache configuration, ways of
associativity and other information related to cache memory installed.
Signed-off-by: Pranav Madhu <pranav.madhu@arm.com>
---
Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf | 1 +
Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h | 6 +
Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c | 1 +
Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type7CacheInformation.c | 297 ++++++++++++++++++++
4 files changed, 305 insertions(+)
diff --git a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
index 883f6a49243d..162b9c68cfcc 100644
--- a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
+++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
@@ -29,6 +29,7 @@
Type1SystemInformation.c
Type3SystemEnclosure.c
Type4ProcessorInformation.c
+ Type7CacheInformation.c
[Packages]
ArmPkg/ArmPkg.dec
diff --git a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h
index 161bd7ba4090..85a765cfe0c0 100644
--- a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h
+++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h
@@ -33,6 +33,12 @@ InstallProcessorInformation (
IN EFI_SMBIOS_PROTOCOL *Smbios
);
+EFI_STATUS
+EFIAPI
+InstallCacheInformation (
+ IN EFI_SMBIOS_PROTOCOL *Smbios
+ );
+
enum SMBIOS_REFRENCE_HANDLES {
SMBIOS_HANDLE_ENCLOSURE = 0x1000,
SMBIOS_HANDLE_CLUSTER1,
diff --git a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c
index 12c54f31e149..c2e45e7877d0 100644
--- a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c
+++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c
@@ -25,6 +25,7 @@ ARM_RD_SMBIOS_TABLE_INSTALL_FPTR mSmbiosTableList[] = {
&InstallSystemInformation,
&InstallSystemEnclosure,
&InstallProcessorInformation,
+ &InstallCacheInformation,
};
/**
diff --git a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type7CacheInformation.c b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type7CacheInformation.c
new file mode 100644
index 000000000000..b8d0af54678c
--- /dev/null
+++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type7CacheInformation.c
@@ -0,0 +1,297 @@
+/** @file
+ SMBIOS Type 7 (Cache information) table for ARM RD platforms.
+
+ Copyright (c) 2020-2021, ARM Limited. All rights reserved.
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Library/DebugLib.h>
+#include <Protocol/Smbios.h>
+
+#include "SgiPlatform.h"
+#include "SmbiosPlatformDxe.h"
+
+#define TYPE7_STRINGS \
+ "L1 Instruction\0" /* L1I */ \
+ "L1 Data\0" /* L1D */ \
+ "L2\0" /* L2 */ \
+ "L3\0" /* L3 */ \
+ "SLC\0" /* L4 */
+
+/* SMBIOS Type7 structure */
+#pragma pack(1)
+struct ArmRdSmbiosType7 {
+ SMBIOS_TABLE_TYPE7 Base;
+ UINT8 Strings[sizeof (TYPE7_STRINGS)];
+} ARM_TYPE7;
+#pragma pack()
+
+/* Cache information (SMBIOS 3.4 spec, section 7.8) */
+static struct ArmRdSmbiosType7 mArmRdSmbiosType7[] = {
+ { // Entry 0, L1 Instruction Cache
+ {
+ {
+ // SMBIOS header
+ EFI_SMBIOS_TYPE_CACHE_INFORMATION, // Type 7
+ sizeof (SMBIOS_TABLE_TYPE7), // Length
+ SMBIOS_HANDLE_L1I_CACHE, // Handle number
+ },
+ 1,
+ (
+ (1 << 8) | // Write-back
+ (1 << 7) | // Cache enabled
+ (1 << 3) | // Cache socketed
+ 0x0 // Cache level 1
+ ),
+ 0xFFFF, // Uses Maximum cache size 2 field
+ 0xFFFF, // Uses Installed cache size 2 field
+ {0, 1}, // Supported SRAM type unknown
+ {0, 1}, // Current SRAM type unknown
+ 0, // Cache Speed Unknown
+ 0x02, // Error correction type unknown
+ 0x03, // Instruction cache
+ 0, // Associativity, update dynamically
+ 0, // Maximum cache size 2, update dynamically
+ 0 // Installed cache size 2, update dynamically
+ },
+ // Text strings (unformatted area)
+ TYPE7_STRINGS
+ },
+ { // Entry 1, L1 Data Cache
+ {
+ {
+ // SMBIOS header
+ EFI_SMBIOS_TYPE_CACHE_INFORMATION, // Type 7
+ sizeof (SMBIOS_TABLE_TYPE7), // Length
+ SMBIOS_HANDLE_L1D_CACHE, // Handle number
+ },
+ 2,
+ (
+ (1 << 8) | // Write-back
+ (1 << 7) | // Cache enabled
+ (1 << 3) | // Cache socketed
+ 0x0 // Cache level 1
+ ),
+ 0xFFFF, // Uses Maximum cache size 2 field
+ 0xFFFF, // Uses Installed cache size 2 field
+ {0, 1}, // Supported SRAM type unknown
+ {0, 1}, // Current SRAM type unknown
+ 0, // Cache Speed Unknown
+ 0x02, // Error correction type unknown
+ 0x04, // Data cache
+ 0, // Associativity, update dynamically
+ 0, // Maximum cache size 2, update dynamically
+ 0 // Installed cache size 2, update dynamically
+ },
+ // Text strings (unformatted area)
+ TYPE7_STRINGS
+ },
+ { // Entry 2, L2 Cache
+ {
+ {
+ // SMBIOS header
+ EFI_SMBIOS_TYPE_CACHE_INFORMATION, // Type 7
+ sizeof (SMBIOS_TABLE_TYPE7), // Length
+ SMBIOS_HANDLE_L2_CACHE, // Handle number
+ },
+ 3,
+ (
+ (1 << 8) | // Write-back
+ (1 << 7) | // Cache enabled
+ (1 << 3) | // Cache socketed
+ 0x1 // Cache level 2
+ ),
+ 0xFFFF, // Uses Maximum cache size 2 field
+ 0xFFFF, // Uses Installed cache size 2 field
+ {0, 1}, // Supported SRAM type unknown
+ {0, 1}, // Current SRAM type unknown
+ 0, // Cache Speed Unknown
+ 0x02, // Error correction type unknown
+ 0x05, // Unified cache
+ 0, // Associativity, update dynamically
+ 0, // Maximum cache size 2, update dynamically
+ 0 // Installed cache size 2, update dynamically
+ },
+ // Text strings (unformatted area)
+ TYPE7_STRINGS
+ },
+ { // Entry 3, L3 Cache
+ {
+ {
+ // SMBIOS header
+ EFI_SMBIOS_TYPE_CACHE_INFORMATION, // Type 7
+ sizeof (SMBIOS_TABLE_TYPE7), // Length
+ SMBIOS_HANDLE_L3_CACHE, // Handle number
+ },
+ 4,
+ (
+ (1 << 8) | // Write-back
+ (1 << 7) | // Cache enabled
+ (1 << 3) | // Cache socketed
+ 0x2 // Cache level 3
+ ),
+ 0xFFFF, // Uses Maximum cache size 2 field
+ 0xFFFF, // Uses Installed cache size 2 field
+ {0, 1}, // Supported SRAM type unknown
+ {0, 1}, // Current SRAM type unknown
+ 0, // Cache Speed Unknown
+ 0x02, // Error correction type unknown
+ 0x05, // Unified cache
+ 0, // Associativity, update dynamically
+ 0, // Maximum cache size 2, update dynamically
+ 0 // Installed cache size 2, update dynamically
+ },
+ // Text strings (unformatted area)
+ TYPE7_STRINGS
+ },
+ { // Entry 4, SLC Cache
+ {
+ {
+ // SMBIOS header
+ EFI_SMBIOS_TYPE_CACHE_INFORMATION, // Type 7
+ sizeof (SMBIOS_TABLE_TYPE7), // Length
+ SMBIOS_HANDLE_L4_CACHE, // Handle number
+ },
+ 5,
+ (
+ (1 << 8) | // Write-back
+ (1 << 7) | // Cache enabled
+ (1 << 3) | // Cache socketed
+ 0x3 // Cache level 4
+ ),
+ 0xFFFF, // Uses Maximum cache size 2 field
+ 0xFFFF, // Uses Installed cache size 2 field
+ {0, 1}, // Supported SRAM type unknown
+ {0, 1}, // Current SRAM type unknown
+ 0, // Cache Speed Unknown
+ 0x02, // Error correction type unknown
+ 0x05, // Unified cache
+ 0, // Associativity, update dynamically
+ 0, // Maximum cache size 2, update dynamically
+ 0 // Installed cache size 2, update dynamically
+ },
+ // Text strings (unformatted area)
+ TYPE7_STRINGS
+ }
+};
+
+/**
+ Install SMBIOS Cache information Table
+
+ @retval EFI_SUCCESS Record was added.
+ @retval EFI_NOT_FOUND Unknown product id.
+ @retval EFI_OUT_OF_RESOURCES Record was not added.
+ @retval EFI_ALREADY_STARTED The SmbiosHandle passed in is already in use.
+**/
+EFI_STATUS
+InstallCacheInformation (
+ IN EFI_SMBIOS_PROTOCOL *Smbios
+ )
+{
+ EFI_STATUS Status;
+ EFI_SMBIOS_HANDLE SmbiosHandle;
+ UINT8 CacheIdx;
+
+ /* Update the cache attributes based on the product */
+ switch (SgiGetProductId ()) {
+ case Sgi575:
+ mArmRdSmbiosType7[0].Base.MaximumCacheSize2 = 64; // 64KB
+ mArmRdSmbiosType7[0].Base.InstalledSize2 = 64; // 64KB
+ mArmRdSmbiosType7[0].Base.Associativity = CacheAssociativity4Way;
+ mArmRdSmbiosType7[1].Base.MaximumCacheSize2 = 64; // 64KB
+ mArmRdSmbiosType7[1].Base.InstalledSize2 = 64; // 64KB
+ mArmRdSmbiosType7[1].Base.Associativity = CacheAssociativity16Way;
+ mArmRdSmbiosType7[2].Base.MaximumCacheSize2 = 512; // 512KB
+ mArmRdSmbiosType7[2].Base.InstalledSize2 = 512; // 512KB
+ mArmRdSmbiosType7[2].Base.Associativity = CacheAssociativity8Way;
+ mArmRdSmbiosType7[3].Base.MaximumCacheSize2 = 2048; // 2MB
+ mArmRdSmbiosType7[3].Base.InstalledSize2 = 2048; // 2MB
+ mArmRdSmbiosType7[3].Base.Associativity = CacheAssociativity16Way;
+ break;
+ case RdN1Edge:
+ case RdN1EdgeX2:
+ mArmRdSmbiosType7[0].Base.MaximumCacheSize2 = 64; // 64KB
+ mArmRdSmbiosType7[0].Base.InstalledSize2 = 64; // 64KB
+ mArmRdSmbiosType7[0].Base.Associativity = CacheAssociativity4Way;
+ mArmRdSmbiosType7[1].Base.MaximumCacheSize2 = 64; // 64KB
+ mArmRdSmbiosType7[1].Base.InstalledSize2 = 64; // 64KB
+ mArmRdSmbiosType7[1].Base.Associativity = CacheAssociativity4Way;
+ mArmRdSmbiosType7[2].Base.MaximumCacheSize2 = 512; // 512KB
+ mArmRdSmbiosType7[2].Base.InstalledSize2 = 512; // 512KB
+ mArmRdSmbiosType7[2].Base.Associativity = CacheAssociativity8Way;
+ mArmRdSmbiosType7[3].Base.MaximumCacheSize2 = 2048; // 2MB
+ mArmRdSmbiosType7[3].Base.InstalledSize2 = 2048; // 2MB
+ mArmRdSmbiosType7[3].Base.Associativity = CacheAssociativity16Way;
+ mArmRdSmbiosType7[4].Base.MaximumCacheSize2 = 8192; // 8MB SLC per chip
+ mArmRdSmbiosType7[4].Base.InstalledSize2 = 8192; // 8MB SLC per chip
+ mArmRdSmbiosType7[4].Base.Associativity = CacheAssociativity16Way;
+ break;
+ case RdE1Edge:
+ mArmRdSmbiosType7[0].Base.MaximumCacheSize2 = 32; // 32KB
+ mArmRdSmbiosType7[0].Base.InstalledSize2 = 32; // 32KB
+ mArmRdSmbiosType7[0].Base.Associativity = CacheAssociativity4Way;
+ mArmRdSmbiosType7[1].Base.MaximumCacheSize2 = 32; // 32KB
+ mArmRdSmbiosType7[1].Base.InstalledSize2 = 32; // 32KB
+ mArmRdSmbiosType7[1].Base.Associativity = CacheAssociativity4Way;
+ mArmRdSmbiosType7[2].Base.MaximumCacheSize2 = 256; // 256KB
+ mArmRdSmbiosType7[2].Base.InstalledSize2 = 256; // 256KB
+ mArmRdSmbiosType7[2].Base.Associativity = CacheAssociativity4Way;
+ mArmRdSmbiosType7[3].Base.MaximumCacheSize2 = 2048; // 2MB
+ mArmRdSmbiosType7[3].Base.InstalledSize2 = 2048; // 2MB
+ mArmRdSmbiosType7[3].Base.Associativity = CacheAssociativity16Way;
+ mArmRdSmbiosType7[4].Base.MaximumCacheSize2 = 8192; // 8MB SLC
+ mArmRdSmbiosType7[4].Base.InstalledSize2 = 8192; // 8MB SLC
+ mArmRdSmbiosType7[4].Base.Associativity = CacheAssociativity16Way;
+ break;
+ case RdV1:
+ case RdV1Mc:
+ mArmRdSmbiosType7[0].Base.MaximumCacheSize2 = 64; // 64KB
+ mArmRdSmbiosType7[0].Base.InstalledSize2 = 64; // 64KB
+ mArmRdSmbiosType7[0].Base.Associativity = CacheAssociativity4Way;
+ mArmRdSmbiosType7[1].Base.MaximumCacheSize2 = 64; // 64KB
+ mArmRdSmbiosType7[1].Base.InstalledSize2 = 64; // 64KB
+ mArmRdSmbiosType7[1].Base.Associativity = CacheAssociativity4Way;
+ mArmRdSmbiosType7[2].Base.MaximumCacheSize2 = 1024; // 1MB
+ mArmRdSmbiosType7[2].Base.InstalledSize2 = 1024; // 1MB
+ mArmRdSmbiosType7[2].Base.Associativity = CacheAssociativity8Way;
+ mArmRdSmbiosType7[4].Base.MaximumCacheSize2 = 16384; // 16MB SLC per chip
+ mArmRdSmbiosType7[4].Base.InstalledSize2 = 16384; // 16MB SLC per chip
+ mArmRdSmbiosType7[4].Base.Associativity = CacheAssociativity16Way;
+ break;
+ case RdN2:
+ mArmRdSmbiosType7[0].Base.MaximumCacheSize2 = 64; // 64KB
+ mArmRdSmbiosType7[0].Base.InstalledSize2 = 64; // 64KB
+ mArmRdSmbiosType7[0].Base.Associativity = CacheAssociativity4Way;
+ mArmRdSmbiosType7[1].Base.MaximumCacheSize2 = 64; // 64KB
+ mArmRdSmbiosType7[1].Base.InstalledSize2 = 64; // 64KB
+ mArmRdSmbiosType7[1].Base.Associativity = CacheAssociativity4Way;
+ mArmRdSmbiosType7[2].Base.MaximumCacheSize2 = 1024; // 1MB
+ mArmRdSmbiosType7[2].Base.InstalledSize2 = 1024; // 1MB
+ mArmRdSmbiosType7[2].Base.Associativity = CacheAssociativity8Way;
+ mArmRdSmbiosType7[4].Base.MaximumCacheSize2 = 32768; // 32MB SLC
+ mArmRdSmbiosType7[4].Base.InstalledSize2 = 32768; // 32MB SLC
+ mArmRdSmbiosType7[4].Base.Associativity = CacheAssociativity16Way;
+ break;
+ }
+
+ for (CacheIdx = 0; CacheIdx < ARRAY_SIZE (mArmRdSmbiosType7); CacheIdx++) {
+ if (mArmRdSmbiosType7[CacheIdx].Base.MaximumCacheSize2 == 0) {
+ continue;
+ }
+
+ SmbiosHandle = ((EFI_SMBIOS_TABLE_HEADER *)&mArmRdSmbiosType7[CacheIdx])->Handle;
+ Status = Smbios->Add (
+ Smbios,
+ NULL,
+ &SmbiosHandle,
+ (EFI_SMBIOS_TABLE_HEADER *)&mArmRdSmbiosType7[CacheIdx]
+ );
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+ }
+
+ return Status;
+}
--
2.17.1
next prev parent reply other threads:[~2021-01-15 18:27 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-15 18:26 [edk2-platforms][PATCH V1 00/11] Add SMBIOS tables for SGI/RD platforms Pranav Madhu
2021-01-15 18:26 ` [edk2-platforms][PATCH V1 01/11] Platform/ARM/SgiPkg: Define RD-N2 platform id values Pranav Madhu
2021-01-15 18:26 ` [edk2-platforms][PATCH V1 02/11] Platform/ARM/SgiPkg: Add GetProductId API for SGI/RD Platforms Pranav Madhu
2021-01-15 18:26 ` [edk2-platforms][PATCH V1 03/11] Platform/ARM/SgiPkg: Add Initial SMBIOS support Pranav Madhu
2021-01-15 18:26 ` [edk2-platforms][PATCH V1 04/11] Platform/ARM/SgiPkg: Add SMBIOS Type1 Table Pranav Madhu
2021-01-15 18:26 ` [edk2-platforms][PATCH V1 05/11] Platform/ARM/SgiPkg: Add SMBIOS Type3 Table Pranav Madhu
2021-01-15 18:26 ` [edk2-platforms][PATCH V1 06/11] Platform/ARM/SgiPkg: Add SMBIOS Type4 Table Pranav Madhu
2021-01-15 18:26 ` Pranav Madhu [this message]
2021-01-15 18:26 ` [edk2-platforms][PATCH V1 08/11] Platform/ARM/SgiPkg: Add SMBIOS Type16 Table Pranav Madhu
2021-01-15 18:26 ` [edk2-platforms][PATCH V1 09/11] Platform/ARM/SgiPkg: Add SMBIOS Type17 Table Pranav Madhu
2021-01-15 18:26 ` [edk2-platforms][PATCH V1 10/11] Platform/ARM/SgiPkg: Add SMBIOS Type19 Table Pranav Madhu
2021-01-15 18:26 ` [edk2-platforms][PATCH V1 11/11] Platform/ARM/SgiPkg: Add SMBIOS Type32 Table Pranav Madhu
2021-01-26 14:33 ` [edk2-devel] [edk2-platforms][PATCH V1 00/11] Add SMBIOS tables for SGI/RD platforms Thomas Abraham
2021-01-29 6:29 ` Pranav Madhu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210115182648.20938-8-pranav.madhu@arm.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox