tbutils.c 20 KB

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