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 EB69FAC18BF for ; Thu, 21 Sep 2023 20:48:51 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=iGfslBOn8jF43fD6ZCwxn5NbSxdWr0gC4hN3AjUkhPU=; c=relaxed/simple; d=groups.io; h=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:MIME-Version: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=1695329330; v=1; b=LJGYnasC4QAZB8BvPVHNTCpzFtiSTLqN5Rh8ifKiRYVcwRUkhNidJGxZquN7e6YEC2Q/uN1t zuDHsZfbSH5VE9KLmowsFQNBDVpUaEEO8RqJ0d3dSAQVnH0rqeI0Y5mWNaWKJDKcFKsxW4CAesd v1J/z1E1IvY+hRlV25wVL2K0= X-Received: by 127.0.0.2 with SMTP id jSGgYY7687511xCOkN3qbux6; Thu, 21 Sep 2023 13:48:50 -0700 X-Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com [40.107.94.84]) by mx.groups.io with SMTP id smtpd.web11.6863.1695329329605361869 for ; Thu, 21 Sep 2023 13:48:49 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KVnBzKk3qRMTuVsaxQ+wmTseDUEpzXU0r8UUNuHwHL6icUCob6rg3SpkK5O8SXrHWSnVRwbe9LPVhLz28zjR5VmB9xPanuVxlMQelxUrqcY6Yr8ikcaFxm8VxGwKFeThETPjtQO7pjfd5tyRxz0rxIk2ygx0SgtH5B/k64nD9aitDhMnoHB+017UF6Ln6eYEgWt1KMfRAeIi+EN+2gvQhM3J3TKlij9xKP3HHH3EQ/bpQs8Qgh3ldRFebeo9887W8gqi69k4ofwkOc71TEO0O51Wd/Kcqi//KNJHxHEiI9eJK766owTvxVw3GRPL2QcYqb1OtpBZnh3g+4JkqBVUuA== 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=0VgImB1ObFQW0YJR01KRUQgcWCoXughJ6O277mRdCW8=; b=P83b148T3GnXWXIYU3YraQWWT+jaF9uTK7/XRN3msJXA5CL6tc3CMCEmPdM6y3LGWNsibTNuVrHXVsXIa8rilNny3RXkKwzlBdgJ0yJTsJpEBfMds4VjL+nFICrrnQXwe//hbnsUREJlyMwH24JGyUt6avDWPbhr4ynYN+QAOCttEqK7SpCzAZOtLfhZZNJZC8nfYxraf5yxzeseIX2DWsGPmZC1hl9IXZfNVJYgF0G20tL6K7qXMoDcsHLF0MSQAARumcAUD90biPOESjrCedYwP9Gknq1hSnPdLJK56ePDSc8uMm+uIAbm8S0ewW4B+RDZD1/YmnFetkf3R2fP5w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none X-Received: from DS7PR12MB5789.namprd12.prod.outlook.com (2603:10b6:8:74::21) by IA1PR12MB7544.namprd12.prod.outlook.com (2603:10b6:208:42c::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.20; Thu, 21 Sep 2023 20:48:45 +0000 X-Received: from DS7PR12MB5789.namprd12.prod.outlook.com ([fe80::639c:a3f3:9403:ed05]) by DS7PR12MB5789.namprd12.prod.outlook.com ([fe80::639c:a3f3:9403:ed05%4]) with mapi id 15.20.6813.017; Thu, 21 Sep 2023 20:48:45 +0000 From: "Jeff Brasen via groups.io" To: Sami Mujawar , "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: AQHZ7KumTPonCe4s10266DpcC2NaobAlizOwgAAp4ACAAAtc0A== Date: Thu, 21 Sep 2023 20:48:45 +0000 Message-ID: References: <737650480edcab199927322064b2459f647f9f02.1695049337.git.jbrasen@nvidia.com> <885016b1-c8f3-8951-8473-15a37cd640a2@arm.com> In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DS7PR12MB5789:EE_|IA1PR12MB7544:EE_ x-ms-office365-filtering-correlation-id: b275efc1-58ca-4528-c1cb-08dbbae42601 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: Qn3LcJTRFwLSvABaBmCNUqMh9sYQb7vl9QnxnnSJAjTjR7d87OjZkph4AtsTMHknx3lJlq/up8pP1XQy3BhjePs9tfdvUUusxNXsgGvtVcfG5j4NSQgfK24C4Jsi0UiQpcHvro7hnpVExwqX6PJHCa3AmVY2nmpkstx8yCHsvuK1D2hQMXhQXWBeF/shYlCU0cOVVXhAdRmuk2roBLLLBBCFPWs/+WWD6C8GSILRMcjl0FsRou9epasH7BJ1W9O5ZEdHXkn1znvNo/TUZofy4RluklwQ3E5EtcgyeFlPTQ/cUbKCVskU+A5nNRzFenMBbRQpEdacUr9YdNi2W/KuBtcwmpTAjKf6cSHQ4a4SEdhSNeWhZUdC9sPbDroTH93EK1urcquBvTLH2pcp5/FmI0NuGkZ37jQYAYWlGg5hVbaL6O0uqhvDB5mdBnCy4wob9evuUo6MDCP0XFouNXTakvSQT43iUjUItkWXqbfLeN6Ts8nLQ7m2JHFST+OwcsfygyIVqUsu/L8l1ZTzYL4jRqLj6mmWxGSJC2Z58SCM2LL/a7UXIs9yr/bAF/wAYl8w8f9Jnl6wA+TLxy1wHuV6/wlRaUt0XxB3ejUgANHeevfAZNTBS8Fkftu04BO4Luub x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?EQYRvEHJ2DfdNBxIRNp4CzKijNs094UBKLVPrnefEwm9ZhJEafJYhCq21Uvi?= =?us-ascii?Q?t6nM20+x/b6yTXz9wNm6KTAcWo4jnxbUGEUwExRJBP4z9HcMq0dGp62oMb2Q?= =?us-ascii?Q?HAsfLlzkbW2Px1s+OvbRB59UM1rs29LH3/vC+UD94IkZmL4ct4JWXXKVz5Zm?= =?us-ascii?Q?73lux67mdk+zI9yRj8w7UwhiIab+ISx3JbgYee0HhVx3f39PaZEihCXOd1d3?= =?us-ascii?Q?iixlBjW72kbz6orombQfVmm1T6XZVisluEJmrCvT51fVAs5JnWwVuLXEeWSj?= =?us-ascii?Q?Z6pBRXM6D7yj5p7cGjtf2ixUdm3xUsYeY4SaZaeDrawglMGh82jBh6SL+Gsz?= =?us-ascii?Q?/8iiBuFoHmbpCxXjKWGioQqwiL8tBNb/96QBhfr12gmsPMq0Q+tGZ4RXbuAG?= =?us-ascii?Q?YbVLN0lNWBa/ZpkD81sZCLO+ZxajPcoadQuPmBl311cjABxkx0b/CaZnwfp1?= =?us-ascii?Q?vaegu9wtyuCR725qxXRYj5CnDQOdYR358juFyIdeHqvIPz8l2ifW+EZcdRgX?= =?us-ascii?Q?Vrf4SOv1Ox4EP4tYacjcwbtJKcr+CfbYKkNL4coWp6XM+ZRy8r7I3hw8YRJb?= =?us-ascii?Q?mEDz/uz6COeKJkk5IZVHa0bVvRjaKajxnWMj1a7Az3sqa4wa2bA8wXRdw2g1?= =?us-ascii?Q?/lssT9RQJK+B9tESz8OMOpfzyZV35oOPOgsn44FP+jhUXiP6Rwx8R57iyXmW?= =?us-ascii?Q?GfKCHtNfohEhIfI6lrT33MhPwjM/uZa82lQUQ82/26nEkLBpKE2+2uxjtRFs?= =?us-ascii?Q?MT/xLondSCJHqOCs2j1K1VGizaMJY/qKy/86N+5aLefOCCk6O3hsQQ3oWSL9?= =?us-ascii?Q?Ra9lKODw4xROJwl8VrBxSlD4LzogenM0y37CMGmXQ+kxt9y33sq6ZAB81p9X?= =?us-ascii?Q?xUYXeVSnAjwvPoA6it6tw8Kqeeg4C4luMEP1t9P0wotZ5n/6daDwFhrYlrTE?= =?us-ascii?Q?4DCdOeQHJ9fOvhh7wCsmubzTQmxQnOzMXaogU4UVCY+Lecz8TAM5DY/0KDMV?= =?us-ascii?Q?RMFzE/gSsn7SgHimp3otEssRxr0OQk3ALUausod2QETYegLQD14AF4R8ZCn2?= =?us-ascii?Q?f+qATTRZtSBVl2pSpFudnfRneVQ2UUDE9x6Wx1S2wZ15UT7oW0TkfyAu/n1g?= =?us-ascii?Q?uetch6tua+3U2gTyqI+wYAN7EWJLU0XLit38Gn1zXuYZJeg50xxO2IfUZq39?= =?us-ascii?Q?cPFSv8y5pUQ4bebo+YgAsyHGvgSDq62YG9myEV8NiutDtJxt6dJsrPhH8ScR?= =?us-ascii?Q?CLm/nzlRkZSK4jdPzoyHwegJNM47D5LVj8Va7jZsMRoAcH+O5QCsZ6Y/3Cu6?= =?us-ascii?Q?NYMObHkP3/3dJlQ8ldybTeyKwWIEBZm7NSAycez6i9I/NYZ1huVtml4zxPT5?= =?us-ascii?Q?d3PlTjNHCSbtiyzsO2yn6AeLpMoIHWHsDFir9n4nUts34c5cCX975LWdt/D/?= =?us-ascii?Q?AjyvFMjiuuVKGCt+VJRFCDq41M4BsiSWl+ZbhkZD7KHsJVuYixBMmm+8sMlo?= =?us-ascii?Q?GILYGYOIcoxaV0auXCu0/x7lXxGccm3OsllOakQIRrLkkDqczwRzz+XaLbkT?= =?us-ascii?Q?n1rOHzWsPQnZPkMv4WNKr2BQbBiEG4pCo0y7Cpsc?= MIME-Version: 1.0 X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DS7PR12MB5789.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b275efc1-58ca-4528-c1cb-08dbbae42601 X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Sep 2023 20:48:45.6013 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Meqcrb+tR3GxEf8MGLSzQGyC3w49aYPiLpoetBEGBVbrStclg7ewouTsTrNK2dqmW/7kPZ04j63JyQ6Tai8mfg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7544 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,jbrasen@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: vkh1vAt9lrT2K26XOBsh8viCx7686176AA= Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_DS7PR12MB5789A740E12E156BD328E66ECBF8ADS7PR12MB5789namp_" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=LJGYnasC; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); dmarc=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 --_000_DS7PR12MB5789A740E12E156BD328E66ECBF8ADS7PR12MB5789namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I see you swapped the order of the functions, that looks good and avoids sp= ecial handling for that case. That looks good to me. Thanks, Jeff From: Sami Mujawar Sent: Thursday, September 21, 2023 2:07 PM To: Jeff Brasen ; 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. External email: Use caution opening links or attachments 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 >; n= d > Subject: RE: [PATCH v4 2/4] DynamicTablesPkg: Add support for simple method= invocation. Only thing I see is if AmlCodeGenInteger fails we don't delete DataNode rig= ht? From: Sami Mujawar > Sent: Thursday, September 21, 2023 10:49 AM To: Jeff Brasen >; devel@edk2= .groups.io Cc: pierre.gondois@arm.com; Swatisri Kantams= etti >; Ashish 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 (#108972): https://edk2.groups.io/g/devel/message/108972 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_DS7PR12MB5789A740E12E156BD328E66ECBF8ADS7PR12MB5789namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

