]>
git.proxmox.com Git - mirror_edk2.git/blob - DynamicTablesPkg/Library/Common/AcpiHelperLib/AcpiHelper.c
4 Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include <Library/BaseLib.h>
10 #include <Library/DebugLib.h>
12 // Module specific include files.
13 #include <Library/AcpiHelperLib.h>
15 /** Convert a hex number to its ASCII code.
17 @param [in] x Hex number to convert.
20 @return The ASCII code corresponding to x.
29 return (UINT8
)(x
+ '0');
33 return (UINT8
)(x
- 10 + 'A');
40 /** Check if a HID is a valid PNP ID.
42 @param [in] Hid The Hid to validate.
44 @retval TRUE The Hid is a valid PNP ID.
45 @retval FALSE The Hid is not a valid PNP ID.
54 if (AsciiStrLen (Hid
) != 7) {
58 // A valid PNP ID must be of the form "AAA####"
59 // where A is an uppercase letter and # is a hex digit.
60 for (Index
= 0; Index
< 3; Index
++) {
61 if (!IS_UPPER_CHAR (Hid
[Index
])) {
66 for (Index
= 3; Index
< 7; Index
++) {
67 if (!IS_UPPER_HEX (Hid
[Index
])) {
75 /** Check if a HID is a valid ACPI ID.
77 @param [in] Hid The Hid to validate.
79 @retval TRUE The Hid is a valid ACPI ID.
80 @retval FALSE The Hid is not a valid ACPI ID.
89 if (AsciiStrLen (Hid
) != 8) {
93 // A valid ACPI ID must be of the form "NNNN####"
94 // where N is an uppercase letter or a digit ('0'-'9')
95 // and # is a hex digit.
96 for (Index
= 0; Index
< 4; Index
++) {
97 if (!(IS_UPPER_CHAR (Hid
[Index
]) || IS_DIGIT (Hid
[Index
]))) {
102 for (Index
= 4; Index
< 8; Index
++) {
103 if (!IS_UPPER_HEX (Hid
[Index
])) {