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.web11.24088.1621866511227654628 for ; Mon, 24 May 2021 07:28:31 -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 D5771ED1; Mon, 24 May 2021 07:28:30 -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 AC2B73F719; Mon, 24 May 2021 07:28:29 -0700 (PDT) From: "Pranav Madhu" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Sami Mujawar Subject: [edk2-platforms][PATCH V4 02/11] Platform/Sgi: Add GetProductId API for SGI/RD Platforms Date: Mon, 24 May 2021 19:58:07 +0530 Message-Id: <20210524142816.9967-3-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 GetProductId API for SGI/RD Platform. The API returns a product id in integer format based on the platform description data. The product id is required for other drivers such as SMBIOS. Signed-off-by: Pranav Madhu Reviewed-by: Sami Mujawar --- Platform/ARM/SgiPkg/Include/SgiPlatform.h | 30 +++++++ Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.c | 86 +++++++++++++= ++++++- 2 files changed, 115 insertions(+), 1 deletion(-) diff --git a/Platform/ARM/SgiPkg/Include/SgiPlatform.h b/Platform/ARM/Sgi= Pkg/Include/SgiPlatform.h index 1c5366878712..4999c9870b49 100644 --- a/Platform/ARM/SgiPkg/Include/SgiPlatform.h +++ b/Platform/ARM/SgiPkg/Include/SgiPlatform.h @@ -68,4 +68,34 @@ typedef struct { UINTN MultiChipMode; } SGI_PLATFORM_DESCRIPTOR; =20 +// Arm SGI/RD Product IDs +typedef enum { + UnknownId =3D 0, + Sgi575, + RdN1Edge, + RdN1EdgeX2, + RdE1Edge, + RdV1, + RdV1Mc, + RdN2 +} ARM_RD_PRODUCT_ID; + +// Arm ProductId look-up table +typedef struct { + UINTN ProductId; + UINTN PlatformId; + UINTN ConfigId; + UINTN MultiChipMode; +} SGI_PRODUCT_ID_LOOKUP; + +/** + Derermine the product ID. + + Determine the product ID by using the data in the Platform ID Descript= or HOB + to lookup for a matching product ID. + + @retval Zero Failed identify platform. + @retval Others ARM_RD_PRODUCT_ID of the identified platform. +**/ +UINT8 SgiGetProductId (VOID); #endif // __SGI_PLATFORM_H__ diff --git a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.c b/Plat= form/ARM/SgiPkg/Library/PlatformLib/PlatformLib.c index 9731d7cccede..f27c949dbc24 100644 --- a/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.c +++ b/Platform/ARM/SgiPkg/Library/PlatformLib/PlatformLib.c @@ -1,6 +1,6 @@ /** @file * -* Copyright (c) 2018, ARM Limited. All rights reserved. +* Copyright (c) 2018-2021, ARM Limited. All rights reserved. * * SPDX-License-Identifier: BSD-2-Clause-Patent * @@ -8,9 +8,12 @@ =20 #include #include +#include #include #include =20 +#include "SgiPlatform.h" + UINT64 NtFwConfigDtBlob; STATIC SGI_NT_FW_CONFIG_INFO_PPI mNtFwConfigDtInfoPpi; =20 @@ -21,6 +24,51 @@ STATIC ARM_CORE_INFO mCoreInfoTable[] =3D { }, }; =20 +STATIC CONST SGI_PRODUCT_ID_LOOKUP SgiProductIdLookup[] =3D { + { + Sgi575, + SGI575_PART_NUM, + SGI575_CONF_NUM, + 0 + }, + { + RdN1Edge, + RD_N1E1_EDGE_PART_NUM, + RD_N1_EDGE_CONF_ID, + 0 + }, + { + RdN1EdgeX2, + RD_N1E1_EDGE_PART_NUM, + RD_N1_EDGE_CONF_ID, + 1 + }, + { + RdE1Edge, + RD_N1E1_EDGE_PART_NUM, + RD_E1_EDGE_CONF_ID, + 0 + }, + { + RdV1, + RD_V1_PART_NUM, + RD_V1_CONF_ID, + 0 + }, + { + RdV1Mc, + RD_V1_PART_NUM, + RD_V1_MC_CONF_ID, + 1 + }, + { + RdN2, + RD_N2_PART_NUM, + RD_N2_CONF_ID, + 0 + } +}; + EFI_BOOT_MODE ArmPlatformGetBootMode ( VOID @@ -75,3 +123,39 @@ ArmPlatformGetPlatformPpiList ( *PpiListSize =3D sizeof (gPlatformPpiTable); *PpiList =3D gPlatformPpiTable; } + +/** + Derermine the product ID. + + Determine the product ID by using the data in the Platform ID Descript= or HOB + to lookup for a matching product ID. + + @retval Zero Failed identify platform. + @retval Others ARM_RD_PRODUCT_ID of the identified platform. +**/ +UINT8 +SgiGetProductId ( + VOID + ) +{ + VOID *SystemIdHob; + UINT8 Idx; + SGI_PLATFORM_DESCRIPTOR *HobData; + + SystemIdHob =3D GetFirstGuidHob (&gArmSgiPlatformIdDescriptorGuid); + if (SystemIdHob =3D=3D NULL) { + return UnknownId; + } + + HobData =3D (SGI_PLATFORM_DESCRIPTOR *)GET_GUID_HOB_DATA (SystemIdHob)= ; + + for (Idx =3D 0; Idx < ARRAY_SIZE (SgiProductIdLookup); Idx++) { + if ((HobData->PlatformId =3D=3D SgiProductIdLookup[Idx].PlatformId) = && + (HobData->ConfigId =3D=3D SgiProductIdLookup[Idx].ConfigId) && + (HobData->MultiChipMode =3D=3D SgiProductIdLookup[Idx].MultiChip= Mode)) { + return SgiProductIdLookup[Idx].ProductId; + } + } + + return UnknownId; +} --=20 2.17.1