From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR05-AM6-obe.outbound.protection.outlook.com (EUR05-AM6-obe.outbound.protection.outlook.com [40.107.22.69]) by mx.groups.io with SMTP id smtpd.web10.7483.1633092523538869231 for ; Fri, 01 Oct 2021 05:48:44 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=OhPA0RDh; spf=pass (domain: arm.com, ip: 40.107.22.69, 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=asklUvRSOjnbxFYElIAo5yW/EHVXYAPES+AeCIs+GAI=; b=OhPA0RDhczIQc2Y08CgyGJO+kviQlIEDCSkXAZaR3xyYKxD1VQC2B1gKF7H5tCl6u9qvnh0AKE3hDkOuSx0ldKuiv/+5eQAJK6sXR2EMl2+0JGrxx64S30oDo2AqSEJilGweJEbvami5rdCS177BS0mA1WbN4bw2pF3lVWvdqaI= Received: from AS9PR06CA0357.eurprd06.prod.outlook.com (2603:10a6:20b:466::25) by AM6PR08MB4470.eurprd08.prod.outlook.com (2603:10a6:20b:b5::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14; Fri, 1 Oct 2021 12:48:40 +0000 Received: from VE1EUR03FT030.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:466:cafe::48) by AS9PR06CA0357.outlook.office365.com (2603:10a6:20b:466::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.16 via Frontend Transport; Fri, 1 Oct 2021 12:48:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.33.187.114) 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.33.187.114 as permitted sender) receiver=protection.outlook.com; client-ip=63.33.187.114; helo=64aa7808-outbound-2.mta.getcheckrecipient.com; Received: from 64aa7808-outbound-2.mta.getcheckrecipient.com (63.33.187.114) by VE1EUR03FT030.mail.protection.outlook.com (10.152.18.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.14 via Frontend Transport; Fri, 1 Oct 2021 12:48:40 +0000 Received: ("Tessian outbound b324a1dbd9be:v103"); Fri, 01 Oct 2021 12:48:40 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 4bd9619a1bb4aad2 X-CR-MTA-TID: 64aa7808 Received: from 93449ba53836.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 48E8CE94-2755-43F5-A885-CE790E3F388A.1; Fri, 01 Oct 2021 12:48:28 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 93449ba53836.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 01 Oct 2021 12:48:28 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LEqmZzz98CwjVSSd+fazd+XfcRsg/+NnOAo1H6cWCt13oXTFwzUXlRJgiJ0UkNll58k2YReKW3r83anwFEyYVSMoyXjWfxux1Yr77UzWPk3gy4q2TU6gB3Ksec0cHgWr4FGhqZCch2THg1AnmknZsP+LsSwWi4LhGKGIMWybOUbnaOeSqUheLcsAFqQ0TiEIGoxVEHaTCPgJ6i5sNZEcqrPVThDLu/xBhvK7qPTQ/VnUxgegUGWqzH6uOxnY6P+t8ZgTwK+DezkRHPVs3+cSkoearfw9hF5yQu6b8POSuID8MvpkasYXuYA/0/tUz1d0n6Eo2gA+CWVcS9VWXOnBuQ== 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=asklUvRSOjnbxFYElIAo5yW/EHVXYAPES+AeCIs+GAI=; b=Rw7QeV2qiitsKUXbFqJDSj6Hmu64EeWkyYd80q21R7VMHlU3Bayd7t3w2Pdq0o4eOUtFidz67tLqDfb1vJcBigJFVmhemuJqWqNRPCM23j4ruIBIeZ2GYwuAG8wUxQPt+CbWQrBvjwicnD+VSAZNDhaz0Ru65n88Vg3TZQj/Ku36QEA6GCGhUYs/GGwayfRwYxtUXcKpL5WHkM0UeNYpxqSDk+MH2REtzgflzes31YCSqJLJgoZUlZWQz4xQ72AURGethiTOxwa+qULX72cLItd/sECEsGsUSVr79xH2KRgWCjuTzkP735xWkmiEtK2C25ATm8xDbzH129Je7KU+yg== 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=asklUvRSOjnbxFYElIAo5yW/EHVXYAPES+AeCIs+GAI=; b=OhPA0RDhczIQc2Y08CgyGJO+kviQlIEDCSkXAZaR3xyYKxD1VQC2B1gKF7H5tCl6u9qvnh0AKE3hDkOuSx0ldKuiv/+5eQAJK6sXR2EMl2+0JGrxx64S30oDo2AqSEJilGweJEbvami5rdCS177BS0mA1WbN4bw2pF3lVWvdqaI= 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 AM6PR08MB3896.eurprd08.prod.outlook.com (2603:10a6:20b:83::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.15; Fri, 1 Oct 2021 12:48:26 +0000 Received: from AS8PR08MB6806.eurprd08.prod.outlook.com ([fe80::c8a5:672a:9ff2:e554]) by AS8PR08MB6806.eurprd08.prod.outlook.com ([fe80::c8a5:672a:9ff2:e554%6]) with mapi id 15.20.4566.019; Fri, 1 Oct 2021 12:48:26 +0000 Subject: Re: [PATCH v1 03/13] DynamicTablesPkg: AML Code generation for Resource data EndTag To: Pierre.Gondois@arm.com, devel@edk2.groups.io, Alexei Fedorov Cc: Akanksha Jain , Alexandru Elisei , nd References: <20210623114039.24491-1-Pierre.Gondois@arm.com> <20210623114039.24491-4-Pierre.Gondois@arm.com> From: "Sami Mujawar" Message-ID: Date: Fri, 1 Oct 2021 13:48:29 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.0.1 In-Reply-To: <20210623114039.24491-4-Pierre.Gondois@arm.com> X-ClientProxiedBy: LO4P123CA0374.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18e::19) 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 LO4P123CA0374.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:18e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4566.16 via Frontend Transport; Fri, 1 Oct 2021 12:48:26 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f6892cdb-d174-4a66-59a9-08d984d9cb73 X-MS-TrafficTypeDiagnostic: AM6PR08MB3896:|AM6PR08MB4470: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:9508;OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: le0+pjk1WBKXj/GHk1W5oDAlQxBRtEx9tf0XNT3UcOVmQHyg9Ln7EUHSoxa6nJ0BQ2umfJdI/L/iioC75K6FIegJIsJSS7ZOsJtJTbFDbn7TfPpVx0e3hoqaNXpdHUZAdw5q754+V46X1Yc4VcYojjEyUsn0p162O0DGG/LOCWfOfTQ3WtxnlYT/KCgOVgE8rte7uR9bzWCOrKdehsCA+Nd2s4W20fG3jCJpEwdjz7HrEaQHsmYMiRqcn8tOyq+zrrenbvKrQ0of//HkBmrsnjTbcnFsFlxj5SQeGRpCoVeqn9bD7z3moZhww0SPskoS93Gzra1F6ao2BAnQSgW6UEwFh1qpznt7aJT1bT79QvX48WggX0ep6imdtcIvrjkf/wvZHXaNYANf/s3hovsy74AkB6umSXydAFo5TXynDIL49dlECLlY98YH/Utgk1MhK0ubcvjWeZF1tgPEVqA12/C/FcXJWK4JHQFgKq0YfSW4V32kVSOCCyVQyv+J+9nxxwgIVboP3I+WJZRI78dwsTz3iMTE5NVwAUOyoMXe2c39BIxk1UL16DfjtrPAcHSKDmmjxyePl7ECzk3avXfIwcs0uBDF0wYpGs3vtCTcX7qcbcSWU7s7KxjQvwYxf8v7I9yaMRgrE1na2K8TjZTsHPm+q7gXcLAgeN2ESzjHjpbgb5goK47AtunBdUJr0tGN5YU9EqCZBBK2sFqlomHJhgLCPpPYqojQO/r4xozFIyBm2jsa2AzqScloJfW8sCqtziFz2O5wC7ORB7l+lWQBig== 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)(36756003)(52116002)(86362001)(6862004)(31696002)(508600001)(956004)(2906002)(6636002)(53546011)(2616005)(44832011)(5660300002)(83380400001)(8676002)(4326008)(37006003)(6486002)(16576012)(8936002)(316002)(54906003)(26005)(66476007)(31686004)(66556008)(66946007)(186003)(38350700002)(38100700002)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3896 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: VE1EUR03FT030.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 8b4a9bc7-7eb0-48f7-3b08-08d984d9c2f3 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5DfvxSoC6jpR2TkYvJtDYnt1A94QIc2LwIER/I/izdRFaXOCqcWCKSH09RLA6Z9+8mvusCFN0bhqNd9U4/3ChaXYC//bXgX6rHdhZZoS3ge8nxOOZyw+yGSP5v3T+Q80llmo1iQkQ5YclEzI1jkk/LlPxUFixCI1GtHKb1nYYojv/NGOJJYbjyORYhNQ5KxKiV6V9oGsR1f66e/zxcUClJeJgtDVUClLcOIUbe4rImoULv5PGYAQO1VbeJtaXdlw/PRIRi7In6IvbkYcYqBiav+8uKLc5onjB/kT2aD2onpI8l9Zm7zQB6F5/f2N3dD6Xg6MSJ4WjS9HNvW/i+aSfZ5v4sFr8E2isoztNxM2U2BtSJYWFLckbi1bV6DV0ByYbNMFSnOWONyRGAg1vy/SKKHlR2czWfSs6P8FtCerQDeht8cBOR1R2MNawadQ7qcUT0OO3/FbXszxcrdHi5WyMQlKb3TCktrFidxoxfGGDb//nyLBot+wPt8Qk2nM7rpun5TuwvNUtD+3kh/31i1Bo5FgqLzuGdqI5aoTEIgVxPod001BOeqlNWc0Uw/1/aljyL3oL3CCqc1pCMAve0y3QXXZ+O34Vyhyga8Q75e4VrorIc0wWQItnlxGAD3thllyZ63ijj08zXx+e8oonte2XbMyrVbjU68vQsXTxofgDLMRbAnzPsxNPJNhMui+qmy8q0rXM4wEnpgyif4ph/gCCR+sdrjpixhB6h3Pkz9u31U= X-Forefront-Antispam-Report: CIP:63.33.187.114;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-2.mta.getcheckrecipient.com;PTR:ec2-63-33-187-114.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(4636009)(36840700001)(46966006)(82310400003)(956004)(6486002)(2616005)(36860700001)(44832011)(6636002)(26005)(356005)(53546011)(81166007)(336012)(86362001)(2906002)(8936002)(37006003)(70206006)(31696002)(70586007)(16576012)(6862004)(8676002)(36756003)(186003)(54906003)(83380400001)(508600001)(316002)(4326008)(47076005)(5660300002)(31686004)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Oct 2021 12:48:40.4300 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f6892cdb-d174-4a66-59a9-08d984d9cb73 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.33.187.114];Helo=[64aa7808-outbound-2.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT030.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4470 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-GB Hi Pierre, Thank you for this patch. Please find my response inline marked [SAMI]. Regards, Sami Mujawar On 23/06/2021 12:40 PM, Pierre.Gondois@arm.com wrote: > From: Pierre Gondois > > Add a helper function AmlCodeGenEndTag() to generate AML Resource Data > EndTag. The EndTag resource data is automatically generated by the ASL > compiler at the end of a list of resource data elements. Therefore, an > equivalent function is not present in ASL. > > However, AmlCodeGenEndTag() is useful when generating AML code for the > ResourceTemplate() macro. > > Signed-off-by: Pierre Gondois > --- > .../AmlLib/CodeGen/AmlResourceDataCodeGen.c | 104 ++++++++++++++++++ > .../AmlLib/CodeGen/AmlResourceDataCodeGen.h | 34 ++++++ > 2 files changed, 138 insertions(+) > > diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c > index 07a96725a4ef..78910cc5d4b4 100644 > --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c > +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c > @@ -274,6 +274,110 @@ AmlCodeGenRdRegister ( > return LinkRdNode (RdNode, NameOpNode, NewRdNode); > } > > +/** Code generation for the EndTag resource data. > + > + The EndTag resource data is automatically generated by the ASL compiler > + at the end of a list of resource data elements. Thus, it doesn't have > + a corresponding ASL function. > + > + This function allocates memory to create a data node. It is the caller's > + responsibility to either: > + - attach this node to an AML tree; > + - delete this node. > + > + @param [in] CheckSum CheckSum to store in the EndTag. > + Optional: can be let to 0. It is not > + updated when new resource data elements > + are added/removed/modified in the list. [SAMI] Can you rephrase the description, please? If I understand correctly, the current implementation does not compute the checksum. However, if the checksum value provided is not zero then an update to the resource nodes would need to recompute the checksum, right? > + @param [in] ParentNode If not NULL, add the generated node > + to the end of the variable list of > + argument of the ParentNode. > + The ParentNode must not initially contain > + an EndTag resource data element. > + @param [out] NewRdNode If success, contains the generated node. > + > + @retval EFI_SUCCESS The function completed successfully. > + @retval EFI_INVALID_PARAMETER Invalid parameter. > + @retval EFI_OUT_OF_RESOURCES Could not allocate memory. > +**/ > +EFI_STATUS > +EFIAPI > +AmlCodeGenEndTag ( > + IN UINT8 CheckSum, OPTIONAL > + IN AML_OBJECT_NODE * ParentNode, OPTIONAL > + OUT AML_DATA_NODE ** NewRdNode OPTIONAL > + ) > +{ > + EFI_STATUS Status; > + AML_DATA_NODE * RdNode; > + EFI_ACPI_END_TAG_DESCRIPTOR EndTag; > + ACPI_SMALL_RESOURCE_HEADER SmallResHdr; > + > + if ((ParentNode == NULL) && (NewRdNode == NULL)) { > + ASSERT (0); > + return EFI_INVALID_PARAMETER; > + } > + > + RdNode = NULL; > + > + // Header > + SmallResHdr.Bits.Length = sizeof (EFI_ACPI_END_TAG_DESCRIPTOR) - > + sizeof (ACPI_SMALL_RESOURCE_HEADER); > + SmallResHdr.Bits.Name = ACPI_SMALL_END_TAG_DESCRIPTOR_NAME; > + SmallResHdr.Bits.Type = ACPI_SMALL_ITEM_FLAG; > + > + // Body > + EndTag.Desc = SmallResHdr.Byte; > + EndTag.Checksum = CheckSum; > + > + Status = AmlCreateDataNode ( > + EAmlNodeDataTypeResourceData, > + (UINT8*)&EndTag, > + sizeof (EFI_ACPI_END_TAG_DESCRIPTOR), > + &RdNode > + ); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + return Status; > + } > + > + if (NewRdNode != NULL) { > + *NewRdNode = RdNode; > + } > + > + if (ParentNode != NULL) { > + // Check the BufferOp doesn't contain any resource data yet. > + // This is a hard check: do not allow to add an EndTag if the BufferNode > + // already has resource data elements attached. Indeed, the EndTag should > + // have already been added. > + if (AmlGetNextVariableArgument ((AML_NODE_HEADER*)ParentNode, NULL) != > + NULL) { > + ASSERT (0); > + Status = EFI_INVALID_PARAMETER; > + goto error_handler; > + } > + > + // Manually add the EndTag RdNode. Indeed, the AmlAppendRdNode function > + // is looking for an EndTag, which we are adding here. > + Status = AmlVarListAddTail ( > + (AML_NODE_HEADER*)ParentNode, > + (AML_NODE_HEADER*)RdNode > + ); > + if (EFI_ERROR (Status)) { > + ASSERT (0); > + goto error_handler; > + } > + } > + > + return Status; > + > +error_handler: > + if (RdNode != NULL) { > + AmlDeleteTree ((AML_NODE_HEADER*)RdNode); > + } > + return Status; > +} > + > // DEPRECATED APIS > #ifndef DISABLE_NEW_DEPRECATED_INTERFACES > > diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.h b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.h > index 3c9217d9ddab..0b464305da40 100644 > --- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.h > +++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.h > @@ -104,4 +104,38 @@ AmlCodeGenRdRegister ( > OUT AML_DATA_NODE_HANDLE *NewRdNode OPTIONAL > ); > > +/** Code generation for the EndTag resource data. > + > + The EndTag resource data is automatically generated by the ASL compiler > + at the end of a list of resource data elements. Thus, it doesn't have > + a corresponding ASL function. > + > + This function allocates memory to create a data node. It is the caller's > + responsibility to either: > + - attach this node to an AML tree; > + - delete this node. > + > + @param [in] CheckSum CheckSum to store in the EndTag. > + Optional: can be let to 0. It is not > + updated when new resource data elements > + are added/removed/modified in the list. > + @param [in] ParentNode If not NULL, add the generated node > + to the end of the variable list of > + argument of the ParentNode. > + The ParentNode must not initially contain > + an EndTag resource data element. > + @param [out] NewRdNode If success, contains the generated node. > + > + @retval EFI_SUCCESS The function completed successfully. > + @retval EFI_INVALID_PARAMETER Invalid parameter. > + @retval EFI_OUT_OF_RESOURCES Could not allocate memory. > +**/ > +EFI_STATUS > +EFIAPI > +AmlCodeGenEndTag ( > + IN UINT8 CheckSum, OPTIONAL > + IN AML_OBJECT_NODE * ParentNode, OPTIONAL > + OUT AML_DATA_NODE ** NewRdNode OPTIONAL > + ); > + > #endif // AML_RESOURCE_DATA_CODE_GEN_H_