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 [40.92.3.78]) by mx.groups.io with SMTP id smtpd.web10.1684.1609873199762195390 for ; Tue, 05 Jan 2021 11:00:00 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@outlook.com header.s=selector1 header.b=NESTHTFp; spf=pass (domain: outlook.com, ip: 40.92.3.78, mailfrom: kun.q@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T2qUfkcnfrjtg3lQS7lEOkmV7CmQEquHpdeAexq0q4Rvnv5nmMB1Qv/v0tst2f5MKFiR9ONWXOcS6I2i7nbgr6mAeLRsdrdgJQDdVUjehFauIrO/JnqPAfbPe1v2ivsEQ73oEKUJdyeLSDZS2LRxWdFriroMITPOTfMMUES4xJmIQDGl8nL2jtQyJTOP90u8OshQjnYuCPhzryUObHQa9SEOpPgVP9mNlFLRY9D1ja6s4LWEOu/WAnT8zHnxoJbXWr80emnckrgxjCMwqs/5/W65RWMgQYWx/qClmjTMoVLMVbJFaM0/DyjGpOKlNqZaS5fqUxaihd+seiQndtj5rg== 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=xgQPzBo3NB+tb/BbpuZo+ZfjBTPTI5F56XDKRX5x/6E=; b=P3OyLo+x0gWkbZSFsf8+7Bgjxxu4aIw1fki60YvyUt47xAbLAVrwE7lUPHsaRM/po8NOlYqiJbW8Neh05qvugZY5CcvsC4DK1VN8siIW/uktPRZieJd2rK8tqZmGxtD3hOwOxhZan7NPee98ZvjxcCS2OIX1eTcdyzi6yFzaH2P3Y6KbljHx515MvTapKFUXL+tdz1EY1zW9kFRFrDfFVkCeJSYtP1nOYOdyvc3NKOh296v6tQnsCH/v/p1cZ/HsiECQaYHUp6JiVKLwl4n+e7ag/hCcFFNbtZ9rw4uUVpvhb4sx8a6uZHGZDHkh0qRd0IUZP8gp3rwud4BcZFTt/Q== 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=xgQPzBo3NB+tb/BbpuZo+ZfjBTPTI5F56XDKRX5x/6E=; b=NESTHTFpwn0GPUu/Iyl0XWYoa6NzDGfLL2hnZi0fxRl+DFghXoPTu/alNrGqIkR6ci6uaeU9elxqwogwR38VOXMMpozxxGbSWKa8thBrOONkfRAxf6a4FbB7l58pKsrZDONk0+nWhP6K8cS+vkb3xOGII6wKaW0Gysq/2cHMEUuiIqgOEuMYXQtSTMWjwT1guQC2G5kk9cpryT8kDRKROTUr52cf4Yz5lvs1V7/A+kvWMUGLYZ+2SDDwAr6OseWyRxX7D+gcf6FFlLLElzq0WoAdIZHAFt3ANKf7ZuiPj3h68Ch3TTissfnn/NlBj1nJX53wL4zFV7hVoNPimM2Zvw== Received: from CY1NAM02FT003.eop-nam02.prod.protection.outlook.com (10.152.74.58) by CY1NAM02HT009.eop-nam02.prod.protection.outlook.com (10.152.75.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.22; Tue, 5 Jan 2021 18:59:58 +0000 Received: from MWHPR06MB3102.namprd06.prod.outlook.com (2a01:111:e400:7e45::53) by CY1NAM02FT003.mail.protection.outlook.com (2a01:111:e400:7e45::151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3721.22 via Frontend Transport; Tue, 5 Jan 2021 18:59:58 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:8556A5446D2B32ED3296847F1100AE6B4CD86BE06B94CDD6B5103D8A110B3FC8;UpperCasedChecksum:D1A59BB9E81EF9A8BADAD3A8A2D4E1DFB9B5CAD19A84B29C296C48053ACD9B4E;SizeAsReceived:7475;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.3721.024; Tue, 5 Jan 2021 18:59:58 +0000 From: "Kun Qin" To: devel@edk2.groups.io CC: Michael D Kinney , Liming Gao , Zhiguang Liu Subject: [PATCH v2 10/16] MdePkg: UefiDevicePathLib: Support UefiDevicePathLib under StandaloneMm Date: Tue, 5 Jan 2021 10:59:29 -0800 Message-ID: X-Mailer: git-send-email 2.30.0.windows.1 In-Reply-To: <20210105185935.3769-1-kun.q@outlook.com> References: <20210105185935.3769-1-kun.q@outlook.com> X-TMN: [OoaSs5tKarkIqOBV0VeGuYmLtfMBAv6V] X-ClientProxiedBy: MWHPR22CA0045.namprd22.prod.outlook.com (2603:10b6:300:69::31) To MWHPR06MB3102.namprd06.prod.outlook.com (2603:10b6:301:3e::35) Return-Path: kun.q@outlook.com X-Microsoft-Original-Message-ID: <20210105185935.3769-11-kun.q@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (50.35.88.161) by MWHPR22CA0045.namprd22.prod.outlook.com (2603:10b6:300:69::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.6 via Frontend Transport; Tue, 5 Jan 2021 18:59:57 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 84f694e7-b634-4d5b-c29f-08d8b1ac18cb X-MS-TrafficTypeDiagnostic: CY1NAM02HT009: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K4BKrIPBx/rqmd/zGTxsnvh+iizVq9a/t5VBjr5ZqLlSlqFyjOtUTi9OzDEmcmUuOQE5qRtOvaFMgPsCBuJ7iFdaL+w4hGHwbwLDONpkDIUnHZnqY4foAGkvL7rL/xdAVjXD1vxMEONygcl8C18xoL6jQ5umS+rsrzQK6AiEuOAgeIxKUEVsDx1pcxHjB3oxWlJ6GEF86cYLPJF4EC1UXmLycfAVeRS6UtpESJmnHHiMF1PXfLO4pDZktDTwe3Hs X-MS-Exchange-AntiSpam-MessageData: /YW6p7uzDSItGOT47wreTibNyEl0ZTt5Acl5hmnP+M/6y569kKZzhoz0T0mDWWkidt5fgZzsxKO44jqLLA6WYbQ33KVXvNqrtl7dr2638lzMlt+qHWEcOukl56FwWneEWuOc+Lyzp6UtwrOKfwvMaQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2021 18:59:57.3547 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-Network-Message-Id: 84f694e7-b634-4d5b-c29f-08d8b1ac18cb X-MS-Exchange-CrossTenant-AuthSource: CY1NAM02FT003.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: CY1NAM02HT009 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 --- Notes: 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