4 Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
5 Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
6 SPDX-License-Identifier: BSD-2-Clause-Patent
9 - ACPI 6.5 Specification - August 2022
12 #include <IndustryStandard/Acpi.h>
13 #include <Library/UefiLib.h>
14 #include "AcpiParser.h"
15 #include "AcpiTableParser.h"
18 STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo
;
19 STATIC UINT32
*InstructionEntryCount
;
22 An array of strings describing the Erst actions
24 STATIC CONST CHAR16
*ErstActionTable
[] = {
25 L
"BEGIN_WRITE_OPERATION",
26 L
"BEGIN_READ_OPERATION",
27 L
"BEGIN_CLEAR_OPERATION",
32 L
"GET_COMMAND_STATUS",
33 L
"GET_RECORD_IDENTIFIER",
34 L
"SET_RECORD_IDENTIFIER",
36 L
"BEGIN_DUMMY_WRITE_OPERATION",
38 L
"GET_ERROR_LOG_ADDRESS_RANGE",
39 L
"GET_ERROR_LOG_ADDRESS_RANGE_LENGTH",
40 L
"GET_ERROR_LOG_ADDRESS_RANGE_ATTRIBUTES",
41 L
"GET_EXECUTE_OPERATION_TIMINGS"
45 An array of strings describing the Erst instructions
47 STATIC CONST CHAR16
*ErstInstructionTable
[] = {
49 L
"READ_REGISTER_VALUE",
51 L
"WRITE_REGISTER_VALUE",
62 L
"SKIP_NEXT_INSTRUCTION_IF_TRUE",
64 L
"SET_SRC_ADDRESS_BASE",
65 L
"SET_DST_ADDRESS_BASE",
72 @param [in] Ptr Pointer to the start of the field data.
73 @param [in] Context Pointer to context specific information e.g. this
74 could be a pointer to the ACPI table header.
84 if (*Ptr
> EFI_ACPI_6_4_ERST_GET_EXECUTE_OPERATION_TIMINGS
) {
85 IncrementErrorCount ();
86 Print (L
"\nError: 0x%02x is not a valid action encoding", *Ptr
);
91 Validate Erst instruction.
93 @param [in] Ptr Pointer to the start of the field data.
94 @param [in] Context Pointer to context specific information e.g. this
95 could be a pointer to the ACPI table header.
100 ValidateErstInstruction (
105 if (*Ptr
> EFI_ACPI_6_4_ERST_MOVE_DATA
) {
106 IncrementErrorCount ();
107 Print (L
"\nError: 0x%02x is not a valid instruction encoding", *Ptr
);
114 @param [in] Ptr Pointer to the start of the field data.
115 @param [in] Context Pointer to context specific information e.g. this
116 could be a pointer to the ACPI table header.
126 if ((*Ptr
& 0xfe) != 0) {
127 IncrementErrorCount ();
128 Print (L
"\nError: Reserved Flag bits not set to 0");
133 Looks up and prints the string corresponding to the index.
135 @param [in] Table Lookup table.
136 @param [in] Index Entry to print.
137 @param [in] NumEntries Number of valid entries in the table.
143 IN CONST CHAR16
*Table
[],
148 CONST CHAR16
*String
;
150 if (Index
< NumEntries
) {
151 String
= Table
[Index
];
153 String
= L
"**INVALID**";
164 Prints the Erst Action.
166 @param [in] Format Optional format string for tracing the data.
167 @param [in] Ptr Pointer to the Action byte.
173 IN CONST CHAR16
*Format OPTIONAL
,
177 FormatByte (ErstActionTable
, *Ptr
, ARRAY_SIZE (ErstActionTable
));
181 Prints the Erst Instruction.
183 @param [in] Format Optional format string for tracing the data.
184 @param [in] Ptr Pointer to the Instruction byte.
189 DumpErstInstruction (
190 IN CONST CHAR16
*Format OPTIONAL
,
194 FormatByte (ErstInstructionTable
, *Ptr
, ARRAY_SIZE (ErstInstructionTable
));
198 An ACPI_PARSER array describing the ACPI ERST Table.
200 STATIC CONST ACPI_PARSER ErstParser
[] = {
201 PARSE_ACPI_HEADER (&AcpiHdrInfo
),
202 { L
"Serialization Header Size", 4, 36, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
203 { L
"Reserved", 4, 40, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
204 { L
"Instruction Entry Count", 4, 44, L
"0x%x", NULL
, (VOID
**)&InstructionEntryCount
, NULL
, NULL
}
208 An ACPI_PARSER array describing the Serialization Instruction Entry structure.
210 STATIC CONST ACPI_PARSER SerializationInstructionEntryParser
[] = {
211 { L
"Serialization Action", 1, 0, L
"0x%x", DumpErstAction
, NULL
, ValidateErstAction
, NULL
},
212 { L
"Instruction", 1, 1, L
"0x%x", DumpErstInstruction
, NULL
, ValidateErstInstruction
, NULL
},
213 { L
"Flags", 1, 2, L
"0x%x", NULL
, NULL
, ValidateErstFlags
, NULL
},
214 { L
"Reserved", 1, 3, L
"0x%x", NULL
, NULL
, NULL
, NULL
},
215 { L
"Register Region", 12, 4, NULL
, DumpGas
, NULL
, NULL
, NULL
},
216 { L
"Value", 8, 16, L
"0x%llx", NULL
, NULL
, NULL
, NULL
},
217 { L
"Mask", 8, 24, L
"0x%llx", NULL
, NULL
, NULL
, NULL
}
221 This function parses the ACPI ERST table.
222 When trace is enabled this function parses the ERST table and
223 traces the ACPI table fields.
225 This function also performs validation of the ACPI table fields.
227 @param [in] Trace If TRUE, trace the ACPI fields.
228 @param [in] Ptr Pointer to the start of the buffer.
229 @param [in] AcpiTableLength Length of the ACPI table.
230 @param [in] AcpiTableRevision Revision of the ACPI table.
237 IN UINT32 AcpiTableLength
,
238 IN UINT8 AcpiTableRevision
253 PARSER_PARAMS (ErstParser
)
256 if (sizeof (EFI_ACPI_6_4_ERST_SERIALIZATION_INSTRUCTION_ENTRY
)*(*InstructionEntryCount
) != (AcpiTableLength
- Offset
)) {
257 IncrementErrorCount ();
259 L
"ERROR: Invalid InstructionEntryCount. " \
260 L
"Count = %d. Offset = %d. AcpiTableLength = %d.\n",
261 *InstructionEntryCount
,
268 while (Offset
< AcpiTableLength
) {
269 Offset
+= ParseAcpi (
272 "Serialization Action",
274 (AcpiTableLength
- Offset
),
275 PARSER_PARAMS (SerializationInstructionEntryParser
)