]>
Commit | Line | Data |
---|---|---|
a6eaba4d | 1 | /** @file\r |
ee4dc24f RN |
2 | XSDT table parser\r |
3 | \r | |
eefa8f8b | 4 | Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.\r |
56ba3746 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
ee4dc24f RN |
6 | \r |
7 | @par Reference(s):\r | |
8 | - ACPI 6.2 Specification - Errata A, September 2017\r | |
9 | **/\r | |
10 | \r | |
11 | #include <IndustryStandard/Acpi.h>\r | |
12 | #include <Library/UefiLib.h>\r | |
13 | #include <Library/PrintLib.h>\r | |
14 | #include "AcpiParser.h"\r | |
15 | #include "AcpiTableParser.h"\r | |
16 | \r | |
17 | // Local variables\r | |
47d20b54 | 18 | STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;\r |
ee4dc24f RN |
19 | \r |
20 | /** An ACPI_PARSER array describing the ACPI XSDT table.\r | |
21 | */\r | |
47d20b54 | 22 | STATIC CONST ACPI_PARSER XsdtParser[] = {\r |
ee4dc24f RN |
23 | PARSE_ACPI_HEADER (&AcpiHdrInfo)\r |
24 | };\r | |
25 | \r | |
a6eaba4d DB |
26 | /**\r |
27 | Get the ACPI XSDT header info.\r | |
28 | **/\r | |
b6e48ec6 | 29 | CONST ACPI_DESCRIPTION_HEADER_INFO *\r |
ee4dc24f RN |
30 | EFIAPI\r |
31 | GetAcpiXsdtHeaderInfo (\r | |
32 | VOID\r | |
47d20b54 | 33 | )\r |
ee4dc24f RN |
34 | {\r |
35 | return &AcpiHdrInfo;\r | |
36 | }\r | |
37 | \r | |
a6eaba4d DB |
38 | /**\r |
39 | This function parses the ACPI XSDT table and optionally traces the ACPI table fields.\r | |
ee4dc24f RN |
40 | \r |
41 | This function also performs validation of the XSDT table.\r | |
42 | \r | |
43 | @param [in] Trace If TRUE, trace the ACPI fields.\r | |
44 | @param [in] Ptr Pointer to the start of the buffer.\r | |
45 | @param [in] AcpiTableLength Length of the ACPI table.\r | |
46 | @param [in] AcpiTableRevision Revision of the ACPI table.\r | |
a6eaba4d | 47 | **/\r |
ee4dc24f RN |
48 | VOID\r |
49 | EFIAPI\r | |
50 | ParseAcpiXsdt (\r | |
47d20b54 MK |
51 | IN BOOLEAN Trace,\r |
52 | IN UINT8 *Ptr,\r | |
53 | IN UINT32 AcpiTableLength,\r | |
54 | IN UINT8 AcpiTableRevision\r | |
ee4dc24f RN |
55 | )\r |
56 | {\r | |
47d20b54 MK |
57 | UINT32 Offset;\r |
58 | UINT32 TableOffset;\r | |
59 | UINT64 *TablePointer;\r | |
60 | UINTN EntryIndex;\r | |
61 | CHAR16 Buffer[32];\r | |
ee4dc24f | 62 | \r |
ee4dc24f RN |
63 | Offset = ParseAcpi (\r |
64 | Trace,\r | |
65 | 0,\r | |
66 | "XSDT",\r | |
67 | Ptr,\r | |
eefa8f8b | 68 | AcpiTableLength,\r |
ee4dc24f RN |
69 | PARSER_PARAMS (XsdtParser)\r |
70 | );\r | |
71 | \r | |
72 | TableOffset = Offset;\r | |
73 | \r | |
74 | if (Trace) {\r | |
47d20b54 MK |
75 | EntryIndex = 0;\r |
76 | TablePointer = (UINT64 *)(Ptr + TableOffset);\r | |
eefa8f8b | 77 | while (Offset < AcpiTableLength) {\r |
47d20b54 MK |
78 | CONST UINT32 *Signature;\r |
79 | CONST UINT32 *Length;\r | |
80 | CONST UINT8 *Revision;\r | |
ee4dc24f | 81 | \r |
47d20b54 MK |
82 | if ((UINT64 *)(UINTN)(*TablePointer) != NULL) {\r |
83 | UINT8 *SignaturePtr;\r | |
ee4dc24f RN |
84 | \r |
85 | ParseAcpiHeader (\r | |
47d20b54 | 86 | (UINT8 *)(UINTN)(*TablePointer),\r |
ee4dc24f RN |
87 | &Signature,\r |
88 | &Length,\r | |
89 | &Revision\r | |
90 | );\r | |
91 | \r | |
47d20b54 | 92 | SignaturePtr = (UINT8 *)Signature;\r |
ee4dc24f RN |
93 | \r |
94 | UnicodeSPrint (\r | |
95 | Buffer,\r | |
96 | sizeof (Buffer),\r | |
97 | L"Entry[%d] - %c%c%c%c",\r | |
98 | EntryIndex++,\r | |
68bef3f0 A |
99 | SignaturePtr[0],\r |
100 | SignaturePtr[1],\r | |
101 | SignaturePtr[2],\r | |
102 | SignaturePtr[3]\r | |
ee4dc24f RN |
103 | );\r |
104 | } else {\r | |
105 | UnicodeSPrint (\r | |
106 | Buffer,\r | |
107 | sizeof (Buffer),\r | |
108 | L"Entry[%d]",\r | |
109 | EntryIndex++\r | |
110 | );\r | |
111 | }\r | |
112 | \r | |
113 | PrintFieldName (2, Buffer);\r | |
114 | Print (L"0x%lx\n", *TablePointer);\r | |
115 | \r | |
116 | // Validate the table pointers are not NULL\r | |
47d20b54 | 117 | if ((UINT64 *)(UINTN)(*TablePointer) == NULL) {\r |
ee4dc24f RN |
118 | IncrementErrorCount ();\r |
119 | Print (\r | |
120 | L"ERROR: Invalid table entry at 0x%lx, table address is 0x%lx\n",\r | |
121 | TablePointer,\r | |
122 | *TablePointer\r | |
123 | );\r | |
124 | }\r | |
47d20b54 | 125 | \r |
ee4dc24f RN |
126 | Offset += sizeof (UINT64);\r |
127 | TablePointer++;\r | |
128 | } // while\r | |
129 | }\r | |
130 | \r | |
131 | // Process the tables\r | |
47d20b54 MK |
132 | Offset = TableOffset;\r |
133 | TablePointer = (UINT64 *)(Ptr + TableOffset);\r | |
eefa8f8b | 134 | while (Offset < AcpiTableLength) {\r |
47d20b54 MK |
135 | if ((UINT64 *)(UINTN)(*TablePointer) != NULL) {\r |
136 | ProcessAcpiTable ((UINT8 *)(UINTN)(*TablePointer));\r | |
ee4dc24f | 137 | }\r |
47d20b54 | 138 | \r |
ee4dc24f RN |
139 | Offset += sizeof (UINT64);\r |
140 | TablePointer++;\r | |
141 | } // while\r | |
142 | }\r |