]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/Bds/BootOptionSupport.c
ArmPlatformPkg/Bds: Fixed the deletion of boot option entries
[mirror_edk2.git] / ArmPlatformPkg / Bds / BootOptionSupport.c
index 336bcb9a2127a59d08d545e388e93886e11267a0..fbdd5947d33dd1afad4d70293956cb7397966271 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 BDS_LOADER_TYPE   *BootType,\r
-  OUT UINT32      *Attributes\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNode,\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 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 BDS_LOADER_TYPE   *BootType,\r
-  OUT UINT32      *Attributes\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNode,\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 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 BDS_LOADER_TYPE   *BootType,\r
-  OUT UINT32      *Attributes\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNode,\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 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,54 +114,55 @@ BdsLoadOptionTftpList (
 \r
 EFI_STATUS\r
 BdsLoadOptionTftpCreateDevicePath (\r
-  IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT BDS_LOADER_TYPE   *BootType,\r
-  OUT UINT32      *Attributes\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNode,\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 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
-    {\r
-        BDS_DEVICE_FILESYSTEM,\r
-        BdsLoadOptionFileSystemList,\r
-        BdsLoadOptionFileSystemIsSupported,\r
-        BdsLoadOptionFileSystemCreateDevicePath,\r
-        BdsLoadOptionFileSystemUpdateDevicePath\r
-    },\r
-    {\r
-        BDS_DEVICE_MEMMAP,\r
-        BdsLoadOptionMemMapList,\r
-        BdsLoadOptionMemMapIsSupported,\r
-        BdsLoadOptionMemMapCreateDevicePath,\r
-        BdsLoadOptionMemMapUpdateDevicePath\r
-    },\r
-    {\r
-        BDS_DEVICE_PXE,\r
-        BdsLoadOptionPxeList,\r
-        BdsLoadOptionPxeIsSupported,\r
-        BdsLoadOptionPxeCreateDevicePath,\r
-        BdsLoadOptionPxeUpdateDevicePath\r
-    },\r
-    {\r
-        BDS_DEVICE_TFTP,\r
-        BdsLoadOptionTftpList,\r
-        BdsLoadOptionTftpIsSupported,\r
-        BdsLoadOptionTftpCreateDevicePath,\r
-        BdsLoadOptionTftpUpdateDevicePath\r
-    }\r
+  {\r
+    BDS_DEVICE_FILESYSTEM,\r
+    BdsLoadOptionFileSystemList,\r
+    BdsLoadOptionFileSystemIsSupported,\r
+    BdsLoadOptionFileSystemCreateDevicePath,\r
+    BdsLoadOptionFileSystemUpdateDevicePath\r
+  },\r
+  {\r
+    BDS_DEVICE_MEMMAP,\r
+    BdsLoadOptionMemMapList,\r
+    BdsLoadOptionMemMapIsSupported,\r
+    BdsLoadOptionMemMapCreateDevicePath,\r
+    BdsLoadOptionMemMapUpdateDevicePath\r
+  },\r
+  {\r
+    BDS_DEVICE_PXE,\r
+    BdsLoadOptionPxeList,\r
+    BdsLoadOptionPxeIsSupported,\r
+    BdsLoadOptionPxeCreateDevicePath,\r
+    BdsLoadOptionPxeUpdateDevicePath\r
+  },\r
+  {\r
+    BDS_DEVICE_TFTP,\r
+    BdsLoadOptionTftpList,\r
+    BdsLoadOptionTftpIsSupported,\r
+    BdsLoadOptionTftpCreateDevicePath,\r
+    BdsLoadOptionTftpUpdateDevicePath\r
+  }\r
 };\r
 \r
 EFI_STATUS\r
@@ -172,7 +176,7 @@ BootDeviceListSupportedInit (
   InitializeListHead (SupportedDeviceList);\r
 \r
   for (Index = 0; Index < BDS_DEVICE_MAX; Index++) {\r
-    BdsLoadOptionSupportList[Index].ListDevices(SupportedDeviceList);\r
+    BdsLoadOptionSupportList[Index].ListDevices (SupportedDeviceList);\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -192,7 +196,7 @@ BootDeviceListSupportedFree (
     SupportedDevice = SUPPORTED_BOOT_DEVICE_FROM_LINK(Entry);\r
     Entry = RemoveEntryList (Entry);\r
     if (SupportedDevice != Except) {\r
-      FreePool(SupportedDevice);\r
+      FreePool (SupportedDevice);\r
     }\r
   }\r
 \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
@@ -222,7 +226,7 @@ STATIC
 EFI_STATUS\r
 BootDeviceGetType (\r
   IN  CHAR16* FileName,\r
-  OUT BDS_LOADER_TYPE *BootType,\r
+  OUT ARM_BDS_LOADER_TYPE *BootType,\r
   OUT UINT32 *Attributes\r
   )\r
 {\r
@@ -295,7 +299,7 @@ BdsLoadOptionFileSystemList (
     Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID **)&DevicePathProtocol);\r
     if (!EFI_ERROR(Status)) {\r
       // Allocate BDS Supported Device structure\r
-      SupportedDevice = (BDS_SUPPORTED_DEVICE*)AllocatePool(sizeof(BDS_SUPPORTED_DEVICE));\r
+      SupportedDevice = (BDS_SUPPORTED_DEVICE*)AllocatePool (sizeof(BDS_SUPPORTED_DEVICE));\r
 \r
       FileProtocol = NULL;\r
       Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiSimpleFileSystemProtocolGuid, (VOID **)&FileProtocol);\r
@@ -327,40 +331,35 @@ BdsLoadOptionFileSystemList (
 \r
 EFI_STATUS\r
 BdsLoadOptionFileSystemCreateDevicePath (\r
-  IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT BDS_LOADER_TYPE   *BootType,\r
-  OUT UINT32      *Attributes\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNode,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   )\r
 {\r
   EFI_STATUS  Status;\r
   FILEPATH_DEVICE_PATH* FilePathDevicePath;\r
-  CHAR8       AsciiBootFilePath[BOOT_DEVICE_FILEPATH_MAX];\r
-  CHAR16      *BootFilePath;\r
+  CHAR16      BootFilePath[BOOT_DEVICE_FILEPATH_MAX];\r
   UINTN       BootFilePathSize;\r
 \r
-  Status = GetHIInputAscii (AsciiBootFilePath,BOOT_DEVICE_FILEPATH_MAX);\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
   }\r
 \r
-  if (AsciiStrSize(AsciiBootFilePath) == 1) {\r
+  BootFilePathSize = StrSize (BootFilePath);\r
+  if (BootFilePathSize == 2) {\r
     *DevicePathNode = NULL;\r
     return EFI_NOT_FOUND;\r
   }\r
 \r
-  // Convert Ascii into Unicode\r
-  BootFilePath = (CHAR16*)AllocatePool(AsciiStrSize(AsciiBootFilePath) * sizeof(CHAR16));\r
-  AsciiStrToUnicodeStr (AsciiBootFilePath, BootFilePath);\r
-  BootFilePathSize = StrSize(BootFilePath);\r
-\r
   // Create the FilePath Device Path node\r
   FilePathDevicePath = (FILEPATH_DEVICE_PATH*)AllocatePool(SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize);\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
-  FreePool (BootFilePath);\r
 \r
   if (BootType != NULL || Attributes != NULL) {\r
     Status = BootDeviceGetType (FilePathDevicePath->PathName, BootType, Attributes);\r
@@ -377,47 +376,43 @@ BdsLoadOptionFileSystemCreateDevicePath (
 \r
 EFI_STATUS\r
 BdsLoadOptionFileSystemUpdateDevicePath (\r
-  IN EFI_DEVICE_PATH *OldDevicePath,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT 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
-  CHAR8       AsciiBootFilePath[BOOT_DEVICE_FILEPATH_MAX];\r
-  CHAR16      *BootFilePath;\r
+  CHAR16      BootFilePath[BOOT_DEVICE_FILEPATH_MAX];\r
   UINTN       BootFilePathSize;\r
   FILEPATH_DEVICE_PATH* EndingDevicePath;\r
   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
-  UnicodeStrToAsciiStr (EndingDevicePath->PathName,AsciiBootFilePath);\r
-  Status = EditHIInputAscii (AsciiBootFilePath,BOOT_DEVICE_FILEPATH_MAX);\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
     return Status;\r
   }\r
 \r
-  if (AsciiStrSize(AsciiBootFilePath) == 1) {\r
+  BootFilePathSize = StrSize(BootFilePath);\r
+  if (BootFilePathSize == 2) {\r
     *NewDevicePath = NULL;\r
     return EFI_NOT_FOUND;\r
   }\r
 \r
-  // Convert Ascii into Unicode\r
-  BootFilePath = (CHAR16*)AllocatePool(AsciiStrSize(AsciiBootFilePath) * sizeof(CHAR16));\r
-  AsciiStrToUnicodeStr (AsciiBootFilePath, BootFilePath);\r
-  BootFilePathSize = StrSize(BootFilePath);\r
-\r
   // Create the FilePath Device Path node\r
   FilePathDevicePath = (FILEPATH_DEVICE_PATH*)AllocatePool(SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize);\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
-  FreePool (BootFilePath);\r
 \r
   // Generate the new Device Path by replacing the last node by the updated node\r
   SetDevicePathEndNode (EndingDevicePath);\r
@@ -433,12 +428,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
@@ -537,38 +532,45 @@ BdsLoadOptionMemMapList (
 \r
 EFI_STATUS\r
 BdsLoadOptionMemMapCreateDevicePath (\r
-  IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT BDS_LOADER_TYPE   *BootType,\r
-  OUT UINT32      *Attributes\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNode,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   )\r
 {\r
-  EFI_STATUS  Status;\r
-  MEMMAP_DEVICE_PATHMemMapDevicePath;\r
-  CHAR8       AsciiStartingAddress[BOOT_DEVICE_ADDRESS_MAX];\r
-  CHAR8       AsciiEndingAddress[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 = GetHIInputAscii (AsciiStartingAddress,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 = GetHIInputAscii (AsciiEndingAddress,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 = AsciiStrHexToUint64 (AsciiStartingAddress);\r
-  MemMapDevicePath->EndingAddress = AsciiStrHexToUint64 (AsciiEndingAddress);\r
+  MemMapDevicePath->StartingAddress = StrHexToUint64 (StrStartingAddress);\r
+  MemMapDevicePath->EndingAddress = StrHexToUint64 (StrEndingAddress);\r
+\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
-  Status = BootDeviceGetType (NULL, BootType, Attributes);\r
   if (EFI_ERROR(Status)) {\r
     FreePool (MemMapDevicePath);\r
   } else {\r
@@ -580,39 +582,43 @@ BdsLoadOptionMemMapCreateDevicePath (
 \r
 EFI_STATUS\r
 BdsLoadOptionMemMapUpdateDevicePath (\r
-  IN EFI_DEVICE_PATH *OldDevicePath,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT 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
-  CHAR8               AsciiStartingAddress[BOOT_DEVICE_ADDRESS_MAX];\r
-  CHAR8               AsciiEndingAddress[BOOT_DEVICE_ADDRESS_MAX];\r
+  CHAR16              StrStartingAddress[BOOT_DEVICE_ADDRESS_MAX];\r
+  CHAR16              StrEndingAddress[BOOT_DEVICE_ADDRESS_MAX];\r
   MEMMAP_DEVICE_PATH* EndingDevicePath;\r
   EFI_DEVICE_PATH*    DevicePath;\r
 \r
   DevicePath = DuplicateDevicePath (OldDevicePath);\r
   EndingDevicePath = (MEMMAP_DEVICE_PATH*)GetLastDevicePathNode (DevicePath);\r
 \r
-  Print(L"Starting Address of the binary: ");\r
-  AsciiSPrint (AsciiStartingAddress,BOOT_DEVICE_ADDRESS_MAX,"0x%X",(UINTN)EndingDevicePath->StartingAddress);\r
-  Status = EditHIInputAscii (AsciiStartingAddress,BOOT_DEVICE_ADDRESS_MAX);\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
-  AsciiSPrint (AsciiEndingAddress,BOOT_DEVICE_ADDRESS_MAX,"0x%X",(UINTN)EndingDevicePath->EndingAddress);\r
-  Status = EditHIInputAscii (AsciiEndingAddress,BOOT_DEVICE_ADDRESS_MAX);\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
     return EFI_ABORTED;\r
   }\r
 \r
-  EndingDevicePath->StartingAddress = AsciiStrHexToUint64 (AsciiStartingAddress);\r
-  EndingDevicePath->EndingAddress = AsciiStrHexToUint64 (AsciiEndingAddress);\r
+  EndingDevicePath->StartingAddress = StrHexToUint64 (StrStartingAddress);\r
+  EndingDevicePath->EndingAddress = StrHexToUint64 (StrEndingAddress);\r
+\r
+  if (BootType != NULL || Attributes != NULL) {\r
+    Status = BootDeviceGetType (NULL, BootType, Attributes);\r
+  }\r
 \r
-  Status = BootDeviceGetType (NULL, BootType, Attributes);\r
   if (EFI_ERROR(Status)) {\r
     FreePool(DevicePath);\r
   } else {\r
@@ -624,12 +630,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
@@ -684,10 +690,10 @@ BdsLoadOptionPxeList (
 \r
 EFI_STATUS\r
 BdsLoadOptionPxeCreateDevicePath (\r
-  IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT BDS_LOADER_TYPE   *BootType,\r
-  OUT UINT32      *Attributes\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNode,\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
@@ -698,10 +704,11 @@ BdsLoadOptionPxeCreateDevicePath (
 \r
 EFI_STATUS\r
 BdsLoadOptionPxeUpdateDevicePath (\r
-  IN EFI_DEVICE_PATH *OldDevicePath,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT 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
@@ -710,7 +717,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
@@ -718,7 +725,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
@@ -771,7 +778,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
@@ -785,10 +792,10 @@ BdsLoadOptionTftpList (
 \r
 EFI_STATUS\r
 BdsLoadOptionTftpCreateDevicePath (\r
-  IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT BDS_LOADER_TYPE   *BootType,\r
-  OUT UINT32      *Attributes\r
+  IN CHAR16*                    FileName,\r
+  OUT EFI_DEVICE_PATH_PROTOCOL  **DevicePathNode,\r
+  OUT ARM_BDS_LOADER_TYPE       *BootType,\r
+  OUT UINT32                    *Attributes\r
   )\r
 {\r
   EFI_STATUS    Status;\r
@@ -797,8 +804,7 @@ BdsLoadOptionTftpCreateDevicePath (
   EFI_IP_ADDRESS  RemoteIp;\r
   IPv4_DEVICE_PATH*   IPv4DevicePathNode;\r
   FILEPATH_DEVICE_PATH* FilePathDevicePath;\r
-  CHAR8       AsciiBootFilePath[BOOT_DEVICE_FILEPATH_MAX];\r
-  CHAR16*     BootFilePath;\r
+  CHAR16      BootFilePath[BOOT_DEVICE_FILEPATH_MAX];\r
   UINTN       BootFilePathSize;\r
 \r
   Print(L"Get the IP address from DHCP: ");\r
@@ -821,16 +827,16 @@ BdsLoadOptionTftpCreateDevicePath (
     return EFI_ABORTED;\r
   }\r
 \r
-  Print(L"File path of the EFI Application or the kernel: ");\r
-  Status = GetHIInputAscii (AsciiBootFilePath,BOOT_DEVICE_FILEPATH_MAX);\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
   }\r
 \r
-  // Convert Ascii into Unicode\r
-  BootFilePath = (CHAR16*)AllocatePool(AsciiStrSize(AsciiBootFilePath) * sizeof(CHAR16));\r
-  AsciiStrToUnicodeStr (AsciiBootFilePath, BootFilePath);\r
   BootFilePathSize = StrSize(BootFilePath);\r
+  if (BootFilePathSize == 2) {\r
+    return EFI_NOT_FOUND;\r
+  }\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
@@ -852,9 +858,11 @@ BdsLoadOptionTftpCreateDevicePath (
   FilePathDevicePath->Header.SubType = MEDIA_FILEPATH_DP;\r
   SetDevicePathNodeLength (FilePathDevicePath, SIZE_OF_FILEPATH_DEVICE_PATH + BootFilePathSize);\r
   CopyMem (FilePathDevicePath->PathName, BootFilePath, BootFilePathSize);\r
-  FreePool (BootFilePath);\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 (IPv4DevicePathNode);\r
   } else {\r
@@ -866,10 +874,11 @@ BdsLoadOptionTftpCreateDevicePath (
 \r
 EFI_STATUS\r
 BdsLoadOptionTftpUpdateDevicePath (\r
-  IN EFI_DEVICE_PATH *OldDevicePath,\r
-  OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT 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
@@ -878,7 +887,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
@@ -887,7 +896,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