From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from FRA01-MR2-obe.outbound.protection.outlook.com (FRA01-MR2-obe.outbound.protection.outlook.com [40.107.9.87]) by mx.groups.io with SMTP id smtpd.web10.17190.1597245806766218395 for ; Wed, 12 Aug 2020 08:23:27 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=Zqw2zWVN; spf=pass (domain: arm.com, ip: 40.107.9.87, 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=eFINIP8or9Zm+z9FJnNPRe2ZC6jbWsMUmHWEYsIZ6Ww=; b=Zqw2zWVN3ysNSUB4zGQBDIUjm8bjOcrNpIiBTHYLU4ga8CfUzY1O57Iev8FXKxmyVDzlL7X33diwydnYpexXhL0ZtqYRl/YRCoDJO+VWb31zNzlOaviZNqIApLLlHeO9pj5zyCHa44230cWT6XEVU5hxQ1W3OGrRcnWqEROtJoA= Received: from AM5PR0402CA0013.eurprd04.prod.outlook.com (2603:10a6:203:90::23) by PR2PR08MB4923.eurprd08.prod.outlook.com (2603:10a6:101:24::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.19; Wed, 12 Aug 2020 15:23:24 +0000 Received: from AM5EUR03FT059.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:90:cafe::3) by AM5PR0402CA0013.outlook.office365.com (2603:10a6:203:90::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.16 via Frontend Transport; Wed, 12 Aug 2020 15:23:24 +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=bestguesspass 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 AM5EUR03FT059.mail.protection.outlook.com (10.152.17.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.16 via Frontend Transport; Wed, 12 Aug 2020 15:23:23 +0000 Received: ("Tessian outbound e8cdb8c6f386:v64"); Wed, 12 Aug 2020 15:23:23 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 8052b62c2e12e684 X-CR-MTA-TID: 64aa7808 Received: from 747c73290921.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D550BC5A-E859-406E-BA1F-AF5C0C2BD507.1; Wed, 12 Aug 2020 15:23:15 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 747c73290921.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 12 Aug 2020 15:23:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Cuq9ATYsG+AfvbHWWFDkLfvgYDjt9ilr/Bigx4YZR+H2ymDQ/8FyFY7u59oq8azfc9kTnEt3WK9XGJ2bptWhR0rN+jBtiD4oZEF4ncqF1AJESVG5+5tEmjqbivHOVvApZtkUGcemfaANSX5YZc4cvtpZe9cq0xNmrCNfJraHD+N610wn7vA0UH467uHbyN0d0S+JW96+HckMuXyrIYrz4xk0VOinmjMXu49mGK+vmgB30Z636ML/3A0ULjzcAYDZ75Yw64a2kH78XuMWzPWD+zfLlwJHz/4qZ5I6opBw9XRp4NR/+0tga7uxZ0i5Qs3IMj3qZslmvgXRdMZAIKIMPQ== 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-SenderADCheck; bh=eFINIP8or9Zm+z9FJnNPRe2ZC6jbWsMUmHWEYsIZ6Ww=; b=DdXV5yz3TTK8tDD5qewW0ErVI3u0jAIBHUhneg9foBQ5clXpvOS0YM1qyvmklziDISJq+G33urQlLymE+Brl6Vcm7L6QTfGJVT+Mnpn/l3+Z+4Njq6bpDATgDnte/FcBRi6qInAkTUSqA9c2JrRjaxCRTppD7C+/37t0t3aSkzOvLIqQ+3mZ1bOlq0k9OwCtbN+yfzZRZQygQfDGQvgUWPbQS7QJyPNoteiaTg8Gf/z9851FOi2xLX9xwD7hoOoMQqsrz2O+dtaoyV34AqHmvXj5XfWEWmltYQ37iFggJJ83NDh87G5qj/fqrxayM1YsbbTGyIBQKCveMo+v8RoFQQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=arm.com; dmarc=bestguesspass action=none header.from=arm.com; dkim=none (message not signed); 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=eFINIP8or9Zm+z9FJnNPRe2ZC6jbWsMUmHWEYsIZ6Ww=; b=Zqw2zWVN3ysNSUB4zGQBDIUjm8bjOcrNpIiBTHYLU4ga8CfUzY1O57Iev8FXKxmyVDzlL7X33diwydnYpexXhL0ZtqYRl/YRCoDJO+VWb31zNzlOaviZNqIApLLlHeO9pj5zyCHa44230cWT6XEVU5hxQ1W3OGrRcnWqEROtJoA= Received: from DB8PR06CA0002.eurprd06.prod.outlook.com (2603:10a6:10:100::15) by DBBPR08MB4299.eurprd08.prod.outlook.com (2603:10a6:10:ce::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.16; Wed, 12 Aug 2020 15:23:11 +0000 Received: from DB5EUR03FT035.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:100:cafe::dc) by DB8PR06CA0002.outlook.office365.com (2603:10a6:10:100::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3283.15 via Frontend Transport; Wed, 12 Aug 2020 15:23:11 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; edk2.groups.io; dkim=none (message not signed) header.d=none;edk2.groups.io; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; Received: from nebula.arm.com (40.67.248.234) by DB5EUR03FT035.mail.protection.outlook.com (10.152.20.65) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.3283.16 via Frontend Transport; Wed, 12 Aug 2020 15:23:11 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2044.4; Wed, 12 Aug 2020 15:23:05 +0000 Received: from E107187.Arm.com (10.57.41.222) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2044.4 via Frontend Transport; Wed, 12 Aug 2020 15:23:04 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , Subject: [PATCH v1 06/30] DynamicTablesPkg: AML tree enumerator Date: Wed, 12 Aug 2020 16:22:12 +0100 Message-ID: <20200812152236.31164-7-sami.mujawar@arm.com> X-Mailer: git-send-email 2.11.0.windows.3 In-Reply-To: <20200812152236.31164-1-sami.mujawar@arm.com> References: <20200812152236.31164-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-HT: Tenant X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4be888a2-5af3-43a8-ac9c-08d83ed3a760 X-MS-TrafficTypeDiagnostic: DBBPR08MB4299:|PR2PR08MB4923: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:6430;OLM:6430; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: XPptf+s9mB3r5mi58zid+IXCMicYV+v7QZKA98Wpvhc+G8+e7+/vNZv87zjGO4og+QSOy8Cc0s0y9eu+TFHjb/G/mqDJPz9JrR7sCY3qDjpT/VAnUwra5MNqnTIhbgQLg8juXX3QFYvJ02MRvI4ZHcFfPrPcdE46I0mHFS6BykqJNFIkgrppcM9U3EXs7dMQqFJ9o/+gr7Ojs+G2WTAqmCgx6CFq9m0BbC0o/4LcfAEvPAzZ4LW7NAwVgZOCN439sA9VrpqjgHJMHYZ6sdZ0lNdPBci6RH/2U3CKbvx9yXHS9pymVPdiMIBeCoX28mwcYCouM0t6HfTQrbXw0QRsAVpCfT9mRtEvn2Vd9JNt6k5EHKNXaU38XkMNfkpsr0p4pqbyWTWQKDP7gG7E5MiIKg== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(4636009)(136003)(396003)(39860400002)(376002)(346002)(46966005)(186003)(7696005)(47076004)(70206006)(81166007)(70586007)(26005)(478600001)(5660300002)(6666004)(44832011)(1076003)(83380400001)(2616005)(6916009)(426003)(82740400003)(8936002)(2906002)(356005)(36756003)(82310400002)(8676002)(54906003)(336012)(4326008)(316002)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4299 Return-Path: Sami.Mujawar@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT059.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 44a655a7-0a2f-4e11-6684-08d83ed3a00c X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QBspPfG/rX5fJSIvBKhmpRtb98p8yRml5FulN4kWNg4z+4QSyhwFj7X+azlB//Y6CVRtt03Q9lK9Gk0ORAXZcU8qCAi/UGUZ4yllzRCuesnEhGLiuuOwlMuCRn95qY+Yi2z29T6n/aStZzlESy57phgArC5eoGP/vfRRyukIg3MVI9Fgnp3VjhYF6dNqQWULMHn6FCq916xgKfchGyXcYBFrPGwXt0HK7pTv0dGxQwjmbQap+uVx6GTvR9mCM1lqoKswJkDHzkG3OqnlaFAhhyuAaGMwtc0QDULc7uuOGPE+cIRV2ziAsRAvaAHZ1dLjOV9KPowiXCSN3VVJY/Hb24zhpzVSWbyALEDsfYpJi46eyPzIjzZFMvjoyTVxhPYVJfgMXSlrTZ95x3xgoE+i2g== 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;SFTY:;SFS:(4636009)(136003)(346002)(39860400002)(396003)(376002)(46966005)(26005)(82310400002)(5660300002)(83380400001)(478600001)(36906005)(316002)(54906003)(7696005)(186003)(6916009)(36756003)(82740400003)(6666004)(70206006)(86362001)(1076003)(2906002)(47076004)(81166007)(8936002)(426003)(44832011)(70586007)(2616005)(4326008)(336012)(8676002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2020 15:23:23.9527 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4be888a2-5af3-43a8-ac9c-08d83ed3a760 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: AM5EUR03FT059.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR2PR08MB4923 Content-Type: text/plain From: Pierre Gondois The AML tree enumerator interface allows enumeration of the nodes in the AML tree. The enumerator interface can be useful to search, serialise, print etc. the nodes in the AML tree. Signed-off-by: Pierre Gondois Signed-off-by: Sami Mujawar --- DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlTreeEnumerator.c | 98 ++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlTreeEnumerator.c b/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlTreeEnumerator.c new file mode 100644 index 0000000000000000000000000000000000000000..3eeb7253bfb647f5430a89a87e8a196c453abe71 --- /dev/null +++ b/DynamicTablesPkg/Library/Common/AmlLib/Tree/AmlTreeEnumerator.c @@ -0,0 +1,98 @@ +/** @file + AML Tree Enumerator. + + Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.
+ + SPDX-License-Identifier: BSD-2-Clause-Patent +**/ + +#include + +#include +#include + +/** Enumerate all nodes of the subtree under the input Node in the AML + bytestream order (i.e. in a depth first order), and call the CallBack + function with the input Context. + The prototype of the Callback function is EDKII_AML_TREE_ENUM_CALLBACK. + + @param [in] Node Enumerate nodes of the subtree under this Node. + Must be a valid node. + @param [in] CallBack Callback function to call on each node. + @param [in, out] Context Void pointer used to pass some information + to the Callback function. + Optional, can be NULL. + @param [out] Status Optional parameter that can be used to get + the status of the Callback function. + If used, need to be init to EFI_SUCCESS. + + @retval TRUE if the enumeration can continue or has finished without + interruption. + @retval FALSE if the enumeration needs to stopped or has stopped. +**/ +BOOLEAN +EFIAPI +AmlEnumTree ( + IN AML_NODE_HEADER * Node, + IN EDKII_AML_TREE_ENUM_CALLBACK CallBack, + IN OUT VOID * Context, OPTIONAL + OUT EFI_STATUS * Status OPTIONAL + ) +{ + BOOLEAN ContinueEnum; + + EAML_PARSE_INDEX Index; + EAML_PARSE_INDEX MaxIndex; + + LIST_ENTRY * StartLink; + LIST_ENTRY * CurrentLink; + + if (!IS_AML_NODE_VALID (Node) || (CallBack == NULL)) { + ASSERT (0); + if (Status != NULL) { + *Status = EFI_INVALID_PARAMETER; + } + return FALSE; + } + + ContinueEnum = (*CallBack)(Node, Context, Status); + if (ContinueEnum == FALSE) { + return ContinueEnum; + } + + // Iterate through the fixed list of arguments. + MaxIndex = (EAML_PARSE_INDEX)AmlGetFixedArgumentCount ( + (AML_OBJECT_NODE*)Node + ); + for (Index = EAmlParseIndexTerm0; Index < MaxIndex; Index++) { + ContinueEnum = AmlEnumTree ( + AmlGetFixedArgument ((AML_OBJECT_NODE*)Node, Index), + CallBack, + Context, + Status + ); + if (ContinueEnum == FALSE) { + return ContinueEnum; + } + } + + // Iterate through the variable list of arguments. + StartLink = AmlNodeGetVariableArgList (Node); + if (StartLink != NULL) { + CurrentLink = StartLink->ForwardLink; + while (CurrentLink != StartLink) { + ContinueEnum = AmlEnumTree ( + (AML_NODE_HEADER*)CurrentLink, + CallBack, + Context, + Status + ); + if (ContinueEnum == FALSE) { + return ContinueEnum; + } + CurrentLink = CurrentLink->ForwardLink; + } // while + } + + return ContinueEnum; +} -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'