I see you swapped the order of the functions, that l= ooks good and avoids special handling for that case. That looks good to me.=

 

Thanks,

Jeff

From: Sami Mujawar <Sami.Mujawar@arm.com&g= t;
Sent: Thursday, September 21, 2023 2:07 PM
To: Jeff Brasen <jbrasen@nvidia.com>; 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.

 

External email: Use caution opening l= inks or attachments

 

Hi Jeff,

 

Yes, I recorded the integer node and data node creat= ion.

 

Regards,

 

Sami Mujawar

 

 


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

 

Only thing I see is if AmlCode= GenInteger fails we don’t delete DataNode right?

 

From: Sami Mujawar <= sami.mujawar@arm.com>
Sent: Thursday, September 21, 2023 10:49 AM
To: Jeff Brasen <jbrasen@nv= idia.com>; devel@edk2.groups.io
Cc: pierre.gondois@arm.com= ; Swatisri Kantamsetti <swat= isrik@nvidia.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 B= rasen wrote:

Add support to add Return objects via AML that pass a single integer
 
argument to the named method.
 
 
 
Signed-off-by: Jeff Brasen <j=
brasen@nvidia.com>
 
---
 
 .../Include/Library/AmlLib/AmlLib.h     &nbs=
p;     |  54 ++++
 
 .../Common/AmlLib/CodeGen/AmlCodeGen.c     &=
