]>
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> |
50df4d8b | 45 | #include <acpi/accommon.h> |
1da177e4 LT |
46 | #include <acpi/actables.h> |
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 | |
c5fc42ac BM |
180 | if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_FACS)) { |
181 | ||
182 | /* FACS only has signature and length fields of common table header */ | |
183 | ||
03c6d130 LB |
184 | ACPI_INFO((AE_INFO, "%4.4s %08lX, %04X", |
185 | header->signature, (unsigned long)address, | |
c5fc42ac BM |
186 | header->length)); |
187 | } else if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_RSDP)) { | |
188 | ||
189 | /* RSDP has no common fields */ | |
190 | ||
03c6d130 LB |
191 | ACPI_INFO((AE_INFO, "RSDP %08lX, %04X (r%d %6.6s)", |
192 | (unsigned long)address, | |
a4bbb810 BM |
193 | (ACPI_CAST_PTR(struct acpi_table_rsdp, header)-> |
194 | revision > | |
195 | 0) ? ACPI_CAST_PTR(struct acpi_table_rsdp, | |
196 | header)->length : 20, | |
197 | ACPI_CAST_PTR(struct acpi_table_rsdp, | |
198 | header)->revision, | |
199 | ACPI_CAST_PTR(struct acpi_table_rsdp, | |
200 | header)->oem_id)); | |
c5fc42ac | 201 | } else { |
4bf27393 BM |
202 | /* Standard ACPI table with full common header */ |
203 | ||
c5fc42ac | 204 | ACPI_INFO((AE_INFO, |
03c6d130 LB |
205 | "%4.4s %08lX, %04X (r%d %6.6s %8.8s %8X %4.4s %8X)", |
206 | header->signature, (unsigned long)address, | |
c5fc42ac BM |
207 | header->length, header->revision, header->oem_id, |
208 | header->oem_table_id, header->oem_revision, | |
209 | header->asl_compiler_id, | |
210 | header->asl_compiler_revision)); | |
211 | } | |
0c9938cc RM |
212 | } |
213 | ||
c5fc42ac BM |
214 | /******************************************************************************* |
215 | * | |
216 | * FUNCTION: acpi_tb_validate_checksum | |
217 | * | |
218 | * PARAMETERS: Table - ACPI table to verify | |
219 | * Length - Length of entire table | |
220 | * | |
221 | * RETURN: Status | |
222 | * | |
223 | * DESCRIPTION: Verifies that the table checksums to zero. Optionally returns | |
224 | * exception on bad checksum. | |
225 | * | |
226 | ******************************************************************************/ | |
227 | ||
228 | acpi_status acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length) | |
229 | { | |
230 | u8 checksum; | |
231 | ||
232 | /* Compute the checksum on the table */ | |
233 | ||
234 | checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, table), length); | |
235 | ||
236 | /* Checksum ok? (should be zero) */ | |
237 | ||
238 | if (checksum) { | |
239 | ACPI_WARNING((AE_INFO, | |
98af37fb | 240 | "Incorrect checksum in table [%4.4s] - %2.2X, should be %2.2X", |
c5fc42ac BM |
241 | table->signature, table->checksum, |
242 | (u8) (table->checksum - checksum))); | |
243 | ||
244 | #if (ACPI_CHECKSUM_ABORT) | |
245 | ||
246 | return (AE_BAD_CHECKSUM); | |
247 | #endif | |
248 | } | |
249 | ||
250 | return (AE_OK); | |
251 | } | |
252 | ||
1da177e4 LT |
253 | /******************************************************************************* |
254 | * | |
f3d2e786 | 255 | * FUNCTION: acpi_tb_checksum |
1da177e4 | 256 | * |
f3d2e786 BM |
257 | * PARAMETERS: Buffer - Pointer to memory region to be checked |
258 | * Length - Length of this memory region | |
1da177e4 | 259 | * |
f3d2e786 | 260 | * RETURN: Checksum (u8) |
1da177e4 | 261 | * |
f3d2e786 | 262 | * DESCRIPTION: Calculates circular checksum of memory region. |
1da177e4 LT |
263 | * |
264 | ******************************************************************************/ | |
265 | ||
67a119f9 | 266 | u8 acpi_tb_checksum(u8 *buffer, u32 length) |
793c2388 | 267 | { |
793c2388 | 268 | u8 sum = 0; |
f3d2e786 | 269 | u8 *end = buffer + length; |
793c2388 | 270 | |
f3d2e786 BM |
271 | while (buffer < end) { |
272 | sum = (u8) (sum + *(buffer++)); | |
793c2388 BM |
273 | } |
274 | ||
f3d2e786 | 275 | return sum; |
793c2388 BM |
276 | } |
277 | ||
1da177e4 LT |
278 | /******************************************************************************* |
279 | * | |
c5fc42ac | 280 | * FUNCTION: acpi_tb_install_table |
1da177e4 | 281 | * |
c5fc42ac BM |
282 | * PARAMETERS: Address - Physical address of DSDT or FACS |
283 | * Flags - Flags | |
284 | * Signature - Table signature, NULL if no need to | |
285 | * match | |
286 | * table_index - Index into root table array | |
1da177e4 | 287 | * |
c5fc42ac | 288 | * RETURN: None |
1da177e4 | 289 | * |
c5fc42ac | 290 | * DESCRIPTION: Install an ACPI table into the global data structure. |
1da177e4 LT |
291 | * |
292 | ******************************************************************************/ | |
293 | ||
765ec201 | 294 | void |
c5fc42ac | 295 | acpi_tb_install_table(acpi_physical_address address, |
67a119f9 | 296 | u8 flags, char *signature, u32 table_index) |
1da177e4 | 297 | { |
f3d2e786 BM |
298 | struct acpi_table_header *table; |
299 | ||
c5fc42ac BM |
300 | if (!address) { |
301 | ACPI_ERROR((AE_INFO, | |
302 | "Null physical address for ACPI table [%s]", | |
303 | signature)); | |
304 | return; | |
f3d2e786 BM |
305 | } |
306 | ||
c5fc42ac BM |
307 | /* Map just the table header */ |
308 | ||
309 | table = acpi_os_map_memory(address, sizeof(struct acpi_table_header)); | |
f3d2e786 | 310 | if (!table) { |
c5fc42ac BM |
311 | return; |
312 | } | |
313 | ||
314 | /* If a particular signature is expected, signature must match */ | |
315 | ||
316 | if (signature && !ACPI_COMPARE_NAME(table->signature, signature)) { | |
317 | ACPI_ERROR((AE_INFO, | |
318 | "Invalid signature 0x%X for ACPI table [%s]", | |
319 | *ACPI_CAST_PTR(u32, table->signature), signature)); | |
320 | goto unmap_and_exit; | |
f3d2e786 BM |
321 | } |
322 | ||
c5fc42ac BM |
323 | /* Initialize the table entry */ |
324 | ||
325 | acpi_gbl_root_table_list.tables[table_index].address = address; | |
326 | acpi_gbl_root_table_list.tables[table_index].length = table->length; | |
327 | acpi_gbl_root_table_list.tables[table_index].flags = flags; | |
f3d2e786 BM |
328 | |
329 | ACPI_MOVE_32_TO_32(& | |
c5fc42ac BM |
330 | (acpi_gbl_root_table_list.tables[table_index]. |
331 | signature), table->signature); | |
f3d2e786 | 332 | |
c5fc42ac | 333 | acpi_tb_print_table_header(address, table); |
f3d2e786 | 334 | |
c5fc42ac | 335 | if (table_index == ACPI_TABLE_INDEX_DSDT) { |
f3d2e786 | 336 | |
c5fc42ac | 337 | /* Global integer width is based upon revision of the DSDT */ |
f3d2e786 | 338 | |
c5fc42ac BM |
339 | acpi_ut_set_integer_width(table->revision); |
340 | } | |
341 | ||
342 | unmap_and_exit: | |
f3d2e786 | 343 | acpi_os_unmap_memory(table, sizeof(struct acpi_table_header)); |
c5fc42ac | 344 | } |
f3d2e786 | 345 | |
a4bbb810 BM |
346 | /******************************************************************************* |
347 | * | |
348 | * FUNCTION: acpi_tb_get_root_table_entry | |
349 | * | |
350 | * PARAMETERS: table_entry - Pointer to the RSDT/XSDT table entry | |
351 | * table_entry_size - sizeof 32 or 64 (RSDT or XSDT) | |
352 | * | |
353 | * RETURN: Physical address extracted from the root table | |
354 | * | |
355 | * DESCRIPTION: Get one root table entry. Handles 32-bit and 64-bit cases on | |
356 | * both 32-bit and 64-bit platforms | |
357 | * | |
358 | * NOTE: acpi_physical_address is 32-bit on 32-bit platforms, 64-bit on | |
359 | * 64-bit platforms. | |
360 | * | |
361 | ******************************************************************************/ | |
362 | ||
363 | static acpi_physical_address | |
67a119f9 | 364 | acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size) |
a4bbb810 BM |
365 | { |
366 | u64 address64; | |
367 | ||
368 | /* | |
369 | * Get the table physical address (32-bit for RSDT, 64-bit for XSDT): | |
370 | * Note: Addresses are 32-bit aligned (not 64) in both RSDT and XSDT | |
371 | */ | |
372 | if (table_entry_size == sizeof(u32)) { | |
373 | /* | |
374 | * 32-bit platform, RSDT: Return 32-bit table entry | |
375 | * 64-bit platform, RSDT: Expand 32-bit to 64-bit and return | |
376 | */ | |
377 | return ((acpi_physical_address) | |
378 | (*ACPI_CAST_PTR(u32, table_entry))); | |
379 | } else { | |
380 | /* | |
381 | * 32-bit platform, XSDT: Truncate 64-bit to 32-bit and return | |
382 | * 64-bit platform, XSDT: Move (unaligned) 64-bit to local, return 64-bit | |
383 | */ | |
384 | ACPI_MOVE_64_TO_64(&address64, table_entry); | |
385 | ||
386 | #if ACPI_MACHINE_WIDTH == 32 | |
387 | if (address64 > ACPI_UINT32_MAX) { | |
388 | ||
ea5d8ebc | 389 | /* Will truncate 64-bit address to 32 bits, issue warning */ |
a4bbb810 BM |
390 | |
391 | ACPI_WARNING((AE_INFO, | |
392 | "64-bit Physical Address in XSDT is too large (%8.8X%8.8X), truncating", | |
393 | ACPI_FORMAT_UINT64(address64))); | |
394 | } | |
395 | #endif | |
396 | return ((acpi_physical_address) (address64)); | |
397 | } | |
398 | } | |
399 | ||
793c2388 BM |
400 | /******************************************************************************* |
401 | * | |
f3d2e786 | 402 | * FUNCTION: acpi_tb_parse_root_table |
793c2388 | 403 | * |
f3d2e786 BM |
404 | * PARAMETERS: Rsdp - Pointer to the RSDP |
405 | * Flags - Flags | |
406 | * | |
407 | * RETURN: Status | |
793c2388 | 408 | * |
f3d2e786 BM |
409 | * DESCRIPTION: This function is called to parse the Root System Description |
410 | * Table (RSDT or XSDT) | |
793c2388 | 411 | * |
f3d2e786 BM |
412 | * NOTE: Tables are mapped (not copied) for efficiency. The FACS must |
413 | * be mapped and cannot be copied because it contains the actual | |
414 | * memory location of the ACPI Global Lock. | |
793c2388 BM |
415 | * |
416 | ******************************************************************************/ | |
417 | ||
ad71860a | 418 | acpi_status __init |
c5fc42ac | 419 | acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags) |
793c2388 | 420 | { |
c5fc42ac | 421 | struct acpi_table_rsdp *rsdp; |
67a119f9 BM |
422 | u32 table_entry_size; |
423 | u32 i; | |
c5fc42ac | 424 | u32 table_count; |
f3d2e786 BM |
425 | struct acpi_table_header *table; |
426 | acpi_physical_address address; | |
8ab7367f | 427 | acpi_physical_address uninitialized_var(rsdt_address); |
f3d2e786 BM |
428 | u32 length; |
429 | u8 *table_entry; | |
f3d2e786 BM |
430 | acpi_status status; |
431 | ||
432 | ACPI_FUNCTION_TRACE(tb_parse_root_table); | |
433 | ||
c5fc42ac BM |
434 | /* |
435 | * Map the entire RSDP and extract the address of the RSDT or XSDT | |
436 | */ | |
437 | rsdp = acpi_os_map_memory(rsdp_address, sizeof(struct acpi_table_rsdp)); | |
438 | if (!rsdp) { | |
439 | return_ACPI_STATUS(AE_NO_MEMORY); | |
440 | } | |
441 | ||
442 | acpi_tb_print_table_header(rsdp_address, | |
443 | ACPI_CAST_PTR(struct acpi_table_header, | |
444 | rsdp)); | |
445 | ||
f3d2e786 BM |
446 | /* Differentiate between RSDT and XSDT root tables */ |
447 | ||
448 | if (rsdp->revision > 1 && rsdp->xsdt_physical_address) { | |
449 | /* | |
450 | * Root table is an XSDT (64-bit physical addresses). We must use the | |
451 | * XSDT if the revision is > 1 and the XSDT pointer is present, as per | |
452 | * the ACPI specification. | |
453 | */ | |
c5fc42ac BM |
454 | address = (acpi_physical_address) rsdp->xsdt_physical_address; |
455 | table_entry_size = sizeof(u64); | |
9f3119b7 ZY |
456 | rsdt_address = (acpi_physical_address) |
457 | rsdp->rsdt_physical_address; | |
f3d2e786 BM |
458 | } else { |
459 | /* Root table is an RSDT (32-bit physical addresses) */ | |
460 | ||
c5fc42ac BM |
461 | address = (acpi_physical_address) rsdp->rsdt_physical_address; |
462 | table_entry_size = sizeof(u32); | |
f3d2e786 | 463 | } |
793c2388 | 464 | |
c5fc42ac BM |
465 | /* |
466 | * It is not possible to map more than one entry in some environments, | |
467 | * so unmap the RSDP here before mapping other tables | |
468 | */ | |
469 | acpi_os_unmap_memory(rsdp, sizeof(struct acpi_table_rsdp)); | |
470 | ||
9f3119b7 ZY |
471 | if (table_entry_size == sizeof(u64)) { |
472 | if (acpi_tb_check_xsdt(address) == AE_NULL_ENTRY) { | |
473 | /* XSDT has NULL entry, RSDT is used */ | |
474 | address = rsdt_address; | |
475 | table_entry_size = sizeof(u32); | |
4fdb2a05 | 476 | ACPI_WARNING((AE_INFO, "BIOS XSDT has NULL entry, " |
9f3119b7 ZY |
477 | "using RSDT")); |
478 | } | |
479 | } | |
c5fc42ac | 480 | /* Map the RSDT/XSDT table header to get the full table length */ |
793c2388 | 481 | |
f3d2e786 BM |
482 | table = acpi_os_map_memory(address, sizeof(struct acpi_table_header)); |
483 | if (!table) { | |
c5fc42ac | 484 | return_ACPI_STATUS(AE_NO_MEMORY); |
f3d2e786 BM |
485 | } |
486 | ||
c5fc42ac BM |
487 | acpi_tb_print_table_header(address, table); |
488 | ||
f3d2e786 BM |
489 | /* Get the length of the full table, verify length and map entire table */ |
490 | ||
491 | length = table->length; | |
492 | acpi_os_unmap_memory(table, sizeof(struct acpi_table_header)); | |
493 | ||
494 | if (length < sizeof(struct acpi_table_header)) { | |
495 | ACPI_ERROR((AE_INFO, "Invalid length 0x%X in RSDT/XSDT", | |
496 | length)); | |
c5fc42ac | 497 | return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH); |
f3d2e786 BM |
498 | } |
499 | ||
500 | table = acpi_os_map_memory(address, length); | |
501 | if (!table) { | |
c5fc42ac | 502 | return_ACPI_STATUS(AE_NO_MEMORY); |
f3d2e786 BM |
503 | } |
504 | ||
505 | /* Validate the root table checksum */ | |
506 | ||
c5fc42ac BM |
507 | status = acpi_tb_verify_checksum(table, length); |
508 | if (ACPI_FAILURE(status)) { | |
f3d2e786 | 509 | acpi_os_unmap_memory(table, length); |
c5fc42ac | 510 | return_ACPI_STATUS(status); |
f3d2e786 | 511 | } |
f3d2e786 BM |
512 | |
513 | /* Calculate the number of tables described in the root table */ | |
514 | ||
515 | table_count = | |
a4bbb810 BM |
516 | (u32) ((table->length - |
517 | sizeof(struct acpi_table_header)) / table_entry_size); | |
52fc0b02 | 518 | |
c5fc42ac BM |
519 | /* |
520 | * First two entries in the table array are reserved for the DSDT and FACS, | |
521 | * which are not actually present in the RSDT/XSDT - they come from the FADT | |
522 | */ | |
f3d2e786 BM |
523 | table_entry = |
524 | ACPI_CAST_PTR(u8, table) + sizeof(struct acpi_table_header); | |
525 | acpi_gbl_root_table_list.count = 2; | |
1da177e4 | 526 | |
f3d2e786 | 527 | /* |
c5fc42ac | 528 | * Initialize the root table array from the RSDT/XSDT |
f3d2e786 | 529 | */ |
c5fc42ac | 530 | for (i = 0; i < table_count; i++) { |
f3d2e786 BM |
531 | if (acpi_gbl_root_table_list.count >= |
532 | acpi_gbl_root_table_list.size) { | |
c5fc42ac BM |
533 | |
534 | /* There is no more room in the root table array, attempt resize */ | |
535 | ||
f3d2e786 BM |
536 | status = acpi_tb_resize_root_table_list(); |
537 | if (ACPI_FAILURE(status)) { | |
538 | ACPI_WARNING((AE_INFO, | |
539 | "Truncating %u table entries!", | |
540 | (unsigned) | |
541 | (acpi_gbl_root_table_list.size - | |
542 | acpi_gbl_root_table_list. | |
543 | count))); | |
544 | break; | |
545 | } | |
546 | } | |
547 | ||
a4bbb810 BM |
548 | /* Get the table physical address (32-bit for RSDT, 64-bit for XSDT) */ |
549 | ||
550 | acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count]. | |
551 | address = | |
552 | acpi_tb_get_root_table_entry(table_entry, table_entry_size); | |
f3d2e786 | 553 | |
c5fc42ac | 554 | table_entry += table_entry_size; |
f3d2e786 | 555 | acpi_gbl_root_table_list.count++; |
1da177e4 | 556 | } |
793c2388 | 557 | |
f3d2e786 BM |
558 | /* |
559 | * It is not possible to map more than one entry in some environments, | |
560 | * so unmap the root table here before mapping other tables | |
561 | */ | |
562 | acpi_os_unmap_memory(table, length); | |
563 | ||
c5fc42ac BM |
564 | /* |
565 | * Complete the initialization of the root table array by examining | |
566 | * the header of each table | |
567 | */ | |
f3d2e786 | 568 | for (i = 2; i < acpi_gbl_root_table_list.count; i++) { |
c5fc42ac BM |
569 | acpi_tb_install_table(acpi_gbl_root_table_list.tables[i]. |
570 | address, flags, NULL, i); | |
f3d2e786 | 571 | |
c5fc42ac | 572 | /* Special case for FADT - get the DSDT and FACS */ |
f3d2e786 | 573 | |
c5fc42ac BM |
574 | if (ACPI_COMPARE_NAME |
575 | (&acpi_gbl_root_table_list.tables[i].signature, | |
576 | ACPI_SIG_FADT)) { | |
577 | acpi_tb_parse_fadt(i, flags); | |
f3d2e786 BM |
578 | } |
579 | } | |
580 | ||
581 | return_ACPI_STATUS(AE_OK); | |
1da177e4 | 582 | } |