public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Sami Mujawar" <sami.mujawar@arm.com>
To: Pranav Madhu <pranav.madhu@arm.com>, devel@edk2.groups.io
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>, nd@arm.com
Subject: Re: [edk2-platforms][PATCH V2 08/11] Platform/Sgi: Add SMBIOS Type16 Table
Date: Mon, 17 May 2021 16:33:39 +0100	[thread overview]
Message-ID: <369cdf1d-fffc-e4d2-4fec-dbde5a58de9e@arm.com> (raw)
In-Reply-To: <20210516092917.21124-9-pranav.madhu@arm.com>

Hi Pranav,

Some comments in previous patches apply here as well and are not mentioned.

With those addressed.

Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>

Regards,

Sami Mujawar


On 16/05/2021 10:29 AM, Pranav Madhu wrote:
> 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 <pranav.madhu@arm.com>
> ---
>   Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.inf       |   4 +
>   Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h         |   7 ++
>   Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c         |   1 +
>   Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type16PhysicalMemoryArray.c | 106 ++++++++++++++++++++
>   4 files changed, 118 insertions(+)
>
> diff --git a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.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
>   
>   [Packages]
>     ArmPkg/ArmPkg.dec
> @@ -44,6 +45,9 @@
>     gArmPlatformTokenSpaceGuid.PcdClusterCount
>     gArmPlatformTokenSpaceGuid.PcdCoreCount
>     gArmSgiTokenSpaceGuid.PcdChipCount
> +  gArmSgiTokenSpaceGuid.PcdDramBlock2Size
> +  gArmTokenSpaceGuid.PcdSystemMemoryBase
> +  gArmTokenSpaceGuid.PcdSystemMemorySize
>     gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareRevision
>   
>   [Protocols]
> diff --git a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h
> index 6f3ad29f0797..e195fdea35af 100644
> --- a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h
> +++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.h
> @@ -41,6 +41,12 @@ InstallCacheInformation (
>     IN     EFI_SMBIOS_PROTOCOL    *Smbios
>     );
>   
> +EFI_STATUS
> +EFIAPI
> +InstallPhysicalMemoryArray (
> +  IN     EFI_SMBIOS_PROTOCOL    *Smbios
> +  );
> +
>   enum SMBIOS_REFRENCE_HANDLES {
>     SMBIOS_HANDLE_ENCLOSURE = 0x1000,
>     SMBIOS_HANDLE_CLUSTER1,
> @@ -49,6 +55,7 @@ enum SMBIOS_REFRENCE_HANDLES {
>     SMBIOS_HANDLE_L2_CACHE,
>     SMBIOS_HANDLE_L3_CACHE,
>     SMBIOS_HANDLE_L4_CACHE,
> +  SMBIOS_HANDLE_PHYSICAL_MEMORY,
>   };
>   
>   #endif // SMBIOS_PLATFORM_DXE_H_
> diff --git a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c
> index 62d0f5ce8033..48073ad0ad27 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[] = {
>     &InstallSystemEnclosure,
>     &InstallProcessorInformation,
>     &InstallCacheInformation,
> +  &InstallPhysicalMemoryArray,
>   };
>   
>   /**
> diff --git a/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type16PhysicalMemoryArray.c b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type16PhysicalMemoryArray.c
> new file mode 100644
> index 000000000000..44a71fa8d18d
> --- /dev/null
> +++ b/Platform/ARM/SgiPkg/Drivers/SmbiosPlatformDxe/Type16PhysicalMemoryArray.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 Arm's
> +  Reference Design platforms. It 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.
> +
> +  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 <Library/BaseMemoryLib.h>
> +#include <Library/DebugLib.h>
> +#include <Protocol/Smbios.h>
> +
> +#include "SmbiosPlatformDxe.h"
> +
> +#define TYPE16_STRINGS                                  \
> +  "\0"                          /* Null string */
> +
> +/* SMBIOS Type16 structure */
> +#pragma pack(1)
> +struct ArmRdSmbiosType16 {
> +  SMBIOS_TABLE_TYPE16 Base;
> +  UINT8               Strings[sizeof (TYPE16_STRINGS)];
> +} ARM_TYPE16;
> +#pragma pack()
> +
> +/* Physical Memory Array */
> +static struct ArmRdSmbiosType16 mArmRdSmbiosType16 = {
> +  {
> +    {
> +      // 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 capacity 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 Reference
> +  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 in is already in use.
> +**/
> +EFI_STATUS
> +InstallPhysicalMemoryArray (
> +  IN     EFI_SMBIOS_PROTOCOL    *Smbios
> +  )
> +{
> +  EFI_STATUS Status;
> +  EFI_SMBIOS_HANDLE SmbiosHandle;
> +  UINT16 NumOfMemoryDevices = 1;
> +  UINT64 InstalledMemory;
> +
> +  SmbiosHandle = ((EFI_SMBIOS_TABLE_HEADER *)&mArmRdSmbiosType16)->Handle;
> +
> +  /* Include 16MB of Trusted DRAM as well */
> +  InstalledMemory = PcdGet64 (PcdSystemMemorySize) + SIZE_16MB;
> +  if (PcdGet64 (PcdDramBlock2Size) != 0) {
> +    NumOfMemoryDevices++;
> +    InstalledMemory += PcdGet64 (PcdDramBlock2Size);
> +  }
> +
> +  mArmRdSmbiosType16.Base.ExtendedMaximumCapacity =
> +    InstalledMemory * FixedPcdGet32 (PcdChipCount);
> +  mArmRdSmbiosType16.Base.NumberOfMemoryDevices =
> +    NumOfMemoryDevices * FixedPcdGet32 (PcdChipCount);
> +
> +  /* Install type 16 table */
> +  Status = Smbios->Add (
> +                     Smbios,
> +                     NULL,
> +                     &SmbiosHandle,
> +                     (EFI_SMBIOS_TABLE_HEADER *)&mArmRdSmbiosType16
> +                     );
> +   if (Status != EFI_SUCCESS) {
> +    DEBUG ((
> +      DEBUG_ERROR,
> +      "SMBIOS: Failed to install Type16 SMBIOS table.\n"
> +      ));
> +  }
> +
> +  return Status;
> +}


  reply	other threads:[~2021-05-17 15:34 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-16  9:29 [edk2-platforms][PATCH V2 00/11] Add SMBIOS tables for Arm's Reference Design platforms Pranav Madhu
2021-05-16  9:29 ` [edk2-platforms][PATCH V2 01/11] Platform/Sgi: Define RD-N2 platform id values Pranav Madhu
2021-05-17 15:32   ` Sami Mujawar
2021-05-16  9:29 ` [edk2-platforms][PATCH V2 02/11] Platform/Sgi: Add GetProductId API for SGI/RD Platforms Pranav Madhu
2021-05-17 15:32   ` Sami Mujawar
2021-05-16  9:29 ` [edk2-platforms][PATCH V2 03/11] Platform/Sgi: Add Initial SMBIOS support Pranav Madhu
2021-05-17 15:33   ` Sami Mujawar
2021-05-16  9:29 ` [edk2-platforms][PATCH V2 04/11] Platform/Sgi: Add SMBIOS Type1 Table Pranav Madhu
2021-05-17 15:33   ` Sami Mujawar
2021-05-16  9:29 ` [edk2-platforms][PATCH V2 05/11] Platform/Sgi: Add SMBIOS Type3 Table Pranav Madhu
2021-05-17 15:33   ` Sami Mujawar
2021-05-16  9:29 ` [edk2-platforms][PATCH V2 06/11] Platform/Sgi: Add SMBIOS Type4 Table Pranav Madhu
2021-05-17 15:33   ` Sami Mujawar
2021-05-16  9:29 ` [edk2-platforms][PATCH V2 07/11] Platform/Sgi: Add SMBIOS Type7 Table Pranav Madhu
2021-05-17 15:33   ` Sami Mujawar
2021-05-16  9:29 ` [edk2-platforms][PATCH V2 08/11] Platform/Sgi: Add SMBIOS Type16 Table Pranav Madhu
2021-05-17 15:33   ` Sami Mujawar [this message]
2021-05-16  9:29 ` [edk2-platforms][PATCH V2 09/11] Platform/Sgi: Add SMBIOS Type17 Table Pranav Madhu
2021-05-17 15:33   ` Sami Mujawar
2021-05-16  9:29 ` [edk2-platforms][PATCH V2 10/11] Platform/Sgi: Add SMBIOS Type19 Table Pranav Madhu
2021-05-17 15:33   ` Sami Mujawar
2021-05-16  9:29 ` [edk2-platforms][PATCH V2 11/11] Platform/Sgi: Add SMBIOS Type32 Table Pranav Madhu
2021-05-17 15:33   ` Sami Mujawar

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=369cdf1d-fffc-e4d2-4fec-dbde5a58de9e@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