]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/Bds: Get User inputs in Unicode
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 9 Sep 2011 10:49:54 +0000 (10:49 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 9 Sep 2011 10:49:54 +0000 (10:49 +0000)
The user input was getting in Ascii and converted later to Unicode
when required.
In this change, the user inputs are caught in Unicode and converted
to Ascii only when needed.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@12310 6f19259b-4bc3-4df7-8a09-765794883524

ArmPlatformPkg/Bds/BdsHelper.c
ArmPlatformPkg/Bds/BdsInternal.h
ArmPlatformPkg/Bds/BootMenu.c
ArmPlatformPkg/Bds/BootOptionSupport.c

index 2f0cb31d39fae0a3aa425949fb64071986ac9a5a..0a6961183aff1e17ec4494117ef51dad9215a5f4 100644 (file)
@@ -68,8 +68,8 @@ GetEnvironmentVariable (
 }
 
 EFI_STATUS
-EditHIInputAscii (
-  IN OUT CHAR  *CmdLine,
+EditHIInputStr (
+  IN OUT CHAR16  *CmdLine,
   IN     UINTN   MaxCmdLine
   )
 {
@@ -79,9 +79,9 @@ EditHIInputAscii (
   EFI_INPUT_KEY   Key;
   EFI_STATUS      Status;
 
-  AsciiPrint (CmdLine);
+  Print (CmdLine);
 
-  for (CmdLineIndex = AsciiStrLen(CmdLine); CmdLineIndex < MaxCmdLine; ) {
+  for (CmdLineIndex = StrLen (CmdLine); CmdLineIndex < MaxCmdLine; ) {
     Status = gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &WaitIndex);
     ASSERT_EFI_ERROR (Status);
 
@@ -98,25 +98,63 @@ EditHIInputAscii (
 
     if ((Char == CHAR_LINEFEED) || (Char == CHAR_CARRIAGE_RETURN) || (Char == 0x7f)) {
       CmdLine[CmdLineIndex] = '\0';
-      AsciiPrint ("\n\r");
+      Print (L"\n\r");
 
       return EFI_SUCCESS;
-    } else if ((Char == '\b') || (Key.ScanCode == SCAN_LEFT) || (Key.ScanCode == SCAN_DELETE)){
+    } else if ((Key.UnicodeChar == L'\b') || (Key.ScanCode == SCAN_LEFT) || (Key.ScanCode == SCAN_DELETE)){
       if (CmdLineIndex != 0) {
         CmdLineIndex--;
-        AsciiPrint ("\b \b");
+        Print (L"\b \b");
       }
     } else if ((Key.ScanCode == SCAN_ESC) || (Char == 0x1B) || (Char == 0x0)) {
       return EFI_INVALID_PARAMETER;
     } else {
-      CmdLine[CmdLineIndex++] = Char;
-      AsciiPrint ("%c", Char);
+      CmdLine[CmdLineIndex++] = Key.UnicodeChar;
+      Print (L"%c", Key.UnicodeChar);
     }
   }
 
   return EFI_SUCCESS;
 }
 
+EFI_STATUS
+GetHIInputStr (
+  IN OUT CHAR16  *CmdLine,
+  IN     UINTN   MaxCmdLine
+  )
+{
+  EFI_STATUS  Status;
+
+  // For a new input just passed an empty string
+  CmdLine[0] = L'\0';
+
+  Status = EditHIInputStr (CmdLine, MaxCmdLine);
+
+  return Status;
+}
+
+EFI_STATUS
+EditHIInputAscii (
+  IN OUT CHAR8   *CmdLine,
+  IN     UINTN   MaxCmdLine
+  )
+{
+  CHAR16*     Str;
+  EFI_STATUS  Status;
+
+  Str = (CHAR16*)AllocatePool (MaxCmdLine * sizeof(CHAR16));
+  AsciiStrToUnicodeStr (CmdLine, Str);
+
+  Status = EditHIInputStr (Str, MaxCmdLine);
+
+  if (!EFI_ERROR(Status)) {
+    UnicodeStrToAsciiStr (Str, CmdLine);
+  }
+  FreePool (Str);
+
+  return Status;
+}
+
 EFI_STATUS
 GetHIInputAscii (
   IN OUT CHAR8   *CmdLine,
@@ -134,13 +172,13 @@ GetHIInputInteger (
   OUT UINTN   *Integer
   )
 {
-  CHAR8  CmdLine[255];
+  CHAR16      CmdLine[255];
   EFI_STATUS  Status;
 
   CmdLine[0] = '\0';
-  Status = EditHIInputAscii (CmdLine,255);
+  Status = EditHIInputStr (CmdLine, 255);
   if (!EFI_ERROR(Status)) {
-    *Integer = AsciiStrDecimalToUintn (CmdLine);
+    *Integer = StrDecimalToUintn (CmdLine);
   }
 
   return Status;
@@ -151,36 +189,36 @@ GetHIInputIP (
   OUT EFI_IP_ADDRESS   *Ip
   )
 {
-  CHAR8  CmdLine[255];
-  CHAR8  *Str;
+  CHAR16  CmdLine[255];
+  CHAR16  *Str;
   EFI_STATUS  Status;
 
   CmdLine[0] = '\0';
-  Status = EditHIInputAscii (CmdLine,255);
+  Status = EditHIInputStr (CmdLine,255);
   if (!EFI_ERROR(Status)) {
     Str = CmdLine;
-    Ip->v4.Addr[0] = (UINT8)AsciiStrDecimalToUintn (Str);
+    Ip->v4.Addr[0] = (UINT8)StrDecimalToUintn (Str);
 
-    Str = AsciiStrStr (Str, ".");
+    Str = StrStr (Str, L".");
     if (Str == NULL) {
       return EFI_INVALID_PARAMETER;
     }
 
-    Ip->v4.Addr[1] = (UINT8)AsciiStrDecimalToUintn (++Str);
+    Ip->v4.Addr[1] = (UINT8)StrDecimalToUintn (++Str);
 
-    Str = AsciiStrStr (Str, ".");
+    Str = StrStr (Str, L".");
     if (Str == NULL) {
       return EFI_INVALID_PARAMETER;
     }
 
-    Ip->v4.Addr[2] = (UINT8)AsciiStrDecimalToUintn (++Str);
+    Ip->v4.Addr[2] = (UINT8)StrDecimalToUintn (++Str);
 
-    Str = AsciiStrStr (Str, ".");
+    Str = StrStr (Str, L".");
     if (Str == NULL) {
       return EFI_INVALID_PARAMETER;
     }
 
-    Ip->v4.Addr[3] = (UINT8)AsciiStrDecimalToUintn (++Str);
+    Ip->v4.Addr[3] = (UINT8)StrDecimalToUintn (++Str);
   }
 
   return Status;
@@ -191,18 +229,18 @@ GetHIInputBoolean (
   OUT BOOLEAN *Value
   )
 {
-  CHAR      CmdBoolean[2];
+  CHAR16      CmdBoolean[2];
   EFI_STATUS  Status;
 
   while(1) {
     Print (L"[y/n] ");
-    Status = GetHIInputAscii (CmdBoolean,2);
+    Status = GetHIInputStr (CmdBoolean,2);
     if (EFI_ERROR(Status)) {
       return Status;
-    } else if ((CmdBoolean[0] == 'y') || (CmdBoolean[0] == 'Y')) {
+    } else if ((CmdBoolean[0] == L'y') || (CmdBoolean[0] == L'Y')) {
       if (Value) *Value = TRUE;
       return EFI_SUCCESS;
-    } else if ((CmdBoolean[0] == 'n') || (CmdBoolean[0] == 'N')) {
+    } else if ((CmdBoolean[0] == L'n') || (CmdBoolean[0] == L'N')) {
       if (Value) *Value = FALSE;
       return EFI_SUCCESS;
     }
index e0bf105db8e6d0dbe9df28b8b19d51d59568ce7a..a788ef7be1355f9306b3c5ffe8bb770f5caeeed1 100644 (file)
@@ -128,6 +128,18 @@ BootDeviceGetDeviceSupport (
   OUT BDS_LOAD_OPTION_SUPPORT**  DeviceSupport\r
   );\r
 \r
+EFI_STATUS\r
+GetHIInputStr (\r
+  IN OUT CHAR16  *CmdLine,\r
+  IN     UINTN   MaxCmdLine\r
+  );\r
+\r
+EFI_STATUS\r
+EditHIInputStr (\r
+  IN OUT CHAR16  *CmdLine,\r
+  IN     UINTN   MaxCmdLine\r
+  );\r
+\r
 EFI_STATUS\r
 GetHIInputAscii (\r
   IN OUT CHAR8   *CmdLine,\r
index b18a58bd8c77a3869b8e5b6fcf0a464cdc4fc7d1..591e7e683b8382759be6b92c3cda25686857d060 100644 (file)
@@ -116,8 +116,7 @@ BootMenuAddBootOption (
   EFI_STATUS               Status;\r
   BDS_SUPPORTED_DEVICE*    SupportedBootDevice;\r
   BDS_LOADER_ARGUMENTS     BootArguments;\r
-  CHAR8                    AsciiBootDescription[BOOT_DEVICE_DESCRIPTION_MAX];\r
-  CHAR16                   *BootDescription;\r
+  CHAR16                    BootDescription[BOOT_DEVICE_DESCRIPTION_MAX];\r
   UINT32                   Attributes;\r
   BDS_LOADER_TYPE          BootType;\r
   BDS_LOAD_OPTION          *BdsLoadOption;\r
@@ -171,24 +170,18 @@ BootMenuAddBootOption (
   }\r
 \r
   Print(L"Description for this new Entry: ");\r
-  Status = GetHIInputAscii (AsciiBootDescription,BOOT_DEVICE_DESCRIPTION_MAX);\r
+  Status = GetHIInputStr (BootDescription, BOOT_DEVICE_DESCRIPTION_MAX);\r
   if (EFI_ERROR(Status)) {\r
     Status = EFI_ABORTED;\r
     goto FREE_DEVICE_PATH;\r
   }\r
 \r
-  // Convert Ascii into Unicode\r
-  BootDescription = (CHAR16*)AllocatePool(AsciiStrSize(AsciiBootDescription) * sizeof(CHAR16));\r
-  AsciiStrToUnicodeStr (AsciiBootDescription, BootDescription);\r
-\r
   // Create new entry\r
   Status = BootOptionCreate (Attributes, BootDescription, DevicePath, BootType, &BootArguments, &BdsLoadOption);\r
   if (!EFI_ERROR(Status)) {\r
     InsertTailList (BootOptionsList,&BdsLoadOption->Link);\r
   }\r
 \r
-  FreePool (BootDescription);\r
-\r
 FREE_DEVICE_PATH:\r
   FreePool (DevicePath);\r
 \r
@@ -303,8 +296,7 @@ BootMenuUpdateBootOption (
   BDS_LOAD_OPTION           *BootOption;\r
   BDS_LOAD_OPTION_SUPPORT   *DeviceSupport;\r
   BDS_LOADER_ARGUMENTS      BootArguments;\r
-  CHAR8                     AsciiBootDescription[BOOT_DEVICE_DESCRIPTION_MAX];\r
-  CHAR16                    *BootDescription;\r
+  CHAR16                        BootDescription[BOOT_DEVICE_DESCRIPTION_MAX];\r
   EFI_DEVICE_PATH*          DevicePath;\r
   BDS_LOADER_TYPE           BootType;\r
 \r
@@ -365,22 +357,15 @@ BootMenuUpdateBootOption (
   }\r
 \r
   Print(L"Description for this new Entry: ");\r
-  UnicodeStrToAsciiStr (BootOption->Description, AsciiBootDescription);\r
-  Status = EditHIInputAscii (AsciiBootDescription, BOOT_DEVICE_DESCRIPTION_MAX);\r
+  Status = EditHIInputStr (BootDescription, BOOT_DEVICE_DESCRIPTION_MAX);\r
   if (EFI_ERROR(Status)) {\r
     Status = EFI_ABORTED;\r
     goto FREE_DEVICE_PATH;\r
   }\r
 \r
-  // Convert Ascii into Unicode\r
-  BootDescription = (CHAR16*)AllocatePool(AsciiStrSize(AsciiBootDescription) * sizeof(CHAR16));\r
-  AsciiStrToUnicodeStr (AsciiBootDescription, BootDescription);\r
-\r
   // Update the entry\r
   Status = BootOptionUpdate (BootOption, BootOption->Attributes, BootDescription, DevicePath, BootType, &BootArguments);\r
 \r
-  FreePool (BootDescription);\r
-\r
 FREE_DEVICE_PATH:\r
   FreePool (DevicePath);\r
 \r
index 336bcb9a2127a59d08d545e388e93886e11267a0..a7e83b828b99ffeea510ba3570bfe458bc28148f 100644 (file)
@@ -335,32 +335,26 @@ BdsLoadOptionFileSystemCreateDevicePath (
 {\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
+  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
@@ -384,8 +378,7 @@ BdsLoadOptionFileSystemUpdateDevicePath (
   )\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
@@ -395,29 +388,24 @@ BdsLoadOptionFileSystemUpdateDevicePath (
 \r
   EndingDevicePath = (FILEPATH_DEVICE_PATH*)GetLastDevicePathNode (DevicePath);\r
  \r
-  UnicodeStrToAsciiStr (EndingDevicePath->PathName,AsciiBootFilePath);\r
-  Status = EditHIInputAscii (AsciiBootFilePath,BOOT_DEVICE_FILEPATH_MAX);\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
@@ -545,17 +533,17 @@ BdsLoadOptionMemMapCreateDevicePath (
 {\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
@@ -565,8 +553,8 @@ BdsLoadOptionMemMapCreateDevicePath (
   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
@@ -587,8 +575,8 @@ BdsLoadOptionMemMapUpdateDevicePath (
   )\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
@@ -596,21 +584,21 @@ BdsLoadOptionMemMapUpdateDevicePath (
   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
+  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
+  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
   Status = BootDeviceGetType (NULL, BootType, Attributes);\r
   if (EFI_ERROR(Status)) {\r
@@ -797,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
@@ -821,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
@@ -852,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