]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/Bds/BootOptionSupport.c
ArmPlatformPkg/Bds: Fixed adding support for new boot entry when the generated Device...
[mirror_edk2.git] / ArmPlatformPkg / Bds / BootOptionSupport.c
index fbdd5947d33dd1afad4d70293956cb7397966271..190169a304b84240b2cd73f88d52ce0f077f0900 100644 (file)
@@ -34,7 +34,7 @@ BdsLoadOptionFileSystemList (
 EFI_STATUS\r
 BdsLoadOptionFileSystemCreateDevicePath (\r
   IN CHAR16*                    FileName,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNode,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNodes,\r
   OUT ARM_BDS_LOADER_TYPE       *BootType,\r
   OUT UINT32                    *Attributes\r
   );\r
@@ -61,7 +61,7 @@ BdsLoadOptionMemMapList (
 EFI_STATUS\r
 BdsLoadOptionMemMapCreateDevicePath (\r
   IN CHAR16*                    FileName,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNode,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNodes,\r
   OUT ARM_BDS_LOADER_TYPE       *BootType,\r
   OUT UINT32                    *Attributes\r
   );\r
@@ -88,7 +88,7 @@ BdsLoadOptionPxeList (
 EFI_STATUS\r
 BdsLoadOptionPxeCreateDevicePath (\r
   IN CHAR16*                    FileName,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNode,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNodes,\r
   OUT ARM_BDS_LOADER_TYPE       *BootType,\r
   OUT UINT32                    *Attributes\r
   );\r
@@ -115,7 +115,7 @@ BdsLoadOptionTftpList (
 EFI_STATUS\r
 BdsLoadOptionTftpCreateDevicePath (\r
   IN CHAR16*                    FileName,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNode,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNodes,\r
   OUT ARM_BDS_LOADER_TYPE       *BootType,\r
   OUT UINT32                    *Attributes\r
   );\r
@@ -332,7 +332,7 @@ BdsLoadOptionFileSystemList (
 EFI_STATUS\r
 BdsLoadOptionFileSystemCreateDevicePath (\r
   IN CHAR16*                    FileName,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNode,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNodes,\r
   OUT ARM_BDS_LOADER_TYPE       *BootType,\r
   OUT UINT32                    *Attributes\r
   )\r
@@ -350,16 +350,17 @@ BdsLoadOptionFileSystemCreateDevicePath (
 \r
   BootFilePathSize = StrSize (BootFilePath);\r
   if (BootFilePathSize == 2) {\r
-    *DevicePathNode = NULL;\r
+    *DevicePathNodes = NULL;\r
     return EFI_NOT_FOUND;\r
   }\r
 \r
   // Create the FilePath Device Path node\r
-  FilePathDevicePath = (FILEPATH_DEVICE_PATH*)AllocatePool(SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize);\r
+  FilePathDevicePath = (FILEPATH_DEVICE_PATH*)AllocatePool(SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize + END_DEVICE_PATH_LENGTH);\r
   FilePathDevicePath->Header.Type = MEDIA_DEVICE_PATH;\r
   FilePathDevicePath->Header.SubType = MEDIA_FILEPATH_DP;\r
   SetDevicePathNodeLength (FilePathDevicePath, SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize);\r
   CopyMem (FilePathDevicePath->PathName, BootFilePath, BootFilePathSize);\r
+  SetDevicePathEndNode ((VOID*)((UINTN)FilePathDevicePath + SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize));\r
 \r
   if (BootType != NULL || Attributes != NULL) {\r
     Status = BootDeviceGetType (FilePathDevicePath->PathName, BootType, Attributes);\r
@@ -368,7 +369,7 @@ BdsLoadOptionFileSystemCreateDevicePath (
   if (EFI_ERROR(Status)) {\r
     FreePool (FilePathDevicePath);\r
   } else {\r
-    *DevicePathNode = (EFI_DEVICE_PATH_PROTOCOL*)FilePathDevicePath;\r
+    *DevicePathNodes = (EFI_DEVICE_PATH_PROTOCOL*)FilePathDevicePath;\r
   }\r
 \r
   return Status;\r
@@ -533,7 +534,7 @@ BdsLoadOptionMemMapList (
 EFI_STATUS\r
 BdsLoadOptionMemMapCreateDevicePath (\r
   IN CHAR16*                    FileName,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNode,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNodes,\r
   OUT ARM_BDS_LOADER_TYPE       *BootType,\r
   OUT UINT32                    *Attributes\r
   )\r
@@ -574,7 +575,7 @@ BdsLoadOptionMemMapCreateDevicePath (
   if (EFI_ERROR(Status)) {\r
     FreePool (MemMapDevicePath);\r
   } else {\r
-    *DevicePathNode = (EFI_DEVICE_PATH_PROTOCOL*)MemMapDevicePath;\r
+    *DevicePathNodes = (EFI_DEVICE_PATH_PROTOCOL*)MemMapDevicePath;\r
   }\r
 \r
   return Status;\r
@@ -691,13 +692,13 @@ BdsLoadOptionPxeList (
 EFI_STATUS\r
 BdsLoadOptionPxeCreateDevicePath (\r
   IN CHAR16*                    FileName,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNode,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNodes,\r
   OUT ARM_BDS_LOADER_TYPE       *BootType,\r
   OUT UINT32                    *Attributes\r
   )\r
 {\r
-  *DevicePathNode = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);\r
-  SetDevicePathEndNode (*DevicePathNode);\r
+  *DevicePathNodes = (EFI_DEVICE_PATH_PROTOCOL *) AllocatePool (END_DEVICE_PATH_LENGTH);\r
+  SetDevicePathEndNode (*DevicePathNodes);\r
   *BootType = BDS_LOADER_EFI_APPLICATION;\r
   return EFI_SUCCESS;\r
 }\r
@@ -793,7 +794,7 @@ BdsLoadOptionTftpList (
 EFI_STATUS\r
 BdsLoadOptionTftpCreateDevicePath (\r
   IN CHAR16*                    FileName,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNode,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNodes,\r
   OUT ARM_BDS_LOADER_TYPE       *BootType,\r
   OUT UINT32                    *Attributes\r
   )\r
@@ -839,7 +840,7 @@ BdsLoadOptionTftpCreateDevicePath (
   }\r
 \r
   // Allocate the memory for the IPv4 + File Path Device Path Nodes\r
-  IPv4DevicePathNode = (IPv4_DEVICE_PATH*)AllocatePool(sizeof(IPv4_DEVICE_PATH) + SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize);\r
+  IPv4DevicePathNode = (IPv4_DEVICE_PATH*)AllocatePool(sizeof(IPv4_DEVICE_PATH) + SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize + END_DEVICE_PATH_LENGTH);\r
 \r
   // Create the IPv4 Device Path\r
   IPv4DevicePathNode->Header.Type    = MESSAGING_DEVICE_PATH;\r
@@ -859,6 +860,9 @@ BdsLoadOptionTftpCreateDevicePath (
   SetDevicePathNodeLength (FilePathDevicePath, SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize);\r
   CopyMem (FilePathDevicePath->PathName, BootFilePath, BootFilePathSize);\r
 \r
+  // Set the End Device Path Node\r
+  SetDevicePathEndNode ((VOID*)((UINTN)FilePathDevicePath + SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize));\r
+\r
   if (BootType != NULL || Attributes != NULL) {\r
     Status = BootDeviceGetType (NULL, BootType, Attributes);\r
   }\r
@@ -866,7 +870,7 @@ BdsLoadOptionTftpCreateDevicePath (
   if (EFI_ERROR(Status)) {\r
     FreePool (IPv4DevicePathNode);\r
   } else {\r
-    *DevicePathNode = (EFI_DEVICE_PATH_PROTOCOL*)IPv4DevicePathNode;\r
+    *DevicePathNodes = (EFI_DEVICE_PATH_PROTOCOL*)IPv4DevicePathNode;\r
   }\r
 \r
   return Status;\r