summaryrefslogtreecommitdiff
path: root/DynamicTablesPkg/Library/Common/TableHelperLib
diff options
context:
space:
mode:
authorSami Mujawar <sami.mujawar@arm.com>2020-08-05 16:36:56 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-08-13 18:00:06 +0000
commitf2bd39fb606f0c3e5a8f7998fa215ba4d6e25687 (patch)
tree4dc2574210e6a3707d9b52a724be847af3552d73 /DynamicTablesPkg/Library/Common/TableHelperLib
parent095db69d4c156eb4f81307d471339a60ca0a9a09 (diff)
downloadedk2-f2bd39fb606f0c3e5a8f7998fa215ba4d6e25687.zip
edk2-f2bd39fb606f0c3e5a8f7998fa215ba4d6e25687.tar.gz
edk2-f2bd39fb606f0c3e5a8f7998fa215ba4d6e25687.tar.bz2
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>
Diffstat (limited to 'DynamicTablesPkg/Library/Common/TableHelperLib')
-rw-r--r--DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c
index fc6cf3b..0d9daad 100644
--- a/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c
+++ b/DynamicTablesPkg/Library/Common/TableHelperLib/TableHelper.c
@@ -1,8 +1,9 @@
/** @file
Table Helper
-Copyright (c) 2017 - 2019, ARM Limited. All rights reserved.
-SPDX-License-Identifier: BSD-2-Clause-Patent
+ Copyright (c) 2017 - 2020, Arm Limited. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <Protocol/AcpiTable.h>
@@ -244,3 +245,28 @@ FindDuplicateValue (
}
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;
+}