]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.c
Removed MdePkg usage of ModuleName: in file headers
[mirror_edk2.git] / MdePkg / Library / UefiDevicePathLib / UefiDevicePathLib.c
index 31a0462f079beaffd47e9a8ed8fac8572b9da1e9..34412a6f46277b537709b9a2a6121107fecefac3 100644 (file)
   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
+// The package level header files this module uses\r
+//\r
+#include <Uefi.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Protocol/DevicePath.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/BaseLib.h>\r
+\r
 /**\r
   Returns the size of a device path in bytes.\r
 \r
@@ -396,6 +412,7 @@ CreateDeviceNode (
   if (DevicePath != NULL) {\r
      DevicePath->Type    = NodeType;\r
      DevicePath->SubType = NodeSubType;\r
+     SetDevicePathNodeLength (DevicePath, NodeLength);\r
   }\r
 \r
   return DevicePath;\r
@@ -496,24 +513,26 @@ FileDevicePath (
   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