Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Module Name: tbgetall - Get all required ACPI tables |
| 4 | * |
| 5 | *****************************************************************************/ |
| 6 | |
| 7 | /* |
| 8 | * Copyright (C) 2000 - 2005, R. Byron Moore |
| 9 | * All rights reserved. |
| 10 | * |
| 11 | * Redistribution and use in source and binary forms, with or without |
| 12 | * modification, are permitted provided that the following conditions |
| 13 | * are met: |
| 14 | * 1. Redistributions of source code must retain the above copyright |
| 15 | * notice, this list of conditions, and the following disclaimer, |
| 16 | * without modification. |
| 17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| 18 | * substantially similar to the "NO WARRANTY" disclaimer below |
| 19 | * ("Disclaimer") and any redistribution must be conditioned upon |
| 20 | * including a substantially similar Disclaimer requirement for further |
| 21 | * binary redistribution. |
| 22 | * 3. Neither the names of the above-listed copyright holders nor the names |
| 23 | * of any contributors may be used to endorse or promote products derived |
| 24 | * from this software without specific prior written permission. |
| 25 | * |
| 26 | * Alternatively, this software may be distributed under the terms of the |
| 27 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 28 | * Software Foundation. |
| 29 | * |
| 30 | * NO WARRANTY |
| 31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
| 34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 41 | * POSSIBILITY OF SUCH DAMAGES. |
| 42 | */ |
| 43 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include <acpi/acpi.h> |
| 45 | #include <acpi/actables.h> |
| 46 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | #define _COMPONENT ACPI_TABLES |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 48 | ACPI_MODULE_NAME("tbgetall") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 50 | /* Local prototypes */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 51 | static acpi_status |
| 52 | acpi_tb_get_primary_table(struct acpi_pointer *address, |
| 53 | struct acpi_table_desc *table_info); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 54 | |
| 55 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 56 | acpi_tb_get_secondary_table(struct acpi_pointer *address, |
| 57 | acpi_string signature, |
| 58 | struct acpi_table_desc *table_info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | |
| 60 | /******************************************************************************* |
| 61 | * |
| 62 | * FUNCTION: acpi_tb_get_primary_table |
| 63 | * |
| 64 | * PARAMETERS: Address - Physical address of table to retrieve |
| 65 | * *table_info - Where the table info is returned |
| 66 | * |
| 67 | * RETURN: Status |
| 68 | * |
| 69 | * DESCRIPTION: Maps the physical address of table into a logical address |
| 70 | * |
| 71 | ******************************************************************************/ |
| 72 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 73 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 74 | acpi_tb_get_primary_table(struct acpi_pointer *address, |
| 75 | struct acpi_table_desc *table_info) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 77 | acpi_status status; |
| 78 | struct acpi_table_header header; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 80 | ACPI_FUNCTION_TRACE("tb_get_primary_table"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | |
| 82 | /* Ignore a NULL address in the RSDT */ |
| 83 | |
| 84 | if (!address->pointer.value) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 85 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | } |
| 87 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 88 | /* Get the header in order to get signature and table size */ |
| 89 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 90 | status = acpi_tb_get_table_header(address, &header); |
| 91 | if (ACPI_FAILURE(status)) { |
| 92 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | /* Clear the table_info */ |
| 96 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 97 | ACPI_MEMSET(table_info, 0, sizeof(struct acpi_table_desc)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | |
| 99 | /* |
| 100 | * Check the table signature and make sure it is recognized. |
| 101 | * Also checks the header checksum |
| 102 | */ |
| 103 | table_info->pointer = &header; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 104 | status = acpi_tb_recognize_table(table_info, ACPI_TABLE_PRIMARY); |
| 105 | if (ACPI_FAILURE(status)) { |
| 106 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | /* Get the entire table */ |
| 110 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 111 | status = acpi_tb_get_table_body(address, &header, table_info); |
| 112 | if (ACPI_FAILURE(status)) { |
| 113 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | /* Install the table */ |
| 117 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 118 | status = acpi_tb_install_table(table_info); |
| 119 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | } |
| 121 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | /******************************************************************************* |
| 123 | * |
| 124 | * FUNCTION: acpi_tb_get_secondary_table |
| 125 | * |
| 126 | * PARAMETERS: Address - Physical address of table to retrieve |
| 127 | * *table_info - Where the table info is returned |
| 128 | * |
| 129 | * RETURN: Status |
| 130 | * |
| 131 | * DESCRIPTION: Maps the physical address of table into a logical address |
| 132 | * |
| 133 | ******************************************************************************/ |
| 134 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 135 | static acpi_status |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 136 | acpi_tb_get_secondary_table(struct acpi_pointer *address, |
| 137 | acpi_string signature, |
| 138 | struct acpi_table_desc *table_info) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 139 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 140 | acpi_status status; |
| 141 | struct acpi_table_header header; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 143 | ACPI_FUNCTION_TRACE_STR("tb_get_secondary_table", signature); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | |
| 145 | /* Get the header in order to match the signature */ |
| 146 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 147 | status = acpi_tb_get_table_header(address, &header); |
| 148 | if (ACPI_FAILURE(status)) { |
| 149 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | /* Signature must match request */ |
| 153 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 154 | if (ACPI_STRNCMP(header.signature, signature, ACPI_NAME_SIZE)) { |
| 155 | ACPI_REPORT_ERROR(("Incorrect table signature - wanted [%s] found [%4.4s]\n", signature, header.signature)); |
| 156 | return_ACPI_STATUS(AE_BAD_SIGNATURE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | /* |
| 160 | * Check the table signature and make sure it is recognized. |
| 161 | * Also checks the header checksum |
| 162 | */ |
| 163 | table_info->pointer = &header; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 164 | status = acpi_tb_recognize_table(table_info, ACPI_TABLE_SECONDARY); |
| 165 | if (ACPI_FAILURE(status)) { |
| 166 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | /* Get the entire table */ |
| 170 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 171 | status = acpi_tb_get_table_body(address, &header, table_info); |
| 172 | if (ACPI_FAILURE(status)) { |
| 173 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | /* Install the table */ |
| 177 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 178 | status = acpi_tb_install_table(table_info); |
| 179 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | } |
| 181 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | /******************************************************************************* |
| 183 | * |
| 184 | * FUNCTION: acpi_tb_get_required_tables |
| 185 | * |
| 186 | * PARAMETERS: None |
| 187 | * |
| 188 | * RETURN: Status |
| 189 | * |
| 190 | * DESCRIPTION: Load and validate tables other than the RSDT. The RSDT must |
| 191 | * already be loaded and validated. |
| 192 | * |
| 193 | * Get the minimum set of ACPI tables, namely: |
| 194 | * |
| 195 | * 1) FADT (via RSDT in loop below) |
| 196 | * 2) FACS (via FADT) |
| 197 | * 3) DSDT (via FADT) |
| 198 | * |
| 199 | ******************************************************************************/ |
| 200 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 201 | acpi_status acpi_tb_get_required_tables(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 202 | { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 203 | acpi_status status = AE_OK; |
| 204 | u32 i; |
| 205 | struct acpi_table_desc table_info; |
| 206 | struct acpi_pointer address; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 207 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 208 | ACPI_FUNCTION_TRACE("tb_get_required_tables"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 209 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 210 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "%d ACPI tables in RSDT\n", |
| 211 | acpi_gbl_rsdt_table_count)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 213 | address.pointer_type = acpi_gbl_table_flags | ACPI_LOGICAL_ADDRESSING; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | |
| 215 | /* |
| 216 | * Loop through all table pointers found in RSDT. |
| 217 | * This will NOT include the FACS and DSDT - we must get |
| 218 | * them after the loop. |
| 219 | * |
| 220 | * The only tables we are interested in getting here is the FADT and |
| 221 | * any SSDTs. |
| 222 | */ |
| 223 | for (i = 0; i < acpi_gbl_rsdt_table_count; i++) { |
| 224 | /* Get the table address from the common internal XSDT */ |
| 225 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 226 | address.pointer.value = acpi_gbl_XSDT->table_offset_entry[i]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | |
| 228 | /* |
| 229 | * Get the tables needed by this subsystem (FADT and any SSDTs). |
| 230 | * NOTE: All other tables are completely ignored at this time. |
| 231 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 232 | status = acpi_tb_get_primary_table(&address, &table_info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | if ((status != AE_OK) && (status != AE_TABLE_NOT_SUPPORTED)) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 234 | ACPI_REPORT_WARNING(("%s, while getting table at %8.8X%8.8X\n", acpi_format_exception(status), ACPI_FORMAT_UINT64(address.pointer.value))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | } |
| 236 | } |
| 237 | |
| 238 | /* We must have a FADT to continue */ |
| 239 | |
| 240 | if (!acpi_gbl_FADT) { |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 241 | ACPI_REPORT_ERROR(("No FADT present in RSDT/XSDT\n")); |
| 242 | return_ACPI_STATUS(AE_NO_ACPI_TABLES); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | /* |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 246 | * Convert the FADT to a common format. This allows earlier revisions of |
| 247 | * the table to coexist with newer versions, using common access code. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 249 | status = acpi_tb_convert_table_fadt(); |
| 250 | if (ACPI_FAILURE(status)) { |
| 251 | ACPI_REPORT_ERROR(("Could not convert FADT to internal common format\n")); |
| 252 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 253 | } |
| 254 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 255 | /* Get the FACS (Pointed to by the FADT) */ |
| 256 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | address.pointer.value = acpi_gbl_FADT->xfirmware_ctrl; |
| 258 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 259 | status = acpi_tb_get_secondary_table(&address, FACS_SIG, &table_info); |
| 260 | if (ACPI_FAILURE(status)) { |
| 261 | ACPI_REPORT_ERROR(("Could not get/install the FACS, %s\n", |
| 262 | acpi_format_exception(status))); |
| 263 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | /* |
| 267 | * Create the common FACS pointer table |
| 268 | * (Contains pointers to the original table) |
| 269 | */ |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 270 | status = acpi_tb_build_common_facs(&table_info); |
| 271 | if (ACPI_FAILURE(status)) { |
| 272 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | } |
| 274 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 275 | /* Get/install the DSDT (Pointed to by the FADT) */ |
| 276 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 277 | address.pointer.value = acpi_gbl_FADT->Xdsdt; |
| 278 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 279 | status = acpi_tb_get_secondary_table(&address, DSDT_SIG, &table_info); |
| 280 | if (ACPI_FAILURE(status)) { |
| 281 | ACPI_REPORT_ERROR(("Could not get/install the DSDT\n")); |
| 282 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | /* Set Integer Width (32/64) based upon DSDT revision */ |
| 286 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 287 | acpi_ut_set_integer_width(acpi_gbl_DSDT->revision); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | |
| 289 | /* Dump the entire DSDT */ |
| 290 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 291 | ACPI_DEBUG_PRINT((ACPI_DB_TABLES, |
| 292 | "Hex dump of entire DSDT, size %d (0x%X), Integer width = %d\n", |
| 293 | acpi_gbl_DSDT->length, acpi_gbl_DSDT->length, |
| 294 | acpi_gbl_integer_bit_width)); |
| 295 | ACPI_DUMP_BUFFER((u8 *) acpi_gbl_DSDT, acpi_gbl_DSDT->length); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | |
| 297 | /* Always delete the RSDP mapping, we are done with it */ |
| 298 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 299 | acpi_tb_delete_tables_by_type(ACPI_TABLE_RSDP); |
| 300 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | } |