mirror of https://github.com/acidanthera/audk.git
DynamicTablesPkg: Add AsciiFromHex helper function
AsciiFromHex is a function converts a hex number to an ASCII character. This function is used across multiple generators, so add it to the TableHelperLib. Signed-off-by: Pierre Gondois <pierre.gondois@arm.com> Signed-off-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
This commit is contained in:
parent
095db69d4c
commit
f2bd39fb60
|
@ -1,6 +1,6 @@
|
||||||
/** @file
|
/** @file
|
||||||
|
|
||||||
Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
|
Copyright (c) 2017 - 2020, Arm Limited. All rights reserved.<BR>
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
|
|
||||||
|
@ -107,4 +107,17 @@ FindDuplicateValue (
|
||||||
IN PFN_IS_EQUAL EqualTestFunction
|
IN PFN_IS_EQUAL EqualTestFunction
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/** Convert a hex number to its ASCII code.
|
||||||
|
|
||||||
|
@param [in] x Hex number to convert.
|
||||||
|
Must be 0 <= x < 16.
|
||||||
|
|
||||||
|
@return The ASCII code corresponding to x.
|
||||||
|
**/
|
||||||
|
UINT8
|
||||||
|
EFIAPI
|
||||||
|
AsciiFromHex (
|
||||||
|
IN UINT8 x
|
||||||
|
);
|
||||||
|
|
||||||
#endif // TABLE_HELPER_LIB_H_
|
#endif // TABLE_HELPER_LIB_H_
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
/** @file
|
/** @file
|
||||||
Table Helper
|
Table Helper
|
||||||
|
|
||||||
Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
|
Copyright (c) 2017 - 2020, Arm Limited. All rights reserved.<BR>
|
||||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
||||||
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#include <Protocol/AcpiTable.h>
|
#include <Protocol/AcpiTable.h>
|
||||||
|
@ -244,3 +245,28 @@ FindDuplicateValue (
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Convert a hex number to its ASCII code.
|
||||||
|
|
||||||
|
@param [in] x Hex number to convert.
|
||||||
|
Must be 0 <= x < 16.
|
||||||
|
|
||||||
|
@return The ASCII code corresponding to x.
|
||||||
|
**/
|
||||||
|
UINT8
|
||||||
|
EFIAPI
|
||||||
|
AsciiFromHex (
|
||||||
|
IN UINT8 x
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (x < 10) {
|
||||||
|
return (UINT8)(x + '0');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (x < 16) {
|
||||||
|
return (UINT8)(x - 10 + 'A');
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT (FALSE);
|
||||||
|
return (UINT8)0;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue