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 8FCC474003D for ; Thu, 8 Feb 2024 18:29:55 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=zYHAPd/QnKs6T2sp7ySMRuzwZJm79Cjg58S76I52PWI=; 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; s=20140610; t=1707416994; v=1; b=I8do6NBkIbBgU12kw+sTwpvWYQe3g+hLslkPYal0Wrt2+rJYMPytRDNGLdZjnK0t8t4Cz6M7 VQh+cJh1jz/ceetXWTkmIsKC0mGE64DyywdJBUVBC+90wZw94lsRX1HDqYiSCVG4g5TxO0vQNF7 oM0ngn+aiOL0KqMIXYApAVgg= X-Received: by 127.0.0.2 with SMTP id 3MzEYY7687511x4whQh6UQ1M; Thu, 08 Feb 2024 10:29:54 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.10]) by mx.groups.io with SMTP id smtpd.web11.2460.1707416993502236085 for ; Thu, 08 Feb 2024 10:29:53 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10978"; a="12655110" X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208,217";a="12655110" X-Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by fmvoesa104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Feb 2024 10:29:53 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,254,1701158400"; d="scan'208,217";a="32796713" X-Received: from fmsmsx602.amr.corp.intel.com ([10.18.126.82]) by fmviesa001.fm.intel.com with ESMTP/TLS/AES256-GCM-SHA384; 08 Feb 2024 10:29:53 -0800 X-Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx602.amr.corp.intel.com (10.18.126.82) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Thu, 8 Feb 2024 10:29:52 -0800 X-Received: from fmsedg602.ED.cps.intel.com (10.1.192.136) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Thu, 8 Feb 2024 10:29:52 -0800 X-Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.101) by edgegateway.intel.com (192.55.55.71) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Thu, 8 Feb 2024 10:29:51 -0800 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JhunXA9zJwImhjRDEYGKO4U6UNS2zEMGXczvrF7iV4Mo8SvqPjNCzjb7L++MWrAeda7uiJ3HRbYvWYVwyIeg1w2wk7gXVMJJgOxMZF6lVB1yDFd+AD6M1z0vJiDaiJuOunyaYXOgMnCyEXdbEORCFKFo+96nia33FMRgXAWkF7hIqR9ZI17Tv5qnBcJl/+6kNHiHS3B8uaSIIbbSwhke9cQj9oSYBWA6COn3grSaaFXjAgt2vdSs5WgROSiLp0QDOzqbGIFvLx2a8uRG3aLDP9HK7Kgw9hQr0D4XbIQwH5/DtHlttYfvKxknxjz9dndctSfDJMFYSacktnEwSrytCA== 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=ZHY1o63UtM+2dFIqlUI9MP9gDVHYKgdnq9FhMjtNMTA=; b=lK52YOnEEhjqK/sHgAPxYbr2Gjk7hbrupEvbKnYzqA31+0lqDDX37BXM7S+qkLivtjBIzI22dCqfDMmNfKO7BuERNs+V+HEMfoYKVffdbq/nQNNCj1FhcKVwtejKxBTHsrLhYx+CP2igSZenu/DXUtUiau99ZE0lWx4A/f/Ejp2d4OgVlL/I+LOltNwLqgKmWYZdAuWf1Q006ZNuEi9FOi/hwfW1/3qclqByGwPuqkaNVBNmdU9Yi6rbKvKwCvoGCVNHmen96uX1q6Ly4xYiV/J+UpplwrRkPvKXYCpSx3RQoOIUysGiJHpuyryn1cmockNoyRiRroMwqBjmyP9Yog== 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 CO6PR11MB5601.namprd11.prod.outlook.com (2603:10b6:303:13d::7) by CO1PR11MB4850.namprd11.prod.outlook.com (2603:10b6:303:9c::7) 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 18:29:44 +0000 X-Received: from CO6PR11MB5601.namprd11.prod.outlook.com ([fe80::a319:b7a0:5b6a:b5ad]) by CO6PR11MB5601.namprd11.prod.outlook.com ([fe80::a319:b7a0:5b6a:b5ad%3]) with mapi id 15.20.7249.037; Thu, 8 Feb 2024 18:29:42 +0000 From: "Clark-williams, Zachary" To: "Chiu, Chasel" , "devel@edk2.groups.io" , "Desimone, Nathaniel L" CC: Liming Gao , "Dong, Eric" Subject: Re: [edk2-devel] [PATCH] MinPlatformPkg/PhatAcpiLib: adding Phat library Thread-Topic: [PATCH] MinPlatformPkg/PhatAcpiLib: adding Phat library Thread-Index: AQHaWVSyGNmg/ptGZ0e/MKEwNgLdq7D/y0IAgAD6qZA= Date: Thu, 8 Feb 2024 18:29:42 +0000 Message-ID: References: <20240206233142.5752-1-zachary.clark-williams@intel.com> In-Reply-To: Accept-Language: en-US X-Mentions: nathaniel.l.desimone@intel.com X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: CO6PR11MB5601:EE_|CO1PR11MB4850:EE_ x-ms-office365-filtering-correlation-id: 4bd6fad7-6c8e-484d-14d2-08dc28d3eaea x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: d+1zuXrtJvJH9XFqosJTuEU/g01ewQnFasp+CNSrcOjO84j2jUllC2KBVMt4la1qTS3dKxCSPLXeyd+x/4gFr0RJyaZkvEJ/u88v9Voj4DHxyOGD0IgMn0qrBq4xLc8CyGQVWkvUMbSoIAfc7rVSf8hqDYippnwsg3Fptw3znYh2GdUe4TM9HBHKJqHTeiLJXtAqSW8EThi4EI2yHaKDGjGFdqDF0PD2CIDSG8fFuyLS1bUjnM4UGwQOhu3azOMVuXJaqixR+xJD5zmPCYURixobqUR4IZNSqiAzgGSBjHriReitHAxZ9pjeFehxAx7gI2G+8XRk2DK8skBwjwHEyXPrPPLLCobwRrz6CiOwSc4ovNsR3FAZTaskJc7GGMu3JbxvH+m6v+cl9blVa8hMaDwclGrELCBlNLCclBrFBKV93Cb6cbW4TletVut1VIt9tWtuSQQ4S9eYAIW5c86wBHgZwnz/v7ru5WezOIb6GCgl0fm9uKnkGRBT9HYS32KTZxaBX5bxPdclV+jrD08dhhymO4YUPxczEWxR1qpS+CwQfNX2ieF1SmvXIv4RkK4kgrcWho6/nx3qCbtt9sQpYhZrf8xcR97kqw0agNYZ7wdUNh410/yvKdwWHffG2bGj x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?Ay54NV0C770UsuxidfiWpOSZjwzC5TCOaV90tJfzBfzR+8y4XqzVbZXBV2X5?= =?us-ascii?Q?sytPehOusKaKGQn741XffWKWmUIFLQFV1xmxNThjUHEtsDkPRZlR1NdvFxln?= =?us-ascii?Q?titISsCArYWImhHxV1m9b3eKKosfG2MTGUpTLfSL4Gpid2hoFlUxteRpH8c0?= =?us-ascii?Q?7RCfOi0bP0TXvrGZe/Ss9YQbwPhgSNQBjr7vQv9ksgt3jJTR8PjEe91ak0f+?= =?us-ascii?Q?mq6NNijpY+WDrEjKTM2MQ8v3cDQaijjKN2VOz1+hag8CHXimJ1VHq65jqGF3?= =?us-ascii?Q?Jxxh5D24HHcLZ0oWXaeoB7mQk8dUhE0AJkFUrv56JBf9u4BT+bGrlTr9qhis?= =?us-ascii?Q?/mlyV4u8kAb8Ap8jXBlByc38QtqSeVZ/ZQyYI6Z4BLHcEwQev5jBmfpx5GvN?= =?us-ascii?Q?cKf74zKbKy09e2bmnN9gyeJ4I55wHNp0GP5LqWKeMhHL5ZiW7CQCpuCXaL0x?= =?us-ascii?Q?CkGswvZNln9FyOO7vcq1UzCtRDyaT/Xu2wa8mNB9DhFtm5bv2MTci/LhLzMM?= =?us-ascii?Q?HczVrDSrnT9x9y5kcHCCMUlRdMn1bK6KJZAjlAX42QX2VCkBH9eDV/lCSrkg?= =?us-ascii?Q?2cagXSUhkQk3fqQnuzFGcQrg/fO2XoEZq/x1W1AOoOn8fo3OnXnXP+y2v8zd?= =?us-ascii?Q?XZvebgvVsghYSXoiEhDapakbJKlCf19KELiuIBuh7EF/Iebu/22di0rIs550?= =?us-ascii?Q?eaNe5rqSpKqsE4UPQ5KrLqWjYCtfQSCwUr6sGm0h5URe16jhzMXrXNEvmeW+?= =?us-ascii?Q?lM5CaaXT6QZsLnuaM0IY5FxbleabyPUAgjD/BZoaaZL15M+nHzbPbXecCBgl?= =?us-ascii?Q?u4WC7fug483T2N7jhgXjAJmX1Bz5dkzmcI2jW5NdBE1xodxghqUoZToJupkZ?= =?us-ascii?Q?z8afn9oUe+hZWKY9f8kZzTYGSiISMv0ruChKWtCNVuQu6tsPJQqh22M/xmEP?= =?us-ascii?Q?yYx0lwta33mmI/YyWrZLCVrvRSa6T9OizT6FK2smVwy/E7q49wvLH4UD5E0K?= =?us-ascii?Q?n/AdHKGYpRRzaIqz6M/9RQFbslgUle1e6QPQiYHjpIZPANmDJDXqrgiDh1lE?= =?us-ascii?Q?qvdnHgCjgmmyk5/51mmo3mvQQaz3xT41323Kd3fm9eORCPuBm8xO46K4IvCm?= =?us-ascii?Q?CPrbeX+E/Y3g6+2ueQvkunhvOadwtdP6fvNDLd+jpJy509ifvhAtqxfOU5QI?= =?us-ascii?Q?vHMwz7wYUysH+HXJCGA8TuZc5Z9u2v/RFUIQokNT/SM5vOYc5Qdhl3ytdEJm?= =?us-ascii?Q?i363Y/7kCAdW+1Vn2jIAvLeEtntYD700BcQVyvv8FyPA4VaU/Ca+XvO4ewjs?= =?us-ascii?Q?onGLAVv8Rj6+YGLoHa0q9dpObFdyMiPLby5vtQ3xJ7SNzsATTNLP+1erpBwJ?= =?us-ascii?Q?Iwl4B4IP25pKyAqY6VfsDbn1fa9vZQiLG91+bm5hRzptjA4xjStbwjTAUspM?= =?us-ascii?Q?ffD8Jq3ge7JDWcM8xe/nzgFF9YpMB3bdh2UkK0lDIopMm3gXtmAg9aZv/EJ5?= =?us-ascii?Q?Vuv4xBxMbWLPhx+5onBBMxuXGc2hnbKeeUPonWtNDW0hwWTsjWoYFVR+j2CB?= =?us-ascii?Q?HDshhLs5TS0N7tesL+b+ErYWqYlfDCiPu5RqPbaHGt82mUiMfDG/xJ7J/ajO?= =?us-ascii?Q?sA=3D=3D?= MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CO6PR11MB5601.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4bd6fad7-6c8e-484d-14d2-08dc28d3eaea X-MS-Exchange-CrossTenant-originalarrivaltime: 08 Feb 2024 18:29:42.4080 (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: ACubWvLTFj7UHSrx+tB1JwpjaeCmRYoNJ2ctbeYhVq6kNq+C4RVhVBl0CL5UXov3q1tHB1oia0Qg38AVY8u4jQcSnaGPoMog0o0QcbQ+qHmt2fVr0Lw38rIH6OUEHzC+ X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO1PR11MB4850 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,zachary.clark-williams@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: rVhnL4X5h2NuutK6ps8thEs5x7686176AA= Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_CO6PR11MB5601978BF8FC6D98E0BF6455C9442CO6PR11MB5601namp_" X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=I8do6NBk; 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; arc=reject ("signature check failed: fail, {[1] = sig:microsoft.com:reject}") --_000_CO6PR11MB5601978BF8FC6D98E0BF6455C9442CO6PR11MB5601namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Thank you Chasel, I've updated the GUID to all capitals to match. @Desimone, Nathaniel L could you rev= iew the patch as well, I would like to get this in by Friday if possible. Thank you, Zack -----Original Message----- From: Chiu, Chasel Sent: Wednesday, February 7, 2024 7:29 PM To: Clark-williams, Zachary ; devel@edk2.= groups.io Cc: Desimone, Nathaniel L ; Liming Gao ; Dong, Eric Subject: RE: [PATCH] MinPlatformPkg/PhatAcpiLib: adding Phat library 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, > Chasel >; Desimone, N= athaniel L > >; = Liming Gao > >; Dong, Eric <= eric.dong@intel.com> > Subject: [PATCH] MinPlatformPkg/PhatAcpiLib: adding Phat library > > From: Zachary clark-Williams > > > Adding a Platform Health Assessment Table (PHAT) ACPI library for > general feature interface with table. MemoryHealthInsights, FSPv and > Chasmfalls all use this table and will migrate to utilize the library for= accessing and appending the PHAT. > > 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 > > diff --git > a/Platform/Intel/MinPlatformPkg/Acpi/Library/PhatAcpiLib/DxePhatAcpiLi > b.c > b/Platform/Intel/MinPlatformPkg/Acpi/Library/PhatAcpiLib/DxePhatAcpiLi > b.c > new file mode 100644 > index 000000000..925f8484b > --- /dev/null > +++ b/Platform/Intel/MinPlatformPkg/Acpi/Library/PhatAcpiLib/DxePhatAc > +++ pi > +++ 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, > + (VOID > + **) &mAcpiTableProtocol); if (EFI_ERROR (Status)) { > + DEBUG ((DEBUG_INFO, "[%a] Locate gEfiAcpiTableProtocolGuid failed > + with > 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/DxePhatAcpiLi > b.inf > b/Platform/Intel/MinPlatformPkg/Acpi/Library/PhatAcpiLib/DxePhatAcpiLi > b.inf > new file mode 100644 > index 000000000..18374b265 > --- /dev/null > +++ b/Platform/Intel/MinPlatformPkg/Acpi/Library/PhatAcpiLib/DxePhatAc > +++ pi > +++ 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 > > + PhatAcpiLib|Include/Library/PhatAcpiLib.h > + > [PcdsFixedAtBuild, PcdsPatchableInModule] > > > 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 @@ > > PciSegmentInfoLib|MinPlatformPkg/Pci/Library/PciSegmentInfoLibSimple/P > PciSegmentInfoLib|ciSeg > mentInfoLibSimple.inf > > PlatformBootManagerLib|MinPlatformPkg/Bds/Library/DxePlatformBootManag > PlatformBootManagerLib|er > Lib/DxePlatformBootManagerLib.inf > > AslUpdateLib|MinPlatformPkg/Acpi/Library/DxeAslUpdateLib/DxeAslUpdateL > AslUpdateLib|ib.in > f > + > + PhatAcpiLib|MinPlatformPkg/Acpi/Library/DxePhatAcpiLib/DxePhatAcpiLib. > + inf > > # > # Misc > @@ -217,5 +218,7 @@ > MinPlatformPkg/Library/BaseLargeVariableLib/BaseLargeVariableReadLib.i= nf > > MinPlatformPkg/Library/BaseLargeVariableLib/BaseLargeVariableWriteLib. > inf > > + 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 (#115272): https://edk2.groups.io/g/devel/message/115272 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- --_000_CO6PR11MB5601978BF8FC6D98E0BF6455C9442CO6PR11MB5601namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Thank you Chasel, I've updated the GUID to all ca= pitals to match.

 

@Desimone, Nathaniel L could you review the patch as well, I would like to get this in by Friday if possible.

 

Thank you,

Zack

 

-----Original Message-----
From: Chiu, Chasel <chasel.chiu@intel.com>
Sent: Wednesday, February 7, 2024 7:29 PM
To: Clark-williams, Zachary <zachary.clark-williams@intel.com>; devel= @edk2.groups.io
Cc: Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Liming Ga= o <gaoliming@byosoft.com.cn>; Dong, Eric <eric.dong@intel.com><= br> Subject: RE: [PATCH] MinPlatformPkg/PhatAcpiLib: adding Phat library

 

 

Hi Zack,

 

Change looks good, just one minor thing that we m= ay correct DxePhatAcpiLib.inf FILE_GUID format during merging this patch.

 

Reviewed-by: Chasel Chiu <= chasel.chiu@intel.com>

 

Thanks,

Chasel

 

 

> -----Original Message-----

> From: Clark-williams, Zachary <zachary.clark-williams@intel.com>

> Sent: Tuesday, February 6, 2024 3:32 PM=

> To: = devel@edk2.groups.io<= /span>

> Cc: Clark-williams, Zachary <zachary.clark-williams@intel.com>; Chiu,

> Chasel <chasel.chiu@i= ntel.com>; Desimone, Nathaniel L

> <nathaniel.l= .desimone@intel.com>; Liming Gao

> <gaoliming@byosoft= .com.cn>; Dong, Eric <eric.dong@intel.co= m>

> Subject: [PATCH] MinPlatformPkg/PhatAcpiLib:= adding Phat library

>

> From: Zachary clark-Williams <zachary.clark-williams@intel.com>

>

> Adding a Platform Health Assessment Table (P= HAT) ACPI library for

> general feature interface with table. Memory= HealthInsights, FSPv and

> Chasmfalls all use this table and will migra= te to utilize the library for accessing and appending the PHAT.<= /p>

>

> Change-Id: I715fa543e81403ee8e159c2c2afd8b87= 09234a11

> Hsd-es-id: 14019467886

> Cc: Chasel Chiu <chas= el.chiu@intel.com>

> Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>

> Cc: Liming Gao <ga= oliming@byosoft.com.cn>

> Cc: Eric Dong <eric.don= g@intel.com>

> Signed-off-by: Zachary Clark-Williams <= /o:p>

> <zachary.c= lark-williams@intel.com>

> ---

>  .../Acpi/Library/PhatAcpiLib/DxePhatAc= piLib.c | 292 ++++++++++++++++++

>  .../Library/PhatAcpiLib/DxePhatAcpiLib= .inf    |  45 +++

>  .../Include/Library/PhatAcpiLib.h = ;            | = 40 +++

>  .../Intel/MinPlatformPkg/MinPlatformPk= g.dec   |   2 +

>  .../Intel/MinPlatformPkg/MinPlatformPk= g.dsc   |   3 +

>  5 files changed, 382 insertions(+)

>  create mode 100644

> Platform/Intel/MinPlatformPkg/Acpi/Library/P= hatAcpiLib/DxePhatAcpiLib.

> c

>  create mode 100644

> Platform/Intel/MinPlatformPkg/Acpi/Library/P= hatAcpiLib/DxePhatAcpiLib.

> inf

>  create mode 100644

> Platform/Intel/MinPlatformPkg/Include/Librar= y/PhatAcpiLib.h

>

> diff --git

> a/Platform/Intel/MinPlatformPkg/Acpi/Library= /PhatAcpiLib/DxePhatAcpiLi

> b.c

> b/Platform/Intel/MinPlatformPkg/Acpi/Library= /PhatAcpiLib/DxePhatAcpiLi

> b.c

> new file mode 100644

> index 000000000..925f8484b

> --- /dev/null

> +++ b/Platform/Intel/MinPlatformPkg/Acpi/Lib= rary/PhatAcpiLib/DxePhatAc

> +++ pi

> +++ Lib.c

> @@ -0,0 +1,292 @@

> +/** @file

> +  Dxe Platform Health Assessment Table= Library

> +

> +  Copyright (c) 2024, Intel Corporatio= n. All rights reserved.<BR>

> +

> +  SPDX-License-Identifier: BSD-2-Claus= e-Patent **/

> +

> +#include <Library/PhatAcpiLib.h>=

> +

> +#include <PiDxe.h>

> +#include <Base.h>

> +#include <Library/UefiLib.h>

> +#include <Library/DebugLib.h>

> +#include <Library/BaseMemoryLib.h>

> +#include <Library/MemoryAllocationLib.h&= gt; #include

> +<Library/UefiBootServicesTableLib.h><= o:p>

> +

> +#include <Protocol/AcpiTable.h><= /o:p>

> +#include <Protocol/AcpiSystemDescription= Table.h>

> +

> +GLOBAL_REMOVE_IF_UNREFERENCED EFI_ACPI_TABL= E_PROTOCOL

> +*mAcpiTableProtocol  =3D NULL;

> +

> +/**

> +  Initialize the header of the Platfor= m Health Assessment Table.

> +

> +  @param[out]  Header  =    The header of the ACPI Table.

> +  @param[in]   OemId &n= bsp;    The OEM ID.

> +  @param[in]   OemTableId Th= e OEM table ID for the Phat.

> +**/

> +VOID

> +InitPhatTableHeader (

> +  OUT EFI_ACPI_DESCRIPTION_HEADER = ;  *Header,

> +  IN  UINT8   &nbs= p;            &= nbsp;        *OemId,

> +  IN  UINT64   &nb= sp;            =         *OemTableId

> +  )

> +{

> +  ZeroMem (Header, sizeof (EFI_ACPI_DE= SCRIPTION_HEADER));

> +

> +  Header->Signature =3D<= /p>

> +EFI_ACPI_6_5_PLATFORM_HEALTH_ASSESSMENT_TAB= LE_SIGNATURE;

> +  //

> +  // total length (FVI, Driver Health)= .

> +  //

> +  Header->Length   &= nbsp;      =3D 0;

> +  Header->Revision   = ;     =3D

> EFI_ACPI_6_5_PLATFORM_HEALTH_ASSESSMENT_TABL= E_REVISION;

> +  Header->Checksum   = ;     =3D 0;

> +  CopyMem (Header->OemId, OemId, si= zeof (Header->OemId));  CopyMem

> + (&Header->OemTableId, OemTableId, s= izeof (UINT64));

> +  Header->OemRevision  &n= bsp;  =3D PcdGet32 (PcdAcpiDefaultOemRevision);

> +  Header->CreatorId  &nbs= p;    =3D PcdGet32 (PcdAcpiDefaultCreatorId);

> +  Header->CreatorRevision =3D PcdGe= t32 (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 &nb= sp;            =      *Entry;

> +  EFI_STATUS    &n= bsp;            = ;            &n= bsp;      Status;

> +

> +  Entry =3D NULL;

> +

> +  Status =3D gBS->LocateProtocol (&= amp;gEfiAcpiTableProtocolGuid, NULL,

> + (VOID

> + **) &mAcpiTableProtocol);  if (EF= I_ERROR (Status)) {

> +    DEBUG ((DEBUG_INFO, &quo= t;[%a] Locate gEfiAcpiTableProtocolGuid failed

> + with

> status: [%r].\n", __FUNCTION__, Status)= );

> +    return NULL;<= /p>

> +  }

> +

> +  //

> +  // Find ACPI table RSD_PTR from the = system table.

> +  //

> +  Status =3D EfiGetSystemConfiguration= Table (&gEfiAcpiTableGuid, (VOID

> + **) &Rsdp);  if (EFI_ERROR (Statu= s)) {

> +    Status =3D EfiGetSystemC= onfigurationTable (&gEfiAcpi10TableGuid,

> + (VOID **) &Rsdp);  }

> +

> +  if (EFI_ERROR (Status) || (Rsdp =3D= =3D NULL)) {

> +    DEBUG ((DEBUG_INFO, &quo= t;[%a] Can't find RSD_PTR from system table!

> + \n",

> __FUNCTION__));

> +    return NULL;<= /p>

> +  } else if (Rsdp->Revision >=3D=

> EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER= _REVISION && Rsdp-

> >XsdtAddress !=3D 0) {

> +    Entry =3D (EFI_ACPI_DESC= RIPTION_HEADER *) (UINTN)

> + Rsdp->XsdtAddress; } else if (Rsdp->= RsdtAddress !=3D 0) {

> +    Entry =3D (EFI_ACPI_DESC= RIPTION_HEADER *) (UINTN)

> + Rsdp->RsdtAddress; }

> +

> +  if (Entry =3D=3D NULL) {<= /p>

> +    DEBUG ((DEBUG_INFO, &quo= t;[%a] XsdtAddress and RsdtAddress are NULL!

> + \n",

> __FUNCTION__));

> +    return NULL;<= /p>

> +  }

> +

> +  return Entry;

> +}

> +

> +/**

> +  This function calculates and updates= an UINT8 checksum.

> +

> +  @param[in]  Buffer  &= nbsp;       Pointer to buffer to checksum

> +  @param[in]  Size  &nb= sp;         Number of bytes to chec= ksum

> +**/

> +VOID

> +AcpiPlatformChecksum (

> +  IN UINT8    &nbs= p;   *Buffer,

> +  IN UINTN    &nbs= p;   Size

> +  )

> +{

> +  UINTN ChecksumOffset;

> +

> +  if (Buffer =3D=3D NULL) {=

> +    return;

> +  }

> +

> +  ChecksumOffset =3D OFFSET_OF (EFI_AC= PI_DESCRIPTION_HEADER, Checksum);

> +

> +  // Set checksum to 0 first

> +  Buffer[ChecksumOffset] =3D 0;

> +

> +  // Update checksum value<= /p>

> +  Buffer[ChecksumOffset] =3D Calculate= CheckSum8 (Buffer, Size); }

> +

> +/**

> +  Convert AIP data block to PHAT ACPI = style, and publish it onto

> +  an existing ACPI  PHAT structur= e or initialize and install a new

> +  instance.

> +

> +  @param[in]   InfoBlock&nbs= p;         Point to AIP data block.=

> +  @param[in]   InfoBlockSize=       The size of AIP data.

> +

> +  @retval EFI_SUCCESS   = ;          Success<= /p>

> +  @retval EFI_OUT_OF_RESOURCES &n= bsp;  Out of memory space.

> +  @retval EFI_INVALID_PARAMETER &= nbsp; Either InfoBlock is NULL,

> +       &= nbsp;           &nbs= p;            &= nbsp; TableKey is NULL, or

> +       &= nbsp;           &nbs= p;            &= nbsp; AcpiTableBufferSize and the size

> +       &= nbsp;           &nbs= p;            &= nbsp; field embedded in the ACPI table

> +       &= nbsp;           &nbs= p;            &= nbsp; pointed to by AcpiTableBuffer

> +       &= nbsp;           &nbs= p;            &= nbsp; are not in sync.

> +  @retval EFI_ACCESS_DENIED  = ;     The table signature matches a table already<= /o:p>

> +       &= nbsp;           &nbs= p;            &= nbsp; present in the system and platform policy

> +       &= nbsp;           &nbs= p;            &= nbsp; does not allow duplicate tables of this type.

> +  @retval EFI_NOT_FOUND  &nb= sp;        AcpiEntry is NULL.=

> +**/

> +EFI_STATUS

> +EFIAPI

> +InstallPhatTable (

> +  IN  VOID    = ;    *InfoBlock,

> +  IN  UINTN   &nbs= p;   InfoBlockSize

> +  )

> +{

> +  EFI_STATUS    &n= bsp;            = ;  Status;

> +  EFI_ACPI_DESCRIPTION_HEADER  *A= cpiEntry;

> +  EFI_ACPI_SDT_PROTOCOL  &nb= sp;     *AcpiSdtProtocol;

> +  EFI_ACPI_DESCRIPTION_HEADER  *P= hatHeader;

> +  UINT8     &= nbsp;           &nbs= p;      *PhatTable;

> +  UINT32     =             &nb= sp;     PhatLen;

> +  UINTN     &= nbsp;           &nbs= p;      TableIndex;

> +  UINT8     &= nbsp;           &nbs= p;      *TableHeader;

> +  EFI_ACPI_TABLE_VERSION  &n= bsp;    TableVersion;

> +  UINTN     &= nbsp;           &nbs= p;      TableKey;

> +

> +  if ((InfoBlock =3D=3D NULL) || (Info= BlockSize =3D=3D 0)) {

> +    DEBUG ((DEBUG_ERROR, &qu= ot;[%a] Table Data Invalid!\n", __FUNCTION__));

> +    return EFI_INVALID_PARAM= ETER;

> +  }

> +

> +  Status     = =3D EFI_SUCCESS;

> +  TableIndex  =3D 0;

> +  TableKey    =3D 0;

> +  TableHeader =3D NULL;

> +

> +  AcpiEntry =3D SearchAcpiTablePointer= ();  if (AcpiEntry =3D=3D NULL) {

> +    DEBUG((DEBUG_ERROR, &quo= t;[%a] ACPI table pointer not found\n",

> __FUNCTION__));

> +    return EFI_NOT_FOUND;

> +  }

> +

> +  //

> +  // Locate the EFI_ACPI_SDT_PROTOCOL.=

> +  //

> +  Status =3D gBS->LocateProtocol (<= o:p>

> +       &= nbsp;          &gEfiAcpiSd= tProtocolGuid,

> +       &= nbsp;          NULL,

> +       &= nbsp;          (VOID **)&A= cpiSdtProtocol

> +       &= nbsp;          );

> +  if (EFI_ERROR (Status)) {=

> +    DEBUG ((DEBUG_ERROR, &qu= ot;[%a] Failed to locate AcpiSdt with status:

> + %r\n",

> __FUNCTION__, Status));

> +    return Status;

> +  }

> +

> +  // Search ACPI table for PHAT

> +  while (!EFI_ERROR (Status)) {

> +    Status =3D AcpiSdtProtoc= ol->GetAcpiTable (

> +       &= nbsp;           &nbs= p;             = TableIndex,

> +       &= nbsp;           &nbs= p;             = (EFI_ACPI_SDT_HEADER **)&TableHeader,

> +       &= nbsp;           &nbs= p;             = &TableVersion,

> +       &= nbsp;           &nbs= p;             = &TableKey

> +       &= nbsp;           &nbs= p;             = );

> +    if (!EFI_ERROR (Status))= {

> +      TableIndex++= ;

> +

> +      if (((EFI_AC= PI_SDT_HEADER *) TableHeader)->Signature =3D=3D

> +       &= nbsp;  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 (UIN= T8 *) AllocateZeroPool (PhatLen);

> +    if (PhatTable =3D=3D NUL= L) {

> +      DEBUG ((DEBU= G_ERROR, "[%a] Failed to allocated new PHAT pool

> + with.\n",

> __FUNCTION__));

> +      return EFI_O= UT_OF_RESOURCES;

> +    }

> +

> +    // Copy original table c= ontent to the new PHAT table pool

> +    CopyMem (PhatTable, Tabl= eHeader, PhatHeader->Length);

> +

> +    // Append InfoBlock in t= he end of the origin PHAT

> +    CopyMem (PhatTable + Pha= tHeader->Length, InfoBlock,

> + InfoBlockSize);

> +

> +    // Update the PHAT head = pointer.

> +    PhatHeader =3D (EFI_ACPI= _DESCRIPTION_HEADER *) PhatTable;

> +

> +    // Update the length fie= ld to found table plus appended new data

> +    PhatHeader->Length = =3D PhatLen;

> +

> +    // Uninstall the origin = PHAT from the ACPI table.

> +    Status =3D mAcpiTablePro= tocol->UninstallAcpiTable (

> +       &= nbsp;           &nbs= p;            &= nbsp;   mAcpiTableProtocol,

> +       &= nbsp;           &nbs= p;            &= nbsp;   TableKey

> +       &= nbsp;           &nbs= p;            &= nbsp;   );

> +    ASSERT_EFI_ERROR (Status= );

> +

> +    if (EFI_ERROR (Status)) = {

> +      DEBUG ((DEBU= G_ERROR, "[%a] Failed to uninstall existing PHAT

> + ACPI table

> with status: %r\n", __FUNCTION__, Statu= s));

> +      FreePool (Ph= atTable);

> +      return Statu= s;

> +    }

> +  } else {

> +    //

> +    // PHAT ACPI table does = not exist, install new one

> +    //

> +    PhatTable =3D AllocateZe= roPool (InfoBlockSize + sizeof

> (EFI_ACPI_DESCRIPTION_HEADER));

> +    if (PhatTable =3D=3D NUL= L) {

> +      DEBUG ((DEBU= G_ERROR, "[%a] Failed to allocate new PHAT

> + pool.\n",

> __FUNCTION__));

> +      return EFI_O= UT_OF_RESOURCES;

> +    }

> +    PhatHeader =3D (EFI_ACPI= _DESCRIPTION_HEADER *) PhatTable;

> +

> +    // Initialize the header= of the Platform Health Assessment Table.

> +    InitPhatTableHeader (Pha= tHeader, AcpiEntry->OemId,

> + &AcpiEntry->OemTableId);=

> +

> +    PhatHeader->Length = =3D sizeof (EFI_ACPI_DESCRIPTION_HEADER) +

> + (UINT32)InfoBlockSize;

> +

> +    // Connect a telemetry d= ata to ACPI table header.

> +    CopyMem (PhatTable + siz= eof (EFI_ACPI_DESCRIPTION_HEADER),

> + InfoBlock, InfoBlockSize);  }

> +

> +  // Update table checksum<= /p>

> +  AcpiPlatformChecksum ((UINT8 *) Phat= Table,

> + ((EFI_ACPI_DESCRIPTION_HEADER *) PhatHeade= r)->Length);

> +

> +  // Install or update the Phat table.=

> +  Status =3D mAcpiTableProtocol->In= stallAcpiTable (

> +       &= nbsp;           &nbs= p;             = mAcpiTableProtocol,

> +       &= nbsp;           &nbs= p;             = PhatTable,

> +       &= nbsp;           &nbs= p;             = PhatHeader->Length,

> +       &= nbsp;           &nbs= p;             = &TableKey

> +       &= nbsp;           &nbs= p;             = );

> +  if (EFI_ERROR (Status)) {=

> +    DEBUG ((DEBUG_INFO, &quo= t;[%a] Install Phat AcpiTable failed, Status =3D

> + [%r]. \n", __FUNCTION__, Status));&nb= sp; }

> +

> +  if (PhatTable !=3D NULL) {

> +    FreePool (PhatTable);

> +  }

> +

> +  DEBUG ((DEBUG_INFO, "[%a] Insta= ll PHAT table, status: %r \n",

> +__FUNCTION__, Status));

> +  return Status;

> +}

> diff --git

> a/Platform/Intel/MinPlatformPkg/Acpi/Library= /PhatAcpiLib/DxePhatAcpiLi

> b.inf

> b/Platform/Intel/MinPlatformPkg/Acpi/Library= /PhatAcpiLib/DxePhatAcpiLi

> b.inf

> new file mode 100644

> index 000000000..18374b265

> --- /dev/null

> +++ b/Platform/Intel/MinPlatformPkg/Acpi/Lib= rary/PhatAcpiLib/DxePhatAc

> +++ pi

> +++ Lib.inf

> @@ -0,0 +1,45 @@

> +## @file

> +#  Dxe Platform Health Assessment Tabl= e Library # #  Copyright (c)

> +2024, Intel Corporation. All rights reserve= d.<BR> # #

> +SPDX-License-Identifier: BSD-2-Clause-Paten= t ###

> +

> +[Defines]

> +  INF_VERSION    =3D 0x= 00010017

> +  BASE_NAME    &nb= sp; =3D DxePhatAcpiLib

> +  FILE_GUID    &nb= sp; =3D 3932-bb84-adfb-4c7a-bc59-e33fc7ad6e20

> +  VERSION_STRING =3D 1.0

> +  MODULE_TYPE    =3D DX= E_DRIVER

> +  LIBRARY_CLASS  =3D DxePhatAcpiL= ib|DXE_DRIVER

> +

> +[Sources]

> +  DxePhatAcpiLib.c

> +

> +[Packages]

> +  MdePkg/MdePkg.dec

> +  MdeModulePkg/MdeModulePkg.dec

> +  MinPlatformPkg/MinPlatformPkg.dec

> +

> +[LibraryClasses]

> +  DebugLib

> +  BaseMemoryLib

> +  MemoryAllocationLib

> +  UefiBootServicesTableLib<= /p>

> +

> +[Guids]

> +  gEfiAcpiTableGuid   &= nbsp;       ## CONSUMES

> +  gEfiAcpi10TableGuid   = ;      ## CONSUMES

> +

> +[Protocols]

> +  gEfiAcpiTableProtocolGuid  = ; ## CONSUMES

> +  gEfiAcpiSdtProtocolGuid  &= nbsp;  ## CONSUMES

> +

> +[Pcd]

> +  gEfiMdeModulePkgTokenSpaceGuid.PcdAc= piDefaultCreatorId        ##<= /p>

> CONSUMES

> +  gEfiMdeModulePkgTokenSpaceGuid.PcdAc= piDefaultCreatorRevision  ##

> CONSUMES

> +  gEfiMdeModulePkgTokenSpaceGuid.PcdAc= piDefaultOemRevision      ##

> CONSUMES

> +

> +[Depex]

> +  TRUE

> diff --git

> a/Platform/Intel/MinPlatformPkg/Include/Libr= ary/PhatAcpiLib.h

> b/Platform/Intel/MinPlatformPkg/Include/Libr= ary/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 Lib= rary Definitions

> +

> +  Copyright (c) 2024, Intel Corporatio= n. All rights reserved.<BR>

> +

> +  SPDX-License-Identifier: BSD-2-Claus= e-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 i= nitialize and install a new

> +  instance.

> +

> +  @param[in]   InfoBlock&nbs= p;         Point to AIP data block.=

> +  @param[in]   InfoBlockSize=       The size of AIP data.

> +

> +  @retval EFI_SUCCESS   = ;          Success<= /p>

> +  @retval EFI_OUT_OF_RESOURCES &n= bsp;  Out of memory space.

> +  @retval EFI_INVALID_PARAMETER &= nbsp; Either InfoBlock is NULL,

> +       &= nbsp;           &nbs= p;            &= nbsp; TableKey is NULL, or

> +       &= nbsp;           &nbs= p;            &= nbsp; AcpiTableBufferSize and the size

> +       &= nbsp;           &nbs= p;            &= nbsp; field embedded in the ACPI table

> +       &= nbsp;           &nbs= p;            &= nbsp; pointed to by AcpiTableBuffer

> +       &= nbsp;           &nbs= p;            &= nbsp; are not in sync.

> +  @retval EFI_ACCESS_DENIED  = ;     The table signature matches a table already<= /o:p>

> +       &= nbsp;           &nbs= p;            &= nbsp; present in the system and platform policy

> +       &= nbsp;           &nbs= p;            &= nbsp; does not allow duplicate tables of this type.

> +  @retval EFI_NOT_FOUND  &nb= sp;        AcpiEntry is NULL.=

> +**/

> +EFI_STATUS

> +EFIAPI

> +InstallPhatTable (

> +  IN  VOID    = ;    *InfoBlock,

> +  IN  UINTN   &nbs= p;   InfoBlockSize

> +  );

> +

> +#endif  // _PHAT_ACPI_LIB_H_

> \ No newline at end of file

> diff --git a/Platform/Intel/MinPlatformPkg/M= inPlatformPkg.dec

> b/Platform/Intel/MinPlatformPkg/MinPlatformP= kg.dec

> index 74e1bce87..09312d329 100644=

> --- a/Platform/Intel/MinPlatformPkg/MinPlatf= ormPkg.dec

> +++ b/Platform/Intel/MinPlatformPkg/MinPlatf= ormPkg.dec

> @@ -88,6 +88,8 @@

>    LargeVariableReadLib|Inclu= de/Library/LargeVariableReadLib.h

>    LargeVariableWriteLib|Incl= ude/Library/LargeVariableWriteLib.h

>

> +  PhatAcpiLib|Include/Library/PhatAcpi= Lib.h

> +

>  [PcdsFixedAtBuild, PcdsPatchableInModu= le]

>

>

> gMinPlatformPkgTokenSpaceGuid.PcdFspMaxUpdSi= ze|0x00000000|UINT32|0x80

> 000000

> diff --git a/Platform/Intel/MinPlatformPkg/M= inPlatformPkg.dsc

> b/Platform/Intel/MinPlatformPkg/MinPlatformP= kg.dsc

> index ee5d21112..4b295babf 100644=

> --- a/Platform/Intel/MinPlatformPkg/MinPlatf= ormPkg.dsc

> +++ b/Platform/Intel/MinPlatformPkg/MinPlatf= ormPkg.dsc

> @@ -64,6 +64,7 @@

>

> PciSegmentInfoLib|MinPlatformPkg/Pci/Library= /PciSegmentInfoLibSimple/P

> PciSegmentInfoLib|ciSeg

> mentInfoLibSimple.inf

>

> PlatformBootManagerLib|MinPlatformPkg/Bds/Li= brary/DxePlatformBootManag

> PlatformBootManagerLib|er

> Lib/DxePlatformBootManagerLib.inf=

>

> AslUpdateLib|MinPlatformPkg/Acpi/Library/Dxe= AslUpdateLib/DxeAslUpdateL

> AslUpdateLib|ib.in

> f

> +

> + PhatAcpiLib|MinPlatformPkg/Acpi/Library/Dx= ePhatAcpiLib/DxePhatAcpiLib.

> + inf

>

>    #

>    # Misc

> @@ -217,5 +218,7 @@

>    MinPlatformPkg/Library/Bas= eLargeVariableLib/BaseLargeVariableReadLib.inf

>   

> MinPlatformPkg/Library/BaseLargeVariableLib/= BaseLargeVariableWriteLib.

> inf

>

> +  MinPlatformPkg/Acpi/Library/DxePhatA= cpiLib/DxePhatAcpiLib.inf

> +

>  [BuildOptions]

>    *_*_*_CC_FLAGS =3D -D DISA= BLE_NEW_DEPRECATED_INTERFACES

> --

> 2.39.1.windows.1

 

_._,_._,_

Groups.io Links:

=20 You receive all messages sent to this group. =20 =20

View/Reply Online (#115272) | =20 | Mute= This Topic | New Topic
Your Subscriptio= n | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_
--_000_CO6PR11MB5601978BF8FC6D98E0BF6455C9442CO6PR11MB5601namp_--