nbsp;  | 244 ++++++++++++++++++
 
 2 files changed, 298 insertions(+)
 
 
 
diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/Dynami=
cTablesPkg/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_H=
ANDLE  *NewObjectNode        OPTION=
AL
 
   );
 
 
 
+/** AML code generation for a method returning a NameString that take=
s 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 "ParameterT=
ypes" 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.: &q=
uot;MET0", "_SB.MET0", etc.
 
+           &nb=
sp;            =
            The inpu=
t string is copied.
 
+  @param [in]  ReturnedNameString   The name of t=
he object returned by the
 
+           &nb=
sp;            =
            method. =
Optional parameter, can be:
 
+           &nb=
sp;            =
             - =
NULL (ignored).
 
+           &nb=
sp;            =
             - =
A NULL-terminated ASL NameString.
 
+           &nb=
sp;            =
            &nb=
sp;  e.g.: "MET0", "_SB.MET0", etc.
 
+            &n=
bsp;            =
;            &n=
bsp; The input string is copied.
 
+  @param [in]  NumArgs      &=
nbsp;       Number of arguments.
 
+           &nb=
sp;            =
            Must be =
0 <=3D NumArgs <=3D 6.
 
+  @param [in]  IsSerialized     &n=
bsp;   TRUE is equivalent to Serialized.
 
+           &nb=
sp;            =
            FALSE is=
 equivalent to NotSerialized.
 
+           &nb=
sp;            =
            Default =
is NotSerialized in ASL spec.
 
+  @param [in]  SyncLevel      =
;      Synchronization level for the method.<=
/o:p>
 
+           &nb=
sp;            =
            Must be =
0 <=3D SyncLevel <=3D 15.
 
+           &nb=
sp;            =
            Default =
is 0 in ASL.
 
+  @param [in]  IntegerArgument     =
; Argument to pass to the NameString.
 
+  @param [in]  ParentNode     &nbs=
p;     If provided, set ParentNode as the parent
 
+           &nb=
sp;            =
            of the n=
ode created.
 
+  @param [out] NewObjectNode      =
  If success, contains the created node.
 
+
 
+  @retval EFI_SUCCESS       &=
nbsp;     Success.
 
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
 
+  @retval EFI_OUT_OF_RESOURCES    Failed to alloc=
ate memory.
 
+**/
 
