From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR01-VE1-obe.outbound.protection.outlook.com (EUR01-VE1-obe.outbound.protection.outlook.com [40.107.14.42]) by mx.groups.io with SMTP id smtpd.web11.13553.1633533399342929021 for ; Wed, 06 Oct 2021 08:16:40 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=7UEt4h3b; spf=pass (domain: arm.com, ip: 40.107.14.42, mailfrom: sami.mujawar@arm.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4K/ugFHMxsYweuZp5Bcp+1uVTHY5fwK40BeseDEczZI=; b=7UEt4h3b5pEw189abbIAWtfaHH89cmM9g1jkMgoXJbUYTqVW+T6Xo2WMcooTGSJIhy25vk7iv7A3sjkJHyW49Q4sa6WIvmJVc8d0oznuMgxBimlMWMiH8Ot3ZPagZrrb1WYkTgcABaQ/WtcbSoAaNVsxONN5TPJaP3cXCgEWE/s= Received: from AM6P193CA0102.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:88::43) by PR2PR08MB4793.eurprd08.prod.outlook.com (2603:10a6:101:1f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14; Wed, 6 Oct 2021 15:16:35 +0000 Received: from VE1EUR03FT044.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:88:cafe::b) by AM6P193CA0102.outlook.office365.com (2603:10a6:209:88::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18 via Frontend Transport; Wed, 6 Oct 2021 15:16:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; edk2.groups.io; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;edk2.groups.io; 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT044.mail.protection.outlook.com (10.152.19.106) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4587.18 via Frontend Transport; Wed, 6 Oct 2021 15:16:35 +0000 Received: ("Tessian outbound 16951d3c485e:v103"); Wed, 06 Oct 2021 15:16:35 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: a379b031e12b387c X-CR-MTA-TID: 64aa7808 Received: from 9da34a9adce9.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 4F9EC91F-A841-47C8-99E5-30F5D2951099.1; Wed, 06 Oct 2021 15:16:28 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9da34a9adce9.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 06 Oct 2021 15:16:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Eil7UVVLxKXg7dfycr8EDB6Qbbo9UhmllIjbeCIJ/0WvigKOY6gUhsyrmlW2GIrFJrEEFNMDh8DPlQbxRfFd0cwB7oTUQSJRxxhEOKjhkkZ8xdP6avmAb8M+9771PVdCzuRCpYS+bsDpZrI4vMwy9Dn70r8hM9xADgdPOGGo2SInjBGZc2abA8rHxdCDbTCC7zbvdYk/RpAVkH9Bfve31mxwdd2bLVj95Myu3Bo+z3SIdZkR7og9QWEtqkd67nAk0sIeeFA5kK08ZA8jTnVjLkU3zsry8XBGLbwDhkYkSIGoayY4yOvfMbQeNWskH/0W24P4xJqVFaiMCxpbgs58Pw== 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=4K/ugFHMxsYweuZp5Bcp+1uVTHY5fwK40BeseDEczZI=; b=gWXEOSDtDL0UOpLfvPGnYi0Nns1C9W0jCZPqOQ8/tRjUqNAqE4Nd0uddInnsQa9LKefiT0Wr6xlvTbOSn3RzJq2z8hqxcpbPFUiXbIeuoNEjYHIsi4kaySlSF4EebdPEpL4InaEVvuVSgJuTwEQw+L+wLZ82JB+7EGLw0Cjw8spuXzLO7NRmGVOXWLKHJov4ae+7iR2CtbYQaDND9d8PYkug8fCBXz3KL2+Z+F434zUUMoVO9e0LD5Sr0he0d4y6E/w6fWyJZD2IOL+dOTglVIpN/nynhcC8rN19lDMmz7RkSE1NLtVPDriF97uobYwRSZK6Nk3+Qxfk2wNwCMVMxA== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4K/ugFHMxsYweuZp5Bcp+1uVTHY5fwK40BeseDEczZI=; b=7UEt4h3b5pEw189abbIAWtfaHH89cmM9g1jkMgoXJbUYTqVW+T6Xo2WMcooTGSJIhy25vk7iv7A3sjkJHyW49Q4sa6WIvmJVc8d0oznuMgxBimlMWMiH8Ot3ZPagZrrb1WYkTgcABaQ/WtcbSoAaNVsxONN5TPJaP3cXCgEWE/s= Authentication-Results-Original: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com; Received: from AS8PR08MB6806.eurprd08.prod.outlook.com (2603:10a6:20b:39b::12) by AS8PR08MB6038.eurprd08.prod.outlook.com (2603:10a6:20b:23f::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.22; Wed, 6 Oct 2021 15:16:18 +0000 Received: from AS8PR08MB6806.eurprd08.prod.outlook.com ([fe80::54b5:239d:9896:ee65]) by AS8PR08MB6806.eurprd08.prod.outlook.com ([fe80::54b5:239d:9896:ee65%4]) with mapi id 15.20.4566.022; Wed, 6 Oct 2021 15:16:18 +0000 Subject: Re: [PATCH v1 3/7] DynamicTablesPkg: AML Code generation to create a named ResourceTemplate() To: Pierre.Gondois@arm.com, devel@edk2.groups.io, Alexei Fedorov Cc: Akanksha Jain , Alexandru Elisei , nd References: <20210623115834.907-1-Pierre.Gondois@arm.com> <20210623115834.907-4-Pierre.Gondois@arm.com> From: "Sami Mujawar" Message-ID: <5ed6dec0-11b3-eded-a4be-5233f7f9ea8c@arm.com> Date: Wed, 6 Oct 2021 16:16:23 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.0.1 In-Reply-To: <20210623115834.907-4-Pierre.Gondois@arm.com> X-ClientProxiedBy: LO4P123CA0490.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1ab::9) To AS8PR08MB6806.eurprd08.prod.outlook.com (2603:10a6:20b:39b::12) MIME-Version: 1.0 Received: from [10.1.196.43] (217.140.106.52) by LO4P123CA0490.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1ab::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.19 via Frontend Transport; Wed, 6 Oct 2021 15:16:17 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0f3f925f-44c4-453b-be9a-08d988dc4972 X-MS-TrafficTypeDiagnostic: AS8PR08MB6038:|PR2PR08MB4793: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:4714;OLM:4714; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: X9oUAoqC20SbL13OIHzuoiQ8RGKQqeoqJ1/ly9WLFup3mCYs5YLhdys8mg8rse9QcuVk31u2wEgPkzJZJ+1TtCG2/rDsxXYRoCBg7nPHO15nVWU6MXdjAY83GV0IUoTrSnaCnDX3dpvJQm7n1piJTLRr8dxKa1qJrBU9sK7sdOOt7ab4gGtc5MuhXqoBbZQbO1/fCBFkm66NiMlLlwczDkYjjoWhrp5sy9Bxpa8o6weVruyHV9aUCLRh2HrSgyb/+vAtWOdR+EDUSWSzGoQXdBL3UvaGwY9/x07TktiN9h7HGDXHo/DDxvVW0yMlxVxKprPb36+fcY5WEhzajw9Ixr3nBy8kIG5ZXaYxLosyWoyHLY5pteDA+QnqmYqtvmpg4kIpOcscCpM4rCjx2+wGdncMsIzKUVtaqa2hnLlyiNixClU9L9EtfShulAdJH8MaS1WQqlUffSXFoVk+7MPWwfYPKQW+WXbbWTI3STMmUee8ACJ1txnNES1zATtOecjK+22msFanq5FJe7sVQBzD4pj0raHH879oOvFTJMhACNKXu1s2xZ4szXFUYI7XJ/Z6ZklTkt2XcKIm3uAjP5Dk5nd/jQjC7Icp/cPw1rLsi287Nt+z/wqYiN4AfYW6DuKTsMDRGziR0DZS21COmjqxl4y4jRkA7KNWmvQLbZyMVZ79PJal6vmneNE80gqYbPMA18wqzQfLqkMM2qgyRuWUQaM3PR5yb4L1l2eGZCNiNEiIWaeqEyst9nJZ4BgCqhUnmgzAJLqUnouG6+aVHE62aA== 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:(4636009)(366004)(66556008)(6666004)(66946007)(26005)(8936002)(53546011)(38350700002)(66476007)(4326008)(186003)(38100700002)(508600001)(54906003)(31686004)(5660300002)(2616005)(956004)(6862004)(2906002)(16576012)(44832011)(8676002)(316002)(52116002)(6636002)(37006003)(83380400001)(36756003)(6486002)(86362001)(31696002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB6038 Original-Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=arm.com; Return-Path: Sami.Mujawar@arm.com X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT044.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 1713e7c5-7cba-44f1-83e6-08d988dc3ef0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TKZb84jCzMMel5VI3LsxhozeBikyrktFM+DysPPv7YL9ZcXpH70s+6TGpPXERk+/lf0LY4RJhVD8qBDSXlercaS4WUKqlaekt8fvqKW6Td2SGVPf0iAw8hBAPL8xwrKUXAPmp9KDYKpUFrR7naqMj8Tx+Ihodno5gniwr/AgjxoJzqo33a+ec1PFv35pxkWRZ8bldGh8ztS/rUaFla4wVokfr5KacIr2ljmrXF7wRy37EKvYULWScHAwyCp9bUHRAoNsMhXpR7rQ7ujLb43M7ovHjkFrYFhOjuvJVO+fpoEdBJ0PnOviUgwQkIpRnX691ZL5UrCjzkeGO4faUbh+U6lnPKuiWX0admDwBvyH1I7aIh1qdN28rV/e0+lYaY0mza3OyKBrMAv8QbrE0OG/HUSsxhy4OEpcriR4GPH7j4ZRBMVAGukcun3R+0VeziH0eWGfNyWcBYZbINNgh/X2ov/w9fwT7UBDh/BHyY0tlL5R1/k6KKdofnH18tVDiFi7PChsDbLXrDmAGjdiL/nGukbzMXb9BYYYwtQg6BfJpfX3/Z+7i0maF7674N637PYTlUFtmV8vvh2z4Rd1VOYhskykUtDFE3scXAvpOLNoJx2WGpb+lRzoTJ5R/NkTYFEnq8Ip03qasgcdSuDyqLzfy6F7Lk5SU99nGx+c4dU/1y/Pm1gzpJ6oYHtVkb370JlalhHgVdIAbOSte/Yo7PJrqflBvg+8jMM6vXmOA0YLAVo= X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(4326008)(316002)(53546011)(31696002)(6862004)(2906002)(6486002)(16576012)(508600001)(5660300002)(6636002)(86362001)(186003)(26005)(47076005)(37006003)(2616005)(36756003)(82310400003)(70206006)(70586007)(6666004)(54906003)(83380400001)(8936002)(8676002)(956004)(81166007)(31686004)(36860700001)(44832011)(356005)(336012)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Oct 2021 15:16:35.4985 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0f3f925f-44c4-453b-be9a-08d988dc4972 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: VE1EUR03FT044.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR2PR08MB4793 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB Hi Pierre, This patch looks good to me. Reviewed-by: Sami Mujawar Regards, Sami Mujawar On 23/06/2021 12:58 PM, Pierre.Gondois@arm.com wrote: > From: Pierre Gondois > > Add AmlCodeGenNameResourceTemplate() to generate code for a > ResourceTemplate(). > > AmlCodeGenNameResourceTemplate ("REST", ParentNode, NewObjectNode) is > equivalent of the following ASL code: > Name(REST, ResourceTemplate () {}) > > Signed-off-by: Pierre Gondois > --- > .../Include/Library/AmlLib/AmlLib.h | 28 ++++++++++ > .../Common/AmlLib/CodeGen/AmlCodeGen.c | 55 +++++++++++++++++++ > 2 files changed, 83 insertions(+) > > diff --git a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h > index 412db886e1f2..544bc670c455 100644 > --- a/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h > +++ b/DynamicTablesPkg/Include/Library/AmlLib/AmlLib.h > @@ -880,6 +880,34 @@ AmlCodeGenNamePackage ( > OUT AML_OBJECT_NODE_HANDLE * NewObjectNode OPTIONAL > ); > > +/** AML code generation for a Name object node, containing a ResourceTemplate. > + > + AmlCodeGenNameResourceTemplate ("PRS0", ParentNode, NewObjectNode) is > + equivalent of the following ASL code: > + Name(PRS0, ResourceTemplate () {}) > + > + @ingroup CodeGenApis > + > + @param [in] NameString The new variable name. > + Must be a NULL-terminated ASL NameString > + e.g.: "DEV0", "DV15.DEV0", etc. > + The input string is copied. > + @param [in] ParentNode If provided, set ParentNode as the parent > + 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 > +AmlCodeGenNameResourceTemplate ( > + IN CONST CHAR8 * NameString, > + IN AML_NODE_HANDLE ParentNode, OPTIONAL > + OUT AML_OBJECT_NODE_HANDLE * NewObjectNode OPTIONAL > + ); > + > /** AML code generation for a Device object node. > > AmlCodeGenDevice ("COM0", ParentNode, NewObjectNode) is > diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c > index f9175c623622..eaa49a5834c2 100644 > --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c > +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlCodeGen.c > @@ -802,6 +802,61 @@ AmlCodeGenNamePackage ( > return Status; > } > > +/** AML code generation for a Name object node, containing a ResourceTemplate. > + > + AmlCodeGenNameResourceTemplate ("PRS0", ParentNode, NewObjectNode) is > + equivalent of the following ASL code: > + Name(PRS0, ResourceTemplate () {}) > + > + @param [in] NameString The new variable name. > + Must be a NULL-terminated ASL NameString > + e.g.: "DEV0", "DV15.DEV0", etc. > + The input string is copied. > + @param [in] ParentNode If provided, set ParentNode as the parent > + 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 > +AmlCodeGenNameResourceTemplate ( > + IN CONST CHAR8 * NameString, > + IN AML_NODE_HEADER * ParentNode, OPTIONAL > + OUT AML_OBJECT_NODE ** NewObjectNode OPTIONAL > + ) > +{ > + EFI_STATUS Status; > + AML_OBJECT_NODE * ResourceTemplateNode; > + > + if ((NameString == NULL) || > + ((ParentNode == NULL) && (NewObjectNode == NULL))) { > + ASSERT (0); > + return EFI_INVALID_PARAMETER; > + } > + > + Status = AmlCodeGenResourceTemplate (&ResourceTemplateNode); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + return Status; > + } > + > + Status = AmlCodeGenName ( > + NameString, > + ResourceTemplateNode, > + ParentNode, > + NewObjectNode > + ); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + AmlDeleteTree ((AML_NODE_HEADER*)ResourceTemplateNode); > + } > + > + return Status; > +} > + > /** AML code generation for a Device object node. > > AmlCodeGenDevice ("COM0", ParentNode, NewObjectNode) is