tbgetall.c 9.6 KB

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