+EFI_STATUS
 
+EFIAPI
 
+AmlCodeGenMethodRetNameStringIntegerArgument (
 
+  IN  CONST CHAR8       =
            *MethodN=
ameString,
 
+  IN  CONST CHAR8       =
            *Returne=
dNameString   OPTIONAL,
 
+  IN        UINT8  =
            &nb=
sp;    NumArgs,
 
+  IN        BOOLEAN &nbs=
p;            &=
nbsp;  IsSerialized,
 
+  IN        UINT8  =
            &nb=
sp;    SyncLevel,
 
+  IN        UINT64  =
;            &n=
bsp;   IntegerArgument,
 
+  IN        AML_NODE_HANDLE&n=
bsp;        ParentNode   =
        OPTIONAL,
 
+  OUT       AML_OBJECT_NODE_HANDLE=
  *NewObjectNode        OPTIONAL
 
+  );
 
+
 
 /** Create a _LPI name.
 
 
 
   AmlCreateLpiNode ("_LPI", 0, 1, ParentNode, &am=
p;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, NewObjectNo=
de) is
 
+  equivalent of the following ASL code:
 
+    Return(NAM1 (6))
 
+
 
+  The ACPI 6.3 specification, s20.2.5.3 "Type 1 Opcodes Enc=
oding" states:
 
+    DefReturn :=3D ReturnOp ArgObject
 
+    ReturnOp :=3D 0xA4
 
+    ArgObject :=3D TermArg =3D> DataRefObject<=
/o:p>
 
+
 
+  Thus, the ReturnNode must be evaluated as a DataRefObject. It =
can
 
+  be a NameString referencing an object. As this CodeGen Api doe=
sn'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 objec=
t referenced by this NameString
 
+           &nb=
sp;            =
      is returned by the Return ASL statement.
 
+           &nb=
sp;            =
      Must be a NULL-terminated ASL NameString
 
+           &nb=
sp;            =
      e.g.: "NAM1", "_SB.NAM1"=
, etc.
 
+            &n=
bsp;            =
;     The input string is copied.
 
+  @param [in]  Integer      &=
nbsp; Argument to pass to the NameString
 
+  @param [in]  ParentNode     If provid=
ed, 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 crea=
ted node.
 
+
 
+  @retval EFI_SUCCESS       &=
nbsp;     Success.
 
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
 
+  @retval EFI_OUT_OF_RESOURCES    Failed to alloc=
ate memory.
 
+**/
 
