mirror of https://github.com/acidanthera/audk.git
DynamicTablesPkg: Add HexFromAscii() to AcpiHelperLib
Add HexFromAscii(), converting an hexadecimal ascii char to an integer. Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com>
This commit is contained in:
parent
1ad5182500
commit
653113412f
|
@ -34,6 +34,21 @@ AsciiFromHex (
|
|||
IN UINT8 Hex
|
||||
);
|
||||
|
||||
/** Convert an ASCII char representing an hexadecimal number
|
||||
to its integer value.
|
||||
|
||||
@param [in] Char Char to convert.
|
||||
Must be between '0'-'9' or 'A'-'F' or 'a'-'f'.
|
||||
|
||||
@return The corresponding integer (between 0-16).
|
||||
-1 if error.
|
||||
**/
|
||||
UINT8
|
||||
EFIAPI
|
||||
HexFromAscii (
|
||||
IN CHAR8 Char
|
||||
);
|
||||
|
||||
/** Check if a HID is a valid PNP ID.
|
||||
|
||||
@param [in] Hid The Hid to validate.
|
||||
|
|
|
@ -38,6 +38,37 @@ AsciiFromHex (
|
|||
return (UINT8)-1;
|
||||
}
|
||||
|
||||
/** Convert an ASCII char representing an hexadecimal number
|
||||
to its integer value.
|
||||
|
||||
@param [in] Char Char to convert.
|
||||
Must be between '0'-'9' or 'A'-'F' or 'a'-'f'.
|
||||
|
||||
@return The corresponding integer (between 0-16).
|
||||
-1 if error.
|
||||
**/
|
||||
UINT8
|
||||
EFIAPI
|
||||
HexFromAscii (
|
||||
IN CHAR8 Char
|
||||
)
|
||||
{
|
||||
if ((Char >= '0') && (Char <= '9')) {
|
||||
return (UINT8)(Char - '0');
|
||||
}
|
||||
|
||||
if ((Char >= 'A') && (Char <= 'F')) {
|
||||
return (UINT8)(Char - 'A' + 10);
|
||||
}
|
||||
|
||||
if ((Char >= 'a') && (Char <= 'f')) {
|
||||
return (UINT8)(Char - 'a' + 10);
|
||||
}
|
||||
|
||||
ASSERT (FALSE);
|
||||
return (UINT8)-1;
|
||||
}
|
||||
|
||||
/** Check if a HID is a valid PNP ID.
|
||||
|
||||
@param [in] Hid The Hid to validate.
|
||||
|
|
Loading…
Reference in New Issue