]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/Bds/BootOptionSupport.c
ArmPlatformPkg/Bds: Add an option in the Boot Manager to edit the Device Path of...
[mirror_edk2.git] / ArmPlatformPkg / Bds / BootOptionSupport.c
index 7de2df4825b761c279f8ea91b5d6e1944a74c632..fb383b6f2468beb405991784c058fc5b7fbabdf3 100644 (file)
@@ -35,15 +35,15 @@ EFI_STATUS
 BdsLoadOptionFileSystemCreateDevicePath (\r
   IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
   OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT BDS_LOADER_TYPE   *BootType,\r
+  OUT ARM_BDS_LOADER_TYPE   *BootType,\r
   OUT UINT32      *Attributes\r
   );\r
 \r
 EFI_STATUS\r
 BdsLoadOptionFileSystemUpdateDevicePath (\r
-  IN BDS_LOAD_OPTION *BootOption,\r
+  IN EFI_DEVICE_PATH *OldDevicePath,\r
   OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT BDS_LOADER_TYPE *BootType,\r
+  OUT ARM_BDS_LOADER_TYPE *BootType,\r
   OUT UINT32 *Attributes\r
   );\r
 \r
@@ -61,15 +61,15 @@ EFI_STATUS
 BdsLoadOptionMemMapCreateDevicePath (\r
   IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
   OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT BDS_LOADER_TYPE   *BootType,\r
+  OUT ARM_BDS_LOADER_TYPE   *BootType,\r
   OUT UINT32      *Attributes\r
   );\r
 \r
 EFI_STATUS\r
 BdsLoadOptionMemMapUpdateDevicePath (\r
-  IN BDS_LOAD_OPTION *BootOption,\r
+  IN EFI_DEVICE_PATH *OldDevicePath,\r
   OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT BDS_LOADER_TYPE *BootType,\r
+  OUT ARM_BDS_LOADER_TYPE *BootType,\r
   OUT UINT32 *Attributes\r
   );\r
 \r
@@ -87,15 +87,15 @@ EFI_STATUS
 BdsLoadOptionPxeCreateDevicePath (\r
   IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
   OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT BDS_LOADER_TYPE   *BootType,\r
+  OUT ARM_BDS_LOADER_TYPE   *BootType,\r
   OUT UINT32      *Attributes\r
   );\r
 \r
 EFI_STATUS\r
 BdsLoadOptionPxeUpdateDevicePath (\r
-  IN BDS_LOAD_OPTION *BootOption,\r
+  IN EFI_DEVICE_PATH *OldDevicePath,\r
   OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT BDS_LOADER_TYPE *BootType,\r
+  OUT ARM_BDS_LOADER_TYPE *BootType,\r
   OUT UINT32 *Attributes\r
   );\r
 \r
@@ -113,15 +113,15 @@ EFI_STATUS
 BdsLoadOptionTftpCreateDevicePath (\r
   IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
   OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT BDS_LOADER_TYPE   *BootType,\r
+  OUT ARM_BDS_LOADER_TYPE   *BootType,\r
   OUT UINT32      *Attributes\r
   );\r
 \r
 EFI_STATUS\r
 BdsLoadOptionTftpUpdateDevicePath (\r
-  IN BDS_LOAD_OPTION *BootOption,\r
+  IN EFI_DEVICE_PATH *OldDevicePath,\r
   OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT BDS_LOADER_TYPE *BootType,\r
+  OUT ARM_BDS_LOADER_TYPE *BootType,\r
   OUT UINT32 *Attributes\r
   );\r
 \r
@@ -131,34 +131,34 @@ BdsLoadOptionTftpIsSupported (
   );\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 +172,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
