tbutils.c 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  1. /******************************************************************************
  2. *
  3. * Module Name: tbutils - table utilities
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2006, R. Byron Moore
  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 <acpi/actables.h>
  44. #define _COMPONENT ACPI_TABLES
  45. ACPI_MODULE_NAME("tbutils")
  46. /* Local prototypes */
  47. static void acpi_tb_parse_fadt(acpi_native_uint table_index, u8 flags);
  48. static void acpi_tb_convert_fadt(void);
  49. static void
  50. acpi_tb_install_table(acpi_physical_address address,
  51. u8 flags, char *signature, acpi_native_uint table_index);
  52. static void inline
  53. acpi_tb_init_generic_address(struct acpi_generic_address *new_gas_struct,
  54. u8 bit_width, u64 address);
  55. /* Table used for conversion of FADT to common format */
  56. typedef struct acpi_fadt_conversion {
  57. u8 target;
  58. u8 source;
  59. u8 length;
  60. } acpi_fadt_conversion;
  61. static struct acpi_fadt_conversion fadt_conversion_table[] = {
  62. {ACPI_FADT_OFFSET(xpm1a_event_block),
  63. ACPI_FADT_OFFSET(pm1a_event_block),
  64. ACPI_FADT_OFFSET(pm1_event_length)},
  65. {ACPI_FADT_OFFSET(xpm1b_event_block),
  66. ACPI_FADT_OFFSET(pm1b_event_block),
  67. ACPI_FADT_OFFSET(pm1_event_length)},
  68. {ACPI_FADT_OFFSET(xpm1a_control_block),
  69. ACPI_FADT_OFFSET(pm1a_control_block),
  70. ACPI_FADT_OFFSET(pm1_control_length)},
  71. {ACPI_FADT_OFFSET(xpm1b_control_block),
  72. ACPI_FADT_OFFSET(pm1b_control_block),
  73. ACPI_FADT_OFFSET(pm1_control_length)},
  74. {ACPI_FADT_OFFSET(xpm2_control_block),
  75. ACPI_FADT_OFFSET(pm2_control_block),
  76. ACPI_FADT_OFFSET(pm2_control_length)},
  77. {ACPI_FADT_OFFSET(xpm_timer_block), ACPI_FADT_OFFSET(pm_timer_block),
  78. ACPI_FADT_OFFSET(pm_timer_length)},
  79. {ACPI_FADT_OFFSET(xgpe0_block), ACPI_FADT_OFFSET(gpe0_block),
  80. ACPI_FADT_OFFSET(gpe0_block_length)},
  81. {ACPI_FADT_OFFSET(xgpe1_block), ACPI_FADT_OFFSET(gpe1_block),
  82. ACPI_FADT_OFFSET(gpe1_block_length)}
  83. };
  84. #define ACPI_FADT_CONVERSION_ENTRIES (sizeof (fadt_conversion_table) / sizeof (struct acpi_fadt_conversion))
  85. /*******************************************************************************
  86. *
  87. * FUNCTION: acpi_tb_print_table_header
  88. *
  89. * PARAMETERS: Address - Table physical address
  90. * Header - Table header
  91. *
  92. * RETURN: None
  93. *
  94. * DESCRIPTION: Print an ACPI table header. Special cases for FACS and RSDP.
  95. *
  96. ******************************************************************************/
  97. void
  98. acpi_tb_print_table_header(acpi_physical_address address,
  99. struct acpi_table_header *header)
  100. {
  101. if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_FACS)) {
  102. /* FACS only has signature and length fields of common table header */
  103. ACPI_INFO((AE_INFO, "%4.4s @ 0x%p/0x%04X",
  104. header->signature, ACPI_CAST_PTR(void, address),
  105. header->length));
  106. } else if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_RSDP)) {
  107. /* RSDP has no common fields */
  108. ACPI_INFO((AE_INFO, "RSDP @ 0x%p/0x%04X (v%3.3d %6.6s)",
  109. ACPI_CAST_PTR(void, address),
  110. (((struct acpi_table_rsdp *)header)->revision > 0) ?
  111. ((struct acpi_table_rsdp *)header)->length : 20,
  112. ((struct acpi_table_rsdp *)header)->revision,
  113. ((struct acpi_table_rsdp *)header)->oem_id));
  114. } else {
  115. ACPI_INFO((AE_INFO,
  116. "%4.4s @ 0x%p/0x%04X (v%3.3d %6.6s %8.8s 0x%08X %4.4s 0x%08X)",
  117. header->signature, ACPI_CAST_PTR(void, address),
  118. header->length, header->revision, header->oem_id,
  119. header->oem_table_id, header->oem_revision,
  120. header->asl_compiler_id,
  121. header->asl_compiler_revision));
  122. }
  123. }
  124. /*******************************************************************************
  125. *
  126. * FUNCTION: acpi_tb_init_generic_address
  127. *
  128. * PARAMETERS: new_gas_struct - GAS struct to be initialized
  129. * bit_width - Width of this register
  130. * Address - Address of the register
  131. *
  132. * RETURN: None
  133. *
  134. * DESCRIPTION: Initialize a GAS structure.
  135. *
  136. ******************************************************************************/
  137. static void inline
  138. acpi_tb_init_generic_address(struct acpi_generic_address *new_gas_struct,
  139. u8 bit_width, u64 address)
  140. {
  141. ACPI_STORE_ADDRESS(new_gas_struct->address, address);
  142. new_gas_struct->space_id = ACPI_ADR_SPACE_SYSTEM_IO;
  143. new_gas_struct->bit_width = bit_width;
  144. new_gas_struct->bit_offset = 0;
  145. new_gas_struct->access_width = 0;
  146. }
  147. /*******************************************************************************
  148. *
  149. * FUNCTION: acpi_tb_validate_checksum
  150. *
  151. * PARAMETERS: Table - ACPI table to verify
  152. * Length - Length of entire table
  153. *
  154. * RETURN: Status
  155. *
  156. * DESCRIPTION: Verifies that the table checksums to zero. Optionally returns
  157. * exception on bad checksum.
  158. *
  159. ******************************************************************************/
  160. acpi_status acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length)
  161. {
  162. u8 checksum;
  163. /* Compute the checksum on the table */
  164. checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, table), length);
  165. /* Checksum ok? (should be zero) */
  166. if (checksum) {
  167. ACPI_WARNING((AE_INFO,
  168. "Incorrect checksum in table [%4.4s] - %2.2X, should be %2.2X",
  169. table->signature, table->checksum,
  170. (u8) (table->checksum - checksum)));
  171. #if (ACPI_CHECKSUM_ABORT)
  172. return (AE_BAD_CHECKSUM);
  173. #endif
  174. }
  175. return (AE_OK);
  176. }
  177. /*******************************************************************************
  178. *
  179. * FUNCTION: acpi_tb_checksum
  180. *
  181. * PARAMETERS: Buffer - Pointer to memory region to be checked
  182. * Length - Length of this memory region
  183. *
  184. * RETURN: Checksum (u8)
  185. *
  186. * DESCRIPTION: Calculates circular checksum of memory region.
  187. *
  188. ******************************************************************************/
  189. u8 acpi_tb_checksum(u8 * buffer, acpi_native_uint length)
  190. {
  191. u8 sum = 0;
  192. u8 *end = buffer + length;
  193. while (buffer < end) {
  194. sum = (u8) (sum + *(buffer++));
  195. }
  196. return sum;
  197. }
  198. /*******************************************************************************
  199. *
  200. * FUNCTION: acpi_tb_convert_fadt
  201. *
  202. * PARAMETERS: None, uses acpi_gbl_FADT
  203. *
  204. * RETURN: None
  205. *
  206. * DESCRIPTION: Converts all versions of the FADT to a common internal format.
  207. *
  208. * NOTE: acpi_gbl_FADT must be of size (struct acpi_table_fadt), and must contain
  209. * a copy of the actual FADT.
  210. *
  211. * ACPICA will use the "X" fields of the FADT for all addresses.
  212. *
  213. * "X" fields are optional extensions to the original V1.0 fields. Even if
  214. * they are present in the structure, they can be optionally not used by
  215. * setting them to zero. Therefore, we must selectively expand V1.0 fields
  216. * if the corresponding X field is zero.
  217. *
  218. * For ACPI 1.0 FADTs, all address fields are expanded to the corresponding
  219. * "X" fields.
  220. *
  221. * For ACPI 2.0 FADTs, any "X" fields that are NULL are filled in by
  222. * expanding the corresponding ACPI 1.0 field.
  223. *
  224. ******************************************************************************/
  225. static void acpi_tb_convert_fadt(void)
  226. {
  227. u8 pm1_register_length;
  228. struct acpi_generic_address *target;
  229. acpi_native_uint i;
  230. /* Expand the FACS and DSDT addresses as necessary */
  231. if (!acpi_gbl_FADT.Xfacs) {
  232. acpi_gbl_FADT.Xfacs = (u64) acpi_gbl_FADT.facs;
  233. }
  234. if (!acpi_gbl_FADT.Xdsdt) {
  235. acpi_gbl_FADT.Xdsdt = (u64) acpi_gbl_FADT.dsdt;
  236. }
  237. /*
  238. * Expand the V1.0 addresses to the "X" generic address structs,
  239. * as necessary.
  240. */
  241. for (i = 0; i < ACPI_FADT_CONVERSION_ENTRIES; i++) {
  242. target =
  243. ACPI_ADD_PTR(struct acpi_generic_address, &acpi_gbl_FADT,
  244. fadt_conversion_table[i].target);
  245. if (!target->address) {
  246. acpi_tb_init_generic_address(target,
  247. *ACPI_ADD_PTR(u8,
  248. &acpi_gbl_FADT,
  249. fadt_conversion_table
  250. [i].length),
  251. *ACPI_ADD_PTR(u64,
  252. &acpi_gbl_FADT,
  253. fadt_conversion_table
  254. [i].source));
  255. }
  256. }
  257. /*
  258. * Calculate separate GAS structs for the PM1 Enable registers.
  259. * These addresses do not appear (directly) in the FADT, so it is
  260. * useful to calculate them once, here.
  261. */
  262. pm1_register_length = (u8) ACPI_DIV_2(acpi_gbl_FADT.pm1_event_length);
  263. /* PM1A is required */
  264. acpi_tb_init_generic_address(&acpi_gbl_xpm1a_enable,
  265. pm1_register_length,
  266. (u64) (acpi_gbl_FADT.xpm1a_event_block.
  267. address + pm1_register_length));
  268. /* PM1B is optional; leave null if not present */
  269. if (acpi_gbl_FADT.xpm1b_event_block.address) {
  270. acpi_tb_init_generic_address(&acpi_gbl_xpm1b_enable,
  271. pm1_register_length,
  272. (u64) (acpi_gbl_FADT.
  273. xpm1b_event_block.address +
  274. pm1_register_length));
  275. }
  276. /* Global FADT is the new common V2.0 FADT */
  277. acpi_gbl_FADT.header.length = sizeof(struct acpi_table_fadt);
  278. }
  279. /*******************************************************************************
  280. *
  281. * FUNCTION: acpi_tb_install_table
  282. *
  283. * PARAMETERS: Address - Physical address of DSDT or FACS
  284. * Flags - Flags
  285. * Signature - Table signature, NULL if no need to
  286. * match
  287. * table_index - Index into root table array
  288. *
  289. * RETURN: None
  290. *
  291. * DESCRIPTION: Install an ACPI table into the global data structure.
  292. *
  293. ******************************************************************************/
  294. static void
  295. acpi_tb_install_table(acpi_physical_address address,
  296. u8 flags, char *signature, acpi_native_uint table_index)
  297. {
  298. struct acpi_table_header *table;
  299. if (!address) {
  300. ACPI_ERROR((AE_INFO,
  301. "Null physical address for ACPI table [%s]",
  302. signature));
  303. return;
  304. }
  305. /* Map just the table header */
  306. table = acpi_os_map_memory(address, sizeof(struct acpi_table_header));
  307. if (!table) {
  308. return;
  309. }
  310. /* If a particular signature is expected, signature must match */
  311. if (signature && !ACPI_COMPARE_NAME(table->signature, signature)) {
  312. ACPI_ERROR((AE_INFO,
  313. "Invalid signature 0x%X for ACPI table [%s]",
  314. *ACPI_CAST_PTR(u32, table->signature), signature));
  315. goto unmap_and_exit;
  316. }
  317. /* Initialize the table entry */
  318. acpi_gbl_root_table_list.tables[table_index].address = address;
  319. acpi_gbl_root_table_list.tables[table_index].length = table->length;
  320. acpi_gbl_root_table_list.tables[table_index].flags = flags;
  321. ACPI_MOVE_32_TO_32(&
  322. (acpi_gbl_root_table_list.tables[table_index].
  323. signature), table->signature);
  324. acpi_tb_print_table_header(address, table);
  325. if (table_index == ACPI_TABLE_INDEX_DSDT) {
  326. /* Global integer width is based upon revision of the DSDT */
  327. acpi_ut_set_integer_width(table->revision);
  328. }
  329. unmap_and_exit:
  330. acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
  331. }
  332. /*******************************************************************************
  333. *
  334. * FUNCTION: acpi_tb_parse_fadt
  335. *
  336. * PARAMETERS: table_index - Index for the FADT
  337. * Flags - Flags
  338. *
  339. * RETURN: None
  340. *
  341. * DESCRIPTION: Initialize the FADT, DSDT and FACS tables
  342. * (FADT contains the addresses of the DSDT and FACS)
  343. *
  344. ******************************************************************************/
  345. static void acpi_tb_parse_fadt(acpi_native_uint table_index, u8 flags)
  346. {
  347. u32 length;
  348. struct acpi_table_header *table;
  349. /*
  350. * Special case for the FADT because of multiple versions and the fact
  351. * that it contains pointers to both the DSDT and FACS tables.
  352. *
  353. * Get a local copy of the FADT and convert it to a common format
  354. * Map entire FADT, assumed to be smaller than one page.
  355. */
  356. length = acpi_gbl_root_table_list.tables[table_index].length;
  357. table =
  358. acpi_os_map_memory(acpi_gbl_root_table_list.tables[table_index].
  359. address, length);
  360. if (!table) {
  361. return;
  362. }
  363. /*
  364. * Validate the FADT checksum before we copy the table. Ignore
  365. * checksum error as we want to try to get the DSDT and FACS.
  366. */
  367. (void)acpi_tb_verify_checksum(table, length);
  368. /* Copy the entire FADT locally */
  369. ACPI_MEMSET(&acpi_gbl_FADT, sizeof(struct acpi_table_fadt), 0);
  370. ACPI_MEMCPY(&acpi_gbl_FADT, table,
  371. ACPI_MIN(length, sizeof(struct acpi_table_fadt)));
  372. acpi_os_unmap_memory(table, length);
  373. /* Convert local FADT to the common internal format */
  374. acpi_tb_convert_fadt();
  375. /* Extract the DSDT and FACS tables from the FADT */
  376. acpi_tb_install_table((acpi_physical_address) acpi_gbl_FADT.Xdsdt,
  377. flags, ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT);
  378. acpi_tb_install_table((acpi_physical_address) acpi_gbl_FADT.Xfacs,
  379. flags, ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS);
  380. }
  381. /*******************************************************************************
  382. *
  383. * FUNCTION: acpi_tb_parse_root_table
  384. *
  385. * PARAMETERS: Rsdp - Pointer to the RSDP
  386. * Flags - Flags
  387. *
  388. * RETURN: Status
  389. *
  390. * DESCRIPTION: This function is called to parse the Root System Description
  391. * Table (RSDT or XSDT)
  392. *
  393. * NOTE: Tables are mapped (not copied) for efficiency. The FACS must
  394. * be mapped and cannot be copied because it contains the actual
  395. * memory location of the ACPI Global Lock.
  396. *
  397. ******************************************************************************/
  398. acpi_status
  399. acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags)
  400. {
  401. struct acpi_table_rsdp *rsdp;
  402. acpi_native_uint table_entry_size;
  403. acpi_native_uint i;
  404. u32 table_count;
  405. struct acpi_table_header *table;
  406. acpi_physical_address address;
  407. u32 length;
  408. u8 *table_entry;
  409. acpi_status status;
  410. ACPI_FUNCTION_TRACE(tb_parse_root_table);
  411. /*
  412. * Map the entire RSDP and extract the address of the RSDT or XSDT
  413. */
  414. rsdp = acpi_os_map_memory(rsdp_address, sizeof(struct acpi_table_rsdp));
  415. if (!rsdp) {
  416. return_ACPI_STATUS(AE_NO_MEMORY);
  417. }
  418. acpi_tb_print_table_header(rsdp_address,
  419. ACPI_CAST_PTR(struct acpi_table_header,
  420. rsdp));
  421. /* Differentiate between RSDT and XSDT root tables */
  422. if (rsdp->revision > 1 && rsdp->xsdt_physical_address) {
  423. /*
  424. * Root table is an XSDT (64-bit physical addresses). We must use the
  425. * XSDT if the revision is > 1 and the XSDT pointer is present, as per
  426. * the ACPI specification.
  427. */
  428. address = (acpi_physical_address) rsdp->xsdt_physical_address;
  429. table_entry_size = sizeof(u64);
  430. } else {
  431. /* Root table is an RSDT (32-bit physical addresses) */
  432. address = (acpi_physical_address) rsdp->rsdt_physical_address;
  433. table_entry_size = sizeof(u32);
  434. }
  435. /*
  436. * It is not possible to map more than one entry in some environments,
  437. * so unmap the RSDP here before mapping other tables
  438. */
  439. acpi_os_unmap_memory(rsdp, sizeof(struct acpi_table_rsdp));
  440. /* Map the RSDT/XSDT table header to get the full table length */
  441. table = acpi_os_map_memory(address, sizeof(struct acpi_table_header));
  442. if (!table) {
  443. return_ACPI_STATUS(AE_NO_MEMORY);
  444. }
  445. acpi_tb_print_table_header(address, table);
  446. /* Get the length of the full table, verify length and map entire table */
  447. length = table->length;
  448. acpi_os_unmap_memory(table, sizeof(struct acpi_table_header));
  449. if (length < sizeof(struct acpi_table_header)) {
  450. ACPI_ERROR((AE_INFO, "Invalid length 0x%X in RSDT/XSDT",
  451. length));
  452. return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH);
  453. }
  454. table = acpi_os_map_memory(address, length);
  455. if (!table) {
  456. return_ACPI_STATUS(AE_NO_MEMORY);
  457. }
  458. /* Validate the root table checksum */
  459. status = acpi_tb_verify_checksum(table, length);
  460. if (ACPI_FAILURE(status)) {
  461. acpi_os_unmap_memory(table, length);
  462. return_ACPI_STATUS(status);
  463. }
  464. /* Calculate the number of tables described in the root table */
  465. table_count =
  466. (table->length -
  467. sizeof(struct acpi_table_header)) / table_entry_size;
  468. /*
  469. * First two entries in the table array are reserved for the DSDT and FACS,
  470. * which are not actually present in the RSDT/XSDT - they come from the FADT
  471. */
  472. table_entry =
  473. ACPI_CAST_PTR(u8, table) + sizeof(struct acpi_table_header);
  474. acpi_gbl_root_table_list.count = 2;
  475. /*
  476. * Initialize the root table array from the RSDT/XSDT
  477. */
  478. for (i = 0; i < table_count; i++) {
  479. if (acpi_gbl_root_table_list.count >=
  480. acpi_gbl_root_table_list.size) {
  481. /* There is no more room in the root table array, attempt resize */
  482. status = acpi_tb_resize_root_table_list();
  483. if (ACPI_FAILURE(status)) {
  484. ACPI_WARNING((AE_INFO,
  485. "Truncating %u table entries!",
  486. (unsigned)
  487. (acpi_gbl_root_table_list.size -
  488. acpi_gbl_root_table_list.
  489. count)));
  490. break;
  491. }
  492. }
  493. /*
  494. * Get the table physical address (32-bit for RSDT, 64-bit for XSDT)
  495. */
  496. if ((table_entry_size == sizeof(u32)) ||
  497. (sizeof(acpi_physical_address) == sizeof(u32))) {
  498. /*
  499. * 32-bit platform, RSDT: Move 32-bit to 32-bit
  500. * 32-bit platform, XSDT: Truncate 64-bit to 32-bit
  501. * 64-bit platform, RSDT: Expand 32-bit to 64-bit
  502. *
  503. * Note: Addresses are 32-bit aligned in both RSDT and XSDT
  504. */
  505. acpi_gbl_root_table_list.
  506. tables[acpi_gbl_root_table_list.count].address =
  507. (acpi_physical_address) (*ACPI_CAST_PTR
  508. (u32, table_entry));
  509. } else {
  510. /*
  511. * 64-bit platform, XSDT: Move 64-bit to 64-bit
  512. *
  513. * Note: 64-bit addresses are only 32-bit aligned in the XSDT
  514. */
  515. ACPI_MOVE_64_TO_64(&acpi_gbl_root_table_list.
  516. tables[acpi_gbl_root_table_list.
  517. count].address, table_entry);
  518. }
  519. table_entry += table_entry_size;
  520. acpi_gbl_root_table_list.count++;
  521. }
  522. /*
  523. * It is not possible to map more than one entry in some environments,
  524. * so unmap the root table here before mapping other tables
  525. */
  526. acpi_os_unmap_memory(table, length);
  527. /*
  528. * Complete the initialization of the root table array by examining
  529. * the header of each table
  530. */
  531. for (i = 2; i < acpi_gbl_root_table_list.count; i++) {
  532. acpi_tb_install_table(acpi_gbl_root_table_list.tables[i].
  533. address, flags, NULL, i);
  534. /* Special case for FADT - get the DSDT and FACS */
  535. if (ACPI_COMPARE_NAME
  536. (&acpi_gbl_root_table_list.tables[i].signature,
  537. ACPI_SIG_FADT)) {
  538. acpi_tb_parse_fadt(i, flags);
  539. }
  540. }
  541. return_ACPI_STATUS(AE_OK);
  542. }
  543. /******************************************************************************
  544. *
  545. * FUNCTION: acpi_tb_map
  546. *
  547. * PARAMETERS: Address - Address to be mapped
  548. * Length - Length to be mapped
  549. * Flags - Logical or physical addressing mode
  550. *
  551. * RETURN: Pointer to mapped region
  552. *
  553. * DESCRIPTION: Maps memory according to flag
  554. *
  555. *****************************************************************************/
  556. void *acpi_tb_map(acpi_physical_address address, u32 length, u32 flags)
  557. {
  558. if (flags == ACPI_TABLE_ORIGIN_MAPPED) {
  559. return (acpi_os_map_memory(address, length));
  560. } else {
  561. return (ACPI_CAST_PTR(void, address));
  562. }
  563. }
  564. /******************************************************************************
  565. *
  566. * FUNCTION: acpi_tb_unmap
  567. *
  568. * PARAMETERS: Pointer - To mapped region
  569. * Length - Length to be unmapped
  570. * Flags - Logical or physical addressing mode
  571. *
  572. * RETURN: None
  573. *
  574. * DESCRIPTION: Unmaps memory according to flag
  575. *
  576. *****************************************************************************/
  577. void acpi_tb_unmap(void *pointer, u32 length, u32 flags)
  578. {
  579. if (flags == ACPI_TABLE_ORIGIN_MAPPED) {
  580. acpi_os_unmap_memory(pointer, length);
  581. }
  582. }