]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Update DevicePathLib to reflect the update of UEFI device utility protocol
authorqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 24 Sep 2007 06:54:04 +0000 (06:54 +0000)
committerqhuang8 <qhuang8@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 24 Sep 2007 06:54:04 +0000 (06:54 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3914 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Include/Library/DevicePathLib.h
MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c
MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLib.c

index bf7a73e0f8561824af486bc9e3e81bb6d0fc341f..b446f675799b8ad4daf9464dbbf1b4fe0b44cae9 100644 (file)
@@ -1,5 +1,5 @@
 /** @file\r
-  Entry point to a DXE Boot Services Driver\r
+  Device Path services.\r
 \r
   Copyright (c) 2006, Intel Corporation                                                         \r
   All rights reserved. This program and the accompanying materials                          \r
@@ -59,7 +59,8 @@ DuplicateDevicePath (
   SecondDevicePath is retained. The newly created device path is returned.  \r
   If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned.  \r
   If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned.  \r
-  If both FirstDevicePath and SecondDevicePath are NULL, then NULL is returned.  \r
+  If both FirstDevicePath and SecondDevicePath are NULL, then a copy of an end-of-device-path is\r
+  returned.  \r
   If there is not enough memory for the newly allocated buffer, then NULL is returned.\r
   The memory for the new device path is allocated from EFI boot services memory. It is the\r
   responsibility of the caller to free the memory allocated.\r
@@ -83,8 +84,10 @@ AppendDevicePath (
   This function creates a new device path by appending a copy of the device node specified by\r
   DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer.\r
   The end-of-device-path device node is moved after the end of the appended device node.\r
-  If DevicePath is NULL, then NULL is returned.\r
-  If DevicePathNode is NULL, then NULL is returned.\r
+  If DeviceNode is NULL then a copy of DevicePath is returned.\r
+  If DevicePathNode is NULL then a copy of DevicePath is returned.\r
+  If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path device node\r
+  is returned.\r
   If there is not enough memory to allocate space for the new device path, then NULL is returned.  \r
   The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
   free the memory allocated.\r
index ef25fc983f8194ad5d788c4235b99cff0e118871..3b2e8f122165a5294a07bc59ebd9c3de1dd53cf7 100644 (file)
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/BaseLib.h>\r
 \r
+//\r
+// Template for an end-of-device path node.\r
+//\r
+STATIC EFI_DEVICE_PATH_PROTOCOL  mEndDevicePath[] = {\r
+  END_DEVICE_PATH_TYPE,\r
+  END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
+  END_DEVICE_PATH_LENGTH,\r
+  0\r
+};\r
+\r
 /**\r
   Returns the size of a device path in bytes.\r
 \r
@@ -114,7 +124,8 @@ DuplicateDevicePath (
   SecondDevicePath is retained. The newly created device path is returned.  \r
   If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned.  \r
   If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned.  \r
-  If both FirstDevicePath and SecondDevicePath are NULL, then NULL is returned.  \r
+  If both FirstDevicePath and SecondDevicePath are NULL, then a copy of an end-of-device-path is\r
+  returned.  \r
   If there is not enough memory for the newly allocated buffer, then NULL is returned.\r
   The memory for the new device path is allocated from EFI boot services memory. It is the\r
   responsibility of the caller to free the memory allocated.\r
@@ -142,7 +153,7 @@ AppendDevicePath (
   // If there's only 1 path, just duplicate it.\r
   //\r
   if (FirstDevicePath == NULL) {\r
-    return DuplicateDevicePath (SecondDevicePath);\r
+    return DuplicateDevicePath ((SecondDevicePath != NULL) ? SecondDevicePath : mEndDevicePath);\r
   }\r
 \r
   if (SecondDevicePath == NULL) {\r
@@ -178,8 +189,10 @@ AppendDevicePath (
   This function creates a new device path by appending a copy of the device node specified by\r
   DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer.\r
   The end-of-device-path device node is moved after the end of the appended device node.\r
-  If DevicePath is NULL, then NULL is returned.\r
-  If DevicePathNode is NULL, then NULL is returned.\r
+  If DeviceNode is NULL then a copy of DevicePath is returned.\r
+  If DevicePathNode is NULL then a copy of DevicePath is returned.\r
+  If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path device node\r
+  is returned.\r
   If there is not enough memory to allocate space for the new device path, then NULL is returned.  \r
   The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
   free the memory allocated.\r
@@ -202,8 +215,8 @@ AppendDevicePathNode (
   EFI_DEVICE_PATH_PROTOCOL  *NewDevicePath;\r
   UINTN                     NodeLength;\r
 \r
-  if (DevicePath == NULL || DevicePathNode == NULL) {\r
-    return NULL;\r
+  if (DevicePathNode == NULL) {\r
+    return DuplicateDevicePath ((DevicePath != NULL) ? DevicePath : mEndDevicePath);\r
   }\r
   //\r
   // Build a Node that has a terminator on it\r
index e9193cf1b23f244d4444775559bd9ffe76f71030..9dbe773e4e5a8093858ca6487a4cb8daa06d722c 100644 (file)
@@ -111,7 +111,8 @@ DuplicateDevicePath (
   SecondDevicePath is retained. The newly created device path is returned.  \r
   If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned.  \r
   If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned.  \r
-  If both FirstDevicePath and SecondDevicePath are NULL, then NULL is returned.  \r
+  If both FirstDevicePath and SecondDevicePath are NULL, then a copy of an end-of-device-path is\r
+  returned.  \r
   If there is not enough memory for the newly allocated buffer, then NULL is returned.\r
   The memory for the new device path is allocated from EFI boot services memory. It is the\r
   responsibility of the caller to free the memory allocated.\r
@@ -138,8 +139,10 @@ AppendDevicePath (
   This function creates a new device path by appending a copy of the device node specified by\r
   DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer.\r
   The end-of-device-path device node is moved after the end of the appended device node.\r
-  If DevicePath is NULL, then NULL is returned.\r
-  If DevicePathNode is NULL, then NULL is returned.\r
+  If DeviceNode is NULL then a copy of DevicePath is returned.\r
+  If DevicePathNode is NULL then a copy of DevicePath is returned.\r
+  If both DevicePathNode and DevicePath are NULL then a copy of an end-of-device-path device node\r
+  is returned.\r
   If there is not enough memory to allocate space for the new device path, then NULL is returned.  \r
   The memory is allocated from EFI boot services memory. It is the responsibility of the caller to\r
   free the memory allocated.\r