summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Universal')
-rw-r--r--MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c78
-rw-r--r--MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c12
-rw-r--r--MdeModulePkg/Universal/SetupBrowserDxe/Expression.c9
3 files changed, 48 insertions, 51 deletions
diff --git a/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c b/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c
index e183abbfe0..dbd371ce70 100644
--- a/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c
+++ b/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c
@@ -308,19 +308,7 @@ Xtoi (
IN CHAR16 *Str
)
{
- UINTN Rvalue;
- UINTN Length;
-
- ASSERT (Str != NULL);
-
- //
- // convert hex digits
- //
- Rvalue = 0;
- Length = sizeof (UINTN);
- HexStringToBuf ((UINT8 *) &Rvalue, &Length, Str, NULL);
-
- return Rvalue;
+ return StrHexToUintn (Str);
}
/**
@@ -337,11 +325,7 @@ Xtoi64 (
OUT UINT64 *Data
)
{
- UINTN Length;
-
- *Data = 0;
- Length = sizeof (UINT64);
- HexStringToBuf ((UINT8 *) Data, &Length, Str, NULL);
+ *Data = StrHexToUint64 (Str);
}
/**
@@ -524,7 +508,15 @@ StrToBuf (
for(Index = 0; Index < StrLength; Index++, Str++) {
- IsHexDigit (&Digit, *Str);
+ if ((*Str >= L'a') && (*Str <= L'f')) {
+ Digit = (UINT8) (*Str - L'a' + 0x0A);
+ } else if ((*Str >= L'A') && (*Str <= L'F')) {
+ Digit = (UINT8) (*Str - L'A' + 0x0A);
+ } else if ((*Str >= L'0') && (*Str <= L'9')) {
+ Digit = (UINT8) (*Str - L'0');
+ } else {
+ return EFI_INVALID_PARAMETER;
+ }
//
// For odd charaters, write the upper nibble for each buffer byte,
@@ -546,6 +538,7 @@ StrToBuf (
/**
Converts a string to GUID value.
+ Guid Format is xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
@param Str The registry format GUID string that contains the GUID value.
@param Guid A pointer to the converted GUID value.
@@ -561,46 +554,51 @@ StrToGuid (
OUT EFI_GUID *Guid
)
{
- UINTN BufferLength;
- UINTN ConvertedStrLen;
- EFI_STATUS Status;
-
- BufferLength = sizeof (Guid->Data1);
- Status = HexStringToBuf ((UINT8 *) &Guid->Data1, &BufferLength, Str, &ConvertedStrLen);
- if (EFI_ERROR (Status)) {
- return Status;
+ //
+ // Get the first UINT32 data
+ //
+ Guid->Data1 = (UINT32) StrHexToUint64 (Str);
+ while (!IS_HYPHEN (*Str) && !IS_NULL (*Str)) {
+ Str ++;
}
- Str += ConvertedStrLen;
+
if (IS_HYPHEN (*Str)) {
Str++;
} else {
return EFI_UNSUPPORTED;
}
-
- BufferLength = sizeof (Guid->Data2);
- Status = HexStringToBuf ((UINT8 *) &Guid->Data2, &BufferLength, Str, &ConvertedStrLen);
- if (EFI_ERROR (Status)) {
- return Status;
+
+ //
+ // Get the second UINT16 data
+ //
+ Guid->Data2 = (UINT16) StrHexToUint64 (Str);
+ while (!IS_HYPHEN (*Str) && !IS_NULL (*Str)) {
+ Str ++;
}
- Str += ConvertedStrLen;
+
if (IS_HYPHEN (*Str)) {
Str++;
} else {
return EFI_UNSUPPORTED;
}
-
- BufferLength = sizeof (Guid->Data3);
- Status = HexStringToBuf ((UINT8 *) &Guid->Data3, &BufferLength, Str, &ConvertedStrLen);
- if (EFI_ERROR (Status)) {
- return Status;
+
+ //
+ // Get the third UINT16 data
+ //
+ Guid->Data3 = (UINT16) StrHexToUint64 (Str);
+ while (!IS_HYPHEN (*Str) && !IS_NULL (*Str)) {
+ Str ++;
}
- Str += ConvertedStrLen;
+
if (IS_HYPHEN (*Str)) {
Str++;
} else {
return EFI_UNSUPPORTED;
}
+ //
+ // Get the followin 8 bytes data
+ //
StrToBuf (&Guid->Data4[0], 2, Str);
//
// Skip 2 byte hex chars
diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
index 53de070a2a..7cbf362275 100644
--- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
+++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c
@@ -22,7 +22,7 @@ Abstract:
#include "IScsiImpl.h"
-CONST CHAR8 IScsiHexString[] = "0123456789ABCDEFabcdef";
+GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 IScsiHexString[] = "0123456789ABCDEFabcdef";
/**
Removes (trims) specified leading and trailing characters from a string.
@@ -216,9 +216,9 @@ IScsiLunToUnicodeStr (
StrCpy (TempStr, L"0-");
} else {
TempStr[0] = (CHAR16) IScsiHexString[Lun[2 * Index] >> 4];
- TempStr[1] = (CHAR16) IScsiHexString[Lun[2 * Index] & 0xf];
+ TempStr[1] = (CHAR16) IScsiHexString[Lun[2 * Index] & 0x0F];
TempStr[2] = (CHAR16) IScsiHexString[Lun[2 * Index + 1] >> 4];
- TempStr[3] = (CHAR16) IScsiHexString[Lun[2 * Index + 1] & 0xf];
+ TempStr[3] = (CHAR16) IScsiHexString[Lun[2 * Index + 1] & 0x0F];
TempStr[4] = L'-';
TempStr[5] = 0;
@@ -388,8 +388,8 @@ IScsiMacAddrToStr (
UINT32 Index;
for (Index = 0; Index < Len; Index++) {
- Str[3 * Index] = NibbleToHexChar ((UINT8) (Mac->Addr[Index] >> 4));
- Str[3 * Index + 1] = NibbleToHexChar (Mac->Addr[Index]);
+ Str[3 * Index] = (CHAR16) IScsiHexString[(Mac->Addr[Index] >> 4) & 0x0F];
+ Str[3 * Index + 1] = (CHAR16) IScsiHexString[Mac->Addr[Index] & 0x0F];
Str[3 * Index + 2] = L'-';
}
@@ -441,7 +441,7 @@ IScsiBinToHex (
for (Index = 0; Index < BinLength; Index++) {
HexStr[Index * 2 + 2] = IScsiHexString[BinBuffer[Index] >> 4];
- HexStr[Index * 2 + 3] = IScsiHexString[BinBuffer[Index] & 0xf];
+ HexStr[Index * 2 + 3] = IScsiHexString[BinBuffer[Index] & 0x0F];
}
HexStr[Index * 2 + 2] = '\0';
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c b/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
index a56c7318b4..5044fd1642 100644
--- a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
+++ b/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c
@@ -619,7 +619,6 @@ IfrToUint (
EFI_HII_VALUE Value;
CHAR16 *String;
CHAR16 *StringPtr;
- UINTN BufferSize;
Status = PopExpression (&Value);
if (EFI_ERROR (Status)) {
@@ -636,19 +635,19 @@ IfrToUint (
if (String == NULL) {
return EFI_NOT_FOUND;
}
-
+
IfrStrToUpper (String);
StringPtr = StrStr (String, L"0X");
if (StringPtr != NULL) {
//
// Hex string
//
- BufferSize = sizeof (UINT64);
- Status = HexStringToBuf ((UINT8 *) &Result->Value.u64, &BufferSize, StringPtr + 2, NULL);
+ Result->Value.u64 = StrHexToUint64 (String);
} else {
//
- // BUGBUG: Need handle decimal string
+ // decimal string
//
+ Result->Value.u64 = StrDecimalToUint64 (String);
}
FreePool (String);
} else {