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 []) by mx.groups.io with SMTP id smtpd.web09.1581.1609873194337953645 for ; Tue, 05 Jan 2021 10:59:56 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@outlook.com header.s=selector1 header.b=uW6PldaX; spf=softfail (domain: outlook.com, ip: , mailfrom: kun.q@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=f+1pP5W0a7yl3FHlY+U7MCQ/qGce9Vjt75p5wc2pA3v+akifNrHAwtjC4iJhiYtiH0vqiOTV6LIRxQGJqX4TK+3FEgpG5pYkA0Ihhxfw9zNiK527RBEZmcoYweWGtmPRJkoWquoYzKhqiq7Xjg6rxA+f8EGXPvriQlSgvmBQ12ujgKCztD/i4Ed95FK/slRrECK4W4IfmLu088Y9v7qx8g12hZD5FDUUMeIl9XiaIZgSuB3X5gTHfawxYlcwNLLeI4+5vqaYy+r5/tcvqm8D32R1PBsLvYH9nuPnfa/zEWFbAqCCzaznRjDhDPXMDN/9s0u7q4cCKB0LJ+ytZESZwA== 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=vy1fz+jqs7yF75C3kNhaVFgFVq2H8tgyJsiTxym5hxk=; b=bdZ+68/2TxJCveg+EceeM0i024yyBZsYDpzbtjpFpc1sTUf706kzk5ANReIIA4B/mvg9cfZ2wLenZa+MmrqWxP9U7Y1AMaG6rQ7tiTinTtQmK6EXNXFuIcHKvxIiv1fRyaOs4soZeY6XS11TvoSv4PpWy780dn4u56BNhdHFKKGjbsq0/TdAhuRxEh2YE3BKyrAMOv11HNKi2jr0KQCo/C4ZKrr8y8b8Y8iAyacN5TPHgwFrrWuRS8E8UmUjHsxq5XSvjwJv6UXef40GEO2KSe7kyx/H5LNyw+yXwJXQY1gwt1x8S2iVWu1ng1Y+2CUPQZCo45Rs0qCw0MGL8X2zig== 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=vy1fz+jqs7yF75C3kNhaVFgFVq2H8tgyJsiTxym5hxk=; b=uW6PldaXWxh0ehVXoPi93YiZUntRtJUeF88kanB2iY3cEK2IXPAN8f2xh6rBlwagiKC3Kz8/63pTznb08o2bwjl2GHmzfdScnEAgPSu+zJnKv8SUKysFg6KdE4tSN7IWUdE/TUDSA5fZqogW9TGYNeCQvVZd89nry4hoBEEt8tqfgMion14UyBgNABsV8H8lSFzBQtoVXB7zYLc9xUPbCDBiJ2PJ0sJYXaEfl+ZwhjikFx4ai1v2rm0vFuB1hoamauYFJm2GYxTB1O0jibdA8BNz5oteY2PoNQzZQrSGufuKfOe9MJGNCC6IGeaST35Bo5E+jUnOjWQHo3t8WiP6ug== Received: from CY1NAM02FT003.eop-nam02.prod.protection.outlook.com (10.152.74.53) by CY1NAM02HT117.eop-nam02.prod.protection.outlook.com (10.152.74.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.22; Tue, 5 Jan 2021 18:59:55 +0000 Received: from MWHPR06MB3102.namprd06.prod.outlook.com (2a01:111:e400:7e45::53) by CY1NAM02FT003.mail.protection.outlook.com (2a01:111:e400:7e45::151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.22 via Frontend Transport; Tue, 5 Jan 2021 18:59:55 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:FAB832C43783E09A9141E45A2132EDDF049B7B634B6521392ED50BD4F5254A20;UpperCasedChecksum:57F6CA4AD3009C356E21CC76AE787C7496C193471A2BB6F414EE207D215F025F;SizeAsReceived:7555;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.3721.024; Tue, 5 Jan 2021 18:59:55 +0000 From: "Kun Qin" To: devel@edk2.groups.io CC: Jian J Wang , Hao A Wu , Dandan Bi , Liming Gao , Jiewen Yao Subject: [PATCH v2 06/16] MdeModulePkg: SmmReportStatusCodeLib: ReportStatusCodeLib in StandaloneMm Date: Tue, 5 Jan 2021 10:59:25 -0800 Message-ID: X-Mailer: git-send-email 2.30.0.windows.1 In-Reply-To: <20210105185935.3769-1-kun.q@outlook.com> References: <20210105185935.3769-1-kun.q@outlook.com> X-TMN: [558ybllXoLOWtd9QhUyhWxU30qM3aLoy] X-ClientProxiedBy: MWHPR22CA0045.namprd22.prod.outlook.com (2603:10b6:300:69::31) To MWHPR06MB3102.namprd06.prod.outlook.com (2603:10b6:301:3e::35) Return-Path: kun.q@outlook.com X-Microsoft-Original-Message-ID: <20210105185935.3769-7-kun.q@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (50.35.88.161) by MWHPR22CA0045.namprd22.prod.outlook.com (2603:10b6:300:69::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 5 Jan 2021 18:59:54 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: c909ea26-942a-4fc0-2f55-08d8b1ac1713 X-MS-TrafficTypeDiagnostic: CY1NAM02HT117: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gqihguqW9nyrXqaH1dn6ENSI21sFkpfAkl/CxDngAq3HotW8Zl+5eWiYuYJ+cfyFDLrKh5tUJiBbG/6JAPTwOP5+VhVj29ye+ZXGyfc8eJPXQZTEQFoxMtTsO7vHp8LVUpIL7YtPWqHhcyhTyvHvBshJc7Ml1IovjqWAXVQWm6fd9JJLaAmji+NcCGcGOyuew0GLBYOOeJFAUM4czszsjvz6qn2G70sWTuzGv7zTKEX8A0Iwz69zoQjfuSrTpegz X-MS-Exchange-AntiSpam-MessageData: zEEbJ50hDhZmNafI2jVhly94gcWUXHIwOf9HlgXNyosQsTFIYRSQHhRhzVXkHFRCgoHhyFwuHOaCcqqCSRr/tG+Wl5FTgAR2wS2qN0LsvGgGd1Cw9b6FF5Ztwjm3rXT0QskAwyjXV/jorIHOaWvZ/A== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2021 18:59:55.1460 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: c909ea26-942a-4fc0-2f55-08d8b1ac1713 X-MS-Exchange-CrossTenant-AuthSource: CY1NAM02FT003.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: CY1NAM02HT117 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 --- Notes: 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