From nobody Sat May 18 07:48:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+107255+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1690328320675725.7547472109212; Tue, 25 Jul 2023 16:38:40 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=KTxhtpEM0aThdS7zzKLI/ELTk4uVzx+lCRTMoiqLcjU=; c=relaxed/simple; d=groups.io; h=X-Received:X-Received:ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:X-Received:X-Received:X-MS-Exchange-Authentication-Results:Received-SPF:X-Received:X-Received:X-Received:X-Received:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:X-NVConfidentiality:X-NV-OnPremToCloud:X-EOPAttributedMessage:X-MS-PublicTrafficType:X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id:X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay:X-Microsoft-Antispam-Message-Info:X-OriginatorOrg:X-MS-Exchange-CrossTenant-OriginalArrivalTime:X-MS-Exchange-CrossTenant-Network-Message-Id:X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp:X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs:X-MS-Exchange-CrossTenant-FromEntityHeader:X-MS-Exchange-Transport-CrossTenantHeadersStamped:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:X-Gm-Message-State:Content-Type:Content-Transfer-Encoding; s=20140610; t=1690328320; v=1; b=xcN8bV6cuJmHPqQCYslNhBLujKduyHAo7WqoZJypECTSs6Ao4lQ6LoUnnRGNugMFbUx5SfEo JRT1dIPpoWar2x6v9crZyIuceJqmI9fcnaoBgEXDVzsEZzgmjEZOTsbXc6Iggpth61AmqZNTCYW 6lLMJNLrIMtwMPWc1113Cmo0= X-Received: by 127.0.0.2 with SMTP id ixsiYY1788612xtbGuh7xCL5; Tue, 25 Jul 2023 16:38:40 -0700 X-Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.53]) by mx.groups.io with SMTP id smtpd.web11.105.1690328319033693234 for ; Tue, 25 Jul 2023 16:38:39 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CCohCnBk1mX6zMHSmenpDIWDGlxgxS8OoVCjkCjvYbxm+WrQHgVjnx1v/i9PFZEFUMiCcsQG2NZuHPZR73PvppKFIX08E8HXg/se7ROH+z8pklfUkgj/YmWzoSfZ8z+YNbvYRGooGRLUZaJmtnWSGLD2OCwGY3T0dswWFMnUYZjRItvda7i/apBqK9YHhvpAmPHXJUwdGL4Tg7P3gJWr50j8RfSI/h2pe6Bq67Ugtnw3gCmI9l2XwLUmlJTIqNziT4B0yUO9L+FEYa5U/+sa7iQZUOTWmvGf+PqXGhaSv3ZtuKqASuxgc+Vic1tkRpmucdLWL4fwkjGR0VrHGATp5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7OKRnISpiXFMRS2Mdk/DO1Ng/UX5WOQdWCc6ZnCmpM8=; b=KAVTYeC5MJOM3W3ev5MAyXFTyBcH6MsBPnbXkkJT2LyHEHvlZPOntlt3nrckiC/XfY4Ou1rz84ZK9g5YMGRcvtg0tdkayqB0HzglVx98VKhisPRrs8esCNCWJAkWG70fofbSVp8OXpO/wFNBYNTXUk03XPIGNKulESSDzhDCNDYoZqp4b+YuYmjYhIlnwUTf7lFF/x/ZZFEDQjz/J5RcFrNjTWapK4TBhpoUwHLudPBXO61iDlTOs7O6NG7VCd+EhL/WiOuXcQvJYOq7OBFEyVEfuuvNqFqkkWBkwy+ZXR1XfdDWMgFvw3eIcsWG1amXswsU2KEmwtAA+r0zf4+72Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none X-Received: from MW4PR04CA0350.namprd04.prod.outlook.com (2603:10b6:303:8a::25) by IA0PR12MB7673.namprd12.prod.outlook.com (2603:10b6:208:435::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.33; Tue, 25 Jul 2023 23:38:35 +0000 X-Received: from CO1NAM11FT111.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8a:cafe::71) by MW4PR04CA0350.outlook.office365.com (2603:10b6:303:8a::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.33 via Frontend Transport; Tue, 25 Jul 2023 23:38:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+107255+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C X-Received: from mail.nvidia.com (216.228.117.161) by CO1NAM11FT111.mail.protection.outlook.com (10.13.174.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.29 via Frontend Transport; Tue, 25 Jul 2023 23:38:35 +0000 X-Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 25 Jul 2023 16:38:22 -0700 X-Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 25 Jul 2023 16:38:22 -0700 X-Received: from build-gmahadevan-20230109T020417557.nvidia.com (10.127.8.12) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Tue, 25 Jul 2023 16:38:22 -0700 From: "Girish Mahadevan via groups.io" To: , CC: , , , , , Subject: [edk2-devel] [PATCH v3 1/5] DynamicTablesPkg: Add SMBIOS table generation Date: Tue, 25 Jul 2023 23:38:01 +0000 Message-ID: <20230725233805.646668-2-gmahadevan@nvidia.com> In-Reply-To: <20230725233805.646668-1-gmahadevan@nvidia.com> References: <20230725233805.646668-1-gmahadevan@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT111:EE_|IA0PR12MB7673:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e9eb5fe-9065-45f2-64ff-08db8d68438a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: Nm7tVifVVXgK1fC7Vg6HF92Z0RQGvQnm6/jpWkZRO+79Bzyn7MIzIXj1yjE12RO2sLdSlG8fZuCai32EwhUGHZvkp0Ma55W0T6+NqlPcDzDnCoIehvoiqUMgYb7JfHhKFdEOe9XBpMs5bHJSJ/UVose0pGCeH0Xt1uqUCe973C34EIggtzQpdM0cVRdODyPSDyP9lUS3pF6wqIdDGNTLHt6DBHcL5ZIXRbGf/Zq7a/XL0XhxFF8dC0qoojvO8lPQ4ZVQEe7ZiIwnIZi5hQOjLV19N5EyvKaiVRxBAX5KYnsaRQotokMhDKwkF+z4zA+7DDKUfGWUr7TxKVN/ZPxs/2IDWnN7dlI/ijOiq/8UFw23+VpOHy0oXCGohGfT3+qq2wioh2zR6BOnMW51Rw2Y8wLKI+GFJYqMO652LkuikgVpDPPlUE73xRpN/p7Z/jq/deMcBAYzKuMiiYGZhlo8nlxgC779Z+8z9ZdhM7rHv8wgZR/LJ2vRUeh4i/TH7uG1tR1uC7iNc9AEMjfzp6CHMMmlpkajSPaBaJp+1FnS2EPsEpfFda+7HKeufmYnF/g46/6blxfK7t+y9q5zdGKoei8Z5BAqvLxavbn+4AGRjXz6Scsz94yiksZk/GNOMdAHj1Zv9PjLoWFrG6+aSTSsZgXgNk4gYXQI+6Vzf9iJxpIc1qqMIWL8d6TuAVfDT/AOPOacG4bx1dnLZ7JvO68uvLKDsk+TB5q/UgwM/RSRRO2LykDL5JNx1Jctn3bSHNHQ X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2023 23:38:35.0753 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8e9eb5fe-9065-45f2-64ff-08db8d68438a 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.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT111.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA0PR12MB7673 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 Reply-To: devel@edk2.groups.io,gmahadevan@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: DanZtY4tc8RcBE9CY43BxCOxx1787277AA= Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1690328321452100004 Content-Type: text/plain; charset="utf-8" Add the SMBIOS Table generator code to the DynamicTablesPkg. This change includes adding new logic to the DynamicTableManager to process and add SMBIOS tables and augmenting the existing SMBIOS Factory generator to include installing multiple SMBIOS tables . Also included is running the SMBIOS and ACPI table generation as part of the SMBIOS and ACPI protocol GUID callback notifications respectively. Change-Id: Icc090108c16e87657260af6daf856f3d69b602e3 Signed-off-by: Girish Mahadevan Reviewed-by: Jeff Brasen reviewed-by: Jose Marinho --- .../DynamicTableFactory.h | 5 + .../DynamicTableFactoryDxe.c | 10 + .../SmbiosTableFactory/SmbiosTableFactory.c | 108 +++ .../DynamicTableManagerDxe.c | 677 +++++++++++++++++- .../DynamicTableManagerDxe.inf | 3 +- .../Protocol/DynamicTableFactoryProtocol.h | 10 + .../Include/SmbiosTableGenerator.h | 204 +++++- MdePkg/Include/IndustryStandard/SmBios.h | 8 + 8 files changed, 994 insertions(+), 31 deletions(-) diff --git a/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFa= ctory.h b/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFacto= ry.h index b160dcf8ad..20e438ea70 100644 --- a/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactory.h +++ b/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactory.h @@ -49,6 +49,11 @@ typedef struct DynamicTableFactoryInfo { CustomDtTableGeneratorList[FixedPcdGet16 ( PcdMaxCustomDTGenerators )]; + + /// An array for holding a map of SMBIOS handles and the CM Object + /// token used to build the SMBIOS record. + SMBIOS_HANDLE_MAP + SmbiosHandleMap[MAX_SMBIOS_HANDLES]; } EDKII_DYNAMIC_TABLE_FACTORY_INFO; =20 /** Return a pointer to the ACPI table generator. diff --git a/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFa= ctoryDxe.c b/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFa= ctoryDxe.c index 6d6d3fa746..577cdb576e 100644 --- a/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDx= e.c +++ b/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/DynamicTableFactoryDx= e.c @@ -1,6 +1,7 @@ /** @file Dynamic Table Factory Dxe =20 + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. Copyright (c) 2017 - 2019, ARM Limited. All rights reserved. =20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -44,6 +45,9 @@ EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL DynamicTableFactory= Protocol =3D { GetDtTableGenerator, RegisterDtTableGenerator, DeregisterDtTableGenerator, + AddSmbiosHandle, + FindSmbiosHandle, + FindSmbiosHandleEx, &TableFactoryInfo }; =20 @@ -65,6 +69,12 @@ DynamicTableFactoryDxeInitialize ( ) { EFI_STATUS Status; + UINTN Idx; + + for (Idx =3D 0; Idx < MAX_SMBIOS_HANDLES; Idx++) { + TableFactoryInfo.SmbiosHandleMap[Idx].SmbiosTblHandle =3D SMBIOS_HANDL= E_PI_RESERVED; + TableFactoryInfo.SmbiosHandleMap[Idx].SmbiosCmToken =3D 0; + } =20 Status =3D gBS->InstallProtocolInterface ( &ImageHandle, diff --git a/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/SmbiosTableFac= tory/SmbiosTableFactory.c b/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe= /SmbiosTableFactory/SmbiosTableFactory.c index 87795919f8..b928c28a14 100644 --- a/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/SmbiosTableFactory/Sm= biosTableFactory.c +++ b/DynamicTablesPkg/Drivers/DynamicTableFactoryDxe/SmbiosTableFactory/Sm= biosTableFactory.c @@ -1,6 +1,7 @@ /** @file SMBIOS Table Factory =20 + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. Copyright (c) 2017 - 2019, ARM Limited. All rights reserved. =20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -12,6 +13,7 @@ #include #include #include +#include #include =20 // Module specific include files. @@ -24,6 +26,71 @@ =20 extern EDKII_DYNAMIC_TABLE_FACTORY_INFO TableFactoryInfo; =20 +/** Add a new entry to the SMBIOS table Map. + + @param [in] Smbios SMBIOS Protocol pointer. + @param [in] SmbiosHandle SMBIOS Handle to be added, if the value SMBI= OS_HANDLE_PI_RESERVED + is passed then a new SmbiosHandle is assigne= d. + @param [in] CmObjectToken CmObjectToken of the CM_OBJECT used to build= the SMBIOS Table + @param [in] GeneratorId Smbios Table Generator Id. + + @retval EFI_SUCCESS Successfully added/generated the handl= e. + @retval EFI_OUT_OF_RESOURCESNULL Failure to add/generate the handle. +**/ +EFI_STATUS +EFIAPI +AddSmbiosHandle ( + IN EFI_SMBIOS_PROTOCOL *Smbios, + IN SMBIOS_HANDLE *SmbiosHandle, + IN CM_OBJECT_TOKEN CmObjectToken, + IN SMBIOS_TABLE_GENERATOR_ID GeneratorId + ) +{ + EFI_STATUS Status; + UINTN Index; + + Status =3D EFI_OUT_OF_RESOURCES; + + for (Index =3D 0; Index < MAX_SMBIOS_HANDLES; Index++) { + if (TableFactoryInfo.SmbiosHandleMap[Index].SmbiosTblHandle =3D=3D SMB= IOS_HANDLE_PI_RESERVED) { + TableFactoryInfo.SmbiosHandleMap[Index].SmbiosTblHandle =3D *Smbio= sHandle; + TableFactoryInfo.SmbiosHandleMap[Index].SmbiosCmToken =3D CmObje= ctToken; + TableFactoryInfo.SmbiosHandleMap[Index].SmbiosGeneratorId =3D Genera= torId; + Status =3D EFI_SU= CCESS; + break; + } + } + + return Status; +} + +/** Return a pointer to the SMBIOS table Map. + + @param [in] GeneratorId The CmObjectToken to look up an SMBIOS Handle. + + @retval SMBIOS_HANDLE_MAP if the CmObjectToken is found. + @retval NULL if not found. +**/ +SMBIOS_HANDLE_MAP * +EFIAPI +FindSmbiosHandle ( + CM_OBJECT_TOKEN CmObjectToken + ) +{ + UINTN Index; + SMBIOS_HANDLE_MAP *SmbiosHandleMap; + + SmbiosHandleMap =3D NULL; + for (Index =3D 0; Index < MAX_SMBIOS_HANDLES; Index++) { + if (TableFactoryInfo.SmbiosHandleMap[Index].SmbiosCmToken =3D=3D CmObj= ectToken) { + SmbiosHandleMap =3D &TableFactoryInfo.SmbiosHandleMap[Index]; + break; + } + } + + return SmbiosHandleMap; +} + /** Return a pointer to the SMBIOS table generator. =20 @param [in] This Pointer to the Dynamic Table Factory Protocol. @@ -229,3 +296,44 @@ DeregisterSmbiosTableGenerator ( DEBUG ((DEBUG_INFO, "Deregistering %s\n", Generator->Description)); return EFI_SUCCESS; } + +/** Find and return SMBIOS handle based on associated CM object token. + + @param [in] GeneratorId SMBIOS generator ID used to build the SMBIO= S Table. + @param [in] CmObjectToken Token of the CM_OBJECT used to build the SM= BIOS Table. + + @return SMBIOS handle of the table associated with SmbiosGeneratorId and + CmObjectToken if found. Otherwise, returns 0xFFFF. +**/ +UINT16 +EFIAPI +FindSmbiosHandleEx ( + IN SMBIOS_TABLE_GENERATOR_ID GeneratorId, + IN CM_OBJECT_TOKEN CmObjToken + ) +{ + SMBIOS_HANDLE_MAP *HandleMap; + + if (CmObjToken =3D=3D CM_NULL_TOKEN) { + return SMBIOS_HANDLE_INVALID; + } + + HandleMap =3D FindSmbiosHandle (CmObjToken); + if (HandleMap =3D=3D NULL) { + return SMBIOS_HANDLE_INVALID; + } + + if (HandleMap->SmbiosGeneratorId !=3D GeneratorId) { + DEBUG (( + DEBUG_ERROR, + "%a: Expect ID %d but get %d\n", + __FUNCTION__, + GeneratorId, + HandleMap->SmbiosGeneratorId + )); + ASSERT (FALSE); + return SMBIOS_HANDLE_INVALID; + } + + return HandleMap->SmbiosTblHandle; +} diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableMa= nagerDxe.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableMa= nagerDxe.c index 1e9b811c40..26aa9b55cf 100644 --- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDx= e.c +++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDx= e.c @@ -8,10 +8,13 @@ **/ =20 #include +#include #include #include #include #include +#include +#include =20 // Module specific include files. #include @@ -22,6 +25,7 @@ #include #include #include +#include =20 /// /// Bit definitions for acceptable ACPI table presence formats. @@ -84,6 +88,18 @@ GET_OBJECT_LIST ( CM_STD_OBJ_ACPI_TABLE_INFO ) =20 +/** 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 *SmbiosProtocolRegistration; + /** A helper function to build and install a single ACPI table. =20 This is a helper function that invokes the Table generator interface @@ -530,6 +546,490 @@ VerifyMandatoryTablesArePresent ( return Status; } =20 +/** 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. =20 The function gathers the information necessary for installing the @@ -701,30 +1201,20 @@ ProcessAcpiTables ( return Status; } =20 -/** Entrypoint of Dynamic Table Manager Dxe. +/** Callback function for ACPI Protocol . =20 - 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. + Callback function for ACPI protocol that installs ACPI tables =20 - @param ImageHandle - @param SystemTable + @param Event + @param Context =20 - @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. + @retval None **/ -EFI_STATUS -EFIAPI -DynamicTableManagerDxeInitialize ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable +STATIC +VOID +AcpiTableProtocolReady ( + IN EFI_EVENT Event, + IN VOID *Context ) { EFI_STATUS Status; @@ -745,7 +1235,7 @@ DynamicTableManagerDxeInitialize ( " Status =3D %r\n", Status )); - return Status; + return; } =20 // Locate the Configuration Manager for the Platform @@ -760,7 +1250,7 @@ DynamicTableManagerDxeInitialize ( "ERROR: Failed to find Configuration Manager protocol. Status =3D %r= \n", Status )); - return Status; + return; } =20 Status =3D GetCgfMgrInfo (CfgMgrProtocol, &CfgMfrInfo); @@ -770,7 +1260,7 @@ DynamicTableManagerDxeInitialize ( "ERROR: Failed to get Configuration Manager info. Status =3D %r\n", Status )); - return Status; + return; } =20 DEBUG (( @@ -793,6 +1283,147 @@ DynamicTableManagerDxeInitialize ( 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 +VOID +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 + )); + } +} + +/** 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. +**/ +EFI_STATUS +EFIAPI +DynamicTableManagerDxeInitialize ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_EVENT AcpiEvent; + EFI_EVENT SmbiosEvent; + + AcpiEvent =3D EfiCreateProtocolNotifyEvent ( + &gEfiAcpiTableProtocolGuid, + TPL_CALLBACK, + AcpiTableProtocolReady, + NULL, + &AcpiTableProtocolRegistration + ); + if (AcpiEvent =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: Failed to ACPI create protocol event\r\n", _= _FUNCTION__)); + return EFI_OUT_OF_RESOURCES; + } + + SmbiosEvent =3D EfiCreateProtocolNotifyEvent ( + &gEfiSmbiosProtocolGuid, + TPL_CALLBACK, + SmbiosProtocolReady, + NULL, + &SmbiosProtocolRegistration + ); + if (SmbiosEvent =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a: Failed to SMBIOS create protocol event\r\n",= __FUNCTION__)); + gBS->CloseEvent (AcpiEvent); + return EFI_OUT_OF_RESOURCES; + } =20 return Status; } diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableMa= nagerDxe.inf b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTable= ManagerDxe.inf index b09272d883..3beab7420a 100644 --- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDx= e.inf +++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDx= e.inf @@ -33,6 +33,7 @@ [LibraryClasses] PrintLib TableHelperLib + UefiLib UefiBootServicesTableLib UefiDriverEntryPoint =20 @@ -42,12 +43,12 @@ [Protocols] gEfiAcpiTableProtocolGuid # PROTOCOL ALWAYS_CONSUMED gEfiAcpiSdtProtocolGuid # PROTOCOL ALWAYS_CONSUMED + gEfiSmbiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED =20 gEdkiiConfigurationManagerProtocolGuid # PROTOCOL ALWAYS_CONSUMED gEdkiiDynamicTableFactoryProtocolGuid # PROTOCOL ALWAYS_CONSUMED =20 [Depex] - gEfiAcpiTableProtocolGuid AND gEdkiiConfigurationManagerProtocolGuid AND gEdkiiDynamicTableFactoryProtocolGuid =20 diff --git a/DynamicTablesPkg/Include/Protocol/DynamicTableFactoryProtocol.= h b/DynamicTablesPkg/Include/Protocol/DynamicTableFactoryProtocol.h index b11fc0c9f1..e298236311 100644 --- a/DynamicTablesPkg/Include/Protocol/DynamicTableFactoryProtocol.h +++ b/DynamicTablesPkg/Include/Protocol/DynamicTableFactoryProtocol.h @@ -1,5 +1,6 @@ /** @file =20 + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. Copyright (c) 2017 - 2019, ARM Limited. All rights reserved. =20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -239,6 +240,15 @@ typedef struct DynamicTableFactoryProtocol { EDKII_DYNAMIC_TABLE_FACTORY_DEREGISTER_DT_TABLE_GENERATOR DeregisterDtTa= bleGenerator; =20 + EDKII_DYNAMIC_TABLE_FACTORY_SMBIOS_TABLE_ADD_HANDLE + AddSmbiosHandl= e; + + EDKII_DYNAMIC_TABLE_FACTORY_SMBIOS_TABLE_GET_HANDLE + GetSmbiosHandl= e; + + EDKII_DYNAMIC_TABLE_FACTORY_SMBIOS_TABLE_GET_HANDLE_EX + GetSmbiosHandl= eEx; + /** Pointer to the data structure that holds the list of registered table generators */ diff --git a/DynamicTablesPkg/Include/SmbiosTableGenerator.h b/DynamicTable= sPkg/Include/SmbiosTableGenerator.h index 934d56c90d..a9f8199a3b 100644 --- a/DynamicTablesPkg/Include/SmbiosTableGenerator.h +++ b/DynamicTablesPkg/Include/SmbiosTableGenerator.h @@ -1,5 +1,6 @@ /** @file =20 + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. Copyright (c) 2017 - 2019, ARM Limited. All rights reserved. =20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -10,7 +11,7 @@ #define SMBIOS_TABLE_GENERATOR_H_ =20 #include - +#include #include =20 #pragma pack(1) @@ -121,12 +122,21 @@ typedef enum StdSmbiosTableGeneratorId { ETableGeneratorNameSpaceStd, \ TableId \ ) +#define MAX_SMBIOS_HANDLES (255) =20 /** Forward declarations. */ typedef struct ConfigurationManagerProtocol EDKII_CONFIGURATION_MANAGER_PR= OTOCOL; typedef struct CmStdObjSmbiosTableInfo CM_STD_OBJ_SMBIOS_TABLE_INFO; typedef struct SmbiosTableGenerator SMBIOS_TABLE_GENERATOR; +typedef struct DynamicTableFactoryProtocol EDKII_DYNAMIC_TABLE_FACTORY_PR= OTOCOL; +typedef UINTN CM_OBJECT_TOKEN; + +typedef struct SmbiosHandleCmObjMap { + SMBIOS_TABLE_GENERATOR_ID SmbiosGeneratorId; + SMBIOS_HANDLE SmbiosTblHandle; + CM_OBJECT_TOKEN SmbiosCmToken; +} SMBIOS_HANDLE_MAP; =20 /** This function pointer describes the interface to SMBIOS table build functions provided by the SMBIOS table generator and called by the @@ -143,9 +153,11 @@ typedef struct SmbiosTableGenerator SMBIOS_TAB= LE_GENERATOR; **/ typedef EFI_STATUS (*SMBIOS_TABLE_GENERATOR_BUILD_TABLE) ( IN CONST SMBIOS_TABLE_GENERATOR *Generator, + IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryProt= ocol, IN CM_STD_OBJ_SMBIOS_TABLE_INFO *CONST SmbiosTableInfo, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, - OUT SMBIOS_STRUCTURE **Table + OUT SMBIOS_STRUCTURE **Table, + OUT CM_OBJECT_TOKEN *CmObjToken ); =20 /** This function pointer describes the interface to used by the @@ -163,32 +175,147 @@ typedef EFI_STATUS (*SMBIOS_TABLE_GENERATOR_BUILD_TA= BLE) ( **/ typedef EFI_STATUS (*SMBIOS_TABLE_GENERATOR_FREE_TABLE) ( IN CONST SMBIOS_TABLE_GENERATOR *Generator, + IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryProt= ocol, IN CONST CM_STD_OBJ_SMBIOS_TABLE_INFO *CONST SmbiosTableInfo, IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, IN SMBIOS_STRUCTURE **Table ); =20 +/** This function pointer describes the interface to SMBIOS table build + functions provided by the SMBIOS table generator and called by the + Table Manager to build an SMBIOS table. + + @param [in] Generator Pointer to the SMBIOS table generator. + @param [in] SmbiosTableInfo Pointer to the SMBIOS table information. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol interface. + @param [out] Table Pointer to the generated SMBIOS table. + + @return EFI_SUCCESS If the table is generated successfully or other + failure codes as returned by the generator. +**/ +typedef EFI_STATUS (*SMBIOS_TABLE_GENERATOR_BUILD_TABLEEX) ( + IN CONST SMBIOS_TABLE_GENERATOR *Generator, + IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryPro= tocol, + IN CM_STD_OBJ_SMBIOS_TABLE_INFO *CONST SmbiosTableInfo, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, + OUT SMBIOS_STRUCTURE ***Table, + OUT CM_OBJECT_TOKEN **CmObjectToken, + OUT UINTN *CONST TableCount + ); + +/** This function pointer describes the interface to used by the + Table Manager to give the generator an opportunity to free + any resources allocated for building the SMBIOS table. + + @param [in] Generator Pointer to the SMBIOS table generator. + @param [in] SmbiosTableInfo Pointer to the SMBIOS table information. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol interface. + @param [in] Table Pointer to the generated SMBIOS table. + + @return EFI_SUCCESS If freed successfully or other failure codes + as returned by the generator. +**/ +typedef EFI_STATUS (*SMBIOS_TABLE_GENERATOR_FREE_TABLEEX) ( + IN CONST SMBIOS_TABLE_GENERATOR *Generator, + IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryProt= ocol, + IN CONST CM_STD_OBJ_SMBIOS_TABLE_INFO *CONST SmbiosTableInfo, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, + IN SMBIOS_STRUCTURE ***Table, + IN CM_OBJECT_TOKEN **CmObjectToken, + IN CONST UINTN TableCount + ); + +/** This function pointer describes the interface to used by the + Table Manager to give the generator an opportunity to add + an SMBIOS Handle. + + This function is called by the Dynamic Table Manager to add a newly added + SMBIOS Table OR it can be called by an SMBIOS Table generator to create + and add a new SMBIOS Handle if there is a reference to another table and + if there is a generator for that table that hasn't been called yet. + + @param [in] Smbios Pointer to the SMBIOS protocol. + @param [in] SmbiosHandle Pointer to an SMBIOS handle (either generate= d by + SmbiosDxe Driver or SMBIOS_HANDLE_PI_RESERV= ED + if a handle needs to be generated). + @param [in] CmObjectToken The CM Object token for that is used to gene= rate + SMBIOS record. + @param [in] GeneratorId The SMBIOS table generator Id. + + @retval EFI_SUCCESS Success. + @retval EFI_OUT_OF_RESOURCES Unable to add the handle. + @retval EFI_NOT_FOUND The requested generator is not found + in the list of registered generators. +**/ +typedef EFI_STATUS (EFIAPI *EDKII_DYNAMIC_TABLE_FACTORY_SMBIOS_TABLE_ADD_H= ANDLE)( + IN EFI_SMBIOS_PROTOCOL *Smbios, + IN SMBIOS_HANDLE *SmbiosHandle, + IN CM_OBJECT_TOKEN CmObjectToken, + IN SMBIOS_TABLE_GENERATOR_ID GeneratorId + ); + +/** This function pointer describes the interface to used by the + Table Manager to give the generator an opportunity to find + an SMBIOS Handle. + + This function is called by the SMBIOS table generator to find an SMBIOS + handle needed as part of generating an SMBIOS Table. + + @param [in] CmObjectToken The CM Object token used to generate the S= MBIOS + record. + + @retval EFI_SUCCESS Success. + @retval EFI_NOT_FOUND The requested generator is not found + in the list of registered generators. +**/ +typedef SMBIOS_HANDLE_MAP *(EFIAPI *EDKII_DYNAMIC_TABLE_FACTORY_SMBIOS_TAB= LE_GET_HANDLE)( + IN CM_OBJECT_TOKEN CmObjectToken + ); + +/** Find and return SMBIOS handle based on associated CM object token. + + @param [in] GeneratorId SMBIOS generator ID used to build the SMBIO= S Table. + @param [in] CmObjectToken Token of the CM_OBJECT used to build the SM= BIOS Table. + + @return SMBIOS handle of the table associated with SmbiosTableId and + CmObjectToken if found. Otherwise, returns 0xFFFF. +**/ +typedef UINT16 (EFIAPI *EDKII_DYNAMIC_TABLE_FACTORY_SMBIOS_TABLE_GET_HANDL= E_EX)( + IN SMBIOS_TABLE_GENERATOR_ID GeneratorId, + IN CM_OBJECT_TOKEN CmObjToken + ); + /** The SMBIOS_TABLE_GENERATOR structure provides an interface that the Table Manager can use to invoke the functions to build SMBIOS tables. */ typedef struct SmbiosTableGenerator { /// The SMBIOS table generator ID. - SMBIOS_TABLE_GENERATOR_ID GeneratorID; + SMBIOS_TABLE_GENERATOR_ID GeneratorID; =20 /// String describing the DT table /// generator. - CONST CHAR16 *Description; + CONST CHAR16 *Description; =20 /// The SMBIOS table type. - SMBIOS_TYPE Type; + SMBIOS_TYPE Type; =20 /// SMBIOS table build function pointer. - SMBIOS_TABLE_GENERATOR_BUILD_TABLE BuildSmbiosTable; + SMBIOS_TABLE_GENERATOR_BUILD_TABLE BuildSmbiosTable; + + /** The function to free any resources + allocated for building the SMBIOS table. + */ + SMBIOS_TABLE_GENERATOR_FREE_TABLE FreeTableResources; + + /// SMBIOS table extended build function pointer. + SMBIOS_TABLE_GENERATOR_BUILD_TABLEEX BuildSmbiosTableEx; =20 /** The function to free any resources allocated for building the SMBIOS table. */ - SMBIOS_TABLE_GENERATOR_FREE_TABLE FreeTableResources; + SMBIOS_TABLE_GENERATOR_FREE_TABLEEX FreeTableResourcesEx; } SMBIOS_TABLE_GENERATOR; =20 /** Register SMBIOS table factory generator. @@ -229,6 +356,69 @@ DeregisterSmbiosTableGenerator ( IN CONST SMBIOS_TABLE_GENERATOR *CONST Generator ); =20 +/** Add SMBIOS Handle. + + This function is called by the Dynamic Table Manager to add a newly added + SMBIOS Table OR it can be called by an SMBIOS Table generator to create + and add a new SMBIOS Handle if there is a reference to another table and + if there is a generator for that table that hasn't been called yet. + + @param [in] Smbios Pointer to the SMBIOS protocol. + @param [in] SmbiosHandle Pointer to an SMBIOS handle (either generate= d by + SmbiosDxe Driver or SMBIOS_HANDLE_PI_RESERV= ED + if a handle needs to be generated). + @param [in] CmObjectToken The CM Object token for that is used to gene= rate + SMBIOS record. + @param [in] GeneratorId The SMBIOS table generator Id. + + @retval EFI_SUCCESS Success. + @retval EFI_OUT_OF_RESOURCES Unable to add the handle. + @retval EFI_NOT_FOUND The requested generator is not found + in the list of registered generators. +**/ +EFI_STATUS +EFIAPI +AddSmbiosHandle ( + IN EFI_SMBIOS_PROTOCOL *Smbios, + IN SMBIOS_HANDLE *SmbiosHandle, + IN CM_OBJECT_TOKEN CmObjectToken, + IN SMBIOS_TABLE_GENERATOR_ID GeneratorId + ); + +/** Find SMBIOS Handle given the CM Object token used to generate the SMBI= OS + record.. + + This function is called by the SMBIOS table generator to find an SMBIOS + handle needed as part of generating an SMBIOS Table. + + @param [in] CmObjectToken The CM Object token used to generate the S= MBIOS + record. + + @retval EFI_SUCCESS Success. + @retval EFI_NOT_FOUND The requested generator is not found + in the list of registered generators. +**/ +SMBIOS_HANDLE_MAP * +EFIAPI +FindSmbiosHandle ( + IN CM_OBJECT_TOKEN CmObjectToken + ); + +/** Find and return SMBIOS handle based on associated CM object token. + + @param [in] GeneratorId SMBIOS generator ID used to build the SMBIO= S Table. + @param [in] CmObjectToken Token of the CM_OBJECT used to build the SM= BIOS Table. + + @return SMBIOS handle of the table associated with SmbiosTableId and + CmObjectToken if found. Otherwise, returns 0xFFFF. +**/ +UINT16 +EFIAPI +FindSmbiosHandleEx ( + IN SMBIOS_TABLE_GENERATOR_ID GeneratorId, + IN CM_OBJECT_TOKEN CmObjToken + ); + #pragma pack() =20 #endif // SMBIOS_TABLE_GENERATOR_H_ diff --git a/MdePkg/Include/IndustryStandard/SmBios.h b/MdePkg/Include/Indu= stryStandard/SmBios.h index 89985bb418..c40986157c 100644 --- a/MdePkg/Include/IndustryStandard/SmBios.h +++ b/MdePkg/Include/IndustryStandard/SmBios.h @@ -28,6 +28,14 @@ SPDX-License-Identifier: BSD-2-Clause-Patent /// #define SMBIOS_HANDLE_PI_RESERVED 0xFFFE =20 +/// +/// Reference SMBIOS 3.6, chapter 6.1.2. +/// Unless otherwise specified, when referring to another structure=E2=80= =99s handle, the value +/// 0FFFFh is used to indicate that the referenced handle is not applicabl= e or does not +/// exist. +/// +#define SMBIOS_HANDLE_INVALID 0xFFFF + /// /// Reference SMBIOS 2.6, chapter 3.1.3. /// Each text string is limited to 64 significant characters due to system= MIF limitations. --=20 2.17.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 (#107255): https://edk2.groups.io/g/devel/message/107255 Mute This Topic: https://groups.io/mt/100361559/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 07:48:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+107257+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1690328322384777.1211738101307; Tue, 25 Jul 2023 16:38:42 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=P5P35DjKTK3mdrwGzKmMGcmi2AECDn2yArju4Jg2IUY=; c=relaxed/simple; d=groups.io; h=X-Received:X-Received:ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:X-Received:X-Received:X-MS-Exchange-Authentication-Results:Received-SPF:X-Received:X-Received:X-Received:X-Received:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:X-NVConfidentiality:MIME-Version:X-NV-OnPremToCloud:X-EOPAttributedMessage:X-MS-PublicTrafficType:X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id:X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay:X-Microsoft-Antispam-Message-Info:X-OriginatorOrg:X-MS-Exchange-CrossTenant-OriginalArrivalTime:X-MS-Exchange-CrossTenant-Network-Message-Id:X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp:X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs:X-MS-Exchange-CrossTenant-FromEntityHeader:X-MS-Exchange-Transport-CrossTenantHeadersStamped:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:X-Gm-Message-State:Content-Type; s=20140610; t=1690328322; v=1; b=g0PevOSUblbmz/NFdxu4vRixzHj//bmHBUfXEb69ONuknGxZXZBUC82ei3RJ72aZ8AxCmicR 9PHOHZleHpa6GwW4yEHzmYcb9xj1WhU8oWY9wiFXVSHtFLoRcBsBRaKKvlsBG4K29VkRqMdX7eo Jqn4gAV1vaBQJDZrdHes6IdM= X-Received: by 127.0.0.2 with SMTP id RGZkYY1788612xdj6xa3e6ys; Tue, 25 Jul 2023 16:38:42 -0700 X-Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.71]) by mx.groups.io with SMTP id smtpd.web11.107.1690328321156784208 for ; Tue, 25 Jul 2023 16:38:41 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XFGoTrhRxvKtRfQRIQWAduOmAO2C4HYuSHhj0MWTTAzKSA0waF8FDBaXDNJQPOLzSapPByCf61asxM/TJPxsS8V6DbaxKrlXDOiW/PHdrCSH9sB+exd8xSFlM2ksrxYS4VMgPlJOn3Doa1DUPBvxLsbxpe+YgHMUE9vTQtuNcYqlfNCjEDXu6pSGA6DxYssBAgWY7OrFIbk/EpxcRo9l6KPcNoADCk6wJAMUp1AVLAndAFXCCDvq3oq9jH81SVPkRFoi5lPX5Gl6BTkW6vmDlVGgFVtfw7GzOauBA16E8fdsRa8pKqb7vGwzFaeSUnVld4FKE5AFY0KZuVBG7M1cKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RLu7Ye2HsMXx7k2CIGO84jY8nFuU5YsqN7/erSzajzI=; b=Lp5GuGz5Dblwr/GkE2EJtIiaOclG2+52LkpPcLJaMuz2eQ84FJmvFCGn+VLgsnQ+emTFz8m6FdkA7LX2+iF0IYp6DJc0iL5VKPyvjVBFBDZCKxvoxRlwws9cI09aCJV+rYJTzNqHsSxpuZl6Y1fxT0zRYKHoTa8OJYSVGzzQUvVdxf9pTN+jTt1HMTTPI8lNvToe4/lOmrraYhGNnGfARk1h9Fc5bozyFg5+dSuNCgW/ziIl5CzY90Mj6VfZNhn/BppQyAErx+CE3Rd6kar6M+FnR92PulTStDsiVVq3twfydHer2q/BTzL5YeZzabUcPFzSgZ6izcBs5VSBCKNltQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none X-Received: from MW4PR03CA0174.namprd03.prod.outlook.com (2603:10b6:303:8d::29) by MN2PR12MB4222.namprd12.prod.outlook.com (2603:10b6:208:19a::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.33; Tue, 25 Jul 2023 23:38:36 +0000 X-Received: from CO1NAM11FT026.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8d:cafe::b7) by MW4PR03CA0174.outlook.office365.com (2603:10b6:303:8d::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.33 via Frontend Transport; Tue, 25 Jul 2023 23:38:36 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+107257+1787277+3901457@groups.io; helo=mail02.groups.io; 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 CO1NAM11FT026.mail.protection.outlook.com (10.13.175.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.29 via Frontend Transport; Tue, 25 Jul 2023 23:38:36 +0000 X-Received: from rnnvmail201.nvidia.com (10.129.68.8) 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.986.5; Tue, 25 Jul 2023 16:38:23 -0700 X-Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 25 Jul 2023 16:38:23 -0700 X-Received: from build-gmahadevan-20230109T020417557.nvidia.com (10.127.8.12) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Tue, 25 Jul 2023 16:38:22 -0700 From: "Girish Mahadevan via groups.io" To: , CC: , , , , , Subject: [edk2-devel] [PATCH v3 2/5] DynamicTablesPkg: Split the ACPI and SMBIOS table generators Date: Tue, 25 Jul 2023 23:38:02 +0000 Message-ID: <20230725233805.646668-3-gmahadevan@nvidia.com> In-Reply-To: <20230725233805.646668-1-gmahadevan@nvidia.com> References: <20230725233805.646668-1-gmahadevan@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT026:EE_|MN2PR12MB4222:EE_ X-MS-Office365-Filtering-Correlation-Id: 34619001-9029-4da4-c9e3-08db8d684446 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: PQDFQFo1Ja+ar772ds0B10Tz+uCdS2qm34T+SXs9+u035TUlo3JQC6gOhsUpMA4/INj/Tq75kjxIgOEw9ZR9YSLrvd5qWmAyxLyvLSfrKTss5LAxgpfH1wIUyHe1msw6gSUipRdE+gsWeGAW/4DgEU2R2P1S5snNGE92DjfynDuManHo5kQ2GdwIPs8k9nvO6vrz6wtXumEH5Z9PI6StQPT5fHBFLhUt226ILbHly08TEy+wyrXXSNkQA/79N+obqCopLLlgwuhU3MGJVgnYoTSHJzWnvdFOzwQlbxUKylvlM/ogETLzCbP47+PLuAfrzm7V9KsmI6cRlhyVCKyEkTLyWS+Tc/P+xeoZFNOWNTGbP0EwWYL9t8GFEwfQQL7ZQLweIoa+FGT3uRa0l1jEe9eBH4tJX8pYSbuQAiCcYl/lkIcQewyRCeBgfpir05Ee9w7JNvn4s2K1mWjk6N92LwrZP5NrGDMFzN2RCdw+q5MIw6AQZ3/Clap5ElSBhYNpDLSzBvULSpYd682CZLdteyjK1DkPBAIA2kfdA2VDupyk0hEi/IIshNnQXffy8TvUJ/HAXQpz02W+QKTPUvL/iLqVb0zG+6+LD/t2YQrNmZDsOHNjtrYBs8njfhKY5wCRdcfhVbXHi42rWShQ2ZStLSwzccrBhWrv60FEzwdv7RUoiSAITtQGUGpooDc75cm0Im0lYEFM80QyG1Vq2RAFyh3NMmnnfpTBSft9koEZWHGjpjY7KnI9i9XlzLeMQUcp X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2023 23:38:36.3880 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 34619001-9029-4da4-c9e3-08db8d684446 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: CO1NAM11FT026.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4222 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 Reply-To: devel@edk2.groups.io,gmahadevan@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: oGpijPIVxyvGdF0mDfJFJr3kx1787277AA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1690328323451100011 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Split the SMBIOS and ACPI table generators into their own files. Signed-off-by: Girish Mahadevan Reviewed-by: Jeff Brasen --- .../DynamicTableManagerDxe/AcpiTableBuilder.c | 798 ++++++++++ .../DynamicTableManagerDxe.c | 1356 +---------------- .../DynamicTableManagerDxe.inf | 2 + .../SmbiosTableBuilder.c | 606 ++++++++ 4 files changed, 1419 insertions(+), 1343 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..2adfb0378e --- /dev/null +++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/AcpiTableBuilder.c @@ -0,0 +1,798 @@ +/** @file + Acpi Table Manager Dxe + + Copyright (c) 2017 - 2019, ARM Limited. All rights reserved. + Copyright (c) 2022 - 2023, NVIDIA CORPORATION & AFFILIATES. All rights r= eserved. + + 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 + +/// +/// Bit definitions for acceptable ACPI table presence formats. +/// Currently only ACPI tables present in the ACPI info list and +/// already installed will count towards "Table Present" during +/// verification routine. +/// +#define ACPI_TABLE_PRESENT_INFO_LIST BIT0 +#define ACPI_TABLE_PRESENT_INSTALLED BIT1 + +/// +/// Order of ACPI table being verified during presence inspection. +/// +#define ACPI_TABLE_VERIFY_FADT 0 +#define ACPI_TABLE_VERIFY_MADT 1 +#define ACPI_TABLE_VERIFY_GTDT 2 +#define ACPI_TABLE_VERIFY_DSDT 3 +#define ACPI_TABLE_VERIFY_DBG2 4 +#define ACPI_TABLE_VERIFY_SPCR 5 +#define ACPI_TABLE_VERIFY_COUNT 6 + +/// +/// Private data structure to verify the presence of mandatory +/// or optional ACPI tables. +/// +typedef struct { + /// ESTD ID for the ACPI table of interest. + ESTD_ACPI_TABLE_ID EstdTableId; + /// Standard UINT32 ACPI signature. + UINT32 AcpiTableSignature; + /// 4 character ACPI table name (the 5th char8 is for null terminator). + CHAR8 AcpiTableName[sizeof (UINT32) + 1]; + /// Indicator on whether the ACPI table is required. + BOOLEAN IsMandatory; + /// Formats of verified presences, as defined by ACPI_TABLE_PRESENT_* + /// This field should be initialized to 0 and will be populated during + /// verification routine. + UINT16 Presence; +} ACPI_TABLE_PRESENCE_INFO; + +/// +/// We require the FADT, MADT, GTDT and the DSDT tables to boot. +/// This list also include optional ACPI tables: DBG2, SPCR. +/// +ACPI_TABLE_PRESENCE_INFO mAcpiVerifyTables[ACPI_TABLE_VERIFY_COUNT] =3D { + { EStdAcpiTableIdFadt, EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATU= RE, "FADT", TRUE, 0 }, + { EStdAcpiTableIdMadt, EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGN= ATURE, "MADT", TRUE, 0 }, + { EStdAcpiTableIdGtdt, EFI_ACPI_6_2_GENERIC_TIMER_DESCRIPTION_TABLE_SIGN= ATURE, "GTDT", TRUE, 0 }, + { EStdAcpiTableIdDsdt, EFI_ACPI_6_2_DIFFERENTIATED_SYSTEM_DESCRIPTION_TA= BLE_SIGNATURE, "DSDT", TRUE, 0 }, + { EStdAcpiTableIdDbg2, EFI_ACPI_6_2_DEBUG_PORT_2_TABLE_SIGNATURE, = "DBG2", FALSE, 0 }, + { EStdAcpiTableIdSpcr, EFI_ACPI_6_2_SERIAL_PORT_CONSOLE_REDIRECTION_TABL= E_SIGNATURE, "SPCR", FALSE, 0 }, +}; + +/** 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 < ACPI_TABLE_VERIFY_COUNT; 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 < ACPI_TABLE_VERIFY_COUNT; 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 < ACPI_TABLE_VERIFY_COUNT; 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 ((mAcpiVerifyTables[ACPI_TABLE_VERIFY_FADT].Presence & ACPI_TABLE_PRE= SENT_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 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 26aa9b55cf..6ad2e623b2 100644 --- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDx= e.c +++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDx= e.c @@ -2,6 +2,7 @@ Dynamic Table Manager Dxe =20 Copyright (c) 2017 - 2019, ARM Limited. All rights reserved. + Copyright (c) 2022 - 2023, NVIDIA CORPORATION & AFFILIATES. All rights r= eserved. =20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -11,10 +12,6 @@ #include #include #include -#include -#include -#include -#include =20 // Module specific include files. #include @@ -24,1351 +21,25 @@ #include #include #include -#include -#include =20 -/// -/// Bit definitions for acceptable ACPI table presence formats. -/// Currently only ACPI tables present in the ACPI info list and -/// already installed will count towards "Table Present" during -/// verification routine. -/// -#define ACPI_TABLE_PRESENT_INFO_LIST BIT0 -#define ACPI_TABLE_PRESENT_INSTALLED BIT1 - -/// -/// Order of ACPI table being verified during presence inspection. -/// -#define ACPI_TABLE_VERIFY_FADT 0 -#define ACPI_TABLE_VERIFY_MADT 1 -#define ACPI_TABLE_VERIFY_GTDT 2 -#define ACPI_TABLE_VERIFY_DSDT 3 -#define ACPI_TABLE_VERIFY_DBG2 4 -#define ACPI_TABLE_VERIFY_SPCR 5 -#define ACPI_TABLE_VERIFY_COUNT 6 - -/// -/// Private data structure to verify the presence of mandatory -/// or optional ACPI tables. -/// -typedef struct { - /// ESTD ID for the ACPI table of interest. - ESTD_ACPI_TABLE_ID EstdTableId; - /// Standard UINT32 ACPI signature. - UINT32 AcpiTableSignature; - /// 4 character ACPI table name (the 5th char8 is for null terminator). - CHAR8 AcpiTableName[sizeof (UINT32) + 1]; - /// Indicator on whether the ACPI table is required. - BOOLEAN IsMandatory; - /// Formats of verified presences, as defined by ACPI_TABLE_PRESENT_* - /// This field should be initialized to 0 and will be populated during - /// verification routine. - UINT16 Presence; -} ACPI_TABLE_PRESENCE_INFO; - -/// -/// We require the FADT, MADT, GTDT and the DSDT tables to boot. -/// This list also include optional ACPI tables: DBG2, SPCR. -/// -ACPI_TABLE_PRESENCE_INFO mAcpiVerifyTables[ACPI_TABLE_VERIFY_COUNT] =3D { - { EStdAcpiTableIdFadt, EFI_ACPI_6_2_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATU= RE, "FADT", TRUE, 0 }, - { EStdAcpiTableIdMadt, EFI_ACPI_6_2_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGN= ATURE, "MADT", TRUE, 0 }, - { EStdAcpiTableIdGtdt, EFI_ACPI_6_2_GENERIC_TIMER_DESCRIPTION_TABLE_SIGN= ATURE, "GTDT", TRUE, 0 }, - { EStdAcpiTableIdDsdt, EFI_ACPI_6_2_DIFFERENTIATED_SYSTEM_DESCRIPTION_TA= BLE_SIGNATURE, "DSDT", TRUE, 0 }, - { EStdAcpiTableIdDbg2, EFI_ACPI_6_2_DEBUG_PORT_2_TABLE_SIGNATURE, = "DBG2", FALSE, 0 }, - { EStdAcpiTableIdSpcr, EFI_ACPI_6_2_SERIAL_PORT_CONSOLE_REDIRECTION_TABL= E_SIGNATURE, "SPCR", FALSE, 0 }, -}; - -/** 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 < ACPI_TABLE_VERIFY_COUNT; 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 < ACPI_TABLE_VERIFY_COUNT; 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 < ACPI_TABLE_VERIFY_COUNT; 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 ((mAcpiVerifyTables[ACPI_TABLE_VERIFY_FADT].Presence & ACPI_TABLE_PRE= SENT_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; - } + ); =20 - // 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 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 @@ -1396,9 +67,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, @@ -1425,5 +95,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 3beab7420a..93fde9f44f 100644 --- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDx= e.inf +++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/DynamicTableManagerDx= e.inf @@ -24,6 +24,8 @@ DynamicTableManagerDxe.c SmbiosTableDispatcher.c SmbiosTableDispatcher.h + AcpiTableBuilder.c + SmbiosTableBuilder.c =20 [Packages] MdePkg/MdePkg.dec diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableBui= lder.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableBuilder= .c new file mode 100644 index 0000000000..bfddaac3aa --- /dev/null +++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableBuilder.c @@ -0,0 +1,606 @@ +/** @file + Dynamic Table Manager Dxe + + Copyright (c) 2017 - 2019, ARM Limited. All rights reserved. + Copyright (c) 2022 - 2023, NVIDIA CORPORATION & AFFILIATES. All rights r= eserved. + + 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.17.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 (#107257): https://edk2.groups.io/g/devel/message/107257 Mute This Topic: https://groups.io/mt/100361561/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 07:48:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+107258+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 16903283227141005.1715774987416; Tue, 25 Jul 2023 16:38:42 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=pbZ4PoEmb6tLvqnAMeedxvGG9QiQn9y83lSEOeJ9C+0=; c=relaxed/simple; d=groups.io; h=X-Received:X-Received:ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:X-Received:X-Received:X-MS-Exchange-Authentication-Results:Received-SPF:X-Received:X-Received:X-Received:X-Received:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:X-NVConfidentiality:MIME-Version:X-NV-OnPremToCloud:X-EOPAttributedMessage:X-MS-PublicTrafficType:X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id:X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay:X-Microsoft-Antispam-Message-Info:X-OriginatorOrg:X-MS-Exchange-CrossTenant-OriginalArrivalTime:X-MS-Exchange-CrossTenant-Network-Message-Id:X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp:X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs:X-MS-Exchange-CrossTenant-FromEntityHeader:X-MS-Exchange-Transport-CrossTenantHeadersStamped:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:X-Gm-Message-State:Content-Type; s=20140610; t=1690328322; v=1; b=Izfs6Yp2I9FZ04UVQpjKxiFBIFV3jjLIdRyvPr3dZe3cO4deVCmugIBOBDWjF7NaJ4lSKJvI 4vaHz2uuaJKrNyR2JYBVJyA36QAKPRMLuzTrgFUynl6CaFr/nUe7jdDxN3ipPgZItMfv+OljPL4 9hPvc+WdMSILCm7/RRtuQ/jA= X-Received: by 127.0.0.2 with SMTP id OVZ0YY1788612xIKbBS8wu6o; Tue, 25 Jul 2023 16:38:42 -0700 X-Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.45]) by mx.groups.io with SMTP id smtpd.web11.108.1690328321615462089 for ; Tue, 25 Jul 2023 16:38:41 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZC5NiaJn/pkf/7+SkW7mNo6nmfuocwvfRgxmdxwLsDeUOw5S9tFWcOAYHCv2HkUEFSI24b8b4AlbTHtf6Z2Q4XCdP3QM8trCVRw7kdrZIOitdImYpfyOEoRc+xczx57vehr/qIa92KhwwkLdBma9a8bIuF2kgA7TQQASjQUI9zkMPpb1q10g91oQExMURvjjOYQaVFVRbcTr/kCgVs42TcxwoAtEiWpmKPTlmUWAqugwzWNS/+GQsvMxLMBNg5zOxytehwAe23rHyMkQo5uaCPCnM8Exwoi1k+hgrlPubcB5J7DfjFe8p1QQY1llJM9Bf6t7cvdeeEjaMgLSlyW2xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zsm3qZ2fqsquUisihCmhryM3JcGfLW2LTkp8nsvvxQ8=; b=gE+WJr+qcxOlCrmsPuM4F7EZ+qUgg07ROkDV2ly2jgUQOtRxpMLgrsN8zFaN052efJPorC28EivICCvcGu0zkIDv21VwXoMkZ9fhVVCZmkNo2/9XolCQ9+35fmfiFl29mBc8HgJRKMzJ+QyZlRFC9FzwLe73kSHqFU+5MdgcGGhrq0PycJnEap4g53qSCoWiF4q6y0F7+aJIUgKKcVNmidJAg/LpHZt2n+K+HVQFbhKKIkQ3cIGPDAR+9MwLPkJc5roiEB29YiEQropsalkzalYH1E4DywqGqs1ToHxX1fLBGtTfpNTIXd7Hl4lSFAKENYg2a+pgQg9eZF+a0swp5g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none X-Received: from MW4P222CA0002.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::7) by MW4PR12MB7333.namprd12.prod.outlook.com (2603:10b6:303:21b::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Tue, 25 Jul 2023 23:38:39 +0000 X-Received: from CO1NAM11FT011.eop-nam11.prod.protection.outlook.com (2603:10b6:303:114:cafe::2b) by MW4P222CA0002.outlook.office365.com (2603:10b6:303:114::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.33 via Frontend Transport; Tue, 25 Jul 2023 23:38:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+107258+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C X-Received: from mail.nvidia.com (216.228.117.161) by CO1NAM11FT011.mail.protection.outlook.com (10.13.175.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.29 via Frontend Transport; Tue, 25 Jul 2023 23:38:39 +0000 X-Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 25 Jul 2023 16:38:24 -0700 X-Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 25 Jul 2023 16:38:23 -0700 X-Received: from build-gmahadevan-20230109T020417557.nvidia.com (10.127.8.12) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Tue, 25 Jul 2023 16:38:23 -0700 From: "Girish Mahadevan via groups.io" To: , CC: , , , , , Subject: [edk2-devel] [PATCH v3 3/5] DynamicTablesPkg: Introduce new namespace for SMBIOS Objects Date: Tue, 25 Jul 2023 23:38:03 +0000 Message-ID: <20230725233805.646668-4-gmahadevan@nvidia.com> In-Reply-To: <20230725233805.646668-1-gmahadevan@nvidia.com> References: <20230725233805.646668-1-gmahadevan@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT011:EE_|MW4PR12MB7333:EE_ X-MS-Office365-Filtering-Correlation-Id: 551d527e-f4b3-4701-e2dc-08db8d684605 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: X57eUaux2yE81g/ZgN8fbtfrhSxEER7MPus64ad8hPoNO9e5idnukAN2KRG1Khz5jvTefU/xlBXzoQriajpJ8HvQoazkeiXzDrZh8snXrLB63h+vSnjen6oBpuh/SFq99oRXsS61G+dfCtCJZP1ZtlEZa5pEA2eSNPi39ceNjfPo5aJumEMApSUH7lARwMM+EDkjIRC5LVlhNiG38GLat/WjyB402hRPvkF+CfW55NjnktMoDZFsSkUJD4cH3//hq3omGe/xwDHjx4E61Oi0opDxUb2ZblbvqsbRPtEMFMWv52PSWMAF9vqOqjAmQ1c8mPTbkwjcT0EoLsbdR6N2YOefuBstE4kYX2Rl+CzBYa9Cxz68luRIUmofeSRqIYeosbVhggaf5UHLPSC/+GTQYX4yMMF0mAp6jcU7wz9K1RsVUwKB6zZfcYnAeJmFRNanXggu4yj8rhAAMXLgoEugS+JnkZQM47mquAPpjZ2M2yGhTndTbMt/ep1Uv9/QH0/brEh1uEoOty0rSViHwZd4D38wV0rY0HUh132meblVPbVWVCTXmvqQF6wQxyoyW9zzkb0R5V8IsU9YZiFsnDegeDvalTiQNehBaD9+R74tTXqJEwJgDJCA6dgZrNiHW93VWvHELOl1txItSZ3MYFVVvYaAIqsMcjDGj36JUo6g4IThvWNXd+gPPyEFuy3Fy4OfpDDBflNSX3wNgT9q9qF7WKtiv6W1UZXBqr3wBMnNwBoPDcB5P7h0lCEPRo5Ri79f X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2023 23:38:39.2400 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 551d527e-f4b3-4701-e2dc-08db8d684605 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.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT011.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7333 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 Reply-To: devel@edk2.groups.io,gmahadevan@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 6SlsqdMVNqKmsxZhXgsqt4Mxx1787277AA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1690328323038100009 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Introduce a new namespace for SMBIOS related CM Objects. Signed-off-by: Girish Mahadevan Reviewed-by: Nick Ramirez Reviewed-by: Jeff Brasen --- .../Include/ConfigurationManagerObject.h | 14 ++++++- .../Include/SmbiosNameSpaceObjects.h | 42 +++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h diff --git a/DynamicTablesPkg/Include/ConfigurationManagerObject.h b/Dynami= cTablesPkg/Include/ConfigurationManagerObject.h index 74ad25d5d9..445c560545 100644 --- a/DynamicTablesPkg/Include/ConfigurationManagerObject.h +++ b/DynamicTablesPkg/Include/ConfigurationManagerObject.h @@ -14,6 +14,7 @@ =20 #include #include +#include =20 #pragma pack(1) =20 @@ -107,7 +108,8 @@ typedef UINT32 CM_OBJECT_ID; typedef enum ObjectNameSpaceID { EObjNameSpaceStandard, ///< Standard Objects Namespace EObjNameSpaceArm, ///< ARM Objects Namespace - EObjNameSpaceOem =3D 0x8, ///< OEM Objects Namespace + EObjNameSpaceOem =3D 0x8, ///< OEM Objects Namespace + EObjNameSpaceSmbios =3D 0xA, ///< SMBIOS Objects Namespace EObjNameSpaceMax } EOBJECT_NAMESPACE_ID; =20 @@ -192,4 +194,14 @@ typedef struct CmObjDescriptor { #define CREATE_CM_OEM_OBJECT_ID(ObjectId) \ (CREATE_CM_OBJECT_ID (EObjNameSpaceOem, ObjectId)) =20 +/** This macro returns a Configuration Manager Object ID + in the SMBIOS Object Namespace. + + @param [in] ObjectId The Object ID. + + @retval Returns an SMBIOS Configuration Manager Object ID. +**/ +#define CREATE_CM_SMBIOS_OBJECT_ID(ObjectId) \ + (CREATE_CM_OBJECT_ID (EObjNameSpaceSmbios, ObjectId)) + #endif // CONFIGURATION_MANAGER_OBJECT_H_ diff --git a/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h b/DynamicTab= lesPkg/Include/SmbiosNameSpaceObjects.h new file mode 100644 index 0000000000..836c902e40 --- /dev/null +++ b/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h @@ -0,0 +1,42 @@ +/** @file + + Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved. + + SPDX-License-Identifier: BSD-2-Clause-Patent + + @par Glossary: + - Cm or CM - Configuration Manager + - Obj or OBJ - Object + - Std or STD - Standard +**/ + +#ifndef SMBIOS_NAMESPACE_OBJECTS_H_ +#define SMBIOS_NAMESPACE_OBJECTS_H_ + +#pragma pack(1) + +typedef enum SmbiosObjectID { + ESmbiosObjReserved, ///< 0 - Reserved + ESmbiosObjBaseboardInfo, ///< 1 - Baseboard Information + ESmbiosObjSystemSlotInfo, ///< 2 - System Slot Information + ESmbiosObjSystemInfo, ///< 3 - System Information + ESmbiosObjTpmDeviceInfo, ///< 4 - TPM Device Info + ESmbiosObjOemStrings, ///< 5 - OEM Strings + ESmbiosObjPortConnectorInfo, ///< 6 - Port connector Information + ESmbiosObjBiosInfo, ///< 7 - Bios Information + ESmbiosObjOnboardDeviceExInfo, ///< 8 - Onboard Device Ex Informat= ion + ESmbiosObjGroupAssociations, ///< 9 - Group Associations + ESmbiosObjBiosLanguageInfo, ///< 10 - BIOS Language Information + ESmbiosObjEnclosureInfo, ///< 11 - Enclosure Information + ESmbiosObjMemoryDeviceInfo, ///< 12 - Memory Device Information + ESmbiosObjSystemBootInfo, ///< 13 - System Boot Info + ESmbiosObjPhysicalMemoryArray, ///< 14 - Physical Memory Array + ESmbiosObjMemoryArrayMappedAddress, ///< 15 - Memory Mapped Address + ESmbiosObjPowerSupplyInfo, ///< 16 - Power Supply Info + ESmbiosObjFirmwareInventoryInfo, ///< 17 - Firmware Inventory Info + ESmbiosObjMax +} ESMBIOS_OBJECT_ID; + +#pragma pack() + +#endif // SMBIOS_NAMESPACE_OBJECTS_H_ --=20 2.17.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 (#107258): https://edk2.groups.io/g/devel/message/107258 Mute This Topic: https://groups.io/mt/100361562/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 07:48:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+107256+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1690328321794841.522600048348; Tue, 25 Jul 2023 16:38:41 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=9U6HFU8nSHnddEviVd0JIhA0ZpLgHq2JDFV9df0KOZ8=; c=relaxed/simple; d=groups.io; h=X-Received:X-Received:ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:X-Received:X-Received:X-MS-Exchange-Authentication-Results:Received-SPF:X-Received:X-Received:X-Received:X-Received:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:X-NVConfidentiality:MIME-Version:X-NV-OnPremToCloud:X-EOPAttributedMessage:X-MS-PublicTrafficType:X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id:X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay:X-Microsoft-Antispam-Message-Info:X-OriginatorOrg:X-MS-Exchange-CrossTenant-OriginalArrivalTime:X-MS-Exchange-CrossTenant-Network-Message-Id:X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp:X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs:X-MS-Exchange-CrossTenant-FromEntityHeader:X-MS-Exchange-Transport-CrossTenantHeadersStamped:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:X-Gm-Message-State:Content-Type; s=20140610; t=1690328321; v=1; b=BiQRlMbnQ21EG+OPie8joQgHOeZnk9s98XsMLQx2Hprs7iitfSqwX59TFK5z24RXPmLTKqSk 52HcpM5pJ1AlZgEoNf/b561r3crMToriX8piUFZU3m+DPsURjsJAxQ9KGIIexw8tdm33B3ZtBC1 R59YZPqvbwikJJrVfY+pTvxc= X-Received: by 127.0.0.2 with SMTP id NOuSYY1788612xxy3Zp7bbmV; Tue, 25 Jul 2023 16:38:41 -0700 X-Received: from NAM11-DM6-obe.outbound.protection.outlook.com (NAM11-DM6-obe.outbound.protection.outlook.com [40.107.223.61]) by mx.groups.io with SMTP id smtpd.web10.126.1690328320865529950 for ; Tue, 25 Jul 2023 16:38:41 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z8EaXftpOAKOyit9FiFoB11ml7+B+Wtay4MKVKzkMGZ/ZdneUgB4J2wqGd+GPbRbu0hFVSJYt1kiaZnuBaa9cg7Gv/zqWGSFMp77hyqk7veO2IOKAz4RKPM1C1g34amJaxwXoZfXmP+LC1BsB5oB0o2msWjQ/SS6MO0VNYVGn+5nGZzrNaiYhRadJxfgaLKnpjDl6teVPE3MoIXVWNiV6SlDAV5Sb7t3nOJt9NUApqlFT7krgtYUwTutJhZm17hmRLiHcEbo0qvGtyMvyLJDEvCTgPgy6K61NiF71I3XHMG54tfCqsRmh2907XHRdKAOCK6nRzu8haU2KlV1zk5Y2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wy/XJSdlZODh5y+B4XhQZkObuVDmPNUGe2oAV326eEY=; b=fOwSS1xsATs3Fv6tfMF6JxaQz/CXKxAz8D0wdNi39Y0SBT8xGJe+fOZP1E6tUgYcEguD8+Y3BHi1Fw2k6ko7UpnrcJuEKLJzWucIjQYoJNHaNliRKmI5prqO0WYiP4B1HOFVM81Ou2qWRF2JVK/xZpG5JwpCe14Pev3HtujAFW0kY4ymZjMTA5fQgkSGAmXx2djMXrpgpyyKiXy+nbThzVRShSv0QFjAIMK1uAddYkjrL9CmgIV11I4tIFxZ/UIXpT/cSMmmJiWloaDvascQcWkj+5sHoZMwC0rosgmHEquCYjgEYtl+e3mO5BbNIdGmOVfTBnx6Fh3SnPx5Gu4TJg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none X-Received: from MW4PR03CA0170.namprd03.prod.outlook.com (2603:10b6:303:8d::25) by MN0PR12MB5739.namprd12.prod.outlook.com (2603:10b6:208:372::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.33; Tue, 25 Jul 2023 23:38:38 +0000 X-Received: from CO1NAM11FT026.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8d:cafe::59) by MW4PR03CA0170.outlook.office365.com (2603:10b6:303:8d::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.33 via Frontend Transport; Tue, 25 Jul 2023 23:38:37 +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 (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+107256+1787277+3901457@groups.io; helo=mail02.groups.io; 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 CO1NAM11FT026.mail.protection.outlook.com (10.13.175.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.29 via Frontend Transport; Tue, 25 Jul 2023 23:38:37 +0000 X-Received: from rnnvmail201.nvidia.com (10.129.68.8) 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.986.5; Tue, 25 Jul 2023 16:38:24 -0700 X-Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 25 Jul 2023 16:38:24 -0700 X-Received: from build-gmahadevan-20230109T020417557.nvidia.com (10.127.8.12) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Tue, 25 Jul 2023 16:38:24 -0700 From: "Girish Mahadevan via groups.io" To: , CC: , , , , , Subject: [edk2-devel] [PATCH v3 4/5] DynamicTablesPkg: Smbios Memory Device (Type 17) Date: Tue, 25 Jul 2023 23:38:04 +0000 Message-ID: <20230725233805.646668-5-gmahadevan@nvidia.com> In-Reply-To: <20230725233805.646668-1-gmahadevan@nvidia.com> References: <20230725233805.646668-1-gmahadevan@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT026:EE_|MN0PR12MB5739:EE_ X-MS-Office365-Filtering-Correlation-Id: cca55658-5f6a-42df-5d61-08db8d6844df X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: +FKNegoHG0odcf6XS76ElO36CwmiyU7uiQ1+zj/qlRYtY24xfFosyDVW3V914JAW8ppo+dNgSDEaNPOsSyVbVfsdDJuemIRKmYf0e08fg+HF+/5KUB+STW9z2RC9b/qDB+GnZklgyE2GbSrk0t93U88ANBnjdD9GkvMEw66B3ASoNX8I4S3k46Dehof7CF15BASUIHSMXrXrJQnxNPFCdhn9fLG+RcG59FN55CM3AexHMjyDyVr7fvXjh7z83T3ktudGuCjLS+vV4efC5igPgy6X3FdKv7whLT9htyr1YfTFtuGP29vlnYtUtpwGBIgiMC19GVohN6xKIku6zbZYE25m8yOTTvQmDX0pQWFFzo59KxfS8JPXX0lD6nl1YDVHvAt8KdFO2hcLy1YnqkDr1PX2DsIsnMubWEEc70REKdV67CHBlsNiOACIg1rlQJehcOEdwG0e7vkdGH2660cphUAknU9L9N48JNzgvpctz/e6YujyCbLkQpKPdiR8EmWiIzEER3itx+Ec4iStwvj7mCEeVTKyd0iRITuOtISqa2uPdcyx6WLg94wTCmHPXuF2YOspaO8o5RJ9ASgRMwZX+BmM1z2WBYf417rANY56Jt3stbxMUNJwPQfhLknyB0IfcGTHcqlCvcs2X/wBUwei8qVELu0Hj32ydkw0xba1Bj40MymFYnaNFPBgL++6tP/IUthyuS2nRt4TV2IZzs1Suchys3fCnS0xkC7OerUs7kPfBSAR4VAgce1BIueOtrcq X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2023 23:38:37.3724 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cca55658-5f6a-42df-5d61-08db8d6844df 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: CO1NAM11FT026.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5739 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 Reply-To: devel@edk2.groups.io,gmahadevan@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: kqqMDW63e7ZaI8B6LCuddQPOx1787277AA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1690328323478100013 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add the Generator library for SMBIOS Table Type 17 - Memory Device. Signed-off-by: Girish Mahadevan Reviewed-by: Jeff Brasen --- .../Include/SmbiosNameSpaceObjects.h | 70 +++ .../SmbiosType17Lib/SmbiosType17Generator.c | 445 ++++++++++++++++++ .../SmbiosType17Lib/SmbiosType17Lib.inf | 36 ++ 3 files changed, 551 insertions(+) create mode 100644 DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosT= ype17Generator.c create mode 100644 DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosT= ype17Lib.inf diff --git a/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h b/DynamicTab= lesPkg/Include/SmbiosNameSpaceObjects.h index 836c902e40..e44d703fac 100644 --- a/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h +++ b/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h @@ -13,6 +13,8 @@ #ifndef SMBIOS_NAMESPACE_OBJECTS_H_ #define SMBIOS_NAMESPACE_OBJECTS_H_ =20 +#include + #pragma pack(1) =20 typedef enum SmbiosObjectID { @@ -37,6 +39,74 @@ typedef enum SmbiosObjectID { ESmbiosObjMax } ESMBIOS_OBJECT_ID; =20 +/** A structure that describes the physical memory device. + + The physical memory devices on the system are described by this object. + + SMBIOS Specification v3.5.0 Type17 + + ID: ESmbiosObjMemoryDeviceInfo, +*/ +typedef struct CmSmbiosMemoryDeviceInfo { + /** Size of the device. + Size of the device in bytes. + */ + UINT64 Size; + + /** Device Set */ + UINT8 DeviceSet; + + /** Speed of the device + Speed of the device in MegaTransfers/second. + */ + UINT32 Speed; + + /** Serial Number of device */ + CHAR8 *SerialNum; + + /** AssetTag identifying the device */ + CHAR8 *AssetTag; + + /** Device Locator String for the device. + String that describes the slot or position of the device on the board. + */ + CHAR8 *DeviceLocator; + + /** Bank locator string for the device. + String that describes the bank where the device is located. + */ + CHAR8 *BankLocator; + + /** Firmware version of the memory device */ + CHAR8 *FirmwareVersion; + + /** Manufacturer Id. + 2 byte Manufacturer Id as per JEDEC Standard JEP106AV + */ + UINT16 ModuleManufacturerId; + + /** Manufacturer Product Id + 2 byte Manufacturer Id as designated by Manufacturer. + */ + UINT16 ModuleProductId; + + CM_OBJECT_TOKEN MemoryDeviceInfoToken; + CM_OBJECT_TOKEN PhysicalArrayToken; + UINT16 DataWidth; + UINT16 TotalWidth; + UINT8 Rank; + + MEMORY_DEVICE_TYPE DeviceType; + MEMORY_DEVICE_TYPE_DETAIL TypeDetail; + MEMORY_DEVICE_TECHNOLOGY DeviceTechnology; + MEMORY_FORM_FACTOR FormFactor; +} CM_SMBIOS_MEMORY_DEVICE_INFO; + +typedef struct { + CM_OBJECT_TOKEN CmObjToken; + SMBIOS_TABLE_GENERATOR_ID GeneratorId; +} CONTAINED_CM_OBJECTS; + #pragma pack() =20 #endif // SMBIOS_NAMESPACE_OBJECTS_H_ diff --git a/DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Ge= nerator.c b/DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Gen= erator.c new file mode 100644 index 0000000000..27f2dfc235 --- /dev/null +++ b/DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Generator= .c @@ -0,0 +1,445 @@ +/** @file + SMBIOS Type17 Table Generator. + + Copyright (c) 2022 - 2023, NVIDIA CORPORATION & AFFILIATES. All rights r= eserved. + Copyright (c) 2020 - 2021, 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 + +/** This macro expands to a function that retrieves the Memory Device + information from the Configuration Manager. +*/ +GET_OBJECT_LIST ( + EObjNameSpaceSmbios, + ESmbiosObjMemoryDeviceInfo, + CM_SMBIOS_MEMORY_DEVICE_INFO + ) + +#define EXTENDED_SIZE_THRESHOLD (0x7FFF00000LL) +#define SIZE_GRANULARITY_THRESHOLD (0x100000L) +#define SIZE_GRANULARITY_BITMASK (0x8000) +#define EXTENDED_SPEED_THRESHOLD (0xFFFF) +#define SMBIOS_TYPE17_MAX_STRINGS (7) +#define RANK_MASK (0x7) + +STATIC +EFI_STATUS +FreeSmbiosType17TableEx ( + IN CONST SMBIOS_TABLE_GENERATOR *CONST This, + IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFact= oryProtocol, + IN CONST CM_STD_OBJ_SMBIOS_TABLE_INFO *CONST SmbiosTab= leInfo, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrPro= tocol, + IN SMBIOS_STRUCTURE ***CONST Table, + IN CM_OBJECT_TOKEN **CmObjec= tToken, + IN CONST UINTN TableCount + ) +{ + UINTN Index; + SMBIOS_STRUCTURE **TableList; + + TableList =3D *Table; + for (Index =3D 0; Index < TableCount; Index++) { + if (TableList[Index] !=3D NULL) { + FreePool (TableList[Index]); + } + } + + if (*CmObjectToken !=3D NULL) { + FreePool (*CmObjectToken); + } + + if (TableList !=3D NULL) { + FreePool (TableList); + } + + return EFI_SUCCESS; +} + +STATIC +VOID +AddPhysArrHandle ( + IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryPro= tocol, + IN CM_OBJECT_TOKEN CmObjToken, + OUT SMBIOS_TABLE_TYPE17 *SmbiosRecord + ) +{ + EFI_SMBIOS_HANDLE PhysMemArrHandle; + SMBIOS_HANDLE_MAP *HandleMap; + + HandleMap =3D TableFactoryProtocol->GetSmbiosHandle (CmObjToken); + if (HandleMap =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a:Failed to get SMBIOS Handle\n", __FUNCTION__)= ); + PhysMemArrHandle =3D 0; + } else { + PhysMemArrHandle =3D HandleMap->SmbiosTblHandle; + } + + SmbiosRecord->MemoryArrayHandle =3D PhysMemArrHandle; +} + +STATIC +VOID +UpdateSmbiosType17Size ( + IN UINT64 Size, + OUT SMBIOS_TABLE_TYPE17 *SmbiosRecord + ) +{ + if (Size < SIZE_GRANULARITY_THRESHOLD) { + SmbiosRecord->Size =3D Size / SIZE_1KB; + SmbiosRecord->Size |=3D SIZE_GRANULARITY_BITMASK; + } else if (Size >=3D EXTENDED_SIZE_THRESHOLD) { + SmbiosRecord->Size =3D 0x7FFF; + SmbiosRecord->ExtendedSize =3D (Size / SIZE_1MB); + } else { + SmbiosRecord->Size =3D (Size / SIZE_1MB); + } +} + +STATIC +VOID +UpdateSmbiosType17Speed ( + IN UINT32 Speed, + OUT SMBIOS_TABLE_TYPE17 *SmbiosRecord + ) +{ + if (Speed > -EXTENDED_SPEED_THRESHOLD) { + SmbiosRecord->Speed =3D EXTENDED_SPEED_THRESHOLD; + SmbiosRecord->ExtendedSpeed =3D Speed; + } else { + SmbiosRecord->Speed =3D Speed; + } +} + +STATIC +VOID +UpdateSmbiosType17Rank ( + IN UINT8 Rank, + OUT SMBIOS_TABLE_TYPE17 *SmbiosRecord + ) +{ + if (Rank > RANK_MASK) { + SmbiosRecord->Attributes =3D 0; + } else { + SmbiosRecord->Attributes |=3D (Rank & RANK_MASK); + } +} + +/** Construct SMBIOS Type17 Table describing memory devices. + + If this function allocates any resources then they must be freed + in the FreeXXXXTableResources function. + + @param [in] This Pointer to the SMBIOS table generator. + @param [in] SmbiosTableInfo Pointer to the SMBIOS table information. + @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol interface. + @param [out] Table Pointer to the SMBIOS table. + + @retval EFI_SUCCESS Table generated successfully. + @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration + Manager is less than the Object size for + the requested object. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND Could not find information. + @retval EFI_OUT_OF_RESOURCES Could not allocate memory. + @retval EFI_UNSUPPORTED Unsupported configuration. +**/ +STATIC +EFI_STATUS +BuildSmbiosType17TableEx ( + IN CONST SMBIOS_TABLE_GENERATOR *This, + IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryPro= tocol, + IN CM_STD_OBJ_SMBIOS_TABLE_INFO *CONST SmbiosTableInfo, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, + OUT SMBIOS_STRUCTURE ***Table, + OUT CM_OBJECT_TOKEN **CmObjectToken, + OUT UINTN *CONST TableCount + ) +{ + EFI_STATUS Status; + UINT32 NumMemDevices; + SMBIOS_STRUCTURE **TableList; + CM_OBJECT_TOKEN *CmObjectList; + CM_SMBIOS_MEMORY_DEVICE_INFO *MemoryDevicesInfo; + UINTN Index; + UINT8 SerialNumRef; + UINT8 AssetTagRef; + UINT8 DeviceLocatorRef; + UINT8 BankLocatorRef; + UINT8 FirmwareVersionRef; + CHAR8 *OptionalStrings; + SMBIOS_TABLE_TYPE17 *SmbiosRecord; + UINTN SmbiosRecordSize; + STRING_TABLE StrTable; + + ASSERT (This !=3D NULL); + ASSERT (SmbiosTableInfo !=3D NULL); + ASSERT (CfgMgrProtocol !=3D NULL); + ASSERT (Table !=3D NULL); + ASSERT (TableCount !=3D NULL); + ASSERT (SmbiosTableInfo->TableGeneratorId =3D=3D This->GeneratorID); + + if ((This =3D=3D NULL) || (SmbiosTableInfo =3D=3D NULL) || (CfgMgrProtoc= ol =3D=3D NULL) || + (Table =3D=3D NULL) || (TableCount =3D=3D NULL) || + (SmbiosTableInfo->TableGeneratorId !=3D This->GeneratorID)) + { + DEBUG ((DEBUG_ERROR, "%a:Invalid Paramater\n ", __FUNCTION__)); + return EFI_INVALID_PARAMETER; + } + + *Table =3D NULL; + Status =3D GetESmbiosObjMemoryDeviceInfo ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &MemoryDevicesInfo, + &NumMemDevices + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "Failed to get Memory Devices CM Object %r\n", + Status + )); + return Status; + } + + TableList =3D (SMBIOS_STRUCTURE **)AllocateZeroPool (sizeof (SMBIOS_STRU= CTURE *) * NumMemDevices); + if (TableList =3D=3D NULL) { + DEBUG (( + DEBUG_ERROR, + "%a:Failed to alloc memory for %u devices table\n", + __FUNCTION__, + NumMemDevices + )); + Status =3D EFI_OUT_OF_RESOURCES; + goto exit; + } + + CmObjectList =3D (CM_OBJECT_TOKEN *)AllocateZeroPool (sizeof (CM_OBJECT_= TOKEN *) * NumMemDevices); + if (CmObjectList =3D=3D NULL) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed to alloc memory for %u CM Objects\n", + __FUNCTION__, + NumMemDevices + )); + Status =3D EFI_OUT_OF_RESOURCES; + goto exit; + } + + for (Index =3D 0; Index < NumMemDevices; Index++) { + StringTableInitialize (&StrTable, SMBIOS_TYPE17_MAX_STRINGS); + + SerialNumRef =3D 0; + AssetTagRef =3D 0; + DeviceLocatorRef =3D 0; + BankLocatorRef =3D 0; + FirmwareVersionRef =3D 0; + + if (MemoryDevicesInfo[Index].DeviceLocator !=3D NULL) { + Status =3D StringTableAddString ( + &StrTable, + MemoryDevicesInfo[Index].DeviceLocator, + &DeviceLocatorRef + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to add DeviceLocator String %r \n", S= tatus)); + } + } + + if (MemoryDevicesInfo[Index].BankLocator !=3D NULL) { + Status =3D StringTableAddString ( + &StrTable, + MemoryDevicesInfo[Index].BankLocator, + &BankLocatorRef + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to BankLocator String %r \n", Status)= ); + } + } + + if (MemoryDevicesInfo[Index].SerialNum !=3D NULL) { + Status =3D StringTableAddString ( + &StrTable, + MemoryDevicesInfo[Index].SerialNum, + &SerialNumRef + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to add SerialNum String %r \n", Statu= s)); + } + } + + if (MemoryDevicesInfo[Index].AssetTag !=3D NULL) { + Status =3D StringTableAddString ( + &StrTable, + MemoryDevicesInfo[Index].AssetTag, + &AssetTagRef + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to add Asset Tag String %r \n", Statu= s)); + } + } + + if (MemoryDevicesInfo[Index].FirmwareVersion !=3D NULL) { + Status =3D StringTableAddString ( + &StrTable, + MemoryDevicesInfo[Index].FirmwareVersion, + &FirmwareVersionRef + ); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "Failed to add Asset Tag String %r \n", Statu= s)); + } + } + + SmbiosRecordSize =3D sizeof (SMBIOS_TABLE_TYPE17) + + StringTableGetStringSetSize (&StrTable); + SmbiosRecord =3D (SMBIOS_TABLE_TYPE17 *)AllocateZeroPool (SmbiosRecord= Size); + if (SmbiosRecord =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto exit; + } + + UpdateSmbiosType17Size (MemoryDevicesInfo[Index].Size, SmbiosRecord); + UpdateSmbiosType17Speed (MemoryDevicesInfo[Index].Speed, SmbiosRecord); + UpdateSmbiosType17Rank (MemoryDevicesInfo[Index].Rank, SmbiosRecord); + + SmbiosRecord->DeviceSet =3D MemoryDevicesInfo[Index].Device= Set; + SmbiosRecord->ModuleManufacturerID =3D + MemoryDevicesInfo[Index].ModuleManufacturerId; + SmbiosRecord->ModuleProductID =3D + MemoryDevicesInfo[Index].ModuleProductId; + SmbiosRecord->DataWidth =3D MemoryDevicesInfo[Index].DataWidth; + SmbiosRecord->TotalWidth =3D MemoryDevicesInfo[Index].TotalWidth; + SmbiosRecord->MemoryType =3D MemoryDevicesInfo[Index].DeviceType; + SmbiosRecord->FormFactor =3D MemoryDevicesInfo[Index].FormFactor; + SmbiosRecord->MemoryTechnology =3D MemoryDevicesInfo[Index].DeviceTech= nology; + // Is there a reference to a Physical Array Device. + if (MemoryDevicesInfo[Index].PhysicalArrayToken !=3D CM_NULL_TOKEN) { + AddPhysArrHandle ( + TableFactoryProtocol, + MemoryDevicesInfo[Index].PhysicalArrayToken, + SmbiosRecord + ); + } + + SmbiosRecord->DeviceLocator =3D DeviceLocatorRef; + SmbiosRecord->BankLocator =3D BankLocatorRef; + SmbiosRecord->AssetTag =3D AssetTagRef; + SmbiosRecord->SerialNumber =3D SerialNumRef; + SmbiosRecord->FirmwareVersion =3D FirmwareVersionRef; + OptionalStrings =3D (CHAR8 *)(SmbiosRecord + 1); + // publish the string set + StringTablePublishStringSet ( + &StrTable, + OptionalStrings, + (SmbiosRecordSize - sizeof (SMBIOS_TABLE_TYPE17)) + ); + // setup the header + SmbiosRecord->Hdr.Type =3D EFI_SMBIOS_TYPE_MEMORY_DEVICE; + SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE17); + TableList[Index] =3D (SMBIOS_STRUCTURE *)SmbiosRecord; + CmObjectList[Index] =3D MemoryDevicesInfo[Index].MemoryDeviceInfo= Token; + StringTableFree (&StrTable); + } + + *Table =3D TableList; + *CmObjectToken =3D CmObjectList; + *TableCount =3D NumMemDevices; +exit: + // free string table + return Status; +} + +/** The interface for the SMBIOS Type17 Table Generator. +*/ +STATIC +CONST +SMBIOS_TABLE_GENERATOR SmbiosType17Generator =3D { + // Generator ID + CREATE_STD_SMBIOS_TABLE_GEN_ID (EStdSmbiosTableIdType17), + // Generator Description + L"SMBIOS.TYPE17.GENERATOR", + // SMBIOS Table Type + EFI_SMBIOS_TYPE_MEMORY_DEVICE, + NULL, + NULL, + // Build table function Extended. + BuildSmbiosType17TableEx, + // Free function Extended. + FreeSmbiosType17TableEx +}; + +/** Register the Generator with the SMBIOS Table Factory. + + @param [in] ImageHandle The handle to the image. + @param [in] SystemTable Pointer to the System Table. + + @retval EFI_SUCCESS The Generator is registered. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_ALREADY_STARTED The Generator for the Table ID + is already registered. +**/ +EFI_STATUS +EFIAPI +SmbiosType17LibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status =3D RegisterSmbiosTableGenerator (&SmbiosType17Generator); + DEBUG (( + DEBUG_INFO, + "SMBIOS Type 17: Register Generator. Status =3D %r\n", + Status + )); + ASSERT_EFI_ERROR (Status); + + return Status; +} + +/** Deregister the Generator from the SMBIOS Table Factory. + + @param [in] ImageHandle The handle to the image. + @param [in] SystemTable Pointer to the System Table. + + @retval EFI_SUCCESS The Generator is deregistered. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND The Generator is not registered. +**/ +EFI_STATUS +EFIAPI +SmbiosType17LibDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status =3D DeregisterSmbiosTableGenerator (&SmbiosType17Generator); + DEBUG (( + DEBUG_INFO, + "SMBIOS Type17: Deregister Generator. Status =3D %r\n", + Status + )); + ASSERT_EFI_ERROR (Status); + return Status; +} diff --git a/DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Li= b.inf b/DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Lib.inf new file mode 100644 index 0000000000..e5067f3000 --- /dev/null +++ b/DynamicTablesPkg/Library/Smbios/SmbiosType17Lib/SmbiosType17Lib.inf @@ -0,0 +1,36 @@ +## @file +# SMBIOS Type17 Table Generator +# +# Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserve= d. +# Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D SmbiosType17LibArm + FILE_GUID =3D 1f063bac-f8f1-4e08-8ffd-9aae52c75497 + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D DXE_DRIVER + LIBRARY_CLASS =3D NULL|DXE_DRIVER + CONSTRUCTOR =3D SmbiosType17LibConstructor + DESTRUCTOR =3D SmbiosType17LibDestructor + +[Sources] + SmbiosType17Generator.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + EmbeddedPkg/EmbeddedPkg.dec + ArmPlatformPkg/ArmPlatformPkg.dec + DynamicTablesPkg/DynamicTablesPkg.dec + +[Protocols] + gEfiSmbiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED + +[LibraryClasses] + BaseLib + DebugLib + SmbiosStringTableLib --=20 2.17.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 (#107256): https://edk2.groups.io/g/devel/message/107256 Mute This Topic: https://groups.io/mt/100361560/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat May 18 07:48:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+107259+1787277+3901457@groups.io; arc=fail (BodyHash is different from the expected one) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 169032832662492.36993768279899; Tue, 25 Jul 2023 16:38:46 -0700 (PDT) Return-Path: DKIM-Signature: a=rsa-sha256; bh=I9pDsqOTTN92ARjgh3wHLMMSpDSaEg25VtOwW4A/9w8=; c=relaxed/simple; d=groups.io; h=X-Received:X-Received:ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:X-Received:X-Received:X-MS-Exchange-Authentication-Results:Received-SPF:X-Received:X-Received:X-Received:X-Received:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:X-NVConfidentiality:MIME-Version:X-NV-OnPremToCloud:X-EOPAttributedMessage:X-MS-PublicTrafficType:X-MS-TrafficTypeDiagnostic:X-MS-Office365-Filtering-Correlation-Id:X-MS-Exchange-SenderADCheck:X-MS-Exchange-AntiSpam-Relay:X-Microsoft-Antispam-Message-Info:X-OriginatorOrg:X-MS-Exchange-CrossTenant-OriginalArrivalTime:X-MS-Exchange-CrossTenant-Network-Message-Id:X-MS-Exchange-CrossTenant-Id:X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp:X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs:X-MS-Exchange-CrossTenant-FromEntityHeader:X-MS-Exchange-Transport-CrossTenantHeadersStamped:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:X-Gm-Message-State:Content-Type; s=20140610; t=1690328326; v=1; b=PPB3suWDFycn96ksMbtNl1TG+ZptyysjT0HY/4x8dMAk1O+1FX/OFPDmv1Gb8YE4hHWjZlsV Ok1pN6N7gH2au85d67psVwF+rVcFqKsU/YrNPB+gMxo0h+VI6/Gb8XRG1naFMV/mUf4qd4aSdMn 3RUOroNyG3WA8W+r4tZ9dr4E= X-Received: by 127.0.0.2 with SMTP id 7Pq2YY1788612x603t3EcF8N; Tue, 25 Jul 2023 16:38:46 -0700 X-Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.107.92.49]) by mx.groups.io with SMTP id smtpd.web11.111.1690328325633186739 for ; Tue, 25 Jul 2023 16:38:45 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SaQEppTf0veQZtVpZVtw6mB5D6SLO+Zso/7q3ZpNc6B4mf/4BaS4LN36WObUuOlv1BLuLy4Y+E6qo2NHmi20FZPSdSiOGuqm9B4O22cJiSvLBfhWCp77phKPbgGXa1OJiEXpZv9QTuFYdsMaktj+DQ9T1soFuuQpBuIRly8vjNczg3p8in9bV6VsG9RK4I1KZNm+PY/+AGmY7+frGprQXgn5NAmvMmD+hWUT9huLwVynHvhjeQL2HS55GVddXux7DXopkXF0LfF4XPd0FKHPStak9C7Y3Q5YI3So24WGJhJrRu4dypC4qcaExOY90SD+kBON4gNwPTR2AhzAXxmHtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=QLiVkqgCXu9vjtFluhxO5VcSSxqVNzgZW4XPrhTL97g=; b=P+MYHxWi1hOnlcixkTj38rKpHQXdtELVTMf37n7vZ9HaPJbJQFhEJjgEIFiwZnGaH8dsVTbVt3WbC2a/5pPOvqGZwWLfz7C6XodFIAY4G9NNo3oLGfGMRSxsH06NOBnAL2q+rYm32dKMgJMEl9N5tnqyF16o711LGC8aBuyWD6TsaGg4C33QXWhj50EvX97GwADHL3WfSt9G+MkKExiDV0oE5reQzwnUr9sIV4karEcTg22pR0MbdB5h6hQoThr45GHsr3niegT4FqsuRwio2ODU83W8iXYiGD32yt/YHg7rBB0uk6A+4WwnpqMHvgzWsgBKzpOuVVfxWdQywgywUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=edk2.groups.io smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none X-Received: from MW4P222CA0019.NAMP222.PROD.OUTLOOK.COM (2603:10b6:303:114::24) by IA1PR12MB6483.namprd12.prod.outlook.com (2603:10b6:208:3a8::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6609.32; Tue, 25 Jul 2023 23:38:41 +0000 X-Received: from CO1NAM11FT011.eop-nam11.prod.protection.outlook.com (2603:10b6:303:114:cafe::9f) by MW4P222CA0019.outlook.office365.com (2603:10b6:303:114::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.29 via Frontend Transport; Tue, 25 Jul 2023 23:38:41 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+107259+1787277+3901457@groups.io; helo=mail02.groups.io; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C X-Received: from mail.nvidia.com (216.228.117.161) by CO1NAM11FT011.mail.protection.outlook.com (10.13.175.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6631.29 via Frontend Transport; Tue, 25 Jul 2023 23:38:41 +0000 X-Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 25 Jul 2023 16:38:25 -0700 X-Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 25 Jul 2023 16:38:25 -0700 X-Received: from build-gmahadevan-20230109T020417557.nvidia.com (10.127.8.12) by mail.nvidia.com (10.129.68.8) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Tue, 25 Jul 2023 16:38:24 -0700 From: "Girish Mahadevan via groups.io" To: , CC: , , , , , Subject: [edk2-devel] [PATCH v3 5/5] DynamicTablesPkg: Smbios Physical Memory Array (Type 16) Date: Tue, 25 Jul 2023 23:38:05 +0000 Message-ID: <20230725233805.646668-6-gmahadevan@nvidia.com> In-Reply-To: <20230725233805.646668-1-gmahadevan@nvidia.com> References: <20230725233805.646668-1-gmahadevan@nvidia.com> X-NVConfidentiality: public MIME-Version: 1.0 X-NV-OnPremToCloud: ExternallySecured X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT011:EE_|IA1PR12MB6483:EE_ X-MS-Office365-Filtering-Correlation-Id: 41b90e01-81e4-434b-e5d3-08db8d684710 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: jYWrXX8WMOrp4KOCrdZRy/UfQUS491IdlL+kosD/5ggkAx9uUAtTh1SZXYjhmMAq4DwSynrIE8Zp+QJ11VN+M08k2dUZzMEWviBAT0Zw6NVEFq00x2N7Kub4WyXcpo3mFOaaPKH17u7/97mwMaQzsTxzhl3Cim35wlM0xGVHIO4xlV2Avcch1CypDzz4JE3+1NIpoOFZwP6XMqiOtw6TpxOXHhEh7XfE8Xe2u/0y30q4cxzetPY7lsv+uaE6NzpS03ZoEWTnUf0Z/S/5phcpbde5gocTklMAqKXsEJg1yIRkXy4wz4eEA8VLZmbNblahMPJNPqmBz0qLBbaX814946mwebsC8psRbw9BG4MVU+VXfxCcL4Xk40kcO1G61vBNnpSGH20cZEcgswGIZdn+FhjxUgXs9ulhEG3xlMIMzQgewX0MY2UKteqrQtA35VtkR9JPmL5rcdZrhCHiPtcWktIXQ1BT/DdZ2K0jm1ke6lWMRTG29HuaVDPQrtIqR/e2HS460IBH0a97OKqddtWfISUZC8iNejfLo8S8gFWI/DoRBohxPu/GrYu4gEOmX0dn062aFLV26bmLKlantsfw3sr3VpBYuYT19Xqni6g3N+XgdyvnTa/IJXyWjQlZLanNCUfM8+Gqu0K6kmx4g/zt3xYgpt/m008FkbaRHZv99N1U7Ud27eRjcDgKnlhz7sHWN0xlMcXu+MFe2y5qPal3EVbWy4XeNHqEyFnP5IGdZSPrdelb6TOhFZ84yy+uRRKU X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jul 2023 23:38:41.0055 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 41b90e01-81e4-434b-e5d3-08db8d684710 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.161];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT011.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6483 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 Reply-To: devel@edk2.groups.io,gmahadevan@nvidia.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: oWJbxtgKqQSQP8vSzvUSDF2Mx1787277AA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1690328327437100001 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add the Generator library for SMBIOS Table Type 16 - Physical Memory Array. Signed-off-by: Girish Mahadevan Reviewed-by: Jeff Brasen Reviewed-by: Nick Ramirez --- .../SmbiosTableBuilder.c | 3 - .../Include/SmbiosNameSpaceObjects.h | 19 + .../SmbiosType16Lib/SmbiosType16Generator.c | 361 ++++++++++++++++++ .../SmbiosType16Lib/SmbiosType16Lib.inf | 35 ++ 4 files changed, 415 insertions(+), 3 deletions(-) create mode 100644 DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosT= ype16Generator.c create mode 100644 DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosT= ype16Lib.inf diff --git a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableBui= lder.c b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableBuilder= .c index bfddaac3aa..5feafcac66 100644 --- a/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableBuilder.c +++ b/DynamicTablesPkg/Drivers/DynamicTableManagerDxe/SmbiosTableBuilder.c @@ -312,7 +312,6 @@ exit_handler: } } =20 - DEBUG ((DEBUG_ERROR, "%a: Returning %r\n", __FUNCTION__, Status)); return Status; } =20 @@ -432,7 +431,6 @@ BuildAndInstallSmbiosTable ( )); } =20 - DEBUG ((DEBUG_ERROR, "%a: Returning %r\n", __FUNCTION__, Status)); return Status; } =20 @@ -516,7 +514,6 @@ ProcessSmbiosTables ( )); } =20 - DEBUG ((DEBUG_ERROR, "%a: Returning %r\n", __FUNCTION__, Status)); return Status; } =20 diff --git a/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h b/DynamicTab= lesPkg/Include/SmbiosNameSpaceObjects.h index e44d703fac..760b082021 100644 --- a/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h +++ b/DynamicTablesPkg/Include/SmbiosNameSpaceObjects.h @@ -107,6 +107,25 @@ typedef struct { SMBIOS_TABLE_GENERATOR_ID GeneratorId; } CONTAINED_CM_OBJECTS; =20 +/** A structure that describes the Physical Memory Array. + + SMBIOS Specification v3.6.0 Type 16 + + ID: ESmbiosObjPhysicalMemoryArray +**/ +typedef struct CmSmbiosPhysicalMemoryArray { + UINT8 Use; + UINT8 Location; + UINT16 MemoryErrorCorrection; + UINT16 MemoryErrorInformationHandle; + UINT16 NumberOfMemoryDevices; + UINT8 MemoryErrorCorrectionType; + UINT64 Size; + UINT8 NumMemDevices; + CM_OBJECT_TOKEN MemoryErrInfoToken; + CM_OBJECT_TOKEN PhysMemArrayToken; +} CM_SMBIOS_PHYSICAL_MEMORY_ARRAY; + #pragma pack() =20 #endif // SMBIOS_NAMESPACE_OBJECTS_H_ diff --git a/DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Ge= nerator.c b/DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Gen= erator.c new file mode 100644 index 0000000000..dad7588ed5 --- /dev/null +++ b/DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Generator= .c @@ -0,0 +1,361 @@ +/** @file + SMBIOS Type16 Table Generator. + + Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. + Copyright (c) 2020 - 2021, 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 + +/** This macro expands to a function that retrieves the Memory Device + information from the Configuration Manager. +*/ +GET_OBJECT_LIST ( + EObjNameSpaceSmbios, + ESmbiosObjPhysicalMemoryArray, + CM_SMBIOS_PHYSICAL_MEMORY_ARRAY + ) + +#define EXTENDED_SIZE_THRESHOLD (SIZE_2TB) + +/** + * Free any resources allocated when installing SMBIOS Type16 table. + * + * @param [in] This Pointer to the SMBIOS table generator. + * @param [in] TableFactoryProtocol Pointer to the SMBIOS Table Factory + Protocol interface. + + * @param [in] SmbiosTableInfo Pointer to the SMBIOS table informati= on. + * @param [in] CfgMgrProtocol Pointer to the Configuration Manager + Protocol interface. + * @param [in] Table Pointer to the SMBIOS table. + * @param [in] CmObjectToken Pointer to the CM ObjectToken Array. + * @param [in] TableCount Number of SMBIOS tables. + + * @retval EFI_SUCCESS Table generated successfully. + * @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration + Manager is less than the Object size for + the requested object. + * @retval EFI_INVALID_PARAMETER A parameter is invalid. + * @retval EFI_NOT_FOUND Could not find information. + * @retval EFI_OUT_OF_RESOURCES Could not allocate memory. + * @retval EFI_UNSUPPORTED Unsupported configuration. +**/ +STATIC +EFI_STATUS +FreeSmbiosType16TableEx ( + IN CONST SMBIOS_TABLE_GENERATOR *CONST This, + IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFa= ctoryProtocol, + IN CONST CM_STD_OBJ_SMBIOS_TABLE_INFO *CONST SmbiosT= ableInfo, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrP= rotocol, + IN SMBIOS_STRUCTURE ***CONST Table, + IN CM_OBJECT_TOKEN **CmObj= ectToken, + IN CONST UINTN TableCo= unt + ) +{ + UINTN Index; + SMBIOS_STRUCTURE **TableList; + + TableList =3D *Table; + for (Index =3D 0; Index < TableCount; Index++) { + if (TableList[Index] !=3D NULL) { + FreePool (TableList[Index]); + } + } + + if (*CmObjectToken !=3D NULL) { + FreePool (*CmObjectToken); + } + + if (TableList !=3D NULL) { + FreePool (TableList); + } + + return EFI_SUCCESS; +} + +/** + * Update the Size encoding for Type 16. + * + * @param [in] SizeBytes Size of the Memory device. + * @param [out] SmbiosRecord SMBIOS record to update. +**/ +STATIC +VOID +UpdateSmbiosType16Size ( + IN UINT64 SizeBytes, + IN OUT SMBIOS_TABLE_TYPE16 *SmbiosRecord + ) +{ + UINT64 SizeKb =3D SizeBytes / SIZE_1KB; + + if (SizeBytes < EXTENDED_SIZE_THRESHOLD) { + SmbiosRecord->MaximumCapacity =3D SizeKb; + } else { + SmbiosRecord->MaximumCapacity =3D 0x80000000; + SmbiosRecord->ExtendedMaximumCapacity =3D SizeKb; + } +} + +/** + * Add the SMBIOS table handle reference to the Error Tables. + * + * @param [in] TableFactoryProtocol Pointer to the SMBIOS Table Fac= tory. + * @param [in] CmObjToken CM Token to lookup.. + * @param [out] SmbiosRecord SMBIOS record to update. +**/ +STATIC +VOID +AddMemErrDeviceHandle ( + IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryPro= tocol, + IN CM_OBJECT_TOKEN CmObjToken, + OUT SMBIOS_TABLE_TYPE16 *SmbiosRecord + ) +{ + EFI_SMBIOS_HANDLE Handle; + SMBIOS_HANDLE_MAP *HandleMap; + + HandleMap =3D TableFactoryProtocol->GetSmbiosHandle (CmObjToken); + if (HandleMap =3D=3D NULL) { + DEBUG ((DEBUG_ERROR, "%a:Failed to get SMBIOS Handle\n", __FUNCTION__)= ); + Handle =3D 0xFFFF; + } else { + Handle =3D HandleMap->SmbiosTblHandle; + } + + SmbiosRecord->MemoryErrorInformationHandle =3D Handle; +} + +/** Construct SMBIOS Type16 Table describing memory devices. + + If this function allocates any resources then they must be freed + in the FreeXXXXTableResources function. + + * @param [in] This Pointer to the SMBIOS table generator. + * @param [in] TableFactoryProtocol Pointer to the SMBIOS Table Factory + * Protocol interface. + * @param [in] SmbiosTableInfo Pointer to the SMBIOS table informati= on. + * @param [in] CfgMgrProtocol Pointer to the Configuration Manager + * Protocol interface. + * @param [out] Table Pointer to the SMBIOS table. + * @param [out] CmObjectToken Pointer to the CM Object Token Array. + * @param [out] TableCount Number of tables installed. + + * @retval EFI_SUCCESS Table generated successfully. + * @retval EFI_BAD_BUFFER_SIZE The size returned by the Configuration + * Manager is less than the Object size for + * the requested object. + * @retval EFI_INVALID_PARAMETER A parameter is invalid. + * @retval EFI_NOT_FOUND Could not find information. + * @retval EFI_OUT_OF_RESOURCES Could not allocate memory. + * @retval EFI_UNSUPPORTED Unsupported configuration. +**/ +STATIC +EFI_STATUS +BuildSmbiosType16TableEx ( + IN CONST SMBIOS_TABLE_GENERATOR *This, + IN CONST EDKII_DYNAMIC_TABLE_FACTORY_PROTOCOL *CONST TableFactoryPro= tocol, + IN CM_STD_OBJ_SMBIOS_TABLE_INFO *CONST SmbiosTableInfo, + IN CONST EDKII_CONFIGURATION_MANAGER_PROTOCOL *CONST CfgMgrProtocol, + OUT SMBIOS_STRUCTURE ***Table, + OUT CM_OBJECT_TOKEN **CmObjectToken, + OUT UINTN *CONST TableCount + ) +{ + EFI_STATUS Status; + SMBIOS_STRUCTURE **TableList; + SMBIOS_TABLE_TYPE16 *SmbiosRecord; + CM_OBJECT_TOKEN *CmObjectList; + CM_SMBIOS_PHYSICAL_MEMORY_ARRAY *PhysMemoryArray; + UINT32 NumObj; + UINTN Index; + + ASSERT (This !=3D NULL); + ASSERT (SmbiosTableInfo !=3D NULL); + ASSERT (CfgMgrProtocol !=3D NULL); + ASSERT (Table !=3D NULL); + ASSERT (TableCount !=3D NULL); + ASSERT (SmbiosTableInfo->TableGeneratorId =3D=3D This->GeneratorID); + + if ((This =3D=3D NULL) || (SmbiosTableInfo =3D=3D NULL) || (CfgMgrProtoc= ol =3D=3D NULL) || + (Table =3D=3D NULL) || (TableCount =3D=3D NULL) || + (SmbiosTableInfo->TableGeneratorId !=3D This->GeneratorID)) + { + DEBUG ((DEBUG_ERROR, "%a:Invalid Paramater\n ", __FUNCTION__)); + return EFI_INVALID_PARAMETER; + } + + *Table =3D NULL; + Status =3D GetESmbiosObjPhysicalMemoryArray ( + CfgMgrProtocol, + CM_NULL_TOKEN, + &PhysMemoryArray, + &NumObj + ); + if (EFI_ERROR (Status)) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed to get Memory Devices CM Object %r\n", + __FUNCTION__, + Status + )); + return Status; + } + + TableList =3D (SMBIOS_STRUCTURE **)AllocateZeroPool (sizeof (SMBIOS_STRU= CTURE *) * NumObj); + if (TableList =3D=3D NULL) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed to alloc memory for %u devices table\n", + __FUNCTION__, + NumObj + )); + Status =3D EFI_OUT_OF_RESOURCES; + goto exitBuildSmbiosType16Table; + } + + CmObjectList =3D (CM_OBJECT_TOKEN *)AllocateZeroPool (sizeof (CM_OBJECT_= TOKEN *) * NumObj); + if (CmObjectList =3D=3D NULL) { + DEBUG (( + DEBUG_ERROR, + "%a: Failed to alloc memory for %u CM Objects.\n", + __FUNCTION__, + NumObj + )); + Status =3D EFI_OUT_OF_RESOURCES; + goto exitBuildSmbiosType16Table; + } + + for (Index =3D 0; Index < NumObj; Index++) { + /** + * Per Spec each structure is terminated by a double-NULL if there are= no + * strings. + */ + SmbiosRecord =3D (SMBIOS_TABLE_TYPE16 *)AllocateZeroPool (sizeof (SMBI= OS_TABLE_TYPE16) + 1 + 1); + if (SmbiosRecord =3D=3D NULL) { + Status =3D EFI_OUT_OF_RESOURCES; + goto exitBuildSmbiosType16Table; + } + + UpdateSmbiosType16Size (PhysMemoryArray->Size, SmbiosRecord); + SmbiosRecord->Location =3D PhysMemoryArray[Index].Locatio= n; + SmbiosRecord->Use =3D PhysMemoryArray[Index].Use; + SmbiosRecord->MemoryErrorCorrection =3D PhysMemoryArray[Index].MemoryE= rrorCorrectionType; + SmbiosRecord->NumberOfMemoryDevices =3D PhysMemoryArray->NumMemDevices; + if (PhysMemoryArray[Index].MemoryErrInfoToken !=3D CM_NULL_TOKEN) { + AddMemErrDeviceHandle ( + TableFactoryProtocol, + PhysMemoryArray[Index].MemoryErrInfoToken, + SmbiosRecord + ); + } else { + SmbiosRecord->MemoryErrorInformationHandle =3D 0xFFFF; + } + + // Setup the header + SmbiosRecord->Hdr.Type =3D EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY; + SmbiosRecord->Hdr.Length =3D sizeof (SMBIOS_TABLE_TYPE16); + + TableList[Index] =3D (SMBIOS_STRUCTURE *)SmbiosRecord; + CmObjectList[Index] =3D PhysMemoryArray[Index].PhysMemArrayToken; + } + + *Table =3D TableList; + *CmObjectToken =3D CmObjectList; + *TableCount =3D NumObj; +exitBuildSmbiosType16Table: + return Status; +} + +/** The interface for the SMBIOS Type16 Table Generator. +*/ +STATIC +CONST +SMBIOS_TABLE_GENERATOR SmbiosType16Generator =3D { + // Generator ID + CREATE_STD_SMBIOS_TABLE_GEN_ID (EStdSmbiosTableIdType16), + // Generator Description + L"SMBIOS.TYPE16.GENERATOR", + // SMBIOS Table Type + EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY, + NULL, + NULL, + // Build table function. + BuildSmbiosType16TableEx, + // Free function. + FreeSmbiosType16TableEx, +}; + +/** Register the Generator with the SMBIOS Table Factory. + + @param [in] ImageHandle The handle to the image. + @param [in] SystemTable Pointer to the System Table. + + @retval EFI_SUCCESS The Generator is registered. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_ALREADY_STARTED The Generator for the Table ID + is already registered. +**/ +EFI_STATUS +EFIAPI +SmbiosType16LibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status =3D RegisterSmbiosTableGenerator (&SmbiosType16Generator); + DEBUG (( + DEBUG_INFO, + "SMBIOS Type 16: Register Generator. Status =3D %r\n", + Status + )); + ASSERT_EFI_ERROR (Status); + + return Status; +} + +/** Deregister the Generator from the SMBIOS Table Factory. + + @param [in] ImageHandle The handle to the image. + @param [in] SystemTable Pointer to the System Table. + + @retval EFI_SUCCESS The Generator is deregistered. + @retval EFI_INVALID_PARAMETER A parameter is invalid. + @retval EFI_NOT_FOUND The Generator is not registered. +**/ +EFI_STATUS +EFIAPI +SmbiosType16LibDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + + Status =3D DeregisterSmbiosTableGenerator (&SmbiosType16Generator); + DEBUG (( + DEBUG_INFO, + "SMBIOS Type16: Deregister Generator. Status =3D %r\n", + Status + )); + ASSERT_EFI_ERROR (Status); + return Status; +} diff --git a/DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Li= b.inf b/DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Lib.inf new file mode 100644 index 0000000000..5bb40db21c --- /dev/null +++ b/DynamicTablesPkg/Library/Smbios/SmbiosType16Lib/SmbiosType16Lib.inf @@ -0,0 +1,35 @@ +## @file +# SMBIOS Type17 Table Generator +# +# Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserve= d. +# Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +## + +[Defines] + INF_VERSION =3D 0x0001001B + BASE_NAME =3D SmbiosType16LibArm + FILE_GUID =3D a256956a-de0b-4aa7-8eac-5ce13bbfbb1f + VERSION_STRING =3D 1.0 + MODULE_TYPE =3D DXE_DRIVER + LIBRARY_CLASS =3D NULL|DXE_DRIVER + CONSTRUCTOR =3D SmbiosType16LibConstructor + DESTRUCTOR =3D SmbiosType16LibDestructor + +[Sources] + SmbiosType16Generator.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + EmbeddedPkg/EmbeddedPkg.dec + ArmPlatformPkg/ArmPlatformPkg.dec + DynamicTablesPkg/DynamicTablesPkg.dec + +[Protocols] + gEfiSmbiosProtocolGuid # PROTOCOL ALWAYS_CONSUMED + +[LibraryClasses] + BaseLib + DebugLib --=20 2.17.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 (#107259): https://edk2.groups.io/g/devel/message/107259 Mute This Topic: https://groups.io/mt/100361564/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-