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 C6B69941A27 for ; Thu, 2 May 2024 16:37:21 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=KrDYQxhYFIy1BvUe1yO0pWYoeRvaTNHj0QLgzCHhUR4=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:User-Agent:From:Subject:To:Cc:References:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20240206; t=1714667840; v=1; b=sA8dK/opq8UCLzfc3ARpJxSGxgnTN9v+VuRh9XaTuzOotTiUFUH3O8+ndN/b8ogqK+AES/lZ lQ4xc6kGb9JKywhC5T/BEER6r76Yzl8mmo03PBxqcnImZRAcu351vQTDedJRWckehFmVXkJD/Wg v9jBl9xXH43faV/NJRmH2j3UbTUMCIaS7to7QnK77vHgMzcOX0S0FheakXw8sasbnEd8k0VRhhx fCGo6WyrheNtYPcXlCGgkNnu5Yi0oe41f1ODH1hMToQr5yX5eNDfasJnXZIPs/xZhtmlYcFrFsw E4SCU78f0QXJMdn0a8uCWDmjgr1IpsO21kj0vUKc2fdXg== X-Received: by 127.0.0.2 with SMTP id dCZQYY7687511xaCbLbS9QBI; Thu, 02 May 2024 09:37:20 -0700 X-Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.1125.1714667839399322877 for ; Thu, 02 May 2024 09:37:19 -0700 X-Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8F0BD2F4; Thu, 2 May 2024 09:37:44 -0700 (PDT) X-Received: from [10.34.111.156] (e126645.nice.Arm.com [10.34.111.156]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1C7773F793; Thu, 2 May 2024 09:37:17 -0700 (PDT) Message-ID: Date: Thu, 2 May 2024 18:37:15 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird From: "PierreGondois" Subject: Re: [edk2-devel] [RESEND PATCH v4 5/5] DynamicTablesPkg: Adds X64 arch MADT Table generator To: Abdul Lateef Attar , devel@edk2.groups.io Cc: Sami Mujawar References: <38079858d41e6fbbe2ae48e5f3603d5c9dab4c76.1714369949.git.AbdulLateef.Attar@amd.com> In-Reply-To: <38079858d41e6fbbe2ae48e5f3603d5c9dab4c76.1714369949.git.AbdulLateef.Attar@amd.com> 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: Thu, 02 May 2024 09:37:19 -0700 Resent-From: pierre.gondois@arm.com Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: bPvtjzmJRsjqlAVD0Y5aoWuIx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b="sA8dK/op"; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=arm.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io Hello Abdul, some comments on the patch: On 4/29/24 08:03, Abdul Lateef Attar wrote: > Adds X64 architecture specific MADT/APIC Table generator. > Register/Deregister MADT table. > Adds X64 architecture namespace objects. >=20 > 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/Acp= iMadtLibX64.inf > create mode 100644 DynamicTablesPkg/Library/Acpi/X64/AcpiMadtLibX64/Mad= tGenerator.c >=20 > diff --git a/DynamicTablesPkg/DynamicTables.dsc.inc b/DynamicTablesPkg/Dy= namicTables.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/AcpiSsdtHpetLi= b.inf > + NULL|DynamicTablesPkg/Library/Acpi/X64/AcpiMadtLibX64/AcpiMadtLibX= 64.inf > } > =20 > [Components.ARM, Components.AARCH64] > diff --git a/DynamicTablesPkg/Include/ConfigurationManagerObject.h b/Dyna= micTablesPkg/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/DynamicTabl= esPkg/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 Interrup= t Information > + EX64ObjMadtProcessorLocalApicX2ApicInfo, ///< 2 - MADT Local APIC/x2A= PIC Controller Information > + EX64ObjMadtIoApicInfo, ///< 3 - MADT IOAPIC Informa= tion > + EX64ObjMadtLocalApicX2ApicNmiInfo, ///< 4 - MADT Local APIC/x2A= PIC NMI Information > + EX64ObjMadtInterruptSourceOverrideInfo, ///< 5 - MADT Interrupt Over= ride 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 = Information Cf. the comment in: [PATCH v4 2/5] DynamicTablesPkg: Adds ACPI HPET Table generator the information should be stored in CmObj, as (for instance): { UINT32 InterruptNumber; UINT32 Flags; UINT64 BaseAddress; ... } Here you are kind of bypassing the framework by using a VOID* pointer. The interest of storing the information in objects is that this information can be re-used at multiple places. For instance for Arm, GicC information is used to generate the MADT table, but also used for to generate the PPTT, SRAT, SSDT topology tables. If the information is generic, multiple IDs can correspond to on CM_OBJ structure as you did, but fields containing real data should be used. For instance there is for Arm: /** A structure that describes the Arm Generic Interrupts. */ typedef struct CmArmGenericInterrupt { /// Interrupt number UINT32 Interrupt; /// Flags /// BIT0: 0: Interrupt is Level triggered /// 1: Interrupt is Edge triggered /// BIT1: 0: Interrupt is Active high /// 1: Interrupt is Active low UINT32 Flags; } CM_ARM_GENERIC_INTERRUPT; but I don't think it fully applies to X64 arch as for instance, the 5.2.12.8 Local APIC Address Override Structure requires a 'Local APIC Address' field which is not present in here. > + UINTN Size; ///< Size of the Interrupt Cont= roller Type Information > +} CM_X64_MADT_INTERRUPT_CONTROLLER_TYPE_INFO; > +#endif > diff --git a/DynamicTablesPkg/Library/Acpi/X64/AcpiMadtLibX64/AcpiMadtLib= X64.inf b/DynamicTablesPkg/Library/Acpi/X64/AcpiMadtLibX64/AcpiMadtLibX64.i= nf > 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/MadtGenerat= or.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 Des= cription 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 EX64ObjMadtProcessorLocalApicX2A= picInfo > +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 EX64ObjMadtLocalApicX2ApicNmiInf= o > +GET_OBJECT_LIST ( > + EObjNameSpaceX64, > + EX64ObjMadtLocalApicX2ApicNmiInfo, > + CM_X64_MADT_INTERRUPT_CONTROLLER_TYPE_INFO > + ); > + > +/// MACRO to create GET_OBJECT_LIST for EX64ObjMadtInterruptSourceOverri= deInfo > +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 configuratio= n. > + > + @param[in] This Pointer to the ACPI_TABLE_GENERATOR prot= ocol. > + @param[in] AcpiTableInfo Pointer to the CM_STD_OBJ_ACPI_TABLE_INF= O structure. > + @param[in] CfgMgrProtocol Pointer to the EDKII_CONFIGURATION_MANAG= ER_PROTOCOL protocol. > + @param[out] Table Pointer to the ACPI table structure. > + > + @retval EFI_SUCCESS The ACPI MADT table is built successfull= y. > + @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 *LocalInterruptIn= fo; > + CM_X64_MADT_INTERRUPT_CONTROLLER_TYPE_INFO *ProcessorLocalAp= icX2ApicInfo; > + CM_X64_MADT_INTERRUPT_CONTROLLER_TYPE_INFO *IoApicInfo; > + CM_X64_MADT_INTERRUPT_CONTROLLER_TYPE_INFO *LocalApicX2ApicN= miInfo; > + CM_X64_MADT_INTERRUPT_CONTROLLER_TYPE_INFO *InterruptSourceO= verrideInfo; > + > + 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->AcpiTableSignat= ure); > + > + 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_HEAD= ER); > + > + // 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 Inf= o\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 API= C/x2APIC Info\n")); > + return Status; > + } else { > + if (ProcessorLocalApicX2ApicInfo->Size =3D=3D 0) { > + DEBUG ((DEBUG_ERROR, "ERROR: MADT: Processor Local APIC/x2APIC Inf= o 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 N= MI Info\n")); > + return Status; > + } else { > + if (LocalApicX2ApicNmiInfo->Size =3D=3D 0) { > + DEBUG ((DEBUG_ERROR, "ERROR: MADT: Local APIC/x2APIC NMI Info size= is 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 O= verride Info\n")); > + } > + > + if ((InterruptSourceOverrideInfo !=3D NULL) && (InterruptSourceOverrid= eInfo->Size !=3D 0)) { > + MadtSize +=3D InterruptSourceOverrideInfo->Size; > + } > + > + // Allocate memory for Madt pointer > + Madt =3D (EFI_ACPI_6_5_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER *)Alloca= teZeroPool (MadtSize); > + if (Madt =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "ERROR: MADT: Failed to allocate memory for MAD= T\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= _HEADER), > + ProcessorLocalApicX2ApicInfo->InterruptControllerTypeInfo, > + ProcessorLocalApicX2ApicInfo->Size > + ); > + > + CopyMem ( > + (UINT8 *)Madt + sizeof (EFI_ACPI_6_5_MULTIPLE_APIC_DESCRIPTION_TABLE= _HEADER) + ProcessorLocalApicX2ApicInfo->Size, > + IoApicInfo->InterruptControllerTypeInfo, > + IoApicInfo->Size > + ); > + > + CopyMem ( > + (UINT8 *)Madt + sizeof (EFI_ACPI_6_5_MULTIPLE_APIC_DESCRIPTION_TABLE= _HEADER) + ProcessorLocalApicX2ApicInfo->Size + IoApicInfo->Size, > + LocalApicX2ApicNmiInfo->InterruptControllerTypeInfo, > + LocalApicX2ApicNmiInfo->Size > + ); > + > + if ((InterruptSourceOverrideInfo !=3D NULL) && (InterruptSourceOverrid= eInfo->Size !=3D 0)) { > + CopyMem ( > + (UINT8 *)Madt + sizeof (EFI_ACPI_6_5_MULTIPLE_APIC_DESCRIPTION_TAB= LE_HEADER) + ProcessorLocalApicX2ApicInfo->Size + IoApicInfo->Size + LocalA= picX2ApicNmiInfo->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 AcpiTableI= nfo, > + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProt= ocol, > + 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->AcpiTableSignat= ure); > + > + 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; I think it misses: FreePool (*Table); > + 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 EF= I 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", Statu= s)); > + 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 EF= I 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", Sta= tus)); > + ASSERT_EFI_ERROR (Status); > + return Status; > +} -=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 (#118532): https://edk2.groups.io/g/devel/message/118532 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-