tbgetall.c 9.2 KB

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