From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-CY1-obe.outbound.protection.outlook.com (NAM02-CY1-obe.outbound.protection.outlook.com [40.92.4.65]) by mx.groups.io with SMTP id smtpd.web12.453.1608664516518435210 for ; Tue, 22 Dec 2020 11:15:17 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@outlook.com header.s=selector1 header.b=MAeRgkvA; spf=pass (domain: outlook.com, ip: 40.92.4.65, mailfrom: kun.q@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EDhErfxImFBQlpoR3f0gJiKH/EGzibXMtUFiI5VZq7ZkCHW5peMLNVCD8N/so4wZuLPq/we+grThM75SgBVrj1yF+y2eVlQgRZlqnAe2e484MYH4oYyRp1t3Nqt029jVqYazLY7OKadricbEgOWGbg/6GRwaau2g7USuoa3HHrdhC3cXDlpi2/H0/XLwhAXZH++w9fJ5sQAQsHZ6odVt/w9N4n3ruYYH8IYFNpUj6IPMd50+COd5hn+F9f/YYNnJVdql0j5DRBddBiORVuXqzKlu8V3nF83uMMvSLab5eEeQRRQm/0cjLNyZqIhCrWhB6L3lfFgV3U8t4GgFPlA6VA== 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=oniS0lX8t1bjukqhGbIriZWn+GUgZhHKfGkLHCq7NSM=; b=S4E7OOROKl86NKsrBKsI1HjmTOwX2s9W9cI8BQcvAmubM7nqL8gkDbTfuH7PAgOmmAXMhVHXiRt5BMJ0Rj3iij42FOx5Ha8VWwTqxMGWbE/Fc5U/rok3hNkLUR4CgVm4xxghYZ9yI+hi0CTrpvaQlTKJ9ge3gEKDrxEAX8pAafqJEtMZGl9MIISul5lSFk5PPf6vnsDexRSlGbmVNVqjqby6zzbDwmW4fXla1D8jKZi2Q5S/lNWwUaxzJKQKmtTGFrxM0bJ6JbkRCQAFIjmFPxOQNxxNXcaHeaz/mVI1qlurfO5g2Rhy1ApzUCqex3WaKNXwUAH7gsGME7rK2KJQAw== 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=oniS0lX8t1bjukqhGbIriZWn+GUgZhHKfGkLHCq7NSM=; b=MAeRgkvAnc/2/onTHK71yZUmr8qxkOYivcIa+5DSZ8MF+2u44agBREBigeeuKpsaqfQ1DFoWZADR18yrRmZj42WmBg/6Dcb81dFgPvtru1pYJLqB34bsPOGvTB9B8cZW1og7gvpqD/iHbinVZGzNIucz0DCTFJkYiayZPWe2ds6SUcyQkcMMBzleGodWb7/5/l3s50ePMvk8vNGlZeznXPoSYOM4MZCfc2iFaWpryffDF+5h75UE9MupHjBNLY26GBXIrn3Q3/NhR70H3Sx/TcxxvxLQE3D8I+E0XVliFw/v5hyGaz64TdT8E6tNKSi4Mviy9po7GONLgEV37dQ1uw== Received: from BL2NAM02FT016.eop-nam02.prod.protection.outlook.com (10.152.76.52) by BL2NAM02HT086.eop-nam02.prod.protection.outlook.com (10.152.77.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.25; Tue, 22 Dec 2020 19:15:13 +0000 Received: from DM5PR06MB3098.namprd06.prod.outlook.com (2a01:111:e400:7e46::46) by BL2NAM02FT016.mail.protection.outlook.com (2a01:111:e400:7e46::427) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.25 via Frontend Transport; Tue, 22 Dec 2020 19:15:13 +0000 Received: from DM5PR06MB3098.namprd06.prod.outlook.com ([fe80::4830:27de:1fd4:e993]) by DM5PR06MB3098.namprd06.prod.outlook.com ([fe80::4830:27de:1fd4:e993%6]) with mapi id 15.20.3676.033; Tue, 22 Dec 2020 19:15:13 +0000 From: "Kun Qin" To: "devel@edk2.groups.io" , "hao.a.wu@intel.com" CC: "Wang, Jian J" , "Bi, Dandan" , Liming Gao , "Yao, Jiewen" Subject: Re: [edk2-devel] [PATCH v1 06/15] MdeModulePkg: SmmReportStatusCodeLib: ReportStatusCodeLib in StandaloneMm Thread-Topic: [edk2-devel] [PATCH v1 06/15] MdeModulePkg: SmmReportStatusCodeLib: ReportStatusCodeLib in StandaloneMm Thread-Index: AQHW1W6oojBHwsGCV0ysC5Z2IgsQJKoC0A2AgACviAs= Date: Tue, 22 Dec 2020 19:15:13 +0000 Message-ID: References: <20201218185011.1366-1-kun.q@outlook.com> , In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:0AC4D43761DFBB00485D1DFEC71FF94BDAAE88BC76B47B77C720F08A3155F769;UpperCasedChecksum:D2704D83708E4F0E926F8A1AE5DB0FDB021F16BD996A3FFD1C51873EC2D81903;SizeAsReceived:7273;Count:44 x-tmn: [YViilZCrehgX2Dly2moFdt5GOSwBwf/F] x-ms-publictraffictype: Email x-incomingheadercount: 44 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: 94f724d4-afc5-4610-08c8-08d8a6ade897 x-ms-traffictypediagnostic: BL2NAM02HT086: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: NRQv1yqktPvUdBS+Jk903ZpyfzKZjzWqRmci824XSUdSPkb9c0igl4l1EMNjhsvXuoImTgkOoPX1xBQrDTnKLv7eZW8raXkFQ+PBIWQj9FHmnRrWosSTPXPw/VIrzxMiHZtFjht+ZdtnOZq9sTdZ+q/UMqu7v4eAsD7kGz6T3gl+KKKmDOrjJi6onTUAXd/0Xz+K+WyPnogpjxkwqI9hg7+MmLoPX8W6PnCcGl0BzahNHs/ouJdfXqwqMkGTyxJqilET5Zf8IbHp4HMta5Hg2nolv/OH/QEWu18wndZIWNQ= x-ms-exchange-antispam-messagedata: DvVsiVZbPFDuy4oYqI9NnHhCAcfC+sAFThYMSd9tRp/kHIURwy5qQcCzXl3UWXqO5L4Dn6doqsLv1lr6uStyI0gogrtjyo+tRVH4OJr0SPuHBMme1DH+7Z0nplZAooD1eajQMiVltAjGV+znqBzbcw== x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: BL2NAM02FT016.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 94f724d4-afc5-4610-08c8-08d8a6ade897 X-MS-Exchange-CrossTenant-originalarrivaltime: 22 Dec 2020 19:15:13.4040 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2NAM02HT086 Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_DM5PR06MB3098C4151F8CA2BC71AB8B51F3DF0DM5PR06MB3098namp_" --_000_DM5PR06MB3098C4151F8CA2BC71AB8B51F3DF0DM5PR06MB3098namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Hao, That was my original plan, but doing it might require a MmServiceTableLib = instance for SMM_CORE type if PiSmmCore links in RSC lib (similar to PiSmmC= oreSmmServicesTableLib). We can create such an instance just like PiSmmCore= SmmServicesTableLib, but the implementation will pull in gSmmCoreSmst as an= external variable and cast it from `EFI_SMM_SYSTEM_TABLE2` to `EFI_MM_SYST= EM_TABLE`, which does not look clean. Thus I just abstract the routine to a= void it. Please let me know if you have better ideas, I can add the change for next= patch series. Thanks, Kun From: Wu, Hao A Sent: Tuesday, December 22, 2020 00:35 To: devel@edk2.groups.io; kun.q@outlook.com Cc: Wang, Jian J; Bi, Dandan; Liming Gao; Yao, Jiewen Subject: Re: [edk2-devel] [PATCH v1 06/15] MdeModulePkg: SmmReportStatusCo= deLib: ReportStatusCodeLib in StandaloneMm > -----Original Message----- > From: devel@edk2.groups.io On Behalf Of Kun Qin > Sent: Saturday, December 19, 2020 2:50 AM > To: devel@edk2.groups.io > Cc: Wang, Jian J ; Wu, Hao A = ; > Bi, Dandan ; Liming Gao > Subject: [edk2-devel] [PATCH v1 06/15] MdeModulePkg: > SmmReportStatusCodeLib: ReportStatusCodeLib in StandaloneMm > > 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/dri= vers. Sorry for a question. Do you think it is feasible to use: gMmst->MmLocateProtocol to locate gEfiMmStatusCodeProtocolGuid and avoid introducing 2 separate implementations for internal function Int= ernalLocateProtocol()? Since I found that the definitions for gEfiMmStatusCodeProtocolGuid an gEf= iSmmStatusCodeProtocolGuid are identical. Best Regards, Hao Wu > > 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/ReportStatusCodeLibSta > ndaloneMm.c | 39 ++++++++++++++++++++ > > MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibTra > ditional.c | 39 ++++++++++++++++++++ > MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib.h > | 37 +++++++++++++++++++ > > MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLi > b.inf | 4 +- > > MdeModulePkg/Library/SmmReportStatusCodeLib/{SmmReportStatusCode > Lib.inf =3D> StandaloneMmReportStatusCodeLib.inf} | 17 +++++---- > MdeModulePkg/MdeModulePkg.dsc > | 1 + > 7 files changed, 137 insertions(+), 16 deletions(-) > > diff --git > a/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib.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. > > Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved. > SPDX-License-Identifier: BSD-2-Clause-Patent @@ -8,7 +8,7 @@ > > #include #include = - > #include > +#include > #include > #include > #include > @@ -16,10 +16,12 @@ > > #include > #include -#include > > +#include > > -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; > > > /** > @@ -29,14 +31,14 @@ EFI_SMM_STATUS_CODE_PROTOCOL > *mStatusCodeProtocol =3D NULL; > NULL is returned if no status code service is available. > > **/ > -EFI_SMM_REPORT_STATUS_CODE > +EFI_MM_REPORT_STATUS_CODE > InternalGetReportStatusCode ( > VOID > ) > { > EFI_STATUS Status; > > - Status =3D gSmst->SmmLocateProtocol (&gEfiSmmStatusCodeProtocolGuid, > NULL, (VOID**)&mStatusCodeProtocol); > + Status =3D InternalLocateProtocol (&gEfiMmStatusCodeProtocolGuid, NUL= L, > + (VOID**)&mStatusCodeProtocol); > if (!EFI_ERROR (Status) && mStatusCodeProtocol !=3D NULL) { > return mStatusCodeProtocol->ReportStatusCode; > } > diff --git > a/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibS > tandaloneMm.c > b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibS > tandaloneMm.c > new file mode 100644 > index 000000000000..fc47dffe9ffb > --- /dev/null > +++ > b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibS > ta > +++ ndaloneMm.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 inter= face that > matches Protocol and > + Registration. > + > + @retval EFI_SUCCESS A protocol instance matching Protocol w= as > found and returned in > + Interface. > + @retval EFI_NOT_FOUND No protocol instances were found that > match 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/ReportStatusCodeLibT > raditional.c > b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibT > raditional.c > new file mode 100644 > index 000000000000..6b3a7c6051c5 > --- /dev/null > +++ > b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibT > ra > +++ ditional.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 inter= face that > matches Protocol and > + Registration. > + > + @retval EFI_SUCCESS A protocol instance matching Protocol w= as > found and returned in > + Interface. > + @retval EFI_NOT_FOUND No protocol instances were found that > match 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/ReportStatusCodeLib. > 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 inter= face that > matches Protocol and > + Registration. > + > + @retval EFI_SUCCESS A protocol instance matching Protocol w= as > found and returned in > + Interface. > + @retval EFI_NOT_FOUND No protocol instances were found that > match 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/SmmReportStatusCod > eLib.inf > index 72496bfababd..02dce09a199d 100644 > --- > a/MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCod > eLib.inf > +++ > b/MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCod > eLib > +++ .inf > @@ -28,6 +28,8 @@ [Defines] > > [Sources] > ReportStatusCodeLib.c > + ReportStatusCodeLib.h > + ReportStatusCodeLibTraditional.c > > [Packages] > MdePkg/MdePkg.dec > @@ -45,7 +47,7 @@ [Guids] > gEfiStatusCodeDataTypeDebugGuid ## SOMETIMES_CONSUMES > ## UNDEFINED > > [Protocols] > - gEfiSmmStatusCodeProtocolGuid ## CONSUMES > + gEfiMmStatusCodeProtocolGuid ## CONSUMES > > [Pcd] > gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask ## > CONSUMES diff --git > a/MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCod > eLib.inf > b/MdeModulePkg/Library/SmmReportStatusCodeLib/StandaloneMmReport > StatusCodeLib.inf > similarity index 64% > copy from > MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLi > b.inf > copy to > MdeModulePkg/Library/SmmReportStatusCodeLib/StandaloneMmReportSt > atusCodeLib.inf > index 72496bfababd..11ecc67fc4fa 100644 > --- > a/MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCod > eLib.inf > +++ > b/MdeModulePkg/Library/SmmReportStatusCodeLib/StandaloneMmReport > Stat > +++ usCodeLib.inf > @@ -12,13 +12,12 @@ > > [Defines] > INF_VERSION =3D 0x00010005 > - BASE_NAME =3D SmmReportStatusCodeLib > - MODULE_UNI_FILE =3D SmmReportStatusCodeLib.uni > - FILE_GUID =3D 67089D19-B3D6-4d9e-A0EB-FEDC1F83A1= EE > - MODULE_TYPE =3D DXE_SMM_DRIVER > + BASE_NAME =3D StandaloneMmReportStatusCodeLib > + FILE_GUID =3D 17C7FC8C-8C5D-497E-9C0E-C21255B30E= 04 > + MODULE_TYPE =3D MM_STANDALONE > VERSION_STRING =3D 1.0 > - PI_SPECIFICATION_VERSION =3D 0x0001000A > - LIBRARY_CLASS =3D ReportStatusCodeLib|DXE_SMM_DRIVER > SMM_CORE > + PI_SPECIFICATION_VERSION =3D 0x00010032 > + LIBRARY_CLASS =3D ReportStatusCodeLib|MM_STANDALONE > > # > # The following information is for reference only and not required by t= he > build tools. > @@ -28,6 +27,8 @@ [Defines] > > [Sources] > ReportStatusCodeLib.c > + ReportStatusCodeLib.h > + ReportStatusCodeLibStandaloneMm.c > > [Packages] > MdePkg/MdePkg.dec > @@ -36,7 +37,7 @@ [Packages] > [LibraryClasses] > PcdLib > BaseMemoryLib > - SmmServicesTableLib > + MmServicesTableLib > DebugLib > MemoryAllocationLib > > @@ -45,7 +46,7 @@ [Guids] > gEfiStatusCodeDataTypeDebugGuid ## SOMETIMES_CONSUMES > ## UNDEFINED > > [Protocols] > - gEfiSmmStatusCodeProtocolGuid ## CONSUMES > + gEfiMmStatusCodeProtocolGuid ## CONSUMES > > [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.i > nf > > MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLi > b.inf > + > + > MdeModulePkg/Library/SmmReportStatusCodeLib/StandaloneMmReportSt > atusCo > + deLib.inf > > MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerSm > m.inf > > MdeModulePkg/Universal/ReportStatusCodeRouter/Smm/ReportStatusCod > eRouterSmm.inf > MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBox.inf > -- > 2.28.0.windows.1 > > > > > --_000_DM5PR06MB3098C4151F8CA2BC71AB8B51F3DF0DM5PR06MB3098namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi Hao,

 

That was my original plan, but doing it might requi= re a MmServiceTableLib instance for SMM_CORE type if PiSmmCore links in RSC= lib (similar to PiSmmCoreSmmServicesTableLib). We can create such an insta= nce just like PiSmmCoreSmmServicesTableLib, but the implementation will pull in gSmmCoreSmst as an external variable = and cast it from `EFI_SMM_SYSTEM_TABLE2` to `EFI_MM_SYSTEM_TABLE`, which do= es not look clean. Thus I just abstract the routine to avoid it.

 

Please let me know if you have better ideas, I can = add the change for next patch series.

 

Thanks,

Kun

 

From: Wu, Hao A
Sent: Tuesday, December 22, 2020 00:35
To: devel@edk2.groups.io; kun.q@outlook.com
Cc: Wang, Jian J; Bi, Dandan; Liming Gao= ; Yao, Jiewen
Subject: Re: [edk2-devel] [PATCH v1 06/15] MdeModulePkg: SmmReportS= tatusCodeLib: ReportStatusCodeLib in StandaloneMm

 

> -----Original M= essage-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of = Kun Qin
> Sent: Saturday, December 19, 2020 2:50 AM
> To: devel@edk2.groups.io
> Cc: Wang, Jian J <jian.j.wang@intel.com>; Wu, Hao A <hao.a.w= u@intel.com>;
> Bi, Dandan <dandan.bi@intel.com>; Liming Gao <gaoliming@byos= oft.com.cn>
> Subject: [edk2-devel] [PATCH v1 06/15] MdeModulePkg:
> SmmReportStatusCodeLib: ReportStatusCodeLib in StandaloneMm
>
> 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<= br> > separate files in order to link in proper Service Table for SMM core/= drivers.


Sorry for a question.

Do you think it is feasible to use:
gMmst->MmLocateProtocol to locate gEfiMmStatusCodeProtocolGuid
and avoid introducing 2 separate implementations for internal function Int= ernalLocateProtocol()?

Since I found that the definitions for gEfiMmStatusCodeProtocolGuid an gEf= iSmmStatusCodeProtocolGuid are identical.

Best Regards,
Hao Wu


>
> Cc: Jian J Wang <jian.j.wang@intel.com>
> Cc: Hao A Wu <hao.a.wu@intel.com>
> Cc: Dandan Bi <dandan.bi@intel.com>
> Cc: Liming Gao <gaoliming@byosoft.com.cn>
>
> Signed-off-by: Kun Qin <kun.q@outlook.com>
> ---
>  MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib= .c
> | 16 ++++----
>
> MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibSta > ndaloneMm.c         &nbs= p;            &= nbsp;            | 3= 9 ++++++++++++++++++++
>
> MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibTra > ditional.c          = ;            &n= bsp;            = ; | 39 ++++++++++++++++++++
>  MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib= .h
> | 37 +++++++++++++++++++
>
> MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLi
> b.inf          &nbs= p;            &= nbsp;           &nbs= p;      |  4 +-
>
> MdeModulePkg/Library/SmmReportStatusCodeLib/{SmmReportStatusCode
> Lib.inf =3D> StandaloneMmReportStatusCodeLib.inf} | 17 +++++---- >  MdeModulePkg/MdeModulePkg.dsc
> |  1 +
>  7 files changed, 137 insertions(+), 16 deletions(-)
>
> diff --git
> a/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib.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.
>
>    Copyright (c) 2009 - 2018, Intel Corporation. All r= ights reserved.<BR>
>    SPDX-License-Identifier: BSD-2-Clause-Patent @@ -8,= 7 +8,7 @@
>
>  #include <Library/ReportStatusCodeLib.h>  #include &= lt;Library/DebugLib.h> -
> #include <Library/SmmServicesTableLib.h>
> +#include <Library/MmServicesTableLib.h>
>  #include <Library/BaseLib.h>
>  #include <Library/BaseMemoryLib.h>
>  #include <Library/PcdLib.h>
> @@ -16,10 +16,12 @@
>
>  #include <Guid/StatusCodeDataTypeId.h>
>  #include <Guid/StatusCodeDataTypeDebug.h> -#include
> <Protocol/SmmStatusCode.h>
> +#include <Protocol/MmStatusCode.h>
>
> -EFI_SMM_REPORT_STATUS_CODE     mReportStatusCode= =3D NULL;
> -EFI_SMM_STATUS_CODE_PROTOCOL   *mStatusCodeProtocol =3D NU= LL;
> +#include "ReportStatusCodeLib.h"
> +
> +EFI_MM_REPORT_STATUS_CODE     mReportStatusCode = = =3D NULL;
> +EFI_MM_STATUS_CODE_PROTOCOL   *mStatusCodeProtocol =3D NUL= L;
>
>
>  /**
> @@ -29,14 +31,14 @@ EFI_SMM_STATUS_CODE_PROTOCOL
> *mStatusCodeProtocol =3D NULL;
>           &nbs= p;  NULL is returned if no status code service is available.
>
>  **/
> -EFI_SMM_REPORT_STATUS_CODE
> +EFI_MM_REPORT_STATUS_CODE
>  InternalGetReportStatusCode (
>    VOID
>    )
>  {
>    EFI_STATUS       = ;             S= tatus;
>
> -  Status =3D gSmst->SmmLocateProtocol (&gEfiSmmStatusCod= eProtocolGuid,
> NULL, (VOID**)&mStatusCodeProtocol);
> +  Status =3D InternalLocateProtocol (&gEfiMmStatusCodeProto= colGuid, NULL,
> + (VOID**)&mStatusCodeProtocol);
>    if (!EFI_ERROR (Status) && mStatusCodeProto= col !=3D NULL) {
>      return mStatusCodeProtocol->ReportSt= atusCode;
>    }
> diff --git
> a/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibS > tandaloneMm.c
> b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibS > tandaloneMm.c
> new file mode 100644
> index 000000000000..fc47dffe9ffb
> --- /dev/null
> +++
> b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibS > ta
> +++ ndaloneMm.c
> @@ -0,0 +1,39 @@
> +/** @file
> +  Abstraction layer for MM service table used by MM ReportStatu= sCodeLib.
> +
> +  Copyright (c) Microsoft Corporation.
> +  SPDX-License-Identifier: BSD-2-Clause-Patent
> +
> +**/
> +
> +#include <PiMm.h>
> +
> +#include <Library/MmServicesTableLib.h>
> +
> +/**
> +  Returns the first protocol instance that matches the given pr= otocol.
> +
> +  @param[in]  Protocol      =     Provides the protocol to search for.
> +  @param[in]  Registration      O= ptional registration key returned from
> +           &n= bsp;            = ;        RegisterProtocolNotify().
> +  @param[out]  Interface     &nbs= p;  On return, a pointer to the first interface that
> matches Protocol and
> +           &n= bsp;            = ;        Registration.
> +
> +  @retval EFI_SUCCESS       =     A protocol instance matching Protocol was
> found and returned in
> +           &n= bsp;            = ;        Interface.
> +  @retval EFI_NOT_FOUND      &nbs= p;  No protocol instances were found that
> match Protocol and
> +           &n= bsp;            = ;        Registration.
> +  @retval EFI_INVALID_PARAMETER Interface is NULL.
> +           &n= bsp;            = ;        Protocol is NULL.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +InternalLocateProtocol (
> +  IN  EFI_GUID  *Protocol,
> +  IN  VOID      *Registration, OP= TIONAL
> +  OUT VOID      **Interface
> +  )
> +{
> +  return gMmst->MmLocateProtocol (Protocol, Registration, In= terface); }
> diff --git
> a/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibT > raditional.c
> b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibT > raditional.c
> new file mode 100644
> index 000000000000..6b3a7c6051c5
> --- /dev/null
> +++
> b/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLibT > ra
> +++ ditional.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 <PiMm.h>
> +
> +#include <Library/SmmServicesTableLib.h>
> +
> +/**
> +  Returns the first protocol instance that matches the given pr= otocol.
> +
> +  @param[in]  Protocol      =     Provides the protocol to search for.
> +  @param[in]  Registration      O= ptional registration key returned from
> +           &n= bsp;            = ;        RegisterProtocolNotify().
> +  @param[out]  Interface     &nbs= p;  On return, a pointer to the first interface that
> matches Protocol and
> +           &n= bsp;            = ;        Registration.
> +
> +  @retval EFI_SUCCESS       =     A protocol instance matching Protocol was
> found and returned in
> +           &n= bsp;            = ;        Interface.
> +  @retval EFI_NOT_FOUND      &nbs= p;  No protocol instances were found that
> match Protocol and
> +           &n= bsp;            = ;        Registration.
> +  @retval EFI_INVALID_PARAMETER Interface is NULL.
> +           &n= bsp;            = ;        Protocol is NULL.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +InternalLocateProtocol (
> +  IN  EFI_GUID  *Protocol,
> +  IN  VOID      *Registration, OP= TIONAL
> +  OUT VOID      **Interface
> +  )
> +{
> +  return gSmst->SmmLocateProtocol (Protocol, Registration, I= nterface);
> +}
> diff --git
> a/MdeModulePkg/Library/SmmReportStatusCodeLib/ReportStatusCodeLib. > 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.<BR>
> +  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 pr= otocol.
> +
> +  @param[in]  Protocol      =     Provides the protocol to search for.
> +  @param[in]  Registration      O= ptional registration key returned from
> +           &n= bsp;            = ;        RegisterProtocolNotify().
> +  @param[out]  Interface     &nbs= p;  On return, a pointer to the first interface that
> matches Protocol and
> +           &n= bsp;            = ;        Registration.
> +
> +  @retval EFI_SUCCESS       =     A protocol instance matching Protocol was
> found and returned in
> +           &n= bsp;            = ;        Interface.
> +  @retval EFI_NOT_FOUND      &nbs= p;  No protocol instances were found that
> match Protocol and
> +           &n= bsp;            = ;        Registration.
> +  @retval EFI_INVALID_PARAMETER Interface is NULL.
> +           &n= bsp;            = ;        Protocol is NULL.
> +
> +**/
> +EFI_STATUS
> +EFIAPI
> +InternalLocateProtocol (
> +  IN  EFI_GUID  *Protocol,
> +  IN  VOID      *Registration, OP= TIONAL
> +  OUT VOID      **Interface
> +  );
> +
> +#endif // _MM_RSC_LIB_H_
> diff --git
> a/MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCod
> eLib.inf
> b/MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCod
> eLib.inf
> index 72496bfababd..02dce09a199d 100644
> ---
> a/MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCod
> eLib.inf
> +++
> b/MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCod
> eLib
> +++ .inf
> @@ -28,6 +28,8 @@ [Defines]
>
>  [Sources]
>    ReportStatusCodeLib.c
> +  ReportStatusCodeLib.h
> +  ReportStatusCodeLibTraditional.c
>
>  [Packages]
>    MdePkg/MdePkg.dec
> @@ -45,7 +47,7 @@ [Guids]
>    gEfiStatusCodeDataTypeDebugGuid   &n= bsp;           ## SOMETIM= ES_CONSUMES
> ## UNDEFINED
>
>  [Protocols]
> -  gEfiSmmStatusCodeProtocolGuid     &n= bsp;           ## CONSUME= S
> +  gEfiMmStatusCodeProtocolGuid     &nb= sp;            ## CO= NSUMES
>
>  [Pcd]
>    gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropert= yMask  ##
> CONSUMES diff --git
> a/MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCod
> eLib.inf
> b/MdeModulePkg/Library/SmmReportStatusCodeLib/StandaloneMmReport
> StatusCodeLib.inf
> similarity index 64%
> copy from
> MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLi
> b.inf
> copy to
> MdeModulePkg/Library/SmmReportStatusCodeLib/StandaloneMmReportSt
> atusCodeLib.inf
> index 72496bfababd..11ecc67fc4fa 100644
> ---
> a/MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCod
> eLib.inf
> +++
> b/MdeModulePkg/Library/SmmReportStatusCodeLib/StandaloneMmReport
> Stat
> +++ usCodeLib.inf
> @@ -12,13 +12,12 @@
>
>  [Defines]
>    INF_VERSION      &nbs= p;             = = =3D 0x00010005
> -  BASE_NAME        &nbs= p;             = = =3D SmmReportStatusCodeLib
> -  MODULE_UNI_FILE       &nbs= p;        =3D SmmReportStatusCodeLib.uni=
> -  FILE_GUID        &nbs= p;             = = =3D 67089D19-B3D6-4d9e-A0EB-FEDC1F83A1EE
> -  MODULE_TYPE        &n= bsp;           =3D DXE_SM= M_DRIVER
> +  BASE_NAME        &nbs= p;             = = =3D StandaloneMmReportStatusCodeLib
> +  FILE_GUID        &nbs= p;             = = =3D 17C7FC8C-8C5D-497E-9C0E-C21255B30E04
> +  MODULE_TYPE        &n= bsp;           =3D MM_STA= NDALONE
>    VERSION_STRING      &= nbsp;          =3D 1.0
> -  PI_SPECIFICATION_VERSION       = = =3D 0x0001000A
> -  LIBRARY_CLASS        =           =3D ReportStatusCode= Lib|DXE_SMM_DRIVER
> SMM_CORE
> +  PI_SPECIFICATION_VERSION       = = =3D 0x00010032
> +  LIBRARY_CLASS        =           =3D ReportStatusCode= Lib|MM_STANDALONE
>
>  #
>  # The following information is for reference only and not requi= red by the
> build tools.
> @@ -28,6 +27,8 @@ [Defines]
>
>  [Sources]
>    ReportStatusCodeLib.c
> +  ReportStatusCodeLib.h
> +  ReportStatusCodeLibStandaloneMm.c
>
>  [Packages]
>    MdePkg/MdePkg.dec
> @@ -36,7 +37,7 @@ [Packages]
>  [LibraryClasses]
>    PcdLib
>    BaseMemoryLib
> -  SmmServicesTableLib
> +  MmServicesTableLib
>    DebugLib
>    MemoryAllocationLib
>
> @@ -45,7 +46,7 @@ [Guids]
>    gEfiStatusCodeDataTypeDebugGuid   &n= bsp;           ## SOMETIM= ES_CONSUMES
> ## UNDEFINED
>
>  [Protocols]
> -  gEfiSmmStatusCodeProtocolGuid     &n= bsp;           ## CONSUME= S
> +  gEfiMmStatusCodeProtocolGuid     &nb= sp;            ## CO= NSUMES
>
>  [Pcd]
>    gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropert= yMask  ##
> 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.i > nf
>
> MdeModulePkg/Library/SmmReportStatusCodeLib/SmmReportStatusCodeLi
> b.inf
> +
> +
> MdeModulePkg/Library/SmmReportStatusCodeLib/StandaloneMmReportSt
> atusCo
> + deLib.inf
>
> MdeModulePkg/Universal/StatusCodeHandler/Smm/StatusCodeHandlerSm
> m.inf
>
> MdeModulePkg/Universal/ReportStatusCodeRouter/Smm/ReportStatusCod
> eRouterSmm.inf
>    MdeModulePkg/Universal/LockBox/SmmLockBox/SmmLockBo= x.inf
> --
> 2.28.0.windows.1
>
>
>
>
>





 

--_000_DM5PR06MB3098C4151F8CA2BC71AB8B51F3DF0DM5PR06MB3098namp_--