]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/Bds/BootOptionSupport.c
ArmPlatformPkg/BdsLib: Let the user press enter when inputting booleans
[mirror_edk2.git] / ArmPlatformPkg / Bds / BootOptionSupport.c
index fb383b6f2468beb405991784c058fc5b7fbabdf3..190169a304b84240b2cd73f88d52ce0f077f0900 100644 (file)
@@ -33,23 +33,24 @@ BdsLoadOptionFileSystemList (
 \r
 EFI_STATUS\r
 BdsLoadOptionFileSystemCreateDevicePath (\r
-  IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT ARM_BDS_LOADER_TYPE   *BootType,\r
-  OUT UINT32      *Attributes\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNodes,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   );\r
 \r
 EFI_STATUS\r
 BdsLoadOptionFileSystemUpdateDevicePath (\r
-  IN EFI_DEVICE_PATH *OldDevicePath,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT ARM_BDS_LOADER_TYPE *BootType,\r
-  OUT UINT32 *Attributes\r
+  IN EFI_DEVICE_PATH            *OldDevicePath,\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **NewDevicePath,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   );\r
 \r
 BOOLEAN\r
 BdsLoadOptionFileSystemIsSupported (\r
-  IN BDS_LOAD_OPTION* BdsLoadOption\r
+  IN  EFI_DEVICE_PATH           *DevicePath\r
   );\r
 \r
 EFI_STATUS\r
@@ -59,23 +60,24 @@ BdsLoadOptionMemMapList (
 \r
 EFI_STATUS\r
 BdsLoadOptionMemMapCreateDevicePath (\r
-  IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT ARM_BDS_LOADER_TYPE   *BootType,\r
-  OUT UINT32      *Attributes\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNodes,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   );\r
 \r
 EFI_STATUS\r
 BdsLoadOptionMemMapUpdateDevicePath (\r
-  IN EFI_DEVICE_PATH *OldDevicePath,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT ARM_BDS_LOADER_TYPE *BootType,\r
-  OUT UINT32 *Attributes\r
+  IN EFI_DEVICE_PATH            *OldDevicePath,\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **NewDevicePath,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   );\r
 \r
 BOOLEAN\r
 BdsLoadOptionMemMapIsSupported (\r
-  IN BDS_LOAD_OPTION* BdsLoadOption\r
+  IN  EFI_DEVICE_PATH           *DevicePath\r
   );\r
 \r
 EFI_STATUS\r
@@ -85,23 +87,24 @@ BdsLoadOptionPxeList (
 \r
 EFI_STATUS\r
 BdsLoadOptionPxeCreateDevicePath (\r
-  IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT ARM_BDS_LOADER_TYPE   *BootType,\r
-  OUT UINT32      *Attributes\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNodes,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   );\r
 \r
 EFI_STATUS\r
 BdsLoadOptionPxeUpdateDevicePath (\r
-  IN EFI_DEVICE_PATH *OldDevicePath,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT ARM_BDS_LOADER_TYPE *BootType,\r
-  OUT UINT32 *Attributes\r
+  IN EFI_DEVICE_PATH            *OldDevicePath,\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **NewDevicePath,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   );\r
 \r
 BOOLEAN\r
 BdsLoadOptionPxeIsSupported (\r
-  IN BDS_LOAD_OPTION* BdsLoadOption\r
+  IN  EFI_DEVICE_PATH           *DevicePath\r
   );\r
 \r
 EFI_STATUS\r
@@ -111,23 +114,24 @@ BdsLoadOptionTftpList (
 \r
 EFI_STATUS\r
 BdsLoadOptionTftpCreateDevicePath (\r
-  IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT ARM_BDS_LOADER_TYPE   *BootType,\r
-  OUT UINT32      *Attributes\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNodes,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   );\r
 \r
 EFI_STATUS\r
 BdsLoadOptionTftpUpdateDevicePath (\r
-  IN EFI_DEVICE_PATH *OldDevicePath,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT ARM_BDS_LOADER_TYPE *BootType,\r
-  OUT UINT32 *Attributes\r
+  IN EFI_DEVICE_PATH            *OldDevicePath,\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **NewDevicePath,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   );\r
 \r
 BOOLEAN\r
 BdsLoadOptionTftpIsSupported (\r
-  IN BDS_LOAD_OPTION* BdsLoadOption\r
+  IN  EFI_DEVICE_PATH           *DevicePath\r
   );\r
 \r
 BDS_LOAD_OPTION_SUPPORT BdsLoadOptionSupportList[] = {\r
@@ -201,15 +205,15 @@ BootDeviceListSupportedFree (
 \r
 EFI_STATUS\r
 BootDeviceGetDeviceSupport (\r
-  IN  BDS_LOAD_OPTION *BootOption,\r
-  OUT BDS_LOAD_OPTION_SUPPORT**  DeviceSupport\r
+  IN  EFI_DEVICE_PATH           *DevicePath,\r
+  OUT BDS_LOAD_OPTION_SUPPORT   **DeviceSupport\r
   )\r
 {\r
   UINTN Index;\r
 \r
   // Find which supported device is the most appropriate\r
   for (Index = 0; Index < BDS_DEVICE_MAX; Index++) {\r
-    if (BdsLoadOptionSupportList[Index].IsSupported (BootOption)) {\r
+    if (BdsLoadOptionSupportList[Index].IsSupported (DevicePath)) {\r
       *DeviceSupport = &BdsLoadOptionSupportList[Index];\r
       return EFI_SUCCESS;\r
     }\r
@@ -327,10 +331,10 @@ BdsLoadOptionFileSystemList (
 \r
 EFI_STATUS\r
 BdsLoadOptionFileSystemCreateDevicePath (\r
-  IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT ARM_BDS_LOADER_TYPE   *BootType,\r
-  OUT UINT32      *Attributes\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNodes,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   )\r
 {\r
   EFI_STATUS  Status;\r
@@ -338,6 +342,7 @@ BdsLoadOptionFileSystemCreateDevicePath (
   CHAR16      BootFilePath[BOOT_DEVICE_FILEPATH_MAX];\r
   UINTN       BootFilePathSize;\r
 \r
+  Print(L"File path of the %s: ", FileName);\r
   Status = GetHIInputStr (BootFilePath, BOOT_DEVICE_FILEPATH_MAX);\r
   if (EFI_ERROR(Status)) {\r
     return EFI_ABORTED;\r
@@ -345,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
@@ -363,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
@@ -371,10 +377,11 @@ BdsLoadOptionFileSystemCreateDevicePath (
 \r
 EFI_STATUS\r
 BdsLoadOptionFileSystemUpdateDevicePath (\r
-  IN EFI_DEVICE_PATH *OldDevicePath,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT ARM_BDS_LOADER_TYPE *BootType,\r
-  OUT UINT32 *Attributes\r
+  IN EFI_DEVICE_PATH            *OldDevicePath,\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **NewDevicePath,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   )\r
 {\r
   EFI_STATUS  Status;\r
@@ -384,10 +391,11 @@ BdsLoadOptionFileSystemUpdateDevicePath (
   FILEPATH_DEVICE_PATH* FilePathDevicePath;\r
   EFI_DEVICE_PATH*  DevicePath;\r
 \r
-  DevicePath = DuplicateDevicePath(OldDevicePath);\r
+  DevicePath = DuplicateDevicePath (OldDevicePath);\r
 \r
   EndingDevicePath = (FILEPATH_DEVICE_PATH*)GetLastDevicePathNode (DevicePath);\r
  \r
+  Print(L"File path of the %s: ", FileName);\r
   StrnCpy (BootFilePath, EndingDevicePath->PathName, BOOT_DEVICE_FILEPATH_MAX);\r
   Status = EditHIInputStr (BootFilePath, BOOT_DEVICE_FILEPATH_MAX);\r
   if (EFI_ERROR(Status)) {\r
@@ -421,12 +429,12 @@ BdsLoadOptionFileSystemUpdateDevicePath (
 \r
 BOOLEAN\r
 BdsLoadOptionFileSystemIsSupported (\r
-  IN BDS_LOAD_OPTION* BdsLoadOption\r
+  IN  EFI_DEVICE_PATH           *DevicePath\r
   )\r
 {\r
   EFI_DEVICE_PATH*  DevicePathNode;\r
 \r
-  DevicePathNode = GetLastDevicePathNode (BdsLoadOption->FilePathList);\r
+  DevicePathNode = GetLastDevicePathNode (DevicePath);\r
 \r
   return IS_DEVICE_PATH_NODE(DevicePathNode,MEDIA_DEVICE_PATH,MEDIA_FILEPATH_DP);\r
 }\r
@@ -525,42 +533,49 @@ BdsLoadOptionMemMapList (
 \r
 EFI_STATUS\r
 BdsLoadOptionMemMapCreateDevicePath (\r
-  IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT ARM_BDS_LOADER_TYPE   *BootType,\r
-  OUT UINT32      *Attributes\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNodes,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   )\r
 {\r
-  EFI_STATUS  Status;\r
-  MEMMAP_DEVICE_PATHMemMapDevicePath;\r
-  CHAR16       StrStartingAddress[BOOT_DEVICE_ADDRESS_MAX];\r
-  CHAR16       StrEndingAddress[BOOT_DEVICE_ADDRESS_MAX];\r
+  EFI_STATUS              Status;\r
+  MEMMAP_DEVICE_PATH      *MemMapDevicePath;\r
+  CHAR16                  StrStartingAddress[BOOT_DEVICE_ADDRESS_MAX];\r
+  CHAR16                  StrEndingAddress[BOOT_DEVICE_ADDRESS_MAX];\r
 \r
-  Print(L"Starting Address of the binary: ");\r
-  Status = GetHIInputStr (StrStartingAddress,BOOT_DEVICE_ADDRESS_MAX);\r
+  Print(L"Starting Address of the %s: ", FileName);\r
+  Status = GetHIInputStr (StrStartingAddress, BOOT_DEVICE_ADDRESS_MAX);\r
   if (EFI_ERROR(Status)) {\r
     return EFI_ABORTED;\r
   }\r
 \r
-  Print(L"Ending Address of the binary: ");\r
-  Status = GetHIInputStr (StrEndingAddress,BOOT_DEVICE_ADDRESS_MAX);\r
+  Print(L"Ending Address of the %s: ", FileName);\r
+  Status = GetHIInputStr (StrEndingAddress, BOOT_DEVICE_ADDRESS_MAX);\r
   if (EFI_ERROR(Status)) {\r
     return EFI_ABORTED;\r
   }\r
 \r
   // Create the MemMap Device Path Node\r
-  MemMapDevicePath = (MEMMAP_DEVICE_PATH*)AllocatePool (sizeof(MEMMAP_DEVICE_PATH));\r
+  MemMapDevicePath = (MEMMAP_DEVICE_PATH*)AllocatePool (sizeof(MEMMAP_DEVICE_PATH) + END_DEVICE_PATH_LENGTH);\r
   MemMapDevicePath->Header.Type = HARDWARE_DEVICE_PATH;\r
   MemMapDevicePath->Header.SubType = HW_MEMMAP_DP;\r
+  SetDevicePathNodeLength (MemMapDevicePath, sizeof(MEMMAP_DEVICE_PATH));\r
   MemMapDevicePath->MemoryType = EfiBootServicesData;\r
   MemMapDevicePath->StartingAddress = StrHexToUint64 (StrStartingAddress);\r
   MemMapDevicePath->EndingAddress = StrHexToUint64 (StrEndingAddress);\r
 \r
-  Status = BootDeviceGetType (NULL, BootType, Attributes);\r
+  // Set a Device Path End Node after the Memory Map Device Path Node\r
+  SetDevicePathEndNode (MemMapDevicePath + 1);\r
+\r
+  if (BootType != NULL || Attributes != NULL) {\r
+    Status = BootDeviceGetType (NULL, BootType, Attributes);\r
+  }\r
+\r
   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
@@ -568,10 +583,11 @@ BdsLoadOptionMemMapCreateDevicePath (
 \r
 EFI_STATUS\r
 BdsLoadOptionMemMapUpdateDevicePath (\r
-  IN EFI_DEVICE_PATH *OldDevicePath,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT ARM_BDS_LOADER_TYPE *BootType,\r
-  OUT UINT32 *Attributes\r
+  IN EFI_DEVICE_PATH            *OldDevicePath,\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **NewDevicePath,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   )\r
 {\r
   EFI_STATUS          Status;\r
@@ -583,14 +599,14 @@ BdsLoadOptionMemMapUpdateDevicePath (
   DevicePath = DuplicateDevicePath (OldDevicePath);\r
   EndingDevicePath = (MEMMAP_DEVICE_PATH*)GetLastDevicePathNode (DevicePath);\r
 \r
-  Print(L"Starting Address of the binary: ");\r
+  Print(L"Starting Address of the %s: ", FileName);\r
   UnicodeSPrint (StrStartingAddress, BOOT_DEVICE_ADDRESS_MAX, L"0x%X", (UINTN)EndingDevicePath->StartingAddress);\r
   Status = EditHIInputStr (StrStartingAddress, BOOT_DEVICE_ADDRESS_MAX);\r
   if (EFI_ERROR(Status)) {\r
     return EFI_ABORTED;\r
   }\r
 \r
-  Print(L"Ending Address of the binary: ");\r
+  Print(L"Ending Address of the %s: ", FileName);\r
   UnicodeSPrint (StrEndingAddress, BOOT_DEVICE_ADDRESS_MAX, L"0x%X", (UINTN)EndingDevicePath->EndingAddress);\r
   Status = EditHIInputStr (StrEndingAddress, BOOT_DEVICE_ADDRESS_MAX);\r
   if (EFI_ERROR(Status)) {\r
@@ -600,7 +616,10 @@ BdsLoadOptionMemMapUpdateDevicePath (
   EndingDevicePath->StartingAddress = StrHexToUint64 (StrStartingAddress);\r
   EndingDevicePath->EndingAddress = StrHexToUint64 (StrEndingAddress);\r
 \r
-  Status = BootDeviceGetType (NULL, BootType, Attributes);\r
+  if (BootType != NULL || Attributes != NULL) {\r
+    Status = BootDeviceGetType (NULL, BootType, Attributes);\r
+  }\r
+\r
   if (EFI_ERROR(Status)) {\r
     FreePool(DevicePath);\r
   } else {\r
@@ -612,12 +631,12 @@ BdsLoadOptionMemMapUpdateDevicePath (
 \r
 BOOLEAN\r
 BdsLoadOptionMemMapIsSupported (\r
-  IN BDS_LOAD_OPTION* BdsLoadOption\r
+  IN  EFI_DEVICE_PATH           *DevicePath\r
   )\r
 {\r
   EFI_DEVICE_PATH*  DevicePathNode;\r
 \r
-  DevicePathNode = GetLastDevicePathNode (BdsLoadOption->FilePathList);\r
+  DevicePathNode = GetLastDevicePathNode (DevicePath);\r
 \r
   return IS_DEVICE_PATH_NODE(DevicePathNode,HARDWARE_DEVICE_PATH,HW_MEMMAP_DP);\r
 }\r
@@ -672,24 +691,25 @@ BdsLoadOptionPxeList (
 \r
 EFI_STATUS\r
 BdsLoadOptionPxeCreateDevicePath (\r
-  IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT ARM_BDS_LOADER_TYPE   *BootType,\r
-  OUT UINT32      *Attributes\r
+  IN CHAR16*                    FileName,\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
 \r
 EFI_STATUS\r
 BdsLoadOptionPxeUpdateDevicePath (\r
-  IN EFI_DEVICE_PATH *OldDevicePath,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT ARM_BDS_LOADER_TYPE *BootType,\r
-  OUT UINT32 *Attributes\r
+  IN EFI_DEVICE_PATH            *OldDevicePath,\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **NewDevicePath,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   )\r
 {\r
   ASSERT (0);\r
@@ -698,7 +718,7 @@ BdsLoadOptionPxeUpdateDevicePath (
 \r
 BOOLEAN\r
 BdsLoadOptionPxeIsSupported (\r
-  IN BDS_LOAD_OPTION* BdsLoadOption\r
+  IN  EFI_DEVICE_PATH           *DevicePath\r
   )\r
 {\r
   EFI_STATUS  Status;\r
@@ -706,7 +726,7 @@ BdsLoadOptionPxeIsSupported (
   EFI_DEVICE_PATH_PROTOCOL  *RemainingDevicePath;\r
   EFI_PXE_BASE_CODE_PROTOCOL  *PxeBcProtocol;\r
 \r
-  Status = BdsConnectDevicePath (BdsLoadOption->FilePathList, &Handle, &RemainingDevicePath);\r
+  Status = BdsConnectDevicePath (DevicePath, &Handle, &RemainingDevicePath);\r
   if (EFI_ERROR(Status)) {\r
     return FALSE;\r
   }\r
@@ -759,7 +779,7 @@ BdsLoadOptionTftpList (
         Status = GenerateDeviceDescriptionName (HandleBuffer[Index], DeviceDescription);\r
         ASSERT_EFI_ERROR (Status);\r
       }\r
-      UnicodeSPrint (SupportedDevice->Description,BOOT_DEVICE_DESCRIPTION_MAX,L"TFP on %s",DeviceDescription);\r
+      UnicodeSPrint (SupportedDevice->Description,BOOT_DEVICE_DESCRIPTION_MAX,L"TFTP on %s",DeviceDescription);\r
 \r
       SupportedDevice->DevicePathProtocol = DevicePathProtocol;\r
       SupportedDevice->Support = &BdsLoadOptionSupportList[BDS_DEVICE_TFTP];\r
@@ -773,10 +793,10 @@ BdsLoadOptionTftpList (
 \r
 EFI_STATUS\r
 BdsLoadOptionTftpCreateDevicePath (\r
-  IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT ARM_BDS_LOADER_TYPE   *BootType,\r
-  OUT UINT32      *Attributes\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNodes,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   )\r
 {\r
   EFI_STATUS    Status;\r
@@ -808,7 +828,7 @@ BdsLoadOptionTftpCreateDevicePath (
     return EFI_ABORTED;\r
   }\r
 \r
-  Print(L"File path of the EFI Application or the kernel : ");\r
+  Print(L"File path of the %s : ", FileName);\r
   Status = GetHIInputStr (BootFilePath, BOOT_DEVICE_FILEPATH_MAX);\r
   if (EFI_ERROR(Status)) {\r
     return EFI_ABORTED;\r
@@ -820,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
@@ -840,11 +860,17 @@ BdsLoadOptionTftpCreateDevicePath (
   SetDevicePathNodeLength (FilePathDevicePath, SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize);\r
   CopyMem (FilePathDevicePath->PathName, BootFilePath, BootFilePathSize);\r
 \r
-  Status = BootDeviceGetType (NULL, BootType, Attributes);\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
+\r
   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
@@ -852,10 +878,11 @@ BdsLoadOptionTftpCreateDevicePath (
 \r
 EFI_STATUS\r
 BdsLoadOptionTftpUpdateDevicePath (\r
-  IN EFI_DEVICE_PATH *OldDevicePath,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT ARM_BDS_LOADER_TYPE *BootType,\r
-  OUT UINT32 *Attributes\r
+  IN EFI_DEVICE_PATH            *OldDevicePath,\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **NewDevicePath,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   )\r
 {\r
   ASSERT (0);\r
@@ -864,7 +891,7 @@ BdsLoadOptionTftpUpdateDevicePath (
 \r
 BOOLEAN\r
 BdsLoadOptionTftpIsSupported (\r
-  IN BDS_LOAD_OPTION* BdsLoadOption\r
+  IN  EFI_DEVICE_PATH           *DevicePath\r
   )\r
 {\r
   EFI_STATUS  Status;\r
@@ -873,7 +900,7 @@ BdsLoadOptionTftpIsSupported (
   EFI_DEVICE_PATH  *NextDevicePath;\r
   EFI_PXE_BASE_CODE_PROTOCOL  *PxeBcProtocol;\r
 \r
-  Status = BdsConnectDevicePath (BdsLoadOption->FilePathList, &Handle, &RemainingDevicePath);\r
+  Status = BdsConnectDevicePath (DevicePath, &Handle, &RemainingDevicePath);\r
   if (EFI_ERROR(Status)) {\r
     return FALSE;\r
   }\r