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