public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Pranav Madhu" <pranav.madhu@arm.com>
To: devel@edk2.groups.io
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Sami Mujawar <sami.mujawar@arm.com>
Subject: [edk2-platforms][PATCH V3 10/11] Platform/Sgi: Add SMBIOS Type19 Table
Date: Tue, 18 May 2021 22:03:47 +0530	[thread overview]
Message-ID: <20210518163348.16618-11-pranav.madhu@arm.com> (raw)
In-Reply-To: <20210518163348.16618-1-pranav.madhu@arm.com>

Add the SMBIOS type 19 table (Memory Array Mapped Addr) that includes
information about the address mapping for a Physical Memory Array.

Signed-off-by: Pranav Madhu <pranav.madhu@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
---
 Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf            |  1 +
 Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h              | 18 ++++
 Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c              |  1 +
 Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type19MemoryArrayMappedAddress.c | 97 ++++++++++++++++++++
 4 files changed, 117 insertions(+)

diff --git a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
index 9061c491d461..f81494114188 100644
--- a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
+++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
@@ -22,6 +22,7 @@
   Type7CacheInformation.c
   Type16PhysicalMemoryArray.c
   Type17MemoryDevice.c
+  Type19MemoryArrayMappedAddress.c
 
 [Packages]
   ArmPkg/ArmPkg.dec
diff --git a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h
index 4e663033d515..d4b838689a32 100644
--- a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h
+++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h
@@ -140,6 +140,24 @@ InstallType17MemoryDevice (
   IN     EFI_SMBIOS_PROTOCOL    *Smbios
   );
 
