/** @file\r
- UEFI Device Path Library.\r
+ Library instance that implement UEFI Device Path Library class based on protocol\r
+ gEfiDevicePathUtilitiesProtocolGuid.\r
\r
Copyright (c) 2006, Intel Corporation<BR>\r
All rights reserved. This program and the accompanying materials\r
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
- Module Name: UefiDevicePathLib.c\r
-\r
**/\r
\r
-//\r
-// Include common header file for this module.\r
-//\r
-#include "CommonHeader.h"\r
\r
-STATIC EFI_DEVICE_PATH_UTILITIES_PROTOCOL *mDevicePathUtilities = NULL;\r
+#include <Uefi.h>\r
+\r
+#include <Protocol/DevicePathUtilities.h>\r
+#include <Protocol/DevicePath.h>\r
+\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+\r
+EFI_DEVICE_PATH_UTILITIES_PROTOCOL *mDevicePathUtilities = NULL;\r
\r
/**\r
The constructor function caches the pointer to DevicePathUtilites protocol.\r
DevicePath including the end of device path node. If DevicePath is NULL, then 0 is returned.\r
\r
@param DevicePath A pointer to a device path data structure.\r
-\r
- @return The size of a device path in bytes.\r
+ \r
+ @retval 0 If DevicePath is NULL.\r
+ @retval Others The size of a device path in bytes.\r
\r
**/\r
UINTN\r
DevicePath is NULL, then NULL is returned. If the memory is successfully allocated, then the\r
contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer\r
is returned. Otherwise, NULL is returned. \r
+ The memory for the new device path is allocated from EFI boot services memory. \r
+ It is the responsibility of the caller to free the memory allocated. \r
\r
@param DevicePath A pointer to a device path data structure.\r
\r
- @return A pointer to the duplicated device path.\r
-\r
+ @retval NULL If DevicePath is NULL.\r
+ @retval Others A pointer to the duplicated device path.\r
+ \r
**/\r
EFI_DEVICE_PATH_PROTOCOL *\r
EFIAPI\r
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
\r
@param FirstDevicePath A pointer to a device path data structure.\r
@param SecondDevicePath A pointer to a device path data structure.\r
-\r
- @return A pointer to the new device path.\r
+ \r
+ @retval NULL If there is not enough memory for the newly allocated buffer.\r
+ @retval Others A pointer to the new device path if success.\r
+ Or a copy an end-of-device-path if both FirstDevicePath and SecondDevicePath are NULL.\r
\r
**/\r
EFI_DEVICE_PATH_PROTOCOL *\r
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 DevicePathNode is NULL then a copy of DevicePath is returned.\r
+ If DevicePath is NULL then a copy of DevicePathNode, followed by an end-of-device path device\r
+ node 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
@param DevicePath A pointer to a device path data structure.\r
@param DevicePathNode A pointer to a single device path node.\r
\r
- @return A pointer to the new device path.\r
+ @retval NULL If there is not enough memory for the new device path.\r
+ @retval Others A pointer to the new device path if success.\r
+ A copy of DevicePathNode followed by an end-of-device-path node \r
+ if both FirstDevicePath and SecondDevicePath are NULL.\r
+ A copy of an end-of-device-path node if both FirstDevicePath and SecondDevicePath are NULL.\r
\r
**/\r
EFI_DEVICE_PATH_PROTOCOL *\r
}\r
\r
/**\r
- Creates a copy of the current device path instance and returns a pointer to the next device path\r
- instance.\r
+ Creates a device node.\r
\r
This function creates a new device node in a newly allocated buffer of size NodeLength and\r
initializes the device path node header with NodeType and NodeSubType. The new device path node\r
handle Device. The allocated device path is returned. If Device is NULL or Device is a handle\r
that does not support the device path protocol, then a device path containing a single device\r
path node for the file specified by FileName is allocated and returned.\r
+ The memory for the new device path is allocated from EFI boot services memory. It is the responsibility\r
+ of the caller to free the memory allocated.\r
+ \r
If FileName is NULL, then ASSERT().\r
+ If FileName is not aligned on a 16-bit boundary, then ASSERT().\r
\r
@param Device A pointer to a device handle. This parameter is optional and\r
may be NULL.\r
DevicePath = NULL;\r
\r
Size = StrSize (FileName);\r
- FileDevicePath = AllocatePool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + EFI_END_DEVICE_PATH_LENGTH);\r
+ FileDevicePath = AllocatePool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + END_DEVICE_PATH_LENGTH);\r
if (FileDevicePath != NULL) {\r
FilePath = (FILEPATH_DEVICE_PATH *) FileDevicePath;\r
FilePath->Header.Type = MEDIA_DEVICE_PATH;\r
\r
return DevicePath;\r
}\r
-\r