+STATIC
 
+EFI_STATUS
 
+EFIAPI
 
+AmlCodeGenReturnNameStringIntegerArgument (
 
+  IN  CONST CHAR8       =
     *NameString,
 
+  IN        UINT64  =
;         Integer,
 
+  IN        AML_NODE_HEADER &=
nbsp;*ParentNode      OPTIONAL,
 
+  OUT       AML_OBJECT_NODE  =
**NewObjectNode   OPTIONAL
 
+  )
 
+{
 
+  EFI_STATUS       Status;
 
+  AML_DATA_NODE    *DataNode;
 
+  AML_OBJECT_NODE  *IntNode;
 
+  CHAR8         &nb=
sp;  *AmlNameString;
 
+  UINT32         &n=
bsp; AmlNameStringSize;
 
+  AML_OBJECT_NODE  *ObjectNode;
 
+
 
+  DataNode   =3D NULL;
 
+  IntNode    =3D NULL;
 
+  ObjectNode =3D NULL;
 
+
 
+  Status =3D ConvertAslNameToAmlName (NameString, &AmlNameSt=
ring);
 
+  if (EFI_ERROR (Status)) {
 
+    ASSERT (0);
 
+    return Status;
 
+  }
 
+
 
+  Status =3D AmlGetNameStringSize (AmlNameString, &AmlNameSt=
ringSize);
 
+  if (EFI_ERROR (Status)) {
 
+    ASSERT (0);
 
+    goto exit_handler;
 
+  }
 
+
 
+  Status =3D AmlCreateDataNode (
 
+           &nb=
sp; EAmlNodeDataTypeNameString,
 
+           &nb=
sp; (UINT8 *)AmlNameString,
 
+           &nb=
sp; AmlNameStringSize,
 
+           &nb=
sp; &DataNode
 
+           &nb=
sp; );
 
+  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 (
 
+           &nb=
sp; (AML_NODE_HEADER *)DataNode,
 
+           &nb=
sp; ParentNode,
 
+           &nb=
sp; &ObjectNode
 
+           &nb=
sp; );
 
+
 
+  // DataNode is either deleted or added to ObjectNode, set to N=
ULL so we don't
 
+  // delete it again
 
+  DataNode =3D NULL;
 
+  if (EFI_ERROR (Status)) {
 
+    ASSERT (0);
 
+    goto exit_handler;
 
+  }
 
+
 
+  Status =3D AmlVarListAddTail (
 
+           &nb=
sp; (AML_NODE_HANDLE)ObjectNode,
 
+           &nb=
sp; (AML_NODE_HANDLE)IntNode
 
+           &nb=
sp; );
 
+  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);<=
/o:p>
 
