From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id 2FD54941E19 for ; Wed, 5 Feb 2025 22:09:51 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=/Dng2GAvLkhHZRXixZ8CLKolNmkhe92SpxAfk34wSx0=; c=relaxed/simple; d=groups.io; h=Received-SPF:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20240830; t=1738793390; v=1; x=1739052589; b=mFfxl/4Y25Vp6ci08fkljY9hZpQXFRCTherUdoHe4U21RD/I9N9JMzLHhMivDn0YCqlp5hSr TIlWEfTFj7bN7xVRi3l1t+X7pervop6gfif89cEA7JxCGEfHdd3EXdcf61cRb5RbSPc/IoBIzL3 0axKdPeHYsXcPqOhI6g5T4VFRnkU0WPbtM39rSxsDYgoAdCc1gsRcVNfAaToTfgoUk7eFalx++q y2sZy2H4HWFerzFbbBhj1YIQG5+uWFidznOaMpNwaYbYxn+slmWmVwaAXS2i7EiWBnGAp5bnXP4 FZyuQTQC3pP9mBSV34zQavREPO8c9MJs5f8Ja/PDNZyuw== X-Received: by 127.0.0.2 with SMTP id pL8qYY7687511xgn7yTy2rId; Wed, 05 Feb 2025 14:09:49 -0800 X-Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.107.93.79]) by mx.groups.io with SMTP id smtpd.web11.25788.1738793387138507978 for ; Wed, 05 Feb 2025 14:09:47 -0800 X-Received: from DM6PR03CA0060.namprd03.prod.outlook.com (2603:10b6:5:100::37) by SN7PR12MB8789.namprd12.prod.outlook.com (2603:10b6:806:34b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8398.24; Wed, 5 Feb 2025 22:09:40 +0000 X-Received: from DS3PEPF000099E2.namprd04.prod.outlook.com (2603:10b6:5:100:cafe::c8) by DM6PR03CA0060.outlook.office365.com (2603:10b6:5:100::37) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8398.27 via Frontend Transport; Wed, 5 Feb 2025 22:09:40 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C X-Received: from mail.nvidia.com (216.228.117.160) by DS3PEPF000099E2.mail.protection.outlook.com (10.167.17.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8398.14 via Frontend Transport; Wed, 5 Feb 2025 22:09:39 +0000 X-Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Wed, 5 Feb 2025 14:09:20 -0800 X-Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.14; Wed, 5 Feb 2025 14:09:20 -0800 X-Received: from NV-PF4WDED0.nvidia.com (10.127.8.14) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.1544.14 via Frontend Transport; Wed, 5 Feb 2025 14:09:19 -0800 From: "Girish Mahadevan via groups.io" To: , , , , , CC: , , , , Subject: [edk2-devel] [staging/dynamictables-reorg PATCH v0 08/12] DynamicTablesPkg: Split the ACPI and SMBIOS table generators Date: Wed, 5 Feb 2025 15:09:06 -0700 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-NVConfidentiality: public X-NV-OnPremToCloud: AnonymousSubmission X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS3PEPF000099E2:EE_|SN7PR12MB8789:EE_ X-MS-Office365-Filtering-Correlation-Id: 9f39b4a6-311c-466d-2703-08dd4631c951 X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?PHR/bbyW4XC3x+rsXG3dx0D8WT4nbGLsm8PjierXc+DAyUAjVddG/cYsdNR0?= =?us-ascii?Q?eEGmUA6+orC5B71jGZuEsroZzGgH7MTvxuHZAWXKvg2N4SQ3ir/Smu2GAzWW?= =?us-ascii?Q?e2h5jWmvXv4wA/NSAvKVvOW1R45OE1Sft2FuEcmE+cSoFQSXF0T0gV+qWJaU?= =?us-ascii?Q?NOnCFnpDTaFKSxNrUF6BeHrE8hC6U9u1lGtlmFQkv2JOqd/0NGDoe1iuc9os?= =?us-ascii?Q?gDw7CURDMMB8iDoVh3HTMx1FDZTjx9G6jJseUD2AgWUiReWnUfavEIZQdqgT?= =?us-ascii?Q?1B+0yMXl6RTydee79mdYbwUdhj+06MR8bWLWZtKQavU7pfoybqyFx3Yunyo9?= =?us-ascii?Q?zvLT3yDsV50vbF7xSVLP4jc4XHoN9FK4Uysw6rt+IO8LxGusGvsGcf/PKDEN?= =?us-ascii?Q?gUHteIzx/BIxTbnGVb9HlupoSGA5Z2XjJMZshCqyJVIri3K1zAHsiEDk8OpV?= =?us-ascii?Q?NA95tcDEBd8m1mbckQ0h6pqvpDynuAfi54P8bAklusjvgeRCBJ8t92lX/h/J?= =?us-ascii?Q?Mj0fU4DSAvumxuZogNh4g/41DxEunis/A6UqPv47wUrV48C8AN+N0D3/9ehz?= =?us-ascii?Q?2nCLwbHtB1cbNX+xoKGTX0PDrZmn4i5OZ4fj1X3MOBuTMnSLm57FTLeHzWx/?= =?us-ascii?Q?eaitWSjGNy248kyME6FvL1UGZ921rcP7ESArBvNLK7t77aC2hBt5eHcWNOx5?= =?us-ascii?Q?qXtA+mhVjo6KTsEE9TKpeyLvyRF8RAdf+J5zL12rEiwvX2G5lmjA4kZKuwhH?= =?us-ascii?Q?4nYeqNU5IeLkOPCOTlYBJT/8l5Tl4WGJUF6BZ0CeTtsME8TcRb1Zccev6Bmw?= =?us-ascii?Q?taDf1ODC6+9bpi9W5NNys7uZqrIn4RhW2A93+GyFPmusNcAPmxhDr9da/no9?= =?us-ascii?Q?0gdLCSTHoe7DL53F8NZMfET+2G+65NtA5bbPXbPt99U4jPMwzl5c/ZXn/c0k?= =?us-ascii?Q?2Hh/MV4VxxA3KPRv12i7AW2JsGFXVTBVzrjIt2C3AKyuN+++HqEEc+jQIupy?= =?us-ascii?Q?2GyhWeGgRl80k05JJoZnGLVj4wUOQKDR+rasPGYfEuzMEvWDvUXjQTLCuyWH?= =?us-ascii?Q?4j4kg9Tg8RUrFTTDWsYPMPQ103E/Ftqyd/JY0y1aFI8AmyZ405WuI0BAqSTo?= =?us-ascii?Q?QRSbjs+d1ozDyvA4JNPn8af0LTGIDAtrYPWcgXHL0MwPXkiMokV7q/aTAmjV?= =?us-ascii?Q?ZUnluOHwjW+UIE1puHATdU77/+NF7LxAtkzxdmDX/DyArOlajVxLNESEef8Y?= =?us-ascii?Q?NnMtw1JPkFVJlyngrVRWliKHqpWTx1cY0Jb7SA+aZDXkCB8bRHvKZkm62/ic?= =?us-ascii?Q?Fv9QNG/NhPrH5sWACfyMpvmoubM2uaoEnuMCEu88a2B2Y/WUOTl24krmuux+?= =?us-ascii?Q?lJRpHls/CJP4heYIueioHx/FaO6cT3L1HZ4vuF2givzPqESzOgbCrw0DnYlc?= =?us-ascii?Q?+q98gd/tCO7gt/rVQsqbRaje1okLVyeRmwsHVfjoWyRmudGB7ReJQWnrnEka?= =?us-ascii?Q?ojvdRw5zp/6ZkWo=3D?= X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Feb 2025 22:09:39.9952 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9f39b4a6-311c-466d-2703-08dd4631c951 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS3PEPF000099E2.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB8789 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Wed, 05 Feb 2025 14:09:47 -0800 Resent-From: gmahadevan@nvidia.com Reply-To: devel@edk2.groups.io,gmahadevan@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: U6oN1iCvdbXEbMdizrpoXTrLx7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240830 header.b="mFfxl/4Y"; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io Split the SMBIOS and ACPI table generators into their own files. Signed-off-by: Girish Mahadevan Reviewed-by: Jeff Brasen --- .../DynamicTableManagerDxe/AcpiTableBuilder.c | 762 ++++++++++ .../DynamicTableManagerDxe.c | 1325 +---------------- .../DynamicTableManagerDxe.inf | 2 + .../SmbiosTableBuilder.c | 605 ++++++++ 4 files changed, 1381 insertions(+), 1313 deletions(-) create mode 100644 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/AcpiTab= leBuilder.c create mode 100644 DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosT= ableBuilder.c diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/AcpiTableBuild= er.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/AcpiTableBuilder.c new file mode 100644 index 0000000000..40e17c3976 --- /dev/null +++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/AcpiTableBuilder.c @@ -0,0 +1,762 @@ +/** @file + Acpi Table Manager Dxe + + Copyright (c) 2017 - 2019, ARM Limited. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include + +// Module specific include files. +#include +#include +#include +#include +#include +#include +#include +#include "DynamicTableManagerDxe.h" + +STATIC ACPI_TABLE_PRESENCE_INFO *mAcpiVerifyTables; +STATIC UINT32 mAcpiVerifyTablesCount; +STATIC INT32 mAcpiVerifyTablesFadtIndex; + +/** This macro expands to a function that retrieves the ACPI Table + List from the Configuration Manager. +*/ +GET_OBJECT_LIST ( + EObjNameSpaceStandard, + EStdObjAcpiTableList, + CM_STD_OBJ_ACPI_TABLE_INFO + ) + +/** A helper function to build and install a single ACPI table. + + This is a helper function that invokes the Table generator interface + for building an ACPI table. It uses the AcpiTableProtocol to install the + table, then frees the resources allocated for generating it. + + @param [in] TableFactoryProtocol Pointer to the Table Factory Protocol + interface. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol Interface. + @param [in] Generator Pointer to the AcpiTable generator. + @param [in] AcpiTableProtocol Pointer to the AcpiTable protocol. + @param [in] AcpiTableInfo Pointer to the ACPI table Info. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND Required object is not found. + @retval EFI_BAD_BUFFER_SIZE Size returned by the Configuration Manager + is less than the Object size for the + requested object. +**/ +STATIC +EFI_STATUS +EFIAPI +BuildAndInstallSingleAcpiTable ( + IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryProto= col, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, + IN CONST ACPI_TABLE_GENERATOR *CONST Generator, + IN EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtoco= l, + IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInfo + ) +{ + EFI_STATUS Status; + EFI_STATUS Status1; + EFI_ACPI_DESCRIPTION_HEADER *AcpiTable; + UINTN TableHandle; + + AcpiTable =3D NULL; + Status =3D Generator->BuildAcpiTable ( + Generator, + AcpiTableInfo, + CfgMgrProtocol, + &AcpiTable + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to Build Table." \ + " TableGeneratorId =3D 0x%x. Status =3D %r\n", + AcpiTableInfo->TableGeneratorId, + Status + )); + // Free any allocated resources. + goto exit_handler; + } + + if (AcpiTable =3D=3D NULL) { + Status =3D EFI_NOT_FOUND; + goto exit_handler; + } + + // Dump ACPI Table Header + DUMP_ACPI_TABLE_HEADER (AcpiTable); + + // Install ACPI table + Status =3D AcpiTableProtocol->InstallAcpiTable ( + AcpiTableProtocol, + AcpiTable, + AcpiTable->Length, + &TableHandle + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to Install ACPI Table. Status =3D %r\n", + Status + )); + // Free any allocated resources. + goto exit_handler; + } + + DEBUG (( + DEBUG_INFO, + "INFO: ACPI Table installed. Status =3D %r\n", + Status + )); + +exit_handler: + // Free any resources allocated for generating the tables. + if (Generator->FreeTableResources !=3D NULL) { + Status1 =3D Generator->FreeTableResources ( + Generator, + AcpiTableInfo, + CfgMgrProtocol, + &AcpiTable + ); + if (EFI_ERROR (Status1)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to Free Table Resources." \ + "TableGeneratorId =3D 0x%x. Status =3D %r\n", + AcpiTableInfo->TableGeneratorId, + Status1 + )); + } + + // Return the first error status in case of failure + if (!EFI_ERROR (Status)) { + Status =3D Status1; + } + } + + return Status; +} + +/** A helper function to build and install multiple ACPI tables. + + This is a helper function that invokes the Table generator interface + for building an ACPI table. It uses the AcpiTableProtocol to install the + table, then frees the resources allocated for generating it. + + @param [in] TableFactoryProtocol Pointer to the Table Factory Protocol + interface. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol Interface. + @param [in] Generator Pointer to the AcpiTable generator. + @param [in] AcpiTableProtocol Pointer to the AcpiTable protocol. + @param [in] AcpiTableInfo Pointer to the ACPI table Info. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND Required object is not found. + @retval EFI_BAD_BUFFER_SIZE Size returned by the Configuration Manager + is less than the Object size for the + requested object. +**/ +STATIC +EFI_STATUS +EFIAPI +BuildAndInstallMultipleAcpiTable ( + IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryProto= col, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, + IN CONST ACPI_TABLE_GENERATOR *CONST Generator, + IN EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtoco= l, + IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInfo + ) +{ + EFI_STATUS Status; + EFI_STATUS Status1; + EFI_ACPI_DESCRIPTION_HEADER **AcpiTable; + UINTN TableCount; + UINTN TableHandle; + UINTN Index; + + AcpiTable =3D NULL; + TableCount =3D 0; + Status =3D Generator->BuildAcpiTableEx ( + Generator, + AcpiTableInfo, + CfgMgrProtocol, + &AcpiTable, + &TableCount + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to Build Table." \ + " TableGeneratorId =3D 0x%x. Status =3D %r\n", + AcpiTableInfo->TableGeneratorId, + Status + )); + // Free any allocated resources. + goto exit_handler; + } + + if ((AcpiTable =3D=3D NULL) || (TableCount =3D=3D 0)) { + Status =3D EFI_NOT_FOUND; + goto exit_handler; + } + + for (Index =3D 0; Index < TableCount; Index++) { + // Dump ACPI Table Header + DUMP_ACPI_TABLE_HEADER (AcpiTable[Index]); + // Install ACPI table + Status =3D AcpiTableProtocol->InstallAcpiTable ( + AcpiTableProtocol, + AcpiTable[Index], + AcpiTable[Index]->Length, + &TableHandle + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to Install ACPI Table. Status =3D %r\n", + Status + )); + // Free any allocated resources. + goto exit_handler; + } + + DEBUG (( + DEBUG_INFO, + "INFO: ACPI Table installed. Status =3D %r\n", + Status + )); + } + +exit_handler: + // Free any resources allocated for generating the tables. + if (Generator->FreeTableResourcesEx !=3D NULL) { + Status1 =3D Generator->FreeTableResourcesEx ( + Generator, + AcpiTableInfo, + CfgMgrProtocol, + &AcpiTable, + TableCount + ); + if (EFI_ERROR (Status1)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to Free Table Resources." \ + "TableGeneratorId =3D 0x%x. Status =3D %r\n", + AcpiTableInfo->TableGeneratorId, + Status1 + )); + } + + // Return the first error status in case of failure + if (!EFI_ERROR (Status)) { + Status =3D Status1; + } + } + + return Status; +} + +/** A helper function to invoke a Table generator + + This is a helper function that invokes the Table generator interface + for building an ACPI table. It uses the AcpiTableProtocol to install the + table, then frees the resources allocated for generating it. + + @param [in] TableFactoryProtocol Pointer to the Table Factory Protocol + interface. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol Interface. + @param [in] AcpiTableProtocol Pointer to the AcpiTable protocol. + @param [in] AcpiTableInfo Pointer to the ACPI table Info. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND Required object is not found. + @retval EFI_BAD_BUFFER_SIZE Size returned by the Configuration Manager + is less than the Object size for the + requested object. +**/ +STATIC +EFI_STATUS +EFIAPI +BuildAndInstallAcpiTable ( + IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryProto= col, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, + IN EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtoco= l, + IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInfo + ) +{ + EFI_STATUS Status; + CONST ACPI_TABLE_GENERATOR *Generator; + + ASSERT (TableFactoryProtocol !=3D NULL); + ASSERT (CfgMgrProtocol !=3D NULL); + ASSERT (AcpiTableProtocol !=3D NULL); + ASSERT (AcpiTableInfo !=3D NULL); + + DEBUG (( + DEBUG_INFO, + "INFO: EStdObjAcpiTableList: Address =3D 0x%p," \ + " TableGeneratorId =3D 0x%x\n", + AcpiTableInfo, + AcpiTableInfo->TableGeneratorId + )); + + Generator =3D NULL; + Status =3D TableFactoryProtocol->GetAcpiTableGenerator ( + TableFactoryProtocol, + AcpiTableInfo->TableGeneratorId, + &Generator + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Table Generator not found." \ + " TableGeneratorId =3D 0x%x. Status =3D %r\n", + AcpiTableInfo->TableGeneratorId, + Status + )); + return Status; + } + + if (Generator =3D=3D NULL) { + return EFI_NOT_FOUND; + } + + DEBUG (( + DEBUG_INFO, + "INFO: Generator found : %s\n", + Generator->Description + )); + + if (Generator->BuildAcpiTableEx !=3D NULL) { + Status =3D BuildAndInstallMultipleAcpiTable ( + TableFactoryProtocol, + CfgMgrProtocol, + Generator, + AcpiTableProtocol, + AcpiTableInfo + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to find build and install ACPI Table." \ + " Status =3D %r\n", + Status + )); + } + } else if (Generator->BuildAcpiTable !=3D NULL) { + Status =3D BuildAndInstallSingleAcpiTable ( + TableFactoryProtocol, + CfgMgrProtocol, + Generator, + AcpiTableProtocol, + AcpiTableInfo + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to find build and install ACPI Table." \ + " Status =3D %r\n", + Status + )); + } + } else { + Status =3D EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "ERROR: Table Generator does not implement the" \ + " ACPI_TABLE_GENERATOR_BUILD_TABLE interface." \ + " TableGeneratorId =3D 0x%x. Status =3D %r\n", + AcpiTableInfo->TableGeneratorId, + Status + )); + } + + return Status; +} + +/** The function checks if the Configuration Manager has provided the + mandatory ACPI tables for installation. + + @param [in] AcpiTableInfo Pointer to the ACPI Table Info list. + @param [in] AcpiTableCount Count of ACPI Table Info. + + @retval EFI_SUCCESS Success. + @retval EFI_NOT_FOUND If mandatory table is not found. + @retval EFI_ALREADY_STARTED If mandatory table found in AcpiTableInfo = is already installed. +**/ +STATIC +EFI_STATUS +EFIAPI +VerifyMandatoryTablesArePresent ( + IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInfo, + IN UINT32 AcpiTableCount + ) +{ + EFI_STATUS Status; + UINTN Handle; + UINTN Index; + UINTN InstalledTableIndex; + EFI_ACPI_DESCRIPTION_HEADER *DescHeader; + EFI_ACPI_TABLE_VERSION Version; + EFI_ACPI_SDT_PROTOCOL *AcpiSdt; + + ASSERT (AcpiTableInfo !=3D NULL); + + Status =3D EFI_SUCCESS; + + // Check against the statically initialized ACPI tables to see if they a= re in ACPI info list + while (AcpiTableCount-- !=3D 0) { + for (Index =3D 0; Index < mAcpiVerifyTablesCount; Index++) { + if (AcpiTableInfo[AcpiTableCount].AcpiTableSignature =3D=3D mAcpiVer= ifyTables[Index].AcpiTableSignature) { + mAcpiVerifyTables[Index].Presence |=3D ACPI_TABLE_PRESENT_INFO_LIS= T; + // Found this table, skip the rest. + break; + } + } + } + + // They also might be published already, so we can search from there + if (FeaturePcdGet (PcdInstallAcpiSdtProtocol)) { + AcpiSdt =3D NULL; + Status =3D gBS->LocateProtocol (&gEfiAcpiSdtProtocolGuid, NULL, (VOID= **)&AcpiSdt); + + if (EFI_ERROR (Status) || (AcpiSdt =3D=3D NULL)) { + DEBUG ((DEBUG_ERROR, "ERROR: Failed to locate ACPI SDT protocol (0x%= p) - %r\n", AcpiSdt, Status)); + return Status; + } + + for (Index =3D 0; Index < mAcpiVerifyTablesCount; Index++) { + Handle =3D 0; + InstalledTableIndex =3D 0; + do { + Status =3D AcpiSdt->GetAcpiTable (InstalledTableIndex, (EFI_ACPI_S= DT_HEADER **)&DescHeader, &Version, &Handle); + if (EFI_ERROR (Status)) { + break; + } + + InstalledTableIndex++; + } while (DescHeader->Signature !=3D mAcpiVerifyTables[Index].AcpiTab= leSignature); + + if (!EFI_ERROR (Status)) { + mAcpiVerifyTables[Index].Presence |=3D ACPI_TABLE_PRESENT_INSTALLE= D; + } + } + } + + // Reset the return Status value to EFI_SUCCESS. We do not fully care if= the table look up has failed. + Status =3D EFI_SUCCESS; + for (Index =3D 0; Index < mAcpiVerifyTablesCount; Index++) { + if (mAcpiVerifyTables[Index].Presence =3D=3D 0) { + if (mAcpiVerifyTables[Index].IsMandatory) { + DEBUG ((DEBUG_ERROR, "ERROR: %a Table not found.\n", mAcpiVerifyTa= bles[Index].AcpiTableName)); + Status =3D EFI_NOT_FOUND; + } else { + DEBUG ((DEBUG_WARN, "WARNING: %a Table not found.\n", mAcpiVerifyT= ables[Index].AcpiTableName)); + } + } else if (mAcpiVerifyTables[Index].Presence =3D=3D + (ACPI_TABLE_PRESENT_INFO_LIST | ACPI_TABLE_PRESENT_INSTALLE= D)) + { + DEBUG ((DEBUG_ERROR, "ERROR: %a Table found while already published.= \n", mAcpiVerifyTables[Index].AcpiTableName)); + Status =3D EFI_ALREADY_STARTED; + } + } + + return Status; +} + +/** Generate and install ACPI tables. + + The function gathers the information necessary for installing the + ACPI tables from the Configuration Manager, invokes the generators + and installs them (via BuildAndInstallAcpiTable). + + @param [in] TableFactoryProtocol Pointer to the Table Factory Protocol + interface. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol Interface. + + @retval EFI_SUCCESS Success. + @retval EFI_NOT_FOUND If a mandatory table or a generator is not= found. + @retval EFI_ALREADY_STARTED If mandatory table found in AcpiTableInfo = is already installed. +**/ +STATIC +EFI_STATUS +EFIAPI +ProcessAcpiTables ( + IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryProto= col, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol + ) +{ + EFI_STATUS Status; + EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtocol; + CM_STD_OBJ_ACPI_TABLE_INFO *AcpiTableInfo; + UINT32 AcpiTableCount; + UINT32 Idx; + + ASSERT (TableFactoryProtocol !=3D NULL); + ASSERT (CfgMgrProtocol !=3D NULL); + + // Find the AcpiTable protocol + Status =3D gBS->LocateProtocol ( + &gEfiAcpiTableProtocolGuid, + NULL, + (VOID **)&AcpiTableProtocol + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to find AcpiTable protocol. Status =3D %r\n", + Status + )); + return Status; + } + + Status =3D GetEStdObjAcpiTableList ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &AcpiTableInfo, + &AcpiTableCount + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to get ACPI Table List. Status =3D %r\n", + Status + )); + return Status; + } + + if (0 =3D=3D AcpiTableCount) { + DEBUG (( + DEBUG_ERROR, + "ERROR: EStdObjAcpiTableList: AcpiTableCount =3D %d\n", + AcpiTableCount + )); + return EFI_NOT_FOUND; + } + + DEBUG (( + DEBUG_INFO, + "INFO: EStdObjAcpiTableList: AcpiTableCount =3D %d\n", + AcpiTableCount + )); + + // Check if mandatory ACPI tables are present. + Status =3D VerifyMandatoryTablesArePresent ( + AcpiTableInfo, + AcpiTableCount + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to verify mandatory ACPI Table(s) presence." + " Status =3D %r\n", + Status + )); + return Status; + } + + // Add the FADT Table first. + if ((mAcpiVerifyTablesFadtIndex >=3D 0) && + ((mAcpiVerifyTables[mAcpiVerifyTablesFadtIndex].Presence & ACPI_TABL= E_PRESENT_INSTALLED) =3D=3D 0)) + { + // FADT is not yet installed + for (Idx =3D 0; Idx < AcpiTableCount; Idx++) { + if (CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdFadt) =3D=3D + AcpiTableInfo[Idx].TableGeneratorId) + { + Status =3D BuildAndInstallAcpiTable ( + TableFactoryProtocol, + CfgMgrProtocol, + AcpiTableProtocol, + &AcpiTableInfo[Idx] + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to find build and install ACPI FADT Table." \ + " Status =3D %r\n", + Status + )); + return Status; + } + + break; + } + } // for + } + + // Add remaining ACPI Tables + for (Idx =3D 0; Idx < AcpiTableCount; Idx++) { + DEBUG (( + DEBUG_INFO, + "INFO: AcpiTableInfo[%d].TableGeneratorId =3D 0x%x\n", + Idx, + AcpiTableInfo[Idx].TableGeneratorId + )); + + // Skip FADT Table since we have already added + if (CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdFadt) =3D=3D + AcpiTableInfo[Idx].TableGeneratorId) + { + continue; + } + + // Skip the Reserved table Generator ID for standard generators + if ((IS_GENERATOR_NAMESPACE_STD (AcpiTableInfo[Idx].TableGeneratorId))= && + ((CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdReserved) = >=3D + AcpiTableInfo[Idx].TableGeneratorId) |= | + (CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdMax) = <=3D + AcpiTableInfo[Idx].TableGeneratorId))) + { + DEBUG (( + DEBUG_WARN, + "WARNING: Invalid ACPI Generator table ID =3D 0x%x, Skipping...\n"= , + AcpiTableInfo[Idx].TableGeneratorId + )); + continue; + } + + Status =3D BuildAndInstallAcpiTable ( + TableFactoryProtocol, + CfgMgrProtocol, + AcpiTableProtocol, + &AcpiTableInfo[Idx] + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to find, build, and install ACPI Table." \ + " Status =3D %r\n", + Status + )); + return Status; + } + } // for + + return Status; +} + +/** Entrypoint of Dynamic Table Manager Dxe. + + The Dynamic Table Manager uses the Configuration Manager Protocol + to get the list of ACPI and SMBIOS tables to install. For each table + in the list it requests the corresponding ACPI/SMBIOS table factory for + a generator capable of building the ACPI/SMBIOS table. + If a suitable table generator is found, it invokes the generator interfa= ce + to build the table. The Dynamic Table Manager then installs the + table and invokes another generator interface to free any resources + allocated for building the table. + + @param ImageHandle + @param SystemTable + + @retval EFI_SUCCESS Success. + @retval EFI_OUT_OF_RESOURCES Memory allocation failed. + @retval EFI_NOT_FOUND Required interface/object was not found. + @retval EFI_INVALID_PARAMETER Some parameter is incorrect/invalid. +**/ +VOID +EFIAPI +AcpiTableProtocolReady ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + EDKII_CONFIGURATION_MANAGER_PROTOCOL *CfgMgrProtocol; + CM_STD_OBJ_CONFIGURATION_MANAGER_INFO *CfgMfrInfo; + EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *TableFactoryProtocol; + + // Locate the Dynamic Table Factory + Status =3D gBS->LocateProtocol ( + &gEdkiiDynamicTableFactoryProtocolGuid, + NULL, + (VOID **)&TableFactoryProtocol + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to find Dynamic Table Factory protocol." \ + " Status =3D %r\n", + Status + )); + return; + } + + // Locate the Configuration Manager for the Platform + Status =3D gBS->LocateProtocol ( + &gEdkiiConfigurationManagerProtocolGuid, + NULL, + (VOID **)&CfgMgrProtocol + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to find Configuration Manager protocol. Status =3D %r= \n", + Status + )); + return; + } + + Status =3D GetCgfMgrInfo (CfgMgrProtocol, &CfgMfrInfo); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to get Configuration Manager info. Status =3D %r\n", + Status + )); + return; + } + + DEBUG (( + DEBUG_INFO, + "INFO: Configuration Manager Version =3D 0x%x, OemID =3D %c%c%c%c%c%c\= n", + CfgMfrInfo->Revision, + CfgMfrInfo->OemId[0], + CfgMfrInfo->OemId[1], + CfgMfrInfo->OemId[2], + CfgMfrInfo->OemId[3], + CfgMfrInfo->OemId[4], + CfgMfrInfo->OemId[5] + )); + + Status =3D GetAcpiTablePresenceInfo ( + &mAcpiVerifyTables, + &mAcpiVerifyTablesCount, + &mAcpiVerifyTablesFadtIndex + ); + if (EFI_ERROR (Status)) { + ASSERT_EFI_ERROR (Status); + return; + } + + Status =3D ProcessAcpiTables (TableFactoryProtocol, CfgMgrProtocol); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: ACPI Table processing failure. Status =3D %r\n", + Status + )); + } +} diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableMa= nagerDxe.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableMa= nagerDxe.c index 3a88b9327b..c1de3f115c 100644 --- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDx= e.c +++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDx= e.c @@ -11,10 +11,6 @@ #include #include #include -#include -#include -#include -#include =20 // Module specific include files. #include @@ -24,1321 +20,25 @@ #include #include #include -#include -#include =20 -#include "DynamicTableManagerDxe.h" - -/// -/// We require the FADT, MADT, GTDT and the DSDT tables to boot. -/// This list also include optional ACPI tables: DBG2, SPCR. -/// -STATIC ACPI_TABLE_PRESENCE_INFO *mAcpiVerifyTables; -STATIC UINT32 mAcpiVerifyTablesCount; -STATIC INT32 mAcpiVerifyTablesFadtIndex; - -/** This macro expands to a function that retrieves the ACPI Table - List from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceStandard, - EStdObjAcpiTableList, - CM_STD_OBJ_ACPI_TABLE_INFO - ) - -/** This macro expands to a function that retrieves the SMBIOS Table - List from the Configuration Manager. -*/ -GET_OBJECT_LIST ( - EObjNameSpaceStandard, - EStdObjSmbiosTableList, - CM_STD_OBJ_SMBIOS_TABLE_INFO - ) - -STATIC VOID *AcpiTableProtocolRegistration; +STATIC VOID *AcpiTableProtocolRegistration; STATIC VOID *SmbiosProtocolRegistration; =20 -/** A helper function to build and install a single ACPI table. - - This is a helper function that invokes the Table generator interface - for building an ACPI table. It uses the AcpiTableProtocol to install the - table, then frees the resources allocated for generating it. - - @param [in] TableFactoryProtocol Pointer to the Table Factory Protocol - interface. - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - Protocol Interface. - @param [in] Generator Pointer to the AcpiTable generator. - @param [in] AcpiTableProtocol Pointer to the AcpiTable protocol. - @param [in] AcpiTableInfo Pointer to the ACPI table Info. - - @retval EFI_SUCCESS Success. - @retval EFI_INVALID_PARAMETER A parameter is invalid. - @retval EFI_NOT_FOUND Required object is not found. - @retval EFI_BAD_BUFFER_SIZE Size returned by the Configuration Manager - is less than the Object size for the - requested object. -**/ -STATIC -EFI_STATUS -EFIAPI -BuildAndInstallSingleAcpiTable ( - IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryProto= col, - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, - IN CONST ACPI_TABLE_GENERATOR *CONST Generator, - IN EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtoco= l, - IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInfo - ) -{ - EFI_STATUS Status; - EFI_STATUS Status1; - EFI_ACPI_DESCRIPTION_HEADER *AcpiTable; - UINTN TableHandle; - - AcpiTable =3D NULL; - Status =3D Generator->BuildAcpiTable ( - Generator, - AcpiTableInfo, - CfgMgrProtocol, - &AcpiTable - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to Build Table." \ - " TableGeneratorId =3D 0x%x. Status =3D %r\n", - AcpiTableInfo->TableGeneratorId, - Status - )); - // Free any allocated resources. - goto exit_handler; - } - - if (AcpiTable =3D=3D NULL) { - Status =3D EFI_NOT_FOUND; - goto exit_handler; - } - - // Dump ACPI Table Header - DUMP_ACPI_TABLE_HEADER (AcpiTable); - - // Install ACPI table - Status =3D AcpiTableProtocol->InstallAcpiTable ( - AcpiTableProtocol, - AcpiTable, - AcpiTable->Length, - &TableHandle - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to Install ACPI Table. Status =3D %r\n", - Status - )); - // Free any allocated resources. - goto exit_handler; - } - - DEBUG (( - DEBUG_INFO, - "INFO: ACPI Table installed. Status =3D %r\n", - Status - )); - -exit_handler: - // Free any resources allocated for generating the tables. - if (Generator->FreeTableResources !=3D NULL) { - Status1 =3D Generator->FreeTableResources ( - Generator, - AcpiTableInfo, - CfgMgrProtocol, - &AcpiTable - ); - if (EFI_ERROR (Status1)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to Free Table Resources." \ - "TableGeneratorId =3D 0x%x. Status =3D %r\n", - AcpiTableInfo->TableGeneratorId, - Status1 - )); - } - - // Return the first error status in case of failure - if (!EFI_ERROR (Status)) { - Status =3D Status1; - } - } - - return Status; -} - -/** A helper function to build and install multiple ACPI tables. - - This is a helper function that invokes the Table generator interface - for building an ACPI table. It uses the AcpiTableProtocol to install the - table, then frees the resources allocated for generating it. - - @param [in] TableFactoryProtocol Pointer to the Table Factory Protocol - interface. - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - Protocol Interface. - @param [in] Generator Pointer to the AcpiTable generator. - @param [in] AcpiTableProtocol Pointer to the AcpiTable protocol. - @param [in] AcpiTableInfo Pointer to the ACPI table Info. - - @retval EFI_SUCCESS Success. - @retval EFI_INVALID_PARAMETER A parameter is invalid. - @retval EFI_NOT_FOUND Required object is not found. - @retval EFI_BAD_BUFFER_SIZE Size returned by the Configuration Manager - is less than the Object size for the - requested object. -**/ -STATIC -EFI_STATUS -EFIAPI -BuildAndInstallMultipleAcpiTable ( - IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryProto= col, - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, - IN CONST ACPI_TABLE_GENERATOR *CONST Generator, - IN EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtoco= l, - IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInfo - ) -{ - EFI_STATUS Status; - EFI_STATUS Status1; - EFI_ACPI_DESCRIPTION_HEADER **AcpiTable; - UINTN TableCount; - UINTN TableHandle; - UINTN Index; - - AcpiTable =3D NULL; - TableCount =3D 0; - Status =3D Generator->BuildAcpiTableEx ( - Generator, - AcpiTableInfo, - CfgMgrProtocol, - &AcpiTable, - &TableCount - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to Build Table." \ - " TableGeneratorId =3D 0x%x. Status =3D %r\n", - AcpiTableInfo->TableGeneratorId, - Status - )); - // Free any allocated resources. - goto exit_handler; - } - - if ((AcpiTable =3D=3D NULL) || (TableCount =3D=3D 0)) { - Status =3D EFI_NOT_FOUND; - goto exit_handler; - } - - for (Index =3D 0; Index < TableCount; Index++) { - // Dump ACPI Table Header - DUMP_ACPI_TABLE_HEADER (AcpiTable[Index]); - // Install ACPI table - Status =3D AcpiTableProtocol->InstallAcpiTable ( - AcpiTableProtocol, - AcpiTable[Index], - AcpiTable[Index]->Length, - &TableHandle - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to Install ACPI Table. Status =3D %r\n", - Status - )); - // Free any allocated resources. - goto exit_handler; - } - - DEBUG (( - DEBUG_INFO, - "INFO: ACPI Table installed. Status =3D %r\n", - Status - )); - } - -exit_handler: - // Free any resources allocated for generating the tables. - if (Generator->FreeTableResourcesEx !=3D NULL) { - Status1 =3D Generator->FreeTableResourcesEx ( - Generator, - AcpiTableInfo, - CfgMgrProtocol, - &AcpiTable, - TableCount - ); - if (EFI_ERROR (Status1)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to Free Table Resources." \ - "TableGeneratorId =3D 0x%x. Status =3D %r\n", - AcpiTableInfo->TableGeneratorId, - Status1 - )); - } - - // Return the first error status in case of failure - if (!EFI_ERROR (Status)) { - Status =3D Status1; - } - } - - return Status; -} - -/** A helper function to invoke a Table generator - - This is a helper function that invokes the Table generator interface - for building an ACPI table. It uses the AcpiTableProtocol to install the - table, then frees the resources allocated for generating it. - - @param [in] TableFactoryProtocol Pointer to the Table Factory Protocol - interface. - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - Protocol Interface. - @param [in] AcpiTableProtocol Pointer to the AcpiTable protocol. - @param [in] AcpiTableInfo Pointer to the ACPI table Info. - - @retval EFI_SUCCESS Success. - @retval EFI_INVALID_PARAMETER A parameter is invalid. - @retval EFI_NOT_FOUND Required object is not found. - @retval EFI_BAD_BUFFER_SIZE Size returned by the Configuration Manager - is less than the Object size for the - requested object. -**/ -STATIC -EFI_STATUS -EFIAPI -BuildAndInstallAcpiTable ( - IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryProto= col, - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, - IN EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtoco= l, - IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInfo - ) -{ - EFI_STATUS Status; - CONST ACPI_TABLE_GENERATOR *Generator; - - ASSERT (TableFactoryProtocol !=3D NULL); - ASSERT (CfgMgrProtocol !=3D NULL); - ASSERT (AcpiTableProtocol !=3D NULL); - ASSERT (AcpiTableInfo !=3D NULL); - - DEBUG (( - DEBUG_INFO, - "INFO: EStdObjAcpiTableList: Address =3D 0x%p," \ - " TableGeneratorId =3D 0x%x\n", - AcpiTableInfo, - AcpiTableInfo->TableGeneratorId - )); - - Generator =3D NULL; - Status =3D TableFactoryProtocol->GetAcpiTableGenerator ( - TableFactoryProtocol, - AcpiTableInfo->TableGeneratorId, - &Generator - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Table Generator not found." \ - " TableGeneratorId =3D 0x%x. Status =3D %r\n", - AcpiTableInfo->TableGeneratorId, - Status - )); - return Status; - } - - if (Generator =3D=3D NULL) { - return EFI_NOT_FOUND; - } - - DEBUG (( - DEBUG_INFO, - "INFO: Generator found : %s\n", - Generator->Description - )); - - if (Generator->BuildAcpiTableEx !=3D NULL) { - Status =3D BuildAndInstallMultipleAcpiTable ( - TableFactoryProtocol, - CfgMgrProtocol, - Generator, - AcpiTableProtocol, - AcpiTableInfo - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to find build and install ACPI Table." \ - " Status =3D %r\n", - Status - )); - } - } else if (Generator->BuildAcpiTable !=3D NULL) { - Status =3D BuildAndInstallSingleAcpiTable ( - TableFactoryProtocol, - CfgMgrProtocol, - Generator, - AcpiTableProtocol, - AcpiTableInfo - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to find build and install ACPI Table." \ - " Status =3D %r\n", - Status - )); - } - } else { - Status =3D EFI_INVALID_PARAMETER; - DEBUG (( - DEBUG_ERROR, - "ERROR: Table Generator does not implement the" \ - " ACPI_TABLE_GENERATOR_BUILD_TABLE interface." \ - " TableGeneratorId =3D 0x%x. Status =3D %r\n", - AcpiTableInfo->TableGeneratorId, - Status - )); - } - - return Status; -} - -/** The function checks if the Configuration Manager has provided the - mandatory ACPI tables for installation. - - @param [in] AcpiTableInfo Pointer to the ACPI Table Info list. - @param [in] AcpiTableCount Count of ACPI Table Info. - - @retval EFI_SUCCESS Success. - @retval EFI_NOT_FOUND If mandatory table is not found. - @retval EFI_ALREADY_STARTED If mandatory table found in AcpiTableInfo = is already installed. -**/ -STATIC -EFI_STATUS -EFIAPI -VerifyMandatoryTablesArePresent ( - IN CONST CM_STD_OBJ_ACPI_TABLE_INFO *CONST AcpiTableInfo, - IN UINT32 AcpiTableCount - ) -{ - EFI_STATUS Status; - UINTN Handle; - UINTN Index; - UINTN InstalledTableIndex; - EFI_ACPI_DESCRIPTION_HEADER *DescHeader; - EFI_ACPI_TABLE_VERSION Version; - EFI_ACPI_SDT_PROTOCOL *AcpiSdt; - - ASSERT (AcpiTableInfo !=3D NULL); - - Status =3D EFI_SUCCESS; - - // Check against the statically initialized ACPI tables to see if they a= re in ACPI info list - while (AcpiTableCount-- !=3D 0) { - for (Index =3D 0; Index < mAcpiVerifyTablesCount; Index++) { - if (AcpiTableInfo[AcpiTableCount].AcpiTableSignature =3D=3D mAcpiVer= ifyTables[Index].AcpiTableSignature) { - mAcpiVerifyTables[Index].Presence |=3D ACPI_TABLE_PRESENT_INFO_LIS= T; - // Found this table, skip the rest. - break; - } - } - } - - // They also might be published already, so we can search from there - if (FeaturePcdGet (PcdInstallAcpiSdtProtocol)) { - AcpiSdt =3D NULL; - Status =3D gBS->LocateProtocol (&gEfiAcpiSdtProtocolGuid, NULL, (VOID= **)&AcpiSdt); - - if (EFI_ERROR (Status) || (AcpiSdt =3D=3D NULL)) { - DEBUG ((DEBUG_ERROR, "ERROR: Failed to locate ACPI SDT protocol (0x%= p) - %r\n", AcpiSdt, Status)); - return Status; - } - - for (Index =3D 0; Index < mAcpiVerifyTablesCount; Index++) { - Handle =3D 0; - InstalledTableIndex =3D 0; - do { - Status =3D AcpiSdt->GetAcpiTable (InstalledTableIndex, (EFI_ACPI_S= DT_HEADER **)&DescHeader, &Version, &Handle); - if (EFI_ERROR (Status)) { - break; - } - - InstalledTableIndex++; - } while (DescHeader->Signature !=3D mAcpiVerifyTables[Index].AcpiTab= leSignature); - - if (!EFI_ERROR (Status)) { - mAcpiVerifyTables[Index].Presence |=3D ACPI_TABLE_PRESENT_INSTALLE= D; - } - } - } - - // Reset the return Status value to EFI_SUCCESS. We do not fully care if= the table look up has failed. - Status =3D EFI_SUCCESS; - for (Index =3D 0; Index < mAcpiVerifyTablesCount; Index++) { - if (mAcpiVerifyTables[Index].Presence =3D=3D 0) { - if (mAcpiVerifyTables[Index].IsMandatory) { - DEBUG ((DEBUG_ERROR, "ERROR: %a Table not found.\n", mAcpiVerifyTa= bles[Index].AcpiTableName)); - Status =3D EFI_NOT_FOUND; - } else { - DEBUG ((DEBUG_WARN, "WARNING: %a Table not found.\n", mAcpiVerifyT= ables[Index].AcpiTableName)); - } - } else if (mAcpiVerifyTables[Index].Presence =3D=3D - (ACPI_TABLE_PRESENT_INFO_LIST | ACPI_TABLE_PRESENT_INSTALLE= D)) - { - DEBUG ((DEBUG_ERROR, "ERROR: %a Table found while already published.= \n", mAcpiVerifyTables[Index].AcpiTableName)); - Status =3D EFI_ALREADY_STARTED; - } - } - - return Status; -} - -/** A helper function to build and install an SMBIOS table. - - This is a helper function that invokes the Table generator interface - for building an SMBIOS table. It uses the SmbiosProtocol to install the - table, then frees the resources allocated for generating it. - - @param [in] TableFactoryProtocol Pointer to the Table Factory Protocol - interface. - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - Protocol Interface. - @param [in] SmbiosProtocol Pointer to the SMBIOS protocol. - @param [in] SmbiosTableInfo Pointer to the SMBIOS table Info. - - @retval EFI_SUCCESS Success. - @retval EFI_INVALID_PARAMETER A parameter is invalid. - @retval EFI_NOT_FOUND Required object is not found. - @retval EFI_BAD_BUFFER_SIZE Size returned by the Configuration Manager - is less than the Object size for the - requested object. -**/ -STATIC -EFI_STATUS -EFIAPI -BuildAndInstallSingleSmbiosTable ( - IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryProto= col, - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, - IN CONST SMBIOS_TABLE_GENERATOR *CONST Generator, - IN EFI_SMBIOS_PROTOCOL *SmbiosProtocol, - IN CM_STD_OBJ_SMBIOS_TABLE_INFO *CONST SmbiosTableInfo - ) -{ - EFI_STATUS Status; - EFI_STATUS Status1; - SMBIOS_STRUCTURE *SmbiosTable; - CM_OBJECT_TOKEN CmObjToken; - EFI_SMBIOS_HANDLE TableHandle; - - SmbiosTable =3D NULL; - Status =3D Generator->BuildSmbiosTable ( - Generator, - TableFactoryProtocol, - SmbiosTableInfo, - CfgMgrProtocol, - &SmbiosTable, - &CmObjToken - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to Build Table." \ - " TableGeneratorId =3D 0x%x. Status =3D %r\n", - SmbiosTableInfo->TableGeneratorId, - Status - )); - // Free any allocated resources. - goto exit_handler; - } - - if (SmbiosTable =3D=3D NULL) { - Status =3D EFI_NOT_FOUND; - goto exit_handler; - } - - TableHandle =3D SMBIOS_HANDLE_PI_RESERVED; - // Install SMBIOS table - Status =3D SmbiosProtocol->Add ( - SmbiosProtocol, - NULL, - &TableHandle, - SmbiosTable - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to Install SMBIOS Table. Status =3D %r\n", - Status - )); - // Free any allocated resources. - goto exit_handler; - } - - Status =3D TableFactoryProtocol->AddSmbiosHandle ( - SmbiosProtocol, - &TableHandle, - CmObjToken, - SmbiosTableInfo->TableGeneratorId - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to Add SMBIOS Handle. Status =3D %r\n", - Status - )); - // Free any allocated resources. - goto exit_handler; - } - - DEBUG (( - DEBUG_INFO, - "INFO: SMBIOS Table installed. Status =3D %r\n", - Status - )); - -exit_handler: - // Free any resources allocated for generating the tables. - if (Generator->FreeTableResources !=3D NULL) { - Status1 =3D Generator->FreeTableResources ( - Generator, - TableFactoryProtocol, - SmbiosTableInfo, - CfgMgrProtocol, - &SmbiosTable - ); - if (EFI_ERROR (Status1)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to Free Table Resources." \ - "TableGeneratorId =3D 0x%x. Status =3D %r\n", - SmbiosTableInfo->TableGeneratorId, - Status1 - )); - } - - // Return the first error status in case of failure - if (!EFI_ERROR (Status)) { - Status =3D Status1; - } - } - - return Status; -} - -/** A helper function to build and install multiple SMBIOS tables. - - This is a helper function that invokes the Table generator interface - for building SMBIOS tables. It uses the SmbiosProtocol to install the - tables, then frees the resources allocated for generating it. - - @param [in] TableFactoryProtocol Pointer to the Table Factory Protocol - interface. - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - Protocol Interface. - @param [in] Generator Pointer to the SmbiosTable generator. - @param [in] SmbiosProtocol Pointer to the Smbios protocol. - @param [in] AcpiTableInfo Pointer to the SMBIOS table Info. - - @retval EFI_SUCCESS Success. - @retval EFI_INVALID_PARAMETER A parameter is invalid. - @retval EFI_NOT_FOUND Required object is not found. - @retval EFI_BAD_BUFFER_SIZE Size returned by the Configuration Manager - is less than the Object size for the - requested object. -**/ -STATIC -EFI_STATUS -EFIAPI -BuildAndInstallMultipleSmbiosTables ( - IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryProto= col, - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, - IN CONST SMBIOS_TABLE_GENERATOR *CONST Generator, - IN EFI_SMBIOS_PROTOCOL *SmbiosProtocol, - IN CM_STD_OBJ_SMBIOS_TABLE_INFO *CONST SmbiosTableInfo - ) -{ - EFI_STATUS Status; - EFI_STATUS Status1; - SMBIOS_STRUCTURE **SmbiosTable; - CM_OBJECT_TOKEN *CmObjToken; - EFI_SMBIOS_HANDLE TableHandle; - UINTN TableCount; - UINTN Index; - - TableCount =3D 0; - Status =3D Generator->BuildSmbiosTableEx ( - Generator, - TableFactoryProtocol, - SmbiosTableInfo, - CfgMgrProtocol, - &SmbiosTable, - &CmObjToken, - &TableCount - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to Build Table." \ - " TableGeneratorId =3D 0x%x. Status =3D %r\n", - SmbiosTableInfo->TableGeneratorId, - Status - )); - // Free any allocated resources. - goto exit_handler; - } - - if ((SmbiosTable =3D=3D NULL) || (TableCount =3D=3D 0)) { - Status =3D EFI_NOT_FOUND; - DEBUG (( - DEBUG_ERROR, - "%a: TableCount %u SmbiosTable %p \n", - __FUNCTION__, - TableCount, - SmbiosTable - )); - goto exit_handler; - } - - for (Index =3D 0; Index < TableCount; Index++) { - TableHandle =3D SMBIOS_HANDLE_PI_RESERVED; - - // Install SMBIOS table - Status =3D SmbiosProtocol->Add ( - SmbiosProtocol, - NULL, - &TableHandle, - SmbiosTable[Index] - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to Install SMBIOS Table. Status =3D %r\n", - Status - )); - // Free any allocated resources. - goto exit_handler; - } - - Status =3D TableFactoryProtocol->AddSmbiosHandle ( - SmbiosProtocol, - &TableHandle, - CmObjToken[Index], - SmbiosTableInfo->TableGeneratorId - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to Add SMBIOS Handle. Status =3D %r\n", - Status - )); - // Free any allocated resources. - goto exit_handler; - } - - DEBUG (( - DEBUG_INFO, - "INFO: SMBIOS Table installed. Status =3D %r\n", - Status - )); - } - -exit_handler: - // Free any resources allocated for generating the tables. - if (Generator->FreeTableResourcesEx !=3D NULL) { - Status1 =3D Generator->FreeTableResourcesEx ( - Generator, - TableFactoryProtocol, - SmbiosTableInfo, - CfgMgrProtocol, - &SmbiosTable, - &CmObjToken, - TableCount - ); - if (EFI_ERROR (Status1)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to Free Table Resources." \ - "TableGeneratorId =3D 0x%x. Status =3D %r\n", - SmbiosTableInfo->TableGeneratorId, - Status1 - )); - } - - // Return the first error status in case of failure - if (!EFI_ERROR (Status)) { - Status =3D Status1; - } - } - - DEBUG ((DEBUG_ERROR, "%a: Returning %r\n", __FUNCTION__, Status)); - return Status; -} - -/** A helper function to invoke a Table generator - - This is a helper function that invokes the Table generator interface - for building an SMBIOS table. It uses the SmbiosProtocol to install the - table, then frees the resources allocated for generating it. - - @param [in] TableFactoryProtocol Pointer to the Table Factory Protocol - interface. - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - Protocol Interface. - @param [in] SmbiosProtocol Pointer to the SMBIOS protocol. - @param [in] SmbiosTableInfo Pointer to the SMBIOS table Info. - - @retval EFI_SUCCESS Success. - @retval EFI_INVALID_PARAMETER A parameter is invalid. - @retval EFI_NOT_FOUND Required object is not found. - @retval EFI_BAD_BUFFER_SIZE Size returned by the Configuration Manager - is less than the Object size for the - requested object. -**/ -EFI_STATUS -EFIAPI -BuildAndInstallSmbiosTable ( - IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryProto= col, - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, - IN EFI_SMBIOS_PROTOCOL *SmbiosProtocol, - IN CM_STD_OBJ_SMBIOS_TABLE_INFO *CONST SmbiosTableInfo - ) -{ - EFI_STATUS Status; - CONST SMBIOS_TABLE_GENERATOR *Generator; - - ASSERT (TableFactoryProtocol !=3D NULL); - ASSERT (CfgMgrProtocol !=3D NULL); - ASSERT (SmbiosProtocol !=3D NULL); - ASSERT (SmbiosTableInfo !=3D NULL); - - DEBUG (( - DEBUG_INFO, - "INFO: EStdObjSmbiosTableList: Address =3D 0x%p," \ - " TableGeneratorId =3D 0x%x\n", - SmbiosTableInfo, - SmbiosTableInfo->TableGeneratorId - )); - - Generator =3D NULL; - Status =3D TableFactoryProtocol->GetSmbiosTableGenerator ( - TableFactoryProtocol, - SmbiosTableInfo->TableGeneratorId, - &Generator - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Table Generator not found." \ - " TableGeneratorId =3D 0x%x. Status =3D %r\n", - SmbiosTableInfo->TableGeneratorId, - Status - )); - return Status; - } - - if (Generator =3D=3D NULL) { - return EFI_NOT_FOUND; - } - - DEBUG (( - DEBUG_INFO, - "INFO: Generator found : %s\n", - Generator->Description - )); - - if (Generator->BuildSmbiosTableEx !=3D NULL) { - Status =3D BuildAndInstallMultipleSmbiosTables ( - TableFactoryProtocol, - CfgMgrProtocol, - Generator, - SmbiosProtocol, - SmbiosTableInfo - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to find build and install SMBIOS Tables." \ - " Status =3D %r\n", - Status - )); - } - } else if (Generator->BuildSmbiosTable !=3D NULL) { - Status =3D BuildAndInstallSingleSmbiosTable ( - TableFactoryProtocol, - CfgMgrProtocol, - Generator, - SmbiosProtocol, - SmbiosTableInfo - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to find build and install SMBIOS Table." \ - " Status =3D %r\n", - Status - )); - } - } else { - Status =3D EFI_INVALID_PARAMETER; - DEBUG (( - DEBUG_ERROR, - "ERROR: Table Generator does not implement the" \ - "SMBIOS_TABLE_GENERATOR_BUILD_TABLE interface." \ - " TableGeneratorId =3D 0x%x. Status =3D %r\n", - SmbiosTableInfo->TableGeneratorId, - Status - )); - } - - DEBUG ((DEBUG_ERROR, "%a: Returning %r\n", __FUNCTION__, Status)); - return Status; -} - -/** Generate and install SMBIOS tables. - - The function gathers the information necessary for installing the - SMBIOS tables from the Configuration Manager, invokes the generators - and installs them (via BuildAndInstallAcpiTable). - - @param [in] TableFactoryProtocol Pointer to the Table Factory Protocol - interface. - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - Protocol Interface. - - @retval EFI_SUCCESS Success. - @retval EFI_NOT_FOUND If a mandatory table or a generator is not found. -**/ -STATIC -EFI_STATUS -EFIAPI -ProcessSmbiosTables ( - IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryProto= col, - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol - ) -{ - EFI_STATUS Status; - EFI_SMBIOS_PROTOCOL *SmbiosProtocol; - CM_STD_OBJ_SMBIOS_TABLE_INFO *SmbiosTableInfo; - UINT32 SmbiosTableCount; - - Status =3D gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)= &SmbiosProtocol); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "Could not locate SMBIOS protocol. %r\n", Status= )); - return Status; - } - - Status =3D GetEStdObjSmbiosTableList ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &SmbiosTableInfo, - &SmbiosTableCount - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to get SMBIOS Table List. Status =3D %r\n", - Status - )); - return Status; - } - - if (SmbiosTableCount =3D=3D 0) { - DEBUG (( - DEBUG_ERROR, - "ERROR: EStdObjSmbiosTableList: SmbiosTableCount =3D %d\n", - SmbiosTableCount - )); - return EFI_NOT_FOUND; - } - - DEBUG (( - DEBUG_INFO, - "INFO: EStdObjSmbiosTableList: SmbiosTableCount =3D %d\n", - SmbiosTableCount - )); - - InitSmbiosTableDispatcher (SmbiosTableInfo, SmbiosTableCount); - - Status =3D DispatchSmbiosTables ( - TableFactoryProtocol, - CfgMgrProtocol, - SmbiosProtocol, - SmbiosTableInfo, - SmbiosTableCount - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to install SMBIOS Tables.Status =3D %r\n", - Status - )); - } - - return Status; -} - -/** Generate and install ACPI tables. - - The function gathers the information necessary for installing the - ACPI tables from the Configuration Manager, invokes the generators - and installs them (via BuildAndInstallAcpiTable). - - @param [in] TableFactoryProtocol Pointer to the Table Factory Protocol - interface. - @param [in] CfgMgrProtocol Pointer to the Configuration Manager - Protocol Interface. - - @retval EFI_SUCCESS Success. - @retval EFI_NOT_FOUND If a mandatory table or a generator is not= found. - @retval EFI_ALREADY_STARTED If mandatory table found in AcpiTableInfo = is already installed. -**/ -STATIC -EFI_STATUS -EFIAPI -ProcessAcpiTables ( - IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryProto= col, - IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol - ) -{ - EFI_STATUS Status; - EFI_ACPI_TABLE_PROTOCOL *AcpiTableProtocol; - CM_STD_OBJ_ACPI_TABLE_INFO *AcpiTableInfo; - UINT32 AcpiTableCount; - UINT32 Idx; - - ASSERT (TableFactoryProtocol !=3D NULL); - ASSERT (CfgMgrProtocol !=3D NULL); - - // Find the AcpiTable protocol - Status =3D gBS->LocateProtocol ( - &gEfiAcpiTableProtocolGuid, - NULL, - (VOID **)&AcpiTableProtocol - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to find AcpiTable protocol. Status =3D %r\n", - Status - )); - return Status; - } - - Status =3D GetEStdObjAcpiTableList ( - CfgMgrProtocol, - CM_NULL_TOKEN, - &AcpiTableInfo, - &AcpiTableCount - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to get ACPI Table List. Status =3D %r\n", - Status - )); - return Status; - } - - if (0 =3D=3D AcpiTableCount) { - DEBUG (( - DEBUG_ERROR, - "ERROR: EStdObjAcpiTableList: AcpiTableCount =3D %d\n", - AcpiTableCount - )); - return EFI_NOT_FOUND; - } - - DEBUG (( - DEBUG_INFO, - "INFO: EStdObjAcpiTableList: AcpiTableCount =3D %d\n", - AcpiTableCount - )); - - // Check if mandatory ACPI tables are present. - Status =3D VerifyMandatoryTablesArePresent ( - AcpiTableInfo, - AcpiTableCount - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to verify mandatory ACPI Table(s) presence." - " Status =3D %r\n", - Status - )); - return Status; - } - - // Add the FADT Table first. - if ((mAcpiVerifyTablesFadtIndex >=3D 0) && - ((mAcpiVerifyTables[mAcpiVerifyTablesFadtIndex].Presence & ACPI_TABL= E_PRESENT_INSTALLED) =3D=3D 0)) - { - // FADT is not yet installed - for (Idx =3D 0; Idx < AcpiTableCount; Idx++) { - if (CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdFadt) =3D=3D - AcpiTableInfo[Idx].TableGeneratorId) - { - Status =3D BuildAndInstallAcpiTable ( - TableFactoryProtocol, - CfgMgrProtocol, - AcpiTableProtocol, - &AcpiTableInfo[Idx] - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to find build and install ACPI FADT Table." \ - " Status =3D %r\n", - Status - )); - return Status; - } - - break; - } - } // for - } - - // Add remaining ACPI Tables - for (Idx =3D 0; Idx < AcpiTableCount; Idx++) { - DEBUG (( - DEBUG_INFO, - "INFO: AcpiTableInfo[%d].TableGeneratorId =3D 0x%x\n", - Idx, - AcpiTableInfo[Idx].TableGeneratorId - )); - - // Skip FADT Table since we have already added - if (CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdFadt) =3D=3D - AcpiTableInfo[Idx].TableGeneratorId) - { - continue; - } - - // Skip the Reserved table Generator ID for standard generators - if ((IS_GENERATOR_NAMESPACE_STD (AcpiTableInfo[Idx].TableGeneratorId))= && - ((CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdReserved) = >=3D - AcpiTableInfo[Idx].TableGeneratorId) |= | - (CREATE_STD_ACPI_TABLE_GEN_ID (EStdAcpiTableIdMax) = <=3D - AcpiTableInfo[Idx].TableGeneratorId))) - { - DEBUG (( - DEBUG_WARN, - "WARNING: Invalid ACPI Generator table ID =3D 0x%x, Skipping...\n"= , - AcpiTableInfo[Idx].TableGeneratorId - )); - continue; - } - - Status =3D BuildAndInstallAcpiTable ( - TableFactoryProtocol, - CfgMgrProtocol, - AcpiTableProtocol, - &AcpiTableInfo[Idx] - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to find, build, and install ACPI Table." \ - " Status =3D %r\n", - Status - )); - return Status; - } - } // for - - return Status; -} - -/** Callback function for ACPI Protocol . - - Callback function for ACPI protocol that installs ACPI tables - - @param Event - @param Context - - @retval None -**/ -STATIC +extern VOID -AcpiTableProtocolReady ( +EFIAPI +SmbiosProtocolReady ( IN EFI_EVENT Event, IN VOID *Context - ) -{ - EFI_STATUS Status; - EDKII_CONFIGURATION_MANAGER_PROTOCOL *CfgMgrProtocol; - CM_STD_OBJ_CONFIGURATION_MANAGER_INFO *CfgMfrInfo; - EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *TableFactoryProtocol; - - // Locate the Dynamic Table Factory - Status =3D gBS->LocateProtocol ( - &gEdkiiDynamicTableFactoryProtocolGuid, - NULL, - (VOID **)&TableFactoryProtocol - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to find Dynamic Table Factory protocol." \ - " Status =3D %r\n", - Status - )); - return; - } - - // Locate the Configuration Manager for the Platform - Status =3D gBS->LocateProtocol ( - &gEdkiiConfigurationManagerProtocolGuid, - NULL, - (VOID **)&CfgMgrProtocol - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to find Configuration Manager protocol. Status =3D %r= \n", - Status - )); - return; - } - - Status =3D GetCgfMgrInfo (CfgMgrProtocol, &CfgMfrInfo); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to get Configuration Manager info. Status =3D %r\n", - Status - )); - return; - } - - DEBUG (( - DEBUG_INFO, - "INFO: Configuration Manager Version =3D 0x%x, OemID =3D %c%c%c%c%c%c\= n", - CfgMfrInfo->Revision, - CfgMfrInfo->OemId[0], - CfgMfrInfo->OemId[1], - CfgMfrInfo->OemId[2], - CfgMfrInfo->OemId[3], - CfgMfrInfo->OemId[4], - CfgMfrInfo->OemId[5] - )); + ); =20 - Status =3D GetAcpiTablePresenceInfo ( - &mAcpiVerifyTables, - &mAcpiVerifyTablesCount, - &mAcpiVerifyTablesFadtIndex - ); - if (EFI_ERROR (Status)) { - ASSERT_EFI_ERROR (Status); - return Status; - } - - Status =3D ProcessAcpiTables (TableFactoryProtocol, CfgMgrProtocol); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: ACPI Table processing failure. Status =3D %r\n", - Status - )); - } -} - -/** Callback function for SMBIOS Protocol . - - Callback function for SMBIOS protocol that installs SMBIOS tables - that use the DynamicTables Package. - - @param Event - @param Context - - @retval None -**/ -STATIC +extern VOID -SmbiosProtocolReady ( +EFIAPI +AcpiTableProtocolReady ( IN EFI_EVENT Event, IN VOID *Context - ) -{ - EFI_STATUS Status; - EDKII_CONFIGURATION_MANAGER_PROTOCOL *CfgMgrProtocol; - CM_STD_OBJ_CONFIGURATION_MANAGER_INFO *CfgMfrInfo; - EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *TableFactoryProtocol; - - // Locate the Dynamic Table Factory - Status =3D gBS->LocateProtocol ( - &gEdkiiDynamicTableFactoryProtocolGuid, - NULL, - (VOID **)&TableFactoryProtocol - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to find Dynamic Table Factory protocol." \ - " Status =3D %r\n", - Status - )); - return; - } - - // Locate the Configuration Manager for the Platform - Status =3D gBS->LocateProtocol ( - &gEdkiiConfigurationManagerProtocolGuid, - NULL, - (VOID **)&CfgMgrProtocol - ); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to find Configuration Manager protocol. Status =3D %r= \n", - Status - )); - return; - } - - Status =3D GetCgfMgrInfo (CfgMgrProtocol, &CfgMfrInfo); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: Failed to get Configuration Manager info. Status =3D %r\n", - Status - )); - return; - } - - DEBUG (( - DEBUG_INFO, - "INFO: Configuration Manager Version =3D 0x%x, OemID =3D %c%c%c%c%c%c\= n", - CfgMfrInfo->Revision, - CfgMfrInfo->OemId[0], - CfgMfrInfo->OemId[1], - CfgMfrInfo->OemId[2], - CfgMfrInfo->OemId[3], - CfgMfrInfo->OemId[4], - CfgMfrInfo->OemId[5] - )); - - Status =3D ProcessSmbiosTables (TableFactoryProtocol, CfgMgrProtocol); - if (EFI_ERROR (Status)) { - DEBUG (( - DEBUG_ERROR, - "ERROR: SMBIOS Table processing failure. Status =3D %r\n", - Status - )); - } -} + ); =20 /** Entrypoint of Dynamic Table Manager Dxe. =20 @@ -1366,9 +66,8 @@ DynamicTableManagerDxeInitialize ( IN EFI_SYSTEM_TABLE *SystemTable ) { - EFI_STATUS Status; - EFI_EVENT AcpiEvent; - EFI_EVENT SmbiosEvent; + EFI_EVENT AcpiEvent; + EFI_EVENT SmbiosEvent; =20 AcpiEvent =3D EfiCreateProtocolNotifyEvent ( &gEfiAcpiTableProtocolGuid, @@ -1395,5 +94,5 @@ DynamicTableManagerDxeInitialize ( return EFI_OUT_OF_RESOURCES; } =20 - return Status; + return EFI_SUCCESS; } diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableMa= nagerDxe.inf b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTable= ManagerDxe.inf index 2a6f1e7b55..5b96269df8 100644 --- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDx= e.inf +++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDx= e.inf @@ -25,6 +25,8 @@ DynamicTableManagerDxe.h SmbiosTableDispatcher.c SmbiosTableDispatcher.h + AcpiTableBuilder.c + SmbiosTableBuilder.c =20 [Sources.ARM, Sources.AARCH64] Arm/ArmDynamicTableManager.c diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableBui= lder.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableBuilder= .c new file mode 100644 index 0000000000..bf6e657bcf --- /dev/null +++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableBuilder.c @@ -0,0 +1,605 @@ +/** @file + Dynamic Table Manager Dxe + + Copyright (c) 2017 - 2019, ARM Limited. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include + +// Module specific include files. +#include +#include +#include +#include +#include +#include +#include +#include + +/** This macro expands to a function that retrieves the SMBIOS Table + List from the Configuration Manager. +*/ +GET_OBJECT_LIST ( + EObjNameSpaceStandard, + EStdObjSmbiosTableList, + CM_STD_OBJ_SMBIOS_TABLE_INFO + ) + +/** A helper function to build and install an SMBIOS table. + + This is a helper function that invokes the Table generator interface + for building an SMBIOS table. It uses the SmbiosProtocol to install the + table, then frees the resources allocated for generating it. + + @param [in] TableFactoryProtocol Pointer to the Table Factory Protocol + interface. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol Interface. + @param [in] SmbiosProtocol Pointer to the SMBIOS protocol. + @param [in] SmbiosTableInfo Pointer to the SMBIOS table Info. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND Required object is not found. + @retval EFI_BAD_BUFFER_SIZE Size returned by the Configuration Manager + is less than the Object size for the + requested object. +**/ +STATIC +EFI_STATUS +EFIAPI +BuildAndInstallSingleSmbiosTable ( + IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryProto= col, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, + IN CONST SMBIOS_TABLE_GENERATOR *CONST Generator, + IN EFI_SMBIOS_PROTOCOL *SmbiosProtocol, + IN CM_STD_OBJ_SMBIOS_TABLE_INFO *CONST SmbiosTableInfo + ) +{ + EFI_STATUS Status; + EFI_STATUS Status1; + SMBIOS_STRUCTURE *SmbiosTable; + CM_OBJECT_TOKEN CmObjToken; + EFI_SMBIOS_HANDLE TableHandle; + + SmbiosTable =3D NULL; + Status =3D Generator->BuildSmbiosTable ( + Generator, + TableFactoryProtocol, + SmbiosTableInfo, + CfgMgrProtocol, + &SmbiosTable, + &CmObjToken + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to Build Table." \ + " TableGeneratorId =3D 0x%x. Status =3D %r\n", + SmbiosTableInfo->TableGeneratorId, + Status + )); + // Free any allocated resources. + goto exit_handler; + } + + if (SmbiosTable =3D=3D NULL) { + Status =3D EFI_NOT_FOUND; + goto exit_handler; + } + + TableHandle =3D SMBIOS_HANDLE_PI_RESERVED; + + // Install SMBIOS table + Status =3D SmbiosProtocol->Add ( + SmbiosProtocol, + NULL, + &TableHandle, + SmbiosTable + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to Install SMBIOS Table. Status =3D %r\n", + Status + )); + // Free any allocated resources. + goto exit_handler; + } + + Status =3D TableFactoryProtocol->AddSmbiosHandle ( + SmbiosProtocol, + &TableHandle, + CmObjToken, + SmbiosTableInfo->TableGeneratorId + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to Add SMBIOS Handle. Status =3D %r\n", + Status + )); + // Free any allocated resources. + goto exit_handler; + } + + DEBUG (( + DEBUG_INFO, + "INFO: SMBIOS Table installed. Status =3D %r\n", + Status + )); + +exit_handler: + // Free any resources allocated for generating the tables. + if (Generator->FreeTableResources !=3D NULL) { + Status1 =3D Generator->FreeTableResources ( + Generator, + TableFactoryProtocol, + SmbiosTableInfo, + CfgMgrProtocol, + &SmbiosTable + ); + if (EFI_ERROR (Status1)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to Free Table Resources." \ + "TableGeneratorId =3D 0x%x. Status =3D %r\n", + SmbiosTableInfo->TableGeneratorId, + Status1 + )); + } + + // Return the first error status in case of failure + if (!EFI_ERROR (Status)) { + Status =3D Status1; + } + } + + return Status; +} + +/** A helper function to build and install multiple SMBIOS tables. + + This is a helper function that invokes the Table generator interface + for building SMBIOS tables. It uses the SmbiosProtocol to install the + tables, then frees the resources allocated for generating it. + + @param [in] TableFactoryProtocol Pointer to the Table Factory Protocol + interface. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol Interface. + @param [in] Generator Pointer to the SmbiosTable generator. + @param [in] SmbiosProtocol Pointer to the Smbios protocol. + @param [in] AcpiTableInfo Pointer to the SMBIOS table Info. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND Required object is not found. + @retval EFI_BAD_BUFFER_SIZE Size returned by the Configuration Manager + is less than the Object size for the + requested object. +**/ +STATIC +EFI_STATUS +EFIAPI +BuildAndInstallMultipleSmbiosTables ( + IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryProto= col, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, + IN CONST SMBIOS_TABLE_GENERATOR *CONST Generator, + IN EFI_SMBIOS_PROTOCOL *SmbiosProtocol, + IN CM_STD_OBJ_SMBIOS_TABLE_INFO *CONST SmbiosTableInfo + ) +{ + EFI_STATUS Status; + EFI_STATUS Status1; + SMBIOS_STRUCTURE **SmbiosTable; + CM_OBJECT_TOKEN *CmObjToken; + EFI_SMBIOS_HANDLE TableHandle; + UINTN TableCount; + UINTN Index; + + TableCount =3D 0; + Status =3D Generator->BuildSmbiosTableEx ( + Generator, + TableFactoryProtocol, + SmbiosTableInfo, + CfgMgrProtocol, + &SmbiosTable, + &CmObjToken, + &TableCount + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to Build Table." \ + " TableGeneratorId =3D 0x%x. Status =3D %r\n", + SmbiosTableInfo->TableGeneratorId, + Status + )); + // Free any allocated resources. + goto exit_handler; + } + + if ((SmbiosTable =3D=3D NULL) || (TableCount =3D=3D 0)) { + Status =3D EFI_NOT_FOUND; + DEBUG (( + DEBUG_ERROR, + "%a: TableCount %u SmbiosTable %p \n", + __FUNCTION__, + TableCount, + SmbiosTable + )); + goto exit_handler; + } + + for (Index =3D 0; Index < TableCount; Index++) { + TableHandle =3D SMBIOS_HANDLE_PI_RESERVED; + + // Install SMBIOS table + Status =3D SmbiosProtocol->Add ( + SmbiosProtocol, + NULL, + &TableHandle, + SmbiosTable[Index] + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to Install SMBIOS Table. Status =3D %r\n", + Status + )); + // Free any allocated resources. + goto exit_handler; + } + + Status =3D TableFactoryProtocol->AddSmbiosHandle ( + SmbiosProtocol, + &TableHandle, + CmObjToken[Index], + SmbiosTableInfo->TableGeneratorId + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to Add SMBIOS Handle. Status =3D %r\n", + Status + )); + // Free any allocated resources. + goto exit_handler; + } + + DEBUG (( + DEBUG_INFO, + "INFO: SMBIOS Table installed. Status =3D %r\n", + Status + )); + } + +exit_handler: + // Free any resources allocated for generating the tables. + if (Generator->FreeTableResourcesEx !=3D NULL) { + Status1 =3D Generator->FreeTableResourcesEx ( + Generator, + TableFactoryProtocol, + SmbiosTableInfo, + CfgMgrProtocol, + &SmbiosTable, + &CmObjToken, + TableCount + ); + if (EFI_ERROR (Status1)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to Free Table Resources." \ + "TableGeneratorId =3D 0x%x. Status =3D %r\n", + SmbiosTableInfo->TableGeneratorId, + Status1 + )); + } + + // Return the first error status in case of failure + if (!EFI_ERROR (Status)) { + Status =3D Status1; + } + } + + DEBUG ((DEBUG_ERROR, "%a: Returning %r\n", __FUNCTION__, Status)); + return Status; +} + +/** A helper function to invoke a Table generator + + This is a helper function that invokes the Table generator interface + for building an SMBIOS table. It uses the SmbiosProtocol to install the + table, then frees the resources allocated for generating it. + + @param [in] TableFactoryProtocol Pointer to the Table Factory Protocol + interface. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol Interface. + @param [in] SmbiosProtocol Pointer to the SMBIOS protocol. + @param [in] SmbiosTableInfo Pointer to the SMBIOS table Info. + + @retval EFI_SUCCESS Success. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND Required object is not found. + @retval EFI_BAD_BUFFER_SIZE Size returned by the Configuration Manager + is less than the Object size for the + requested object. +**/ +EFI_STATUS +EFIAPI +BuildAndInstallSmbiosTable ( + IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryProto= col, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, + IN EFI_SMBIOS_PROTOCOL *SmbiosProtocol, + IN CM_STD_OBJ_SMBIOS_TABLE_INFO *CONST SmbiosTableInfo + ) +{ + EFI_STATUS Status; + CONST SMBIOS_TABLE_GENERATOR *Generator; + + ASSERT (TableFactoryProtocol !=3D NULL); + ASSERT (CfgMgrProtocol !=3D NULL); + ASSERT (SmbiosProtocol !=3D NULL); + ASSERT (SmbiosTableInfo !=3D NULL); + + DEBUG (( + DEBUG_INFO, + "INFO: EStdObjSmbiosTableList: Address =3D 0x%p," \ + " TableGeneratorId =3D 0x%x\n", + SmbiosTableInfo, + SmbiosTableInfo->TableGeneratorId + )); + + Generator =3D NULL; + Status =3D TableFactoryProtocol->GetSmbiosTableGenerator ( + TableFactoryProtocol, + SmbiosTableInfo->TableGeneratorId, + &Generator + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Table Generator not found." \ + " TableGeneratorId =3D 0x%x. Status =3D %r\n", + SmbiosTableInfo->TableGeneratorId, + Status + )); + return Status; + } + + if (Generator =3D=3D NULL) { + return EFI_NOT_FOUND; + } + + DEBUG (( + DEBUG_INFO, + "INFO: Generator found : %s\n", + Generator->Description + )); + + if (Generator->BuildSmbiosTableEx !=3D NULL) { + Status =3D BuildAndInstallMultipleSmbiosTables ( + TableFactoryProtocol, + CfgMgrProtocol, + Generator, + SmbiosProtocol, + SmbiosTableInfo + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to find build and install SMBIOS Tables." \ + " Status =3D %r\n", + Status + )); + } + } else if (Generator->BuildSmbiosTable !=3D NULL) { + Status =3D BuildAndInstallSingleSmbiosTable ( + TableFactoryProtocol, + CfgMgrProtocol, + Generator, + SmbiosProtocol, + SmbiosTableInfo + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to find build and install SMBIOS Table." \ + " Status =3D %r\n", + Status + )); + } + } else { + Status =3D EFI_INVALID_PARAMETER; + DEBUG (( + DEBUG_ERROR, + "ERROR: Table Generator does not implement the" \ + "SMBIOS_TABLE_GENERATOR_BUILD_TABLE interface." \ + " TableGeneratorId =3D 0x%x. Status =3D %r\n", + SmbiosTableInfo->TableGeneratorId, + Status + )); + } + + DEBUG ((DEBUG_ERROR, "%a: Returning %r\n", __FUNCTION__, Status)); + return Status; +} + +/** Generate and install SMBIOS tables. + + The function gathers the information necessary for installing the + SMBIOS tables from the Configuration Manager, invokes the generators + and installs them (via BuildAndInstallAcpiTable). + + @param [in] TableFactoryProtocol Pointer to the Table Factory Protocol + interface. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol Interface. + + @retval EFI_SUCCESS Success. + @retval EFI_NOT_FOUND If a mandatory table or a generator is not found. +**/ +STATIC +EFI_STATUS +EFIAPI +ProcessSmbiosTables ( + IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryProto= col, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol + ) +{ + EFI_STATUS Status; + EFI_SMBIOS_PROTOCOL *SmbiosProtocol; + CM_STD_OBJ_SMBIOS_TABLE_INFO *SmbiosTableInfo; + UINT32 SmbiosTableCount; + + Status =3D gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)= &SmbiosProtocol); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Could not locate SMBIOS protocol. %r\n", Status= )); + return Status; + } + + Status =3D GetEStdObjSmbiosTableList ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &SmbiosTableInfo, + &SmbiosTableCount + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to get SMBIOS Table List. Status =3D %r\n", + Status + )); + return Status; + } + + if (SmbiosTableCount =3D=3D 0) { + DEBUG (( + DEBUG_ERROR, + "ERROR: EStdObjSmbiosTableList: SmbiosTableCount =3D %d\n", + SmbiosTableCount + )); + return EFI_NOT_FOUND; + } + + DEBUG (( + DEBUG_INFO, + "INFO: EStdObjSmbiosTableList: SmbiosTableCount =3D %d\n", + SmbiosTableCount + )); + + InitSmbiosTableDispatcher (SmbiosTableInfo, SmbiosTableCount); + + Status =3D DispatchSmbiosTables ( + TableFactoryProtocol, + CfgMgrProtocol, + SmbiosProtocol, + SmbiosTableInfo, + SmbiosTableCount + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to install SMBIOS Tables.Status =3D %r\n", + Status + )); + } + + DEBUG ((DEBUG_ERROR, "%a: Returning %r\n", __FUNCTION__, Status)); + return Status; +} + +/** Callback function for SMBIOS Protocol . + + Callback function for SMBIOS protocol that installs SMBIOS tables + that use the DynamicTables Package. + + @param Event + @param Context + + @retval None +**/ +VOID +EFIAPI +SmbiosProtocolReady ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + EFI_STATUS Status; + EDKII_CONFIGURATION_MANAGER_PROTOCOL *CfgMgrProtocol; + CM_STD_OBJ_CONFIGURATION_MANAGER_INFO *CfgMfrInfo; + EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *TableFactoryProtocol; + + // Locate the Dynamic Table Factory + Status =3D gBS->LocateProtocol ( + &gEdkiiDynamicTableFactoryProtocolGuid, + NULL, + (VOID **)&TableFactoryProtocol + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to find Dynamic Table Factory protocol." \ + " Status =3D %r\n", + Status + )); + return; + } + + // Locate the Configuration Manager for the Platform + Status =3D gBS->LocateProtocol ( + &gEdkiiConfigurationManagerProtocolGuid, + NULL, + (VOID **)&CfgMgrProtocol + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to find Configuration Manager protocol. Status =3D %r= \n", + Status + )); + return; + } + + Status =3D GetCgfMgrInfo (CfgMgrProtocol, &CfgMfrInfo); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: Failed to get Configuration Manager info. Status =3D %r\n", + Status + )); + return; + } + + DEBUG (( + DEBUG_INFO, + "INFO: Configuration Manager Version =3D 0x%x, OemID =3D %c%c%c%c%c%c\= n", + CfgMfrInfo->Revision, + CfgMfrInfo->OemId[0], + CfgMfrInfo->OemId[1], + CfgMfrInfo->OemId[2], + CfgMfrInfo->OemId[3], + CfgMfrInfo->OemId[4], + CfgMfrInfo->OemId[5] + )); + + Status =3D ProcessSmbiosTables (TableFactoryProtocol, CfgMgrProtocol); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "ERROR: SMBIOS Table processing failure. Status =3D %r\n", + Status + )); + } +} --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#121093): https://edk2.groups.io/g/devel/message/121093 Mute This Topic: https://groups.io/mt/111022012/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-