tbgetall.c 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. /******************************************************************************
  2. *
  3. * Module Name: tbgetall - Get all required ACPI tables
  4. *
  5. *****************************************************************************/
  6. /*
  7. * Copyright (C) 2000 - 2005, 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("tbgetall")
  46. /* Local prototypes */
  47. static acpi_status
  48. acpi_tb_get_primary_table(struct acpi_pointer *address,
  49. struct acpi_table_desc *table_info);
  50. static acpi_status
  51. acpi_tb_get_secondary_table(struct acpi_pointer *address,
  52. acpi_string signature,
  53. struct acpi_table_desc *table_info);
  54. /*******************************************************************************
  55. *
  56. * FUNCTION: acpi_tb_get_primary_table
  57. *
  58. * PARAMETERS: Address - Physical address of table to retrieve
  59. * *table_info - Where the table info is returned
  60. *
  61. * RETURN: Status
  62. *
  63. * DESCRIPTION: Maps the physical address of table into a logical address
  64. *
  65. ******************************************************************************/
  66. static acpi_status
  67. acpi_tb_get_primary_table(struct acpi_pointer *address,
  68. struct acpi_table_desc *table_info)
  69. {
  70. acpi_status status;
  71. struct acpi_table_header header;
  72. ACPI_FUNCTION_TRACE("tb_get_primary_table");
  73. /* Ignore a NULL address in the RSDT */
  74. if (!address->pointer.value) {
  75. return_ACPI_STATUS(AE_OK);
  76. }
  77. /* Get the header in order to get signature and table size */
  78. status = acpi_tb_get_table_header(address, &header);
  79. if (ACPI_FAILURE(status)) {
  80. return_ACPI_STATUS(status);
  81. }
  82. /* Clear the table_info */
  83. ACPI_MEMSET(table_info, 0, sizeof(struct acpi_table_desc));
  84. /*
  85. * Check the table signature and make sure it is recognized.
  86. * Also checks the header checksum
  87. */
  88. table_info->pointer = &header;
  89. status = acpi_tb_recognize_table(table_info, ACPI_TABLE_PRIMARY);
  90. if (ACPI_FAILURE(status)) {
  91. return_ACPI_STATUS(status);
  92. }
  93. /* Get the entire table */
  94. status = acpi_tb_get_table_body(address, &header, table_info);
  95. if (ACPI_FAILURE(status)) {
  96. return_ACPI_STATUS(status);
  97. }
  98. /* Install the table */
  99. status = acpi_tb_install_table(table_info);
  100. return_ACPI_STATUS(status);
  101. }
  102. /*******************************************************************************
  103. *
  104. * FUNCTION: acpi_tb_get_secondary_table
  105. *
  106. * PARAMETERS: Address - Physical address of table to retrieve
  107. * *table_info - Where the table info is returned
  108. *
  109. * RETURN: Status
  110. *
  111. * DESCRIPTION: Maps the physical address of table into a logical address
  112. *
  113. ******************************************************************************/
  114. static acpi_status
  115. acpi_tb_get_secondary_table(struct acpi_pointer *address,
  116. acpi_string signature,
  117. struct acpi_table_desc *table_info)
  118. {
  119. acpi_status status;
  120. struct acpi_table_header header;
  121. ACPI_FUNCTION_TRACE_STR("tb_get_secondary_table", signature);
  122. /* Get the header in order to match the signature */
  123. status = acpi_tb_get_table_header(address, &header);
  124. if (ACPI_FAILURE(status)) {
  125. return_ACPI_STATUS(status);
  126. }
  127. /* Signature must match request */
  128. if (ACPI_STRNCMP(header.signature, signature, ACPI_NAME_SIZE)) {
  129. ACPI_REPORT_ERROR(("Incorrect table signature - wanted [%s] found [%4.4s]\n", signature, header.signature));
  130. return_ACPI_STATUS(AE_BAD_SIGNATURE);
  131. }
  132. /*
  133. * Check the table signature and make sure it is recognized.
  134. * Also checks the header checksum
  135. */
  136. table_info->pointer = &header;
  137. status = acpi_tb_recognize_table(table_info, ACPI_TABLE_SECONDARY);
  138. if (ACPI_FAILURE(status)) {
  139. return_ACPI_STATUS(status);
  140. }
  141. /* Get the entire table */
  142. status = acpi_tb_get_table_body(address, &header, table_info);
  143. if (ACPI_FAILURE(status)) {
  144. return_ACPI_STATUS(status);
  145. }
  146. /* Install the table */
  147. status = acpi_tb_install_table(table_info);
  148. return_ACPI_STATUS(status);
  149. }
  150. /*******************************************************************************
  151. *
  152. * FUNCTION: acpi_tb_get_required_tables
  153. *
  154. * PARAMETERS: None
  155. *
  156. * RETURN: Status
  157. *
  158. * DESCRIPTION: Load and validate tables other than the RSDT. The RSDT must
  159. * already be loaded and validated.
  160. *
  161. * Get the minimum set of ACPI tables, namely:
  162. *
  163. * 1) FADT (via RSDT in loop below)
  164. * 2) FACS (via FADT)
  165. * 3) DSDT (via FADT)
  166. *
  167. ******************************************************************************/
  168. acpi_status acpi_tb_get_required_tables(void)
  169. {
  170. acpi_status status = AE_OK;
  171. u32 i;
  172. struct acpi_table_desc table_info;
  173. struct acpi_pointer address;
  174. ACPI_FUNCTION_TRACE("tb_get_required_tables");
  175. ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%d ACPI tables in RSDT\n",
  176. acpi_gbl_rsdt_table_count));
  177. address.pointer_type = acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING;
  178. /*
  179. * Loop through all table pointers found in RSDT.
  180. * This will NOT include the FACS and DSDT - we must get
  181. * them after the loop.
  182. *
  183. * The only tables we are interested in getting here is the FADT and
  184. * any SSDTs.
  185. */
  186. for (i = 0; i < acpi_gbl_rsdt_table_count; i++) {
  187. /* Get the table address from the common internal XSDT */
  188. address.pointer.value = acpi_gbl_XSDT->table_offset_entry[i];
  189. /*
  190. * Get the tables needed by this subsystem (FADT and any SSDTs).
  191. * NOTE: All other tables are completely ignored at this time.
  192. */
  193. status = acpi_tb_get_primary_table(&address, &table_info);
  194. if ((status != AE_OK) && (status != AE_TABLE_NOT_SUPPORTED)) {
  195. ACPI_REPORT_WARNING(("%s, while getting table at %8.8X%8.8X\n", acpi_format_exception(status), ACPI_FORMAT_UINT64(address.pointer.value)));
  196. }
  197. }
  198. /* We must have a FADT to continue */
  199. if (!acpi_gbl_FADT) {
  200. ACPI_REPORT_ERROR(("No FADT present in RSDT/XSDT\n"));
  201. return_ACPI_STATUS(AE_NO_ACPI_TABLES);
  202. }
  203. /*
  204. * Convert the FADT to a common format. This allows earlier revisions of
  205. * the table to coexist with newer versions, using common access code.
  206. */
  207. status = acpi_tb_convert_table_fadt();
  208. if (ACPI_FAILURE(status)) {
  209. ACPI_REPORT_ERROR(("Could not convert FADT to internal common format\n"));
  210. return_ACPI_STATUS(status);
  211. }
  212. /* Get the FACS (Pointed to by the FADT) */
  213. address.pointer.value = acpi_gbl_FADT->xfirmware_ctrl;
  214. status = acpi_tb_get_secondary_table(&address, FACS_SIG, &table_info);
  215. if (ACPI_FAILURE(status)) {
  216. ACPI_REPORT_ERROR(("Could not get/install the FACS, %s\n",
  217. acpi_format_exception(status)));
  218. return_ACPI_STATUS(status);
  219. }
  220. /*
  221. * Create the common FACS pointer table
  222. * (Contains pointers to the original table)
  223. */
  224. status = acpi_tb_build_common_facs(&table_info);
  225. if (ACPI_FAILURE(status)) {
  226. return_ACPI_STATUS(status);
  227. }
  228. /* Get/install the DSDT (Pointed to by the FADT) */
  229. address.pointer.value = acpi_gbl_FADT->Xdsdt;
  230. status = acpi_tb_get_secondary_table(&address, DSDT_SIG, &table_info);
  231. if (ACPI_FAILURE(status)) {
  232. ACPI_REPORT_ERROR(("Could not get/install the DSDT\n"));
  233. return_ACPI_STATUS(status);
  234. }
  235. /* Set Integer Width (32/64) based upon DSDT revision */
  236. acpi_ut_set_integer_width(acpi_gbl_DSDT->revision);
  237. /* Dump the entire DSDT */
  238. ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
  239. "Hex dump of entire DSDT, size %d (0x%X), Integer width = %d\n",
  240. acpi_gbl_DSDT->length, acpi_gbl_DSDT->length,
  241. acpi_gbl_integer_bit_width));
  242. ACPI_DUMP_BUFFER((u8 *) acpi_gbl_DSDT, acpi_gbl_DSDT->length);
  243. /* Always delete the RSDP mapping, we are done with it */
  244. acpi_tb_delete_tables_by_type(ACPI_TABLE_RSDP);
  245. return_ACPI_STATUS(status);
  246. }