From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail05.groups.io (mail05.groups.io [45.79.224.7]) by spool.mail.gandi.net (Postfix) with ESMTPS id F36E5941410 for ; Wed, 29 May 2024 08:57:16 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=2wNsWp6tifxtGjGL8AEVqq2UTPmp8Pdrqf+R0PNQYJw=; c=relaxed/simple; d=groups.io; h=From:To:CC:Subject:Thread-Topic:Thread-Index:Date:Message-ID:References:In-Reply-To:Accept-Language:msip_labels:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20240206; t=1716973036; v=1; b=hH/2YK1WRdj8e3LqIN6cKKuM9CKJ5xSsNWjPttCc2VnGLcXzYsFPHDu9A+T0rqmaYtA1WX0f pwx6TK9TjbOVGJW9ReaTJnWS+Gyr9+wUzUVh5DvynhkMhni/vfsxROeoCzr1cmop6i9tl6Jf5yB n2VnSPTvxJJOY2AAuXlragB4X5+vAVJYGoC9lez6DKbTsfs9ofLTjcdfxOkq+NjYFQPB/L9MXvk WrOiGHoBicArcKqB7eHgrFSCWOYeQ1pnHeY100oia9kII/Hat+N7j6d+KH86fFRhMD6hMEp+IxC L0iKk/K75ph2J5WewaLeDBktedOavuHQEd9xiJ4AXBbhA== X-Received: by 127.0.0.2 with SMTP id 4ujOYY7687511xwrmckLcyRv; Wed, 29 May 2024 01:57:15 -0700 X-Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.60]) by mx.groups.io with SMTP id smtpd.web11.9201.1716973029903350845 for ; Wed, 29 May 2024 01:57:10 -0700 X-Received: from LV8PR12MB9452.namprd12.prod.outlook.com (2603:10b6:408:200::8) by PH7PR12MB8795.namprd12.prod.outlook.com (2603:10b6:510:275::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7611.30; Wed, 29 May 2024 08:57:07 +0000 X-Received: from LV8PR12MB9452.namprd12.prod.outlook.com ([fe80::9d67:b4b7:7bad:8c08]) by LV8PR12MB9452.namprd12.prod.outlook.com ([fe80::9d67:b4b7:7bad:8c08%5]) with mapi id 15.20.7633.017; Wed, 29 May 2024 08:57:07 +0000 From: "Chang, Abner via groups.io" To: "Attar, AbdulLateef (Abdul Lateef)" , "devel@edk2.groups.io" CC: "Attar, AbdulLateef (Abdul Lateef)" , "Grimes, Paul" Subject: Re: [edk2-devel] [edk2-platforms 3/3] AmdPlatformPkg: Adds SPI smm core platform hook Thread-Topic: [edk2-platforms 3/3] AmdPlatformPkg: Adds SPI smm core platform hook Thread-Index: AQHasQh7kyP+tAmeSkim2MZEhWDbe7Gt6kXA Date: Wed, 29 May 2024 08:57:07 +0000 Message-ID: References: <34726328bd35e35c1c8ac4953d98bc71099a7f10.1716905162.git.AbdulLateef.Attar@amd.com> In-Reply-To: <34726328bd35e35c1c8ac4953d98bc71099a7f10.1716905162.git.AbdulLateef.Attar@amd.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_dce362fe-1558-4fb5-9f64-8a6240d76441_ActionId=fb9c4960-78b4-48fd-8d4d-c9dbe5f3cdf3;MSIP_Label_dce362fe-1558-4fb5-9f64-8a6240d76441_ContentBits=0;MSIP_Label_dce362fe-1558-4fb5-9f64-8a6240d76441_Enabled=true;MSIP_Label_dce362fe-1558-4fb5-9f64-8a6240d76441_Method=Standard;MSIP_Label_dce362fe-1558-4fb5-9f64-8a6240d76441_Name=AMD Internal Distribution Only;MSIP_Label_dce362fe-1558-4fb5-9f64-8a6240d76441_SetDate=2024-05-29T08:57:00Z;MSIP_Label_dce362fe-1558-4fb5-9f64-8a6240d76441_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: LV8PR12MB9452:EE_|PH7PR12MB8795:EE_ x-ms-office365-filtering-correlation-id: 3f887f7a-1d34-49e0-51af-08dc7fbd51bc x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: =?us-ascii?Q?Pn9BCYL6uN1WhSX+GIzpNIdFdFoG9wrkG3GasGKbKol0V8HQ/JEvV/gu2LEs?= =?us-ascii?Q?tG/9rUkUaBOuKoPz2D4RB1hFMeM4hWuKOaFTy5l0Bj65qkY0HgU7lTNN5Ow5?= =?us-ascii?Q?A9EvsYy3j0xCXXTS1NScV7OQ4cE0mGmsmSMaaaqF3YTf1j+YAaedtP2PlAx4?= =?us-ascii?Q?DwgJOs3q1vWWFFe0qAYYc86fyBp36trm/3f9S/Xuxmzuhp9mce10lksUkBN5?= =?us-ascii?Q?hHB9XXl1iNE3ba5vVtKdJnHPpZNnxs1Y0oEhj1rOb/yE+5SCxCreyo310sNq?= =?us-ascii?Q?xFzCbJiwiy/Q//fDUMQ22bvKJn6jkhLs2R4aRGTTeYXGbGOpDZEk8s1OG+EH?= =?us-ascii?Q?vVKwJftKUYbNLki2JO2tbNQEK1ALR+REWNGBJbEXiOjoRU2jfofEvinsBHay?= =?us-ascii?Q?FV7+EzD77HV+MheHkA5cH0GX7jMFg7XaTv+P1szsEhSPOArz3rZkENjij3Nc?= =?us-ascii?Q?gxarTBc5Hd3uiM0opnTuKNIQai+c35sDuwh9S67RU01+igoUTPIw+2XfI9mx?= =?us-ascii?Q?dzg0S6aqWTOepZhqPA5O3Mwg086qRg+wFQxVqNJzdH+eQ3Lo9uqP4mgPn+qZ?= =?us-ascii?Q?FT9pZj5H0sbeyRCoTPStLbgcQU64DovxSz234hrXTfH24tiJQHMRMzr+Q7eP?= =?us-ascii?Q?mhIBUOCyOVQ0pyaw5dNEV+2+nq8EfUlHhXp/mm88Au/+bQcmwRRUsXwsCc7i?= =?us-ascii?Q?Qao8ca5/ZT2FxtYJ2LFy8RC6eB2vr81N6oguJjBRX7XRXf+waknb9h4d+Vsh?= =?us-ascii?Q?MW6Y59SKUIkmIBYhA4YBe5lE21ss9icUV+F+sWtlH0LanDXLmEHXopRsAxsy?= =?us-ascii?Q?fajWR1jghhoa/8dbGmExmftUAYG1ZzMgP4RVvAQTz4/gzQOIQQ8FdOrVb21I?= =?us-ascii?Q?JGMGQRlWWGcGjoTxvYvRTZuNnNsJxwpTqEjjt0h+PDk3yQx2SBs6fGeVBI02?= =?us-ascii?Q?4di7TR6ZZPh9hcHsFjd1pYpMN2Z39+cP0oP/iK8Zka2pZtczTrrvpW7ML4VC?= =?us-ascii?Q?c4V1/NPsY4JvHz1sFFCMgT/oNpoYnNHW5t8n3zrsOHsP0qzc6bSWQ1ovsEKo?= =?us-ascii?Q?OMdDFJ3HEco0rmDJIwWdsYNeiRVpy3x35KyOKm4Y80ZTfUGMY7i33QF1I3A/?= =?us-ascii?Q?ohkLCKKSqqTiQ5nyPTNl0On94rqTx3fm+DRnYgi2g54r158Tl7Tec24Nt8Mf?= =?us-ascii?Q?i1r+4MvkRm4pRWN5nrCiDKE2AS5qPb8wXMf+A0AZhAG2uZsJHrO4HDS5Ucii?= =?us-ascii?Q?D2btdzfYlI3SzyRgQBdgQ6qluSakEOgSWhBEPndvUZvBeRKbXH4FG/uF+lqx?= =?us-ascii?Q?3EHnLtk9UWekgvNMkRNgJ4HVnOPAhGZNi7QsD+CCZKnCYA=3D=3D?= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?hH80zra66VUA1sdxoKA/kGCr9MEVrkftBSDOgGHSLwPa/ZDzjpqi6g2qBq+h?= =?us-ascii?Q?1sn0BCjg5iepI7hBIto83jnC3tMIRPY+s14TZTCcjmdgtB9rkbM8sy4ihG/2?= =?us-ascii?Q?XB34uqWH1iNqTqIR67/3PhIbttwzsDczX+oA6s771IbwIBiWwz4JZi3WgoEP?= =?us-ascii?Q?Dx5qMUWbh/mKf2jat/UX79ZKnSgXMmR8/lPyPrqAmM/UuqCqJsjML4abzwOA?= =?us-ascii?Q?qYqvHgqh/aqcZdmqbZcXsMB0pi20NGOWDAQzypVHEr8klaI5h5w4QBkPcb8o?= =?us-ascii?Q?HgYB4/g1CjAw48DvPbklrUEIYwbkCaGmp2gewHTopcfHJAWzAva5+5/0fFVd?= =?us-ascii?Q?OgCCHuSwyf5iJH2oG3cILm3fRlDJ2j/8TXOSsPX9CgeGEVBTyfJb/VrIOCiO?= =?us-ascii?Q?vklhqWAUgrhVfU/vo+MggPhlFnlg6mWodbHM5cp7amdhpVnndvsFvv/u2+tU?= =?us-ascii?Q?JDSTgwnsLS3k885DrRXZKvP7g6NPX5GcD9r6ldGTJbC9p+iyGdrtbjxTXJG0?= =?us-ascii?Q?fUSNLgL084CMMEv7bV51I+X+nrSlLrxnj4NCbV+ALw3RJzsZvqKl3BEvgIOs?= =?us-ascii?Q?fbiEGDzSJMmwt4FBPDbp3z93buao9erp1ylsLOCbcEBZGgydRcp7cMU66NMq?= =?us-ascii?Q?ZZNfkHTidoU8kSmRGibgcKiTjD/Wba1p8DAheqUBBI/y20RNEWOCA0QiI2xw?= =?us-ascii?Q?b9BO3DtyzXrket5maLWIVSs4kNLTmD/69hQ+spnkFDO97VIm37NImqbI/bZl?= =?us-ascii?Q?lgq26o/boIiKXelqytt9Dy09DQ0RnFH/JW1GquWvZ3cBbd5CZv7JZi4r4Ips?= =?us-ascii?Q?ZrvB9JDXakG+fZWWf6AiKcf2UCnC2wrtKw8eh6A41wBvoNhZSXPIMl8vBeTg?= =?us-ascii?Q?pEPXPdMMdvZmLuv6e/wiRghryDppTcPQhM7U9be3mXY5iMx9Ra8SRUZW/Bde?= =?us-ascii?Q?vW2Zk9OmQF3KAx9wV5cfAypsFG79WQGUX80WT/FfbW/6wRtL9txq98hOjXfk?= =?us-ascii?Q?DxADa2fKSzI8MtKzh6PSvXtSMkypJGXkKVN7My0AY7Y5OKhXrPmCkmYG1Qcl?= =?us-ascii?Q?oli2vYGSo+HoheUeb1nliAuWr/E+LbWEKA1N00qJ8Aq79fdjplpomsfYxLt5?= =?us-ascii?Q?G5H6m4fFMBaxXAZni6eLKqZr/dLcjD+O46mlTG00/+dPM85p6z2wp8X1efYp?= =?us-ascii?Q?LqYhUerrgZnO8I/5WJNsKkG4+e8I0SlyUWzU6gW+LCxzknknYJyycdPcfco0?= =?us-ascii?Q?/dKmaOB9JvyG/P+4AmWsTg0fTqfx4rgXthspPl4mHuIRkBTAxJBrtn6/3c3I?= =?us-ascii?Q?DqiK5ik96AJPfMj70VyvIOOqlURZPRfIFMBzQ1745vfjUkLWpQ7wxZWHS+ro?= =?us-ascii?Q?g3u9HONlhnwKjUdj7J/Ci5NGgDHAolR3QAzExjF1uA47wz0CmkDZp00Q3emZ?= =?us-ascii?Q?kn4R+sbyL7Un1XAoMKubJFgrqg3DnWl+BIVo3f+gIaGdNiFpeCKBfhhMkFZG?= =?us-ascii?Q?w2k7fM2PuOA4Y3NbxofmE0VFSW6DRTQq57Ii8C+uZs9vazGdltCtoHeqP0PW?= =?us-ascii?Q?Ki81Yevs1FLOLurtE2k=3D?= MIME-Version: 1.0 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: LV8PR12MB9452.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3f887f7a-1d34-49e0-51af-08dc7fbd51bc X-MS-Exchange-CrossTenant-originalarrivaltime: 29 May 2024 08:57:07.6195 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: 30xG/kylf4JHUAso08vhL+P1Ima/36Og2U4OBL91L/r8Xiim2dD/gea9P/DDxXv+wlKfq/0SoLlxcVH9cV3LCw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB8795 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Resent-Date: Wed, 29 May 2024 01:57:10 -0700 Resent-From: abner.chang@amd.com Reply-To: devel@edk2.groups.io,abner.chang@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: Fs3K4OWGKWPqBVRhdob27oxQx7686176AA= 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=20240206 header.b="hH/2YK1W"; dmarc=pass (policy=none) header.from=groups.io; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 45.79.224.7 as permitted sender) smtp.mailfrom=bounce@groups.io [AMD Official Use Only - AMD Internal Distribution Only] Reviewed-by: Abner Chang > -----Original Message----- > From: Abdul Lateef Attar > Sent: Tuesday, May 28, 2024 10:08 PM > To: devel@edk2.groups.io > Cc: Attar, AbdulLateef (Abdul Lateef) ; Chang, > Abner ; Grimes, Paul > Subject: [edk2-platforms 3/3] AmdPlatformPkg: Adds SPI smm core platform > hook > > Register a smm core platform hook handler for SPI device, > using AMD SmmCorePlatformHookLib library. > > This platform hook saves the SPI host controller state. > > Cc: Abner Chang > Cc: Paul Grimes > Signed-off-by: Abdul Lateef Attar > --- > .../AMD/AmdPlatformPkg/AmdPlatformPkg.dec | 3 + > .../AMD/AmdPlatformPkg/AmdPlatformPkg.dsc | 2 + > .../Include/Protocol/AmdSpiSmmHcState.h | 107 +++++++++++++ > .../SmmCoreAmdSpiHcHookLib.c | 145 ++++++++++++++++++ > .../SmmCoreAmdSpiHcHookLib.h | 20 +++ > .../SmmCoreAmdSpiHcHookLib.inf | 41 +++++ > .../SmmCoreAmdSpiHcHookLib.uni | 11 ++ > 7 files changed, 329 insertions(+) > create mode 100644 > Platform/AMD/AmdPlatformPkg/Include/Protocol/AmdSpiSmmHcState.h > create mode 100644 > Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmC > oreAmdSpiHcHookLib.c > create mode 100644 > Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmC > oreAmdSpiHcHookLib.h > create mode 100644 > Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmC > oreAmdSpiHcHookLib.inf > create mode 100644 > Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmC > oreAmdSpiHcHookLib.uni > > diff --git a/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dec > b/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dec > index 3020e628a3..907c5b9b74 100644 > --- a/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dec > +++ b/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dec > @@ -29,6 +29,9 @@ > [Guids] > gAmdPlatformPkgTokenSpaceGuid =3D { 0x663DE733, 0x70E0, 0x4D37, > { 0xBB, 0x30, 0x7D, 0x9E, 0xAF, 0x9B, 0xDA, 0xE9 }} > > +[Protocols] > + gAmdSpiHcStateProtocolGuid =3D { 0x189566ab, 0x245, 0x43ae, {0x9d= , > 0x1, 0xd2, 0x21, 0x1c, 0xb9, 0x1a, 0xda }} > + > [PcdsDynamic] > ## Event GUID to trigger logo displaying > # Default set to > gMinPlatformPkgTokenSpaceGuid.gBdsEventAfterConsoleReadyBeforeBootO > ptionGuid > diff --git a/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dsc > b/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dsc > index 482e6f2f30..012270074d 100644 > --- a/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dsc > +++ b/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dsc > @@ -64,6 +64,7 @@ > > [LibraryClasses.common.SMM_CORE] > > SmmCorePlatformHookLib|AmdPlatformPkg/Library/SmmCorePlatformHook > Lib/SmmCorePlatformHookLib.inf > + > SmmCoreAmdSpiHcHookLib|AmdPlatformPkg/Library/SmmCoreAmdSpiHcH > ookLib/SmmCoreAmdSpiHcHookLib.inf > > [Components] > > AmdPlatformPkg/Library/BaseAlwaysFalseDepexLib/BaseAlwaysFalseDepexLi > b.inf > @@ -79,3 +80,4 @@ > > [Components.common.SMM_CORE] > > AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmCorePlatformHook > Lib.inf > + > AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmCoreAmdSpiHcH > ookLib.inf > diff --git > a/Platform/AMD/AmdPlatformPkg/Include/Protocol/AmdSpiSmmHcState.h > b/Platform/AMD/AmdPlatformPkg/Include/Protocol/AmdSpiSmmHcState.h > new file mode 100644 > index 0000000000..0e2bccb3ef > --- /dev/null > +++ > b/Platform/AMD/AmdPlatformPkg/Include/Protocol/AmdSpiSmmHcState.h > @@ -0,0 +1,107 @@ > +/** @file > + Header file of AMD SMM SPI host controller state protocol > + > + Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights rese= rved. > + > + SPDX-License-Identifier: BSD-2-Clause-Patent > +**/ > + > +#ifndef AMD_SMM_SPI_HC_STATE_PROTOCOL_H_ > +#define AMD_SMM_SPI_HC_STATE_PROTOCOL_H_ > + > +typedef struct _SMM_EFI_SPI_HC_STATE_PROTOCOL > SMM_EFI_SPI_HC_STATE_PROTOCOL; > + > +/** > + Save/Restore the state of the SPI Host Controller > + > + Use a chipset specific method to save the state of the SPI Host contro= ller so > + it can be used without disturbing other transactions. > + > + @param[in] This Pointer to an SMM_EFI_SPI_HC_STATE_PROTOCOL > structure. > + > + @retval EFI_SUCCESS The State was saved successfully > + @retval DEVICE_ERROR SPI Executes command failed > + > +**/ > +typedef EFI_STATUS > +(EFIAPI *SMM_SPI_HC_STATE)( > + IN CONST SMM_EFI_SPI_HC_STATE_PROTOCOL *This > + ); > + > +/** > + Lock/Unlock the SPI host controller register > + > + Use a chipset specific method to lock or unlock SPI host controller re= gister. > + > + @param[in] This Pointer to an SMM_EFI_SPI_HC_STATE_PROTOCOL > structure. > + > + @retval EFI_SUCCESS The clock was set up successfully > + @retval DEVICE_ERROR SPI Executes command failed > + > + > +**/ > +typedef EFI_STATUS > +(EFIAPI *SMM_SPI_HC_LOCK_UNLOCK)( > + IN CONST SMM_EFI_SPI_HC_STATE_PROTOCOL *This > + ); > + > +/** > + Block/Unblock SPI opcode > + > + Use a chipset specific method to block and unclock specific SPI opcode= . > + > + @param[in] This Pointer to an SMM_EFI_SPI_HC_STATE_PROTOCOL > structure. > + > + @retval EFI_SUCCESS The clock was set up successfully > + @retval DEVICE_ERROR SPI Executes command failed > + > +**/ > +typedef EFI_STATUS > +(EFIAPI *SMM_SPI_HC_BLOCK_UNBLOCK_OPCODE)( > + IN CONST SMM_EFI_SPI_HC_STATE_PROTOCOL *This, > + IN UINT8 Opcode > + ); > + > +/** > + Block/Unblock any SPI opcodes > + > + Use a chipset specific method to block and unclock all SPI opcodes. > + > + @param[in] This Pointer to an SMM_EFI_SPI_HC_STATE_PROTOCOL > structure. > + > + @retval EFI_SUCCESS The clock was set up successfully > + @retval DEVICE_ERROR SPI Executes command failed > + > +**/ > +typedef EFI_STATUS > +(EFIAPI *SMM_SPI_HC_BLOCK_UNBLOCK_ALL_OPCODES)( > + IN CONST SMM_EFI_SPI_HC_STATE_PROTOCOL *This > + ); > + > +/// > +/// Manage and control the SPI host controller state. > +/// > +struct _SMM_EFI_SPI_HC_STATE_PROTOCOL { > + /// > + /// Save and Restore SPI host controller state. > + /// > + SMM_SPI_HC_STATE SaveState; > + SMM_SPI_HC_STATE RestoreState; > + > + /// > + /// Lock and Unlock SPI host controller registers > + /// > + SMM_SPI_HC_LOCK_UNLOCK Lock; > + SMM_SPI_HC_LOCK_UNLOCK Unlock; > + > + /// > + /// Block and Unblock SPI Opcode > + /// > + SMM_SPI_HC_BLOCK_UNBLOCK_OPCODE BlockOpcode; > + SMM_SPI_HC_BLOCK_UNBLOCK_OPCODE UnblockOpcode; > + SMM_SPI_HC_BLOCK_UNBLOCK_ALL_OPCODES UnblockAllOpcodes; > +}; > + > +extern EFI_GUID gAmdSpiHcStateProtocolGuid; > + > +#endif // AMD_SMM_SPI_HC_STATE_PROTOCOL_H__ > diff --git > a/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/Smm > CoreAmdSpiHcHookLib.c > b/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/Sm > mCoreAmdSpiHcHookLib.c > new file mode 100644 > index 0000000000..4284f13a5e > --- /dev/null > +++ > b/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/Sm > mCoreAmdSpiHcHookLib.c > @@ -0,0 +1,145 @@ > +/** @file > + SMM core hook for AMD SPI Host Controller State > + > + Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights rese= rved. > + > + SPDX-License-Identifier: BSD-2-Clause-Patent > +**/ > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include "SmmCoreAmdSpiHcHookLib.h" > + > +VOID *mSmmCorePlatformHookHcStateRegistration =3D NULL; > + > +SMM_CORE_HOOK_AMD_SPI_HC_STATE_CONTEXT > mSmmCorePlatformHookContext; > + > +/** > + Performs platform specific tasks before invoking registered SMI handle= rs. > + > + This function performs platform specific tasks before invoking registe= red > SMI handlers. > + > + @retval EFI_SUCCESS The platform hook completes successfully. > + @retval Other values The platform hook cannot complete due to som= e > error. > + > +**/ > +EFI_STATUS > +EFIAPI > +SmmCoreSpiHcHookBeforeSmmDispatch ( > + VOID > + ) > +{ > + EFI_STATUS Status; > + SMM_EFI_SPI_HC_STATE_PROTOCOL *SpiHcState; > + > + Status =3D EFI_SUCCESS; > + SpiHcState =3D mSmmCorePlatformHookContext.SmmSpiHcStateInterface; > + if (SpiHcState !=3D NULL) { > + Status =3D SpiHcState->SaveState (SpiHcState); > + // Open up SPI HC for SMM, Restore state will automatically return b= ack to > + // state on SMM entry > + Status =3D SpiHcState->Unlock (SpiHcState); > + Status =3D SpiHcState->UnblockAllOpcodes (SpiHcState); > + } > + > + return Status; > +} > + > +/** > + Performs platform specific tasks after invoking registered SMI handler= s. > + > + This function performs platform specific tasks after invoking register= ed SMI > handlers. > + > + @retval EFI_SUCCESS The platform hook completes successfully. > + @retval Other values The platform hook cannot complete due to som= e > error. > + > +**/ > +EFI_STATUS > +EFIAPI > +SmmCoreSpiHcHookAfterSmmDispatch ( > + VOID > + ) > +{ > + EFI_STATUS Status; > + SMM_EFI_SPI_HC_STATE_PROTOCOL *SpiHcState; > + > + Status =3D EFI_SUCCESS; > + SpiHcState =3D mSmmCorePlatformHookContext.SmmSpiHcStateInterface; > + if (SpiHcState !=3D NULL) { > + Status =3D SpiHcState->RestoreState (SpiHcState); > + } > + > + return Status; > +} > + > +/** > + Notification for SMM ReadyToLock protocol. > + > + @param[in] Protocol Points to the protocol's unique identifier. > + @param[in] Interface Points to the interface instance. > + @param[in] Handle The handle on which the interface was installed. > + > + @retval EFI_SUCCESS Notification runs successfully. > +**/ > +EFI_STATUS > +EFIAPI > +SmmCorePlatformHookHcStateNotify ( > + IN CONST EFI_GUID *Protocol, > + IN VOID *Interface, > + IN EFI_HANDLE Handle > + ) > +{ > + mSmmCorePlatformHookContext.SmmSpiHcStateInterface =3D Interface; > + mSmmCorePlatformHookContext.SmmSpiHcStateHandle =3D Handle; > + return EFI_SUCCESS; > +} > + > +/** > + Constructor for SmmLockBox library. > + This is used to set SmmLockBox context, which will be used in PEI phas= e in > S3 boot path later. > + > + @param[in] ImageHandle Image handle of this driver. > + @param[in] SystemTable A Pointer to the EFI System Table. > + > + @retval EFI_SUCCESS > + @return Others Some error occurs. > +**/ > +EFI_STATUS > +EFIAPI > +SmmCoreAmdSpiHcHookConstructor ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + EFI_STATUS Status; > + > + SetMem ( > + &mSmmCorePlatformHookContext, > + sizeof (mSmmCorePlatformHookContext), > + 0 > + ); > + // > + // Register gAmdSpiHcStateProtocolGuid notification. > + // > + Status =3D gSmst->SmmRegisterProtocolNotify ( > + &gAmdSpiHcStateProtocolGuid, > + SmmCorePlatformHookHcStateNotify, > + &mSmmCorePlatformHookHcStateRegistration > + ); > + ASSERT_EFI_ERROR (Status); > + > + // > + // Register AMD SMM Dispatcher hook instance. > + // > + Status =3D RegisterSmmDispatcherHook ( > + SmmCoreSpiHcHookBeforeSmmDispatch, > + SmmCoreSpiHcHookAfterSmmDispatch, > + 0 > + ); > + return Status; > +} > diff --git > a/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/Smm > CoreAmdSpiHcHookLib.h > b/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/Sm > mCoreAmdSpiHcHookLib.h > new file mode 100644 > index 0000000000..8a5dfe623c > --- /dev/null > +++ > b/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/Sm > mCoreAmdSpiHcHookLib.h > @@ -0,0 +1,20 @@ > +/** @file > + Header file of SMM core platform hook for AMD SPI Host Controller stat= e > library > + > + Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights rese= rved. > + > + SPDX-License-Identifier: BSD-2-Clause-Patent > +**/ > + > +#ifndef SMM_CORE_AMD_SPI_HC_HOOK_LIB_H_ > +#define SMM_CORE_AMD_SPI_HC_HOOK_LIB_H_ > + > +/// > +/// Structure of AMD SPI HC State record > +/// > +typedef struct { > + VOID *SmmSpiHcStateInterface; ///< AMD SMM SPI HC State Proto= col > Interface > + EFI_HANDLE SmmSpiHcStateHandle; ///< Handle of MD SMM SPI HC > State Protocol handle > +} SMM_CORE_HOOK_AMD_SPI_HC_STATE_CONTEXT; > + > +#endif // SMM_CORE_AMD_SPI_HC_HOOK_LIB_H_ > diff --git > a/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/Smm > CoreAmdSpiHcHookLib.inf > b/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/Sm > mCoreAmdSpiHcHookLib.inf > new file mode 100644 > index 0000000000..9855aa8543 > --- /dev/null > +++ > b/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/Sm > mCoreAmdSpiHcHookLib.inf > @@ -0,0 +1,41 @@ > +## @file > +# INF of SMM Core AMD SPI Host Contoller State hook library. > +# > +# Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights res= erved. > +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +## > +[Defines] > + INF_VERSION =3D 0x00010005 > + BASE_NAME =3D SmmCoreAmdSpiHcHookLib > + MODULE_UNI_FILE =3D SmmCoreAmdSpiHcHookLib.uni > + FILE_GUID =3D 65D0E2A5-C8C6-4DEE-8FD0-5A006A49E9B= 7 > + MODULE_TYPE =3D SMM_CORE > + VERSION_STRING =3D 1.0 > + PI_SPECIFICATION_VERSION =3D 0x0001000A > + LIBRARY_CLASS =3D SmmCoreAmdSpiHcHookLib|SMM_CORE > + CONSTRUCTOR =3D SmmCoreAmdSpiHcHookConstructor > + > +# > +# The following information is for reference only and not required by th= e build > tools. > +# > +# VALID_ARCHITECTURES =3D IA32 X64 > +# > + > +[Sources] > + SmmCoreAmdSpiHcHookLib.c > + SmmCoreAmdSpiHcHookLib.h > + > +[Packages] > + AmdPlatformPkg/AmdPlatformPkg.dec > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + > +[LibraryClasses] > + SmmServicesTableLib > + BaseLib > + DebugLib > + BaseMemoryLib > + > +[Protocols] > + gAmdSpiHcStateProtocolGuid > diff --git > a/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/Smm > CoreAmdSpiHcHookLib.uni > b/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/Sm > mCoreAmdSpiHcHookLib.uni > new file mode 100644 > index 0000000000..0a73c4acb4 > --- /dev/null > +++ > b/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/Sm > mCoreAmdSpiHcHookLib.uni > @@ -0,0 +1,11 @@ > +## @file > +# UNI file of SMM Core AMD SPI Host Controller State hook library modul= e > +# > +# Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights res= erved. > +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +## > + > +#string STR_MODULE_ABSTRACT #language en-US "SMM Core AMD > SPI HC State Hook Library instance" > + > +#string STR_MODULE_DESCRIPTION #language en-US "SMM Core AMD > SPI Host Controller Hook Library instance" > -- > 2.34.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 (#119334): https://edk2.groups.io/g/devel/message/119334 Mute This Topic: https://groups.io/mt/106349079/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-