From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=40.92.69.103; helo=eur02-ve1-obe.outbound.protection.outlook.com; envelope-from=marvin.haeuser@outlook.com; receiver=edk2-devel@lists.01.org Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-oln040092069103.outbound.protection.outlook.com [40.92.69.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id B8880210BFF73 for ; Sat, 21 Jul 2018 15:32:03 -0700 (PDT) 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=Y7adH6f9x6OpBdBOTb7TJdU4nuNUgGsni0a8oGj6aDw=; b=Mr9Xs7uAjuNrz2nuWDNiBqm6lQQqJ531wuLJGiGDYOIdUneuluAOwBf1ClTz4WWZzRMGGvsJKO3bnlR/dfbDlB3zBq24rZCGhNwdsD4stk93IGZI53HVZzrn4t2vj57zbGecXyOi42jrYgDSch2E0Ekf+T/AN3w3umzAciv6AUKSnzOUwhGLvoWGMRuRPiq5R70FU2RrnenArQc68k0G/0tSYDwIy+PvMUVWhgdl2jVpiLWBvju8lwZWCQZs5vQCfInyrNqs4oDP2gkwixwzo2NEdzpZAcwO1UmOnrBA/xOwwd6mcpreQiXeGoTzOOuUndPBocSyVkbsfivmjcBF1Q== Received: from VE1EUR02FT006.eop-EUR02.prod.protection.outlook.com (10.152.12.60) by VE1EUR02HT174.eop-EUR02.prod.protection.outlook.com (10.152.13.83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.20.952.17; Sat, 21 Jul 2018 22:32:01 +0000 Received: from VI1PR0801MB1790.eurprd08.prod.outlook.com (10.152.12.60) by VE1EUR02FT006.mail.protection.outlook.com (10.152.12.221) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.20.952.17 via Frontend Transport; Sat, 21 Jul 2018 22:32:01 +0000 Received: from VI1PR0801MB1790.eurprd08.prod.outlook.com ([fe80::7532:4dc6:e9f7:4765]) by VI1PR0801MB1790.eurprd08.prod.outlook.com ([fe80::7532:4dc6:e9f7:4765%2]) with mapi id 15.20.0973.018; Sat, 21 Jul 2018 22:32:01 +0000 From: =?iso-8859-1?Q?Marvin_H=E4user?= To: "edk2-devel@lists.01.org" CC: "michael.d.kinney@intel.com" , "liming.gao@intel.com" , "star.zeng@intel.com" , "eric.dong@intel.com" , "ruiyu.ni@intel.com" , "achin.gupta@arm.com" , "jiewen.yao@intel.com" , "supreeth.venkatesh@arm.com" Thread-Topic: [PATCH 2/4] MdePkg: Import MmServicesTableLib library. Thread-Index: AQHUIUKkYaRe3eopiU+oe3KBvBhb3A== Date: Sat, 21 Jul 2018 22:32:01 +0000 Message-ID: References: <5f41891c14511148a07d6b05c3f9ff7547aa8200.1532212228.git.Marvin.Haeuser@outlook.com> In-Reply-To: <5f41891c14511148a07d6b05c3f9ff7547aa8200.1532212228.git.Marvin.Haeuser@outlook.com> Accept-Language: de-DE, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: AM0PR01CA0013.eurprd01.prod.exchangelabs.com (2603:10a6:208:69::26) To VI1PR0801MB1790.eurprd08.prod.outlook.com (2603:10a6:800:5b::15) x-incomingtopheadermarker: OriginalChecksum:3DE95A2CBEC20AF8E176152E1E4FDCC1CE2AB23AE81DA6F878B5F7A6BB590EB3; UpperCasedChecksum:6C89AD1E2769CC5932B82D6C1631102538D37BD81C2196C0D4BA2C4567AB4998; SizeAsReceived:7978; Count:50 x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [EDmctLpkFCYfcltohh81tnsDEMepMBXM] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VE1EUR02HT174; 7:5lSuOVgtat95EdPIrhbneG3nCaZCJo/SPXKj0+8ULNsmcUbDEqyJrCFQZthYXD1QdUOEmxRRmJqMYehYf3PIreS3M4xQg2pzCi3i+gt3Wolgv4ky42bAavWmuQVU/k37DBGT673YVdMMpWe5gwmDVRgs7BwBFm/YlWSVGfdav/qQno5ETU2ftYkDuUX736rqMhzMfBSCFjnyY7epR/6cFHHM0kU1hAjtrqXMf9bxefGmGhXAwFTwNgeTeJRfO7h1 x-incomingheadercount: 50 x-eopattributedmessage: 0 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(201702061078)(5061506573)(5061507331)(1603103135)(2017031320274)(2017031324274)(2017031323274)(2017031322404)(1603101448)(1601125500)(1701031045); SRVR:VE1EUR02HT174; x-ms-traffictypediagnostic: VE1EUR02HT174: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(82015058); SRVR:VE1EUR02HT174; BCL:0; PCL:0; RULEID:; SRVR:VE1EUR02HT174; x-forefront-prvs: 074040B844 x-forefront-antispam-report: SFV:NSPM; SFS:(7070007)(979002)(6029001)(189003)(199004)(256004)(86362001)(56003)(8936002)(486006)(26005)(104016004)(426003)(74316002)(305945005)(105586002)(99286004)(102836004)(6346003)(54906003)(476003)(2501003)(97736004)(76176011)(386003)(5250100002)(5640700003)(6306002)(2351001)(82202002)(5660300001)(966005)(7696005)(106356001)(25786009)(4326008)(55016002)(6436002)(33656002)(8676002)(446003)(81156014)(11346002)(68736007)(2900100001)(87572001)(14454004)(6916009)(53376002)(72206003)(20460500001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1901; SCL:1; SRVR:VE1EUR02HT174; H:VI1PR0801MB1790.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:; received-spf: None (protection.outlook.com: outlook.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Marvin.Haeuser@outlook.com; x-microsoft-antispam-message-info: xFeGz4X83WhvIlIcXl09ZASWmSUIc8kAMoFz5zaOAo0wZgE9KxXGWoT0aQ/IGMQBwD6c2M7ekdHl26TkBj42cJYdh8PI3hfQnuv6lSN7KhoSffGFK5nlHMmUVPDVRUKj/yHKcKOsI/vQieJ40jC/vGnvgx4gXfN9lRXpsxKHahjw/Nzk2AeZAaIujkmqN+lz+/6pC5aeIKP6iK4kfKXSpAy7mepIXr4eq9YVEmRP4ro= MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 7181d4b0-87d6-4f4e-ba33-0d3746212cec X-MS-Exchange-CrossTenant-Network-Message-Id: f3da2024-d633-4a17-9950-08d5ef59c68d X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 7181d4b0-87d6-4f4e-ba33-0d3746212cec X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jul 2018 22:32:01.1164 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR02HT174 Subject: [PATCH 2/4] MdePkg: Import MmServicesTableLib library. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 21 Jul 2018 22:32:05 -0000 Content-Language: en-US Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Implements the MmServicesTableLib library class. The code was derieved from SmmServicesTableLib. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marvin Haeuser --- MdePkg/Library/MmServicesTableLib/MmServicesTableLib.c | 85 ++++++++++++= ++++++++ MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf | 41 ++++++++++ MdePkg/Library/MmServicesTableLib/MmServicesTableLib.uni | 21 +++++ MdePkg/MdePkg.dsc | 1 + 4 files changed, 148 insertions(+) diff --git a/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.c b/MdePk= g/Library/MmServicesTableLib/MmServicesTableLib.c new file mode 100644 index 000000000000..1ecbb044162d --- /dev/null +++ b/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.c @@ -0,0 +1,85 @@ +/** @file + MM Services Table Library. + + Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
+ This program and the accompanying materials + are licensed and made available under the terms and conditions of the BS= D License + which accompanies this distribution. The full text of the license may b= e 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 IMP= LIED. + +**/ + +#include +#include +#include +#include + +EFI_MM_SYSTEM_TABLE *gMmst =3D NULL; + +/** + The constructor function caches the pointer of MM 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 UefiBootServicesTable= Lib on purpose + // to prevent inclusion of gBS, gST, and gImageHandle from MM Drivers un= less 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; +} + +/** + This function allows the caller to determine if the driver is executing = in + Management Mode(MM). + + This function returns TRUE if the driver is executing in MM and FALSE if= the + driver is not executing in MM. + + @retval TRUE The driver is executing in Management Mode (MM). + @retval FALSE The driver is not executing in Management Mode (MM). + +**/ +BOOLEAN +EFIAPI +InMm ( + VOID + ) +{ + // + // We are already in MM + // + return TRUE; +} diff --git a/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf b/Mde= Pkg/Library/MmServicesTableLib/MmServicesTableLib.inf new file mode 100644 index 000000000000..fd6b2cbe1f94 --- /dev/null +++ b/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf @@ -0,0 +1,41 @@ +## @file +# MM Services Table Library. +# +# Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
+# +# This program and the accompanying materials +# are licensed and made available under the terms and conditions of the B= SD License +# which accompanies this distribution. The full text of the license may b= e 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 IM= PLIED. +# +# +## + +[Defines] + INF_VERSION =3D 0x00010005 + BASE_NAME =3D MmServicesTableLib + MODULE_UNI_FILE =3D MmServicesTableLib.uni + FILE_GUID =3D 319D85EE-D290-4B26-BBDA-9D43CF35DF60 + MODULE_TYPE =3D DXE_SMM_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D MmServicesTableLib|DXE_SMM_DRIVER + PI_SPECIFICATION_VERSION =3D 0x0001000A + CONSTRUCTOR =3D MmServicesTableLibConstructor + +[Sources] + MmServicesTableLib.c + +[Packages] + MdePkg/MdePkg.dec + +[LibraryClasses] + DebugLib + +[Protocols] + gEfiMmBaseProtocolGuid ## CONSUMES + +[Depex] + gEfiMmBaseProtocolGuid + diff --git a/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.uni b/Mde= Pkg/Library/MmServicesTableLib/MmServicesTableLib.uni new file mode 100644 index 000000000000..5194cd829051 --- /dev/null +++ b/MdePkg/Library/MmServicesTableLib/MmServicesTableLib.uni @@ -0,0 +1,21 @@ +// /** @file +// MM Services Table Library. +// +// MM Services Table Library. +// +// Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
+// +// This program and the accompanying materials +// are licensed and made available under the terms and conditions of the B= SD License +// which accompanies this distribution. The full text of the license may b= e 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 IM= PLIED. +// +// **/ + + +#string STR_MODULE_ABSTRACT #language en-US "MM Services Table= Library" + +#string STR_MODULE_DESCRIPTION #language en-US "MM Services Table= Library." + diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc index c7b93d4c8c44..7903638f8dad 100644 --- a/MdePkg/MdePkg.dsc +++ b/MdePkg/MdePkg.dsc @@ -151,6 +151,7 @@ [Components.IA32, Components.X64] MdePkg/Library/SmmIoLibSmmCpuIo2/SmmIoLibSmmCpuIo2.inf MdePkg/Library/SmmPciLibPciRootBridgeIo/SmmPciLibPciRootBridgeIo.inf MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf + MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf MdePkg/Library/SmmPeriodicSmiLib/SmmPeriodicSmiLib.inf MdePkg/Library/BaseS3BootScriptLibNull/BaseS3BootScriptLibNull.inf --=20 2.18.0.windows.1