TianoCore EDK2 master
Loading...
Searching...
No Matches
FadtParser.c
Go to the documentation of this file.
1
13#include <Library/UefiLib.h>
14#include "AcpiParser.h"
15#include "AcpiTableParser.h"
16#include "AcpiView.h"
17
18// Local variables
19STATIC CONST UINT32 *DsdtAddress;
20STATIC CONST UINT64 *X_DsdtAddress;
21STATIC CONST UINT32 *Flags;
22STATIC CONST UINT32 *FirmwareCtrl;
23STATIC CONST UINT64 *X_FirmwareCtrl;
24STATIC CONST UINT8 *FadtMinorRevision;
26
30#define HW_REDUCED_ACPI BIT20
31
35#define FACS_SIGNATURE_OFFSET 0
36
40#define FACS_VERSION_OFFSET 32
41
45#define FACS_LENGTH_OFFSET 4
46
51EFIAPI
53 VOID
54 );
55
65VOID
66EFIAPI
68 IN UINT8 *Ptr,
69 IN UINT32 Length,
70 IN VOID *Context
71 )
72{
73 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
74 if (*(UINT32 *)Ptr != 0) {
76 Print (
77 L"\nERROR: Firmware Control must be zero for ARM platforms."
78 );
79 }
80
81 #endif
82}
83
93VOID
94EFIAPI
96 IN UINT8 *Ptr,
97 IN UINT32 Length,
98 IN VOID *Context
99 )
100{
101 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
102 if (*(UINT64 *)Ptr != 0) {
104 Print (
105 L"\nERROR: X Firmware Control must be zero for ARM platforms."
106 );
107 }
108
109 #endif
110}
111
120STATIC
121VOID
122EFIAPI
124 IN UINT8 *Ptr,
125 IN UINT32 Length,
126 IN VOID *Context
127 )
128{
129 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
130 if (((*(UINT32 *)Ptr) & HW_REDUCED_ACPI) == 0) {
132 Print (
133 L"\nERROR: HW_REDUCED_ACPI flag must be set for ARM platforms."
134 );
135 }
136
137 #endif
138}
139
140STATIC CONST ACPI_PARSER FadtFlagParser[] = {
141 { L"WBINVD", 1, 0, L"%d", NULL, NULL, NULL, NULL },
142 { L"WBINVD_FLUSH", 1, 1, L"%d", NULL, NULL, NULL, NULL },
143 { L"PROC_C1", 1, 2, L"%d", NULL, NULL, NULL, NULL },
144 { L"P_LVL2_UP", 1, 3, L"%d", NULL, NULL, NULL, NULL },
145 { L"PWR_BUTTON", 1, 4, L"%d", NULL, NULL, NULL, NULL },
146 { L"SLP_BUTTON", 1, 5, L"%d", NULL, NULL, NULL, NULL },
147 { L"FIX_RTC", 1, 6, L"%d", NULL, NULL, NULL, NULL },
148 { L"RTC_S4", 1, 7, L"%d", NULL, NULL, NULL, NULL },
149 { L"TMR_VAL_EXT", 1, 8, L"%d", NULL, NULL, NULL, NULL },
150 { L"DCK_CAP", 1, 9, L"%d", NULL, NULL, NULL, NULL },
151 { L"RESET_REG_SUP", 1, 10, L"%d", NULL, NULL, NULL, NULL },
152 { L"SEALED_CASE", 1, 11, L"%d", NULL, NULL, NULL, NULL },
153 { L"HEADLESS", 1, 12, L"%d", NULL, NULL, NULL, NULL },
154 { L"CPU_SW_SLP", 1, 13, L"%d", NULL, NULL, NULL, NULL },
155 { L"PCI_EXP_WAK", 1, 14, L"%d", NULL, NULL, NULL, NULL },
156 { L"USE_PLATFORM_CLOCK", 1, 15, L"%d", NULL, NULL, NULL, NULL },
157 { L"S4_RTC_STS_VALID", 1, 16, L"%d", NULL, NULL, NULL, NULL },
158 { L"REMOTE_POWER_ON_CAPABLE", 1, 17, L"%d", NULL, NULL, NULL, NULL },
159 { L"FORCE_APIC_CLUSTER_MODEL", 1, 18, L"%d", NULL, NULL, NULL, NULL },
160 { L"FORCE_APIC_PHYSICAL_DESTINATION_MODE", 1, 19, L"%d", NULL, NULL, NULL, NULL },
161 { L"HW_REDUCED_ACPI", 1, 20, L"%d", NULL, NULL, NULL, NULL },
162 { L"LOW_POWER_S0_IDLE_CAPABLE", 1, 21, L"%d", NULL, NULL, NULL, NULL },
163 { L"Reserved", 10, 22, L"%d", NULL, NULL, NULL, NULL }
164};
165
174VOID
175EFIAPI
177 IN CONST CHAR16 *Format OPTIONAL,
178 IN UINT8 *Ptr,
179 IN UINT32 Length
180 )
181{
182 if (Format != NULL) {
183 Print (Format, *(UINT32 *)Ptr);
184 return;
185 }
186
187 Print (L"0x%X\n", *(UINT32 *)Ptr);
189 TRUE,
190 2,
191 NULL,
192 Ptr,
193 4,
194 PARSER_PARAMS (FadtFlagParser)
195 );
196}
197
202 PARSE_ACPI_HEADER (&AcpiHdrInfo),
203 { L"FIRMWARE_CTRL", 4, 36, L"0x%x", NULL, (VOID **)&FirmwareCtrl,
205 { L"DSDT", 4, 40, L"0x%x", NULL, (VOID **)&DsdtAddress, NULL, NULL },
206 { L"Reserved", 1, 44, L"%x", NULL, NULL, NULL, NULL },
207 { L"Preferred_PM_Profile", 1, 45, L"0x%x", NULL, NULL, NULL, NULL },
208 { L"SCI_INT", 2, 46, L"0x%x", NULL, NULL, NULL, NULL },
209 { L"SMI_CMD", 4, 48, L"0x%x", NULL, NULL, NULL, NULL },
210 { L"ACPI_ENABLE", 1, 52, L"0x%x", NULL, NULL, NULL, NULL },
211 { L"ACPI_DISABLE", 1, 53, L"0x%x", NULL, NULL, NULL, NULL },
212 { L"S4BIOS_REQ", 1, 54, L"0x%x", NULL, NULL, NULL, NULL },
213 { L"PSTATE_CNT", 1, 55, L"0x%x", NULL, NULL, NULL, NULL },
214 { L"PM1a_EVT_BLK", 4, 56, L"0x%x", NULL, NULL, NULL, NULL },
215 { L"PM1b_EVT_BLK", 4, 60, L"0x%x", NULL, NULL, NULL, NULL },
216 { L"PM1a_CNT_BLK", 4, 64, L"0x%x", NULL, NULL, NULL, NULL },
217 { L"PM1b_CNT_BLK", 4, 68, L"0x%x", NULL, NULL, NULL, NULL },
218 { L"PM2_CNT_BLK", 4, 72, L"0x%x", NULL, NULL, NULL, NULL },
219 { L"PM_TMR_BLK", 4, 76, L"0x%x", NULL, NULL, NULL, NULL },
220 { L"GPE0_BLK", 4, 80, L"0x%x", NULL, NULL, NULL, NULL },
221 { L"GPE1_BLK", 4, 84, L"0x%x", NULL, NULL, NULL, NULL },
222 { L"PM1_EVT_LEN", 1, 88, L"0x%x", NULL, NULL, NULL, NULL },
223 { L"PM1_CNT_LEN", 1, 89, L"0x%x", NULL, NULL, NULL, NULL },
224 { L"PM2_CNT_LEN", 1, 90, L"0x%x", NULL, NULL, NULL, NULL },
225 { L"PM_TMR_LEN", 1, 91, L"0x%x", NULL, NULL, NULL, NULL },
226 { L"GPE0_BLK_LEN", 1, 92, L"0x%x", NULL, NULL, NULL, NULL },
227 { L"GPE1_BLK_LEN", 1, 93, L"0x%x", NULL, NULL, NULL, NULL },
228 { L"GPE1_BASE", 1, 94, L"0x%x", NULL, NULL, NULL, NULL },
229 { L"CST_CNT", 1, 95, L"0x%x", NULL, NULL, NULL, NULL },
230 { L"P_LVL2_LAT", 2, 96, L"0x%x", NULL, NULL, NULL, NULL },
231 { L"P_LVL3_LAT", 2, 98, L"0x%x", NULL, NULL, NULL, NULL },
232 { L"FLUSH_SIZE", 2, 100, L"0x%x", NULL, NULL, NULL, NULL },
233 { L"FLUSH_STRIDE", 2, 102, L"0x%x", NULL, NULL, NULL, NULL },
234 { L"DUTY_OFFSET", 1, 104, L"0x%x", NULL, NULL, NULL, NULL },
235 { L"DUTY_WIDTH", 1, 105, L"0x%x", NULL, NULL, NULL, NULL },
236 { L"DAY_ALRM", 1, 106, L"0x%x", NULL, NULL, NULL, NULL },
237 { L"MON_ALRM", 1, 107, L"0x%x", NULL, NULL, NULL, NULL },
238 { L"CENTURY", 1, 108, L"0x%x", NULL, NULL, NULL, NULL },
239 { L"IAPC_BOOT_ARCH", 2, 109, L"0x%x", NULL, NULL, NULL, NULL },
240 { L"Reserved", 1, 111, L"0x%x", NULL, NULL, NULL, NULL },
241 { L"Flags", 4, 112, NULL, DumpFadtFlags, (VOID **)&Flags, ValidateFlags, NULL },
242 { L"RESET_REG", 12, 116, NULL, DumpGas, NULL, NULL, NULL },
243 { L"RESET_VALUE", 1, 128, L"0x%x", NULL, NULL, NULL, NULL },
244 { L"ARM_BOOT_ARCH", 2, 129, L"0x%x", NULL, NULL, NULL, NULL },
245 { L"FADT Minor Version", 1, 131, L"0x%x", NULL, (VOID **)&FadtMinorRevision,
246 NULL, NULL },
247 { L"X_FIRMWARE_CTRL", 8, 132, L"0x%lx", NULL, (VOID **)&X_FirmwareCtrl,
249 { L"X_DSDT", 8, 140, L"0x%lx", NULL, (VOID **)&X_DsdtAddress, NULL, NULL },
250 { L"X_PM1a_EVT_BLK", 12, 148, NULL, DumpGas, NULL, NULL, NULL },
251 { L"X_PM1b_EVT_BLK", 12, 160, NULL, DumpGas, NULL, NULL, NULL },
252 { L"X_PM1a_CNT_BLK", 12, 172, NULL, DumpGas, NULL, NULL, NULL },
253 { L"X_PM1b_CNT_BLK", 12, 184, NULL, DumpGas, NULL, NULL, NULL },
254 { L"X_PM2_CNT_BLK", 12, 196, NULL, DumpGas, NULL, NULL, NULL },
255 { L"X_PM_TMR_BLK", 12, 208, NULL, DumpGas, NULL, NULL, NULL },
256 { L"X_GPE0_BLK", 12, 220, NULL, DumpGas, NULL, NULL, NULL },
257 { L"X_GPE1_BLK", 12, 232, NULL, DumpGas, NULL, NULL, NULL },
258 { L"SLEEP_CONTROL_REG", 12, 244, NULL, DumpGas, NULL, NULL, NULL },
259 { L"SLEEP_STATUS_REG", 12, 256, NULL, DumpGas, NULL, NULL, NULL },
260 { L"Hypervisor VendorIdentity", 8, 268, L"%lx", NULL, NULL, NULL, NULL }
261};
262
274VOID
275EFIAPI
277 IN BOOLEAN Trace,
278 IN UINT8 *Ptr,
279 IN UINT32 AcpiTableLength,
280 IN UINT8 AcpiTableRevision
281 )
282{
283 EFI_STATUS Status;
284 UINT8 *DsdtPtr;
285 UINT8 *FirmwareCtrlPtr;
286 UINT32 FacsSignature;
287 UINT32 FacsLength;
288 UINT8 FacsRevision;
289 PARSE_ACPI_TABLE_PROC FacsParserProc;
290
291 ParseAcpi (
292 Trace,
293 0,
294 "FADT",
295 Ptr,
296 AcpiTableLength,
298 );
299
300 if (Trace) {
301 if (FadtMinorRevision != NULL) {
302 Print (L"\nSummary:\n");
303 PrintFieldName (2, L"FADT Version");
304 Print (L"%d.%d\n", *AcpiHdrInfo.Revision, *FadtMinorRevision);
305 }
306
307 if (*GetAcpiXsdtHeaderInfo ()->OemTableId != *AcpiHdrInfo.OemTableId) {
309 Print (L"ERROR: OEM Table Id does not match with RSDT/XSDT.\n");
310 }
311 }
312
313 // If X_FIRMWARE_CTRL is not zero then use X_FIRMWARE_CTRL and ignore
314 // FIRMWARE_CTRL, else use FIRMWARE_CTRL.
315 if ((X_FirmwareCtrl != NULL) && (*X_FirmwareCtrl != 0)) {
316 FirmwareCtrlPtr = (UINT8 *)(UINTN)(*X_FirmwareCtrl);
317 } else if ((FirmwareCtrl != NULL) && (*FirmwareCtrl != 0)) {
318 FirmwareCtrlPtr = (UINT8 *)(UINTN)(*FirmwareCtrl);
319 } else {
320 FirmwareCtrlPtr = NULL;
321 // if HW_REDUCED_ACPI flag is not set, both FIRMWARE_CTRL and
322 // X_FIRMWARE_CTRL cannot be zero, and the FACS Table must be
323 // present.
324 if ((Trace) &&
325 (Flags != NULL) &&
326 ((*Flags & EFI_ACPI_6_3_HW_REDUCED_ACPI) != EFI_ACPI_6_3_HW_REDUCED_ACPI))
327 {
329 Print (
330 L"ERROR: No FACS table found, "
331 L"both X_FIRMWARE_CTRL and FIRMWARE_CTRL are zero.\n"
332 );
333 }
334 }
335
336 if (FirmwareCtrlPtr != NULL) {
337 // The FACS table does not have a standard ACPI table header. Therefore,
338 // the signature, length and version needs to be initially parsed.
339 // The FACS signature is 4 bytes starting at offset 0.
340 FacsSignature = *(UINT32 *)(FirmwareCtrlPtr + FACS_SIGNATURE_OFFSET);
341
342 // The FACS length is 4 bytes starting at offset 4.
343 FacsLength = *(UINT32 *)(FirmwareCtrlPtr + FACS_LENGTH_OFFSET);
344
345 // The FACS version is 1 byte starting at offset 32.
346 FacsRevision = *(UINT8 *)(FirmwareCtrlPtr + FACS_VERSION_OFFSET);
347
349 FacsSignature,
350 FirmwareCtrlPtr,
351 FacsLength
352 );
353
354 Status = GetParser (FacsSignature, &FacsParserProc);
355 if (EFI_ERROR (Status)) {
356 Print (
357 L"ERROR: No registered parser found for FACS.\n"
358 );
359 return;
360 }
361
362 FacsParserProc (
363 Trace,
364 FirmwareCtrlPtr,
365 FacsLength,
366 FacsRevision
367 );
368 }
369
370 // If X_DSDT is valid then use X_DSDT and ignore DSDT, else use DSDT.
371 if ((X_DsdtAddress != NULL) && (*X_DsdtAddress != 0)) {
372 DsdtPtr = (UINT8 *)(UINTN)(*X_DsdtAddress);
373 } else if ((DsdtAddress != NULL) && (*DsdtAddress != 0)) {
374 DsdtPtr = (UINT8 *)(UINTN)(*DsdtAddress);
375 } else {
376 // Both DSDT and X_DSDT cannot be invalid.
377 #if defined (MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
378 if (Trace) {
379 // The DSDT Table is mandatory for ARM systems
380 // as the CPU information MUST be presented in
381 // the DSDT.
383 Print (L"ERROR: Both X_DSDT and DSDT are invalid.\n");
384 }
385
386 #endif
387 return;
388 }
389
390 ProcessAcpiTable (DsdtPtr);
391}
UINT64 UINTN
VOID EFIAPI DumpGas(IN CONST CHAR16 *Format OPTIONAL, IN UINT8 *Ptr, IN UINT32 Length)
Definition: AcpiParser.c:867
VOID EFIAPI PrintFieldName(IN UINT32 Indent, IN CONST CHAR16 *FieldName)
Definition: AcpiParser.c:641
VOID EFIAPI IncrementErrorCount(VOID)
Definition: AcpiParser.c:83
UINT32 EFIAPI ParseAcpi(IN BOOLEAN Trace, IN UINT32 Indent, IN CONST CHAR8 *AsciiName OPTIONAL, IN UINT8 *Ptr, IN UINT32 Length, IN CONST ACPI_PARSER *Parser, IN UINT32 ParserItems)
Definition: AcpiParser.c:683
UINT32 EFIAPI ParseAcpiBitFields(IN BOOLEAN Trace, IN UINT32 Indent, IN CONST CHAR8 *AsciiName OPTIONAL, IN UINT8 *Ptr, IN UINT32 Length, IN CONST ACPI_PARSER *Parser, IN UINT32 ParserItems)
Definition: AcpiParser.c:968
#define PARSER_PARAMS(Parser)
Definition: AcpiParser.h:494
#define PARSE_ACPI_HEADER(Info)
Definition: AcpiParser.h:501
EFI_STATUS EFIAPI GetParser(IN UINT32 Signature, OUT PARSE_ACPI_TABLE_PROC *ParserProc)
VOID EFIAPI ProcessAcpiTable(IN UINT8 *Ptr)
VOID(EFIAPI * PARSE_ACPI_TABLE_PROC)(IN BOOLEAN Trace, IN UINT8 *Ptr, IN UINT32 AcpiTableLength, IN UINT8 AcpiTableRevision)
BOOLEAN ProcessTableReportOptions(IN CONST UINT32 Signature, IN CONST UINT8 *TablePtr, IN CONST UINT32 Length)
Definition: AcpiView.c:79
#define FACS_VERSION_OFFSET
Definition: FadtParser.c:40
VOID EFIAPI DumpFadtFlags(IN CONST CHAR16 *Format OPTIONAL, IN UINT8 *Ptr, IN UINT32 Length)
Definition: FadtParser.c:176
STATIC VOID EFIAPI ValidateXFirmwareCtrl(IN UINT8 *Ptr, IN UINT32 Length, IN VOID *Context)
Definition: FadtParser.c:95
CONST ACPI_DESCRIPTION_HEADER_INFO *EFIAPI GetAcpiXsdtHeaderInfo(VOID)
Definition: XsdtParser.c:31
STATIC VOID EFIAPI ValidateFlags(IN UINT8 *Ptr, IN UINT32 Length, IN VOID *Context)
Definition: FadtParser.c:123
#define FACS_SIGNATURE_OFFSET
Definition: FadtParser.c:35
STATIC VOID EFIAPI ValidateFirmwareCtrl(IN UINT8 *Ptr, IN UINT32 Length, IN VOID *Context)
Definition: FadtParser.c:67
#define HW_REDUCED_ACPI
Definition: FadtParser.c:30
VOID EFIAPI ParseAcpiFadt(IN BOOLEAN Trace, IN UINT8 *Ptr, IN UINT32 AcpiTableLength, IN UINT8 AcpiTableRevision)
Definition: FadtParser.c:276
STATIC CONST ACPI_PARSER FadtParser[]
Definition: FadtParser.c:201
#define FACS_LENGTH_OFFSET
Definition: FadtParser.c:45
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define STATIC
Definition: Base.h:264
#define TRUE
Definition: Base.h:301
#define IN
Definition: Base.h:279
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
UINTN EFIAPI Print(IN CONST CHAR16 *Format,...)
Definition: UefiLibPrint.c:113
UINT8 * Revision
Revision.
Definition: AcpiParser.h:396
UINT64 * OemTableId
OEM table Id.
Definition: AcpiParser.h:402