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 9D18CD801A6 for ; Sat, 23 Sep 2023 06:16:16 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=TMkPsdpt8ogwb0feCqqLQatTdvuI6+zT0eJJ+4YTDRc=; 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:msip_labels: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=1695449775; v=1; b=hL2+A8qpb3Vhxp/6OFhHEnxq4we03H4EOcxM7kOfA0wgFjN+UsFWqo/+NuF3HND7Vk01azDK OHrK54zjzpEM6TX+Q+NjXSf6zzJMwk3MHzk8Q44SPi2xrHeg0Txb5yOp8PCEQOLmN6HX32lQUfK hTYoW7EaqOePkoTL1/dDLus0= X-Received: by 127.0.0.2 with SMTP id IKD4YY7687511xsPdovIV7FA; Fri, 22 Sep 2023 23:16:15 -0700 X-Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com [40.107.94.74]) by mx.groups.io with SMTP id smtpd.web10.14993.1695442946991790934 for ; Fri, 22 Sep 2023 21:22:27 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OMJJnvHIIspeaPffEsBu5gVGlYsfyPNhvX+T2gB50zbtqr6nhC8d5i7uKt8FRFfFDmdmOYBPu+1JRf3aIamXv6ZB6gUZHAm+H1b8wu3IYFeH3Wigh4mL4K0R4YjAThtuKMIxWU+8yRlgU2F520S7/XcA/X0OStbqIL32kpkGnZdGIqAjxaE0MSg/UWZOGX0awdl6U03SYLBJEcXEW5azf+LpWciIXpaY0DV1b39/CbgR3tpa8J27M0RCJxUA8pAsypYSfqil4QmoeEzaVrMCSIymjj4PcbJ2bqJx/5Zmhy4D5YE/IMr5ZfDSHUmXFmdGp12erlKLFUFX4MZLm5wx/Q== 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=9ub3COj2VcZTG+WsRmkkmpkIPdcTTcRrlxSCEjhg5v8=; b=aZ8m04pFI7wg2QBxGasxm55MC9WipXV9tET4G0m94m4qzwJUR3QMwfYOs7y8JTcw2vMHvTuJQQI4zZ4LZDGCdVagIdRp/awz0FVky/oGY4GmokcXN6YJV8BoOOAATCZz6bdT9lu6pM6KfJF+uzwpmTKPc+clU3yxFtcgvPhaxd4btdRmXbBIpW74WjFky8SqZihH1m06MujaKfQXmZqpy1NXBoNKzJl50Nu5LRZAqgqcrA51Dm7FBSVo7CAP1VvfL9Yf2vLFzTLbVajXvu8/CL5PeQw48NMffDFX7LL6SfXZnHGbXwNmbXFKSUItdO2Sp0ZDBmjmg+O1TFTYVvj+JA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none X-Received: from IA1PR12MB6458.namprd12.prod.outlook.com (2603:10b6:208:3aa::22) by SJ1PR12MB6241.namprd12.prod.outlook.com (2603:10b6:a03:458::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.21; Sat, 23 Sep 2023 04:22:20 +0000 X-Received: from IA1PR12MB6458.namprd12.prod.outlook.com ([fe80::d727:a124:4199:a8c6]) by IA1PR12MB6458.namprd12.prod.outlook.com ([fe80::d727:a124:4199:a8c6%5]) with mapi id 15.20.6813.017; Sat, 23 Sep 2023 04:22:20 +0000 From: "Attar, AbdulLateef (Abdul Lateef) via groups.io" To: "devel@edk2.groups.io" , "jbrasen@nvidia.com" , Sami Mujawar 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: [edk2-devel] [PATCH v4 2/4] DynamicTablesPkg: Add support for simple method invocation. Thread-Index: AQHZ6kd3XEhbrZrV0kSwiCZ/7TN35LAlgpcAgAANmQCAACmrAIAAC5yAgAIOE9A= Date: Sat, 23 Sep 2023 04:22:20 +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: msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=6054fe02-783f-4d31-b37e-6fb22a11b9fd;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=0;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Method=Standard;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Name=General;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2023-09-23T04:11:38Z;MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: IA1PR12MB6458:EE_|SJ1PR12MB6241:EE_ x-ms-office365-filtering-correlation-id: e6cfc766-d35d-413a-1663-08dbbbecad93 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: HLvqdkusZA9/8J2kXNsCXas79ONLlhkdrTGxaNpd+1Dd+2IQbW89tRJBNUDUGQVY3CroKYQAgagNn3UV27RK0fsDSjXtDyoJNvLe7kc615bIBNmRqUWlfOLm4qjhzMf181qgk+JzM1yNA7BHXyY9t2ff1b2wYPTseqyauR3PkH0zo1WXHiaMnYyATphQk66axh9l9rY6MvSrQd9/KNrAoCWN4Y+u/FbYdeOXROhlIxvnIuAwY+CFDCINtYeKIXe50yRHUtLJ/rAgw6TRmjP8DKQVrKGS9Qfj6phd58DnXgG7Q/Sqbl4exBQ5ntgZ2UNF2S/XUixCUspJEy83fRNhfpFDYLU0RlQoEg1ibYGVfVPwcNqrfpgTBVRy69GYzQTYaHp8KlbZvj/MDU8jnxwd4nXHH0Eb+DCZzFdLAz7FPXd/U0V7ISJjXzvaUJhV3e+/+xgRwGvNwFY+S8GRbPjbxYdYp2tKU9D+cqNBt4HqKMTFrSWTLvckdJeAu1ax7AE+Cs9v2upyEPPdoXkN1lgcUGRBAmhWhfSkL4FuvF0RE17S859EDuyVRK1PZoJtnSOkeiZTqkyiC0L029WEiIYLLdRMDxZjv2y0pequlXq7uAI= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?XLwGgcw3DwU32Jr4pYfNUmeFHvhs4CoX/uQTm/tAA4//edyxmR2pauWszc1S?= =?us-ascii?Q?FhEpgPyMdcjwR0Spd9ymx60IlzR+9m4x9OYOTuP9ySp8XoPg9w/91ePpeSUA?= =?us-ascii?Q?r6+q9uVnexzSpmjx8a/4hMuQIkK157mjC8c7bC33OyZ7uSDIrudIgLaXRnkH?= =?us-ascii?Q?fDJdai7ioEqssozlHnxLqezk2qOwEv/Ji0rTUC1dFmjYKPstJi3tUjzqPnAc?= =?us-ascii?Q?ZzsfL8pCEhJuLFZribCuWw899d9yxfdSjQu5gCyWv9f8vhnWLD9TtE3Fi0l2?= =?us-ascii?Q?yWXdzxfCg2jGqPrpVVHXtF/+uxsDtjmQ5lk4eZ72+vdP8QvMLZ/apakoa8Bu?= =?us-ascii?Q?Ics5C5fqYNTtBFSPYKb0XTvmlWc/jbjbRIh6sRFG0+u71ca8fDsPCgDkt6IU?= =?us-ascii?Q?V0MIlzHMtXY+jXRHB1iDy55K1saFlR33wCSA56lwynyRie0A42ZugwWZjLMp?= =?us-ascii?Q?TMIPnz+Cah6OdhVUE6W1Ly8uuWEePVcxQwy5o56/ffTQnzdOXWQBSHKETksf?= =?us-ascii?Q?teRIMmfqyCmjXlgaz8ccyd60sg/BqXinhrI/U/A85YkKTmJz4lL/zlqYozV5?= =?us-ascii?Q?5K4DrMw+tmZvnQHHxz4PyviZtCQZGZKbIxJSzki9qepjG2AjJ4916mKwJQLR?= =?us-ascii?Q?plYdoTnYNOwPZBEhZtmAG0Y0AYv3rZ2UkGbV05dlkuMCUVtqSxJ4jY1ZyN0e?= =?us-ascii?Q?Qqlx0RGPxf1xpBjjj+vxzz3oAEivi6PuuHAPCocGSzsDmqTslPODZAUPEwY7?= =?us-ascii?Q?U3ZJ4rBMkSG/WX9Rz+c5zWi2ckT3RwKfw9JNwuMeYib2XxDCl7kmu0iuZe//?= =?us-ascii?Q?zyuXt+7t3XF5gRTKhpfHFPg8HnPfKjd9tf3PmpXqBRl/K9hJDEmWVmsWJwY1?= =?us-ascii?Q?7TBxVvYy5nOCtMEL7+ewLtFLM3Xz7s5PNy9nS+NaN0RpRpKc/yOpU2s/5rtj?= =?us-ascii?Q?TmkC1DGzpxK7k5MYbwUVhbycEMo70YJ40zONZmD5wS/MYbptmpcHzJHqRJFg?= =?us-ascii?Q?iX1WpwZl+e7LQ4BADI0LUrR1pwQ8dlIJeyMlqx9a/hgc4LU4WT+boGYeqoRa?= =?us-ascii?Q?Sc+F55S5g/Hvfxw6frS3cH1pe/SVe9u10x9GonYsbjaN5MbQ2SAw8PhBi8BM?= =?us-ascii?Q?E0KJeV0W1zzV0ZM6dWRJH4jgwqWYX96pasb07R8bRm5WrYSwu1n4zVbfLoHF?= =?us-ascii?Q?4ZDT+Q/rnf/4PeEIHfwCLhIUd0OLYsiae8YHJZLr8W3uSTwJOM5opgLpyoj4?= =?us-ascii?Q?Jo29smfa4tmV9064b4xlJe5fy7QG2kFvxX2s/wt1r89B1ZuBRQVmiNm1xhfP?= =?us-ascii?Q?Xdmo4YsIbJVuS9AFLVLj1fNa2HPPP7XpUbjtMoUYXKQNMqny1S/dJJYM7nVt?= =?us-ascii?Q?GZGm2sXuqtI3n+SRB9BN8RBl6mMt5M2MV4HReAuRmu1/qChiceRpskSDP3Me?= =?us-ascii?Q?KpzdtnWbmXpA7NWwKD9wo1w+N1PYTB+V+cqbmyLNMxat0y8r/YSl4RZ0kBA9?= =?us-ascii?Q?CkZ+wG/LqQjKGoZto7Pjz3dnKepas5eboTXMCmt5XlXxeWfE5c1nbVdMzw?= =?us-ascii?Q?=3D=3D?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: IA1PR12MB6458.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: e6cfc766-d35d-413a-1663-08dbbbecad93 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Sep 2023 04:22:20.1401 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: gwspgOgp+s3rQHVWRKjBfgeMsEhcnEVo1ctM3FPAO5e6VNE04N82G9wMF7JM45jTsrKHEpF7Sj5v4QVnDX0s3g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR12MB6241 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,AbdulLateef.Attar@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: PSda1l7QBUP4bHLpnv1FbqTUx7686176AA= Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_IA1PR12MB6458D84A392B1AC547D4D125E0FEAIA1PR12MB6458namp_" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=hL2+A8qp; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=none; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") --_000_IA1PR12MB6458D84A392B1AC547D4D125E0FEAIA1PR12MB6458namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable [AMD Official Use Only - General] Hi Jeff, Sami, I'm not reviewer, just providing the opinion. How about making it generic(generic to integer argument) instead of single= integer argument. IN UINT64 IntegerArgument IN UINT64 *IntegerArgumentArray. Create the list(by making use of AmlVarListAddTail) of data object depends = on IntergerArgument value. Also, I think if data in data node is AML_ARG0(0x68), AML_ARG1...., then it= will considered as Arg0, Arg1, ....etc. Thanks AbduL From: devel@edk2.groups.io On Behalf Of Jeff Brasen = via groups.io Sent: Friday, September 22, 2023 2:19 AM 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. Caution: This message originated from an External Source. Use proper cautio= n when opening attachments, clicking links, or responding. 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 >; n= d > 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 (#109024): https://edk2.groups.io/g/devel/message/109024 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_IA1PR12MB6458D84A392B1AC547D4D125E0FEAIA1PR12MB6458namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

[AMD Official Use Only - General]


Hi Jeff, Sami,

        &nbs= p;       I’m not reviewer, just providi= ng the opinion.

How about making it generic(generic to integer argum= ent)  instead of single integer argument.

    IN     &= nbsp;  UINT64         &nb= sp;        IntegerArgument

    IN      =   UINT64         &n= bsp;         *IntegerArgumentArray.

Create the list(by making use of AmlVarListAddTail) = of data object depends on IntergerArgument value.

 

Also, I think if data in data node is AML_ARG0(0x68)= , AML_ARG1…., then it will considered as Arg0, Arg1, ….etc.

 

Thanks

AbduL

 

 

From: devel@edk2.groups.io <devel@edk2.gro= ups.io> On Behalf Of Jeff Brasen via groups.io
Sent: Friday, September 22, 2023 2:19 AM
To: Sami Mujawar <Sami.Mujawar@arm.com>; devel@edk2.groups.io<= br> 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: [edk2-devel] [PATCH v4 2/4] DynamicTablesPkg: Add suppo= rt for simple method invocation.

 

Caution: This message originated from an External Source. Use proper caution= when opening attachments, clicking links, or responding.

 

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>
Sent: Thursday, September 21, 2023 2:07 PM
To: Jeff Brasen <jbrasen@nv= idia.com>; 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.

 

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 (#109024) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--_000_IA1PR12MB6458D84A392B1AC547D4D125E0FEAIA1PR12MB6458namp_--