summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/DevicePathDxe
diff options
context:
space:
mode:
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2008-05-23 05:30:08 +0000
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2008-05-23 05:30:08 +0000
commit36fe40c2ea61a81b7f004886682e55fb2d5358be (patch)
tree561545cf3b4ddb433f1b2f8761c0da9450c74705 /MdeModulePkg/Universal/DevicePathDxe
parentd9e5c1fffb22d39dd52ef23febe40cd4e2ee0965 (diff)
downloadedk2-platforms-36fe40c2ea61a81b7f004886682e55fb2d5358be.tar.xz
1) Add BufToHexString, HexStringToBuf and IsHexDigit to BaseLib.
2) Remove the duplicated functions implementation from the modules that reference these APIs git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5283 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal/DevicePathDxe')
-rw-r--r--MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c128
1 files changed, 0 insertions, 128 deletions
diff --git a/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c b/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c
index 3dd9b79a86..75e5cf8a32 100644
--- a/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c
+++ b/MdeModulePkg/Universal/DevicePathDxe/DevicePathFromText.c
@@ -271,134 +271,6 @@ GetNextDeviceNodeStr (
return ReturnStr;
}
-STATIC
-BOOLEAN
-IsHexDigit (
- OUT UINT8 *Digit,
- IN CHAR16 Char
- )
-/*++
-
- Routine Description:
- Determines if a Unicode character is a hexadecimal digit.
- The test is case insensitive.
-
- Arguments:
- Digit - Pointer to byte that receives the value of the hex character.
- Char - Unicode character to test.
-
- Returns:
- TRUE - If the character is a hexadecimal digit.
- FALSE - Otherwise.
-
---*/
-{
- if ((Char >= L'0') && (Char <= L'9')) {
- *Digit = (UINT8) (Char - L'0');
- return TRUE;
- }
-
- if ((Char >= L'A') && (Char <= L'F')) {
- *Digit = (UINT8) (Char - L'A' + 0x0A);
- return TRUE;
- }
-
- if ((Char >= L'a') && (Char <= L'f')) {
- *Digit = (UINT8) (Char - L'a' + 0x0A);
- return TRUE;
- }
-
- return FALSE;
-}
-
-STATIC
-EFI_STATUS
-HexStringToBuf (
- IN OUT UINT8 *Buf,
- IN OUT UINTN *Len,
- IN CHAR16 *Str,
- OUT UINTN *ConvertedStrLen OPTIONAL
- )
-/*++
-
- Routine Description:
- Converts Unicode string to binary buffer.
- The conversion may be partial.
- The first character in the string that is not hex digit stops the conversion.
- At a minimum, any blob of data could be represented as a hex string.
-
- Arguments:
- Buf - Pointer to buffer that receives the data.
- Len - Length in bytes of the buffer to hold converted data.
- If routine return with EFI_SUCCESS, containing length of converted data.
- If routine return with EFI_BUFFER_TOO_SMALL, containg length of buffer desired.
- Str - String to be converted from.
- ConvertedStrLen - Length of the Hex String consumed.
-
- Returns:
- EFI_SUCCESS: Routine Success.
- EFI_BUFFER_TOO_SMALL: The buffer is too small to hold converted data.
- EFI_
-
---*/
-{
- UINTN HexCnt;
- UINTN Idx;
- UINTN BufferLength;
- UINT8 Digit;
- UINT8 Byte;
-
- Digit = 0;
-
- //
- // Find out how many hex characters the string has.
- //
- for (Idx = 0, HexCnt = 0; IsHexDigit (&Digit, Str[Idx]); Idx++, HexCnt++);
-
- if (HexCnt == 0) {
- *Len = 0;
- return EFI_SUCCESS;
- }
- //
- // Two Unicode characters make up 1 buffer byte. Round up.
- //
- BufferLength = (HexCnt + 1) / 2;
-
- //
- // Test if buffer is passed enough.
- //
- if (BufferLength > (*Len)) {
- *Len = BufferLength;
- return EFI_BUFFER_TOO_SMALL;
- }
-
- *Len = BufferLength;
-
- for (Idx = 0; Idx < HexCnt; Idx++) {
-
- IsHexDigit (&Digit, Str[HexCnt - 1 - Idx]);
-
- //
- // For odd charaters, write the lower nibble for each buffer byte,
- // and for even characters, the upper nibble.
- //
- if ((Idx & 1) == 0) {
- Byte = Digit;
- } else {
- Byte = Buf[Idx / 2];
- Byte &= 0x0F;
- Byte = (UINT8) (Byte | Digit << 4);
- }
-
- Buf[Idx / 2] = Byte;
- }
-
- if (ConvertedStrLen != NULL) {
- *ConvertedStrLen = HexCnt;
- }
-
- return EFI_SUCCESS;
-}
STATIC
CHAR16 *