+  }
 
+
 
+  return Status;
 
+}

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

...

&nb= sp;

STAT= IC

&nb= sp;

EFI= _STATUS

&nb= sp;

EFIA= PI

&nb= sp;

Aml= CodeGenReturnNameStringIntegerArgument (

&nb= sp;

&nb= sp; IN<= /span> &n= bsp;CONST CHAR8            *NameString,

&nb= sp;

&nb= sp; IN<= /span> &n= bsp;      UINT64           Integer,=

&nb= sp;

&nb= sp; IN<= /span> &n= bsp;      AML_NODE_HEADER  *ParentNode     &n= bsp;OPTIONAL,

&nb= sp;

&nb= sp; OUT= &= nbsp;     AML_OBJECT_NODE  **NewObjectNode  

OPTI= ONAL

&nb= sp;

&nb= sp; )

&nb= sp;

{

&nb= sp;

&nb= sp; EFI_STATUS       Status;

&nb= sp;

&nb= sp; AML_DATA_NODE    *DataNode;

&nb= sp;

&nb= sp; AML_OBJECT_NODE  *IntNode;

&nb= sp;

&nb= sp; CHAR8            *AmlNameString;

&nb= sp;

&nb= sp; UINT32           AmlNameStringSize;

&nb= sp;

&nb= sp; AML_OBJECT_NODE  *ObjectNode;

&nb= sp;

&nb= sp; DataNode   =3D NUL= L;=

&nb= sp;

&nb= sp; IntNode    =3D NUL= L;=

&nb= sp;

&nb= sp; ObjectNode =3D NUL= L;=

&nb= sp;

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

&nb= sp;

&nb= sp; if<= /span> (E= FI_ERROR (Status)) {

&nb= sp;

&nb= sp;   ASS= ERT (0);

&nb= sp;

&nb= sp;   ret= urn Status;

&nb= sp;

&nb= sp; }

&nb= sp;

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

&nb= sp;

&nb= sp; if<= /span> (E= FI_ERROR (Status)) {

&nb= sp;

&nb= sp;   ASS= ERT (0);

&nb= sp;

&nb= sp;   got= o = exit_handler;

&nb= sp;

&nb= sp; }

&nb= sp;

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

&nb= sp;

&nb= sp; if<= /span> (E= FI_ERROR (Status)) {

&nb= sp;

&nb= sp;   ASS= ERT (0);

&nb= sp;

&nb= sp;   got= o = exit_handler;

&nb= sp;

&nb= sp; }

&nb= sp;

&nb= sp; Status =3D AmlCreateDataNode (

&nb= sp;

&nb= sp;            EAmlNodeDataTypeNameString,

&nb= sp;

&nb= sp;            (UINT8 *)AmlNameString,=

&nb= sp;

&nb= sp;            AmlNameStringSize,=

&nb= sp;

&nb= sp;            &DataNode

&nb= sp;

&nb= sp;            );

&nb= sp;

&nb= sp; if<= /span> (E= FI_ERROR (Status)) {

&nb= sp;

&nb= sp;   ASS= ERT (0);

&nb= sp;

&nb= sp;   got= o = exit_handler1;

&nb= sp;

&nb= sp; }

&nb= sp;

&nb= sp; //= AmlCodeGenReturn() deletes DataNode if error.

&nb= sp;

&nb= sp; Status =3D AmlCodeGenReturn (

&nb= sp;

&nb= sp;            (AML_NODE_HEADER *)DataNode,

&nb= sp;

&nb= sp;            ParentNode,<= /p>

&nb= sp;

&nb= sp;            &ObjectNode

&nb= sp;

&nb= sp;            );

&nb= sp;

&nb= sp; if<= /span> (E= FI_ERROR (Status)) {

&nb= sp;

&nb= sp;   ASS= ERT (0);

&nb= sp;

&nb= sp;   got= o = exit_handler1;

&nb= sp;

&nb= sp; }

&nb= sp;

&nb= sp; Status =3D AmlVarListAddTail (

&nb= sp;

&nb= sp;            (AML_NODE_HANDLE)ObjectNode,

&nb= sp;

&nb= sp;            (AML_NODE_HANDLE)IntNode

&nb= sp;

&nb= sp;            );

&nb= sp;

&nb= sp; if<= /span> (E= FI_ERROR (Status)) {

&nb= sp;

&nb= sp;   //= ObjectNode is already attached to ParentNode in AmlCodeGenReturn(),=

&nb= sp;

&nb= sp;   //= so no need to free it here, it will be deleted when deleting the

&nb= sp;

&nb= sp;   //= ParentNode tree

&nb= sp;

&nb= sp;   ASS= ERT (0);

&nb= sp;

&nb= sp;   got= o = exit_handler1;

&nb= sp;

&nb= sp; }

&nb= sp;

&nb= sp; if<= /span> (N= ewObjectNode !=3D

0= ) = {

&nb= sp;

&nb= sp;   *NewObjectNode =3D ObjectNode;

&nb= sp;

&nb= sp; }

&nb= sp;

&nb= sp; got= o = exit_handler;

&nb= sp;

exi= t_handler1:

&nb= sp;

&nb= sp; if<= /span> (I= ntNode !=3D

NULL= ) = {

&nb= sp;

&nb= sp;   AmlDeleteTree ((AML_NODE_HANDLE)IntNode);

&nb= sp;

&nb= sp; }

&nb= sp;

exi= t_handler:

&nb= sp;

&nb= sp; if<= /span> (A= mlNameString !=3D

NULL= ) = {

&nb= sp;

&nb= sp;   FreePool (AmlNameString);

&nb= sp;

&nb= sp; }

&nb= sp;

&nb= sp; ret= urn Status;

&nb= sp;

}

