]> git.proxmox.com Git - mirror_edk2.git/blob - DynamicTablesPkg/Include/Library/AcpiHelperLib.h
DynamicTablesPkg: Add AmlGetEisaIdFromString() to AcpiHelperLib
[mirror_edk2.git] / DynamicTablesPkg / Include / Library / AcpiHelperLib.h
1 /** @file
2
3 Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.<BR>
4
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6 **/
7
8 #ifndef ACPI_HELPER_LIB_H_
9 #define ACPI_HELPER_LIB_H_
10
11 /** Is a character upper case
12 */
13 #define IS_UPPER_CHAR(x) ((x >= 'A') && (x <= 'Z'))
14
15 /** Is a character a decimal digit
16 */
17 #define IS_DIGIT(x) ((x >= '0') && (x <= '9'))
18
19 /** Is a character an upper case hexadecimal digit
20 */
21 #define IS_UPPER_HEX(x) (((x >= 'A') && (x <= 'F')) || IS_DIGIT (x))
22
23 /** Convert a hex number to its ASCII code.
24
25 @param [in] Hex Hex number to convert.
26 Must be 0 <= x < 16.
27
28 @return The ASCII code corresponding to x.
29 -1 if error.
30 **/
31 UINT8
32 EFIAPI
33 AsciiFromHex (
34 IN UINT8 Hex
35 );
36
37 /** Convert an ASCII char representing an hexadecimal number
38 to its integer value.
39
40 @param [in] Char Char to convert.
41 Must be between '0'-'9' or 'A'-'F' or 'a'-'f'.
42
43 @return The corresponding integer (between 0-16).
44 -1 if error.
45 **/
46 UINT8
47 EFIAPI
48 HexFromAscii (
49 IN CHAR8 Char
50 );
51
52 /** Check if a HID is a valid PNP ID.
53
54 @param [in] Hid The Hid to validate.
55
56 @retval TRUE The Hid is a valid PNP ID.
57 @retval FALSE The Hid is not a valid PNP ID.
58 **/
59 BOOLEAN
60 IsValidPnpId (
61 IN CONST CHAR8 * Hid
62 );
63
64 /** Check if a HID is a valid ACPI ID.
65
66 @param [in] Hid The Hid to validate.
67
68 @retval TRUE The Hid is a valid ACPI ID.
69 @retval FALSE The Hid is not a valid ACPI ID.
70 **/
71 BOOLEAN
72 IsValidAcpiId (
73 IN CONST CHAR8 * Hid
74 );
75
76 /** Convert a EisaId string to its compressed UINT32 equivalent.
77
78 Cf. ACPI 6.4 specification, s19.3.4 "ASL Macros": "Eisaid"
79
80 @param [in] EisaIdStr Input EisaId string.
81 @param [out] EisaIdInt Output EisaId UINT32 (compressed).
82
83 @retval EFI_SUCCESS The function completed successfully.
84 @retval EFI_INVALID_PARAMETER Invalid parameter.
85 **/
86 EFI_STATUS
87 EFIAPI
88 AmlGetEisaIdFromString (
89 IN CONST CHAR8 * EisaIdStr,
90 OUT UINT32 * EisaIdInt
91 );
92
93 #endif // ACPI_HELPER_LIB_H_