public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Kun Qin" <kun.q@outlook.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	Michael D Kinney <michael.d.kinney@intel.com>,
	'Liming Gao' <liming.gao@intel.com>,
	Zhiguang Liu <zhiguang.liu@intel.com>
Subject: Re: [edk2-devel] [PATCH v2 10/16] MdePkg: UefiDevicePathLib: Support UefiDevicePathLib under StandaloneMm
Date: Tue, 12 Jan 2021 03:26:37 +0000	[thread overview]
Message-ID: <MWHPR06MB310206FC395325A9F1AD0FD3F3AA0@MWHPR06MB3102.namprd06.prod.outlook.com> (raw)
In-Reply-To: <16576B256B69BE5C.24224@groups.io>

[-- Attachment #1: Type: text/plain, Size: 10574 bytes --]

Hi Michael/Liming/Zhiguang,

Do you have any suggestions/feedback on this specific patch? It would be helpful if I can coalesce the changes before sending out v3 patch.

Thanks in advance.

Regards,
Kun

From: Kun Qin<mailto:kun.q@outlook.com>
Sent: Tuesday, January 5, 2021 11:00
To: devel@edk2.groups.io<mailto:devel@edk2.groups.io>
Cc: Michael D Kinney<mailto:michael.d.kinney@intel.com>; Liming Gao<mailto:gaoliming@byosoft.com.cn>; Zhiguang Liu<mailto:zhiguang.liu@intel.com>
Subject: [edk2-devel] [PATCH v2 10/16] MdePkg: UefiDevicePathLib: Support UefiDevicePathLib under StandaloneMm

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 <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>

Signed-off-by: Kun Qin <kun.q@outlook.com>
---

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/UefiDevicePathLibOptionalDevicePathProtocol.inf              |  1 +
 MdePkg/Library/UefiDevicePathLib/{UefiDevicePathLib.inf => UefiDevicePathLibStandaloneMm.inf} | 11 +++--
 MdePkg/MdePkg.dsc                                                                             |  1 +
 7 files changed, 100 insertions(+), 38 deletions(-)

diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c b/MdePkg/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 (
 }


-/**
-  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, then 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 = gBS->HandleProtocol (
-                  Handle,
-                  &gEfiDevicePathProtocolGuid,
-                  (VOID *) &DevicePath
-                  );
-  if (EFI_ERROR (Status)) {
-    DevicePath = NULL;
-  }
-  return DevicePath;
-}
-
 /**
   Allocates a device path for a file and appends it to an existing device path.

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 out 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.<BR>
+  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, then 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 = gBS->HandleProtocol (
+                  Handle,
+                  &gEfiDevicePathProtocolGuid,
+                  (VOID *) &DevicePath
+                  );
+  if (EFI_ERROR (Status)) {
+    DevicePath = NULL;
+  }
+  return DevicePath;
+}
diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilitiesStandaloneMm.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 out 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.<BR>
+  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, then 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/MdePkg/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]

 [Sources]
   DevicePathUtilities.c
+  DevicePathUtilitiesDxeSmm.c
   DevicePathToText.c
   DevicePathFromText.c
   UefiDevicePathLib.c
diff --git a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibOptionalDevicePathProtocol.inf b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibOptionalDevicePathProtocol.inf
index e812e3e1d41e..81323bc70061 100644
--- a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibOptionalDevicePathProtocol.inf
+++ b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibOptionalDevicePathProtocol.inf
@@ -29,6 +29,7 @@ [Defines]

 [Sources]
   DevicePathUtilities.c
+  DevicePathUtilitiesDxeSmm.c
   DevicePathToText.c
   DevicePathFromText.c
   UefiDevicePathLibOptionalDevicePathProtocol.c
diff --git a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf b/MdePkg/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.<BR>
+# Copyright (c) Microsoft Corporation.
 #
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -14,10 +15,11 @@ [Defines]
   INF_VERSION                    = 0x00010005
   BASE_NAME                      = UefiDevicePathLib
   MODULE_UNI_FILE                = UefiDevicePathLib.uni
-  FILE_GUID                      = 91c1677a-e57f-4191-8b8e-eb7711a716e0
-  MODULE_TYPE                    = UEFI_DRIVER
+  FILE_GUID                      = D8E58437-44D3-4154-B7A7-EB794923EF12
+  MODULE_TYPE                    = MM_STANDALONE
+  PI_SPECIFICATION_VERSION       = 0x00010032
   VERSION_STRING                 = 1.0
-  LIBRARY_CLASS                  = DevicePathLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE MM_STANDALONE
+  LIBRARY_CLASS                  = DevicePathLib | MM_STANDALONE MM_CORE_STANDALONE


 #
@@ -26,6 +28,7 @@ [Defines]

 [Sources]
   DevicePathUtilities.c
+  DevicePathUtilitiesStandaloneMm.c
   DevicePathToText.c
   DevicePathFromText.c
   UefiDevicePathLib.c
@@ -34,7 +37,6 @@ [Sources]
 [Packages]
   MdePkg/MdePkg.dec

-
 [LibraryClasses]
   BaseLib
   MemoryAllocationLib
@@ -71,4 +73,3 @@ [Protocols]

 [Pcd]
   gEfiMdePkgTokenSpaceGuid.PcdMaximumDevicePathNodeCount    ## SOMETIMES_CONSUMES
-
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/UefiDebugLibDebugPortProtocol.inf
   MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf
   MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
+  MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibStandaloneMm.inf
   MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibOptionalDevicePathProtocol.inf
   MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibDevicePathProtocol.inf
   MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
--
2.30.0.windows.1







[-- Attachment #2: Type: text/html, Size: 18684 bytes --]

  parent reply	other threads:[~2021-01-12  3:26 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210105185935.3769-1-kun.q@outlook.com>
2021-01-05 18:59 ` [PATCH v2 01/16] StandaloneMmPkg: StandaloneMmCoreEntryPoint: Extends support for X64 Kun Qin
2021-01-05 18:59 ` [PATCH v2 02/16] StandaloneMmPkg: StandaloneMmCoreHobLib: Extend support for x64 Mm Core Kun Qin
2021-01-05 18:59 ` [PATCH v2 03/16] StandaloneMmPkg: StandaloneMmCoreMemoryAllocationLib: Fix compiler warning Kun Qin
2021-01-06  3:33   ` Yao, Jiewen
2021-01-05 18:59 ` [PATCH v2 04/16] StandaloneMmPkg: StandaloneMmMemLib: Extends support for X64 architecture Kun Qin
2021-01-06  3:38   ` Yao, Jiewen
2021-01-06  6:37     ` [edk2-devel] " Kun Qin
2021-01-05 18:59 ` [PATCH v2 05/16] MdeModulePkg: SmmLockBoxSmmLib: Support StandaloneMm for SmmLockBoxLib Kun Qin
2021-01-05 18:59 ` [PATCH v2 06/16] MdeModulePkg: SmmReportStatusCodeLib: ReportStatusCodeLib in StandaloneMm Kun Qin
2021-01-06  3:24   ` [edk2-devel] " Wu, Hao A
2021-01-05 18:59 ` [PATCH v2 07/16] MdeModulePkg: StatusCodeHandler: StatusCodeHandler driver " Kun Qin
2021-01-06  3:24   ` Wu, Hao A
2021-01-05 18:59 ` [PATCH v2 08/16] MdeModulePkg: FirmwarePerformanceDataTable: Added StandaloneMm support Kun Qin
2021-01-06  3:24   ` Wu, Hao A
2021-01-05 18:59 ` [PATCH v2 09/16] MdeModulePkg: ReportStatusCodeRouter: Support StandaloneMm RSC Router Kun Qin
2021-01-06  3:24   ` Wu, Hao A
2021-01-05 18:59 ` [PATCH v2 10/16] MdePkg: UefiDevicePathLib: Support UefiDevicePathLib under StandaloneMm Kun Qin
2021-01-05 18:59 ` [PATCH v2 11/16] PcAtChipsetPkg: AcpiTimerLib: Added StandaloneMm instance of AcpiTimerLib Kun Qin
2021-01-13  6:50   ` [edk2-devel] " Ni, Ray
2021-01-13 18:38     ` Kun Qin
2021-01-05 18:59 ` [PATCH v2 12/16] SecurityPkg: Tcg2PhysicalPresenceLib: Introduce StandaloneMm instance Kun Qin
2021-01-05 18:59 ` [PATCH v2 13/16] SecurityPkg: Tcg2PpVendorLibNull: Added support for MM_STANDALONE type Kun Qin
2021-01-05 18:59 ` [PATCH v2 14/16] SecurityPkg: Tpm2DeviceLibDTpm: Introduce StandaloneMm instance Kun Qin
2021-01-05 18:59 ` [PATCH v2 15/16] UefiCpuPkg: CpuIo2Smm: Support of CpuIo driver under StandaloneMm Kun Qin
2021-01-06 15:46   ` Laszlo Ersek
2021-01-06 15:51     ` Laszlo Ersek
2021-01-06 19:02       ` [edk2-devel] " Kun Qin
2021-01-06 19:07         ` Laszlo Ersek
2021-01-07 19:05     ` Leif Lindholm
2021-01-05 18:59 ` [PATCH v2 16/16] UefiCpuPkg: SmmCpuExceptionHandlerLib: Added StandaloneMm module support Kun Qin
2021-01-06 15:48   ` Laszlo Ersek
     [not found] ` <16576B257D31F1E6.24224@groups.io>
2021-01-12  3:24   ` [edk2-devel] [PATCH v2 11/16] PcAtChipsetPkg: AcpiTimerLib: Added StandaloneMm instance of AcpiTimerLib Kun Qin
     [not found] ` <16576B256B69BE5C.24224@groups.io>
2021-01-12  3:26   ` Kun Qin [this message]
2021-01-13  1:14     ` 回复: [edk2-devel] [PATCH v2 10/16] MdePkg: UefiDevicePathLib: Support UefiDevicePathLib under StandaloneMm gaoliming

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MWHPR06MB310206FC395325A9F1AD0FD3F3AA0@MWHPR06MB3102.namprd06.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox