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 20258740035 for ; Wed, 29 May 2024 08:57:21 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=TQ0Pok28gVDiJcVcyIyGgaUsyTmtQvsPg7zXuQoceh4=; 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=1716973041; v=1; b=1fk7oFF+Oo5eNsKSXXxOTbRX0+R3rX66mu/draC5PN3Q/dBriyC29jhALeLvhSpWCbvX0wGt KGSrlboRsE0U2emFFSS+xiUt60hXVB78+Yj/0In0vZlBeu9nTxNAF3rEgXQq0CsmJBeRqk+jilJ KcZ0LNgBbHQZ6IMHdSndqGiApvdfdLVoO9XQd7I7xAG/AvNWmBM9w08fjBCZgdQ+ltw3QKDK1LR f4dRizkM2EDC34i/kcTsXF74B/5iiLN06SYVwPQkHcMn5hDaOKBGnL1z2+Q0y/RO3UImLWKfSH0 iOlDIoSSlWXAmMMlN3SPLNZi+0B8R4jniUkondOqIY63Q== X-Received: by 127.0.0.2 with SMTP id Y3fUYY7687511xBCX1wLvLKs; Wed, 29 May 2024 01:57:20 -0700 X-Received: from NAM12-BN8-obe.outbound.protection.outlook.com (NAM12-BN8-obe.outbound.protection.outlook.com [40.107.237.71]) by mx.groups.io with SMTP id smtpd.web10.9280.1716973035008551822 for ; Wed, 29 May 2024 01:57:15 -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:12 +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:12 +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 2/3] AmdPlatformPkg: Implements SmmCorePlatformHookLib library Thread-Topic: [edk2-platforms 2/3] AmdPlatformPkg: Implements SmmCorePlatformHookLib library Thread-Index: AQHasQiC9S1dkULde0GelMqwKxdgaLGt6k4g Date: Wed, 29 May 2024 08:57:12 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_dce362fe-1558-4fb5-9f64-8a6240d76441_ActionId=28933a57-d44c-4d4c-9db1-775462acf464;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:08Z;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: 2706f92c-a7b0-4dc6-c423-08dc7fbd54ad x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam-message-info: =?us-ascii?Q?msKZJK/EAScnTuvWwh4mWTnEBV/tN56uSkClpiaPwBkFqUYR+z9rERY8HlFj?= =?us-ascii?Q?35uKUViIYsQZJ5vPfru0fPySXDb0EWzlveJctxA2DDLSQxs3FB4E8MA/nF5Z?= =?us-ascii?Q?57Y4R+PASMW6VT9EFzU6BMRQSxP50HDfuhClueA4/URrO6ROVqLJM9b3yX26?= =?us-ascii?Q?h4Lfi4k6usocPkz1xNPdwD30XBW122/b1PAvYbk9gL6DDRfApraCQLto11Je?= =?us-ascii?Q?/pKaZw9G2yYSo6DU3GifchJYtzpUSpYUAinqKsfHAQroOLCXRiNzBoAi0qAi?= =?us-ascii?Q?FplbUWaRcc1D1hldRHCVhTznyXRctYUzFDY3kVZwkbnUOWq+a5zOjaglcTmM?= =?us-ascii?Q?U48yWONUsS4ShPvwr9OyHBsODIpqhP6d661hDOOVG7fwfmQFCzPob01PkMOe?= =?us-ascii?Q?Pf4aB2nhtZGSNdme+MuVGVBqJOQKxRWqBgqBz7pks/RJb4o02WEjv8Q0zK/Z?= =?us-ascii?Q?4axX3cFp0Ey48wn9P2oPJAjec6FoxvbSKn7gksp4v+s6iQyeBJTAgnp5hDMy?= =?us-ascii?Q?OQ+N/HEFgNB9ovtHW4GoPfJEbzvFJI33KUNZEYZpelwXcv5UXx5m+wlFFolc?= =?us-ascii?Q?e2nL31rZnz0UMq08Mx77cOCpUBocY4DRDmEUr/Gmkp7okGpPQs6kZfIa4GnD?= =?us-ascii?Q?ppT6z9/R+eW0lwGYC/07PzF3IQnUEEr1DcO8CKj7MnFfJS2IJ+o5gM+KHuv0?= =?us-ascii?Q?kzqjHwcBzL6mN5NIgu3qtBoF6t5caELYpH0CeOlOvLTVAfsfEERXr0VzwLdD?= =?us-ascii?Q?n6DWpJxikYACAZIfwgODFTsgFd0ONfD4flhnCxpeGHzH41CkLu4qUnjMc19n?= =?us-ascii?Q?ZEM5dM/l8uhFBuNnwVGhpklcYEv6OJC8cRlrFT2A6THVIXOi4DV1uRBe7jCl?= =?us-ascii?Q?jxQUzZxTOfKOT0TgeOuHy12wUWIGRWKWQ533IijR/ZvlzX656Q4GXlf5jB9d?= =?us-ascii?Q?KQTiQKnZHRTFG5EU6E+cas2GBMxBvcpMijc3Y7VX/xgZls/McHCSWS6hmyL0?= =?us-ascii?Q?0CAaUYbz4u6eY/IOqW716lMmz7AHzf0ELR6DfXKCLVDEfdSD5COAH8nMugct?= =?us-ascii?Q?DC0qGwwPEFmHXVdJ3SZDZlKkZqRUPFcwrvEe075Dy7C21LhLFR1DSmzj3gJ9?= =?us-ascii?Q?PiCfK8UQbHN2e8Uuy/XpntRdlxJ6Oao39pfhYGPBVpfQYmHksmOtg4o61hAo?= =?us-ascii?Q?7rfM3/UaMj6EBG83E4JNz7Xls+B/jmcIivhOLoJJ8562sDCxqybz39SUpvz+?= =?us-ascii?Q?eUoncbdZwDnNhBnpQScg0EMKVnEFGOgVuXncenX2UbipOWjUFnPsAv7YH9kU?= =?us-ascii?Q?iSI1CHZSxU4dwlKY5iJ+pfYk+x5b7L9shSHkEs/xdUoqjg=3D=3D?= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?us-ascii?Q?LS2F3AqyCJ31mABI1TCQ+/HTvgrlUKswXcisE8m+K6JoeZyXpYP3zkP73ZtC?= =?us-ascii?Q?3CWmpAnXK69ukqfEyKTIuddD9oWgWmMl7F36SckrU++1k8D0lQWSBOGj/O2X?= =?us-ascii?Q?kMvxhtn0WCNowLanHPhJ1bxS8GpkZdofPrdvOySppyKEt4agYG7ca/+zLbom?= =?us-ascii?Q?5KGJf1v7I3vA9aO8yhDFnXEe1GC0WohyigUpwF0Ec/gAZ0qvgR/W7EGOuIBY?= =?us-ascii?Q?hyCqhKmjI8cUwcRa9lsDMQL2NYogtFZGG8JYEK0Uuqo1KifeR+vbZYCxxrrU?= =?us-ascii?Q?FDp92WjAfqk41dsKckr/5F+Xsd/wmNWc6gPgMJaPUL2iqvM38s6c7FX05Dxk?= =?us-ascii?Q?eQqE2mVCmoUQ84pI8c5Ah3B0Wf7ay2TGNamuw2FyJI4mPNE4tylzKmKzrHp/?= =?us-ascii?Q?ChBa9w84pp/kXcYGMYh5O7WzwaTZ1X6R6Iq+7+SKJQtY0uCYWL2kBcMW8fq9?= =?us-ascii?Q?VAlkH5kOnhAq2tm3UvjgMM10/shwx+uZa2+YjClJcS1dt14XPUSEjtOwA57d?= =?us-ascii?Q?03fncq5mw2GPbludKhpLA/9p7HgCAjML5EYGh6SPB1IbonoevzILDJ4Qy4ZU?= =?us-ascii?Q?tlPWynAMyMHwh5I55RgcSphjXl+VgCab6lmj0I+wYU7G9T4/4i3uq0lnEha4?= =?us-ascii?Q?21W39o4g65aeAvmEjLAPcnYx6mf2v6xRFtbtWmLAGZE1AbKddWT1QtzmwHP8?= =?us-ascii?Q?299HZrr6nxjNrxqbw0W5QuvR4WIHe6XvmNfySGrLqO/NhHPpQWrUWNSLULia?= =?us-ascii?Q?J8OG9pvOFufh1V8T4ZF7vC8BTfi+7rAYWJwENnwu6vi5RDC06TAWJL/KXgyB?= =?us-ascii?Q?8FFNwdWKRZg61hPK3lSj5V8N3otj7SZe1LPRfqk71dE829CTXjvWsHn9Ifg+?= =?us-ascii?Q?jIQSOBY90gvst841bRmTC2fmrl8hipmPKywTezJmHxJKr4Wyra9tKg2aOAED?= =?us-ascii?Q?5HQDRFfGoxX52WiUh4DsMd/hotY31/6zRRfNhdgQt1Ag4pRdfDlvomp7BOK+?= =?us-ascii?Q?p4Kc3+XbnyJDvkkT5iIJFqUmEB9p4thN0Tifw15/e9pfkPKcbb+dDFqUe0Uo?= =?us-ascii?Q?kolmQFiqPZIUYBfNhKQNl2yzF1MuvTT1M5Qxk/nxnisODtLeScAic3iqCR6E?= =?us-ascii?Q?5+2t2XW0iFO702oXGBggBlTsgFLXDkHsxMmgNIhHzOalyXz9xXAhMqVUzbz6?= =?us-ascii?Q?IexLL0LhChFfI+wd6W0wtnlZiAk9qDCF/JPXAfWnFIbB3VrsbLrroNR2o7w+?= =?us-ascii?Q?7ii+dnchObxuV1tYinv3EewwYtZKj/vMAi2vrTIfcK5+B4Xbv52s/kxBvkew?= =?us-ascii?Q?bPcbnDOYaMuJ3kSt6sEXcR4CuD/qHsrrd4r4sbOtxNBQ7qPCB1wdZi3mvIHU?= =?us-ascii?Q?RFPT/x9CWaygcIo1vw+dE7py9mAQj1dnw8E2ER8QNmZ9qCfYFu4HMIJy2Ckh?= =?us-ascii?Q?oL9+2d3+1eNeQ2HAyXmjgYPk85S5eRO4eFYZgu/eoSnafYTJYxMVdqlu2nfX?= =?us-ascii?Q?dQ8sFAv96tuVJtAPRfgAhYO3BGTBAt8T5FUXLgXUB/VsqwFg3QDcU+aa1sX8?= =?us-ascii?Q?btzafXEqZYlNDH93PJI=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: 2706f92c-a7b0-4dc6-c423-08dc7fbd54ad X-MS-Exchange-CrossTenant-originalarrivaltime: 29 May 2024 08:57:12.5726 (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: 3SlORX+rkGq4oDn8ktIiA5iuuKyaext4kjihzGdT4dhbEye1hqPow0AiLRFZV4kxy4ZLFVK1aUt/1pJ53lEQGQ== 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:15 -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: cCCYTzzsfHw2WfT55KFqw3qdx7686176AA= 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=1fk7oFF+; 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 2/3] AmdPlatformPkg: Implements > SmmCorePlatformHookLib library > > Implements SmmCorePlatformHookLib library for AMD platform. > > Cc: Abner Chang > Cc: Paul Grimes > Signed-off-by: Abdul Lateef Attar > --- > .../AMD/AmdPlatformPkg/AmdPlatformPkg.dec | 5 + > .../AMD/AmdPlatformPkg/AmdPlatformPkg.dsc | 6 + > .../Library/AmdSmmCorePlatformHookLib.h | 68 +++++++ > .../SmmCorePlatformHookLib.c | 169 ++++++++++++++++++ > .../SmmCorePlatformHookLib.inf | 39 ++++ > .../SmmCorePlatformHookLib.uni | 11 ++ > 6 files changed, 298 insertions(+) > create mode 100644 > Platform/AMD/AmdPlatformPkg/Include/Library/AmdSmmCorePlatformHoo > kLib.h > create mode 100644 > Platform/AMD/AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmCor > ePlatformHookLib.c > create mode 100644 > Platform/AMD/AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmCor > ePlatformHookLib.inf > create mode 100644 > Platform/AMD/AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmCor > ePlatformHookLib.uni > > diff --git a/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dec > b/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dec > index 106820dc85..3020e628a3 100644 > --- a/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dec > +++ b/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dec > @@ -21,6 +21,11 @@ > ## @libraryclass Defines a get/set interface for platform specific d= ata. > PlatformSocLib|Include/Library/AmdPlatformSocLib.h > > + ## @libraryclass AMD SMM core platform hook library > + # Provide the functions to register hook before and > + # after SMM dispatcher. > + > SmmCorePlatformHookLib|Include/Library/AmdSmmCorePlatformHookLib.h > + > [Guids] > gAmdPlatformPkgTokenSpaceGuid =3D { 0x663DE733, 0x70E0, 0x4D37, > { 0xBB, 0x30, 0x7D, 0x9E, 0xAF, 0x9B, 0xDA, 0xE9 }} > > diff --git a/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dsc > b/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dsc > index d11d3594e3..482e6f2f30 100644 > --- a/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dsc > +++ b/Platform/AMD/AmdPlatformPkg/AmdPlatformPkg.dsc > @@ -62,6 +62,9 @@ > > MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemor > yAllocationLib.inf > > PlatformSocLib|AmdPlatformPkg/Library/DxePlatformSocLib/DxePlatformSoc > LibNull.inf > > +[LibraryClasses.common.SMM_CORE] > + > SmmCorePlatformHookLib|AmdPlatformPkg/Library/SmmCorePlatformHook > Lib/SmmCorePlatformHookLib.inf > + > [Components] > > AmdPlatformPkg/Library/BaseAlwaysFalseDepexLib/BaseAlwaysFalseDepexLi > b.inf > AmdPlatformPkg/Library/DxePlatformSocLib/DxePlatformSocLibNull.inf > @@ -73,3 +76,6 @@ > AmdPlatformPkg/Universal/LogoDxe/LogoDxe.inf = # > Server platfrom Bitmap logo driver > AmdPlatformPkg/Universal/LogoDxe/S3LogoDxe.inf > AmdPlatformPkg/Universal/SmbiosCommonDxe/SmbiosCommonDxe.inf > + > +[Components.common.SMM_CORE] > + > AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmCorePlatformHook > Lib.inf > diff --git > a/Platform/AMD/AmdPlatformPkg/Include/Library/AmdSmmCorePlatformHo > okLib.h > b/Platform/AMD/AmdPlatformPkg/Include/Library/AmdSmmCorePlatformHo > okLib.h > new file mode 100644 > index 0000000000..6ae76920b4 > --- /dev/null > +++ > b/Platform/AMD/AmdPlatformPkg/Include/Library/AmdSmmCorePlatformHo > okLib.h > @@ -0,0 +1,68 @@ > +/** @file > + AMD Smm Core Platform Hook Library > + > + Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights rese= rved. > + > + SPDX-License-Identifier: BSD-2-Clause-Patent > + > +**/ > + > +#ifndef AMD_SMM_CORE_PLATFORM_HOOK_LIB_ > +#define AMD_SMM_CORE_PLATFORM_HOOK_LIB_ > + > +/** > + This is the prototype of SMM Dispatcher hook before. > + > + @retval EFI_STATUS > + > +**/ > +typedef > +EFI_STATUS > +(EFIAPI *AMD_SMM_DISPATCH_HOOK_BEFORE)( > + VOID > + ); > + > +/** > + This is the prototype of SMM Dispatcher after before. > + > + @retval EFI_STATUS > + > +**/ > +typedef > +EFI_STATUS > +(EFIAPI *AMD_SMM_DISPATCH_HOOK_AFTER)( > + VOID > + ); > + > +typedef UINT32 AMD_SMM_DISPATCH_HOOK_PRIORITY; > + > +/// > +/// This is the structure of the SMM Dispatcher hook record > +/// > +typedef struct { > + LIST_ENTRY NextList; ///< Point= to next > AMD_SMM_DISPATCH_HOOK. > + AMD_SMM_DISPATCH_HOOK_BEFORE AmdSmmDispatchHookBefore; > ///< The hook before function. > + AMD_SMM_DISPATCH_HOOK_AFTER AmdSmmDispatchHookAfter; ///< > The hook after function. > + AMD_SMM_DISPATCH_HOOK_PRIORITY Priority; ///< The p= riority > of this hook instance. > + ///< Prior= ity could be implemented for > + ///< futur= e usage. > +} AMD_SMM_DISPATCH_HOOK; > + > +/** > + Register a SMM dispatcher hook. > + > + @param[in] SmmDispatchHookBefore Function hook to SMM Dispatch > before. > + @param[in] SmmDispatchHookAfter Function hook to SMM Dispatch > after. > + @param[in] Priority The priority to execute the hook. > + > + @retval EFI_SUCCESS The hook is registered successfully. > + > +**/ > +EFI_STATUS > +RegisterSmmDispatcherHook ( > + IN AMD_SMM_DISPATCH_HOOK_BEFORE SmmDispatchHookBefore > OPTIONAL, > + IN AMD_SMM_DISPATCH_HOOK_AFTER SmmDispatchHookAfter > OPTIONAL, > + IN AMD_SMM_DISPATCH_HOOK_PRIORITY Priority > + ); > + > +#endif // AMD_SMM_CORE_PLATFORM_HOOK_LIB_ > diff --git > a/Platform/AMD/AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmC > orePlatformHookLib.c > b/Platform/AMD/AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmC > orePlatformHookLib.c > new file mode 100644 > index 0000000000..ad6a40749f > --- /dev/null > +++ > b/Platform/AMD/AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmC > orePlatformHookLib.c > @@ -0,0 +1,169 @@ > +/** @file > + AMD SMM core hook library > + > + 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 > + > +LIST_ENTRY *RegisteredHookPtr =3D NULL; > +LIST_ENTRY RegisteredHook; > + > +/** > + Register a SMM dispatcher hook. > + > + @param[in] SmmDispatchHookBefore Function hook to SMM Dispatch > before. > + @param[in] SmmDispatchHookAfter Function hook to SMM Dispatch > after. > + @param[in] Priority The priority to execute the hook. > + > + @retval EFI_SUCCESS The hook is registered successfully. > + > +**/ > +EFI_STATUS > +RegisterSmmDispatcherHook ( > + IN AMD_SMM_DISPATCH_HOOK_BEFORE SmmDispatchHookBefore > OPTIONAL, > + IN AMD_SMM_DISPATCH_HOOK_AFTER SmmDispatchHookAfter > OPTIONAL, > + IN AMD_SMM_DISPATCH_HOOK_PRIORITY Priority > + ) > +{ > + AMD_SMM_DISPATCH_HOOK *ThisHook; > + > + if ((SmmDispatchHookBefore =3D=3D NULL) && (SmmDispatchHookAfter =3D= =3D > NULL)) { > + DEBUG ((DEBUG_ERROR, "%a: Both SmmDispatchHookBefore and > SmmDispatchHookAfter are NULL.\n", __func__)); > + return EFI_INVALID_PARAMETER; > + } > + > + if (RegisteredHookPtr =3D=3D NULL) { > + InitializeListHead (&RegisteredHook); > + RegisteredHookPtr =3D &RegisteredHook; > + } > + > + ThisHook =3D (AMD_SMM_DISPATCH_HOOK *)AllocateZeroPool (sizeof > (AMD_SMM_DISPATCH_HOOK)); > + if (ThisHook =3D=3D NULL) { > + DEBUG ((DEBUG_ERROR, "%a: Insufficient memory for > AMD_SMM_DISPATCH_HOOK.\n", __func__)); > + return EFI_OUT_OF_RESOURCES; > + } > + > + InitializeListHead (&ThisHook->NextList); > + ThisHook->AmdSmmDispatchHookBefore =3D SmmDispatchHookBefore; > + ThisHook->AmdSmmDispatchHookAfter =3D SmmDispatchHookAfter; > + ThisHook->Priority =3D Priority; > + InsertHeadList (&RegisteredHook, &ThisHook->NextList); > + DEBUG ((DEBUG_VERBOSE, "%a: New AMD_SMM_DISPATCH_HOOK is > inserted.\n", __func__)); > + return EFI_SUCCESS; > +} > + > +/** > + 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 > +PlatformHookBeforeSmmDispatch ( > + VOID > + ) > +{ > + AMD_SMM_DISPATCH_HOOK *ThisHook; > + > + if (IsListEmpty (&RegisteredHook)) { > + return EFI_NOT_FOUND; > + } > + > + ThisHook =3D (AMD_SMM_DISPATCH_HOOK *)GetFirstNode > (&RegisteredHook); > + while (TRUE) { > + // > + // We can handle priority in the future when needed. > + // > + if (ThisHook->AmdSmmDispatchHookBefore !=3D NULL) { > + ThisHook->AmdSmmDispatchHookBefore (); > + } > + > + if (IsNodeAtEnd (&RegisteredHook, &ThisHook->NextList)) { > + break; > + } > + > + ThisHook =3D (AMD_SMM_DISPATCH_HOOK *)GetNextNode > (&RegisteredHook, &ThisHook->NextList); > + } > + > + return EFI_SUCCESS; > +} > + > +/** > + 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 > +PlatformHookAfterSmmDispatch ( > + VOID > + ) > +{ > + AMD_SMM_DISPATCH_HOOK *ThisHook; > + > + if (IsListEmpty (&RegisteredHook)) { > + return EFI_NOT_FOUND; > + } > + > + ThisHook =3D (AMD_SMM_DISPATCH_HOOK *)GetFirstNode > (&RegisteredHook); > + while (TRUE) { > + // > + // We can handle priority in the future when needed. > + // > + if (ThisHook->AmdSmmDispatchHookAfter !=3D NULL) { > + ThisHook->AmdSmmDispatchHookAfter (); > + } > + > + if (IsNodeAtEnd (&RegisteredHook, &ThisHook->NextList)) { > + break; > + } > + > + ThisHook =3D (AMD_SMM_DISPATCH_HOOK *)GetNextNode > (&RegisteredHook, &ThisHook->NextList); > + } > + > + 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 > +SmmCorePlatformHookConstructor ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + if (RegisteredHookPtr =3D=3D NULL) { > + InitializeListHead (&RegisteredHook); > + RegisteredHookPtr =3D &RegisteredHook; > + } > + > + return EFI_SUCCESS; > +} > diff --git > a/Platform/AMD/AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmC > orePlatformHookLib.inf > b/Platform/AMD/AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmC > orePlatformHookLib.inf > new file mode 100644 > index 0000000000..a79fc56077 > --- /dev/null > +++ > b/Platform/AMD/AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmC > orePlatformHookLib.inf > @@ -0,0 +1,39 @@ > +## @file > +# INF of SMM Core hook library INF file. > +# > +# 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 SmmCorePlatformHookLib > + MODULE_UNI_FILE =3D SmmCorePlatformHookLib.uni > + FILE_GUID =3D 70ACB6CA-80D2-46a9-A0EB-0C83DFC476C= 9 > + MODULE_TYPE =3D SMM_CORE > + VERSION_STRING =3D 1.0 > + PI_SPECIFICATION_VERSION =3D 0x0001000A > + LIBRARY_CLASS =3D SmmCorePlatformHookLib|SMM_CORE > + CONSTRUCTOR =3D SmmCorePlatformHookConstructor > + > +# > +# The following information is for reference only and not required by th= e build > tools. > +# > +# VALID_ARCHITECTURES =3D IA32 X64 > +# > + > +[Sources] > + SmmCorePlatformHookLib.c > + > +[Packages] > + AmdPlatformPkg/AmdPlatformPkg.dec > + MdePkg/MdePkg.dec > + MdeModulePkg/MdeModulePkg.dec > + > +[LibraryClasses] > + BaseLib > + BaseMemoryLib > + DebugLib > + MemoryAllocationLib > + SmmServicesTableLib > + > diff --git > a/Platform/AMD/AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmC > orePlatformHookLib.uni > b/Platform/AMD/AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmC > orePlatformHookLib.uni > new file mode 100644 > index 0000000000..0b326c159b > --- /dev/null > +++ > b/Platform/AMD/AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmC > orePlatformHookLib.uni > @@ -0,0 +1,11 @@ > +## @file > +# UNI file of SMM Core hook library module > +# > +# 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 > Platform Hook Library instance" > + > +#string STR_MODULE_DESCRIPTION #language en-US "SMM Core > Platform 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 (#119335): https://edk2.groups.io/g/devel/message/119335 Mute This Topic: https://groups.io/mt/106349081/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-