From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (NAM11-CO1-obe.outbound.protection.outlook.com [40.92.18.42]) by mx.groups.io with SMTP id smtpd.web11.1119.1608317431334224229 for ; Fri, 18 Dec 2020 10:50:31 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@outlook.com header.s=selector1 header.b=Ik4JHZxs; spf=pass (domain: outlook.com, ip: 40.92.18.42, mailfrom: kun.q@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gjbcKTW6rchmiPTvsPtG9Sc67LzVaPfnj4md+hwTbZGkp1Y3W3b0zWU8ypsAs2+iAzhIOBprt32Kt83nT+972bq1xPj6EUTmMzGMGL1VfUEZG568KDoOrWIoY89bQ2YTs+3+u7uewD8Tig9ufyP0w/S/VhIBjqziFU4LKNB94FGS3PvurMhr3uh0UH4fr+PfPKgUW71MOBhvgxg0//LXNtY9zFnBwrV5ohqpvPKN9Xf7BpvdRX2FO8KIjt2tP+cABBOyJOVuo4jvlZC+5PSd3jLU3zceMe62nAA2ilGAhIX9442R0M92xW9YpyQ6OVXAWM1bvGbRXiFaStyxAPv9cA== 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=Fmp3QCAFLBLnvGqZ4drrLo8RtCf9jzB8ro9xkeY5kj8=; b=AX25LfUAVGn/O8JnEzdDT5mxIU27cANBeaxdvDgsECb6tQWiZXkjpT0N1Q7lZqesE+mGBiqQGyrZ3t6X8IFr9W+PEfE8xxehYjPRPSe91fE1NoTzvEF4+054y/+S02oLzrMgBXje8NgLi6aEfIgMU+++vgefCR7bUCtrI6ANpqJ0QURLFvn0zV2wOGchSK3TPuUGc8l1bOmV87h9OPpXNXic1w48Bn4gJB0yNMGp/wl7SiMDx1W9tjxZ6PhF77xA2sEOe7bgNurFXmQ13QZB5pNQu1z6DTPPBylvJ9JXygodkScZvVeBE74slVDONPl7WYf9xguYCJJFVgdPBxRJ/w== 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=Fmp3QCAFLBLnvGqZ4drrLo8RtCf9jzB8ro9xkeY5kj8=; b=Ik4JHZxsEFBRlrXhpOM3x3UXrZHJLspYRX9wAwCFxDS9qmF7B084gHVuD47lxAu/wdpiNWIW3pNeMiUWjLxcs9SMusN0NHABRjoFFuuLw28uGdVTf7CkmEiHqYqSVi0b0z4+FdljQPXHzU/bptyztIUGuljCdwgNTtsd3CRNCWSm7o0Qt2Su97PXwe0zaDxa4Po32y8RW+YTQ7/K0r/i34ehbhfyXw2Vz9s9cYjuNNFRDsMIPSV1tQqfa80jgwjmPpiorfhPpnm5IdziZhXRaAGmmP9CbQ6eYQqWP60+7onRPXwf+NcUo5sBtd2EvqYP7bP/qy4cjfKpn1uOdDt6tw== Received: from DM6NAM11FT039.eop-nam11.prod.protection.outlook.com (2a01:111:e400:fc4d::40) by DM6NAM11HT186.eop-nam11.prod.protection.outlook.com (2a01:111:e400:fc4d::454) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.25; Fri, 18 Dec 2020 18:50:30 +0000 Received: from MWHPR06MB3102.namprd06.prod.outlook.com (2a01:111:e400:fc4d::48) by DM6NAM11FT039.mail.protection.outlook.com (2a01:111:e400:fc4d::83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.25 via Frontend Transport; Fri, 18 Dec 2020 18:50:30 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:2361675CEF7CE69BC8C2F5ED8CC1A34F52DC53CD6214DA38A42B7187FCB7E8F6;UpperCasedChecksum:ADA24A6F96AC3359D082B551EEAB89781D3C011195AB0508A0B422A6889A6A40;SizeAsReceived:7486;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.3654.026; Fri, 18 Dec 2020 18:50:30 +0000 From: "Kun Qin" To: devel@edk2.groups.io CC: Jian J Wang , Hao A Wu , Dandan Bi , Liming Gao Subject: [PATCH v1 06/15] MdeModulePkg: SmmReportStatusCodeLib: ReportStatusCodeLib in StandaloneMm Date: Fri, 18 Dec 2020 10:50:02 -0800 Message-ID: X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20201218185011.1366-1-kun.q@outlook.com> References: <20201218185011.1366-1-kun.q@outlook.com> X-TMN: [AXh0Vz9fICF7Imfh/lGNrGgUIj0SFym3] X-ClientProxiedBy: MW2PR16CA0018.namprd16.prod.outlook.com (2603:10b6:907::31) To MWHPR06MB3102.namprd06.prod.outlook.com (2603:10b6:301:3e::35) Return-Path: kun.q@outlook.com X-Microsoft-Original-Message-ID: <20201218185011.1366-7-kun.q@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (50.35.88.161) by MW2PR16CA0018.namprd16.prod.outlook.com (2603:10b6:907::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Fri, 18 Dec 2020 18:50:30 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: d64615d0-6eb6-48ff-22bc-08d8a385caff X-MS-TrafficTypeDiagnostic: DM6NAM11HT186: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s5Z4a7Gff6Y2m9aLH8agLGe+oqb+ge7MTk9Ow5IZJQ5upBEskCc7ET/T7BqD+6f+9oG5no0UTYBg/tojEqZmuoND/NtVRlRdv3xIg+do2t6SEMo/hdQWvPlUzXmmduKMO4fYugHdt0KEzI8fZKyNkrjkd3v+cDZ5pCrDe4/DevzGm1knXkU6yp9vg2Pw9eUO3ojg6SD1L2sgU3ypgu1G0YjrgH5QX4X4VfQPAg3CdF3s4Cmfz4wbwlYrPOnyldRF X-MS-Exchange-AntiSpam-MessageData: aFsB6eia7WjduSgxRrFjQr11xFhQigX7VL7Gzim7/EsEVN3R2iqULipOvOa40wPLE/5EL67c3dcxZ8CZ6cZn1ZfeCImBKUIavO+gAN2eNf3IljrK4N1bgfdFrVxX6sJKnm93q/wwzjG3t0gSeS2J4A== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2020 18:50:30.3481 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: d64615d0-6eb6-48ff-22bc-08d8a385caff X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT039.eop-nam11.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: DM6NAM11HT186 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 Signed-off-by: Kun Qin --- MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib.c = | 16 ++++---- MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibStandaloneM= m.c | 39 ++++++++++++++++++++ MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibTraditional= .c | 39 ++++++++++++++++++++ MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib.h = | 37 +++++++++++++++++++ MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLib.inf = | 4 +- MdeModulePkg/Library/SmmReportStatusCodeLib/{SmmReportStatusCodeLib.inf = =3D> StandaloneMmReportStatusCodeLib.inf} | 17 +++++---- MdeModulePkg/MdeModulePkg.dsc = | 1 + 7 files changed, 137 insertions(+), 16 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..fc47dffe9ffb --- /dev/null +++ b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibStanda= loneMm.c @@ -0,0 +1,39 @@ +/** @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 +EFIAPI +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..6b3a7c6051c5 --- /dev/null +++ b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibTradit= ional.c @@ -0,0 +1,39 @@ +/** @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 +EFIAPI +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..9a16741e64f6 --- /dev/null +++ b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib.h @@ -0,0 +1,37 @@ +/** @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 +EFIAPI +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 64% copy from MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLi= b.inf copy to MdeModulePkg/Library/SmmReportStatusCodeLib/StandaloneMmReportStatu= sCodeLib.inf index 72496bfababd..11ecc67fc4fa 100644 --- a/MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLib.in= f +++ b/MdeModulePkg/Library/SmmReportStatusCodeLib/StandaloneMmReportStatusC= odeLib.inf @@ -12,13 +12,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 +27,8 @@ [Defines] =20 [Sources] ReportStatusCodeLib.c + ReportStatusCodeLib.h + ReportStatusCodeLibStandaloneMm.c =20 [Packages] MdePkg/MdePkg.dec @@ -36,7 +37,7 @@ [Packages] [LibraryClasses] PcdLib BaseMemoryLib - SmmServicesTableLib + MmServicesTableLib DebugLib MemoryAllocationLib =20 @@ -45,7 +46,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 cd91a70b4fdd..05bf5fe08094 100644 --- a/MdeModulePkg/MdeModulePkg.dsc +++ b/MdeModulePkg/MdeModulePkg.dsc @@ -473,6 +473,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.28.0.windows.1