From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM02-BL2-obe.outbound.protection.outlook.com (NAM02-BL2-obe.outbound.protection.outlook.com []) by mx.groups.io with SMTP id smtpd.web09.1130.1610663817090348190 for ; Thu, 14 Jan 2021 14:36:58 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@outlook.com header.s=selector1 header.b=OCXxeWwt; 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=EIGohRo8XpcR9QNIgPGjB6rmuwVV8LMCS89CTTGSIUJmYbzA2zeQRjxVL7mVvbh1rahwU7QwYiJwxfyvkJtBHhUPkMvZge8mF96T4XLbMHshc6SogF9KcCkqnYtFoqVIurvq29takONbJRxuBLhikBidbI6cmwl0UpAc43UKUCLRYxfQ+RvWdp2Vd3PTQrn4lpYB4GhOB/dP8KuDE/OSnepuexHuGkiLng0DnsW41Y7ZUE1haGI9rQrzUuZI33QIBLmgembckwMGafyL5mL0GpvPLSDvZ+tecnPIMKkM65sDaQOZsc/ZALAcd68iF7xVluloxeRG+E7EFaNODk545Q== 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=O/Bke9klMOQx3Sj74s1KLvMBriYlg5RqsPQc2Pg2Sx4=; b=QUBzS8BzUf7p8BYWKQshSqqfGsC22CqgLBmsuSPhEE/CiwN0I4yO0++GtLTLiCRS0YSV6vmnS/b/MYG4LYvIV2b5uxeokB8bACQT38N5u1drwnPB677PkNkjmIczICLsL2IjWfjmKtRVyCaufRqQiUFt2cgi4dfFth8Ej6mH2k3mteeAQgBN9cb1a2to1ZKy5HNIWlBfnA0LIskJu5SxSSRxX2YTUWQo/c/yI9oudWJFhKEao6BkHDLkDPT8kE7xHs2KldfWBw++U6ZhtBkGXRxjN5ey03Y0eX0tpVWEwAaKh6NxpjWeA8hfTxQhsYwdqbsy5gpcTBn18v45tP/I8w== 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=O/Bke9klMOQx3Sj74s1KLvMBriYlg5RqsPQc2Pg2Sx4=; b=OCXxeWwtFofN4Ug23ghRIwyFUdFpBKeWox0KlJayOp3iLxyRhzkOZ8SoAtNshtOQltgUVEVLNrMaodhJeWra2WTM+OVcA0iQiX3SO95c7YMdWSGctmABI14ghxsqnP4YugwWjETUpktbWXUmJebo/U2WR2ANfFsUl+6xyQrU7d8DNVeQcsiPdx0SLwB6Y9/uuhJZ2ZFrC1chQcyXQQWichCLBaf/Afc80Wvgbjk4L6H/SSmqpngjHdxzVlgM+rvq/sr8hQj5VZFjygjbpC9K1gueI11467Or80SP7w5fAUqfZ8JaZEnoK0XO05D6cLf1rMpi6ZBG8Ww6zwePh0JriA== Received: from CY1NAM02FT023.eop-nam02.prod.protection.outlook.com (10.152.74.60) by CY1NAM02HT055.eop-nam02.prod.protection.outlook.com (10.152.74.179) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10; Thu, 14 Jan 2021 22:36:56 +0000 Received: from MWHPR06MB3102.namprd06.prod.outlook.com (2a01:111:e400:7e45::41) by CY1NAM02FT023.mail.protection.outlook.com (2a01:111:e400:7e45::237) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Thu, 14 Jan 2021 22:36:56 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:94FE7250DA2157EE8B4A40FFF4A98B07A94479DA00DB1C70C88505B66AC41BF1;UpperCasedChecksum:B2617125845F50326E4AA218ED0C6BC6759BD12DC0BA42873BEFDA31A705D2A9;SizeAsReceived:7478;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.3742.012; Thu, 14 Jan 2021 22:36:56 +0000 From: "Kun Qin" To: devel@edk2.groups.io CC: Michael D Kinney , Liming Gao , Zhiguang Liu Subject: [PATCH v3 11/18] MdePkg: UefiDevicePathLib: Support UefiDevicePathLib under StandaloneMm Date: Thu, 14 Jan 2021 14:36:30 -0800 Message-ID: X-Mailer: git-send-email 2.30.0.windows.1 In-Reply-To: <20210114223637.2737-1-kun.q@outlook.com> References: <20210114223637.2737-1-kun.q@outlook.com> X-TMN: [2L0n/9Y+Cv7jI7ahTb/sXsvHFOm9/XSy] X-ClientProxiedBy: MW4PR04CA0389.namprd04.prod.outlook.com (2603:10b6:303:81::34) To MWHPR06MB3102.namprd06.prod.outlook.com (2603:10b6:301:3e::35) Return-Path: kun.q@outlook.com X-Microsoft-Original-Message-ID: <20210114223637.2737-7-kun.q@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (50.35.88.161) by MW4PR04CA0389.namprd04.prod.outlook.com (2603:10b6:303:81::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3763.10 via Frontend Transport; Thu, 14 Jan 2021 22:36:56 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: b06eb2ec-45fc-4114-bb59-08d8b8dce5f8 X-MS-TrafficTypeDiagnostic: CY1NAM02HT055: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jfSLRjGegqIhQtpGO7qmvM+HnMUxlXSb74LW1XbFab7EFV4CEXFeEYqg+cpMk1QdVYRfuc2zXxakpxwjPLH2QxitGrnNvsnQaRbWg7q9D1Mg3Pe6McCsr7hbr1dhX+1VrE8OdIbVspgDFQfj5mUvlaQgnjSJk1Bp6+qrKJFTUsOzoIPuqtVLoyjcz9yE+XPnJCre896E+GBtmnqIW19pGts7+zKiXqwAvdOG/ziT5RD6Vqxzl5w90jEv2F/EEFd+ X-MS-Exchange-AntiSpam-MessageData: IjtyN2bdmOSIaUGSe9qj0EgcIShfP+4YxRSdvsBlO7bbAs8sRoc7WkDFO61uHeXC/KKmh5wg6GB+wRw9+gFKyYrJDRuNeSW1MpRIbq261CX7pGJk5+GSpk9PF7PJJl0NDHGPPUFAb4MQTo2RM+2dGA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jan 2021 22:36:56.2614 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: b06eb2ec-45fc-4114-bb59-08d8b8dce5f8 X-MS-Exchange-CrossTenant-AuthSource: CY1NAM02FT023.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: CY1NAM02HT055 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain This change added an instance of UefiDevicePathLib for StandaloneMm. It abstracts DevicePathFromHandle function into different files for Standalone MM and other instances to avoid linking gBS into MM_STANDALONE drivers. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Signed-off-by: Kun Qin Reviewed-by: Liming Gao --- Notes: v3: - Added reviewed-by tag [Liming] =20 v2: - No review, no change. MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c = | 33 ------------- MdePkg/Library/UefiDevicePathLib/DevicePathUtilitiesDxeSmm.c = | 51 ++++++++++++++++++++ MdePkg/Library/UefiDevicePathLib/DevicePathUtilitiesStandaloneMm.c = | 40 +++++++++++++++ MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf = | 1 + MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibOptionalDevicePathProtoc= ol.inf | 1 + MdePkg/Library/UefiDevicePathLib/{UefiDevicePathLib.inf =3D> UefiDevicePat= hLibStandaloneMm.inf} | 11 +++-- MdePkg/MdePkg.dsc = | 1 + 7 files changed, 100 insertions(+), 38 deletions(-) diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c b/MdePk= g/Library/UefiDevicePathLib/DevicePathUtilities.c index 9274ef8dda98..7d5fb18d2516 100644 --- a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c +++ b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c @@ -806,39 +806,6 @@ UefiDevicePathLibIsDevicePathMultiInstance ( } =20 =20 -/** - Retrieves the device path protocol from a handle. - - This function returns the device path protocol from the handle specified= by Handle. - If Handle is NULL or Handle does not contain a device path protocol, the= n NULL - is returned. - - @param Handle The handle from which to retrieve the= device - path protocol. - - @return The device path protocol from the handle specified by Handle. - -**/ -EFI_DEVICE_PATH_PROTOCOL * -EFIAPI -DevicePathFromHandle ( - IN EFI_HANDLE Handle - ) -{ - EFI_DEVICE_PATH_PROTOCOL *DevicePath; - EFI_STATUS Status; - - Status =3D gBS->HandleProtocol ( - Handle, - &gEfiDevicePathProtocolGuid, - (VOID *) &DevicePath - ); - if (EFI_ERROR (Status)) { - DevicePath =3D NULL; - } - return DevicePath; -} - /** Allocates a device path for a file and appends it to an existing device = path. =20 diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilitiesDxeSmm.c b= /MdePkg/Library/UefiDevicePathLib/DevicePathUtilitiesDxeSmm.c new file mode 100644 index 000000000000..7f3b6076ef34 --- /dev/null +++ b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilitiesDxeSmm.c @@ -0,0 +1,51 @@ +/** @file + Device Path services. The thing to remember is device paths are built ou= t of + nodes. The device path is terminated by an end node that is length + sizeof(EFI_DEVICE_PATH_PROTOCOL). That would be why there is sizeof(EFI_= DEVICE_PATH_PROTOCOL) + all over this file. + + The only place where multi-instance device paths are supported is in + environment varibles. Multi-instance device paths should never be placed + on a Handle. + + Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) Microsoft Corporation. + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "UefiDevicePathLib.h" + + +/** + Retrieves the device path protocol from a handle. + + This function returns the device path protocol from the handle specified= by Handle. + If Handle is NULL or Handle does not contain a device path protocol, the= n NULL + is returned. + + @param Handle The handle from which to retrieve the= device + path protocol. + + @return The device path protocol from the handle specified by Handle. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +DevicePathFromHandle ( + IN EFI_HANDLE Handle + ) +{ + EFI_DEVICE_PATH_PROTOCOL *DevicePath; + EFI_STATUS Status; + + Status =3D gBS->HandleProtocol ( + Handle, + &gEfiDevicePathProtocolGuid, + (VOID *) &DevicePath + ); + if (EFI_ERROR (Status)) { + DevicePath =3D NULL; + } + return DevicePath; +} diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilitiesStandalone= Mm.c b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilitiesStandaloneMm.c new file mode 100644 index 000000000000..930e778d373a --- /dev/null +++ b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilitiesStandaloneMm.c @@ -0,0 +1,40 @@ +/** @file + Device Path services. The thing to remember is device paths are built ou= t of + nodes. The device path is terminated by an end node that is length + sizeof(EFI_DEVICE_PATH_PROTOCOL). That would be why there is sizeof(EFI_= DEVICE_PATH_PROTOCOL) + all over this file. + + The only place where multi-instance device paths are supported is in + environment varibles. Multi-instance device paths should never be placed + on a Handle. + + Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) Microsoft Corporation. + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include "UefiDevicePathLib.h" + + +/** + Retrieves the device path protocol from a handle. + + This function returns the device path protocol from the handle specified= by Handle. + If Handle is NULL or Handle does not contain a device path protocol, the= n NULL + is returned. + + @param Handle The handle from which to retrieve the= device + path protocol. + + @return The device path protocol from the handle specified by Handle. + +**/ +EFI_DEVICE_PATH_PROTOCOL * +EFIAPI +DevicePathFromHandle ( + IN EFI_HANDLE Handle + ) +{ + return NULL; +} diff --git a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf b/MdePk= g/Library/UefiDevicePathLib/UefiDevicePathLib.inf index 3c41c0695a72..eb85a54a74c3 100644 --- a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf +++ b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf @@ -26,6 +26,7 @@ [Defines] =20 [Sources] DevicePathUtilities.c + DevicePathUtilitiesDxeSmm.c DevicePathToText.c DevicePathFromText.c UefiDevicePathLib.c diff --git a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibOptionalDevi= cePathProtocol.inf b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibOpti= onalDevicePathProtocol.inf index e812e3e1d41e..81323bc70061 100644 --- a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibOptionalDevicePathP= rotocol.inf +++ b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibOptionalDevicePathP= rotocol.inf @@ -29,6 +29,7 @@ [Defines] =20 [Sources] DevicePathUtilities.c + DevicePathUtilitiesDxeSmm.c DevicePathToText.c DevicePathFromText.c UefiDevicePathLibOptionalDevicePathProtocol.c diff --git a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf b/MdePk= g/Library/UefiDevicePathLib/UefiDevicePathLibStandaloneMm.inf similarity index 79% copy from MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf copy to MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibStandaloneMm.inf index 3c41c0695a72..23fedf38b7eb 100644 --- a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf +++ b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibStandaloneMm.inf @@ -4,6 +4,7 @@ # Device Path Library that layers on top of the Memory Allocation Library. # # Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) Microsoft Corporation. # # SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -14,10 +15,11 @@ [Defines] INF_VERSION =3D 0x00010005 BASE_NAME =3D UefiDevicePathLib MODULE_UNI_FILE =3D UefiDevicePathLib.uni - FILE_GUID =3D 91c1677a-e57f-4191-8b8e-eb7711a716e0 - MODULE_TYPE =3D UEFI_DRIVER + FILE_GUID =3D D8E58437-44D3-4154-B7A7-EB794923EF12 + MODULE_TYPE =3D MM_STANDALONE + PI_SPECIFICATION_VERSION =3D 0x00010032 VERSION_STRING =3D 1.0 - LIBRARY_CLASS =3D DevicePathLib|DXE_CORE DXE_DRIVER DXE= _RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE MM_STA= NDALONE + LIBRARY_CLASS =3D DevicePathLib | MM_STANDALONE MM_CORE= _STANDALONE =20 =20 # @@ -26,6 +28,7 @@ [Defines] =20 [Sources] DevicePathUtilities.c + DevicePathUtilitiesStandaloneMm.c DevicePathToText.c DevicePathFromText.c UefiDevicePathLib.c @@ -34,7 +37,6 @@ [Sources] [Packages] MdePkg/MdePkg.dec =20 - [LibraryClasses] BaseLib MemoryAllocationLib @@ -71,4 +73,3 @@ [Protocols] =20 [Pcd] gEfiMdePkgTokenSpaceGuid.PcdMaximumDevicePathNodeCount ## SOMETIMES_C= ONSUMES - diff --git a/MdePkg/MdePkg.dsc b/MdePkg/MdePkg.dsc index 8d1a5b20c9cd..ce009086815f 100644 --- a/MdePkg/MdePkg.dsc +++ b/MdePkg/MdePkg.dsc @@ -109,6 +109,7 @@ [Components] MdePkg/Library/UefiDebugLibDebugPortProtocol/UefiDebugLibDebugPortProtoc= ol.inf MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf + MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibStandaloneMm.inf MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibOptionalDevicePathProt= ocol.inf MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibDevi= cePathProtocol.inf MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf --=20 2.30.0.windows.1