}
EFI_STATUS
-EditHIInputAscii (
- IN OUT CHAR8 *CmdLine,
+EditHIInputStr (
+ IN OUT CHAR16 *CmdLine,
IN UINTN MaxCmdLine
)
{
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);
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,
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;
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;
OUT BOOLEAN *Value
)
{
- CHAR8 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;
}
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
}\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
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
}\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
{\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
)\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
\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
{\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
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
)\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
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
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
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
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