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