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.52]) by mx.groups.io with SMTP id smtpd.web12.80.1623775008218112987 for ; Tue, 15 Jun 2021 09:36:48 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=guu+gv3K; spf=pass (domain: arm.com, ip: 40.107.22.52, 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=NyM89onTPC8CkUDlwVODFJ58Xu+n+bohMZKZnkCG1d4=; b=guu+gv3KY3p86AP8i7vrCOEZ4ln322rz13OuY14sWfBMIBfTfgpziBbymNlRA+nM623xDEYlyIDojwHaX/QbetX2HxfR5ixW16D/aA+ZzE6nfCEdX8AVmCPQQ4H0KJnqtt4xwPiFS2rBqjG0P+YW/U8ffE+6xyLrZBu13F89tCc= Received: from AM6P193CA0062.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:8e::39) by AM9PR08MB6179.eurprd08.prod.outlook.com (2603:10a6:20b:2da::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21; Tue, 15 Jun 2021 16:36:45 +0000 Received: from AM5EUR03FT005.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:8e:cafe::bd) by AM6P193CA0062.outlook.office365.com (2603:10a6:209:8e::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Tue, 15 Jun 2021 16:36:45 +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 AM5EUR03FT005.mail.protection.outlook.com (10.152.16.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Tue, 15 Jun 2021 16:36:45 +0000 Received: ("Tessian outbound 94919dbe50f5:v93"); Tue, 15 Jun 2021 16:36:45 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 8a639bd4afda105b X-CR-MTA-TID: 64aa7808 Received: from 5e6a83b3d0bc.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 62AA4853-A899-426E-9C49-17E052C45E36.1; Tue, 15 Jun 2021 16:36:38 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 5e6a83b3d0bc.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 15 Jun 2021 16:36:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MJj9ICzPaAToPU9czblxBsQ8yi9bQQFkCNHPxICavOeuZFV6h7E8VMIgyZjnOb/EdtejONEyd6vm5ZQr+RG7wRdu2WLVu+bBwDS5IN11Smwf52iuV287yLptd9/t9R+kbULYANshgAFOoNit5djBYWRp8qLXqKpKzK5LVQwTajMZ9oFxKwJqnZ6PpxBwuYYRoba75tvtv55WetTLtF1yC8jFX6uaDbLevB1Yr8CLNyEGb66XUDqrUi864N1BnN8Zf6RvkOKNdGJUSg1mnJz3gf5Gqht+UzyxVhZU5S0Sz1lV2QorcqJKtUFMB6f6OvmcZUjIZq49AB48givtoNzxHw== 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=NyM89onTPC8CkUDlwVODFJ58Xu+n+bohMZKZnkCG1d4=; b=j7qkO6mz+IjL2zUdwGkzhDzgGb9snkxLpHoVLr1B9o7OdGA9/3QVavQ2U+9JOxwpD6dAQPymnteOoPUQwMOrU7bQSAq6Rzc/SenDda0uWRvDMLDFKrirDUuuymQrIXBKmatRe/fpJCUpzhCMUtRLZCVwcl/kZvpVHJvZTiQAmwih79aixZqWXOS+bbUTB9FE1WcCmbFwenU0789ESErWNuU/Z6SdlDUx+4cbjfvbq9nBhHMxB30etfLf5Zz5v6T57IVAylsxBVguLvywqEunFnomAzs8ipjWnUy5fjfkrDquRWsmCOb2RKeSYdA0rgHsbYQPtGT+He06AkM5DW1L9g== 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=pass (p=none sp=none pct=100) 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=NyM89onTPC8CkUDlwVODFJ58Xu+n+bohMZKZnkCG1d4=; b=guu+gv3KY3p86AP8i7vrCOEZ4ln322rz13OuY14sWfBMIBfTfgpziBbymNlRA+nM623xDEYlyIDojwHaX/QbetX2HxfR5ixW16D/aA+ZzE6nfCEdX8AVmCPQQ4H0KJnqtt4xwPiFS2rBqjG0P+YW/U8ffE+6xyLrZBu13F89tCc= Received: from DB6PR0301CA0036.eurprd03.prod.outlook.com (2603:10a6:4:3e::46) by DBBPR08MB4284.eurprd08.prod.outlook.com (2603:10a6:10:d0::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.20; Tue, 15 Jun 2021 16:36:33 +0000 Received: from DB5EUR03FT039.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:3e:cafe::6a) by DB6PR0301CA0036.outlook.office365.com (2603:10a6:4:3e::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4219.21 via Frontend Transport; Tue, 15 Jun 2021 16:36:33 +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=pass 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 DB5EUR03FT039.mail.protection.outlook.com (10.152.21.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4219.21 via Frontend Transport; Tue, 15 Jun 2021 16:36:33 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.14; Tue, 15 Jun 2021 16:36:27 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.14; Tue, 15 Jun 2021 16:36:24 +0000 Received: from E114225.Arm.com (10.1.196.43) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Tue, 15 Jun 2021 16:36:24 +0000 From: "Sami Mujawar" To: CC: Sami Mujawar , , , , , , Subject: [PATCH v1 8/8] DynamicTablesPkg: IORT generator updates for Rev E.b spec Date: Tue, 15 Jun 2021 17:36:18 +0100 Message-ID: <20210615163618.85200-9-sami.mujawar@arm.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: <20210615163618.85200-1-sami.mujawar@arm.com> References: <20210615163618.85200-1-sami.mujawar@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1e9e907e-8cef-4dce-b53d-08d9301bc38b X-MS-TrafficTypeDiagnostic: DBBPR08MB4284:|AM9PR08MB6179: 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: 4QX6CJ76s1o/5dgNUOR2j5MiWpxf6/i+NPcjVFposNGjwqCTswKXci7E8AAXPqajU4eAzcJPLr46NKR5AIWuTwGe4NCpORTcpOvxr3fhWluxoXMmLTLY6a9Se4iwdi5qj1nJEHaf0ym4MKloxXoqV6ODvYexy0lpiMUfxPSXApOCOKBT0hgkNUIx26hqZLrHo3gtThsZUjL+J6wkORVoDgRoyZtV9vO0aC5gxUalC/ZUSbqGYDTjLKC5TUj8IhNX1H0G4TTZZZCfgHK4eNVQC1GrMrufmQZNf4Em+ytRNyRksPwgMWYAEdhaR4OB5Y+ew2HDSsp1JDWg6WPUas7Nujth2GFvE2wF/92HTAFoZjSxlsPQOQWBYf0IjqJ/VXiA2QHa1e5Qllce+qvXSFoon94ZBfS5/P+0GWD1WXLpodApOWXWJjLL2oFldDPsKJiCfT6ZdKE9m19xU1/MKe9QsBnpiD+j93Q3f0+3GPf1dADhPfKXvTQhb3VkU2FmHzmZJug3v27eElEyv6tgjo217fc+90CFP4VF5ow+843FUj0CzAHQXRxdlTLwG6CCk7V4ebXOVsEjDsYs4Iwd2YejMZh09uLAQBQoCrvppZipI13Xn6GsEdLs6EM6Di5/6paGmxEWcNT1J9s4ulHG5Ii7SBiheu96kE0jQW2LMParkusDQIdJZ8IXJ1Q76SsMRmDIUczv8guU0p+WYC8/bcE9COyDORofHlUpICZB/xHynwvC6EiBZTAlxbw8tkwxZp5kixRGAe7JkYYWG8AQxzvMO73kABGWpHazIgVS2cF52qdfGFMT+ztgnLN2Q40kpezTlKv+s8VSWhrlgpnql1J5k6PiOYeMWFkLWpyND6AJV0g= 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)(396003)(346002)(136003)(376002)(39850400004)(46966006)(36840700001)(26005)(36756003)(54906003)(36860700001)(2906002)(47076005)(81166007)(478600001)(316002)(19627235002)(82310400003)(83380400001)(336012)(8676002)(186003)(8936002)(1076003)(7696005)(44832011)(4326008)(70586007)(70206006)(6916009)(5660300002)(356005)(82740400003)(426003)(2616005)(6666004)(86362001)(15650500001)(30864003)(36900700001)(579004);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB4284 Return-Path: Sami.Mujawar@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT005.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: dbd53c05-7884-4ee1-37e8-08d9301bbc86 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nIh5pL2HcpuIDzk0jaXZe4GVe2xYUc1oN0Gn6ZSFbVKwVFFLXSRoV9ERkkYY40Lg/NQ/JA8cguirU5uzZ4bWi9RHvdx43e0o5AuxnP8F0GE+0wmfXYpIs06QXKNEghJQc1MqOOK6uUKwTetd+w8FRgC97o1HCbOKVWGJ0GYh+JL2WgCvCGYCUtc7BBDqCTA4CHnFZf5PtGTcJdFaaJCjaS/Po+JVMD8Fb719q5ydFRdOQoDrXaa+5ALsRD0S0nFIBxqhLoUBOTG474wGvrCe1vNaaKGa0xM6rXPmF1fYJzPnMnyCcALnlMMKE4J3PSkpCUGbqJ5nMUuSm5b8YxHRjvXJwLEuoxLu1pAuG+bCHBFHSyg/h51XyqQgSjA2QSNOgkhMPEd14AzeDYK7GxAC3jLxSRFSNZgHcY9iA9f5Mk2RB/Uk9xwduEK1yZ41QJr18k3InCDQ+95DUodAUfm9V9qHwuGRnRV/TIzPZgo2UiY//9rTOe6xxcuQ2EhG4zRr4hOQ2ZH5AQEMNeFzosXBgzk7xDEjeC5xHjH84bJCLqR3wZhTKEOycsthFBYi6jcT+c9r8tST1drcszK4cHse/Z+Ue5GHhgsDXD89/dIGa69rQyMLenTW0PVoXrE5HC9eJp50N+gz6B2piddzDd0j9UMRx2hicdNe00DpQ0bn+vCcHjZGxVcYgB4XS/z68hvmQORmsAnmG2slXu/Z0H7ul1tG6x1FEjizuYcn1g8LzwpDLQqNW2r4IH9RGnd3k9Ktiek8pvMieNCBrPY+2o2nfG8bN9/b7KAgR4yXXVUdXaaMgB0t1sXFbr6QfHbaQH78 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)(376002)(346002)(136003)(39850400004)(396003)(46966006)(36840700001)(7696005)(478600001)(2616005)(81166007)(54906003)(36756003)(83380400001)(44832011)(6666004)(15650500001)(6916009)(316002)(5660300002)(82740400003)(70206006)(47076005)(36860700001)(186003)(82310400003)(336012)(2906002)(30864003)(4326008)(426003)(26005)(19627235002)(8936002)(86362001)(70586007)(8676002)(1076003)(579004);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Jun 2021 16:36:45.1879 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1e9e907e-8cef-4dce-b53d-08d9301bc38b 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: AM5EUR03FT005.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6179 Content-Type: text/plain Bugzilla: 3458 - Add support IORT Rev E.b specification updates (https://bugzilla.tianocore.org/show_bug.cgi?id=3458) The IO Remapping Table, Platform Design Document, Revision E.b, Feb 2021 (https://developer.arm.com/documentation/den0049/) introduces the following updates, collectively including the updates and errata fixes to Rev E and Rev E.a: - increments the IORT table revision to 3. - updates the node definition to add an 'Identifier' field. - adds definition of node type 6 - Reserved Memory Range node. - adds definition for Memory Range Descriptors. - adds flag to indicate PRI support for root complexes. - adds flag to indicate if the root complex supports forwarding of PASID information on translated transactions to the SMMU. Therefore, update the IORT generator to: - increment IORT table revision count to 3. - populate Identifier filed if revision is greater than 2. - add support to populate Reserved Memory Range nodes and the Memory range descriptors. - add validation to check that the Identifier field is unique. Signed-off-by: Sami Mujawar --- DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c | 659 ++++++++++++++++++-- DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.h | 5 +- 2 files changed, 623 insertions(+), 41 deletions(-) diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c index 9ccf72594db378878d4e3abbafe98e749d9963da..5124c767c41b8f6d8fae314c31c4772d28e44276 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.c @@ -5,8 +5,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent @par Reference(s): - - IO Remapping Table, Platform Design Document, - Document number: ARM DEN 0049D, Issue D, March 2018 + - IO Remapping Table, Platform Design Document, Revision E.b, Feb 2021 + (https://developer.arm.com/documentation/den0049/) **/ @@ -37,9 +37,11 @@ Requirements: - EArmObjSmmuV1SmmuV2 - EArmObjSmmuV3 - EArmObjPmcg + - EArmObjRmr - EArmObjGicItsIdentifierArray - EArmObjIdMappingArray - - EArmObjGicItsIdentifierArray + - EArmObjSmmuInterruptArray + - EArmObjMemoryRangeDescriptor */ /** This macro expands to a function that retrieves the ITS @@ -96,6 +98,24 @@ GET_OBJECT_LIST ( CM_ARM_PMCG_NODE ); +/** This macro expands to a function that retrieves the + RMR node information from the Configuration Manager. +*/ +GET_OBJECT_LIST ( + EObjNameSpaceArm, + EArmObjRmr, + CM_ARM_RMR_NODE + ); + +/** This macro expands to a function that retrieves the + Memory Range Descriptor Array information from the Configuration Manager. +*/ +GET_OBJECT_LIST ( + EObjNameSpaceArm, + EArmObjMemoryRangeDescriptor, + CM_ARM_MEMORY_RANGE_DESCRIPTOR + ); + /** This macro expands to a function that retrieves the ITS Identifier Array information from the Configuration Manager. */ @@ -177,13 +197,16 @@ GetSizeofItsGroupNodes ( (*NodeIndexer)->Token = NodeList->Token; (*NodeIndexer)->Object = (VOID*)NodeList; (*NodeIndexer)->Offset = (UINT32)(Size + NodeStartOffset); + (*NodeIndexer)->Identifier = NodeList->Identifier; DEBUG (( DEBUG_INFO, - "IORT: Node Indexer = %p, Token = %p, Object = %p, Offset = 0x%x\n", + "IORT: Node Indexer = %p, Token = %p, Object = %p," + " Offset = 0x%x, Identifier = 0x%x\n", *NodeIndexer, (*NodeIndexer)->Token, (*NodeIndexer)->Object, - (*NodeIndexer)->Offset + (*NodeIndexer)->Offset, + (*NodeIndexer)->Identifier )); Size += GetItsGroupNodeSize (NodeList); @@ -250,13 +273,16 @@ GetSizeofNamedComponentNodes ( (*NodeIndexer)->Token = NodeList->Token; (*NodeIndexer)->Object = (VOID*)NodeList; (*NodeIndexer)->Offset = (UINT32)(Size + NodeStartOffset); + (*NodeIndexer)->Identifier = NodeList->Identifier; DEBUG (( DEBUG_INFO, - "IORT: Node Indexer = %p, Token = %p, Object = %p, Offset = 0x%x\n", + "IORT: Node Indexer = %p, Token = %p, Object = %p," + " Offset = 0x%x, Identifier = 0x%x\n", *NodeIndexer, (*NodeIndexer)->Token, (*NodeIndexer)->Object, - (*NodeIndexer)->Offset + (*NodeIndexer)->Offset, + (*NodeIndexer)->Identifier )); Size += GetNamedComponentNodeSize (NodeList); @@ -322,13 +348,16 @@ GetSizeofRootComplexNodes ( (*NodeIndexer)->Token = NodeList->Token; (*NodeIndexer)->Object = (VOID*)NodeList; (*NodeIndexer)->Offset = (UINT32)(Size + NodeStartOffset); + (*NodeIndexer)->Identifier = NodeList->Identifier; DEBUG (( DEBUG_INFO, - "IORT: Node Indexer = %p, Token = %p, Object = %p, Offset = 0x%x\n", + "IORT: Node Indexer = %p, Token = %p, Object = %p," + " Offset = 0x%x, Identifier = 0x%x\n", *NodeIndexer, (*NodeIndexer)->Token, (*NodeIndexer)->Object, - (*NodeIndexer)->Offset + (*NodeIndexer)->Offset, + (*NodeIndexer)->Identifier )); Size += GetRootComplexNodeSize (NodeList); @@ -400,13 +429,16 @@ GetSizeofSmmuV1V2Nodes ( (*NodeIndexer)->Token = NodeList->Token; (*NodeIndexer)->Object = (VOID*)NodeList; (*NodeIndexer)->Offset = (UINT32)(Size + NodeStartOffset); + (*NodeIndexer)->Identifier = NodeList->Identifier; DEBUG (( DEBUG_INFO, - "IORT: Node Indexer = %p, Token = %p, Object = %p, Offset = 0x%x\n", + "IORT: Node Indexer = %p, Token = %p, Object = %p," + " Offset = 0x%x, Identifier = 0x%x\n", *NodeIndexer, (*NodeIndexer)->Token, (*NodeIndexer)->Object, - (*NodeIndexer)->Offset + (*NodeIndexer)->Offset, + (*NodeIndexer)->Identifier )); Size += GetSmmuV1V2NodeSize (NodeList); @@ -471,13 +503,16 @@ GetSizeofSmmuV3Nodes ( (*NodeIndexer)->Token = NodeList->Token; (*NodeIndexer)->Object = (VOID*)NodeList; (*NodeIndexer)->Offset = (UINT32)(Size + NodeStartOffset); + (*NodeIndexer)->Identifier = NodeList->Identifier; DEBUG (( DEBUG_INFO, - "IORT: Node Indexer = %p, Token = %p, Object = %p, Offset = 0x%x\n", + "IORT: Node Indexer = %p, Token = %p, Object = %p," + " Offset = 0x%x, Identifier = 0x%x\n", *NodeIndexer, (*NodeIndexer)->Token, (*NodeIndexer)->Object, - (*NodeIndexer)->Offset + (*NodeIndexer)->Offset, + (*NodeIndexer)->Identifier )); Size += GetSmmuV3NodeSize (NodeList); @@ -542,13 +577,16 @@ GetSizeofPmcgNodes ( (*NodeIndexer)->Token = NodeList->Token; (*NodeIndexer)->Object = (VOID*)NodeList; (*NodeIndexer)->Offset = (UINT32)(Size + NodeStartOffset); + (*NodeIndexer)->Identifier = NodeList->Identifier; DEBUG (( DEBUG_INFO, - "IORT: Node Indexer = %p, Token = %p, Object = %p, Offset = 0x%x\n", + "IORT: Node Indexer = %p, Token = %p, Object = %p," + " Offset = 0x%x, Identifier = 0x%x\n", *NodeIndexer, (*NodeIndexer)->Token, (*NodeIndexer)->Object, - (*NodeIndexer)->Offset + (*NodeIndexer)->Offset, + (*NodeIndexer)->Identifier )); Size += GetPmcgNodeSize (NodeList); @@ -558,6 +596,83 @@ GetSizeofPmcgNodes ( return Size; } +/** Returns the size of the RMR node. + + @param [in] Node Pointer to RMR node. + + @retval Size of the RMR node. +**/ +STATIC +UINT32 +GetRmrNodeSize ( + IN CONST CM_ARM_RMR_NODE * Node + ) +{ + ASSERT (Node != NULL); + + /* Size of RMR node + + Size of ID mapping array + + Size of Memory Range Descriptor array + */ + return (UINT32)(sizeof (EFI_ACPI_6_0_IO_REMAPPING_RMR_NODE) + + (Node->IdMappingCount * + sizeof (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE)) + + (Node->MemRangeDescCount * + sizeof (EFI_ACPI_6_0_IO_REMAPPING_MEM_RANGE_DESC))); +} + +/** Returns the total size required for the RMR nodes and + updates the Node Indexer. + + This function calculates the size required for the node group + and also populates the Node Indexer array with offsets for the + individual nodes. + + @param [in] NodeStartOffset Offset from the start of the + IORT where this node group starts. + @param [in] NodeList Pointer to RMR node list. + @param [in] NodeCount Count of the RMR nodes. + @param [in, out] NodeIndexer Pointer to the next Node Indexer. + + @retval Total size of the RMR nodes. +**/ +STATIC +UINT64 +GetSizeofRmrNodes ( + IN CONST UINT32 NodeStartOffset, + IN CONST CM_ARM_RMR_NODE * NodeList, + IN UINT32 NodeCount, + IN OUT IORT_NODE_INDEXER ** CONST NodeIndexer + ) +{ + UINT64 Size; + + ASSERT (NodeList != NULL); + + Size = 0; + while (NodeCount-- != 0) { + (*NodeIndexer)->Token = NodeList->Token; + (*NodeIndexer)->Object = (VOID*)NodeList; + (*NodeIndexer)->Offset = (UINT32)(Size + NodeStartOffset); + (*NodeIndexer)->Identifier = NodeList->Identifier; + DEBUG (( + DEBUG_INFO, + "IORT: Node Indexer = %p, Token = %p, Object = %p," + " Offset = 0x%x, Identifier = 0x%x\n", + *NodeIndexer, + (*NodeIndexer)->Token, + (*NodeIndexer)->Object, + (*NodeIndexer)->Offset, + (*NodeIndexer)->Identifier + )); + + Size += GetRmrNodeSize (NodeList); + (*NodeIndexer)++; + NodeList++; + } + return Size; +} + /** Returns the offset of the Node referenced by the Token. @param [in] NodeIndexer Pointer to node indexer array. @@ -707,6 +822,7 @@ AddIdMappingArray ( @param [in] This Pointer to the table Generator. @param [in] CfgMgrProtocol Pointer to the Configuration Manager Protocol Interface. + @param [in] AcpiTableInfo Pointer to the ACPI table info structure. @param [in] Iort Pointer to IORT table structure. @param [in] NodesStartOffset Offset for the start of the ITS Group Nodes. @@ -723,6 +839,7 @@ EFI_STATUS AddItsGroupNodes ( IN CONST ACPI_TABLE_GENERATOR * CONST This, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, + IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInfo, IN CONST EFI_ACPI_6_0_IO_REMAPPING_TABLE * Iort, IN CONST UINT32 NodesStartOffset, IN CONST CM_ARM_ITS_GROUP_NODE * NodeList, @@ -759,11 +876,17 @@ AddItsGroupNodes ( // Populate the node header ItsGroupNode->Node.Type = EFI_ACPI_IORT_TYPE_ITS_GROUP; ItsGroupNode->Node.Length = (UINT16)NodeLength; - ItsGroupNode->Node.Revision = 0; - ItsGroupNode->Node.Reserved = EFI_ACPI_RESERVED_DWORD; ItsGroupNode->Node.NumIdMappings = 0; ItsGroupNode->Node.IdReference = 0; + if (AcpiTableInfo->AcpiTableRevision < EFI_ACPI_IO_REMAPPING_TABLE_REV3) { + ItsGroupNode->Node.Revision = 0; + ItsGroupNode->Node.Identifier = EFI_ACPI_RESERVED_DWORD; + } else { + ItsGroupNode->Node.Revision = 1; + ItsGroupNode->Node.Identifier = NodeList->Identifier; + } + // IORT specific data ItsGroupNode->NumItsIdentifiers = NodeList->ItsIdCount; ItsIds = (UINT32*)((UINT8*)ItsGroupNode + @@ -814,6 +937,7 @@ AddItsGroupNodes ( @param [in] This Pointer to the table Generator. @param [in] CfgMgrProtocol Pointer to the Configuration Manager Protocol Interface. + @param [in] AcpiTableInfo Pointer to the ACPI table info structure. @param [in] Iort Pointer to IORT table structure. @param [in] NodesStartOffset Offset for the start of the Named Component Nodes. @@ -830,6 +954,7 @@ EFI_STATUS AddNamedComponentNodes ( IN CONST ACPI_TABLE_GENERATOR * CONST This, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, + IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInfo, IN CONST EFI_ACPI_6_0_IO_REMAPPING_TABLE * Iort, IN CONST UINT32 NodesStartOffset, IN CONST CM_ARM_NAMED_COMPONENT_NODE * NodeList, @@ -865,10 +990,16 @@ AddNamedComponentNodes ( // Populate the node header NcNode->Node.Type = EFI_ACPI_IORT_TYPE_NAMED_COMP; NcNode->Node.Length = (UINT16)NodeLength; - NcNode->Node.Revision = 2; - NcNode->Node.Reserved = EFI_ACPI_RESERVED_DWORD; NcNode->Node.NumIdMappings = NodeList->IdMappingCount; + if (AcpiTableInfo->AcpiTableRevision < EFI_ACPI_IO_REMAPPING_TABLE_REV3) { + NcNode->Node.Revision = 2; + NcNode->Node.Identifier = EFI_ACPI_RESERVED_DWORD; + } else { + NcNode->Node.Revision = 4; + NcNode->Node.Identifier = NodeList->Identifier; + } + ObjectNameLength = AsciiStrLen (NodeList->ObjectName) + 1; NcNode->Node.IdReference = (NodeList->IdMappingCount == 0) ? 0 : ((UINT32)(sizeof (EFI_ACPI_6_0_IO_REMAPPING_NAMED_COMP_NODE) + @@ -899,8 +1030,19 @@ AddNamedComponentNodes ( return Status; } - if ((NodeList->IdMappingCount > 0) && - (NodeList->IdMappingToken != CM_NULL_TOKEN)) { + if (NodeList->IdMappingCount > 0) { + if (NodeList->IdMappingToken == CM_NULL_TOKEN) { + Status = EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "ERROR: IORT: Invalid Id Mapping token," + " Token = 0x%x, Status =%r\n", + NodeList->IdMappingToken, + Status + )); + return Status; + } + // Ids for Named Component IdMapArray = (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE*)((UINT8*)NcNode + NcNode->Node.IdReference); @@ -938,6 +1080,7 @@ AddNamedComponentNodes ( @param [in] This Pointer to the table Generator. @param [in] CfgMgrProtocol Pointer to the Configuration Manager Protocol Interface. + @param [in] AcpiTableInfo Pointer to the ACPI table info structure. @param [in] Iort Pointer to IORT table structure. @param [in] NodesStartOffset Offset for the start of the Root Complex Nodes. @@ -954,6 +1097,7 @@ EFI_STATUS AddRootComplexNodes ( IN CONST ACPI_TABLE_GENERATOR * CONST This, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, + IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInfo, IN CONST EFI_ACPI_6_0_IO_REMAPPING_TABLE * Iort, IN CONST UINT32 NodesStartOffset, IN CONST CM_ARM_ROOT_COMPLEX_NODE * NodeList, @@ -987,12 +1131,18 @@ AddRootComplexNodes ( // Populate the node header RcNode->Node.Type = EFI_ACPI_IORT_TYPE_ROOT_COMPLEX; RcNode->Node.Length = (UINT16)NodeLength; - RcNode->Node.Revision = 1; - RcNode->Node.Reserved = EFI_ACPI_RESERVED_DWORD; RcNode->Node.NumIdMappings = NodeList->IdMappingCount; RcNode->Node.IdReference = (NodeList->IdMappingCount == 0) ? 0 : sizeof (EFI_ACPI_6_0_IO_REMAPPING_RC_NODE); + if (AcpiTableInfo->AcpiTableRevision < EFI_ACPI_IO_REMAPPING_TABLE_REV3) { + RcNode->Node.Revision = 1; + RcNode->Node.Identifier = EFI_ACPI_RESERVED_DWORD; + } else { + RcNode->Node.Revision = 3; + RcNode->Node.Identifier = NodeList->Identifier; + } + // Root Complex specific data RcNode->CacheCoherent = NodeList->CacheCoherent; RcNode->AllocationHints = NodeList->AllocationHints; @@ -1005,8 +1155,19 @@ AddRootComplexNodes ( RcNode->Reserved1[1] = EFI_ACPI_RESERVED_BYTE; RcNode->Reserved1[2] = EFI_ACPI_RESERVED_BYTE; - if ((NodeList->IdMappingCount > 0) && - (NodeList->IdMappingToken != CM_NULL_TOKEN)) { + if (NodeList->IdMappingCount > 0) { + if (NodeList->IdMappingToken == CM_NULL_TOKEN) { + Status = EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "ERROR: IORT: Invalid Id Mapping token," + " Token = 0x%x, Status =%r\n", + NodeList->IdMappingToken, + Status + )); + return Status; + } + // Ids for Root Complex IdMapArray = (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE*)((UINT8*)RcNode + RcNode->Node.IdReference); @@ -1107,6 +1268,7 @@ AddSmmuInterruptArray ( @param [in] This Pointer to the table Generator. @param [in] CfgMgrProtocol Pointer to the Configuration Manager Protocol Interface. + @param [in] AcpiTableInfo Pointer to the ACPI table info structure. @param [in] Iort Pointer to IORT table structure. @param [in] NodesStartOffset Offset for the start of the SMMU v1/v2 Nodes. @@ -1123,6 +1285,7 @@ EFI_STATUS AddSmmuV1V2Nodes ( IN CONST ACPI_TABLE_GENERATOR * CONST This, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, + IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInfo, IN CONST EFI_ACPI_6_0_IO_REMAPPING_TABLE * Iort, IN CONST UINT32 NodesStartOffset, IN CONST CM_ARM_SMMUV1_SMMUV2_NODE * NodeList, @@ -1159,8 +1322,6 @@ AddSmmuV1V2Nodes ( // Populate the node header SmmuNode->Node.Type = EFI_ACPI_IORT_TYPE_SMMUv1v2; SmmuNode->Node.Length = (UINT16)NodeLength; - SmmuNode->Node.Revision = 0; - SmmuNode->Node.Reserved = EFI_ACPI_RESERVED_DWORD; SmmuNode->Node.NumIdMappings = NodeList->IdMappingCount; SmmuNode->Node.IdReference = (NodeList->IdMappingCount == 0) ? 0 : (sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_NODE) + @@ -1169,6 +1330,14 @@ AddSmmuV1V2Nodes ( (NodeList->PmuInterruptCount * sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU_INT))); + if (AcpiTableInfo->AcpiTableRevision < EFI_ACPI_IO_REMAPPING_TABLE_REV3) { + SmmuNode->Node.Revision = 1; + SmmuNode->Node.Identifier = EFI_ACPI_RESERVED_DWORD; + } else { + SmmuNode->Node.Revision = 3; + SmmuNode->Node.Identifier = NodeList->Identifier; + } + // SMMU v1/v2 specific data SmmuNode->Base = NodeList->BaseAddress; SmmuNode->Span = NodeList->Span; @@ -1263,8 +1432,19 @@ AddSmmuV1V2Nodes ( } } - if ((NodeList->IdMappingCount > 0) && - (NodeList->IdMappingToken != CM_NULL_TOKEN)) { + if (NodeList->IdMappingCount > 0) { + if (NodeList->IdMappingToken == CM_NULL_TOKEN) { + Status = EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "ERROR: IORT: Invalid Id Mapping token," + " Token = 0x%x, Status =%r\n", + NodeList->IdMappingToken, + Status + )); + return Status; + } + // Ids for SMMU v1/v2 Node IdMapArray = (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE*)((UINT8*)SmmuNode + SmmuNode->Node.IdReference); @@ -1300,6 +1480,7 @@ AddSmmuV1V2Nodes ( @param [in] This Pointer to the table Generator. @param [in] CfgMgrProtocol Pointer to the Configuration Manager Protocol Interface. + @param [in] AcpiTableInfo Pointer to the ACPI table info structure. @param [in] Iort Pointer to IORT table structure. @param [in] NodesStartOffset Offset for the start of the SMMUv3 Nodes. @param [in] NodeList Pointer to an array of SMMUv3 Node Objects. @@ -1314,6 +1495,7 @@ EFI_STATUS AddSmmuV3Nodes ( IN CONST ACPI_TABLE_GENERATOR * CONST This, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, + IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInfo, IN CONST EFI_ACPI_6_0_IO_REMAPPING_TABLE * Iort, IN CONST UINT32 NodesStartOffset, IN CONST CM_ARM_SMMUV3_NODE * NodeList, @@ -1346,12 +1528,18 @@ AddSmmuV3Nodes ( // Populate the node header SmmuV3Node->Node.Type = EFI_ACPI_IORT_TYPE_SMMUv3; SmmuV3Node->Node.Length = (UINT16)NodeLength; - SmmuV3Node->Node.Revision = 2; - SmmuV3Node->Node.Reserved = EFI_ACPI_RESERVED_DWORD; SmmuV3Node->Node.NumIdMappings = NodeList->IdMappingCount; SmmuV3Node->Node.IdReference = (NodeList->IdMappingCount == 0) ? 0 : sizeof (EFI_ACPI_6_0_IO_REMAPPING_SMMU3_NODE); + if (AcpiTableInfo->AcpiTableRevision < EFI_ACPI_IO_REMAPPING_TABLE_REV3) { + SmmuV3Node->Node.Revision = 2; + SmmuV3Node->Node.Identifier = EFI_ACPI_RESERVED_DWORD; + } else { + SmmuV3Node->Node.Revision = 4; + SmmuV3Node->Node.Identifier = NodeList->Identifier; + } + // SMMUv3 specific data SmmuV3Node->Base = NodeList->BaseAddress; SmmuV3Node->Flags = NodeList->Flags; @@ -1379,8 +1567,19 @@ AddSmmuV3Nodes ( SmmuV3Node->DeviceIdMappingIndex = NodeList->DeviceIdMappingIndex; } - if ((NodeList->IdMappingCount > 0) && - (NodeList->IdMappingToken != CM_NULL_TOKEN)) { + if (NodeList->IdMappingCount > 0) { + if (NodeList->IdMappingToken == CM_NULL_TOKEN) { + Status = EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "ERROR: IORT: Invalid Id Mapping token," + " Token = 0x%x, Status =%r\n", + NodeList->IdMappingToken, + Status + )); + return Status; + } + // Ids for SMMUv3 node IdMapArray = (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE*)((UINT8*)SmmuV3Node + SmmuV3Node->Node.IdReference); @@ -1417,6 +1616,7 @@ AddSmmuV3Nodes ( @param [in] This Pointer to the table Generator. @param [in] CfgMgrProtocol Pointer to the Configuration Manager Protocol Interface. + @param [in] AcpiTableInfo Pointer to the ACPI table info structure. @param [in] Iort Pointer to IORT table structure. @param [in] NodesStartOffset Offset for the start of the PMCG Nodes. @param [in] NodeList Pointer to an array of PMCG Node Objects. @@ -1431,6 +1631,7 @@ EFI_STATUS AddPmcgNodes ( IN CONST ACPI_TABLE_GENERATOR * CONST This, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, + IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInfo, IN CONST EFI_ACPI_6_0_IO_REMAPPING_TABLE * Iort, IN CONST UINT32 NodesStartOffset, IN CONST CM_ARM_PMCG_NODE * NodeList, @@ -1465,12 +1666,18 @@ AddPmcgNodes ( // Populate the node header PmcgNode->Node.Type = EFI_ACPI_IORT_TYPE_PMCG; PmcgNode->Node.Length = (UINT16)NodeLength; - PmcgNode->Node.Revision = 1; - PmcgNode->Node.Reserved = EFI_ACPI_RESERVED_DWORD; PmcgNode->Node.NumIdMappings = NodeList->IdMappingCount; PmcgNode->Node.IdReference = (NodeList->IdMappingCount == 0) ? 0 : sizeof (EFI_ACPI_6_0_IO_REMAPPING_PMCG_NODE); + if (AcpiTableInfo->AcpiTableRevision < EFI_ACPI_IO_REMAPPING_TABLE_REV3) { + PmcgNode->Node.Revision = 1; + PmcgNode->Node.Identifier = EFI_ACPI_RESERVED_DWORD; + } else { + PmcgNode->Node.Revision = 2; + PmcgNode->Node.Identifier = NodeList->Identifier; + } + // PMCG specific data PmcgNode->Base = NodeList->BaseAddress; PmcgNode->OverflowInterruptGsiv = NodeList->OverflowInterrupt; @@ -1494,8 +1701,19 @@ AddPmcgNodes ( return Status; } - if ((NodeList->IdMappingCount > 0) && - (NodeList->IdMappingToken != CM_NULL_TOKEN)) { + if (NodeList->IdMappingCount > 0) { + if (NodeList->IdMappingToken == CM_NULL_TOKEN) { + Status = EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "ERROR: IORT: Invalid Id Mapping token," + " Token = 0x%x, Status =%r\n", + NodeList->IdMappingToken, + Status + )); + return Status; + } + // Ids for PMCG node IdMapArray = (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE*)((UINT8*)PmcgNode + PmcgNode->Node.IdReference); @@ -1526,6 +1744,273 @@ AddPmcgNodes ( return EFI_SUCCESS; } +/** Update the Memory Range Descriptor Array. + + This function retrieves the Memory Range Descriptor objects referenced by + MemRangeDescToken and updates the Memory Range Descriptor array. + + @param [in] This Pointer to the table Generator. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol Interface. + @param [in] DescArray Pointer to an array of Memory Range + Descriptors. + @param [in] DescCount Number of Id Descriptors. + @param [in] DescToken Reference Token for retrieving the + Memory Range Descriptor Array. + + @retval EFI_SUCCESS Table generated successfully. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND The required object was not found. +**/ +STATIC +EFI_STATUS +AddMemRangeDescArray ( + IN CONST ACPI_TABLE_GENERATOR * CONST This, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, + IN EFI_ACPI_6_0_IO_REMAPPING_MEM_RANGE_DESC * DescArray, + IN UINT32 DescCount, + IN CONST CM_OBJECT_TOKEN DescToken + ) +{ + EFI_STATUS Status; + CM_ARM_MEMORY_RANGE_DESCRIPTOR * MemRangeDesc; + UINT32 MemRangeDescCount; + + ASSERT (DescArray != NULL); + + // Get the Id Mapping Array + Status = GetEArmObjMemoryRangeDescriptor ( + CfgMgrProtocol, + DescToken, + &MemRangeDesc, + &MemRangeDescCount + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: IORT: Failed to get Memory Range Descriptor array. Status = %r\n", + Status + )); + return Status; + } + + if (MemRangeDescCount < DescCount) { + DEBUG (( + DEBUG_ERROR, + "ERROR: IORT: Failed to get the required number of Memory" + " Range Descriptors.\n" + )); + return EFI_NOT_FOUND; + } + + // Populate the Memory Range Descriptor array + while (DescCount-- != 0) { + + DescArray->Base = MemRangeDesc->BaseAddress; + DescArray->Length = MemRangeDesc->Length; + DescArray->Reserved = EFI_ACPI_RESERVED_DWORD; + + DescArray++; + MemRangeDesc++; + } + + return EFI_SUCCESS; +} + +/** Update the RMR Node Information. + + This function updates the RMR node information in the IORT table. + + @param [in] This Pointer to the table Generator. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol Interface. + @param [in] AcpiTableInfo Pointer to the ACPI table info structure. + @param [in] Iort Pointer to IORT table structure. + @param [in] NodesStartOffset Offset for the start of the PMCG Nodes. + @param [in] NodeList Pointer to an array of PMCG Node Objects. + @param [in] NodeCount Number of PMCG Node Objects. + + @retval EFI_SUCCESS Table generated successfully. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND The required object was not found. +**/ +STATIC +EFI_STATUS +AddRmrNodes ( + IN CONST ACPI_TABLE_GENERATOR * CONST This, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL * CONST CfgMgrProtocol, + IN CONST CM_STD_OBJ_ACPI_TABLE_INFO * CONST AcpiTableInfo, + IN CONST EFI_ACPI_6_0_IO_REMAPPING_TABLE * Iort, + IN CONST UINT32 NodesStartOffset, + IN CONST CM_ARM_RMR_NODE * NodeList, + IN UINT32 NodeCount + ) +{ + EFI_STATUS Status; + EFI_ACPI_6_0_IO_REMAPPING_RMR_NODE * RmrNode; + EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE * IdMapArray; + EFI_ACPI_6_0_IO_REMAPPING_MEM_RANGE_DESC * MemRangeDescArray; + UINT64 NodeLength; + + ASSERT (Iort != NULL); + + RmrNode = (EFI_ACPI_6_0_IO_REMAPPING_RMR_NODE*)((UINT8*)Iort + + NodesStartOffset); + + while (NodeCount-- != 0) { + NodeLength = GetRmrNodeSize (NodeList); + if (NodeLength > MAX_UINT16) { + Status = EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "ERROR: IORT: RMR Node length 0x%lx > MAX_UINT16. Status = %r\n", + NodeLength, + Status + )); + return Status; + } + + if (NodeList->MemRangeDescCount == 0) { + Status = EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "ERROR: IORT: Memory Range Desc count = %d. Status = %r\n", + NodeList->MemRangeDescCount, + Status + )); + return Status; + } + + if (NodeList->MemRangeDescToken == CM_NULL_TOKEN) { + Status = EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "ERROR: IORT: Invalid Memory Range Descriptor token," + " Token = 0x%x. Status = %r\n", + NodeList->MemRangeDescToken, + Status + )); + return Status; + } + + // Populate the node header + RmrNode->Node.Type = EFI_ACPI_IORT_TYPE_RMR; + RmrNode->Node.Length = (UINT16)NodeLength; + RmrNode->Node.Revision = 1; + RmrNode->Node.Identifier = NodeList->Identifier; + RmrNode->Node.NumIdMappings = NodeList->IdMappingCount; + RmrNode->Node.IdReference = (NodeList->IdMappingCount == 0) ? + 0 : sizeof (EFI_ACPI_6_0_IO_REMAPPING_RMR_NODE); + + // RMR specific data + RmrNode->Flags = NodeList->Flags; + RmrNode->NumMemRangeDesc = NodeList->MemRangeDescCount; + RmrNode->MemRangeDescRef = (NodeList->MemRangeDescCount == 0) ? + 0 : (sizeof (EFI_ACPI_6_0_IO_REMAPPING_RMR_NODE) + + (NodeList->IdMappingCount * + sizeof (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE))); + + if (NodeList->IdMappingCount > 0) { + if (NodeList->IdMappingToken == CM_NULL_TOKEN) { + Status = EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "ERROR: IORT: Invalid Id Mapping token," + " Token = 0x%x, Status =%r\n", + NodeList->IdMappingToken, + Status + )); + return Status; + } + + // Ids for RMR node + IdMapArray = (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE*)((UINT8*)RmrNode + + RmrNode->Node.IdReference); + + Status = AddIdMappingArray ( + This, + CfgMgrProtocol, + IdMapArray, + NodeList->IdMappingCount, + NodeList->IdMappingToken + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: IORT: Failed to add Id Mapping Array. Status = %r\n", + Status + )); + return Status; + } + } + + // Memory Range Descriptors for RMR node + MemRangeDescArray = (EFI_ACPI_6_0_IO_REMAPPING_MEM_RANGE_DESC*)( + (UINT8*)RmrNode + + RmrNode->MemRangeDescRef + ); + + Status = AddMemRangeDescArray ( + This, + CfgMgrProtocol, + MemRangeDescArray, + NodeList->MemRangeDescCount, + NodeList->MemRangeDescToken + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: IORT: Failed to Memory Range Descriptor Array. Status = %r\n", + Status + )); + return Status; + } + + // Next RMR Node + RmrNode = (EFI_ACPI_6_0_IO_REMAPPING_RMR_NODE*)((UINT8*)RmrNode + + RmrNode->Node.Length); + NodeList++; + } // RMR Node + + return EFI_SUCCESS; +} + +/** Validates that the IORT nodes Identifier are unique. + + @param [in] NodeIndexer Pointer to the Node Indexer. + @param [in] NodeCount Number of IORT Nodes. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER Identifier field not unique. +**/ +STATIC +EFI_STATUS +ValidateNodeIdentifiers ( + IN CONST IORT_NODE_INDEXER * CONST NodeIndexer, + IN UINT32 NodeCount + ) +{ + UINT32 IndexI; + UINT32 IndexJ; + + for (IndexI = 0; IndexI < NodeCount; IndexI++) { + for (IndexJ = 0; IndexJ < NodeCount; IndexJ++) { + if ((IndexI != IndexJ) && + (NodeIndexer[IndexI].Identifier == NodeIndexer[IndexJ].Identifier)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: IORT: UID %d of Token %p matches with that of Token %p.\n", + NodeIndexer[IndexI].Identifier, + NodeIndexer[IndexI].Token, + NodeIndexer[IndexJ].Token + )); + return EFI_INVALID_PARAMETER; + } + }// IndexJ + } // IndexI + return EFI_SUCCESS; +} + /** Construct the IORT ACPI table. This function invokes the Configuration Manager protocol interface @@ -1570,6 +2055,7 @@ BuildIortTable ( UINT32 SmmuV1V2NodeCount; UINT32 SmmuV3NodeCount; UINT32 PmcgNodeCount; + UINT32 RmrNodeCount; UINT32 ItsGroupOffset; UINT32 NamedComponentOffset; @@ -1577,6 +2063,7 @@ BuildIortTable ( UINT32 SmmuV1V2Offset; UINT32 SmmuV3Offset; UINT32 PmcgOffset; + UINT32 RmrOffset; CM_ARM_ITS_GROUP_NODE * ItsGroupNodeList; CM_ARM_NAMED_COMPONENT_NODE * NamedComponentNodeList; @@ -1584,6 +2071,7 @@ BuildIortTable ( CM_ARM_SMMUV1_SMMUV2_NODE * SmmuV1V2NodeList; CM_ARM_SMMUV3_NODE * SmmuV3NodeList; CM_ARM_PMCG_NODE * PmcgNodeList; + CM_ARM_RMR_NODE * RmrNodeList; EFI_ACPI_6_0_IO_REMAPPING_TABLE * Iort; IORT_NODE_INDEXER * NodeIndexer; @@ -1726,6 +2214,27 @@ BuildIortTable ( // Add the PMCG node count IortNodeCount += PmcgNodeCount; + if (AcpiTableInfo->AcpiTableRevision >= EFI_ACPI_IO_REMAPPING_TABLE_REV3) { + // Get the RMR node info + Status = GetEArmObjRmr ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &RmrNodeList, + &RmrNodeCount + ); + if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: IORT: Failed to get RMR Node Info. Status = %r\n", + Status + )); + goto error_handler; + } + + // Add the RMR node count + IortNodeCount += RmrNodeCount; + } + // Allocate Node Indexer array NodeIndexer = (IORT_NODE_INDEXER*)AllocateZeroPool ( (sizeof (IORT_NODE_INDEXER) * @@ -1929,6 +2438,37 @@ BuildIortTable ( )); } + // RMR Nodes + if ((AcpiTableInfo->AcpiTableRevision >= EFI_ACPI_IO_REMAPPING_TABLE_REV3) && + (RmrNodeCount > 0)) { + RmrOffset = (UINT32)TableSize; + // Size of RMR node list. + NodeSize = GetSizeofRmrNodes ( + RmrOffset, + RmrNodeList, + RmrNodeCount, + &NodeIndexer + ); + if (NodeSize > MAX_UINT32) { + Status = EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "ERROR: IORT: Invalid Size of RMR Nodes. Status = %r\n", + Status + )); + goto error_handler; + } + TableSize += NodeSize; + + DEBUG (( + DEBUG_INFO, + " RmrNodeCount = %d\n" \ + " RmrOffset = %d\n", + RmrNodeCount, + RmrOffset + )); + } + DEBUG (( DEBUG_INFO, "INFO: IORT:\n" \ @@ -1950,6 +2490,19 @@ BuildIortTable ( goto error_handler; } + // Validate that the identifiers for the nodes are unique + if (AcpiTableInfo->AcpiTableRevision >= EFI_ACPI_IO_REMAPPING_TABLE_REV3) { + Status = ValidateNodeIdentifiers (Generator->NodeIndexer, IortNodeCount); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: IORT: Node Identifier not unique. Status = %r\n", + Status + )); + goto error_handler; + } + } + // Allocate the Buffer for IORT table *Table = (EFI_ACPI_DESCRIPTION_HEADER*)AllocateZeroPool (TableSize); if (*Table == NULL) { @@ -1998,6 +2551,7 @@ BuildIortTable ( Status = AddItsGroupNodes ( This, CfgMgrProtocol, + AcpiTableInfo, Iort, ItsGroupOffset, ItsGroupNodeList, @@ -2017,6 +2571,7 @@ BuildIortTable ( Status = AddNamedComponentNodes ( This, CfgMgrProtocol, + AcpiTableInfo, Iort, NamedComponentOffset, NamedComponentNodeList, @@ -2036,6 +2591,7 @@ BuildIortTable ( Status = AddRootComplexNodes ( This, CfgMgrProtocol, + AcpiTableInfo, Iort, RootComplexOffset, RootComplexNodeList, @@ -2055,6 +2611,7 @@ BuildIortTable ( Status = AddSmmuV1V2Nodes ( This, CfgMgrProtocol, + AcpiTableInfo, Iort, SmmuV1V2Offset, SmmuV1V2NodeList, @@ -2074,6 +2631,7 @@ BuildIortTable ( Status = AddSmmuV3Nodes ( This, CfgMgrProtocol, + AcpiTableInfo, Iort, SmmuV3Offset, SmmuV3NodeList, @@ -2093,6 +2651,7 @@ BuildIortTable ( Status = AddPmcgNodes ( This, CfgMgrProtocol, + AcpiTableInfo, Iort, PmcgOffset, PmcgNodeList, @@ -2101,7 +2660,27 @@ BuildIortTable ( if (EFI_ERROR (Status)) { DEBUG (( DEBUG_ERROR, - "ERROR: IORT: Failed to add SMMUv3 Node. Status = %r\n", + "ERROR: IORT: Failed to add PMCG Node. Status = %r\n", + Status + )); + goto error_handler; + } + } + + if (RmrNodeCount > 0) { + Status = AddRmrNodes ( + This, + CfgMgrProtocol, + AcpiTableInfo, + Iort, + RmrOffset, + RmrNodeList, + RmrNodeCount + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: IORT: Failed to add RMR Node. Status = %r\n", Status )); goto error_handler; @@ -2184,11 +2763,11 @@ ACPI_IORT_GENERATOR IortGenerator = { // Generator Description L"ACPI.STD.IORT.GENERATOR", // ACPI Table Signature - EFI_ACPI_6_2_IO_REMAPPING_TABLE_SIGNATURE, + EFI_ACPI_6_3_IO_REMAPPING_TABLE_SIGNATURE, // ACPI Table Revision supported by this Generator EFI_ACPI_IO_REMAPPING_TABLE_REVISION, // Minimum supported ACPI Table Revision - EFI_ACPI_IO_REMAPPING_TABLE_REVISION, + EFI_ACPI_IO_REMAPPING_TABLE_REV0, // Creator ID TABLE_GENERATOR_CREATOR_ID_ARM, // Creator Revision diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.h b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.h index bbf8aaf9efa38a75626a49af6f380b1c8c1a0629..afe2089b1dc20ed671583e2a309cc1a46c3404c6 100644 --- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.h +++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiIortLibArm/IortGenerator.h @@ -1,6 +1,6 @@ /** @file - Copyright (c) 2018, ARM Limited. All rights reserved. + Copyright (c) 2018 - 2021, ARM Limited. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent @@ -25,6 +25,9 @@ typedef struct IortNodeIndexer { VOID * Object; /// Node offset from the start of the IORT table UINT32 Offset; + + /// Unique identifier for the Node + UINT32 Identifier; } IORT_NODE_INDEXER; typedef struct AcpiIortGenerator { -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'