From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (EUR01-DB5-obe.outbound.protection.outlook.com [40.107.15.58]) by mx.groups.io with SMTP id smtpd.web12.16985.1597245835974108691 for ; Wed, 12 Aug 2020 08:23:56 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=5FhMGeH3; spf=pass (domain: arm.com, ip: 40.107.15.58, mailfrom: sami.mujawar@arm.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4PObdGNzp62KBu51lW1e5DxOkzDf5njJBVUUbLRiQmQ=; b=5FhMGeH31GyLAaPln46umM4/MHhssAeGFVbQxk5+/3Eref9M7jAYlwTvh6DM/u15dH79XVnbRYd8VYyN36YQCHhdj40+KTP5SquHDUxfjw0gGKX6our6eBn3Psp1Fcqd8ok4Bd9hJAJ14KBytxslkqt2x7xPwEoZoxqvmjFYJMA= Received: from AM6P195CA0108.EURP195.PROD.OUTLOOK.COM (2603:10a6:209:86::49) by HE1PR0802MB2460.eurprd08.prod.outlook.com (2603:10a6:3:dd::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.19; Wed, 12 Aug 2020 15:23:52 +0000 Received: from VE1EUR03FT005.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:86:cafe::b4) by AM6P195CA0108.outlook.office365.com (2603:10a6:209:86::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.15 via Frontend Transport; Wed, 12 Aug 2020 15:23:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT005.mail.protection.outlook.com (10.152.18.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.16 via Frontend Transport; Wed, 12 Aug 2020 15:23:51 +0000 Received: ("Tessian outbound 7a6fb63c1e64:v64"); Wed, 12 Aug 2020 15:23:51 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 90b06eda58a0e0d9 X-CR-MTA-TID: 64aa7808 Received: from c20a0246022e.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A9311265-41A3-4C37-8F4D-B8A8926F32F3.1; Wed, 12 Aug 2020 15:23:46 +0000 Received: from EUR03-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c20a0246022e.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 12 Aug 2020 15:23:46 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hl2VgBn2MqOxh4CljYT83b0pALD92EvS4d13vfTml3mU0oKZuzq2Po6B5QNARQAHeeT7xosu7LrUEcZ2AeJnolK3qR0Rh/vbPgo/WNoqu7/PfGHyrFX4QC17uDckiC2yo2JWEH3BW7rl6UqrzJNTiu7reDDCgVsPoS1SdaO2hIaGMNU5+Ih6EwzHZHpWn8iceajRxvh5efdGlOus1EES9+L8Ntpfsj3y2IfL+yYeSR1sML07qVuxuDX1oymYmLEnvddDjKEto1Do++XvJDBZ1JbskPUQcga2WBIGPk8n0Jmn1aRKDejN8gI8yEPXwh12J90jpHHYLjMrwJqvEzdlQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4PObdGNzp62KBu51lW1e5DxOkzDf5njJBVUUbLRiQmQ=; b=jmfsZBLi4q1ofM2B4Wqb1908pHXmGwQHGSjFwf/Gvd55H3X6c52/WXoJi9sDxTafoaELclurtMjROhWek2PNV1rW8mMgaYwm8AYkElf5f+FiKUQejQSWWF266HhA+HzuYcMxEvQT9bOipMe2TyFvaWm3BYYsHMAjwmoovegFZd6SuCYSz2IeikNm9oB8zEhRshERPy/4Y7JhPQ71ifcCp87LmW72bUw01gwol/nTq3t7z9bA/qnRp2N+oqFoNQLjgY7ex4zCZqUvJWa4YfG3WoZT62EPoBKAFXI03A1NYRP7J8rVQi56KX5vFY+XTGkDSGAUWB8OY9whcHAJSXAjYQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=bestguesspass action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4PObdGNzp62KBu51lW1e5DxOkzDf5njJBVUUbLRiQmQ=; b=5FhMGeH31GyLAaPln46umM4/MHhssAeGFVbQxk5+/3Eref9M7jAYlwTvh6DM/u15dH79XVnbRYd8VYyN36YQCHhdj40+KTP5SquHDUxfjw0gGKX6our6eBn3Psp1Fcqd8ok4Bd9hJAJ14KBytxslkqt2x7xPwEoZoxqvmjFYJMA= Received: from DB6PR07CA0066.eurprd07.prod.outlook.com (2603:10a6:6:2a::28) by DB7PR08MB3785.eurprd08.prod.outlook.com (2603:10a6:10:32::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.16; Wed, 12 Aug 2020 15:23:39 +0000 Received: from DB5EUR03FT059.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:2a:cafe::3a) by DB6PR07CA0066.outlook.office365.com (2603:10a6:6:2a::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.10 via Frontend Transport; Wed, 12 Aug 2020 15:23:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT059.mail.protection.outlook.com (10.152.21.175) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3283.16 via Frontend Transport; Wed, 12 Aug 2020 15:23:39 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2044.4; Wed, 12 Aug 2020 15:23:37 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1779.2; Wed, 12 Aug 2020 15:23:36 +0000 Received: from E107187.Arm.com (10.57.41.222) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2044.4 via Frontend Transport; Wed, 12 Aug 2020 15:23:36 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , Subject: [PATCH v1 22/30] DynamicTablesPkg: AML Resource Data Codegen Date: Wed, 12 Aug 2020 16:22:28 +0100 Message-ID: <20200812152236.31164-23-sami.mujawar@arm.com> X-Mailer: git-send-email 2.11.0.windows.3 In-Reply-To: <20200812152236.31164-1-sami.mujawar@arm.com> References: <20200812152236.31164-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f775c230-8fd4-48a4-1284-08d83ed3b807 X-MS-TrafficTypeDiagnostic: DB7PR08MB3785:|HE1PR0802MB2460: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:3173;OLM:3173; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(136003)(39860400002)(346002)(376002)(396003)(46966005)(5660300002)(82740400003)(19627235002)(86362001)(47076004)(186003)(336012)(316002)(6916009)(36756003)(82310400002)(54906003)(26005)(2906002)(70586007)(30864003)(426003)(70206006)(8676002)(81166007)(6666004)(44832011)(83380400001)(478600001)(356005)(4326008)(2616005)(1076003)(7696005)(8936002);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3785 Return-Path: Sami.Mujawar@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT005.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 3ff8d287-ce2a-46c5-4f12-08d83ed3b061 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Mcv8b55aHhqRi8/s0LHNfN3gZIBqebfFsdaOLavOj2RYSZ+UIJH0y9F9kzo5FyTFdE/jIV7TTFFuAkX20Tnh2cuG8qjW4lnDiWZ7rExG1LeBXxhAkHyygDiqsI1xpQxBt3SVfNLg1SYogVGuOUfZPvPYejwdHJcbFz8qKXzXWEbVs4WV6CKhE3Nv+31CpKeCCgY0yXPE397JHlGBfm0AfuU5f8lBYKBpskYNCwzcvrh2YAK6ES5TM+CR4NFI3jVWBvAATMGbUCr/iMuiAWotQ45sckpcTLvxOWHc5qdV/NWm0qUUAlr8dvFl0IZqfGsmn1Bo1P/ONwBUtnIMYtD4Wuc5uF75CVpORktYdDpqv2eEXBLXSgAX280OG9m/G1YdeEsKtNJSFf4aE2NLyPq3/w== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFTY:;SFS:(4636009)(396003)(346002)(136003)(376002)(39860400002)(46966005)(4326008)(186003)(86362001)(70586007)(6666004)(82310400002)(336012)(82740400003)(8676002)(36756003)(81166007)(83380400001)(47076004)(30864003)(478600001)(1076003)(70206006)(8936002)(2906002)(316002)(19627235002)(54906003)(6916009)(26005)(7696005)(44832011)(5660300002)(36906005)(426003)(2616005);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2020 15:23:51.7905 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f775c230-8fd4-48a4-1284-08d83ed3b807 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT005.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2460 Content-Type: text/plain From: Pierre Gondois AML Codegen is a Dynamic AML technique that facilitates generation of small segments of AML code. The AML code generated using AML Codegen is represented as nodes in the AML Tree. AML Resource Data Codegen implements interfaces required for generating Resource Data elements that can be attached to an AML tree. Signed-off-by: Pierre Gondois Signed-off-by: Sami Mujawar --- DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c | 256 ++++++++++++++++++++ DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.h | 59 +++++ 2 files changed, 315 insertions(+) diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c new file mode 100644 index 0000000000000000000000000000000000000000..9e7a508e60721558ab59b375dbd526c7066d7329 --- /dev/null +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c @@ -0,0 +1,256 @@ +/** @file + AML Resource Data Code Generation. + + Copyright (c) 2020, Arm Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Glossary: + - Rd or RD - Resource Data + - Rds or RDS - Resource Data Small + - Rdl or RDL - Resource Data Large +**/ + +#include +#include + +#include +#include +#include +#include +#include + +/** If ParentNode is not NULL, append RdNode. + If NewRdNode is not NULL, update its value to RdNode. + + @param [in] RdNode Newly created Resource Data node. + @param [in] ParentNode If not NULL, add the generated node + to the end of the variable list of + argument of the ParentNode, but + before the "End Tag" Resource Data. + Must be a BufferOpNode. + @param [out] NewRdNode If not NULL, update the its value to RdNode. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. +**/ +STATIC +EFI_STATUS +EFIAPI +LinkRdNode ( + IN AML_DATA_NODE * RdNode, + IN AML_OBJECT_NODE * ParentNode, + IN AML_DATA_NODE ** NewRdNode + ) +{ + EFI_STATUS Status; + EFI_STATUS Status1; + + if (NewRdNode != NULL) { + *NewRdNode = RdNode; + } + + // Add RdNode as the last element, but before the EndTag. + if (ParentNode != NULL) { + Status = AmlAppendRdNode (ParentNode, RdNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + Status1 = AmlDeleteTree ((AML_NODE_HEADER*)RdNode); + ASSERT_EFI_ERROR (Status1); + // Return original error. + return Status; + } + } + + return EFI_SUCCESS; +} + +/** Code generation for the "Interrupt ()" ASL function. + + This function creates a Resource Data element corresponding to the + "Interrupt ()" ASL function and stores it in an AML Data Node. + + The Resource Data effectively created is an Extended Interrupt Resource + Data. See ACPI 6.3 specification, s6.4.3.6 "Extended Interrupt Descriptor" + for more information about Extended Interrupt Resource Data. + + This function allocates memory to create a data node. It is the caller's + responsibility to either: + - attach this node to an AML tree; + - delete this node. + + @param [in] ResourceConsumer The device consumes the specified interrupt + or produces it for use by a child device. + @param [in] EdgeTriggered The interrupt is edge triggered or + level triggered. + @param [in] ActiveLow The interrupt is active-high or active-low. + @param [in] Shared The interrupt can be shared with other + devices or not (Exclusive). + @param [in] IrqList Interrupt list. Must be non-NULL. + @param [in] IrqCount Interrupt count. Must be non-zero. + @param [in] ParentNode If not NULL, add the generated node + to the end of the variable list of + argument of the ParentNode, but + before the "End Tag" Resource Data. + Must be a BufferOpNode. + @param [out] NewRdNode If success, contains the generated node. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Could not allocate memory. +**/ +EFI_STATUS +EFIAPI +AmlCodeGenInterrupt ( + IN BOOLEAN ResourceConsumer, + IN BOOLEAN EdgeTriggered, + IN BOOLEAN ActiveLow, + IN BOOLEAN Shared, + IN UINT32 * IrqList, + IN UINT8 IrqCount, + IN AML_OBJECT_NODE * ParentNode, OPTIONAL + OUT AML_DATA_NODE ** NewRdNode OPTIONAL + ) +{ + EFI_STATUS Status; + + AML_DATA_NODE * RdNode; + EFI_ACPI_EXTENDED_INTERRUPT_DESCRIPTOR RdInterrupt; + UINT32 * FirstInterrupt; + + if ((IrqList == NULL) || + (IrqCount == 0) || + ((ParentNode == NULL) && (NewRdNode == NULL))) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + RdInterrupt.Header.Header.Bits.Name = + ACPI_LARGE_EXTENDED_IRQ_DESCRIPTOR_NAME; + RdInterrupt.Header.Header.Bits.Type = ACPI_LARGE_ITEM_FLAG; + RdInterrupt.Header.Length = sizeof (EFI_ACPI_EXTENDED_INTERRUPT_DESCRIPTOR) - + sizeof (ACPI_LARGE_RESOURCE_HEADER); + RdInterrupt.InterruptVectorFlags = (ResourceConsumer ? BIT0 : 0) | + (EdgeTriggered ? BIT1 : 0) | + (ActiveLow ? BIT2 : 0) | + (Shared ? BIT3 : 0); + RdInterrupt.InterruptTableLength = IrqCount; + + // Get the address of the first interrupt field. + FirstInterrupt = RdInterrupt.InterruptNumber; + + // Copy the list of interrupts. + CopyMem (FirstInterrupt, IrqList, (sizeof (UINT32) * IrqCount)); + + Status = AmlCreateDataNode ( + EAmlNodeDataTypeResourceData, + (UINT8*)&RdInterrupt, + sizeof (EFI_ACPI_EXTENDED_INTERRUPT_DESCRIPTOR), + &RdNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + return LinkRdNode (RdNode, ParentNode, NewRdNode); +} + +/** Add an Interrupt Resource Data node. + + This function creates a Resource Data element corresponding to the + "Interrupt ()" ASL function, stores it in an AML Data Node. + + It then adds it after the input CurrRdNode in the list of resource data + element. + + The Resource Data effectively created is an Extended Interrupt Resource + Data. See ACPI 6.3 specification, s6.4.3.6 "Extended Interrupt Descriptor" + for more information about Extended Interrupt Resource Data. + + The Extended Interrupt contains one single interrupt. + + This function allocates memory to create a data node. It is the caller's + responsibility to either: + - attach this node to an AML tree; + - delete this node. + + Note: The _CRS node must be defined using the ASL Name () function. + e.g. Name (_CRS, ResourceTemplate () { + ... + } + + @param [in] NameOpCrsNode NameOp object node defining a "_CRS" object. + Must have an OpCode=AML_NAME_OP, SubOpCode=0. + NameOp object nodes are defined in ASL + using the "Name ()" function. + @param [in] ResourceConsumer The device consumes the specified interrupt + or produces it for use by a child device. + @param [in] EdgeTriggered The interrupt is edge triggered or + level triggered. + @param [in] ActiveLow The interrupt is active-high or active-low. + @param [in] Shared The interrupt can be shared with other + devices or not (Exclusive). + @param [in] IrqList Interrupt list. Must be non-NULL. + @param [in] IrqCount Interrupt count. Must be non-zero. + + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Could not allocate memory. +**/ +EFI_STATUS +EFIAPI +AmlCodeGenCrsAddRdInterrupt ( + IN AML_OBJECT_NODE_HANDLE NameOpCrsNode, + IN BOOLEAN ResourceConsumer, + IN BOOLEAN EdgeTriggered, + IN BOOLEAN ActiveLow, + IN BOOLEAN Shared, + IN UINT32 * IrqList, + IN UINT8 IrqCount + ) +{ + EFI_STATUS Status; + + AML_OBJECT_NODE_HANDLE BufferOpNode; + + if ((IrqList == NULL) || + (IrqCount == 0) || + (!AmlNodeHasOpCode (NameOpCrsNode, AML_NAME_OP, 0)) || + (!AmlNameOpCompareName (NameOpCrsNode, "_CRS"))) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + // Get the _CRS value which is represented as a BufferOp object node + // which is the 2nd fixed argument (i.e. index 1). + BufferOpNode = (AML_OBJECT_NODE_HANDLE)AmlGetFixedArgument ( + NameOpCrsNode, + EAmlParseIndexTerm1 + ); + if ((BufferOpNode == NULL) || + (AmlGetNodeType ((AML_NODE_HANDLE)BufferOpNode) != EAmlNodeObject) || + (!AmlNodeHasOpCode (BufferOpNode, AML_BUFFER_OP, 0))) { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + // Generate the Extended Interrupt Resource Data node, + // and attach it as the last variable argument of the BufferOpNode. + Status = AmlCodeGenInterrupt ( + ResourceConsumer, + EdgeTriggered, + ActiveLow, + Shared, + IrqList, + IrqCount, + BufferOpNode, + NULL + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + } + + return Status; +} diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.h b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.h new file mode 100644 index 0000000000000000000000000000000000000000..08364db4431f8d41c70f220ee7417453ceb2496d --- /dev/null +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.h @@ -0,0 +1,59 @@ +/** @file + AML Resource Data Code Generation. + + Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#ifndef AML_RESOURCE_DATA_CODE_GEN_H_ +#define AML_RESOURCE_DATA_CODE_GEN_H_ + +/** Code generation for the "Interrupt ()" ASL function. + + This function creates a Resource Data element corresponding to the + "Interrupt ()" ASL function and stores it in an AML Data Node. + + The Resource Data effectively created is an Extended Interrupt Resource + Data. See ACPI 6.3 specification, s6.4.3.6 "Extended Interrupt Descriptor" + for more information about Extended Interrupt Resource Data. + + This function allocates memory to create a data node. It is the caller's + responsibility to either: + - attach this node to an AML tree; + - delete this node. + + @param [in] ResourceConsumer The device consumes the specified interrupt + or produces it for use by a child device. + @param [in] EdgeTriggered The interrupt is edge triggered or + level triggered. + @param [in] ActiveLow The interrupt is active-high or active-low. + @param [in] Shared The interrupt can be shared with other + devices or not (Exclusive). + @param [in] IrqList Interrupt list. Must be non-NULL. + @param [in] IrqCount Interrupt count. Must be non-zero. + @param [in] ParentNode If not NULL, add the generated node + to the end of the variable list of + argument of the ParentNode, but + before the "End Tag" Resource Data. + Must be a BufferOpNode. + @param [out] NewRdNode If success, contains the generated node. + + @retval EFI_SUCCESS The function completed successfully. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Could not allocate memory. +**/ +EFI_STATUS +EFIAPI +AmlCodeGenInterrupt ( + IN BOOLEAN ResourceConsumer, + IN BOOLEAN EdgeTriggered, + IN BOOLEAN ActiveLow, + IN BOOLEAN Shared, + IN UINT32 * IrqList, + IN UINT8 IrqCount, + IN AML_OBJECT_NODE * ParentNode, OPTIONAL + OUT AML_DATA_NODE ** NewRdNode OPTIONAL + ); + +#endif // AML_RESOURCE_DATA_CODE_GEN_H_ -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'