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