Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Module Name: tbconvrt - ACPI Table conversion utilities |
| 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 | #include <linux/module.h> |
| 45 | |
| 46 | #include <acpi/acpi.h> |
| 47 | #include <acpi/actables.h> |
| 48 | |
| 49 | |
| 50 | #define _COMPONENT ACPI_TABLES |
| 51 | ACPI_MODULE_NAME ("tbconvrt") |
| 52 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 53 | /* Local prototypes */ |
| 54 | |
| 55 | static void |
| 56 | acpi_tb_init_generic_address ( |
| 57 | struct acpi_generic_address *new_gas_struct, |
| 58 | u8 register_bit_width, |
| 59 | acpi_physical_address address); |
| 60 | |
| 61 | static void |
| 62 | acpi_tb_convert_fadt1 ( |
| 63 | struct fadt_descriptor_rev2 *local_fadt, |
| 64 | struct fadt_descriptor_rev1 *original_fadt); |
| 65 | |
| 66 | static void |
| 67 | acpi_tb_convert_fadt2 ( |
| 68 | struct fadt_descriptor_rev2 *local_fadt, |
| 69 | struct fadt_descriptor_rev2 *original_fadt); |
| 70 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | |
| 72 | u8 acpi_fadt_is_v1; |
| 73 | EXPORT_SYMBOL(acpi_fadt_is_v1); |
| 74 | |
| 75 | /******************************************************************************* |
| 76 | * |
| 77 | * FUNCTION: acpi_tb_get_table_count |
| 78 | * |
| 79 | * PARAMETERS: RSDP - Pointer to the RSDP |
| 80 | * RSDT - Pointer to the RSDT/XSDT |
| 81 | * |
| 82 | * RETURN: The number of tables pointed to by the RSDT or XSDT. |
| 83 | * |
| 84 | * DESCRIPTION: Calculate the number of tables. Automatically handles either |
| 85 | * an RSDT or XSDT. |
| 86 | * |
| 87 | ******************************************************************************/ |
| 88 | |
| 89 | u32 |
| 90 | acpi_tb_get_table_count ( |
| 91 | struct rsdp_descriptor *RSDP, |
| 92 | struct acpi_table_header *RSDT) |
| 93 | { |
| 94 | u32 pointer_size; |
| 95 | |
| 96 | |
| 97 | ACPI_FUNCTION_ENTRY (); |
| 98 | |
| 99 | |
| 100 | if (RSDP->revision < 2) { |
| 101 | pointer_size = sizeof (u32); |
| 102 | } |
| 103 | else { |
| 104 | pointer_size = sizeof (u64); |
| 105 | } |
| 106 | |
| 107 | /* |
| 108 | * Determine the number of tables pointed to by the RSDT/XSDT. |
| 109 | * This is defined by the ACPI Specification to be the number of |
| 110 | * pointers contained within the RSDT/XSDT. The size of the pointers |
| 111 | * is architecture-dependent. |
| 112 | */ |
| 113 | return ((RSDT->length - sizeof (struct acpi_table_header)) / pointer_size); |
| 114 | } |
| 115 | |
| 116 | |
| 117 | /******************************************************************************* |
| 118 | * |
| 119 | * FUNCTION: acpi_tb_convert_to_xsdt |
| 120 | * |
| 121 | * PARAMETERS: table_info - Info about the RSDT |
| 122 | * |
| 123 | * RETURN: Status |
| 124 | * |
| 125 | * DESCRIPTION: Convert an RSDT to an XSDT (internal common format) |
| 126 | * |
| 127 | ******************************************************************************/ |
| 128 | |
| 129 | acpi_status |
| 130 | acpi_tb_convert_to_xsdt ( |
| 131 | struct acpi_table_desc *table_info) |
| 132 | { |
| 133 | acpi_size table_size; |
| 134 | u32 i; |
| 135 | XSDT_DESCRIPTOR *new_table; |
| 136 | |
| 137 | |
| 138 | ACPI_FUNCTION_ENTRY (); |
| 139 | |
| 140 | |
| 141 | /* Compute size of the converted XSDT */ |
| 142 | |
| 143 | table_size = ((acpi_size) acpi_gbl_rsdt_table_count * sizeof (u64)) + |
| 144 | sizeof (struct acpi_table_header); |
| 145 | |
| 146 | /* Allocate an XSDT */ |
| 147 | |
| 148 | new_table = ACPI_MEM_CALLOCATE (table_size); |
| 149 | if (!new_table) { |
| 150 | return (AE_NO_MEMORY); |
| 151 | } |
| 152 | |
| 153 | /* Copy the header and set the length */ |
| 154 | |
| 155 | ACPI_MEMCPY (new_table, table_info->pointer, sizeof (struct acpi_table_header)); |
| 156 | new_table->length = (u32) table_size; |
| 157 | |
| 158 | /* Copy the table pointers */ |
| 159 | |
| 160 | for (i = 0; i < acpi_gbl_rsdt_table_count; i++) { |
| 161 | if (acpi_gbl_RSDP->revision < 2) { |
| 162 | ACPI_STORE_ADDRESS (new_table->table_offset_entry[i], |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 163 | (ACPI_CAST_PTR (struct rsdt_descriptor_rev1, |
| 164 | table_info->pointer))->table_offset_entry[i]); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | } |
| 166 | else { |
| 167 | new_table->table_offset_entry[i] = |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 168 | (ACPI_CAST_PTR (XSDT_DESCRIPTOR, |
| 169 | table_info->pointer))->table_offset_entry[i]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | } |
| 171 | } |
| 172 | |
| 173 | /* Delete the original table (either mapped or in a buffer) */ |
| 174 | |
| 175 | acpi_tb_delete_single_table (table_info); |
| 176 | |
| 177 | /* Point the table descriptor to the new table */ |
| 178 | |
| 179 | table_info->pointer = ACPI_CAST_PTR (struct acpi_table_header, new_table); |
| 180 | table_info->length = table_size; |
| 181 | table_info->allocation = ACPI_MEM_ALLOCATED; |
| 182 | |
| 183 | return (AE_OK); |
| 184 | } |
| 185 | |
| 186 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 187 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | * |
| 189 | * FUNCTION: acpi_tb_init_generic_address |
| 190 | * |
| 191 | * PARAMETERS: new_gas_struct - GAS struct to be initialized |
| 192 | * register_bit_width - Width of this register |
| 193 | * Address - Address of the register |
| 194 | * |
| 195 | * RETURN: None |
| 196 | * |
| 197 | * DESCRIPTION: Initialize a GAS structure. |
| 198 | * |
| 199 | ******************************************************************************/ |
| 200 | |
| 201 | static void |
| 202 | acpi_tb_init_generic_address ( |
| 203 | struct acpi_generic_address *new_gas_struct, |
| 204 | u8 register_bit_width, |
| 205 | acpi_physical_address address) |
| 206 | { |
| 207 | |
| 208 | ACPI_STORE_ADDRESS (new_gas_struct->address, address); |
| 209 | |
| 210 | new_gas_struct->address_space_id = ACPI_ADR_SPACE_SYSTEM_IO; |
| 211 | new_gas_struct->register_bit_width = register_bit_width; |
| 212 | new_gas_struct->register_bit_offset = 0; |
| 213 | new_gas_struct->access_width = 0; |
| 214 | } |
| 215 | |
| 216 | |
| 217 | /******************************************************************************* |
| 218 | * |
| 219 | * FUNCTION: acpi_tb_convert_fadt1 |
| 220 | * |
| 221 | * PARAMETERS: local_fadt - Pointer to new FADT |
| 222 | * original_fadt - Pointer to old FADT |
| 223 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 224 | * RETURN: None, populates local_fadt |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | * |
| 226 | * DESCRIPTION: Convert an ACPI 1.0 FADT to common internal format |
| 227 | * |
| 228 | ******************************************************************************/ |
| 229 | |
| 230 | static void |
| 231 | acpi_tb_convert_fadt1 ( |
| 232 | struct fadt_descriptor_rev2 *local_fadt, |
| 233 | struct fadt_descriptor_rev1 *original_fadt) |
| 234 | { |
| 235 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | /* ACPI 1.0 FACS */ |
| 237 | /* The BIOS stored FADT should agree with Revision 1.0 */ |
| 238 | acpi_fadt_is_v1 = 1; |
| 239 | |
| 240 | /* |
| 241 | * Copy the table header and the common part of the tables. |
| 242 | * |
| 243 | * The 2.0 table is an extension of the 1.0 table, so the entire 1.0 |
| 244 | * table can be copied first, then expand some fields to 64 bits. |
| 245 | */ |
| 246 | ACPI_MEMCPY (local_fadt, original_fadt, sizeof (struct fadt_descriptor_rev1)); |
| 247 | |
| 248 | /* Convert table pointers to 64-bit fields */ |
| 249 | |
| 250 | ACPI_STORE_ADDRESS (local_fadt->xfirmware_ctrl, local_fadt->V1_firmware_ctrl); |
| 251 | ACPI_STORE_ADDRESS (local_fadt->Xdsdt, local_fadt->V1_dsdt); |
| 252 | |
| 253 | /* |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 254 | * System Interrupt Model isn't used in ACPI 2.0 |
| 255 | * (local_fadt->Reserved1 = 0;) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | */ |
| 257 | |
| 258 | /* |
| 259 | * This field is set by the OEM to convey the preferred power management |
| 260 | * profile to OSPM. It doesn't have any 1.0 equivalence. Since we don't |
| 261 | * know what kind of 32-bit system this is, we will use "unspecified". |
| 262 | */ |
| 263 | local_fadt->prefer_PM_profile = PM_UNSPECIFIED; |
| 264 | |
| 265 | /* |
| 266 | * Processor Performance State Control. This is the value OSPM writes to |
| 267 | * the SMI_CMD register to assume processor performance state control |
| 268 | * responsibility. There isn't any equivalence in 1.0, but as many 1.x |
| 269 | * ACPI tables contain _PCT and _PSS we also keep this value, unless |
| 270 | * acpi_strict is set. |
| 271 | */ |
| 272 | if (acpi_strict) |
| 273 | local_fadt->pstate_cnt = 0; |
| 274 | |
| 275 | /* |
| 276 | * Support for the _CST object and C States change notification. |
| 277 | * This data item hasn't any 1.0 equivalence so leave it zero. |
| 278 | */ |
| 279 | local_fadt->cst_cnt = 0; |
| 280 | |
| 281 | /* |
| 282 | * FADT Rev 2 was an interim FADT released between ACPI 1.0 and ACPI 2.0. |
| 283 | * It primarily adds the FADT reset mechanism. |
| 284 | */ |
| 285 | if ((original_fadt->revision == 2) && |
| 286 | (original_fadt->length == sizeof (struct fadt_descriptor_rev2_minus))) { |
| 287 | /* |
| 288 | * Grab the entire generic address struct, plus the 1-byte reset value |
| 289 | * that immediately follows. |
| 290 | */ |
| 291 | ACPI_MEMCPY (&local_fadt->reset_register, |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 292 | &(ACPI_CAST_PTR (struct fadt_descriptor_rev2_minus, |
| 293 | original_fadt))->reset_register, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | sizeof (struct acpi_generic_address) + 1); |
| 295 | } |
| 296 | else { |
| 297 | /* |
| 298 | * Since there isn't any equivalence in 1.0 and since it is highly |
| 299 | * likely that a 1.0 system has legacy support. |
| 300 | */ |
| 301 | local_fadt->iapc_boot_arch = BAF_LEGACY_DEVICES; |
| 302 | } |
| 303 | |
| 304 | /* |
| 305 | * Convert the V1.0 block addresses to V2.0 GAS structures |
| 306 | */ |
| 307 | acpi_tb_init_generic_address (&local_fadt->xpm1a_evt_blk, local_fadt->pm1_evt_len, |
| 308 | (acpi_physical_address) local_fadt->V1_pm1a_evt_blk); |
| 309 | acpi_tb_init_generic_address (&local_fadt->xpm1b_evt_blk, local_fadt->pm1_evt_len, |
| 310 | (acpi_physical_address) local_fadt->V1_pm1b_evt_blk); |
| 311 | acpi_tb_init_generic_address (&local_fadt->xpm1a_cnt_blk, local_fadt->pm1_cnt_len, |
| 312 | (acpi_physical_address) local_fadt->V1_pm1a_cnt_blk); |
| 313 | acpi_tb_init_generic_address (&local_fadt->xpm1b_cnt_blk, local_fadt->pm1_cnt_len, |
| 314 | (acpi_physical_address) local_fadt->V1_pm1b_cnt_blk); |
| 315 | acpi_tb_init_generic_address (&local_fadt->xpm2_cnt_blk, local_fadt->pm2_cnt_len, |
| 316 | (acpi_physical_address) local_fadt->V1_pm2_cnt_blk); |
| 317 | acpi_tb_init_generic_address (&local_fadt->xpm_tmr_blk, local_fadt->pm_tm_len, |
| 318 | (acpi_physical_address) local_fadt->V1_pm_tmr_blk); |
| 319 | acpi_tb_init_generic_address (&local_fadt->xgpe0_blk, 0, |
| 320 | (acpi_physical_address) local_fadt->V1_gpe0_blk); |
| 321 | acpi_tb_init_generic_address (&local_fadt->xgpe1_blk, 0, |
| 322 | (acpi_physical_address) local_fadt->V1_gpe1_blk); |
| 323 | |
| 324 | /* Create separate GAS structs for the PM1 Enable registers */ |
| 325 | |
| 326 | acpi_tb_init_generic_address (&acpi_gbl_xpm1a_enable, |
| 327 | (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len), |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 328 | (acpi_physical_address) |
| 329 | (local_fadt->xpm1a_evt_blk.address + |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len))); |
| 331 | |
| 332 | /* PM1B is optional; leave null if not present */ |
| 333 | |
| 334 | if (local_fadt->xpm1b_evt_blk.address) { |
| 335 | acpi_tb_init_generic_address (&acpi_gbl_xpm1b_enable, |
| 336 | (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len), |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 337 | (acpi_physical_address) |
| 338 | (local_fadt->xpm1b_evt_blk.address + |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 339 | ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len))); |
| 340 | } |
| 341 | } |
| 342 | |
| 343 | |
| 344 | /******************************************************************************* |
| 345 | * |
| 346 | * FUNCTION: acpi_tb_convert_fadt2 |
| 347 | * |
| 348 | * PARAMETERS: local_fadt - Pointer to new FADT |
| 349 | * original_fadt - Pointer to old FADT |
| 350 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 351 | * RETURN: None, populates local_fadt |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | * |
| 353 | * DESCRIPTION: Convert an ACPI 2.0 FADT to common internal format. |
| 354 | * Handles optional "X" fields. |
| 355 | * |
| 356 | ******************************************************************************/ |
| 357 | |
| 358 | static void |
| 359 | acpi_tb_convert_fadt2 ( |
| 360 | struct fadt_descriptor_rev2 *local_fadt, |
| 361 | struct fadt_descriptor_rev2 *original_fadt) |
| 362 | { |
| 363 | |
| 364 | /* We have an ACPI 2.0 FADT but we must copy it to our local buffer */ |
| 365 | |
| 366 | ACPI_MEMCPY (local_fadt, original_fadt, sizeof (struct fadt_descriptor_rev2)); |
| 367 | |
| 368 | /* |
| 369 | * "X" fields are optional extensions to the original V1.0 fields, so |
| 370 | * we must selectively expand V1.0 fields if the corresponding X field |
| 371 | * is zero. |
| 372 | */ |
| 373 | if (!(local_fadt->xfirmware_ctrl)) { |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 374 | ACPI_STORE_ADDRESS (local_fadt->xfirmware_ctrl, |
| 375 | local_fadt->V1_firmware_ctrl); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 376 | } |
| 377 | |
| 378 | if (!(local_fadt->Xdsdt)) { |
| 379 | ACPI_STORE_ADDRESS (local_fadt->Xdsdt, local_fadt->V1_dsdt); |
| 380 | } |
| 381 | |
| 382 | if (!(local_fadt->xpm1a_evt_blk.address)) { |
| 383 | acpi_tb_init_generic_address (&local_fadt->xpm1a_evt_blk, |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 384 | local_fadt->pm1_evt_len, |
| 385 | (acpi_physical_address) local_fadt->V1_pm1a_evt_blk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | if (!(local_fadt->xpm1b_evt_blk.address)) { |
| 389 | acpi_tb_init_generic_address (&local_fadt->xpm1b_evt_blk, |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 390 | local_fadt->pm1_evt_len, |
| 391 | (acpi_physical_address) local_fadt->V1_pm1b_evt_blk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 392 | } |
| 393 | |
| 394 | if (!(local_fadt->xpm1a_cnt_blk.address)) { |
| 395 | acpi_tb_init_generic_address (&local_fadt->xpm1a_cnt_blk, |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 396 | local_fadt->pm1_cnt_len, |
| 397 | (acpi_physical_address) local_fadt->V1_pm1a_cnt_blk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | } |
| 399 | |
| 400 | if (!(local_fadt->xpm1b_cnt_blk.address)) { |
| 401 | acpi_tb_init_generic_address (&local_fadt->xpm1b_cnt_blk, |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 402 | local_fadt->pm1_cnt_len, |
| 403 | (acpi_physical_address) local_fadt->V1_pm1b_cnt_blk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | } |
| 405 | |
| 406 | if (!(local_fadt->xpm2_cnt_blk.address)) { |
| 407 | acpi_tb_init_generic_address (&local_fadt->xpm2_cnt_blk, |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 408 | local_fadt->pm2_cnt_len, |
| 409 | (acpi_physical_address) local_fadt->V1_pm2_cnt_blk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | if (!(local_fadt->xpm_tmr_blk.address)) { |
| 413 | acpi_tb_init_generic_address (&local_fadt->xpm_tmr_blk, |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 414 | local_fadt->pm_tm_len, |
| 415 | (acpi_physical_address) local_fadt->V1_pm_tmr_blk); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | if (!(local_fadt->xgpe0_blk.address)) { |
| 419 | acpi_tb_init_generic_address (&local_fadt->xgpe0_blk, |
| 420 | 0, (acpi_physical_address) local_fadt->V1_gpe0_blk); |
| 421 | } |
| 422 | |
| 423 | if (!(local_fadt->xgpe1_blk.address)) { |
| 424 | acpi_tb_init_generic_address (&local_fadt->xgpe1_blk, |
| 425 | 0, (acpi_physical_address) local_fadt->V1_gpe1_blk); |
| 426 | } |
| 427 | |
| 428 | /* Create separate GAS structs for the PM1 Enable registers */ |
| 429 | |
| 430 | acpi_tb_init_generic_address (&acpi_gbl_xpm1a_enable, |
| 431 | (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len), |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 432 | (acpi_physical_address) |
| 433 | (local_fadt->xpm1a_evt_blk.address + |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 434 | ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len))); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 435 | |
| 436 | acpi_gbl_xpm1a_enable.address_space_id = |
| 437 | local_fadt->xpm1a_evt_blk.address_space_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 438 | |
| 439 | /* PM1B is optional; leave null if not present */ |
| 440 | |
| 441 | if (local_fadt->xpm1b_evt_blk.address) { |
| 442 | acpi_tb_init_generic_address (&acpi_gbl_xpm1b_enable, |
| 443 | (u8) ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len), |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 444 | (acpi_physical_address) |
| 445 | (local_fadt->xpm1b_evt_blk.address + |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 446 | ACPI_DIV_2 (acpi_gbl_FADT->pm1_evt_len))); |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 447 | |
| 448 | acpi_gbl_xpm1b_enable.address_space_id = |
| 449 | local_fadt->xpm1b_evt_blk.address_space_id; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 450 | } |
| 451 | } |
| 452 | |
| 453 | |
| 454 | /******************************************************************************* |
| 455 | * |
| 456 | * FUNCTION: acpi_tb_convert_table_fadt |
| 457 | * |
| 458 | * PARAMETERS: None |
| 459 | * |
| 460 | * RETURN: Status |
| 461 | * |
| 462 | * DESCRIPTION: Converts a BIOS supplied ACPI 1.0 FADT to a local |
| 463 | * ACPI 2.0 FADT. If the BIOS supplied a 2.0 FADT then it is simply |
| 464 | * copied to the local FADT. The ACPI CA software uses this |
| 465 | * local FADT. Thus a significant amount of special #ifdef |
| 466 | * type codeing is saved. |
| 467 | * |
| 468 | ******************************************************************************/ |
| 469 | |
| 470 | acpi_status |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 471 | acpi_tb_convert_table_fadt ( |
| 472 | void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 473 | { |
| 474 | struct fadt_descriptor_rev2 *local_fadt; |
| 475 | struct acpi_table_desc *table_desc; |
| 476 | |
| 477 | |
| 478 | ACPI_FUNCTION_TRACE ("tb_convert_table_fadt"); |
| 479 | |
| 480 | |
| 481 | /* |
| 482 | * acpi_gbl_FADT is valid. Validate the FADT length. The table must be |
| 483 | * at least as long as the version 1.0 FADT |
| 484 | */ |
| 485 | if (acpi_gbl_FADT->length < sizeof (struct fadt_descriptor_rev1)) { |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 486 | ACPI_REPORT_ERROR (("FADT is invalid, too short: 0x%X\n", |
| 487 | acpi_gbl_FADT->length)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); |
| 489 | } |
| 490 | |
| 491 | /* Allocate buffer for the ACPI 2.0(+) FADT */ |
| 492 | |
| 493 | local_fadt = ACPI_MEM_CALLOCATE (sizeof (struct fadt_descriptor_rev2)); |
| 494 | if (!local_fadt) { |
| 495 | return_ACPI_STATUS (AE_NO_MEMORY); |
| 496 | } |
| 497 | |
| 498 | if (acpi_gbl_FADT->revision >= FADT2_REVISION_ID) { |
| 499 | if (acpi_gbl_FADT->length < sizeof (struct fadt_descriptor_rev2)) { |
| 500 | /* Length is too short to be a V2.0 table */ |
| 501 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 502 | ACPI_REPORT_WARNING (( |
| 503 | "Inconsistent FADT length (0x%X) and revision (0x%X), using FADT V1.0 portion of table\n", |
| 504 | acpi_gbl_FADT->length, acpi_gbl_FADT->revision)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 505 | |
| 506 | acpi_tb_convert_fadt1 (local_fadt, (void *) acpi_gbl_FADT); |
| 507 | } |
| 508 | else { |
| 509 | /* Valid V2.0 table */ |
| 510 | |
| 511 | acpi_tb_convert_fadt2 (local_fadt, acpi_gbl_FADT); |
| 512 | } |
| 513 | } |
| 514 | else { |
| 515 | /* Valid V1.0 table */ |
| 516 | |
| 517 | acpi_tb_convert_fadt1 (local_fadt, (void *) acpi_gbl_FADT); |
| 518 | } |
| 519 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 520 | /* Global FADT pointer will point to the new common V2.0 FADT */ |
| 521 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 522 | acpi_gbl_FADT = local_fadt; |
| 523 | acpi_gbl_FADT->length = sizeof (FADT_DESCRIPTOR); |
| 524 | |
| 525 | /* Free the original table */ |
| 526 | |
| 527 | table_desc = acpi_gbl_table_lists[ACPI_TABLE_FADT].next; |
| 528 | acpi_tb_delete_single_table (table_desc); |
| 529 | |
| 530 | /* Install the new table */ |
| 531 | |
| 532 | table_desc->pointer = ACPI_CAST_PTR (struct acpi_table_header, acpi_gbl_FADT); |
| 533 | table_desc->allocation = ACPI_MEM_ALLOCATED; |
| 534 | table_desc->length = sizeof (struct fadt_descriptor_rev2); |
| 535 | |
| 536 | /* Dump the entire FADT */ |
| 537 | |
| 538 | ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, |
| 539 | "Hex dump of common internal FADT, size %d (%X)\n", |
| 540 | acpi_gbl_FADT->length, acpi_gbl_FADT->length)); |
| 541 | ACPI_DUMP_BUFFER ((u8 *) (acpi_gbl_FADT), acpi_gbl_FADT->length); |
| 542 | |
| 543 | return_ACPI_STATUS (AE_OK); |
| 544 | } |
| 545 | |
| 546 | |
| 547 | /******************************************************************************* |
| 548 | * |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 549 | * FUNCTION: acpi_tb_build_common_facs |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | * |
| 551 | * PARAMETERS: table_info - Info for currently installed FACS |
| 552 | * |
| 553 | * RETURN: Status |
| 554 | * |
| 555 | * DESCRIPTION: Convert ACPI 1.0 and ACPI 2.0 FACS to a common internal |
| 556 | * table format. |
| 557 | * |
| 558 | ******************************************************************************/ |
| 559 | |
| 560 | acpi_status |
| 561 | acpi_tb_build_common_facs ( |
| 562 | struct acpi_table_desc *table_info) |
| 563 | { |
| 564 | |
| 565 | ACPI_FUNCTION_TRACE ("tb_build_common_facs"); |
| 566 | |
| 567 | |
| 568 | /* Absolute minimum length is 24, but the ACPI spec says 64 */ |
| 569 | |
| 570 | if (acpi_gbl_FACS->length < 24) { |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 571 | ACPI_REPORT_ERROR (("Invalid FACS table length: 0x%X\n", |
| 572 | acpi_gbl_FACS->length)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 573 | return_ACPI_STATUS (AE_INVALID_TABLE_LENGTH); |
| 574 | } |
| 575 | |
| 576 | if (acpi_gbl_FACS->length < 64) { |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 577 | ACPI_REPORT_WARNING (( |
| 578 | "FACS is shorter than the ACPI specification allows: 0x%X, using anyway\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 579 | acpi_gbl_FACS->length)); |
| 580 | } |
| 581 | |
| 582 | /* Copy fields to the new FACS */ |
| 583 | |
| 584 | acpi_gbl_common_fACS.global_lock = &(acpi_gbl_FACS->global_lock); |
| 585 | |
| 586 | if ((acpi_gbl_RSDP->revision < 2) || |
| 587 | (acpi_gbl_FACS->length < 32) || |
| 588 | (!(acpi_gbl_FACS->xfirmware_waking_vector))) { |
| 589 | /* ACPI 1.0 FACS or short table or optional X_ field is zero */ |
| 590 | |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame^] | 591 | acpi_gbl_common_fACS.firmware_waking_vector = ACPI_CAST_PTR (u64, |
| 592 | &(acpi_gbl_FACS->firmware_waking_vector)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | acpi_gbl_common_fACS.vector_width = 32; |
| 594 | } |
| 595 | else { |
| 596 | /* ACPI 2.0 FACS with valid X_ field */ |
| 597 | |
| 598 | acpi_gbl_common_fACS.firmware_waking_vector = &acpi_gbl_FACS->xfirmware_waking_vector; |
| 599 | acpi_gbl_common_fACS.vector_width = 64; |
| 600 | } |
| 601 | |
| 602 | return_ACPI_STATUS (AE_OK); |
| 603 | } |
| 604 | |
| 605 | |