&nb= sp;

 

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 take=
s 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 "ParameterT=
ypes" 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.: &q=
uot;MET0", "_SB.MET0", etc.
 
+           &nb=
sp;            =
            The inpu=
t string is copied.
 
+  @param [in]  ReturnedNameString   The name of t=
he object returned by the
 
+           &nb=
sp;            =
            method. =
Optional parameter, can be:
 
+           &nb=
sp;            =
             - =
NULL (ignored).
 
+           &nb=
sp;            =
             - =
A NULL-terminated ASL NameString.
 
+           &nb=
sp;            =
            &nb=
sp;  e.g.: "MET0", "_SB.MET0", etc.
 
+           &nb=
sp;            =
            &nb=
sp;  The input string is copied.
 
+  @param [in]  NumArgs      &=
nbsp;       Number of arguments.
 
+           &nb=
sp;            =
            Must be =
0 <=3D NumArgs <=3D 6.
 
+  @param [in]  IsSerialized     &n=
bsp;   TRUE is equivalent to Serialized.
 
+           &nb=
sp;            =
            FALSE is=
 equivalent to NotSerialized.
 
+           &nb=
sp;            =
            Default =
is NotSerialized in ASL spec.
 
+  @param [in]  SyncLevel      =
;      Synchronization level for the method.<=
/o:p>
 
