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 57ABF941352 for ; Tue, 28 May 2024 14:08:17 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=AtAmdaRQt9Yv8utQfDbTkZX3/D0yGvAbRKUMbtCLbUw=; c=relaxed/simple; d=groups.io; h=Received-SPF:From:To:CC:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Received-SPF:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Resent-Date:Resent-From:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20240206; t=1716905297; v=1; b=rjvmv8N+R1YJkPXcQb3qEKsjuvv8jJbDk5tU1adKfv+weWM256yQV6ess0T0eWpOZpe6ahAT psMIQfz9Um8YXJ3zqpSuBBvFPHBXkSa5PnWdQYj65q1YmRmIFgrLXB+/EHGi55AEttAo2xJ9nPC 00s2NVUKwVLgy3e5vcJRmaWAS8GY4HROsH8mmDRb3djOoAbHV53ZgovFvUdHxdMaf7qC/PZL/FJ fd/x1c4HZEQ7TvY6V6QpjyG2l+m7iQ1CVwJqqg0X7lwbzEX1btVkXhgcNblYRBjl/EAHk/UI9W7 KYsJKDq1lv+dR+BD9aTGo5XGW6oPrzGJaSmbqp3XmChcQ== X-Received: by 127.0.0.2 with SMTP id iVknYY7687511xFmItCNOsug; Tue, 28 May 2024 07:08:15 -0700 X-Received: from NAM12-DM6-obe.outbound.protection.outlook.com (NAM12-DM6-obe.outbound.protection.outlook.com [40.107.243.80]) by mx.groups.io with SMTP id smtpd.web10.22888.1716905295278414651 for ; Tue, 28 May 2024 07:08:15 -0700 X-Received: from CH2PR02CA0003.namprd02.prod.outlook.com (2603:10b6:610:4e::13) by MW4PR12MB7309.namprd12.prod.outlook.com (2603:10b6:303:22f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.17; Tue, 28 May 2024 14:08:09 +0000 X-Received: from CH3PEPF00000017.namprd21.prod.outlook.com (2603:10b6:610:4e:cafe::e6) by CH2PR02CA0003.outlook.office365.com (2603:10b6:610:4e::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.17 via Frontend Transport; Tue, 28 May 2024 14:08:08 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C X-Received: from SATLEXMB04.amd.com (165.204.84.17) by CH3PEPF00000017.mail.protection.outlook.com (10.167.244.122) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7656.0 via Frontend Transport; Tue, 28 May 2024 14:08:08 +0000 X-Received: from SATLEXMB05.amd.com (10.181.40.146) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 28 May 2024 09:08:08 -0500 X-Received: from SATLEXMB04.amd.com (10.181.40.145) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Tue, 28 May 2024 09:08:07 -0500 X-Received: from BLR-LAB-SFW01.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35 via Frontend Transport; Tue, 28 May 2024 09:08:06 -0500 From: "Abdul Lateef Attar via groups.io" To: CC: Abdul Lateef Attar , Abner Chang , Paul Grimes Subject: [edk2-devel] [edk2-platforms 3/3] AmdPlatformPkg: Adds SPI smm core platform hook Date: Tue, 28 May 2024 19:37:52 +0530 Message-ID: <34726328bd35e35c1c8ac4953d98bc71099a7f10.1716905162.git.AbdulLateef.Attar@amd.com> In-Reply-To: References: MIME-Version: 1.0 Received-SPF: None (SATLEXMB05.amd.com: AbdulLateef.Attar@amd.com does not designate permitted sender hosts) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH3PEPF00000017:EE_|MW4PR12MB7309:EE_ X-MS-Office365-Filtering-Correlation-Id: a9ed176b-533f-4d2a-5e5f-08dc7f1f9a3e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?SWoiGStKBDbGfgLBumKWJ2yV73k/iJcRDY4YtPqYQaghP0EE0vJO0DMUoqBj?= =?us-ascii?Q?qVWN6cpVjJsZrxM3UXfQ+hFWYkFq/Yrodpqq/xlxXmUOCcBGkx6d+JC0jHWK?= =?us-ascii?Q?lQkzp+KOJM6dOQ9FkZ2Z4Nv5yQvKi0G44S6BeyUw2/nIEH4TfM+yPJW2bJlC?= =?us-ascii?Q?g8lMRBu5dH/gWcHBfA/xsctJ6VgW/YwlPpW7FjBs5rjrDI6gLMQ7xPeKDE/6?= =?us-ascii?Q?gP43cJLyL3LnZJzxS2CH1n9qs3nhZuQArkeO9XNnhnaAb2E2g17sAX6H5BGe?= =?us-ascii?Q?xYVDzrgb2VTcTcnGKZ400sUjfYMXTtFqWmDgpx2ED+eRrgBjnAnEJAjgWbL8?= =?us-ascii?Q?u9Jf6qJdRRhRrAczvZ4Z69hwpITAu8VnhqrLsuYiGWbwH6A0KooevkAIeUDj?= =?us-ascii?Q?O4fpR8cdW6O4Qmqg94j0e5ZgwPhm6w1uxs6Lo97fNaZ8iixGnY5nIPNlVRga?= =?us-ascii?Q?h1Fhh8L6nVQLOpsENwKKi18jJMUKUXX7AJqmiG7+N0WJI4UvFK6PUrk6hmXN?= =?us-ascii?Q?Djx/5WU7WYseCzIelxbIuDMYs51/ZYXRyv0A+3sk3OIoYMjv73q6QAiYBOhy?= =?us-ascii?Q?yL5LkhWfjiHxohymKRnOqIvg3F28XTEh5BnGooOFNCifwRSVBVTobkUi+Shs?= =?us-ascii?Q?rUCiXKZDYEZ9A59wxnX5rBaAFlnGFDx7WEhZO0frQMh4SIZrDA9WRi8tDubY?= =?us-ascii?Q?rplTfjCqIOAcNCsDWO1Tt9ArY48qFneq1e+oA/75xkNe7WU1LKKLEzCiJAs4?= =?us-ascii?Q?Tucsy1btt1j+dqjBQJwBP+ElqNQRFcGq+G8cqX0Tbgpwfk/0JV5p6HBXoiyV?= =?us-ascii?Q?j0pSIQsF+DhY8X8PHqIhsBhfALUoQX1aw2n2y9P82lOPDoGvfsIhOw5WQIvz?= =?us-ascii?Q?Cb21XQuXBmbURGJJgoDORIJjzifCCBpdcOMNe5YLfUh4GEMvkIYrfFhBwcox?= =?us-ascii?Q?ph0j2Vurr1kWZrK3ujg8NXt/Fn3upDWd+KMduwp3SlL/TOTFiGXBdGYHRaFA?= =?us-ascii?Q?vnqa4pXtDcLIc3MOlPE+7XEDXIE2PvzrN7gsmVD48bYsOiXXOiWJ9IvF/fQn?= =?us-ascii?Q?yzztYRDcsqVb46L/SVDPwtjn5YwzR5549/kgx1DprmbtmwHTsBbx8eiAzNPM?= =?us-ascii?Q?KRHJjTiiAlkBQvdAyP6ts4r3p668w7Nc0Hbd3qafzTLaJg6cTPnONlJEUTe+?= =?us-ascii?Q?+ZsSnfN3t4EWyQO53IwXpACEqUsXZ/i6CFwCAcxqC/LSvVeXTU+rwn+Y0Kq+?= =?us-ascii?Q?kUNGIG5tVS+J7DTirgjc4YKkFl+Txns9IRDKUJ1/zfsL6yYdzMYLGudQdSEZ?= =?us-ascii?Q?OsBVbd+Ne7DyvOStsgf+XEv7EO0vjJ2K/RCeYeDGS9pEd84FQBeLIFpPReeP?= =?us-ascii?Q?uvUluxNWZftbyO0reMiK6N4nBF0o?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 May 2024 14:08:08.7635 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a9ed176b-533f-4d2a-5e5f-08dc7f1f9a3e X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CH3PEPF00000017.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB7309 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: Tue, 28 May 2024 07:08:15 -0700 Resent-From: AbdulLateef.Attar@amd.com Reply-To: devel@edk2.groups.io,AbdulLateef.Attar@amd.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: irXDwJ2aKYQA24YkVk3kGkvOx7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=rjvmv8N+; 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 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/AmdSpiSmmH= cState.h create mode 100644 Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHook= Lib/SmmCoreAmdSpiHcHookLib.c create mode 100644 Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHook= Lib/SmmCoreAmdSpiHcHookLib.h create mode 100644 Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHook= Lib/SmmCoreAmdSpiHcHookLib.inf create mode 100644 Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHook= Lib/SmmCoreAmdSpiHcHookLib.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 }} =20 +[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.gBdsEventAfterConsoleRea= dyBeforeBootOptionGuid 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 @@ =20 [LibraryClasses.common.SMM_CORE] SmmCorePlatformHookLib|AmdPlatformPkg/Library/SmmCorePlatformHookLib/Smm= CorePlatformHookLib.inf + SmmCoreAmdSpiHcHookLib|AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/Smm= CoreAmdSpiHcHookLib.inf =20 [Components] AmdPlatformPkg/Library/BaseAlwaysFalseDepexLib/BaseAlwaysFalseDepexLib.i= nf @@ -79,3 +80,4 @@ =20 [Components.common.SMM_CORE] AmdPlatformPkg/Library/SmmCorePlatformHookLib/SmmCorePlatformHookLib.inf + AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmCoreAmdSpiHcHookLib.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 reserv= ed. + + 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_PROTOCO= L; + +/** + Save/Restore the state of the SPI Host Controller + + Use a chipset specific method to save the state of the SPI Host controll= er so + it can be used without disturbing other transactions. + + @param[in] This Pointer to an SMM_EFI_SPI_HC_STATE_PROTOCOL st= ructure. + + @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 regi= ster. + + @param[in] This Pointer to an SMM_EFI_SPI_HC_STATE_PROTOCOL st= ructure. + + @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 st= ructure. + + @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 st= ructure. + + @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/SmmCoreAmdSpiHc= HookLib/SmmCoreAmdSpiHcHookLib.c new file mode 100644 index 0000000000..4284f13a5e --- /dev/null +++ b/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmCoreAmd= SpiHcHookLib.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 reserv= ed. + + 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 handlers= . + + This function performs platform specific tasks before invoking registere= d SMI handlers. + + @retval EFI_SUCCESS The platform hook completes successfully. + @retval Other values The platform hook cannot complete due to some = 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 bac= k 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 handlers. + + This function performs platform specific tasks after invoking registered= SMI handlers. + + @retval EFI_SUCCESS The platform hook completes successfully. + @retval Other values The platform hook cannot complete due to some = 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 phase = 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/SmmCoreAmdSpiHc= HookLib/SmmCoreAmdSpiHcHookLib.h new file mode 100644 index 0000000000..8a5dfe623c --- /dev/null +++ b/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmCoreAmd= SpiHcHookLib.h @@ -0,0 +1,20 @@ +/** @file + Header file of SMM core platform hook for AMD SPI Host Controller state = library + + Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reserv= ed. + + 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 Protoco= l Interface + EFI_HANDLE SmmSpiHcStateHandle; ///< Handle of MD SMM SPI HC Stat= e 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/SmmCoreAmdSpi= HcHookLib/SmmCoreAmdSpiHcHookLib.inf new file mode 100644 index 0000000000..9855aa8543 --- /dev/null +++ b/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmCoreAmd= SpiHcHookLib.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 reser= ved. +# +# 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-5A006A49E9B7 + 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 the = 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/SmmCoreAmdSpi= HcHookLib/SmmCoreAmdSpiHcHookLib.uni new file mode 100644 index 0000000000..0a73c4acb4 --- /dev/null +++ b/Platform/AMD/AmdPlatformPkg/Library/SmmCoreAmdSpiHcHookLib/SmmCoreAmd= SpiHcHookLib.uni @@ -0,0 +1,11 @@ +## @file +# UNI file of SMM Core AMD SPI Host Controller State hook library module +# +# Copyright (C) 2023 - 2024 Advanced Micro Devices, Inc. All rights reser= ved. +# +# 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" --=20 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 (#119306): https://edk2.groups.io/g/devel/message/119306 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-