From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.92.20.108]) by mx.groups.io with SMTP id smtpd.web12.1142.1608317435357351161 for ; Fri, 18 Dec 2020 10:50:35 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@outlook.com header.s=selector1 header.b=s1qM7+b4; spf=pass (domain: outlook.com, ip: 40.92.20.108, mailfrom: kun.q@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZE/4IbsasIzz5lhtk0T51QtohxyS72OnW4XSoQuZ60iYFIq2PSNNuruOBWmERwMiOoBDtQqz55CoSjveM+dWWiviH7vzvGtVvHUWxF4BQwcGUPr5MWMrBILfN59QNY34cIxCHwiGqfzP6z6MKcXSYzfaWTT4CMTzuVWAsZf+i5A6cePj4tu9f5ZgDTmosXVx5VCkHBWvRwEVqg7KXMXT9M2k3rm+O71NDrAfQzwJJXZjP48XyYDaRGkkEFIALkYsncjQmJl/c+eb8NmNCehT3juBKmNBQTEcsthXSLFgnL6mZtOmWH6xCC7MmOr8UYRryLRbWJBrhdL8meDuQVo5HA== 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=lP2NHb1V81KL2e9R8vBIpU0vaUnMW7RpyZ4qZjakvBw=; b=gkkiidyKxx+yqNxZuID9aJWsC/ilRHpa62CLzIKKPEME7Ebhf/XX+znpuOXxgDU5LLs+Z0G5i183SqsLeadcnmCDIjJG+XKy2Rq0pzmwn1BN6j9ZLgdsGpzySwNzhJV/xrI/JW62ADMjNkaDIEHuIP2XnIaccmVQoNnPfj3M4dXbLFME0hasEZJRi/cAQmsNJbt0+JfSFX7B67CAVOI5tGZJ2WBBSM220Nhjq9l8fIDq4PW34KSffz9e7AxQO4iJeMItR8BUPPNdhnjURS+C+kh79+LBiqTwKH748MOvgJIVS08PKbbUla2rcDt7Dyy7X+Z2Lcv3MFrEh2KWh4tZFg== 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=lP2NHb1V81KL2e9R8vBIpU0vaUnMW7RpyZ4qZjakvBw=; b=s1qM7+b4okxAmJLIld87eL//gy9rQSlxJAKHP2lg8G/glmVfC+RBCtFCyCtffyD8MjUEgWmtIkKVOi1OxdFXXhMYRMMuNLCH4K7K09SaLyZJgG2EMtGdrzbKAavuJfQgQVLlSFU+ZYGUDG6oS+uqqU94VuVmj/WyDvU9cJFJVy1TywthLTZB7XrIZMuvQRPywsn24mj9psya/TW+76XId3CRIEgRYx8AEqJ4yZsEVOq8hW/uT9B3/JYNveP+x2V/kPg/p5GatJ8PAWC3CJ2DSIZm77U8AFf9labi4TSEsmXGECr+8bywIotvq1XDzW6NaTatDPYe80ftZpEE1YhT1A== Received: from DM6NAM11FT039.eop-nam11.prod.protection.outlook.com (2a01:111:e400:fc4d::41) by DM6NAM11HT143.eop-nam11.prod.protection.outlook.com (2a01:111:e400:fc4d::231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.25; Fri, 18 Dec 2020 18:50:34 +0000 Received: from MWHPR06MB3102.namprd06.prod.outlook.com (2a01:111:e400:fc4d::48) by DM6NAM11FT039.mail.protection.outlook.com (2a01:111:e400:fc4d::83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3676.25 via Frontend Transport; Fri, 18 Dec 2020 18:50:34 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:74AAA4B15ED6EB4C524041D47E6D69671B8FC5130DCB56B97BED07A791C67BE5;UpperCasedChecksum:C8A805F81001F9569CB5EBF76EBA4ECBB998A5942E559DD9AF038BFF4E3B62F5;SizeAsReceived:7532;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.3654.026; Fri, 18 Dec 2020 18:50:32 +0000 From: "Kun Qin" To: devel@edk2.groups.io CC: Michael D Kinney , Liming Gao , Zhiguang Liu Subject: [PATCH v1 09/15] MdePkg: UefiDevicePathLib: Support UefiDevicePathLib under StandaloneMm Date: Fri, 18 Dec 2020 10:50:05 -0800 Message-ID: X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <20201218185011.1366-1-kun.q@outlook.com> References: <20201218185011.1366-1-kun.q@outlook.com> X-TMN: [vLvAt4vaNq22Boq/HDgazZuJRXZXEfUb] X-ClientProxiedBy: MW2PR16CA0018.namprd16.prod.outlook.com (2603:10b6:907::31) To MWHPR06MB3102.namprd06.prod.outlook.com (2603:10b6:301:3e::35) Return-Path: kun.q@outlook.com X-Microsoft-Original-Message-ID: <20201218185011.1366-10-kun.q@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (50.35.88.161) by MW2PR16CA0018.namprd16.prod.outlook.com (2603:10b6:907::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Fri, 18 Dec 2020 18:50:31 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 1ab88dc1-38e9-4a75-f520-08d8a385cc18 X-MS-TrafficTypeDiagnostic: DM6NAM11HT143: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Z80YDFKBHMQqeMk5rda0JEPeja5harD5h5wFy+YH2vQnd7GWOMIFftJRdMLao/ir/s1DaiiTdRuOgCunh3KAHvGhIL2XtIFQ7oSFcJe11bqz2gnOAGrCdBC2UIw8vZ7aSy2l37fzN0d+JR5meF83ch3Fu2c7RZK23wqOONSKj5F22UIZYBpolkYf4dNDMAD45R6di2QpCsvX+awKll65ySUosKjdRn+IUlz78VnlQCDRXYA4S4V9OExtl//2jeOn X-MS-Exchange-AntiSpam-MessageData: p4Q8xlDJR1icpSvISUUDfyy/cwo3mVXxXrxb+e+T8KcSzz/CEjSI2kwupHGPT5RgRg4NaqTxbEoxiRkEHHuzgXm/qbqXC7YcVBHg0umlMaK+BM53/x/sdDMVfwOu00Onj/ZEvaoObnTUQzb6fgTwkw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Dec 2020 18:50:31.5824 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: 1ab88dc1-38e9-4a75-f520-08d8a385cc18 X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT039.eop-nam11.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: DM6NAM11HT143 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 --- 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.28.0.windows.1