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
;
110 case ReportTableList
:
111 if (mTableCount
== 0) {
113 OriginalAttribute
= gST
->ConOut
->Mode
->Attribute
;
114 gST
->ConOut
->SetAttribute (
116 EFI_TEXT_ATTR(EFI_CYAN
,
117 ((OriginalAttribute
&(BIT4
|BIT5
|BIT6
))>>4))
120 Print (L
"\nInstalled Table(s):\n");
122 gST
->ConOut
->SetAttribute (gST
->ConOut
, OriginalAttribute
);
126 L
"\t%4d. %c%c%c%c\n",
134 case ReportDumpBinFile
:
135 if (Signature
== SelectedTable
->Type
) {
136 SelectedTable
->Found
= TRUE
;
137 DumpAcpiTableToFile (TablePtr
, Length
);
141 // We should never be here.
142 // This case is only present to prevent compiler warning.
148 OriginalAttribute
= gST
->ConOut
->Mode
->Attribute
;
149 gST
->ConOut
->SetAttribute (
151 EFI_TEXT_ATTR(EFI_LIGHTBLUE
,
152 ((OriginalAttribute
&(BIT4
|BIT5
|BIT6
))>>4))
156 L
"\n\n --------------- %c%c%c%c Table --------------- \n\n",
163 gST
->ConOut
->SetAttribute (gST
->ConOut
, OriginalAttribute
);
173 This function iterates the configuration table entries in the
174 system table, retrieves the RSDP pointer and starts parsing the ACPI tables.
176 @param [in] SystemTable Pointer to the EFI system table.
178 @retval Returns EFI_NOT_FOUND if the RSDP pointer is not found.
179 Returns EFI_UNSUPPORTED if the RSDP version is less than 2.
180 Returns EFI_SUCCESS if successful.
185 IN EFI_SYSTEM_TABLE
* SystemTable
190 EFI_CONFIGURATION_TABLE
* EfiConfigurationTable
;
191 BOOLEAN FoundAcpiTable
;
192 UINTN OriginalAttribute
;
193 UINTN PrintAttribute
;
194 EREPORT_OPTION ReportOption
;
198 PARSE_ACPI_TABLE_PROC RsdpParserProc
;
200 SELECTED_ACPI_TABLE
*SelectedTable
;
203 // set local variables to suppress incorrect compiler/analyzer warnings
205 EfiConfigurationTable
= NULL
;
206 OriginalAttribute
= 0;
208 // Reset Table counts
212 // Reset The error/warning counters
214 ResetWarningCount ();
216 // Retrieve the user selection of ACPI table to process
217 GetSelectedAcpiTable (&SelectedTable
);
219 // Search the table for an entry that matches the ACPI Table Guid
220 FoundAcpiTable
= FALSE
;
221 for (Index
= 0; Index
< SystemTable
->NumberOfTableEntries
; Index
++) {
222 if (CompareGuid (&gEfiAcpiTableGuid
,
223 &(SystemTable
->ConfigurationTable
[Index
].VendorGuid
))) {
224 EfiConfigurationTable
= &SystemTable
->ConfigurationTable
[Index
];
225 FoundAcpiTable
= TRUE
;
230 if (FoundAcpiTable
) {
231 RsdpPtr
= (UINT8
*)EfiConfigurationTable
->VendorTable
;
233 // The RSDP revision is 1 byte starting at offset 15
234 RsdpRevision
= *(RsdpPtr
+ RSDP_REVISION_OFFSET
);
236 if (RsdpRevision
< 2) {
238 L
"ERROR: RSDP version less than 2 is not supported.\n"
240 return EFI_UNSUPPORTED
;
243 #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
244 if (GetMandatoryTableValidate ()) {
245 ArmSbbrResetTableCounts ();
249 // The RSDP length is 4 bytes starting at offset 20
250 RsdpLength
= *(UINT32
*)(RsdpPtr
+ RSDP_LENGTH_OFFSET
);
252 Trace
= ProcessTableReportOptions (RSDP_TABLE_INFO
, RsdpPtr
, RsdpLength
);
254 Status
= GetParser (RSDP_TABLE_INFO
, &RsdpParserProc
);
255 if (EFI_ERROR (Status
)) {
257 L
"ERROR: No registered parser found for RSDP.\n"
270 IncrementErrorCount ();
272 L
"ERROR: Failed to find ACPI Table Guid in System Configuration Table.\n"
274 return EFI_NOT_FOUND
;
277 #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
278 if (GetMandatoryTableValidate ()) {
279 ArmSbbrReqsValidate ((ARM_SBBR_VERSION
)GetMandatoryTableSpec ());
283 ReportOption
= GetReportOption ();
284 if (ReportTableList
!= ReportOption
) {
285 if (((ReportSelected
== ReportOption
) ||
286 (ReportDumpBinFile
== ReportOption
)) &&
287 (!SelectedTable
->Found
)) {
288 Print (L
"\nRequested ACPI Table not found.\n");
289 } else if (GetConsistencyChecking () &&
290 (ReportDumpBinFile
!= ReportOption
)) {
291 OriginalAttribute
= gST
->ConOut
->Mode
->Attribute
;
293 Print (L
"\nTable Statistics:\n");
295 if (GetColourHighlighting ()) {
296 PrintAttribute
= (GetErrorCount () > 0) ?
299 ((OriginalAttribute
&(BIT4
|BIT5
|BIT6
))>>4)
302 gST
->ConOut
->SetAttribute (gST
->ConOut
, PrintAttribute
);
304 Print (L
"\t%d Error(s)\n", GetErrorCount ());
306 if (GetColourHighlighting ()) {
307 PrintAttribute
= (GetWarningCount () > 0) ?
310 ((OriginalAttribute
&(BIT4
|BIT5
|BIT6
))>>4)
314 gST
->ConOut
->SetAttribute (gST
->ConOut
, PrintAttribute
);
316 Print (L
"\t%d Warning(s)\n", GetWarningCount ());
318 if (GetColourHighlighting ()) {
319 gST
->ConOut
->SetAttribute (gST
->ConOut
, OriginalAttribute
);