From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (NAM02-SN1-obe.outbound.protection.outlook.com [40.92.5.14]) by mx.groups.io with SMTP id smtpd.web09.1129.1610663815663782335 for ; Thu, 14 Jan 2021 14:36:55 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@outlook.com header.s=selector1 header.b=chSnOTDA; spf=pass (domain: outlook.com, ip: 40.92.5.14, mailfrom: kun.q@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PRTKEKVvBjXolVUCkQsV7r77guiBngAyWPfTRZ8MgyQhGFxkuy9b4+GNDjKrN4Fw+7kfqpoEjG05BNXhVdl65XpIg9XDBY2SX1dQTx1vENLssJq0hjnYKLRzoxim/qjt+fVKSztVKAk+qmKI0lRnjpmkG/RbgV19UGh1eVXsMsr+NvX5q+bEqvAPwPDXeIVbWgi8CyYcyjGGcAUahY41YOmQ+FUjX+f6w7vLMOM1ap6LmUnggYSPBWjx9Nz9qTIDvG5NtOCFtZsl9c79uSFMwDkE5w/WfI0bGevEz2Y5nzveSFRk8QMaeXmxVmHkvGwvswUEtTvoj2w5spgBNTphgA== 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=DTYHHVqPMe5KiCGbNPt5P0JWNJbGFsx+uDTjByL92/Q=; b=WIErX4ds2ETJf7BuA9AU2m48HsoST9w583wGRzSlMKyXy08OlZL5vOdg4MC1El9oTJCPdtHLeCL1XIlEd/xGcq59wAnJWPaVHEgULVRJd9QjrEAizor2H5mNqla4ZLTqrW6Rd4qxT3MtvYFmi4gOz4q8xFXuTB9wW2eURYMqQukTs5/gWbsJEcalR3bUcYSFgAcRZsOLb9QVJWUVEbTavbWEtoentTb7n5Pwr6A+wfM/YqwbEvvrlv8hNn+HwrVenb4FN2ZHSUeFZokKNhiJbQoYZnzNbrxEEri3qIPd+hKo+HBz3u2z4GRKrjs5kJEWXNHvveP32nqq7VraNhtG6A== 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=DTYHHVqPMe5KiCGbNPt5P0JWNJbGFsx+uDTjByL92/Q=; b=chSnOTDA5mWJ+aPn++YELKvqewErN7c6bwV5xw2V+Pxd9xsoGP0geusNowtRIsy8+4cCTiw14vf7WQ5M39hJD0np196k420GNqGaKW7oLaTeE/XsjIwFRZNr0TmVRayjjRRNtnVpeeOwErQOXStUNsTr9OMEnk0diXyL8/ejyzwJd7ojRlzAuq/qyOO0MY+IgkXbMc8TpftJFVa97ukDbe3qXfNqvHtsC933eRlRloMer0tWcYsuCGV6ZM+vdFfPxBWdlprSFJTzYKJfObOkWrKPMWdS92ACp3gyEvetr72hIJbajvBVhE3TbSYT4/zQi1Yuj+kfbo7/Od3ev+bFGA== Received: from CY1NAM02FT023.eop-nam02.prod.protection.outlook.com (10.152.74.58) by CY1NAM02HT088.eop-nam02.prod.protection.outlook.com (10.152.74.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6; Thu, 14 Jan 2021 22:36:54 +0000 Received: from MWHPR06MB3102.namprd06.prod.outlook.com (2a01:111:e400:7e45::41) by CY1NAM02FT023.mail.protection.outlook.com (2a01:111:e400:7e45::237) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Thu, 14 Jan 2021 22:36:54 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:B273C5589C95733B35A79090AE5BC8C426A7E59F0793508400AE1C71AD36E119;UpperCasedChecksum:647A7B30F811CBC50FFB73D79D1A46EE1B614EEDB84393A7D9CBEC04DBA9EB34;SizeAsReceived:7548;Count:47 Received: from MWHPR06MB3102.namprd06.prod.outlook.com ([fe80::acb3:ab69:563d:b0d6]) by MWHPR06MB3102.namprd06.prod.outlook.com ([fe80::acb3:ab69:563d:b0d6%5]) with mapi id 15.20.3742.012; Thu, 14 Jan 2021 22:36:54 +0000 From: "Kun Qin" To: devel@edk2.groups.io CC: Jian J Wang , Hao A Wu , Dandan Bi , Liming Gao , Jiewen Yao Subject: [PATCH v3 07/18] MdeModulePkg: SmmReportStatusCodeLib: ReportStatusCodeLib in StandaloneMm Date: Thu, 14 Jan 2021 14:36:26 -0800 Message-ID: X-Mailer: git-send-email 2.30.0.windows.1 In-Reply-To: <20210114223637.2737-1-kun.q@outlook.com> References: <20210114223637.2737-1-kun.q@outlook.com> X-TMN: [oUwPV+usPwfSrp9nRtPBe9kf4jJl2wRL] X-ClientProxiedBy: MW4PR04CA0389.namprd04.prod.outlook.com (2603:10b6:303:81::34) To MWHPR06MB3102.namprd06.prod.outlook.com (2603:10b6:301:3e::35) Return-Path: kun.q@outlook.com X-Microsoft-Original-Message-ID: <20210114223637.2737-3-kun.q@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (50.35.88.161) by MW4PR04CA0389.namprd04.prod.outlook.com (2603:10b6:303:81::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Thu, 14 Jan 2021 22:36:54 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: e3f40e7c-110b-4c08-a66c-08d8b8dce4f3 X-MS-TrafficTypeDiagnostic: CY1NAM02HT088: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OmZULj5F4daxW6NAaP81dLh+Y18joCulEV86E2YillupjWwZDPetMj9fORrwW+zNjU4Y9egETJKoVBjA2gCQI2QkpTugrqvsYc7JH8P+jqKr7FzDOELCCdwAC880MWkWoDYLBVYSpBtZFOyVIUf2NnoUaYL/FDr1cvlk/lYMxpalOitgn9x8o+5imYuZrp+c5n1EKyWbWtiFZPopOX5tktvHA4683JhvKYYEJl87S3B86zf26eA8Uis9t8+uT9Zv X-MS-Exchange-AntiSpam-MessageData: Mq3ke7DuIU6oRoBVtyV96HuduLzFbhGhdEr4DfM5LQYtEof3LxiaCfKiMdO2VKjVX5oFJdKYfaQpSBryVS79gqtblOL16PW+xbJ0o1M7freuHz5N1lkfjmi1lwBb52iN9B0oTo/47sWPMRQg3M5Sow== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jan 2021 22:36:54.6114 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: e3f40e7c-110b-4c08-a66c-08d8b8dce4f3 X-MS-Exchange-CrossTenant-AuthSource: CY1NAM02FT023.eop-nam02.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: CY1NAM02HT088 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: 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