summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/HiiDatabaseDxe
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/HiiDatabaseDxe
parentd9e5c1fffb22d39dd52ef23febe40cd4e2ee0965 (diff)
downloadedk2-36fe40c2ea61a81b7f004886682e55fb2d5358be.zip
edk2-36fe40c2ea61a81b7f004886682e55fb2d5358be.tar.gz
edk2-36fe40c2ea61a81b7f004886682e55fb2d5358be.tar.bz2
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/HiiDatabaseDxe')
-rw-r--r--MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c11
-rw-r--r--MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c4
-rw-r--r--MdeModulePkg/Universal/HiiDatabaseDxe/R8Lib.c228
-rw-r--r--MdeModulePkg/Universal/HiiDatabaseDxe/R8Lib.h86
4 files changed, 9 insertions, 320 deletions
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
index 15a55d7..3f35ed9 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2007, Intel Corporation
+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
@@ -92,7 +92,7 @@ HexStringToBufPrivate (
//
// Find out how many hex characters the string has.
//
- for (Idx = 0, HexCnt = 0; R8_IsHexDigit (&Digit, Str[Idx]); Idx++, HexCnt++);
+ for (Idx = 0, HexCnt = 0; IsHexDigit (&Digit, Str[Idx]); Idx++, HexCnt++);
if (HexCnt == 0) {
*Len = 0;
@@ -115,7 +115,7 @@ HexStringToBufPrivate (
for (Idx = 0; Idx < HexCnt; Idx++) {
- R8_IsHexDigit (&Digit, Str[Idx]);
+ IsHexDigit (&Digit, Str[Idx]);
//
// For odd charaters, write the lower nibble for each buffer byte,
@@ -765,7 +765,7 @@ GetValueOfNumber (
goto Exit;
}
- Status = R8_HexStringToBuf (Buf, &Length, Str, NULL);
+ Status = HexStringToBuf (Buf, &Length, Str, NULL);
if (EFI_ERROR (Status)) {
goto Exit;
}
@@ -1607,7 +1607,7 @@ HiiBlockToConfig (
goto Exit;
}
- Status = R8_BufToHexString (ValueStr, &Length, Value, Width);
+ Status = BufToHexString (ValueStr, &Length, Value, Width);
ASSERT_EFI_ERROR (Status);
SafeFreePool (Value);
Value = NULL;
@@ -2114,3 +2114,4 @@ Exit:
}
+
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c
index 99084db..3d13777 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c
@@ -104,8 +104,6 @@ STATIC HII_DATABASE_PRIVATE_DATA mPrivate = {
NULL
};
-//@MT: EFI_DRIVER_ENTRY_POINT (InitializeHiiDatabase)
-
EFI_STATUS
EFIAPI
InitializeHiiDatabase (
@@ -131,8 +129,6 @@ Returns:
EFI_HANDLE *HandleBuffer;
UINTN HandleCount;
- //@MT: EfiInitializeDriverLib (ImageHandle, SystemTable);
-
//
// There will be only one HII Database in the system
// If there is another out there, someone is trying to install us
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/R8Lib.c b/MdeModulePkg/Universal/HiiDatabaseDxe/R8Lib.c
index 5458b16..007be63 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/R8Lib.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/R8Lib.c
@@ -1,5 +1,5 @@
/**@file
- Copyright (c) 2007, Intel Corporation
+ 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
@@ -15,31 +15,6 @@
#include "HiiDatabase.h"
-CHAR16
-NibbleToHexChar (
- IN UINT8 Nibble
- )
-/*++
-
- Routine Description:
- Converts the low nibble of a byte to hex unicode character.
-
- Arguments:
- Nibble - lower nibble of a byte.
-
- Returns:
- Hex unicode character.
-
---*/
-{
- Nibble &= 0x0F;
- if (Nibble <= 0x9) {
- return (CHAR16)(Nibble + L'0');
- }
-
- return (CHAR16)(Nibble - 0xA + L'A');
-}
-
/**
Compare whether two names of languages are identical.
@@ -81,204 +56,3 @@ R8_EfiLibCompareLanguage (
-
-/**
- Converts binary buffer to Unicode string.
- At a minimum, any blob of data could be represented as a hex string.
-
- @param Str Pointer to the string.
- @param HexStringBufferLength Length in bytes of buffer to hold the hex string.
- Includes tailing '\0' character. If routine return
- with EFI_SUCCESS, containing length of hex string
- buffer. If routine return with
- EFI_BUFFER_TOO_SMALL, containg length of hex
- string buffer desired.
- @param Buf Buffer to be converted from.
- @param Len Length in bytes of the buffer to be converted.
-
- @retval EFI_SUCCESS Routine success.
- @retval EFI_BUFFER_TOO_SMALL The hex string buffer is too small.
-
-**/
-EFI_STATUS
-R8_BufToHexString (
- IN OUT CHAR16 *Str,
- IN OUT UINTN *HexStringBufferLength,
- IN UINT8 *Buf,
- IN UINTN Len
- )
-{
- //
- // Porting Guide:
- // This library interface is simply obsolete.
- // Include the source code to user code.
- //
- UINTN Idx;
- UINT8 Byte;
- UINTN StrLen;
-
- //
- // Make sure string is either passed or allocate enough.
- // It takes 2 Unicode characters (4 bytes) to represent 1 byte of the binary buffer.
- // Plus the Unicode termination character.
- //
- StrLen = Len * 2;
- if (StrLen > ((*HexStringBufferLength) - 1)) {
- *HexStringBufferLength = StrLen + 1;
- return EFI_BUFFER_TOO_SMALL;
- }
-
- *HexStringBufferLength = StrLen + 1;
- //
- // Ends the string.
- //
- Str[StrLen] = L'\0';
-
- for (Idx = 0; Idx < Len; Idx++) {
-
- Byte = Buf[Idx];
- Str[StrLen - 1 - Idx * 2] = NibbleToHexChar (Byte);
- Str[StrLen - 2 - Idx * 2] = NibbleToHexChar ((UINT8)(Byte >> 4));
- }
-
- return EFI_SUCCESS;
-}
-
-
-
-
-/**
- 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.
-
- @param Buf Pointer to buffer that receives the data.
- @param 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.
- @param Str String to be converted from.
- @param ConvertedStrLen Length of the Hex String consumed.
-
- @retval EFI_SUCCESS Routine Success.
- @retval EFI_BUFFER_TOO_SMALL The buffer is too small to hold converted data.
-
-**/
-EFI_STATUS
-R8_HexStringToBuf (
- IN OUT UINT8 *Buf,
- IN OUT UINTN *Len,
- IN CHAR16 *Str,
- OUT UINTN *ConvertedStrLen OPTIONAL
- )
-{
- //
- // Porting Guide:
- // This library interface is simply obsolete.
- // Include the source code to user code.
- //
-
- UINTN HexCnt;
- UINTN Idx;
- UINTN BufferLength;
- UINT8 Digit;
- UINT8 Byte;
-
- //
- // Find out how many hex characters the string has.
- //
- for (Idx = 0, HexCnt = 0; R8_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++) {
-
- R8_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;
-}
-
-
-
-
-/**
- Determines if a Unicode character is a hexadecimal digit.
- The test is case insensitive.
-
- @param Digit Pointer to byte that receives the value of the hex
- character.
- @param Char Unicode character to test.
-
- @retval TRUE If the character is a hexadecimal digit.
- @retval FALSE Otherwise.
-
-**/
-BOOLEAN
-R8_IsHexDigit (
- OUT UINT8 *Digit,
- IN CHAR16 Char
- )
-{
- //
- // Porting Guide:
- // This library interface is simply obsolete.
- // Include the source code to user code.
- //
-
- 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;
-}
-
-
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/R8Lib.h b/MdeModulePkg/Universal/HiiDatabaseDxe/R8Lib.h
index 4e6e1a1..9ca8d15 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/R8Lib.h
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/R8Lib.h
@@ -1,5 +1,5 @@
/**@file
- Copyright (c) 2007, Intel Corporation
+ 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
@@ -34,88 +34,6 @@ R8_EfiLibCompareLanguage (
;
-
-
-/**
- Converts binary buffer to Unicode string.
- At a minimum, any blob of data could be represented as a hex string.
-
- @param Str Pointer to the string.
- @param HexStringBufferLength Length in bytes of buffer to hold the hex string.
- Includes tailing '\0' character. If routine return
- with EFI_SUCCESS, containing length of hex string
- buffer. If routine return with
- EFI_BUFFER_TOO_SMALL, containg length of hex
- string buffer desired.
- @param Buf Buffer to be converted from.
- @param Len Length in bytes of the buffer to be converted.
-
- @retval EFI_SUCCESS Routine success.
- @retval EFI_BUFFER_TOO_SMALL The hex string buffer is too small.
-
-**/
-EFI_STATUS
-R8_BufToHexString (
- IN OUT CHAR16 *Str,
- IN OUT UINTN *HexStringBufferLength,
- IN UINT8 *Buf,
- IN UINTN Len
- )
-;
-
-
-
-
-/**
- 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.
-
- @param Buf Pointer to buffer that receives the data.
- @param 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.
- @param Str String to be converted from.
- @param ConvertedStrLen Length of the Hex String consumed.
-
- @retval EFI_SUCCESS Routine Success.
- @retval EFI_BUFFER_TOO_SMALL The buffer is too small to hold converted data.
-
-**/
-EFI_STATUS
-R8_HexStringToBuf (
- IN OUT UINT8 *Buf,
- IN OUT UINTN *Len,
- IN CHAR16 *Str,
- OUT UINTN *ConvertedStrLen OPTIONAL
- )
-;
-
-
-
-
-/**
- Determines if a Unicode character is a hexadecimal digit.
- The test is case insensitive.
-
- @param Digit Pointer to byte that receives the value of the hex
- character.
- @param Char Unicode character to test.
-
- @retval TRUE If the character is a hexadecimal digit.
- @retval FALSE Otherwise.
-
-**/
-BOOLEAN
-R8_IsHexDigit (
- OUT UINT8 *Digit,
- IN CHAR16 Char
- )
-;
-
-
#endif
+