From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.92.40.19]) by mx.groups.io with SMTP id smtpd.web11.18286.1611690453691059243 for ; Tue, 26 Jan 2021 11:47:33 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@outlook.com header.s=selector1 header.b=rP43uSeV; spf=pass (domain: outlook.com, ip: 40.92.40.19, mailfrom: kun.q@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BBut2+6KZ+iEa4ho+7ZZWNrF9rliEFNKHLlLyU0i09CVn4JYIyxXv6s+coEWP4OKFtGaQqgOeMDOrebgPxQXoljT3T75tWfjnuKvL88ls7eNN5tNYhA+O72MmhQU9wxYvzGCDZYhXoA5BVQIlrijeNPUA+6UUKWK/mBkHJEP1SB5G/xEfIls+5fP/DnGAYqSGN+BR5e46WqlkpaFf1l+RQt+6oddmiTJDLEQELBC5y9kKcDq6fQ4f7ldV8VTD0HfTyNqQFHwtbK2t72AhYi0HetF+rBXejjyjZrWMZrz7ek2TPI/FDJAOMeW8r/c6AsiiTPVjzhM7OsFj+9qnfttMA== 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=W6cT5mqdAMwUsqp1rSJH8PC78adL+hAQAYRxxClCaic=; b=TNPWXzJcwZBmU4qVkXS1F81RyGPj3/0+B+MKMHWNh+6FoSEqzOyEijbxQgu4/afBrUjQ9O01UANdbB+IGzoTDHTnl9spHkpsEU8zQiwqquBmKEx25L4wUCnBudIi0aO6wDcB9Yf5UnzIKFd8zC4vxaW3Y66hIYuHzw2K11Fh7wFt1E1xWV3dcUbVrBJIosbKLWx1boSfqRpljmq3EwehDLFkZNYIOf0kqO66pO6CQVvkAO67fTHe4piXuB0ai2glKfdPADTcG+Zv5S+69cQJCMTw/J0G4y+fe9ipLyF1uPvibX9u1rVZQi8bf2GdrKGB7SWnlhRBYZL2uzDK+Bp8wg== 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=W6cT5mqdAMwUsqp1rSJH8PC78adL+hAQAYRxxClCaic=; b=rP43uSeVbfwyOto4PD+LGm0d4IWObO880bgKbtKnsqFylxpQkMNge+joXJ+MqMryfJ18rrz6Li9DWcWTKCMsF+O6Z7XeEzV6dBP29WA1cNrd622hZ/mcgOMRYsGs3ruRxFD68sCKHY0cn0KcJ8MZzsgkcmwTgdcxF0hcmFA1mV6G0gdbqc7DlAp5a+wOzTT+3/3oibefPY9IvCAiCBiAgtciETe3aVcbQvwFqeKRDrFBwqlkcvhDMHO4ev8c8ZYTHfIAdBH4hul+Wxescz67mCu+eAl1BKuXnfr1gH4bPrn0DouPzNvqccGFAvHmat2iHZ8s3X2ignifsDhN35xbhg== Received: from BN7NAM10FT059.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::40) by BN7NAM10HT036.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11; Tue, 26 Jan 2021 19:47:32 +0000 Received: from MWHPR06MB3102.namprd06.prod.outlook.com (2a01:111:e400:7e8f::4c) by BN7NAM10FT059.mail.protection.outlook.com (2a01:111:e400:7e8f::447) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11 via Frontend Transport; Tue, 26 Jan 2021 19:47:31 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:4CC25C84F322B7A40FA8495A988DA86E995EFDF0F06A1E156B44C0E1F409EECF;UpperCasedChecksum:CD86FDEA66D74B4F5A785100178B3DAD7199BF466C82B67E4A3F188BE7A1889F;SizeAsReceived:7491;Count:47 Received: from MWHPR06MB3102.namprd06.prod.outlook.com ([fe80::d4ee:1260:6f53:3f7b]) by MWHPR06MB3102.namprd06.prod.outlook.com ([fe80::d4ee:1260:6f53:3f7b%6]) with mapi id 15.20.3784.017; Tue, 26 Jan 2021 19:47:31 +0000 From: "Kun Qin" To: devel@edk2.groups.io CC: Michael D Kinney , Liming Gao , Zhiguang Liu Subject: [PATCH v4 12/20] MdePkg: UefiDevicePathLib: Support UefiDevicePathLib under StandaloneMm Date: Tue, 26 Jan 2021 11:47:02 -0800 Message-ID: X-Mailer: git-send-email 2.30.0.windows.1 In-Reply-To: <20210126194710.2248-1-kun.q@outlook.com> References: <20210126194710.2248-1-kun.q@outlook.com> X-TMN: [47Uc7kvaKLw97U8fEAwyWeF1ArNTuaga] X-ClientProxiedBy: MWHPR11CA0001.namprd11.prod.outlook.com (2603:10b6:301:1::11) To MWHPR06MB3102.namprd06.prod.outlook.com (2603:10b6:301:3e::35) Return-Path: kun.q@outlook.com X-Microsoft-Original-Message-ID: <20210126194710.2248-10-kun.q@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (50.35.88.161) by MWHPR11CA0001.namprd11.prod.outlook.com (2603:10b6:301:1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.14 via Frontend Transport; Tue, 26 Jan 2021 19:47:29 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: b285b51e-15c4-4065-6d6b-08d8c2333713 X-MS-TrafficTypeDiagnostic: BN7NAM10HT036: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t0XT/hZYMx5QSFi3m56pUuaXI7YCXpfdnPZBOkYYq+WiZK/RHxpYhwK5Ll9kkjyenhMYLgob8Ps5ZNi89ygfsXzGXaJHDQhvsH3DHpLEu1IYyJnVSjbrcwjLDXgnWW3dTscS4hlfAg9P+3hB5w7cK6Znr0bVPqFMt7U186RPWwHsCOATIkjHCdpuevxufGXnp6d0vC4KwrquFMcRH7Fn2O41ChRxIkKSWuGZEJMMP7sG0uHPzJkQanY1hVepPgB7ulS7a24X9eEMxtw/UtnmJ8CGUAKt4bvZKJkoT49PCCgkA8AgI/YEwh4EnwqzmFblaDh6PLa3Jl5kjBZ2BKlgH6Z0qb18O2FXY+s7kE0B+B/2obgPDMIi03d70NffgCpiFa4U47iQWd+HFJcHrkgeTw== X-MS-Exchange-AntiSpam-MessageData: yVQU1hqgj0TNbCpNFuf2J6SHp1Ge103RmwFPx8zAL0AyQuYVWC3BmHM0Q6tXXCurRFjxP+Fzx05vUxCW5zZgD3iT4Eiqwo3e2cCJudS+UuZJqyO+mj2ecE3aZd1IbOr2mAsMe1bGWIsXSGr/5xAQXA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b285b51e-15c4-4065-6d6b-08d8c2333713 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2021 19:47:29.8394 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: BN7NAM10FT059.eop-nam10.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: BN7NAM10HT036 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: v4: - Reviewed previously. No change. =20 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