diff options
author | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-05-23 05:30:08 +0000 |
---|---|---|
committer | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-05-23 05:30:08 +0000 |
commit | 36fe40c2ea61a81b7f004886682e55fb2d5358be (patch) | |
tree | 561545cf3b4ddb433f1b2f8761c0da9450c74705 /MdeModulePkg/Universal | |
parent | d9e5c1fffb22d39dd52ef23febe40cd4e2ee0965 (diff) | |
download | edk2-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')
18 files changed, 146 insertions, 942 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 *
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c index 4cdbe5fb88..45bfeaffcd 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c +++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c @@ -563,7 +563,6 @@ DriverSampleInit ( //
// Initialize the library and our protocol.
//
- //@MT: EfiInitializeDriverLib (ImageHandle, SystemTable);
//
// Initialize screen dimensions for SendForm().
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c b/MdeModulePkg/Universal/HiiDatabaseDxe/ConfigRouting.c index 15a55d794a..3f35ed9005 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 99084db068..3d13777883 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 5458b16b61..007be630da 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 4e6e1a1e61..9ca8d15482 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 + diff --git a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c index 1699bfb709..52fd68843c 100644 --- a/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c +++ b/MdeModulePkg/Universal/Network/IScsiDxe/IScsiMisc.c @@ -25,44 +25,6 @@ Abstract: STATIC CONST CHAR8 IScsiHexString[] = "0123456789ABCDEFabcdef";
/**
- Determines if a Unicode character is a hexadecimal digit.
- The test is case insensitive.
-
- @param Digit[out] Pointer to byte that receives the value of the hex character.
-
- @param Char[in] Unicode character to test.
-
- @retval TRUE If the character is a hexadecimal digit.
-
- @retval FALSE Otherwise.
-
-**/
-static
-BOOLEAN
-IsHexDigit (
- OUT UINT8 *Digit,
- IN CHAR16 Char
- )
-{
- 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;
-}
-
-/**
Removes (trims) specified leading and trailing characters from a string.
@param str[in][out] Pointer to the null-terminated string to be trimmed. On return,
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c b/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c index 730f51d435..a074b92a27 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Expression.c @@ -647,7 +647,7 @@ IfrToUint ( // Hex string // BufferSize = sizeof (UINT64); - Status = R8_HexStringToBuf ((UINT8 *) &Result->Value.u64, &BufferSize, StringPtr + 2, NULL); + Status = HexStringToBuf ((UINT8 *) &Result->Value.u64, &BufferSize, StringPtr + 2, NULL); } else { // // BUGBUG: Need handle decimal string diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c index ed16d7b032..c813081454 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/IfrParse.c @@ -21,7 +21,6 @@ Abstract: #include "Setup.h" #include "Ui.h" -//@MT:#include "EfiPrintLib.h" UINT16 mStatementIndex; UINT16 mExpressionOpCodeIndex; diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c b/MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c index 5257f32b66..cc580b81c7 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/InputHandler.c @@ -612,7 +612,7 @@ EnterCarriageReturn: default: if (ManualInput) { if (HexInput) { - if (!R8_IsHexDigit (&Digital, Key.UnicodeChar)) { + if (!IsHexDigit (&Digital, Key.UnicodeChar)) { UpdateStatusBar (INPUT_ERROR, Question->QuestionFlags, TRUE); break; } diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Print.c b/MdeModulePkg/Universal/SetupBrowserDxe/Print.c index 6cc50c3ad5..235ee45d2d 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Print.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Print.c @@ -33,11 +33,6 @@ Abstract: **/ -//@MT:#include "Tiano.h" -//@MT:#include "EfiDriverLib.h" -//@MT:#include "EfiPrintLib.h" -//@MT:#include "EfiStdArg.h" -//@MT:#include "TianoHii.h" #include "Setup.h" UINTN diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/R8Lib.c b/MdeModulePkg/Universal/SetupBrowserDxe/R8Lib.c deleted file mode 100644 index 1ffeb1bb9d..0000000000 --- a/MdeModulePkg/Universal/SetupBrowserDxe/R8Lib.c +++ /dev/null @@ -1,243 +0,0 @@ -/**@file - Copyright (c) 2007, 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 "Setup.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'); -} - - - -/** - 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/SetupBrowserDxe/R8Lib.h b/MdeModulePkg/Universal/SetupBrowserDxe/R8Lib.h deleted file mode 100644 index a0903196e6..0000000000 --- a/MdeModulePkg/Universal/SetupBrowserDxe/R8Lib.h +++ /dev/null @@ -1,97 +0,0 @@ -/**@file - Copyright (c) 2007, 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. - - -**/ - - - -/** - 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 - ) -; - - diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c index 4ec9e6ee2a..820353131f 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.c @@ -88,9 +88,9 @@ CHAR16 gPromptBlockWidth; CHAR16 gOptionBlockWidth; CHAR16 gHelpBlockWidth; -EFI_GUID gZeroGuid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; +EFI_GUID gZeroGuid = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}}; EFI_GUID gSetupBrowserGuid = { - 0xab368524, 0xb60c, 0x495b, 0xa0, 0x9, 0x12, 0xe8, 0x5b, 0x1a, 0xea, 0x32 + 0xab368524, 0xb60c, 0x495b, {0xa0, 0x9, 0x12, 0xe8, 0x5b, 0x1a, 0xea, 0x32} }; FUNCTIION_KEY_SETTING gFunctionKeySettingTable[] = { @@ -102,14 +102,16 @@ FUNCTIION_KEY_SETTING gFunctionKeySettingTable[] = { 0x847bc3fe, 0xb974, 0x446d, - 0x94, - 0x49, - 0x5a, - 0xd5, - 0x41, - 0x2e, - 0x99, - 0x3b + { + 0x94, + 0x49, + 0x5a, + 0xd5, + 0x41, + 0x2e, + 0x99, + 0x3b + } }, NONE_FUNCTION_KEY_SETTING }, @@ -121,14 +123,16 @@ FUNCTIION_KEY_SETTING gFunctionKeySettingTable[] = { 0x3ebfa8e6, 0x511d, 0x4b5b, - 0xa9, - 0x5f, - 0xfb, - 0x38, - 0x26, - 0xf, - 0x1c, - 0x27 + { + 0xa9, + 0x5f, + 0xfb, + 0x38, + 0x26, + 0xf, + 0x1c, + 0x27 + } }, NONE_FUNCTION_KEY_SETTING }, @@ -140,14 +144,16 @@ FUNCTIION_KEY_SETTING gFunctionKeySettingTable[] = { 0x642237c7, 0x35d4, 0x472d, - 0x83, - 0x65, - 0x12, - 0xe0, - 0xcc, - 0xf2, - 0x7a, - 0x22 + { + 0x83, + 0x65, + 0x12, + 0xe0, + 0xcc, + 0xf2, + 0x7a, + 0x22 + } }, NONE_FUNCTION_KEY_SETTING }, @@ -159,21 +165,21 @@ FUNCTIION_KEY_SETTING gFunctionKeySettingTable[] = { 0x1f2d63e1, 0xfebd, 0x4dc7, - 0x9c, - 0xc5, - 0xba, - 0x2b, - 0x1c, - 0xef, - 0x9c, - 0x5b + { + 0x9c, + 0xc5, + 0xba, + 0x2b, + 0x1c, + 0xef, + 0x9c, + 0x5b + } }, NONE_FUNCTION_KEY_SETTING }, }; -//@MT: EFI_DRIVER_ENTRY_POINT (InitializeSetup) - EFI_STATUS EFIAPI SendForm ( @@ -536,8 +542,6 @@ InitializeSetup ( EFI_HANDLE HiiDriverHandle; EFI_HII_PACKAGE_LIST_HEADER *PackageList; - //@MT: EfiInitializeDriverLib (ImageHandle, SystemTable); - // // Locate required Hii relative protocols // @@ -1171,7 +1175,7 @@ GetQuestionValue ( if (IsString) { StrCpy ((CHAR16 *) Dst, Value); } else { - Status = R8_HexStringToBuf (Dst, &StorageWidth, Value, NULL); + Status = HexStringToBuf (Dst, &StorageWidth, Value, NULL); } gBS->FreePool (Value); @@ -1237,7 +1241,7 @@ GetQuestionValue ( if (!IsBufferStorage && IsString) { StrCpy ((CHAR16 *) Dst, Value); } else { - Status = R8_HexStringToBuf (Dst, &StorageWidth, Value, NULL); + Status = HexStringToBuf (Dst, &StorageWidth, Value, NULL); if (EFI_ERROR (Status)) { gBS->FreePool (Result); return Status; @@ -1410,7 +1414,7 @@ SetQuestionValue ( BufferLen = (StorageWidth * 2 + 1) * sizeof (CHAR16); Value = AllocateZeroPool (BufferLen); ASSERT (Value != NULL); - R8_BufToHexString (Value, &BufferLen, Src, StorageWidth); + BufToHexString (Value, &BufferLen, Src, StorageWidth); } Status = SetValueByName (Storage, Question->VariableName, Value); @@ -1450,7 +1454,7 @@ SetQuestionValue ( StrCpy (Value, (CHAR16 *) Src); } else { BufferLen = (StorageWidth * 2 + 1) * sizeof (CHAR16); - R8_BufToHexString (Value, &BufferLen, Src, StorageWidth); + BufToHexString (Value, &BufferLen, Src, StorageWidth); } // diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h index 647c4488fc..80a9d299a3 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Setup.h @@ -54,23 +54,8 @@ Revision History #include <Library/HiiLib.h> #include <Library/ExtendedHiiLib.h> -#include "R8Lib.h" - #include "Colors.h" -//@MT:#include EFI_PROTOCOL_DEFINITION (HiiDatabase) -//@MT:#include EFI_PROTOCOL_DEFINITION (HiiString) -//@MT:#include EFI_PROTOCOL_DEFINITION (HiiConfigRouting) -//@MT:#include EFI_PROTOCOL_DEFINITION (HiiConfigAccess) -//@MT:#include EFI_PROTOCOL_DEFINITION (FormBrowser2) - -//@MT:#include EFI_GUID_DEFINITION (GlobalVariable) -//@MT:#include EFI_PROTOCOL_DEFINITION (DevicePath) -//@MT:#include EFI_PROTOCOL_DEFINITION (SimpleTextOut) -//@MT:#include EFI_PROTOCOL_DEFINITION (SimpleTextIn) -//@MT:#include EFI_PROTOCOL_DEFINITION (Print) -//@MT:#include EFI_PROTOCOL_DEFINITION (UnicodeCollation) - // // This is the generated header file which includes whatever needs to be exported (strings + IFR) // diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf b/MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf index b31b4ca5aa..842629d90e 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf +++ b/MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf @@ -45,8 +45,6 @@ ProcessOptions.c
Ui.c
Ui.h
- R8Lib.c
- R8Lib.h
Colors.h
@@ -81,3 +79,4 @@ [Depex]
gEfiHiiDatabaseProtocolGuid AND gEfiHiiConfigRoutingProtocolGuid
+
diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c index 06479c7409..064a8d9e33 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.c @@ -33,53 +33,97 @@ MENU_REFRESH_ENTRY *gMenuRefreshHead; // Search table for UiDisplayMenu() // SCAN_CODE_TO_SCREEN_OPERATION gScanCodeToOperation[] = { - SCAN_UP, - UiUp, - SCAN_DOWN, - UiDown, - SCAN_PAGE_UP, - UiPageUp, - SCAN_PAGE_DOWN, - UiPageDown, - SCAN_ESC, - UiReset, - SCAN_F2, - UiPrevious, - SCAN_LEFT, - UiLeft, - SCAN_RIGHT, - UiRight, - SCAN_F9, - UiDefault, - SCAN_F10, - UiSave + { + SCAN_UP, + UiUp, + }, + { + SCAN_DOWN, + UiDown, + }, + { + SCAN_PAGE_UP, + UiPageUp, + }, + { + SCAN_PAGE_DOWN, + UiPageDown, + }, + { + SCAN_ESC, + UiReset, + }, + { + SCAN_F2, + UiPrevious, + }, + { + SCAN_LEFT, + UiLeft, + }, + { + SCAN_RIGHT, + UiRight, + }, + { + SCAN_F9, + UiDefault, + }, + { + SCAN_F10, + UiSave + } }; SCREEN_OPERATION_T0_CONTROL_FLAG gScreenOperationToControlFlag[] = { - UiNoOperation, - CfUiNoOperation, - UiDefault, - CfUiDefault, - UiSelect, - CfUiSelect, - UiUp, - CfUiUp, - UiDown, - CfUiDown, - UiLeft, - CfUiLeft, - UiRight, - CfUiRight, - UiReset, - CfUiReset, - UiSave, - CfUiSave, - UiPrevious, - CfUiPrevious, - UiPageUp, - CfUiPageUp, - UiPageDown, - CfUiPageDown + { + UiNoOperation, + CfUiNoOperation, + }, + { + UiDefault, + CfUiDefault, + }, + { + UiSelect, + CfUiSelect, + }, + { + UiUp, + CfUiUp, + }, + { + UiDown, + CfUiDown, + }, + { + UiLeft, + CfUiLeft, + }, + { + UiRight, + CfUiRight, + }, + { + UiReset, + CfUiReset, + }, + { + UiSave, + CfUiSave, + }, + { + UiPrevious, + CfUiPrevious, + }, + { + UiPageUp, + CfUiPageUp, + }, + { + UiPageDown, + CfUiPageDown + } }; diff --git a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.h b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.h index a5b7076be6..e402248204 100644 --- a/MdeModulePkg/Universal/SetupBrowserDxe/Ui.h +++ b/MdeModulePkg/Universal/SetupBrowserDxe/Ui.h @@ -25,11 +25,7 @@ Revision History #ifndef _UI_H #define _UI_H -//@MT:#include "Tiano.h" -//@MT:#include "EfiDriverLib.h" #include "Setup.h" -//@MT:#include "GraphicsLib.h" -//@MT:#include "EfiPrintLib.h" // // Globals |