@@ -180,7 +180,8 @@ BootDeviceListSupportedInit (
 \r
 EFI_STATUS\r
 BootDeviceListSupportedFree (\r
-  IN LIST_ENTRY *SupportedDeviceList\r
+  IN LIST_ENTRY *SupportedDeviceList,\r
+  IN BDS_SUPPORTED_DEVICE *Except\r
   )\r
 {\r
   LIST_ENTRY  *Entry;\r
@@ -190,7 +191,9 @@ BootDeviceListSupportedFree (
   while (Entry != SupportedDeviceList) {\r
     SupportedDevice = SUPPORTED_BOOT_DEVICE_FROM_LINK(Entry);\r
     Entry = RemoveEntryList (Entry);\r
-    FreePool(SupportedDevice);\r
+    if (SupportedDevice != Except) {\r
+      FreePool (SupportedDevice);\r
+    }\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -206,7 +209,7 @@ BootDeviceGetDeviceSupport (
 \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 (BootOption)) {\r
       *DeviceSupport = &BdsLoadOptionSupportList[Index];\r
       return EFI_SUCCESS;\r
     }\r
@@ -219,7 +222,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
@@ -292,7 +295,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
@@ -326,26 +329,25 @@ EFI_STATUS
 BdsLoadOptionFileSystemCreateDevicePath (\r
   IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
   OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT BDS_LOADER_TYPE   *BootType,\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
-  Print(L"File path of the EFI Application or the kernel: ");\r
-  Status = GetHIInputAscii (AsciiBootFilePath,BOOT_DEVICE_FILEPATH_MAX);\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
+  BootFilePathSize = StrSize (BootFilePath);\r
+  if (BootFilePathSize == 2) {\r
+    *DevicePathNode = 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
@@ -353,9 +355,11 @@ BdsLoadOptionFileSystemCreateDevicePath (
   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 (FilePathDevicePath->PathName, BootType, Attributes);\r
+  if (BootType != NULL || Attributes != NULL) {\r
+    Status = BootDeviceGetType (FilePathDevicePath->PathName, BootType, Attributes);\r
+  }\r
+\r
   if (EFI_ERROR(Status)) {\r
     FreePool (FilePathDevicePath);\r
   } else {\r
@@ -367,34 +371,34 @@ BdsLoadOptionFileSystemCreateDevicePath (
 \r
 EFI_STATUS\r
 BdsLoadOptionFileSystemUpdateDevicePath (\r
-  IN BDS_LOAD_OPTION *BootOption,\r
+  IN EFI_DEVICE_PATH *OldDevicePath,\r
   OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT BDS_LOADER_TYPE *BootType,\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 (BootOption->FilePathList);\r
-  EndingDevicePath = (FILEPATH_DEVICE_PATH*)GetLastDevicePathNode (DevicePath);\r
+  DevicePath = DuplicateDevicePath(OldDevicePath);\r
 \r
-  Print(L"File path of the EFI Application or the kernel: ");\r
-  UnicodeStrToAsciiStr (EndingDevicePath->PathName,AsciiBootFilePath);\r
-  Status = EditHIInputAscii(AsciiBootFilePath,BOOT_DEVICE_FILEPATH_MAX);\r
+  EndingDevicePath = (FILEPATH_DEVICE_PATH*)GetLastDevicePathNode (DevicePath);\r
\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
-  // 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
+    *NewDevicePath = 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
@@ -402,14 +406,17 @@ BdsLoadOptionFileSystemUpdateDevicePath (
   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
   *NewDevicePath = AppendDevicePathNode (DevicePath, (CONST EFI_DEVICE_PATH_PROTOCOL *)FilePathDevicePath);\r
   FreePool(DevicePath);\r
 \r
-  return BootDeviceGetType (FilePathDevicePath->PathName, BootType, Attributes);\r
+  if (BootType != NULL || Attributes != NULL) {\r
+    return BootDeviceGetType (FilePathDevicePath->PathName, BootType, Attributes);\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 BOOLEAN\r
@@ -520,34 +527,34 @@ EFI_STATUS
 BdsLoadOptionMemMapCreateDevicePath (\r
   IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
   OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT BDS_LOADER_TYPE   *BootType,\r
+  OUT ARM_BDS_LOADER_TYPE   *BootType,\r
   OUT UINT32      *Attributes\r
   )\r
 {\r
   EFI_STATUS  Status;\r
   MEMMAP_DEVICE_PATH* MemMapDevicePath;\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
 \r
   Print(L"Starting Address of the binary: ");\r
-  Status = GetHIInputAscii (AsciiStartingAddress,BOOT_DEVICE_ADDRESS_MAX);\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
+  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));\r
   MemMapDevicePath->Header.Type = HARDWARE_DEVICE_PATH;\r
   MemMapDevicePath->Header.SubType = HW_MEMMAP_DP;\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
   Status = BootDeviceGetType (NULL, BootType, Attributes);\r
   if (EFI_ERROR(Status)) {\r
@@ -561,15 +568,46 @@ BdsLoadOptionMemMapCreateDevicePath (
 \r
 EFI_STATUS\r
 BdsLoadOptionMemMapUpdateDevicePath (\r
-  IN BDS_LOAD_OPTION *BootOption,\r
+  IN EFI_DEVICE_PATH *OldDevicePath,\r
   OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT BDS_LOADER_TYPE *BootType,\r
+  OUT ARM_BDS_LOADER_TYPE *BootType,\r
   OUT UINT32 *Attributes\r
   )\r
 {\r
-  ASSERT(0);\r
-  //TODO: Implement me\r
-  return EFI_SUCCESS;\r
+  EFI_STATUS          Status;\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
+  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
+  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 = StrHexToUint64 (StrStartingAddress);\r
+  EndingDevicePath->EndingAddress = StrHexToUint64 (StrEndingAddress);\r
+\r
+  Status = BootDeviceGetType (NULL, BootType, Attributes);\r
+  if (EFI_ERROR(Status)) {\r
+    FreePool(DevicePath);\r
+  } else {\r
+    *NewDevicePath = DevicePath;\r
+  }\r
+\r
+  return Status;\r
 }\r
 \r
 BOOLEAN\r
@@ -636,7 +674,7 @@ EFI_STATUS
 BdsLoadOptionPxeCreateDevicePath (\r
   IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
   OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT BDS_LOADER_TYPE   *BootType,\r
+  OUT ARM_BDS_LOADER_TYPE   *BootType,\r
   OUT UINT32      *Attributes\r
   )\r
 {\r
@@ -648,9 +686,9 @@ BdsLoadOptionPxeCreateDevicePath (
 \r
 EFI_STATUS\r
 BdsLoadOptionPxeUpdateDevicePath (\r
-  IN BDS_LOAD_OPTION *BootOption,\r
+  IN EFI_DEVICE_PATH *OldDevicePath,\r
   OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT BDS_LOADER_TYPE *BootType,\r
+  OUT ARM_BDS_LOADER_TYPE *BootType,\r
   OUT UINT32 *Attributes\r
   )\r
 {\r
@@ -737,7 +775,7 @@ EFI_STATUS
 BdsLoadOptionTftpCreateDevicePath (\r
   IN  BDS_SUPPORTED_DEVICE* BdsLoadOption,\r
   OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathNode,\r
-  OUT BDS_LOADER_TYPE   *BootType,\r
+  OUT ARM_BDS_LOADER_TYPE   *BootType,\r
   OUT UINT32      *Attributes\r
   )\r
 {\r
@@ -747,8 +785,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
@@ -771,16 +808,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 EFI Application or the kernel : ");\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
@@ -802,7 +839,6 @@ 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 (EFI_ERROR(Status)) {\r
@@ -816,9 +852,9 @@ BdsLoadOptionTftpCreateDevicePath (
 \r
 EFI_STATUS\r
 BdsLoadOptionTftpUpdateDevicePath (\r
-  IN BDS_LOAD_OPTION *BootOption,\r
+  IN EFI_DEVICE_PATH *OldDevicePath,\r
   OUT EFI_DEVICE_PATH_PROTOCOL** NewDevicePath,\r
-  OUT BDS_LOADER_TYPE *BootType,\r
+  OUT ARM_BDS_LOADER_TYPE *BootType,\r
   OUT UINT32 *Attributes\r
   )\r
 {\r