mirror of https://github.com/acidanthera/audk.git
Replace BufToHexString by UnicodeValueToString
Replace HexStringToBuf by StrHexToUint64 git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8034 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
dfbe9de95f
commit
63d55bb98a
|
@ -80,6 +80,10 @@ GetDevicePath (
|
|||
UINTN Length;
|
||||
EFI_STRING PathHdr;
|
||||
EFI_STRING DevicePathString;
|
||||
UINT8 *DevicePathBuffer;
|
||||
CHAR16 TemStr[2];
|
||||
UINTN Index;
|
||||
UINT8 DigitUint8;
|
||||
|
||||
if (String == NULL || DevicePath == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
@ -114,21 +118,52 @@ GetDevicePath (
|
|||
// as the device path resides in RAM memory.
|
||||
// Translate the data into binary.
|
||||
//
|
||||
Length /= 2;
|
||||
*DevicePath = (UINT8 *) AllocateZeroPool (Length);
|
||||
if (*DevicePath == NULL) {
|
||||
DevicePathBuffer = (UINT8 *) AllocateZeroPool ((Length + 1) / 2);
|
||||
if (DevicePathBuffer == NULL) {
|
||||
FreePool (DevicePathString);
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
HexStringToBufInReverseOrder (*DevicePath, &Length, DevicePathString);
|
||||
ZeroMem (TemStr, sizeof (TemStr));
|
||||
for (Index = 0; DevicePathString[Index] != L'\0'; Index ++) {
|
||||
TemStr[0] = DevicePathString[Index];
|
||||
DigitUint8 = (UINT8) StrHexToUint64 (TemStr);
|
||||
if ((Index & 1) == 0) {
|
||||
DevicePathBuffer [Index/2] = DigitUint8;
|
||||
} else {
|
||||
DevicePathBuffer [Index/2] = (UINT8) ((DevicePathBuffer [Index/2] << 4) + DigitUint8);
|
||||
}
|
||||
}
|
||||
|
||||
FreePool (DevicePathString);
|
||||
|
||||
*DevicePath = DevicePathBuffer;
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
Converts the unicode character of the string from uppercase to lowercase.
|
||||
This is a internal function.
|
||||
|
||||
@param Str String to be converted
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
HiiToLower (
|
||||
IN OUT CHAR16 *Str
|
||||
)
|
||||
{
|
||||
CHAR16 *Ptr;
|
||||
|
||||
for (Ptr = Str; *Ptr != L'\0'; Ptr++) {
|
||||
if (*Ptr >= L'A' && *Ptr <= L'Z') {
|
||||
*Ptr = (CHAR16) (*Ptr - L'A' + L'a');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Generate a sub string then output it.
|
||||
|
@ -159,8 +194,11 @@ GenerateSubStr (
|
|||
{
|
||||
UINTN Length;
|
||||
EFI_STRING Str;
|
||||
EFI_STATUS Status;
|
||||
EFI_STRING StringHeader;
|
||||
CHAR16 *TemString;
|
||||
CHAR16 *TemName;
|
||||
UINT8 *TemBuffer;
|
||||
UINTN Index;
|
||||
|
||||
ASSERT (String != NULL && SubStr != NULL);
|
||||
|
||||
|
@ -171,34 +209,55 @@ GenerateSubStr (
|
|||
}
|
||||
|
||||
Length = StrLen (String) + BufferLen * 2 + 1 + 1;
|
||||
Str = AllocateZeroPool (Length * sizeof (CHAR16));
|
||||
Str = AllocateZeroPool (Length * sizeof (CHAR16));
|
||||
ASSERT (Str != NULL);
|
||||
|
||||
StrCpy (Str, String);
|
||||
Length = (BufferLen * 2 + 1) * sizeof (CHAR16);
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
StringHeader = Str + StrLen (String);
|
||||
TemString = (CHAR16 *) StringHeader;
|
||||
|
||||
switch (Flag) {
|
||||
case 1:
|
||||
Status = BufInReverseOrderToHexString (StringHeader, (UINT8 *) Buffer, BufferLen);
|
||||
//
|
||||
// Convert Buffer to Hex String in reverse order
|
||||
//
|
||||
TemBuffer = ((UINT8 *) Buffer);
|
||||
for (Index = 0; Index < BufferLen; Index ++, TemBuffer ++) {
|
||||
TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemBuffer, 2);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
Status = UnicodeToConfigString (StringHeader, &Length, (CHAR16 *) Buffer);
|
||||
//
|
||||
// Check buffer is enough
|
||||
//
|
||||
TemName = (CHAR16 *) Buffer;
|
||||
ASSERT (Length < ((StrLen (TemName) * 4 + 1) * sizeof (CHAR16)));
|
||||
//
|
||||
// Convert Unicode String to Config String, e.g. "ABCD" => "0041004200430044"
|
||||
//
|
||||
for (; *TemName != L'\0'; TemName++) {
|
||||
TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemName, 4);
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
Status = BufToHexString (StringHeader, &Length, (UINT8 *) Buffer, BufferLen);
|
||||
//
|
||||
// Convert the uppercase to lowercase since <HexAf> is defined in lowercase format.
|
||||
// Convert Buffer to Hex String
|
||||
//
|
||||
ToLower (StringHeader);
|
||||
TemBuffer = ((UINT8 *) Buffer) + BufferLen - 1;
|
||||
for (Index = 0; Index < BufferLen; Index ++, TemBuffer --) {
|
||||
TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemBuffer, 2);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
//
|
||||
// Convert the uppercase to lowercase since <HexAf> is defined in lowercase format.
|
||||
//
|
||||
HiiToLower (StringHeader);
|
||||
StrCat (Str, L"&");
|
||||
|
||||
*SubStr = Str;
|
||||
|
@ -344,14 +403,17 @@ GetValueOfNumber (
|
|||
EFI_STRING Str;
|
||||
UINT8 *Buf;
|
||||
EFI_STATUS Status;
|
||||
UINT8 DigitUint8;
|
||||
UINTN Index;
|
||||
CHAR16 TemStr[2];
|
||||
|
||||
ASSERT (StringPtr != NULL && Number != NULL && Len != NULL);
|
||||
ASSERT (*StringPtr != 0);
|
||||
ASSERT (*StringPtr != L'\0');
|
||||
|
||||
Buf = NULL;
|
||||
|
||||
TmpPtr = StringPtr;
|
||||
while (*StringPtr != 0 && *StringPtr != L'&') {
|
||||
while (*StringPtr != L'\0' && *StringPtr != L'&') {
|
||||
StringPtr++;
|
||||
}
|
||||
*Len = StringPtr - TmpPtr;
|
||||
|
@ -363,7 +425,7 @@ GetValueOfNumber (
|
|||
goto Exit;
|
||||
}
|
||||
CopyMem (Str, TmpPtr, *Len * sizeof (CHAR16));
|
||||
*(Str + *Len) = 0;
|
||||
*(Str + *Len) = L'\0';
|
||||
|
||||
Length = (Length + 1) / 2;
|
||||
Buf = (UINT8 *) AllocateZeroPool (Length);
|
||||
|
@ -372,9 +434,16 @@ GetValueOfNumber (
|
|||
goto Exit;
|
||||
}
|
||||
|
||||
Status = HexStringToBuf (Buf, &Length, Str, NULL);
|
||||
if (EFI_ERROR (Status)) {
|
||||
goto Exit;
|
||||
Length = *Len;
|
||||
ZeroMem (TemStr, sizeof (TemStr));
|
||||
for (Index = 0; Index < Length; Index ++) {
|
||||
TemStr[0] = Str[Length - Index - 1];
|
||||
DigitUint8 = (UINT8) StrHexToUint64 (TemStr);
|
||||
if ((Index & 1) == 0) {
|
||||
Buf [Index/2] = DigitUint8;
|
||||
} else {
|
||||
Buf [Index/2] = (UINT8) ((Buf [Index/2] << 4) + DigitUint8);
|
||||
}
|
||||
}
|
||||
|
||||
*Number = Buf;
|
||||
|
@ -384,6 +453,7 @@ Exit:
|
|||
if (Str != NULL) {
|
||||
FreePool (Str);
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
@ -959,6 +1029,9 @@ HiiBlockToConfig (
|
|||
UINT8 *Value;
|
||||
EFI_STRING ValueStr;
|
||||
EFI_STRING ConfigElement;
|
||||
UINTN Index;
|
||||
UINT8 *TemBuffer;
|
||||
CHAR16 *TemString;
|
||||
|
||||
if (This == NULL || Progress == NULL || Config == NULL) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
@ -1108,9 +1181,12 @@ HiiBlockToConfig (
|
|||
goto Exit;
|
||||
}
|
||||
|
||||
Status = BufToHexString (ValueStr, &Length, Value, Width);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
ToLower (ValueStr);
|
||||
TemString = ValueStr;
|
||||
TemBuffer = Value + Width - 1;
|
||||
for (Index = 0; Index < Width; Index ++, TemBuffer --) {
|
||||
TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemBuffer, 2);
|
||||
}
|
||||
HiiToLower (ValueStr);
|
||||
|
||||
FreePool (Value);
|
||||
Value = NULL;
|
||||
|
|
|
@ -809,7 +809,7 @@ InsertStringPackage (
|
|||
AsciiStrCpy (Language, (CHAR8 *) PackageHdr + HeaderSize - LanguageSize);
|
||||
for (Link = PackageList->StringPkgHdr.ForwardLink; Link != &PackageList->StringPkgHdr; Link = Link->ForwardLink) {
|
||||
StringPackage = CR (Link, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);
|
||||
if (R8_EfiLibCompareLanguage (Language, StringPackage->StringPkgHdr->Language)) {
|
||||
if (HiiCompareLanguage (Language, StringPackage->StringPkgHdr->Language)) {
|
||||
FreePool (Language);
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||
#include <Library/UefiLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
#include <Library/PrintLib.h>
|
||||
|
||||
|
||||
#define HII_DATABASE_NOTIFY_GUID \
|
||||
|
@ -1688,11 +1689,25 @@ HiiGetAltCfg (
|
|||
);
|
||||
|
||||
|
||||
/**
|
||||
Compare whether two names of languages are identical.
|
||||
|
||||
@param Language1 Name of language 1
|
||||
@param Language2 Name of language 2
|
||||
|
||||
@retval TRUE same
|
||||
@retval FALSE not same
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
HiiCompareLanguage (
|
||||
IN CHAR8 *Language1,
|
||||
IN CHAR8 *Language2
|
||||
)
|
||||
;
|
||||
|
||||
//
|
||||
// Global variables
|
||||
//
|
||||
extern EFI_EVENT gHiiKeyboardLayoutChanged;
|
||||
|
||||
#include "R8Lib.h"
|
||||
|
||||
#endif
|
||||
|
|
|
@ -36,9 +36,6 @@
|
|||
String.c
|
||||
Database.c
|
||||
Font.c
|
||||
R8Lib.h
|
||||
R8Lib.c
|
||||
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
|
@ -57,6 +54,7 @@
|
|||
UefiLib
|
||||
PcdLib
|
||||
UefiRuntimeServicesTableLib
|
||||
PrintLib
|
||||
|
||||
[Protocols]
|
||||
gEfiDevicePathProtocolGuid ## SOMETIMES_CONSUMES
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
/** @file
|
||||
Implement a utility function named R8_EfiLibCompareLanguage.
|
||||
|
||||
Copyright (c) 2007 - 2008, Intel Corporation
|
||||
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#include "HiiDatabase.h"
|
||||
|
||||
|
||||
/**
|
||||
Compare whether two names of languages are identical.
|
||||
|
||||
@param Language1 Name of language 1
|
||||
@param Language2 Name of language 2
|
||||
|
||||
@retval TRUE same
|
||||
@retval FALSE not same
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
R8_EfiLibCompareLanguage (
|
||||
IN CHAR8 *Language1,
|
||||
IN CHAR8 *Language2
|
||||
)
|
||||
{
|
||||
//
|
||||
// Porting Guide:
|
||||
// This library interface is simply obsolete.
|
||||
// Include the source code to user code.
|
||||
//
|
||||
UINTN Index;
|
||||
|
||||
for (Index = 0; (Language1[Index] != 0) && (Language2[Index] != 0); Index++) {
|
||||
if (Language1[Index] != Language2[Index]) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (((Language1[Index] == 0) && (Language2[Index] == 0)) ||
|
||||
((Language1[Index] == 0) && (Language2[Index] != ';')) ||
|
||||
((Language1[Index] == ';') && (Language2[Index] != 0)) ||
|
||||
((Language1[Index] == ';') && (Language2[Index] != ';'))) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
/** @file
|
||||
Implement a utility function named R8_EfiLibCompareLanguage.
|
||||
|
||||
Copyright (c) 2007 - 2008, Intel Corporation
|
||||
|
||||
All rights reserved. This program and the accompanying materials
|
||||
are licensed and made available under the terms and conditions of the BSD License
|
||||
which accompanies this distribution. The full text of the license may be found at
|
||||
http://opensource.org/licenses/bsd-license.php
|
||||
|
||||
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
||||
|
||||
|
||||
**/
|
||||
|
||||
#ifndef __R8_LIB_H__
|
||||
#define __R8_LIB_H__
|
||||
|
||||
/**
|
||||
Compare whether two names of languages are identical.
|
||||
|
||||
@param Language1 Name of language 1
|
||||
@param Language2 Name of language 2
|
||||
|
||||
@retval TRUE same
|
||||
@retval FALSE not same
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
R8_EfiLibCompareLanguage (
|
||||
IN CHAR8 *Language1,
|
||||
IN CHAR8 *Language2
|
||||
)
|
||||
;
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1014,7 +1014,7 @@ HiiNewString (
|
|||
Link = Link->ForwardLink
|
||||
) {
|
||||
StringPackage = CR (Link, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);
|
||||
if (R8_EfiLibCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) Language)) {
|
||||
if (HiiCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) Language)) {
|
||||
Matched = TRUE;
|
||||
break;
|
||||
}
|
||||
|
@ -1353,7 +1353,7 @@ HiiGetString (
|
|||
Link = Link->ForwardLink
|
||||
) {
|
||||
StringPackage = CR (Link, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);
|
||||
if (R8_EfiLibCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) Language)) {
|
||||
if (HiiCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) Language)) {
|
||||
Status = GetStringWorker (Private, StringPackage, StringId, String, StringSize, StringFontInfo);
|
||||
if (Status != EFI_NOT_FOUND) {
|
||||
return Status;
|
||||
|
@ -1446,7 +1446,7 @@ HiiSetString (
|
|||
Link = Link->ForwardLink
|
||||
) {
|
||||
StringPackage = CR (Link, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);
|
||||
if (R8_EfiLibCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) Language)) {
|
||||
if (HiiCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) Language)) {
|
||||
OldPackageLen = StringPackage->StringPkgHdr->Header.Length;
|
||||
Status = SetStringWorker (
|
||||
Private,
|
||||
|
@ -1635,7 +1635,7 @@ HiiGetSecondaryLanguages (
|
|||
Link1 = Link1->ForwardLink
|
||||
) {
|
||||
StringPackage = CR (Link1, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);
|
||||
if (R8_EfiLibCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) FirstLanguage)) {
|
||||
if (HiiCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) FirstLanguage)) {
|
||||
Languages = StringPackage->StringPkgHdr->Language;
|
||||
//
|
||||
// Language is a series of ';' terminated strings, first one is primary
|
||||
|
@ -1663,3 +1663,41 @@ HiiGetSecondaryLanguages (
|
|||
return EFI_INVALID_LANGUAGE;
|
||||
}
|
||||
|
||||
/**
|
||||
Compare whether two names of languages are identical.
|
||||
|
||||
@param Language1 Name of language 1
|
||||
@param Language2 Name of language 2
|
||||
|
||||
@retval TRUE same
|
||||
@retval FALSE not same
|
||||
|
||||
**/
|
||||
BOOLEAN
|
||||
HiiCompareLanguage (
|
||||
IN CHAR8 *Language1,
|
||||
IN CHAR8 *Language2
|
||||
)
|
||||
{
|
||||
//
|
||||
// Porting Guide:
|
||||
// This library interface is simply obsolete.
|
||||
// Include the source code to user code.
|
||||
//
|
||||
UINTN Index;
|
||||
|
||||
for (Index = 0; (Language1[Index] != 0) && (Language2[Index] != 0); Index++) {
|
||||
if (Language1[Index] != Language2[Index]) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (((Language1[Index] == 0) && (Language2[Index] == 0)) ||
|
||||
((Language1[Index] == 0) && (Language2[Index] != ';')) ||
|
||||
((Language1[Index] == ';') && (Language2[Index] != 0)) ||
|
||||
((Language1[Index] == ';') && (Language2[Index] != ';'))) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
|
|
@ -64,21 +64,6 @@ IScsiIpToStr (
|
|||
UnicodeSPrint ( Str, 2 * IP4_STR_MAX_SIZE, L"%d.%d.%d.%d", Ip->Addr[0], Ip->Addr[1], Ip->Addr[2], Ip->Addr[3]);
|
||||
}
|
||||
|
||||
/**
|
||||
Pop up an invalid notify which displays the message in Warning.
|
||||
|
||||
@param[in] Warning The warning message.
|
||||
**/
|
||||
VOID
|
||||
PopUpInvalidNotify (
|
||||
IN CHAR16 *Warning
|
||||
)
|
||||
{
|
||||
EFI_INPUT_KEY Key;
|
||||
|
||||
IfrLibCreatePopUp (1, &Key, Warning);
|
||||
}
|
||||
|
||||
/**
|
||||
Update the list of iSCSI devices the iSCSI driver is controlling.
|
||||
|
||||
|
@ -512,6 +497,7 @@ IScsiFormCallback (
|
|||
EFI_IP_ADDRESS SubnetMask;
|
||||
EFI_IP_ADDRESS Gateway;
|
||||
EFI_STATUS Status;
|
||||
EFI_INPUT_KEY Key;
|
||||
|
||||
Private = ISCSI_FORM_CALLBACK_INFO_FROM_FORM_CALLBACK (This);
|
||||
|
||||
|
@ -534,7 +520,7 @@ IScsiFormCallback (
|
|||
|
||||
Status = gIScsiInitiatorName.Set (&gIScsiInitiatorName, &BufferSize, IScsiName);
|
||||
if (EFI_ERROR (Status)) {
|
||||
PopUpInvalidNotify (L"Invalid iSCSI Name!");
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid iSCSI Name!", NULL);
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -543,7 +529,7 @@ IScsiFormCallback (
|
|||
IScsiUnicodeStrToAsciiStr (IfrNvData->LocalIp, Ip4String);
|
||||
Status = IScsiAsciiStrToIp (Ip4String, &HostIp.v4);
|
||||
if (EFI_ERROR (Status) || !Ip4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {
|
||||
PopUpInvalidNotify (L"Invalid IP address!");
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
} else {
|
||||
CopyMem (&Private->Current->SessionConfigData.LocalIp, &HostIp.v4, sizeof (HostIp.v4));
|
||||
|
@ -555,7 +541,7 @@ IScsiFormCallback (
|
|||
IScsiUnicodeStrToAsciiStr (IfrNvData->SubnetMask, Ip4String);
|
||||
Status = IScsiAsciiStrToIp (Ip4String, &SubnetMask.v4);
|
||||
if (EFI_ERROR (Status) || ((SubnetMask.Addr[0] != 0) && (IScsiGetSubnetMaskPrefixLength (&SubnetMask.v4) == 0))) {
|
||||
PopUpInvalidNotify (L"Invalid Subnet Mask!");
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Subnet Mask!", NULL);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
} else {
|
||||
CopyMem (&Private->Current->SessionConfigData.SubnetMask, &SubnetMask.v4, sizeof (SubnetMask.v4));
|
||||
|
@ -567,7 +553,7 @@ IScsiFormCallback (
|
|||
IScsiUnicodeStrToAsciiStr (IfrNvData->Gateway, Ip4String);
|
||||
Status = IScsiAsciiStrToIp (Ip4String, &Gateway.v4);
|
||||
if (EFI_ERROR (Status) || ((Gateway.Addr[0] != 0) && !Ip4IsUnicast (NTOHL (Gateway.Addr[0]), 0))) {
|
||||
PopUpInvalidNotify (L"Invalid Gateway!");
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid Gateway!", NULL);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
} else {
|
||||
CopyMem (&Private->Current->SessionConfigData.Gateway, &Gateway.v4, sizeof (Gateway.v4));
|
||||
|
@ -579,7 +565,7 @@ IScsiFormCallback (
|
|||
IScsiUnicodeStrToAsciiStr (IfrNvData->TargetIp, Ip4String);
|
||||
Status = IScsiAsciiStrToIp (Ip4String, &HostIp.v4);
|
||||
if (EFI_ERROR (Status) || !Ip4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {
|
||||
PopUpInvalidNotify (L"Invalid IP address!");
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid IP address!", NULL);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
} else {
|
||||
CopyMem (&Private->Current->SessionConfigData.TargetIp, &HostIp.v4, sizeof (HostIp.v4));
|
||||
|
@ -591,7 +577,7 @@ IScsiFormCallback (
|
|||
IScsiUnicodeStrToAsciiStr (IfrNvData->TargetName, IScsiName);
|
||||
Status = IScsiNormalizeName (IScsiName, AsciiStrLen (IScsiName));
|
||||
if (EFI_ERROR (Status)) {
|
||||
PopUpInvalidNotify (L"Invalid iSCSI Name!");
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid iSCSI Name!", NULL);
|
||||
} else {
|
||||
AsciiStrCpy (Private->Current->SessionConfigData.TargetName, IScsiName);
|
||||
}
|
||||
|
@ -609,7 +595,7 @@ IScsiFormCallback (
|
|||
IScsiUnicodeStrToAsciiStr (IfrNvData->BootLun, LunString);
|
||||
Status = IScsiAsciiStrToLun (LunString, (UINT8 *) &Lun);
|
||||
if (EFI_ERROR (Status)) {
|
||||
PopUpInvalidNotify (L"Invalid LUN string!");
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Invalid LUN string!", NULL);
|
||||
} else {
|
||||
CopyMem (Private->Current->SessionConfigData.BootLun, &Lun, sizeof (Lun));
|
||||
}
|
||||
|
@ -661,11 +647,11 @@ IScsiFormCallback (
|
|||
|
||||
if ((Gateway.Addr[0] != 0)) {
|
||||
if (SubnetMask.Addr[0] == 0) {
|
||||
PopUpInvalidNotify (L"Gateway address is set but subnet mask is zero.");
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Gateway address is set but subnet mask is zero.", NULL);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
break;
|
||||
} else if (!IP4_NET_EQUAL (HostIp.Addr[0], Gateway.Addr[0], SubnetMask.Addr[0])) {
|
||||
PopUpInvalidNotify (L"Local IP and Gateway are not in the same subnet.");
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Local IP and Gateway are not in the same subnet.", NULL);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
break;
|
||||
}
|
||||
|
@ -677,7 +663,7 @@ IScsiFormCallback (
|
|||
if (!Private->Current->SessionConfigData.TargetInfoFromDhcp) {
|
||||
CopyMem (&HostIp.v4, &Private->Current->SessionConfigData.TargetIp, sizeof (HostIp.v4));
|
||||
if (!Ip4IsUnicast (NTOHL (HostIp.Addr[0]), 0)) {
|
||||
PopUpInvalidNotify (L"Target IP is invalid!");
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Target IP is invalid!", NULL);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
break;
|
||||
}
|
||||
|
@ -685,7 +671,7 @@ IScsiFormCallback (
|
|||
|
||||
if (IfrNvData->CHAPType != ISCSI_CHAP_NONE) {
|
||||
if ((IfrNvData->CHAPName[0] == '\0') || (IfrNvData->CHAPSecret[0] == '\0')) {
|
||||
PopUpInvalidNotify (L"CHAP Name or CHAP Secret is invalid!");
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"CHAP Name or CHAP Secret is invalid!", NULL);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
break;
|
||||
}
|
||||
|
@ -693,7 +679,7 @@ IScsiFormCallback (
|
|||
if ((IfrNvData->CHAPType == ISCSI_CHAP_MUTUAL) &&
|
||||
((IfrNvData->ReverseCHAPName[0] == '\0') || (IfrNvData->ReverseCHAPSecret[0] == '\0'))
|
||||
) {
|
||||
PopUpInvalidNotify (L"Reverse CHAP Name or Reverse CHAP Secret is invalid!");
|
||||
CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, L"Reverse CHAP Name or Reverse CHAP Secret is invalid!", NULL);
|
||||
Status = EFI_INVALID_PARAMETER;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -123,53 +123,62 @@ IScsiAsciiStrToLun (
|
|||
OUT UINT8 *Lun
|
||||
)
|
||||
{
|
||||
UINT32 Index;
|
||||
CHAR8 *LunUnitStr[4];
|
||||
CHAR8 Digit;
|
||||
UINTN Temp;
|
||||
UINTN Index, IndexValue, IndexNum, SizeStr;
|
||||
CHAR8 TemStr[2];
|
||||
UINT8 TemValue;
|
||||
UINT16 Value [4];
|
||||
|
||||
ZeroMem (Lun, 8);
|
||||
ZeroMem (LunUnitStr, sizeof (LunUnitStr));
|
||||
ZeroMem (TemStr, 2);
|
||||
ZeroMem ((UINT8 *) Value, sizeof (Value));
|
||||
SizeStr = AsciiStrLen (Str);
|
||||
IndexValue = 0;
|
||||
IndexNum = 0;
|
||||
|
||||
Index = 0;
|
||||
LunUnitStr[0] = Str;
|
||||
|
||||
if (!IsHexDigit ((UINT8 *) &Digit, *Str)) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
while (*Str != '\0') {
|
||||
//
|
||||
// Legal representations of LUN:
|
||||
// 4752-3A4F-6b7e-2F99,
|
||||
// 6734-9-156f-127,
|
||||
// 4186-9
|
||||
//
|
||||
if (*Str == '-') {
|
||||
*Str = '\0';
|
||||
Index++;
|
||||
|
||||
if (*(Str + 1) != '\0') {
|
||||
if (!IsHexDigit ((UINT8 *) &Digit, *(Str + 1))) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
LunUnitStr[Index] = Str + 1;
|
||||
for (Index = 0; Index < SizeStr; Index ++) {
|
||||
TemStr[0] = Str[Index];
|
||||
TemValue = (UINT8) AsciiStrHexToUint64 (TemStr);
|
||||
if (TemValue == 0 && TemStr[0] != '0') {
|
||||
if ((TemStr[0] != '-') || (IndexNum == 0)) {
|
||||
//
|
||||
// Invalid Lun Char
|
||||
//
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
} else if (!IsHexDigit ((UINT8 *) &Digit, *Str)) {
|
||||
}
|
||||
|
||||
if ((TemValue == 0) && (TemStr[0] == '-')) {
|
||||
//
|
||||
// Next Lun value
|
||||
//
|
||||
if (++IndexValue >= 4) {
|
||||
//
|
||||
// Max 4 Lun value
|
||||
//
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
//
|
||||
// Restart str index for the next lun value
|
||||
//
|
||||
IndexNum = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (++IndexNum > 4) {
|
||||
//
|
||||
// Each Lun Str can't exceed size 4, because it will be as UINT16 value
|
||||
//
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Str++;
|
||||
//
|
||||
// Combine UINT16 value
|
||||
//
|
||||
Value[IndexValue] = (UINT16) ((Value[IndexValue] << 4) + TemValue);
|
||||
}
|
||||
|
||||
for (Index = 0; (Index < 4) && (LunUnitStr[Index] != NULL); Index++) {
|
||||
if (AsciiStrLen (LunUnitStr[Index]) > 4) {
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Temp = AsciiStrHexToUintn (LunUnitStr[Index]);
|
||||
*((UINT16 *) &Lun[Index * 2]) = HTONS (Temp);
|
||||
for (Index = 0; Index <= IndexValue; Index ++) {
|
||||
*((UINT16 *) &Lun[Index * 2]) = HTONS (Value[Index]);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
@ -434,53 +443,39 @@ IScsiHexToBin (
|
|||
)
|
||||
{
|
||||
UINTN Index;
|
||||
UINT32 HexCount;
|
||||
CHAR8 *HexBuf;
|
||||
UINTN Length;
|
||||
UINT8 Digit;
|
||||
UINT8 Byte;
|
||||
CHAR8 TemStr[2];
|
||||
|
||||
Digit = 0;
|
||||
ZeroMem (TemStr, sizeof (TemStr));
|
||||
|
||||
//
|
||||
// Find out how many hex characters the string has.
|
||||
//
|
||||
HexBuf = HexStr;
|
||||
if ((HexBuf[0] == '0') && ((HexBuf[1] == 'x') || (HexBuf[1] == 'X'))) {
|
||||
HexBuf += 2;
|
||||
if ((HexStr[0] == '0') && ((HexStr[1] == 'x') || (HexStr[1] == 'X'))) {
|
||||
HexStr += 2;
|
||||
}
|
||||
|
||||
for (Index = 0, HexCount = 0; IsHexDigit (&Digit, HexBuf[Index]); Index++, HexCount++)
|
||||
;
|
||||
Length = AsciiStrLen (HexStr);
|
||||
|
||||
if (HexCount == 0) {
|
||||
*BinLength = 0;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
//
|
||||
// Test if buffer is passed enough.
|
||||
//
|
||||
if (((HexCount + 1) / 2) > *BinLength) {
|
||||
*BinLength = (HexCount + 1) / 2;
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
}
|
||||
|
||||
*BinLength = (HexCount + 1) / 2;
|
||||
|
||||
for (Index = 0; Index < HexCount; Index++) {
|
||||
|
||||
IsHexDigit (&Digit, HexBuf[HexCount - 1 - Index]);
|
||||
|
||||
if ((Index & 1) == 0) {
|
||||
Byte = Digit;
|
||||
} else {
|
||||
Byte = BinBuffer[*BinLength - 1 - Index / 2];
|
||||
Byte &= 0x0F;
|
||||
Byte = (UINT8) (Byte | (Digit << 4));
|
||||
for (Index = 0; Index < Length; Index ++) {
|
||||
TemStr[0] = HexStr[Index];
|
||||
Digit = (UINT8) AsciiStrHexToUint64 (TemStr);
|
||||
if (Digit == 0 && TemStr[0] != '0') {
|
||||
//
|
||||
// Invalid Lun Char
|
||||
//
|
||||
break;
|
||||
}
|
||||
if ((Index & 1) == 0) {
|
||||
BinBuffer [Index/2] = Digit;
|
||||
} else {
|
||||
BinBuffer [Index/2] = (UINT8) ((BinBuffer [Index/2] << 4) + Digit);
|
||||
}
|
||||
|
||||
BinBuffer[*BinLength - 1 - Index / 2] = Byte;
|
||||
}
|
||||
|
||||
*BinLength = (UINT32) ((Index + 1)/2);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -605,7 +605,13 @@ EnterCarriageReturn:
|
|||
default:
|
||||
if (ManualInput) {
|
||||
if (HexInput) {
|
||||
if (!IsHexDigit (&Digital, Key.UnicodeChar)) {
|
||||
if ((Key.UnicodeChar >= L'0') && (Key.UnicodeChar <= L'9')) {
|
||||
Digital = (UINT8) (Key.UnicodeChar - L'0');
|
||||
} else if ((Key.UnicodeChar >= L'A') && (Key.UnicodeChar <= L'F')) {
|
||||
Digital = (UINT8) (Key.UnicodeChar - L'A' + 0x0A);
|
||||
} else if ((Key.UnicodeChar >= L'a') && (Key.UnicodeChar <= L'f')) {
|
||||
Digital = (UINT8) (Key.UnicodeChar - L'a' + 0x0A);
|
||||
} else {
|
||||
UpdateStatusBar (INPUT_ERROR, Question->QuestionFlags, TRUE);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1018,8 +1018,12 @@ GetQuestionValue (
|
|||
CHAR16 *Value;
|
||||
CHAR16 *StringPtr;
|
||||
UINTN Length;
|
||||
UINTN Index;
|
||||
UINTN LengthStr;
|
||||
BOOLEAN IsBufferStorage;
|
||||
BOOLEAN IsString;
|
||||
CHAR16 TemStr[5];
|
||||
UINT8 DigitUint8;
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
|
@ -1142,14 +1146,43 @@ GetQuestionValue (
|
|||
return Status;
|
||||
}
|
||||
|
||||
LengthStr = StrLen (Value);
|
||||
Status = EFI_SUCCESS;
|
||||
if (IsString) {
|
||||
//
|
||||
// Convert Config String to Unicode String, e.g "0041004200430044" => "ABCD"
|
||||
// Add string tail char L'\0' into Length
|
||||
//
|
||||
Length = StorageWidth + sizeof (CHAR16);
|
||||
Status = ConfigStringToUnicode ((CHAR16 *) Dst, &Length, Value);
|
||||
Length = StorageWidth + sizeof (CHAR16);
|
||||
if (Length < ((LengthStr / 4 + 1) * 2)) {
|
||||
Status = EFI_BUFFER_TOO_SMALL;
|
||||
} else {
|
||||
StringPtr = (CHAR16 *) Dst;
|
||||
ZeroMem (TemStr, sizeof (TemStr));
|
||||
for (Index = 0; Index < LengthStr; Index += 4) {
|
||||
StrnCpy (TemStr, Value + Index, 4);
|
||||
StringPtr[Index/4] = (CHAR16) StrHexToUint64 (TemStr);
|
||||
}
|
||||
//
|
||||
// Add tailing L'\0' character
|
||||
//
|
||||
StringPtr[Index/4] = L'\0';
|
||||
}
|
||||
} else {
|
||||
Status = HexStringToBuf (Dst, &StorageWidth, Value, NULL);
|
||||
if (StorageWidth < ((LengthStr + 1) / 2)) {
|
||||
Status = EFI_BUFFER_TOO_SMALL;
|
||||
} else {
|
||||
ZeroMem (TemStr, sizeof (TemStr));
|
||||
for (Index = 0; Index < LengthStr; Index ++) {
|
||||
TemStr[0] = Value[LengthStr - Index - 1];
|
||||
DigitUint8 = (UINT8) StrHexToUint64 (TemStr);
|
||||
if ((Index & 1) == 0) {
|
||||
Dst [Index/2] = DigitUint8;
|
||||
} else {
|
||||
Dst [Index/2] = (UINT8) ((Dst [Index/2] << 4) + DigitUint8);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
FreePool (Value);
|
||||
|
@ -1222,18 +1255,48 @@ GetQuestionValue (
|
|||
}
|
||||
*StringPtr = L'\0';
|
||||
|
||||
LengthStr = StrLen (Value);
|
||||
Status = EFI_SUCCESS;
|
||||
if (!IsBufferStorage && IsString) {
|
||||
//
|
||||
// Convert Config String to Unicode String, e.g "0041004200430044" => "ABCD"
|
||||
// Add string tail char L'\0' into Length
|
||||
//
|
||||
Length = StorageWidth + sizeof (CHAR16);
|
||||
Status = ConfigStringToUnicode ((CHAR16 *) Dst, &Length, Value);
|
||||
} else {
|
||||
Status = HexStringToBuf (Dst, &StorageWidth, Value, NULL);
|
||||
if (EFI_ERROR (Status)) {
|
||||
FreePool (Result);
|
||||
return Status;
|
||||
Length = StorageWidth + sizeof (CHAR16);
|
||||
if (Length < ((LengthStr / 4 + 1) * 2)) {
|
||||
Status = EFI_BUFFER_TOO_SMALL;
|
||||
} else {
|
||||
StringPtr = (CHAR16 *) Dst;
|
||||
ZeroMem (TemStr, sizeof (TemStr));
|
||||
for (Index = 0; Index < LengthStr; Index += 4) {
|
||||
StrnCpy (TemStr, Value + Index, 4);
|
||||
StringPtr[Index/4] = (CHAR16) StrHexToUint64 (TemStr);
|
||||
}
|
||||
//
|
||||
// Add tailing L'\0' character
|
||||
//
|
||||
StringPtr[Index/4] = L'\0';
|
||||
}
|
||||
} else {
|
||||
if (StorageWidth < ((LengthStr + 1) / 2)) {
|
||||
Status = EFI_BUFFER_TOO_SMALL;
|
||||
} else {
|
||||
ZeroMem (TemStr, sizeof (TemStr));
|
||||
for (Index = 0; Index < LengthStr; Index ++) {
|
||||
TemStr[0] = Value[LengthStr - Index - 1];
|
||||
DigitUint8 = (UINT8) StrHexToUint64 (TemStr);
|
||||
if ((Index & 1) == 0) {
|
||||
Dst [Index/2] = DigitUint8;
|
||||
} else {
|
||||
Dst [Index/2] = (UINT8) ((Dst [Index/2] << 4) + DigitUint8);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
FreePool (Result);
|
||||
return Status;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -1244,6 +1307,7 @@ GetQuestionValue (
|
|||
} else {
|
||||
SetValueByName (Storage, Question->VariableName, Value);
|
||||
}
|
||||
|
||||
FreePool (Result);
|
||||
}
|
||||
|
||||
|
@ -1286,6 +1350,10 @@ SetQuestionValue (
|
|||
UINTN Length;
|
||||
BOOLEAN IsBufferStorage;
|
||||
BOOLEAN IsString;
|
||||
UINT8 *TemBuffer;
|
||||
CHAR16 *TemName;
|
||||
CHAR16 *TemString;
|
||||
UINTN Index;
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
|
@ -1397,20 +1465,32 @@ SetQuestionValue (
|
|||
} else {
|
||||
if (IsString) {
|
||||
//
|
||||
// Convert Unicode String to Config String, e.g. "ABCD" => "0041004200430044"
|
||||
// Allocate enough string buffer.
|
||||
//
|
||||
Value = NULL;
|
||||
BufferLen = ((StrLen ((CHAR16 *) Src) * 4) + 1) * sizeof (CHAR16);
|
||||
Value = AllocateZeroPool (BufferLen);
|
||||
ASSERT (Value != NULL);
|
||||
Status = UnicodeToConfigString (Value, &BufferLen, (CHAR16 *) Src);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
//
|
||||
// Convert Unicode String to Config String, e.g. "ABCD" => "0041004200430044"
|
||||
//
|
||||
TemName = (CHAR16 *) Src;
|
||||
TemString = Value;
|
||||
for (; *TemName != L'\0'; TemName++) {
|
||||
TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemName, 4);
|
||||
}
|
||||
} else {
|
||||
BufferLen = StorageWidth * 2 + 1;
|
||||
Value = AllocateZeroPool (BufferLen * sizeof (CHAR16));
|
||||
ASSERT (Value != NULL);
|
||||
BufToHexString (Value, &BufferLen, Src, StorageWidth);
|
||||
ToLower (Value);
|
||||
//
|
||||
// Convert Buffer to Hex String
|
||||
//
|
||||
TemBuffer = Src + StorageWidth - 1;
|
||||
TemString = Value;
|
||||
for (Index = 0; Index < StorageWidth; Index ++, TemBuffer --) {
|
||||
TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemBuffer, 2);
|
||||
}
|
||||
}
|
||||
|
||||
Status = SetValueByName (Storage, Question->VariableName, Value);
|
||||
|
@ -1446,17 +1526,34 @@ SetQuestionValue (
|
|||
}
|
||||
|
||||
Value = ConfigResp + StrLen (ConfigResp);
|
||||
|
||||
if (!IsBufferStorage && IsString) {
|
||||
//
|
||||
// Convert Unicode String to Config String, e.g. "ABCD" => "0041004200430044"
|
||||
//
|
||||
BufferLen = ((StrLen ((CHAR16 *) Src) * 4) + 1) * sizeof (CHAR16);
|
||||
Status = UnicodeToConfigString (Value, &BufferLen, (CHAR16 *) Src);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
TemName = (CHAR16 *) Src;
|
||||
TemString = Value;
|
||||
for (; *TemName != L'\0'; TemName++) {
|
||||
TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemName, 4);
|
||||
}
|
||||
} else {
|
||||
BufferLen = StorageWidth * 2 + 1;
|
||||
BufToHexString (Value, &BufferLen, Src, StorageWidth);
|
||||
ToLower (Value);
|
||||
//
|
||||
// Convert Buffer to Hex String
|
||||
//
|
||||
TemBuffer = Src + StorageWidth - 1;
|
||||
TemString = Value;
|
||||
for (Index = 0; Index < StorageWidth; Index ++, TemBuffer --) {
|
||||
TemString += UnicodeValueToString (TemString, PREFIX_ZERO | RADIX_HEX, *TemBuffer, 2);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Convert to lower char.
|
||||
//
|
||||
for (TemString = Value; *Value != L'\0'; Value++) {
|
||||
if (*Value >= L'A' && *Value <= L'Z') {
|
||||
*Value = (CHAR16) (*Value - L'A' + L'a');
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -1506,6 +1506,9 @@ UiDisplayMenu (
|
|||
UINT16 DefaultId;
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
FORM_BROWSER_STATEMENT *Statement;
|
||||
CHAR16 TemStr[2];
|
||||
UINT8 *DevicePathBuffer;
|
||||
UINT8 DigitUint8;
|
||||
|
||||
CopyMem (&LocalScreen, &gScreenDimensions, sizeof (EFI_SCREEN_DESCRIPTOR));
|
||||
|
||||
|
@ -2359,7 +2362,26 @@ UiDisplayMenu (
|
|||
BufferSize = StrLen (StringPtr) / 2;
|
||||
DevicePath = AllocatePool (BufferSize);
|
||||
|
||||
HexStringToBufInReverseOrder ((UINT8 *) DevicePath, &BufferSize, StringPtr);
|
||||
//
|
||||
// Convert from Device Path String to DevicePath Buffer in the reverse order.
|
||||
//
|
||||
DevicePathBuffer = (UINT8 *) DevicePath;
|
||||
for (Index = 0; StringPtr[Index] != L'\0'; Index ++) {
|
||||
TemStr[0] = StringPtr[Index];
|
||||
DigitUint8 = (UINT8) StrHexToUint64 (TemStr);
|
||||
if (DigitUint8 == 0 && TemStr[0] != L'0') {
|
||||
//
|
||||
// Invalid Hex Char as the tail.
|
||||
//
|
||||
break;
|
||||
}
|
||||
if ((Index & 1) == 0) {
|
||||
DevicePathBuffer [Index/2] = DigitUint8;
|
||||
} else {
|
||||
DevicePathBuffer [Index/2] = (UINT8) ((DevicePathBuffer [Index/2] << 4) + DigitUint8);
|
||||
}
|
||||
}
|
||||
|
||||
Selection->Handle = HiiLibDevicePathToHiiHandle (DevicePath);
|
||||
if (Selection->Handle == NULL) {
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue