From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 5FA5CAC0999 for ; Thu, 8 Feb 2024 03:29:10 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=VPmex1GwEyd+uwkZNyLnhwbVln1/82VwaLSopfe0Lig=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1707362948; v=1; b=rLpAbahzClV/L6mgmJZrxH/czIRJifN35h7Ofed3UF90EjTj3Z9+8jOC0euBViU+EoTaw8xm stRM5YR/Rsx8vGdLYwAm3szGoOUN/pr4zUQdHn+n+8GQskCU3Pmo5haXCLMmcjjCna+ia2SEQis 5Q65OZkqOYdN0jX+zx51DjVQ= X-Received: by 127.0.0.2 with SMTP id yUfoYY7687511xlWlcYlK96Y; Wed, 07 Feb 2024 19:29:08 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.11]) by mx.groups.io with SMTP id smtpd.web10.10204.1707362947665856255 for ; Wed, 07 Feb 2024 19:29:08 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10977"; a="11713260" X-IronPort-AV: E=Sophos;i="6.05,252,1701158400"; d="scan'208";a="11713260" X-Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by orvoesa103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 07 Feb 2024 19:29:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,252,1701158400"; d="scan'208";a="24785819" X-Received: from orsmsx601.amr.corp.intel.com ([10.22.229.14]) by fmviesa002.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 07 Feb 2024 19:29:06 -0800 X-Received: from orsmsx610.amr.corp.intel.com (10.22.229.23) by ORSMSX601.amr.corp.intel.com (10.22.229.14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Wed, 7 Feb 2024 19:29:05 -0800 X-Received: from orsedg603.ED.cps.intel.com (10.7.248.4) by orsmsx610.amr.corp.intel.com (10.22.229.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Wed, 7 Feb 2024 19:29:05 -0800 X-Received: from NAM12-MW2-obe.outbound.protection.outlook.com (104.47.66.41) by edgegateway.intel.com (134.134.137.100) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 7 Feb 2024 19:29:05 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XJrsiiH6oYpf8NHPl5EjRYpIeVaqg7xaETGBoMYPGYHyPhz6bx6Pea2J8R5Vcyjeo4jhS6xR/fX7aj+PDyqdjSTRklQ49TnTcjlxUE2RRUB4Jh/6ytP65LhR2smIHAXZaDcDPA12w+Fy6ez10wxRknbnII5J1dz8pubnWkytjJ94tuOVYdmPtQ5wlif5jATBlicxGzTyZdpl/nhPBx8wIpbfXSLr7jfbCqZZCLGoxm2cbvZRs5zkDm+bZhYlsy8BIp8Dv6ZmxYiA7PiyZ1HSNPlWQtAvT2ebi3IJn8Ds2oaegKdJt2fAotJkLSjDLvTxKlb+iim65bO5wjhCSytybQ== 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=318ihbXNQXm2Rst1cgqT9hrmS1Op1xyIDlUoHhzmDc0=; b=dJCLQE3xLeSKfHvaU3TnvP4z52SFNbo3vxOTrIOBeX7BGpi3FerY1AOy70ULywHKhLlBq/ITx9l1v/pPuGbKSrUTAdK0SDrrtFyBmjn69I/sqxL0DROhu/R7uPIJf6/DQr0RpIyc5qZOq+zV0geO2c+9bbpd+JWPB/aIO33aw8j2N7eXEBqORC5BQpESn9EOTrQDUPdpJsvTeHSREYQjycglu7s+kasFkmDe5BejQ2pMJ5xQvbP0kee95PXfVzhLnX7YBQHk2qwiXCy+9TJRPBHz0VioC4p6qng4vxIU4Os1iRZs0V+gNp+S2+4tN6pj5cL0FAOz/hbeyEv2kieZvQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none X-Received: from BN9PR11MB5483.namprd11.prod.outlook.com (2603:10b6:408:104::10) by DS0PR11MB7405.namprd11.prod.outlook.com (2603:10b6:8:134::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.36; Thu, 8 Feb 2024 03:29:03 +0000 X-Received: from BN9PR11MB5483.namprd11.prod.outlook.com ([fe80::aced:fdb2:cf39:5641]) by BN9PR11MB5483.namprd11.prod.outlook.com ([fe80::aced:fdb2:cf39:5641%6]) with mapi id 15.20.7249.038; Thu, 8 Feb 2024 03:29:03 +0000 From: "Chiu, Chasel" To: "Clark-williams, Zachary" , "devel@edk2.groups.io" CC: "Desimone, Nathaniel L" , Liming Gao , "Dong, Eric" Subject: Re: [edk2-devel] [PATCH] MinPlatformPkg/PhatAcpiLib: adding Phat library Thread-Topic: [PATCH] MinPlatformPkg/PhatAcpiLib: adding Phat library Thread-Index: AQHaWVSyS/ZYDg3BVkS38YPuGjDk1rD/ylUg Date: Thu, 8 Feb 2024 03:29:02 +0000 Message-ID: References: <20240206233142.5752-1-zachary.clark-williams@intel.com> In-Reply-To: <20240206233142.5752-1-zachary.clark-williams@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BN9PR11MB5483:EE_|DS0PR11MB7405:EE_ x-ms-office365-filtering-correlation-id: ba919bc2-d9f9-49f8-b209-08dc2856189a x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: 7NxnBkmSXbPI0bjLzBQjII95PvZ1ueGq8DUEgnikJamoS8thColGL6SfHCdbIhLa6joT6gWl3Mgs+UArrDpCuGlnBrYKoYIA68KagWv+bePJ/DFFwNcg3j+i+JYqFpr/a6msQihJMMzURANiNUSZdTuKe0Hobdukp2xTu8+IRVt63aXDfNIcCbZPKPsFnXZkrCA/zz/I7SHfO2hwVDGSJ+8QJxr9nlDK17gjuVmuboPd4C6v720sSCb/FKt3waXwDL6UfYcqWlp7GzIFN27xJX3ZFDEyzJ0FHRzvBgO2dpG9ImMwiQ+Z5BXEQ0SIw/2mVRcfy0TXitS3K9DYZTj9/Mzp/w6G9ws2yuw6YKm2ZFfi78SlI+5S1xiqs331bV8omQsRWkMZ2kzHsiFTokZpl4TNdoRFf9Vv5PPRXXcY03TBFP/LEbmPiHspdBRufsUGz2aCncc6iRCs2DHZk2adb6jc3sQNOF9dY2YgOqueKzTOQ4s2mS5oveZBE2BdwRMdW8BsgJyV74pFJfv5EgQo7SnynGsTgmvviaulYKVRbjGWSPuVq5A9XLmKEW121hwLpdM6DQoM9OCazn3NkoDmWhstkh8kps7Dkk/i919MT5w+gzBYaJWRMig0pxAG0KUw x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?C/YDjv3XFaTsxxD3i7nA4BxSR5Od7AL7kfO61TiP5kCGg3JMV0FycMLk3LHj?= =?us-ascii?Q?Qc9cJQ/uRLaRVvDEB12jvZ4dzGOqAkWoNccB+ngpb/8U1an6DeZVAkOZo5mJ?= =?us-ascii?Q?OLjo6HTghaETBVjIqrYLXKu6QBSnjudgcFjFdGiqn/Qz//K6a13zo8y1MxAj?= =?us-ascii?Q?GkOULw/E3FANMcT7D7ureAcJssgskqh2oHb7kdiMiwPOQj3yrDpr+hPFctxH?= =?us-ascii?Q?Mx++9CkljyhG9Lh9ex+E3KbICSZPt6PxEX0emCr6/ZPC1anThgqmwUCL1H2K?= =?us-ascii?Q?4hXft5x2rZDKp5u23TqWp9FF/ntWbQN+tq4YkDA8wNZ4VY7oMwlO08RqMwno?= =?us-ascii?Q?T9J+5+tQiJ/5KhkQJ/cfsV+UiHu3F/CL4t5rTlRaAtVYdnLIiJj73wxOYzkO?= =?us-ascii?Q?m1PaQ9+FihkS4MIumYMIRv/MsZV02A0EnAen1mvW8gt644//Kv/Et0Ywm530?= =?us-ascii?Q?lGB23UwoZcsskZSC7XzHgxWGxP44ykWfCCq9JOK8Otv92ktW9+H8+TEBP4WK?= =?us-ascii?Q?VY0Pi9N9J0KWB3QAcsJGuxQruW2e+gVJmzT/8yAZ7HsuSvMVFeMNVRWTjXpF?= =?us-ascii?Q?VD/YywljMUJB7cJf/FfhHH/luD4O7LNaLYvEBqf9y7+nLcGp5ynRbrH2SrXj?= =?us-ascii?Q?hZwUQNf8PP1TgA9ytnw/oOPGGMCoPHNCd3GMXe2WhXHHUGS+XgKWpXcXV366?= =?us-ascii?Q?HEodSj3oC1UjZv3ljSZE582Qk14GT61q1WFZ4/jtimJer0vLfHJMN2UI2SUs?= =?us-ascii?Q?QhOR4gzd76d6BavhwUSnS5v4+/p5eICAx2stasm8zgXqO5pYCSicqvWvIfG/?= =?us-ascii?Q?j7Wgk1FDMgCUS6xGLPT1K6EfLYCWUCI4AT9nzKsYFWPqYCryVbgiIutb8Spf?= =?us-ascii?Q?oyph3hYt6rhS40ij/SBdyqyKAvUykNrTwZ6LIXVQ6Q+i9zVuqCwzTTrYoWpE?= =?us-ascii?Q?J+9obWSxKMuY8ZRSxe3ohm/BJJt5ISVmY2U1TdmxZjjfWbmjltRybXIWN78c?= =?us-ascii?Q?JKlJGzPccJM73YFDB6vrM2J44X5eOifPOgeu4WvibegrzuR9zCHiQ7SHfaa3?= =?us-ascii?Q?JK2vRidGpxEPWzIq9VgqAj6v1b+MRalbgp7ZHZs/j5/LDcamVan6SorEXd+s?= =?us-ascii?Q?geBEzJjz8D4yTotfLjyeAT3gsLQJxHTEl7aZ0pEXEyilsQl7WPqaizUEC/Vt?= =?us-ascii?Q?0RygQcnUM8zLcpGBSim+RQ+zDYn2z3PGb630K394qR3wfk+hJB9gpf/lCx0h?= =?us-ascii?Q?StB/RoCzawQxlSpY4/kwZEMrpVHUJxv+06K0KqJAL2sKo9GQUFn8HXVl0pcy?= =?us-ascii?Q?OmYGFNzTRe5yGmikTTO4MNhRtJeGEK2CGi5Yh0Xca9muXRnAM8djwCgkjruk?= =?us-ascii?Q?rdLmIVDfZ5vfu0uG4ph2C1UT7JK99NsqhSp7ACYFkcIMMDEf0OYFNwGMPtrD?= =?us-ascii?Q?5oo27o7khJvqOianZ56VIA4AihhjMV1ukwcz/AN2MpVY0S0QyFnCuHDDzYCP?= =?us-ascii?Q?ToBIBRJhbpOjjhzNiLDRCOPk2szr1nfJCM2ur0Vidv0+3ENiA2kgt8OjfO/9?= =?us-ascii?Q?c35KmGoc+Aqt2WliirVpgYugkSpMnmTedWZXl0iZ?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BN9PR11MB5483.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ba919bc2-d9f9-49f8-b209-08dc2856189a X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Feb 2024 03:29:02.4581 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: qRmMn7BwchywRe6mUgnpl/F8PP0M4LoJoCPDdue6L1V+onMI4swGfTLDt87gtMX0WXNUUU1hnUfqEn8VYmiP4Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS0PR11MB7405 X-OriginatorOrg: intel.com 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,chasel.chiu@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: KAfQ0WaqoHd3uG8wzUqO7FY1x7686176AA= Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=rLpAbahz; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}"); dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io Hi Zack, Change looks good, just one minor thing that we may correct DxePhatAcpiLib.= inf FILE_GUID format during merging this patch. Reviewed-by: Chasel Chiu Thanks, Chasel > -----Original Message----- > From: Clark-williams, Zachary > Sent: Tuesday, February 6, 2024 3:32 PM > To: devel@edk2.groups.io > Cc: Clark-williams, Zachary ; Chiu, Cha= sel > ; Desimone, Nathaniel L > ; Liming Gao ; > Dong, Eric > Subject: [PATCH] MinPlatformPkg/PhatAcpiLib: adding Phat library >=20 > From: Zachary clark-Williams >=20 > Adding a Platform Health Assessment Table (PHAT) ACPI library for general= feature > interface with table. MemoryHealthInsights, FSPv and Chasmfalls all use t= his > table and will migrate to utilize the library for accessing and appending= the PHAT. >=20 > Change-Id: I715fa543e81403ee8e159c2c2afd8b8709234a11 > Hsd-es-id: 14019467886 > Cc: Chasel Chiu > Cc: Nate DeSimone > Cc: Liming Gao > Cc: Eric Dong > Signed-off-by: Zachary Clark-Williams > --- > .../Acpi/Library/PhatAcpiLib/DxePhatAcpiLib.c | 292 ++++++++++++++++++ > .../Library/PhatAcpiLib/DxePhatAcpiLib.inf | 45 +++ > .../Include/Library/PhatAcpiLib.h | 40 +++ > .../Intel/MinPlatformPkg/MinPlatformPkg.dec | 2 + > .../Intel/MinPlatformPkg/MinPlatformPkg.dsc | 3 + > 5 files changed, 382 insertions(+) > create mode 100644 > Platform/Intel/MinPlatformPkg/Acpi/Library/PhatAcpiLib/DxePhatAcpiLib.c > create mode 100644 > Platform/Intel/MinPlatformPkg/Acpi/Library/PhatAcpiLib/DxePhatAcpiLib.inf > create mode 100644 > Platform/Intel/MinPlatformPkg/Include/Library/PhatAcpiLib.h >=20 > diff --git > a/Platform/Intel/MinPlatformPkg/Acpi/Library/PhatAcpiLib/DxePhatAcpiLib.c > b/Platform/Intel/MinPlatformPkg/Acpi/Library/PhatAcpiLib/DxePhatAcpiLib.c > new file mode 100644 > index 000000000..925f8484b > --- /dev/null > +++ b/Platform/Intel/MinPlatformPkg/Acpi/Library/PhatAcpiLib/DxePhatAcpi > +++ Lib.c > @@ -0,0 +1,292 @@ > +/** @file > + Dxe Platform Health Assessment Table Library > + > + Copyright (c) 2024, Intel Corporation. All rights reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent **/ > + > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include #include > + > + > +#include > +#include > + > +GLOBAL_REMOVE_IF_UNREFERENCED EFI_ACPI_TABLE_PROTOCOL > +*mAcpiTableProtocol =3D NULL; > + > +/** > + Initialize the header of the Platform Health Assessment Table. > + > + @param[out] Header The header of the ACPI Table. > + @param[in] OemId The OEM ID. > + @param[in] OemTableId The OEM table ID for the Phat. > +**/ > +VOID > +InitPhatTableHeader ( > + OUT EFI_ACPI_DESCRIPTION_HEADER *Header, > + IN UINT8 *OemId, > + IN UINT64 *OemTableId > + ) > +{ > + ZeroMem (Header, sizeof (EFI_ACPI_DESCRIPTION_HEADER)); > + > + Header->Signature =3D > +EFI_ACPI_6_5_PLATFORM_HEALTH_ASSESSMENT_TABLE_SIGNATURE; > + // > + // total length (FVI, Driver Health). > + // > + Header->Length =3D 0; > + Header->Revision =3D > EFI_ACPI_6_5_PLATFORM_HEALTH_ASSESSMENT_TABLE_REVISION; > + Header->Checksum =3D 0; > + CopyMem (Header->OemId, OemId, sizeof (Header->OemId)); > + CopyMem (&Header->OemTableId, OemTableId, sizeof (UINT64)); > + Header->OemRevision =3D PcdGet32 (PcdAcpiDefaultOemRevision); > + Header->CreatorId =3D PcdGet32 (PcdAcpiDefaultCreatorId); > + Header->CreatorRevision =3D PcdGet32 (PcdAcpiDefaultCreatorRevision); = } > + > +/** > + This function scan ACPI table entry point. > + > + @retval ACPI table entry pointer > +**/ > +VOID * > +SearchAcpiTablePointer ( > + VOID > + ) > +{ > + EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp; > + EFI_ACPI_DESCRIPTION_HEADER *Entry; > + EFI_STATUS Status; > + > + Entry =3D NULL; > + > + Status =3D gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOI= D > + **) &mAcpiTableProtocol); if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_INFO, "[%a] Locate gEfiAcpiTableProtocolGuid failed wi= th > status: [%r].\n", __FUNCTION__, Status)); > + return NULL; > + } > + > + // > + // Find ACPI table RSD_PTR from the system table. > + // > + Status =3D EfiGetSystemConfigurationTable (&gEfiAcpiTableGuid, (VOID > + **) &Rsdp); if (EFI_ERROR (Status)) { > + Status =3D EfiGetSystemConfigurationTable (&gEfiAcpi10TableGuid, > + (VOID **) &Rsdp); } > + > + if (EFI_ERROR (Status) || (Rsdp =3D=3D NULL)) { > + DEBUG ((DEBUG_INFO, "[%a] Can't find RSD_PTR from system table! \n", > __FUNCTION__)); > + return NULL; > + } else if (Rsdp->Revision >=3D > EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION && Rsdp- > >XsdtAddress !=3D 0) { > + Entry =3D (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->XsdtAddress; > + } else if (Rsdp->RsdtAddress !=3D 0) { > + Entry =3D (EFI_ACPI_DESCRIPTION_HEADER *) (UINTN) Rsdp->RsdtAddress; > + } > + > + if (Entry =3D=3D NULL) { > + DEBUG ((DEBUG_INFO, "[%a] XsdtAddress and RsdtAddress are NULL! \n", > __FUNCTION__)); > + return NULL; > + } > + > + return Entry; > +} > + > +/** > + This function calculates and updates an UINT8 checksum. > + > + @param[in] Buffer Pointer to buffer to checksum > + @param[in] Size Number of bytes to checksum > +**/ > +VOID > +AcpiPlatformChecksum ( > + IN UINT8 *Buffer, > + IN UINTN Size > + ) > +{ > + UINTN ChecksumOffset; > + > + if (Buffer =3D=3D NULL) { > + return; > + } > + > + ChecksumOffset =3D OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER, Checksum); > + > + // Set checksum to 0 first > + Buffer[ChecksumOffset] =3D 0; > + > + // Update checksum value > + Buffer[ChecksumOffset] =3D CalculateCheckSum8 (Buffer, Size); } > + > +/** > + Convert AIP data block to PHAT ACPI style, and publish it onto > + an existing ACPI PHAT structure or initialize and install a new > + instance. > + > + @param[in] InfoBlock Point to AIP data block. > + @param[in] InfoBlockSize The size of AIP data. > + > + @retval EFI_SUCCESS Success > + @retval EFI_OUT_OF_RESOURCES Out of memory space. > + @retval EFI_INVALID_PARAMETER Either InfoBlock is NULL, > + TableKey is NULL, or > + AcpiTableBufferSize and the size > + field embedded in the ACPI table > + pointed to by AcpiTableBuffer > + are not in sync. > + @retval EFI_ACCESS_DENIED The table signature matches a table al= ready > + present in the system and platform pol= icy > + does not allow duplicate tables of thi= s type. > + @retval EFI_NOT_FOUND AcpiEntry is NULL. > +**/ > +EFI_STATUS > +EFIAPI > +InstallPhatTable ( > + IN VOID *InfoBlock, > + IN UINTN InfoBlockSize > + ) > +{ > + EFI_STATUS Status; > + EFI_ACPI_DESCRIPTION_HEADER *AcpiEntry; > + EFI_ACPI_SDT_PROTOCOL *AcpiSdtProtocol; > + EFI_ACPI_DESCRIPTION_HEADER *PhatHeader; > + UINT8 *PhatTable; > + UINT32 PhatLen; > + UINTN TableIndex; > + UINT8 *TableHeader; > + EFI_ACPI_TABLE_VERSION TableVersion; > + UINTN TableKey; > + > + if ((InfoBlock =3D=3D NULL) || (InfoBlockSize =3D=3D 0)) { > + DEBUG ((DEBUG_ERROR, "[%a] Table Data Invalid!\n", __FUNCTION__)); > + return EFI_INVALID_PARAMETER; > + } > + > + Status =3D EFI_SUCCESS; > + TableIndex =3D 0; > + TableKey =3D 0; > + TableHeader =3D NULL; > + > + AcpiEntry =3D SearchAcpiTablePointer (); if (AcpiEntry =3D=3D NULL) { > + DEBUG((DEBUG_ERROR, "[%a] ACPI table pointer not found\n", > __FUNCTION__)); > + return EFI_NOT_FOUND; > + } > + > + // > + // Locate the EFI_ACPI_SDT_PROTOCOL. > + // > + Status =3D gBS->LocateProtocol ( > + &gEfiAcpiSdtProtocolGuid, > + NULL, > + (VOID **)&AcpiSdtProtocol > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "[%a] Failed to locate AcpiSdt with status: %r\= n", > __FUNCTION__, Status)); > + return Status; > + } > + > + // Search ACPI table for PHAT > + while (!EFI_ERROR (Status)) { > + Status =3D AcpiSdtProtocol->GetAcpiTable ( > + TableIndex, > + (EFI_ACPI_SDT_HEADER **)&TableHeader, > + &TableVersion, > + &TableKey > + ); > + if (!EFI_ERROR (Status)) { > + TableIndex++; > + > + if (((EFI_ACPI_SDT_HEADER *) TableHeader)->Signature =3D=3D > + EFI_ACPI_6_5_PLATFORM_HEALTH_ASSESSMENT_TABLE_SIGNATURE) > + { > + DEBUG ((DEBUG_INFO, "[%a] Existing Phat AcpiTable is found.\n", > __FUNCTION__)); > + break; > + } > + } > + } > + > + if (!EFI_ERROR (Status)) { > + // > + // A PHAT is already in the ACPI table, update existing table and re= -install > + // > + PhatHeader =3D (EFI_ACPI_DESCRIPTION_HEADER *) TableHeader; > + PhatLen =3D PhatHeader->Length + (UINT32) InfoBlockSize; > + PhatTable =3D (UINT8 *) AllocateZeroPool (PhatLen); > + if (PhatTable =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "[%a] Failed to allocated new PHAT pool with.= \n", > __FUNCTION__)); > + return EFI_OUT_OF_RESOURCES; > + } > + > + // Copy original table content to the new PHAT table pool > + CopyMem (PhatTable, TableHeader, PhatHeader->Length); > + > + // Append InfoBlock in the end of the origin PHAT > + CopyMem (PhatTable + PhatHeader->Length, InfoBlock, InfoBlockSize); > + > + // Update the PHAT head pointer. > + PhatHeader =3D (EFI_ACPI_DESCRIPTION_HEADER *) PhatTable; > + > + // Update the length field to found table plus appended new data > + PhatHeader->Length =3D PhatLen; > + > + // Uninstall the origin PHAT from the ACPI table. > + Status =3D mAcpiTableProtocol->UninstallAcpiTable ( > + mAcpiTableProtocol, > + TableKey > + ); > + ASSERT_EFI_ERROR (Status); > + > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_ERROR, "[%a] Failed to uninstall existing PHAT ACPI = table > with status: %r\n", __FUNCTION__, Status)); > + FreePool (PhatTable); > + return Status; > + } > + } else { > + // > + // PHAT ACPI table does not exist, install new one > + // > + PhatTable =3D AllocateZeroPool (InfoBlockSize + sizeof > (EFI_ACPI_DESCRIPTION_HEADER)); > + if (PhatTable =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "[%a] Failed to allocate new PHAT pool.\n", > __FUNCTION__)); > + return EFI_OUT_OF_RESOURCES; > + } > + PhatHeader =3D (EFI_ACPI_DESCRIPTION_HEADER *) PhatTable; > + > + // Initialize the header of the Platform Health Assessment Table. > + InitPhatTableHeader (PhatHeader, AcpiEntry->OemId, > + &AcpiEntry->OemTableId); > + > + PhatHeader->Length =3D sizeof (EFI_ACPI_DESCRIPTION_HEADER) + > + (UINT32)InfoBlockSize; > + > + // Connect a telemetry data to ACPI table header. > + CopyMem (PhatTable + sizeof (EFI_ACPI_DESCRIPTION_HEADER), > + InfoBlock, InfoBlockSize); } > + > + // Update table checksum > + AcpiPlatformChecksum ((UINT8 *) PhatTable, > + ((EFI_ACPI_DESCRIPTION_HEADER *) PhatHeader)->Length); > + > + // Install or update the Phat table. > + Status =3D mAcpiTableProtocol->InstallAcpiTable ( > + mAcpiTableProtocol, > + PhatTable, > + PhatHeader->Length, > + &TableKey > + ); > + if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_INFO, "[%a] Install Phat AcpiTable failed, Status =3D > + [%r]. \n", __FUNCTION__, Status)); } > + > + if (PhatTable !=3D NULL) { > + FreePool (PhatTable); > + } > + > + DEBUG ((DEBUG_INFO, "[%a] Install PHAT table, status: %r \n", > +__FUNCTION__, Status)); > + return Status; > +} > diff --git > a/Platform/Intel/MinPlatformPkg/Acpi/Library/PhatAcpiLib/DxePhatAcpiLib.i= nf > b/Platform/Intel/MinPlatformPkg/Acpi/Library/PhatAcpiLib/DxePhatAcpiLib.i= nf > new file mode 100644 > index 000000000..18374b265 > --- /dev/null > +++ b/Platform/Intel/MinPlatformPkg/Acpi/Library/PhatAcpiLib/DxePhatAcpi > +++ Lib.inf > @@ -0,0 +1,45 @@ > +## @file > +# Dxe Platform Health Assessment Table Library # # Copyright (c) > +2024, Intel Corporation. All rights reserved.
# # > +SPDX-License-Identifier: BSD-2-Clause-Patent ### > + > +[Defines] > + INF_VERSION =3D 0x00010017 > + BASE_NAME =3D DxePhatAcpiLib > + FILE_GUID =3D 3932-bb84-adfb-4c7a-bc59-e33fc7ad6e20 > + VERSION_STRING =3D 1.0 > + MODULE_TYPE =3D DXE_DRIVER > + LIBRARY_CLASS =3D DxePhatAcpiLib|DXE_DRIVER > + > +[Sources] > + DxePhatAcpiLib.c > + > +[Packages] > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + MinPlatformPkg/MinPlatformPkg.dec > + > +[LibraryClasses] > + DebugLib > + BaseMemoryLib > + MemoryAllocationLib > + UefiBootServicesTableLib > + > +[Guids] > + gEfiAcpiTableGuid ## CONSUMES > + gEfiAcpi10TableGuid ## CONSUMES > + > +[Protocols] > + gEfiAcpiTableProtocolGuid ## CONSUMES > + gEfiAcpiSdtProtocolGuid ## CONSUMES > + > +[Pcd] > + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorId ## > CONSUMES > + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultCreatorRevision ## > CONSUMES > + gEfiMdeModulePkgTokenSpaceGuid.PcdAcpiDefaultOemRevision ## > CONSUMES > + > +[Depex] > + TRUE > diff --git a/Platform/Intel/MinPlatformPkg/Include/Library/PhatAcpiLib.h > b/Platform/Intel/MinPlatformPkg/Include/Library/PhatAcpiLib.h > new file mode 100644 > index 000000000..fe4fe5f5b > --- /dev/null > +++ b/Platform/Intel/MinPlatformPkg/Include/Library/PhatAcpiLib.h > @@ -0,0 +1,40 @@ > +/** @file > + Platform Health Assessment Table Library Definitions > + > + Copyright (c) 2024, Intel Corporation. All rights reserved.
> + > + SPDX-License-Identifier: BSD-2-Clause-Patent **/ > + > +#ifndef _PHAT_ACPI_LIB_H_ > +#define _PHAT_ACPI_LIB_H_ > + > +/** > + Convert AIP data block to PHAT ACPI style, and publish it onto > + an existing ACPI PHAT structure or initialize and install a new > + instance. > + > + @param[in] InfoBlock Point to AIP data block. > + @param[in] InfoBlockSize The size of AIP data. > + > + @retval EFI_SUCCESS Success > + @retval EFI_OUT_OF_RESOURCES Out of memory space. > + @retval EFI_INVALID_PARAMETER Either InfoBlock is NULL, > + TableKey is NULL, or > + AcpiTableBufferSize and the size > + field embedded in the ACPI table > + pointed to by AcpiTableBuffer > + are not in sync. > + @retval EFI_ACCESS_DENIED The table signature matches a table al= ready > + present in the system and platform pol= icy > + does not allow duplicate tables of thi= s type. > + @retval EFI_NOT_FOUND AcpiEntry is NULL. > +**/ > +EFI_STATUS > +EFIAPI > +InstallPhatTable ( > + IN VOID *InfoBlock, > + IN UINTN InfoBlockSize > + ); > + > +#endif // _PHAT_ACPI_LIB_H_ > \ No newline at end of file > diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec > b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec > index 74e1bce87..09312d329 100644 > --- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec > +++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dec > @@ -88,6 +88,8 @@ > LargeVariableReadLib|Include/Library/LargeVariableReadLib.h > LargeVariableWriteLib|Include/Library/LargeVariableWriteLib.h >=20 > + PhatAcpiLib|Include/Library/PhatAcpiLib.h > + > [PcdsFixedAtBuild, PcdsPatchableInModule] >=20 >=20 > gMinPlatformPkgTokenSpaceGuid.PcdFspMaxUpdSize|0x00000000|UINT32|0x80 > 000000 > diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc > b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc > index ee5d21112..4b295babf 100644 > --- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc > +++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc > @@ -64,6 +64,7 @@ >=20 > PciSegmentInfoLib|MinPlatformPkg/Pci/Library/PciSegmentInfoLibSimple/PciS= eg > mentInfoLibSimple.inf >=20 > PlatformBootManagerLib|MinPlatformPkg/Bds/Library/DxePlatformBootManager > Lib/DxePlatformBootManagerLib.inf >=20 > AslUpdateLib|MinPlatformPkg/Acpi/Library/DxeAslUpdateLib/DxeAslUpdateLib.= in > f > + > + PhatAcpiLib|MinPlatformPkg/Acpi/Library/DxePhatAcpiLib/DxePhatAcpiLib. > + inf >=20 > # > # Misc > @@ -217,5 +218,7 @@ > MinPlatformPkg/Library/BaseLargeVariableLib/BaseLargeVariableReadLib.i= nf > MinPlatformPkg/Library/BaseLargeVariableLib/BaseLargeVariableWriteLib.= inf >=20 > + MinPlatformPkg/Acpi/Library/DxePhatAcpiLib/DxePhatAcpiLib.inf > + > [BuildOptions] > *_*_*_CC_FLAGS =3D -D DISABLE_NEW_DEPRECATED_INTERFACES > -- > 2.39.1.windows.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 (#115263): https://edk2.groups.io/g/devel/message/115263 Mute This Topic: https://groups.io/mt/104209287/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-