From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id D4054740046 for ; Mon, 29 Apr 2024 06:04:02 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=AMFqEgoIh01Mc5RMad8gLV5fQ2CUlb1JcdJV6oaJ5U0=; c=relaxed/simple; d=groups.io; h=Received-SPF:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Received-SPF:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20240206; t=1714370641; v=1; b=pBs+Td1HoETFqDgkff8w8+q/2y2lgErpgMuBHFdkoLZA8xxJDki9fq2McqmKHgPJWnS0fvef o2JuhwqLmqmhEmsctATnJxZVqFzuRL9vglQU2h/tPdVCvx4xFYWQfMHhas+2+5HCTPjc+5Sid5d 84DXLDW4QE5ACAEjxuXevKd1L+5LQ20PTX5jsCTLRUw4MlcI2Sh6Pk9bitlUsWAfGcPRcEzFTrg cgrxzXFIjGbABLnLlqAVMYdTaGHZQHBI4X4nRPCKuZg3aFU7lNd6aK5cbaagMym0lWLEZbk0nwt 8CT7cUzOiGs4emK7hkbWe5hGUyuhXitSZN2T3BBsovvng== X-Received: by 127.0.0.2 with SMTP id 5Gu8YY7687511xbR6ZXgG6Lz; Sun, 28 Apr 2024 23:04:01 -0700 X-Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.45]) by mx.groups.io with SMTP id smtpd.web10.14225.1714370640711198461 for ; Sun, 28 Apr 2024 23:04:00 -0700 X-Received: from BL1PR13CA0184.namprd13.prod.outlook.com (2603:10b6:208:2be::9) by DM6PR12MB4075.namprd12.prod.outlook.com (2603:10b6:5:21d::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.34; Mon, 29 Apr 2024 06:03:57 +0000 X-Received: from BL02EPF0001A106.namprd05.prod.outlook.com (2603:10b6:208:2be:cafe::1d) by BL1PR13CA0184.outlook.office365.com (2603:10b6:208:2be::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.22 via Frontend Transport; Mon, 29 Apr 2024 06:03:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB03.amd.com; pr=C X-Received: from SATLEXMB03.amd.com (165.204.84.17) by BL02EPF0001A106.mail.protection.outlook.com (10.167.241.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7544.18 via Frontend Transport; Mon, 29 Apr 2024 06:03:57 +0000 X-Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 29 Apr 2024 01:03:56 -0500 X-Received: from BLR-LAB-SFW01.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Mon, 29 Apr 2024 01:03:54 -0500 From: "Abdul Lateef Attar via groups.io" To: CC: Abdul Lateef Attar , Sami Mujawar , Pierre Gondois Subject: [edk2-devel] [RESEND PATCH v4 5/5] DynamicTablesPkg: Adds X64 arch MADT Table generator Date: Mon, 29 Apr 2024 11:33:35 +0530 Message-ID: <38079858d41e6fbbe2ae48e5f3603d5c9dab4c76.1714369949.git.AbdulLateef.Attar@amd.com> In-Reply-To: References: MIME-Version: 1.0 Received-SPF: None (SATLEXMB03.amd.com: AbdulLateef.Attar@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0001A106:EE_|DM6PR12MB4075:EE_ X-MS-Office365-Filtering-Correlation-Id: 82949e67-63be-41ed-5626-08dc6812280c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?QaeefnV8Li6zgHQHjYf/+RpZYch9tF4sBa7TdmdCP3lmlYmlKuQq9piRTLCR?= =?us-ascii?Q?r9COZyL9pHR5u+SjwgFuY5yOh2AH83IkTsYitsSgG4J2TR8nLg8m/lMKqTuk?= =?us-ascii?Q?hi9iLPavz+LKAjt4HQRJ+1ty9zbzVssVt+fmHF3BTo1OYQP3yVgDptvAra74?= =?us-ascii?Q?x1Eg5kfJaWJef0tRm+rulcGId3bF4Rndr1U3sIKF818qXAOWjzirNkRfaTw/?= =?us-ascii?Q?BMW9U4N4UEtLg4N4FJhEQB/408EPJWhQTkoUhgz8yRIyjT5FgvRHlMIIsgaw?= =?us-ascii?Q?4EVT3ZJN/mrsxnIewV3z1Pa79zEGWHdVIfflO2QX26W/v8nrxv3mev1zvnih?= =?us-ascii?Q?c1+sbI6+ygbqVHdNM9arp1jSEA6EkIiZuwFa4mT8eqM57Ur3cJhiMEypic1c?= =?us-ascii?Q?rmm5eCtmsghvDzoHYq+r3FbKjcspDpTJ+NfYUq7tMcmuwCgmBCYc6TVtAqwU?= =?us-ascii?Q?5pNVf5Ag9k1o4sTppFYbtB+j3UXcFVv2jX7ETOTzOwakJxr/6IZkQn+nsIQ8?= =?us-ascii?Q?7wCXuB78XFQlc/ObViDr5+LSHw9w5mgRFMNKTJb+PYLOts8rOLupaEbLycCZ?= =?us-ascii?Q?zrFEnMcwzzy6Kl1IxJ3p5R6LfbNxKoIWAV0QoNTtWn0R8rJ66UvSXtA9ebSp?= =?us-ascii?Q?MQWm7eMd20IjrrDdLWNtLogwYioytas3BvYKT1soMFDRWejQ+fawSd2cIEmt?= =?us-ascii?Q?M5Pgdc4/YfEFEp8JlTvOQDLX5Ia/vGSqdTSlA9HERsuPL3DXHOXGwygXV1eD?= =?us-ascii?Q?BaliOf2AD9SY0D5rvXD7D/1egR9vf6vbdifc78+q4g5t6E5CxU85lYOENA+K?= =?us-ascii?Q?1leIXx0wWeGPGxXrm7zWzuc7RytMAtrzGA5UAAQcM9WwZKIrD+u/Xpj7SH3L?= =?us-ascii?Q?7nqwNIPUXqC2U55x9mCQSxnpD7XX+xmeD9tHXRhOusTdufsDUMPJeCqInp/i?= =?us-ascii?Q?TQg2ykmZh+U6oyamjK2BOUDMIHoKlqEip9deKCEqPCbrqMWrZ7fBiEh4t4aY?= =?us-ascii?Q?2H8PldwT1R7iwZfBDVK6SXICBjyr2wJJNVJR4c2eLntJx+TCgxlwE1rxG3wc?= =?us-ascii?Q?kJ1p+/8IeZjGNc5tmZuxng/nq6pfbWSpMlqGFoq6u2193N+ARawm90c8OZXU?= =?us-ascii?Q?ZB8DwC7kU6SsVfvjgaHDHe+R2n9eQfTIP2P9mbvuTyldmQz5lwUTB49CZRjL?= =?us-ascii?Q?QECV5WcKgRyHIoc4jHWVBLTgOcqah+Cm2j3T+lvE2p6Smb5lKPAS5zM1Q5ZP?= =?us-ascii?Q?BtGZ0flNtiwzyXWnOF5WWRdlBH2GRhwxYEnAjhan8ulwAHYdDOjLiE54ssSX?= =?us-ascii?Q?pfEvtO/HJ0ve6oGM68QEf52vbAgwpNngev34PXe9YjFc93yBrg0wtrRMHVNo?= =?us-ascii?Q?SuWBf/z0ico4d1WaQc91ky1dlwrz?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2024 06:03:57.0052 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 82949e67-63be-41ed-5626-08dc6812280c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL02EPF0001A106.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB4075 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Sun, 28 Apr 2024 23:04:01 -0700 Resent-From: AbdulLateef.Attar@amd.com Reply-To: devel@edk2.groups.io,AbdulLateef.Attar@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: L29EoDFj4xAx8nXsfr2BhVsGx7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=pBs+Td1H; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io Adds X64 architecture specific MADT/APIC Table generator. Register/Deregister MADT table. Adds X64 architecture namespace objects. Cc: Sami Mujawar Cc: Pierre Gondois Signed-off-by: Abdul Lateef Attar --- DynamicTablesPkg/DynamicTables.dsc.inc | 6 + .../Include/ConfigurationManagerObject.h | 1 + .../Include/X64NameSpaceObjects.h | 48 +++ .../X64/AcpiMadtLibX64/AcpiMadtLibX64.inf | 27 ++ .../Acpi/X64/AcpiMadtLibX64/MadtGenerator.c | 375 ++++++++++++++++++ 5 files changed, 457 insertions(+) create mode 100644 DynamicTablesPkg/Include/X64NameSpaceObjects.h create mode 100644 DynamicTablesPkg/Library/Acpi/X64/AcpiMadtLibX64/AcpiMa= dtLibX64.inf create mode 100644 DynamicTablesPkg/Library/Acpi/X64/AcpiMadtLibX64/MadtGe= nerator.c diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc b/DynamicTablesPkg/Dyna= micTables.dsc.inc index fc2ac5962e..19034e6f65 100644 --- a/DynamicTablesPkg/DynamicTables.dsc.inc +++ b/DynamicTablesPkg/DynamicTables.dsc.inc @@ -39,6 +39,11 @@ DynamicTablesPkg/Library/Acpi/AcpiSsdtHpetLib/AcpiSsdtHpetLib.inf =20 [Components.IA32, Components.X64] + # + # Generators + # + DynamicTablesPkg/Library/Acpi/X64/AcpiMadtLibX64/AcpiMadtLibX64.inf + # # Dynamic Table Factory Dxe # @@ -48,6 +53,7 @@ NULL|DynamicTablesPkg/Library/Acpi/AcpiHpetLib/AcpiHpetLib.inf NULL|DynamicTablesPkg/Library/Acpi/AcpiWsmtLib/AcpiWsmtLib.inf NULL|DynamicTablesPkg/Library/Acpi/AcpiSsdtHpetLib/AcpiSsdtHpetLib.i= nf + NULL|DynamicTablesPkg/Library/Acpi/X64/AcpiMadtLibX64/AcpiMadtLibX64= .inf } =20 [Components.ARM, Components.AARCH64] diff --git a/DynamicTablesPkg/Include/ConfigurationManagerObject.h b/Dynami= cTablesPkg/Include/ConfigurationManagerObject.h index f2cfadf3d4..31197eb019 100644 --- a/DynamicTablesPkg/Include/ConfigurationManagerObject.h +++ b/DynamicTablesPkg/Include/ConfigurationManagerObject.h @@ -110,6 +110,7 @@ typedef enum ObjectNameSpaceID { EObjNameSpaceStandard, ///< Standard Objects Namespace EObjNameSpaceArm, ///< ARM Objects Namespace EObjNameSpaceArch, ///< Arch Objects Namespace + EObjNameSpaceX64, ///< X64 Objects Namespace EObjNameSpaceOem =3D 0x8, ///< OEM Objects Namespace EObjNameSpaceMax } EOBJECT_NAMESPACE_ID; diff --git a/DynamicTablesPkg/Include/X64NameSpaceObjects.h b/DynamicTables= Pkg/Include/X64NameSpaceObjects.h new file mode 100644 index 0000000000..cd5c1ff43c --- /dev/null +++ b/DynamicTablesPkg/Include/X64NameSpaceObjects.h @@ -0,0 +1,48 @@ +/** @file + + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Glossary: + - Cm or CM - Configuration Manager + - Obj or OBJ - Object + - X64 - X64 processor architecture + **/ + +#ifndef X64_NAMESPACE_OBJECT_H_ +#define X64_NAMESPACE_OBJECT_H_ + +/** The EX64_OBJECT_ID enum describes the Object IDs + in the X64 Namespace +*/ +typedef enum X64ObjectID { + EX64ObjReserved, ///< 0 - Reserved + EX64ObjMadtLocalInterruptInfo, ///< 1 - MADT Local Interrupt = Information + EX64ObjMadtProcessorLocalApicX2ApicInfo, ///< 2 - MADT Local APIC/x2API= C Controller Information + EX64ObjMadtIoApicInfo, ///< 3 - MADT IOAPIC Informati= on + EX64ObjMadtLocalApicX2ApicNmiInfo, ///< 4 - MADT Local APIC/x2API= C NMI Information + EX64ObjMadtInterruptSourceOverrideInfo, ///< 5 - MADT Interrupt Overri= de Information + EX64ObjMax +} E_X64_OBJECT_ID; + +/** A structure that describes the + MADT Local Interrupt Information for the Platform. + + ID: EX64ObjMadtLocalInterruptInfo +*/ +typedef struct CmX64MadtLocalInterruptInfo { + UINT32 LocalApicAddress; ///< Local Interrupt Controller Address + UINT32 Flags; ///< Flags +} CM_X64_MADT_LOCAL_INTERRUPT_INFO; + +/** A structure that describes the + MADT Interrupt controller type information for the platform. + + ID: EX64ObjMadtInterruptControllerTypeInfo +*/ +typedef struct CmX64MadtInterruptControllerTypeInfo { + VOID *InterruptControllerTypeInfo; ///< Interrupt Controller Type In= formation + UINTN Size; ///< Size of the Interrupt Contro= ller Type Information +} CM_X64_MADT_INTERRUPT_CONTROLLER_TYPE_INFO; +#endif diff --git a/DynamicTablesPkg/Library/Acpi/X64/AcpiMadtLibX64/AcpiMadtLibX6= 4.inf b/DynamicTablesPkg/Library/Acpi/X64/AcpiMadtLibX64/AcpiMadtLibX64.inf new file mode 100644 index 0000000000..4d59e9023c --- /dev/null +++ b/DynamicTablesPkg/Library/Acpi/X64/AcpiMadtLibX64/AcpiMadtLibX64.inf @@ -0,0 +1,27 @@ +## @file +# MADT Acpi table generator +# +# Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. +# +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 1.27 + BASE_NAME =3D AcpiMadtLibX64 + FILE_GUID =3D BF8A63EC-21B9-4531-9866-F3F1593282EC + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D DXE_DRIVER + LIBRARY_CLASS =3D NULL|DXE_DRIVER + CONSTRUCTOR =3D AcpiMadtLibX64Constructor + DESTRUCTOR =3D AcpiMadtLibX64Destructor + +[Sources] + MadtGenerator.c + +[Packages] + DynamicTablesPkg/DynamicTablesPkg.dec + MdeModulePkg/MdeModulePkg.dec + MdePkg/MdePkg.dec + + diff --git a/DynamicTablesPkg/Library/Acpi/X64/AcpiMadtLibX64/MadtGenerator= .c b/DynamicTablesPkg/Library/Acpi/X64/AcpiMadtLibX64/MadtGenerator.c new file mode 100644 index 0000000000..8cfed66c8f --- /dev/null +++ b/DynamicTablesPkg/Library/Acpi/X64/AcpiMadtLibX64/MadtGenerator.c @@ -0,0 +1,375 @@ +/** @file + This library provides the implementation of the ACPI Multiple APIC Descr= iption Table (MADT) + for X64 architecture. + + Copyright (c) 2017 - 2023, Arm Limited. All rights reserved. + Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** The Creator ID for the ACPI tables generated using + the standard ACPI table generators. +*/ +#define TABLE_GENERATOR_CREATOR_ID_GENERIC SIGNATURE_32('D', 'Y', 'N', 'T= ') + +/// MACRO to create GET_OBJECT_LIST for EX64ObjMadtLocalInterruptInfo +GET_OBJECT_LIST ( + EObjNameSpaceX64, + EX64ObjMadtLocalInterruptInfo, + CM_X64_MADT_LOCAL_INTERRUPT_INFO + ); + +/// MACRO to create GET_OBJECT_LIST for EX64ObjMadtProcessorLocalApicX2Api= cInfo +GET_OBJECT_LIST ( + EObjNameSpaceX64, + EX64ObjMadtProcessorLocalApicX2ApicInfo, + CM_X64_MADT_INTERRUPT_CONTROLLER_TYPE_INFO + ); + +/// MACRO to create GET_OBJECT_LIST for EX64ObjMadtIoApicInfo +GET_OBJECT_LIST ( + EObjNameSpaceX64, + EX64ObjMadtIoApicInfo, + CM_X64_MADT_INTERRUPT_CONTROLLER_TYPE_INFO + ); + +/// MACRO to create GET_OBJECT_LIST for EX64ObjMadtLocalApicX2ApicNmiInfo +GET_OBJECT_LIST ( + EObjNameSpaceX64, + EX64ObjMadtLocalApicX2ApicNmiInfo, + CM_X64_MADT_INTERRUPT_CONTROLLER_TYPE_INFO + ); + +/// MACRO to create GET_OBJECT_LIST for EX64ObjMadtInterruptSourceOverride= Info +GET_OBJECT_LIST ( + EObjNameSpaceX64, + EX64ObjMadtInterruptSourceOverrideInfo, + CM_X64_MADT_INTERRUPT_CONTROLLER_TYPE_INFO + ); + +/** + Build the ACPI MADT table. + + This function builds the ACPI MADT table as per the input configuration. + + @param[in] This Pointer to the ACPI_TABLE_GENERATOR protoc= ol. + @param[in] AcpiTableInfo Pointer to the CM_STD_OBJ_ACPI_TABLE_INFO = structure. + @param[in] CfgMgrProtocol Pointer to the EDKII_CONFIGURATION_MANAGER= _PROTOCOL protocol. + @param[out] Table Pointer to the ACPI table structure. + + @retval EFI_SUCCESS The ACPI MADT table is built successfully. + @retval EFI_INVALID_PARAMETER The input parameter is invalid. +**/ +STATIC +EFI_STATUS +BuildMadtTable ( + IN CONST ACPI_TABLE_GENERATOR *CONST This, + IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInfo, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, + OUT EFI_ACPI_DESCRIPTION_HEADER **CONST Table + ) +{ + EFI_STATUS Status; + EFI_ACPI_6_5_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER *Madt; + UINTN MadtSize; + CM_X64_MADT_LOCAL_INTERRUPT_INFO *LocalInterruptInfo= ; + CM_X64_MADT_INTERRUPT_CONTROLLER_TYPE_INFO *ProcessorLocalApic= X2ApicInfo; + CM_X64_MADT_INTERRUPT_CONTROLLER_TYPE_INFO *IoApicInfo; + CM_X64_MADT_INTERRUPT_CONTROLLER_TYPE_INFO *LocalApicX2ApicNmi= Info; + CM_X64_MADT_INTERRUPT_CONTROLLER_TYPE_INFO *InterruptSourceOve= rrideInfo; + + 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); + + if ((AcpiTableInfo->AcpiTableRevision < This->MinAcpiTableRevision) || + (AcpiTableInfo->AcpiTableRevision > This->AcpiTableRevision)) + { + DEBUG (( + DEBUG_ERROR, + "ERROR: MADT: Requested table revision =3D %d, is not supported." + "Supported table revision: Minimum =3D %d, Maximum =3D %d\n", + AcpiTableInfo->AcpiTableRevision, + This->MinAcpiTableRevision, + This->AcpiTableRevision + )); + return EFI_INVALID_PARAMETER; + } + + *Table =3D NULL; + MadtSize =3D sizeof (EFI_ACPI_6_5_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER= ); + + // Get Local Interrupt Info + Status =3D GetEX64ObjMadtLocalInterruptInfo ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &LocalInterruptInfo, + NULL + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "ERROR: MADT: Failed to get Local Interrupt Info\= n")); + return Status; + } + + // Get Processor Local APIC/x2APIC Info + Status =3D GetEX64ObjMadtProcessorLocalApicX2ApicInfo ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &ProcessorLocalApicX2ApicInfo, + NULL + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "ERROR: MADT: Failed to get Processor Local APIC/= x2APIC Info\n")); + return Status; + } else { + if (ProcessorLocalApicX2ApicInfo->Size =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "ERROR: MADT: Processor Local APIC/x2APIC Info = size is 0\n")); + return EFI_NOT_FOUND; + } + } + + MadtSize +=3D ProcessorLocalApicX2ApicInfo->Size; + + // Get IO APIC Info + Status =3D GetEX64ObjMadtIoApicInfo ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &IoApicInfo, + NULL + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "ERROR: MADT: Failed to get IO APIC Info\n")); + return Status; + } else { + if (IoApicInfo->Size =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "ERROR: MADT: IO APIC Info size is 0\n")); + return EFI_NOT_FOUND; + } + } + + MadtSize +=3D IoApicInfo->Size; + + // Get Local APIC/x2APIC NMI Info + Status =3D GetEX64ObjMadtLocalApicX2ApicNmiInfo ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &LocalApicX2ApicNmiInfo, + NULL + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "ERROR: MADT: Failed to get Local APIC/x2APIC NMI= Info\n")); + return Status; + } else { + if (LocalApicX2ApicNmiInfo->Size =3D=3D 0) { + DEBUG ((DEBUG_ERROR, "ERROR: MADT: Local APIC/x2APIC NMI Info size i= s 0\n")); + return EFI_NOT_FOUND; + } + } + + MadtSize +=3D LocalApicX2ApicNmiInfo->Size; + + // Get Interrupt Source Override Info + Status =3D GetEX64ObjMadtInterruptSourceOverrideInfo ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &InterruptSourceOverrideInfo, + NULL + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_WARN, "WARNING: MADT: Failed to get Interrupt Source Ove= rride Info\n")); + } + + if ((InterruptSourceOverrideInfo !=3D NULL) && (InterruptSourceOverrideI= nfo->Size !=3D 0)) { + MadtSize +=3D InterruptSourceOverrideInfo->Size; + } + + // Allocate memory for Madt pointer + Madt =3D (EFI_ACPI_6_5_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER *)Allocate= ZeroPool (MadtSize); + if (Madt =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "ERROR: MADT: Failed to allocate memory for MADT\= n")); + return EFI_OUT_OF_RESOURCES; + } + + // Initialize the MADT header + Status =3D AddAcpiHeader ( + CfgMgrProtocol, + This, + &Madt->Header, + AcpiTableInfo, + (UINT32)MadtSize + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "ERROR: MADT: Failed to initialize MADT header\n"= )); + FreePool (Madt); + return Status; + } + + Madt->LocalApicAddress =3D LocalInterruptInfo->LocalApicAddress; + Madt->Flags =3D LocalInterruptInfo->Flags; + + CopyMem ( + (UINT8 *)Madt + sizeof (EFI_ACPI_6_5_MULTIPLE_APIC_DESCRIPTION_TABLE_H= EADER), + ProcessorLocalApicX2ApicInfo->InterruptControllerTypeInfo, + ProcessorLocalApicX2ApicInfo->Size + ); + + CopyMem ( + (UINT8 *)Madt + sizeof (EFI_ACPI_6_5_MULTIPLE_APIC_DESCRIPTION_TABLE_H= EADER) + ProcessorLocalApicX2ApicInfo->Size, + IoApicInfo->InterruptControllerTypeInfo, + IoApicInfo->Size + ); + + CopyMem ( + (UINT8 *)Madt + sizeof (EFI_ACPI_6_5_MULTIPLE_APIC_DESCRIPTION_TABLE_H= EADER) + ProcessorLocalApicX2ApicInfo->Size + IoApicInfo->Size, + LocalApicX2ApicNmiInfo->InterruptControllerTypeInfo, + LocalApicX2ApicNmiInfo->Size + ); + + if ((InterruptSourceOverrideInfo !=3D NULL) && (InterruptSourceOverrideI= nfo->Size !=3D 0)) { + CopyMem ( + (UINT8 *)Madt + sizeof (EFI_ACPI_6_5_MULTIPLE_APIC_DESCRIPTION_TABLE= _HEADER) + ProcessorLocalApicX2ApicInfo->Size + IoApicInfo->Size + LocalApi= cX2ApicNmiInfo->Size, + InterruptSourceOverrideInfo->InterruptControllerTypeInfo, + InterruptSourceOverrideInfo->Size + ); + } + + *Table =3D (EFI_ACPI_DESCRIPTION_HEADER *)Madt; + return EFI_SUCCESS; +} + +/** Free any resources allocated for constructing the MADT + + @param [in] This Pointer to the table generator. + @param [in] AcpiTableInfo Pointer to the ACPI Table Info. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol Interface. + @param [in, out] Table Pointer to the ACPI Table. + + @retval EFI_SUCCESS The resources were freed successfully. + @retval EFI_INVALID_PARAMETER The table pointer is NULL or invalid. +**/ +STATIC +EFI_STATUS +FreeMadtTableResources ( + IN CONST ACPI_TABLE_GENERATOR *CONST This, + IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInf= o, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtoc= ol, + IN OUT EFI_ACPI_DESCRIPTION_HEADER **CONST Table + ) +{ + 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); + + if ((Table =3D=3D NULL) || (*Table =3D=3D NULL)) { + DEBUG ((DEBUG_ERROR, "ERROR: MADT: Invalid Table Pointer\n")); + ASSERT ((Table !=3D NULL) && (*Table !=3D NULL)); + return EFI_INVALID_PARAMETER; + } + + *Table =3D NULL; + return EFI_SUCCESS; +} + +/// Macro for MADT Table generator revision +#define MADT_GENERATOR_REVISION CREATE_REVISION (1, 0) + +/// Interface for MADT table generator +STATIC +CONST +ACPI_TABLE_GENERATOR mMadtTableGenerator =3D { + // Generator ID + CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdMadt), + // Generator Description + L"ACPI.STD.MADT.GENERATOR", + // ACPI Table Signature + EFI_ACPI_6_5_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE, + // ACPI Table Revision supported by this Generator + EFI_ACPI_6_5_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION, + // Minimum supported ACPI Table Revision + EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION, + // Creator ID + TABLE_GENERATOR_CREATOR_ID_GENERIC, + // Creator Revision + MADT_GENERATOR_REVISION, + // Build Table function + BuildMadtTable, + // Free Resource function + FreeMadtTableResources, + // Extended build function not needed + NULL, + // Extended build function not implemented by the generator. + // Hence extended free resource function is not required. + NULL +}; + +/** + The constructor function registers the ACPI MADT table generator. + + The constructor function registers the ACPI MADT table generator. + + @param[in] ImageHandle The firmware allocated handle for the EFI = image. + @param[in] SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor executed successfully. + @retval EFI_INVALID_PARAMETER The input parameter is invalid. +**/ +EFI_STATUS +EFIAPI +AcpiMadtLibX64Constructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status =3D RegisterAcpiTableGenerator (&mMadtTableGenerator); + DEBUG ((DEBUG_INFO, "MADT: Register Generator. Status =3D %r\n", Status)= ); + ASSERT_EFI_ERROR (Status); + return Status; +} + +/** + The destructor function unregisters the ACPI MADT table generator. + + The destructor function unregisters the ACPI MADT table generator. + + @param[in] ImageHandle The firmware allocated handle for the EFI = image. + @param[in] SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The destructor executed successfully. + @retval EFI_INVALID_PARAMETER The input parameter is invalid. +**/ +EFI_STATUS +EFIAPI +AcpiMadtLibX64Destructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status =3D DeregisterAcpiTableGenerator (&mMadtTableGenerator); + DEBUG ((DEBUG_INFO, "MADT: Unregister Generator. Status =3D %r\n", Statu= s)); + ASSERT_EFI_ERROR (Status); + return Status; +} --=20 2.34.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 (#118374): https://edk2.groups.io/g/devel/message/118374 Mute This Topic: https://groups.io/mt/105796054/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-