From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (EUR04-VI1-obe.outbound.protection.outlook.com [40.107.8.73]) by mx.groups.io with SMTP id smtpd.web12.7975.1585129188977107444 for ; Wed, 25 Mar 2020 02:39:49 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@armh.onmicrosoft.com header.s=selector2-armh-onmicrosoft-com header.b=7uOPNdrm; spf=pass (domain: arm.com, ip: 40.107.8.73, mailfrom: krzysztof.koch@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=PLvy6rozeAPtZ+p++hql4Km1dT3ZQURhHPbDxBRWvcY=; b=7uOPNdrmSfTY4PvdDJ0m3QqB1ZfgG2UVqYdE+ie6OENFp92pZxkJlouKt/ZXKTL7coxDPeLnPv6fvnFSjQpCmVpGKGOL8hCXwPBkwalz70Ikmjme1dpv+uBNlcEVLCs7u9JfCqen6YD01KFfwGMVG7Ycobri4mWr6q0vuh8BEBk= Received: from AM6P193CA0093.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:88::34) by DB8PR08MB5324.eurprd08.prod.outlook.com (2603:10a6:10:11e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.18; Wed, 25 Mar 2020 09:39:46 +0000 Received: from VE1EUR03FT037.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:88:cafe::f0) by AM6P193CA0093.outlook.office365.com (2603:10a6:209:88::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.20 via Frontend Transport; Wed, 25 Mar 2020 09:39:45 +0000 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 VE1EUR03FT037.mail.protection.outlook.com (10.152.19.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.17 via Frontend Transport; Wed, 25 Mar 2020 09:39:45 +0000 Received: ("Tessian outbound fb361fb66447:v48"); Wed, 25 Mar 2020 09:39:45 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 67a1aeb606d7ea16 X-CR-MTA-TID: 64aa7808 Received: from 003d1da8a047.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 2D89B320-7AC1-40D4-8664-DC44A0AC6715.1; Wed, 25 Mar 2020 09:39:39 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 003d1da8a047.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 25 Mar 2020 09:39:39 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QuTd7GeMRbp4BWlv58NrhrO8StOg7PvBvDI0XXx5hcTInaMpnUxxuYmRd5JaoLo7ktIKTO5bmwd2DQt178Fw4UejD0vpLNETzN1Pvz6/CX/j5cwFFY+3xSbspttP4b8Si3e87R39peGnjA88dLuGdTxDOMrJC9dK9Wak6MF7f9M8a1gbav79FKf+B3vYWedFM2AMsASwzMieTAbwAm+ljL6ZbXEOwVnpnIpSJaL7AihmSaX9Ie/fiQ4v6DZJrJUt3Kxa/qNzU+3Iakvr6GxWepWI6gMMjpy5ElOn/Lw7Ml+TywVat3RqRX3IxAKk0KXKJDWXaeW6wYXlnKEurHOsGg== 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=PLvy6rozeAPtZ+p++hql4Km1dT3ZQURhHPbDxBRWvcY=; b=RpsKpa5uBWLqe2Z4TPEtI8WTz1WQBMM+RRNZxgCB+ITOwUll6qP3IPQgS0+ouB0JwN8rRa/ymtzZiXI4AdmdyC1hRQ/8T4MC6DRmrkc2y5eDiKyUfXt1uTowqzQ8eZ0kc+wfbTja+gPkn7DBqrFi0ap8DoB5RFNU/ztGGxVMy2Up+BuHgzM8qwLoy8WQyik4fLIxqCAQmWvQoZ+Q/XEV1ZpOVDwsuXoGjqMUx9Ca/DxmOmg+KNPvvxOhvQBqXvzm+StODbI4vVE8lhECtll7Dma7rTN2L7KU1j/i2k1uqEfizHisc8I+bBhHXp9I4gWG10/GOGc2v4slGvrfZuUADw== 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=PLvy6rozeAPtZ+p++hql4Km1dT3ZQURhHPbDxBRWvcY=; b=7uOPNdrmSfTY4PvdDJ0m3QqB1ZfgG2UVqYdE+ie6OENFp92pZxkJlouKt/ZXKTL7coxDPeLnPv6fvnFSjQpCmVpGKGOL8hCXwPBkwalz70Ikmjme1dpv+uBNlcEVLCs7u9JfCqen6YD01KFfwGMVG7Ycobri4mWr6q0vuh8BEBk= Received: from VI1PR07CA0202.eurprd07.prod.outlook.com (2603:10a6:802:3f::26) by AM0PR08MB5187.eurprd08.prod.outlook.com (2603:10a6:208:15d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.20; Wed, 25 Mar 2020 09:39:37 +0000 Received: from VE1EUR03FT046.eop-EUR03.prod.protection.outlook.com (2603:10a6:802:3f:cafe::6d) by VI1PR07CA0202.outlook.office365.com (2603:10a6:802:3f::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.12 via Frontend Transport; Wed, 25 Mar 2020 09:39:37 +0000 Authentication-Results-Original: 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 VE1EUR03FT046.mail.protection.outlook.com (10.152.19.226) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.2856.17 via Frontend Transport; Wed, 25 Mar 2020 09:39:37 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) 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.1415.2; Wed, 25 Mar 2020 09:39:26 +0000 Received: from E119924.Arm.com (10.57.55.133) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.1415.2 via Frontend Transport; Wed, 25 Mar 2020 09:39:26 +0000 From: "Krzysztof Koch" To: CC: , , , , , Subject: [PATCH v1 2/3] ShellPkg: acpiview: Add library for SBBR ACPI requirements validation Date: Wed, 25 Mar 2020 09:39:23 +0000 Message-ID: <20200325093924.22884-3-krzysztof.koch@arm.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: <20200325093924.22884-1-krzysztof.koch@arm.com> References: <20200325093924.22884-1-krzysztof.koch@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;IPV:;CTRY:IE;EFV:NLI;SFV:NSPM;SFS:(10009020)(4636009)(396003)(136003)(39860400002)(376002)(346002)(46966005)(81166006)(26005)(47076004)(44832011)(81156014)(82740400003)(2616005)(86362001)(8676002)(186003)(478600001)(70206006)(2906002)(8936002)(316002)(54906003)(70586007)(6666004)(36756003)(356004)(7696005)(19627235002)(4326008)(336012)(1076003)(426003)(5660300002)(30864003)(6916009);DIR:OUT;SFP:1101;SCL:1;SRVR:AM0PR08MB5187;H:nebula.arm.com;FPR:;SPF:Pass;LANG:en;PTR:InfoDomainNonexistent; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f71a874c-5cee-4949-94ed-08d7d0a073dd X-MS-TrafficTypeDiagnostic: AM0PR08MB5187:|DB8PR08MB5324: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:962;OLM:962; X-Forefront-PRVS: 0353563E2B X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: WyxvhcRUaV2/WMoqwbPyMfNJy5ZdMligziJbsP93Y/gu5JHe9yx/ui9/xCBZO+FDUjfCyAml536g4awmtBRb3UVXqmyiQwh6KFpe0mAMAaU3Ze1IpWmxXPJe+2gAiASR+3JCpIkWopfzjPUAhr8yvwq04wFiPpz23Femt84zEScCPOCzF1+ExQhBvEKxlacjNUvUNADaifjQQUJRmudJ0eRCap/TD0KGGXx+i1CVmcK+GCTLXHRV9+ON6Jy2hlcuBdeg3lww+bI0KLLPUugxlq/6UZhTaZz31AuJ6BvbrjNA1aXgoJKUqN23ZzFu1TOjJHbu/Kut88niOWLKkvNnQb2rk7fOtG+tTpZMinjXlWSXL7sWAGC7xAcSUN33ZojetNuvu2MEsmOYZZUBRX8debY0UCBYoCpX4CrsFYEmeDrXk7d62qFURKjeyAnffbN6nB7GP3zwd+bDzWhItwLQB3Pax6yh0XpId3L4bOVt4jied4wQKfTX50CfnG7BQyYR837/B5Lk34pKq+MQXrV3vA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB5187 Original-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; Return-Path: Krzysztof.Koch@arm.com X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT037.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123;IPV:CAL;SCL:-1;CTRY:IE;EFV:NLI;SFV:NSPM;SFS:(10009020)(4636009)(346002)(136003)(376002)(396003)(39860400002)(46966005)(6916009)(81166006)(81156014)(8936002)(70586007)(19627235002)(1076003)(5660300002)(70206006)(478600001)(8676002)(36756003)(26826003)(2906002)(6666004)(7696005)(86362001)(316002)(54906003)(186003)(2616005)(426003)(30864003)(4326008)(336012)(44832011)(82740400003)(26005)(36906005)(47076004);DIR:OUT;SFP:1101;SCL:1;SRVR:DB8PR08MB5324;H:64aa7808-outbound-1.mta.getcheckrecipient.com;FPR:;SPF:Pass;LANG:en;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; X-MS-Office365-Filtering-Correlation-Id-Prvs: c4d85a38-414f-4f2c-bae9-08d7d0a06f1d X-Forefront-PRVS: 0353563E2B X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +12rZ0b9sKwMkPrTLJnk28gUQH2xG8HERQcAcOJENhB1hljcxIrQIda6web6Q7L0Nzz3sUr0fxl7fXyACQ2vnsE7lX5C8Ebz/qDKwRaaFkRIuyx3rqUg5N5HwJrLPp87akdFQLl4bluoC6jB1wv6AMb5E7BZ7ugr2Gn8UfmYKS0elHEDP/uyW1G1qtI4481nTFAghctBDEmQBGAQK9PQuYXOp33QC8YOqZauVUC+X/EnkVKXd8z9bfbl8xBc85kUMV0ie2kUhFfiXNrjeRgmCy/kNEoK0qrbrfOk7iSAZXGs6doGCGxIwCpmizfXjEs5TEWkVmlPjZWiLxFNk5wT7eO1y4EoryeHYWyHr54WP9C57xLTf0jRy3GXOm8HWbE4BTkLbmqMq4QokThuXrLWcmwaiYTk56RJzFhq5djetn+Uf/W2n540NIBMr6qynBf451pKGfeVrN3i4KTRqecDRpH/hGh7bvKYZ57DaAwqLgwD9/ivKScZCQ22Y9fd/AfQQrPRxcghQk/+kVzRIHzXyQ== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2020 09:39:45.2089 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f71a874c-5cee-4949-94ed-08d7d0a073dd 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5324 Content-Type: text/plain For Arm-based platforms, define and implement an interface for Server Base Boot Requirements (SBBR) compliance checks. The library is responsible for validating that all mandatory ACPI tables are installed on the platform. Internally, the library maintains a data structure which tracks instance counts for ACPI tables which are labeled as 'mandatory' in any SBBR specification version. The provided interface allows: - resetting all instance counts to 0 - incremementing the instance count for a table with a given signature - validating the instance counts against the requirements in SBBR The ACPI table requirements for each SBBR spec version are represented internally as a list of table signatures. Every missing mandatory table (for the input SBBR version) is reported to the user as a separate error. If all requirements are met, an info message is displayed. Reference(s): - Arm Server Base Boot Requirements 1.2, September 2019 - Arm Server Base Boot Requirements 1.1, May 2018 - Arm Server Base Boot Requirements 1.0, March 2016 Signed-off-by: Krzysztof Koch --- Notes: v1: - add library for SBBR ACPI requirements validation [Krzysztof] ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.c | 222 ++++++++++++++++++++ ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.h | 91 ++++++++ ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf | 6 +- 3 files changed, 318 insertions(+), 1 deletion(-) diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.c new file mode 100644 index 0000000000000000000000000000000000000000..d3284417fa5f4da1c29ba56b8587f1119c776278 --- /dev/null +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.c @@ -0,0 +1,222 @@ +/** @file + Arm Server Base Boot Requirements ACPI table requirement validator. + + Copyright (c) 2020, ARM Limited. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Glossary: + - Sbbr or SBBR - Server Base Boot Requirements + - Sbsa or SBSA - Server Base System Architecture + + @par Reference(s): + - Arm Server Base Boot Requirements 1.2, September 2019 + - Arm Server Base Boot Requirements 1.1, May 2018 + - Arm Server Base Boot Requirements 1.0, March 2016 + - Arm Server Base System Architecture 6.0 +**/ + +#include +#include +#include "AcpiParser.h" +#include "Arm/SbbrValidator.h" + +/** + SBBR specification version strings +**/ +STATIC CONST CHAR8* ArmSbbrVersions[ArmSbbrVersionMax] = { + "1.0", // ArmSbbrVersion_1_0 + "1.1", // ArmSbbrVersion_1_1 + "1.2" // ArmSbbrVersion_1_2 +}; + +/** + SBBR 1.0 mandatory ACPI tables +**/ +STATIC CONST UINT32 ArmSbbr10Mandatory[] = { + EFI_ACPI_6_3_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, + EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, + EFI_ACPI_6_3_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, + EFI_ACPI_6_3_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE, + EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE, + EFI_ACPI_6_3_DEBUG_PORT_2_TABLE_SIGNATURE, + EFI_ACPI_6_3_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE +}; + +/** + SBBR 1.1 mandatory ACPI tables +**/ +STATIC CONST UINT32 ArmSbbr11Mandatory[] = { + EFI_ACPI_6_3_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, + EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, + EFI_ACPI_6_3_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, + EFI_ACPI_6_3_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE, + EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE, + EFI_ACPI_6_3_DEBUG_PORT_2_TABLE_SIGNATURE, + EFI_ACPI_6_3_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE, + EFI_ACPI_6_3_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE +}; + +/** + SBBR 1.2 mandatory ACPI tables +**/ +STATIC CONST UINT32 ArmSbbr12Mandatory[] = { + EFI_ACPI_6_3_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, + EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, + EFI_ACPI_6_3_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, + EFI_ACPI_6_3_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE, + EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE, + EFI_ACPI_6_3_DEBUG_PORT_2_TABLE_SIGNATURE, + EFI_ACPI_6_3_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE, + EFI_ACPI_6_3_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE, + EFI_ACPI_6_3_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_STRUCTURE_SIGNATURE +}; + +/** + Mandatory ACPI tables for every SBBR specification version. +**/ +STATIC CONST ACPI_SBBR_REQ ArmSbbrReqs[ArmSbbrVersionMax] = { + { ArmSbbr10Mandatory, ARRAY_SIZE (ArmSbbr10Mandatory) }, // SBBR v1.0 + { ArmSbbr11Mandatory, ARRAY_SIZE (ArmSbbr11Mandatory) }, // SBBR v1.1 + { ArmSbbr12Mandatory, ARRAY_SIZE (ArmSbbr12Mandatory) } // SBBR v1.2 +}; + +/** + Data structure to track instance counts for all ACPI tables which are + defined as 'mandatory' in any SBBR version. +**/ +STATIC ACPI_TABLE_COUNTER ArmSbbrTableCounts[] = { + {EFI_ACPI_6_3_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, 0}, + {EFI_ACPI_6_3_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE, 0}, + {EFI_ACPI_6_3_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE, 0}, + {EFI_ACPI_6_3_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE, 0}, + {EFI_ACPI_6_3_GENERIC_TIMER_DESCRIPTION_TABLE_SIGNATURE, 0}, + {EFI_ACPI_6_3_DEBUG_PORT_2_TABLE_SIGNATURE, 0}, + {EFI_ACPI_6_3_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE, 0}, + {EFI_ACPI_6_3_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE, 0}, + {EFI_ACPI_6_3_PROCESSOR_PROPERTIES_TOPOLOGY_TABLE_STRUCTURE_SIGNATURE, 0} +}; + +/** + Reset the platform ACPI table instance count for all SBBR-mandatory tables. +**/ +VOID +EFIAPI +ArmSbbrResetTableCounts ( + VOID + ) +{ + UINT32 Table; + + for (Table = 0; Table < ARRAY_SIZE (ArmSbbrTableCounts); Table++) { + ArmSbbrTableCounts[Table].Count = 0; + } +} + +/** + Increment instance count for SBBR-mandatory ACPI table with the given + signature. + + @param [in] Signature ACPI table signature. + + @retval TRUE Count incremented successfully. + @retval FALSE Table with the input signature not found. +**/ +BOOLEAN +EFIAPI +ArmSbbrIncrementTableCount ( + UINT32 Signature + ) +{ + UINT32 Table; + + for (Table = 0; Table < ARRAY_SIZE (ArmSbbrTableCounts); Table++) { + if (Signature == ArmSbbrTableCounts[Table].Signature) { + ArmSbbrTableCounts[Table].Count++; + return TRUE; + } + } + + return FALSE; +} + +/** + Validate that all ACPI tables required by the given SBBR specification + version are installed on the platform. + + @param [in] Version SBBR spec version to validate against. + + @retval EFI_SUCCESS All required tables are present. + @retval EFI_INVALID_PARAMETER Invalid SBBR version. + @retval EFI_NOT_FOUND One or more mandatory tables are missing. + @retval EFI_UNSUPPORTED Mandatory ACPI table does not have its + instance count tracked. +**/ +EFI_STATUS +EFIAPI +ArmSbbrReqsValidate ( + ARM_SBBR_VERSION Version + ) +{ + UINT32 Table; + UINT32 Index; + UINT32 MandatoryTable; + CONST UINT8* SignaturePtr; + BOOLEAN IsArmSbbrViolated; + + if (Version >= ArmSbbrVersionMax) { + return EFI_INVALID_PARAMETER; + } + + IsArmSbbrViolated = FALSE; + + // Go through the list of mandatory tables for the input SBBR version + for (Table = 0; Table < ArmSbbrReqs[Version].TableCount; Table++) { + MandatoryTable = ArmSbbrReqs[Version].Tables[Table]; + SignaturePtr = (CONST UINT8*)(UINTN)&MandatoryTable; + + // Locate the instance count for the table with the given signature + Index = 0; + while ((Index < ARRAY_SIZE (ArmSbbrTableCounts)) && + (ArmSbbrTableCounts[Index].Signature != MandatoryTable)) { + Index++; + } + + if (Index >= ARRAY_SIZE (ArmSbbrTableCounts)) { + IncrementErrorCount (); + Print ( + L"\nERROR: SBBR v%a: Mandatory %c%c%c%c table's instance count not " \ + L"found\n", + ArmSbbrVersions[Version], + SignaturePtr[0], + SignaturePtr[1], + SignaturePtr[2], + SignaturePtr[3] + ); + return EFI_UNSUPPORTED; + } + + if (ArmSbbrTableCounts[Index].Count == 0) { + IsArmSbbrViolated = TRUE; + IncrementErrorCount (); + Print ( + L"\nERROR: SBBR v%a: Mandatory %c%c%c%c table is missing", + ArmSbbrVersions[Version], + SignaturePtr[0], + SignaturePtr[1], + SignaturePtr[2], + SignaturePtr[3] + ); + } + } + + if (!IsArmSbbrViolated) { + Print ( + L"\nINFO: SBBR v%a: All mandatory ACPI tables are installed", + ArmSbbrVersions[Version] + ); + } + + Print (L"\n"); + + return IsArmSbbrViolated ? EFI_NOT_FOUND : EFI_SUCCESS; +} diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.h new file mode 100644 index 0000000000000000000000000000000000000000..3135f74fcb6c2d41d8abccc6067c0d6d40f3d089 --- /dev/null +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Arm/SbbrValidator.h @@ -0,0 +1,91 @@ +/** @file + Header file for SbbrValidator.c + + Copyright (c) 2020, ARM Limited. All rights reserved. + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Glossary: + - Sbbr or SBBR - Server Base Boot Requirements + - Sbsa or SBSA - Server Base System Architecture + + @par Reference(s): + - Arm Server Base Boot Requirements 1.2, September 2019 + - Arm Server Base Boot Requirements 1.1, May 2018 + - Arm Server Base Boot Requirements 1.0, March 2016 + - Arm Server Base System Architecture 6.0 +**/ + +#ifndef SBBR_VALIDATOR_H_ +#define SBBR_VALIDATOR_H_ + +#include + +/** + Arm SBBR specification versions. +**/ +typedef enum { + ArmSbbrVersion_1_0 = 0, + ArmSbbrVersion_1_1 = 1, + ArmSbbrVersion_1_2 = 2, + ArmSbbrVersionMax = 3 +} ARM_SBBR_VERSION; + +/** + The ACPI table instance counter. +**/ +typedef struct AcpiTableCounter { + CONST UINT32 Signature; /// ACPI table signature + UINT32 Count; /// Instance count +} ACPI_TABLE_COUNTER; + +/** + ACPI table SBBR requirements. +**/ +typedef struct AcpiSbbrReq { + CONST UINT32* Tables; /// List of required tables + CONST UINT32 TableCount; /// Number of elements in Tables +} ACPI_SBBR_REQ; + +/** + Reset the platform ACPI table instance count for all SBBR-mandatory tables. +**/ +VOID +EFIAPI +ArmSbbrResetTableCounts ( + VOID + ); + +/** + Increment instance count for SBBR-mandatory ACPI table with the given + signature. + + @param [in] Signature ACPI table signature. + + @retval TRUE Count incremented successfully. + @retval FALSE Table with the input signature not found. +**/ +BOOLEAN +EFIAPI +ArmSbbrIncrementTableCount ( + UINT32 Signature + ); + +/** + Validate that all ACPI tables required by the given SBBR specification + version are installed on the platform. + + @param [in] Version SBBR spec version to validate against. + + @retval EFI_SUCCESS All required tables are present. + @retval EFI_INVALID_PARAMETER Invalid SBBR version. + @retval EFI_NOT_FOUND One or more mandatory tables are missing. + @retval EFI_UNSUPPORTED Mandatory ACPI table does not have its + instance count tracked. +**/ +EFI_STATUS +EFIAPI +ArmSbbrReqsValidate ( + ARM_SBBR_VERSION Version + ); + +#endif // SBBR_VALIDATOR_H_ diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf index ea504c934aeebaa452a380e6ea169586e467642a..d21ecd40a8cf8f2d99613fde2ddb2a66702e6ad3 100644 --- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf +++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf @@ -1,7 +1,7 @@ ## @file # Provides Shell 'acpiview' command functions # -# Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.
+# Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
# # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -47,6 +47,10 @@ [Sources.common] Parsers/Madt/MadtParser.h Parsers/Pptt/PpttParser.h +[Sources.ARM, Sources.AARCH64] + Arm/SbbrValidator.h + Arm/SbbrValidator.c + [Packages] MdePkg/MdePkg.dec ShellPkg/ShellPkg.dec -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'