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 BF0A87803CE for ; Thu, 21 Dec 2023 13:56:00 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=uljwjlS5ZbG65n9ebuAhuaD1esIl74uJsAb6eb4XC+4=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Received-SPF:ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Authentication-Results-Original:Message-ID:Date:User-Agent:Subject:To:Cc:References:From:In-Reply-To:MIME-Version:NoDisclaimer: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:Content-Transfer-Encoding; s=20140610; t=1703166959; v=1; b=nP58JAmDvBq90iAx2TXEAldrwTzhL3KMaSwvXCuKrtBFjS7QpEz0DrTBES/rIhQ0gFJJtwfX ub1zquBfFL1vkEPLvHqxUMYlvGV5mOxAArgeudNNo7Ceinwog/E7OvkpwaMD8as1Kl6kRDJfJYE 6y7iGQFsvLXEgYgAdQ6DxX1Y= X-Received: by 127.0.0.2 with SMTP id Jz1eYY7687511xZf7j49s4VQ; Thu, 21 Dec 2023 05:55:59 -0800 X-Received: from EUR05-AM6-obe.outbound.protection.outlook.com (EUR05-AM6-obe.outbound.protection.outlook.com [40.107.22.46]) by mx.groups.io with SMTP id smtpd.web10.51677.1703166958474314284 for ; Thu, 21 Dec 2023 05:55:58 -0800 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=HHhyN3CqMHrMkxmXQftA6PL8xr0FCdczv26DmPLssLntaqBu9RTNoOARDwu7A0KTnK4KRABc6+rKAQ/Ar3GsXiCOGoXKeBlJLVC4se+OGWNemdVxpfvhzIf/UBWRt5XxiGWA5FP3s9ryjTGr9S6xWaNTRXmWTEV5Y4i6z1cnRTILp7DwjVUzI2Uk6NO8h5JRUNUgRSHgc6fd0hwZTybEhin59IZjF/zXxv2QYnEzrolb9n1I4GSwmqqsFJEW89uzRNh6YfBrgtpdgEQf/xFAKXRQ2f4kekjjKI9/sQrpkaJD0epN2skT4hgsY8MeViZ3nY190CxwWzT7ynQ/ejde1Q== ARC-Message-Signature: i=2; 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=78Cg9FZ+ituLa5wROkpG9FtBnVXKUy2ZQyWegP23TY4=; b=Qz0m3AoTgxB3WkaUtje5bttpxpb/hiqideY0StvQWxQgVBoCbhGXxDK2wzLbyJ3Q6JXrzY3+g0ho323s8+w2kx9RjeMmjd+jvfGydnLpO1f/Cez7of0BBE5q1HL1xNIX1h/Pkf0gou1TSLF7Zt3EouBJYQ5qWcvuGoYX3JDFh2AQ3jlaT/kzeURLIYKDxqkXYjSE/+pozumxaI5LoBnJy63WURLX+5DlqnXxl/74cLCHzvRaBndw8Q6UO4usOZi3stEzgzZ7T1zDRkamoEuPvrOlH7Y3cbPR0qfDI/6QlDGhE284zO6stM/EFEbxdTrWxfIDmskG1Jgq2IxGh626+A== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) X-Received: from DB8P191CA0019.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:130::29) by GV1PR08MB8644.eurprd08.prod.outlook.com (2603:10a6:150:85::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.40; Thu, 21 Dec 2023 13:55:52 +0000 X-Received: from DU2PEPF0001E9C5.eurprd03.prod.outlook.com (2603:10a6:10:130:cafe::7b) by DB8P191CA0019.outlook.office365.com (2603:10a6:10:130::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.19 via Frontend Transport; Thu, 21 Dec 2023 13:55:52 +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 DU2PEPF0001E9C5.mail.protection.outlook.com (10.167.8.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.14 via Frontend Transport; Thu, 21 Dec 2023 13:55:51 +0000 X-Received: ("Tessian outbound 20615a7e7970:v228"); Thu, 21 Dec 2023 13:55:51 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: e4b08335aeb55272 X-CR-MTA-TID: 64aa7808 X-Received: from ef094d4c9087.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 142DBE73-D2F5-401E-9AE5-CFF70519E564.1; Thu, 21 Dec 2023 13:55:41 +0000 X-Received: from EUR03-AM7-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id ef094d4c9087.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 21 Dec 2023 13:55:41 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SKzIKQsQQJ/Cy6v2pvtJHZwCY43exAAuF/AdlzcdECvaIyVIFAqPoaMA64qHQ/xDPLL0eyC3mX4PnVllQGPfUQU2YYqI0OWaetCGLbLosnSFe6QXa7u4zvKCBVqioGuJVo3G5kf5qRBWTfFyAhKgM6/qCFc9TFv0s7Fs6hskC5pQ8WVji91csjxj+cw1IhmV238Zwh9I2Kp34bjTOViKhAZXmf1NgM/HO9Kkr6FgJp1N9zf0fXkLh4xTMFQt/646m5QPEHUeDdPFNK20NaFf9oKwO8IJrtbA78JHC+pICUYK4SKpBuPm6oXMNeZcgKNrRiUytkcvWjG5lin1M/3Duw== 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=78Cg9FZ+ituLa5wROkpG9FtBnVXKUy2ZQyWegP23TY4=; b=QDyxEf777VbBK/oIitu1J0dsFWbjvIorjRbs+BWPNFjnaOXo9ckWK32HD5UGX5EhkD7HVz6mJwjlPJsTXOxO50ZRmuMNSfXvJoSMGJVX0i5kBe6GHd0/gENr3Zbgz9q/mnbQxqDZuAOpPkCBnQHGFDDGlh5jWETKFsSFJ8vlyL9WjuVxaD7WzgVKCzDETAi/GUfyT3WHgpX9fHrySbMnE+tTgcCTPNN4W5HYgXPZz/ScwfadNDCqGF390HbkVhRQwhr99A1neMIpsSeSFH5yaNZ6Lnb30b1UoMzufcjyBahMFXc9/9IpUJqILQDSWFwWv1yWkVRyApArnKSpwFBbCQ== 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 Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-Received: from AS8PR08MB6806.eurprd08.prod.outlook.com (2603:10a6:20b:39b::12) by DU0PR08MB10367.eurprd08.prod.outlook.com (2603:10a6:10:409::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7113.18; Thu, 21 Dec 2023 13:55:38 +0000 X-Received: from AS8PR08MB6806.eurprd08.prod.outlook.com ([fe80::f36e:3882:2fce:d775]) by AS8PR08MB6806.eurprd08.prod.outlook.com ([fe80::f36e:3882:2fce:d775%4]) with mapi id 15.20.7113.019; Thu, 21 Dec 2023 13:55:38 +0000 Message-ID: <83bbfabf-bef8-467b-8c96-7386005022ff@arm.com> Date: Thu, 21 Dec 2023 13:55:37 +0000 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] [Resend PATCH v5 4/4] DynamicTablesPkg: AML Code generation to invoke a method To: Abdul Lateef Attar , devel@edk2.groups.io Cc: Abdul Lateef Attar , Pierre Gondois , "nd@arm.com" References: <0304349ab5b384980681427b98dc3313faf279eb.1703064925.git.AbdulLateef.Attar@amd.com> From: "Sami Mujawar" In-Reply-To: <0304349ab5b384980681427b98dc3313faf279eb.1703064925.git.AbdulLateef.Attar@amd.com> X-ClientProxiedBy: LO4P123CA0369.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18e::14) To AS8PR08MB6806.eurprd08.prod.outlook.com (2603:10a6:20b:39b::12) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: AS8PR08MB6806:EE_|DU0PR08MB10367:EE_|DU2PEPF0001E9C5:EE_|GV1PR08MB8644:EE_ X-MS-Office365-Filtering-Correlation-Id: 642d3b16-1a05-485f-3f37-08dc022c8b49 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: exjZ62XPhp1Gyf93ShY94AOGda/3LrkwFDn6DWyAmIDky/tXJ4eLDTcXG6FKU45CxmKJVEnkUREh7g2Ctks/A9M3bJd6Wj2S7VrN989TKAVEhwmD/ogyGN5u/gzweM3Vjk1m0Q1xUTuiBiX80lOIp1p5xqRTNL0WwYbSX4vsRXp3UjJpsqsQXCKkgQC3/uKBUNy3mb3xR0fmrOOYwRelS/rkccdhBKmHX8lwrCHydQKSt5VzrB27wKwjELkdUBN6C5LC3VQKIyuefFKoWCVTCMbVVvyf9AQv6NUa7VVdtLBq2255ia5mOB2oJnHPS21WUl+HmSD9NAbsbOGK2H9kK+8wVQC3ivGMispUoqbSp2BHG44+TQHPiMmH/1+wRUJ4d0mrPGQADACM0P/5zRUbdJ+P/Zhr6SS30mepyeUEUk94gaVvpwZgiFnSSRlfpA+8eKLroSxQa+wwJgPrOCt5VBldywgxLsY18igIFF6W6OVMEKlW8FPh/Is9pmgFvC0EfFSEV6qNDpKedtb2adzpciBrCUlYHcZJusvK6F3ivC0uoSCJt71ZyIxZcivv6bHU1P/CtUtktgyr+w04nCt+9GiU4ZgBsz10td2qNFCcrc/c2PDoZ3PjXbxg5m/VjRJiFQEdJDul9piRqloZI4T7gA== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR08MB6806.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(136003)(346002)(39860400002)(366004)(396003)(230922051799003)(186009)(64100799003)(451199024)(1800799012)(31686004)(41300700001)(38100700002)(66556008)(2906002)(5660300002)(30864003)(8936002)(66476007)(4326008)(8676002)(54906003)(316002)(66946007)(44832011)(31696002)(26005)(86362001)(6512007)(36756003)(83380400001)(6506007)(6486002)(2616005)(478600001)(53546011)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB10367 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: DU2PEPF0001E9C5.eurprd03.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: ffffd346-7467-4273-d8b6-08dc022c8331 X-Microsoft-Antispam-Message-Info: 0aAeoJcuTY+ZczKObwUNsFiRnf4qlxAnUJ76zbpFR5vf2izawfJwOxtruMYiZ0nqpWdc48B2XAu2Lczo5XQsEZ+/HYnfBWHCKkiDD+v5oXQRw+udXr7HBwmobso0bYp7qsLOxJbIkkN5JRokGX1xNe8r0GbypwZfkH/D1YF8Tvi1JEt/whm679rsgrfDEREjYsoWdpvqhCko8wAnVdpE04HwgIzPMwe7OJR82YBylI00q4nDRmxaeQp6f+H9cxykGKC5py1ySU5eKQF5CjAaKWREL7a6EwNXAFmugMxsZZhSBlJbZ6Z/I8NObYepSbJ6O4HqBZieKlPMKnyGUUs9vqNaqnGZl08S1EWFeyQTRm5ukhNW0NxTKPCIryMi4biO/QkfOVzOW7CyWegglr05exYOINJGlu1qOiFt0061mSjSQ/tnUg8IAeO36CgiuOIM6srooeHvNoXTpCwRXHPpcXfviKOMdMO0AyajUPLWDtDcPdfFqs0kC3VMs96st3Xcpr2KhIOJBZAYSJhouvOqziSpEstEyxfpkuLigUDrHZNTXWWdkvCCU0reUVtmN66rpbb2T7K5fSaBd8GN0TkYVTgr6clYLXspxauhjiJOh1hk2DtdbrFkL8zmTkHFmi6TNc3bN2m0WDCEWcdtuKSVqOhRakzFMR0MagSo8jtK8wypfqfbg21QWDtJE3hWni3UT0B9Xkos5kYXyJq/3YiddPI8cEWbB8PgcvCebbbpHa0bF4RiLrK0yZCwLZ6odJdsUjZtGeJHj/8O97fWaU8BpQ== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Dec 2023 13:55:51.8261 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 642d3b16-1a05-485f-3f37-08dc022c8b49 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: DU2PEPF0001E9C5.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB8644 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: ef5NVtfoZLAW05nkBAZFOvEmx7686176AA= Content-Language: en-GB Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=nP58JAmD; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); 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 Hi Abdul, I have some minor feedback maked inline as [SAMI]. I think other than the typecast change for the value returned by=20 StrSize(), the remainder of the patch looks ok to me (i.e. with the=20 minor changes I suggested). Please let me know if you agree with my suggestions and I will make the=20 changes and get this patch merged. Regards, Sami Mujawar On 20/12/2023 09:38 am, Abdul Lateef Attar wrote: > From: Abdul Lateef Attar > > Adds API to generate AML code to invoke/call another > method. Also provides ability to pass arguments of > type integer, string, ArgObj or LocalObj. > > Cc: Pierre Gondois > Cc: Sami Mujawar > Signed-off-by: Abdul Lateef Attar > --- > .../Include/Library/AmlLib/AmlLib.h | 112 +++++++++ > .../Common/AmlLib/CodeGen/AmlCodeGen.c | 235 +++++++++++++++++- > 2 files changed, 346 insertions(+), 1 deletion(-) > > diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTa= blesPkg/Include/Library/AmlLib/AmlLib.h > index eb8740692f..043ec3d842 100644 > --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h > +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h > @@ -101,6 +101,56 @@ typedef enum { > AmlAddressRangeMax =3D 4 > } AML_MEMORY_ATTRIBUTES_MTP; > =20 > +/** Method parameter types > + > + Possible values are: > + 0 - AmlMethodParamTypeInteger > + 1 - AmlMethodParamTypeString > + 2 - AmlMethodParamTypeArg > + 3 - AmlMethodParamTypeLocal > + > + @par Reference(s) > + - ACPI 6.5, s20.2.5 "Term Objects Encoding" > + > +**/ > +typedef enum { > + AmlMethodParamTypeInteger =3D 0, > + AmlMethodParamTypeString =3D 1, > + AmlMethodParamTypeArg =3D 2, > + AmlMethodParamTypeLocal =3D 3 > +} AML_METHOD_PARAM_TYPE; > + > +/** AML Method parameter data > + holds the AML method parameter data. > +**/ > +typedef union { > + UINT8 Arg; > + UINT8 Local; > + UINT64 Integer; > + VOID *Buffer; > +} AML_METHOD_PARAM_DATA; > + > +/** structure to hold AML method parameter types > + Type - Type of parameter > + Data - holds data of parameter > + if Type is AmlMethodParamTypeInteger > + then Data is of type Integer to hold integer value. > + if Type is AmlMethodParamTypeString > + then Data contains null terminated string. > + If Type is AmlMethodParamTypeArg > + then Data contains the Argument number, > + 0 to 6 are supported value. > + If Type is AmlMethodParamTypeLocal > + then Data contains the Local variable number, > + 0 to 7 are supported value. > + DataSize - for future use > +**/ > +typedef struct { > + AML_METHOD_PARAM_TYPE Type; > + AML_METHOD_PARAM_DATA Data; > + UINTN DataSize; > +} AML_METHOD_PARAM; > + > /** Parse the definition block. > =20 > The function parses the whole AML blob. It starts with the ACPI DSDT/= SSDT > @@ -1693,4 +1743,66 @@ AmlAddNameStringToNamedPackage ( > IN AML_OBJECT_NODE_HANDLE NamedNode > ); > =20 > +/** AML code generation to invoke/call another method. > + > + This method is a subset implementation of MethodInvocation > + defined in the ACPI specification 6.5, > + section 20.2.5 "Term Objects Encoding". > + Added integer, string, ArgObj and LocalObj support. > + > + Example 1: > + AmlCodeGenInvokeMethod ("MET0", 0, NULL, ParentNode); > + is equivalent to the following ASL code: > + MET0 (); > + > + Example 2: > + AML_METHOD_PARAM Param[4]; > + Param[0].Data.Integer =3D 0x100; > + Param[0].Type =3D AmlMethodParamTypeInteger; > + Param[1].Data.Buffer =3D "TEST"; > + Param[1].Type =3D AmlMethodParamTypeString; > + Param[2].Data.Arg =3D 0; > + Param[2].Type =3D AmlMethodParamTypeArg; > + Param[3].Data.Local =3D 2; > + Param[3].Type =3D AmlMethodParamTypeLocal; > + AmlCodeGenInvokeMethod ("MET0", 4, Param, ParentNode); > + > + is equivalent to the following ASL code: > + MET0 (0x100, "TEST", Arg0, Local2); > + > + Example 3: > + AML_METHOD_PARAM Param[2]; > + Param[0].Data.Arg =3D 0; > + Param[0].Type =3D AmlMethodParamTypeArg; > + Param[1].Data.Integer =3D 0x100; > + Param[1].Type =3D AmlMethodParamTypeInteger; > + AmlCodeGenMethodRetNameString ("MET2", NULL, 2, TRUE, 0, ParentNode,= &MethodNode); > + AmlCodeGenInvokeMethod ("MET3", 2, Param, MethodNode); > + > + is equivalent to the following ASL code: > + Method (MET2, 2, Serialized) > + { > + MET3 (Arg0, 0x0100) > + } > + > + @param [in] MethodNameString The method name to be called or invoked. > + @param [in] NumArgs Number of arguments to be passed, > + 0 to 7 are permissible values. > + @param [in] Parameters Contains the parameter data. > + @param [in] ParentNode The parent node to which the method invo= cation > + nodes are attached. > + > + @retval EFI_SUCCESS Success. > + @retval EFI_INVALID_PARAMETER Invalid parameter. > + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. > + **/ > +EFI_STATUS > +EFIAPI > +AmlCodeGenInvokeMethod ( > + IN CONST CHAR8 *MethodNameString, > + IN UINT8 NumArgs, > + IN AML_METHOD_PARAM *Parameters OPTIONAL, > + IN AML_NODE_HANDLE ParentNode > + ); > + > #endif // AML_LIB_H_ > diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c = b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c > index a6db34fb97..ddec9b67ed 100644 > --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c > +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c > @@ -2,6 +2,7 @@ > AML Code Generation. > =20 > Copyright (c) 2020 - 2022, Arm Limited. All rights reserved.
> + Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. > =20 > SPDX-License-Identifier: BSD-2-Clause-Patent > **/ > @@ -921,7 +922,7 @@ AmlCodeGenNameUnicodeString ( > Status =3D AmlCreateDataNode ( > EAmlNodeDataTypeRaw, > (CONST UINT8 *)String, > - StrSize (String), > + (UINT32)StrSize (String), [SAMI] This does not seem to be related to this patch. Were you getting=20 any issues when building? If so, can you submit a separate patch, please? If you agree, I will drop the above line from this patch and merge. [/SAMI] > &DataNode > ); > if (EFI_ERROR (Status)) { > @@ -3849,3 +3850,235 @@ exit_handler: > =20 > return Status; > } > + > +/** AML code generation to invoke/call another method. > + > + This method is a subset implementation of MethodInvocation > + defined in the ACPI specification 6.5, > + section 20.2.5 "Term Objects Encoding". > + Added integer, string, ArgObj and LocalObj support. > + > + Example 1: > + AmlCodeGenInvokeMethod ("MET0", 0, NULL, ParentNode); > + is equivalent to the following ASL code: > + MET0 (); > + > + Example 2: > + AML_METHOD_PARAM Param[4]; > + Param[0].Data.Integer =3D 0x100; > + Param[0].Type =3D AmlMethodParamTypeInteger; > + Param[1].Data.Buffer =3D "TEST"; > + Param[1].Type =3D AmlMethodParamTypeString; > + Param[2].Data.Arg =3D 0; > + Param[2].Type =3D AmlMethodParamTypeArg; > + Param[3].Data.Local =3D 2; > + Param[3].Type =3D AmlMethodParamTypeLocal; > + AmlCodeGenInvokeMethod ("MET0", 4, Param, ParentNode); > + > + is equivalent to the following ASL code: > + MET0 (0x100, "TEST", Arg0, Local2); > + > + Example 3: > + AML_METHOD_PARAM Param[2]; > + Param[0].Data.Arg =3D 0; > + Param[0].Type =3D AmlMethodParamTypeArg; > + Param[1].Data.Integer =3D 0x100; > + Param[1].Type =3D AmlMethodParamTypeInteger; > + AmlCodeGenMethodRetNameString ("MET2", NULL, 2, TRUE, 0, ParentNode,= &MethodNode); > + AmlCodeGenInvokeMethod ("MET3", 2, Param, MethodNode); > + > + is equivalent to the following ASL code: > + Method (MET2, 2, Serialized) > + { > + MET3 (Arg0, 0x0100) > + } > + > + @param [in] MethodNameString The method name to be called or invoked. > + @param [in] NumArgs Number of arguments to be passed, > + 0 to 7 are permissible values. > + @param [in] Parameters Contains the parameter data. > + @param [in] ParentNode The parent node to which the method invo= cation > + nodes are attached. > + > + @retval EFI_SUCCESS Success. > + @retval EFI_INVALID_PARAMETER Invalid parameter. > + @retval EFI_OUT_OF_RESOURCES Failed to allocate memory. > + **/ > +EFI_STATUS > +EFIAPI > +AmlCodeGenInvokeMethod ( > + IN CONST CHAR8 *MethodNameString, > + IN UINT8 NumArgs, > + IN AML_METHOD_PARAM *Parameters OPTIONAL, > + IN AML_NODE_HANDLE ParentNode > + ) > +{ > + EFI_STATUS Status; > + UINT8 Index; > + CHAR8 *AmlNameString; > + UINT32 AmlNameStringSize; > + AML_DATA_NODE *DataNode; > + AML_OBJECT_NODE *ObjectNode; > + AML_NODE_HANDLE *NodeStream; > + > + if ((MethodNameString =3D=3D NULL) || (ParentNode =3D=3D NULL)) { > + ASSERT (0); > + return EFI_INVALID_PARAMETER; > + } > + > + if ((NumArgs > 7) || > + ((Parameters =3D=3D NULL) && (NumArgs > 0))) > + { > + ASSERT (0); > + return EFI_INVALID_PARAMETER; > + } > + > + /// Allocate space to store methodname, object, data node pointers > + NodeStream =3D AllocateZeroPool (sizeof (AML_NODE_HANDLE) * (NumArgs += 1)); > + if (NodeStream =3D=3D NULL) { > + ASSERT (0); > + return EFI_OUT_OF_RESOURCES; > + } > + > + /// Create a called or invoked method name string. > + Status =3D ConvertAslNameToAmlName (MethodNameString, &AmlNameString); > + if (EFI_ERROR (Status)) { > + ASSERT_EFI_ERROR (Status); > + goto exit_handler; > + } > + > + Status =3D AmlGetNameStringSize (AmlNameString, &AmlNameStringSize); > + if (EFI_ERROR (Status)) { > + ASSERT_EFI_ERROR (Status); > + FreePool (AmlNameString); > + goto exit_handler; > + } > + > + DataNode =3D NULL; > + Status =3D AmlCreateDataNode ( > + EAmlNodeDataTypeNameString, > + (UINT8 *)AmlNameString, > + AmlNameStringSize, > + &DataNode > + ); > + FreePool (AmlNameString); > + if (EFI_ERROR (Status)) { > + ASSERT_EFI_ERROR (Status); > + goto exit_handler; > + } > + > + NodeStream[0] =3D (AML_NODE_HANDLE)DataNode; > + > + if (Parameters !=3D NULL) { > + /// Validate and convert the Parameters to the stream of nodes. > + for (Index =3D 0; Index < NumArgs; Index++) { > + switch (Parameters[Index].Type) { > + case AmlMethodParamTypeInteger: > + ObjectNode =3D NULL; [SAMI] I think the above line can be moved right after the 'for'=20 statement. If you agree I can fix this before merging. > + Status =3D AmlCodeGenInteger (Parameters[Index].Data.Integ= er, &ObjectNode); > + if (EFI_ERROR (Status)) { > + ASSERT_EFI_ERROR (Status); > + goto exit_handler; > + } > + > + NodeStream[Index+1] =3D (AML_NODE_HANDLE)ObjectNode; [SAMI] Minor, a space is required before and after '+'. I will fix that=20 before merging. > + break; > + case AmlMethodParamTypeString: > + ObjectNode =3D NULL; > + if (Parameters[Index].Data.Buffer =3D=3D NULL) { > + ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER); > + Status =3D EFI_INVALID_PARAMETER; > + goto exit_handler; > + } > + > + Status =3D AmlCodeGenString (Parameters[Index].Data.Buffer, &O= bjectNode); [SAMI] Minor, I prefer to keep the code within 80 characters. I will fix=20 that before merging. > + if (EFI_ERROR (Status)) { > + ASSERT_EFI_ERROR (Status); > + goto exit_handler; > + } > + > + NodeStream[Index+1] =3D (AML_NODE_HANDLE)ObjectNode; [SAMI] I believe the above line can be moved after the switch block. I=20 can do that if you agree. > + break; > + case AmlMethodParamTypeArg: > + ObjectNode =3D NULL; > + if (Parameters[Index].Data.Arg > (UINT8)(AML_ARG6 - AML_ARG0))= { > + ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER); > + Status =3D EFI_INVALID_PARAMETER; > + goto exit_handler; > + } > + > + Status =3D AmlCreateObjectNode ( > + AmlGetByteEncodingByOpCode (AML_ARG0 + Parameters[I= ndex].Data.Arg, 0), > + 0, > + &ObjectNode > + ); > + if (EFI_ERROR (Status)) { > + ASSERT_EFI_ERROR (Status); > + goto exit_handler; > + } > + > + NodeStream[Index+1] =3D (AML_NODE_HANDLE)ObjectNode; > + break; > + case AmlMethodParamTypeLocal: > + ObjectNode =3D NULL; > + if (Parameters[Index].Data.Local > (UINT8)(AML_LOCAL7 - AML_LO= CAL0)) { > + ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER); > + Status =3D EFI_INVALID_PARAMETER; > + goto exit_handler; > + } > + > + Status =3D AmlCreateObjectNode ( > + AmlGetByteEncodingByOpCode (AML_LOCAL0 + Parameters= [Index].Data.Local, 0), > + 0, > + &ObjectNode > + ); > + if (EFI_ERROR (Status)) { > + ASSERT_EFI_ERROR (Status); > + goto exit_handler; > + } > + > + NodeStream[Index+1] =3D (AML_NODE_HANDLE)ObjectNode; > + break; > + default: > + ASSERT_EFI_ERROR (EFI_INVALID_PARAMETER); > + Status =3D EFI_INVALID_PARAMETER; > + goto exit_handler; > + break; > + } > + } > + } > + > + /// Index <=3D NumArgs, because an additional method name was added. > + for (Index =3D 0; Index <=3D NumArgs; Index++) { > + Status =3D AmlVarListAddTail ( > + (AML_NODE_HANDLE)ParentNode, > + (AML_NODE_HANDLE)NodeStream[Index] > + ); > + if (EFI_ERROR (Status)) { > + ASSERT_EFI_ERROR (Status); > + goto exit_handler_detach; > + } > + } > + > + FreePool (NodeStream); > + return Status; > + > +exit_handler_detach: > + /// The index contains the last successful node attached. > + for ( ; Index > 0; Index--) { > + /// Index contains the node number that is failed for AmlVarListAddT= ail(). > + /// Hence, start detaching from the last successful > + AmlDetachNode (NodeStream[Index-1]); > + } > + > +exit_handler: > + /// Index <=3D NumArgs, because an additional method name was added. > + for (Index =3D 0; Index <=3D NumArgs; Index++) { > + if (NodeStream[Index] !=3D 0) { > + AmlDeleteTree (NodeStream[Index]); > + } > + } > + > + FreePool (NodeStream); > + return Status; > +} -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#112817): https://edk2.groups.io/g/devel/message/112817 Mute This Topic: https://groups.io/mt/103278521/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-