4 Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include <IndustryStandard/Acpi.h>
16 #include <Library/UefiLib.h>
17 #include "AcpiParser.h"
18 #include "AcpiTableParser.h"
22 A list of registered ACPI table parsers.
24 STATIC ACPI_TABLE_PARSER mTableParserList
[MAX_ACPI_TABLE_PARSERS
];
27 Register the ACPI table Parser
29 This function registers the ACPI table parser.
31 @param [in] Signature The ACPI table signature.
32 @param [in] ParserProc The ACPI table parser.
34 @retval EFI_SUCCESS The parser is registered.
35 @retval EFI_INVALID_PARAMETER A parameter is invalid.
36 @retval EFI_ALREADY_STARTED The parser for the Table
37 was already registered.
38 @retval EFI_OUT_OF_RESOURCES No space to register the
45 IN PARSE_ACPI_TABLE_PROC ParserProc
50 if ((ParserProc
== NULL
) || (Signature
== ACPI_PARSER_SIGNATURE_NULL
)) {
51 return EFI_INVALID_PARAMETER
;
54 // Search if a parser is already installed
56 Index
< (sizeof (mTableParserList
) / sizeof (mTableParserList
[0]));
59 if (Signature
== mTableParserList
[Index
].Signature
) {
60 if (mTableParserList
[Index
].Parser
!= NULL
) {
61 return EFI_ALREADY_STARTED
;
66 // Find the first free slot and register the parser
68 Index
< (sizeof (mTableParserList
) / sizeof (mTableParserList
[0]));
71 if (mTableParserList
[Index
].Signature
== ACPI_PARSER_SIGNATURE_NULL
) {
72 mTableParserList
[Index
].Signature
= Signature
;
73 mTableParserList
[Index
].Parser
= ParserProc
;
79 return EFI_OUT_OF_RESOURCES
;
83 Deregister the ACPI table Parser
85 This function deregisters the ACPI table parser.
87 @param [in] Signature The ACPI table signature.
89 @retval EFI_SUCCESS The parser was deregistered.
90 @retval EFI_INVALID_PARAMETER A parameter is invalid.
91 @retval EFI_NOT_FOUND A registered parser was not found.
101 if (Signature
== ACPI_PARSER_SIGNATURE_NULL
) {
102 return EFI_INVALID_PARAMETER
;
106 Index
< (sizeof (mTableParserList
) / sizeof (mTableParserList
[0]));
109 if (Signature
== mTableParserList
[Index
].Signature
) {
110 mTableParserList
[Index
].Signature
= ACPI_PARSER_SIGNATURE_NULL
;
111 mTableParserList
[Index
].Parser
= NULL
;
116 // No matching registered parser found.
117 return EFI_NOT_FOUND
;
121 Get the ACPI table Parser
123 This function returns the ACPI table parser proc from the list of
126 @param [in] Signature The ACPI table signature.
127 @param [out] ParserProc Pointer to a ACPI table parser proc.
129 @retval EFI_SUCCESS The parser was returned successfully.
130 @retval EFI_INVALID_PARAMETER A parameter is invalid.
131 @retval EFI_NOT_FOUND A registered parser was not found.
137 OUT PARSE_ACPI_TABLE_PROC
* ParserProc
142 if ((ParserProc
== NULL
) || (Signature
== ACPI_PARSER_SIGNATURE_NULL
)) {
143 return EFI_INVALID_PARAMETER
;
147 Index
< (sizeof (mTableParserList
) / sizeof (mTableParserList
[0]));
150 if (Signature
== mTableParserList
[Index
].Signature
) {
151 *ParserProc
= mTableParserList
[Index
].Parser
;
156 // No matching registered parser found.
157 return EFI_NOT_FOUND
;
161 This function processes the ACPI tables.
162 This function calls ProcessTableReportOptions() to list the ACPI
163 tables, perform binary dump of the tables and determine if the
164 ACPI fields should be traced.
166 This function also invokes the parser for the ACPI tables.
168 This function also performs a RAW dump of the ACPI table including
169 the unknown/unparsed ACPI tables and validates the checksum.
171 @param [in] Ptr Pointer to the start of the ACPI
182 CONST UINT32
* AcpiTableSignature
;
183 CONST UINT32
* AcpiTableLength
;
184 CONST UINT8
* AcpiTableRevision
;
185 PARSE_ACPI_TABLE_PROC ParserProc
;
194 Trace
= ProcessTableReportOptions (
201 DumpRaw (Ptr
, *AcpiTableLength
);
202 VerifyChecksum (TRUE
, Ptr
, *AcpiTableLength
);
205 Status
= GetParser (*AcpiTableSignature
, &ParserProc
);
206 if (EFI_ERROR (Status
)) {
207 // No registered parser found, do default handling.
209 DumpAcpiHeader (Ptr
);