]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /****************************************************************************** |
2 | * | |
f3d2e786 | 3 | * Module Name: tbutils - table utilities |
1da177e4 LT |
4 | * |
5 | *****************************************************************************/ | |
6 | ||
7 | /* | |
75a44ce0 | 8 | * Copyright (C) 2000 - 2008, Intel Corp. |
1da177e4 LT |
9 | * All rights reserved. |
10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | |
15 | * notice, this list of conditions, and the following disclaimer, | |
16 | * without modification. | |
17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | |
18 | * substantially similar to the "NO WARRANTY" disclaimer below | |
19 | * ("Disclaimer") and any redistribution must be conditioned upon | |
20 | * including a substantially similar Disclaimer requirement for further | |
21 | * binary redistribution. | |
22 | * 3. Neither the names of the above-listed copyright holders nor the names | |
23 | * of any contributors may be used to endorse or promote products derived | |
24 | * from this software without specific prior written permission. | |
25 | * | |
26 | * Alternatively, this software may be distributed under the terms of the | |
27 | * GNU General Public License ("GPL") version 2 as published by the Free | |
28 | * Software Foundation. | |
29 | * | |
30 | * NO WARRANTY | |
31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | |
34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | |
40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
41 | * POSSIBILITY OF SUCH DAMAGES. | |
42 | */ | |
43 | ||
1da177e4 | 44 | #include <acpi/acpi.h> |
e2f7a777 LB |
45 | #include "accommon.h" |
46 | #include "actables.h" | |
1da177e4 | 47 | |
1da177e4 | 48 | #define _COMPONENT ACPI_TABLES |
4be44fcd | 49 | ACPI_MODULE_NAME("tbutils") |
1da177e4 | 50 | |
44f6c012 | 51 | /* Local prototypes */ |
a4bbb810 | 52 | static acpi_physical_address |
67a119f9 BM |
53 | acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size); |
54 | ||
9f3119b7 ZY |
55 | /******************************************************************************* |
56 | * | |
57 | * FUNCTION: acpi_tb_check_xsdt | |
58 | * | |
59 | * PARAMETERS: address - Pointer to the XSDT | |
60 | * | |
61 | * RETURN: status | |
62 | * AE_OK - XSDT is okay | |
63 | * AE_NO_MEMORY - can't map XSDT | |
64 | * AE_INVALID_TABLE_LENGTH - invalid table length | |
65 | * AE_NULL_ENTRY - XSDT has NULL entry | |
66 | * | |
67 | * DESCRIPTION: validate XSDT | |
68 | ******************************************************************************/ | |
69 | ||
70 | static acpi_status | |
71 | acpi_tb_check_xsdt(acpi_physical_address address) | |
72 | { | |
73 | struct acpi_table_header *table; | |
74 | u32 length; | |
75 | u64 xsdt_entry_address; | |
76 | u8 *table_entry; | |
77 | u32 table_count; | |
78 | int i; | |
79 | ||
80 | table = acpi_os_map_memory(address, sizeof(struct acpi_table_header)); | |
81 | if (!table) | |
82 | return AE_NO_MEMORY; | |
83 | ||
84 | length = table->length; | |
85 | acpi_os_unmap_memory(table, sizeof(struct acpi_table_header)); | |
86 | if (length < sizeof(struct acpi_table_header)) | |
87 | return AE_INVALID_TABLE_LENGTH; | |
88 | ||
89 | table = acpi_os_map_memory(address, length); | |
90 | if (!table) | |
91 | return AE_NO_MEMORY; | |
92 | ||
93 | /* Calculate the number of tables described in XSDT */ | |
94 | table_count = | |
95 | (u32) ((table->length - | |
96 | sizeof(struct acpi_table_header)) / sizeof(u64)); | |
97 | table_entry = | |
98 | ACPI_CAST_PTR(u8, table) + sizeof(struct acpi_table_header); | |
99 | for (i = 0; i < table_count; i++) { | |
100 | ACPI_MOVE_64_TO_64(&xsdt_entry_address, table_entry); | |
101 | if (!xsdt_entry_address) { | |
102 | /* XSDT has NULL entry */ | |
103 | break; | |
104 | } | |
105 | table_entry += sizeof(u64); | |
106 | } | |
107 | acpi_os_unmap_memory(table, length); | |
108 | ||
109 | if (i < table_count) | |
110 | return AE_NULL_ENTRY; | |
111 | else | |
112 | return AE_OK; | |
113 | } | |
a4bbb810 | 114 | |
009c4cbe BM |
115 | /******************************************************************************* |
116 | * | |
117 | * FUNCTION: acpi_tb_initialize_facs | |
118 | * | |
119 | * PARAMETERS: None | |
120 | * | |
121 | * RETURN: Status | |
122 | * | |
123 | * DESCRIPTION: Create a permanent mapping for the FADT and save it in a global | |
124 | * for accessing the Global Lock and Firmware Waking Vector | |
125 | * | |
126 | ******************************************************************************/ | |
127 | ||
128 | acpi_status acpi_tb_initialize_facs(void) | |
129 | { | |
130 | acpi_status status; | |
131 | ||
132 | status = acpi_get_table_by_index(ACPI_TABLE_INDEX_FACS, | |
133 | ACPI_CAST_INDIRECT_PTR(struct | |
134 | acpi_table_header, | |
135 | &acpi_gbl_FACS)); | |
136 | return status; | |
137 | } | |
138 | ||
c857303a BM |
139 | /******************************************************************************* |
140 | * | |
141 | * FUNCTION: acpi_tb_tables_loaded | |
142 | * | |
143 | * PARAMETERS: None | |
144 | * | |
145 | * RETURN: TRUE if required ACPI tables are loaded | |
146 | * | |
147 | * DESCRIPTION: Determine if the minimum required ACPI tables are present | |
148 | * (FADT, FACS, DSDT) | |
149 | * | |
150 | ******************************************************************************/ | |
151 | ||
152 | u8 acpi_tb_tables_loaded(void) | |
153 | { | |
154 | ||
155 | if (acpi_gbl_root_table_list.count >= 3) { | |
156 | return (TRUE); | |
157 | } | |
158 | ||
159 | return (FALSE); | |
160 | } | |
161 | ||
0c9938cc RM |
162 | /******************************************************************************* |
163 | * | |
f3d2e786 | 164 | * FUNCTION: acpi_tb_print_table_header |
0c9938cc | 165 | * |
f3d2e786 BM |
166 | * PARAMETERS: Address - Table physical address |
167 | * Header - Table header | |
0c9938cc | 168 | * |
f3d2e786 | 169 | * RETURN: None |
0c9938cc | 170 | * |
c5fc42ac | 171 | * DESCRIPTION: Print an ACPI table header. Special cases for FACS and RSDP. |
0c9938cc RM |
172 | * |
173 | ******************************************************************************/ | |
174 | ||
f3d2e786 BM |
175 | void |
176 | acpi_tb_print_table_header(acpi_physical_address address, | |
177 | struct acpi_table_header *header) | |
0c9938cc | 178 | { |
0c9938cc | 179 | |
b6bc342d BM |
180 | /* |
181 | * The reason that the Address is cast to a void pointer is so that we | |
182 | * can use %p which will work properly on both 32-bit and 64-bit hosts. | |
183 | */ | |
c5fc42ac BM |
184 | if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_FACS)) { |
185 | ||
b6bc342d | 186 | /* FACS only has signature and length fields */ |
c5fc42ac | 187 | |
b6bc342d BM |
188 | ACPI_INFO((AE_INFO, "%4.4s %p %05X", |
189 | header->signature, ACPI_CAST_PTR(void, address), | |
c5fc42ac BM |
190 | header->length)); |
191 | } else if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_RSDP)) { | |
192 | ||
193 | /* RSDP has no common fields */ | |
194 | ||
b6bc342d BM |
195 | ACPI_INFO((AE_INFO, "RSDP %p %05X (v%.2d %6.6s)", |
196 | ACPI_CAST_PTR (void, address), | |
a4bbb810 BM |
197 | (ACPI_CAST_PTR(struct acpi_table_rsdp, header)-> |
198 | revision > | |
199 | 0) ? ACPI_CAST_PTR(struct acpi_table_rsdp, | |
200 | header)->length : 20, | |
201 | ACPI_CAST_PTR(struct acpi_table_rsdp, | |
202 | header)->revision, | |
203 | ACPI_CAST_PTR(struct acpi_table_rsdp, | |
204 | header)->oem_id)); | |
c5fc42ac | 205 | } else { |
4bf27393 BM |
206 | /* Standard ACPI table with full common header */ |
207 | ||
c5fc42ac | 208 | ACPI_INFO((AE_INFO, |
b6bc342d BM |
209 | "%4.4s %p %05X (v%.2d %6.6s %8.8s %08X %4.4s %08X)", |
210 | header->signature, ACPI_CAST_PTR (void, address), | |
c5fc42ac BM |
211 | header->length, header->revision, header->oem_id, |
212 | header->oem_table_id, header->oem_revision, | |
213 | header->asl_compiler_id, | |
214 | header->asl_compiler_revision)); | |
215 | } | |
0c9938cc RM |
216 | } |
217 | ||
c5fc42ac BM |
218 | /******************************************************************************* |
219 | * | |
220 | * FUNCTION: acpi_tb_validate_checksum | |
221 | * | |
222 | * PARAMETERS: Table - ACPI table to verify | |
223 | * Length - Length of entire table | |
224 | * | |
225 | * RETURN: Status | |
226 | * | |
227 | * DESCRIPTION: Verifies that the table checksums to zero. Optionally returns | |
228 | * exception on bad checksum. | |
229 | * | |
230 | ******************************************************************************/ | |
231 | ||
232 | acpi_status acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length) | |
233 | { | |
234 | u8 checksum; | |
235 | ||
236 | /* Compute the checksum on the table */ | |
237 | ||
238 | checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, table), length); | |
239 | ||
240 | /* Checksum ok? (should be zero) */ | |
241 | ||
242 | if (checksum) { | |
243 | ACPI_WARNING((AE_INFO, | |
98af37fb | 244 | "Incorrect checksum in table [%4.4s] - %2.2X, should be %2.2X", |
c5fc42ac BM |
245 | table->signature, table->checksum, |
246 | (u8) (table->checksum - checksum))); | |
247 | ||
248 | #if (ACPI_CHECKSUM_ABORT) | |
249 | ||
250 | return (AE_BAD_CHECKSUM); | |
251 | #endif | |
252 | } | |
253 | ||
254 | return (AE_OK); | |
255 | } | |
256 | ||
1da177e4 LT |
257 | /******************************************************************************* |
258 | * | |
f3d2e786 | 259 | * FUNCTION: acpi_tb_checksum |
1da177e4 | 260 | * |
f3d2e786 BM |
261 | * PARAMETERS: Buffer - Pointer to memory region to be checked |
262 | * Length - Length of this memory region | |
1da177e4 | 263 | * |
f3d2e786 | 264 | * RETURN: Checksum (u8) |
1da177e4 | 265 | * |
f3d2e786 | 266 | * DESCRIPTION: Calculates circular checksum of memory region. |
1da177e4 LT |
267 | * |
268 | ******************************************************************************/ | |
269 | ||
67a119f9 | 270 | u8 acpi_tb_checksum(u8 *buffer, u32 length) |
793c2388 | 271 | { |
793c2388 | 272 | u8 sum = 0; |
f3d2e786 | 273 | u8 *end = buffer + length; |
793c2388 | 274 | |
f3d2e786 BM |
275 | while (buffer < end) { |
276 | sum = (u8) (sum + *(buffer++)); | |
793c2388 BM |
277 | } |
278 | ||
f3d2e786 | 279 | return sum; |
793c2388 BM |
280 | } |
281 | ||
1da177e4 LT |
282 | /******************************************************************************* |
283 | * | |
c5fc42ac | 284 | * FUNCTION: acpi_tb_install_table |
1da177e4 | 285 | * |
c5fc42ac | 286 | * PARAMETERS: Address - Physical address of DSDT or FACS |
c5fc42ac BM |
287 | * Signature - Table signature, NULL if no need to |
288 | * match | |
289 | * table_index - Index into root table array | |
1da177e4 | 290 | * |
c5fc42ac | 291 | * RETURN: None |
1da177e4 | 292 | * |
ac5f98db BM |
293 | * DESCRIPTION: Install an ACPI table into the global data structure. The |
294 | * table override mechanism is implemented here to allow the host | |
295 | * OS to replace any table before it is installed in the root | |
296 | * table array. | |
1da177e4 LT |
297 | * |
298 | ******************************************************************************/ | |
299 | ||
765ec201 | 300 | void |
c5fc42ac | 301 | acpi_tb_install_table(acpi_physical_address address, |
97cbb7d1 | 302 | char *signature, u32 table_index) |
1da177e4 | 303 | { |
97cbb7d1 | 304 | u8 flags; |
ac5f98db BM |
305 | acpi_status status; |
306 | struct acpi_table_header *table_to_install; | |
307 | struct acpi_table_header *mapped_table; | |
308 | struct acpi_table_header *override_table = NULL; | |
f3d2e786 | 309 | |
c5fc42ac BM |
310 | if (!address) { |
311 | ACPI_ERROR((AE_INFO, | |
312 | "Null physical address for ACPI table [%s]", | |
313 | signature)); | |
314 | return; | |
f3d2e786 BM |
315 | } |
316 | ||
c5fc42ac BM |
317 | /* Map just the table header */ |
318 | ||
ac5f98db BM |
319 | mapped_table = |
320 | acpi_os_map_memory(address, sizeof(struct acpi_table_header)); | |
321 | if (!mapped_table) { | |
c5fc42ac BM |
322 | return; |
323 | } | |
324 | ||
ac5f98db | 325 | /* If a particular signature is expected (DSDT/FACS), it must match */ |
c5fc42ac | 326 | |
ac5f98db | 327 | if (signature && !ACPI_COMPARE_NAME(mapped_table->signature, signature)) { |
c5fc42ac | 328 | ACPI_ERROR((AE_INFO, |
ac5f98db BM |
329 | "Invalid signature 0x%X for ACPI table, expected [%s]", |
330 | *ACPI_CAST_PTR(u32, mapped_table->signature), | |
331 | signature)); | |
c5fc42ac | 332 | goto unmap_and_exit; |
f3d2e786 BM |
333 | } |
334 | ||
ac5f98db BM |
335 | /* |
336 | * ACPI Table Override: | |
337 | * | |
338 | * Before we install the table, let the host OS override it with a new | |
339 | * one if desired. Any table within the RSDT/XSDT can be replaced, | |
340 | * including the DSDT which is pointed to by the FADT. | |
341 | */ | |
342 | status = acpi_os_table_override(mapped_table, &override_table); | |
343 | if (ACPI_SUCCESS(status) && override_table) { | |
344 | ACPI_INFO((AE_INFO, | |
345 | "%4.4s @ 0x%p Table override, replaced with:", | |
346 | mapped_table->signature, ACPI_CAST_PTR(void, | |
347 | address))); | |
348 | ||
349 | acpi_gbl_root_table_list.tables[table_index].pointer = | |
350 | override_table; | |
ac5f98db BM |
351 | address = ACPI_PTR_TO_PHYSADDR(override_table); |
352 | ||
353 | table_to_install = override_table; | |
97cbb7d1 | 354 | flags = ACPI_TABLE_ORIGIN_OVERRIDE; |
ac5f98db BM |
355 | } else { |
356 | table_to_install = mapped_table; | |
97cbb7d1 | 357 | flags = ACPI_TABLE_ORIGIN_MAPPED; |
ac5f98db BM |
358 | } |
359 | ||
c5fc42ac BM |
360 | /* Initialize the table entry */ |
361 | ||
362 | acpi_gbl_root_table_list.tables[table_index].address = address; | |
ac5f98db BM |
363 | acpi_gbl_root_table_list.tables[table_index].length = |
364 | table_to_install->length; | |
c5fc42ac | 365 | acpi_gbl_root_table_list.tables[table_index].flags = flags; |
f3d2e786 BM |
366 | |
367 | ACPI_MOVE_32_TO_32(& | |
c5fc42ac | 368 | (acpi_gbl_root_table_list.tables[table_index]. |
ac5f98db | 369 | signature), table_to_install->signature); |
f3d2e786 | 370 | |
ac5f98db | 371 | acpi_tb_print_table_header(address, table_to_install); |
f3d2e786 | 372 | |
c5fc42ac | 373 | if (table_index == ACPI_TABLE_INDEX_DSDT) { |
f3d2e786 | 374 | |
c5fc42ac | 375 | /* Global integer width is based upon revision of the DSDT */ |
f3d2e786 | 376 | |
ac5f98db | 377 | acpi_ut_set_integer_width(table_to_install->revision); |
c5fc42ac BM |
378 | } |
379 | ||
380 | unmap_and_exit: | |
ac5f98db | 381 | acpi_os_unmap_memory(mapped_table, sizeof(struct acpi_table_header)); |
c5fc42ac | 382 | } |
f3d2e786 | 383 | |
a4bbb810 BM |
384 | /******************************************************************************* |
385 | * | |
386 | * FUNCTION: acpi_tb_get_root_table_entry | |
387 | * | |
388 | * PARAMETERS: table_entry - Pointer to the RSDT/XSDT table entry | |
389 | * table_entry_size - sizeof 32 or 64 (RSDT or XSDT) | |
390 | * | |
391 | * RETURN: Physical address extracted from the root table | |
392 | * | |
393 | * DESCRIPTION: Get one root table entry. Handles 32-bit and 64-bit cases on | |
394 | * both 32-bit and 64-bit platforms | |
395 | * | |
396 | * NOTE: acpi_physical_address is 32-bit on 32-bit platforms, 64-bit on | |
397 | * 64-bit platforms. | |
398 | * | |
399 | ******************************************************************************/ | |
400 | ||
401 | static acpi_physical_address | |
67a119f9 | 402 | acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size) |
a4bbb810 BM |
403 | { |
404 | u64 address64; | |
405 | ||
406 | /* | |
407 | * Get the table physical address (32-bit for RSDT, 64-bit for XSDT): | |
408 | * Note: Addresses are 32-bit aligned (not 64) in both RSDT and XSDT | |
409 | */ | |
410 | if (table_entry_size == sizeof(u32)) { | |
411 | /* | |
412 | * 32-bit platform, RSDT: Return 32-bit table entry | |
413 | * 64-bit platform, RSDT: Expand 32-bit to 64-bit and return | |
414 | */ | |
415 | return ((acpi_physical_address) | |
416 | (*ACPI_CAST_PTR(u32, table_entry))); | |
417 | } else { | |
418 | /* | |
419 | * 32-bit platform, XSDT: Truncate 64-bit to 32-bit and return | |
ec41f193 BM |
420 | * 64-bit platform, XSDT: Move (unaligned) 64-bit to local, |
421 | * return 64-bit | |
a4bbb810 BM |
422 | */ |
423 | ACPI_MOVE_64_TO_64(&address64, table_entry); | |
424 | ||
425 | #if ACPI_MACHINE_WIDTH == 32 | |
426 | if (address64 > ACPI_UINT32_MAX) { | |
427 | ||
ea5d8ebc | 428 | /* Will truncate 64-bit address to 32 bits, issue warning */ |
a4bbb810 BM |
429 | |
430 | ACPI_WARNING((AE_INFO, | |
ec41f193 BM |
431 | "64-bit Physical Address in XSDT is too large (%8.8X%8.8X)," |
432 | " truncating", | |
a4bbb810 BM |
433 | ACPI_FORMAT_UINT64(address64))); |
434 | } | |
435 | #endif | |
436 | return ((acpi_physical_address) (address64)); | |
437 | } | |
438 | } | |
439 | ||
793c2388 BM |
440 | /******************************************************************************* |
441 | * | |
f3d2e786 | 442 | * FUNCTION: acpi_tb_parse_root_table |
793c2388 | 443 | * |
f3d2e786 | 444 | * PARAMETERS: Rsdp - Pointer to the RSDP |
f3d2e786 BM |
445 | * |
446 | * RETURN: Status | |
793c2388 | 447 | * |
f3d2e786 BM |
448 | * DESCRIPTION: This function is called to parse the Root System Description |
449 | * Table (RSDT or XSDT) | |
793c2388 | 450 | * |
f3d2e786 BM |
451 | * NOTE: Tables are mapped (not copied) for efficiency. The FACS must |
452 | * be mapped and cannot be copied because it contains the actual | |
453 | * memory location of the ACPI Global Lock. | |
793c2388 BM |
454 | * |
455 | ******************************************************************************/ | |
456 | ||
ad71860a | 457 | acpi_status __init |
97cbb7d1 | 458 | acpi_tb_parse_root_table(acpi_physical_address rsdp_address) |
793c2388 | 459 | { |
c5fc42ac | 460 | struct acpi_table_rsdp *rsdp; |
67a119f9 BM |
461 | u32 table_entry_size; |
462 | u32 i; | |
c5fc42ac | 463 | u32 table_count; |
f3d2e786 BM |
464 | struct acpi_table_header *table; |
465 | acpi_physical_address address; | |
8ab7367f | 466 | acpi_physical_address uninitialized_var(rsdt_address); |
f3d2e786 BM |
467 | u32 length; |
468 | u8 *table_entry; | |
f3d2e786 BM |
469 | acpi_status status; |
470 | ||
471 | ACPI_FUNCTION_TRACE(tb_parse_root_table); | |
472 | ||
c5fc42ac BM |
473 | /* |
474 | * Map the entire RSDP and extract the address of the RSDT or XSDT | |
475 | */ | |
476 | rsdp = acpi_os_map_memory(rsdp_address, sizeof(struct acpi_table_rsdp)); | |
477 | if (!rsdp) { | |
478 | return_ACPI_STATUS(AE_NO_MEMORY); | |
479 | } | |
480 | ||
481 | acpi_tb_print_table_header(rsdp_address, | |
482 | ACPI_CAST_PTR(struct acpi_table_header, | |
483 | rsdp)); | |
484 | ||
f3d2e786 BM |
485 | /* Differentiate between RSDT and XSDT root tables */ |
486 | ||
237889bf ZY |
487 | if (rsdp->revision > 1 && rsdp->xsdt_physical_address |
488 | && !acpi_rsdt_forced) { | |
f3d2e786 BM |
489 | /* |
490 | * Root table is an XSDT (64-bit physical addresses). We must use the | |
491 | * XSDT if the revision is > 1 and the XSDT pointer is present, as per | |
492 | * the ACPI specification. | |
493 | */ | |
c5fc42ac BM |
494 | address = (acpi_physical_address) rsdp->xsdt_physical_address; |
495 | table_entry_size = sizeof(u64); | |
9f3119b7 ZY |
496 | rsdt_address = (acpi_physical_address) |
497 | rsdp->rsdt_physical_address; | |
f3d2e786 BM |
498 | } else { |
499 | /* Root table is an RSDT (32-bit physical addresses) */ | |
500 | ||
c5fc42ac BM |
501 | address = (acpi_physical_address) rsdp->rsdt_physical_address; |
502 | table_entry_size = sizeof(u32); | |
f3d2e786 | 503 | } |
793c2388 | 504 | |
c5fc42ac BM |
505 | /* |
506 | * It is not possible to map more than one entry in some environments, | |
507 | * so unmap the RSDP here before mapping other tables | |
508 | */ | |
509 | acpi_os_unmap_memory(rsdp, sizeof(struct acpi_table_rsdp)); | |
510 | ||
9f3119b7 ZY |
511 | if (table_entry_size == sizeof(u64)) { |
512 | if (acpi_tb_check_xsdt(address) == AE_NULL_ENTRY) { | |
513 | /* XSDT has NULL entry, RSDT is used */ | |
514 | address = rsdt_address; | |
515 | table_entry_size = sizeof(u32); | |
4fdb2a05 | 516 | ACPI_WARNING((AE_INFO, "BIOS XSDT has NULL entry, " |
9f3119b7 ZY |
517 | "using RSDT")); |
518 | } | |
519 | } | |
c5fc42ac | 520 | /* Map the RSDT/XSDT table header to get the full table length */ |
793c2388 | 521 | |
f3d2e786 BM |
522 | table = acpi_os_map_memory(address, sizeof(struct acpi_table_header)); |
523 | if (!table) { | |
c5fc42ac | 524 | return_ACPI_STATUS(AE_NO_MEMORY); |
f3d2e786 BM |
525 | } |
526 | ||
c5fc42ac BM |
527 | acpi_tb_print_table_header(address, table); |
528 | ||
f3d2e786 BM |
529 | /* Get the length of the full table, verify length and map entire table */ |
530 | ||
531 | length = table->length; | |
532 | acpi_os_unmap_memory(table, sizeof(struct acpi_table_header)); | |
533 | ||
534 | if (length < sizeof(struct acpi_table_header)) { | |
535 | ACPI_ERROR((AE_INFO, "Invalid length 0x%X in RSDT/XSDT", | |
536 | length)); | |
c5fc42ac | 537 | return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH); |
f3d2e786 BM |
538 | } |
539 | ||
540 | table = acpi_os_map_memory(address, length); | |
541 | if (!table) { | |
c5fc42ac | 542 | return_ACPI_STATUS(AE_NO_MEMORY); |
f3d2e786 BM |
543 | } |
544 | ||
545 | /* Validate the root table checksum */ | |
546 | ||
c5fc42ac BM |
547 | status = acpi_tb_verify_checksum(table, length); |
548 | if (ACPI_FAILURE(status)) { | |
f3d2e786 | 549 | acpi_os_unmap_memory(table, length); |
c5fc42ac | 550 | return_ACPI_STATUS(status); |
f3d2e786 | 551 | } |
f3d2e786 BM |
552 | |
553 | /* Calculate the number of tables described in the root table */ | |
554 | ||
ec41f193 BM |
555 | table_count = (u32)((table->length - sizeof(struct acpi_table_header)) / |
556 | table_entry_size); | |
c5fc42ac | 557 | /* |
ec41f193 BM |
558 | * First two entries in the table array are reserved for the DSDT |
559 | * and FACS, which are not actually present in the RSDT/XSDT - they | |
560 | * come from the FADT | |
c5fc42ac | 561 | */ |
f3d2e786 BM |
562 | table_entry = |
563 | ACPI_CAST_PTR(u8, table) + sizeof(struct acpi_table_header); | |
564 | acpi_gbl_root_table_list.count = 2; | |
1da177e4 | 565 | |
f3d2e786 | 566 | /* |
c5fc42ac | 567 | * Initialize the root table array from the RSDT/XSDT |
f3d2e786 | 568 | */ |
c5fc42ac | 569 | for (i = 0; i < table_count; i++) { |
f3d2e786 BM |
570 | if (acpi_gbl_root_table_list.count >= |
571 | acpi_gbl_root_table_list.size) { | |
c5fc42ac BM |
572 | |
573 | /* There is no more room in the root table array, attempt resize */ | |
574 | ||
f3d2e786 BM |
575 | status = acpi_tb_resize_root_table_list(); |
576 | if (ACPI_FAILURE(status)) { | |
577 | ACPI_WARNING((AE_INFO, | |
578 | "Truncating %u table entries!", | |
386e4a83 MS |
579 | (unsigned) (table_count - |
580 | (acpi_gbl_root_table_list. | |
581 | count - 2)))); | |
f3d2e786 BM |
582 | break; |
583 | } | |
584 | } | |
585 | ||
a4bbb810 BM |
586 | /* Get the table physical address (32-bit for RSDT, 64-bit for XSDT) */ |
587 | ||
588 | acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count]. | |
589 | address = | |
590 | acpi_tb_get_root_table_entry(table_entry, table_entry_size); | |
f3d2e786 | 591 | |
c5fc42ac | 592 | table_entry += table_entry_size; |
f3d2e786 | 593 | acpi_gbl_root_table_list.count++; |
1da177e4 | 594 | } |
793c2388 | 595 | |
f3d2e786 BM |
596 | /* |
597 | * It is not possible to map more than one entry in some environments, | |
598 | * so unmap the root table here before mapping other tables | |
599 | */ | |
600 | acpi_os_unmap_memory(table, length); | |
601 | ||
c5fc42ac BM |
602 | /* |
603 | * Complete the initialization of the root table array by examining | |
604 | * the header of each table | |
605 | */ | |
f3d2e786 | 606 | for (i = 2; i < acpi_gbl_root_table_list.count; i++) { |
c5fc42ac | 607 | acpi_tb_install_table(acpi_gbl_root_table_list.tables[i]. |
97cbb7d1 | 608 | address, NULL, i); |
f3d2e786 | 609 | |
c5fc42ac | 610 | /* Special case for FADT - get the DSDT and FACS */ |
f3d2e786 | 611 | |
c5fc42ac BM |
612 | if (ACPI_COMPARE_NAME |
613 | (&acpi_gbl_root_table_list.tables[i].signature, | |
614 | ACPI_SIG_FADT)) { | |
97cbb7d1 | 615 | acpi_tb_parse_fadt(i); |
f3d2e786 BM |
616 | } |
617 | } | |
618 | ||
619 | return_ACPI_STATUS(AE_OK); | |
1da177e4 | 620 | } |