1 | /** @file
|
---|
2 | State and accessors for 'acpiview' configuration.
|
---|
3 |
|
---|
4 | Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.<BR>
|
---|
5 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
6 | **/
|
---|
7 |
|
---|
8 | #include <Library/BaseMemoryLib.h>
|
---|
9 | #include <Library/DebugLib.h>
|
---|
10 |
|
---|
11 | #include "AcpiViewConfig.h"
|
---|
12 |
|
---|
13 | // Report variables
|
---|
14 | STATIC BOOLEAN mConsistencyCheck;
|
---|
15 | STATIC BOOLEAN mColourHighlighting;
|
---|
16 | STATIC EREPORT_OPTION mReportType;
|
---|
17 | STATIC BOOLEAN mMandatoryTableValidate;
|
---|
18 | STATIC UINTN mMandatoryTableSpec;
|
---|
19 |
|
---|
20 | // User selection of which ACPI table should be checked
|
---|
21 | SELECTED_ACPI_TABLE mSelectedAcpiTable;
|
---|
22 |
|
---|
23 | /**
|
---|
24 | Reset the AcpiView user configuration to defaults
|
---|
25 | **/
|
---|
26 | VOID
|
---|
27 | EFIAPI
|
---|
28 | AcpiConfigSetDefaults (
|
---|
29 | VOID
|
---|
30 | )
|
---|
31 | {
|
---|
32 | mReportType = ReportAll;
|
---|
33 | mSelectedAcpiTable.Type = 0;
|
---|
34 | mSelectedAcpiTable.Name = NULL;
|
---|
35 | mSelectedAcpiTable.Found = FALSE;
|
---|
36 | mConsistencyCheck = TRUE;
|
---|
37 | mMandatoryTableValidate = FALSE;
|
---|
38 | mMandatoryTableSpec = 0;
|
---|
39 | }
|
---|
40 |
|
---|
41 | /**
|
---|
42 | This function converts a string to ACPI table signature.
|
---|
43 |
|
---|
44 | @param [in] Str Pointer to the string to be converted to the
|
---|
45 | ACPI table signature.
|
---|
46 |
|
---|
47 | @retval The ACPI table signature.
|
---|
48 | **/
|
---|
49 | STATIC
|
---|
50 | UINT32
|
---|
51 | ConvertStrToAcpiSignature (
|
---|
52 | IN CONST CHAR16 *Str
|
---|
53 | )
|
---|
54 | {
|
---|
55 | UINT8 Index;
|
---|
56 | CHAR8 Ptr[4];
|
---|
57 |
|
---|
58 | ZeroMem (Ptr, sizeof (Ptr));
|
---|
59 | Index = 0;
|
---|
60 |
|
---|
61 | // Convert to Upper case and convert to ASCII
|
---|
62 | while ((Index < 4) && (Str[Index] != 0)) {
|
---|
63 | if (Str[Index] >= L'a' && Str[Index] <= L'z') {
|
---|
64 | Ptr[Index] = (CHAR8)(Str[Index] - (L'a' - L'A'));
|
---|
65 | } else {
|
---|
66 | Ptr[Index] = (CHAR8)Str[Index];
|
---|
67 | }
|
---|
68 | Index++;
|
---|
69 | }
|
---|
70 | return *(UINT32 *) Ptr;
|
---|
71 | }
|
---|
72 |
|
---|
73 | /**
|
---|
74 | This function selects an ACPI table in current context.
|
---|
75 | The string name of the table is converted into UINT32
|
---|
76 | table signature.
|
---|
77 |
|
---|
78 | @param [in] TableName The name of the ACPI table to select.
|
---|
79 | **/
|
---|
80 | VOID
|
---|
81 | EFIAPI
|
---|
82 | SelectAcpiTable (
|
---|
83 | IN CONST CHAR16 *TableName
|
---|
84 | )
|
---|
85 | {
|
---|
86 | ASSERT (TableName != NULL);
|
---|
87 |
|
---|
88 | mSelectedAcpiTable.Name = TableName;
|
---|
89 | mSelectedAcpiTable.Type = ConvertStrToAcpiSignature (mSelectedAcpiTable.Name);
|
---|
90 | }
|
---|
91 |
|
---|
92 | /**
|
---|
93 | This function returns the selected ACPI table.
|
---|
94 |
|
---|
95 | @param [out] SelectedAcpiTable Pointer that will contain the returned struct.
|
---|
96 | **/
|
---|
97 | VOID
|
---|
98 | EFIAPI
|
---|
99 | GetSelectedAcpiTable (
|
---|
100 | OUT SELECTED_ACPI_TABLE **SelectedAcpiTable
|
---|
101 | )
|
---|
102 | {
|
---|
103 | *SelectedAcpiTable = &mSelectedAcpiTable;
|
---|
104 | }
|
---|
105 |
|
---|
106 | /**
|
---|
107 | This function returns the colour highlighting status.
|
---|
108 |
|
---|
109 | @retval TRUE Colour highlighting is enabled.
|
---|
110 | **/
|
---|
111 | BOOLEAN
|
---|
112 | EFIAPI
|
---|
113 | GetColourHighlighting (
|
---|
114 | VOID
|
---|
115 | )
|
---|
116 | {
|
---|
117 | return mColourHighlighting;
|
---|
118 | }
|
---|
119 |
|
---|
120 | /**
|
---|
121 | This function sets the colour highlighting status.
|
---|
122 |
|
---|
123 | @param [in] Highlight The highlight status.
|
---|
124 | **/
|
---|
125 | VOID
|
---|
126 | EFIAPI
|
---|
127 | SetColourHighlighting (
|
---|
128 | BOOLEAN Highlight
|
---|
129 | )
|
---|
130 | {
|
---|
131 | mColourHighlighting = Highlight;
|
---|
132 | }
|
---|
133 |
|
---|
134 | /**
|
---|
135 | This function returns the consistency checking status.
|
---|
136 |
|
---|
137 | @retval TRUE Consistency checking is enabled.
|
---|
138 | **/
|
---|
139 | BOOLEAN
|
---|
140 | EFIAPI
|
---|
141 | GetConsistencyChecking (
|
---|
142 | VOID
|
---|
143 | )
|
---|
144 | {
|
---|
145 | return mConsistencyCheck;
|
---|
146 | }
|
---|
147 |
|
---|
148 | /**
|
---|
149 | This function sets the consistency checking status.
|
---|
150 |
|
---|
151 | @param [in] ConsistencyChecking The consistency checking status.
|
---|
152 | **/
|
---|
153 | VOID
|
---|
154 | EFIAPI
|
---|
155 | SetConsistencyChecking (
|
---|
156 | BOOLEAN ConsistencyChecking
|
---|
157 | )
|
---|
158 | {
|
---|
159 | mConsistencyCheck = ConsistencyChecking;
|
---|
160 | }
|
---|
161 |
|
---|
162 | /**
|
---|
163 | This function returns the report options.
|
---|
164 |
|
---|
165 | @return The current report option.
|
---|
166 | **/
|
---|
167 | EREPORT_OPTION
|
---|
168 | EFIAPI
|
---|
169 | GetReportOption (
|
---|
170 | VOID
|
---|
171 | )
|
---|
172 | {
|
---|
173 | return mReportType;
|
---|
174 | }
|
---|
175 |
|
---|
176 | /**
|
---|
177 | This function sets the report options.
|
---|
178 |
|
---|
179 | @param [in] ReportType The report option to set.
|
---|
180 | **/
|
---|
181 | VOID
|
---|
182 | EFIAPI
|
---|
183 | SetReportOption (
|
---|
184 | EREPORT_OPTION ReportType
|
---|
185 | )
|
---|
186 | {
|
---|
187 | mReportType = ReportType;
|
---|
188 | }
|
---|
189 |
|
---|
190 | /**
|
---|
191 | This function returns the ACPI table requirements validation flag.
|
---|
192 |
|
---|
193 | @retval TRUE Check for mandatory table presence should be performed.
|
---|
194 | **/
|
---|
195 | BOOLEAN
|
---|
196 | EFIAPI
|
---|
197 | GetMandatoryTableValidate (
|
---|
198 | VOID
|
---|
199 | )
|
---|
200 | {
|
---|
201 | return mMandatoryTableValidate;
|
---|
202 | }
|
---|
203 |
|
---|
204 | /**
|
---|
205 | This function sets the ACPI table requirements validation flag.
|
---|
206 |
|
---|
207 | @param [in] Validate Enable/Disable ACPI table requirements validation.
|
---|
208 | **/
|
---|
209 | VOID
|
---|
210 | EFIAPI
|
---|
211 | SetMandatoryTableValidate (
|
---|
212 | BOOLEAN Validate
|
---|
213 | )
|
---|
214 | {
|
---|
215 | mMandatoryTableValidate = Validate;
|
---|
216 | }
|
---|
217 |
|
---|
218 | /**
|
---|
219 | This function returns the identifier of specification to validate ACPI table
|
---|
220 | requirements against.
|
---|
221 |
|
---|
222 | @return ID of specification listing mandatory tables.
|
---|
223 | **/
|
---|
224 | UINTN
|
---|
225 | EFIAPI
|
---|
226 | GetMandatoryTableSpec (
|
---|
227 | VOID
|
---|
228 | )
|
---|
229 | {
|
---|
230 | return mMandatoryTableSpec;
|
---|
231 | }
|
---|
232 |
|
---|
233 | /**
|
---|
234 | This function sets the identifier of specification to validate ACPI table
|
---|
235 | requirements against.
|
---|
236 |
|
---|
237 | @param [in] Spec ID of specification listing mandatory tables.
|
---|
238 | **/
|
---|
239 | VOID
|
---|
240 | EFIAPI
|
---|
241 | SetMandatoryTableSpec (
|
---|
242 | UINTN Spec
|
---|
243 | )
|
---|
244 | {
|
---|
245 | mMandatoryTableSpec = Spec;
|
---|
246 | }
|
---|