3 Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
4 SPDX-License-Identifier: BSD-2-Clause-Patent
7 - Sbbr or SBBR - Server Base Boot Requirements
10 - Arm Server Base Boot Requirements 1.2, September 2019
13 #include <Library/PrintLib.h>
14 #include <Library/UefiLib.h>
15 #include <Library/ShellLib.h>
16 #include <Library/UefiBootServicesTableLib.h>
17 #include <Library/BaseMemoryLib.h>
18 #include <Library/DebugLib.h>
19 #include <Library/MemoryAllocationLib.h>
20 #include <Library/AcpiViewCommandLib.h>
21 #include "AcpiParser.h"
22 #include "AcpiTableParser.h"
24 #include "AcpiViewConfig.h"
26 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
27 #include "Arm/SbbrValidator.h"
30 STATIC UINT32 mTableCount
;
31 STATIC UINT32 mBinTableCount
;
34 This function dumps the ACPI table to a file.
36 @param [in] Ptr Pointer to the ACPI table data.
37 @param [in] Length The length of the ACPI table.
40 @retval FALSE Failure.
49 CHAR16 FileNameBuffer
[MAX_FILE_NAME_LEN
];
51 SELECTED_ACPI_TABLE
*SelectedTable
;
53 GetSelectedAcpiTable (&SelectedTable
);
57 sizeof (FileNameBuffer
),
63 Print (L
"Dumping ACPI table to : %s ... ", FileNameBuffer
);
65 TransferBytes
= ShellDumpBufferToFile (FileNameBuffer
, Ptr
, Length
);
66 return (Length
== TransferBytes
);
70 This function processes the table reporting options for the ACPI table.
72 @param [in] Signature The ACPI table Signature.
73 @param [in] TablePtr Pointer to the ACPI table data.
74 @param [in] Length The length fo the ACPI table.
76 @retval Returns TRUE if the ACPI table should be traced.
79 ProcessTableReportOptions (
80 IN CONST UINT32 Signature
,
81 IN CONST UINT8
*TablePtr
,
82 IN CONST UINT32 Length
85 UINTN OriginalAttribute
;
89 SELECTED_ACPI_TABLE
*SelectedTable
;
92 // set local variables to suppress incorrect compiler/analyzer warnings
94 OriginalAttribute
= 0;
95 SignaturePtr
= (UINT8
*)(UINTN
)&Signature
;
97 HighLight
= GetColourHighlighting ();
98 GetSelectedAcpiTable (&SelectedTable
);
100 switch (GetReportOption ()) {
105 if (Signature
== SelectedTable
->Type
) {
107 SelectedTable
->Found
= TRUE
;
111 case ReportTableList
:
112 if (mTableCount
== 0) {
114 OriginalAttribute
= gST
->ConOut
->Mode
->Attribute
;
115 gST
->ConOut
->SetAttribute (
119 ((OriginalAttribute
&(BIT4
|BIT5
|BIT6
))>>4)
124 Print (L
"\nInstalled Table(s):\n");
126 gST
->ConOut
->SetAttribute (gST
->ConOut
, OriginalAttribute
);
131 L
"\t%4d. %c%c%c%c\n",
139 case ReportDumpBinFile
:
140 if (Signature
== SelectedTable
->Type
) {
141 SelectedTable
->Found
= TRUE
;
142 DumpAcpiTableToFile (TablePtr
, Length
);
147 // We should never be here.
148 // This case is only present to prevent compiler warning.
154 OriginalAttribute
= gST
->ConOut
->Mode
->Attribute
;
155 gST
->ConOut
->SetAttribute (
159 ((OriginalAttribute
&(BIT4
|BIT5
|BIT6
))>>4)
165 L
"\n\n --------------- %c%c%c%c Table --------------- \n\n",
172 gST
->ConOut
->SetAttribute (gST
->ConOut
, OriginalAttribute
);
180 This function iterates the configuration table entries in the
181 system table, retrieves the RSDP pointer and starts parsing the ACPI tables.
183 @param [in] SystemTable Pointer to the EFI system table.
185 @retval Returns EFI_NOT_FOUND if the RSDP pointer is not found.
186 Returns EFI_UNSUPPORTED if the RSDP version is less than 2.
187 Returns EFI_SUCCESS if successful.
192 IN EFI_SYSTEM_TABLE
*SystemTable
197 EFI_CONFIGURATION_TABLE
*EfiConfigurationTable
;
198 BOOLEAN FoundAcpiTable
;
199 UINTN OriginalAttribute
;
200 UINTN PrintAttribute
;
201 EREPORT_OPTION ReportOption
;
205 PARSE_ACPI_TABLE_PROC RsdpParserProc
;
207 SELECTED_ACPI_TABLE
*SelectedTable
;
210 // set local variables to suppress incorrect compiler/analyzer warnings
212 EfiConfigurationTable
= NULL
;
213 OriginalAttribute
= 0;
215 // Reset Table counts
219 // Reset The error/warning counters
221 ResetWarningCount ();
223 // Retrieve the user selection of ACPI table to process
224 GetSelectedAcpiTable (&SelectedTable
);
226 // Search the table for an entry that matches the ACPI Table Guid
227 FoundAcpiTable
= FALSE
;
228 for (Index
= 0; Index
< SystemTable
->NumberOfTableEntries
; Index
++) {
231 &(SystemTable
->ConfigurationTable
[Index
].VendorGuid
)
234 EfiConfigurationTable
= &SystemTable
->ConfigurationTable
[Index
];
235 FoundAcpiTable
= TRUE
;
240 if (FoundAcpiTable
) {
241 RsdpPtr
= (UINT8
*)EfiConfigurationTable
->VendorTable
;
243 // The RSDP revision is 1 byte starting at offset 15
244 RsdpRevision
= *(RsdpPtr
+ RSDP_REVISION_OFFSET
);
246 if (RsdpRevision
< 2) {
248 L
"ERROR: RSDP version less than 2 is not supported.\n"
250 return EFI_UNSUPPORTED
;
253 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
254 if (GetMandatoryTableValidate ()) {
255 ArmSbbrResetTableCounts ();
260 // The RSDP length is 4 bytes starting at offset 20
261 RsdpLength
= *(UINT32
*)(RsdpPtr
+ RSDP_LENGTH_OFFSET
);
263 Trace
= ProcessTableReportOptions (RSDP_TABLE_INFO
, RsdpPtr
, RsdpLength
);
265 Status
= GetParser (RSDP_TABLE_INFO
, &RsdpParserProc
);
266 if (EFI_ERROR (Status
)) {
268 L
"ERROR: No registered parser found for RSDP.\n"
280 IncrementErrorCount ();
282 L
"ERROR: Failed to find ACPI Table Guid in System Configuration Table.\n"
284 return EFI_NOT_FOUND
;
287 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
288 if (GetMandatoryTableValidate ()) {
289 ArmSbbrReqsValidate ((ARM_SBBR_VERSION
)GetMandatoryTableSpec ());
294 ReportOption
= GetReportOption ();
295 if (ReportTableList
!= ReportOption
) {
296 if (((ReportSelected
== ReportOption
) ||
297 (ReportDumpBinFile
== ReportOption
)) &&
298 (!SelectedTable
->Found
))
300 Print (L
"\nRequested ACPI Table not found.\n");
301 } else if (GetConsistencyChecking () &&
302 (ReportDumpBinFile
!= ReportOption
))
304 OriginalAttribute
= gST
->ConOut
->Mode
->Attribute
;
306 Print (L
"\nTable Statistics:\n");
308 if (GetColourHighlighting ()) {
309 PrintAttribute
= (GetErrorCount () > 0) ?
312 ((OriginalAttribute
&(BIT4
|BIT5
|BIT6
))>>4)
315 gST
->ConOut
->SetAttribute (gST
->ConOut
, PrintAttribute
);
318 Print (L
"\t%d Error(s)\n", GetErrorCount ());
320 if (GetColourHighlighting ()) {
321 PrintAttribute
= (GetWarningCount () > 0) ?
324 ((OriginalAttribute
&(BIT4
|BIT5
|BIT6
))>>4)
328 gST
->ConOut
->SetAttribute (gST
->ConOut
, PrintAttribute
);
331 Print (L
"\t%d Warning(s)\n", GetWarningCount ());
333 if (GetColourHighlighting ()) {
334 gST
->ConOut
->SetAttribute (gST
->ConOut
, OriginalAttribute
);