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.52]) by mx.groups.io with SMTP id smtpd.web10.18111.1611690450341999948 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=DZHQFmJQ; spf=pass (domain: outlook.com, ip: 40.92.40.52, mailfrom: kun.q@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ayMUsUQaP+UaTUIqV7qzFLUOn7d4wngxIXq2AfZrJtma1M4N2Dp0cLAEhmVwoJhntHciD7A8KLUXJiv3hUiH/8lH3g7AZUemKlvrAi5TzDSdaoU5q1GA2JOgdTOljENy9Lt6mpVdXau55EeqeZlanK4Z4wKiQxzOkwZZSnsyiXu6P5axHwJGvVtY4ceolQPCKGEnsyqNnboX8aSMsv4uZpbaRqFI/GSQyrz6MVwQ2E8wZveUG99KiITzgNT6flgvnsLn/peVRWpG/6uN/s+X73lkkQMkL7QrjRfsIoLJyjmcQ61HZZ90nPBRv52fGoElhKNARUekyDPQv69Ov4fsXg== 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=e3ONG17zJkjIZZ2xGyJq789T3bHpTnkx2chLFl7pHdY=; b=aq6wBTSkSvwtcEO/urInby5JDpuDyNBi/h3obFm178jWsJfOZHhdhXuO12ioLbR7CV0W0xhNLvN1/r3ZyuuLbmtdkW3HuMb83IeMb4EnPN2rO/0x2dEAFXQQ0ByUB+lrykp1GbUfPJaUQA/Lbh8CUIftJsgfBRwc/Wepjq0RQkmftlAwGukc5cTacN4aMH+ofpc7yvKm7FCesrpfhKWQpmbQKAFL46Q8kukJspWbvZKSoOeHzHDwzVZpXwBZt2aQL7xmeVYlVK+qpje6Q29MFWSRw8IlIw0DDr13RElEuYIWlOZOLh/G7VDlMjNHXs19AdpbLcWtI5lwWxbVGCZFNQ== 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=e3ONG17zJkjIZZ2xGyJq789T3bHpTnkx2chLFl7pHdY=; b=DZHQFmJQB+yPYy+yVwz28EIxE6SouKlQnIS/vHn7dIcUj92WQv01+LKbQk3WJjDfEyct2Pn1KwpBs+woqqfXNHb01/GtLlG4uVCVLPgdD5u8m5fbOVl4xn1oJmFk+cUXX6K87jdhSLOw3Pom8b+fnDytxmtKeFY76mIYsfSetaUzcf3sSMWcP/NBwu7/+R2aIrQG8IRQ5Dn9pKJvSrpO+Vqx5WO7h9MptYkjdyaWJVuLgh++XS1xhs0qVeaVgS9ln9y8HEpb49DliRPjybY/SmqbTeUiKH7s1h9LG7iXeoL80TbYAgDUewwzYmqhBIAsPnduuPGp3g0dFVGTOLZqQg== Received: from BN7NAM10FT059.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::4b) by BN7NAM10HT067.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::210) 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:29 +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:29 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:3BBFEF9880EA284E2499F31AA7D212919BCE417376A1E7307FD0F47BA6A2FD59;UpperCasedChecksum:F746AB568EA5327FFAF8AA2C80E078CEDCF7157A4A8EED5AA660B43E8F9560CD;SizeAsReceived:7554;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:29 +0000 From: "Kun Qin" To: devel@edk2.groups.io CC: Jian J Wang , Hao A Wu , Dandan Bi , Liming Gao , Jiewen Yao Subject: [PATCH v4 07/20] MdeModulePkg: SmmReportStatusCodeLib: ReportStatusCodeLib in StandaloneMm Date: Tue, 26 Jan 2021 11:46:57 -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: [X5VU62Blg+/zAyRh0F0UlBMTYQfwlZIL] 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-5-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: 85d02a72-bde1-4831-001c-08d8c23335e7 X-MS-TrafficTypeDiagnostic: BN7NAM10HT067: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zYhLnz1Xfrg3Y+M43t69GIB4S6C9L0VnD07Kd17SuF/vkt9K8FKlbstE0GTABNsaaqV9MpnBc3AtSEohaXa53ARhNvcoxJaR+JSeE2dk+IVMPAQlps+9YtWnuPKauCgN1T3n4Btasv/tag+NHDXA5I0u66sy9ZMZdWKMcKXs7WDA2J5GKALGJeLlDqWBibhyf61g+sky+JXS/I6FH3hw6G3reMfUjTEhqhWLHyJv8OZtSUu//7a69reKP98O+RWbORdpQMAbW6MD3DFAy3Q3W+FG04YoLbQpR0FuptEw8KQvPsYh+BPn3tL2j0m371UPq5yJXsNq4uQZ6UQQmhy5Jd6BlZK9NM/7OmKlzFMsrxFXKMkeb+F23Qm+NFN/hDMNp+5ENFf0LstsaaG6kQAEQw== X-MS-Exchange-AntiSpam-MessageData: adhlsiyOy4ADaYJbObVvRJbFxS6KccDc0Y16ZS5opoFDfKOzcHFjcP2XtDPaQGtcFu7km5WdnP+a9MeLM0fbppYWJngI6eaG28lW7GnQ5kicmWbj2pQOq9w+XTxYoirePgrlXc/vVL3572URN73bGA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 85d02a72-bde1-4831-001c-08d8c23335e7 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2021 19:47:27.8336 (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: BN7NAM10HT067 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain This change added support of StandaloneMm for ReportStatusCodeLib. It adds a new instance of ReportStatusCodeLib for MM_STANDALONE type, and abstracts the references of gMmst and gSmst functionalities into separate files in order to link in proper Service Table for SMM core/drivers. Cc: Jian J Wang Cc: Hao A Wu Cc: Dandan Bi Cc: Liming Gao Cc: Jiewen Yao Signed-off-by: Kun Qin Reviewed-by: Hao A Wu --- Notes: v4: - Previously reviewed. No change. =20 v3: - Added reviewed-by tag [Hao] =20 v2: - Removed "EFIAPI" for internal functions. - Minor new file description update. MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib.c = | 16 +++++---- MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibStandaloneM= m.c | 38 ++++++++++++++++++++ MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibTraditional= .c | 38 ++++++++++++++++++++ MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib.h = | 36 +++++++++++++++++++ MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLib.inf = | 4 ++- MdeModulePkg/Library/SmmReportStatusCodeLib/{SmmReportStatusCodeLib.inf = =3D> StandaloneMmReportStatusCodeLib.inf} | 22 ++++++------ MdeModulePkg/MdeModulePkg.dsc = | 1 + 7 files changed, 137 insertions(+), 18 deletions(-) diff --git a/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLi= b.c b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib.c index 3a1772538cdf..fb1769db9223 100644 --- a/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib.c +++ b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib.c @@ -1,5 +1,5 @@ /** @file - Report Status Code Library for SMM Phase. + Report Status Code Library for MM Phase. =20 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent @@ -8,7 +8,7 @@ =20 #include #include -#include +#include #include #include #include @@ -16,10 +16,12 @@ =20 #include #include -#include +#include =20 -EFI_SMM_REPORT_STATUS_CODE mReportStatusCode =3D NULL; -EFI_SMM_STATUS_CODE_PROTOCOL *mStatusCodeProtocol =3D NULL; +#include "ReportStatusCodeLib.h" + +EFI_MM_REPORT_STATUS_CODE mReportStatusCode =3D NULL; +EFI_MM_STATUS_CODE_PROTOCOL *mStatusCodeProtocol =3D NULL; =20 =20 /** @@ -29,14 +31,14 @@ EFI_SMM_STATUS_CODE_PROTOCOL *mStatusCodeProtocol =3D= NULL; NULL is returned if no status code service is available. =20 **/ -EFI_SMM_REPORT_STATUS_CODE +EFI_MM_REPORT_STATUS_CODE InternalGetReportStatusCode ( VOID ) { EFI_STATUS Status; =20 - Status =3D gSmst->SmmLocateProtocol (&gEfiSmmStatusCodeProtocolGuid, NUL= L, (VOID**)&mStatusCodeProtocol); + Status =3D InternalLocateProtocol (&gEfiMmStatusCodeProtocolGuid, NULL, = (VOID**)&mStatusCodeProtocol); if (!EFI_ERROR (Status) && mStatusCodeProtocol !=3D NULL) { return mStatusCodeProtocol->ReportStatusCode; } diff --git a/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLi= bStandaloneMm.c b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusC= odeLibStandaloneMm.c new file mode 100644 index 000000000000..a4c428dc88a9 --- /dev/null +++ b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibStanda= loneMm.c @@ -0,0 +1,38 @@ +/** @file + Abstraction layer for MM service table used by MM ReportStatusCodeLib. + + Copyright (c) Microsoft Corporation. + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +#include + +/** + Returns the first protocol instance that matches the given protocol. + + @param[in] Protocol Provides the protocol to search for. + @param[in] Registration Optional registration key returned from + RegisterProtocolNotify(). + @param[out] Interface On return, a pointer to the first interfac= e that matches Protocol and + Registration. + + @retval EFI_SUCCESS A protocol instance matching Protocol was = found and returned in + Interface. + @retval EFI_NOT_FOUND No protocol instances were found that matc= h Protocol and + Registration. + @retval EFI_INVALID_PARAMETER Interface is NULL. + Protocol is NULL. + +**/ +EFI_STATUS +InternalLocateProtocol ( + IN EFI_GUID *Protocol, + IN VOID *Registration, OPTIONAL + OUT VOID **Interface + ) +{ + return gMmst->MmLocateProtocol (Protocol, Registration, Interface); +} diff --git a/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLi= bTraditional.c b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCo= deLibTraditional.c new file mode 100644 index 000000000000..603e222f5508 --- /dev/null +++ b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibTradit= ional.c @@ -0,0 +1,38 @@ +/** @file + Abstraction layer for SMM service table used by SMM ReportStatusCodeLib. + + Copyright (c) Microsoft Corporation. + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +#include + +/** + Returns the first protocol instance that matches the given protocol. + + @param[in] Protocol Provides the protocol to search for. + @param[in] Registration Optional registration key returned from + RegisterProtocolNotify(). + @param[out] Interface On return, a pointer to the first interfac= e that matches Protocol and + Registration. + + @retval EFI_SUCCESS A protocol instance matching Protocol was = found and returned in + Interface. + @retval EFI_NOT_FOUND No protocol instances were found that matc= h Protocol and + Registration. + @retval EFI_INVALID_PARAMETER Interface is NULL. + Protocol is NULL. + +**/ +EFI_STATUS +InternalLocateProtocol ( + IN EFI_GUID *Protocol, + IN VOID *Registration, OPTIONAL + OUT VOID **Interface + ) +{ + return gSmst->SmmLocateProtocol (Protocol, Registration, Interface); +} diff --git a/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLi= b.h b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib.h new file mode 100644 index 000000000000..2820e40dde19 --- /dev/null +++ b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib.h @@ -0,0 +1,36 @@ +/** @file + Report Status Code Library for MM Phase. + + Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef _MM_RSC_LIB_H_ +#define _MM_RSC_LIB_H_ + +/** + Returns the first protocol instance that matches the given protocol. + + @param[in] Protocol Provides the protocol to search for. + @param[in] Registration Optional registration key returned from + RegisterProtocolNotify(). + @param[out] Interface On return, a pointer to the first interfac= e that matches Protocol and + Registration. + + @retval EFI_SUCCESS A protocol instance matching Protocol was = found and returned in + Interface. + @retval EFI_NOT_FOUND No protocol instances were found that matc= h Protocol and + Registration. + @retval EFI_INVALID_PARAMETER Interface is NULL. + Protocol is NULL. + +**/ +EFI_STATUS +InternalLocateProtocol ( + IN EFI_GUID *Protocol, + IN VOID *Registration, OPTIONAL + OUT VOID **Interface + ); + +#endif // _MM_RSC_LIB_H_ diff --git a/MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCod= eLib.inf b/MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeL= ib.inf index 72496bfababd..02dce09a199d 100644 --- a/MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLib.in= f +++ b/MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLib.in= f @@ -28,6 +28,8 @@ [Defines] =20 [Sources] ReportStatusCodeLib.c + ReportStatusCodeLib.h + ReportStatusCodeLibTraditional.c =20 [Packages] MdePkg/MdePkg.dec @@ -45,7 +47,7 @@ [Guids] gEfiStatusCodeDataTypeDebugGuid ## SOMETIMES_CONSUMES ##= UNDEFINED =20 [Protocols] - gEfiSmmStatusCodeProtocolGuid ## CONSUMES + gEfiMmStatusCodeProtocolGuid ## CONSUMES =20 [Pcd] gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask ## CONSUMES diff --git a/MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCod= eLib.inf b/MdeModulePkg/Library/SmmReportStatusCodeLib/StandaloneMmReportSt= atusCodeLib.inf similarity index 56% copy from MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLi= b.inf copy to MdeModulePkg/Library/SmmReportStatusCodeLib/StandaloneMmReportStatu= sCodeLib.inf index 72496bfababd..866e09249a6a 100644 --- a/MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLib.in= f +++ b/MdeModulePkg/Library/SmmReportStatusCodeLib/StandaloneMmReportStatusC= odeLib.inf @@ -1,9 +1,10 @@ ## @file -# SMM report status code library. +# Standalone MM report status code library. # -# Retrieve status code and report status code in SMM phase. +# Retrieve status code and report status code in MM phase. # # Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) Microsoft Corporation. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -12,13 +13,12 @@ =20 [Defines] INF_VERSION =3D 0x00010005 - BASE_NAME =3D SmmReportStatusCodeLib - MODULE_UNI_FILE =3D SmmReportStatusCodeLib.uni - FILE_GUID =3D 67089D19-B3D6-4d9e-A0EB-FEDC1F83A1EE - MODULE_TYPE =3D DXE_SMM_DRIVER + BASE_NAME =3D StandaloneMmReportStatusCodeLib + FILE_GUID =3D 17C7FC8C-8C5D-497E-9C0E-C21255B30E04 + MODULE_TYPE =3D MM_STANDALONE VERSION_STRING =3D 1.0 - PI_SPECIFICATION_VERSION =3D 0x0001000A - LIBRARY_CLASS =3D ReportStatusCodeLib|DXE_SMM_DRIVER SM= M_CORE + PI_SPECIFICATION_VERSION =3D 0x00010032 + LIBRARY_CLASS =3D ReportStatusCodeLib|MM_STANDALONE =20 # # The following information is for reference only and not required by the = build tools. @@ -28,6 +28,8 @@ [Defines] =20 [Sources] ReportStatusCodeLib.c + ReportStatusCodeLib.h + ReportStatusCodeLibStandaloneMm.c =20 [Packages] MdePkg/MdePkg.dec @@ -36,7 +38,7 @@ [Packages] [LibraryClasses] PcdLib BaseMemoryLib - SmmServicesTableLib + MmServicesTableLib DebugLib MemoryAllocationLib =20 @@ -45,7 +47,7 @@ [Guids] gEfiStatusCodeDataTypeDebugGuid ## SOMETIMES_CONSUMES ##= UNDEFINED =20 [Protocols] - gEfiSmmStatusCodeProtocolGuid ## CONSUMES + gEfiMmStatusCodeProtocolGuid ## CONSUMES =20 [Pcd] gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask ## CONSUMES diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index 9afd40eeed46..200fbcc18a18 100644 --- a/MdeModulePkg/MdeModulePkg.dsc +++ b/MdeModulePkg/MdeModulePkg.dsc @@ -474,6 +474,7 @@ [Components.IA32, Components.X64] } MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe.inf MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLib.inf + MdeModulePkg/Library/SmmReportStatusCodeLib/StandaloneMmReportStatusCode= Lib.inf MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerSmm.inf MdeModulePkg/Universal/ReportStatusCodeRouter/Smm/ReportStatusCodeRouter= Smm.inf MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf --=20 2.30.0.windows.1