]>
Commit | Line | Data |
---|---|---|
a6eaba4d | 1 | /** @file\r |
ee4dc24f RN |
2 | RSDP table parser\r |
3 | \r | |
4 | Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.\r | |
5 | This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | @par Reference(s):\r | |
14 | - ACPI 6.2 Specification - Errata A, September 2017\r | |
15 | **/\r | |
16 | \r | |
17 | #include <Library/UefiLib.h>\r | |
18 | #include "AcpiParser.h"\r | |
19 | #include "AcpiTableParser.h"\r | |
20 | \r | |
21 | // Local Variables\r | |
22 | STATIC CONST UINT64* XsdtAddress;\r | |
23 | \r | |
a6eaba4d DB |
24 | /**\r |
25 | This function validates the RSDT Address.\r | |
ee4dc24f RN |
26 | \r |
27 | @param [in] Ptr Pointer to the start of the field data.\r | |
28 | @param [in] Context Pointer to context specific information e.g. this\r | |
29 | could be a pointer to the ACPI table header.\r | |
a6eaba4d | 30 | **/\r |
ee4dc24f RN |
31 | STATIC\r |
32 | VOID\r | |
33 | EFIAPI\r | |
34 | ValidateRsdtAddress (\r | |
35 | IN UINT8* Ptr,\r | |
36 | IN VOID* Context\r | |
37 | );\r | |
38 | \r | |
a6eaba4d DB |
39 | /**\r |
40 | This function validates the XSDT Address.\r | |
ee4dc24f RN |
41 | \r |
42 | @param [in] Ptr Pointer to the start of the field data.\r | |
43 | @param [in] Context Pointer to context specific information e.g. this\r | |
44 | could be a pointer to the ACPI table header.\r | |
a6eaba4d | 45 | **/\r |
ee4dc24f RN |
46 | STATIC\r |
47 | VOID\r | |
48 | EFIAPI\r | |
49 | ValidateXsdtAddress (\r | |
50 | IN UINT8* Ptr,\r | |
51 | IN VOID* Context\r | |
52 | );\r | |
53 | \r | |
a6eaba4d DB |
54 | /**\r |
55 | An array describing the ACPI RSDP Table.\r | |
56 | **/\r | |
ee4dc24f RN |
57 | STATIC CONST ACPI_PARSER RsdpParser[] = {\r |
58 | {L"Signature", 8, 0, NULL, Dump8Chars, NULL, NULL, NULL},\r | |
59 | {L"Checksum", 1, 8, L"0x%x", NULL, NULL, NULL, NULL},\r | |
60 | {L"Oem ID", 6, 9, NULL, Dump6Chars, NULL, NULL, NULL},\r | |
61 | {L"Revision", 1, 15, L"%d", NULL, NULL, NULL, NULL},\r | |
62 | {L"RSDT Address", 4, 16, L"0x%x", NULL, NULL, ValidateRsdtAddress, NULL},\r | |
63 | {L"Length", 4, 20, L"%d", NULL, NULL, NULL, NULL},\r | |
64 | {L"XSDT Address", 8, 24, L"0x%lx", NULL, (VOID**)&XsdtAddress,\r | |
65 | ValidateXsdtAddress, NULL},\r | |
66 | {L"Extended Checksum", 1, 32, L"0x%x", NULL, NULL, NULL, NULL},\r | |
67 | {L"Reserved", 3, 33, L"%x %x %x", Dump3Chars, NULL, NULL, NULL}\r | |
68 | };\r | |
69 | \r | |
a6eaba4d DB |
70 | /**\r |
71 | This function validates the RSDT Address.\r | |
ee4dc24f RN |
72 | \r |
73 | @param [in] Ptr Pointer to the start of the field data.\r | |
74 | @param [in] Context Pointer to context specific information e.g. this\r | |
75 | could be a pointer to the ACPI table header.\r | |
a6eaba4d | 76 | **/\r |
ee4dc24f RN |
77 | STATIC\r |
78 | VOID\r | |
79 | EFIAPI\r | |
80 | ValidateRsdtAddress (\r | |
81 | IN UINT8* Ptr,\r | |
82 | IN VOID* Context\r | |
83 | )\r | |
84 | {\r | |
85 | #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)\r | |
86 | // Reference: Server Base Boot Requirements System Software on ARM Platforms\r | |
87 | // Section: 4.2.1.1 RSDP\r | |
88 | // Root System Description Pointer (RSDP), ACPI ? 5.2.5.\r | |
89 | // - Within the RSDP, the RsdtAddress field must be null (zero) and the\r | |
90 | // XsdtAddresss MUST be a valid, non-null, 64-bit value.\r | |
f75c7478 DB |
91 | UINT32 RsdtAddr;\r |
92 | \r | |
93 | RsdtAddr = *(UINT32*)Ptr;\r | |
94 | \r | |
ee4dc24f RN |
95 | if (RsdtAddr != 0) {\r |
96 | IncrementErrorCount ();\r | |
97 | Print (\r | |
98 | L"\nERROR: Rsdt Address = 0x%p. This must be NULL on ARM Platforms.",\r | |
99 | RsdtAddr\r | |
100 | );\r | |
101 | }\r | |
102 | #endif\r | |
103 | }\r | |
104 | \r | |
a6eaba4d DB |
105 | /**\r |
106 | This function validates the XSDT Address.\r | |
ee4dc24f RN |
107 | \r |
108 | @param [in] Ptr Pointer to the start of the field data.\r | |
109 | @param [in] Context Pointer to context specific information e.g. this\r | |
110 | could be a pointer to the ACPI table header.\r | |
a6eaba4d | 111 | **/\r |
ee4dc24f RN |
112 | STATIC\r |
113 | VOID\r | |
114 | EFIAPI\r | |
115 | ValidateXsdtAddress (\r | |
116 | IN UINT8* Ptr,\r | |
117 | IN VOID* Context\r | |
118 | )\r | |
119 | {\r | |
120 | #if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)\r | |
121 | // Reference: Server Base Boot Requirements System Software on ARM Platforms\r | |
122 | // Section: 4.2.1.1 RSDP\r | |
123 | // Root System Description Pointer (RSDP), ACPI ? 5.2.5.\r | |
124 | // - Within the RSDP, the RsdtAddress field must be null (zero) and the\r | |
125 | // XsdtAddresss MUST be a valid, non-null, 64-bit value.\r | |
f75c7478 DB |
126 | UINT64 XsdtAddr;\r |
127 | \r | |
128 | XsdtAddr = *(UINT64*)Ptr;\r | |
129 | \r | |
ee4dc24f RN |
130 | if (XsdtAddr == 0) {\r |
131 | IncrementErrorCount ();\r | |
132 | Print (\r | |
133 | L"\nERROR: Xsdt Address = 0x%p. This must not be NULL on ARM Platforms.",\r | |
134 | XsdtAddr\r | |
135 | );\r | |
136 | }\r | |
137 | #endif\r | |
138 | }\r | |
139 | \r | |
a6eaba4d DB |
140 | /**\r |
141 | This function parses the ACPI RSDP table.\r | |
ee4dc24f RN |
142 | \r |
143 | This function invokes the parser for the XSDT table.\r | |
144 | * Note - This function does not support parsing of RSDT table.\r | |
145 | \r | |
146 | This function also performs a RAW dump of the ACPI table and\r | |
147 | validates the checksum.\r | |
148 | \r | |
149 | @param [in] Trace If TRUE, trace the ACPI fields.\r | |
150 | @param [in] Ptr Pointer to the start of the buffer.\r | |
151 | @param [in] AcpiTableLength Length of the ACPI table.\r | |
152 | @param [in] AcpiTableRevision Revision of the ACPI table.\r | |
a6eaba4d | 153 | **/\r |
ee4dc24f RN |
154 | VOID\r |
155 | EFIAPI\r | |
156 | ParseAcpiRsdp (\r | |
157 | IN BOOLEAN Trace,\r | |
158 | IN UINT8* Ptr,\r | |
159 | IN UINT32 AcpiTableLength,\r | |
160 | IN UINT8 AcpiTableRevision\r | |
161 | )\r | |
162 | {\r | |
163 | if (Trace) {\r | |
164 | DumpRaw (Ptr, AcpiTableLength);\r | |
165 | VerifyChecksum (TRUE, Ptr, AcpiTableLength);\r | |
166 | }\r | |
167 | \r | |
168 | ParseAcpi (Trace, 0, "RSDP", Ptr, AcpiTableLength, PARSER_PARAMS (RsdpParser));\r | |
169 | \r | |
170 | // This code currently supports parsing of XSDT table only\r | |
171 | // and does not parse the RSDT table. Platforms provide the\r | |
172 | // RSDT to enable compatibility with ACPI 1.0 operating systems.\r | |
173 | // Therefore the RSDT should not be used on ARM platforms.\r | |
174 | if ((*XsdtAddress) == 0) {\r | |
175 | IncrementErrorCount ();\r | |
176 | Print (L"ERROR: XSDT Pointer is not set.\n");\r | |
177 | return;\r | |
178 | }\r | |
179 | \r | |
180 | ProcessAcpiTable ((UINT8*)(UINTN)(*XsdtAddress));\r | |
181 | }\r |