]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - drivers/acpi/acpica/tbutils.c
ACPICA: Tables: Fix multiple ACPI_FREE()s around acpi_tb_add_table().
[mirror_ubuntu-artful-kernel.git] / drivers / acpi / acpica / tbutils.c
CommitLineData
1da177e4
LT
1/******************************************************************************
2 *
42f47869 3 * Module Name: tbutils - ACPI Table utilities
1da177e4
LT
4 *
5 *****************************************************************************/
6
7/*
fbb7a2dc 8 * Copyright (C) 2000 - 2014, 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 49ACPI_MODULE_NAME("tbutils")
1da177e4 50
44f6c012 51/* Local prototypes */
671cc68d
LZ
52static acpi_status acpi_tb_validate_xsdt(acpi_physical_address address);
53
a4bbb810 54static acpi_physical_address
67a119f9
BM
55acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size);
56
33620c54 57#if (!ACPI_REDUCED_HARDWARE)
009c4cbe
BM
58/*******************************************************************************
59 *
60 * FUNCTION: acpi_tb_initialize_facs
61 *
62 * PARAMETERS: None
63 *
64 * RETURN: Status
65 *
66 * DESCRIPTION: Create a permanent mapping for the FADT and save it in a global
67 * for accessing the Global Lock and Firmware Waking Vector
68 *
69 ******************************************************************************/
70
71acpi_status acpi_tb_initialize_facs(void)
72{
73 acpi_status status;
74
22e5b40a
BM
75 /* If Hardware Reduced flag is set, there is no FACS */
76
77 if (acpi_gbl_reduced_hardware) {
78 acpi_gbl_FACS = NULL;
79 return (AE_OK);
80 }
81
009c4cbe
BM
82 status = acpi_get_table_by_index(ACPI_TABLE_INDEX_FACS,
83 ACPI_CAST_INDIRECT_PTR(struct
84 acpi_table_header,
85 &acpi_gbl_FACS));
9c0d7939 86 return (status);
009c4cbe 87}
33620c54 88#endif /* !ACPI_REDUCED_HARDWARE */
009c4cbe 89
c857303a
BM
90/*******************************************************************************
91 *
92 * FUNCTION: acpi_tb_tables_loaded
93 *
94 * PARAMETERS: None
95 *
96 * RETURN: TRUE if required ACPI tables are loaded
97 *
98 * DESCRIPTION: Determine if the minimum required ACPI tables are present
99 * (FADT, FACS, DSDT)
100 *
101 ******************************************************************************/
102
103u8 acpi_tb_tables_loaded(void)
104{
105
b9ee2043 106 if (acpi_gbl_root_table_list.current_table_count >= 3) {
c857303a
BM
107 return (TRUE);
108 }
109
110 return (FALSE);
111}
112
729df0f8
LM
113/*******************************************************************************
114 *
115 * FUNCTION: acpi_tb_check_dsdt_header
116 *
117 * PARAMETERS: None
118 *
119 * RETURN: None
120 *
121 * DESCRIPTION: Quick compare to check validity of the DSDT. This will detect
122 * if the DSDT has been replaced from outside the OS and/or if
123 * the DSDT header has been corrupted.
124 *
125 ******************************************************************************/
126
127void acpi_tb_check_dsdt_header(void)
128{
129
130 /* Compare original length and checksum to current values */
131
43323cb4
BM
132 if (acpi_gbl_original_dsdt_header.length != acpi_gbl_DSDT->length ||
133 acpi_gbl_original_dsdt_header.checksum != acpi_gbl_DSDT->checksum) {
3b3ea775
BM
134 ACPI_BIOS_ERROR((AE_INFO,
135 "The DSDT has been corrupted or replaced - "
136 "old, new headers below"));
729df0f8 137 acpi_tb_print_table_header(0, &acpi_gbl_original_dsdt_header);
43323cb4 138 acpi_tb_print_table_header(0, acpi_gbl_DSDT);
729df0f8 139
aa2110cb
LM
140 ACPI_ERROR((AE_INFO,
141 "Please send DMI info to linux-acpi@vger.kernel.org\n"
142 "If system does not work as expected, please boot with acpi=copy_dsdt"));
143
729df0f8
LM
144 /* Disable further error messages */
145
43323cb4 146 acpi_gbl_original_dsdt_header.length = acpi_gbl_DSDT->length;
729df0f8 147 acpi_gbl_original_dsdt_header.checksum =
43323cb4 148 acpi_gbl_DSDT->checksum;
729df0f8
LM
149 }
150}
151
69ec87ef
LM
152/*******************************************************************************
153 *
154 * FUNCTION: acpi_tb_copy_dsdt
155 *
156 * PARAMETERS: table_desc - Installed table to copy
157 *
158 * RETURN: None
159 *
160 * DESCRIPTION: Implements a subsystem option to copy the DSDT to local memory.
161 * Some very bad BIOSs are known to either corrupt the DSDT or
162 * install a new, bad DSDT. This copy works around the problem.
163 *
164 ******************************************************************************/
165
43323cb4 166struct acpi_table_header *acpi_tb_copy_dsdt(u32 table_index)
69ec87ef
LM
167{
168 struct acpi_table_header *new_table;
43323cb4
BM
169 struct acpi_table_desc *table_desc;
170
171 table_desc = &acpi_gbl_root_table_list.tables[table_index];
69ec87ef
LM
172
173 new_table = ACPI_ALLOCATE(table_desc->length);
174 if (!new_table) {
175 ACPI_ERROR((AE_INFO, "Could not copy DSDT of length 0x%X",
176 table_desc->length));
43323cb4 177 return (NULL);
69ec87ef
LM
178 }
179
180 ACPI_MEMCPY(new_table, table_desc->pointer, table_desc->length);
181 acpi_tb_delete_table(table_desc);
dc156adf 182 table_desc->address = ACPI_PTR_TO_PHYSADDR(new_table);
69ec87ef
LM
183 table_desc->pointer = new_table;
184 table_desc->flags = ACPI_TABLE_ORIGIN_ALLOCATED;
185
186 ACPI_INFO((AE_INFO,
187 "Forced DSDT copy: length 0x%05X copied locally, original unmapped",
188 new_table->length));
43323cb4
BM
189
190 return (new_table);
69ec87ef
LM
191}
192
1da177e4
LT
193/*******************************************************************************
194 *
c5fc42ac 195 * FUNCTION: acpi_tb_install_table
1da177e4 196 *
ba494bee
BM
197 * PARAMETERS: address - Physical address of DSDT or FACS
198 * signature - Table signature, NULL if no need to
c5fc42ac
BM
199 * match
200 * table_index - Index into root table array
1da177e4 201 *
c5fc42ac 202 * RETURN: None
1da177e4 203 *
ac5f98db 204 * DESCRIPTION: Install an ACPI table into the global data structure. The
f7b004a1 205 * table override mechanism is called to allow the host
ac5f98db
BM
206 * OS to replace any table before it is installed in the root
207 * table array.
1da177e4
LT
208 *
209 ******************************************************************************/
210
765ec201 211void
c5fc42ac 212acpi_tb_install_table(acpi_physical_address address,
97cbb7d1 213 char *signature, u32 table_index)
1da177e4 214{
f7b004a1
BM
215 struct acpi_table_header *table;
216 struct acpi_table_header *final_table;
217 struct acpi_table_desc *table_desc;
f3d2e786 218
c5fc42ac
BM
219 if (!address) {
220 ACPI_ERROR((AE_INFO,
221 "Null physical address for ACPI table [%s]",
222 signature));
223 return;
f3d2e786
BM
224 }
225
c5fc42ac
BM
226 /* Map just the table header */
227
f7b004a1
BM
228 table = acpi_os_map_memory(address, sizeof(struct acpi_table_header));
229 if (!table) {
230 ACPI_ERROR((AE_INFO,
231 "Could not map memory for table [%s] at %p",
232 signature, ACPI_CAST_PTR(void, address)));
c5fc42ac
BM
233 return;
234 }
235
ac5f98db 236 /* If a particular signature is expected (DSDT/FACS), it must match */
c5fc42ac 237
f7b004a1 238 if (signature && !ACPI_COMPARE_NAME(table->signature, signature)) {
3b3ea775
BM
239 ACPI_BIOS_ERROR((AE_INFO,
240 "Invalid signature 0x%X for ACPI table, expected [%s]",
241 *ACPI_CAST_PTR(u32, table->signature),
242 signature));
c5fc42ac 243 goto unmap_and_exit;
f3d2e786
BM
244 }
245
f7b004a1
BM
246 /*
247 * Initialize the table entry. Set the pointer to NULL, since the
248 * table is not fully mapped at this time.
249 */
250 table_desc = &acpi_gbl_root_table_list.tables[table_index];
251
252 table_desc->address = address;
253 table_desc->pointer = NULL;
254 table_desc->length = table->length;
255 table_desc->flags = ACPI_TABLE_ORIGIN_MAPPED;
256 ACPI_MOVE_32_TO_32(table_desc->signature.ascii, table->signature);
257
ac5f98db
BM
258 /*
259 * ACPI Table Override:
260 *
261 * Before we install the table, let the host OS override it with a new
262 * one if desired. Any table within the RSDT/XSDT can be replaced,
263 * including the DSDT which is pointed to by the FADT.
f7b004a1
BM
264 *
265 * NOTE: If the table is overridden, then final_table will contain a
266 * mapped pointer to the full new table. If the table is not overridden,
267 * or if there has been a physical override, then the table will be
268 * fully mapped later (in verify table). In any case, we must
269 * unmap the header that was mapped above.
ac5f98db 270 */
f7b004a1
BM
271 final_table = acpi_tb_table_override(table, table_desc);
272 if (!final_table) {
273 final_table = table; /* There was no override */
ac5f98db
BM
274 }
275
f7b004a1 276 acpi_tb_print_table_header(table_desc->address, final_table);
c5fc42ac 277
f7b004a1 278 /* Set the global integer width (based upon revision of the DSDT) */
f3d2e786 279
c5fc42ac 280 if (table_index == ACPI_TABLE_INDEX_DSDT) {
f7b004a1
BM
281 acpi_ut_set_integer_width(final_table->revision);
282 }
f3d2e786 283
f7b004a1
BM
284 /*
285 * If we have a physical override during this early loading of the ACPI
286 * tables, unmap the table for now. It will be mapped again later when
287 * it is actually used. This supports very early loading of ACPI tables,
288 * before virtual memory is fully initialized and running within the
289 * host OS. Note: A logical override has the ACPI_TABLE_ORIGIN_OVERRIDE
290 * flag set and will not be deleted below.
291 */
292 if (final_table != table) {
293 acpi_tb_delete_table(table_desc);
c5fc42ac
BM
294 }
295
10622bf8 296unmap_and_exit:
f7b004a1
BM
297
298 /* Always unmap the table header that we mapped above */
299
300 acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
c5fc42ac 301}
f3d2e786 302
a4bbb810
BM
303/*******************************************************************************
304 *
305 * FUNCTION: acpi_tb_get_root_table_entry
306 *
307 * PARAMETERS: table_entry - Pointer to the RSDT/XSDT table entry
308 * table_entry_size - sizeof 32 or 64 (RSDT or XSDT)
309 *
310 * RETURN: Physical address extracted from the root table
311 *
312 * DESCRIPTION: Get one root table entry. Handles 32-bit and 64-bit cases on
313 * both 32-bit and 64-bit platforms
314 *
315 * NOTE: acpi_physical_address is 32-bit on 32-bit platforms, 64-bit on
316 * 64-bit platforms.
317 *
318 ******************************************************************************/
319
320static acpi_physical_address
67a119f9 321acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size)
a4bbb810
BM
322{
323 u64 address64;
324
325 /*
326 * Get the table physical address (32-bit for RSDT, 64-bit for XSDT):
327 * Note: Addresses are 32-bit aligned (not 64) in both RSDT and XSDT
328 */
671cc68d 329 if (table_entry_size == ACPI_RSDT_ENTRY_SIZE) {
a4bbb810
BM
330 /*
331 * 32-bit platform, RSDT: Return 32-bit table entry
332 * 64-bit platform, RSDT: Expand 32-bit to 64-bit and return
333 */
334 return ((acpi_physical_address)
335 (*ACPI_CAST_PTR(u32, table_entry)));
336 } else {
337 /*
338 * 32-bit platform, XSDT: Truncate 64-bit to 32-bit and return
ec41f193
BM
339 * 64-bit platform, XSDT: Move (unaligned) 64-bit to local,
340 * return 64-bit
a4bbb810
BM
341 */
342 ACPI_MOVE_64_TO_64(&address64, table_entry);
343
344#if ACPI_MACHINE_WIDTH == 32
345 if (address64 > ACPI_UINT32_MAX) {
346
ea5d8ebc 347 /* Will truncate 64-bit address to 32 bits, issue warning */
a4bbb810 348
3b3ea775
BM
349 ACPI_BIOS_WARNING((AE_INFO,
350 "64-bit Physical Address in XSDT is too large (0x%8.8X%8.8X),"
351 " truncating",
352 ACPI_FORMAT_UINT64(address64)));
a4bbb810
BM
353 }
354#endif
355 return ((acpi_physical_address) (address64));
356 }
357}
358
671cc68d
LZ
359/*******************************************************************************
360 *
361 * FUNCTION: acpi_tb_validate_xsdt
362 *
363 * PARAMETERS: address - Physical address of the XSDT (from RSDP)
364 *
365 * RETURN: Status. AE_OK if the table appears to be valid.
366 *
367 * DESCRIPTION: Validate an XSDT to ensure that it is of minimum size and does
368 * not contain any NULL entries. A problem that is seen in the
369 * field is that the XSDT exists, but is actually useless because
370 * of one or more (or all) NULL entries.
371 *
372 ******************************************************************************/
373
374static acpi_status acpi_tb_validate_xsdt(acpi_physical_address xsdt_address)
375{
376 struct acpi_table_header *table;
377 u8 *next_entry;
378 acpi_physical_address address;
379 u32 length;
380 u32 entry_count;
381 acpi_status status;
382 u32 i;
383
384 /* Get the XSDT length */
385
386 table =
387 acpi_os_map_memory(xsdt_address, sizeof(struct acpi_table_header));
388 if (!table) {
389 return (AE_NO_MEMORY);
390 }
391
392 length = table->length;
393 acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
394
395 /*
396 * Minimum XSDT length is the size of the standard ACPI header
397 * plus one physical address entry
398 */
399 if (length < (sizeof(struct acpi_table_header) + ACPI_XSDT_ENTRY_SIZE)) {
400 return (AE_INVALID_TABLE_LENGTH);
401 }
402
403 /* Map the entire XSDT */
404
405 table = acpi_os_map_memory(xsdt_address, length);
406 if (!table) {
407 return (AE_NO_MEMORY);
408 }
409
410 /* Get the number of entries and pointer to first entry */
411
412 status = AE_OK;
413 next_entry = ACPI_ADD_PTR(u8, table, sizeof(struct acpi_table_header));
414 entry_count = (u32)((table->length - sizeof(struct acpi_table_header)) /
415 ACPI_XSDT_ENTRY_SIZE);
416
417 /* Validate each entry (physical address) within the XSDT */
418
419 for (i = 0; i < entry_count; i++) {
420 address =
421 acpi_tb_get_root_table_entry(next_entry,
422 ACPI_XSDT_ENTRY_SIZE);
423 if (!address) {
424
425 /* Detected a NULL entry, XSDT is invalid */
426
427 status = AE_NULL_ENTRY;
428 break;
429 }
430
431 next_entry += ACPI_XSDT_ENTRY_SIZE;
432 }
433
434 /* Unmap table */
435
436 acpi_os_unmap_memory(table, length);
437 return (status);
438}
439
793c2388
BM
440/*******************************************************************************
441 *
f3d2e786 442 * FUNCTION: acpi_tb_parse_root_table
793c2388 443 *
ba494bee 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
45c9f78b 457acpi_status __init acpi_tb_parse_root_table(acpi_physical_address rsdp_address)
793c2388 458{
c5fc42ac 459 struct acpi_table_rsdp *rsdp;
67a119f9
BM
460 u32 table_entry_size;
461 u32 i;
c5fc42ac 462 u32 table_count;
f3d2e786
BM
463 struct acpi_table_header *table;
464 acpi_physical_address address;
465 u32 length;
466 u8 *table_entry;
f3d2e786
BM
467 acpi_status status;
468
469 ACPI_FUNCTION_TRACE(tb_parse_root_table);
470
671cc68d
LZ
471 /* Map the entire RSDP and extract the address of the RSDT or XSDT */
472
c5fc42ac
BM
473 rsdp = acpi_os_map_memory(rsdp_address, sizeof(struct acpi_table_rsdp));
474 if (!rsdp) {
475 return_ACPI_STATUS(AE_NO_MEMORY);
476 }
477
478 acpi_tb_print_table_header(rsdp_address,
479 ACPI_CAST_PTR(struct acpi_table_header,
480 rsdp));
481
fab46105 482 /* Use XSDT if present and not overridden. Otherwise, use RSDT */
f3d2e786 483
fab46105
LZ
484 if ((rsdp->revision > 1) &&
485 rsdp->xsdt_physical_address && !acpi_gbl_do_not_use_xsdt) {
f3d2e786 486 /*
671cc68d
LZ
487 * RSDP contains an XSDT (64-bit physical addresses). We must use
488 * the XSDT if the revision is > 1 and the XSDT pointer is present,
489 * as per the ACPI specification.
f3d2e786 490 */
c5fc42ac 491 address = (acpi_physical_address) rsdp->xsdt_physical_address;
671cc68d 492 table_entry_size = ACPI_XSDT_ENTRY_SIZE;
f3d2e786
BM
493 } else {
494 /* Root table is an RSDT (32-bit physical addresses) */
495
c5fc42ac 496 address = (acpi_physical_address) rsdp->rsdt_physical_address;
671cc68d 497 table_entry_size = ACPI_RSDT_ENTRY_SIZE;
f3d2e786 498 }
793c2388 499
c5fc42ac
BM
500 /*
501 * It is not possible to map more than one entry in some environments,
502 * so unmap the RSDP here before mapping other tables
503 */
504 acpi_os_unmap_memory(rsdp, sizeof(struct acpi_table_rsdp));
505
671cc68d 506 /*
fab46105
LZ
507 * If it is present and used, validate the XSDT for access/size
508 * and ensure that all table entries are at least non-NULL
671cc68d
LZ
509 */
510 if (table_entry_size == ACPI_XSDT_ENTRY_SIZE) {
511 status = acpi_tb_validate_xsdt(address);
512 if (ACPI_FAILURE(status)) {
513 ACPI_BIOS_WARNING((AE_INFO,
514 "XSDT is invalid (%s), using RSDT",
515 acpi_format_exception(status)));
516
517 /* Fall back to the RSDT */
518
519 address =
520 (acpi_physical_address) rsdp->rsdt_physical_address;
521 table_entry_size = ACPI_RSDT_ENTRY_SIZE;
9f3119b7
ZY
522 }
523 }
671cc68d 524
c5fc42ac 525 /* Map the RSDT/XSDT table header to get the full table length */
793c2388 526
f3d2e786
BM
527 table = acpi_os_map_memory(address, sizeof(struct acpi_table_header));
528 if (!table) {
c5fc42ac 529 return_ACPI_STATUS(AE_NO_MEMORY);
f3d2e786
BM
530 }
531
c5fc42ac
BM
532 acpi_tb_print_table_header(address, table);
533
671cc68d
LZ
534 /*
535 * Validate length of the table, and map entire table.
536 * Minimum length table must contain at least one entry.
537 */
f3d2e786
BM
538 length = table->length;
539 acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
540
671cc68d 541 if (length < (sizeof(struct acpi_table_header) + table_entry_size)) {
3b3ea775
BM
542 ACPI_BIOS_ERROR((AE_INFO,
543 "Invalid table length 0x%X in RSDT/XSDT",
544 length));
c5fc42ac 545 return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
f3d2e786
BM
546 }
547
548 table = acpi_os_map_memory(address, length);
549 if (!table) {
c5fc42ac 550 return_ACPI_STATUS(AE_NO_MEMORY);
f3d2e786
BM
551 }
552
553 /* Validate the root table checksum */
554
c5fc42ac
BM
555 status = acpi_tb_verify_checksum(table, length);
556 if (ACPI_FAILURE(status)) {
f3d2e786 557 acpi_os_unmap_memory(table, length);
c5fc42ac 558 return_ACPI_STATUS(status);
f3d2e786 559 }
f3d2e786 560
671cc68d 561 /* Get the number of entries and pointer to first entry */
f3d2e786 562
ec41f193
BM
563 table_count = (u32)((table->length - sizeof(struct acpi_table_header)) /
564 table_entry_size);
671cc68d
LZ
565 table_entry = ACPI_ADD_PTR(u8, table, sizeof(struct acpi_table_header));
566
c5fc42ac 567 /*
ec41f193
BM
568 * First two entries in the table array are reserved for the DSDT
569 * and FACS, which are not actually present in the RSDT/XSDT - they
570 * come from the FADT
c5fc42ac 571 */
b9ee2043 572 acpi_gbl_root_table_list.current_table_count = 2;
1da177e4 573
671cc68d
LZ
574 /* Initialize the root table array from the RSDT/XSDT */
575
c5fc42ac 576 for (i = 0; i < table_count; i++) {
b9ee2043
BM
577 if (acpi_gbl_root_table_list.current_table_count >=
578 acpi_gbl_root_table_list.max_table_count) {
c5fc42ac
BM
579
580 /* There is no more room in the root table array, attempt resize */
581
f3d2e786
BM
582 status = acpi_tb_resize_root_table_list();
583 if (ACPI_FAILURE(status)) {
584 ACPI_WARNING((AE_INFO,
585 "Truncating %u table entries!",
5582982d
LZ
586 (unsigned)(table_count -
587 (acpi_gbl_root_table_list.
b9ee2043
BM
588 current_table_count -
589 2))));
f3d2e786
BM
590 break;
591 }
592 }
593
a4bbb810
BM
594 /* Get the table physical address (32-bit for RSDT, 64-bit for XSDT) */
595
b9ee2043
BM
596 acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.
597 current_table_count].address =
a4bbb810 598 acpi_tb_get_root_table_entry(table_entry, table_entry_size);
f3d2e786 599
c5fc42ac 600 table_entry += table_entry_size;
b9ee2043 601 acpi_gbl_root_table_list.current_table_count++;
1da177e4 602 }
793c2388 603
f3d2e786
BM
604 /*
605 * It is not possible to map more than one entry in some environments,
606 * so unmap the root table here before mapping other tables
607 */
608 acpi_os_unmap_memory(table, length);
609
c5fc42ac
BM
610 /*
611 * Complete the initialization of the root table array by examining
612 * the header of each table
613 */
b9ee2043 614 for (i = 2; i < acpi_gbl_root_table_list.current_table_count; i++) {
c5fc42ac 615 acpi_tb_install_table(acpi_gbl_root_table_list.tables[i].
97cbb7d1 616 address, NULL, i);
f3d2e786 617
671cc68d 618 /* Special case for FADT - validate it then get the DSDT and FACS */
f3d2e786 619
c5fc42ac
BM
620 if (ACPI_COMPARE_NAME
621 (&acpi_gbl_root_table_list.tables[i].signature,
622 ACPI_SIG_FADT)) {
97cbb7d1 623 acpi_tb_parse_fadt(i);
f3d2e786
BM
624 }
625 }
626
627 return_ACPI_STATUS(AE_OK);
1da177e4 628}