4 Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
5 SPDX-License-Identifier: BSD-2-Clause-Patent
8 - Sbbr or SBBR - Server Base Boot Requirements
11 - Arm Server Base Boot Requirements 1.2, September 2019
15 #include <IndustryStandard/Acpi.h>
16 #include <Library/UefiLib.h>
17 #include "AcpiParser.h"
18 #include "AcpiTableParser.h"
20 #include "AcpiViewConfig.h"
22 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
23 #include "Arm/SbbrValidator.h"
27 A list of registered ACPI table parsers.
29 STATIC ACPI_TABLE_PARSER mTableParserList
[MAX_ACPI_TABLE_PARSERS
];
32 Register the ACPI table Parser
34 This function registers the ACPI table parser.
36 @param [in] Signature The ACPI table signature.
37 @param [in] ParserProc The ACPI table parser.
39 @retval EFI_SUCCESS The parser is registered.
40 @retval EFI_INVALID_PARAMETER A parameter is invalid.
41 @retval EFI_ALREADY_STARTED The parser for the Table
42 was already registered.
43 @retval EFI_OUT_OF_RESOURCES No space to register the
50 IN PARSE_ACPI_TABLE_PROC ParserProc
55 if ((ParserProc
== NULL
) || (Signature
== ACPI_PARSER_SIGNATURE_NULL
)) {
56 return EFI_INVALID_PARAMETER
;
59 // Search if a parser is already installed
61 Index
< (sizeof (mTableParserList
) / sizeof (mTableParserList
[0]));
64 if (Signature
== mTableParserList
[Index
].Signature
) {
65 if (mTableParserList
[Index
].Parser
!= NULL
) {
66 return EFI_ALREADY_STARTED
;
71 // Find the first free slot and register the parser
73 Index
< (sizeof (mTableParserList
) / sizeof (mTableParserList
[0]));
76 if (mTableParserList
[Index
].Signature
== ACPI_PARSER_SIGNATURE_NULL
) {
77 mTableParserList
[Index
].Signature
= Signature
;
78 mTableParserList
[Index
].Parser
= ParserProc
;
84 return EFI_OUT_OF_RESOURCES
;
88 Deregister the ACPI table Parser
90 This function deregisters the ACPI table parser.
92 @param [in] Signature The ACPI table signature.
94 @retval EFI_SUCCESS The parser was deregistered.
95 @retval EFI_INVALID_PARAMETER A parameter is invalid.
96 @retval EFI_NOT_FOUND A registered parser was not found.
106 if (Signature
== ACPI_PARSER_SIGNATURE_NULL
) {
107 return EFI_INVALID_PARAMETER
;
111 Index
< (sizeof (mTableParserList
) / sizeof (mTableParserList
[0]));
114 if (Signature
== mTableParserList
[Index
].Signature
) {
115 mTableParserList
[Index
].Signature
= ACPI_PARSER_SIGNATURE_NULL
;
116 mTableParserList
[Index
].Parser
= NULL
;
121 // No matching registered parser found.
122 return EFI_NOT_FOUND
;
126 Get the ACPI table Parser
128 This function returns the ACPI table parser proc from the list of
131 @param [in] Signature The ACPI table signature.
132 @param [out] ParserProc Pointer to a ACPI table parser proc.
134 @retval EFI_SUCCESS The parser was returned successfully.
135 @retval EFI_INVALID_PARAMETER A parameter is invalid.
136 @retval EFI_NOT_FOUND A registered parser was not found.
142 OUT PARSE_ACPI_TABLE_PROC
*ParserProc
147 if ((ParserProc
== NULL
) || (Signature
== ACPI_PARSER_SIGNATURE_NULL
)) {
148 return EFI_INVALID_PARAMETER
;
152 Index
< (sizeof (mTableParserList
) / sizeof (mTableParserList
[0]));
155 if (Signature
== mTableParserList
[Index
].Signature
) {
156 *ParserProc
= mTableParserList
[Index
].Parser
;
161 // No matching registered parser found.
162 return EFI_NOT_FOUND
;
166 This function processes the ACPI tables.
167 This function calls ProcessTableReportOptions() to list the ACPI
168 tables, perform binary dump of the tables and determine if the
169 ACPI fields should be traced.
171 This function also invokes the parser for the ACPI tables.
173 This function also performs a RAW dump of the ACPI table including
174 the unknown/unparsed ACPI tables and validates the checksum.
176 @param [in] Ptr Pointer to the start of the ACPI
187 CONST UINT32
*AcpiTableSignature
;
188 CONST UINT32
*AcpiTableLength
;
189 CONST UINT8
*AcpiTableRevision
;
190 CONST UINT8
*SignaturePtr
;
191 PARSE_ACPI_TABLE_PROC ParserProc
;
200 Trace
= ProcessTableReportOptions (
207 DumpRaw (Ptr
, *AcpiTableLength
);
209 // Do not process the ACPI table any further if the table length read
210 // is invalid. The ACPI table should at least contain the table header.
211 if (*AcpiTableLength
< sizeof (EFI_ACPI_DESCRIPTION_HEADER
)) {
212 SignaturePtr
= (CONST UINT8
*)AcpiTableSignature
;
213 IncrementErrorCount ();
215 L
"ERROR: Invalid %c%c%c%c table length. Length = %d\n",
225 if (GetConsistencyChecking ()) {
226 VerifyChecksum (TRUE
, Ptr
, *AcpiTableLength
);
230 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
231 if (GetMandatoryTableValidate ()) {
232 ArmSbbrIncrementTableCount (*AcpiTableSignature
);
237 Status
= GetParser (*AcpiTableSignature
, &ParserProc
);
238 if (EFI_ERROR (Status
)) {
239 // No registered parser found, do default handling.
241 DumpAcpiHeader (Ptr
);