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 5D1C5D81163 for ; Mon, 11 Dec 2023 10:37:53 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=UArhVIf7rO5c4ZHotH51Rc+OcKbUsqRb5RhA6WbWYao=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:Received-SPF:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1702291072; v=1; b=gEuq4GgixAdPjt0d6Hun/wSIVv3fa77n+M+DHOSHpwTG7XP0J0AAU5inTu6D+485xJnnSxKS v8E2anVP+72oJ7HI5uLIdxUZkY1vmUVi19e20rHNtqppNmOnS1OdBZptkHUma9YAIRoAfV1e1Du tfOlOSr9luoEON+twWxayX8s= X-Received: by 127.0.0.2 with SMTP id CARiYY7687511xwJO8FopLFT; Mon, 11 Dec 2023 02:37:52 -0800 X-Received: from NAM10-MW2-obe.outbound.protection.outlook.com (NAM10-MW2-obe.outbound.protection.outlook.com [40.107.94.65]) by mx.groups.io with SMTP id smtpd.web10.5615.1702291071194603025 for ; Mon, 11 Dec 2023 02:37:51 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZSoZV47Y/2n6Dah0aSTLkpr5Sy0K1yjoHgodlOmtcepLRS5ZBDQTbSDBwpx/OaM+kqS2SkQV/iOIp2muXlbxavU0ilEwnm1I/0hC/8ZBCutN1Q9tv0UvJjFvbFTeMvED/rVoEsJMD/u/PPu0tUuws8F8R00YI+zPnlJsPW92Qj5H88PAVsZkTCOrvt6fkF/L+6AuFitlFaQHML8yrnpzeKOx3tFn4dgPKk+afFcyC74EuagVR56p7iquMT1pkbeaPhQvkiPlZInB0nZUJDOlSWpCVsdI6C1B5z896bZTARz85HrnnDY/pdw3NM5Reuxyh2+FjRHyR0tj+Gx4Py3LBA== 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=tblRJFsoWHt6PJdPqLuxuCRDaAg/s2Rj7pNuwhjVGg0=; b=ZTFhQcMesCxF8rxBisp3ZRX0mYwzZciAVr7J5x0H9muktIjnEQuslHdswegYBqh1ulLl5rl99JAY2cpmqSmQL0wxqFqgcPwtWxBOQn1dtYiFJDfJpP+89jLHQqNCTowiGnVOxWZctTfSNOGBAzia7Dwm7OsuoZjfQI4Omp/rStv8tU32kvuGVBP3fMeQKUDg1rU4BiAGiKsheyPxXhhITim/yrlxFjmX/sR5MKXDePz07i8u6vXvQir90OlZT/B285GFi8ygbbSw7eyoSzlXtJ0YCYoqMo0XmD/srog0rgRWv6XbX3tGjtWYKxmMnHbga1mQL6qdkHvVMlYfAGAfGQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0) X-Received: from MN2PR05CA0050.namprd05.prod.outlook.com (2603:10b6:208:236::19) by PH7PR12MB8055.namprd12.prod.outlook.com (2603:10b6:510:268::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7068.32; Mon, 11 Dec 2023 10:37:47 +0000 X-Received: from BL6PEPF0001AB55.namprd02.prod.outlook.com (2603:10b6:208:236:cafe::a) by MN2PR05CA0050.outlook.office365.com (2603:10b6:208:236::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.21 via Frontend Transport; Mon, 11 Dec 2023 10:37:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C X-Received: from SATLEXMB04.amd.com (165.204.84.17) by BL6PEPF0001AB55.mail.protection.outlook.com (10.167.241.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7091.18 via Frontend Transport; Mon, 11 Dec 2023 10:37:46 +0000 X-Received: from SATLEXMB06.amd.com (10.181.40.147) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Mon, 11 Dec 2023 04:37:46 -0600 X-Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB06.amd.com (10.181.40.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.34; Mon, 11 Dec 2023 04:37:46 -0600 X-Received: from BLR-LAB-SFW01.amd.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.34 via Frontend Transport; Mon, 11 Dec 2023 04:37:44 -0600 From: "Abdul Lateef Attar via groups.io" To: CC: Abdul Lateef Attar , Pierre Gondois , Sami Mujawar Subject: [edk2-devel] [PATCH v3 5/5] DynamicTablesPkg: Adds wrapper API AmlCodeGenMethodInvokeMethodArgn Date: Mon, 11 Dec 2023 16:07:33 +0530 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL6PEPF0001AB55:EE_|PH7PR12MB8055:EE_ X-MS-Office365-Filtering-Correlation-Id: 66db9ace-4a6a-44ed-c0ef-08dbfa353724 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: gwh5vq5HfRcote9rl1FI5XhQ+Biy2Z+GqJHLtneS/Y5Zjk7ViEizr/+vqm8ZAYJxx55ceknDcHct82qwImIitPGc2mYcBVXHjGy9cZ9+vr8acYbpLBdxAbQo1kgzsM+Pf/6ReCwXZS9B4WkbOy23bkX57syYmYQt43Y/b5nMsdo3JzVUEmqUJyiPul5Iwj3fxBMJ5AYgzfMnder7o0sHTj4zMf0ikHtKkY6U475GYSuu+CE1DIAQrPsYQVq0PLLfe9ajciMeOUnHhXF3lp82TXml79h9owbEbDfveZZ5b7ogIF9i/s5BONqgixt0Zz8eBZitMmjcfH+i60DkxSsz/p+IDU1Pt+0qnPndUe9Hq4z7brwor6j8kSU1F2sHDSl46iDiFjtFHKidqTNstQyPY12hkBr5oOcy+D0UxUE9wr30PGl3rRRfXzPECcqYQdZO/bETaZ8C0YEGOoW8Vxle7PGRaKcn9I3b4BnsHZMJHIcC0Jdc1kSeBY8Dh45ATnp/i5Nf5Vuy64mDNXT8HSCTPZapc4c8S64Ba5kZFHHmBXvwooRSyNSjdDcHQeLgOoHgrirf37jlVnduOgvM5uJHAeDvO8kwokSYBQbjLGNuSqUTRuDXkOfWFp8fu9W963Ur/eOxVdrKy3/A8aNx7mSLdakQn6G/IIwfjQt1u2crFT0j+3M0gzfy0GzNj6OfN5Q+QxzeFTWFX1jBQ3c8ap5Z68fR1yp83qR0L5F3z4m/VoC/4hMuMtx/chFYbEKi9NqBnfD26f2PAI9XJs1zZTbxndw7QvQaaNUQJhuX9SlZboc= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2023 10:37:46.7954 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 66db9ace-4a6a-44ed-c0ef-08dbfa353724 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BL6PEPF0001AB55.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8055 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: RUzq7qEiOccfyvbR01X6HrRqx7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=gEuq4Ggi; 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}") From: Abdul Lateef Attar Adds a wrapper API AmlCodeGenMethodInvokeMethodArgnWithInteger() to the AmlCodeGenMethodInvokeMethodArgn(). Wrapper API provides ability to add integer arguments along with ArgN argument. This help to generate dynamic code to invoke another method(might be in static ASL file) with build-in argument parameters plus integer arguments. e.g: Method (MET0, 3, Serialized) { \_SB.MET1 (Arg0, Arg1, Arg2, 0x10, 0x20)) } Cc: Pierre Gondois Cc: Sami Mujawar Signed-off-by: Abdul Lateef Attar --- .../Include/Library/AmlLib/AmlLib.h | 68 +++++++ .../Common/AmlLib/CodeGen/AmlCodeGen.c | 187 ++++++++++++++++++ 2 files changed, 255 insertions(+) diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTabl= esPkg/Include/Library/AmlLib/AmlLib.h index 5ab205b5f0..132846a38a 100644 --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h @@ -1739,4 +1739,72 @@ AmlCodeGenMethodInvokeMethodArgn ( OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL ); =20 +/** AML code generation for a method invoking another method + with ArgN arguments and optionally integer arguments. + + Arg0Int =3D 0x10; + Arg1Int =3D 0x20; + AmlCodeGenMethodInvokeMethodArgnWithInteger ( + "MET0", "MET1", 4, TRUE, 3, + Arg0Int, Arg1Int, NULL, NULL, NULL, NULL, + ParentNode, NewObjectNode + ); + is equivalent of the following ASL code: + Method(MET0, 4, Serialized, 3) { + MET1 (Arg0, Arg1, Arg2, Arg3, 0x10, 0x20) + } + + @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] InvokeMethodNameString The called/invoked method's name. + Must be a NULL-terminated ASL NameStri= ng + e.g.: "MET1", "_SB.MET1", 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] IntegerArg0 If provided and meets the validation c= riteria, + then set as integer argument to invoke= d method. + @param [in] IntegerArg1 If provided and meets the validation c= riteria, + then set as integer argument to invoke= d method. + @param [in] IntegerArg2 If provided and meets the validation c= riteria, + then set as integer argument to invoke= d method. + @param [in] IntegerArg3 If provided and meets the validation c= riteria, + then set as integer argument to invoke= d method. + @param [in] IntegerArg4 If provided and meets the validation c= riteria, + then set as integer argument to invoke= d method. + @param [in] IntegerArg5 If provided and meets the validation c= riteria, + then set as integer argument to invoke= d method. + @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. +**/ +EFI_STATUS +EFIAPI +AmlCodeGenMethodInvokeMethodArgnWithInteger ( + IN CONST CHAR8 *MethodNameString, + IN CONST CHAR8 *InvokeMethodNameString, + IN UINT8 NumArgs, + IN BOOLEAN IsSerialized, + IN UINT8 SyncLevel, + IN UINT64 *IntegerArg0 OPTIONAL, + IN UINT64 *IntegerArg1 OPTIONAL, + IN UINT64 *IntegerArg2 OPTIONAL, + IN UINT64 *IntegerArg3 OPTIONAL, + IN UINT64 *IntegerArg4 OPTIONAL, + IN UINT64 *IntegerArg5 OPTIONAL, + IN AML_NODE_HANDLE ParentNode OPTIONAL, + OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL + ); + #endif // AML_LIB_H_ diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/= DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c index b05fa6d109..b3b01e7baf 100644 --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c @@ -4001,3 +4001,190 @@ exit_handler: =20 return Status; } + +/** AML code generation for a method invoking another method + with ArgN arguments and optionally integer arguments. + + Arg0Int =3D 0x10; + Arg1Int =3D 0x20; + AmlCodeGenMethodInvokeMethodArgnWithInteger ( + "MET0", "MET1", 4, TRUE, 3, + Arg0Int, Arg1Int, NULL, NULL, NULL, NULL, + ParentNode, NewObjectNode + ); + is equivalent of the following ASL code: + Method(MET0, 4, Serialized, 3) { + MET1 (Arg0, Arg1, Arg2, Arg3, 0x10, 0x20) + } + + @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] InvokeMethodNameString The called/invoked method's name. + Must be a NULL-terminated ASL NameStri= ng + e.g.: "MET1", "_SB.MET1", 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] IntegerArg0 If provided and meets the validation c= riteria, + then set as integer argument to invoke= d method. + @param [in] IntegerArg1 If provided and meets the validation c= riteria, + then set as integer argument to invoke= d method. + @param [in] IntegerArg2 If provided and meets the validation c= riteria, + then set as integer argument to invoke= d method. + @param [in] IntegerArg3 If provided and meets the validation c= riteria, + then set as integer argument to invoke= d method. + @param [in] IntegerArg4 If provided and meets the validation c= riteria, + then set as integer argument to invoke= d method. + @param [in] IntegerArg5 If provided and meets the validation c= riteria, + then set as integer argument to invoke= d method. + @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. +**/ +EFI_STATUS +EFIAPI +AmlCodeGenMethodInvokeMethodArgnWithInteger ( + IN CONST CHAR8 *MethodNameString, + IN CONST CHAR8 *InvokeMethodNameString, + IN UINT8 NumArgs, + IN BOOLEAN IsSerialized, + IN UINT8 SyncLevel, + IN UINT64 *IntegerArg0 OPTIONAL, + IN UINT64 *IntegerArg1 OPTIONAL, + IN UINT64 *IntegerArg2 OPTIONAL, + IN UINT64 *IntegerArg3 OPTIONAL, + IN UINT64 *IntegerArg4 OPTIONAL, + IN UINT64 *IntegerArg5 OPTIONAL, + IN AML_NODE_HANDLE ParentNode OPTIONAL, + OUT AML_OBJECT_NODE_HANDLE *NewObjectNode OPTIONAL + ) +{ + EFI_STATUS Status; + AML_OBJECT_NODE_HANDLE MethodObjectNode; + AML_OBJECT_NODE *IntNode; + UINT64 LocalIntegerArg[6]; + UINT8 LocalIntegerArgCount; + UINT8 Index; + + if ((MethodNameString =3D=3D NULL) || (InvokeMethodNameString =3D=3D NUL= L)) { + return EFI_INVALID_PARAMETER; + } + + /// Sanity check optional argument + /// AML library allows max 6 argument + /// Hence Integer argument count should be within the range + /// (NumArgs + Integer argument) should not be grater than 6 + LocalIntegerArgCount =3D 0; + if (IntegerArg0 !=3D NULL) { + if (NumArgs > 5) { + return EFI_INVALID_PARAMETER; + } + + LocalIntegerArg[LocalIntegerArgCount++] =3D *IntegerArg0; + } + + if (IntegerArg1 !=3D NULL) { + if (NumArgs > 4) { + return EFI_INVALID_PARAMETER; + } + + LocalIntegerArg[LocalIntegerArgCount++] =3D *IntegerArg1; + } + + if (IntegerArg2 !=3D NULL) { + if (NumArgs > 3) { + return EFI_INVALID_PARAMETER; + } + + LocalIntegerArg[LocalIntegerArgCount++] =3D *IntegerArg2; + } + + if (IntegerArg3 !=3D NULL) { + if (NumArgs > 2) { + return EFI_INVALID_PARAMETER; + } + + LocalIntegerArg[LocalIntegerArgCount++] =3D *IntegerArg3; + } + + if (IntegerArg4 !=3D NULL) { + if (NumArgs > 1) { + return EFI_INVALID_PARAMETER; + } + + LocalIntegerArg[LocalIntegerArgCount++] =3D *IntegerArg4; + } + + if (IntegerArg5 !=3D NULL) { + if (NumArgs > 0) { + return EFI_INVALID_PARAMETER; + } + + LocalIntegerArg[LocalIntegerArgCount++] =3D *IntegerArg5; + } + + /// Create a method invoking another method with Argn + Status =3D AmlCodeGenMethodInvokeMethodArgn ( + MethodNameString, + InvokeMethodNameString, + NumArgs, + IsSerialized, + SyncLevel, + NULL, + &MethodObjectNode + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + return Status; + } + + /// Now append the integer argument + for (Index =3D 0; Index < LocalIntegerArgCount; Index++) { + IntNode =3D NULL; + Status =3D AmlCodeGenInteger (LocalIntegerArg[Index], &IntNode); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto exit_handler; + } + + Status =3D AmlVarListAddTail ( + (AML_NODE_HANDLE)MethodObjectNode, + (AML_NODE_HANDLE)IntNode + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto exit_handler; + } + } + + IntNode =3D NULL; + Status =3D LinkNode ( + MethodObjectNode, + ParentNode, + NewObjectNode + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + goto exit_handler; + } + + return Status; + +exit_handler: + if (MethodObjectNode !=3D NULL) { + AmlDeleteTree ((AML_NODE_HANDLE)MethodObjectNode); + } + + return Status; +} --=20 2.34.1 -=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 (#112288): https://edk2.groups.io/g/devel/message/112288 Mute This Topic: https://groups.io/mt/103106352/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-