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 |
|
---|
69 | Index++;
|
---|
70 | }
|
---|
71 |
|
---|
72 | return *(UINT32 *)Ptr;
|
---|
73 | }
|
---|
74 |
|
---|
75 | /**
|
---|
76 | This function selects an ACPI table in current context.
|
---|
77 | The string name of the table is converted into UINT32
|
---|
78 | table signature.
|
---|
79 |
|
---|
80 | @param [in] TableName The name of the ACPI table to select.
|
---|
81 | **/
|
---|
82 | VOID
|
---|
83 | EFIAPI
|
---|
84 | SelectAcpiTable (
|
---|
85 | IN CONST CHAR16 *TableName
|
---|
86 | )
|
---|
87 | {
|
---|
88 | ASSERT (TableName != NULL);
|
---|
89 |
|
---|
90 | mSelectedAcpiTable.Name = TableName;
|
---|
91 | mSelectedAcpiTable.Type = ConvertStrToAcpiSignature (mSelectedAcpiTable.Name);
|
---|
92 | }
|
---|
93 |
|
---|
94 | /**
|
---|
95 | This function returns the selected ACPI table.
|
---|
96 |
|
---|
97 | @param [out] SelectedAcpiTable Pointer that will contain the returned struct.
|
---|
98 | **/
|
---|
99 | VOID
|
---|
100 | EFIAPI
|
---|
101 | GetSelectedAcpiTable (
|
---|
102 | OUT SELECTED_ACPI_TABLE **SelectedAcpiTable
|
---|
103 | )
|
---|
104 | {
|
---|
105 | *SelectedAcpiTable = &mSelectedAcpiTable;
|
---|
106 | }
|
---|
107 |
|
---|
108 | /**
|
---|
109 | This function returns the colour highlighting status.
|
---|
110 |
|
---|
111 | @retval TRUE Colour highlighting is enabled.
|
---|
112 | **/
|
---|
113 | BOOLEAN
|
---|
114 | EFIAPI
|
---|
115 | GetColourHighlighting (
|
---|
116 | VOID
|
---|
117 | )
|
---|
118 | {
|
---|
119 | return mColourHighlighting;
|
---|
120 | }
|
---|
121 |
|
---|
122 | /**
|
---|
123 | This function sets the colour highlighting status.
|
---|
124 |
|
---|
125 | @param [in] Highlight The highlight status.
|
---|
126 | **/
|
---|
127 | VOID
|
---|
128 | EFIAPI
|
---|
129 | SetColourHighlighting (
|
---|
130 | BOOLEAN Highlight
|
---|
131 | )
|
---|
132 | {
|
---|
133 | mColourHighlighting = Highlight;
|
---|
134 | }
|
---|
135 |
|
---|
136 | /**
|
---|
137 | This function returns the consistency checking status.
|
---|
138 |
|
---|
139 | @retval TRUE Consistency checking is enabled.
|
---|
140 | **/
|
---|
141 | BOOLEAN
|
---|
142 | EFIAPI
|
---|
143 | GetConsistencyChecking (
|
---|
144 | VOID
|
---|
145 | )
|
---|
146 | {
|
---|
147 | return mConsistencyCheck;
|
---|
148 | }
|
---|
149 |
|
---|
150 | /**
|
---|
151 | This function sets the consistency checking status.
|
---|
152 |
|
---|
153 | @param [in] ConsistencyChecking The consistency checking status.
|
---|
154 | **/
|
---|
155 | VOID
|
---|
156 | EFIAPI
|
---|
157 | SetConsistencyChecking (
|
---|
158 | BOOLEAN ConsistencyChecking
|
---|
159 | )
|
---|
160 | {
|
---|
161 | mConsistencyCheck = ConsistencyChecking;
|
---|
162 | }
|
---|
163 |
|
---|
164 | /**
|
---|
165 | This function returns the report options.
|
---|
166 |
|
---|
167 | @return The current report option.
|
---|
168 | **/
|
---|
169 | EREPORT_OPTION
|
---|
170 | EFIAPI
|
---|
171 | GetReportOption (
|
---|
172 | VOID
|
---|
173 | )
|
---|
174 | {
|
---|
175 | return mReportType;
|
---|
176 | }
|
---|
177 |
|
---|
178 | /**
|
---|
179 | This function sets the report options.
|
---|
180 |
|
---|
181 | @param [in] ReportType The report option to set.
|
---|
182 | **/
|
---|
183 | VOID
|
---|
184 | EFIAPI
|
---|
185 | SetReportOption (
|
---|
186 | EREPORT_OPTION ReportType
|
---|
187 | )
|
---|
188 | {
|
---|
189 | mReportType = ReportType;
|
---|
190 | }
|
---|
191 |
|
---|
192 | /**
|
---|
193 | This function returns the ACPI table requirements validation flag.
|
---|
194 |
|
---|
195 | @retval TRUE Check for mandatory table presence should be performed.
|
---|
196 | **/
|
---|
197 | BOOLEAN
|
---|
198 | EFIAPI
|
---|
199 | GetMandatoryTableValidate (
|
---|
200 | VOID
|
---|
201 | )
|
---|
202 | {
|
---|
203 | return mMandatoryTableValidate;
|
---|
204 | }
|
---|
205 |
|
---|
206 | /**
|
---|
207 | This function sets the ACPI table requirements validation flag.
|
---|
208 |
|
---|
209 | @param [in] Validate Enable/Disable ACPI table requirements validation.
|
---|
210 | **/
|
---|
211 | VOID
|
---|
212 | EFIAPI
|
---|
213 | SetMandatoryTableValidate (
|
---|
214 | BOOLEAN Validate
|
---|
215 | )
|
---|
216 | {
|
---|
217 | mMandatoryTableValidate = Validate;
|
---|
218 | }
|
---|
219 |
|
---|
220 | /**
|
---|
221 | This function returns the identifier of specification to validate ACPI table
|
---|
222 | requirements against.
|
---|
223 |
|
---|
224 | @return ID of specification listing mandatory tables.
|
---|
225 | **/
|
---|
226 | UINTN
|
---|
227 | EFIAPI
|
---|
228 | GetMandatoryTableSpec (
|
---|
229 | VOID
|
---|
230 | )
|
---|
231 | {
|
---|
232 | return mMandatoryTableSpec;
|
---|
233 | }
|
---|
234 |
|
---|
235 | /**
|
---|
236 | This function sets the identifier of specification to validate ACPI table
|
---|
237 | requirements against.
|
---|
238 |
|
---|
239 | @param [in] Spec ID of specification listing mandatory tables.
|
---|
240 | **/
|
---|
241 | VOID
|
---|
242 | EFIAPI
|
---|
243 | SetMandatoryTableSpec (
|
---|
244 | UINTN Spec
|
---|
245 | )
|
---|
246 | {
|
---|
247 | mMandatoryTableSpec = Spec;
|
---|
248 | }
|
---|