TianoCore EDK2 master
Loading...
Searching...
No Matches
AcpiView.c
Go to the documentation of this file.
1
13#include <Library/PrintLib.h>
14#include <Library/UefiLib.h>
15#include <Library/ShellLib.h>
18#include <Library/DebugLib.h>
21#include "AcpiParser.h"
22#include "AcpiTableParser.h"
23#include "AcpiView.h"
24#include "AcpiViewConfig.h"
25
26#if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
27 #include "Arm/SbbrValidator.h"
28#endif
29
30STATIC UINT32 mTableCount;
31STATIC UINT32 mBinTableCount;
32
43BOOLEAN
45 IN CONST UINT8 *Ptr,
46 IN CONST UINTN Length
47 )
48{
49 CHAR16 FileNameBuffer[MAX_FILE_NAME_LEN];
50 UINTN TransferBytes;
51 SELECTED_ACPI_TABLE *SelectedTable;
52
53 GetSelectedAcpiTable (&SelectedTable);
54
56 FileNameBuffer,
57 sizeof (FileNameBuffer),
58 L".\\%s%04d.bin",
59 SelectedTable->Name,
60 mBinTableCount++
61 );
62
63 Print (L"Dumping ACPI table to : %s ... ", FileNameBuffer);
64
65 TransferBytes = ShellDumpBufferToFile (FileNameBuffer, Ptr, Length);
66 return (Length == TransferBytes);
67}
68
78BOOLEAN
80 IN CONST UINT32 Signature,
81 IN CONST UINT8 *TablePtr,
82 IN CONST UINT32 Length
83 )
84{
85 UINTN OriginalAttribute;
86 UINT8 *SignaturePtr;
87 BOOLEAN Log;
88 BOOLEAN HighLight;
89 SELECTED_ACPI_TABLE *SelectedTable;
90
91 //
92 // set local variables to suppress incorrect compiler/analyzer warnings
93 //
94 OriginalAttribute = 0;
95 SignaturePtr = (UINT8 *)(UINTN)&Signature;
96 Log = FALSE;
97 HighLight = GetColourHighlighting ();
98 GetSelectedAcpiTable (&SelectedTable);
99
100 switch (GetReportOption ()) {
101 case ReportAll:
102 Log = TRUE;
103 break;
104 case ReportSelected:
105 if (Signature == SelectedTable->Type) {
106 Log = TRUE;
107 SelectedTable->Found = TRUE;
108 }
109
110 break;
111 case ReportTableList:
112 if (mTableCount == 0) {
113 if (HighLight) {
114 OriginalAttribute = gST->ConOut->Mode->Attribute;
115 gST->ConOut->SetAttribute (
116 gST->ConOut,
117 EFI_TEXT_ATTR (
118 EFI_CYAN,
119 ((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)
120 )
121 );
122 }
123
124 Print (L"\nInstalled Table(s):\n");
125 if (HighLight) {
126 gST->ConOut->SetAttribute (gST->ConOut, OriginalAttribute);
127 }
128 }
129
130 Print (
131 L"\t%4d. %c%c%c%c\n",
132 ++mTableCount,
133 SignaturePtr[0],
134 SignaturePtr[1],
135 SignaturePtr[2],
136 SignaturePtr[3]
137 );
138 break;
140 if (Signature == SelectedTable->Type) {
141 SelectedTable->Found = TRUE;
142 DumpAcpiTableToFile (TablePtr, Length);
143 }
144
145 break;
146 case ReportMax:
147 // We should never be here.
148 // This case is only present to prevent compiler warning.
149 break;
150 } // switch
151
152 if (Log) {
153 if (HighLight) {
154 OriginalAttribute = gST->ConOut->Mode->Attribute;
155 gST->ConOut->SetAttribute (
156 gST->ConOut,
157 EFI_TEXT_ATTR (
158 EFI_LIGHTBLUE,
159 ((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)
160 )
161 );
162 }
163
164 Print (
165 L"\n\n --------------- %c%c%c%c Table --------------- \n\n",
166 SignaturePtr[0],
167 SignaturePtr[1],
168 SignaturePtr[2],
169 SignaturePtr[3]
170 );
171 if (HighLight) {
172 gST->ConOut->SetAttribute (gST->ConOut, OriginalAttribute);
173 }
174 }
175
176 return Log;
177}
178
190EFIAPI
192 IN EFI_SYSTEM_TABLE *SystemTable
193 )
194{
195 EFI_STATUS Status;
196 UINTN Index;
197 EFI_CONFIGURATION_TABLE *EfiConfigurationTable;
198 BOOLEAN FoundAcpiTable;
199 UINTN OriginalAttribute;
200 UINTN PrintAttribute;
201 EREPORT_OPTION ReportOption;
202 UINT8 *RsdpPtr;
203 UINT32 RsdpLength;
204 UINT8 RsdpRevision;
205 PARSE_ACPI_TABLE_PROC RsdpParserProc;
206 BOOLEAN Trace;
207 SELECTED_ACPI_TABLE *SelectedTable;
208
209 //
210 // set local variables to suppress incorrect compiler/analyzer warnings
211 //
212 EfiConfigurationTable = NULL;
213 OriginalAttribute = 0;
214
215 // Reset Table counts
216 mTableCount = 0;
217 mBinTableCount = 0;
218
219 // Reset The error/warning counters
222
223 // Retrieve the user selection of ACPI table to process
224 GetSelectedAcpiTable (&SelectedTable);
225
226 // Search the table for an entry that matches the ACPI Table Guid
227 FoundAcpiTable = FALSE;
228 for (Index = 0; Index < SystemTable->NumberOfTableEntries; Index++) {
229 if (CompareGuid (
230 &gEfiAcpiTableGuid,
231 &(SystemTable->ConfigurationTable[Index].VendorGuid)
232 ))
233 {
234 EfiConfigurationTable = &SystemTable->ConfigurationTable[Index];
235 FoundAcpiTable = TRUE;
236 break;
237 }
238 }
239
240 if (FoundAcpiTable) {
241 RsdpPtr = (UINT8 *)EfiConfigurationTable->VendorTable;
242
243 // The RSDP revision is 1 byte starting at offset 15
244 RsdpRevision = *(RsdpPtr + RSDP_REVISION_OFFSET);
245
246 if (RsdpRevision < 2) {
247 Print (
248 L"ERROR: RSDP version less than 2 is not supported.\n"
249 );
250 return EFI_UNSUPPORTED;
251 }
252
253 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
256 }
257
258 #endif
259
260 // The RSDP length is 4 bytes starting at offset 20
261 RsdpLength = *(UINT32 *)(RsdpPtr + RSDP_LENGTH_OFFSET);
262
263 Trace = ProcessTableReportOptions (RSDP_TABLE_INFO, RsdpPtr, RsdpLength);
264
265 Status = GetParser (RSDP_TABLE_INFO, &RsdpParserProc);
266 if (EFI_ERROR (Status)) {
267 Print (
268 L"ERROR: No registered parser found for RSDP.\n"
269 );
270 return Status;
271 }
272
273 RsdpParserProc (
274 Trace,
275 RsdpPtr,
276 RsdpLength,
277 RsdpRevision
278 );
279 } else {
281 Print (
282 L"ERROR: Failed to find ACPI Table Guid in System Configuration Table.\n"
283 );
284 return EFI_NOT_FOUND;
285 }
286
287 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
290 }
291
292 #endif
293
294 ReportOption = GetReportOption ();
295 if (ReportTableList != ReportOption) {
296 if (((ReportSelected == ReportOption) ||
297 (ReportDumpBinFile == ReportOption)) &&
298 (!SelectedTable->Found))
299 {
300 Print (L"\nRequested ACPI Table not found.\n");
301 } else if (GetConsistencyChecking () &&
302 (ReportDumpBinFile != ReportOption))
303 {
304 OriginalAttribute = gST->ConOut->Mode->Attribute;
305
306 Print (L"\nTable Statistics:\n");
307
308 if (GetColourHighlighting ()) {
309 PrintAttribute = (GetErrorCount () > 0) ?
310 EFI_TEXT_ATTR (
311 EFI_RED,
312 ((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)
313 ) :
314 OriginalAttribute;
315 gST->ConOut->SetAttribute (gST->ConOut, PrintAttribute);
316 }
317
318 Print (L"\t%d Error(s)\n", GetErrorCount ());
319
320 if (GetColourHighlighting ()) {
321 PrintAttribute = (GetWarningCount () > 0) ?
322 EFI_TEXT_ATTR (
323 EFI_RED,
324 ((OriginalAttribute&(BIT4|BIT5|BIT6))>>4)
325 ) :
326 OriginalAttribute;
327
328 gST->ConOut->SetAttribute (gST->ConOut, PrintAttribute);
329 }
330
331 Print (L"\t%d Warning(s)\n", GetWarningCount ());
332
333 if (GetColourHighlighting ()) {
334 gST->ConOut->SetAttribute (gST->ConOut, OriginalAttribute);
335 }
336 }
337 }
338
339 return EFI_SUCCESS;
340}
UINT64 UINTN
VOID ResetWarningCount(VOID)
Definition: AcpiParser.c:58
UINT32 GetErrorCount(VOID)
Definition: AcpiParser.c:47
VOID ResetErrorCount(VOID)
Definition: AcpiParser.c:34
VOID EFIAPI IncrementErrorCount(VOID)
Definition: AcpiParser.c:83
UINT32 GetWarningCount(VOID)
Definition: AcpiParser.c:71
#define RSDP_TABLE_INFO
Definition: AcpiParser.h:19
EFI_STATUS EFIAPI GetParser(IN UINT32 Signature, OUT PARSE_ACPI_TABLE_PROC *ParserProc)
VOID(EFIAPI * PARSE_ACPI_TABLE_PROC)(IN BOOLEAN Trace, IN UINT8 *Ptr, IN UINT32 AcpiTableLength, IN UINT8 AcpiTableRevision)
BOOLEAN ProcessTableReportOptions(IN CONST UINT32 Signature, IN CONST UINT8 *TablePtr, IN CONST UINT32 Length)
Definition: AcpiView.c:79
STATIC BOOLEAN DumpAcpiTableToFile(IN CONST UINT8 *Ptr, IN CONST UINTN Length)
Definition: AcpiView.c:44
EFI_STATUS EFIAPI AcpiView(IN EFI_SYSTEM_TABLE *SystemTable)
Definition: AcpiView.c:191
#define RSDP_REVISION_OFFSET
Definition: AcpiView.h:19
#define RSDP_LENGTH_OFFSET
Definition: AcpiView.h:24
UINTN EFIAPI ShellDumpBufferToFile(IN CONST CHAR16 *FileNameBuffer, IN CONST VOID *Buffer, IN CONST UINTN BufferSize)
EREPORT_OPTION EFIAPI GetReportOption(VOID)
UINTN EFIAPI GetMandatoryTableSpec(VOID)
BOOLEAN EFIAPI GetConsistencyChecking(VOID)
BOOLEAN EFIAPI GetColourHighlighting(VOID)
BOOLEAN EFIAPI GetMandatoryTableValidate(VOID)
VOID EFIAPI GetSelectedAcpiTable(OUT SELECTED_ACPI_TABLE **SelectedAcpiTable)
EREPORT_OPTION
@ ReportAll
Report All tables.
@ ReportTableList
Report List of tables.
@ ReportSelected
Report Selected table.
@ ReportDumpBinFile
Dump selected table to a file.
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
Definition: MemLibGuid.c:73
UINTN EFIAPI UnicodeSPrint(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString,...)
Definition: PrintLib.c:408
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define STATIC
Definition: Base.h:264
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
EFI_STATUS EFIAPI ArmSbbrReqsValidate(ARM_SBBR_VERSION Version)
VOID EFIAPI ArmSbbrResetTableCounts(VOID)
ARM_SBBR_VERSION
Definition: SbbrValidator.h:26
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_SYSTEM_TABLE * gST
UINTN EFIAPI Print(IN CONST CHAR16 *Format,...)
Definition: UefiLibPrint.c:113
EFI_SIMPLE_TEXT_OUTPUT_MODE * Mode
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * ConOut
Definition: UefiSpec.h:2064
BOOLEAN Found
The selected table has been found in the system.
CONST CHAR16 * Name
User friendly name of the selected ACPI table.
UINT32 Type
32bit signature of the selected ACPI table.