From nobody Fri Mar 29 11:52:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+63580+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63580+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1596212373; cv=none; d=zohomail.com; s=zohoarc; b=nXabqky43JIIScI4PgTfza9e0DOwL+zNjqGmZT72WC2iXpCqVMIdevuE1r3x9KLsT4anzEfspJ5iu/mjHVUKPQ35W0z2SzYoHkRGWijD1sOM/F2i2k5U1TTjnIY5aUNvCVnl5R+B4G/oZb53fCyWnixC1vkyZuMFVq2mvBFMf08= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596212373; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=0MH5RAqwNq/JzcGcRIbiAc820j2VXpcb4pflc+mdBjE=; b=Jg2wpM+eHaXJFZIn4TgoL+BPQTzfWNkcn5S/ScKq1frhzdCdIfb4hUBrFOUg6O08DbdGk2PkU98mi2Om7CDIv6ho2JcdFS+pDrMFl2i9VQEewpstg9mObVLUjIOw1ATXJHdNOEj/P3z4CfYAjf276RyFsVsynyxlyez/N+KY5SA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63580+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1596212373096411.12941994796984; Fri, 31 Jul 2020 09:19:33 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id teUiYY1788612x4mMdfq7N0g; Fri, 31 Jul 2020 09:19:32 -0700 X-Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by mx.groups.io with SMTP id smtpd.web11.379.1596212371982982241 for ; Fri, 31 Jul 2020 09:19:32 -0700 X-Received: by mail-wm1-f43.google.com with SMTP id q76so8532685wme.4 for ; Fri, 31 Jul 2020 09:19:31 -0700 (PDT) X-Gm-Message-State: CAzYLa3p0Wzs8V9SfHvyGFUlx1787277AA= X-Google-Smtp-Source: ABdhPJwBRZaU5FGYuG4zaBm9KcDx/7IhXtnXQqFJjTJ3qYlAe9wS88ggEi9Sk2yF/s53XIILJqW62w== X-Received: by 2002:a1c:5f41:: with SMTP id t62mr4391813wmb.53.1596212368908; Fri, 31 Jul 2020 09:19:28 -0700 (PDT) X-Received: from localhost.localdomain (cpc159317-cmbg20-2-0-cust162.5-4.cable.virginm.net. [81.111.29.163]) by smtp.gmail.com with ESMTPSA id v11sm14149739wrr.10.2020.07.31.09.19.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:19:28 -0700 (PDT) From: "Tomas Pilar (tpilar)" To: devel@edk2.groups.io Cc: Sami Mujawar , Alexei Fedorov Subject: [edk2-devel] [PATCH 1/8] DynamicTablesPkg: Include BaseStackCheckLib Date: Fri, 31 Jul 2020 17:19:19 +0100 Message-Id: <20200731161926.341330-2-tomas@nuviainc.com> In-Reply-To: <20200731161926.341330-1-tomas@nuviainc.com> References: <20200731161926.341330-1-tomas@nuviainc.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,tomas@nuviainc.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1596212372; bh=2/xXyZyB12fxJdIOUqEbTW8EQa44CQuWazoZwOlKjJc=; h=Cc:Date:From:Reply-To:Subject:To; b=wbTtg5HDd3D7mujNy1/cBAZA6MMdC6Gr/s/tnTZ+k0BpU3X66A2s0+P9vflw6t0K44X ASys7HY1Hnk+S5ZkgizwbyQKht4tt3MMi7RmMxajI+YVW/bWK7j239ykU/GkxDWtJhtV0 dnjtzryJODYLOpYOSnYj/RG6NnbfMBZFNIM= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" In GCC10 the __stack_chk_guard global variable no longer exists, the stack checking is done a different way. This patch includes the BaseStackCheckLib as a NULL library which provides the global variable explicitly. This fixes compilation with GCC10. Cc: Sami Mujawar Cc: Alexei Fedorov Signed-off-by: Tomas Pilar --- DynamicTablesPkg/DynamicTablesPkg.dsc | 1 + 1 file changed, 1 insertion(+) diff --git a/DynamicTablesPkg/DynamicTablesPkg.dsc b/DynamicTablesPkg/Dynam= icTablesPkg.dsc index 02f04447ff..346fa8ccdd 100644 --- a/DynamicTablesPkg/DynamicTablesPkg.dsc +++ b/DynamicTablesPkg/DynamicTablesPkg.dsc @@ -33,6 +33,7 @@ =20 [LibraryClasses.ARM, LibraryClasses.AARCH64] NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf + NULL|MdePkg/Library/BaseStackCheckLib/BaseStackCheckLib.inf PL011UartLib|ArmPlatformPkg/Library/PL011UartLib/PL011UartLib.inf =20 [Components.common] --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#63580): https://edk2.groups.io/g/devel/message/63580 Mute This Topic: https://groups.io/mt/75910564/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Mar 29 11:52:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+63581+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63581+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1596212373; cv=none; d=zohomail.com; s=zohoarc; b=bj8Az0MSjweEv8E+jHKR+xWVxPxvd61cVCNiB44rlgP+JgeTlarH3LZrWtDY0Km/cqw2UicD6I9bMr6BNMkkNmVMwREKPF+UKHOMD+Y21AMD1aZjxvGbg4B6QmzzPyj9g6E4vtf6VjS3K5jnRUFlMleyIQYyfipIREBJyTsDbdw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596212373; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=TSCK7kwWY9F3Z+DKVQmuI88BooxvIvKJGnt+QdVX1zE=; b=cmI/qrXCx3Vs4ueefO+sv+CebIhlBb/O8T0teJPo8Syn4XPxjlgMftTrKDiMpvCNGgsoiYYesqZvzsxex3KvZZu6x1VebxkbzFVoO2W9ceRO1LzDThKanRAgW4rXA0wFOdihox34mBZUhaPVudbfTc4LOriVYPvbMfFld4MFcXk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63581+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1596212373629672.9633712397934; Fri, 31 Jul 2020 09:19:33 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id w0p3YY1788612xxpHmdwlbWJ; Fri, 31 Jul 2020 09:19:33 -0700 X-Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by mx.groups.io with SMTP id smtpd.web11.380.1596212372197870463 for ; Fri, 31 Jul 2020 09:19:32 -0700 X-Received: by mail-wm1-f43.google.com with SMTP id d190so8961776wmd.4 for ; Fri, 31 Jul 2020 09:19:31 -0700 (PDT) X-Gm-Message-State: LrK9NXbUIcYiQFp6Mlt5jqOlx1787277AA= X-Google-Smtp-Source: ABdhPJw020QsAkIxymYlWxxEkoeaODQdD0WUrtiLH4xzI8iRIxY6uanqJkIW9mX0JuBcVUX7E9Fhfw== X-Received: by 2002:a1c:b188:: with SMTP id a130mr4255963wmf.125.1596212369976; Fri, 31 Jul 2020 09:19:29 -0700 (PDT) X-Received: from localhost.localdomain (cpc159317-cmbg20-2-0-cust162.5-4.cable.virginm.net. [81.111.29.163]) by smtp.gmail.com with ESMTPSA id v11sm14149739wrr.10.2020.07.31.09.19.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:19:29 -0700 (PDT) From: "Tomas Pilar (tpilar)" To: devel@edk2.groups.io Cc: Sami Mujawar , Alexei Fedorov Subject: [edk2-devel] [PATCH 2/8] DynamicTablesPkg: Fold Namespaces into CmObjectId Enums Date: Fri, 31 Jul 2020 17:19:20 +0100 Message-Id: <20200731161926.341330-3-tomas@nuviainc.com> In-Reply-To: <20200731161926.341330-1-tomas@nuviainc.com> References: <20200731161926.341330-1-tomas@nuviainc.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,tomas@nuviainc.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1596212373; bh=SmValJre4PWCs6gI3JHlNlN/Uw82GBl7ygQWTUWgNsw=; h=Cc:Date:From:Reply-To:Subject:To; b=rGqdQ0TvHrXJR4g0yXsQmZPDYl019WoD0qSe4liCi7nFw4hAoxGCKapMK9x8+Zg4iOk aXjYvOGaRor1k4PtN18TRQ45dQEDkQyfNE8skmt5qI2xY4coOiG6UWQ1WycIYIx8346it 6t26e+68wBUxAYugCGphQMIQ9JpzYfmdbcA= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" The enums for CmObjectIds defined in Dynamic Tables Framework that are used to identify types of configuration manager objects already include their namespaces in the symbols for enum values. Namespace enum values are shifted up by NAMESPACE_BIT_SHIFT and the enums tables for CmObjectIds are bitwise-ORed with their corresponding namespace. This means we no longer need to use macros to compose and decompose CmObjectIds. The macros are adjusted so that they result in NOP. Cc: Sami Mujawar Cc: Alexei Fedorov Signed-off-by: Tomas Pilar --- .../Include/ArmNameSpaceObjects.h | 3 +- .../Include/ConfigurationManagerNameSpace.h | 43 ++++++++++++++ .../Include/ConfigurationManagerObject.h | 57 ++++++++----------- .../Include/StandardNameSpaceObjects.h | 7 ++- 4 files changed, 72 insertions(+), 38 deletions(-) create mode 100644 DynamicTablesPkg/Include/ConfigurationManagerNameSpace.h diff --git a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h b/DynamicTables= Pkg/Include/ArmNameSpaceObjects.h index 2f32696031..cf7846e024 100644 --- a/DynamicTablesPkg/Include/ArmNameSpaceObjects.h +++ b/DynamicTablesPkg/Include/ArmNameSpaceObjects.h @@ -14,6 +14,7 @@ #define ARM_NAMESPACE_OBJECTS_H_ =20 #include +#include =20 #pragma pack(1) =20 @@ -21,7 +22,7 @@ in the ARM Namespace */ typedef enum ArmObjectID { - EArmObjReserved, ///< 0 - Reserved + EArmObjReserved =3D EObjNameSpaceArm, ///< 0 - Reserved, namespace sta= rts at 0x10000000 EArmObjBootArchInfo, ///< 1 - Boot Architecture Info EArmObjCpuInfo, ///< 2 - CPU Info EArmObjPowerManagementProfileInfo, ///< 3 - Power Management Profile = Info diff --git a/DynamicTablesPkg/Include/ConfigurationManagerNameSpace.h b/Dyn= amicTablesPkg/Include/ConfigurationManagerNameSpace.h new file mode 100644 index 0000000000..acba77e2b3 --- /dev/null +++ b/DynamicTablesPkg/Include/ConfigurationManagerNameSpace.h @@ -0,0 +1,43 @@ +/** @file + + Copyright (c) 2020, ARM Limited. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef CONFIGURATION_MANAGER_NAMESPACE_H_ +#define CONFIGURATION_MANAGER_NAMESPACE_H_ + +/** The EOBJECT_NAMESPACE_ID enum describes the defined namespaces + for the Configuration Manager Objects. + + Description of Configuration Manager Object ID +__________________________________________________________________________= _____ +|31 |30 |29 |28 || 27 | 26 | 25 | 24 || 23 | 22 | 21 | 20 || 19 | 18 | 17 = | 16| +--------------------------------------------------------------------------= ----- +| Name Space ID || 0 | 0 | 0 | 0 || 0 | 0 | 0 | 0 || 0 | 0 | 0 = | 0| +__________________________________________________________________________= _____ + +Bits: [31:28] - Name Space ID + 0000 - Standard + 0001 - ARM + 1000 - Custom/OEM + All other values are reserved. + +Bits: [27:16] - Reserved. +__________________________________________________________________________= _____ +|15 |14 |13 |12 || 11 | 10 | 9 | 8 || 7 | 6 | 5 | 4 || 3 | 2 | 1 = | 0| +--------------------------------------------------------------------------= ----- +| 0 | 0 | 0 | 0 || 0 | 0 | 0 | 0 || Object ID = | +__________________________________________________________________________= _____ + +Bits: [15:8] - Are reserved and must be zero. +Bits: [7:0] - Object ID +*/ +typedef enum ObjectNameSpaceID { + EObjNameSpaceStandard =3D 0x00000000, ///< Standard Objects Namespa= ce + EObjNameSpaceArm =3D 0x10000000, ///< ARM Objects Namespace + EObjNameSpaceOem =3D 0x80000000, ///< OEM Objects Namespace +} EOBJECT_NAMESPACE_ID; + +#endif diff --git a/DynamicTablesPkg/Include/ConfigurationManagerObject.h b/Dynami= cTablesPkg/Include/ConfigurationManagerObject.h index b0d3e709ec..9d39bd8a9e 100644 --- a/DynamicTablesPkg/Include/ConfigurationManagerObject.h +++ b/DynamicTablesPkg/Include/ConfigurationManagerObject.h @@ -86,25 +86,11 @@ typedef UINT32 CM_OBJECT_ID; =20 /** A mask for Object ID */ -#define OBJECT_ID_MASK 0xFF +#define OBJECT_ID_MASK 0x000000FF =20 /** A mask for Namespace ID */ -#define NAMESPACE_ID_MASK 0xF - -/** Starting bit position for Namespace ID -*/ -#define NAMESPACE_ID_BIT_SHIFT 28 - -/** The EOBJECT_NAMESPACE_ID enum describes the defined namespaces - for the Configuration Manager Objects. -*/ -typedef enum ObjectNameSpaceID { - EObjNameSpaceStandard, ///< Standard Objects Namespace - EObjNameSpaceArm, ///< ARM Objects Namespace - EObjNameSpaceOem =3D 0x8, ///< OEM Objects Namespace - EObjNameSpaceMax -} EOBJECT_NAMESPACE_ID; +#define NAMESPACE_ID_MASK 0xF0000000 =20 /** A descriptor for Configuration Manager Objects. =20 @@ -133,19 +119,21 @@ typedef struct CmObjDescriptor { =20 @retval Returns the Namespace ID corresponding to the CmObjectID. **/ -#define GET_CM_NAMESPACE_ID(CmObjectId) \ - (((CmObjectId) >> NAMESPACE_ID_BIT_SHIFT) & \ - NAMESPACE_ID_MASK) +#define GET_CM_NAMESPACE_ID(CmObjectId) ((CmObjectId) & NAMESPACE_ID_MASK) + +/** Deprecated, use just CmObjectId. =20 -/** This macro returns the Object ID from the CmObjectID. + This macro returns the Object ID from the CmObjectID. =20 @param [in] CmObjectId The Configuration Manager Object ID. =20 @retval Returns the Object ID corresponding to the CmObjectID. **/ -#define GET_CM_OBJECT_ID(CmObjectId) ((CmObjectId) & OBJECT_ID_MASK) +#define GET_CM_OBJECT_ID(CmObjectId) (CmObjectId) =20 -/** This macro returns a Configuration Manager Object ID +/** Deprecated. Use just ObjectId. + + This macro returns a Configuration Manager Object ID from the NameSpace ID and the ObjectID. =20 @param [in] NameSpaceId The namespace ID for the Object. @@ -153,38 +141,39 @@ typedef struct CmObjDescriptor { =20 @retval Returns the Configuration Manager Object ID. **/ -#define CREATE_CM_OBJECT_ID(NameSpaceId, ObjectId) = \ - ((((NameSpaceId) & NAMESPACE_ID_MASK) << NAMESPACE_ID_BIT_SHIFT)= | \ - ((ObjectId) & OBJECT_ID_MASK)) +#define CREATE_CM_OBJECT_ID(NameSpaceId, ObjectId) (ObjectId) + +/** Deprecated, use just ObjectId. =20 -/** This macro returns a Configuration Manager Object ID + This macro returns a Configuration Manager Object ID in the Standard Object Namespace. =20 @param [in] ObjectId The Object ID. =20 @retval Returns a Standard Configuration Manager Object ID. **/ -#define CREATE_CM_STD_OBJECT_ID(ObjectId) \ - (CREATE_CM_OBJECT_ID (EObjNameSpaceStandard, ObjectId)) +#define CREATE_CM_STD_OBJECT_ID(ObjectId) (ObjectId) =20 -/** This macro returns a Configuration Manager Object ID +/** Deprecated, use just ObjectId. + + This macro returns a Configuration Manager Object ID in the ARM Object Namespace. =20 @param [in] ObjectId The Object ID. =20 @retval Returns an ARM Configuration Manager Object ID. **/ -#define CREATE_CM_ARM_OBJECT_ID(ObjectId) \ - (CREATE_CM_OBJECT_ID (EObjNameSpaceArm, ObjectId)) +#define CREATE_CM_ARM_OBJECT_ID(ObjectId) (ObjectId) + +/** Deprecated, use just ObjectId. =20 -/** This macro returns a Configuration Manager Object ID + This macro returns a Configuration Manager Object ID in the OEM Object Namespace. =20 @param [in] ObjectId The Object ID. =20 @retval Returns an OEM Configuration Manager Object ID. **/ -#define CREATE_CM_OEM_OBJECT_ID(ObjectId) \ - (CREATE_CM_OBJECT_ID (EObjNameSpaceOem, ObjectId)) +#define CREATE_CM_OEM_OBJECT_ID(ObjectId) (ObjectId) =20 #endif // CONFIGURATION_MANAGER_OBJECT_H_ diff --git a/DynamicTablesPkg/Include/StandardNameSpaceObjects.h b/DynamicT= ablesPkg/Include/StandardNameSpaceObjects.h index 0ba6b16369..053ef937a4 100644 --- a/DynamicTablesPkg/Include/StandardNameSpaceObjects.h +++ b/DynamicTablesPkg/Include/StandardNameSpaceObjects.h @@ -15,6 +15,7 @@ =20 #include #include +#include =20 #pragma pack(1) =20 @@ -44,9 +45,9 @@ typedef UINTN CM_OBJECT_TOKEN; in the Standard Namespace. */ typedef enum StdObjectID { - EStdObjCfgMgrInfo =3D 0x00000000, ///< 0 - Configuration Manager Info - EStdObjAcpiTableList, ///< 1 - ACPI table Info List - EStdObjSmbiosTableList, ///< 2 - SMBIOS table Info List + EStdObjCfgMgrInfo =3D EObjNameSpaceStandard, ///< 0 - Configuration Mana= ger Info, namespace starts at 0 + EStdObjAcpiTableList, ///< 1 - ACPI table Info List + EStdObjSmbiosTableList, ///< 2 - SMBIOS table Info Li= st EStdObjMax } ESTD_OBJECT_ID; =20 --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#63581): https://edk2.groups.io/g/devel/message/63581 Mute This Topic: https://groups.io/mt/75910565/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Mar 29 11:52:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+63582+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63582+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1596212378; cv=none; d=zohomail.com; s=zohoarc; b=jgUx4OJlbAdUrv395t+BUZLIIh2VrNp4O8G38DphIu0xGRRASkVheShss253axij5ExRfZJJAxL8BpAUdz4Z6yo1Hc/Yu09FDFw9oifkXEGeAAXnzqxDJNVLPPLc/O9xnCT8TznpLWXsa6IaIcsNcDaTBkdpg8LXnN+doUyMEyM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596212378; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=pGQsGbrZUDopr86CSMAv7qybfEGHUlOGYanCWW1hdSY=; b=SjVS33zARjmB9TXFTGCuvuB7/sb86RRyTGNXsawIk9LT8OdQ0wb85li2DBcClcDj7u02fFSQL7PftXhaZWnXKCrOsc8Rfb8Pa1e5dcWxpQKB/NqfxMVLU6BZAevSGxc5S3YGjZ1vlgSmy4qkGZJLnF86ADmOlNbPDA7BoXJDNEQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63582+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1596212378627394.9323360271451; Fri, 31 Jul 2020 09:19:38 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 2ePFYY1788612xRv3NTK8e7s; Fri, 31 Jul 2020 09:19:38 -0700 X-Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) by mx.groups.io with SMTP id smtpd.web12.386.1596212373674432623 for ; Fri, 31 Jul 2020 09:19:34 -0700 X-Received: by mail-wm1-f50.google.com with SMTP id g10so6716311wmc.1 for ; Fri, 31 Jul 2020 09:19:33 -0700 (PDT) X-Gm-Message-State: TOfukgIqa1Hj2VAspLULuQLax1787277AA= X-Google-Smtp-Source: ABdhPJwJVwgLIpgvkgEiwtX/7OYk1TQwiqLDlDALbqD3UYAbw81ONIqV+YahVabKrWZkxk/7rdxIeQ== X-Received: by 2002:a1c:7f17:: with SMTP id a23mr4345034wmd.28.1596212371605; Fri, 31 Jul 2020 09:19:31 -0700 (PDT) X-Received: from localhost.localdomain (cpc159317-cmbg20-2-0-cust162.5-4.cable.virginm.net. [81.111.29.163]) by smtp.gmail.com with ESMTPSA id v11sm14149739wrr.10.2020.07.31.09.19.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:19:30 -0700 (PDT) From: "Tomas Pilar (tpilar)" To: devel@edk2.groups.io Cc: Sami Mujawar , Alexei Fedorov Subject: [edk2-devel] [PATCH 3/8] DynamicTablesPkg: Add ConfigurationManagerDumpApp Date: Fri, 31 Jul 2020 17:19:21 +0100 Message-Id: <20200731161926.341330-4-tomas@nuviainc.com> In-Reply-To: <20200731161926.341330-1-tomas@nuviainc.com> References: <20200731161926.341330-1-tomas@nuviainc.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,tomas@nuviainc.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1596212378; bh=4GEBNj0zfoulXzOZmPVoYByVuU/eTQApL0zpYokQixo=; h=Cc:Date:From:Reply-To:Subject:To; b=LgZVQjwBZdBLGnU1Ar0AYJcsCgVixH/9clepH20VJJCPA/Fp2/fie0UTvOw271MiGJu s44HO+PXxRoD8MepR9qdKMztceK87OPNWjUyhTqVPz4j/F8V6lnIwUJhF5J+R8Jf8pc5L c/ubzzRkBXdlNZS5oMGLmCkl8NhCUEDoYRY= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Simple application to dump the contents of the configuration manager loaded in the platform to the screen. There is no provision in the ConfigurationManagerProtocol for informing consumers of the contents of the database, so the app scans through the known namespaces using the GetObject method. Cc: Sami Mujawar Cc: Alexei Fedorov Signed-off-by: Tomas Pilar --- .../ConfigurationManagerDumpApp.c | 76 +++++++++++++++++++ .../ConfigurationManagerDumpApp.h | 8 ++ .../ConfigurationManagerDumpApp.inf | 42 ++++++++++ .../ConfigurationObjectStrings.c | 50 ++++++++++++ DynamicTablesPkg/DynamicTablesPkg.dsc | 6 ++ 5 files changed, 182 insertions(+) create mode 100644 DynamicTablesPkg/Applications/ConfigurationManagerDumpA= pp/ConfigurationManagerDumpApp.c create mode 100644 DynamicTablesPkg/Applications/ConfigurationManagerDumpA= pp/ConfigurationManagerDumpApp.h create mode 100644 DynamicTablesPkg/Applications/ConfigurationManagerDumpA= pp/ConfigurationManagerDumpApp.inf create mode 100644 DynamicTablesPkg/Applications/ConfigurationManagerDumpA= pp/ConfigurationObjectStrings.c diff --git a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/Conf= igurationManagerDumpApp.c b/DynamicTablesPkg/Applications/ConfigurationMana= gerDumpApp/ConfigurationManagerDumpApp.c new file mode 100644 index 0000000000..15936c78c1 --- /dev/null +++ b/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/Configurati= onManagerDumpApp.c @@ -0,0 +1,76 @@ +#include +#include +#include +#include + +#include "ConfigurationManagerDumpApp.h" + +EDKII_CONFIGURATION_MANAGER_PROTOCOL *mCfgMgr; + +EFI_STATUS +EFIAPI +UefiMain( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE * SystemTable + ) +{ + EFI_STATUS Status =3D gBS->LocateProtocol ( + &gEdkiiConfigurationManagerProtocolGuid, NULL, (VOID **)&mCfgMgr); + + UINTN ObjectId; + CM_OBJ_DESCRIPTOR CmObject; + UINTN Count =3D 0; + + + if (EFI_ERROR(Status)) { + Print(L"No Configuration Manager installed!\n"); + return EFI_UNSUPPORTED; + } + + for (ObjectId =3D EObjNameSpaceStandard; ObjectId < EStdObjMax; ObjectId= ++) { + Status =3D mCfgMgr->GetObject (mCfgMgr, ObjectId, CM_NULL_TOKEN, &CmOb= ject); + if (EFI_ERROR(Status)) { + continue; + } + + Print ( + L"<%s>::<%s>\n", + ObjectNameSpaceString[EObjNameSpaceStandard], + StdObjectString[ObjectId - EObjNameSpaceStandard]); + + Print ( + L"Id=3D%x Size=3D0x%x at=3D%p count=3D%d\n", + CmObject.ObjectId, + CmObject.Size, + CmObject.Count, + CmObject.Count); + + Count++; + } + + for (ObjectId =3D EObjNameSpaceArm; ObjectId < EArmObjMax; ObjectId++) { + Status =3D mCfgMgr->GetObject (mCfgMgr, ObjectId, CM_NULL_TOKEN, &CmOb= ject); + if (EFI_ERROR(Status)) { + continue; + } + + Print ( + L"<%s>::<%s>\n", + ObjectNameSpaceString[EObjNameSpaceArm], + ArmObjectString[ObjectId - EObjNameSpaceArm]); + + Print ( + L"Id=3D%x Size=3D0x%x at=3D%p count=3D%d\n", + CmObject.ObjectId, + CmObject.Size, + CmObject.Count, + CmObject.Count); + + Count++; + } + + Print(L"Found %d objects\n", Count); + return EFI_SUCCESS; +} + + diff --git a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/Conf= igurationManagerDumpApp.h b/DynamicTablesPkg/Applications/ConfigurationMana= gerDumpApp/ConfigurationManagerDumpApp.h new file mode 100644 index 0000000000..5017d55b4a --- /dev/null +++ b/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/Configurati= onManagerDumpApp.h @@ -0,0 +1,8 @@ +#ifndef CONFIGURATION_MANAGER_DUMP_APP_H_ +#define CONFIGURATION_MANAGER_DUMP_APP_H_ + +extern CHAR16 *ArmObjectString[]; +extern CHAR16 *ObjectNameSpaceString[]; +extern CHAR16 *StdObjectString[]; + +#endif diff --git a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/Conf= igurationManagerDumpApp.inf b/DynamicTablesPkg/Applications/ConfigurationMa= nagerDumpApp/ConfigurationManagerDumpApp.inf new file mode 100644 index 0000000000..9f8beb916d --- /dev/null +++ b/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/Configurati= onManagerDumpApp.inf @@ -0,0 +1,42 @@ +## @file +# Application that will dump the contents of the configuration +# manager. +# +# Copyright (c) 2020, ARM Limited. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x00010019 + BASE_NAME =3D ConfigurationManagerDumpApp + FILE_GUID =3D 1E12FA81-8465-4D78-918F-735DB8CB828B + MODULE_TYPE =3D UEFI_APPLICATION + VERSION_STRING =3D 1.0 + ENTRY_POINT =3D UefiMain + +# +# The following information is for reference only and not required by the = build tools. +# +# VALID_ARCHITECTURES =3D ARM AARCH64 +# + +[Sources] + ConfigurationManagerDumpApp.c + ConfigurationManagerDumpApp.h + ConfigurationObjectStrings.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + DynamicTablesPkg/DynamicTablesPkg.dec + +[LibraryClasses] + UefiLib + UefiBootServicesTableLib + UefiApplicationEntryPoint + +[Protocols] + gEdkiiConfigurationManagerProtocolGuid # PROTOCOL PRODUCES + + diff --git a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/Conf= igurationObjectStrings.c b/DynamicTablesPkg/Applications/ConfigurationManag= erDumpApp/ConfigurationObjectStrings.c new file mode 100644 index 0000000000..ad8dbb6354 --- /dev/null +++ b/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/Configurati= onObjectStrings.c @@ -0,0 +1,50 @@ + +CHAR16 *ArmObjectString[] =3D { + L"Reserved", + L"Boot Architecture Info", + L"CPU Info", + L"Power Management Profile Info", + L"GIC CPU Interface Info", + L"GIC Distributor Info", + L"GIC MSI Frame Info", + L"GIC Redistributor Info", + L"GIC ITS Info", + L"Serial Console Port Info", + L"Serial Debug Port Info", + L"Generic Timer Info", + L"Platform GT Block Info", + L"Generic Timer Block Frame Info", + L"Platform Generic Watchdog", + L"PCI Configuration Space Info", + L"Hypervisor Vendor Id", + L"Fixed feature flags for FADT", + L"ITS Group", + L"Named Component", + L"Root Complex", + L"SMMUv1 or SMMUv2", + L"SMMUv3", + L"PMCG", + L"GIC ITS Identifier Array", + L"ID Mapping Array", + L"SMMU Interrupt Array", + L"Processor Hierarchy Info", + L"Cache Info", + L"Processor Node ID Info", + L"CM Object Reference", + L"Memory Affinity Info", + L"Device Handle Acpi", + L"Device Handle Pci", + L"Generic Initiator Affinity" +}; + +CHAR16 *ObjectNameSpaceString[] =3D { + L"Standard Objects Namespace", + L"ARM Objects Namespace", + L"OEM Objects Namespace" +}; + +CHAR16 *StdObjectString[] =3D { + L"Configuration Manager Info", + L"ACPI table Info List", + L"SMBIOS table Info List" +}; diff --git a/DynamicTablesPkg/DynamicTablesPkg.dsc b/DynamicTablesPkg/Dynam= icTablesPkg.dsc index 346fa8ccdd..367e06a855 100644 --- a/DynamicTablesPkg/DynamicTablesPkg.dsc +++ b/DynamicTablesPkg/DynamicTablesPkg.dsc @@ -30,6 +30,11 @@ PrintLib|MdePkg/Library/BasePrintLib/BasePrintLib.inf UefiBootServicesTableLib|MdePkg/Library/UefiBootServicesTableLib/UefiBoo= tServicesTableLib.inf UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntry= Point.inf + UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiA= pplicationEntryPoint.inf + UefiLib|MdePkg/Library/UefiLib/UefiLib.inf + DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf + UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/U= efiRuntimeServicesTableLib.inf + =20 [LibraryClasses.ARM, LibraryClasses.AARCH64] NULL|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf @@ -38,6 +43,7 @@ =20 [Components.common] DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf + DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/ConfigurationM= anagerDumpApp.inf =20 [BuildOptions] *_*_*_CC_FLAGS =3D -DDISABLE_NEW_DEPRECATED_INTERFACES --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#63582): https://edk2.groups.io/g/devel/message/63582 Mute This Topic: https://groups.io/mt/75910567/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Mar 29 11:52:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+63583+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63583+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1596212379; cv=none; d=zohomail.com; s=zohoarc; b=TvE6EStgcfDfx/nYzuBn5xZmJ4xU/AZYxGRvfkqei6JNyF55IlC5R1k9w+J3YHIWXWrP0tygR4S/ZIJYcFTOAFZCLgW9RP4MOfmAhws9hzfvjp4n8LWLxs5XkCZvLsELZhUATcb2xpk4jaRUDn000gc6wuzGT6TT4FdOHBk1fuA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596212379; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=KP/lBygZs98hwAyMBi0pn79xEsskmSX3KboBmrk9Qy0=; b=cftAvM6fncs2PMSWtychy3a/CWUgfk8ukdAsuM8FuJq1BUdRJ5yC314EA+7GDlIGsl7BxxP//wknDHDq1LNoHx14WrEWcHPAQhg9OlAlI4TTgcOMMV7cR+VkUER+KmdvBx6okzXCorncnSJ9phqWcngjos/HtnLjE47HjoF5yzg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63583+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1596212379544650.3178452493169; Fri, 31 Jul 2020 09:19:39 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id vsZzYY1788612xemLDBq6bkq; Fri, 31 Jul 2020 09:19:39 -0700 X-Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by mx.groups.io with SMTP id smtpd.web10.439.1596212374340309222 for ; Fri, 31 Jul 2020 09:19:34 -0700 X-Received: by mail-wm1-f67.google.com with SMTP id c80so8990243wme.0 for ; Fri, 31 Jul 2020 09:19:34 -0700 (PDT) X-Gm-Message-State: BbwdvjU6GtySHr7XdDkrEq7Wx1787277AA= X-Google-Smtp-Source: ABdhPJzjs/3t6mh3qmsIrpGGQnCEg0/lGVG4XHIp5BIdx46je/Y46TJYAMwXFMdZwfbmoazs16lG5Q== X-Received: by 2002:a1c:9e84:: with SMTP id h126mr4266410wme.61.1596212372496; Fri, 31 Jul 2020 09:19:32 -0700 (PDT) X-Received: from localhost.localdomain (cpc159317-cmbg20-2-0-cust162.5-4.cable.virginm.net. [81.111.29.163]) by smtp.gmail.com with ESMTPSA id v11sm14149739wrr.10.2020.07.31.09.19.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:19:31 -0700 (PDT) From: "Tomas Pilar (tpilar)" To: devel@edk2.groups.io Cc: Sami Mujawar , Alexei Fedorov Subject: [edk2-devel] [PATCH 4/8] DynamicTablesPkg: Update ConfigurationManagerProtocol Date: Fri, 31 Jul 2020 17:19:22 +0100 Message-Id: <20200731161926.341330-5-tomas@nuviainc.com> In-Reply-To: <20200731161926.341330-1-tomas@nuviainc.com> References: <20200731161926.341330-1-tomas@nuviainc.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,tomas@nuviainc.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1596212379; bh=UiZMnQORidHadx7hFXO67vFLhCzNiTp9/F1oYmkRwhA=; h=Cc:Date:From:Reply-To:Subject:To; b=boY0aE0z2dE5EnlBvOq+MPzW38TZ0h0+ab7N6U+R07ytsUGhLZnWfBelSvMjIGy/Zdl Cmhfm39bS7UcEdO87xO3fi2duaF9Pn0ZLjMZ1pHrUwekH+ZG0SUbDwUOo8XktbDuEDABz cNVe1VxDUimIuceOB+ldrwjKSrnJU+C06Q4= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" The Configuration Manager Protocol is updated to include a FreeObject function that must be used by the callers to GetObject to clean up any dynamic allocations and other resources reserved by the Configuration Manager in the process of fulfilling the request in GetObject. A NULL inline static FreeObject function is provided for the ease of transition for v1.0 managers. Cc: Sami Mujawar Cc: Alexei Fedorov Signed-off-by: Tomas Pilar --- .../Protocol/ConfigurationManagerProtocol.h | 83 ++++++++++++++++++- 1 file changed, 80 insertions(+), 3 deletions(-) diff --git a/DynamicTablesPkg/Include/Protocol/ConfigurationManagerProtocol= .h b/DynamicTablesPkg/Include/Protocol/ConfigurationManagerProtocol.h index 7de1be3b23..72bf3c79bc 100644 --- a/DynamicTablesPkg/Include/Protocol/ConfigurationManagerProtocol.h +++ b/DynamicTablesPkg/Include/Protocol/ConfigurationManagerProtocol.h @@ -25,7 +25,7 @@ =20 /** This macro defines the Configuration Manager Protocol Revision. */ -#define EDKII_CONFIGURATION_MANAGER_PROTOCOL_REVISION CREATE_REVISION (1,= 0) +#define EDKII_CONFIGURATION_MANAGER_PROTOCOL_REVISION CREATE_REVISION (1,= 1) =20 #pragma pack(1) =20 @@ -35,10 +35,18 @@ typedef struct ConfigurationManagerProtocol EDKII_CONFIGURATION_MANAGER_PR= OTOCOL; typedef struct PlatformRepositoryInfo EDKII_PLATFORM_REPOSITORY_INFO; =20 -/** The GetObject function defines the interface implemented by the +/** The GetObject function defines the interface of the Configuration Manager Protocol for returning the Configuration Manager Objects. =20 + If Token is CM_NULL_TOKEN, the function provides in its output all + the objects of the given CmObjectId. If the Token is not CM_NULL_TOKEN, + the function provides only those object that match both the CmObjectId + and Token. + + The memory in CmObject.Data may be static or dynamic. The caller of th= is + function must call FreeObject on the CmObject populated by this functi= on. + @param [in] This Pointer to the Configuration Manager Protocol. @param [in] CmObjectId The Configuration Manager Object ID. @param [in] Token An optional token identifying the object. If @@ -62,10 +70,24 @@ EFI_STATUS IN OUT CM_OBJ_DESCRIPTOR * CONST CmObject ); =20 -/** The SetObject function defines the interface implemented by the +/** The SetObject function defines the interface of the Configuration Manager Protocol for updating the Configuration Manager Objects. =20 + If Token is CM_NULL_TOKEN, and CmObject is not NULL, then the objects + in the configuration manager that match the CmObjectId and do not + have an associated cross reference Token are replaced by the contents = of + CmObject. + + If Token is not CM_NULL_TOKEN and CmObject is not NULL, then the objec= ts + that match both CmObjectId and Token in the configuration manager are + replaced with the contents of CmObject. + + If CmObject is NULL, then objects that match the CmObjectId and Token + are removed from the configuration manager. If Token is also CM_NULL_T= OKEN, + then all objects of given CmObjectId are removed, regardless of their + cross-reference Token. + @param [in] This Pointer to the Configuration Manager Protocol. @param [in] CmObjectId The Configuration Manager Object ID. @param [in] Token An optional token identifying the object. If @@ -90,6 +112,29 @@ EFI_STATUS IN CM_OBJ_DESCRIPTOR * CONST CmObject ); =20 +/** The FreeObject function defines the interface of the + Configuration Manager Protocol for correctly freeing resources + that have been reserved by calls to the GetObject interface. + + The caller of GetObject must use this function to dispose of CmObject + populated by the GetObject call when the CmObject is no longer needed. + + If an implementation of the Configuration Manager Protocol does not + use dynamically allocated memory, this function should simply return + EFI_SUCCESS. + + @param [in] This Pointer to the Configuration Manager Protocol + @param [in] CmObject Pointer to the CmObject that has been popula= ted + by the GetObject function and is to be destr= oyed. + @retval EFI_SUCCESS The CmObject was successfully destroyed +**/ +typedef +EFI_STATUS +(EFIAPI * EDKII_CONFIGURATION_MANAGER_FREE_OBJECT) ( + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST This, + IN CM_OBJ_DESCRIPTOR * CmObject + ); + /** The EDKII_CONFIGURATION_MANAGER_PROTOCOL structure describes the Configuration Manager Protocol interface. */ @@ -111,12 +156,44 @@ typedef struct ConfigurationManagerProtocol { provisioned by the Configuration Manager. */ EDKII_PLATFORM_REPOSITORY_INFO * PlatRepoInfo; + + /** The interface used to destroy CmObject instances + populated by calls to GetObject + */ + EDKII_CONFIGURATION_MANAGER_FREE_OBJECT FreeObject; } EDKII_CONFIGURATION_MANAGER_PROTOCOL; =20 /** The Configuration Manager Protocol GUID. */ extern EFI_GUID gEdkiiConfigurationManagerProtocolGuid; =20 +/** Inline NULL implementation of FreeObject for backward compatibility + of configuration managers that do not require to deallocate any + memory following a call to GetObject. + + @param[in] This Pointer to Configuration Manager Protocol instan= ce + @param[in] CmObject Pointer to CmObject populated by GetObject + + @retval EFI_SUCCESS Successfully handled CmObject. + @retval EFI_INVALID_PARAMETER CmObject is NULL. + @retval EFI_INVALID_PARAMETER This is NULL. + @retval EFI_INVALID_PARAMETER CmObject is not valid. +**/ +static +inline +EFI_STATUS +EFIAPI EdkiiCfgMgrFreeObjectNull ( + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST This, + IN CM_OBJ_DESCRIPTOR * CmObject + ) +{ + if (!This || !CmObject) { + return EFI_INVALID_PARAMETER; + } + + return EFI_SUCCESS; +} + #pragma pack() =20 #endif // CONFIGURATION_MANAGER_PROTOCOL_H_ --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#63583): https://edk2.groups.io/g/devel/message/63583 Mute This Topic: https://groups.io/mt/75910568/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Mar 29 11:52:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+63584+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63584+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1596212380; cv=none; d=zohomail.com; s=zohoarc; b=hvsBFyDMJrnLpHiKAsCfHYh5LIvCsCBL/RCqClxW0I+YRc5O1LKf7CMMQqUn4vEROko/0RVKX/LXcmVnHjnD01DiL/X8f/Pkuu8msxNKbKDk1JW7A7c69wbjum1IjgPBO7LHk/k6xvuqB+jnReQGJWc1miGn+0eH83YSrXZ+XKY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596212380; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=6bcDZ5lTfXQaLpLecnlm26JP3k9ge4EzGoqCPx102oI=; b=hsS7gOhbT2N+YtpEkrFBnATYtCSzrEy1OrPQUnGalY4p0pNeTP8F5j3p3oguSUBj3b3WMHlHfMNsBf4etvB9HtgXg3Bp25DOGCMwFvsRusX9INqp0LnM2ZLFDOptPW+C5Z5YoNCU+KXE0Buxy8psg8p7Hxe+fxAsBfbwEmrv9M0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63584+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1596212380327967.4127693162143; Fri, 31 Jul 2020 09:19:40 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 4ZTKYY1788612xEauOs5QK3M; Fri, 31 Jul 2020 09:19:39 -0700 X-Received: from mail-wr1-f42.google.com (mail-wr1-f42.google.com [209.85.221.42]) by mx.groups.io with SMTP id smtpd.web10.441.1596212376194265621 for ; Fri, 31 Jul 2020 09:19:36 -0700 X-Received: by mail-wr1-f42.google.com with SMTP id r4so25547803wrx.9 for ; Fri, 31 Jul 2020 09:19:35 -0700 (PDT) X-Gm-Message-State: GaZMQbRR7hJ88KhWR0HfsYsdx1787277AA= X-Google-Smtp-Source: ABdhPJwkLMdbb6d/DaiRTRx86ZRvNo0sRmljgLlDnQ9UCxQOxArueHSvjCYSpb1vNM6hDXS5jEZGgg== X-Received: by 2002:a5d:4a03:: with SMTP id m3mr3985160wrq.186.1596212373727; Fri, 31 Jul 2020 09:19:33 -0700 (PDT) X-Received: from localhost.localdomain (cpc159317-cmbg20-2-0-cust162.5-4.cable.virginm.net. [81.111.29.163]) by smtp.gmail.com with ESMTPSA id v11sm14149739wrr.10.2020.07.31.09.19.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:19:32 -0700 (PDT) From: "Tomas Pilar (tpilar)" To: devel@edk2.groups.io Cc: Sami Mujawar , Alexei Fedorov Subject: [edk2-devel] [PATCH 5/8] DynamicTablesPkg: Add CfgMgrProtocol helper functions Date: Fri, 31 Jul 2020 17:19:23 +0100 Message-Id: <20200731161926.341330-6-tomas@nuviainc.com> In-Reply-To: <20200731161926.341330-1-tomas@nuviainc.com> References: <20200731161926.341330-1-tomas@nuviainc.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,tomas@nuviainc.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1596212379; bh=SzG2I0kSFyLDNSf2deU2Ov6+4hwkdrzdjdIVbbe0UUE=; h=Cc:Date:From:Reply-To:Subject:To; b=qV8xJvJY+wPZb5otmKfrFAviKHjZ02Mr87oj60rLMAGm9mL8QPLwYbMvNI0bCyNb5KG NUU0p3J1bzlNnJyeC9F2m3gpo75m3DrehvYhHlJG1ZJCjPK1xTSNjLE6L30g5cuAT4ela UMAkD+wBNv2sMLl+M7z+Zx+wWXd2wWs7M9g= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Add functions abstracting adding and removing of objects using the ConfigurationManagerProtocol to TableHelperLib. Also add helpers for writing component library constructors for component libraries populating a ConfigurationManager. Cc: Sami Mujawar Cc: Alexei Fedorov Signed-off-by: Tomas Pilar --- .../Include/Library/TableHelperLib.h | 170 ++++++++ .../Common/TableHelperLib/TableHelper.c | 379 +++++++++++++++++- .../Common/TableHelperLib/TableHelperLib.inf | 6 + 3 files changed, 554 insertions(+), 1 deletion(-) diff --git a/DynamicTablesPkg/Include/Library/TableHelperLib.h b/DynamicTab= lesPkg/Include/Library/TableHelperLib.h index e4a8dfa046..0d3d1bbd60 100644 --- a/DynamicTablesPkg/Include/Library/TableHelperLib.h +++ b/DynamicTablesPkg/Include/Library/TableHelperLib.h @@ -12,6 +12,176 @@ #ifndef TABLE_HELPER_LIB_H_ #define TABLE_HELPER_LIB_H_ =20 +#include + +/** + Get a unique token that can be used for configuration object + cross referencing. + + @retval Unique arbitrary cross reference token. +**/ +UINTN +EFIAPI +GetNewToken(); + +/** + Return the count of objects of a given ObjectId. + + @param[in] CmObjectId The id of the desired configuration objects. + @param[out] ItemCount Number of objects with given ObjectId. +**/ +EFI_STATUS +EFIAPI +CfgMgrCountObjects ( + IN CONST CM_OBJECT_ID CmObjectId, + OUT UINT32 *ItemCount + ); + +/** + Get a single object form the configuration manager with the + matching ObjectId regardless of any cross reference tokens. + + @param[in] CmObjectId The id of the desired configuration object + @param[out] Buffer Buffer containing the payload of the CmObject. + + @retval EFI_SUCCESS Payload was successfully returned + @retval EFI_NOT_FOUND There was no such object + @retval EFI_UNSUPPORTED ConfigurationManangerProtocol is not installed +**/ +EFI_STATUS +EFIAPI +CfgMgrGetSimpleObject( + IN CONST CM_OBJECT_ID CmObjectId, + OUT VOID ** Buffer + ); + +/** + Prototype for an initialiser function to be used by component + libraries that are linked as NULL libraries to a Configuration + Manager binary and used to populate said Configuration Manager + with objects. + + @param[in] CfgMgrProtocol The newly installed ConfigurationManagerProto= col + that can be used by the library to populate t= he + Configuration Manager with objects. +**/ +typedef EFI_STATUS (EFIAPI *CFG_MGR_COMPONENT_LIB_INIT) ( + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CfgMgrProtocol + ); + +/** + Register a callback inintialiser to be called when a configuration + manager is installed. The initialiser function is expected to + populate the newly installed configuration manager with objects when + called. + + This helper should be used by component libraries that want to + provide configuration objects and are to be linked in as NULL + libraries into the configuration manager binary. + + @param[in] InitFunction An initialiser function that will be called wh= en + a configuration manager becomes available. + @retval EFI_OUT_OF_RESOURCES Failed to allocate necessary memory. + @retval EFI_SUCCESS Registration was successful. +**/ +EFI_STATUS +EFIAPI +RegisterForCfgManager ( + IN CONST CFG_MGR_COMPONENT_LIB_INIT InitFunction + ); + +/** + Remove a configuration object from the configuration manager. If a + cross reference token is supplied, only objects referenced by that + token will be removed. If a token is not supplied, all objects of the + given type will be removed. + + @param[in] CmObjectId The id of the object that is to be removed. + @param[in] Token Unique cross-reference token of the object to be= removed. + + @retval EFI_UNSUPPORTED There is no configuration manager installed. + @retval EFI_NOT_FOUND The combination of id and token was not found in= the + configuration manager. + @retval EFI_SUCCESS Object was successfully deleted. +**/ +EFI_STATUS +EFIAPI +CfgMgrRemoveObject ( + IN CONST CM_OBJECT_ID CmObjectId, + IN CONST CM_OBJECT_TOKEN Token OPTIONAL + ); + +/** + Add an instance of object to the configuration manager. If an object with + the specified object id and token already exists in the manager, append = the + provided object to the existing list. Otherwise, create a new list with = this + object being the only member. + + @param[in] CmObjectId The id of the object that is to be added. + @param[in] Token The unique cross-reference token for this object. + @param[in] Buffer The instance of the object being added. + @param[in] BufferSize Size of Buffer in bytes. + + @retval EFI_OUT_OF_RESOURCES Failed to allocate required memory when a= ppending data + @retval EFI_UNSUPPORTED There is no Configuration Manager install= ed + @retval EFI_SUCCESS Object was successfully added to the Conf= iguration Manager +**/ +EFI_STATUS +EFIAPI +CfgMgrAddObject ( + IN CONST CM_OBJECT_ID CmObjectId, + IN CONST CM_OBJECT_TOKEN Token OPTIONAL, + IN VOID * Buffer, + IN UINTN BufferSize + ); + +/** + Add multiple objects of the same type/token to the configuration manager. + If an object with the specified object id and token already exists in the + manager, append the provided objects to the existing list. Otherwise, cr= eate + a new list. + + @param[in] CmObjectId The id of the object that is to be added. + @param[in] Token The unique cross-reference token for this object. + @param[in] Buffer The instance of the objects being added. + @param[in] BufferSize Size of Buffer in bytes. + @param[in] ItemCount Number of instances of object in the Buffer. + + @retval EFI_OUT_OF_RESOURCES Failed to allocate required memory when a= ppending data. + @retval EFI_UNSUPPORTED There is no Configuration Manager install= ed. + @retval EFI_SUCCESS Object was successfully added to the Conf= iguration Manager. +**/ +EFI_STATUS +EFIAPI +CfgMgrAddObjects ( + IN CONST CM_OBJECT_ID CmObjectId, + IN CONST CM_OBJECT_TOKEN Token OPTIONAL, + IN VOID * Buffer, + IN UINTN BufferSize, + IN UINT32 ItemCount + ); + +/** + Retrieve an object with a given id from the installed configuration + manager. If a token is not specified, returns all objects of given + id, regardless of token. The methods unwraps the CmObject abstraction + and only returns the payloads. + + @param[in] CmObjectId The id of the desired configuration objects. + @param[in] Token Optional cross reference token. If not supplied= , all. + objects of the given id are returned. + @param[out] Buffer Buffer containing a number of payloads of CmObj= ects. + @param[out] ItemCount The count of payloads in Buffer. +**/ +EFI_STATUS +EFIAPI +CfgMgrGetObjects ( + IN CONST CM_OBJECT_ID CmObjectId, + IN CONST CM_OBJECT_TOKEN Token OPTIONAL, + OUT VOID ** Buffer OPTIONAL, + OUT UINT32 * ItemCount OPTIONAL + ); + /** The GetCgfMgrInfo function gets the CM_STD_OBJ_CONFIGURATION_MANAGER_I= NFO object from the Configuration Manager. =20 diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c b= /DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c index fc6cf3b088..18c0e95e0d 100644 --- a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c +++ b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c @@ -6,9 +6,13 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/ =20 #include + #include -#include #include +#include +#include +#include +#include =20 // Module specific include files. #include @@ -16,6 +20,378 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include =20 +/** + Get a unique token that can be used for configuration object + cross referencing. + + @retval Unique arbitrary cross reference token +**/ +UINTN +EFIAPI +GetNewToken() +{ + UINTN Token; + EFI_STATUS Status =3D gBS->GetNextMonotonicCount(&Token); + if (EFI_ERROR(Status)) { + return CM_NULL_TOKEN; + } + + return Token; +} + +/** + Event callback for executing the registered component library + inintialiser with the newly installed ConfigurationManagerProtocol + as the only parameter. +**/ +STATIC +VOID +EFIAPI +ComponentInitEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + ASSERT (Context !=3D NULL); + + CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CfgMgrProtocol; + CFG_MGR_COMPONENT_LIB_INIT InitFunction =3D Context; + + EFI_STATUS Status =3D gBS->LocateProtocol ( + &gEdkiiConfigurationManagerProtocolGuid, + NULL, + (VOID **) &CfgMgrProtocol); + + + if (EFI_ERROR(Status)) { // Should never happen + gBS->CloseEvent(Event); + RegisterForCfgManager(InitFunction); + return; + } + + InitFunction(CfgMgrProtocol); +} + +/** + Register a callback inintialiser to be called when a configuration + manager is installed. The initialiser function is expected to + populate the newly installed configuration manager with objects when + called. + + This helper should be used by component libraries that want to + provide configuration objects and are to be linked in as NULL + libraries into the configuration manager binary. + + @param[in] InitFunction An initialiser function that will be called wh= en + a configuration manager becomes available. + @retval EFI_OUT_OF_RESOURCES Failed to allocate necessary memory + @retval EFI_SUCCESS Registration was successful +**/ +EFI_STATUS +EFIAPI +RegisterForCfgManager ( + CONST CFG_MGR_COMPONENT_LIB_INIT InitFunction + ) +{ + EFI_STATUS Status =3D EFI_NOT_STARTED; + EFI_EVENT InitEvent; + VOID *Registration; + + ASSERT(InitFunction !=3D NULL); + + Status =3D gBS->CreateEvent ( + EVT_NOTIFY_SIGNAL, + TPL_NOTIFY, + ComponentInitEvent, + InitFunction, + &InitEvent); + + if (EFI_ERROR(Status)) { + return Status; + } + + Status =3D gBS->RegisterProtocolNotify ( + &gEdkiiConfigurationManagerProtocolGuid, + InitEvent, + &Registration); + + if (EFI_ERROR(Status)) { + gBS->CloseEvent(InitEvent); + } + + return Status; +} + +/** + Return the count of objects of a given ObjectId. + If there are no objects, ItemCount is set to zero. + + @param[in] CmObjectId The id of the desired configuration objects. + @param[out] ItemCount Number of objects with given ObjectId. +**/ +EFI_STATUS +EFIAPI +CfgMgrCountObjects ( + IN CONST CM_OBJECT_ID CmObjectId, + OUT UINT32 *ItemCount + ) +{ + EFI_STATUS Status =3D EFI_NOT_STARTED; + + Status =3D CfgMgrGetObjects (CmObjectId, CM_NULL_TOKEN, NULL, ItemCount); + if (Status =3D=3D EFI_NOT_FOUND) { + *ItemCount =3D 0; + } + + return Status; +} + +/** + Retrieve an object with a given id from the installed configuration + manager. If a token is not specified, returns all objects of given + id, regardless of token. The methods unwraps the CmObject abstraction + and only returns the payloads. + + If Buffer is not NULL, the data will be returned in allocated memory. The + caller must free this memory when they are done with the data. + + If ItemCount is not NULL, the count of items matching the criteria + is returned. + + @param[in] CmObjectId The id of the desired configuration objects + @param[in] Token Optional cross reference token. If not supplied= , all + objects of the given id are returned. + @param[out] Buffer Buffer containing a number of payloads of CmObj= ects. + @param[out] ItemCount The count of payloads in Buffer +**/ +EFI_STATUS +EFIAPI +CfgMgrGetObjects ( + IN CONST CM_OBJECT_ID CmObjectId, + IN CONST CM_OBJECT_TOKEN Token OPTIONAL, + OUT VOID ** Buffer OPTIONAL, + OUT UINT32 * ItemCount OPTIONAL + ) +{ + EDKII_CONFIGURATION_MANAGER_PROTOCOL *CfgMgr; + EFI_STATUS Status; + + Status =3D gBS->LocateProtocol ( + &gEdkiiConfigurationManagerProtocolGuid, NULL, (VOID **) &CfgMgr); + if (EFI_ERROR(Status)) { + DEBUG ((DEBUG_ERROR, "ERROR: No Configuration Manager Protocol Found!\= n")); + return EFI_UNSUPPORTED; + } + + CM_OBJ_DESCRIPTOR Object; + + Status =3D CfgMgr->GetObject(CfgMgr, CmObjectId, Token, &Object); + if (EFI_ERROR(Status)) { + if (Status !=3D EFI_NOT_FOUND) { + DEBUG ( + (DEBUG_ERROR, + "ERROR: FADT: Failed to get <%s> [%r]\n", + CmObjectIdName (CmObjectId), + Status)); + } + + return Status; + } + + if (Buffer) { + *Buffer =3D AllocateCopyPool (Object.Size, Object.Data); + if (Buffer =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + } + + if (ItemCount) { + *ItemCount =3D Object.Count; + } + + if (CfgMgr->Revision >=3D CREATE_REVISION(1, 1)) { + CfgMgr->FreeObject(CfgMgr, &Object); + } + + return EFI_SUCCESS; +} + +/** + Get a single object form the configuration manager with the + matching ObjectId regardless of any cross reference tokens. + + @param[in] CmObjectId The id of the desired configuration object + @param[out] Buffer Buffer containing the payload of the CmObject. + + @retval EFI_SUCCESS Payload was successfully returned + @retval EFI_NOT_FOUND There was no such object + @retval EFI_UNSUPPORTED ConfigurationManangerProtocol is not installed +**/ +EFI_STATUS +EFIAPI +CfgMgrGetSimpleObject( + IN CONST CM_OBJECT_ID CmObjectId, + OUT VOID ** Buffer + ) +{ + EFI_STATUS Status; + + Status =3D CfgMgrGetObjects(CmObjectId, CM_NULL_TOKEN, Buffer, NULL); + if (Status =3D=3D EFI_NOT_FOUND) { + DEBUG ((DEBUG_ERROR, + "ERROR: Failed to get <%s> [%r]\n", + CmObjectIdName (CmObjectId), + Status)); + } + return Status; +} + +/** + Add an instance of object to the configuration manager. If an object with + the specified object id and token already exists in the manager, append = the + provided object to the existing list. Otherwise, create a new list with = this + object being the only member. + + @param[in] CmObjectId The id of the object that is to be added + @param[in] Token The unique cross-reference token for this object + @param[in] Buffer The instance of the object being added + @param[in] BufferSize Size of Buffer in bytes + + @retval EFI_OUT_OF_RESOURCES Failed to allocate required memory when a= ppending data + @retval EFI_UNSUPPORTED There is no Configuration Manager install= ed + @retval EFI_SUCCESS Object was successfully added to the Conf= iguration Manager +**/ +EFI_STATUS +EFIAPI +CfgMgrAddObject ( + IN CONST CM_OBJECT_ID CmObjectId, + IN CONST CM_OBJECT_TOKEN Token OPTIONAL, + IN VOID * Buffer, + IN UINTN BufferSize + ) +{ + EFI_STATUS Status; + EDKII_CONFIGURATION_MANAGER_PROTOCOL *CfgMgrProtocol; + CM_OBJ_DESCRIPTOR CurrentObject =3D { 0 }; + CM_OBJ_DESCRIPTOR NewObject; + + ASSERT(Buffer !=3D NULL); + ASSERT(BufferSize !=3D 0); + + Status =3D gBS->LocateProtocol ( + &gEdkiiConfigurationManagerProtocolGuid, NULL, (VOID **) &CfgMgrProtoc= ol); + + if (EFI_ERROR(Status)) { + return EFI_UNSUPPORTED; + } + + Status =3D CfgMgrProtocol->GetObject ( + CfgMgrProtocol, CmObjectId, Token, &CurrentObject); + + NewObject.ObjectId =3D CmObjectId; + NewObject.Count =3D 1 + CurrentObject.Count; + NewObject.Size =3D BufferSize +CurrentObject.Size; + + NewObject.Data =3D AllocateZeroPool(NewObject.Size); + if (NewObject.Data =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + CopyMem(NewObject.Data, CurrentObject.Data, CurrentObject.Size); // NOP = if CurrentObject does not exist + CopyMem((UINT8 *) NewObject.Data + CurrentObject.Size, Buffer, BufferSiz= e); + + Status =3D + CfgMgrProtocol->SetObject (CfgMgrProtocol, CmObjectId, Token, &NewObje= ct); + + FreePool (NewObject.Data); + return Status; +} + +/** + Add multiple objects of the same type/token to the configuration manager. + If an object with the specified object id and token already exists in the + manager, append the provided objects to the existing list. Otherwise, cr= eate + a new list. + + @param[in] CmObjectId The id of the object that is to be added. + @param[in] Token The unique cross-reference token for this object. + @param[in] Buffer The instance of the objects being added. + @param[in] BufferSize Size of Buffer in bytes. + @param[in] ItemCount Number of instances of object in the Buffer. + + @retval EFI_OUT_OF_RESOURCES Failed to allocate required memory when a= ppending data. + @retval EFI_UNSUPPORTED There is no Configuration Manager install= ed. + @retval EFI_SUCCESS Object was successfully added to the Conf= iguration Manager. +**/ +EFI_STATUS +EFIAPI +CfgMgrAddObjects ( + IN CONST CM_OBJECT_ID CmObjectId, + IN CONST CM_OBJECT_TOKEN Token OPTIONAL, + IN VOID * Buffer, + IN UINTN BufferSize, + IN UINT32 ItemCount + ) +{ + UINTN Index; + UINT8 *Cursor =3D Buffer; + UINTN ItemSize =3D BufferSize / ItemCount; + EFI_STATUS Status =3D EFI_NOT_STARTED; + + for (Index =3D 0; Index < ItemCount; Index++) { + Status =3D CfgMgrAddObject(CmObjectId, Token, Cursor, ItemSize); + if (EFI_ERROR(Status)) { + return Status; + } + Cursor +=3D ItemSize; + } + + return EFI_SUCCESS; +} + +/** + Remove a configuration object from the configuration manager. If a + cross reference token is supplied, only objects referenced by that + token will be removed. If a token is not supplied, all objects of the + given type will be removed. + + @param[in] CmObjectId The id of object that is to be removed + @param[in] Token Unique cross-reference token of the object to be= removed + + @retval EFI_UNSUPPORTED There is no configuration manager installed + @retval EFI_NOT_FOUND The combination of id and token was not found in= the + configuration manager + @retval EFI_SUCCESS Object was successfully deleted +**/ +EFI_STATUS +EFIAPI +CfgMgrRemoveObject ( + IN CONST CM_OBJECT_ID CmObjectId, + IN CONST CM_OBJECT_TOKEN Token OPTIONAL + ) +{ + EFI_STATUS Status =3D EFI_NOT_STARTED; + EDKII_CONFIGURATION_MANAGER_PROTOCOL *CfgMgrProtocol; + CM_OBJ_DESCRIPTOR CurrentObject; + + Status =3D gBS->LocateProtocol ( + &gEdkiiConfigurationManagerProtocolGuid, NULL, (VOID **) &CfgMgrProtoc= ol); + + if (EFI_ERROR(Status)) { + return EFI_UNSUPPORTED; + } + + Status =3D CfgMgrProtocol->GetObject ( + CfgMgrProtocol, CmObjectId, Token, &CurrentObject); + + if (EFI_ERROR(Status)) { + return Status; + } + + return CfgMgrProtocol->SetObject (CfgMgrProtocol, CmObjectId, Token, NUL= L); +} + + /** The GetCgfMgrInfo function gets the CM_STD_OBJ_CONFIGURATION_MANAGER_I= NFO object from the Configuration Manager. =20 @@ -44,6 +420,7 @@ GetCgfMgrInfo ( ASSERT (CfgMfrInfo !=3D NULL); =20 *CfgMfrInfo =3D NULL; + Status =3D CfgMgrProtocol->GetObject ( CfgMgrProtocol, CREATE_CM_STD_OBJECT_ID (EStdObjCfgMgrInfo), diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.= inf b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf index 26d82e6850..e12380073e 100644 --- a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf +++ b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf @@ -23,8 +23,14 @@ =20 [LibraryClasses] BaseLib + BaseMemoryLib + DebugLib + PrintLib + MemoryAllocationLib + UefiBootServicesTableLib =20 [Protocols] + gEfiSerialIoProtocolGuid =20 [Guids] =20 --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#63584): https://edk2.groups.io/g/devel/message/63584 Mute This Topic: https://groups.io/mt/75910569/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Mar 29 11:52:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+63585+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63585+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1596212380; cv=none; d=zohomail.com; s=zohoarc; b=UZ9wCnu0XHgI/sdymHyh/WJ9yPa5zB2Ze9PZG/MNHbkJs2F1mOOkwB73vHTsdw9eB9WV/4WvaLyC00UNyqMH6C6sU0mAOkSfKOQGXSIWsi1yV9LcE3iRktWLxmjVyp+mSv+tFimMFNnncxr1RXvjceYS0GU+fgj0Zgj7+Yx67nc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596212380; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=smuDwY+OJ0EaDkggZc8dXYc3IhZTiBRdZo23WGZhiHw=; b=DFfuLEgn2bddLtHqoS7ZBx7INQ6KXUqGlbXlBXWCzTyUFJqajzY89aVQ8lnOZ/WLXUxwNOGKH7IC5U/FZjBliCpcIfQxm7rVR03MB9rf79HCSEPJexUrGhu0yUx4ErT6v1aUPnzwSb60gOLKbFImilh9cnbbKKiuUiIzQSV72m0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63585+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1596212380806669.7183881255341; Fri, 31 Jul 2020 09:19:40 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id iyX9YY1788612xJjgqdrIOsd; Fri, 31 Jul 2020 09:19:40 -0700 X-Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by mx.groups.io with SMTP id smtpd.web10.443.1596212377223021177 for ; Fri, 31 Jul 2020 09:19:37 -0700 X-Received: by mail-wm1-f47.google.com with SMTP id c80so8990358wme.0 for ; Fri, 31 Jul 2020 09:19:37 -0700 (PDT) X-Gm-Message-State: PTsmHQkOHO95yl9yOfx8gyHtx1787277AA= X-Google-Smtp-Source: ABdhPJzr8OAWTjUH0O/JtsZZy2yv+P6G3YVQzKT23ErZqP8c/lBGRt/EniFrnCfm99vJLrkJUk3zgg== X-Received: by 2002:a1c:4e17:: with SMTP id g23mr4425239wmh.42.1596212374992; Fri, 31 Jul 2020 09:19:34 -0700 (PDT) X-Received: from localhost.localdomain (cpc159317-cmbg20-2-0-cust162.5-4.cable.virginm.net. [81.111.29.163]) by smtp.gmail.com with ESMTPSA id v11sm14149739wrr.10.2020.07.31.09.19.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:19:34 -0700 (PDT) From: "Tomas Pilar (tpilar)" To: devel@edk2.groups.io Cc: Sami Mujawar , Alexei Fedorov Subject: [edk2-devel] [PATCH 6/8] DynamicTablesPkg/TableHelperLib: User friendly strings Date: Fri, 31 Jul 2020 17:19:24 +0100 Message-Id: <20200731161926.341330-7-tomas@nuviainc.com> In-Reply-To: <20200731161926.341330-1-tomas@nuviainc.com> References: <20200731161926.341330-1-tomas@nuviainc.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,tomas@nuviainc.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1596212380; bh=fvo6fopzjqIsLHvswZxPKMQCx9UJuG4Q9Z6EfjlvXkk=; h=Cc:Date:From:Reply-To:Subject:To; b=qneEoUBfKEXGVHXFPnv74glcD/XXEYsQHR4fKZ95YaJjMi4yJVxSJ+qi4/FEmTGZS75 EZH7y3rQVg70UqlLrMN0oOKrHqLhIPFZQxYwKWocHLaEFNEZ5KSGaCoNlBzMVBD8Jvscy EKdMFUkYo4xqDs5BxFl4d5KoiuvFo1eK/MQ= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Add user friendly strings for CmObjectIds to TableHelperLib and add debug print invocations to common helper methods. Cc: Sami Mujawar Cc: Alexei Fedorov Signed-off-by: Tomas Pilar --- .../ConfigurationManagerDumpApp.c | 13 +-- .../ConfigurationManagerDumpApp.h | 8 -- .../ConfigurationManagerDumpApp.inf | 3 +- .../ConfigurationObjectStrings.c | 50 ---------- .../Include/Library/TableHelperLib.h | 12 +++ .../ConfigurationObjectStrings.c | 92 +++++++++++++++++++ .../Common/TableHelperLib/TableHelperLib.inf | 1 + 7 files changed, 109 insertions(+), 70 deletions(-) delete mode 100644 DynamicTablesPkg/Applications/ConfigurationManagerDumpA= pp/ConfigurationManagerDumpApp.h delete mode 100644 DynamicTablesPkg/Applications/ConfigurationManagerDumpA= pp/ConfigurationObjectStrings.c create mode 100644 DynamicTablesPkg/Library/Common/TableHelperLib/Configur= ationObjectStrings.c diff --git a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/Conf= igurationManagerDumpApp.c b/DynamicTablesPkg/Applications/ConfigurationMana= gerDumpApp/ConfigurationManagerDumpApp.c index 15936c78c1..20977c1b82 100644 --- a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/Configurati= onManagerDumpApp.c +++ b/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/Configurati= onManagerDumpApp.c @@ -1,10 +1,9 @@ #include #include #include +#include #include =20 -#include "ConfigurationManagerDumpApp.h" - EDKII_CONFIGURATION_MANAGER_PROTOCOL *mCfgMgr; =20 EFI_STATUS @@ -33,10 +32,7 @@ UefiMain( continue; } =20 - Print ( - L"<%s>::<%s>\n", - ObjectNameSpaceString[EObjNameSpaceStandard], - StdObjectString[ObjectId - EObjNameSpaceStandard]); + Print (L"<%s>\n", CmObjectIdName (ObjectId)); =20 Print ( L"Id=3D%x Size=3D0x%x at=3D%p count=3D%d\n", @@ -54,10 +50,7 @@ UefiMain( continue; } =20 - Print ( - L"<%s>::<%s>\n", - ObjectNameSpaceString[EObjNameSpaceArm], - ArmObjectString[ObjectId - EObjNameSpaceArm]); + Print (L"<%s>\n", CmObjectIdName(ObjectId)); =20 Print ( L"Id=3D%x Size=3D0x%x at=3D%p count=3D%d\n", diff --git a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/Conf= igurationManagerDumpApp.h b/DynamicTablesPkg/Applications/ConfigurationMana= gerDumpApp/ConfigurationManagerDumpApp.h deleted file mode 100644 index 5017d55b4a..0000000000 --- a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/Configurati= onManagerDumpApp.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef CONFIGURATION_MANAGER_DUMP_APP_H_ -#define CONFIGURATION_MANAGER_DUMP_APP_H_ - -extern CHAR16 *ArmObjectString[]; -extern CHAR16 *ObjectNameSpaceString[]; -extern CHAR16 *StdObjectString[]; - -#endif diff --git a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/Conf= igurationManagerDumpApp.inf b/DynamicTablesPkg/Applications/ConfigurationMa= nagerDumpApp/ConfigurationManagerDumpApp.inf index 9f8beb916d..f930ca3dcb 100644 --- a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/Configurati= onManagerDumpApp.inf +++ b/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/Configurati= onManagerDumpApp.inf @@ -23,8 +23,6 @@ =20 [Sources] ConfigurationManagerDumpApp.c - ConfigurationManagerDumpApp.h - ConfigurationObjectStrings.c =20 [Packages] MdePkg/MdePkg.dec @@ -32,6 +30,7 @@ DynamicTablesPkg/DynamicTablesPkg.dec =20 [LibraryClasses] + TableHelperLib UefiLib UefiBootServicesTableLib UefiApplicationEntryPoint diff --git a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/Conf= igurationObjectStrings.c b/DynamicTablesPkg/Applications/ConfigurationManag= erDumpApp/ConfigurationObjectStrings.c deleted file mode 100644 index ad8dbb6354..0000000000 --- a/DynamicTablesPkg/Applications/ConfigurationManagerDumpApp/Configurati= onObjectStrings.c +++ /dev/null @@ -1,50 +0,0 @@ - -CHAR16 *ArmObjectString[] =3D { - L"Reserved", - L"Boot Architecture Info", - L"CPU Info", - L"Power Management Profile Info", - L"GIC CPU Interface Info", - L"GIC Distributor Info", - L"GIC MSI Frame Info", - L"GIC Redistributor Info", - L"GIC ITS Info", - L"Serial Console Port Info", - L"Serial Debug Port Info", - L"Generic Timer Info", - L"Platform GT Block Info", - L"Generic Timer Block Frame Info", - L"Platform Generic Watchdog", - L"PCI Configuration Space Info", - L"Hypervisor Vendor Id", - L"Fixed feature flags for FADT", - L"ITS Group", - L"Named Component", - L"Root Complex", - L"SMMUv1 or SMMUv2", - L"SMMUv3", - L"PMCG", - L"GIC ITS Identifier Array", - L"ID Mapping Array", - L"SMMU Interrupt Array", - L"Processor Hierarchy Info", - L"Cache Info", - L"Processor Node ID Info", - L"CM Object Reference", - L"Memory Affinity Info", - L"Device Handle Acpi", - L"Device Handle Pci", - L"Generic Initiator Affinity" -}; - -CHAR16 *ObjectNameSpaceString[] =3D { - L"Standard Objects Namespace", - L"ARM Objects Namespace", - L"OEM Objects Namespace" -}; - -CHAR16 *StdObjectString[] =3D { - L"Configuration Manager Info", - L"ACPI table Info List", - L"SMBIOS table Info List" -}; diff --git a/DynamicTablesPkg/Include/Library/TableHelperLib.h b/DynamicTab= lesPkg/Include/Library/TableHelperLib.h index 0d3d1bbd60..9269e77377 100644 --- a/DynamicTablesPkg/Include/Library/TableHelperLib.h +++ b/DynamicTablesPkg/Include/Library/TableHelperLib.h @@ -24,6 +24,18 @@ UINTN EFIAPI GetNewToken(); =20 +/** + Returns the user friendly name for the given ObjectId. + + @param[in] CmObjectId The id of the configuration manager object + @return User friendly name for object id. +**/ +const CHAR16* +EFIAPI +CmObjectIdName( + IN CONST CM_OBJECT_ID CmObjectrId + ); + /** Return the count of objects of a given ObjectId. =20 diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationOb= jectStrings.c b/DynamicTablesPkg/Library/Common/TableHelperLib/Configuratio= nObjectStrings.c new file mode 100644 index 0000000000..e4c0e77633 --- /dev/null +++ b/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationObjectStr= ings.c @@ -0,0 +1,92 @@ +/** @file + ConfigurationObjectStrings.c + + Copyright (c) 2020, ARM Limited. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include + +const CHAR16 *ArmObjectString[] =3D { + L"Reserved", + L"Boot Architecture Info", + L"CPU Info", + L"Power Management Profile Info", + L"GIC CPU Interface Info", + L"GIC Distributor Info", + L"GIC MSI Frame Info", + L"GIC Redistributor Info", + L"GIC ITS Info", + L"Serial Console Port Info", + L"Serial Debug Port Info", + L"Generic Timer Info", + L"Platform GT Block Info", + L"Generic Timer Block Frame Info", + L"Platform Generic Watchdog", + L"PCI Configuration Space Info", + L"Hypervisor Vendor Id", + L"Fixed feature flags for FADT", + L"ITS Group", + L"Named Component", + L"Root Complex", + L"SMMUv1 or SMMUv2", + L"SMMUv3", + L"PMCG", + L"GIC ITS Identifier Array", + L"ID Mapping Array", + L"SMMU Interrupt Array", + L"Processor Hierarchy Info", + L"Cache Info", + L"Processor Node ID Info", + L"CM Object Reference", + L"Memory Affinity Info", + L"Device Handle Acpi", + L"Device Handle Pci", + L"Generic Initiator Affinity" +}; + +const CHAR16 *ObjectNameSpaceString[] =3D { + L"Standard Objects Namespace", + L"ARM Objects Namespace", + L"OEM Objects Namespace" +}; + +const CHAR16 *StdObjectString[] =3D { + L"Configuration Manager Info", + L"ACPI table Info List", + L"SMBIOS table Info List" +}; + +const CHAR16* UnknownObject =3D L"Unknown Object"; + +/** + Returns the user friendly name for the given ObjectId. + + @param[in] CmObjectId The id of the configuration manager object + @return User friendly name for object id. +**/ +const CHAR16* +EFIAPI +CmObjectIdName( + IN CONST CM_OBJECT_ID CmObjectId + ) +{ + switch (GET_CM_NAMESPACE_ID(CmObjectId)) { + case EObjNameSpaceStandard: + if (CmObjectId < EStdObjMax) { + return StdObjectString[CmObjectId - EObjNameSpaceStandard]; + } else { + return UnknownObject; + } + case EObjNameSpaceArm: + if (CmObjectId < EArmObjMax) { + return ArmObjectString[CmObjectId - EObjNameSpaceArm]; + } else { + return UnknownObject; + } + default: + return UnknownObject; + } + + return UnknownObject; +} diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.= inf b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf index e12380073e..0fbc1fe5b2 100644 --- a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf +++ b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf @@ -16,6 +16,7 @@ =20 [Sources] TableHelper.c + ConfigurationObjectStrings.c =20 [Packages] MdePkg/MdePkg.dec --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#63585): https://edk2.groups.io/g/devel/message/63585 Mute This Topic: https://groups.io/mt/75910570/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Mar 29 11:52:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+63586+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63586+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1596212381; cv=none; d=zohomail.com; s=zohoarc; b=BFisexJ8i2XvfMx7cxLonQkUCAtGeyFTesFuUJtiBlOvNNcJFEaUm8gPpaN2QKHwjVVXYtPYrwF1xmn7xQ4DWXBWd0clGJ1d3/2fKDolr+CRUkCCW+CTYnGS1qfZODYoNcP8hqeTjoG/NfTI/Lj5FBHLcr5HFqZQ9BHLOOR+tV4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596212381; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=stPOcrsHcP6nGZn0gBMdBAZyauMZmQJ3SDn8lVhSfeE=; b=P+7879niYFn5c55F9qdioSh895nbBniGCA9gF9pJg9l8YirMYEDPzCDxmLNR653WKonvvIm8Y7u48v374vxCq+P8E4oeRzHVX/xuBtGQV39H+1cPdxUtamFk48UEMPdk573reP3uWIvsj5wPZuTyQv82qTrPjdoF8G9XXUHzK+E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63586+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1596212381372173.13803066733885; Fri, 31 Jul 2020 09:19:41 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id GNPKYY1788612xW3obWCuCom; Fri, 31 Jul 2020 09:19:40 -0700 X-Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) by mx.groups.io with SMTP id smtpd.web11.382.1596212378103026577 for ; Fri, 31 Jul 2020 09:19:38 -0700 X-Received: by mail-wr1-f45.google.com with SMTP id r4so25547894wrx.9 for ; Fri, 31 Jul 2020 09:19:37 -0700 (PDT) X-Gm-Message-State: FwsVUf5iWE7onsJXYzxxAhlAx1787277AA= X-Google-Smtp-Source: ABdhPJz6cj6JMvrwtGCjhG+TKuWErxCsj92vnhmDjcFogkrnMoLR4+Xk/wQXsPUoEp7yGpA2txQQxQ== X-Received: by 2002:a5d:4642:: with SMTP id j2mr4076240wrs.82.1596212376034; Fri, 31 Jul 2020 09:19:36 -0700 (PDT) X-Received: from localhost.localdomain (cpc159317-cmbg20-2-0-cust162.5-4.cable.virginm.net. [81.111.29.163]) by smtp.gmail.com with ESMTPSA id v11sm14149739wrr.10.2020.07.31.09.19.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:19:35 -0700 (PDT) From: "Tomas Pilar (tpilar)" To: devel@edk2.groups.io Cc: Sami Mujawar , Alexei Fedorov Subject: [edk2-devel] [PATCH 7/8] DynamicTablesPkg: Simplify AddAcpiHeader, CfgMgrGetInfo Date: Fri, 31 Jul 2020 17:19:25 +0100 Message-Id: <20200731161926.341330-8-tomas@nuviainc.com> In-Reply-To: <20200731161926.341330-1-tomas@nuviainc.com> References: <20200731161926.341330-1-tomas@nuviainc.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,tomas@nuviainc.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1596212380; bh=YEfNwCrVqILXcnYS2h3/NDo2G6T+Ax3N9B9qTRmaAtw=; h=Cc:Date:From:Reply-To:Subject:To; b=Csuyu6NvzN9AS34eYIhro9JNji+HHSwPRh7AR2icdZgbLrFeS22rYjaGXcuuwADZNVY JkvCor2h6pJeSrVEm5qb6iAuzfZhogk5zgCJuE0e7/ubGzx4YKQp8KyacDY5UY8Rc9pdL dNUiFSZ6b41cNMDpx6PeGVnMjJ2l3nu+Yds= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Simplify the methods to use the other object getter methods. The methods no longer need CfgMgr context parameter, the getter helpers retrieve the singleton platform protocol. The CfgMgrGetInfo always allocates the memory that is passed to the caller. Cc: Sami Mujawar Cc: Alexei Fedorov Signed-off-by: Tomas Pilar --- .../DynamicTableManagerDxe.c | 20 ++-- .../Include/Library/TableHelperLib.h | 23 ++--- .../Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c | 10 +- .../Acpi/Arm/AcpiFadtLibArm/FadtGenerator.c | 12 +-- .../Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c | 8 +- .../Acpi/Arm/AcpiIortLibArm/IortGenerator.c | 8 +- .../Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c | 8 +- .../Acpi/Arm/AcpiMcfgLibArm/McfgGenerator.c | 8 +- .../Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c | 8 +- .../Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c | 10 +- .../Acpi/Arm/AcpiSratLibArm/SratGenerator.c | 8 +- .../Common/TableHelperLib/TableHelper.c | 97 ++++--------------- .../Common/TableHelperLib/TableHelperLib.inf | 3 +- 13 files changed, 56 insertions(+), 167 deletions(-) diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableMa= nagerDxe.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableMa= nagerDxe.c index e27dcaf374..b194a38659 100644 --- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDx= e.c +++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDx= e.c @@ -661,7 +661,7 @@ DynamicTableManagerDxeInitialize ( { EFI_STATUS Status; EDKII_CONFIGURATION_MANAGER_PROTOCOL * CfgMgrProtocol; - CM_STD_OBJ_CONFIGURATION_MANAGER_INFO * CfgMfrInfo; + CM_STD_OBJ_CONFIGURATION_MANAGER_INFO * CfgMgrInfo; EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL * TableFactoryProtocol; =20 // Locate the Dynamic Table Factory @@ -695,7 +695,7 @@ DynamicTableManagerDxeInitialize ( return Status; } =20 - Status =3D GetCgfMgrInfo (CfgMgrProtocol, &CfgMfrInfo); + Status =3D CfgMgrGetInfo (&CfgMgrInfo); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, @@ -708,15 +708,17 @@ DynamicTableManagerDxeInitialize ( DEBUG (( DEBUG_INFO, "INFO: Configuration Manager Version =3D 0x%x, OemID =3D %c%c%c%c%c%c\= n", - CfgMfrInfo->Revision, - CfgMfrInfo->OemId[0], - CfgMfrInfo->OemId[1], - CfgMfrInfo->OemId[2], - CfgMfrInfo->OemId[3], - CfgMfrInfo->OemId[4], - CfgMfrInfo->OemId[5] + CfgMgrInfo->Revision, + CfgMgrInfo->OemId[0], + CfgMgrInfo->OemId[1], + CfgMgrInfo->OemId[2], + CfgMgrInfo->OemId[3], + CfgMgrInfo->OemId[4], + CfgMgrInfo->OemId[5] )); =20 + FreePool(CfgMgrInfo); + Status =3D ProcessAcpiTables (TableFactoryProtocol, CfgMgrProtocol); if (EFI_ERROR (Status)) { DEBUG (( diff --git a/DynamicTablesPkg/Include/Library/TableHelperLib.h b/DynamicTab= lesPkg/Include/Library/TableHelperLib.h index 9269e77377..0dce81827b 100644 --- a/DynamicTablesPkg/Include/Library/TableHelperLib.h +++ b/DynamicTablesPkg/Include/Library/TableHelperLib.h @@ -194,33 +194,26 @@ CfgMgrGetObjects ( OUT UINT32 * ItemCount OPTIONAL ); =20 -/** The GetCgfMgrInfo function gets the CM_STD_OBJ_CONFIGURATION_MANAGER_I= NFO +/** The CfgMgrGetInfo function gets the CM_STD_OBJ_CONFIGURATION_MANAGER_I= NFO object from the Configuration Manager. =20 - @param [in] CfgMgrProtocol Pointer to the Configuration Manager protocol - interface. @param [out] CfgMfrInfo Pointer to the Configuration Manager Info object structure. =20 @retval EFI_SUCCESS The object is returned. - @retval EFI_INVALID_PARAMETER The Object ID is invalid. @retval EFI_NOT_FOUND The requested Object is not found. - @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration - Manager is less than the Object size. **/ EFI_STATUS EFIAPI -GetCgfMgrInfo ( - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProto= col, +CfgMgrGetInfo ( OUT CM_STD_OBJ_CONFIGURATION_MANAGER_INFO ** CfgMfrInfo ); =20 -/** The AddAcpiHeader function updates the ACPI header structure. It uses = the - ACPI table Generator and the Configuration Manager protocol to obtain = the - information required for constructing the header. +/** The AddAcpiHeader function updates the ACPI header structure pointed by + the AcpiHeader. It utilizes the ACPI table Generator and the Configura= tion + Manager protocol to obtain any information required for constructing t= he + header. =20 - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - protocol interface. @param [in] Generator Pointer to the ACPI table Generator. @param [in,out] AcpiHeader Pointer to the ACPI table header to be updated. @@ -230,14 +223,10 @@ GetCgfMgrInfo ( @retval EFI_SUCCESS The ACPI table is updated successfully. @retval EFI_INVALID_PARAMETER A parameter is invalid. @retval EFI_NOT_FOUND The required object information is not fou= nd. - @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration - Manager is less than the Object size for t= he - requested object. **/ EFI_STATUS EFIAPI AddAcpiHeader ( - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtoc= ol, IN CONST ACPI_TABLE_GENERATOR * CONST Generator, IN OUT EFI_ACPI_DESCRIPTION_HEADER * CONST AcpiHeader, IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInf= o, diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator= .c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c index 51c843d25f..21a7f9bf64 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c @@ -330,12 +330,10 @@ BuildDbg2Table ( } =20 Status =3D AddAcpiHeader ( - CfgMgrProtocol, - This, - (EFI_ACPI_DESCRIPTION_HEADER*)&AcpiDbg2, - AcpiTableInfo, - sizeof (DBG2_TABLE) - ); + This, + (EFI_ACPI_DESCRIPTION_HEADER *)&AcpiDbg2, + AcpiTableInfo, + sizeof (DBG2_TABLE)); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/FadtGenerator= .c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/FadtGenerator.c index b748c982b2..febaca3dae 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/FadtGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/FadtGenerator.c @@ -528,19 +528,17 @@ BuildFadtTable ( *Table =3D NULL; =20 Status =3D AddAcpiHeader ( - CfgMgrProtocol, - This, - (EFI_ACPI_DESCRIPTION_HEADER*)&AcpiFadt, - AcpiTableInfo, - sizeof (EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE) - ); + This, + (EFI_ACPI_DESCRIPTION_HEADER *)&AcpiFadt, + AcpiTableInfo, + sizeof (EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE)); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, "ERROR: FADT: Failed to add ACPI header. Status =3D %r\n", Status )); - goto error_handler; + return Status; } =20 // Update PmProfile Info diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator= .c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c index c109f2ac20..4af410fb5b 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c @@ -593,13 +593,7 @@ BuildGtdtTable ( TableSize )); =20 - Status =3D AddAcpiHeader ( - CfgMgrProtocol, - This, - &Gtdt->Header, - AcpiTableInfo, - TableSize - ); + Status =3D AddAcpiHeader (This, &Gtdt->Header, AcpiTableInfo, TableSize); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator= .c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c index 65d006c89e..97f86ddb30 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c @@ -1942,13 +1942,7 @@ BuildIortTable ( TableSize )); =20 - Status =3D AddAcpiHeader ( - CfgMgrProtocol, - This, - &Iort->Header, - AcpiTableInfo, - (UINT32)TableSize - ); + Status =3D AddAcpiHeader (This, &Iort->Header, AcpiTableInfo, (UINT32) T= ableSize); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/MadtGenerator= .c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c index 2651ca1541..ab42c96b06 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c @@ -641,13 +641,7 @@ BuildMadtTable ( TableSize )); =20 - Status =3D AddAcpiHeader ( - CfgMgrProtocol, - This, - &Madt->Header, - AcpiTableInfo, - TableSize - ); + Status =3D AddAcpiHeader (This, &Madt->Header, AcpiTableInfo, TableSize); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/McfgGenerator= .c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/McfgGenerator.c index 1293ac8e43..a486e2297a 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/McfgGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/McfgGenerator.c @@ -210,13 +210,7 @@ BuildMcfgTable ( TableSize )); =20 - Status =3D AddAcpiHeader ( - CfgMgrProtocol, - This, - &Mcfg->Header, - AcpiTableInfo, - TableSize - ); + Status =3D AddAcpiHeader (This, &Mcfg->Header, AcpiTableInfo, TableSize); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator= .c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c index d70fc59e75..99eb6e0929 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c @@ -1291,13 +1291,7 @@ BuildPpttTable ( )); =20 // Add ACPI header - Status =3D AddAcpiHeader ( - CfgMgrProtocol, - This, - &Pptt->Header, - AcpiTableInfo, - TableSize - ); + Status =3D AddAcpiHeader (This, &Pptt->Header, AcpiTableInfo, TableSize); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator= .c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c index 4b2580da7d..46f53f819a 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c @@ -202,12 +202,10 @@ BuildSpcrTable ( DEBUG ((DEBUG_INFO, " Interrupt =3D %d\n", SerialPortInfo->Interrupt)); =20 Status =3D AddAcpiHeader ( - CfgMgrProtocol, - This, - (EFI_ACPI_DESCRIPTION_HEADER*)&AcpiSpcr, - AcpiTableInfo, - sizeof (EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE) - ); + This, + (EFI_ACPI_DESCRIPTION_HEADER *)&AcpiSpcr, + AcpiTableInfo, + sizeof (EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE)); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSratLibArm/SratGenerator= .c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSratLibArm/SratGenerator.c index 620e2929ef..fda0837f32 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSratLibArm/SratGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSratLibArm/SratGenerator.c @@ -610,13 +610,7 @@ BuildSratTable ( TableSize )); =20 - Status =3D AddAcpiHeader ( - CfgMgrProtocol, - This, - &Srat->Header, - AcpiTableInfo, - TableSize - ); + Status =3D AddAcpiHeader (This, &Srat->Header, AcpiTableInfo, TableSize); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c b= /DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c index 18c0e95e0d..2f266feb9c 100644 --- a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c +++ b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c @@ -392,74 +392,30 @@ CfgMgrRemoveObject ( } =20 =20 -/** The GetCgfMgrInfo function gets the CM_STD_OBJ_CONFIGURATION_MANAGER_I= NFO - object from the Configuration Manager. +/** The CfgMgrGetInfo function gets the CM_STD_OBJ_CONFIGURATION_MANAGER_I= NFO + object from the Configuration Manager. The caller is responsible for f= reeing + the memory allocated by this function. =20 - @param [in] CfgMgrProtocol Pointer to the Configuration Manager protocol - interface. - @param [out] CfgMfrInfo Pointer to the Configuration Manager Info + @param [out] CfgMgrInfo Pointer to the Configuration Manager Info object structure. =20 @retval EFI_SUCCESS The object is returned. - @retval EFI_INVALID_PARAMETER The Object ID is invalid. @retval EFI_NOT_FOUND The requested Object is not found. - @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration - Manager is less than the Object size. + @retval EFI_INVALID_PARAMETER CfgMgrInfo is NULL. **/ EFI_STATUS EFIAPI -GetCgfMgrInfo ( - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProto= col, - OUT CM_STD_OBJ_CONFIGURATION_MANAGER_INFO ** CfgMfrInfo +CfgMgrGetInfo ( + OUT CM_STD_OBJ_CONFIGURATION_MANAGER_INFO ** CfgMgrInfo ) { - EFI_STATUS Status; - CM_OBJ_DESCRIPTOR CmObjectDesc; - - ASSERT (CfgMgrProtocol !=3D NULL); - ASSERT (CfgMfrInfo !=3D NULL); - - *CfgMfrInfo =3D NULL; - - Status =3D CfgMgrProtocol->GetObject ( - CfgMgrProtocol, - CREATE_CM_STD_OBJECT_ID (EStdObjCfgMgrInfo), - CM_NULL_TOKEN, - &CmObjectDesc - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to Get Configuration Manager Info. Status =3D %r\n", - Status - )); - return Status; - } - - if (CmObjectDesc.ObjectId !=3D CREATE_CM_STD_OBJECT_ID (EStdObjCfgMgrInf= o)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: EStdObjCfgMgrInfo: Invalid ObjectId =3D 0x%x, expected Id = =3D 0x%x\n", - CmObjectDesc.ObjectId, - CREATE_CM_STD_OBJECT_ID (EStdObjCfgMgrInfo) - )); - ASSERT (FALSE); + if (CfgMgrInfo =3D=3D NULL) { return EFI_INVALID_PARAMETER; } =20 - if (CmObjectDesc.Size < - (sizeof (CM_STD_OBJ_CONFIGURATION_MANAGER_INFO) * CmObjectDesc.Count= )) { - DEBUG (( - DEBUG_ERROR, - "ERROR: EStdObjCfgMgrInfo: Buffer too small, size =3D 0x%x\n", - CmObjectDesc.Size - )); - ASSERT (FALSE); - return EFI_BAD_BUFFER_SIZE; - } + *CfgMgrInfo =3D NULL; =20 - *CfgMfrInfo =3D (CM_STD_OBJ_CONFIGURATION_MANAGER_INFO*)CmObjectDesc.Dat= a; - return Status; + return CfgMgrGetSimpleObject (EStdObjCfgMgrInfo, (VOID **)CfgMgrInfo); } =20 /** The AddAcpiHeader function updates the ACPI header structure pointed by @@ -467,8 +423,6 @@ GetCgfMgrInfo ( Manager protocol to obtain any information required for constructing t= he header. =20 - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - protocol interface. @param [in] Generator Pointer to the ACPI table Generator. @param [in,out] AcpiHeader Pointer to the ACPI table header to be updated. @@ -478,14 +432,10 @@ GetCgfMgrInfo ( @retval EFI_SUCCESS The ACPI table is updated successfully. @retval EFI_INVALID_PARAMETER A parameter is invalid. @retval EFI_NOT_FOUND The required object information is not fou= nd. - @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration - Manager is less than the Object size for t= he - requested object. **/ EFI_STATUS EFIAPI AddAcpiHeader ( - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtoc= ol, IN CONST ACPI_TABLE_GENERATOR * CONST Generator, IN OUT EFI_ACPI_DESCRIPTION_HEADER * CONST AcpiHeader, IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInf= o, @@ -495,27 +445,17 @@ AddAcpiHeader ( EFI_STATUS Status; CM_STD_OBJ_CONFIGURATION_MANAGER_INFO * CfgMfrInfo; =20 - ASSERT (CfgMgrProtocol !=3D NULL); - ASSERT (Generator !=3D NULL); - ASSERT (AcpiHeader !=3D NULL); - ASSERT (Length >=3D sizeof (EFI_ACPI_DESCRIPTION_HEADER)); - - if ((CfgMgrProtocol =3D=3D NULL) || - (Generator =3D=3D NULL) || + if ((Generator =3D=3D NULL) || (AcpiHeader =3D=3D NULL) || - (Length < sizeof (EFI_ACPI_DESCRIPTION_HEADER)) - ) { + (Length < sizeof (EFI_ACPI_DESCRIPTION_HEADER))) { + DEBUG ((DEBUG_ERROR, + "ERROR: Cannot add ACPI header [Invalid Pamrameter].\n")); return EFI_INVALID_PARAMETER; } =20 - Status =3D GetCgfMgrInfo (CfgMgrProtocol, &CfgMfrInfo); + Status =3D CfgMgrGetInfo (&CfgMfrInfo); if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to get Configuration Manager info. Status =3D %r\n", - Status - )); - goto error_handler; + return Status; } =20 // UINT32 Signature @@ -555,8 +495,9 @@ AddAcpiHeader ( // UINT32 CreatorRevision AcpiHeader->CreatorRevision =3D Generator->CreatorRevision; =20 -error_handler: - return Status; + FreePool (CfgMfrInfo); + + return EFI_SUCCESS; } =20 /** diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.= inf b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf index 0fbc1fe5b2..4ee478dab9 100644 --- a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf +++ b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelperLib.inf @@ -32,6 +32,5 @@ =20 [Protocols] gEfiSerialIoProtocolGuid - -[Guids] + gEdkiiConfigurationManagerProtocolGuid =20 --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#63586): https://edk2.groups.io/g/devel/message/63586 Mute This Topic: https://groups.io/mt/75910571/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Fri Mar 29 11:52:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+63587+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63587+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1596212384; cv=none; d=zohomail.com; s=zohoarc; b=EqofJsTlf4B4DU0ZRNP7u6cvA2lP5fvShS3bNjPib6mjK6BWDi0zr2WXEViqQRZLaDahKkrUC/HneHlOazwCyXUMNRYBp84DfvdruGYjyiKgMmwVhr8YId7zI4ATQSJhWclb3O0gPt56HlCW6jRcbTw9EkUznL98M7ZHlAJKHUQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596212384; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=DYX7WDolc4aux6wYY4NSt0xt8z9vRUiAfCHTxcTnmWc=; b=Iwk8qhNtUxL5jk9QH+9jXPMq5MWvC2E8vEUMwN3YHlNTO2oPKXgVndmSXP789aEfkg8F5GDGZb6XXKMa6I+c/PalAc4gjOEYES7eauEaJKlRYZaGisPp9i0a8BeP0XZv0IBlDLIRSphHh3J7KGgPfoEfMONusL87Xr79H1ct348= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63587+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1596212384612436.37951290475803; Fri, 31 Jul 2020 09:19:44 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id eJjTYY1788612xqD4xAQyNQI; Fri, 31 Jul 2020 09:19:44 -0700 X-Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by mx.groups.io with SMTP id smtpd.web11.383.1596212382779352273 for ; Fri, 31 Jul 2020 09:19:43 -0700 X-Received: by mail-wr1-f47.google.com with SMTP id f1so27958957wro.2 for ; Fri, 31 Jul 2020 09:19:42 -0700 (PDT) X-Gm-Message-State: cBisbTGSNxUSyx1mpg5X3Eu2x1787277AA= X-Google-Smtp-Source: ABdhPJyxv3vc5RQ3bsDvpuXiWxqSv4s9FcIU9tN8MARcqMwVlzuLT3l3Q+YK4i4aYi1wR7cUX9ckRw== X-Received: by 2002:adf:f48b:: with SMTP id l11mr3994845wro.376.1596212377517; Fri, 31 Jul 2020 09:19:37 -0700 (PDT) X-Received: from localhost.localdomain (cpc159317-cmbg20-2-0-cust162.5-4.cable.virginm.net. [81.111.29.163]) by smtp.gmail.com with ESMTPSA id v11sm14149739wrr.10.2020.07.31.09.19.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jul 2020 09:19:36 -0700 (PDT) From: "Tomas Pilar (tpilar)" To: devel@edk2.groups.io Cc: Sami Mujawar , Alexei Fedorov Subject: [edk2-devel] [PATCH 8/8] DynamicTablesPkg: Remove GET_OBJECT_LIST Date: Fri, 31 Jul 2020 17:19:26 +0100 Message-Id: <20200731161926.341330-9-tomas@nuviainc.com> In-Reply-To: <20200731161926.341330-1-tomas@nuviainc.com> References: <20200731161926.341330-1-tomas@nuviainc.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,tomas@nuviainc.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1596212384; bh=gr+hMeJ59u9Zg6x7NWKsxUSB9F/eQDhTeKxEyqh0nuI=; h=Cc:Date:From:Reply-To:Subject:To; b=TcayaKcXQ+6u6eLTQlFkMxC9dZEStE7+UcFeJ7zEfjMD2p7dZy0Y+K4gazUH3mbzumq czvQc1SQEhewiH1HD3a1Ug6u8gLEAXr4RZBmuUEXgl75+RwzcdF6g45ZNd0B1ardRf/pV 2qRpdCAsKSI6dEQSPLLNP1VEHXIEcUkPsQg= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Replace macro-generated accessor functions in DynamicTables generators with TableHelperLib helpers that are compatible with v1.1 revision of Configuration Manager Protocol. Cc: Sami Mujawar Cc: Alexei Fedorov Signed-off-by: Tomas Pilar --- .../DynamicTableFactoryDxe.c | 1 - .../DynamicTableManagerDxe.c | 34 +- .../Include/ConfigurationManagerHelper.h | 126 -- .../Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c | 34 +- .../Acpi/Arm/AcpiFadtLibArm/FadtGenerator.c | 199 +--- .../Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c | 234 ++-- .../Acpi/Arm/AcpiIortLibArm/IortGenerator.c | 1058 +++++------------ .../Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c | 304 ++--- .../Acpi/Arm/AcpiMcfgLibArm/McfgGenerator.c | 100 +- .../Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c | 287 ++--- .../Acpi/Arm/AcpiRawLibArm/RawGenerator.c | 1 - .../Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c | 35 +- .../Acpi/Arm/AcpiSratLibArm/SratGenerator.c | 437 +++---- 13 files changed, 785 insertions(+), 2065 deletions(-) delete mode 100644 DynamicTablesPkg/Include/ConfigurationManagerHelper.h diff --git a/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFa= ctoryDxe.c b/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFa= ctoryDxe.c index d1432348f0..b8f3e1c877 100644 --- a/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDx= e.c +++ b/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDx= e.c @@ -15,7 +15,6 @@ // Module specific include files. #include #include -#include #include #include #include diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableMa= nagerDxe.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableMa= nagerDxe.c index b194a38659..ae827fdf2c 100644 --- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDx= e.c +++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDx= e.c @@ -8,6 +8,7 @@ **/ =20 #include +#include #include #include #include @@ -15,22 +16,12 @@ // Module specific include files. #include #include -#include #include #include #include #include #include =20 -/** This macro expands to a function that retrieves the ACPI Table - List from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceStandard, - EStdObjAcpiTableList, - CM_STD_OBJ_ACPI_TABLE_INFO - ) - /** A helper function to build and install a single ACPI table. =20 This is a helper function that invokes the Table generator interface @@ -516,12 +507,7 @@ ProcessAcpiTables ( return Status; } =20 - Status =3D GetEStdObjAcpiTableList ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &AcpiTableInfo, - &AcpiTableCount - ); + Status =3D CfgMgrCountObjects (EStdObjAcpiTableList, &AcpiTableCount); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, @@ -546,6 +532,9 @@ ProcessAcpiTables ( AcpiTableCount )); =20 + CfgMgrGetObjects ( + EStdObjAcpiTableList, CM_NULL_TOKEN, (VOID**)&AcpiTableInfo, &AcpiTabl= eCount); + // Check if mandatory ACPI tables are present. Status =3D VerifyMandatoryTablesArePresent ( AcpiTableInfo, @@ -558,7 +547,7 @@ ProcessAcpiTables ( " Status =3D %r\n", Status )); - return Status; + goto EXIT; } =20 // Add the FADT Table first. @@ -578,7 +567,7 @@ ProcessAcpiTables ( " Status =3D %r\n", Status )); - return Status; + goto EXIT; } break; } @@ -626,10 +615,12 @@ ProcessAcpiTables ( " Status =3D %r\n", Status )); - return Status; + goto EXIT; } } // for =20 +EXIT: + FreePool(AcpiTableInfo); return Status; } =20 @@ -697,11 +688,6 @@ DynamicTableManagerDxeInitialize ( =20 Status =3D CfgMgrGetInfo (&CfgMgrInfo); if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to get Configuration Manager info. Status =3D %r\n", - Status - )); return Status; } =20 diff --git a/DynamicTablesPkg/Include/ConfigurationManagerHelper.h b/Dynami= cTablesPkg/Include/ConfigurationManagerHelper.h deleted file mode 100644 index 29f34a0434..0000000000 --- a/DynamicTablesPkg/Include/ConfigurationManagerHelper.h +++ /dev/null @@ -1,126 +0,0 @@ -/** @file - - Copyright (c) 2017 - 2019, ARM Limited. All rights reserved. - - SPDX-License-Identifier: BSD-2-Clause-Patent - - @par Glossary: - - Cm or CM - Configuration Manager - - Obj or OBJ - Object -**/ - -#ifndef CONFIGURATION_MANAGER_HELPER_H_ -#define CONFIGURATION_MANAGER_HELPER_H_ - -/** The GET_OBJECT_LIST macro expands to a function that is used to retrie= ve - an object or an object list from the Configuration Manager using the - Configuration Manager Protocol interface. - - The macro expands to a function which has the following prototype: - - STATIC - EFI_STATUS - EFIAPI - Get ( - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, - IN CONST CM_OBJECT_TOKEN Token OPTIONAL, - OUT Type ** List, - OUT UINT32 * Count OPTIONAL - ); - - Generated function parameters: - @param [in] CfgMgrProtocol Pointer to the Configuration Manager protocol - interface. - @param [in] Token Reference token for the Object. - @param [out] List Pointer to the Object list. - @param [out] Count Count of the objects returned in the list. - - Macro Parameters: - @param [in] CmObjectNameSpace The Object Namespace - @param [in] CmObjectId Object Id. - @param [in] Type Structure used to describe the Object. - - @retval EFI_SUCCESS Success. - @retval EFI_INVALID_PARAMETER A parameter is invalid. - @retval EFI_NOT_FOUND The required object information is not fou= nd. - @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration - Manager is less than the Object size for t= he - requested object. -**/ -#define GET_OBJECT_LIST(CmObjectNameSpace, CmObjectId, Type) = \ -STATIC = \ -EFI_STATUS = \ -EFIAPI = \ -Get##CmObjectId ( = \ - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, = \ - IN CONST CM_OBJECT_TOKEN Token OPTIONAL, = \ - OUT Type ** List, = \ - OUT UINT32 * CONST Count OPTIONAL = \ - ) = \ -{ = \ - EFI_STATUS Status; = \ - CM_OBJ_DESCRIPTOR CmObjectDesc; = \ - UINT32 ObjCount =3D 0; = \ - if (List =3D=3D NULL) { = \ - Status =3D EFI_INVALID_PARAMETER; = \ - DEBUG (( = \ - DEBUG_ERROR, = \ - "ERROR: Get" #CmObjectId ": Invalid out parameter for" = \ - " object list. Status =3D %r\n", = \ - Status = \ - )); = \ - goto error_handler; = \ - } = \ - Status =3D CfgMgrProtocol->GetObject ( = \ - CfgMgrProtocol, = \ - CREATE_CM_OBJECT_ID ( = \ - CmObjectNameSpace, = \ - CmObjectId = \ - ), = \ - Token, = \ - &CmObjectDesc = \ - ); = \ - if (EFI_ERROR (Status)) { = \ - DEBUG (( = \ - DEBUG_INFO, = \ - "INFO: Get" #CmObjectId ": Platform does not implement " = \ - #CmObjectId ". Status =3D %r\n", = \ - Status = \ - )); = \ - *List =3D NULL; = \ - goto error_handler; = \ - } = \ - if (CmObjectDesc.ObjectId !=3D = \ - CREATE_CM_OBJECT_ID (CmObjectNameSpace, CmObjectId)) { = \ - DEBUG (( = \ - DEBUG_ERROR, = \ - "ERROR: Get" #CmObjectId ": " #CmObjectId = \ - ": Invalid ObjectId =3D 0x%x\n, expected Id =3D 0x%x\n", = \ - CmObjectDesc.ObjectId, = \ - CREATE_CM_OBJECT_ID (CmObjectNameSpace, CmObjectId) = \ - )); = \ - ASSERT (FALSE); = \ - Status =3D EFI_INVALID_PARAMETER; = \ - goto error_handler; = \ - } = \ - if (CmObjectDesc.Size < (sizeof (Type) * CmObjectDesc.Count)) { = \ - DEBUG (( = \ - DEBUG_ERROR, = \ - "ERROR: Get" #CmObjectId ": " #CmObjectId = \ - ": Buffer too small, size =3D 0x%x\n", = \ - CmObjectDesc.Size = \ - )); = \ - ASSERT (FALSE); = \ - Status =3D EFI_BAD_BUFFER_SIZE; = \ - goto error_handler; = \ - } = \ - ObjCount =3D CmObjectDesc.Count; = \ - *List =3D (Type*)CmObjectDesc.Data; = \ -error_handler: = \ - if (Count !=3D NULL) { = \ - *Count =3D ObjCount; = \ - } = \ - return Status; = \ -} - -#endif // CONFIGURATION_MANAGER_HELPER_H_ diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator= .c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c index 21a7f9bf64..b6a1dc0ddf 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -19,7 +20,6 @@ // Module specific include files. #include #include -#include #include #include =20 @@ -166,15 +166,6 @@ DBG2_TABLE AcpiDbg2 =3D { =20 #pragma pack() =20 -/** This macro expands to a function that retrieves the Serial - debug port information from the Configuration Manager -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjSerialDebugPortInfo, - CM_ARM_SERIAL_PORT_INFO - ); - /** Initialize the PL011/SBSA UART with the parameters obtained from the Configuration Manager. =20 @@ -285,21 +276,14 @@ BuildDbg2Table ( return EFI_INVALID_PARAMETER; } =20 + // Pointers to allocated memory *Table =3D NULL; =20 - Status =3D GetEArmObjSerialDebugPortInfo ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &SerialPortInfo, - NULL - ); + Status =3D CfgMgrGetSimpleObject ( + EArmObjSerialDebugPortInfo, (VOID **)&SerialPortInfo); + if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: DBG2: Failed to get serial port information. Status =3D %r\n= ", - Status - )); - goto error_handler; + return Status; } =20 if (SerialPortInfo->BaseAddress =3D=3D 0) { @@ -335,11 +319,6 @@ BuildDbg2Table ( AcpiTableInfo, sizeof (DBG2_TABLE)); if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: DBG2: Failed to add ACPI header. Status =3D %r\n", - Status - )); goto error_handler; } =20 @@ -372,6 +351,7 @@ BuildDbg2Table ( *Table =3D (EFI_ACPI_DESCRIPTION_HEADER*)&AcpiDbg2; =20 error_handler: + FreePool(SerialPortInfo); return Status; } =20 diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/FadtGenerator= .c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/FadtGenerator.c index febaca3dae..8b523b0e3d 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/FadtGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiFadtLibArm/FadtGenerator.c @@ -11,12 +11,12 @@ =20 #include #include +#include #include =20 // Module specific include files. #include #include -#include #include #include =20 @@ -198,47 +198,8 @@ EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE AcpiFadt =3D= { =20 #pragma pack() =20 -/** This macro expands to a function that retrieves the Power - Management Profile Information from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjPowerManagementProfileInfo, - CM_ARM_POWER_MANAGEMENT_PROFILE_INFO - ); - -/** This macro expands to a function that retrieves the Boot - Architecture Information from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjBootArchInfo, - CM_ARM_BOOT_ARCH_INFO - ); - -/** This macro expands to a function that retrieves the Hypervisor - Vendor ID from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjHypervisorVendorIdentity, - CM_ARM_HYPERVISOR_VENDOR_ID - ); - -/** This macro expands to a function that retrieves the Fixed - feature flags for the platform from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjFixedFeatureFlags, - CM_ARM_FIXED_FEATURE_FLAGS - ); - /** Update the Power Management Profile information in the FADT Table. =20 - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - Protocol Interface. - @retval EFI_SUCCESS Success. @retval EFI_INVALID_PARAMETER A parameter is invalid. @retval EFI_NOT_FOUND The required object was not found. @@ -249,30 +210,16 @@ GET_OBJECT_LIST ( STATIC EFI_STATUS EFIAPI -FadtAddPmProfileInfo ( - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol -) +FadtAddPmProfileInfo (VOID) { EFI_STATUS Status; CM_ARM_POWER_MANAGEMENT_PROFILE_INFO * PmProfile; =20 - ASSERT (CfgMgrProtocol !=3D NULL); - // Get the Power Management Profile from the Platform Configuration Mana= ger - Status =3D GetEArmObjPowerManagementProfileInfo ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &PmProfile, - NULL - ); + Status =3D CfgMgrGetSimpleObject ( + EArmObjPowerManagementProfileInfo, (VOID **)&PmProfile); if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: FADT: Failed to get Power Management Profile information." \ - " Status =3D %r\n", - Status - )); - goto error_handler; + return Status; } =20 DEBUG (( @@ -283,15 +230,13 @@ FadtAddPmProfileInfo ( =20 AcpiFadt.PreferredPmProfile =3D PmProfile->PowerManagementProfile; =20 -error_handler: - return Status; + FreePool(PmProfile); + + return EFI_SUCCESS; } =20 /** Updates the Boot Architecture information in the FADT Table. =20 - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - Protocol Interface. - @retval EFI_SUCCESS Success. @retval EFI_INVALID_PARAMETER A parameter is invalid. @retval EFI_NOT_FOUND The required object was not found. @@ -302,29 +247,15 @@ error_handler: STATIC EFI_STATUS EFIAPI -FadtAddBootArchInfo ( - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol -) +FadtAddBootArchInfo (VOID) { EFI_STATUS Status; CM_ARM_BOOT_ARCH_INFO * BootArchInfo; =20 - ASSERT (CfgMgrProtocol !=3D NULL); - // Get the Boot Architecture flags from the Platform Configuration Manag= er - Status =3D GetEArmObjBootArchInfo ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &BootArchInfo, - NULL - ); + Status =3D CfgMgrGetSimpleObject (EArmObjBootArchInfo, (VOID **)&BootArc= hInfo); if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: FADT: Failed to get Boot Architecture flags. Status =3D %r\n= ", - Status - )); - goto error_handler; + return Status; } =20 DEBUG (( @@ -335,15 +266,13 @@ FadtAddBootArchInfo ( =20 AcpiFadt.ArmBootArch =3D BootArchInfo->BootArchFlags; =20 -error_handler: - return Status; + FreePool(BootArchInfo); + + return EFI_SUCCESS; } =20 /** Update the Hypervisor Vendor ID in the FADT Table. =20 - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - Protocol Interface. - @retval EFI_SUCCESS Success. @retval EFI_INVALID_PARAMETER A parameter is invalid. @retval EFI_NOT_FOUND The required object was not found. @@ -354,38 +283,16 @@ error_handler: STATIC EFI_STATUS EFIAPI -FadtAddHypervisorVendorId ( - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol -) +FadtAddHypervisorVendorId (VOID) { EFI_STATUS Status; CM_ARM_HYPERVISOR_VENDOR_ID * HypervisorVendorInfo; =20 - ASSERT (CfgMgrProtocol !=3D NULL); - // Get the Hypervisor Vendor ID from the Platform Configuration Manager - Status =3D GetEArmObjHypervisorVendorIdentity ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &HypervisorVendorInfo, - NULL - ); + Status =3D CfgMgrGetSimpleObject ( + EArmObjHypervisorVendorIdentity, (VOID **) &HypervisorVendorInfo); if (EFI_ERROR (Status)) { - if (Status =3D=3D EFI_NOT_FOUND) { - DEBUG (( - DEBUG_INFO, - "INFO: FADT: Platform does not have a Hypervisor Vendor ID." - "Status =3D %r\n", - Status - )); - } else { - DEBUG (( - DEBUG_ERROR, - "ERROR: FADT: Failed to get Hypervisor Vendor ID. Status =3D %r\n", - Status - )); - } - goto error_handler; + return Status; } =20 DEBUG (( @@ -396,8 +303,9 @@ FadtAddHypervisorVendorId ( =20 AcpiFadt.HypervisorVendorIdentity =3D HypervisorVendorInfo->HypervisorVe= ndorId; =20 -error_handler: - return Status; + FreePool (HypervisorVendorInfo); + + return EFI_SUCCESS; } =20 /** Update the Fixed Feature Flags in the FADT Table. @@ -415,38 +323,17 @@ error_handler: STATIC EFI_STATUS EFIAPI -FadtAddFixedFeatureFlags ( - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol -) +FadtAddFixedFeatureFlags (VOID) { EFI_STATUS Status; CM_ARM_FIXED_FEATURE_FLAGS * FixedFeatureFlags; =20 - ASSERT (CfgMgrProtocol !=3D NULL); - // Get the Fixed feature flags from the Platform Configuration Manager - Status =3D GetEArmObjFixedFeatureFlags ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &FixedFeatureFlags, - NULL - ); + + Status =3D CfgMgrGetSimpleObject ( + EArmObjFixedFeatureFlags, (VOID **)&FixedFeatureFlags); if (EFI_ERROR (Status)) { - if (Status =3D=3D EFI_NOT_FOUND) { - DEBUG (( - DEBUG_INFO, - "INFO: FADT: Platform does not define additional Fixed feature fla= gs." - "Status =3D %r\n", - Status - )); - } else { - DEBUG (( - DEBUG_ERROR, - "ERROR: FADT: Failed to get Fixed feature flags. Status =3D %r\n", - Status - )); - } - goto error_handler; + return Status; } =20 DEBUG (( @@ -467,8 +354,9 @@ FadtAddFixedFeatureFlags ( AcpiFadt.Flags |=3D (FixedFeatureFlags->Flags & VALID_HARDWARE_REDUCED_FLAG_MASK); =20 -error_handler: - return Status; + FreePool (FixedFeatureFlags); + + return EFI_SUCCESS; } =20 /** Construct the FADT table. @@ -507,7 +395,6 @@ BuildFadtTable ( =20 ASSERT (This !=3D NULL); ASSERT (AcpiTableInfo !=3D NULL); - ASSERT (CfgMgrProtocol !=3D NULL); ASSERT (Table !=3D NULL); ASSERT (AcpiTableInfo->TableGeneratorId =3D=3D This->GeneratorID); ASSERT (AcpiTableInfo->AcpiTableSignature =3D=3D This->AcpiTableSignatur= e); @@ -533,30 +420,25 @@ BuildFadtTable ( AcpiTableInfo, sizeof (EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE)); if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: FADT: Failed to add ACPI header. Status =3D %r\n", - Status - )); return Status; } =20 // Update PmProfile Info - Status =3D FadtAddPmProfileInfo (CfgMgrProtocol); + Status =3D FadtAddPmProfileInfo (); if (EFI_ERROR (Status)) { - goto error_handler; + return Status; } =20 // Update BootArch Info - Status =3D FadtAddBootArchInfo (CfgMgrProtocol); + Status =3D FadtAddBootArchInfo (); if (EFI_ERROR (Status)) { - goto error_handler; + return Status; } =20 // Add the Hypervisor Vendor Id if present // Note if no hypervisor is present the zero bytes // will be placed in this field. - Status =3D FadtAddHypervisorVendorId (CfgMgrProtocol); + Status =3D FadtAddHypervisorVendorId (); if (EFI_ERROR (Status)) { if (Status =3D=3D EFI_NOT_FOUND) { DEBUG (( @@ -570,11 +452,11 @@ BuildFadtTable ( "ERROR: FADT: Error reading Hypervisor Vendor ID, Status =3D %r", Status )); - goto error_handler; + return Status; } } =20 - Status =3D FadtAddFixedFeatureFlags (CfgMgrProtocol); + Status =3D FadtAddFixedFeatureFlags (); if (EFI_ERROR (Status)) { if (Status =3D=3D EFI_NOT_FOUND) { DEBUG (( @@ -582,20 +464,19 @@ BuildFadtTable ( "INFO: FADT: No Fixed feature flags found," \ " assuming no additional flags are defined for the platform.\n" )); - Status =3D EFI_SUCCESS; } else { DEBUG (( DEBUG_ERROR, "ERROR: FADT: Error reading Fixed feature flags, Status =3D %r", Status )); - goto error_handler; + return Status; } } =20 - *Table =3D (EFI_ACPI_DESCRIPTION_HEADER*)&AcpiFadt; -error_handler: - return Status; + *Table =3D (EFI_ACPI_DESCRIPTION_HEADER *) &AcpiFadt; + + return EFI_SUCCESS; } =20 /** This macro defines the FADT Table Generator revision. diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator= .c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c index 4af410fb5b..119265187a 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiGtdtLibArm/GtdtGenerator.c @@ -17,7 +17,6 @@ // Module specific include files. #include #include -#include #include #include =20 @@ -32,49 +31,11 @@ Requirements: - EArmObjGTBlockTimerFrameInfo (OPTIONAL) */ =20 -/** This macro expands to a function that retrieves the Generic - Timer Information from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjGenericTimerInfo, - CM_ARM_GENERIC_TIMER_INFO - ); - -/** This macro expands to a function that retrieves the SBSA Generic - Watchdog Timer Information from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjPlatformGenericWatchdogInfo, - CM_ARM_GENERIC_WATCHDOG_INFO - ); - -/** This macro expands to a function that retrieves the Platform Generic - Timer Block Information from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjPlatformGTBlockInfo, - CM_ARM_GTBLOCK_INFO - ); - -/** This macro expands to a function that retrieves the Generic - Timer Block Timer Frame Information from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjGTBlockTimerFrameInfo, - CM_ARM_GTBLOCK_TIMER_FRAME_INFO - ); - /** Add the Generic Timer Information to the GTDT table. =20 Also update the Platform Timer offset information if the platform implements platform timers. =20 - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - Protocol Interface. @param [in] Gtdt Pointer to the GTDT Table. @param [in] PlatformTimerCount Platform timer count. @param [in] AcpiTableRevision Acpi Revision targeted by the platform. @@ -90,7 +51,6 @@ STATIC EFI_STATUS EFIAPI AddGenericTimerInfo ( - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrPro= tocol, IN EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE * CONST Gtdt, IN CONST UINT32 PlatformT= imerCount, IN CONST UINT32 AcpiTable= Revision @@ -99,24 +59,13 @@ AddGenericTimerInfo ( EFI_STATUS Status; CM_ARM_GENERIC_TIMER_INFO * GenericTimerInfo; =20 - ASSERT (CfgMgrProtocol !=3D NULL); - ASSERT (Gtdt !=3D NULL); - - Status =3D GetEArmObjGenericTimerInfo ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &GenericTimerInfo, - NULL - ); + ASSERT (Gtdt !=3D NULL); =20 - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: GTDT: Failed to get GenericTimerInfo. Status =3D %r\n", - Status - )); - return Status; - } + Status =3D CfgMgrGetSimpleObject ( + EArmObjGenericTimerInfo, (VOID **)&GenericTimerInfo); + if (EFI_ERROR (Status)) { + return Status; + } =20 Gtdt->CntControlBasePhysicalAddress =3D GenericTimerInfo->CounterControlBaseAddress; @@ -140,7 +89,9 @@ AddGenericTimerInfo ( Gtdt->VirtualPL2TimerFlags =3D GenericTimerInfo->VirtualPL2TimerFlags; } =20 - return Status; + FreePool (GenericTimerInfo); + + return EFI_SUCCESS; } =20 /** Add the SBSA Generic Watchdog Timers to the GTDT table. @@ -148,26 +99,36 @@ AddGenericTimerInfo ( @param [in] Gtdt Pointer to the GTDT Table. @param [in] WatchdogOffset Offset to the watchdog information in the GTDT Table. - @param [in] WatchdogInfoList Pointer to the watchdog information list. - @param [in] WatchdogCount Platform timer count. **/ STATIC VOID AddGenericWatchdogList ( IN EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE * CONST Gtdt, - IN CONST UINT32 WatchdogOffset, - IN CONST CM_ARM_GENERIC_WATCHDOG_INFO * WatchdogInfoLis= t, - IN UINT32 WatchdogCount + IN CONST UINT32 WatchdogOffset ) { EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE * Watchdog; + UINT32 WatchdogCount; + VOID *WatchdogInfoList; + CM_ARM_GENERIC_WATCHDOG_INFO *Cursor; + EFI_STATUS Status; =20 ASSERT (Gtdt !=3D NULL); - ASSERT (WatchdogInfoList !=3D NULL); + + Status =3D CfgMgrGetObjects ( + EArmObjPlatformGenericWatchdogInfo, + CM_NULL_TOKEN, + &WatchdogInfoList, + &WatchdogCount); + + if (EFI_ERROR(Status)) { + return; + } =20 Watchdog =3D (EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE *) ((UINT8*)Gtdt + WatchdogOffset); =20 + Cursor =3D WatchdogInfoList; while (WatchdogCount-- !=3D 0) { // Add watchdog entry DEBUG ((DEBUG_INFO, "GTDT: Watchdog =3D 0x%p\n", Watchdog)); @@ -176,14 +137,16 @@ AddGenericWatchdogList ( sizeof (EFI_ACPI_6_3_GTDT_SBSA_GENERIC_WATCHDOG_STRUCTURE); Watchdog->Reserved =3D EFI_ACPI_RESERVED_BYTE; Watchdog->RefreshFramePhysicalAddress =3D - WatchdogInfoList->RefreshFrameAddress; + Cursor->RefreshFrameAddress; Watchdog->WatchdogControlFramePhysicalAddress =3D - WatchdogInfoList->ControlFrameAddress; - Watchdog->WatchdogTimerGSIV =3D WatchdogInfoList->TimerGSIV; - Watchdog->WatchdogTimerFlags =3D WatchdogInfoList->Flags; + Cursor->ControlFrameAddress; + Watchdog->WatchdogTimerGSIV =3D Cursor->TimerGSIV; + Watchdog->WatchdogTimerFlags =3D Cursor->Flags; Watchdog++; - WatchdogInfoList++; + Cursor++; } // for + + FreePool (WatchdogInfoList); } =20 /** @@ -313,8 +276,6 @@ AddGTBlockTimerFrames ( =20 /** Add the GT Block Timers in the GTDT Table. =20 - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - Protocol Interface. @param [in] Gtdt Pointer to the GTDT Table. @param [in] GTBlockOffset Offset of the GT Block information in the GTDT Table. @@ -328,7 +289,6 @@ AddGTBlockTimerFrames ( STATIC EFI_STATUS AddGTBlockList ( - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtoco= l, IN EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE * CONST Gtdt, IN CONST UINT32 GTBlockOffset, IN CONST CM_ARM_GTBLOCK_INFO * GTBlockInfo, @@ -351,12 +311,11 @@ AddGTBlockList ( while (BlockTimerCount-- !=3D 0) { DEBUG ((DEBUG_INFO, "GTDT: GTBlock =3D 0x%p\n", GTBlock)); =20 - Status =3D GetEArmObjGTBlockTimerFrameInfo ( - CfgMgrProtocol, - GTBlockInfo->GTBlockTimerFrameToken, - >BlockTimerFrameList, - >BlockTimerFrameCount - ); + Status =3D CfgMgrGetObjects ( + EArmObjGTBlockTimerFrameInfo, + GTBlockInfo->GTBlockTimerFrameToken, + NULL, + >BlockTimerFrameCount); if (EFI_ERROR (Status) || (GTBlockTimerFrameCount !=3D GTBlockInfo->GTBlockTimerFrameCount))= { DEBUG (( @@ -397,18 +356,20 @@ AddGTBlockList ( GtBlockFrame =3D (EFI_ACPI_6_3_GTDT_GT_BLOCK_TIMER_STRUCTURE*) ((UINT8*)GTBlock + GTBlock->GTBlockTimerOffset); =20 + CfgMgrGetObjects ( + EArmObjGTBlockTimerFrameInfo, + GTBlockInfo->GTBlockTimerFrameToken, + (VOID **)>BlockTimerFrameList, + >BlockTimerFrameCount); + // Add GT Block Timer frames Status =3D AddGTBlockTimerFrames ( GtBlockFrame, GTBlockTimerFrameList, GTBlockTimerFrameCount ); + FreePool (GTBlockTimerFrameList); if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: GTDT: Failed to add Generic Timer Frames. Status =3D %r\n", - Status - )); return Status; } =20 @@ -458,7 +419,6 @@ BuildGtdtTable ( UINT32 PlatformTimerCount; UINT32 WatchdogCount; UINT32 BlockTimerCount; - CM_ARM_GENERIC_WATCHDOG_INFO * WatchdogInfoList; CM_ARM_GTBLOCK_INFO * GTBlockInfo; EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE * Gtdt; UINT32 Idx; @@ -467,7 +427,6 @@ BuildGtdtTable ( =20 ASSERT (This !=3D NULL); ASSERT (AcpiTableInfo !=3D NULL); - ASSERT (CfgMgrProtocol !=3D NULL); ASSERT (Table !=3D NULL); ASSERT (AcpiTableInfo->TableGeneratorId =3D=3D This->GeneratorID); ASSERT (AcpiTableInfo->AcpiTableSignature =3D=3D This->AcpiTableSignatur= e); @@ -485,46 +444,15 @@ BuildGtdtTable ( return EFI_INVALID_PARAMETER; } =20 - *Table =3D NULL; - Status =3D GetEArmObjPlatformGTBlockInfo ( - CfgMgrProtocol, - CM_NULL_TOKEN, - >BlockInfo, - &BlockTimerCount - ); - if (EFI_ERROR (Status) && (Status !=3D EFI_NOT_FOUND)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: GTDT: Failed to Get Platform GT Block Information." \ - " Status =3D %r\n", - Status - )); - goto error_handler; - } - - Status =3D GetEArmObjPlatformGenericWatchdogInfo ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &WatchdogInfoList, - &WatchdogCount - ); + Status =3D CfgMgrGetObjects ( + EArmObjPlatformGTBlockInfo, + CM_NULL_TOKEN, + (VOID **)>BlockInfo, + &BlockTimerCount); if (EFI_ERROR (Status) && (Status !=3D EFI_NOT_FOUND)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: GTDT: Failed to Get Platform Generic Watchdog Information." \ - " Status =3D %r\n", - Status - )); - goto error_handler; + return Status; } =20 - DEBUG (( - DEBUG_INFO, - "GTDT: BlockTimerCount =3D %d, WatchdogCount =3D %d\n", - BlockTimerCount, - WatchdogCount - )); - // Calculate the GTDT Table Size PlatformTimerCount =3D 0; TableSize =3D sizeof (EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE); @@ -558,6 +486,20 @@ BuildGtdtTable ( )); } =20 + WatchdogCount =3D 0; + Status =3D CfgMgrCountObjects ( + EArmObjPlatformGenericWatchdogInfo, &WatchdogCount); + if (EFI_ERROR (Status) && (Status !=3D EFI_NOT_FOUND)) { + goto error_handler; + } + + DEBUG (( + DEBUG_INFO, + "GTDT: BlockTimerCount =3D %d, WatchdogCount =3D %d\n", + BlockTimerCount, + WatchdogCount + )); + WatchdogOffset =3D 0; if (WatchdogCount !=3D 0) { WatchdogOffset =3D TableSize; @@ -572,20 +514,12 @@ BuildGtdtTable ( )); } =20 - *Table =3D (EFI_ACPI_DESCRIPTION_HEADER*)AllocateZeroPool (TableSize); - if (*Table =3D=3D NULL) { + Gtdt =3D AllocateZeroPool (TableSize); + if (Gtdt =3D=3D NULL) { Status =3D EFI_OUT_OF_RESOURCES; - DEBUG (( - DEBUG_ERROR, - "ERROR: GTDT: Failed to allocate memory for GTDT Table, Size =3D %d,= " \ - " Status =3D %r\n", - TableSize, - Status - )); goto error_handler; } =20 - Gtdt =3D (EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE*)*Table; DEBUG (( DEBUG_INFO, "GTDT: Gtdt =3D 0x%p TableSize =3D 0x%x\n", @@ -595,20 +529,11 @@ BuildGtdtTable ( =20 Status =3D AddAcpiHeader (This, &Gtdt->Header, AcpiTableInfo, TableSize); if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: GTDT: Failed to add ACPI header. Status =3D %r\n", - Status - )); goto error_handler; } =20 Status =3D AddGenericTimerInfo ( - CfgMgrProtocol, - Gtdt, - PlatformTimerCount, - AcpiTableInfo->AcpiTableRevision - ); + Gtdt, PlatformTimerCount, AcpiTableInfo->AcpiTableRevision); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, @@ -619,13 +544,7 @@ BuildGtdtTable ( } =20 if (BlockTimerCount !=3D 0) { - Status =3D AddGTBlockList ( - CfgMgrProtocol, - Gtdt, - GTBlockOffset, - GTBlockInfo, - BlockTimerCount - ); + Status =3D AddGTBlockList (Gtdt, GTBlockOffset, GTBlockInfo, BlockTime= rCount); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, @@ -637,21 +556,19 @@ BuildGtdtTable ( } =20 if (WatchdogCount !=3D 0) { - AddGenericWatchdogList ( - Gtdt, - WatchdogOffset, - WatchdogInfoList, - WatchdogCount - ); + AddGenericWatchdogList (Gtdt, WatchdogOffset); } =20 + FreePool (GTBlockInfo); + + *Table =3D (EFI_ACPI_DESCRIPTION_HEADER *)Gtdt; return Status; =20 error_handler: - if (*Table !=3D NULL) { - FreePool (*Table); - *Table =3D NULL; + if (Gtdt !=3D NULL) { + FreePool (Gtdt); } + FreePool (GTBlockInfo); return Status; } =20 @@ -677,7 +594,6 @@ FreeGtdtTableResources ( { ASSERT (This !=3D NULL); ASSERT (AcpiTableInfo !=3D NULL); - ASSERT (CfgMgrProtocol !=3D NULL); ASSERT (AcpiTableInfo->TableGeneratorId =3D=3D This->GeneratorID); ASSERT (AcpiTableInfo->AcpiTableSignature =3D=3D This->AcpiTableSignatur= e); =20 diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator= .c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c index 97f86ddb30..dc518238c7 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c @@ -20,7 +20,6 @@ // Module specific include files. #include #include -#include #include #include =20 @@ -42,244 +41,82 @@ Requirements: - EArmObjGicItsIdentifierArray */ =20 -/** This macro expands to a function that retrieves the ITS - Group node information from the Configuration Manager. +/* + Function type that evaluates the size of a node and sets + the node pointer to the next node. Used in iteration over + node lists. */ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjItsGroup, - CM_ARM_ITS_GROUP_NODE - ); - -/** This macro expands to a function that retrieves the - Named Component node information from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjNamedComponent, - CM_ARM_NAMED_COMPONENT_NODE - ); - -/** This macro expands to a function that retrieves the - Root Complex node information from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjRootComplex, - CM_ARM_ROOT_COMPLEX_NODE - ); - -/** This macro expands to a function that retrieves the - SMMU v1/v2 node information from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjSmmuV1SmmuV2, - CM_ARM_SMMUV1_SMMUV2_NODE - ); - -/** This macro expands to a function that retrieves the - SMMU v3 node information from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjSmmuV3, - CM_ARM_SMMUV3_NODE - ); - -/** This macro expands to a function that retrieves the - PMCG node information from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjPmcg, - CM_ARM_PMCG_NODE - ); - -/** This macro expands to a function that retrieves the - ITS Identifier Array information from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjGicItsIdentifierArray, - CM_ARM_ITS_IDENTIFIER - ); - -/** This macro expands to a function that retrieves the - Id Mapping Array information from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjIdMappingArray, - CM_ARM_ID_MAPPING - ); - -/** This macro expands to a function that retrieves the - SMMU Interrupt Array information from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjSmmuInterruptArray, - CM_ARM_SMMU_INTERRUPT - ); +typedef UINT32 (EFIAPI *INDEX_NODE)(VOID ** Node); =20 -/** Returns the size of the ITS Group node. - - @param [in] Node Pointer to ITS Group node. +/** Returns the size of the ITS Group node, increments + to the next node. =20 + @param [in,out] Ptr Pointer to ITS Group node. @retval Size of the ITS Group Node. **/ STATIC UINT32 GetItsGroupNodeSize ( - IN CONST CM_ARM_ITS_GROUP_NODE * Node + IN OUT VOID ** Ptr ) { - ASSERT (Node !=3D NULL); + ASSERT (Ptr !=3D NULL && *Ptr !=3D NULL); + + CM_ARM_ITS_GROUP_NODE *Node =3D *Ptr; + *Ptr =3D Node + 1; =20 /* Size of ITS Group Node + Size of ITS Identifier array */ - return (UINT32)(sizeof (EFI_ACPI_6_0_IO_REMAPPING_ITS_NODE) + - (Node->ItsIdCount * sizeof (UINT32))); -} - -/** Returns the total size required for the ITS Group nodes and - updates the Node Indexer. - - This function calculates the size required for the node group - and also populates the Node Indexer array with offsets for the - individual nodes. - - @param [in] NodeStartOffset Offset from the start of the - IORT where this node group starts. - @param [in] NodeList Pointer to ITS Group node list. - @param [in] NodeCount Count of the ITS Group nodes. - @param [in, out] NodeIndexer Pointer to the next Node Indexer. - - @retval Total size of the ITS Group Nodes. -**/ -STATIC -UINT64 -GetSizeofItsGroupNodes ( - IN CONST UINT32 NodeStartOffset, - IN CONST CM_ARM_ITS_GROUP_NODE * NodeList, - IN UINT32 NodeCount, - IN OUT IORT_NODE_INDEXER ** CONST NodeIndexer - ) -{ - UINT64 Size; - - ASSERT (NodeList !=3D NULL); - - Size =3D 0; - while (NodeCount-- !=3D 0) { - (*NodeIndexer)->Token =3D NodeList->Token; - (*NodeIndexer)->Object =3D (VOID*)NodeList; - (*NodeIndexer)->Offset =3D (UINT32)(Size + NodeStartOffset); - DEBUG (( - DEBUG_INFO, - "IORT: Node Indexer =3D %p, Token =3D %p, Object =3D %p, Offset =3D = 0x%x\n", - *NodeIndexer, - (*NodeIndexer)->Token, - (*NodeIndexer)->Object, - (*NodeIndexer)->Offset - )); - - Size +=3D GetItsGroupNodeSize (NodeList); - (*NodeIndexer)++; - NodeList++; - } - return Size; + return (UINT32) ( + sizeof (EFI_ACPI_6_0_IO_REMAPPING_ITS_NODE) + + (Node->ItsIdCount) * sizeof (UINT32)); } =20 -/** Returns the size of the Named Component node. - - @param [in] Node Pointer to Named Component node. +/** Returns the size of the Named Component node and + point to the next node =20 + @param [in,out] Ptr Pointer to Named Component node. @retval Size of the Named Component node. **/ STATIC UINT32 GetNamedComponentNodeSize ( - IN CONST CM_ARM_NAMED_COMPONENT_NODE * Node + IN OUT VOID ** Ptr ) { - ASSERT (Node !=3D NULL); + ASSERT (Ptr !=3D NULL && *Ptr !=3D NULL); + + CM_ARM_NAMED_COMPONENT_NODE * Node =3D *Ptr; + *Ptr =3D Node + 1; =20 /* Size of Named Component node + Size of ID mapping array + Size of ASCII string + 'padding to 32-bit word aligned'. */ + return (UINT32)(sizeof (EFI_ACPI_6_0_IO_REMAPPING_NAMED_COMP_NODE) + - (Node->IdMappingCount * + ((Node->IdMappingCount * sizeof (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE)) + - ALIGN_VALUE (AsciiStrSize (Node->ObjectName), 4)); -} - -/** Returns the total size required for the Named Component nodes and - updates the Node Indexer. - - This function calculates the size required for the node group - and also populates the Node Indexer array with offsets for the - individual nodes. - - @param [in] NodeStartOffset Offset from the start of the - IORT where this node group starts. - @param [in] NodeList Pointer to Named Component node list. - @param [in] NodeCount Count of the Named Component nodes. - @param [in, out] NodeIndexer Pointer to the next Node Indexer. - - @retval Total size of the Named Component nodes. -**/ -STATIC -UINT64 -GetSizeofNamedComponentNodes ( - IN CONST UINT32 NodeStartOffset, - IN CONST CM_ARM_NAMED_COMPONENT_NODE * NodeList, - IN UINT32 NodeCount, - IN OUT IORT_NODE_INDEXER ** CONST NodeIndexer - ) -{ - UINT64 Size; - - ASSERT (NodeList !=3D NULL); - - Size =3D 0; - while (NodeCount-- !=3D 0) { - (*NodeIndexer)->Token =3D NodeList->Token; - (*NodeIndexer)->Object =3D (VOID*)NodeList; - (*NodeIndexer)->Offset =3D (UINT32)(Size + NodeStartOffset); - DEBUG (( - DEBUG_INFO, - "IORT: Node Indexer =3D %p, Token =3D %p, Object =3D %p, Offset =3D = 0x%x\n", - *NodeIndexer, - (*NodeIndexer)->Token, - (*NodeIndexer)->Object, - (*NodeIndexer)->Offset - )); - - Size +=3D GetNamedComponentNodeSize (NodeList); - (*NodeIndexer)++; - NodeList++; - } - - return Size; + ALIGN_VALUE (AsciiStrSize (Node->ObjectName), 4))); } =20 -/** Returns the size of the Root Complex node. - - @param [in] Node Pointer to Root Complex node. +/** Returns the size of the Root Complex node and point + to the next node. =20 + @param [in,out] Ptr Pointer to Root Complex node. @retval Size of the Root Complex node. **/ STATIC UINT32 GetRootComplexNodeSize ( - IN CONST CM_ARM_ROOT_COMPLEX_NODE * Node + IN OUT VOID ** Ptr ) { - ASSERT (Node !=3D NULL); + ASSERT (Ptr !=3D NULL && *Ptr !=3D NULL); + + CM_ARM_ROOT_COMPLEX_NODE *Node =3D *Ptr; + *Ptr =3D Node + 1; =20 /* Size of Root Complex node + Size of ID mapping array @@ -289,69 +126,22 @@ GetRootComplexNodeSize ( sizeof (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE))); } =20 -/** Returns the total size required for the Root Complex nodes and - updates the Node Indexer. - - This function calculates the size required for the node group - and also populates the Node Indexer array with offsets for the - individual nodes. - - @param [in] NodeStartOffset Offset from the start of the - IORT where this node group starts. - @param [in] NodeList Pointer to Root Complex node list. - @param [in] NodeCount Count of the Root Complex nodes. - @param [in, out] NodeIndexer Pointer to the next Node Indexer. - - @retval Total size of the Root Complex nodes. -**/ -STATIC -UINT64 -GetSizeofRootComplexNodes ( - IN CONST UINT32 NodeStartOffset, - IN CONST CM_ARM_ROOT_COMPLEX_NODE * NodeList, - IN UINT32 NodeCount, - IN OUT IORT_NODE_INDEXER ** CONST NodeIndexer - ) -{ - UINT64 Size; - - ASSERT (NodeList !=3D NULL); - - Size =3D 0; - while (NodeCount-- !=3D 0) { - (*NodeIndexer)->Token =3D NodeList->Token; - (*NodeIndexer)->Object =3D (VOID*)NodeList; - (*NodeIndexer)->Offset =3D (UINT32)(Size + NodeStartOffset); - DEBUG (( - DEBUG_INFO, - "IORT: Node Indexer =3D %p, Token =3D %p, Object =3D %p, Offset =3D = 0x%x\n", - *NodeIndexer, - (*NodeIndexer)->Token, - (*NodeIndexer)->Object, - (*NodeIndexer)->Offset - )); - - Size +=3D GetRootComplexNodeSize (NodeList); - (*NodeIndexer)++; - NodeList++; - } - - return Size; -} - -/** Returns the size of the SMMUv1/SMMUv2 node. - - @param [in] Node Pointer to SMMUv1/SMMUv2 node list. +/** Returns the size of the SMMUv1/SMMUv2 node and point + to the next node. =20 + @param [in,out] Ptr Pointer to SMMUv1/SMMUv2 node list. @retval Size of the SMMUv1/SMMUv2 node. **/ STATIC UINT32 GetSmmuV1V2NodeSize ( - IN CONST CM_ARM_SMMUV1_SMMUV2_NODE * Node + IN OUT VOID **Ptr ) { - ASSERT (Node !=3D NULL); + ASSERT (Ptr !=3D NULL && *Ptr !=3D NULL); + + CM_ARM_SMMUV1_SMMUV2_NODE * Node =3D *Ptr; + *Ptr =3D Node + 1; =20 /* Size of SMMU v1/SMMU v2 node + Size of ID mapping array + @@ -367,68 +157,22 @@ GetSmmuV1V2NodeSize ( sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT))); } =20 -/** Returns the total size required for the SMMUv1/SMMUv2 nodes and - updates the Node Indexer. - - This function calculates the size required for the node group - and also populates the Node Indexer array with offsets for the - individual nodes. - - @param [in] NodeStartOffset Offset from the start of the - IORT where this node group starts. - @param [in] NodeList Pointer to SMMUv1/SMMUv2 node list. - @param [in] NodeCount Count of the SMMUv1/SMMUv2 nodes. - @param [in, out] NodeIndexer Pointer to the next Node Indexer. - - @retval Total size of the SMMUv1/SMMUv2 nodes. -**/ -STATIC -UINT64 -GetSizeofSmmuV1V2Nodes ( - IN CONST UINT32 NodeStartOffset, - IN CONST CM_ARM_SMMUV1_SMMUV2_NODE * NodeList, - IN UINT32 NodeCount, - IN OUT IORT_NODE_INDEXER ** CONST NodeIndexer - ) -{ - UINT64 Size; - - ASSERT (NodeList !=3D NULL); - - Size =3D 0; - while (NodeCount-- !=3D 0) { - (*NodeIndexer)->Token =3D NodeList->Token; - (*NodeIndexer)->Object =3D (VOID*)NodeList; - (*NodeIndexer)->Offset =3D (UINT32)(Size + NodeStartOffset); - DEBUG (( - DEBUG_INFO, - "IORT: Node Indexer =3D %p, Token =3D %p, Object =3D %p, Offset =3D = 0x%x\n", - *NodeIndexer, - (*NodeIndexer)->Token, - (*NodeIndexer)->Object, - (*NodeIndexer)->Offset - )); - - Size +=3D GetSmmuV1V2NodeSize (NodeList); - (*NodeIndexer)++; - NodeList++; - } - return Size; -} - -/** Returns the size of the SMMUv3 node. - - @param [in] Node Pointer to SMMUv3 node list. +/** Returns the size of the SMMUv3 node and point to the next + node. =20 + @param [in,out] Ptr Pointer to SMMUv3 node list. @retval Total size of the SMMUv3 nodes. **/ STATIC UINT32 GetSmmuV3NodeSize ( - IN CONST CM_ARM_SMMUV3_NODE * Node + IN OUT VOID ** Ptr ) { - ASSERT (Node !=3D NULL); + ASSERT (Ptr !=3D NULL && *Ptr !=3D NULL); + + CM_ARM_SMMUV3_NODE *Node =3D *Ptr; + *Ptr =3D Node + 1; =20 /* Size of SMMU v1/SMMU v2 node + Size of ID mapping array @@ -438,68 +182,22 @@ GetSmmuV3NodeSize ( sizeof (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE))); } =20 -/** Returns the total size required for the SMMUv3 nodes and - updates the Node Indexer. - - This function calculates the size required for the node group - and also populates the Node Indexer array with offsets for the - individual nodes. - - @param [in] NodeStartOffset Offset from the start of the - IORT where this node group starts. - @param [in] NodeList Pointer to SMMUv3 node list. - @param [in] NodeCount Count of the SMMUv3 nodes. - @param [in, out] NodeIndexer Pointer to the next Node Indexer. - - @retval Total size of the SMMUv3 nodes. -**/ -STATIC -UINT64 -GetSizeofSmmuV3Nodes ( - IN CONST UINT32 NodeStartOffset, - IN CONST CM_ARM_SMMUV3_NODE * NodeList, - IN UINT32 NodeCount, - IN OUT IORT_NODE_INDEXER ** CONST NodeIndexer - ) -{ - UINT64 Size; - - ASSERT (NodeList !=3D NULL); - - Size =3D 0; - while (NodeCount-- !=3D 0) { - (*NodeIndexer)->Token =3D NodeList->Token; - (*NodeIndexer)->Object =3D (VOID*)NodeList; - (*NodeIndexer)->Offset =3D (UINT32)(Size + NodeStartOffset); - DEBUG (( - DEBUG_INFO, - "IORT: Node Indexer =3D %p, Token =3D %p, Object =3D %p, Offset =3D = 0x%x\n", - *NodeIndexer, - (*NodeIndexer)->Token, - (*NodeIndexer)->Object, - (*NodeIndexer)->Offset - )); - - Size +=3D GetSmmuV3NodeSize (NodeList); - (*NodeIndexer)++; - NodeList++; - } - return Size; -} - -/** Returns the size of the PMCG node. - - @param [in] Node Pointer to PMCG node. +/** Returns the size of the PMCG node and point to the next + node. =20 + @param [in,out] Ptr Pointer to PMCG node. @retval Size of the PMCG node. **/ STATIC UINT32 GetPmcgNodeSize ( - IN CONST CM_ARM_PMCG_NODE * Node + IN OUT VOID ** Ptr ) { - ASSERT (Node !=3D NULL); + ASSERT (Ptr !=3D NULL && *Ptr !=3D NULL); + + CM_ARM_PMCG_NODE * Node =3D *Ptr; + *Ptr =3D Node + 1; =20 /* Size of PMCG node + Size of ID mapping array @@ -509,38 +207,49 @@ GetPmcgNodeSize ( sizeof (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE))); } =20 -/** Returns the total size required for the PMCG nodes and - updates the Node Indexer. +/** Returns the total size required for a group of IORT nodes. The configu= ration + manager objects specified by object id must contain CM_OBJECT_TOKEN as + their first field. =20 This function calculates the size required for the node group and also populates the Node Indexer array with offsets for the individual nodes. =20 + @param [in] ObjectId The configuration manager object id = of + nodes that are to be summed. @param [in] NodeStartOffset Offset from the start of the IORT where this node group starts. - @param [in] NodeList Pointer to PMCG node list. - @param [in] NodeCount Count of the PMCG nodes. @param [in, out] NodeIndexer Pointer to the next Node Indexer. + @param [in] GetNodeSize The function to determine the size o= f a single node + of the appropriate type determined b= y object id. =20 - @retval Total size of the PMCG nodes. + @retval Total size of the group of nodes **/ STATIC UINT64 -GetSizeofPmcgNodes ( - IN CONST UINT32 NodeStartOffset, - IN CONST CM_ARM_PMCG_NODE * NodeList, - IN UINT32 NodeCount, - IN OUT IORT_NODE_INDEXER ** CONST NodeIndexer +GetSizeOfNodes ( + IN CONST CM_OBJECT_ID ObjectId, + IN CONST UINT32 NodeStartOffset, + IN OUT IORT_NODE_INDEXER ** CONST NodeIndexer, + IN CONST INDEX_NODE IndexNode ) { - UINT64 Size; - - ASSERT (NodeList !=3D NULL); + UINT64 Size; + EFI_STATUS Status; + VOID *NodeList; + UINT32 NodeCount; + VOID *Cursor; + + Status =3D CfgMgrGetObjects (ObjectId, CM_NULL_TOKEN, &NodeList, &NodeCo= unt); + if (EFI_ERROR(Status)) { + return 0; + } =20 + Cursor =3D NodeList; Size =3D 0; while (NodeCount-- !=3D 0) { - (*NodeIndexer)->Token =3D NodeList->Token; - (*NodeIndexer)->Object =3D (VOID*)NodeList; + (*NodeIndexer)->Token =3D *(CM_OBJECT_TOKEN *) Cursor; // CM_OBJECT_TO= KEN is always the first element of a node + (*NodeIndexer)->Object =3D Cursor; (*NodeIndexer)->Offset =3D (UINT32)(Size + NodeStartOffset); DEBUG (( DEBUG_INFO, @@ -551,10 +260,11 @@ GetSizeofPmcgNodes ( (*NodeIndexer)->Offset )); =20 - Size +=3D GetPmcgNodeSize (NodeList); + Size +=3D IndexNode (&Cursor); (*NodeIndexer)++; - NodeList++; } + + FreePool (NodeList); return Size; } =20 @@ -631,14 +341,14 @@ STATIC EFI_STATUS AddIdMappingArray ( IN CONST ACPI_TABLE_GENERATOR * CONST This, - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProto= col, IN EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE * IdMapArray, IN UINT32 IdCount, IN CONST CM_OBJECT_TOKEN IdMappingTo= ken ) { EFI_STATUS Status; - CM_ARM_ID_MAPPING * IdMappings; + VOID * IdMappings; + CM_ARM_ID_MAPPING * Cursor; UINT32 IdMappingCount; ACPI_IORT_GENERATOR * Generator; =20 @@ -647,18 +357,12 @@ AddIdMappingArray ( Generator =3D (ACPI_IORT_GENERATOR*)This; =20 // Get the Id Mapping Array - Status =3D GetEArmObjIdMappingArray ( - CfgMgrProtocol, - IdMappingToken, - &IdMappings, - &IdMappingCount - ); + Status =3D CfgMgrGetObjects ( + EArmObjIdMappingArray, + IdMappingToken, + &IdMappings, + &IdMappingCount); if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: IORT: Failed to get Id Mapping array. Status =3D %r\n", - Status - )); return Status; } =20 @@ -667,15 +371,17 @@ AddIdMappingArray ( DEBUG_ERROR, "ERROR: IORT: Failed to get the required number of Id Mappings.\n" )); - return EFI_NOT_FOUND; + Status =3D EFI_NOT_FOUND; + goto EXIT; } =20 + Cursor =3D IdMappings; // Populate the Id Mapping array while (IdCount-- !=3D 0) { Status =3D GetNodeOffsetReferencedByToken ( Generator->NodeIndexer, Generator->IortNodeCount, - IdMappings->OutputReferenceToken, + Cursor->OutputReferenceToken, &IdMapArray->OutputReference ); if (EFI_ERROR (Status)) { @@ -684,22 +390,24 @@ AddIdMappingArray ( "ERROR: IORT: Failed to get Output Reference for ITS Identifier ar= ray." "Reference Token =3D %p" " Status =3D %r\n", - IdMappings->OutputReferenceToken, + Cursor->OutputReferenceToken, Status )); - return Status; + goto EXIT; } =20 - IdMapArray->InputBase =3D IdMappings->InputBase; - IdMapArray->NumIds =3D IdMappings->NumIds; - IdMapArray->OutputBase =3D IdMappings->OutputBase; - IdMapArray->Flags =3D IdMappings->Flags; + IdMapArray->InputBase =3D Cursor->InputBase; + IdMapArray->NumIds =3D Cursor->NumIds; + IdMapArray->OutputBase =3D Cursor->OutputBase; + IdMapArray->Flags =3D Cursor->Flags; =20 IdMapArray++; - IdMappings++; + Cursor++; } // Id Mapping array =20 - return EFI_SUCCESS; +EXIT: + FreePool (IdMappings); + return Status; } =20 /** Update the ITS Group Node Information. @@ -722,10 +430,9 @@ STATIC EFI_STATUS AddItsGroupNodes ( IN CONST ACPI_TABLE_GENERATOR * CONST This, - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, IN CONST EFI_ACPI_6_0_IO_REMAPPING_TABLE * Iort, IN CONST UINT32 NodesStartOffset, - IN CONST CM_ARM_ITS_GROUP_NODE * NodeList, + IN VOID * NodeList, IN UINT32 NodeCount ) { @@ -736,6 +443,7 @@ AddItsGroupNodes ( UINT32 ItsIdentifierCount; UINT32 IdIndex; UINT64 NodeLength; + CM_ARM_ITS_GROUP_NODE *Node; =20 ASSERT (Iort !=3D NULL); =20 @@ -743,7 +451,8 @@ AddItsGroupNodes ( NodesStartOffset); =20 while (NodeCount-- !=3D 0) { - NodeLength =3D GetItsGroupNodeSize (NodeList); + Node =3D (CM_ARM_ITS_GROUP_NODE *) NodeList; + NodeLength =3D GetItsGroupNodeSize (&NodeList); // Advances NodeList if (NodeLength > MAX_UINT16) { Status =3D EFI_INVALID_PARAMETER; DEBUG (( @@ -765,22 +474,16 @@ AddItsGroupNodes ( ItsGroupNode->Node.IdReference =3D 0; =20 // IORT specific data - ItsGroupNode->NumItsIdentifiers =3D NodeList->ItsIdCount; + ItsGroupNode->NumItsIdentifiers =3D Node->ItsIdCount; ItsIds =3D (UINT32*)((UINT8*)ItsGroupNode + sizeof (EFI_ACPI_6_0_IO_REMAPPING_ITS_NODE)); =20 - Status =3D GetEArmObjGicItsIdentifierArray ( - CfgMgrProtocol, - NodeList->ItsIdToken, - &ItsIdentifier, - &ItsIdentifierCount - ); + Status =3D CfgMgrGetObjects ( + EArmObjGicItsIdentifierArray, + Node->ItsIdToken, + (VOID **)&ItsIdentifier, + &ItsIdentifierCount); if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: IORT: Failed to get ITS Identifier array. Status =3D %r\n", - Status - )); return Status; } =20 @@ -789,7 +492,8 @@ AddItsGroupNodes ( DEBUG_ERROR, "ERROR: IORT: Failed to get the required number of ITS Identifiers= .\n" )); - return EFI_NOT_FOUND; + Status =3D EFI_NOT_FOUND; + goto EXIT; } =20 // Populate the ITS identifier array @@ -800,10 +504,11 @@ AddItsGroupNodes ( // Next IORT Group Node ItsGroupNode =3D (EFI_ACPI_6_0_IO_REMAPPING_ITS_NODE*)((UINT8*)ItsGrou= pNode + ItsGroupNode->Node.Length); - NodeList++; } // IORT Group Node =20 - return EFI_SUCCESS; +EXIT: + FreePool (ItsIdentifier); + return Status; } =20 /** Update the Named Component Node Information. @@ -812,8 +517,6 @@ AddItsGroupNodes ( table. =20 @param [in] This Pointer to the table Generator. - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - Protocol Interface. @param [in] Iort Pointer to IORT table structure. @param [in] NodesStartOffset Offset for the start of the Named Component Nodes. @@ -829,10 +532,9 @@ STATIC EFI_STATUS AddNamedComponentNodes ( IN CONST ACPI_TABLE_GENERATOR * CONST This, - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProto= col, IN CONST EFI_ACPI_6_0_IO_REMAPPING_TABLE * Iort, IN CONST UINT32 NodesStartO= ffset, - IN CONST CM_ARM_NAMED_COMPONENT_NODE * NodeList, + IN VOID * NodeList, IN UINT32 NodeCount ) { @@ -842,6 +544,7 @@ AddNamedComponentNodes ( CHAR8 * ObjectName; UINTN ObjectNameLength; UINT64 NodeLength; + CM_ARM_NAMED_COMPONENT_NODE * Node; =20 ASSERT (Iort !=3D NULL); =20 @@ -849,7 +552,8 @@ AddNamedComponentNodes ( NodesStartOffset); =20 while (NodeCount-- !=3D 0) { - NodeLength =3D GetNamedComponentNodeSize (NodeList); + Node =3D (CM_ARM_NAMED_COMPONENT_NODE*) NodeList; + NodeLength =3D GetNamedComponentNodeSize (&NodeList); // Advances Nod= eList if (NodeLength > MAX_UINT16) { Status =3D EFI_INVALID_PARAMETER; DEBUG (( @@ -867,20 +571,20 @@ AddNamedComponentNodes ( NcNode->Node.Length =3D (UINT16)NodeLength; NcNode->Node.Revision =3D 2; NcNode->Node.Reserved =3D EFI_ACPI_RESERVED_DWORD; - NcNode->Node.NumIdMappings =3D NodeList->IdMappingCount; + NcNode->Node.NumIdMappings =3D Node->IdMappingCount; =20 - ObjectNameLength =3D AsciiStrLen (NodeList->ObjectName) + 1; + ObjectNameLength =3D AsciiStrLen (Node->ObjectName) + 1; NcNode->Node.IdReference =3D (UINT32)(sizeof (EFI_ACPI_6_0_IO_REMAPPING_NAMED_COMP_NODE) + (ALIGN_VALUE (ObjectNameLength, 4))); =20 // Named Component specific data - NcNode->Flags =3D NodeList->Flags; - NcNode->CacheCoherent =3D NodeList->CacheCoherent; - NcNode->AllocationHints =3D NodeList->AllocationHints; + NcNode->Flags =3D Node->Flags; + NcNode->CacheCoherent =3D Node->CacheCoherent; + NcNode->AllocationHints =3D Node->AllocationHints; NcNode->Reserved =3D EFI_ACPI_RESERVED_WORD; - NcNode->MemoryAccessFlags =3D NodeList->MemoryAccessFlags; - NcNode->AddressSizeLimit =3D NodeList->AddressSizeLimit; + NcNode->MemoryAccessFlags =3D Node->MemoryAccessFlags; + NcNode->AddressSizeLimit =3D Node->AddressSizeLimit; =20 // Copy the object name ObjectName =3D (CHAR8*)((UINT8*)NcNode + @@ -888,7 +592,7 @@ AddNamedComponentNodes ( Status =3D AsciiStrCpyS ( ObjectName, ObjectNameLength, - NodeList->ObjectName + Node->ObjectName ); if (EFI_ERROR (Status)) { DEBUG (( @@ -899,19 +603,14 @@ AddNamedComponentNodes ( return Status; } =20 - if ((NodeList->IdMappingCount > 0) && - (NodeList->IdMappingToken !=3D CM_NULL_TOKEN)) { + if ((Node->IdMappingCount > 0) && + (Node->IdMappingToken !=3D CM_NULL_TOKEN)) { // Ids for Named Component IdMapArray =3D (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE*)((UINT8*)NcNode + NcNode->Node.IdReference); =20 Status =3D AddIdMappingArray ( - This, - CfgMgrProtocol, - IdMapArray, - NodeList->IdMappingCount, - NodeList->IdMappingToken - ); + This, IdMapArray, Node->IdMappingCount, Node->IdMappingToken); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, @@ -925,7 +624,6 @@ AddNamedComponentNodes ( // Next Named Component Node NcNode =3D (EFI_ACPI_6_0_IO_REMAPPING_NAMED_COMP_NODE*)((UINT8*)NcNode= + NcNode->Node.Length); - NodeList++; } // Named Component Node =20 return EFI_SUCCESS; @@ -936,8 +634,6 @@ AddNamedComponentNodes ( This function updates the Root Complex node information in the IORT ta= ble. =20 @param [in] This Pointer to the table Generator. - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - Protocol Interface. @param [in] Iort Pointer to IORT table structure. @param [in] NodesStartOffset Offset for the start of the Root Comp= lex Nodes. @@ -953,10 +649,9 @@ STATIC EFI_STATUS AddRootComplexNodes ( IN CONST ACPI_TABLE_GENERATOR * CONST This, - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProto= col, IN CONST EFI_ACPI_6_0_IO_REMAPPING_TABLE * Iort, IN CONST UINT32 NodesStartO= ffset, - IN CONST CM_ARM_ROOT_COMPLEX_NODE * NodeList, + IN VOID * NodeList, IN UINT32 NodeCount ) { @@ -964,6 +659,7 @@ AddRootComplexNodes ( EFI_ACPI_6_0_IO_REMAPPING_RC_NODE * RcNode; EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE * IdMapArray; UINT64 NodeLength; + CM_ARM_ROOT_COMPLEX_NODE * Node; =20 ASSERT (Iort !=3D NULL); =20 @@ -971,7 +667,8 @@ AddRootComplexNodes ( NodesStartOffset); =20 while (NodeCount-- !=3D 0) { - NodeLength =3D GetRootComplexNodeSize (NodeList); + Node =3D (CM_ARM_ROOT_COMPLEX_NODE *) NodeList; + NodeLength =3D GetRootComplexNodeSize (&NodeList); // Advances NodeLi= st if (NodeLength > MAX_UINT16) { Status =3D EFI_INVALID_PARAMETER; DEBUG (( @@ -989,33 +686,28 @@ AddRootComplexNodes ( RcNode->Node.Length =3D (UINT16)NodeLength; RcNode->Node.Revision =3D 1; RcNode->Node.Reserved =3D EFI_ACPI_RESERVED_DWORD; - RcNode->Node.NumIdMappings =3D NodeList->IdMappingCount; + RcNode->Node.NumIdMappings =3D Node->IdMappingCount; RcNode->Node.IdReference =3D sizeof (EFI_ACPI_6_0_IO_REMAPPING_RC_NODE= ); =20 // Root Complex specific data - RcNode->CacheCoherent =3D NodeList->CacheCoherent; - RcNode->AllocationHints =3D NodeList->AllocationHints; + RcNode->CacheCoherent =3D Node->CacheCoherent; + RcNode->AllocationHints =3D Node->AllocationHints; RcNode->Reserved =3D EFI_ACPI_RESERVED_WORD; - RcNode->MemoryAccessFlags =3D NodeList->MemoryAccessFlags; - RcNode->AtsAttribute =3D NodeList->AtsAttribute; - RcNode->PciSegmentNumber =3D NodeList->PciSegmentNumber; - RcNode->MemoryAddressSize =3D NodeList->MemoryAddressSize; + RcNode->MemoryAccessFlags =3D Node->MemoryAccessFlags; + RcNode->AtsAttribute =3D Node->AtsAttribute; + RcNode->PciSegmentNumber =3D Node->PciSegmentNumber; + RcNode->MemoryAddressSize =3D Node->MemoryAddressSize; RcNode->Reserved1[0] =3D EFI_ACPI_RESERVED_BYTE; RcNode->Reserved1[1] =3D EFI_ACPI_RESERVED_BYTE; RcNode->Reserved1[2] =3D EFI_ACPI_RESERVED_BYTE; =20 - if ((NodeList->IdMappingCount > 0) && - (NodeList->IdMappingToken !=3D CM_NULL_TOKEN)) { + if ((Node->IdMappingCount > 0) && + (Node->IdMappingToken !=3D CM_NULL_TOKEN)) { // Ids for Root Complex IdMapArray =3D (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE*)((UINT8*)RcNode + RcNode->Node.IdReference); Status =3D AddIdMappingArray ( - This, - CfgMgrProtocol, - IdMapArray, - NodeList->IdMappingCount, - NodeList->IdMappingToken - ); + This, IdMapArray, Node->IdMappingCount, Node->IdMappingToken); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, @@ -1029,7 +721,6 @@ AddRootComplexNodes ( // Next Root Complex Node RcNode =3D (EFI_ACPI_6_0_IO_REMAPPING_RC_NODE*)((UINT8*)RcNode + RcNode->Node.Length); - NodeList++; } // Root Complex Node =20 return EFI_SUCCESS; @@ -1040,8 +731,6 @@ AddRootComplexNodes ( This function retrieves the InterruptArray object referenced by the InterruptToken and updates the SMMU InterruptArray. =20 - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - Protocol Interface. @param [in, out] InterruptArray Pointer to an array of Interrupts. @param [in] InterruptCount Number of entries in the InterruptAr= ray. @param [in] InterruptToken Reference Token for retrieving the S= MMU @@ -1054,31 +743,25 @@ AddRootComplexNodes ( STATIC EFI_STATUS AddSmmuInterrruptArray ( - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtoc= ol, IN OUT EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT * InterruptArr= ay, IN UINT32 InterruptCou= nt, IN CONST CM_OBJECT_TOKEN InterruptTok= en ) { EFI_STATUS Status; - CM_ARM_SMMU_INTERRUPT * SmmuInterrupt; + CM_ARM_SMMU_INTERRUPT * Cursor; + VOID * SmmuInterrupt; UINT32 SmmuInterruptCount; =20 ASSERT (InterruptArray !=3D NULL); =20 // Get the SMMU Interrupt Array - Status =3D GetEArmObjSmmuInterruptArray ( - CfgMgrProtocol, - InterruptToken, - &SmmuInterrupt, - &SmmuInterruptCount - ); + Status =3D CfgMgrGetObjects ( + EArmObjSmmuInterruptArray, + InterruptToken, + &SmmuInterrupt, + &SmmuInterruptCount); if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: IORT: Failed to get SMMU Interrupt array. Status =3D %r\n", - Status - )); return Status; } =20 @@ -1087,25 +770,27 @@ AddSmmuInterrruptArray ( DEBUG_ERROR, "ERROR: IORT: Failed to get the required number of SMMU Interrupts.\= n" )); - return EFI_NOT_FOUND; + Status =3D EFI_NOT_FOUND; + goto EXIT; } =20 + Cursor =3D SmmuInterrupt; // Populate the Id Mapping array while (InterruptCount-- !=3D 0) { - InterruptArray->Interrupt =3D SmmuInterrupt->Interrupt; - InterruptArray->InterruptFlags =3D SmmuInterrupt->Flags; + InterruptArray->Interrupt =3D Cursor->Interrupt; + InterruptArray->InterruptFlags =3D Cursor->Flags; InterruptArray++; - SmmuInterrupt++; + Cursor++; } // Id Mapping array =20 +EXIT: + FreePool (SmmuInterrupt); return EFI_SUCCESS; } =20 /** Update the SMMU v1/v2 Node Information. =20 @param [in] This Pointer to the table Generator. - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - Protocol Interface. @param [in] Iort Pointer to IORT table structure. @param [in] NodesStartOffset Offset for the start of the SMMU v1/v2 Nodes. @@ -1121,10 +806,9 @@ STATIC EFI_STATUS AddSmmuV1V2Nodes ( IN CONST ACPI_TABLE_GENERATOR * CONST This, - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtoc= ol, IN CONST EFI_ACPI_6_0_IO_REMAPPING_TABLE * Iort, IN CONST UINT32 NodesStartOf= fset, - IN CONST CM_ARM_SMMUV1_SMMUV2_NODE * NodeList, + IN VOID * NodeList, IN UINT32 NodeCount ) { @@ -1135,6 +819,7 @@ AddSmmuV1V2Nodes ( EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT * ContextInterruptArray; EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT * PmuInterruptArray; UINT64 NodeLength; + CM_ARM_SMMUV1_SMMUV2_NODE * Node; =20 ASSERT (Iort !=3D NULL); =20 @@ -1142,7 +827,8 @@ AddSmmuV1V2Nodes ( NodesStartOffset); =20 while (NodeCount-- !=3D 0) { - NodeLength =3D GetSmmuV1V2NodeSize (NodeList); + Node =3D (CM_ARM_SMMUV1_SMMUV2_NODE*) NodeList; + NodeLength =3D GetSmmuV1V2NodeSize (&NodeList); // Advances NodeList if (NodeLength > MAX_UINT16) { Status =3D EFI_INVALID_PARAMETER; DEBUG (( @@ -1159,25 +845,25 @@ AddSmmuV1V2Nodes ( SmmuNode->Node.Length =3D (UINT16)NodeLength; SmmuNode->Node.Revision =3D 0; SmmuNode->Node.Reserved =3D EFI_ACPI_RESERVED_DWORD; - SmmuNode->Node.NumIdMappings =3D NodeList->IdMappingCount; + SmmuNode->Node.NumIdMappings =3D Node->IdMappingCount; SmmuNode->Node.IdReference =3D sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_= NODE) + - (NodeList->ContextInterruptCount * + (Node->ContextInterruptCount * sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT)) + - (NodeList->PmuInterruptCount * + (Node->PmuInterruptCount * sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT)); =20 // SMMU v1/v2 specific data - SmmuNode->Base =3D NodeList->BaseAddress; - SmmuNode->Span =3D NodeList->Span; - SmmuNode->Model =3D NodeList->Model; - SmmuNode->Flags =3D NodeList->Flags; + SmmuNode->Base =3D Node->BaseAddress; + SmmuNode->Span =3D Node->Span; + SmmuNode->Model =3D Node->Model; + SmmuNode->Flags =3D Node->Flags; =20 // Reference to Global Interrupt Array SmmuNode->GlobalInterruptArrayRef =3D OFFSET_OF (EFI_ACPI_6_0_IO_REMAPPING_SMMU_NODE, SMMU_NSgIrpt); =20 // Context Interrupt - SmmuNode->NumContextInterrupts =3D NodeList->ContextInterruptCount; + SmmuNode->NumContextInterrupts =3D Node->ContextInterruptCount; SmmuNode->ContextInterruptArrayRef =3D sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_NODE); ContextInterruptArray =3D @@ -1185,26 +871,24 @@ AddSmmuV1V2Nodes ( sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_NODE)); =20 // PMU Interrupt - SmmuNode->NumPmuInterrupts =3D NodeList->PmuInterruptCount; + SmmuNode->NumPmuInterrupts =3D Node->PmuInterruptCount; SmmuNode->PmuInterruptArrayRef =3D SmmuNode->ContextInterruptArrayRef + - (NodeList->ContextInterruptCount * + (Node->ContextInterruptCount * sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT)); PmuInterruptArray =3D (EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT*)((UINT8*)SmmuNode + SmmuNode->PmuInterruptArrayRef); =20 - SmmuNode->SMMU_NSgIrpt =3D NodeList->SMMU_NSgIrpt; - SmmuNode->SMMU_NSgIrptFlags =3D NodeList->SMMU_NSgIrptFlags; - SmmuNode->SMMU_NSgCfgIrpt =3D NodeList->SMMU_NSgCfgIrpt; - SmmuNode->SMMU_NSgCfgIrptFlags =3D NodeList->SMMU_NSgCfgIrptFlags; + SmmuNode->SMMU_NSgIrpt =3D Node->SMMU_NSgIrpt; + SmmuNode->SMMU_NSgIrptFlags =3D Node->SMMU_NSgIrptFlags; + SmmuNode->SMMU_NSgCfgIrpt =3D Node->SMMU_NSgCfgIrpt; + SmmuNode->SMMU_NSgCfgIrptFlags =3D Node->SMMU_NSgCfgIrptFlags; =20 // Add Context Interrupt Array Status =3D AddSmmuInterrruptArray ( - CfgMgrProtocol, - ContextInterruptArray, - SmmuNode->NumContextInterrupts, - NodeList->ContextInterruptToken - ); + ContextInterruptArray, + SmmuNode->NumContextInterrupts, + Node->ContextInterruptToken); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, @@ -1216,13 +900,11 @@ AddSmmuV1V2Nodes ( =20 // Add PMU Interrupt Array if ((SmmuNode->NumPmuInterrupts > 0) && - (NodeList->PmuInterruptToken !=3D CM_NULL_TOKEN)) { + (Node->PmuInterruptToken !=3D CM_NULL_TOKEN)) { Status =3D AddSmmuInterrruptArray ( - CfgMgrProtocol, - PmuInterruptArray, - SmmuNode->NumPmuInterrupts, - NodeList->PmuInterruptToken - ); + PmuInterruptArray, + SmmuNode->NumPmuInterrupts, + Node->PmuInterruptToken); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, @@ -1233,18 +915,13 @@ AddSmmuV1V2Nodes ( } } =20 - if ((NodeList->IdMappingCount > 0) && - (NodeList->IdMappingToken !=3D CM_NULL_TOKEN)) { + if ((Node->IdMappingCount > 0) && + (Node->IdMappingToken !=3D CM_NULL_TOKEN)) { // Ids for SMMU v1/v2 Node IdMapArray =3D (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE*)((UINT8*)SmmuNod= e + SmmuNode->Node.IdReference); Status =3D AddIdMappingArray ( - This, - CfgMgrProtocol, - IdMapArray, - NodeList->IdMappingCount, - NodeList->IdMappingToken - ); + This, IdMapArray, Node->IdMappingCount, Node->IdMappingToken); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, @@ -1257,7 +934,6 @@ AddSmmuV1V2Nodes ( // Next SMMU v1/v2 Node SmmuNode =3D (EFI_ACPI_6_0_IO_REMAPPING_SMMU_NODE*)((UINT8*)SmmuNode + SmmuNode->Node.Length); - NodeList++; } // SMMU v1/v2 Node =20 return EFI_SUCCESS; @@ -1268,8 +944,6 @@ AddSmmuV1V2Nodes ( This function updates the SMMUv3 node information in the IORT table. =20 @param [in] This Pointer to the table Generator. - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - Protocol Interface. @param [in] Iort Pointer to IORT table structure. @param [in] NodesStartOffset Offset for the start of the SMMUv3 No= des. @param [in] NodeList Pointer to an array of SMMUv3 Node Ob= jects. @@ -1283,10 +957,9 @@ STATIC EFI_STATUS AddSmmuV3Nodes ( IN CONST ACPI_TABLE_GENERATOR * CONST This, - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtoc= ol, IN CONST EFI_ACPI_6_0_IO_REMAPPING_TABLE * Iort, IN CONST UINT32 NodesStartOf= fset, - IN CONST CM_ARM_SMMUV3_NODE * NodeList, + IN VOID * NodeList, IN UINT32 NodeCount ) { @@ -1294,6 +967,7 @@ AddSmmuV3Nodes ( EFI_ACPI_6_0_IO_REMAPPING_SMMU3_NODE * SmmuV3Node; EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE * IdMapArray; UINT64 NodeLength; + CM_ARM_SMMUV3_NODE * Node; =20 ASSERT (Iort !=3D NULL); =20 @@ -1301,7 +975,8 @@ AddSmmuV3Nodes ( NodesStartOffset); =20 while (NodeCount-- !=3D 0) { - NodeLength =3D GetSmmuV3NodeSize (NodeList); + Node =3D (CM_ARM_SMMUV3_NODE*) NodeList; + NodeLength =3D GetSmmuV3NodeSize (&NodeList); // Advances NodeList if (NodeLength > MAX_UINT16) { Status =3D EFI_INVALID_PARAMETER; DEBUG (( @@ -1318,24 +993,24 @@ AddSmmuV3Nodes ( SmmuV3Node->Node.Length =3D (UINT16)NodeLength; SmmuV3Node->Node.Revision =3D 2; SmmuV3Node->Node.Reserved =3D EFI_ACPI_RESERVED_DWORD; - SmmuV3Node->Node.NumIdMappings =3D NodeList->IdMappingCount; + SmmuV3Node->Node.NumIdMappings =3D Node->IdMappingCount; SmmuV3Node->Node.IdReference =3D sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU3_NODE); =20 // SMMUv3 specific data - SmmuV3Node->Base =3D NodeList->BaseAddress; - SmmuV3Node->Flags =3D NodeList->Flags; + SmmuV3Node->Base =3D Node->BaseAddress; + SmmuV3Node->Flags =3D Node->Flags; SmmuV3Node->Reserved =3D EFI_ACPI_RESERVED_WORD; - SmmuV3Node->VatosAddress =3D NodeList->VatosAddress; - SmmuV3Node->Model =3D NodeList->Model; - SmmuV3Node->Event =3D NodeList->EventInterrupt; - SmmuV3Node->Pri =3D NodeList->PriInterrupt; - SmmuV3Node->Gerr =3D NodeList->GerrInterrupt; - SmmuV3Node->Sync =3D NodeList->SyncInterrupt; + SmmuV3Node->VatosAddress =3D Node->VatosAddress; + SmmuV3Node->Model =3D Node->Model; + SmmuV3Node->Event =3D Node->EventInterrupt; + SmmuV3Node->Pri =3D Node->PriInterrupt; + SmmuV3Node->Gerr =3D Node->GerrInterrupt; + SmmuV3Node->Sync =3D Node->SyncInterrupt; =20 if ((SmmuV3Node->Flags & EFI_ACPI_IORT_SMMUv3_FLAG_PROXIMITY_DOMAIN) != =3D 0) { // The Proximity Domain Valid flag is set to 1 - SmmuV3Node->ProximityDomain =3D NodeList->ProximityDomain; + SmmuV3Node->ProximityDomain =3D Node->ProximityDomain; } else { SmmuV3Node->ProximityDomain =3D 0; } @@ -1346,21 +1021,16 @@ AddSmmuV3Nodes ( // the DeviceID mapping index field is ignored. SmmuV3Node->DeviceIdMappingIndex =3D 0; } else { - SmmuV3Node->DeviceIdMappingIndex =3D NodeList->DeviceIdMappingIndex; + SmmuV3Node->DeviceIdMappingIndex =3D Node->DeviceIdMappingIndex; } =20 - if ((NodeList->IdMappingCount > 0) && - (NodeList->IdMappingToken !=3D CM_NULL_TOKEN)) { + if ((Node->IdMappingCount > 0) && + (Node->IdMappingToken !=3D CM_NULL_TOKEN)) { // Ids for SMMUv3 node IdMapArray =3D (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE*)((UINT8*)SmmuV3N= ode + SmmuV3Node->Node.IdReference); Status =3D AddIdMappingArray ( - This, - CfgMgrProtocol, - IdMapArray, - NodeList->IdMappingCount, - NodeList->IdMappingToken - ); + This, IdMapArray, Node->IdMappingCount, Node->IdMappingToken); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, @@ -1374,7 +1044,6 @@ AddSmmuV3Nodes ( // Next SMMUv3 Node SmmuV3Node =3D (EFI_ACPI_6_0_IO_REMAPPING_SMMU3_NODE*)((UINT8*)SmmuV3N= ode + SmmuV3Node->Node.Length); - NodeList++; } // SMMUv3 Node =20 return EFI_SUCCESS; @@ -1385,8 +1054,6 @@ AddSmmuV3Nodes ( This function updates the PMCG node information in the IORT table. =20 @param [in] This Pointer to the table Generator. - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - Protocol Interface. @param [in] Iort Pointer to IORT table structure. @param [in] NodesStartOffset Offset for the start of the PMCG Node= s. @param [in] NodeList Pointer to an array of PMCG Node Obje= cts. @@ -1400,10 +1067,9 @@ STATIC EFI_STATUS AddPmcgNodes ( IN CONST ACPI_TABLE_GENERATOR * CONST This, - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtoc= ol, IN CONST EFI_ACPI_6_0_IO_REMAPPING_TABLE * Iort, IN CONST UINT32 NodesStartOf= fset, - IN CONST CM_ARM_PMCG_NODE * NodeList, + IN VOID * NodeList, IN UINT32 NodeCount ) { @@ -1412,6 +1078,7 @@ AddPmcgNodes ( EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE * IdMapArray; ACPI_IORT_GENERATOR * Generator; UINT64 NodeLength; + CM_ARM_PMCG_NODE * Node; =20 ASSERT (Iort !=3D NULL); =20 @@ -1420,7 +1087,8 @@ AddPmcgNodes ( NodesStartOffset); =20 while (NodeCount-- !=3D 0) { - NodeLength =3D GetPmcgNodeSize (NodeList); + Node =3D (CM_ARM_PMCG_NODE*) NodeList; + NodeLength =3D GetPmcgNodeSize (&NodeList); // Advances NodeList if (NodeLength > MAX_UINT16) { Status =3D EFI_INVALID_PARAMETER; DEBUG (( @@ -1437,18 +1105,18 @@ AddPmcgNodes ( PmcgNode->Node.Length =3D (UINT16)NodeLength; PmcgNode->Node.Revision =3D 1; PmcgNode->Node.Reserved =3D EFI_ACPI_RESERVED_DWORD; - PmcgNode->Node.NumIdMappings =3D NodeList->IdMappingCount; + PmcgNode->Node.NumIdMappings =3D Node->IdMappingCount; PmcgNode->Node.IdReference =3D sizeof (EFI_ACPI_6_0_IO_REMAPPING_PMCG_= NODE); =20 // PMCG specific data - PmcgNode->Base =3D NodeList->BaseAddress; - PmcgNode->OverflowInterruptGsiv =3D NodeList->OverflowInterrupt; - PmcgNode->Page1Base =3D NodeList->Page1BaseAddress; + PmcgNode->Base =3D Node->BaseAddress; + PmcgNode->OverflowInterruptGsiv =3D Node->OverflowInterrupt; + PmcgNode->Page1Base =3D Node->Page1BaseAddress; =20 Status =3D GetNodeOffsetReferencedByToken ( Generator->NodeIndexer, Generator->IortNodeCount, - NodeList->ReferenceToken, + Node->ReferenceToken, &PmcgNode->NodeReference ); if (EFI_ERROR (Status)) { @@ -1457,25 +1125,20 @@ AddPmcgNodes ( "ERROR: IORT: Failed to get Output Reference for PMCG Node." "Reference Token =3D %p" " Status =3D %r\n", - NodeList->ReferenceToken, + Node->ReferenceToken, Status )); return Status; } =20 - if ((NodeList->IdMappingCount > 0) && - (NodeList->IdMappingToken !=3D CM_NULL_TOKEN)) { + if ((Node->IdMappingCount > 0) && + (Node->IdMappingToken !=3D CM_NULL_TOKEN)) { // Ids for PMCG node IdMapArray =3D (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE*)((UINT8*)PmcgNod= e + PmcgNode->Node.IdReference); =20 Status =3D AddIdMappingArray ( - This, - CfgMgrProtocol, - IdMapArray, - NodeList->IdMappingCount, - NodeList->IdMappingToken - ); + This, IdMapArray, Node->IdMappingCount, Node->IdMappingToken); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, @@ -1489,7 +1152,6 @@ AddPmcgNodes ( // Next PMCG Node PmcgNode =3D (EFI_ACPI_6_0_IO_REMAPPING_PMCG_NODE*)((UINT8*)PmcgNode + PmcgNode->Node.Length); - NodeList++; } // PMCG Node =20 return EFI_SUCCESS; @@ -1547,20 +1209,13 @@ BuildIortTable ( UINT32 SmmuV3Offset; UINT32 PmcgOffset; =20 - CM_ARM_ITS_GROUP_NODE * ItsGroupNodeList; - CM_ARM_NAMED_COMPONENT_NODE * NamedComponentNodeList; - CM_ARM_ROOT_COMPLEX_NODE * RootComplexNodeList; - CM_ARM_SMMUV1_SMMUV2_NODE * SmmuV1V2NodeList; - CM_ARM_SMMUV3_NODE * SmmuV3NodeList; - CM_ARM_PMCG_NODE * PmcgNodeList; - + VOID * NodeList; EFI_ACPI_6_0_IO_REMAPPING_TABLE * Iort; IORT_NODE_INDEXER * NodeIndexer; ACPI_IORT_GENERATOR * Generator; =20 ASSERT (This !=3D NULL); ASSERT (AcpiTableInfo !=3D NULL); - ASSERT (CfgMgrProtocol !=3D NULL); ASSERT (Table !=3D NULL); ASSERT (AcpiTableInfo->TableGeneratorId =3D=3D This->GeneratorID); ASSERT (AcpiTableInfo->AcpiTableSignature =3D=3D This->AcpiTableSignatur= e); @@ -1579,136 +1234,68 @@ BuildIortTable ( } =20 Generator =3D (ACPI_IORT_GENERATOR*)This; + + // Pointers to allocated memory *Table =3D NULL; =20 // Get the ITS group node info - Status =3D GetEArmObjItsGroup ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &ItsGroupNodeList, - &ItsGroupNodeCount - ); + Status =3D CfgMgrCountObjects (EArmObjItsGroup, &ItsGroupNodeCount); if (EFI_ERROR (Status) && (Status !=3D EFI_NOT_FOUND)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: IORT: Failed to get ITS Group Node Info. Status =3D %r\n", - Status - )); - goto error_handler; + return Status; } =20 // Add the ITS group node count IortNodeCount =3D ItsGroupNodeCount; =20 // Get the Named component node info - Status =3D GetEArmObjNamedComponent ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &NamedComponentNodeList, - &NamedComponentNodeCount - ); + Status =3D CfgMgrCountObjects (EArmObjNamedComponent, &NamedComponentNod= eCount); if (EFI_ERROR (Status) && (Status !=3D EFI_NOT_FOUND)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: IORT: Failed to get Named Component Node Info. Status =3D %r= \n", - Status - )); - goto error_handler; + return Status; } =20 // Add the Named Component group count IortNodeCount +=3D NamedComponentNodeCount; =20 // Get the Root complex node info - Status =3D GetEArmObjRootComplex ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &RootComplexNodeList, - &RootComplexNodeCount - ); + Status =3D CfgMgrCountObjects (EArmObjRootComplex, &RootComplexNodeCount= ); if (EFI_ERROR (Status) && (Status !=3D EFI_NOT_FOUND)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: IORT: Failed to get Root Complex Node Info. Status =3D %r\n", - Status - )); - goto error_handler; + return Status; } =20 // Add the Root Complex node count IortNodeCount +=3D RootComplexNodeCount; =20 // Get the SMMU v1/v2 node info - Status =3D GetEArmObjSmmuV1SmmuV2 ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &SmmuV1V2NodeList, - &SmmuV1V2NodeCount - ); + Status =3D CfgMgrCountObjects (EArmObjSmmuV1SmmuV2, &SmmuV1V2NodeCount); if (EFI_ERROR (Status) && (Status !=3D EFI_NOT_FOUND)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: IORT: Failed to get SMMUv1/SMMUv2 Node Info. Status =3D %r\n= ", - Status - )); - goto error_handler; + return Status; } =20 // Add the SMMU v1/v2 node count IortNodeCount +=3D SmmuV1V2NodeCount; =20 // Get the SMMUv3 node info - Status =3D GetEArmObjSmmuV3 ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &SmmuV3NodeList, - &SmmuV3NodeCount - ); + Status =3D CfgMgrCountObjects (EArmObjSmmuV3, &SmmuV3NodeCount); if (EFI_ERROR (Status) && (Status !=3D EFI_NOT_FOUND)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: IORT: Failed to get SMMUv3 Node Info. Status =3D %r\n", - Status - )); - goto error_handler; + return Status; } =20 // Add the SMMUv3 node count IortNodeCount +=3D SmmuV3NodeCount; =20 // Get the PMCG node info - Status =3D GetEArmObjPmcg ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &PmcgNodeList, - &PmcgNodeCount - ); + Status =3D CfgMgrCountObjects (EArmObjPmcg, &PmcgNodeCount); if (EFI_ERROR (Status) && (Status !=3D EFI_NOT_FOUND)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: IORT: Failed to get PMCG Node Info. Status =3D %r\n", - Status - )); - goto error_handler; + return Status; } =20 // Add the PMCG node count IortNodeCount +=3D PmcgNodeCount; =20 // Allocate Node Indexer array - NodeIndexer =3D (IORT_NODE_INDEXER*)AllocateZeroPool ( - (sizeof (IORT_NODE_INDEXER) * - IortNodeCount) - ); + NodeIndexer =3D AllocateZeroPool ((sizeof (IORT_NODE_INDEXER) * IortNode= Count)); if (NodeIndexer =3D=3D NULL) { - Status =3D EFI_OUT_OF_RESOURCES; - DEBUG (( - DEBUG_ERROR, - "ERROR: IORT: Failed to allocate memory for Node Indexer" \ - " Status =3D %r\n", - Status - )); - goto error_handler; + return EFI_OUT_OF_RESOURCES; } =20 DEBUG ((DEBUG_INFO, "INFO: NodeIndexer =3D %p\n", NodeIndexer)); @@ -1721,13 +1308,10 @@ BuildIortTable ( // ITS Group Nodes if (ItsGroupNodeCount > 0) { ItsGroupOffset =3D (UINT32)TableSize; - // Size of ITS Group node list. - NodeSize =3D GetSizeofItsGroupNodes ( - ItsGroupOffset, - ItsGroupNodeList, - ItsGroupNodeCount, - &NodeIndexer - ); + + NodeSize =3D GetSizeOfNodes ( + EArmObjItsGroup, ItsGroupOffset, &NodeIndexer, GetItsGroupNodeSize); + if (NodeSize > MAX_UINT32) { Status =3D EFI_INVALID_PARAMETER; DEBUG (( @@ -1751,13 +1335,13 @@ BuildIortTable ( // Named Component Nodes if (NamedComponentNodeCount > 0) { NamedComponentOffset =3D (UINT32)TableSize; - // Size of Named Component node list. - NodeSize =3D GetSizeofNamedComponentNodes ( - NamedComponentOffset, - NamedComponentNodeList, - NamedComponentNodeCount, - &NodeIndexer - ); + + NodeSize =3D GetSizeOfNodes ( + EArmObjNamedComponent, + NamedComponentOffset, + &NodeIndexer, + GetNamedComponentNodeSize); + if (NodeSize > MAX_UINT32) { Status =3D EFI_INVALID_PARAMETER; DEBUG (( @@ -1781,13 +1365,13 @@ BuildIortTable ( // Root Complex Nodes if (RootComplexNodeCount > 0) { RootComplexOffset =3D (UINT32)TableSize; - // Size of Root Complex node list. - NodeSize =3D GetSizeofRootComplexNodes ( - RootComplexOffset, - RootComplexNodeList, - RootComplexNodeCount, - &NodeIndexer - ); + + NodeSize =3D GetSizeOfNodes ( + EArmObjRootComplex, + RootComplexOffset, + &NodeIndexer, + GetRootComplexNodeSize); + if (NodeSize > MAX_UINT32) { Status =3D EFI_INVALID_PARAMETER; DEBUG (( @@ -1811,13 +1395,9 @@ BuildIortTable ( // SMMUv1/SMMUv2 Nodes if (SmmuV1V2NodeCount > 0) { SmmuV1V2Offset =3D (UINT32)TableSize; - // Size of SMMUv1/SMMUv2 node list. - NodeSize =3D GetSizeofSmmuV1V2Nodes ( - SmmuV1V2Offset, - SmmuV1V2NodeList, - SmmuV1V2NodeCount, - &NodeIndexer - ); + + NodeSize =3D GetSizeOfNodes ( + EArmObjSmmuV1SmmuV2, SmmuV1V2Offset, &NodeIndexer, GetSmmuV1V2NodeSi= ze); if (NodeSize > MAX_UINT32) { Status =3D EFI_INVALID_PARAMETER; DEBUG (( @@ -1841,13 +1421,9 @@ BuildIortTable ( // SMMUv3 Nodes if (SmmuV3NodeCount > 0) { SmmuV3Offset =3D (UINT32)TableSize; - // Size of SMMUv3 node list. - NodeSize =3D GetSizeofSmmuV3Nodes ( - SmmuV3Offset, - SmmuV3NodeList, - SmmuV3NodeCount, - &NodeIndexer - ); + + NodeSize =3D GetSizeOfNodes ( + EArmObjSmmuV3, SmmuV3Offset, &NodeIndexer, GetSmmuV3NodeSize); if (NodeSize > MAX_UINT32) { Status =3D EFI_INVALID_PARAMETER; DEBUG (( @@ -1871,13 +1447,9 @@ BuildIortTable ( // PMCG Nodes if (PmcgNodeCount > 0) { PmcgOffset =3D (UINT32)TableSize; - // Size of PMCG node list. - NodeSize =3D GetSizeofPmcgNodes ( - PmcgOffset, - PmcgNodeList, - PmcgNodeCount, - &NodeIndexer - ); + + NodeSize =3D GetSizeOfNodes ( + EArmObjPmcg, PmcgOffset, &NodeIndexer, GetPmcgNodeSize); if (NodeSize > MAX_UINT32) { Status =3D EFI_INVALID_PARAMETER; DEBUG (( @@ -1920,21 +1492,12 @@ BuildIortTable ( } =20 // Allocate the Buffer for IORT table - *Table =3D (EFI_ACPI_DESCRIPTION_HEADER*)AllocateZeroPool (TableSize); - if (*Table =3D=3D NULL) { + Iort =3D AllocateZeroPool (TableSize); + if (Iort =3D=3D NULL) { Status =3D EFI_OUT_OF_RESOURCES; - DEBUG (( - DEBUG_ERROR, - "ERROR: IORT: Failed to allocate memory for IORT Table, Size =3D %d,= " \ - " Status =3D %r\n", - TableSize, - Status - )); goto error_handler; } =20 - Iort =3D (EFI_ACPI_6_0_IO_REMAPPING_TABLE*)*Table; - DEBUG (( DEBUG_INFO, "IORT: Iort =3D 0x%p TableSize =3D 0x%lx\n", @@ -1944,11 +1507,6 @@ BuildIortTable ( =20 Status =3D AddAcpiHeader (This, &Iort->Header, AcpiTableInfo, (UINT32) T= ableSize); if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: IORT: Failed to add ACPI header. Status =3D %r\n", - Status - )); goto error_handler; } =20 @@ -1958,14 +1516,10 @@ BuildIortTable ( Iort->Reserved =3D EFI_ACPI_RESERVED_DWORD; =20 if (ItsGroupNodeCount > 0) { + CfgMgrGetSimpleObject(EArmObjItsGroup, &NodeList); Status =3D AddItsGroupNodes ( - This, - CfgMgrProtocol, - Iort, - ItsGroupOffset, - ItsGroupNodeList, - ItsGroupNodeCount - ); + This, Iort, ItsGroupOffset, NodeList, ItsGroupNodeCount); + FreePool (NodeList); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, @@ -1977,14 +1531,10 @@ BuildIortTable ( } =20 if (NamedComponentNodeCount > 0) { + CfgMgrGetSimpleObject(EArmObjNamedComponent, &NodeList); Status =3D AddNamedComponentNodes ( - This, - CfgMgrProtocol, - Iort, - NamedComponentOffset, - NamedComponentNodeList, - NamedComponentNodeCount - ); + This, Iort, NamedComponentOffset, NodeList, NamedComponentNodeCount); + FreePool (NodeList); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, @@ -1996,14 +1546,10 @@ BuildIortTable ( } =20 if (RootComplexNodeCount > 0) { + CfgMgrGetSimpleObject(EArmObjRootComplex, &NodeList); Status =3D AddRootComplexNodes ( - This, - CfgMgrProtocol, - Iort, - RootComplexOffset, - RootComplexNodeList, - RootComplexNodeCount - ); + This, Iort, RootComplexOffset, NodeList, RootComplexNodeCount); + FreePool (NodeList); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, @@ -2015,14 +1561,10 @@ BuildIortTable ( } =20 if (SmmuV1V2NodeCount > 0) { + CfgMgrGetSimpleObject(EArmObjSmmuV1SmmuV2, &NodeList); Status =3D AddSmmuV1V2Nodes ( - This, - CfgMgrProtocol, - Iort, - SmmuV1V2Offset, - SmmuV1V2NodeList, - SmmuV1V2NodeCount - ); + This, Iort, SmmuV1V2Offset, NodeList, SmmuV1V2NodeCount); + FreePool (NodeList); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, @@ -2034,14 +1576,10 @@ BuildIortTable ( } =20 if (SmmuV3NodeCount > 0) { + CfgMgrGetSimpleObject(EArmObjSmmuV3, &NodeList); Status =3D AddSmmuV3Nodes ( - This, - CfgMgrProtocol, - Iort, - SmmuV3Offset, - SmmuV3NodeList, - SmmuV3NodeCount - ); + This, Iort, SmmuV3Offset, NodeList, SmmuV3NodeCount); + FreePool (NodeList); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, @@ -2053,14 +1591,9 @@ BuildIortTable ( } =20 if (PmcgNodeCount > 0) { - Status =3D AddPmcgNodes ( - This, - CfgMgrProtocol, - Iort, - PmcgOffset, - PmcgNodeList, - PmcgNodeCount - ); + CfgMgrGetSimpleObject(EArmObjPmcg, &NodeList); + Status =3D AddPmcgNodes (This, Iort, PmcgOffset, NodeList, PmcgNodeCou= nt); + FreePool (NodeList); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, @@ -2071,6 +1604,8 @@ BuildIortTable ( } } =20 + *Table =3D (EFI_ACPI_DESCRIPTION_HEADER*) Iort; + return EFI_SUCCESS; =20 error_handler: @@ -2078,11 +1613,10 @@ error_handler: FreePool (Generator->NodeIndexer); Generator->NodeIndexer =3D NULL; } - - if (*Table !=3D NULL) { - FreePool (*Table); - *Table =3D NULL; + if (Iort !=3D NULL) { + FreePool (Iort); } + return Status; } =20 diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/MadtGenerator= .c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c index ab42c96b06..0d75a24724 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMadtLibArm/MadtGenerator.c @@ -17,7 +17,6 @@ // Module specific include files. #include #include -#include #include #include =20 @@ -33,54 +32,6 @@ Requirements: - EArmObjGicItsInfo (OPTIONAL) */ =20 -/** This macro expands to a function that retrieves the GIC - CPU interface Information from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjGicCInfo, - CM_ARM_GICC_INFO - ); - -/** This macro expands to a function that retrieves the GIC - Distributor Information from the Configuration Manager. -*/ - -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjGicDInfo, - CM_ARM_GICD_INFO - ); - -/** This macro expands to a function that retrieves the GIC - MSI Frame Information from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjGicMsiFrameInfo, - CM_ARM_GIC_MSI_FRAME_INFO - ); - -/** This macro expands to a function that retrieves the GIC - Redistributor Information from the Configuration Manager. -*/ - -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjGicRedistributorInfo, - CM_ARM_GIC_REDIST_INFO - ); - -/** This macro expands to a function that retrieves the GIC - Interrupt Translation Service Information from the - Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjGicItsInfo, - CM_ARM_GIC_ITS_INFO - ); - /** This function updates the GIC CPU Interface Information in the EFI_ACPI_6_3_GIC_STRUCTURE structure. =20 @@ -215,15 +166,21 @@ STATIC EFI_STATUS AddGICCList ( IN EFI_ACPI_6_3_GIC_STRUCTURE * Gicc, - IN CONST CM_ARM_GICC_INFO * GicCInfo, - IN UINT32 GicCCount, IN CONST UINT8 MadtRev ) { BOOLEAN IsAcpiProcUidDuplicated; + CM_ARM_GICC_INFO *Cursor; + VOID *GicCInfo; + UINT32 GicCCount; =20 ASSERT (Gicc !=3D NULL); - ASSERT (GicCInfo !=3D NULL); + + EFI_STATUS Status =3D + CfgMgrGetObjects (EArmObjGicCInfo, CM_NULL_TOKEN, &GicCInfo, &GicCCoun= t); + if (EFI_ERROR (Status)) { + return Status; + } =20 IsAcpiProcUidDuplicated =3D FindDuplicateValue ( GicCInfo, @@ -234,31 +191,40 @@ AddGICCList ( // Duplicate ACPI Processor UID was found so the GICC info provided // is invalid if (IsAcpiProcUidDuplicated) { + FreePool (GicCInfo); return EFI_INVALID_PARAMETER; } =20 + Cursor =3D GicCInfo; while (GicCCount-- !=3D 0) { - AddGICC (Gicc++, GicCInfo++, MadtRev); + AddGICC (Gicc++, Cursor++, MadtRev); } =20 + FreePool (GicCInfo); return EFI_SUCCESS; } =20 /** Update the GIC Distributor Information in the MADT Table. =20 @param [in] Gicd Pointer to GIC Distributor structure. - @param [in] GicDInfo Pointer to the GIC Distributor Information. **/ STATIC VOID AddGICD ( - EFI_ACPI_6_3_GIC_DISTRIBUTOR_STRUCTURE * CONST Gicd, - CONST CM_ARM_GICD_INFO * CONST GicDInfo -) + EFI_ACPI_6_3_GIC_DISTRIBUTOR_STRUCTURE * CONST Gicd + ) { + EFI_STATUS Status; + CM_ARM_GICD_INFO *GicDInfo; + ASSERT (Gicd !=3D NULL); ASSERT (GicDInfo !=3D NULL); =20 + Status =3D CfgMgrGetSimpleObject (EArmObjGicDInfo, (VOID **)&GicDInfo); + if (EFI_ERROR (Status)) { + return; + } + // UINT8 Type Gicd->Type =3D EFI_ACPI_6_3_GICD; // UINT8 Length @@ -279,6 +245,8 @@ AddGICD ( Gicd->Reserved2[0] =3D EFI_ACPI_RESERVED_BYTE; Gicd->Reserved2[1] =3D EFI_ACPI_RESERVED_BYTE; Gicd->Reserved2[2] =3D EFI_ACPI_RESERVED_BYTE; + + FreePool (GicDInfo); } =20 /** Update the GIC MSI Frame Information. @@ -310,23 +278,32 @@ AddGICMsiFrame ( /** Add the GIC MSI Frame Information to the MADT Table. =20 @param [in] GicMsiFrame Pointer to GIC MSI Frame structure list. - @param [in] GicMsiFrameInfo Pointer to the GIC MSI Frame info list. - @param [in] GicMsiFrameCount Count of GIC MSI Frames. **/ STATIC VOID AddGICMsiFrameInfoList ( - IN EFI_ACPI_6_3_GIC_MSI_FRAME_STRUCTURE * GicMsiFrame, - IN CONST CM_ARM_GIC_MSI_FRAME_INFO * GicMsiFrameInfo, - IN UINT32 GicMsiFrameCount -) + IN EFI_ACPI_6_3_GIC_MSI_FRAME_STRUCTURE * GicMsiFrame + ) { + EFI_STATUS Status; + VOID *GicMsiInfo; + CM_ARM_GIC_MSI_FRAME_INFO *Cursor; + UINT32 GicMsiCount; + ASSERT (GicMsiFrame !=3D NULL); - ASSERT (GicMsiFrameInfo !=3D NULL); =20 - while (GicMsiFrameCount-- !=3D 0) { - AddGICMsiFrame (GicMsiFrame++, GicMsiFrameInfo++); + Status =3D CfgMgrGetObjects ( + EArmObjGicMsiFrameInfo, CM_NULL_TOKEN, &GicMsiInfo, &GicMsiCount); + if (EFI_ERROR(Status)) { + return; + } + + Cursor =3D GicMsiInfo; + while (GicMsiCount-- !=3D 0) { + AddGICMsiFrame (GicMsiFrame++, Cursor++); } + + FreePool (GicMsiInfo); } =20 /** Update the GIC Redistributor Information. @@ -355,23 +332,32 @@ AddGICRedistributor ( /** Add the GIC Redistributor Information to the MADT Table. =20 @param [in] Gicr Pointer to GIC Redistributor structure list. - @param [in] GicRInfo Pointer to the GIC Distributor info list. - @param [in] GicRCount Count of GIC Distributors. **/ STATIC VOID AddGICRedistributorList ( - IN EFI_ACPI_6_3_GICR_STRUCTURE * Gicr, - IN CONST CM_ARM_GIC_REDIST_INFO * GicRInfo, - IN UINT32 GicRCount + IN EFI_ACPI_6_3_GICR_STRUCTURE * Gicr ) { + CM_ARM_GIC_REDIST_INFO *Cursor; + VOID *GicRInfo; + UINT32 GicRCount; + EFI_STATUS Status; + ASSERT (Gicr !=3D NULL); - ASSERT (GicRInfo !=3D NULL); =20 + Status =3D CfgMgrGetObjects ( + EArmObjGicRedistributorInfo, CM_NULL_TOKEN, &GicRInfo, &GicRCount); + if (EFI_ERROR (Status)) { + return; + } + + Cursor =3D GicRInfo; while (GicRCount-- !=3D 0) { - AddGICRedistributor (Gicr++, GicRInfo++); + AddGICRedistributor (Gicr++, Cursor++); } + + FreePool (GicRInfo); } =20 /** Update the GIC Interrupt Translation Service Information @@ -401,23 +387,32 @@ AddGICInterruptTranslationService ( to the MADT Table. =20 @param [in] GicIts Pointer to GIC ITS structure list. - @param [in] GicItsInfo Pointer to the GIC ITS list. - @param [in] GicItsCount Count of GIC ITS. **/ STATIC VOID AddGICItsList ( - IN EFI_ACPI_6_3_GIC_ITS_STRUCTURE * GicIts, - IN CONST CM_ARM_GIC_ITS_INFO * GicItsInfo, - IN UINT32 GicItsCount + IN EFI_ACPI_6_3_GIC_ITS_STRUCTURE * GicIts ) { + CM_ARM_GIC_ITS_INFO *Cursor; + VOID *GicItsInfo; + UINT32 GicItsCount; + EFI_STATUS Status; + ASSERT (GicIts !=3D NULL); - ASSERT (GicItsInfo !=3D NULL); =20 + Status =3D CfgMgrGetObjects ( + EArmObjGicItsInfo, CM_NULL_TOKEN, &GicItsInfo, &GicItsCount); + if (EFI_ERROR(Status)) { + return; + } + + Cursor =3D GicItsInfo; while (GicItsCount-- !=3D 0) { - AddGICInterruptTranslationService (GicIts++, GicItsInfo++); + AddGICInterruptTranslationService (GicIts++, Cursor++); } + + FreePool (GicItsInfo); } =20 /** Construct the MADT ACPI table. @@ -454,16 +449,13 @@ BuildMadtTable ( { EFI_STATUS Status; UINT32 TableSize; + UINT32 GicCCount; UINT32 GicDCount; UINT32 GicMSICount; UINT32 GicRedistCount; UINT32 GicItsCount; - CM_ARM_GICC_INFO * GicCInfo; - CM_ARM_GICD_INFO * GicDInfo; - CM_ARM_GIC_MSI_FRAME_INFO * GicMSIInfo; - CM_ARM_GIC_REDIST_INFO * GicRedistInfo; - CM_ARM_GIC_ITS_INFO * GicItsInfo; + UINT32 GicCOffset; UINT32 GicDOffset; UINT32 GicMSIOffset; @@ -474,7 +466,6 @@ BuildMadtTable ( =20 ASSERT (This !=3D NULL); ASSERT (AcpiTableInfo !=3D NULL); - ASSERT (CfgMgrProtocol !=3D NULL); ASSERT (Table !=3D NULL); ASSERT (AcpiTableInfo->TableGeneratorId =3D=3D This->GeneratorID); ASSERT (AcpiTableInfo->AcpiTableSignature =3D=3D This->AcpiTableSignatur= e); @@ -492,21 +483,12 @@ BuildMadtTable ( return EFI_INVALID_PARAMETER; } =20 + // Allocated memory pointers *Table =3D NULL; =20 - Status =3D GetEArmObjGicCInfo ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &GicCInfo, - &GicCCount - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: MADT: Failed to get GICC Info. Status =3D %r\n", - Status - )); - goto error_handler; + Status =3D CfgMgrCountObjects (EArmObjGicCInfo, &GicCCount); + if (EFI_ERROR(Status)) { + return Status; } =20 if (GicCCount =3D=3D 0) { @@ -515,23 +497,12 @@ BuildMadtTable ( "ERROR: MADT: GIC CPU Interface information not provided.\n" )); ASSERT (GicCCount !=3D 0); - Status =3D EFI_INVALID_PARAMETER; - goto error_handler; + return EFI_INVALID_PARAMETER; } =20 - Status =3D GetEArmObjGicDInfo ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &GicDInfo, - &GicDCount - ); + Status =3D CfgMgrCountObjects (EArmObjGicDInfo, &GicDCount); if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: MADT: Failed to get GICD Info. Status =3D %r\n", - Status - )); - goto error_handler; + return Status; } =20 if (GicDCount =3D=3D 0) { @@ -540,8 +511,7 @@ BuildMadtTable ( "ERROR: MADT: GIC Distributor information not provided.\n" )); ASSERT (GicDCount !=3D 0); - Status =3D EFI_INVALID_PARAMETER; - goto error_handler; + return EFI_INVALID_PARAMETER; } =20 if (GicDCount > 1) { @@ -552,53 +522,22 @@ BuildMadtTable ( GicDCount )); ASSERT (GicDCount <=3D 1); - Status =3D EFI_INVALID_PARAMETER; - goto error_handler; + return EFI_INVALID_PARAMETER; } =20 - Status =3D GetEArmObjGicMsiFrameInfo ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &GicMSIInfo, - &GicMSICount - ); + Status =3D CfgMgrCountObjects (EArmObjGicMsiFrameInfo, &GicMSICount); if (EFI_ERROR (Status) && (Status !=3D EFI_NOT_FOUND)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: MADT: Failed to get GIC MSI Info. Status =3D %r\n", - Status - )); - goto error_handler; + return Status; } =20 - Status =3D GetEArmObjGicRedistributorInfo ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &GicRedistInfo, - &GicRedistCount - ); + Status =3D CfgMgrCountObjects (EArmObjGicRedistributorInfo, &GicRedistCo= unt); if (EFI_ERROR (Status) && (Status !=3D EFI_NOT_FOUND)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: MADT: Failed to get GIC Redistributor Info. Status =3D %r\n", - Status - )); - goto error_handler; + return Status; } =20 - Status =3D GetEArmObjGicItsInfo ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &GicItsInfo, - &GicItsCount - ); + Status =3D CfgMgrCountObjects (EArmObjGicItsInfo, &GicItsCount); if (EFI_ERROR (Status) && (Status !=3D EFI_NOT_FOUND)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: MADT: Failed to get GIC ITS Info. Status =3D %r\n", - Status - )); - goto error_handler; + return Status; } =20 TableSize =3D sizeof (EFI_ACPI_6_3_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADE= R); @@ -619,21 +558,11 @@ BuildMadtTable ( TableSize +=3D (sizeof (EFI_ACPI_6_3_GIC_ITS_STRUCTURE) * GicItsCount); =20 // Allocate the Buffer for MADT table - *Table =3D (EFI_ACPI_DESCRIPTION_HEADER*)AllocateZeroPool (TableSize); - if (*Table =3D=3D NULL) { - Status =3D EFI_OUT_OF_RESOURCES; - DEBUG (( - DEBUG_ERROR, - "ERROR: MADT: Failed to allocate memory for MADT Table, Size =3D %d,= " \ - " Status =3D %r\n", - TableSize, - Status - )); - goto error_handler; + Madt =3D AllocateZeroPool (TableSize); + if (Madt =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; } =20 - Madt =3D (EFI_ACPI_6_3_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER*)*Table; - DEBUG (( DEBUG_INFO, "MADT: Madt =3D 0x%p TableSize =3D 0x%x\n", @@ -643,20 +572,13 @@ BuildMadtTable ( =20 Status =3D AddAcpiHeader (This, &Madt->Header, AcpiTableInfo, TableSize); if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: MADT: Failed to add ACPI header. Status =3D %r\n", - Status - )); goto error_handler; } =20 Status =3D AddGICCList ( - (EFI_ACPI_6_3_GIC_STRUCTURE*)((UINT8*)Madt + GicCOffset), - GicCInfo, - GicCCount, - Madt->Header.Revision - ); + (EFI_ACPI_6_3_GIC_STRUCTURE *)((UINT8 *)Madt + GicCOffset), + Madt->Header.Revision); + if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, @@ -666,42 +588,25 @@ BuildMadtTable ( goto error_handler; } =20 - AddGICD ( - (EFI_ACPI_6_3_GIC_DISTRIBUTOR_STRUCTURE*)((UINT8*)Madt + GicDOffset), - GicDInfo - ); + AddGICD ((VOID *)((UINT8 *)Madt + GicDOffset)); =20 if (GicMSICount !=3D 0) { - AddGICMsiFrameInfoList ( - (EFI_ACPI_6_3_GIC_MSI_FRAME_STRUCTURE*)((UINT8*)Madt + GicMSIOffset), - GicMSIInfo, - GicMSICount - ); + AddGICMsiFrameInfoList ((VOID *)((UINT8 *)Madt + GicMSIOffset)); } =20 if (GicRedistCount !=3D 0) { - AddGICRedistributorList ( - (EFI_ACPI_6_3_GICR_STRUCTURE*)((UINT8*)Madt + GicRedistOffset), - GicRedistInfo, - GicRedistCount - ); + AddGICRedistributorList ((VOID *)((UINT8 *)Madt + GicRedistOffset)); } =20 if (GicItsCount !=3D 0) { - AddGICItsList ( - (EFI_ACPI_6_3_GIC_ITS_STRUCTURE*)((UINT8*)Madt + GicItsOffset), - GicItsInfo, - GicItsCount - ); + AddGICItsList ((VOID *)((UINT8 *)Madt + GicItsOffset)); } =20 + *Table =3D (EFI_ACPI_DESCRIPTION_HEADER*)Madt; return EFI_SUCCESS; =20 error_handler: - if (*Table !=3D NULL) { - FreePool (*Table); - *Table =3D NULL; - } + FreePool (Madt); return Status; } =20 @@ -727,7 +632,6 @@ FreeMadtTableResources ( { ASSERT (This !=3D NULL); ASSERT (AcpiTableInfo !=3D NULL); - ASSERT (CfgMgrProtocol !=3D NULL); ASSERT (AcpiTableInfo->TableGeneratorId =3D=3D This->GeneratorID); ASSERT (AcpiTableInfo->AcpiTableSignature =3D=3D This->AcpiTableSignatur= e); =20 diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/McfgGenerator= .c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/McfgGenerator.c index a486e2297a..0283ea11f5 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/McfgGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiMcfgLibArm/McfgGenerator.c @@ -18,7 +18,6 @@ // Module specific include files. #include #include -#include #include #include =20 @@ -48,50 +47,52 @@ typedef =20 #pragma pack() =20 -/** Retrieve the PCI Configuration Space Information. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjPciConfigSpaceInfo, - CM_ARM_PCI_CONFIG_SPACE_INFO - ); - /** Add the PCI Enhanced Configuration Space Information to the MCFG Table. =20 @param [in] Mcfg Pointer to MCFG Table. @param [in] PciCfgSpaceOffset Offset for the PCI Configuration Space Info structure in the MCFG Table. - @param [in] PciCfgSpaceInfoList Pointer to the PCI Configuration Space - Info List. - @param [in] PciCfgSpaceCount Count of PCI Configuration Space Info. **/ STATIC VOID AddPciConfigurationSpaceList ( IN MCFG_TABLE * CONST Mcfg, - IN CONST UINT32 PciCfgSpaceOffset, - IN CONST CM_ARM_PCI_CONFIG_SPACE_INFO * PciCfgSpaceInfoList, - IN UINT32 PciCfgSpaceCount + IN CONST UINT32 PciCfgSpaceOffset ) { - MCFG_CFG_SPACE_ADDR * PciCfgSpace; + MCFG_CFG_SPACE_ADDR *PciCfgSpace; + CM_ARM_PCI_CONFIG_SPACE_INFO *Cursor; + VOID *PciCfgSpaceInfoList; + UINT32 PciCfgSpaceCount; + EFI_STATUS Status; =20 ASSERT (Mcfg !=3D NULL); - ASSERT (PciCfgSpaceInfoList !=3D NULL); + + Status =3D CfgMgrGetObjects ( + EArmObjPciConfigSpaceInfo, + CM_NULL_TOKEN, + &PciCfgSpaceInfoList, + &PciCfgSpaceCount); + if (EFI_ERROR (Status)) { + return; + } =20 PciCfgSpace =3D (MCFG_CFG_SPACE_ADDR *)((UINT8*)Mcfg + PciCfgSpaceOffset= ); =20 + Cursor =3D PciCfgSpaceInfoList; while (PciCfgSpaceCount-- !=3D 0) { // Add PCI Configuration Space entry - PciCfgSpace->BaseAddress =3D PciCfgSpaceInfoList->BaseAddress; + PciCfgSpace->BaseAddress =3D Cursor->BaseAddress; PciCfgSpace->PciSegmentGroupNumber =3D - PciCfgSpaceInfoList->PciSegmentGroupNumber; - PciCfgSpace->StartBusNumber =3D PciCfgSpaceInfoList->StartBusNumber; - PciCfgSpace->EndBusNumber =3D PciCfgSpaceInfoList->EndBusNumber; + Cursor->PciSegmentGroupNumber; + PciCfgSpace->StartBusNumber =3D Cursor->StartBusNumber; + PciCfgSpace->EndBusNumber =3D Cursor->EndBusNumber; PciCfgSpace->Reserved =3D EFI_ACPI_RESERVED_DWORD; PciCfgSpace++; - PciCfgSpaceInfoList++; + Cursor++; } + + FreePool (PciCfgSpaceInfoList); } =20 /** Construct the MCFG ACPI table. @@ -152,20 +153,14 @@ BuildMcfgTable ( return EFI_INVALID_PARAMETER; } =20 + // Pointers to allocated memory *Table =3D NULL; - Status =3D GetEArmObjPciConfigSpaceInfo ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &PciConfigSpaceInfoList, - &ConfigurationSpaceCount - ); + PciConfigSpaceInfoList =3D NULL; + + Status =3D + CfgMgrCountObjects (EArmObjPciConfigSpaceInfo, &ConfigurationSpaceCoun= t); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, - "ERROR: MCFG: Failed to get PCI Configuration Space Information." \ - " Status =3D %r\n", - Status - )); - goto error_handler; + return Status; } =20 if (ConfigurationSpaceCount =3D=3D 0) { @@ -174,9 +169,8 @@ BuildMcfgTable ( "ERROR: MCFG: Configuration Space Count =3D %d\n", ConfigurationSpaceCount )); - Status =3D EFI_INVALID_PARAMETER; ASSERT (ConfigurationSpaceCount !=3D 0); - goto error_handler; + return EFI_INVALID_PARAMETER; } =20 DEBUG (( @@ -189,20 +183,11 @@ BuildMcfgTable ( TableSize =3D sizeof (MCFG_TABLE) + ((sizeof (MCFG_CFG_SPACE_ADDR) * ConfigurationSpaceCount)); =20 - *Table =3D (EFI_ACPI_DESCRIPTION_HEADER*)AllocateZeroPool (TableSize); - if (*Table =3D=3D NULL) { - Status =3D EFI_OUT_OF_RESOURCES; - DEBUG (( - DEBUG_ERROR, - "ERROR: MCFG: Failed to allocate memory for MCFG Table, Size =3D %d,= " \ - " Status =3D %r\n", - TableSize, - Status - )); - goto error_handler; + Mcfg =3D AllocateZeroPool (TableSize); + if (Mcfg =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; } =20 - Mcfg =3D (MCFG_TABLE*)*Table; DEBUG (( DEBUG_INFO, "MCFG: Mcfg =3D 0x%p TableSize =3D 0x%x\n", @@ -212,30 +197,19 @@ BuildMcfgTable ( =20 Status =3D AddAcpiHeader (This, &Mcfg->Header, AcpiTableInfo, TableSize); if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: MCFG: Failed to add ACPI header. Status =3D %r\n", - Status - )); goto error_handler; } =20 Mcfg->Reserved =3D EFI_ACPI_RESERVED_QWORD; =20 - AddPciConfigurationSpaceList ( - Mcfg, - sizeof (MCFG_TABLE), - PciConfigSpaceInfoList, - ConfigurationSpaceCount - ); + AddPciConfigurationSpaceList (Mcfg, sizeof (MCFG_TABLE)); + + *Table =3D (EFI_ACPI_DESCRIPTION_HEADER*) Mcfg; =20 return EFI_SUCCESS; =20 error_handler: - if (*Table !=3D NULL) { - FreePool (*Table); - *Table =3D NULL; - } + FreePool (Mcfg); return Status; } =20 diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator= .c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c index 99eb6e0929..0722b469f0 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c @@ -21,7 +21,6 @@ // Module specific include files. #include #include -#include #include #include =20 @@ -39,56 +38,6 @@ - EArmObjGicCInfo (REQUIRED) */ =20 -/** - This macro expands to a function that retrieves the Processor Hierarchy - information from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjProcHierarchyInfo, - CM_ARM_PROC_HIERARCHY_INFO - ); - -/** - This macro expands to a function that retrieves the cache information - from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjCacheInfo, - CM_ARM_CACHE_INFO - ); - -/** - This macro expands to a function that retrieves the ID information for - Processor Hierarchy Nodes from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjProcNodeIdInfo, - CM_ARM_PROC_NODE_ID_INFO - ); - -/** - This macro expands to a function that retrieves the cross-CM-object- - reference information from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjCmRef, - CM_ARM_OBJ_REF - ); - -/** - This macro expands to a function that retrieves the GIC CPU interface - information from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjGicCInfo, - CM_ARM_GICC_INFO - ); - /** Returns the size of the PPTT Processor Hierarchy Node (Type 0) given a Processor Hierarchy Info CM object. @@ -279,8 +228,6 @@ DetectCyclesInTopology ( Update the array of private resources for a given Processor Hierarchy No= de. =20 @param [in] Generator Pointer to the PPTT Generator. - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - Protocol Interface. @param [in] PrivResArray Pointer to the array of private resour= ces. @param [in] PrivResCount Number of private resources. @param [in] PrivResArrayToken Reference Token for the CM_ARM_OBJ_REF @@ -294,20 +241,19 @@ STATIC EFI_STATUS AddPrivateResources ( IN CONST ACPI_PPTT_GENERATOR * CONST Generator, - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, IN UINT32 * PrivResArray, IN UINT32 PrivResCount, IN CONST CM_OBJECT_TOKEN PrivResArrayTok= en ) { EFI_STATUS Status; - CM_ARM_OBJ_REF * CmObjRefs; + CM_ARM_OBJ_REF * Cursor; + VOID * CmObjRefs; UINT32 CmObjRefCount; PPTT_NODE_INDEXER * PpttNodeFound; =20 ASSERT ( (Generator !=3D NULL) && - (CfgMgrProtocol !=3D NULL) && (PrivResArray !=3D NULL) && (PrivResCount !=3D 0) ); @@ -327,12 +273,8 @@ AddPrivateResources ( =20 CmObjRefCount =3D 0; // Get the CM Object References - Status =3D GetEArmObjCmRef ( - CfgMgrProtocol, - PrivResArrayToken, - &CmObjRefs, - &CmObjRefCount - ); + Status =3D CfgMgrGetObjects ( + EArmObjCmRef, PrivResArrayToken, (VOID **)&CmObjRefs, &CmObjRefCount); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, @@ -356,11 +298,12 @@ AddPrivateResources ( PrivResArrayToken, Status )); - return Status; + goto EXIT; } =20 + Cursor =3D CmObjRefs; while (PrivResCount-- !=3D 0) { - if (CmObjRefs->ReferenceToken =3D=3D CM_NULL_TOKEN) { + if (Cursor->ReferenceToken =3D=3D CM_NULL_TOKEN) { Status =3D EFI_INVALID_PARAMETER; DEBUG (( DEBUG_ERROR, @@ -368,7 +311,7 @@ AddPrivateResources ( "private resource. Status =3D %r\n", Status )); - return Status; + goto EXIT; } =20 // The Node indexer has the Processor hierarchy nodes at the begining @@ -378,7 +321,7 @@ AddPrivateResources ( Generator->CacheStructIndexedList, (Generator->ProcTopologyStructCount - Generator->ProcHierarchyNodeCount), - CmObjRefs->ReferenceToken, + Cursor->ReferenceToken, &PpttNodeFound ); if (EFI_ERROR (Status)) { @@ -386,19 +329,21 @@ AddPrivateResources ( DEBUG_ERROR, "ERROR: PPTT: Failed to get a private resource with Token =3D %p f= rom " \ "Node Indexer. Status =3D %r\n", - CmObjRefs->ReferenceToken, + Cursor->ReferenceToken, Status )); - return Status; + goto EXIT; } =20 // Update the offset of the private resources in the Processor // Hierarchy Node structure *(PrivResArray++) =3D PpttNodeFound->Offset; - CmObjRefs++; + Cursor++; } =20 - return EFI_SUCCESS; +EXIT: + FreePool (CmObjRefs); + return Status; } =20 /** @@ -485,7 +430,6 @@ STATIC EFI_STATUS AddProcHierarchyNodes ( IN CONST ACPI_PPTT_GENERATOR * CONST Generator, - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, IN CONST EFI_ACPI_6_3_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_HEADER * Pptt, IN CONST UINT32 NodesStartOffset ) @@ -508,7 +452,6 @@ AddProcHierarchyNodes ( =20 ASSERT ( (Generator !=3D NULL) && - (CfgMgrProtocol !=3D NULL) && (Pptt !=3D NULL) ); =20 @@ -533,6 +476,9 @@ AddProcHierarchyNodes ( =20 UniqueGicCRefCount =3D 0; =20 + // Pointers to allocated memory + GicCInfoList =3D NULL; + while (NodeCount-- !=3D 0) { ProcInfoNode =3D (CM_ARM_PROC_HIERARCHY_INFO*)ProcNodeIterator->Object; =20 @@ -632,12 +578,11 @@ AddProcHierarchyNodes ( )); return Status; } else { - Status =3D GetEArmObjGicCInfo ( - CfgMgrProtocol, - ProcInfoNode->GicCToken, - &GicCInfoList, - &GicCInfoCount - ); + Status =3D CfgMgrGetObjects ( + EArmObjGicCInfo, + ProcInfoNode->GicCToken, + (VOID **)&GicCInfoList, + &GicCInfoCount); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, @@ -664,6 +609,7 @@ AddProcHierarchyNodes ( ProcInfoNode->Token, Status )); + FreePool (GicCInfoList); return Status; } =20 @@ -673,6 +619,7 @@ AddProcHierarchyNodes ( // Increment the reference count for the number of // Unique GICC objects that were retrieved. UniqueGicCRefCount++; + FreePool (GicCInfoList); } =20 ProcStruct->NumberOfPrivateResources =3D ProcInfoNode->NoOfPrivateReso= urces; @@ -683,7 +630,6 @@ AddProcHierarchyNodes ( // Populate the private resources array Status =3D AddPrivateResources ( Generator, - CfgMgrProtocol, PrivateResources, ProcStruct->NumberOfPrivateResources, ProcInfoNode->PrivateResourcesArrayToken @@ -707,18 +653,8 @@ AddProcHierarchyNodes ( =20 // Knowing the total number of GICC references made and that all GICC To= ken // references are unique, we can test if no GICC instances have been lef= t out. - Status =3D GetEArmObjGicCInfo ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &GicCInfoList, - &GicCInfoCount - ); + Status =3D CfgMgrCountObjects (EArmObjGicCInfo, &GicCInfoCount); if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: PPTT: Failed to get GICC Info. Status =3D %r\n", - Status - )); return Status; } =20 @@ -749,8 +685,6 @@ AddProcHierarchyNodes ( the Configuration Manager and adds this information to the PPTT table. =20 @param [in] Generator Pointer to the PPTT Generator. - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - Protocol Interface. @param [in] Pptt Pointer to PPTT table structure. @param [in] NodesStartOffset Offset from the start of PPTT table to= the start of Cache Type Structures. @@ -763,7 +697,6 @@ STATIC EFI_STATUS AddCacheTypeStructures ( IN CONST ACPI_PPTT_GENERATOR * CONST Generator, - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, IN CONST EFI_ACPI_6_3_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_HEADER * Pptt, IN CONST UINT32 NodesStartOffset ) @@ -775,11 +708,8 @@ AddCacheTypeStructures ( PPTT_NODE_INDEXER * CacheNodeIterator; UINT32 NodeCount; =20 - ASSERT ( - (Generator !=3D NULL) && - (CfgMgrProtocol !=3D NULL) && - (Pptt !=3D NULL) - ); + ASSERT (Generator !=3D NULL); + ASSERT (Pptt !=3D NULL); =20 CacheStruct =3D (EFI_ACPI_6_3_PPTT_STRUCTURE_CACHE*)((UINT8*)Pptt + NodesStartOffset); @@ -971,8 +901,6 @@ AddCacheTypeStructures ( the Configuration Manager and and adds this information to the PPTT tabl= e. =20 @param [in] Generator Pointer to the PPTT Generator. - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - Protocol Interface. @param [in] Pptt Pointer to PPTT table structure. @param [in] NodesStartOffset Offset from the start of PPTT table to t= he start of ID Type Structures. @@ -985,7 +913,6 @@ STATIC EFI_STATUS AddIdTypeStructures ( IN CONST ACPI_PPTT_GENERATOR * CONST Generator, - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, IN CONST EFI_ACPI_6_3_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_HEADER * Pptt, IN CONST UINT32 NodesStartOffset ) @@ -998,7 +925,6 @@ AddIdTypeStructures ( =20 ASSERT ( (Generator !=3D NULL) && - (CfgMgrProtocol !=3D NULL) && (Pptt !=3D NULL) ); =20 @@ -1074,10 +1000,7 @@ BuildPpttTable ( UINT32 CacheStructOffset; UINT32 IdStructOffset; =20 - CM_ARM_PROC_HIERARCHY_INFO * ProcHierarchyNodeList; - CM_ARM_CACHE_INFO * CacheStructList; - CM_ARM_PROC_NODE_ID_INFO * IdStructList; - + VOID * NodeList; ACPI_PPTT_GENERATOR * Generator; =20 // Pointer to the Node Indexer array @@ -1088,7 +1011,6 @@ BuildPpttTable ( ASSERT ( (This !=3D NULL) && (AcpiTableInfo !=3D NULL) && - (CfgMgrProtocol !=3D NULL) && (Table !=3D NULL) && (AcpiTableInfo->TableGeneratorId =3D=3D This->GeneratorID) && (AcpiTableInfo->AcpiTableSignature =3D=3D This->AcpiTableSignature) @@ -1108,23 +1030,12 @@ BuildPpttTable ( } =20 Generator =3D (ACPI_PPTT_GENERATOR*)This; - *Table =3D NULL; =20 // Get the processor hierarchy info and update the processor topology // structure count with Processor Hierarchy Nodes (Type 0) - Status =3D GetEArmObjProcHierarchyInfo ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &ProcHierarchyNodeList, - &ProcHierarchyNodeCount - ); + Status =3D CfgMgrCountObjects (EArmObjProcHierarchyInfo, &ProcHierarchyN= odeCount); if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: PPTT: Failed to get processor hierarchy info. Status =3D %r\= n", - Status - )); - goto error_handler; + return Status; } =20 ProcTopologyStructCount =3D ProcHierarchyNodeCount; @@ -1132,19 +1043,9 @@ BuildPpttTable ( =20 // Get the cache info and update the processor topology structure count = with // Cache Type Structures (Type 1) - Status =3D GetEArmObjCacheInfo ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &CacheStructList, - &CacheStructCount - ); + Status =3D CfgMgrCountObjects (EArmObjCacheInfo, &CacheStructCount); if (EFI_ERROR (Status) && (Status !=3D EFI_NOT_FOUND)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: PPTT: Failed to get cache info. Status =3D %r\n", - Status - )); - goto error_handler; + return Status; } =20 ProcTopologyStructCount +=3D CacheStructCount; @@ -1152,38 +1053,18 @@ BuildPpttTable ( =20 // Get the processor hierarchy node ID info and update the processor top= ology // structure count with ID Structures (Type 2) - Status =3D GetEArmObjProcNodeIdInfo ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &IdStructList, - &IdStructCount - ); + Status =3D CfgMgrCountObjects (EArmObjProcNodeIdInfo, &IdStructCount); if (EFI_ERROR (Status) && (Status !=3D EFI_NOT_FOUND)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: PPTT: Failed to get processor hierarchy node ID info. " \ - "Status =3D %r\n", - Status - )); - goto error_handler; + return Status; } =20 ProcTopologyStructCount +=3D IdStructCount; Generator->IdStructCount =3D IdStructCount; =20 // Allocate Node Indexer array - NodeIndexer =3D (PPTT_NODE_INDEXER*)AllocateZeroPool ( - sizeof (PPTT_NODE_INDEXER) * - ProcTopologyStructCount - ); + NodeIndexer =3D AllocateZeroPool (sizeof (PPTT_NODE_INDEXER) * ProcTopol= ogyStructCount); if (NodeIndexer =3D=3D NULL) { - Status =3D EFI_OUT_OF_RESOURCES; - DEBUG (( - DEBUG_ERROR, - "ERROR: PPTT: Failed to allocate memory for Node Indexer. Status =3D= %r\n ", - Status - )); - goto error_handler; + return EFI_OUT_OF_RESOURCES; } =20 DEBUG ((DEBUG_INFO, "INFO: NodeIndexer =3D %p\n", NodeIndexer)); @@ -1197,12 +1078,14 @@ BuildPpttTable ( if (Generator->ProcHierarchyNodeCount !=3D 0) { ProcHierarchyNodeOffset =3D TableSize; Generator->ProcHierarchyNodeIndexedList =3D NodeIndexer; + + CfgMgrGetSimpleObject(EArmObjProcHierarchyInfo, &NodeList); TableSize +=3D GetSizeofProcHierarchyNodes ( - ProcHierarchyNodeOffset, - ProcHierarchyNodeList, - Generator->ProcHierarchyNodeCount, - &NodeIndexer - ); + ProcHierarchyNodeOffset, + NodeList, + Generator->ProcHierarchyNodeCount, + &NodeIndexer); + FreePool (NodeList); =20 DEBUG (( DEBUG_INFO, @@ -1220,33 +1103,32 @@ BuildPpttTable ( if (Generator->CacheStructCount !=3D 0) { CacheStructOffset =3D TableSize; Generator->CacheStructIndexedList =3D NodeIndexer; + + CfgMgrGetSimpleObject(EArmObjCacheInfo, &NodeList); TableSize +=3D GetSizeofCacheTypeStructs ( - CacheStructOffset, - CacheStructList, - Generator->CacheStructCount, - &NodeIndexer - ); - DEBUG (( - DEBUG_INFO, - " CacheStructCount =3D %d\n" \ - " CacheStructOffset =3D 0x%x\n" \ - " CacheStructIndexedList =3D 0x%p\n", - Generator->CacheStructCount, - CacheStructOffset, - Generator->CacheStructIndexedList - )); + CacheStructOffset, NodeList, Generator->CacheStructCount, &NodeIndex= er); + FreePool (NodeList); + + DEBUG ( + (DEBUG_INFO, + " CacheStructCount =3D %d\n" + " CacheStructOffset =3D 0x%x\n" + " CacheStructIndexedList =3D 0x%p\n", + Generator->CacheStructCount, + CacheStructOffset, + Generator->CacheStructIndexedList)); } =20 // Include the size of ID Type Structures and index them if (Generator->IdStructCount !=3D 0) { IdStructOffset =3D TableSize; Generator->IdStructIndexedList =3D NodeIndexer; + + CfgMgrGetSimpleObject (EArmObjProcNodeIdInfo, &NodeList); TableSize +=3D GetSizeofIdStructs ( - IdStructOffset, - IdStructList, - Generator->IdStructCount, - &NodeIndexer - ); + IdStructOffset, NodeList, Generator->IdStructCount, &NodeIndexer); + FreePool (NodeList); + DEBUG (( DEBUG_INFO, " IdStructCount =3D %d\n" \ @@ -1268,21 +1150,12 @@ BuildPpttTable ( )); =20 // Allocate the Buffer for the PPTT table - *Table =3D (EFI_ACPI_DESCRIPTION_HEADER*)AllocateZeroPool (TableSize); - if (*Table =3D=3D NULL) { + Pptt =3D AllocateZeroPool (TableSize); + if (Pptt =3D=3D NULL) { Status =3D EFI_OUT_OF_RESOURCES; - DEBUG (( - DEBUG_ERROR, - "ERROR: PPTT: Failed to allocate memory for PPTT Table. " \ - "Size =3D %d. Status =3D %r\n", - TableSize, - Status - )); goto error_handler; } =20 - Pptt =3D (EFI_ACPI_6_3_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_HEADER*)*Tabl= e; - DEBUG (( DEBUG_INFO, "PPTT: Pptt =3D 0x%p. TableSize =3D 0x%x\n", @@ -1293,22 +1166,12 @@ BuildPpttTable ( // Add ACPI header Status =3D AddAcpiHeader (This, &Pptt->Header, AcpiTableInfo, TableSize); if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: PPTT: Failed to add ACPI header. Status =3D %r\n", - Status - )); goto error_handler; } =20 // Add Processor Hierarchy Nodes (Type 0) to the generated table if (Generator->ProcHierarchyNodeCount !=3D 0) { - Status =3D AddProcHierarchyNodes ( - Generator, - CfgMgrProtocol, - Pptt, - ProcHierarchyNodeOffset - ); + Status =3D AddProcHierarchyNodes (Generator, Pptt, ProcHierarchyNodeOf= fset); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, @@ -1321,12 +1184,7 @@ BuildPpttTable ( =20 // Add Cache Type Structures (Type 1) to the generated table if (Generator->CacheStructCount !=3D 0) { - Status =3D AddCacheTypeStructures ( - Generator, - CfgMgrProtocol, - Pptt, - CacheStructOffset - ); + Status =3D AddCacheTypeStructures (Generator, Pptt, CacheStructOffset); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, @@ -1339,12 +1197,7 @@ BuildPpttTable ( =20 // Add ID Type Structures (Type 2) to the generated table if (Generator->IdStructCount !=3D 0) { - Status =3D AddIdTypeStructures ( - Generator, - CfgMgrProtocol, - Pptt, - IdStructOffset - ); + Status =3D AddIdTypeStructures (Generator, Pptt, IdStructOffset); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, @@ -1366,6 +1219,7 @@ BuildPpttTable ( goto error_handler; } =20 + *Table =3D (EFI_ACPI_DESCRIPTION_HEADER*)Pptt; return Status; =20 error_handler: @@ -1374,9 +1228,8 @@ error_handler: Generator->NodeIndexer =3D NULL; } =20 - if (*Table !=3D NULL) { - FreePool (*Table); - *Table =3D NULL; + if (Pptt !=3D NULL) { + FreePool (Pptt); } =20 return Status; diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/RawGenerator.c= b/DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/RawGenerator.c index 2facfaa048..2a8e392d84 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/RawGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiRawLibArm/RawGenerator.c @@ -12,7 +12,6 @@ // Module specific include files. #include #include -#include #include #include =20 diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator= .c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c index 46f53f819a..0a7e9da96e 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSpcrLibArm/SpcrGenerator.c @@ -14,12 +14,12 @@ #include #include #include +#include #include =20 // Module specific include files. #include #include -#include #include #include =20 @@ -83,15 +83,6 @@ EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE AcpiSpcr = =3D { =20 #pragma pack() =20 -/** This macro expands to a function that retrieves the Serial - Port Information from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjSerialConsolePortInfo, - CM_ARM_SERIAL_PORT_INFO - ) - /** Construct the SPCR ACPI table. =20 This function invokes the Configuration Manager protocol interface @@ -131,7 +122,6 @@ BuildSpcrTable ( =20 ASSERT (This !=3D NULL); ASSERT (AcpiTableInfo !=3D NULL); - ASSERT (CfgMgrProtocol !=3D NULL); ASSERT (Table !=3D NULL); ASSERT (AcpiTableInfo->TableGeneratorId =3D=3D This->GeneratorID); ASSERT (AcpiTableInfo->AcpiTableSignature =3D=3D This->AcpiTableSignatur= e); @@ -149,21 +139,10 @@ BuildSpcrTable ( return EFI_INVALID_PARAMETER; } =20 - *Table =3D NULL; - - Status =3D GetEArmObjSerialConsolePortInfo ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &SerialPortInfo, - NULL - ); + Status =3D CfgMgrGetSimpleObject ( + EArmObjSerialConsolePortInfo, (VOID **)&SerialPortInfo); if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: SPCR: Failed to get serial port information. Status =3D %r\n= ", - Status - )); - goto error_handler; + return Status; } =20 if (SerialPortInfo->BaseAddress =3D=3D 0) { @@ -207,11 +186,6 @@ BuildSpcrTable ( AcpiTableInfo, sizeof (EFI_ACPI_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE)); if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: SPCR: Failed to add ACPI header. Status =3D %r\n", - Status - )); goto error_handler; } =20 @@ -268,6 +242,7 @@ BuildSpcrTable ( *Table =3D (EFI_ACPI_DESCRIPTION_HEADER*)&AcpiSpcr; =20 error_handler: + FreePool (SerialPortInfo); return Status; } =20 diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSratLibArm/SratGenerator= .c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSratLibArm/SratGenerator.c index fda0837f32..28cc8f9e8e 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiSratLibArm/SratGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiSratLibArm/SratGenerator.c @@ -21,7 +21,6 @@ // Module specific include files. #include #include -#include #include #include =20 @@ -38,65 +37,6 @@ - EArmObjDeviceHandlePci (OPTIONAL) */ =20 -/** This macro expands to a function that retrieves the GIC - CPU interface Information from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjGicCInfo, - CM_ARM_GICC_INFO - ); - -/** This macro expands to a function that retrieves the GIC - Interrupt Translation Service Information from the - Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjGicItsInfo, - CM_ARM_GIC_ITS_INFO - ); - -/** - This macro expands to a function that retrieves the Memory Affinity - information from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjMemoryAffinityInfo, - CM_ARM_MEMORY_AFFINITY_INFO - ); - -/** - This macro expands to a function that retrieves the Generic Initiator Af= finity - information from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjGenericInitiatorAffinityInfo, - CM_ARM_GENERIC_INITIATOR_AFFINITY_INFO - ); - -/** - This macro expands to a function that retrieves the ACPI Device Handle - information from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjDeviceHandleAcpi, - CM_ARM_DEVICE_HANDLE_ACPI - ); - -/** - This macro expands to a function that retrieves the PCI Device Handle - information from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceArm, - EArmObjDeviceHandlePci, - CM_ARM_DEVICE_HANDLE_PCI - ); - =20 /** Return the PCI Device information in BDF format =20 @@ -123,147 +63,163 @@ GetBdf ( =20 /** Add the GICC Affinity Structures in the SRAT Table. =20 - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - Protocol Interface. @param [in] Srat Pointer to the SRAT Table. @param [in] GicCAffOffset Offset of the GICC Affinity information in the SRAT Table. - @param [in] GicCInfo Pointer to the GIC CPU Information list. - @param [in] GicCCount Count of GIC CPU Interfaces. =20 @retval EFI_SUCCESS Table generated successfully. **/ STATIC EFI_STATUS AddGICCAffinity ( - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProt= ocol, IN EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER * CONST Srat, - IN CONST UINT32 GicCAffOff= set, - IN CONST CM_ARM_GICC_INFO * GicCInfo, - IN UINT32 GicCCount + IN CONST UINT32 GicCAffOff= set ) { - EFI_ACPI_6_3_GICC_AFFINITY_STRUCTURE * GicCAff; + EFI_ACPI_6_3_GICC_AFFINITY_STRUCTURE *GicCAff; + VOID *GicCInfo; + CM_ARM_GICC_INFO *Cursor; + UINT32 GicCCount; + EFI_STATUS Status; =20 ASSERT (Srat !=3D NULL); - ASSERT (GicCInfo !=3D NULL); + + Status =3D + CfgMgrGetObjects (EArmObjGicCInfo, CM_NULL_TOKEN, &GicCInfo, &GicCCoun= t); + if (EFI_ERROR (Status)) { + return Status; + } =20 GicCAff =3D (EFI_ACPI_6_3_GICC_AFFINITY_STRUCTURE *)((UINT8*)Srat + GicCAffOffset); =20 + Cursor =3D GicCInfo; while (GicCCount-- !=3D 0) { DEBUG ((DEBUG_INFO, "SRAT: GicCAff =3D 0x%p\n", GicCAff)); =20 GicCAff->Type =3D EFI_ACPI_6_3_GICC_AFFINITY; GicCAff->Length =3D sizeof (EFI_ACPI_6_3_GICC_AFFINITY_STRUCTURE); - GicCAff->ProximityDomain =3D GicCInfo->ProximityDomain; - GicCAff->AcpiProcessorUid =3D GicCInfo->AcpiProcessorUid; - GicCAff->Flags =3D GicCInfo->AffinityFlags; - GicCAff->ClockDomain =3D GicCInfo->ClockDomain; + GicCAff->ProximityDomain =3D Cursor->ProximityDomain; + GicCAff->AcpiProcessorUid =3D Cursor->AcpiProcessorUid; + GicCAff->Flags =3D Cursor->AffinityFlags; + GicCAff->ClockDomain =3D Cursor->ClockDomain; =20 // Next GicCAff++; - GicCInfo++; + Cursor++; }// while + + FreePool (GicCInfo); return EFI_SUCCESS; } =20 /** Add the GIC ITS Affinity Structures in the SRAT Table. =20 - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - Protocol Interface. @param [in] Srat Pointer to the SRAT Table. @param [in] GicItsAffOffset Offset of the GIC ITS Affinity information in the SRAT Table. - @param [in] GicItsInfo Pointer to the GIC ITS Information list. - @param [in] GicItsCount Count of GIC ITS. =20 @retval EFI_SUCCESS Table generated successfully. **/ STATIC EFI_STATUS AddGICItsAffinity ( - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProt= ocol, IN EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER * CONST Srat, - IN CONST UINT32 GicItsAffO= ffset, - IN CONST CM_ARM_GIC_ITS_INFO * GicItsInfo, - IN UINT32 GicItsCount + IN CONST UINT32 GicItsAffO= ffset ) { - EFI_ACPI_6_3_GIC_ITS_AFFINITY_STRUCTURE * GicItsAff; + EFI_ACPI_6_3_GIC_ITS_AFFINITY_STRUCTURE *GicItsAff; + CM_ARM_GIC_ITS_INFO *Cursor; + VOID *GicItsInfo; + UINT32 GicItsCount; + EFI_STATUS Status; =20 ASSERT (Srat !=3D NULL); - ASSERT (GicItsInfo !=3D NULL); + + Status =3D CfgMgrGetObjects ( + EArmObjGicItsInfo, CM_NULL_TOKEN, (VOID **)&GicItsInfo, &GicItsCount); + if (EFI_ERROR (Status)) { + return Status; + } =20 GicItsAff =3D (EFI_ACPI_6_3_GIC_ITS_AFFINITY_STRUCTURE *)((UINT8*)Srat + GicItsAffOffset); =20 + Cursor =3D GicItsInfo; while (GicItsCount-- !=3D 0) { DEBUG ((DEBUG_INFO, "SRAT: GicItsAff =3D 0x%p\n", GicItsAff)); =20 GicItsAff->Type =3D EFI_ACPI_6_3_GIC_ITS_AFFINITY; GicItsAff->Length =3D sizeof (EFI_ACPI_6_3_GIC_ITS_AFFINITY_STRUCTURE); - GicItsAff->ProximityDomain =3D GicItsInfo->ProximityDomain; + GicItsAff->ProximityDomain =3D Cursor->ProximityDomain; GicItsAff->Reserved[0] =3D EFI_ACPI_RESERVED_BYTE; GicItsAff->Reserved[1] =3D EFI_ACPI_RESERVED_BYTE; - GicItsAff->ItsId =3D GicItsInfo->GicItsId; + GicItsAff->ItsId =3D Cursor->GicItsId; =20 // Next GicItsAff++; - GicItsInfo++; + Cursor++; }// while + + FreePool (GicItsInfo); return EFI_SUCCESS; } =20 /** Add the Memory Affinity Structures in the SRAT Table. =20 - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - Protocol Interface. @param [in] Srat Pointer to the SRAT Table. @param [in] MemAffOffset Offset of the Memory Affinity information in the SRAT Table. - @param [in] MemAffInfo Pointer to the Memory Affinity Information= list. - @param [in] MemAffCount Count of Memory Affinity objects. =20 @retval EFI_SUCCESS Table generated successfully. **/ STATIC EFI_STATUS AddMemoryAffinity ( - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProt= ocol, IN EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER * CONST Srat, - IN CONST UINT32 MemAffOffs= et, - IN CONST CM_ARM_MEMORY_AFFINITY_INFO * MemAffInfo, - IN UINT32 MemAffCount + IN CONST UINT32 MemAffOffs= et ) { - EFI_ACPI_6_3_MEMORY_AFFINITY_STRUCTURE * MemAff; + EFI_ACPI_6_3_MEMORY_AFFINITY_STRUCTURE *MemAff; + CM_ARM_MEMORY_AFFINITY_INFO *Cursor; + VOID *MemAffInfo; + UINT32 MemAffCount; + EFI_STATUS Status; =20 ASSERT (Srat !=3D NULL); - ASSERT (MemAffInfo !=3D NULL); + + Status =3D CfgMgrGetObjects ( + EArmObjMemoryAffinityInfo, CM_NULL_TOKEN, &MemAffInfo, &MemAffCount); + if (EFI_ERROR (Status)) { + return Status; + } =20 MemAff =3D (EFI_ACPI_6_3_MEMORY_AFFINITY_STRUCTURE *)((UINT8*)Srat + MemAffOffset); =20 + + Cursor =3D MemAffInfo; while (MemAffCount-- !=3D 0) { DEBUG ((DEBUG_INFO, "SRAT: MemAff =3D 0x%p\n", MemAff)); =20 MemAff->Type =3D EFI_ACPI_6_3_MEMORY_AFFINITY; MemAff->Length =3D sizeof (EFI_ACPI_6_3_MEMORY_AFFINITY_STRUCTURE); - MemAff->ProximityDomain =3D MemAffInfo->ProximityDomain; + MemAff->ProximityDomain =3D Cursor->ProximityDomain; MemAff->Reserved1 =3D EFI_ACPI_RESERVED_WORD; - MemAff->AddressBaseLow =3D (UINT32)(MemAffInfo->BaseAddress & MAX_UINT= 32); - MemAff->AddressBaseHigh =3D (UINT32)(MemAffInfo->BaseAddress >> 32); - MemAff->LengthLow =3D (UINT32)(MemAffInfo->Length & MAX_UINT32); - MemAff->LengthHigh =3D (UINT32)(MemAffInfo->Length >> 32); + MemAff->AddressBaseLow =3D (UINT32)(Cursor->BaseAddress & MAX_UINT32); + MemAff->AddressBaseHigh =3D (UINT32)(Cursor->BaseAddress >> 32); + MemAff->LengthLow =3D (UINT32)(Cursor->Length & MAX_UINT32); + MemAff->LengthHigh =3D (UINT32)(Cursor->Length >> 32); MemAff->Reserved2 =3D EFI_ACPI_RESERVED_DWORD; - MemAff->Flags =3D MemAffInfo->Flags; + MemAff->Flags =3D Cursor->Flags; MemAff->Reserved3 =3D EFI_ACPI_RESERVED_QWORD; =20 // Next MemAff++; - MemAffInfo++; + Cursor++; }// while + + FreePool (MemAffInfo); return EFI_SUCCESS; } =20 @@ -290,11 +246,8 @@ AddMemoryAffinity ( STATIC EFI_STATUS AddGenericInitiatorAffinity ( - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProt= ocol, IN EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER * CONST Srat, - IN CONST UINT32 GenInitAff= Off, - IN CONST CM_ARM_GENERIC_INITIATOR_AFFINITY_INFO * GenInitAff= Info, - IN UINT32 GenInitAff= Count + IN CONST UINT32 GenInitAff= Off ) { EFI_STATUS Status; @@ -302,13 +255,25 @@ AddGenericInitiatorAffinity ( CM_ARM_DEVICE_HANDLE_ACPI * DeviceHandleAcp= i; CM_ARM_DEVICE_HANDLE_PCI * DeviceHandlePci; UINT32 DeviceHandleCou= nt; + CM_ARM_GENERIC_INITIATOR_AFFINITY_INFO * Cursor; + VOID * GenInitAffInfo; + UINT32 GenInitAffCount; =20 ASSERT (Srat !=3D NULL); - ASSERT (GenInitAffInfo !=3D NULL); + + Status =3D CfgMgrGetObjects ( + EArmObjGenericInitiatorAffinityInfo, + CM_NULL_TOKEN, + &GenInitAffInfo, + &GenInitAffCount); + if (EFI_ERROR (Status)) { + return Status; + } =20 GenInitAff =3D (EFI_ACPI_6_3_GENERIC_INITIATOR_AFFINITY_STRUCTURE *)( (UINT8*)Srat + GenInitAffOff); =20 + Cursor =3D GenInitAffInfo; while (GenInitAffCount-- !=3D 0) { DEBUG ((DEBUG_INFO, "SRAT: GenInitAff =3D 0x%p\n", GenInitAff)); =20 @@ -316,35 +281,35 @@ AddGenericInitiatorAffinity ( GenInitAff->Length =3D sizeof (EFI_ACPI_6_3_GENERIC_INITIATOR_AFFINITY_STRUCTURE); GenInitAff->Reserved1 =3D EFI_ACPI_RESERVED_WORD; - GenInitAff->DeviceHandleType =3D GenInitAffInfo->DeviceHandleType; - GenInitAff->ProximityDomain =3D GenInitAffInfo->ProximityDomain; + GenInitAff->DeviceHandleType =3D Cursor->DeviceHandleType; + GenInitAff->ProximityDomain =3D Cursor->ProximityDomain; =20 - if (GenInitAffInfo->DeviceHandleToken =3D=3D CM_NULL_TOKEN) { + if (Cursor->DeviceHandleToken =3D=3D CM_NULL_TOKEN) { DEBUG (( DEBUG_ERROR, "ERROR: SRAT: Invalid Device Handle Token.\n" )); ASSERT (0); - return EFI_INVALID_PARAMETER; + Status =3D EFI_INVALID_PARAMETER; + goto EXIT; } =20 - if (GenInitAffInfo->DeviceHandleType =3D=3D EFI_ACPI_6_3_ACPI_DEVICE_H= ANDLE) { - Status =3D GetEArmObjDeviceHandleAcpi ( - CfgMgrProtocol, - GenInitAffInfo->DeviceHandleToken, - &DeviceHandleAcpi, - &DeviceHandleCount - ); + if (Cursor->DeviceHandleType =3D=3D EFI_ACPI_6_3_ACPI_DEVICE_HANDLE) { + Status =3D CfgMgrGetObjects ( + EArmObjDeviceHandleAcpi, + Cursor->DeviceHandleToken, + (VOID **) &DeviceHandleAcpi, + &DeviceHandleCount); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, "ERROR: SRAT: Failed to get ACPI Device Handle Inf." " DeviceHandleToken =3D %p." " Status =3D %r\n", - GenInitAffInfo->DeviceHandleToken, + Cursor->DeviceHandleToken, Status )); - return Status; + goto EXIT; } =20 // We are expecting only one device handle. @@ -357,24 +322,24 @@ AddGenericInitiatorAffinity ( GenInitAff->DeviceHandle.Acpi.Reserved[1] =3D EFI_ACPI_RESERVED_BYTE; GenInitAff->DeviceHandle.Acpi.Reserved[2] =3D EFI_ACPI_RESERVED_BYTE; GenInitAff->DeviceHandle.Acpi.Reserved[3] =3D EFI_ACPI_RESERVED_BYTE; - } else if (GenInitAffInfo->DeviceHandleType =3D=3D + FreePool (DeviceHandleAcpi); + } else if (Cursor->DeviceHandleType =3D=3D EFI_ACPI_6_3_PCI_DEVICE_HANDLE) { - Status =3D GetEArmObjDeviceHandlePci ( - CfgMgrProtocol, - GenInitAffInfo->DeviceHandleToken, - &DeviceHandlePci, - &DeviceHandleCount - ); + Status =3D CfgMgrGetObjects ( + EArmObjDeviceHandlePci, + Cursor->DeviceHandleToken, + (VOID **) &DeviceHandlePci, + &DeviceHandleCount); if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, "ERROR: SRAT: Failed to get ACPI Device Handle Inf." " DeviceHandleToken =3D %p." " Status =3D %r\n", - GenInitAffInfo->DeviceHandleToken, + Cursor->DeviceHandleToken, Status )); - return Status; + goto EXIT; } =20 // We are expecting only one device handle @@ -384,6 +349,8 @@ AddGenericInitiatorAffinity ( GenInitAff->DeviceHandle.Pci.PciSegment =3D DeviceHandlePci->Segment= Number; GenInitAff->DeviceHandle.Pci.PciBdfNumber =3D GetBdf (DeviceHandlePc= i); =20 + FreePool (DeviceHandlePci); + GenInitAff->DeviceHandle.Pci.Reserved[0] =3D EFI_ACPI_RESERVED_BYTE; GenInitAff->DeviceHandle.Pci.Reserved[1] =3D EFI_ACPI_RESERVED_BYTE; GenInitAff->DeviceHandle.Pci.Reserved[2] =3D EFI_ACPI_RESERVED_BYTE; @@ -405,15 +372,18 @@ AddGenericInitiatorAffinity ( return EFI_INVALID_PARAMETER; } =20 - GenInitAff->Flags =3D GenInitAffInfo->Flags; + GenInitAff->Flags =3D Cursor->Flags; GenInitAff->Reserved2[0] =3D EFI_ACPI_RESERVED_BYTE; GenInitAff->Reserved2[1] =3D EFI_ACPI_RESERVED_BYTE; =20 // Next GenInitAff++; - GenInitAffInfo++; + Cursor++; }// while - return EFI_SUCCESS; + +EXIT: + FreePool (GenInitAffInfo); + return Status; } =20 /** Construct the SRAT ACPI table. @@ -450,6 +420,7 @@ BuildSratTable ( ) { EFI_STATUS Status; + UINT32 TableSize; UINT32 GicCCount; UINT32 GicItsCount; @@ -461,21 +432,13 @@ BuildSratTable ( UINT32 MemAffOffset; UINT32 GenInitiatorAffOffset; =20 - CM_ARM_GICC_INFO * GicCInfo; - CM_ARM_GIC_ITS_INFO * GicItsInfo; - CM_ARM_MEMORY_AFFINITY_INFO * MemAffInfo; - CM_ARM_GENERIC_INITIATOR_AFFINITY_INFO * GenInitiatorAffInfo; - EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER * Srat; =20 - ASSERT ( - (This !=3D NULL) && - (AcpiTableInfo !=3D NULL) && - (CfgMgrProtocol !=3D NULL) && - (Table !=3D NULL) && - (AcpiTableInfo->TableGeneratorId =3D=3D This->GeneratorID) && - (AcpiTableInfo->AcpiTableSignature =3D=3D This->AcpiTableSignature) - ); + ASSERT (This !=3D NULL); + ASSERT (AcpiTableInfo !=3D NULL); + ASSERT (Table !=3D NULL); + ASSERT (AcpiTableInfo->TableGeneratorId =3D=3D This->GeneratorID); + ASSERT (AcpiTableInfo->AcpiTableSignature =3D=3D This->AcpiTableSignatur= e); =20 if ((AcpiTableInfo->AcpiTableRevision < This->MinAcpiTableRevision) || (AcpiTableInfo->AcpiTableRevision > This->AcpiTableRevision)) { @@ -490,21 +453,9 @@ BuildSratTable ( return EFI_INVALID_PARAMETER; } =20 - *Table =3D NULL; - - Status =3D GetEArmObjGicCInfo ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &GicCInfo, - &GicCCount - ); + Status =3D CfgMgrCountObjects (EArmObjGicCInfo, &GicCCount); if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: SRAT: Failed to get GICC Info. Status =3D %r\n", - Status - )); - goto error_handler; + return Status; } =20 if (GicCCount =3D=3D 0) { @@ -513,54 +464,23 @@ BuildSratTable ( "ERROR: SRAT: GIC CPU Interface information not provided.\n" )); ASSERT (0); - Status =3D EFI_INVALID_PARAMETER; - goto error_handler; + return EFI_INVALID_PARAMETER; } =20 - Status =3D GetEArmObjGicItsInfo ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &GicItsInfo, - &GicItsCount - ); + Status =3D CfgMgrCountObjects (EArmObjGicItsInfo, &GicItsCount); if (EFI_ERROR (Status) && (Status !=3D EFI_NOT_FOUND)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: SRAT: Failed to get GIC ITS Info. Status =3D %r\n", - Status - )); - goto error_handler; + return Status; } =20 - Status =3D GetEArmObjMemoryAffinityInfo ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &MemAffInfo, - &MemAffCount - ); + Status =3D CfgMgrCountObjects (EArmObjMemoryAffinityInfo, &MemAffCount); if (EFI_ERROR (Status) && (Status !=3D EFI_NOT_FOUND)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: SRAT: Failed to get Memory Affinity Info. Status =3D %r\n", - Status - )); - goto error_handler; + return Status; } =20 - Status =3D GetEArmObjGenericInitiatorAffinityInfo ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &GenInitiatorAffInfo, - &GenInitiatorAffCount - ); + Status =3D CfgMgrCountObjects ( + EArmObjGenericInitiatorAffinityInfo, &GenInitiatorAffCount); if (EFI_ERROR (Status) && (Status !=3D EFI_NOT_FOUND)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: SRAT: Failed to get Generic Initiator Affinity Info." - " Status =3D %r\n", - Status - )); - goto error_handler; + return Status; } =20 // Calculate the size of the SRAT table @@ -588,35 +508,15 @@ BuildSratTable ( } =20 // Allocate the Buffer for SRAT table - *Table =3D (EFI_ACPI_DESCRIPTION_HEADER*)AllocateZeroPool (TableSize); - if (*Table =3D=3D NULL) { - Status =3D EFI_OUT_OF_RESOURCES; - DEBUG (( - DEBUG_ERROR, - "ERROR: SRAT: Failed to allocate memory for SRAT Table, Size =3D %d,= " \ - " Status =3D %r\n", - TableSize, - Status - )); - goto error_handler; + Srat =3D AllocateZeroPool (TableSize); + if (Srat =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; } =20 - Srat =3D (EFI_ACPI_6_3_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER*)*Table; - - DEBUG (( - DEBUG_INFO, - "SRAT: Srat =3D 0x%p TableSize =3D 0x%x\n", - Srat, - TableSize - )); + DEBUG ((DEBUG_INFO, "SRAT: Srat =3D 0x%p TableSize =3D 0x%x\n", Srat, Ta= bleSize)); =20 Status =3D AddAcpiHeader (This, &Srat->Header, AcpiTableInfo, TableSize); if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: SRAT: Failed to add ACPI header. Status =3D %r\n", - Status - )); goto error_handler; } =20 @@ -625,86 +525,33 @@ BuildSratTable ( Srat->Reserved1 =3D 1; Srat->Reserved2 =3D EFI_ACPI_RESERVED_QWORD; =20 - Status =3D AddGICCAffinity ( - CfgMgrProtocol, - Srat, - GicCAffOffset, - GicCInfo, - GicCCount - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: SRAT: Failed to add GICC Affinity structures. Status =3D %r\= n", - Status - )); - goto error_handler; - } + AddGICCAffinity (Srat, GicCAffOffset); =20 if (GicItsCount !=3D 0) { - Status =3D AddGICItsAffinity ( - CfgMgrProtocol, - Srat, - GicItsAffOffset, - GicItsInfo, - GicItsCount - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: SRAT: Failed to add GIC ITS Affinity structures. Status = =3D %r\n", - Status - )); - goto error_handler; - } + AddGICItsAffinity (Srat, GicItsAffOffset); } =20 if (MemAffCount !=3D 0) { - Status =3D AddMemoryAffinity ( - CfgMgrProtocol, - Srat, - MemAffOffset, - MemAffInfo, - MemAffCount - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: SRAT: Failed to add Memory Affinity structures. Status =3D= %r\n", - Status - )); - goto error_handler; - } + AddMemoryAffinity (Srat, MemAffOffset); } =20 if (GenInitiatorAffCount !=3D 0) { - Status =3D AddGenericInitiatorAffinity ( - CfgMgrProtocol, - Srat, - GenInitiatorAffOffset, - GenInitiatorAffInfo, - GenInitiatorAffCount - ); + Status =3D AddGenericInitiatorAffinity (Srat, GenInitiatorAffOffset); if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: SRAT: Failed to add Generic Initiator Affinity structures." - " Status =3D %r\n", - Status - )); + DEBUG ( + (DEBUG_ERROR, + "ERROR: SRAT: Failed to add Generic Initiator Affinity structures= ." + " Status =3D %r\n", + Status)); goto error_handler; } } =20 + *Table =3D (EFI_ACPI_DESCRIPTION_HEADER*)Srat; return Status; =20 error_handler: - - if (*Table !=3D NULL) { - FreePool (*Table); - *Table =3D NULL; - } - + FreePool (Srat); return Status; } =20 @@ -728,13 +575,11 @@ FreeSratTableResources ( IN OUT EFI_ACPI_DESCRIPTION_HEADER ** CONST Table ) { - ASSERT ( - (This !=3D NULL) && - (AcpiTableInfo !=3D NULL) && - (CfgMgrProtocol !=3D NULL) && - (AcpiTableInfo->TableGeneratorId =3D=3D This->GeneratorID) && - (AcpiTableInfo->AcpiTableSignature =3D=3D This->AcpiTableSignature) - ); + ASSERT (This !=3D NULL); + ASSERT (AcpiTableInfo !=3D NULL); + ASSERT (CfgMgrProtocol !=3D NULL); + ASSERT (AcpiTableInfo->TableGeneratorId =3D=3D This->GeneratorID); + ASSERT (AcpiTableInfo->AcpiTableSignature =3D=3D This->AcpiTableSignatur= e); =20 if ((Table =3D=3D NULL) || (*Table =3D=3D NULL)) { DEBUG ((DEBUG_ERROR, "ERROR: SRAT: Invalid Table Pointer\n")); --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#63587): https://edk2.groups.io/g/devel/message/63587 Mute This Topic: https://groups.io/mt/75910574/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-