summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/DevicePathDxe
diff options
context:
space:
mode:
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2008-12-01 02:32:12 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2008-12-01 02:32:12 +0000
commitac7e320cb8326befd240020db709151884c889bc (patch)
tree0244f130be9838647093dbabad4ee7d0d7b5348a /MdeModulePkg/Universal/DevicePathDxe
parent48bd50c5a1e4c31818bba1d2ce88f9270b2f2440 (diff)
downloadedk2-platforms-ac7e320cb8326befd240020db709151884c889bc.tar.xz
Remove NibbleToHexChar() function from BaseLib
Move IsHexDigit, BufToHexString, HexStringToBuf from BaseLib to MdeModulePkg IfrSupportLib. The reason is: 1) IsHexDigit function provides the logic to check Hex Digit and convert it to Decimal value, which is required by IScsi LUN and HII user input. But this logic is not provided by any functions in MdeLib. So, it can't be deleted. It is moved to IfrSupportLib. 2) BufToHexString function converts a array of buffers to hex string. If the buffer length is less than sizeof (UINT64), it can be directly replaced by UnicodeValueToString(). But HII modules may use BufToHexString to convert the buffers whose length > sizeof (UINT64). For example: .\MdeModulePkg\Universal\HiiDatabaseDxe\ConfigRouting.c line 201, 1148 .\Universal\SetupBrowserDxe\Setup.c line line 1457, 1503 Like this case, it is not easy to use UnicodeValueToString to replace BufToHexString. So, BufToHexString is still kept. Because such usages are in HII modules, this function is moved to IfrSupportLib. 3) HexStringToBuf is moved to IfrSupportLib. The reason is similar to BufToHexString. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6782 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal/DevicePathDxe')
-rw-r--r--MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c78
1 files changed, 38 insertions, 40 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