+/**
+  Install SMBIOS memory array mapped address table
+
+  Install the SMBIOS memory array mapped address (type 19) 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 use.
+**/
+EFI_STATUS
+EFIAPI
+InstallType19MemoryArrayMappedAddress (
+  IN     EFI_SMBIOS_PROTOCOL    *Smbios
+  );
+
 typedef enum {
   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 4e6a6b250813..bed5da77786d 100644
--- a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c
+++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c
@@ -33,6 +33,7 @@ ARM_RD_SMBIOS_TABLE_INSTALL_FPTR mSmbiosTableList[] = {
   &InstallType7CacheInformation,
   &InstallType16PhysicalMemoryArray,
   &InstallType17MemoryDevice,
+  &InstallType19MemoryArrayMappedAddress,
 };
 
 /**
diff --git a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type19MemoryArrayMappedAddress.c b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type19MemoryArrayMappedAddress.c
new file mode 100644
index 000000000000..301208c4bc03
--- /dev/null
+++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type19MemoryArrayMappedAddress.c
@@ -0,0 +1,97 @@
+/** @file
+  SMBIOS Type 19 (Memory Array Mapped Address) table for ARM RD platforms.
+
+  This file installs SMBIOS Type 19 (Memory Array Mapped Address) table for Arm's
+  Reference Design platforms. It includes information about the address mapping
+  for a Physical Memory Array.
+
+  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.20
+**/
+
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Protocol/Smbios.h>
+
+#include "SmbiosPlatformDxe.h"
+
+#define TYPE19_STRINGS                                  \
+  "\0"                          /* Null string */
+
+/* SMBIOS Type19 structure */
+#pragma pack(1)
+typedef struct {
+  SMBIOS_TABLE_TYPE19 Base;
+  CHAR8               Strings[sizeof (TYPE19_STRINGS)];
+} ARM_RD_SMBIOS_TYPE19;
+#pragma pack()
+
+/* Memory Array Mapped Address */
+STATIC ARM_RD_SMBIOS_TYPE19 mArmRdSmbiosType19 = {
+  {
+    {
+      // SMBIOS header
+      EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS,  // Type 19
+      sizeof (SMBIOS_TABLE_TYPE19),     // Length
+      SMBIOS_HANDLE_PI_RESERVED,        // Assign an unused handle number
+    },
+    0,                                  // Starting address
+    0,                                  // Ending address
+    SMBIOS_HANDLE_PHYSICAL_MEMORY,      // Memory array handle
+    1                                   // Partition width
+  },
+  // Text strings (unformatted area)
+  TYPE19_STRINGS
+};
+
+/**
+  Install SMBIOS memory array mapped address table
+
+  Install the SMBIOS memory array mapped address (type 19) 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 use.
+**/
+EFI_STATUS
+InstallType19MemoryArrayMappedAddress (
+  IN     EFI_SMBIOS_PROTOCOL    *Smbios
+  )
+{
+  EFI_STATUS Status;
+  EFI_SMBIOS_HANDLE SmbiosHandle;
+
+  SmbiosHandle = ((EFI_SMBIOS_TABLE_HEADER *)&mArmRdSmbiosType19)->Handle;
+
+  mArmRdSmbiosType19.Base.StartingAddress = 0xFFFFFFFF;
+  mArmRdSmbiosType19.Base.EndingAddress = 0xFFFFFFFF;
+  mArmRdSmbiosType19.Base.ExtendedStartingAddress =
+          PcdGet64 (PcdSystemMemoryBase);
+  mArmRdSmbiosType19.Base.ExtendedEndingAddress =
+          (PcdGet64 (PcdSystemMemoryBase) +
+           PcdGet64 (PcdSystemMemorySize) +
+           SIZE_16MB    // 16MB Trusted DRAM
+          ) - 1;
+
+  /* Install type 19 table */
+  Status = Smbios->Add (
+                     Smbios,
+                     NULL,
+                     &SmbiosHandle,
+                     (EFI_SMBIOS_TABLE_HEADER *)&mArmRdSmbiosType19
+                     );
+  if (EFI_ERROR (Status)) {
+    DEBUG ((
+      DEBUG_ERROR,
+      "SMBIOS: Failed to install Type19 SMBIOS table.\n"
+      ));
+  }
+
+  return Status;
+}
-- 
2.17.1


  parent reply	other threads:[~2021-05-18 16:34 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-18 16:33 [edk2-platforms][PATCH V3 00/11] Add SMBIOS tables for Arm's Reference Design platforms Pranav Madhu
2021-05-18 16:33 ` [edk2-platforms][PATCH V3 01/11] Platform/Sgi: Define RD-N2 platform id values Pranav Madhu
2021-05-18 16:33 ` [edk2-platforms][PATCH V3 02/11] Platform/Sgi: Add GetProductId API for SGI/RD Platforms Pranav Madhu
2021-05-18 16:33 ` [edk2-platforms][PATCH V3 03/11] Platform/Sgi: Add Initial SMBIOS support Pranav Madhu
2021-05-18 16:33 ` [edk2-platforms][PATCH V3 04/11] Platform/Sgi: Add SMBIOS Type1 Table Pranav Madhu
2021-05-18 16:33 ` [edk2-platforms][PATCH V3 05/11] Platform/Sgi: Add SMBIOS Type3 Table Pranav Madhu
2021-05-18 16:33 ` [edk2-platforms][PATCH V3 06/11] Platform/Sgi: Add SMBIOS Type4 Table Pranav Madhu
2021-05-18 16:33 ` [edk2-platforms][PATCH V3 07/11] Platform/Sgi: Add SMBIOS Type7 Table Pranav Madhu
2021-05-18 16:33 ` [edk2-platforms][PATCH V3 08/11] Platform/Sgi: Add SMBIOS Type16 Table Pranav Madhu
2021-05-18 16:33 ` [edk2-platforms][PATCH V3 09/11] Platform/Sgi: Add SMBIOS Type17 Table Pranav Madhu
2021-05-18 16:33 ` Pranav Madhu [this message]
2021-05-18 16:33 ` [edk2-platforms][PATCH V3 11/11] Platform/Sgi: Add SMBIOS Type32 Table Pranav Madhu
2021-05-19 11:30 ` [edk2-devel] [edk2-platforms][PATCH V3 00/11] Add SMBIOS tables for Arm's Reference Design platforms Thomas Abraham

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=20210518163348.16618-11-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