+           &nb=
sp;            =
            Must be =
0 <=3D SyncLevel <=3D 15.
 
+           &nb=
sp;            =
            Default =
is 0 in ASL.
 
+  @param [in]  IntegerArgument     =
; Argument to pass to the NameString.
 
+  @param [in]  ParentNode     &nbs=
p;     If provided, set ParentNode as the parent
 
+           &nb=
sp;            =
            of the n=
ode created.
 
+  @param [out] NewObjectNode      =
  If success, contains the created node.
 
+
 
+  @retval EFI_SUCCESS       &=
nbsp;     Success.
 
+  @retval EFI_INVALID_PARAMETER   Invalid parameter.
 
+  @retval EFI_OUT_OF_RESOURCES    Failed to alloc=
ate memory.
 
+**/
 
+EFI_STATUS
 
+EFIAPI
 
+AmlCodeGenMethodRetNameStringIntegerArgument (
 
+  IN  CONST CHAR8       =
            *MethodN=
ameString,
 
+  IN  CONST CHAR8       =
            *Returne=
dNameString   OPTIONAL,
 
+  IN        UINT8  =
            &nb=
sp;    NumArgs,
 
+  IN        BOOLEAN &nbs=
p;            &=
nbsp;  IsSerialized,
 
+  IN        UINT8  =
            &nb=
sp;    SyncLevel,
 
+  IN        UINT64  =
;            &n=
bsp;   IntegerArgument,
 
+  IN        AML_NODE_HANDLE&n=
bsp;        ParentNode   =
        OPTIONAL,
 
+  OUT       AML_OBJECT_NODE_HANDLE=
  *NewObjectNode        OPTIONAL
 
+  )
 
+{
 
+  EFI_STATUS        &nbs=
p;     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 (
 
+           &nb=
sp; MethodNameString,
 
+           &nb=
sp; NumArgs,
 
+           &nb=
sp; IsSerialized,
 
+           &nb=
sp; SyncLevel,
 
+           &nb=
sp; NULL,
 
+           &nb=
sp; &MethodNode
 
+           &nb=
sp; );
 
+  if (EFI_ERROR (Status)) {
 
+    ASSERT (0);
 
+    return Status;
 
+  }
 
+
 
+  // Return ReturnedNameString if provided.
 
+  if (ReturnedNameString !=3D NULL) {
 
+    Status =3D AmlCodeGenReturnNameStringIntegerArgume=
nt (
 
+           &nb=
sp;   ReturnedNameString,
 
+           &nb=
sp;   IntegerArgument,
 
+           &nb=
sp;   (AML_NODE_HANDLE)MethodNode,
 
+           &nb=
sp;   NULL
 
+           &nb=
sp;   );
 
+    if (EFI_ERROR (Status)) {
 
+      ASSERT (0);
 
+      goto error_handler;
 
+    }
 
+  }
 
+
 
+  Status =3D LinkNode (
 
+           &nb=
sp; MethodNode,
 
+           &nb=
sp; ParentNode,
 
+           &nb=
sp; NewObjectNode
 
+           &nb=
sp; );
 
+  if (EFI_ERROR (Status)) {
 
+    ASSERT (0);
 
+    goto error_handler;
 
+  }
 
+
 
+  return Status;
 
+
 
+error_handler:
 
+  if (MethodNode !=3D NULL) {
 
+    AmlDeleteTree ((AML_NODE_HANDLE)MethodNode);<=
/o:p>
 
+  }
 
+
 
+  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 (#108972) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--_000_DS7PR12MB5789A740E12E156BD328E66ECBF8ADS7PR12MB5789namp_--