From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 3BD94740039 for ; Thu, 21 Sep 2023 20:07:37 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=2ILNxG2eJ1oCqu/edD3uvNVfEqONtoMOZrIAhEFCWnQ=; c=relaxed/simple; d=groups.io; h=Received-SPF:ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:Authentication-Results-Original:nodisclaimer:MIME-Version:Original-Authentication-Results:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type; s=20140610; t=1695326855; v=1; b=CaRrbeqTjvt7ofp6y4IVl/7FTOACw+yrSrgMAQnbE+Sqfz95Mn0/hXMVCqFiigfgrBJVFH7G NqeQ3XLm2kbaG0FtX9Tm+BWz6j48nZDY01hwpB84RQVTQyTqaupqWfmMh1qr7F3+1y4H54wL1oT a/Zg7avszIyAKLeDSItdPuoQ= X-Received: by 127.0.0.2 with SMTP id SwcNYY7687511xYwGrtTLAxP; Thu, 21 Sep 2023 13:07:35 -0700 X-Received: from EUR02-VI1-obe.outbound.protection.outlook.com (EUR02-VI1-obe.outbound.protection.outlook.com [40.107.241.45]) by mx.groups.io with SMTP id smtpd.web11.5936.1695326853686669166 for ; Thu, 21 Sep 2023 13:07:34 -0700 X-Received: from AM6P192CA0044.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:82::21) by VE1PR08MB5712.eurprd08.prod.outlook.com (2603:10a6:800:1a8::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.28; Thu, 21 Sep 2023 20:07:27 +0000 X-Received: from AM7EUR03FT031.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:82:cafe::7b) by AM6P192CA0044.outlook.office365.com (2603:10a6:209:82::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.30 via Frontend Transport; Thu, 21 Sep 2023 20:07:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass 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; pr=C X-Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT031.mail.protection.outlook.com (100.127.140.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.20 via Frontend Transport; Thu, 21 Sep 2023 20:07:27 +0000 X-Received: ("Tessian outbound 169aaa6bf2b7:v175"); Thu, 21 Sep 2023 20:07:27 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 7cb15384a908e0e2 X-CR-MTA-TID: 64aa7808 X-Received: from 4a9e469def7a.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id C9FD4FB7-FD80-4F6A-B51D-2F5EDF3C8C29.1; Thu, 21 Sep 2023 20:07:17 +0000 X-Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 4a9e469def7a.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 21 Sep 2023 20:07:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aBI1dRe+JcrWJdZxM4XkFrKDF2kOH9wxPKWeriBqNtDm/dxVFQ3wMltyh4x/IVDKkAD2Kaf0g66vJzkGJFL4r+pNQT26ZN1SViu17Tpt+K/5ROHkCbJDQ9+s+JtR0ubCR2Z6/3ttZeACp/W+QiWZlqnG2LlK/6w6ns8oxyvIeISNAkijZPmXIbh6fv6EPCaRqjdtbwA+gY94oDjiCJCTr62mbOu+TcktmSjYlOVwgL2MnzIsRc2wK29vUCfFKhTK2uo2vdoWThwUshxnXYRQ1zduHcqZEIuduEh+cLMZf+EGAA6TztABYzxMTCDtusWdeiLjridi/+CEBoL1qwAogQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KrwYAyGccDdmyZo7NoYqG+GbvebwMgHqevs3uZcaGJY=; b=kH675DT32bGpJV7iwHPyxscnZrz9x0lFM0mc1iN0qnZaQq0RwFFfFgW9LUIuze08PnwYgcfgJ1QD/TXtypr/sZt2na6NuyvrSmMdpKOA8KsilMGolgCVLcmrNzAWKc4zxUlCVuIJ2QZ+9YhO5KaiNMsqr4DzLFkRHrzIFhTnTY0dgZ273L4aTErD1dZeYW3KhYxyagekeboqyAZanmrqm6ZUzRaQ82ecwXs/tlWif6B8PY40C6Pu2CTwWwVeMCLCUdKgh1hDgPae/xh4CYNDNAn9D7OmMYaFh7l6uvewL/CZ5P9FVkqlazx4RKADcVzIxfjuLtkCLywD+cDnlox++g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none X-Received: from PAXPR08MB6813.eurprd08.prod.outlook.com (2603:10a6:102:15f::10) by GV2PR08MB8677.eurprd08.prod.outlook.com (2603:10a6:150:b9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27; Thu, 21 Sep 2023 20:07:13 +0000 X-Received: from PAXPR08MB6813.eurprd08.prod.outlook.com ([fe80::bb60:6578:6a9a:fadd]) by PAXPR08MB6813.eurprd08.prod.outlook.com ([fe80::bb60:6578:6a9a:fadd%4]) with mapi id 15.20.6792.021; Thu, 21 Sep 2023 20:07:12 +0000 From: "Sami Mujawar" To: "Jeff Brasen (jbrasen@nvidia.com)" , "devel@edk2.groups.io" CC: Pierre Gondois , Swatisri Kantamsetti , Ashish Singhal , nd Subject: Re: [edk2-devel] [PATCH v4 2/4] DynamicTablesPkg: Add support for simple method invocation. Thread-Topic: [PATCH v4 2/4] DynamicTablesPkg: Add support for simple method invocation. Thread-Index: AQHZ7KuUm7vAdASyqkiRRuvMIGFGzrAli2gAgAApJz8= Date: Thu, 21 Sep 2023 20:07:12 +0000 Message-ID: References: <737650480edcab199927322064b2459f647f9f02.1695049337.git.jbrasen@nvidia.com> <885016b1-c8f3-8951-8473-15a37cd640a2@arm.com> In-Reply-To: Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-traffictypediagnostic: PAXPR08MB6813:EE_|GV2PR08MB8677:EE_|AM7EUR03FT031:EE_|VE1PR08MB5712:EE_ X-MS-Office365-Filtering-Correlation-Id: 3d29d02a-88d1-40f2-1c8a-08dbbade60ed x-ld-processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-checkrecipientrouted: true nodisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: uGu6gjBB/wxcMcVHA1hvaf8RHjYBvo7Vsq0YUqsRbRNrIDZl34Cg+3/5BLRBJoI+jTohLImetUqTKBYRF92U14cYyrFQUXMlU/synsS/5uQJ9Qb9VyTR64cWq7Ksnavur8TrXywdYEIhZO2VhXnSHy5k+g6bxLMkmOKBMQ51cs7tAJvihITb09QWFqx5yKXy6b7KA8hATVJmzxXnsubsB7HdfUSoFDgdIuSfSuaPfmyZaMeMovV0yhCT110ILkioGcMr2z8rk+9mEp6EZhGkRPtwx9gjL+i+J+TfVBsGhIkOrP+SyWXOMUct9H1L7tyKClyUGWyQbPHnaXw8AJ+ZQngBYUsif5dqjIPwYPznLIfD5lo0Kh50XKq+aqDdoIDXCoXAoncdBdcsxtWZzkX+06MtD9Z/mk+Siz5jC7bsTqU/8Gc7KYgpO6RlLDyyo3BHXQVJRd9XJ1NxFHODknsS76dES2i6FVZpuY/5L/fAJJV/69ye9Pe1ArU1gHLITTPni8GJo6krCy2p9rfUT+JcBXRdS1Ffr5fAfkzO2x5f13Vr+yYoRfPSw4zM8K+fDyYeRwW5A1UarDJWILY54IJHi2h9qnorppw48E5WaLFB6pIVuoE0Yf+XZE9rXthsr0Zp X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR08MB6813.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(396003)(376002)(346002)(366004)(136003)(451199024)(1800799009)(186009)(5660300002)(7696005)(6506007)(53546011)(86362001)(54906003)(9686003)(66446008)(66556008)(66946007)(76116006)(38070700005)(41300700001)(66476007)(64756008)(38100700002)(91956017)(71200400001)(110136005)(478600001)(316002)(55016003)(8676002)(30864003)(8936002)(52536014)(2906002)(33656002)(4326008)(122000001)(83380400001)(579004)(559001);DIR:OUT;SFP:1101; MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8677 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT031.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 611d8186-f837-4511-d023-08dbbade580f X-Microsoft-Antispam-Message-Info: bFX4ZVwGBZm/Xs1YHWLdnLgwh9ZZEhzhAmOc5BwRu4sj2xZ3dj8uPyRLJVtediAu3SugpGXcZ4f7REq/dl8UbiT331zNAP7JTAtA131bvHLSfx0t6YrlkG6baTwQOYvFf4kXwPMkslNtgGtVpYgKP8Zh3kZyjgVmgJn4WG7x0ojwPlXecG43Cr+iEVtYjfh/MCwzNWOpdGsZHPpqIHLXWlytsJxuicDOcEP+uCvRya+QYBbE+CHIuqWN/Yq8j6PDlfNdrV6Sp8QsvzOoqAzwnNJcAagG2D+G7n0TPqWvE0vnXfjmRyxIELqOU/MWdG+qPbJsoa/njybKTtAocRz9XLyF0YignIxmsEyVc/5lEvtffw9sFpjMjMvXUTFZ96a7pIIWV43t08OJPFNpEnDzS0PtL1VoxR+RqUAiZf+2KaeegCZ7dc5urPm9ilkTJS1T/M4B9574GscPIT/sYW+aPqxXdlBNdKNOaD5Wh2rEs/irk2U0iKAMABQQoiHIH2pH8Nf9jqqFjvZx6KLkPSSC6F8cfeSk2H5rRCdGTuqIssr7iT8QXjQfqXiyNki5mfmLbohUBiauiMcZjOsl5lL7+yRHHl2eoul8lRNSPgVzaVTSxSvSDliA6UUarkfcN8yIp4FXvmzeFIk/NThh9zrud9Mnj11/JGlP6bXiiRUDSTZgRn6K+2K/E2qWf7KSK6EGY4drbo9FDnGGWx4CF+iAEHCRHWft8AATwE+kTDhUWY/KA3sQibXZ24pngLwiAvWkdiD5g9suZwA3J/40ZMcVpw== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Sep 2023 20:07:27.3934 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3d29d02a-88d1-40f2-1c8a-08dbbade60ed 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: AM7EUR03FT031.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5712 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 Reply-To: devel@edk2.groups.io,sami.mujawar@arm.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 1je9NYvb9EsRFLIxWr0tfm8Ax7686176AA= Content-Language: en-GB Content-Type: multipart/alternative; boundary="_000_PAXPR08MB6813725255B4DCF597B65CA784F8APAXPR08MB6813eurp_" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=CaRrbeqT; 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 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") --_000_PAXPR08MB6813725255B4DCF597B65CA784F8APAXPR08MB6813eurp_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Hi Jeff, Yes, I recorded the integer node and data node creation. Regards, Sami Mujawar ________________________________ From: Jeff Brasen Sent: 21 September 2023 18:38 To: Sami Mujawar ; devel@edk2.groups.io Cc: Pierre Gondois ; Swatisri Kantamsetti ; Ashish Singhal ; nd Subject: RE: [PATCH v4 2/4] DynamicTablesPkg: Add support for simple method= invocation. Only thing I see is if AmlCodeGenInteger fails we don=92t delete DataNode r= ight? From: Sami Mujawar Sent: Thursday, September 21, 2023 10:49 AM To: Jeff Brasen ; devel@edk2.groups.io Cc: pierre.gondois@arm.com; Swatisri Kantamsetti ; As= hish Singhal ; nd@arm.com Subject: Re: [PATCH v4 2/4] DynamicTablesPkg: Add support for simple method= invocation. External email: Use caution opening links or attachments Hi Jeff, Thank you for this patch. Please see my response inline marked [SAMI]. Regards, Sami Mujawar On 18/09/2023 04:46 pm, Jeff Brasen wrote: Add support to add Return objects via AML that pass a single integer argument to the named method. Signed-off-by: Jeff Brasen --- .../Include/Library/AmlLib/AmlLib.h | 54 ++++ .../Common/AmlLib/CodeGen/AmlCodeGen.c | 244 ++++++++++++++++++ 2 files changed, 298 insertions(+) diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTabl= esPkg/Include/Library/AmlLib/AmlLib.h index d201ae9499..b82c7a3ce8 100644 --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h @@ -1194,6 +1194,60 @@ AmlCodeGenMethodRetInteger ( OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL ); +/** AML code generation for a method returning a NameString that takes an + integer argument. + + AmlCodeGenMethodRetNameStringIntegerArgument ( + "MET0", "MET1", 1, TRUE, 3, 5, ParentNode, NewObjectNode + ); + is equivalent of the following ASL code: + Method(MET0, 1, Serialized, 3) { + Return (MET1 (5)) + } + + The ASL parameters "ReturnType" and "ParameterTypes" are not asked + in this function. They are optional parameters in ASL. + + @param [in] MethodNameString The new Method's name. + Must be a NULL-terminated ASL NameStri= ng + e.g.: "MET0", "_SB.MET0", etc. + The input string is copied. + @param [in] ReturnedNameString The name of the object returned by the + method. Optional parameter, can be: + - NULL (ignored). + - A NULL-terminated ASL NameString. + e.g.: "MET0", "_SB.MET0", etc. + The input string is copied. + @param [in] NumArgs Number of arguments. + Must be 0 <=3D NumArgs <=3D 6. + @param [in] IsSerialized TRUE is equivalent to Serialized. + FALSE is equivalent to NotSerialized. + Default is NotSerialized in ASL spec. + @param [in] SyncLevel Synchronization level for the method. + Must be 0 <=3D SyncLevel <=3D 15. + Default is 0 in ASL. + @param [in] IntegerArgument Argument to pass to the NameString. + @param [in] ParentNode If provided, set ParentNode as the par= ent + of the node created. + @param [out] NewObjectNode If success, contains the created node. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +EFI_STATUS +EFIAPI +AmlCodeGenMethodRetNameStringIntegerArgument ( + IN CONST CHAR8 *MethodNameString, + IN CONST CHAR8 *ReturnedNameString OPTIONAL, + IN UINT8 NumArgs, + IN BOOLEAN IsSerialized, + IN UINT8 SyncLevel, + IN UINT64 IntegerArgument, + IN AML_NODE_HANDLE ParentNode OPTIONAL, + OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL + ); + /** Create a _LPI name. AmlCreateLpiNode ("_LPI", 0, 1, ParentNode, &LpiNode) is diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/= DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c index 88537b7e2d..ea519d1aa8 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c @@ -1881,6 +1881,138 @@ AmlCodeGenReturnInteger ( return Status; } +/** AML code generation for a Return object node, + returning the object as an input NameString with a integer argument. + + AmlCodeGenReturn ("NAM1", 6, ParentNode, NewObjectNode) is + equivalent of the following ASL code: + Return(NAM1 (6)) + + The ACPI 6.3 specification, s20.2.5.3 "Type 1 Opcodes Encoding" states: + DefReturn :=3D ReturnOp ArgObject + ReturnOp :=3D 0xA4 + ArgObject :=3D TermArg =3D> DataRefObject + + Thus, the ReturnNode must be evaluated as a DataRefObject. It can + be a NameString referencing an object. As this CodeGen Api doesn't + do semantic checking, it is strongly advised to check the AML bytecode + generated by this function against an ASL compiler. + + The ReturnNode must be generated inside a Method body scope. + + @param [in] NameString The object referenced by this NameString + is returned by the Return ASL statement. + Must be a NULL-terminated ASL NameString + e.g.: "NAM1", "_SB.NAM1", etc. + The input string is copied. + @param [in] Integer Argument to pass to the NameString + @param [in] ParentNode If provided, set ParentNode as the parent + of the node created. + Must be a MethodOp node. + @param [out] NewObjectNode If success, contains the created node. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +STATIC +EFI_STATUS +EFIAPI +AmlCodeGenReturnNameStringIntegerArgument ( + IN CONST CHAR8 *NameString, + IN UINT64 Integer, + IN AML_NODE_HEADER *ParentNode OPTIONAL, + OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL + ) +{ + EFI_STATUS Status; + AML_DATA_NODE *DataNode; + AML_OBJECT_NODE *IntNode; + CHAR8 *AmlNameString; + UINT32 AmlNameStringSize; + AML_OBJECT_NODE *ObjectNode; + + DataNode =3D NULL; + IntNode =3D NULL; + ObjectNode =3D NULL; + + Status =3D ConvertAslNameToAmlName (NameString, &AmlNameString); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + Status =3D AmlGetNameStringSize (AmlNameString, &AmlNameStringSize); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto exit_handler; + } + + Status =3D AmlCreateDataNode ( + EAmlNodeDataTypeNameString, + (UINT8 *)AmlNameString, + AmlNameStringSize, + &DataNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto exit_handler; + } + + Status =3D AmlCodeGenInteger (Integer, &IntNode); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto exit_handler; + } + + // AmlCodeGenReturn() deletes DataNode if error. + Status =3D AmlCodeGenReturn ( + (AML_NODE_HEADER *)DataNode, + ParentNode, + &ObjectNode + ); + + // DataNode is either deleted or added to ObjectNode, set to NULL so we = don't + // delete it again + DataNode =3D NULL; + if (EFI_ERROR (Status)) { + ASSERT (0); + goto exit_handler; + } + + Status =3D AmlVarListAddTail ( + (AML_NODE_HANDLE)ObjectNode, + (AML_NODE_HANDLE)IntNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto exit_handler; + } + + if (NewObjectNode !=3D 0) { + *NewObjectNode =3D ObjectNode; + } + +exit_handler: + if (AmlNameString !=3D NULL) { + FreePool (AmlNameString); + } + + if (IntNode !=3D NULL) { + AmlDeleteTree ((AML_NODE_HANDLE)IntNode); + } + + if (DataNode !=3D NULL) { + AmlDeleteTree ((AML_NODE_HANDLE)DataNode); + } + + if (ObjectNode !=3D NULL) { + AmlDeleteTree ((AML_NODE_HANDLE)ObjectNode); + } + + return Status; +} [SAMI] I think the error handling in the above function can be simplified a= s below: ... STATIC EFI_STATUS EFIAPI AmlCodeGenReturnNameStringIntegerArgument ( IN CONST CHAR8 *NameString, IN UINT64 Integer, IN AML_NODE_HEADER *ParentNode OPTIONAL, OUT AML_OBJECT_NODE **NewObjectNode OPTIONAL ) { EFI_STATUS Status; AML_DATA_NODE *DataNode; AML_OBJECT_NODE *IntNode; CHAR8 *AmlNameString; UINT32 AmlNameStringSize; AML_OBJECT_NODE *ObjectNode; DataNode =3D NULL; IntNode =3D NULL; ObjectNode =3D NULL; Status =3D ConvertAslNameToAmlName (NameString, &AmlNameString); if (EFI_ERROR (Status)) { ASSERT (0); return Status; } Status =3D AmlGetNameStringSize (AmlNameString, &AmlNameStringSize); if (EFI_ERROR (Status)) { ASSERT (0); goto exit_handler; } Status =3D AmlCodeGenInteger (Integer, &IntNode); if (EFI_ERROR (Status)) { ASSERT (0); goto exit_handler; } Status =3D AmlCreateDataNode ( EAmlNodeDataTypeNameString, (UINT8 *)AmlNameString, AmlNameStringSize, &DataNode ); if (EFI_ERROR (Status)) { ASSERT (0); goto exit_handler1; } // AmlCodeGenReturn() deletes DataNode if error. Status =3D AmlCodeGenReturn ( (AML_NODE_HEADER *)DataNode, ParentNode, &ObjectNode ); if (EFI_ERROR (Status)) { ASSERT (0); goto exit_handler1; } Status =3D AmlVarListAddTail ( (AML_NODE_HANDLE)ObjectNode, (AML_NODE_HANDLE)IntNode ); if (EFI_ERROR (Status)) { // ObjectNode is already attached to ParentNode in AmlCodeGenReturn(), // so no need to free it here, it will be deleted when deleting the // ParentNode tree ASSERT (0); goto exit_handler1; } if (NewObjectNode !=3D 0) { *NewObjectNode =3D ObjectNode; } goto exit_handler; exit_handler1: if (IntNode !=3D NULL) { AmlDeleteTree ((AML_NODE_HANDLE)IntNode); } exit_handler: if (AmlNameString !=3D NULL) { FreePool (AmlNameString); } return Status; } Please let me know if you agree with this, and I will make this change befo= re merging. [/SAMI] + /** AML code generation for a method returning a NameString. AmlCodeGenMethodRetNameString ( @@ -1989,6 +2121,118 @@ error_handler: return Status; } +/** AML code generation for a method returning a NameString that takes an + integer argument. + + AmlCodeGenMethodRetNameStringIntegerArgument ( + "MET0", "MET1", 1, TRUE, 3, 5, ParentNode, NewObjectNode + ); + is equivalent of the following ASL code: + Method(MET0, 1, Serialized, 3) { + Return (MET1 (5)) + } + + The ASL parameters "ReturnType" and "ParameterTypes" are not asked + in this function. They are optional parameters in ASL. + + @param [in] MethodNameString The new Method's name. + Must be a NULL-terminated ASL NameStri= ng + e.g.: "MET0", "_SB.MET0", etc. + The input string is copied. + @param [in] ReturnedNameString The name of the object returned by the + method. Optional parameter, can be: + - NULL (ignored). + - A NULL-terminated ASL NameString. + e.g.: "MET0", "_SB.MET0", etc. + The input string is copied. + @param [in] NumArgs Number of arguments. + Must be 0 <=3D NumArgs <=3D 6. + @param [in] IsSerialized TRUE is equivalent to Serialized. + FALSE is equivalent to NotSerialized. + Default is NotSerialized in ASL spec. + @param [in] SyncLevel Synchronization level for the method. + Must be 0 <=3D SyncLevel <=3D 15. + Default is 0 in ASL. + @param [in] IntegerArgument Argument to pass to the NameString. + @param [in] ParentNode If provided, set ParentNode as the par= ent + of the node created. + @param [out] NewObjectNode If success, contains the created node. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Invalid parameter. + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. +**/ +EFI_STATUS +EFIAPI +AmlCodeGenMethodRetNameStringIntegerArgument ( + IN CONST CHAR8 *MethodNameString, + IN CONST CHAR8 *ReturnedNameString OPTIONAL, + IN UINT8 NumArgs, + IN BOOLEAN IsSerialized, + IN UINT8 SyncLevel, + IN UINT64 IntegerArgument, + IN AML_NODE_HANDLE ParentNode OPTIONAL, + OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL + ) +{ + EFI_STATUS Status; + AML_OBJECT_NODE_HANDLE MethodNode; + + if ((MethodNameString =3D=3D NULL) || + ((ParentNode =3D=3D NULL) && (NewObjectNode =3D=3D NULL))) + { + ASSERT (0); + return EFI_INVALID_PARAMETER; + } + + // Create a Method named MethodNameString. + Status =3D AmlCodeGenMethod ( + MethodNameString, + NumArgs, + IsSerialized, + SyncLevel, + NULL, + &MethodNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + return Status; + } + + // Return ReturnedNameString if provided. + if (ReturnedNameString !=3D NULL) { + Status =3D AmlCodeGenReturnNameStringIntegerArgument ( + ReturnedNameString, + IntegerArgument, + (AML_NODE_HANDLE)MethodNode, + NULL + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + } + + Status =3D LinkNode ( + MethodNode, + ParentNode, + NewObjectNode + ); + if (EFI_ERROR (Status)) { + ASSERT (0); + goto error_handler; + } + + return Status; + +error_handler: + if (MethodNode !=3D NULL) { + AmlDeleteTree ((AML_NODE_HANDLE)MethodNode); + } + + return Status; +} + /** AML code generation for a method returning an Integer. AmlCodeGenMethodRetInteger ( -=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 (#108968): https://edk2.groups.io/g/devel/message/108968 Mute This Topic: https://groups.io/mt/101436335/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- --_000_PAXPR08MB6813725255B4DCF597B65CA784F8APAXPR08MB6813eurp_ Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable
Hi Jeff,

Yes, I recorded the integer node and data node creation.

Regards,

Sami Mujawar



From: Jeff Brasen <jbras= en@nvidia.com>
Sent: 21 September 2023 18:38
To: Sami Mujawar <Sami.Mujawar@arm.com>; devel@edk2.groups.io = <devel@edk2.groups.io>
Cc: Pierre Gondois <Pierre.Gondois@arm.com>; Swatisri Kantamse= tti <swatisrik@nvidia.com>; Ashish Singhal <ashishsingha@nvidia.co= m>; nd <nd@arm.com>
Subject: RE: [PATCH v4 2/4] DynamicTablesPkg: Add support for simple= method invocation.
 

Only thing I see is if AmlCodeGenInteger fails we don=92t delete DataNode r= ight?

 

From: Sami Mujawar <sami.mujawar@arm.com>
Sent: Thursday, September 21, 2023 10:49 AM
To: Jeff Brasen <jbrasen@nvidia.com>; devel@edk2.groups.io
Cc: pierre.gondois@arm.com; Swatisri Kantamsetti <swatisrik@nvidi= a.com>; Ashish Singhal <ashishsingha@nvidia.com>; nd@arm.com
Subject: Re: [PATCH v4 2/4] DynamicTablesPkg: Add support for simple= method invocation.

 

External email: Use caution opening links or attachments

 

Hi Jeff,

Thank you for this patch.

Please see my response inline marked [SAMI].

Regards,

Sami Mujawar

On 18/09/2023 04:46 pm, Jeff Brasen wrote:

Add support to add Return objects via AML that pass a single intege=
r
 
argument to the named method.
 
 
 
Signed-off-by: Jeff Brasen &l=
t;jbrasen@nvidia.com>
 
---
 
 .../Include/Library/AmlLib/AmlLib.h     &=
nbsp;     |  54 ++++
 
 .../Common/AmlLib/CodeGen/AmlCodeGen.c    &nbs=
p;   | 244 ++++++++++++++++++
 
 2 files changed, 298 insertions(+)
 
 
 
diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/Dyn=
amicTablesPkg/Include/Library/AmlLib/AmlLib.h
 
index d201ae9499..b82c7a3ce8 100644
 
--- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
 
+++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h
 
@@ -1194,6 +1194,60 @@ AmlCodeGenMethodRetInteger (
 
   OUT       AML_OBJECT_NOD=
E_HANDLE  *NewObjectNode        OPT=
IONAL
 
   );
 
 
 
+/** AML code generation for a method returning a NameString that t=
akes an
 
+    integer argument.
 
+
 
+  AmlCodeGenMethodRetNameStringIntegerArgument (
 
+    "MET0", "MET1", 1, TRUE, 3,=
 5, ParentNode, NewObjectNode
 
+    );
 
+  is equivalent of the following ASL code:
 
+    Method(MET0, 1, Serialized, 3) {
 
+      Return (MET1 (5))
 
+    }
 
+
 
+  The ASL parameters "ReturnType" and "Paramet=
erTypes" are not asked
 
+  in this function. They are optional parameters in ASL.
 
+
 
+  @param [in]  MethodNameString     =
The new Method's name.
 
+           =
            &nb=
sp;            Must =
be a NULL-terminated ASL NameString
 
+           =
            &nb=
sp;            e.g.:=
 "MET0", "_SB.MET0", etc.
 
+           =
            &nb=
sp;            The i=
nput string is copied.
 
+  @param [in]  ReturnedNameString   The name o=
f the object returned by the
 
+           =
            &nb=
sp;            metho=
d. Optional parameter, can be:
 
+           =
            &nb=
sp;            =
 - NULL (ignored).
 
+           =
            &nb=
sp;            =
 - A NULL-terminated ASL NameString.
 
+           =
            &nb=
sp;            =
   e.g.: "MET0", "_SB.MET0", etc.
 
+            =
;            &n=
bsp;            =
;  The input string is copied.
 
+  @param [in]  NumArgs     &nbs=
p;        Number of arguments.
 
+           =
            &nb=
sp;            Must =
be 0 <=3D NumArgs <=3D 6.
 
+  @param [in]  IsSerialized     =
;    TRUE is equivalent to Serialized.
 
+           =
            &nb=
sp;            FALSE=
 is equivalent to NotSerialized.
 
+           =
            &nb=
sp;            Defau=
lt is NotSerialized in ASL spec.
 
+  @param [in]  SyncLevel     &n=
bsp;      Synchronization level for the method.
 
+           =
            &nb=
sp;            Must =
be 0 <=3D SyncLevel <=3D 15.
 
+           =
            &nb=
sp;            Defau=
lt is 0 in ASL.
 
+  @param [in]  IntegerArgument    &n=
bsp; Argument to pass to the NameString.
 
+  @param [in]  ParentNode     &=
nbsp;     If provided, set ParentNode as the parent
 
+           =
            &nb=
sp;            of th=
e node created.
 
+  @param [out] NewObjectNode     &nb=
sp;  If success, contains the created node.
 
+
 
+  @retval EFI_SUCCESS      &nbs=
p;      Success.
 
+  @retval EFI_INVALID_PARAMETER   Invalid parameter=
.
 
+  @retval EFI_OUT_OF_RESOURCES    Failed to al=
locate memory.
 
+**/
 
+EFI_STATUS
 
+EFIAPI
 
+AmlCodeGenMethodRetNameStringIntegerArgument (
 
+  IN  CONST CHAR8      &nb=
sp;            *Meth=
odNameString,
 
+  IN  CONST CHAR8      &nb=
sp;            *Retu=
rnedNameString   OPTIONAL,
 
+  IN        UINT8 &nb=
sp;            =
     NumArgs,
 
+  IN        BOOLEAN &=
nbsp;           &nbs=
p;   IsSerialized,
 
+  IN        UINT8 &nb=
sp;            =
     SyncLevel,
 
+  IN        UINT64 &n=
bsp;            =
;    IntegerArgument,
 
+  IN        AML_NODE_HANDL=
E         ParentNode  &nb=
sp;        OPTIONAL,
 
+  OUT       AML_OBJECT_NODE_HAN=
DLE  *NewObjectNode        OPTIONAL=
 
+  );
 
+
 
 /** Create a _LPI name.
 
 
 
   AmlCreateLpiNode ("_LPI", 0, 1, ParentNode, =
&LpiNode) is
 
diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCode=
Gen.c b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
 
index 88537b7e2d..ea519d1aa8 100644
 
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
 
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c
 
@@ -1881,6 +1881,138 @@ AmlCodeGenReturnInteger (
 
   return Status;
 
 }
 
 
 
+/** AML code generation for a Return object node,
 
+    returning the object as an input NameString wit=
h a integer argument.
 
+
 
+  AmlCodeGenReturn ("NAM1", 6, ParentNode, NewObjec=
tNode) is
 
+  equivalent of the following ASL code:
 
+    Return(NAM1 (6))
 
+
 
+  The ACPI 6.3 specification, s20.2.5.3 "Type 1 Opcodes =
Encoding" states:
 
+    DefReturn :=3D ReturnOp ArgObject
 
+    ReturnOp :=3D 0xA4
 
+    ArgObject :=3D TermArg =3D> DataRefObject
 
+
 
+  Thus, the ReturnNode must be evaluated as a DataRefObject. =
It can
 
+  be a NameString referencing an object. As this CodeGen Api =
doesn't
 
+  do semantic checking, it is strongly advised to check the A=
ML bytecode
 
+  generated by this function against an ASL compiler.
 
+
 
+  The ReturnNode must be generated inside a Method body scope=
.
 
+
 
+  @param [in]  NameString     The ob=
ject referenced by this NameString
 
+           =
            &nb=
sp;      is returned by the Return ASL statement.<=
/pre>
 
+           =
            &nb=
sp;      Must be a NULL-terminated ASL NameString<=
/pre>
 
+           =
            &nb=
sp;      e.g.: "NAM1", "_SB.NAM1&qu=
ot;, etc.
 
+            =
;            &n=
bsp;     The input string is copied.
 
+  @param [in]  Integer     &nbs=
p;  Argument to pass to the NameString
 
+  @param [in]  ParentNode     If pro=
vided, set ParentNode as the parent
 
+           =
            &nb=
sp;      of the node created.
 
+            =
;            &n=
bsp;     Must be a MethodOp node.
 
+  @param [out] NewObjectNode  If success, contains the c=
reated node.
 
+
 
+  @retval EFI_SUCCESS      &nbs=
p;      Success.
 
+  @retval EFI_INVALID_PARAMETER   Invalid parameter=
.
 
+  @retval EFI_OUT_OF_RESOURCES    Failed to al=
locate memory.
 
+**/
 
+STATIC
 
+EFI_STATUS
 
+EFIAPI
 
+AmlCodeGenReturnNameStringIntegerArgument (
 
+  IN  CONST CHAR8      &nb=
sp;     *NameString,
 
+  IN        UINT64 &n=
bsp;         Integer,
 
+  IN        AML_NODE_HEADE=
R  *ParentNode      OPTIONAL,
 
+  OUT       AML_OBJECT_NODE&nbs=
p; **NewObjectNode   OPTIONAL
 
+  )
 
+{
 
+  EFI_STATUS       Status;
 
+  AML_DATA_NODE    *DataNode;
 
+  AML_OBJECT_NODE  *IntNode;
 
+  CHAR8         =
   *AmlNameString;
 
+  UINT32         =
;  AmlNameStringSize;
 
+  AML_OBJECT_NODE  *ObjectNode;
 
+
 
+  DataNode   =3D NULL;
 
+  IntNode    =3D NULL;
 
+  ObjectNode =3D NULL;
 
+
 
+  Status =3D ConvertAslNameToAmlName (NameString, &AmlNam=
eString);
 
+  if (EFI_ERROR (Status)) {
 
+    ASSERT (0);
 
+    return Status;
 
+  }
 
+
 
+  Status =3D AmlGetNameStringSize (AmlNameString, &AmlNam=
eStringSize);
 
+  if (EFI_ERROR (Status)) {
 
+    ASSERT (0);
 
+    goto exit_handler;
 
+  }
 
+
 
+  Status =3D AmlCreateDataNode (
 
+           =
  EAmlNodeDataTypeNameString,
 
+           =
  (UINT8 *)AmlNameString,
 
+           =
  AmlNameStringSize,
 
+           =
  &DataNode
 
+           =
  );
 
+  if (EFI_ERROR (Status)) {
 
+    ASSERT (0);
 
+    goto exit_handler;
 
+  }
 
+
 
+  Status =3D AmlCodeGenInteger (Integer, &IntNode);
 
+  if (EFI_ERROR (Status)) {
 
+    ASSERT (0);
 
+    goto exit_handler;
 
+  }
 
+
 
+  // AmlCodeGenReturn() deletes DataNode if error.
 
+  Status =3D AmlCodeGenReturn (
 
+           =
  (AML_NODE_HEADER *)DataNode,
 
+           =
  ParentNode,
 
+           =
  &ObjectNode
 
+           =
  );
 
+
 
+  // DataNode is either deleted or added to ObjectNode, set t=
o NULL so we don't
 
+  // delete it again
 
+  DataNode =3D NULL;
 
+  if (EFI_ERROR (Status)) {
 
+    ASSERT (0);
 
+    goto exit_handler;
 
+  }
 
+
 
+  Status =3D AmlVarListAddTail (
 
+           =
  (AML_NODE_HANDLE)ObjectNode,
 
+           =
  (AML_NODE_HANDLE)IntNode
 
+           =
  );
 
+  if (EFI_ERROR (Status)) {
 
+    ASSERT (0);
 
+    goto exit_handler;
 
+  }
 
+
 
+  if (NewObjectNode !=3D 0) {
 
+    *NewObjectNode =3D ObjectNode;
 
+  }
 
+
 
+exit_handler:
 
+  if (AmlNameString !=3D NULL) {
 
+    FreePool (AmlNameString);
 
+  }
 
+
 
+  if (IntNode !=3D NULL) {
 
+    AmlDeleteTree ((AML_NODE_HANDLE)IntNode);
 
+  }
 
+
 
+  if (DataNode !=3D NULL) {
 
+    AmlDeleteTree ((AML_NODE_HANDLE)DataNode);
 
+  }
 
+
 
+  if (ObjectNode !=3D NULL) {
 
+    AmlDeleteTree ((AML_NODE_HANDLE)ObjectNode);
 
+  }
 
+
 
+  return Status;
 
+}

[SAMI] I think the error handling in the above function can be simplifie= d as below:

...

 <= /span>

STATIC

 <= /span>

EFI_STA= TUS

 <= /span>

EFIAPI

 <= /span>

AmlCode= GenReturnNameStringIntegerArgument (

 <= /span>

  = I= N  CONST CHAR8            *NameString,

 <= /span>

  = I= N        UINT64           Inte= ger,

 <= /span>

  = I= N        AML_NODE_HEADER  *ParentNode    = ;  OPTIONAL,

 <= /span>

  = O= UT OPTIONAL= =

 <= /span>

  = )

 <= /span>

{

 <= /span>

  = EFI_STATUS       Status;

 <= /span>

  = AML_DATA_NODE    *DataNode;

 <= /span>

  = AML_OBJECT_NODE  *IntNode;

 <= /span>

  = CHAR8            *AmlNameString;

 <= /span>

  = UINT32           AmlNameStringSize;

 <= /span>

  = AML_OBJECT_NODE  *ObjectNode;

 <= /span>

  = DataNode   =3D NULL;

 <= /span>

  = IntNode    =3D NULL;

 <= /span>

  = ObjectNode =3D NULL;

 <= /span>

  = Status =3D ConvertAslNameToAmlName (NameString, &AmlNameString);=

 <= /span>

  = i= f (EFI_ERROR (Status)) {

 <= /span>

  =   ASSERT (0);

 <= /span>

  =   return Status;

 <= /span>

  = }

 <= /span>

  = Status =3D AmlGetNameStringSize (AmlNameString, &AmlNameStringSize);

 <= /span>

  = i= f (EFI_ERROR (Status)) {

 <= /span>

  =   ASSERT (0);

 <= /span>

  =   goto exit_handler;

 <= /span>

  = }

 <= /span>

  = Status =3D AmlCodeGenInteger (Integer, &IntNode);

 <= /span>

  = i= f (EFI_ERROR (Status)) {

 <= /span>

  =   ASSERT (0);

 <= /span>

  =   goto exit_handler;

 <= /span>

  = }

 <= /span>

  = Status =3D AmlCreateDataNode (

 <= /span>

  =            EAmlNodeDataTypeNameString,

 <= /span>

  =            (UINT8 *)AmlNameString,

 <= /span>

  =            AmlNameStringSize,

 <= /span>

  =            &DataNode

 <= /span>

  =            );

 <= /span>

  = i= f (EFI_ERROR (Status)) {

 <= /span>

  =   ASSERT (0);

 <= /span>

  =   goto exit_handler1;

 <= /span>

  = }

 <= /span>

  = = // AmlCodeGenReturn() deletes DataNode if error.

 <= /span>

  = Status =3D AmlCodeGenReturn (

 <= /span>

  =            (AML_NODE_HEADER *)DataNode,

 <= /span>

  =            ParentNode,

 <= /span>

  =            &ObjectNode

 <= /span>

  =            );

 <= /span>

  = i= f (EFI_ERROR (Status)) {

 <= /span>

  =   ASSERT (0);

 <= /span>

  =   goto exit_handler1;

 <= /span>

  = }

 <= /span>

  = Status =3D AmlVarListAddTail (

 <= /span>

  =            (AML_NODE_HANDLE)ObjectNode,

 <= /span>

  =            (AML_NODE_HANDLE)IntNode

 <= /span>

  =            );

 <= /span>

  = i= f (EFI_ERROR (Status)) {

 <= /span>

  =   // ObjectNode is already attached to ParentNode in AmlCodeGenReturn(= ),  <= /span>

  =   // so no need to free it here, it will be deleted when deleting the<= /span><= /span>

 <= /span>

  =   // ParentNode tree

 <= /span>

  =   ASSERT (0);

 <= /span>

  =   goto exit_handler1;

 <= /span>

  = }

 <= /span>

  = i= f (NewObjectNode !=3D

0) {<= /span>

 <= /span>

  =   *NewObjectNode =3D ObjectNode;

 <= /span>

  = }

 <= /span>

  = g= oto exit_handler;

 <= /span>

exit_ha= ndler1:

 <= /span>

  = i= f (IntNode !=3D

NULL) {<= /span>

 <= /span>

  =   AmlDeleteTree ((AML_NODE_HANDLE)IntNode);

 <= /span>

  = }

 <= /span>

exit_ha= ndler:

 <= /span>

  = i= f (AmlNameString !=3D

NULL) {<= /span>

 <= /span>

  =   FreePool (AmlNameString);

 <= /span>

  = }

 <= /span>

  = r= eturn Status;

 <= /span>

}

 <= /span>

 

Please let me know if you agree with this, and I will make this change b= efore merging.

[/SAMI]

 
+
 
 /** AML code generation for a method returning a NameString.
 
 
 
   AmlCodeGenMethodRetNameString (
 
@@ -1989,6 +2121,118 @@ error_handler:
 
   return Status;
 
 }
 
 
 
+/** AML code generation for a method returning a NameString that t=
akes an
 
+    integer argument.
 
+
 
+  AmlCodeGenMethodRetNameStringIntegerArgument (
 
+    "MET0", "MET1", 1, TRUE, 3,=
 5, ParentNode, NewObjectNode
 
+    );
 
+  is equivalent of the following ASL code:
 
+    Method(MET0, 1, Serialized, 3) {
 
+      Return (MET1 (5))
 
+    }
 
+
 
+  The ASL parameters "ReturnType" and "Paramet=
erTypes" are not asked
 
+  in this function. They are optional parameters in ASL.
 
+
 
+  @param [in]  MethodNameString     =
The new Method's name.
 
+           =
            &nb=
sp;            Must =
be a NULL-terminated ASL NameString
 
+           =
            &nb=
sp;            e.g.:=
 "MET0", "_SB.MET0", etc.
 
+           =
            &nb=
sp;            The i=
nput string is copied.
 
+  @param [in]  ReturnedNameString   The name o=
f the object returned by the
 
+           =
            &nb=
sp;            metho=
d. Optional parameter, can be:
 
+           =
            &nb=
sp;             =
;- NULL (ignored).
 
+           =
            &nb=
sp;            =
 - A NULL-terminated ASL NameString.
 
+           =
            &nb=
sp;            =
   e.g.: "MET0", "_SB.MET0", etc.
 
+           =
            &nb=
sp;            =
   The input string is copied.
 
+  @param [in]  NumArgs     &nbs=
p;        Number of arguments.
 
+           =
            &nb=
sp;            Must =
be 0 <=3D NumArgs <=3D 6.
 
+  @param [in]  IsSerialized     =
;    TRUE is equivalent to Serialized.
 
+           =
            &nb=
sp;            FALSE=
 is equivalent to NotSerialized.
 
+           =
            &nb=
sp;            Defau=
lt is NotSerialized in ASL spec.
 
+  @param [in]  SyncLevel     &n=
bsp;      Synchronization level for the method.
 
+           =
            &nb=
sp;            Must =
be 0 <=3D SyncLevel <=3D 15.
 
+           =
            &nb=
sp;            Defau=
lt is 0 in ASL.
 
+  @param [in]  IntegerArgument    &n=
bsp; Argument to pass to the NameString.
 
+  @param [in]  ParentNode     &=
nbsp;     If provided, set ParentNode as the parent
 
+           =
            &nb=
sp;            of th=
e node created.
 
+  @param [out] NewObjectNode     &nb=
sp;  If success, contains the created node.
 
+
 
+  @retval EFI_SUCCESS      &nbs=
p;      Success.
 
+  @retval EFI_INVALID_PARAMETER   Invalid parameter=
.
 
+  @retval EFI_OUT_OF_RESOURCES    Failed to al=
locate memory.
 
+**/
 
+EFI_STATUS
 
+EFIAPI
 
+AmlCodeGenMethodRetNameStringIntegerArgument (
 
+  IN  CONST CHAR8      &nb=
sp;            *Meth=
odNameString,
 
+  IN  CONST CHAR8      &nb=
sp;            *Retu=
rnedNameString   OPTIONAL,
 
+  IN        UINT8 &nb=
sp;            =
     NumArgs,
 
+  IN        BOOLEAN &=
nbsp;           &nbs=
p;   IsSerialized,
 
+  IN        UINT8 &nb=
sp;            =
     SyncLevel,
 
+  IN        UINT64 &n=
bsp;            =
;    IntegerArgument,
 
+  IN        AML_NODE_HANDL=
E         ParentNode  &nb=
sp;        OPTIONAL,
 
+  OUT       AML_OBJECT_NODE_HAN=
DLE  *NewObjectNode        OPTIONAL=
 
+  )
 
+{
 
+  EFI_STATUS        &=
nbsp;     Status;
 
+  AML_OBJECT_NODE_HANDLE  MethodNode;
 
+
 
+  if ((MethodNameString =3D=3D NULL)  ||
 
+      ((ParentNode =3D=3D NULL) &&=
; (NewObjectNode =3D=3D NULL)))
 
+  {
 
+    ASSERT (0);
 
+    return EFI_INVALID_PARAMETER;
 
+  }
 
+
 
+  // Create a Method named MethodNameString.
 
+  Status =3D AmlCodeGenMethod (
 
+           =
  MethodNameString,
 
+           =
  NumArgs,
 
+           =
  IsSerialized,
 
+           =
  SyncLevel,
 
+           =
  NULL,
 
+           =
  &MethodNode
 
+           =
  );
 
+  if (EFI_ERROR (Status)) {
 
+    ASSERT (0);
 
+    return Status;
 
+  }
 
+
 
+  // Return ReturnedNameString if provided.
 
+  if (ReturnedNameString !=3D NULL) {
 
+    Status =3D AmlCodeGenReturnNameStringIntegerArg=
ument (
 
+           =
    ReturnedNameString,
 
+           =
    IntegerArgument,
 
+           =
    (AML_NODE_HANDLE)MethodNode,
 
+           =
    NULL
 
+           =
    );
 
+    if (EFI_ERROR (Status)) {
 
+      ASSERT (0);
 
+      goto error_handler;
 
+    }
 
+  }
 
+
 
+  Status =3D LinkNode (
 
+           =
  MethodNode,
 
+           =
  ParentNode,
 
+           =
  NewObjectNode
 
+           =
  );
 
+  if (EFI_ERROR (Status)) {
 
+    ASSERT (0);
 
+    goto error_handler;
 
+  }
 
+
 
+  return Status;
 
+
 
+error_handler:
 
+  if (MethodNode !=3D NULL) {
 
+    AmlDeleteTree ((AML_NODE_HANDLE)MethodNode);
 
+  }
 
+
 
+  return Status;
 
+}
 
+
 
 /** AML code generation for a method returning an Integer.
 
 
 
   AmlCodeGenMethodRetInteger (
 
_._,_._,_

Groups.io Links:

=20 You receive all messages sent to this group. =20 =20

View/Reply Online (#108968) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--_000_PAXPR08MB6813725255B4DCF597B65CA784F8APAXPR08MB6813eurp_--