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
This commit is contained in:
qwang12
2008-05-23 05:30:08 +00:00
parent d9e5c1fffb
commit 36fe40c2ea
21 changed files with 146 additions and 974 deletions

View File

@ -84,33 +84,6 @@ IP4_ADDR mIp4AllMasks[IP4_MASK_NUM] = {
EFI_IPv4_ADDRESS mZeroIp4Addr = {{0, 0, 0, 0}}; EFI_IPv4_ADDRESS mZeroIp4Addr = {{0, 0, 0, 0}};
/**
Converts the low nibble of a byte to hex unicode character.
@param Nibble lower nibble of a byte.
@return Hex unicode character.
**/
CHAR16
NibbleToHexChar (
IN UINT8 Nibble
)
{
//
// Porting Guide:
// This library interface is simply obsolete.
// Include the source code to user code.
//
Nibble &= 0x0F;
if (Nibble <= 0x9) {
return (CHAR16)(Nibble + L'0');
}
return (CHAR16)(Nibble - 0xA + L'A');
}
/** /**
Return the length of the mask. If the mask is invalid, Return the length of the mask. If the mask is invalid,
return the invalid length 33, which is IP4_MASK_NUM. return the invalid length 33, which is IP4_MASK_NUM.

View File

@ -37,9 +37,6 @@
Form.c Form.c
LibraryInternal.h LibraryInternal.h
IfrOpCodeCreation.c IfrOpCodeCreation.c
R8Lib.h
R8Lib.c
[Packages] [Packages]
MdePkg/MdePkg.dec MdePkg/MdePkg.dec

View File

@ -33,6 +33,4 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <MdeModuleHii.h> #include <MdeModuleHii.h>
#include "R8Lib.h"
#endif #endif

View File

@ -271,134 +271,6 @@ GetNextDeviceNodeStr (
return ReturnStr; 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 STATIC
CHAR16 * CHAR16 *

View File

@ -563,7 +563,6 @@ DriverSampleInit (
// //
// Initialize the library and our protocol. // Initialize the library and our protocol.
// //
//@MT: EfiInitializeDriverLib (ImageHandle, SystemTable);
// //
// Initialize screen dimensions for SendForm(). // Initialize screen dimensions for SendForm().

View File

@ -1,6 +1,6 @@
/** @file /** @file
Copyright (c) 2007, Intel Corporation Copyright (c) 2007 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 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. // 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) { if (HexCnt == 0) {
*Len = 0; *Len = 0;
@ -115,7 +115,7 @@ HexStringToBufPrivate (
for (Idx = 0; Idx < HexCnt; Idx++) { 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, // For odd charaters, write the lower nibble for each buffer byte,
@ -765,7 +765,7 @@ GetValueOfNumber (
goto Exit; goto Exit;
} }
Status = R8_HexStringToBuf (Buf, &Length, Str, NULL); Status = HexStringToBuf (Buf, &Length, Str, NULL);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
goto Exit; goto Exit;
} }
@ -1607,7 +1607,7 @@ HiiBlockToConfig (
goto Exit; goto Exit;
} }
Status = R8_BufToHexString (ValueStr, &Length, Value, Width); Status = BufToHexString (ValueStr, &Length, Value, Width);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
SafeFreePool (Value); SafeFreePool (Value);
Value = NULL; Value = NULL;
@ -2114,3 +2114,4 @@ Exit:
} }

View File

@ -104,8 +104,6 @@ STATIC HII_DATABASE_PRIVATE_DATA mPrivate = {
NULL NULL
}; };
//@MT: EFI_DRIVER_ENTRY_POINT (InitializeHiiDatabase)
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
InitializeHiiDatabase ( InitializeHiiDatabase (
@ -131,8 +129,6 @@ Returns:
EFI_HANDLE *HandleBuffer; EFI_HANDLE *HandleBuffer;
UINTN HandleCount; UINTN HandleCount;
//@MT: EfiInitializeDriverLib (ImageHandle, SystemTable);
// //
// There will be only one HII Database in the system // There will be only one HII Database in the system
// If there is another out there, someone is trying to install us // If there is another out there, someone is trying to install us

View File

@ -1,5 +1,5 @@
/**@file /**@file
Copyright (c) 2007, Intel Corporation Copyright (c) 2007 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License are licensed and made available under the terms and conditions of the BSD License
@ -15,31 +15,6 @@
#include "HiiDatabase.h" #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. 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;
}

View File

@ -1,5 +1,5 @@
/**@file /**@file
Copyright (c) 2007, Intel Corporation Copyright (c) 2007 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 #endif

View File

@ -24,44 +24,6 @@ Abstract:
STATIC CONST CHAR8 IScsiHexString[] = "0123456789ABCDEFabcdef"; 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. Removes (trims) specified leading and trailing characters from a string.

View File

@ -647,7 +647,7 @@ IfrToUint (
// Hex string // Hex string
// //
BufferSize = sizeof (UINT64); 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 { } else {
// //
// BUGBUG: Need handle decimal string // BUGBUG: Need handle decimal string

View File

@ -21,7 +21,6 @@ Abstract:
#include "Setup.h" #include "Setup.h"
#include "Ui.h" #include "Ui.h"
//@MT:#include "EfiPrintLib.h"
UINT16 mStatementIndex; UINT16 mStatementIndex;
UINT16 mExpressionOpCodeIndex; UINT16 mExpressionOpCodeIndex;

View File

@ -612,7 +612,7 @@ EnterCarriageReturn:
default: default:
if (ManualInput) { if (ManualInput) {
if (HexInput) { if (HexInput) {
if (!R8_IsHexDigit (&Digital, Key.UnicodeChar)) { if (!IsHexDigit (&Digital, Key.UnicodeChar)) {
UpdateStatusBar (INPUT_ERROR, Question->QuestionFlags, TRUE); UpdateStatusBar (INPUT_ERROR, Question->QuestionFlags, TRUE);
break; break;
} }

View File

@ -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" #include "Setup.h"
UINTN UINTN

View File

@ -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;
}

View File

@ -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
)
;

View File

@ -88,9 +88,9 @@ CHAR16 gPromptBlockWidth;
CHAR16 gOptionBlockWidth; CHAR16 gOptionBlockWidth;
CHAR16 gHelpBlockWidth; 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 = { 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[] = { FUNCTIION_KEY_SETTING gFunctionKeySettingTable[] = {
@ -102,14 +102,16 @@ FUNCTIION_KEY_SETTING gFunctionKeySettingTable[] = {
0x847bc3fe, 0x847bc3fe,
0xb974, 0xb974,
0x446d, 0x446d,
0x94, {
0x49, 0x94,
0x5a, 0x49,
0xd5, 0x5a,
0x41, 0xd5,
0x2e, 0x41,
0x99, 0x2e,
0x3b 0x99,
0x3b
}
}, },
NONE_FUNCTION_KEY_SETTING NONE_FUNCTION_KEY_SETTING
}, },
@ -121,14 +123,16 @@ FUNCTIION_KEY_SETTING gFunctionKeySettingTable[] = {
0x3ebfa8e6, 0x3ebfa8e6,
0x511d, 0x511d,
0x4b5b, 0x4b5b,
0xa9, {
0x5f, 0xa9,
0xfb, 0x5f,
0x38, 0xfb,
0x26, 0x38,
0xf, 0x26,
0x1c, 0xf,
0x27 0x1c,
0x27
}
}, },
NONE_FUNCTION_KEY_SETTING NONE_FUNCTION_KEY_SETTING
}, },
@ -140,14 +144,16 @@ FUNCTIION_KEY_SETTING gFunctionKeySettingTable[] = {
0x642237c7, 0x642237c7,
0x35d4, 0x35d4,
0x472d, 0x472d,
0x83, {
0x65, 0x83,
0x12, 0x65,
0xe0, 0x12,
0xcc, 0xe0,
0xf2, 0xcc,
0x7a, 0xf2,
0x22 0x7a,
0x22
}
}, },
NONE_FUNCTION_KEY_SETTING NONE_FUNCTION_KEY_SETTING
}, },
@ -159,21 +165,21 @@ FUNCTIION_KEY_SETTING gFunctionKeySettingTable[] = {
0x1f2d63e1, 0x1f2d63e1,
0xfebd, 0xfebd,
0x4dc7, 0x4dc7,
0x9c, {
0xc5, 0x9c,
0xba, 0xc5,
0x2b, 0xba,
0x1c, 0x2b,
0xef, 0x1c,
0x9c, 0xef,
0x5b 0x9c,
0x5b
}
}, },
NONE_FUNCTION_KEY_SETTING NONE_FUNCTION_KEY_SETTING
}, },
}; };
//@MT: EFI_DRIVER_ENTRY_POINT (InitializeSetup)
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
SendForm ( SendForm (
@ -536,8 +542,6 @@ InitializeSetup (
EFI_HANDLE HiiDriverHandle; EFI_HANDLE HiiDriverHandle;
EFI_HII_PACKAGE_LIST_HEADER *PackageList; EFI_HII_PACKAGE_LIST_HEADER *PackageList;
//@MT: EfiInitializeDriverLib (ImageHandle, SystemTable);
// //
// Locate required Hii relative protocols // Locate required Hii relative protocols
// //
@ -1171,7 +1175,7 @@ GetQuestionValue (
if (IsString) { if (IsString) {
StrCpy ((CHAR16 *) Dst, Value); StrCpy ((CHAR16 *) Dst, Value);
} else { } else {
Status = R8_HexStringToBuf (Dst, &StorageWidth, Value, NULL); Status = HexStringToBuf (Dst, &StorageWidth, Value, NULL);
} }
gBS->FreePool (Value); gBS->FreePool (Value);
@ -1237,7 +1241,7 @@ GetQuestionValue (
if (!IsBufferStorage && IsString) { if (!IsBufferStorage && IsString) {
StrCpy ((CHAR16 *) Dst, Value); StrCpy ((CHAR16 *) Dst, Value);
} else { } else {
Status = R8_HexStringToBuf (Dst, &StorageWidth, Value, NULL); Status = HexStringToBuf (Dst, &StorageWidth, Value, NULL);
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status)) {
gBS->FreePool (Result); gBS->FreePool (Result);
return Status; return Status;
@ -1410,7 +1414,7 @@ SetQuestionValue (
BufferLen = (StorageWidth * 2 + 1) * sizeof (CHAR16); BufferLen = (StorageWidth * 2 + 1) * sizeof (CHAR16);
Value = AllocateZeroPool (BufferLen); Value = AllocateZeroPool (BufferLen);
ASSERT (Value != NULL); ASSERT (Value != NULL);
R8_BufToHexString (Value, &BufferLen, Src, StorageWidth); BufToHexString (Value, &BufferLen, Src, StorageWidth);
} }
Status = SetValueByName (Storage, Question->VariableName, Value); Status = SetValueByName (Storage, Question->VariableName, Value);
@ -1450,7 +1454,7 @@ SetQuestionValue (
StrCpy (Value, (CHAR16 *) Src); StrCpy (Value, (CHAR16 *) Src);
} else { } else {
BufferLen = (StorageWidth * 2 + 1) * sizeof (CHAR16); BufferLen = (StorageWidth * 2 + 1) * sizeof (CHAR16);
R8_BufToHexString (Value, &BufferLen, Src, StorageWidth); BufToHexString (Value, &BufferLen, Src, StorageWidth);
} }
// //

View File

@ -54,23 +54,8 @@ Revision History
#include <Library/HiiLib.h> #include <Library/HiiLib.h>
#include <Library/ExtendedHiiLib.h> #include <Library/ExtendedHiiLib.h>
#include "R8Lib.h"
#include "Colors.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) // This is the generated header file which includes whatever needs to be exported (strings + IFR)
// //

View File

@ -45,8 +45,6 @@
ProcessOptions.c ProcessOptions.c
Ui.c Ui.c
Ui.h Ui.h
R8Lib.c
R8Lib.h
Colors.h Colors.h
@ -81,3 +79,4 @@
[Depex] [Depex]
gEfiHiiDatabaseProtocolGuid AND gEfiHiiConfigRoutingProtocolGuid gEfiHiiDatabaseProtocolGuid AND gEfiHiiConfigRoutingProtocolGuid

View File

@ -33,53 +33,97 @@ MENU_REFRESH_ENTRY *gMenuRefreshHead;
// Search table for UiDisplayMenu() // Search table for UiDisplayMenu()
// //
SCAN_CODE_TO_SCREEN_OPERATION gScanCodeToOperation[] = { SCAN_CODE_TO_SCREEN_OPERATION gScanCodeToOperation[] = {
SCAN_UP, {
UiUp, SCAN_UP,
SCAN_DOWN, UiUp,
UiDown, },
SCAN_PAGE_UP, {
UiPageUp, SCAN_DOWN,
SCAN_PAGE_DOWN, UiDown,
UiPageDown, },
SCAN_ESC, {
UiReset, SCAN_PAGE_UP,
SCAN_F2, UiPageUp,
UiPrevious, },
SCAN_LEFT, {
UiLeft, SCAN_PAGE_DOWN,
SCAN_RIGHT, UiPageDown,
UiRight, },
SCAN_F9, {
UiDefault, SCAN_ESC,
SCAN_F10, UiReset,
UiSave },
{
SCAN_F2,
UiPrevious,
},
{
SCAN_LEFT,
UiLeft,
},
{
SCAN_RIGHT,
UiRight,
},
{
SCAN_F9,
UiDefault,
},
{
SCAN_F10,
UiSave
}
}; };
SCREEN_OPERATION_T0_CONTROL_FLAG gScreenOperationToControlFlag[] = { SCREEN_OPERATION_T0_CONTROL_FLAG gScreenOperationToControlFlag[] = {
UiNoOperation, {
CfUiNoOperation, UiNoOperation,
UiDefault, CfUiNoOperation,
CfUiDefault, },
UiSelect, {
CfUiSelect, UiDefault,
UiUp, CfUiDefault,
CfUiUp, },
UiDown, {
CfUiDown, UiSelect,
UiLeft, CfUiSelect,
CfUiLeft, },
UiRight, {
CfUiRight, UiUp,
UiReset, CfUiUp,
CfUiReset, },
UiSave, {
CfUiSave, UiDown,
UiPrevious, CfUiDown,
CfUiPrevious, },
UiPageUp, {
CfUiPageUp, UiLeft,
UiPageDown, CfUiLeft,
CfUiPageDown },
{
UiRight,
CfUiRight,
},
{
UiReset,
CfUiReset,
},
{
UiSave,
CfUiSave,
},
{
UiPrevious,
CfUiPrevious,
},
{
UiPageUp,
CfUiPageUp,
},
{
UiPageDown,
CfUiPageDown
}
}; };

View File

@ -25,11 +25,7 @@ Revision History
#ifndef _UI_H #ifndef _UI_H
#define _UI_H #define _UI_H
//@MT:#include "Tiano.h"
//@MT:#include "EfiDriverLib.h"
#include "Setup.h" #include "Setup.h"
//@MT:#include "GraphicsLib.h"
//@MT:#include "EfiPrintLib.h"
// //
// Globals // Globals