]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg: UefiDevicePathLib: Support UefiDevicePathLib under StandaloneMm
authorKun Qin <kun.q@outlook.com>
Thu, 17 Dec 2020 22:35:38 +0000 (14:35 -0800)
committerKun Qin <kun.q@outlook.com>
Mon, 1 Feb 2021 18:03:35 +0000 (10:03 -0800)
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>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
MdePkg/Library/UefiDevicePathLib/DevicePathUtilities.c
MdePkg/Library/UefiDevicePathLib/DevicePathUtilitiesDxeSmm.c [new file with mode: 0644]
MdePkg/Library/UefiDevicePathLib/DevicePathUtilitiesStandaloneMm.c [new file with mode: 0644]
MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibOptionalDevicePathProtocol.inf
MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibStandaloneMm.inf [new file with mode: 0644]
MdePkg/MdePkg.dsc

index 9274ef8dda98127f33beee24fe8ca9e56a55f3a1..7d5fb18d25165a94ac700c55b8b9c5c47388d7f6 100644 (file)
@@ -806,39 +806,6 @@ UefiDevicePathLibIsDevicePathMultiInstance (
 }\r
 \r
 \r
-/**\r
-  Retrieves the device path protocol from a handle.\r
-\r
-  This function returns the device path protocol from the handle specified by Handle.\r
-  If Handle is NULL or Handle does not contain a device path protocol, then NULL\r
-  is returned.\r
-\r
-  @param  Handle                     The handle from which to retrieve the device\r
-                                     path protocol.\r
-\r
-  @return The device path protocol from the handle specified by Handle.\r
-\r
-**/\r
-EFI_DEVICE_PATH_PROTOCOL *\r
-EFIAPI\r
-DevicePathFromHandle (\r
-  IN EFI_HANDLE                      Handle\r
-  )\r
-{\r
-  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
-  EFI_STATUS                Status;\r
-\r
-  Status = gBS->HandleProtocol (\r
-                  Handle,\r
-                  &gEfiDevicePathProtocolGuid,\r
-                  (VOID *) &DevicePath\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    DevicePath = NULL;\r
-  }\r
-  return DevicePath;\r
-}\r
-\r
 /**\r
   Allocates a device path for a file and appends it to an existing device path.\r
 \r
diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilitiesDxeSmm.c b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilitiesDxeSmm.c
new file mode 100644 (file)
index 0000000..7f3b607
--- /dev/null
@@ -0,0 +1,51 @@
+/** @file\r
+  Device Path services. The thing to remember is device paths are built out of\r
+  nodes. The device path is terminated by an end node that is length\r
+  sizeof(EFI_DEVICE_PATH_PROTOCOL). That would be why there is sizeof(EFI_DEVICE_PATH_PROTOCOL)\r
+  all over this file.\r
+\r
+  The only place where multi-instance device paths are supported is in\r
+  environment varibles. Multi-instance device paths should never be placed\r
+  on a Handle.\r
+\r
+  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) Microsoft Corporation.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include "UefiDevicePathLib.h"\r
+\r
+\r
+/**\r
+  Retrieves the device path protocol from a handle.\r
+\r
+  This function returns the device path protocol from the handle specified by Handle.\r
+  If Handle is NULL or Handle does not contain a device path protocol, then NULL\r
+  is returned.\r
+\r
+  @param  Handle                     The handle from which to retrieve the device\r
+                                     path protocol.\r
+\r
+  @return The device path protocol from the handle specified by Handle.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+DevicePathFromHandle (\r
+  IN EFI_HANDLE                      Handle\r
+  )\r
+{\r
+  EFI_DEVICE_PATH_PROTOCOL  *DevicePath;\r
+  EFI_STATUS                Status;\r
+\r
+  Status = gBS->HandleProtocol (\r
+                  Handle,\r
+                  &gEfiDevicePathProtocolGuid,\r
+                  (VOID *) &DevicePath\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    DevicePath = NULL;\r
+  }\r
+  return DevicePath;\r
+}\r
diff --git a/MdePkg/Library/UefiDevicePathLib/DevicePathUtilitiesStandaloneMm.c b/MdePkg/Library/UefiDevicePathLib/DevicePathUtilitiesStandaloneMm.c
new file mode 100644 (file)
index 0000000..930e778
--- /dev/null
@@ -0,0 +1,40 @@
+/** @file\r
+  Device Path services. The thing to remember is device paths are built out of\r
+  nodes. The device path is terminated by an end node that is length\r
+  sizeof(EFI_DEVICE_PATH_PROTOCOL). That would be why there is sizeof(EFI_DEVICE_PATH_PROTOCOL)\r
+  all over this file.\r
+\r
+  The only place where multi-instance device paths are supported is in\r
+  environment varibles. Multi-instance device paths should never be placed\r
+  on a Handle.\r
+\r
+  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) Microsoft Corporation.\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include "UefiDevicePathLib.h"\r
+\r
+\r
+/**\r
+  Retrieves the device path protocol from a handle.\r
+\r
+  This function returns the device path protocol from the handle specified by Handle.\r
+  If Handle is NULL or Handle does not contain a device path protocol, then NULL\r
+  is returned.\r
+\r
+  @param  Handle                     The handle from which to retrieve the device\r
+                                     path protocol.\r
+\r
+  @return The device path protocol from the handle specified by Handle.\r
+\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+DevicePathFromHandle (\r
+  IN EFI_HANDLE                      Handle\r
+  )\r
+{\r
+  return NULL;\r
+}\r
index 3c41c0695a72226f5ccdc7dfc2019d3123c34768..eb85a54a74c3aab1562145425c74d17e4971ea61 100644 (file)
@@ -26,6 +26,7 @@
 \r
 [Sources]\r
   DevicePathUtilities.c\r
+  DevicePathUtilitiesDxeSmm.c\r
   DevicePathToText.c\r
   DevicePathFromText.c\r
   UefiDevicePathLib.c\r
index e812e3e1d41ec759179a1ad02389aa42a9e7ca82..81323bc700618bf4bee84f617de595b38e3b6574 100644 (file)
@@ -29,6 +29,7 @@
 \r
 [Sources]\r
   DevicePathUtilities.c\r
+  DevicePathUtilitiesDxeSmm.c\r
   DevicePathToText.c\r
   DevicePathFromText.c\r
   UefiDevicePathLibOptionalDevicePathProtocol.c\r
diff --git a/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibStandaloneMm.inf b/MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibStandaloneMm.inf
new file mode 100644 (file)
index 0000000..23fedf3
--- /dev/null
@@ -0,0 +1,75 @@
+## @file\r
+# Instance of Device Path Library based on Memory Allocation Library.\r
+#\r
+# Device Path Library that layers on top of the Memory Allocation Library.\r
+#\r
+# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) Microsoft Corporation.\r
+#\r
+#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = UefiDevicePathLib\r
+  MODULE_UNI_FILE                = UefiDevicePathLib.uni\r
+  FILE_GUID                      = D8E58437-44D3-4154-B7A7-EB794923EF12\r
+  MODULE_TYPE                    = MM_STANDALONE\r
+  PI_SPECIFICATION_VERSION       = 0x00010032\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = DevicePathLib | MM_STANDALONE MM_CORE_STANDALONE\r
+\r
+\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
+#\r
+\r
+[Sources]\r
+  DevicePathUtilities.c\r
+  DevicePathUtilitiesStandaloneMm.c\r
+  DevicePathToText.c\r
+  DevicePathFromText.c\r
+  UefiDevicePathLib.c\r
+  UefiDevicePathLib.h\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseLib\r
+  MemoryAllocationLib\r
+  DebugLib\r
+  BaseMemoryLib\r
+  PcdLib\r
+  PrintLib\r
+\r
+[Guids]\r
+  ## SOMETIMES_CONSUMES  ## GUID\r
+  gEfiVTUTF8Guid\r
+  ## SOMETIMES_CONSUMES  ## GUID\r
+  gEfiVT100Guid\r
+  ## SOMETIMES_CONSUMES  ## GUID\r
+  gEfiVT100PlusGuid\r
+  ## SOMETIMES_CONSUMES  ## GUID\r
+  gEfiPcAnsiGuid\r
+  ## SOMETIMES_CONSUMES  ## GUID\r
+  gEfiUartDevicePathGuid\r
+  ## SOMETIMES_CONSUMES  ## GUID\r
+  gEfiSasDevicePathGuid\r
+  ## SOMETIMES_CONSUMES  ## GUID\r
+  gEfiVirtualDiskGuid\r
+  ## SOMETIMES_CONSUMES  ## GUID\r
+  gEfiVirtualCdGuid\r
+  ## SOMETIMES_CONSUMES  ## GUID\r
+  gEfiPersistentVirtualDiskGuid\r
+  ## SOMETIMES_CONSUMES  ## GUID\r
+  gEfiPersistentVirtualCdGuid\r
+\r
+[Protocols]\r
+  gEfiDevicePathProtocolGuid                    ## SOMETIMES_CONSUMES\r
+  gEfiDebugPortProtocolGuid                     ## UNDEFINED\r
+\r
+[Pcd]\r
+  gEfiMdePkgTokenSpaceGuid.PcdMaximumDevicePathNodeCount    ## SOMETIMES_CONSUMES\r
index 8d1a5b20c9cdeaeaac644b5e018da2a9dd29ea7c..ce009086815f3b6c812c3585cfe24fa61e436210 100644 (file)
   MdePkg/Library/UefiDebugLibDebugPortProtocol/UefiDebugLibDebugPortProtocol.inf\r
   MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf\r
   MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf\r
+  MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibStandaloneMm.inf\r
   MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibOptionalDevicePathProtocol.inf\r
   MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibDevicePathProtocol.inf\r
   MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf\r