From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.120; helo=mga04.intel.com; envelope-from=jian.j.wang@intel.com; receiver=edk2-devel@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id AF768211AEA76 for ; Wed, 9 Jan 2019 17:35:44 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jan 2019 17:35:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,459,1539673200"; d="scan'208";a="105408876" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga007.jf.intel.com with ESMTP; 09 Jan 2019 17:35:43 -0800 Received: from fmsmsx155.amr.corp.intel.com (10.18.116.71) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 9 Jan 2019 17:35:43 -0800 Received: from shsmsx154.ccr.corp.intel.com (10.239.6.54) by FMSMSX155.amr.corp.intel.com (10.18.116.71) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 9 Jan 2019 17:35:43 -0800 Received: from shsmsx107.ccr.corp.intel.com ([169.254.9.239]) by SHSMSX154.ccr.corp.intel.com ([169.254.7.46]) with mapi id 14.03.0415.000; Thu, 10 Jan 2019 09:35:42 +0800 From: "Wang, Jian J" To: Ard Biesheuvel , "edk2-devel@lists.01.org" CC: Laszlo Ersek , Leif Lindholm , "Kinney, Michael D" , "Gao, Liming" , "Wu, Hao A" , Jagadeesh Ujja , Achin Gupta , Thomas Panakamattam Abraham , Sami Mujawar Thread-Topic: [PATCH 2/6] MdePkg: implement MmServicesTableLib based on traditional SMM Thread-Index: AQHUo5I1ElDnyCOQLU2xQjGb+qVVU6WnwgiQ Date: Thu, 10 Jan 2019 01:35:41 +0000 Message-ID: References: <20190103182825.32231-1-ard.biesheuvel@linaro.org> <20190103182825.32231-4-ard.biesheuvel@linaro.org> In-Reply-To: <20190103182825.32231-4-ard.biesheuvel@linaro.org> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiOTZjNzJiZDMtMTIzMS00ZTFkLTgxNzEtODI2ZDU5MmI1NjZjIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiWWl3QUpreVJkT2RiblJraGVvcGZiZmR6b2V1WENlYkNDZ0FSeGYwMWw5aHI1UHMyMXlFSGpLRW84QmhoUHNxUSJ9 x-ctpclassification: CTP_NT dlp-product: dlpe-windows dlp-version: 11.0.400.15 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH 2/6] MdePkg: implement MmServicesTableLib based on traditional SMM X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Jan 2019 01:35:44 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Ard, Regards, Jian > -----Original Message----- > From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org] > Sent: Friday, January 04, 2019 2:28 AM > To: edk2-devel@lists.01.org > Cc: Ard Biesheuvel ; Laszlo Ersek > ; Leif Lindholm ; Kinney, > Michael D ; Gao, Liming ; > Wang, Jian J ; Wu, Hao A ; > Jagadeesh Ujja ; Achin Gupta > ; Thomas Panakamattam Abraham > ; Sami Mujawar > Subject: [PATCH 2/6] MdePkg: implement MmServicesTableLib based on > traditional SMM >=20 > The definitions of the rebranded MM protocol stack were chosen such > that the existing SMM based core drivers can be reused. So let's > implement MmServicesTableLib based on gEfiMmBaseProtocolGuid, which > is simply gEfiSmmBase2ProtocolGuid under the hood. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel > --- > MdePkg/Library/MmServicesTableLib/MmServicesTableLib.c | 63 > ++++++++++++++++++++ > MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf | 45 > ++++++++++++++ > MdePkg/Library/MmServicesTableLib/MmServicesTableLib.uni | 22 +++++++ > MdePkg/MdePkg.dsc | 1 + > 4 files changed, 131 insertions(+) >=20 > diff --git a/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.c > b/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.c > new file mode 100644 > index 000000000000..f41d25e59805 > --- /dev/null > +++ b/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.c > @@ -0,0 +1,63 @@ > +/** @file > + MM Services Table Library. > + > + Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
> + Copyright (c) 2018, Linaro, Ltd. All rights reserved.
> + This program and the accompanying materials > + are licensed and made available under the terms and conditions of the = BSD > License > + which accompanies this distribution. The full text of the license may= be found > at > + http://opensource.org/licenses/bsd-license.php. > + > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > + > +**/ > + > +#include > +#include > +#include > +#include > + > +EFI_MM_SYSTEM_TABLE *gMmst =3D NULL; > + > +/** > + The constructor function caches the pointer of SMM Services Table. > + > + @param ImageHandle The firmware allocated handle for the EFI image. > + @param SystemTable A pointer to the EFI System Table. > + > + @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS. > + > +**/ > +EFI_STATUS > +EFIAPI > +MmServicesTableLibConstructor ( > + IN EFI_HANDLE ImageHandle, > + IN EFI_SYSTEM_TABLE *SystemTable > + ) > +{ > + EFI_STATUS Status; > + EFI_MM_BASE_PROTOCOL *InternalMmBase; > + > + InternalMmBase =3D NULL; > + // > + // Retrieve MM Base Protocol, Do not use gBS from > UefiBootServicesTableLib on purpose > + // to prevent inclusion of gBS, gST, and gImageHandle from SMM Drivers > unless the > + // MM driver explicity declares that dependency. > + // > + Status =3D SystemTable->BootServices->LocateProtocol ( > + &gEfiMmBaseProtocolGuid, > + NULL, > + (VOID **)&InternalMmBase > + ); > + ASSERT_EFI_ERROR (Status); > + ASSERT (InternalMmBase !=3D NULL); > + > + // > + // We are in MM, retrieve the pointer to MM System Table > + // > + InternalMmBase->GetMmstLocation (InternalMmBase, &gMmst); > + ASSERT (gMmst !=3D NULL); > + > + return EFI_SUCCESS; > +} > diff --git a/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf > b/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf > new file mode 100644 > index 000000000000..4418cc2f1464 > --- /dev/null > +++ b/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf > @@ -0,0 +1,45 @@ > +## @file > +# MM Services Table Library. > +# > +# Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
> +# Copyright (c) 2018, Linaro, Ltd. All rights reserved.
> +# > +# This program and the accompanying materials > +# are licensed and made available under the terms and conditions of the= BSD > License > +# which accompanies this distribution. The full text of the license may= be found > at > +# http://opensource.org/licenses/bsd-license.php. > +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > +# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > +# > +# > +## > + > +[Defines] > + INF_VERSION =3D 0x0001001B > + BASE_NAME =3D MmServicesTableLib > + MODULE_UNI_FILE =3D MmServicesTableLib.uni > + FILE_GUID =3D 9508ECFD-66D1-4B4C-9415-F25F0FFF9E9= 3 > + MODULE_TYPE =3D DXE_SMM_DRIVER > + VERSION_STRING =3D 1.0 > + LIBRARY_CLASS =3D MmServicesTableLib|DXE_SMM_DRIVER > + PI_SPECIFICATION_VERSION =3D 0x00010032 > + CONSTRUCTOR =3D MmServicesTableLibConstructor > + > +# > +# VALID_ARCHITECTURES =3D IA32 X64 ARM AARCH64 > +# > + > +[Sources] > + MmServicesTableLib.c > + > +[Packages] > + MdePkg/MdePkg.dec > + > +[LibraryClasses] > + DebugLib > + > +[Protocols] > + gEfiMmBaseProtocolGuid ## CONSUMES > + > +[Depex] > + gEfiMmBaseProtocolGuid > diff --git a/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.uni > b/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.uni > new file mode 100644 > index 000000000000..2b2c7e14024c > --- /dev/null > +++ b/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.uni > @@ -0,0 +1,22 @@ > +// /** @file > +// MM Services Table Library. > +// > +// MM Services Table Library. > +// Looks like there's a duplicate line above. > +// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved. > +// Copyright (c) 2018, Linaro, Ltd. All rights reserved.
> +// > +// This program and the accompanying materials > +// are licensed and made available under the terms and conditions of the= BSD > License > +// which accompanies this distribution. The full text of the license may= be > found at > +// http://opensource.org/licenses/bsd-license.php. > +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > BASIS, > +// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER > EXPRESS OR IMPLIED. > +// > +// **/ > + > + > +#string STR_MODULE_ABSTRACT #language en-US "MM Services Tab= le > Library" > + > +#string STR_MODULE_DESCRIPTION #language en-US "MM Services Tab= le > Library." > + > diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc > index d43ffe4deb49..428b14e6a4e0 100644 > --- a/MdePkg/MdePkg.dsc > +++ b/MdePkg/MdePkg.dsc > @@ -141,6 +141,7 @@ [Components.IA32, Components.X64] > MdePkg/Library/BaseRngLib/BaseRngLib.inf > MdePkg/Library/SmmPciExpressLib/SmmPciExpressLib.inf > MdePkg/Library/SmiHandlerProfileLibNull/SmiHandlerProfileLibNull.inf > + MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf >=20 > [Components.EBC] > MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf > -- > 2.17.1