aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/tables/tbrsdt.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/tables/tbrsdt.c')
-rw-r--r--drivers/acpi/tables/tbrsdt.c231
1 files changed, 95 insertions, 136 deletions
diff --git a/drivers/acpi/tables/tbrsdt.c b/drivers/acpi/tables/tbrsdt.c
index b7ffe39c3626..ad0252c2f7db 100644
--- a/drivers/acpi/tables/tbrsdt.c
+++ b/drivers/acpi/tables/tbrsdt.c
@@ -41,14 +41,11 @@
41 * POSSIBILITY OF SUCH DAMAGES. 41 * POSSIBILITY OF SUCH DAMAGES.
42 */ 42 */
43 43
44
45#include <acpi/acpi.h> 44#include <acpi/acpi.h>
46#include <acpi/actables.h> 45#include <acpi/actables.h>
47 46
48
49#define _COMPONENT ACPI_TABLES 47#define _COMPONENT ACPI_TABLES
50 ACPI_MODULE_NAME ("tbrsdt") 48ACPI_MODULE_NAME("tbrsdt")
51
52 49
53/******************************************************************************* 50/*******************************************************************************
54 * 51 *
@@ -61,18 +58,13 @@
61 * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table) 58 * DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table)
62 * 59 *
63 ******************************************************************************/ 60 ******************************************************************************/
64 61acpi_status acpi_tb_verify_rsdp(struct acpi_pointer *address)
65acpi_status
66acpi_tb_verify_rsdp (
67 struct acpi_pointer *address)
68{ 62{
69 struct acpi_table_desc table_info; 63 struct acpi_table_desc table_info;
70 acpi_status status; 64 acpi_status status;
71 struct rsdp_descriptor *rsdp; 65 struct rsdp_descriptor *rsdp;
72
73
74 ACPI_FUNCTION_TRACE ("tb_verify_rsdp");
75 66
67 ACPI_FUNCTION_TRACE("tb_verify_rsdp");
76 68
77 switch (address->pointer_type) { 69 switch (address->pointer_type) {
78 case ACPI_LOGICAL_POINTER: 70 case ACPI_LOGICAL_POINTER:
@@ -84,73 +76,53 @@ acpi_tb_verify_rsdp (
84 /* 76 /*
85 * Obtain access to the RSDP structure 77 * Obtain access to the RSDP structure
86 */ 78 */
87 status = acpi_os_map_memory (address->pointer.physical, 79 status = acpi_os_map_memory(address->pointer.physical,
88 sizeof (struct rsdp_descriptor), 80 sizeof(struct rsdp_descriptor),
89 (void *) &rsdp); 81 (void *)&rsdp);
90 if (ACPI_FAILURE (status)) { 82 if (ACPI_FAILURE(status)) {
91 return_ACPI_STATUS (status); 83 return_ACPI_STATUS(status);
92 } 84 }
93 break; 85 break;
94 86
95 default: 87 default:
96 return_ACPI_STATUS (AE_BAD_PARAMETER); 88 return_ACPI_STATUS(AE_BAD_PARAMETER);
97 } 89 }
98 90
99 /* 91 /* Verify RSDP signature and checksum */
100 * The signature and checksum must both be correct
101 */
102 if (ACPI_STRNCMP ((char *) rsdp, RSDP_SIG, sizeof (RSDP_SIG)-1) != 0) {
103 /* Nope, BAD Signature */
104 92
105 status = AE_BAD_SIGNATURE; 93 status = acpi_tb_validate_rsdp(rsdp);
94 if (ACPI_FAILURE(status)) {
106 goto cleanup; 95 goto cleanup;
107 } 96 }
108 97
109 /* Check the standard checksum */
110
111 if (acpi_tb_checksum (rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) {
112 status = AE_BAD_CHECKSUM;
113 goto cleanup;
114 }
115
116 /* Check extended checksum if table version >= 2 */
117
118 if (rsdp->revision >= 2) {
119 if (acpi_tb_checksum (rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0) {
120 status = AE_BAD_CHECKSUM;
121 goto cleanup;
122 }
123 }
124
125 /* The RSDP supplied is OK */ 98 /* The RSDP supplied is OK */
126 99
127 table_info.pointer = ACPI_CAST_PTR (struct acpi_table_header, rsdp); 100 table_info.pointer = ACPI_CAST_PTR(struct acpi_table_header, rsdp);
128 table_info.length = sizeof (struct rsdp_descriptor); 101 table_info.length = sizeof(struct rsdp_descriptor);
129 table_info.allocation = ACPI_MEM_MAPPED; 102 table_info.allocation = ACPI_MEM_MAPPED;
130 103
131 /* Save the table pointers and allocation info */ 104 /* Save the table pointers and allocation info */
132 105
133 status = acpi_tb_init_table_descriptor (ACPI_TABLE_RSDP, &table_info); 106 status = acpi_tb_init_table_descriptor(ACPI_TABLE_RSDP, &table_info);
134 if (ACPI_FAILURE (status)) { 107 if (ACPI_FAILURE(status)) {
135 goto cleanup; 108 goto cleanup;
136 } 109 }
137 110
138 /* Save the RSDP in a global for easy access */ 111 /* Save the RSDP in a global for easy access */
139 112
140 acpi_gbl_RSDP = ACPI_CAST_PTR (struct rsdp_descriptor, table_info.pointer); 113 acpi_gbl_RSDP =
141 return_ACPI_STATUS (status); 114 ACPI_CAST_PTR(struct rsdp_descriptor, table_info.pointer);
142 115 return_ACPI_STATUS(status);
143 116
144 /* Error exit */ 117 /* Error exit */
145cleanup: 118 cleanup:
146 119
147 if (acpi_gbl_table_flags & ACPI_PHYSICAL_POINTER) { 120 if (acpi_gbl_table_flags & ACPI_PHYSICAL_POINTER) {
148 acpi_os_unmap_memory (rsdp, sizeof (struct rsdp_descriptor)); 121 acpi_os_unmap_memory(rsdp, sizeof(struct rsdp_descriptor));
149 } 122 }
150 return_ACPI_STATUS (status); 123 return_ACPI_STATUS(status);
151} 124}
152 125
153
154/******************************************************************************* 126/*******************************************************************************
155 * 127 *
156 * FUNCTION: acpi_tb_get_rsdt_address 128 * FUNCTION: acpi_tb_get_rsdt_address
@@ -159,35 +131,35 @@ cleanup:
159 * 131 *
160 * RETURN: None, Address 132 * RETURN: None, Address
161 * 133 *
162 * DESCRIPTION: Extract the address of the RSDT or XSDT, depending on the 134 * DESCRIPTION: Extract the address of either the RSDT or XSDT, depending on the
163 * version of the RSDP 135 * version of the RSDP and whether the XSDT pointer is valid
164 * 136 *
165 ******************************************************************************/ 137 ******************************************************************************/
166 138
167void 139void acpi_tb_get_rsdt_address(struct acpi_pointer *out_address)
168acpi_tb_get_rsdt_address (
169 struct acpi_pointer *out_address)
170{ 140{
171 141
172 ACPI_FUNCTION_ENTRY (); 142 ACPI_FUNCTION_ENTRY();
173 143
144 out_address->pointer_type =
145 acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING;
174 146
175 out_address->pointer_type = acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING; 147 /* Use XSDT if it is present */
176 148
177 /* 149 if ((acpi_gbl_RSDP->revision >= 2) &&
178 * For RSDP revision 0 or 1, we use the RSDT. 150 acpi_gbl_RSDP->xsdt_physical_address) {
179 * For RSDP revision 2 (and above), we use the XSDT
180 */
181 if (acpi_gbl_RSDP->revision < 2) {
182 out_address->pointer.value = acpi_gbl_RSDP->rsdt_physical_address;
183 }
184 else {
185 out_address->pointer.value = 151 out_address->pointer.value =
186 acpi_gbl_RSDP->xsdt_physical_address; 152 acpi_gbl_RSDP->xsdt_physical_address;
153 acpi_gbl_root_table_type = ACPI_TABLE_TYPE_XSDT;
154 } else {
155 /* No XSDT, use the RSDT */
156
157 out_address->pointer.value =
158 acpi_gbl_RSDP->rsdt_physical_address;
159 acpi_gbl_root_table_type = ACPI_TABLE_TYPE_RSDT;
187 } 160 }
188} 161}
189 162
190
191/******************************************************************************* 163/*******************************************************************************
192 * 164 *
193 * FUNCTION: acpi_tb_validate_rsdt 165 * FUNCTION: acpi_tb_validate_rsdt
@@ -200,50 +172,43 @@ acpi_tb_get_rsdt_address (
200 * 172 *
201 ******************************************************************************/ 173 ******************************************************************************/
202 174
203acpi_status 175acpi_status acpi_tb_validate_rsdt(struct acpi_table_header *table_ptr)
204acpi_tb_validate_rsdt (
205 struct acpi_table_header *table_ptr)
206{ 176{
207 int no_match; 177 int no_match;
208
209
210 ACPI_FUNCTION_NAME ("tb_validate_rsdt");
211 178
179 ACPI_FUNCTION_NAME("tb_validate_rsdt");
212 180
213 /* 181 /*
214 * For RSDP revision 0 or 1, we use the RSDT. 182 * Search for appropriate signature, RSDT or XSDT
215 * For RSDP revision 2 and above, we use the XSDT
216 */ 183 */
217 if (acpi_gbl_RSDP->revision < 2) { 184 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
218 no_match = ACPI_STRNCMP ((char *) table_ptr, RSDT_SIG, 185 no_match = ACPI_STRNCMP((char *)table_ptr, RSDT_SIG,
219 sizeof (RSDT_SIG) -1); 186 sizeof(RSDT_SIG) - 1);
220 } 187 } else {
221 else { 188 no_match = ACPI_STRNCMP((char *)table_ptr, XSDT_SIG,
222 no_match = ACPI_STRNCMP ((char *) table_ptr, XSDT_SIG, 189 sizeof(XSDT_SIG) - 1);
223 sizeof (XSDT_SIG) -1);
224 } 190 }
225 191
226 if (no_match) { 192 if (no_match) {
227 /* Invalid RSDT or XSDT signature */ 193 /* Invalid RSDT or XSDT signature */
228 194
229 ACPI_REPORT_ERROR (( 195 ACPI_REPORT_ERROR(("Invalid signature where RSDP indicates RSDT/XSDT should be located\n"));
230 "Invalid signature where RSDP indicates RSDT/XSDT should be located\n"));
231 196
232 ACPI_DUMP_BUFFER (acpi_gbl_RSDP, 20); 197 ACPI_DUMP_BUFFER(acpi_gbl_RSDP, 20);
233 198
234 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_ERROR, 199 ACPI_DEBUG_PRINT_RAW((ACPI_DB_ERROR,
235 "RSDT/XSDT signature at %X (%p) is invalid\n", 200 "RSDT/XSDT signature at %X (%p) is invalid\n",
236 acpi_gbl_RSDP->rsdt_physical_address, 201 acpi_gbl_RSDP->rsdt_physical_address,
237 (void *) (acpi_native_uint) acpi_gbl_RSDP->rsdt_physical_address)); 202 (void *)(acpi_native_uint) acpi_gbl_RSDP->
203 rsdt_physical_address));
238 204
239 if (acpi_gbl_RSDP->revision < 2) { 205 if (acpi_gbl_root_table_type == ACPI_TABLE_TYPE_RSDT) {
240 ACPI_REPORT_ERROR (("Looking for RSDT (RSDP->Rev < 2)\n")) 206 ACPI_REPORT_ERROR(("Looking for RSDT\n"))
241 } 207 } else {
242 else { 208 ACPI_REPORT_ERROR(("Looking for XSDT\n"))
243 ACPI_REPORT_ERROR (("Looking for XSDT (RSDP->Rev >= 2)\n"))
244 } 209 }
245 210
246 ACPI_DUMP_BUFFER ((char *) table_ptr, 48); 211 ACPI_DUMP_BUFFER((char *)table_ptr, 48);
247 212
248 return (AE_BAD_SIGNATURE); 213 return (AE_BAD_SIGNATURE);
249 } 214 }
@@ -251,7 +216,6 @@ acpi_tb_validate_rsdt (
251 return (AE_OK); 216 return (AE_OK);
252} 217}
253 218
254
255/******************************************************************************* 219/*******************************************************************************
256 * 220 *
257 * FUNCTION: acpi_tb_get_table_rsdt 221 * FUNCTION: acpi_tb_get_table_rsdt
@@ -264,66 +228,61 @@ acpi_tb_validate_rsdt (
264 * 228 *
265 ******************************************************************************/ 229 ******************************************************************************/
266 230
267acpi_status 231acpi_status acpi_tb_get_table_rsdt(void)
268acpi_tb_get_table_rsdt (
269 void)
270{ 232{
271 struct acpi_table_desc table_info; 233 struct acpi_table_desc table_info;
272 acpi_status status; 234 acpi_status status;
273 struct acpi_pointer address; 235 struct acpi_pointer address;
274
275
276 ACPI_FUNCTION_TRACE ("tb_get_table_rsdt");
277 236
237 ACPI_FUNCTION_TRACE("tb_get_table_rsdt");
278 238
279 /* Get the RSDT/XSDT via the RSDP */ 239 /* Get the RSDT/XSDT via the RSDP */
280 240
281 acpi_tb_get_rsdt_address (&address); 241 acpi_tb_get_rsdt_address(&address);
282 242
283 table_info.type = ACPI_TABLE_XSDT; 243 table_info.type = ACPI_TABLE_XSDT;
284 status = acpi_tb_get_table (&address, &table_info); 244 status = acpi_tb_get_table(&address, &table_info);
285 if (ACPI_FAILURE (status)) { 245 if (ACPI_FAILURE(status)) {
286 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Could not get the RSDT/XSDT, %s\n", 246 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
287 acpi_format_exception (status))); 247 "Could not get the RSDT/XSDT, %s\n",
248 acpi_format_exception(status)));
288 249
289 return_ACPI_STATUS (status); 250 return_ACPI_STATUS(status);
290 } 251 }
291 252
292 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, 253 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
293 "RSDP located at %p, points to RSDT physical=%8.8X%8.8X \n", 254 "RSDP located at %p, points to RSDT physical=%8.8X%8.8X \n",
294 acpi_gbl_RSDP, 255 acpi_gbl_RSDP,
295 ACPI_FORMAT_UINT64 (address.pointer.value))); 256 ACPI_FORMAT_UINT64(address.pointer.value)));
296 257
297 /* Check the RSDT or XSDT signature */ 258 /* Check the RSDT or XSDT signature */
298 259
299 status = acpi_tb_validate_rsdt (table_info.pointer); 260 status = acpi_tb_validate_rsdt(table_info.pointer);
300 if (ACPI_FAILURE (status)) { 261 if (ACPI_FAILURE(status)) {
301 return_ACPI_STATUS (status); 262 return_ACPI_STATUS(status);
302 } 263 }
303 264
304 /* Get the number of tables defined in the RSDT or XSDT */ 265 /* Get the number of tables defined in the RSDT or XSDT */
305 266
306 acpi_gbl_rsdt_table_count = acpi_tb_get_table_count (acpi_gbl_RSDP, 267 acpi_gbl_rsdt_table_count = acpi_tb_get_table_count(acpi_gbl_RSDP,
307 table_info.pointer); 268 table_info.pointer);
308 269
309 /* Convert and/or copy to an XSDT structure */ 270 /* Convert and/or copy to an XSDT structure */
310 271
311 status = acpi_tb_convert_to_xsdt (&table_info); 272 status = acpi_tb_convert_to_xsdt(&table_info);
312 if (ACPI_FAILURE (status)) { 273 if (ACPI_FAILURE(status)) {
313 return_ACPI_STATUS (status); 274 return_ACPI_STATUS(status);
314 } 275 }
315 276
316 /* Save the table pointers and allocation info */ 277 /* Save the table pointers and allocation info */
317 278
318 status = acpi_tb_init_table_descriptor (ACPI_TABLE_XSDT, &table_info); 279 status = acpi_tb_init_table_descriptor(ACPI_TABLE_XSDT, &table_info);
319 if (ACPI_FAILURE (status)) { 280 if (ACPI_FAILURE(status)) {
320 return_ACPI_STATUS (status); 281 return_ACPI_STATUS(status);
321 } 282 }
322 283
323 acpi_gbl_XSDT = ACPI_CAST_PTR (XSDT_DESCRIPTOR, table_info.pointer); 284 acpi_gbl_XSDT = ACPI_CAST_PTR(XSDT_DESCRIPTOR, table_info.pointer);
324 285
325 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "XSDT located at %p\n", acpi_gbl_XSDT)); 286 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "XSDT located at %p\n", acpi_gbl_XSDT));
326 return_ACPI_STATUS (status); 287 return_ACPI_STATUS(status);
327} 288}
328
329