From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.92.40.81]) by mx.groups.io with SMTP id smtpd.web11.18284.1611690449878012625 for ; Tue, 26 Jan 2021 11:47:30 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@outlook.com header.s=selector1 header.b=e4IUkphA; spf=pass (domain: outlook.com, ip: 40.92.40.81, mailfrom: kun.q@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aWZan+tCi6tuYxuNagVu4UzZWlaIWsbDnaU0KrmP3YYI7+X4AEA2EZ/m7GjNpd6q7tTcppsF+zdUaBiRfJK6E5IXewK7dIwSEWBU5bnDSxvdex6BgL1x7SW8mHnGRbV5garnh6QUdYtZUHnE4YvoFBJ9tGuTP+VPGL0Qpp/GgbSAeOoBpV7i0a0bRy+sYDmKCV6Eg1ZTdxEo9jB3uMk3fYl6ro3rGZxHv7UeDPQH2+9x/sdHIIm/oo/I90VE+bPaAX/Fg+CP095gzBvE7wXpUc8oguv16igCA1/SPkQ2e14Lju/lFCWdJdOquoCSivZHo1WntghkcGAgRzqVEIHr6g== 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-SenderADCheck; bh=H9gq5/JBhj4R2c4s1WHuDqZLjI/N9P5a6FN7hY/e6Ds=; b=DEFyv1UD7TZkG3yy8SukXNSzoPst0ZaMpT5eeIWnYe4Nz6nfVkgq3bjLyzQiS4g0RA/U8qhWQhDmqoxG2dzJG8fl+9QFABgMC/nkbSVKFapkPbRumxuxl2jylnslzeHNUi/Jy68OBHaudmNAY/LPqTd7d3JdVjee51V7rrKVxGYsWnCpf5AXPxyb2iabojpT4L2J1QQtWw/XKmZ68ZpKgUna/UIqTvMw5MmZih/24jdOEMyOcSqyLxCGKG5bypz8w8df6FzsfOY3fh59tx2qH2OcparTyHzZQYWlqr5UxUI6hdHr9XmOW1AeXZ1B7mcUmdBp4ASNFMJjxTAFRMNkkg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=H9gq5/JBhj4R2c4s1WHuDqZLjI/N9P5a6FN7hY/e6Ds=; b=e4IUkphAuQwhMFUlSNrc6n86VWxsYT2mP9fyKw5228KZxqt6P1XEn63tIbNmQvstEe7b5VHNAvcARvfF0UHCLfnlt/OTc/DiZi0bN0NldXebamFe06XZDCN1Zt8ZUUIgVKx/SQl9FmQ2IO3usXtCTHpxbMbboD9k0MokToclOM1hyKl6ddqc/xz7oHhJ77iI4h+zPooFCaAnz1Pa+SIELMt6GQRsgJM/ZIPuLL3par+ceNrwEnLo6XxsfvCsO5gHSylXhpYTU5OfbO+Pqz8OFVYhlFsMkoZvBbuxNRRMhiIMK/2lmVZuQ8JO2q+zytjmuib+K82gkPC9eeVfSFZxpA== Received: from BN7NAM10FT059.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::42) by BN7NAM10HT079.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11; Tue, 26 Jan 2021 19:47:27 +0000 Received: from MWHPR06MB3102.namprd06.prod.outlook.com (2a01:111:e400:7e8f::4c) by BN7NAM10FT059.mail.protection.outlook.com (2a01:111:e400:7e8f::447) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11 via Frontend Transport; Tue, 26 Jan 2021 19:47:27 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:87673A7662F7CE975D1E83AFB07740F1BEC49732ADDD7BDEBC13E08EF7E69697;UpperCasedChecksum:BCD4715D41FA470489F7FA8D635FF16AFC105CB90AE00280A4F26A11802E9EBC;SizeAsReceived:7449;Count:47 Received: from MWHPR06MB3102.namprd06.prod.outlook.com ([fe80::d4ee:1260:6f53:3f7b]) by MWHPR06MB3102.namprd06.prod.outlook.com ([fe80::d4ee:1260:6f53:3f7b%6]) with mapi id 15.20.3784.017; Tue, 26 Jan 2021 19:47:27 +0000 From: "Kun Qin" To: devel@edk2.groups.io CC: Jian J Wang , Hao A Wu , Eric Dong Subject: [PATCH v4 06/20] MdeModulePkg: SmmLockBoxSmmLib: Support StandaloneMm for SmmLockBoxLib Date: Tue, 26 Jan 2021 11:46:56 -0800 Message-ID: X-Mailer: git-send-email 2.30.0.windows.1 In-Reply-To: <20210126194710.2248-1-kun.q@outlook.com> References: <20210126194710.2248-1-kun.q@outlook.com> X-TMN: [KviCGyh7GQbmurQte5qwoPKZJYBbMWe1] X-ClientProxiedBy: MWHPR11CA0001.namprd11.prod.outlook.com (2603:10b6:301:1::11) To MWHPR06MB3102.namprd06.prod.outlook.com (2603:10b6:301:3e::35) Return-Path: kun.q@outlook.com X-Microsoft-Original-Message-ID: <20210126194710.2248-4-kun.q@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (50.35.88.161) by MWHPR11CA0001.namprd11.prod.outlook.com (2603:10b6:301:1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.14 via Frontend Transport; Tue, 26 Jan 2021 19:47:27 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: c98e8fa3-8a61-44f8-9c2a-08d8c23335aa X-MS-TrafficTypeDiagnostic: BN7NAM10HT079: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +WxWQURlF+jKv+dQMZXfIBoDSIrBQOvPMlWRF9RIt5OwIwolQBNyhQzt8xdFwCU4UKaDtDO1RDIHy2sNpw7SJ/xfkVgvPy8LiCuYjmh4JJitqF2yOlYrPp6jHK3wBDT1NDIhsJuzDCrX2d0sXC0eXi2WgS2euqeVI/WMt2EdITihZxIXLIsMc8oi6tmweLLMgLkDUZRBo0Yhk/l6cAbFW+2eNmrIqx0nhhUnI0sQERuvJU6x+fJBXa0MdQYE7Vo0kNz7XYr4h+FO2J5t5h6WiAlwY85FfaT33sms9jvyE94GeSO3nPR3hvLfXg4olbk/plDPSNBTDbEzQttIVHeGsu6Za82rKb0J/f99P7nNQITUfLVDH7RCUpAdHvZMPZZtZmvU5GvB6WjmcU4l620tEw== X-MS-Exchange-AntiSpam-MessageData: slo5zeo8GrSr2U9BAs+hvKt7pbkgXUz6sMf63EYlErGSZiJcWO44YaCyuXlGTNGwGeDmcSga6H683/GXtuHvwPFAA4iFjI/k3r8c8F8LviqPmo5cYM7knrIHX/Vhoi8snJqykuuO4XCPhAUFkzh48A== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c98e8fa3-8a61-44f8-9c2a-08d8c23335aa X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2021 19:47:27.4598 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: BN7NAM10FT059.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7NAM10HT079 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain This change added support of StandaloneMm for SmmLockBoxLib. It replaces gSmst with gMmst to support both traditional MM and standalone MM. The contructor and desctructor functions are abstracted to support different function prototype definitions. Cc: Jian J Wang Cc: Hao A Wu Cc: Eric Dong Signed-off-by: Kun Qin Reviewed-by: Hao A Wu --- Notes: v4: - Previously reviewed. No change. =20 v3: - Previously reviewed. No change. =20 v2: - Removed "EFIAPI" for internal library functions [Hao] - Added Reviewed-by tag [Hao] MdeModulePkg/Library/SmmLockBoxLib/{SmmLockBoxSmmLib.c =3D> SmmLockBoxMmLi= b.c} | 82 +++++++++----------- MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.c = | 53 +++++++++++++ MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxTraditionalMmLib.c = | 53 +++++++++++++ MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxLibPrivate.h = | 25 ++++++ MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf = | 15 ++-- MdeModulePkg/Library/SmmLockBoxLib/{SmmLockBoxSmmLib.inf =3D> SmmLockBoxSt= andaloneMmLib.inf} | 26 ++++--- MdeModulePkg/MdeModulePkg.dsc = | 2 + 7 files changed, 191 insertions(+), 65 deletions(-) diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.c b/MdeMod= ulePkg/Library/SmmLockBoxLib/SmmLockBoxMmLib.c similarity index 89% rename from MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.c rename to MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxMmLib.c index 4cc0e8b78e5b..a709851806eb 100644 --- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.c +++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxMmLib.c @@ -6,16 +6,16 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 -#include -#include +#include +#include #include #include #include #include #include #include -#include -#include +#include +#include #include =20 #include "SmmLockBoxLibPrivate.h" @@ -49,13 +49,13 @@ InternalGetSmmLockBoxContext ( // // Check if gEfiSmmLockBoxCommunicationGuid is installed by someone // - for (Index =3D 0; Index < gSmst->NumberOfTableEntries; Index++) { - if (CompareGuid (&gSmst->SmmConfigurationTable[Index].VendorGuid, &gEf= iSmmLockBoxCommunicationGuid)) { + for (Index =3D 0; Index < gMmst->NumberOfTableEntries; Index++) { + if (CompareGuid (&gMmst->MmConfigurationTable[Index].VendorGuid, &gEfi= SmmLockBoxCommunicationGuid)) { // // Found. That means some other library instance is already run. // No need to install again, just return. // - return (SMM_LOCK_BOX_CONTEXT *)gSmst->SmmConfigurationTable[Index].V= endorTable; + return (SMM_LOCK_BOX_CONTEXT *)gMmst->MmConfigurationTable[Index].Ve= ndorTable; } } =20 @@ -142,8 +142,8 @@ SmmLockBoxSmmEndOfDxeNotify ( // // Locate SmmSxDispatch2 protocol. // - Status =3D gSmst->SmmLocateProtocol ( - &gEfiSmmSxDispatch2ProtocolGuid, + Status =3D gMmst->MmLocateProtocol ( + &gEfiMmSxDispatchProtocolGuid, NULL, (VOID **)&SxDispatch ); @@ -191,29 +191,24 @@ SmmLockBoxEndOfS3ResumeNotify ( Constructor for SmmLockBox library. This is used to set SmmLockBox context, which will be used in PEI phase = in S3 boot path later. =20 - @param[in] ImageHandle Image handle of this driver. - @param[in] SystemTable A Pointer to the EFI System Table. - @retval EFI_SUCEESS @return Others Some error occurs. **/ EFI_STATUS -EFIAPI -SmmLockBoxSmmConstructor ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable +SmmLockBoxMmConstructor ( + VOID ) { EFI_STATUS Status; SMM_LOCK_BOX_CONTEXT *SmmLockBoxContext; =20 - DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SmmLockBoxSmmConstructor - Enter\n= ")); + DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SmmLockBoxMmConstructor - Enter\n"= )); =20 // // Register SmmReadyToLock notification. // - Status =3D gSmst->SmmRegisterProtocolNotify ( - &gEfiSmmReadyToLockProtocolGuid, + Status =3D gMmst->MmRegisterProtocolNotify ( + &gEfiMmReadyToLockProtocolGuid, SmmLockBoxSmmReadyToLockNotify, &mSmmLockBoxRegistrationSmmReadyToLock ); @@ -222,8 +217,8 @@ SmmLockBoxSmmConstructor ( // // Register SmmEndOfDxe notification. // - Status =3D gSmst->SmmRegisterProtocolNotify ( - &gEfiSmmEndOfDxeProtocolGuid, + Status =3D gMmst->MmRegisterProtocolNotify ( + &gEfiMmEndOfDxeProtocolGuid, SmmLockBoxSmmEndOfDxeNotify, &mSmmLockBoxRegistrationSmmEndOfDxe ); @@ -232,7 +227,7 @@ SmmLockBoxSmmConstructor ( // // Register EndOfS3Resume notification. // - Status =3D gSmst->SmmRegisterProtocolNotify ( + Status =3D gMmst->MmRegisterProtocolNotify ( &gEdkiiEndOfS3ResumeGuid, SmmLockBoxEndOfS3ResumeNotify, &mSmmLockBoxRegistrationEndOfS3Resume @@ -249,7 +244,7 @@ SmmLockBoxSmmConstructor ( // No need to install again, just return. // DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SmmLockBoxContext - already inst= alled\n")); - DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SmmLockBoxSmmConstructor - Exit\= n")); + DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SmmLockBoxMmConstructor - Exit\n= ")); return EFI_SUCCESS; } =20 @@ -263,8 +258,8 @@ SmmLockBoxSmmConstructor ( } mSmmLockBoxContext.LockBoxDataAddress =3D (EFI_PHYSICAL_ADDRESS)(UINTN)&= mLockBoxQueue; =20 - Status =3D gSmst->SmmInstallConfigurationTable ( - gSmst, + Status =3D gMmst->MmInstallConfigurationTable ( + gMmst, &gEfiSmmLockBoxCommunicationGuid, &mSmmLockBoxContext, sizeof(mSmmLockBoxContext) @@ -274,7 +269,7 @@ SmmLockBoxSmmConstructor ( =20 DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SmmLockBoxContext - %x\n", (UINTN)= &mSmmLockBoxContext)); DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib LockBoxDataAddress - %x\n", (UINTN= )&mLockBoxQueue)); - DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SmmLockBoxSmmConstructor - Exit\n"= )); + DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SmmLockBoxMmConstructor - Exit\n")= ); =20 return Status; } @@ -284,26 +279,21 @@ SmmLockBoxSmmConstructor ( This is used to uninstall SmmLockBoxCommunication configuration table if it has been installed in Constructor. =20 - @param[in] ImageHandle Image handle of this driver. - @param[in] SystemTable A Pointer to the EFI System Table. - @retval EFI_SUCEESS The destructor always returns EFI_SUCCESS. =20 **/ EFI_STATUS -EFIAPI -SmmLockBoxSmmDestructor ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable +SmmLockBoxMmDestructor ( + VOID ) { EFI_STATUS Status; =20 - DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SmmLockBoxSmmDestructor in %a modu= le\n", gEfiCallerBaseName)); + DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SmmLockBoxMmDestructor in %a modul= e\n", gEfiCallerBaseName)); =20 if (mSmmConfigurationTableInstalled) { - Status =3D gSmst->SmmInstallConfigurationTable ( - gSmst, + Status =3D gMmst->MmInstallConfigurationTable ( + gMmst, &gEfiSmmLockBoxCommunicationGuid, NULL, 0 @@ -316,8 +306,8 @@ SmmLockBoxSmmDestructor ( // // Unregister SmmReadyToLock notification. // - Status =3D gSmst->SmmRegisterProtocolNotify ( - &gEfiSmmReadyToLockProtocolGuid, + Status =3D gMmst->MmRegisterProtocolNotify ( + &gEfiMmReadyToLockProtocolGuid, NULL, &mSmmLockBoxRegistrationSmmReadyToLock ); @@ -327,8 +317,8 @@ SmmLockBoxSmmDestructor ( // // Unregister SmmEndOfDxe notification. // - Status =3D gSmst->SmmRegisterProtocolNotify ( - &gEfiSmmEndOfDxeProtocolGuid, + Status =3D gMmst->MmRegisterProtocolNotify ( + &gEfiMmEndOfDxeProtocolGuid, NULL, &mSmmLockBoxRegistrationSmmEndOfDxe ); @@ -338,7 +328,7 @@ SmmLockBoxSmmDestructor ( // // Unregister EndOfS3Resume notification. // - Status =3D gSmst->SmmRegisterProtocolNotify ( + Status =3D gMmst->MmRegisterProtocolNotify ( &gEdkiiEndOfS3ResumeGuid, NULL, &mSmmLockBoxRegistrationEndOfS3Resume @@ -453,7 +443,7 @@ SaveLockBox ( // // Allocate SMRAM buffer // - Status =3D gSmst->SmmAllocatePages ( + Status =3D gMmst->MmAllocatePages ( AllocateAnyPages, EfiRuntimeServicesData, EFI_SIZE_TO_PAGES (Length), @@ -468,14 +458,14 @@ SaveLockBox ( // // Allocate LockBox // - Status =3D gSmst->SmmAllocatePool ( + Status =3D gMmst->MmAllocatePool ( EfiRuntimeServicesData, sizeof(*LockBox), (VOID **)&LockBox ); ASSERT_EFI_ERROR (Status); if (EFI_ERROR (Status)) { - gSmst->SmmFreePages (SmramBuffer, EFI_SIZE_TO_PAGES (Length)); + gMmst->MmFreePages (SmramBuffer, EFI_SIZE_TO_PAGES (Length)); DEBUG ((DEBUG_INFO, "SmmLockBoxSmmLib SaveLockBox - Exit (%r)\n", EFI_= OUT_OF_RESOURCES)); return EFI_OUT_OF_RESOURCES; } @@ -662,7 +652,7 @@ UpdateLockBox ( DEBUG_INFO, "SmmLockBoxSmmLib UpdateLockBox - Allocate new buffer to enlarge= .\n" )); - Status =3D gSmst->SmmAllocatePages ( + Status =3D gMmst->MmAllocatePages ( AllocateAnyPages, EfiRuntimeServicesData, EFI_SIZE_TO_PAGES (Offset + Length), @@ -679,7 +669,7 @@ UpdateLockBox ( // CopyMem ((VOID *)(UINTN)SmramBuffer, (VOID *)(UINTN)LockBox->Smram= Buffer, (UINTN)LockBox->Length); ZeroMem ((VOID *)(UINTN)LockBox->SmramBuffer, (UINTN)LockBox->Leng= th); - gSmst->SmmFreePages (LockBox->SmramBuffer, EFI_SIZE_TO_PAGES ((UIN= TN)LockBox->Length)); + gMmst->MmFreePages (LockBox->SmramBuffer, EFI_SIZE_TO_PAGES ((UINT= N)LockBox->Length)); =20 LockBox->SmramBuffer =3D SmramBuffer; } diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.c= b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.c new file mode 100644 index 000000000000..722121da430b --- /dev/null +++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.c @@ -0,0 +1,53 @@ +/** @file + +Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) Microsoft Corporation. + +SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +#include "SmmLockBoxLibPrivate.h" + +/** + 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_SUCEESS + @return Others Some error occurs. +**/ +EFI_STATUS +EFIAPI +SmmLockBoxStandaloneMmConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_MM_SYSTEM_TABLE *SystemTable + ) +{ + return SmmLockBoxMmConstructor (); +} + +/** + Destructor for SmmLockBox library. + This is used to uninstall SmmLockBoxCommunication configuration table + if it has been installed in Constructor. + + @param[in] ImageHandle Image handle of this driver. + @param[in] SystemTable A Pointer to the EFI System Table. + + @retval EFI_SUCEESS The destructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +SmmLockBoxStandaloneMmDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_MM_SYSTEM_TABLE *SystemTable + ) +{ + return SmmLockBoxMmDestructor (); +} diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxTraditionalMmLib.= c b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxTraditionalMmLib.c new file mode 100644 index 000000000000..a748abb16c54 --- /dev/null +++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxTraditionalMmLib.c @@ -0,0 +1,53 @@ +/** @file + +Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.
+Copyright (c) Microsoft Corporation. + +SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +#include "SmmLockBoxLibPrivate.h" + +/** + 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_SUCEESS + @return Others Some error occurs. +**/ +EFI_STATUS +EFIAPI +SmmLockBoxTraditionalConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + return SmmLockBoxMmConstructor (); +} + +/** + Destructor for SmmLockBox library. + This is used to uninstall SmmLockBoxCommunication configuration table + if it has been installed in Constructor. + + @param[in] ImageHandle Image handle of this driver. + @param[in] SystemTable A Pointer to the EFI System Table. + + @retval EFI_SUCEESS The destructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +SmmLockBoxTraditionalDestructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + return SmmLockBoxMmDestructor (); +} diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxLibPrivate.h b/Md= eModulePkg/Library/SmmLockBoxLib/SmmLockBoxLibPrivate.h index 35311cb85d69..449333e94bc6 100644 --- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxLibPrivate.h +++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxLibPrivate.h @@ -43,5 +43,30 @@ typedef struct { =20 #pragma pack() =20 +/** + Constructor for SmmLockBox library. + This is used to set SmmLockBox context, which will be used in PEI phase = in S3 boot path later. + + @retval EFI_SUCEESS + @return Others Some error occurs. +**/ +EFI_STATUS +SmmLockBoxMmConstructor ( + VOID + ); + +/** + Destructor for SmmLockBox library. + This is used to uninstall SmmLockBoxCommunication configuration table + if it has been installed in Constructor. + + @retval EFI_SUCEESS The destructor always returns EFI_SUCCESS. + +**/ +EFI_STATUS +SmmLockBoxMmDestructor ( + VOID + ); + #endif =20 diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf b/MdeM= odulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf index 2b6cc983b988..44f7b63c5d20 100644 --- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf +++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf @@ -15,8 +15,8 @@ [Defines] MODULE_TYPE =3D DXE_SMM_DRIVER VERSION_STRING =3D 1.0 LIBRARY_CLASS =3D LockBoxLib|DXE_SMM_DRIVER - CONSTRUCTOR =3D SmmLockBoxSmmConstructor - DESTRUCTOR =3D SmmLockBoxSmmDestructor + CONSTRUCTOR =3D SmmLockBoxTraditionalConstructor + DESTRUCTOR =3D SmmLockBoxTraditionalDestructor =20 # # The following information is for reference only and not required by the = build tools. @@ -25,7 +25,8 @@ [Defines] # =20 [Sources] - SmmLockBoxSmmLib.c + SmmLockBoxTraditionalMmLib.c + SmmLockBoxMmLib.c SmmLockBoxLibPrivate.h =20 [Packages] @@ -33,14 +34,14 @@ [Packages] MdeModulePkg/MdeModulePkg.dec =20 [LibraryClasses] - SmmServicesTableLib + MmServicesTableLib BaseLib DebugLib =20 [Protocols] - gEfiSmmReadyToLockProtocolGuid ## NOTIFY - gEfiSmmEndOfDxeProtocolGuid ## NOTIFY - gEfiSmmSxDispatch2ProtocolGuid ## NOTIFY + gEfiMmReadyToLockProtocolGuid ## NOTIFY + gEfiMmEndOfDxeProtocolGuid ## NOTIFY + gEfiMmSxDispatchProtocolGuid ## NOTIFY =20 [Guids] ## SOMETIMES_CONSUMES ## UNDEFINED # SmmSystemTable diff --git a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf b/MdeM= odulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.inf similarity index 52% copy from MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf copy to MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.inf index 2b6cc983b988..d46dfb3f9aa8 100644 --- a/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf +++ b/MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.inf @@ -2,6 +2,7 @@ # SMM LockBox library instance. # # Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) Microsoft Corporation. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -9,14 +10,14 @@ =20 [Defines] INF_VERSION =3D 0x00010005 - BASE_NAME =3D SmmLockBoxSmmLib - MODULE_UNI_FILE =3D SmmLockBoxSmmLib.uni - FILE_GUID =3D E04894D6-290D-4171-A362-0ACFD939F3C8 - MODULE_TYPE =3D DXE_SMM_DRIVER + BASE_NAME =3D SmmLockBoxStandaloneMmLib + FILE_GUID =3D 3C05978B-30CA-4544-9C5A-AB99265EFC31 + MODULE_TYPE =3D MM_STANDALONE VERSION_STRING =3D 1.0 - LIBRARY_CLASS =3D LockBoxLib|DXE_SMM_DRIVER - CONSTRUCTOR =3D SmmLockBoxSmmConstructor - DESTRUCTOR =3D SmmLockBoxSmmDestructor + PI_SPECIFICATION_VERSION =3D 0x00010032 + LIBRARY_CLASS =3D LockBoxLib|MM_STANDALONE + CONSTRUCTOR =3D SmmLockBoxStandaloneMmConstructor + DESTRUCTOR =3D SmmLockBoxStandaloneMmDestructor =20 # # The following information is for reference only and not required by the = build tools. @@ -25,7 +26,8 @@ [Defines] # =20 [Sources] - SmmLockBoxSmmLib.c + SmmLockBoxStandaloneMmLib.c + SmmLockBoxMmLib.c SmmLockBoxLibPrivate.h =20 [Packages] @@ -33,14 +35,14 @@ [Packages] MdeModulePkg/MdeModulePkg.dec =20 [LibraryClasses] - SmmServicesTableLib + MmServicesTableLib BaseLib DebugLib =20 [Protocols] - gEfiSmmReadyToLockProtocolGuid ## NOTIFY - gEfiSmmEndOfDxeProtocolGuid ## NOTIFY - gEfiSmmSxDispatch2ProtocolGuid ## NOTIFY + gEfiMmReadyToLockProtocolGuid ## NOTIFY + gEfiMmEndOfDxeProtocolGuid ## NOTIFY + gEfiMmSxDispatchProtocolGuid ## NOTIFY =20 [Guids] ## SOMETIMES_CONSUMES ## UNDEFINED # SmmSystemTable diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index 6d4e361afd51..9afd40eeed46 100644 --- a/MdeModulePkg/MdeModulePkg.dsc +++ b/MdeModulePkg/MdeModulePkg.dsc @@ -167,6 +167,7 @@ [LibraryClasses.common.MM_STANDALONE] MemoryAllocationLib|MdeModulePkg/Library/BaseMemoryAllocationLibNull/Bas= eMemoryAllocationLibNull.inf StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntryPoint= /StandaloneMmDriverEntryPoint.inf MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/Standalon= eMmServicesTableLib.inf + LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.= inf =20 [LibraryClasses.ARM, LibraryClasses.AARCH64] ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf @@ -484,6 +485,7 @@ [Components.IA32, Components.X64] MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxPeiLib.inf MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxDxeLib.inf MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf + MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxStandaloneMmLib.inf MdeModulePkg/Library/SmmCorePlatformHookLibNull/SmmCorePlatformHookLibNu= ll.inf MdeModulePkg/Library/SmmSmiHandlerProfileLib/SmmSmiHandlerProfileLib.inf MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaArchCustomDecompressLib= .inf --=20 2.30.0.windows.1