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 <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
+#include "UefiDevicePathLibInternal.h"\r
+\r
STATIC EFI_DEVICE_PATH_UTILITIES_PROTOCOL *mDevicePathUtilities = NULL;\r
\r
/**\r
UINTN Size;\r
FILEPATH_DEVICE_PATH *FilePath;\r
EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
- EFI_DEVICE_PATH_PROTOCOL *FileDevicePathNode;\r
+ EFI_DEVICE_PATH_PROTOCOL *FileDevicePath;\r
\r
DevicePath = NULL;\r
\r
Size = StrSize (FileName);\r
- FileDevicePathNode = CreateDeviceNode (\r
- MEDIA_DEVICE_PATH,\r
- MEDIA_FILEPATH_DP,\r
- (UINT16) (Size + SIZE_OF_FILEPATH_DEVICE_PATH)\r
- );\r
- if (FileDevicePathNode != NULL) {\r
- FilePath = (FILEPATH_DEVICE_PATH *) FileDevicePathNode;\r
+ FileDevicePath = AllocatePool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + EFI_END_DEVICE_PATH_LENGTH);\r
+ if (FileDevicePath != NULL) {\r
+ FilePath = (FILEPATH_DEVICE_PATH *) FileDevicePath;\r
+ FilePath->Header.Type = MEDIA_DEVICE_PATH;\r
+ FilePath->Header.SubType = MEDIA_FILEPATH_DP;\r
CopyMem (&FilePath->PathName, FileName, Size);\r
+ SetDevicePathNodeLength (&FilePath->Header, Size + SIZE_OF_FILEPATH_DEVICE_PATH);\r
+ SetDevicePathEndNode (NextDevicePathNode (&FilePath->Header));\r
+\r
if (Device != NULL) {\r
DevicePath = DevicePathFromHandle (Device);\r
}\r
- DevicePath = AppendDevicePathNode (DevicePath, FileDevicePathNode);\r
- FreePool (FileDevicePathNode);\r
+\r
+ DevicePath = AppendDevicePath (DevicePath, FileDevicePath);\r
+ FreePool (FileDevicePath);\r
}\r
\r
return DevicePath;\r