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"
21 #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
22 #include "Arm/SbbrValidator.h"
26 A list of registered ACPI table parsers.
28 STATIC ACPI_TABLE_PARSER mTableParserList
[MAX_ACPI_TABLE_PARSERS
];
31 Register the ACPI table Parser
33 This function registers the ACPI table parser.
35 @param [in] Signature The ACPI table signature.
36 @param [in] ParserProc The ACPI table parser.
38 @retval EFI_SUCCESS The parser is registered.
39 @retval EFI_INVALID_PARAMETER A parameter is invalid.
40 @retval EFI_ALREADY_STARTED The parser for the Table
41 was already registered.
42 @retval EFI_OUT_OF_RESOURCES No space to register the
49 IN PARSE_ACPI_TABLE_PROC ParserProc
54 if ((ParserProc
== NULL
) || (Signature
== ACPI_PARSER_SIGNATURE_NULL
)) {
55 return EFI_INVALID_PARAMETER
;
58 // Search if a parser is already installed
60 Index
< (sizeof (mTableParserList
) / sizeof (mTableParserList
[0]));
63 if (Signature
== mTableParserList
[Index
].Signature
) {
64 if (mTableParserList
[Index
].Parser
!= NULL
) {
65 return EFI_ALREADY_STARTED
;
70 // Find the first free slot and register the parser
72 Index
< (sizeof (mTableParserList
) / sizeof (mTableParserList
[0]));
75 if (mTableParserList
[Index
].Signature
== ACPI_PARSER_SIGNATURE_NULL
) {
76 mTableParserList
[Index
].Signature
= Signature
;
77 mTableParserList
[Index
].Parser
= ParserProc
;
83 return EFI_OUT_OF_RESOURCES
;
87 Deregister the ACPI table Parser
89 This function deregisters the ACPI table parser.
91 @param [in] Signature The ACPI table signature.
93 @retval EFI_SUCCESS The parser was deregistered.
94 @retval EFI_INVALID_PARAMETER A parameter is invalid.
95 @retval EFI_NOT_FOUND A registered parser was not found.
105 if (Signature
== ACPI_PARSER_SIGNATURE_NULL
) {
106 return EFI_INVALID_PARAMETER
;
110 Index
< (sizeof (mTableParserList
) / sizeof (mTableParserList
[0]));
113 if (Signature
== mTableParserList
[Index
].Signature
) {
114 mTableParserList
[Index
].Signature
= ACPI_PARSER_SIGNATURE_NULL
;
115 mTableParserList
[Index
].Parser
= NULL
;
120 // No matching registered parser found.
121 return EFI_NOT_FOUND
;
125 Get the ACPI table Parser
127 This function returns the ACPI table parser proc from the list of
130 @param [in] Signature The ACPI table signature.
131 @param [out] ParserProc Pointer to a ACPI table parser proc.
133 @retval EFI_SUCCESS The parser was returned successfully.
134 @retval EFI_INVALID_PARAMETER A parameter is invalid.
135 @retval EFI_NOT_FOUND A registered parser was not found.
141 OUT PARSE_ACPI_TABLE_PROC
* ParserProc
146 if ((ParserProc
== NULL
) || (Signature
== ACPI_PARSER_SIGNATURE_NULL
)) {
147 return EFI_INVALID_PARAMETER
;
151 Index
< (sizeof (mTableParserList
) / sizeof (mTableParserList
[0]));
154 if (Signature
== mTableParserList
[Index
].Signature
) {
155 *ParserProc
= mTableParserList
[Index
].Parser
;
160 // No matching registered parser found.
161 return EFI_NOT_FOUND
;
165 This function processes the ACPI tables.
166 This function calls ProcessTableReportOptions() to list the ACPI
167 tables, perform binary dump of the tables and determine if the
168 ACPI fields should be traced.
170 This function also invokes the parser for the ACPI tables.
172 This function also performs a RAW dump of the ACPI table including
173 the unknown/unparsed ACPI tables and validates the checksum.
175 @param [in] Ptr Pointer to the start of the ACPI
186 CONST UINT32
* AcpiTableSignature
;
187 CONST UINT32
* AcpiTableLength
;
188 CONST UINT8
* AcpiTableRevision
;
189 CONST UINT8
* SignaturePtr
;
190 PARSE_ACPI_TABLE_PROC ParserProc
;
199 Trace
= ProcessTableReportOptions (
206 DumpRaw (Ptr
, *AcpiTableLength
);
208 // Do not process the ACPI table any further if the table length read
209 // is invalid. The ACPI table should at least contain the table header.
210 if (*AcpiTableLength
< sizeof (EFI_ACPI_DESCRIPTION_HEADER
)) {
211 SignaturePtr
= (CONST UINT8
*)AcpiTableSignature
;
212 IncrementErrorCount ();
214 L
"ERROR: Invalid %c%c%c%c table length. Length = %d\n",
224 if (GetConsistencyChecking ()) {
225 VerifyChecksum (TRUE
, Ptr
, *AcpiTableLength
);
229 #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
230 if (GetMandatoryTableValidate ()) {
231 ArmSbbrIncrementTableCount (*AcpiTableSignature
);
235 Status
= GetParser (*AcpiTableSignature
, &ParserProc
);
236 if (EFI_ERROR (Status
)) {
237 // No registered parser found, do default handling.
239 DumpAcpiHeader (Ptr
);