diff options
| author | Len Brown <len.brown@intel.com> | 2009-01-09 00:13:17 -0500 |
|---|---|---|
| committer | Len Brown <len.brown@intel.com> | 2009-01-09 03:30:47 -0500 |
| commit | 95b482a8d31116f3f5c2a5089569393234d06385 (patch) | |
| tree | f32aec8673a285a9d188948be97af3034ee06e93 /drivers/acpi/tables | |
| parent | 6620e0c49f577454b772fb381543d60ae53eb885 (diff) | |
ACPICA: create acpica/ directory
also, delete sleep/ and delete ACPI_CFLAGS from Makefile
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/tables')
| -rw-r--r-- | drivers/acpi/tables/Makefile | 7 | ||||
| -rw-r--r-- | drivers/acpi/tables/tbfadt.c | 610 | ||||
| -rw-r--r-- | drivers/acpi/tables/tbfind.c | 140 | ||||
| -rw-r--r-- | drivers/acpi/tables/tbinstal.c | 574 | ||||
| -rw-r--r-- | drivers/acpi/tables/tbutils.c | 582 | ||||
| -rw-r--r-- | drivers/acpi/tables/tbxface.c | 735 | ||||
| -rw-r--r-- | drivers/acpi/tables/tbxfroot.c | 274 |
7 files changed, 0 insertions, 2922 deletions
diff --git a/drivers/acpi/tables/Makefile b/drivers/acpi/tables/Makefile deleted file mode 100644 index 7385efa61622..000000000000 --- a/drivers/acpi/tables/Makefile +++ /dev/null | |||
| @@ -1,7 +0,0 @@ | |||
| 1 | # | ||
| 2 | # Makefile for all Linux ACPI interpreter subdirectories | ||
| 3 | # | ||
| 4 | |||
| 5 | obj-y := tbxface.o tbinstal.o tbutils.o tbfind.o tbfadt.o tbxfroot.o | ||
| 6 | |||
| 7 | EXTRA_CFLAGS += $(ACPI_CFLAGS) | ||
diff --git a/drivers/acpi/tables/tbfadt.c b/drivers/acpi/tables/tbfadt.c deleted file mode 100644 index 87f22e68c6d6..000000000000 --- a/drivers/acpi/tables/tbfadt.c +++ /dev/null | |||
| @@ -1,610 +0,0 @@ | |||
| 1 | /****************************************************************************** | ||
| 2 | * | ||
| 3 | * Module Name: tbfadt - FADT table utilities | ||
| 4 | * | ||
| 5 | *****************************************************************************/ | ||
| 6 | |||
| 7 | /* | ||
| 8 | * Copyright (C) 2000 - 2008, Intel Corp. | ||
| 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 <acpi/acpi.h> | ||
| 45 | #include <acpi/accommon.h> | ||
| 46 | #include <acpi/actables.h> | ||
| 47 | |||
| 48 | #define _COMPONENT ACPI_TABLES | ||
| 49 | ACPI_MODULE_NAME("tbfadt") | ||
| 50 | |||
| 51 | /* Local prototypes */ | ||
| 52 | static inline void | ||
| 53 | acpi_tb_init_generic_address(struct acpi_generic_address *generic_address, | ||
| 54 | u8 space_id, u8 byte_width, u64 address); | ||
| 55 | |||
| 56 | static void acpi_tb_convert_fadt(void); | ||
| 57 | |||
| 58 | static void acpi_tb_validate_fadt(void); | ||
| 59 | |||
| 60 | /* Table for conversion of FADT to common internal format and FADT validation */ | ||
| 61 | |||
| 62 | typedef struct acpi_fadt_info { | ||
| 63 | char *name; | ||
| 64 | u8 address64; | ||
| 65 | u8 address32; | ||
| 66 | u8 length; | ||
| 67 | u8 default_length; | ||
| 68 | u8 type; | ||
| 69 | |||
| 70 | } acpi_fadt_info; | ||
| 71 | |||
| 72 | #define ACPI_FADT_REQUIRED 1 | ||
| 73 | #define ACPI_FADT_SEPARATE_LENGTH 2 | ||
| 74 | |||
| 75 | static struct acpi_fadt_info fadt_info_table[] = { | ||
| 76 | {"Pm1aEventBlock", | ||
| 77 | ACPI_FADT_OFFSET(xpm1a_event_block), | ||
| 78 | ACPI_FADT_OFFSET(pm1a_event_block), | ||
| 79 | ACPI_FADT_OFFSET(pm1_event_length), | ||
| 80 | ACPI_PM1_REGISTER_WIDTH * 2, /* Enable + Status register */ | ||
| 81 | ACPI_FADT_REQUIRED}, | ||
| 82 | |||
| 83 | {"Pm1bEventBlock", | ||
| 84 | ACPI_FADT_OFFSET(xpm1b_event_block), | ||
| 85 | ACPI_FADT_OFFSET(pm1b_event_block), | ||
| 86 | ACPI_FADT_OFFSET(pm1_event_length), | ||
| 87 | ACPI_PM1_REGISTER_WIDTH * 2, /* Enable + Status register */ | ||
| 88 | 0}, | ||
| 89 | |||
| 90 | {"Pm1aControlBlock", | ||
| 91 | ACPI_FADT_OFFSET(xpm1a_control_block), | ||
| 92 | ACPI_FADT_OFFSET(pm1a_control_block), | ||
| 93 | ACPI_FADT_OFFSET(pm1_control_length), | ||
| 94 | ACPI_PM1_REGISTER_WIDTH, | ||
| 95 | ACPI_FADT_REQUIRED}, | ||
| 96 | |||
| 97 | {"Pm1bControlBlock", | ||
| 98 | ACPI_FADT_OFFSET(xpm1b_control_block), | ||
| 99 | ACPI_FADT_OFFSET(pm1b_control_block), | ||
| 100 | ACPI_FADT_OFFSET(pm1_control_length), | ||
| 101 | ACPI_PM1_REGISTER_WIDTH, | ||
| 102 | 0}, | ||
| 103 | |||
| 104 | {"Pm2ControlBlock", | ||
| 105 | ACPI_FADT_OFFSET(xpm2_control_block), | ||
| 106 | ACPI_FADT_OFFSET(pm2_control_block), | ||
| 107 | ACPI_FADT_OFFSET(pm2_control_length), | ||
| 108 | ACPI_PM2_REGISTER_WIDTH, | ||
| 109 | ACPI_FADT_SEPARATE_LENGTH}, | ||
| 110 | |||
| 111 | {"PmTimerBlock", | ||
| 112 | ACPI_FADT_OFFSET(xpm_timer_block), | ||
| 113 | ACPI_FADT_OFFSET(pm_timer_block), | ||
| 114 | ACPI_FADT_OFFSET(pm_timer_length), | ||
| 115 | ACPI_PM_TIMER_WIDTH, | ||
| 116 | ACPI_FADT_REQUIRED}, | ||
| 117 | |||
| 118 | {"Gpe0Block", | ||
| 119 | ACPI_FADT_OFFSET(xgpe0_block), | ||
| 120 | ACPI_FADT_OFFSET(gpe0_block), | ||
| 121 | ACPI_FADT_OFFSET(gpe0_block_length), | ||
| 122 | 0, | ||
| 123 | ACPI_FADT_SEPARATE_LENGTH}, | ||
| 124 | |||
| 125 | {"Gpe1Block", | ||
| 126 | ACPI_FADT_OFFSET(xgpe1_block), | ||
| 127 | ACPI_FADT_OFFSET(gpe1_block), | ||
| 128 | ACPI_FADT_OFFSET(gpe1_block_length), | ||
| 129 | 0, | ||
| 130 | ACPI_FADT_SEPARATE_LENGTH} | ||
| 131 | }; | ||
| 132 | |||
| 133 | #define ACPI_FADT_INFO_ENTRIES (sizeof (fadt_info_table) / sizeof (struct acpi_fadt_info)) | ||
| 134 | |||
| 135 | /******************************************************************************* | ||
| 136 | * | ||
| 137 | * FUNCTION: acpi_tb_init_generic_address | ||
| 138 | * | ||
| 139 | * PARAMETERS: generic_address - GAS struct to be initialized | ||
| 140 | * byte_width - Width of this register | ||
| 141 | * Address - Address of the register | ||
| 142 | * | ||
| 143 | * RETURN: None | ||
| 144 | * | ||
| 145 | * DESCRIPTION: Initialize a Generic Address Structure (GAS) | ||
| 146 | * See the ACPI specification for a full description and | ||
| 147 | * definition of this structure. | ||
| 148 | * | ||
| 149 | ******************************************************************************/ | ||
| 150 | |||
| 151 | static inline void | ||
| 152 | acpi_tb_init_generic_address(struct acpi_generic_address *generic_address, | ||
| 153 | u8 space_id, u8 byte_width, u64 address) | ||
| 154 | { | ||
| 155 | |||
| 156 | /* | ||
| 157 | * The 64-bit Address field is non-aligned in the byte packed | ||
| 158 | * GAS struct. | ||
| 159 | */ | ||
| 160 | ACPI_MOVE_64_TO_64(&generic_address->address, &address); | ||
| 161 | |||
| 162 | /* All other fields are byte-wide */ | ||
| 163 | |||
| 164 | generic_address->space_id = space_id; | ||
| 165 | generic_address->bit_width = (u8)ACPI_MUL_8(byte_width); | ||
| 166 | generic_address->bit_offset = 0; | ||
| 167 | generic_address->access_width = 0; /* Access width ANY */ | ||
| 168 | } | ||
| 169 | |||
| 170 | /******************************************************************************* | ||
| 171 | * | ||
| 172 | * FUNCTION: acpi_tb_parse_fadt | ||
| 173 | * | ||
| 174 | * PARAMETERS: table_index - Index for the FADT | ||
| 175 | * Flags - Flags | ||
| 176 | * | ||
| 177 | * RETURN: None | ||
| 178 | * | ||
| 179 | * DESCRIPTION: Initialize the FADT, DSDT and FACS tables | ||
| 180 | * (FADT contains the addresses of the DSDT and FACS) | ||
| 181 | * | ||
| 182 | ******************************************************************************/ | ||
| 183 | |||
| 184 | void acpi_tb_parse_fadt(u32 table_index, u8 flags) | ||
| 185 | { | ||
| 186 | u32 length; | ||
| 187 | struct acpi_table_header *table; | ||
| 188 | |||
| 189 | /* | ||
| 190 | * The FADT has multiple versions with different lengths, | ||
| 191 | * and it contains pointers to both the DSDT and FACS tables. | ||
| 192 | * | ||
| 193 | * Get a local copy of the FADT and convert it to a common format | ||
| 194 | * Map entire FADT, assumed to be smaller than one page. | ||
| 195 | */ | ||
| 196 | length = acpi_gbl_root_table_list.tables[table_index].length; | ||
| 197 | |||
| 198 | table = | ||
| 199 | acpi_os_map_memory(acpi_gbl_root_table_list.tables[table_index]. | ||
| 200 | address, length); | ||
| 201 | if (!table) { | ||
| 202 | return; | ||
| 203 | } | ||
| 204 | |||
| 205 | /* | ||
| 206 | * Validate the FADT checksum before we copy the table. Ignore | ||
| 207 | * checksum error as we want to try to get the DSDT and FACS. | ||
| 208 | */ | ||
| 209 | (void)acpi_tb_verify_checksum(table, length); | ||
| 210 | |||
| 211 | /* Obtain a local copy of the FADT in common ACPI 2.0+ format */ | ||
| 212 | |||
| 213 | acpi_tb_create_local_fadt(table, length); | ||
| 214 | |||
| 215 | /* All done with the real FADT, unmap it */ | ||
| 216 | |||
| 217 | acpi_os_unmap_memory(table, length); | ||
| 218 | |||
| 219 | /* Obtain the DSDT and FACS tables via their addresses within the FADT */ | ||
| 220 | |||
| 221 | acpi_tb_install_table((acpi_physical_address) acpi_gbl_FADT.Xdsdt, | ||
| 222 | flags, ACPI_SIG_DSDT, ACPI_TABLE_INDEX_DSDT); | ||
| 223 | |||
| 224 | acpi_tb_install_table((acpi_physical_address) acpi_gbl_FADT.Xfacs, | ||
| 225 | flags, ACPI_SIG_FACS, ACPI_TABLE_INDEX_FACS); | ||
| 226 | } | ||
| 227 | |||
| 228 | /******************************************************************************* | ||
| 229 | * | ||
| 230 | * FUNCTION: acpi_tb_create_local_fadt | ||
| 231 | * | ||
| 232 | * PARAMETERS: Table - Pointer to BIOS FADT | ||
| 233 | * Length - Length of the table | ||
| 234 | * | ||
| 235 | * RETURN: None | ||
| 236 | * | ||
| 237 | * DESCRIPTION: Get a local copy of the FADT and convert it to a common format. | ||
| 238 | * Performs validation on some important FADT fields. | ||
| 239 | * | ||
| 240 | * NOTE: We create a local copy of the FADT regardless of the version. | ||
| 241 | * | ||
| 242 | ******************************************************************************/ | ||
| 243 | |||
| 244 | void acpi_tb_create_local_fadt(struct acpi_table_header *table, u32 length) | ||
| 245 | { | ||
| 246 | |||
| 247 | /* | ||
| 248 | * Check if the FADT is larger than the largest table that we expect | ||
| 249 | * (the ACPI 2.0/3.0 version). If so, truncate the table, and issue | ||
| 250 | * a warning. | ||
| 251 | */ | ||
| 252 | if (length > sizeof(struct acpi_table_fadt)) { | ||
| 253 | ACPI_WARNING((AE_INFO, | ||
| 254 | "FADT (revision %u) is longer than ACPI 2.0 version, " | ||
| 255 | "truncating length 0x%X to 0x%zX", | ||
| 256 | table->revision, (unsigned)length, | ||
| 257 | sizeof(struct acpi_table_fadt))); | ||
| 258 | } | ||
| 259 | |||
| 260 | /* Clear the entire local FADT */ | ||
| 261 | |||
| 262 | ACPI_MEMSET(&acpi_gbl_FADT, 0, sizeof(struct acpi_table_fadt)); | ||
| 263 | |||
| 264 | /* Copy the original FADT, up to sizeof (struct acpi_table_fadt) */ | ||
| 265 | |||
| 266 | ACPI_MEMCPY(&acpi_gbl_FADT, table, | ||
| 267 | ACPI_MIN(length, sizeof(struct acpi_table_fadt))); | ||
| 268 | |||
| 269 | /* | ||
| 270 | * 1) Convert the local copy of the FADT to the common internal format | ||
| 271 | * 2) Validate some of the important values within the FADT | ||
| 272 | */ | ||
| 273 | acpi_tb_convert_fadt(); | ||
| 274 | } | ||
| 275 | |||
| 276 | /******************************************************************************* | ||
| 277 | * | ||
| 278 | * FUNCTION: acpi_tb_convert_fadt | ||
| 279 | * | ||
| 280 | * PARAMETERS: None, uses acpi_gbl_FADT | ||
| 281 | * | ||
| 282 | * RETURN: None | ||
| 283 | * | ||
| 284 | * DESCRIPTION: Converts all versions of the FADT to a common internal format. | ||
| 285 | * Expand all 32-bit addresses to 64-bit. | ||
| 286 | * | ||
| 287 | * NOTE: acpi_gbl_FADT must be of size (struct acpi_table_fadt), | ||
| 288 | * and must contain a copy of the actual FADT. | ||
| 289 | * | ||
| 290 | * ACPICA will use the "X" fields of the FADT for all addresses. | ||
| 291 | * | ||
| 292 | * "X" fields are optional extensions to the original V1.0 fields. Even if | ||
| 293 | * they are present in the structure, they can be optionally not used by | ||
| 294 | * setting them to zero. Therefore, we must selectively expand V1.0 fields | ||
| 295 | * if the corresponding X field is zero. | ||
| 296 | * | ||
| 297 | * For ACPI 1.0 FADTs, all address fields are expanded to the corresponding | ||
| 298 | * "X" fields. | ||
| 299 | * | ||
| 300 | * For ACPI 2.0 FADTs, any "X" fields that are NULL are filled in by | ||
| 301 | * expanding the corresponding ACPI 1.0 field. | ||
| 302 | * | ||
| 303 | ******************************************************************************/ | ||
| 304 | |||
| 305 | static void acpi_tb_convert_fadt(void) | ||
| 306 | { | ||
| 307 | u8 pm1_register_bit_width; | ||
| 308 | u8 pm1_register_byte_width; | ||
| 309 | struct acpi_generic_address *target64; | ||
| 310 | u32 i; | ||
| 311 | |||
| 312 | /* Update the local FADT table header length */ | ||
| 313 | |||
| 314 | acpi_gbl_FADT.header.length = sizeof(struct acpi_table_fadt); | ||
| 315 | |||
| 316 | /* | ||
| 317 | * Expand the 32-bit FACS and DSDT addresses to 64-bit as necessary. | ||
| 318 | * Later code will always use the X 64-bit field. Also, check for an | ||
| 319 | * address mismatch between the 32-bit and 64-bit address fields | ||
| 320 | * (FIRMWARE_CTRL/X_FIRMWARE_CTRL, DSDT/X_DSDT) which would indicate | ||
| 321 | * the presence of two FACS or two DSDT tables. | ||
| 322 | */ | ||
| 323 | if (!acpi_gbl_FADT.Xfacs) { | ||
| 324 | acpi_gbl_FADT.Xfacs = (u64) acpi_gbl_FADT.facs; | ||
| 325 | } else if (acpi_gbl_FADT.facs && | ||
| 326 | (acpi_gbl_FADT.Xfacs != (u64) acpi_gbl_FADT.facs)) { | ||
| 327 | ACPI_WARNING((AE_INFO, | ||
| 328 | "32/64 FACS address mismatch in FADT - two FACS tables!")); | ||
| 329 | } | ||
| 330 | |||
| 331 | if (!acpi_gbl_FADT.Xdsdt) { | ||
| 332 | acpi_gbl_FADT.Xdsdt = (u64) acpi_gbl_FADT.dsdt; | ||
| 333 | } else if (acpi_gbl_FADT.dsdt && | ||
| 334 | (acpi_gbl_FADT.Xdsdt != (u64) acpi_gbl_FADT.dsdt)) { | ||
| 335 | ACPI_WARNING((AE_INFO, | ||
| 336 | "32/64 DSDT address mismatch in FADT - two DSDT tables!")); | ||
| 337 | } | ||
| 338 | |||
| 339 | /* | ||
| 340 | * For ACPI 1.0 FADTs (revision 1 or 2), ensure that reserved fields which | ||
| 341 | * should be zero are indeed zero. This will workaround BIOSs that | ||
| 342 | * inadvertently place values in these fields. | ||
| 343 | * | ||
| 344 | * The ACPI 1.0 reserved fields that will be zeroed are the bytes located at | ||
| 345 | * offset 45, 55, 95, and the word located at offset 109, 110. | ||
| 346 | */ | ||
| 347 | if (acpi_gbl_FADT.header.revision < FADT2_REVISION_ID) { | ||
| 348 | acpi_gbl_FADT.preferred_profile = 0; | ||
| 349 | acpi_gbl_FADT.pstate_control = 0; | ||
| 350 | acpi_gbl_FADT.cst_control = 0; | ||
| 351 | acpi_gbl_FADT.boot_flags = 0; | ||
| 352 | } | ||
| 353 | |||
| 354 | /* | ||
| 355 | * Expand the ACPI 1.0 32-bit addresses to the ACPI 2.0 64-bit "X" | ||
| 356 | * generic address structures as necessary. Later code will always use | ||
| 357 | * the 64-bit address structures. | ||
| 358 | */ | ||
| 359 | for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) { | ||
| 360 | target64 = | ||
| 361 | ACPI_ADD_PTR(struct acpi_generic_address, &acpi_gbl_FADT, | ||
| 362 | fadt_info_table[i].address64); | ||
| 363 | |||
| 364 | /* Expand only if the 64-bit X target is null */ | ||
| 365 | |||
| 366 | if (!target64->address) { | ||
| 367 | |||
| 368 | /* The space_id is always I/O for the 32-bit legacy address fields */ | ||
| 369 | |||
| 370 | acpi_tb_init_generic_address(target64, | ||
| 371 | ACPI_ADR_SPACE_SYSTEM_IO, | ||
| 372 | *ACPI_ADD_PTR(u8, | ||
| 373 | &acpi_gbl_FADT, | ||
| 374 | fadt_info_table | ||
| 375 | [i].length), | ||
| 376 | (u64) * ACPI_ADD_PTR(u32, | ||
| 377 | &acpi_gbl_FADT, | ||
| 378 | fadt_info_table | ||
| 379 | [i]. | ||
| 380 | address32)); | ||
| 381 | } | ||
| 382 | } | ||
| 383 | |||
| 384 | /* Validate FADT values now, before we make any changes */ | ||
| 385 | |||
| 386 | acpi_tb_validate_fadt(); | ||
| 387 | |||
| 388 | /* | ||
| 389 | * Optionally check all register lengths against the default values and | ||
| 390 | * update them if they are incorrect. | ||
| 391 | */ | ||
| 392 | if (acpi_gbl_use_default_register_widths) { | ||
| 393 | for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) { | ||
| 394 | target64 = | ||
| 395 | ACPI_ADD_PTR(struct acpi_generic_address, | ||
| 396 | &acpi_gbl_FADT, | ||
| 397 | fadt_info_table[i].address64); | ||
| 398 | |||
| 399 | /* | ||
| 400 | * If a valid register (Address != 0) and the (default_length > 0) | ||
| 401 | * (Not a GPE register), then check the width against the default. | ||
| 402 | */ | ||
| 403 | if ((target64->address) && | ||
| 404 | (fadt_info_table[i].default_length > 0) && | ||
| 405 | (fadt_info_table[i].default_length != | ||
| 406 | target64->bit_width)) { | ||
| 407 | ACPI_WARNING((AE_INFO, | ||
| 408 | "Invalid length for %s: %d, using default %d", | ||
| 409 | fadt_info_table[i].name, | ||
| 410 | target64->bit_width, | ||
| 411 | fadt_info_table[i]. | ||
| 412 | default_length)); | ||
| 413 | |||
| 414 | /* Incorrect size, set width to the default */ | ||
| 415 | |||
| 416 | target64->bit_width = | ||
| 417 | fadt_info_table[i].default_length; | ||
| 418 | } | ||
| 419 | } | ||
| 420 | } | ||
| 421 | |||
| 422 | /* | ||
| 423 | * Get the length of the individual PM1 registers (enable and status). | ||
| 424 | * Each register is defined to be (event block length / 2). | ||
| 425 | */ | ||
| 426 | pm1_register_bit_width = | ||
| 427 | (u8)ACPI_DIV_2(acpi_gbl_FADT.xpm1a_event_block.bit_width); | ||
| 428 | pm1_register_byte_width = (u8)ACPI_DIV_8(pm1_register_bit_width); | ||
| 429 | |||
| 430 | /* | ||
| 431 | * Adjust the lengths of the PM1 Event Blocks so that they can be used to | ||
| 432 | * access the PM1 status register(s). Use (width / 2) | ||
| 433 | */ | ||
| 434 | acpi_gbl_FADT.xpm1a_event_block.bit_width = pm1_register_bit_width; | ||
| 435 | acpi_gbl_FADT.xpm1b_event_block.bit_width = pm1_register_bit_width; | ||
| 436 | |||
| 437 | /* | ||
| 438 | * Calculate separate GAS structs for the PM1 Enable registers. | ||
| 439 | * These addresses do not appear (directly) in the FADT, so it is | ||
| 440 | * useful to calculate them once, here. | ||
| 441 | * | ||
| 442 | * The PM event blocks are split into two register blocks, first is the | ||
| 443 | * PM Status Register block, followed immediately by the PM Enable | ||
| 444 | * Register block. Each is of length (xpm1x_event_block.bit_width/2). | ||
| 445 | * | ||
| 446 | * On various systems the v2 fields (and particularly the bit widths) | ||
| 447 | * cannot be relied upon, though. Hence resort to using the v1 length | ||
| 448 | * here (and warn about the inconsistency). | ||
| 449 | */ | ||
| 450 | if (acpi_gbl_FADT.xpm1a_event_block.bit_width | ||
| 451 | != acpi_gbl_FADT.pm1_event_length * 8) | ||
| 452 | printk(KERN_WARNING "FADT: " | ||
| 453 | "X_PM1a_EVT_BLK.bit_width (%u) does not match" | ||
| 454 | " PM1_EVT_LEN (%u)\n", | ||
| 455 | acpi_gbl_FADT.xpm1a_event_block.bit_width, | ||
| 456 | acpi_gbl_FADT.pm1_event_length); | ||
| 457 | |||
| 458 | /* The PM1A register block is required */ | ||
| 459 | |||
| 460 | acpi_tb_init_generic_address(&acpi_gbl_xpm1a_enable, | ||
| 461 | acpi_gbl_FADT.xpm1a_event_block.space_id, | ||
| 462 | pm1_register_byte_width, | ||
| 463 | (acpi_gbl_FADT.xpm1a_event_block.address + | ||
| 464 | pm1_register_byte_width)); | ||
| 465 | /* Don't forget to copy space_id of the GAS */ | ||
| 466 | acpi_gbl_xpm1a_enable.space_id = | ||
| 467 | acpi_gbl_FADT.xpm1a_event_block.space_id; | ||
| 468 | |||
| 469 | /* The PM1B register block is optional, ignore if not present */ | ||
| 470 | |||
| 471 | if (acpi_gbl_FADT.xpm1b_event_block.address) { | ||
| 472 | if (acpi_gbl_FADT.xpm1b_event_block.bit_width | ||
| 473 | != acpi_gbl_FADT.pm1_event_length * 8) | ||
| 474 | printk(KERN_WARNING "FADT: " | ||
| 475 | "X_PM1b_EVT_BLK.bit_width (%u) does not match" | ||
| 476 | " PM1_EVT_LEN (%u)\n", | ||
| 477 | acpi_gbl_FADT.xpm1b_event_block.bit_width, | ||
| 478 | acpi_gbl_FADT.pm1_event_length); | ||
| 479 | acpi_tb_init_generic_address(&acpi_gbl_xpm1b_enable, | ||
| 480 | acpi_gbl_FADT.xpm1b_event_block.space_id, | ||
| 481 | pm1_register_byte_width, | ||
| 482 | (acpi_gbl_FADT.xpm1b_event_block. | ||
| 483 | address + pm1_register_byte_width)); | ||
| 484 | /* Don't forget to copy space_id of the GAS */ | ||
| 485 | acpi_gbl_xpm1b_enable.space_id = | ||
| 486 | acpi_gbl_FADT.xpm1b_event_block.space_id; | ||
| 487 | |||
| 488 | } | ||
| 489 | } | ||
| 490 | |||
| 491 | /****************************************************************************** | ||
| 492 | * | ||
| 493 | * FUNCTION: acpi_tb_validate_fadt | ||
| 494 | * | ||
| 495 | * PARAMETERS: Table - Pointer to the FADT to be validated | ||
| 496 | * | ||
| 497 | * RETURN: None | ||
| 498 | * | ||
| 499 | * DESCRIPTION: Validate various important fields within the FADT. If a problem | ||
| 500 | * is found, issue a message, but no status is returned. | ||
| 501 | * Used by both the table manager and the disassembler. | ||
| 502 | * | ||
| 503 | * Possible additional checks: | ||
| 504 | * (acpi_gbl_FADT.pm1_event_length >= 4) | ||
| 505 | * (acpi_gbl_FADT.pm1_control_length >= 2) | ||
| 506 | * (acpi_gbl_FADT.pm_timer_length >= 4) | ||
| 507 | * Gpe block lengths must be multiple of 2 | ||
| 508 | * | ||
| 509 | ******************************************************************************/ | ||
| 510 | |||
| 511 | static void acpi_tb_validate_fadt(void) | ||
| 512 | { | ||
| 513 | char *name; | ||
| 514 | u32 *address32; | ||
| 515 | struct acpi_generic_address *address64; | ||
| 516 | u8 length; | ||
| 517 | u32 i; | ||
| 518 | |||
| 519 | /* | ||
| 520 | * Check for FACS and DSDT address mismatches. An address mismatch between | ||
| 521 | * the 32-bit and 64-bit address fields (FIRMWARE_CTRL/X_FIRMWARE_CTRL and | ||
| 522 | * DSDT/X_DSDT) would indicate the presence of two FACS or two DSDT tables. | ||
| 523 | */ | ||
| 524 | if (acpi_gbl_FADT.facs && | ||
| 525 | (acpi_gbl_FADT.Xfacs != (u64) acpi_gbl_FADT.facs)) { | ||
| 526 | ACPI_WARNING((AE_INFO, | ||
| 527 | "32/64X FACS address mismatch in FADT - " | ||
| 528 | "two FACS tables! %8.8X/%8.8X%8.8X", | ||
| 529 | acpi_gbl_FADT.facs, | ||
| 530 | ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xfacs))); | ||
| 531 | } | ||
| 532 | |||
| 533 | if (acpi_gbl_FADT.dsdt && | ||
| 534 | (acpi_gbl_FADT.Xdsdt != (u64) acpi_gbl_FADT.dsdt)) { | ||
| 535 | ACPI_WARNING((AE_INFO, | ||
| 536 | "32/64X DSDT address mismatch in FADT - " | ||
| 537 | "two DSDT tables! %8.8X/%8.8X%8.8X", | ||
| 538 | acpi_gbl_FADT.dsdt, | ||
| 539 | ACPI_FORMAT_UINT64(acpi_gbl_FADT.Xdsdt))); | ||
| 540 | } | ||
| 541 | |||
| 542 | /* Examine all of the 64-bit extended address fields (X fields) */ | ||
| 543 | |||
| 544 | for (i = 0; i < ACPI_FADT_INFO_ENTRIES; i++) { | ||
| 545 | /* | ||
| 546 | * Generate pointers to the 32-bit and 64-bit addresses, get the | ||
| 547 | * register length (width), and the register name | ||
| 548 | */ | ||
| 549 | address64 = ACPI_ADD_PTR(struct acpi_generic_address, | ||
| 550 | &acpi_gbl_FADT, | ||
| 551 | fadt_info_table[i].address64); | ||
| 552 | address32 = | ||
| 553 | ACPI_ADD_PTR(u32, &acpi_gbl_FADT, | ||
| 554 | fadt_info_table[i].address32); | ||
| 555 | length = | ||
| 556 | *ACPI_ADD_PTR(u8, &acpi_gbl_FADT, | ||
| 557 | fadt_info_table[i].length); | ||
| 558 | name = fadt_info_table[i].name; | ||
| 559 | |||
| 560 | /* | ||
| 561 | * For each extended field, check for length mismatch between the | ||
| 562 | * legacy length field and the corresponding 64-bit X length field. | ||
| 563 | */ | ||
| 564 | if (address64 && (address64->bit_width != ACPI_MUL_8(length))) { | ||
| 565 | ACPI_WARNING((AE_INFO, | ||
| 566 | "32/64X length mismatch in %s: %d/%d", | ||
| 567 | name, ACPI_MUL_8(length), | ||
| 568 | address64->bit_width)); | ||
| 569 | } | ||
| 570 | |||
| 571 | if (fadt_info_table[i].type & ACPI_FADT_REQUIRED) { | ||
| 572 | /* | ||
| 573 | * Field is required (Pm1a_event, Pm1a_control, pm_timer). | ||
| 574 | * Both the address and length must be non-zero. | ||
| 575 | */ | ||
| 576 | if (!address64->address || !length) { | ||
| 577 | ACPI_ERROR((AE_INFO, | ||
| 578 | "Required field %s has zero address and/or length: %8.8X%8.8X/%X", | ||
| 579 | name, | ||
| 580 | ACPI_FORMAT_UINT64(address64-> | ||
| 581 | address), | ||
| 582 | length)); | ||
| 583 | } | ||
| 584 | } else if (fadt_info_table[i].type & ACPI_FADT_SEPARATE_LENGTH) { | ||
| 585 | /* | ||
| 586 | * Field is optional (PM2Control, GPE0, GPE1) AND has its own | ||
| 587 | * length field. If present, both the address and length must be valid. | ||
| 588 | */ | ||
| 589 | if ((address64->address && !length) | ||
| 590 | || (!address64->address && length)) { | ||
| 591 | ACPI_WARNING((AE_INFO, | ||
| 592 | "Optional field %s has zero address or length: %8.8X%8.8X/%X", | ||
| 593 | name, | ||
| 594 | ACPI_FORMAT_UINT64(address64-> | ||
| 595 | address), | ||
| 596 | length)); | ||
| 597 | } | ||
| 598 | } | ||
| 599 | |||
| 600 | /* If both 32- and 64-bit addresses are valid (non-zero), they must match */ | ||
| 601 | |||
| 602 | if (address64->address && *address32 && | ||
| 603 | (address64->address != (u64) * address32)) { | ||
| 604 | ACPI_ERROR((AE_INFO, | ||
| 605 | "32/64X address mismatch in %s: %8.8X/%8.8X%8.8X, using 64X", | ||
| 606 | name, *address32, | ||
| 607 | ACPI_FORMAT_UINT64(address64->address))); | ||
| 608 | } | ||
| 609 | } | ||
| 610 | } | ||
diff --git a/drivers/acpi/tables/tbfind.c b/drivers/acpi/tables/tbfind.c deleted file mode 100644 index 9d20cb6db892..000000000000 --- a/drivers/acpi/tables/tbfind.c +++ /dev/null | |||
| @@ -1,140 +0,0 @@ | |||
| 1 | /****************************************************************************** | ||
| 2 | * | ||
| 3 | * Module Name: tbfind - find table | ||
| 4 | * | ||
| 5 | *****************************************************************************/ | ||
| 6 | |||
| 7 | /* | ||
| 8 | * Copyright (C) 2000 - 2008, Intel Corp. | ||
| 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 <acpi/acpi.h> | ||
| 45 | #include <acpi/accommon.h> | ||
| 46 | #include <acpi/actables.h> | ||
| 47 | |||
| 48 | #define _COMPONENT ACPI_TABLES | ||
| 49 | ACPI_MODULE_NAME("tbfind") | ||
| 50 | |||
| 51 | /******************************************************************************* | ||
| 52 | * | ||
| 53 | * FUNCTION: acpi_tb_find_table | ||
| 54 | * | ||
| 55 | * PARAMETERS: Signature - String with ACPI table signature | ||
| 56 | * oem_id - String with the table OEM ID | ||
| 57 | * oem_table_id - String with the OEM Table ID | ||
| 58 | * table_index - Where the table index is returned | ||
| 59 | * | ||
| 60 | * RETURN: Status and table index | ||
| 61 | * | ||
| 62 | * DESCRIPTION: Find an ACPI table (in the RSDT/XSDT) that matches the | ||
| 63 | * Signature, OEM ID and OEM Table ID. Returns an index that can | ||
| 64 | * be used to get the table header or entire table. | ||
| 65 | * | ||
| 66 | ******************************************************************************/ | ||
| 67 | acpi_status | ||
| 68 | acpi_tb_find_table(char *signature, | ||
| 69 | char *oem_id, char *oem_table_id, u32 *table_index) | ||
| 70 | { | ||
| 71 | u32 i; | ||
| 72 | acpi_status status; | ||
| 73 | struct acpi_table_header header; | ||
| 74 | |||
| 75 | ACPI_FUNCTION_TRACE(tb_find_table); | ||
| 76 | |||
| 77 | /* Normalize the input strings */ | ||
| 78 | |||
| 79 | ACPI_MEMSET(&header, 0, sizeof(struct acpi_table_header)); | ||
| 80 | ACPI_STRNCPY(header.signature, signature, ACPI_NAME_SIZE); | ||
| 81 | ACPI_STRNCPY(header.oem_id, oem_id, ACPI_OEM_ID_SIZE); | ||
| 82 | ACPI_STRNCPY(header.oem_table_id, oem_table_id, ACPI_OEM_TABLE_ID_SIZE); | ||
| 83 | |||
| 84 | /* Search for the table */ | ||
| 85 | |||
| 86 | for (i = 0; i < acpi_gbl_root_table_list.count; ++i) { | ||
| 87 | if (ACPI_MEMCMP(&(acpi_gbl_root_table_list.tables[i].signature), | ||
| 88 | header.signature, ACPI_NAME_SIZE)) { | ||
| 89 | |||
| 90 | /* Not the requested table */ | ||
| 91 | |||
| 92 | continue; | ||
| 93 | } | ||
| 94 | |||
| 95 | /* Table with matching signature has been found */ | ||
| 96 | |||
| 97 | if (!acpi_gbl_root_table_list.tables[i].pointer) { | ||
| 98 | |||
| 99 | /* Table is not currently mapped, map it */ | ||
| 100 | |||
| 101 | status = | ||
| 102 | acpi_tb_verify_table(&acpi_gbl_root_table_list. | ||
| 103 | tables[i]); | ||
| 104 | if (ACPI_FAILURE(status)) { | ||
| 105 | return_ACPI_STATUS(status); | ||
| 106 | } | ||
| 107 | |||
| 108 | if (!acpi_gbl_root_table_list.tables[i].pointer) { | ||
| 109 | continue; | ||
| 110 | } | ||
| 111 | } | ||
| 112 | |||
| 113 | /* Check for table match on all IDs */ | ||
| 114 | |||
| 115 | if (!ACPI_MEMCMP | ||
| 116 | (acpi_gbl_root_table_list.tables[i].pointer->signature, | ||
| 117 | header.signature, ACPI_NAME_SIZE) && (!oem_id[0] | ||
| 118 | || | ||
| 119 | !ACPI_MEMCMP | ||
| 120 | (acpi_gbl_root_table_list. | ||
| 121 | tables[i].pointer-> | ||
| 122 | oem_id, | ||
| 123 | header.oem_id, | ||
| 124 | ACPI_OEM_ID_SIZE)) | ||
| 125 | && (!oem_table_id[0] | ||
| 126 | || !ACPI_MEMCMP(acpi_gbl_root_table_list.tables[i]. | ||
| 127 | pointer->oem_table_id, | ||
| 128 | header.oem_table_id, | ||
| 129 | ACPI_OEM_TABLE_ID_SIZE))) { | ||
| 130 | *table_index = i; | ||
| 131 | |||
| 132 | ACPI_DEBUG_PRINT((ACPI_DB_TABLES, | ||
| 133 | "Found table [%4.4s]\n", | ||
| 134 | header.signature)); | ||
| 135 | return_ACPI_STATUS(AE_OK); | ||
| 136 | } | ||
| 137 | } | ||
| 138 | |||
| 139 | return_ACPI_STATUS(AE_NOT_FOUND); | ||
| 140 | } | ||
diff --git a/drivers/acpi/tables/tbinstal.c b/drivers/acpi/tables/tbinstal.c deleted file mode 100644 index 019b0d84cbea..000000000000 --- a/drivers/acpi/tables/tbinstal.c +++ /dev/null | |||
| @@ -1,574 +0,0 @@ | |||
| 1 | /****************************************************************************** | ||
| 2 | * | ||
| 3 | * Module Name: tbinstal - ACPI table installation and removal | ||
| 4 | * | ||
| 5 | *****************************************************************************/ | ||
| 6 | |||
| 7 | /* | ||
| 8 | * Copyright (C) 2000 - 2008, Intel Corp. | ||
| 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 <acpi/acpi.h> | ||
| 45 | #include <acpi/accommon.h> | ||
| 46 | #include <acpi/acnamesp.h> | ||
| 47 | #include <acpi/actables.h> | ||
| 48 | |||
| 49 | #define _COMPONENT ACPI_TABLES | ||
| 50 | ACPI_MODULE_NAME("tbinstal") | ||
| 51 | |||
| 52 | /****************************************************************************** | ||
| 53 | * | ||
| 54 | * FUNCTION: acpi_tb_verify_table | ||
| 55 | * | ||
| 56 | * PARAMETERS: table_desc - table | ||
| 57 | * | ||
| 58 | * RETURN: Status | ||
| 59 | * | ||
| 60 | * DESCRIPTION: this function is called to verify and map table | ||
| 61 | * | ||
| 62 | *****************************************************************************/ | ||
| 63 | acpi_status acpi_tb_verify_table(struct acpi_table_desc *table_desc) | ||
| 64 | { | ||
| 65 | acpi_status status = AE_OK; | ||
| 66 | |||
| 67 | ACPI_FUNCTION_TRACE(tb_verify_table); | ||
| 68 | |||
| 69 | /* Map the table if necessary */ | ||
| 70 | |||
| 71 | if (!table_desc->pointer) { | ||
| 72 | if ((table_desc->flags & ACPI_TABLE_ORIGIN_MASK) == | ||
| 73 | ACPI_TABLE_ORIGIN_MAPPED) { | ||
| 74 | table_desc->pointer = | ||
| 75 | acpi_os_map_memory(table_desc->address, | ||
| 76 | table_desc->length); | ||
| 77 | } | ||
| 78 | if (!table_desc->pointer) { | ||
| 79 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
| 80 | } | ||
| 81 | } | ||
| 82 | |||
| 83 | /* FACS is the odd table, has no standard ACPI header and no checksum */ | ||
| 84 | |||
| 85 | if (!ACPI_COMPARE_NAME(&table_desc->signature, ACPI_SIG_FACS)) { | ||
| 86 | |||
| 87 | /* Always calculate checksum, ignore bad checksum if requested */ | ||
| 88 | |||
| 89 | status = | ||
| 90 | acpi_tb_verify_checksum(table_desc->pointer, | ||
| 91 | table_desc->length); | ||
| 92 | } | ||
| 93 | |||
| 94 | return_ACPI_STATUS(status); | ||
| 95 | } | ||
| 96 | |||
| 97 | /******************************************************************************* | ||
| 98 | * | ||
| 99 | * FUNCTION: acpi_tb_add_table | ||
| 100 | * | ||
| 101 | * PARAMETERS: table_desc - Table descriptor | ||
| 102 | * table_index - Where the table index is returned | ||
| 103 | * | ||
| 104 | * RETURN: Status | ||
| 105 | * | ||
| 106 | * DESCRIPTION: This function is called to add the ACPI table | ||
| 107 | * | ||
| 108 | ******************************************************************************/ | ||
| 109 | |||
| 110 | acpi_status | ||
| 111 | acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index) | ||
| 112 | { | ||
| 113 | u32 i; | ||
| 114 | acpi_status status = AE_OK; | ||
| 115 | |||
| 116 | ACPI_FUNCTION_TRACE(tb_add_table); | ||
| 117 | |||
| 118 | if (!table_desc->pointer) { | ||
| 119 | status = acpi_tb_verify_table(table_desc); | ||
| 120 | if (ACPI_FAILURE(status) || !table_desc->pointer) { | ||
| 121 | return_ACPI_STATUS(status); | ||
| 122 | } | ||
| 123 | } | ||
| 124 | |||
| 125 | /* | ||
| 126 | * Originally, we checked the table signature for "SSDT" or "PSDT" here. | ||
| 127 | * Next, we added support for OEMx tables, signature "OEM". | ||
| 128 | * Valid tables were encountered with a null signature, so we've just | ||
| 129 | * given up on validating the signature, since it seems to be a waste | ||
| 130 | * of code. The original code was removed (05/2008). | ||
| 131 | */ | ||
| 132 | |||
| 133 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); | ||
| 134 | |||
| 135 | /* Check if table is already registered */ | ||
| 136 | |||
| 137 | for (i = 0; i < acpi_gbl_root_table_list.count; ++i) { | ||
| 138 | if (!acpi_gbl_root_table_list.tables[i].pointer) { | ||
| 139 | status = | ||
| 140 | acpi_tb_verify_table(&acpi_gbl_root_table_list. | ||
| 141 | tables[i]); | ||
| 142 | if (ACPI_FAILURE(status) | ||
| 143 | || !acpi_gbl_root_table_list.tables[i].pointer) { | ||
| 144 | continue; | ||
| 145 | } | ||
| 146 | } | ||
| 147 | |||
| 148 | /* | ||
| 149 | * Check for a table match on the entire table length, | ||
| 150 | * not just the header. | ||
| 151 | */ | ||
| 152 | if (table_desc->length != | ||
| 153 | acpi_gbl_root_table_list.tables[i].length) { | ||
| 154 | continue; | ||
| 155 | } | ||
| 156 | |||
| 157 | if (ACPI_MEMCMP(table_desc->pointer, | ||
| 158 | acpi_gbl_root_table_list.tables[i].pointer, | ||
| 159 | acpi_gbl_root_table_list.tables[i].length)) { | ||
| 160 | continue; | ||
| 161 | } | ||
| 162 | |||
| 163 | /* | ||
| 164 | * Note: the current mechanism does not unregister a table if it is | ||
| 165 | * dynamically unloaded. The related namespace entries are deleted, | ||
| 166 | * but the table remains in the root table list. | ||
| 167 | * | ||
| 168 | * The assumption here is that the number of different tables that | ||
| 169 | * will be loaded is actually small, and there is minimal overhead | ||
| 170 | * in just keeping the table in case it is needed again. | ||
| 171 | * | ||
| 172 | * If this assumption changes in the future (perhaps on large | ||
| 173 | * machines with many table load/unload operations), tables will | ||
| 174 | * need to be unregistered when they are unloaded, and slots in the | ||
| 175 | * root table list should be reused when empty. | ||
| 176 | */ | ||
| 177 | |||
| 178 | /* | ||
| 179 | * Table is already registered. | ||
| 180 | * We can delete the table that was passed as a parameter. | ||
| 181 | */ | ||
| 182 | acpi_tb_delete_table(table_desc); | ||
| 183 | *table_index = i; | ||
| 184 | |||
| 185 | if (acpi_gbl_root_table_list.tables[i]. | ||
| 186 | flags & ACPI_TABLE_IS_LOADED) { | ||
| 187 | |||
| 188 | /* Table is still loaded, this is an error */ | ||
| 189 | |||
| 190 | status = AE_ALREADY_EXISTS; | ||
| 191 | goto release; | ||
| 192 | } else { | ||
| 193 | /* Table was unloaded, allow it to be reloaded */ | ||
| 194 | |||
| 195 | table_desc->pointer = | ||
| 196 | acpi_gbl_root_table_list.tables[i].pointer; | ||
| 197 | table_desc->address = | ||
| 198 | acpi_gbl_root_table_list.tables[i].address; | ||
| 199 | status = AE_OK; | ||
| 200 | goto print_header; | ||
| 201 | } | ||
| 202 | } | ||
| 203 | |||
| 204 | /* Add the table to the global root table list */ | ||
| 205 | |||
| 206 | status = acpi_tb_store_table(table_desc->address, table_desc->pointer, | ||
| 207 | table_desc->length, table_desc->flags, | ||
| 208 | table_index); | ||
| 209 | if (ACPI_FAILURE(status)) { | ||
| 210 | goto release; | ||
| 211 | } | ||
| 212 | |||
| 213 | print_header: | ||
| 214 | acpi_tb_print_table_header(table_desc->address, table_desc->pointer); | ||
| 215 | |||
| 216 | release: | ||
| 217 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | ||
| 218 | return_ACPI_STATUS(status); | ||
| 219 | } | ||
| 220 | |||
| 221 | /******************************************************************************* | ||
| 222 | * | ||
| 223 | * FUNCTION: acpi_tb_resize_root_table_list | ||
| 224 | * | ||
| 225 | * PARAMETERS: None | ||
| 226 | * | ||
| 227 | * RETURN: Status | ||
| 228 | * | ||
| 229 | * DESCRIPTION: Expand the size of global table array | ||
| 230 | * | ||
| 231 | ******************************************************************************/ | ||
| 232 | |||
| 233 | acpi_status acpi_tb_resize_root_table_list(void) | ||
| 234 | { | ||
| 235 | struct acpi_table_desc *tables; | ||
| 236 | |||
| 237 | ACPI_FUNCTION_TRACE(tb_resize_root_table_list); | ||
| 238 | |||
| 239 | /* allow_resize flag is a parameter to acpi_initialize_tables */ | ||
| 240 | |||
| 241 | if (!(acpi_gbl_root_table_list.flags & ACPI_ROOT_ALLOW_RESIZE)) { | ||
| 242 | ACPI_ERROR((AE_INFO, | ||
| 243 | "Resize of Root Table Array is not allowed")); | ||
| 244 | return_ACPI_STATUS(AE_SUPPORT); | ||
| 245 | } | ||
| 246 | |||
| 247 | /* Increase the Table Array size */ | ||
| 248 | |||
| 249 | tables = ACPI_ALLOCATE_ZEROED(((acpi_size) acpi_gbl_root_table_list. | ||
| 250 | size + ACPI_ROOT_TABLE_SIZE_INCREMENT) | ||
| 251 | * sizeof(struct acpi_table_desc)); | ||
| 252 | if (!tables) { | ||
| 253 | ACPI_ERROR((AE_INFO, | ||
| 254 | "Could not allocate new root table array")); | ||
| 255 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
| 256 | } | ||
| 257 | |||
| 258 | /* Copy and free the previous table array */ | ||
| 259 | |||
| 260 | if (acpi_gbl_root_table_list.tables) { | ||
| 261 | ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables, | ||
| 262 | (acpi_size) acpi_gbl_root_table_list.size * | ||
| 263 | sizeof(struct acpi_table_desc)); | ||
| 264 | |||
| 265 | if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { | ||
| 266 | ACPI_FREE(acpi_gbl_root_table_list.tables); | ||
| 267 | } | ||
| 268 | } | ||
| 269 | |||
| 270 | acpi_gbl_root_table_list.tables = tables; | ||
| 271 | acpi_gbl_root_table_list.size += ACPI_ROOT_TABLE_SIZE_INCREMENT; | ||
| 272 | acpi_gbl_root_table_list.flags |= (u8) ACPI_ROOT_ORIGIN_ALLOCATED; | ||
| 273 | |||
| 274 | return_ACPI_STATUS(AE_OK); | ||
| 275 | } | ||
| 276 | |||
| 277 | /******************************************************************************* | ||
| 278 | * | ||
| 279 | * FUNCTION: acpi_tb_store_table | ||
| 280 | * | ||
| 281 | * PARAMETERS: Address - Table address | ||
| 282 | * Table - Table header | ||
| 283 | * Length - Table length | ||
| 284 | * Flags - flags | ||
| 285 | * | ||
| 286 | * RETURN: Status and table index. | ||
| 287 | * | ||
| 288 | * DESCRIPTION: Add an ACPI table to the global table list | ||
| 289 | * | ||
| 290 | ******************************************************************************/ | ||
| 291 | |||
| 292 | acpi_status | ||
| 293 | acpi_tb_store_table(acpi_physical_address address, | ||
| 294 | struct acpi_table_header *table, | ||
| 295 | u32 length, u8 flags, u32 *table_index) | ||
| 296 | { | ||
| 297 | acpi_status status = AE_OK; | ||
| 298 | |||
| 299 | /* Ensure that there is room for the table in the Root Table List */ | ||
| 300 | |||
| 301 | if (acpi_gbl_root_table_list.count >= acpi_gbl_root_table_list.size) { | ||
| 302 | status = acpi_tb_resize_root_table_list(); | ||
| 303 | if (ACPI_FAILURE(status)) { | ||
| 304 | return (status); | ||
| 305 | } | ||
| 306 | } | ||
| 307 | |||
| 308 | /* Initialize added table */ | ||
| 309 | |||
| 310 | acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count]. | ||
| 311 | address = address; | ||
| 312 | acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count]. | ||
| 313 | pointer = table; | ||
| 314 | acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].length = | ||
| 315 | length; | ||
| 316 | acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count]. | ||
| 317 | owner_id = 0; | ||
| 318 | acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].flags = | ||
| 319 | flags; | ||
| 320 | |||
| 321 | ACPI_MOVE_32_TO_32(& | ||
| 322 | (acpi_gbl_root_table_list. | ||
| 323 | tables[acpi_gbl_root_table_list.count].signature), | ||
| 324 | table->signature); | ||
| 325 | |||
| 326 | *table_index = acpi_gbl_root_table_list.count; | ||
| 327 | acpi_gbl_root_table_list.count++; | ||
| 328 | return (status); | ||
| 329 | } | ||
| 330 | |||
| 331 | /******************************************************************************* | ||
| 332 | * | ||
| 333 | * FUNCTION: acpi_tb_delete_table | ||
| 334 | * | ||
| 335 | * PARAMETERS: table_index - Table index | ||
| 336 | * | ||
| 337 | * RETURN: None | ||
| 338 | * | ||
| 339 | * DESCRIPTION: Delete one internal ACPI table | ||
| 340 | * | ||
| 341 | ******************************************************************************/ | ||
| 342 | |||
| 343 | void acpi_tb_delete_table(struct acpi_table_desc *table_desc) | ||
| 344 | { | ||
| 345 | /* Table must be mapped or allocated */ | ||
| 346 | if (!table_desc->pointer) { | ||
| 347 | return; | ||
| 348 | } | ||
| 349 | switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) { | ||
| 350 | case ACPI_TABLE_ORIGIN_MAPPED: | ||
| 351 | acpi_os_unmap_memory(table_desc->pointer, table_desc->length); | ||
| 352 | break; | ||
| 353 | case ACPI_TABLE_ORIGIN_ALLOCATED: | ||
| 354 | ACPI_FREE(table_desc->pointer); | ||
| 355 | break; | ||
| 356 | default:; | ||
| 357 | } | ||
| 358 | |||
| 359 | table_desc->pointer = NULL; | ||
| 360 | } | ||
| 361 | |||
| 362 | /******************************************************************************* | ||
| 363 | * | ||
| 364 | * FUNCTION: acpi_tb_terminate | ||
| 365 | * | ||
| 366 | * PARAMETERS: None | ||
| 367 | * | ||
| 368 | * RETURN: None | ||
| 369 | * | ||
| 370 | * DESCRIPTION: Delete all internal ACPI tables | ||
| 371 | * | ||
| 372 | ******************************************************************************/ | ||
| 373 | |||
| 374 | void acpi_tb_terminate(void) | ||
| 375 | { | ||
| 376 | u32 i; | ||
| 377 | |||
| 378 | ACPI_FUNCTION_TRACE(tb_terminate); | ||
| 379 | |||
| 380 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); | ||
| 381 | |||
| 382 | /* Delete the individual tables */ | ||
| 383 | |||
| 384 | for (i = 0; i < acpi_gbl_root_table_list.count; ++i) { | ||
| 385 | acpi_tb_delete_table(&acpi_gbl_root_table_list.tables[i]); | ||
| 386 | } | ||
| 387 | |||
| 388 | /* | ||
| 389 | * Delete the root table array if allocated locally. Array cannot be | ||
| 390 | * mapped, so we don't need to check for that flag. | ||
| 391 | */ | ||
| 392 | if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { | ||
| 393 | ACPI_FREE(acpi_gbl_root_table_list.tables); | ||
| 394 | } | ||
| 395 | |||
| 396 | acpi_gbl_root_table_list.tables = NULL; | ||
| 397 | acpi_gbl_root_table_list.flags = 0; | ||
| 398 | acpi_gbl_root_table_list.count = 0; | ||
| 399 | |||
| 400 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n")); | ||
| 401 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | ||
| 402 | } | ||
| 403 | |||
| 404 | /******************************************************************************* | ||
| 405 | * | ||
| 406 | * FUNCTION: acpi_tb_delete_namespace_by_owner | ||
| 407 | * | ||
| 408 | * PARAMETERS: table_index - Table index | ||
| 409 | * | ||
| 410 | * RETURN: None | ||
| 411 | * | ||
| 412 | * DESCRIPTION: Delete all namespace objects created when this table was loaded. | ||
| 413 | * | ||
| 414 | ******************************************************************************/ | ||
| 415 | |||
| 416 | void acpi_tb_delete_namespace_by_owner(u32 table_index) | ||
| 417 | { | ||
| 418 | acpi_owner_id owner_id; | ||
| 419 | |||
| 420 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); | ||
| 421 | if (table_index < acpi_gbl_root_table_list.count) { | ||
| 422 | owner_id = | ||
| 423 | acpi_gbl_root_table_list.tables[table_index].owner_id; | ||
| 424 | } else { | ||
| 425 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | ||
| 426 | return; | ||
| 427 | } | ||
| 428 | |||
| 429 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | ||
| 430 | acpi_ns_delete_namespace_by_owner(owner_id); | ||
| 431 | } | ||
| 432 | |||
| 433 | /******************************************************************************* | ||
| 434 | * | ||
| 435 | * FUNCTION: acpi_tb_allocate_owner_id | ||
| 436 | * | ||
| 437 | * PARAMETERS: table_index - Table index | ||
| 438 | * | ||
| 439 | * RETURN: Status | ||
| 440 | * | ||
| 441 | * DESCRIPTION: Allocates owner_id in table_desc | ||
| 442 | * | ||
| 443 | ******************************************************************************/ | ||
| 444 | |||
| 445 | acpi_status acpi_tb_allocate_owner_id(u32 table_index) | ||
| 446 | { | ||
| 447 | acpi_status status = AE_BAD_PARAMETER; | ||
| 448 | |||
| 449 | ACPI_FUNCTION_TRACE(tb_allocate_owner_id); | ||
| 450 | |||
| 451 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); | ||
| 452 | if (table_index < acpi_gbl_root_table_list.count) { | ||
| 453 | status = acpi_ut_allocate_owner_id | ||
| 454 | (&(acpi_gbl_root_table_list.tables[table_index].owner_id)); | ||
| 455 | } | ||
| 456 | |||
| 457 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | ||
| 458 | return_ACPI_STATUS(status); | ||
| 459 | } | ||
| 460 | |||
| 461 | /******************************************************************************* | ||
| 462 | * | ||
| 463 | * FUNCTION: acpi_tb_release_owner_id | ||
| 464 | * | ||
| 465 | * PARAMETERS: table_index - Table index | ||
| 466 | * | ||
| 467 | * RETURN: Status | ||
| 468 | * | ||
| 469 | * DESCRIPTION: Releases owner_id in table_desc | ||
| 470 | * | ||
| 471 | ******************************************************************************/ | ||
| 472 | |||
| 473 | acpi_status acpi_tb_release_owner_id(u32 table_index) | ||
| 474 | { | ||
| 475 | acpi_status status = AE_BAD_PARAMETER; | ||
| 476 | |||
| 477 | ACPI_FUNCTION_TRACE(tb_release_owner_id); | ||
| 478 | |||
| 479 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); | ||
| 480 | if (table_index < acpi_gbl_root_table_list.count) { | ||
| 481 | acpi_ut_release_owner_id(& | ||
| 482 | (acpi_gbl_root_table_list. | ||
| 483 | tables[table_index].owner_id)); | ||
| 484 | status = AE_OK; | ||
| 485 | } | ||
| 486 | |||
| 487 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | ||
| 488 | return_ACPI_STATUS(status); | ||
| 489 | } | ||
| 490 | |||
| 491 | /******************************************************************************* | ||
| 492 | * | ||
| 493 | * FUNCTION: acpi_tb_get_owner_id | ||
| 494 | * | ||
| 495 | * PARAMETERS: table_index - Table index | ||
| 496 | * owner_id - Where the table owner_id is returned | ||
| 497 | * | ||
| 498 | * RETURN: Status | ||
| 499 | * | ||
| 500 | * DESCRIPTION: returns owner_id for the ACPI table | ||
| 501 | * | ||
| 502 | ******************************************************************************/ | ||
| 503 | |||
| 504 | acpi_status acpi_tb_get_owner_id(u32 table_index, acpi_owner_id *owner_id) | ||
| 505 | { | ||
| 506 | acpi_status status = AE_BAD_PARAMETER; | ||
| 507 | |||
| 508 | ACPI_FUNCTION_TRACE(tb_get_owner_id); | ||
| 509 | |||
| 510 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); | ||
| 511 | if (table_index < acpi_gbl_root_table_list.count) { | ||
| 512 | *owner_id = | ||
| 513 | acpi_gbl_root_table_list.tables[table_index].owner_id; | ||
| 514 | status = AE_OK; | ||
| 515 | } | ||
| 516 | |||
| 517 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | ||
| 518 | return_ACPI_STATUS(status); | ||
| 519 | } | ||
| 520 | |||
| 521 | /******************************************************************************* | ||
| 522 | * | ||
| 523 | * FUNCTION: acpi_tb_is_table_loaded | ||
| 524 | * | ||
| 525 | * PARAMETERS: table_index - Table index | ||
| 526 | * | ||
| 527 | * RETURN: Table Loaded Flag | ||
| 528 | * | ||
| 529 | ******************************************************************************/ | ||
| 530 | |||
| 531 | u8 acpi_tb_is_table_loaded(u32 table_index) | ||
| 532 | { | ||
| 533 | u8 is_loaded = FALSE; | ||
| 534 | |||
| 535 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); | ||
| 536 | if (table_index < acpi_gbl_root_table_list.count) { | ||
| 537 | is_loaded = (u8) | ||
| 538 | (acpi_gbl_root_table_list.tables[table_index]. | ||
| 539 | flags & ACPI_TABLE_IS_LOADED); | ||
| 540 | } | ||
| 541 | |||
| 542 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | ||
| 543 | return (is_loaded); | ||
| 544 | } | ||
| 545 | |||
| 546 | /******************************************************************************* | ||
| 547 | * | ||
| 548 | * FUNCTION: acpi_tb_set_table_loaded_flag | ||
| 549 | * | ||
| 550 | * PARAMETERS: table_index - Table index | ||
| 551 | * is_loaded - TRUE if table is loaded, FALSE otherwise | ||
| 552 | * | ||
| 553 | * RETURN: None | ||
| 554 | * | ||
| 555 | * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE. | ||
| 556 | * | ||
| 557 | ******************************************************************************/ | ||
| 558 | |||
| 559 | void acpi_tb_set_table_loaded_flag(u32 table_index, u8 is_loaded) | ||
| 560 | { | ||
| 561 | |||
| 562 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); | ||
| 563 | if (table_index < acpi_gbl_root_table_list.count) { | ||
| 564 | if (is_loaded) { | ||
| 565 | acpi_gbl_root_table_list.tables[table_index].flags |= | ||
| 566 | ACPI_TABLE_IS_LOADED; | ||
| 567 | } else { | ||
| 568 | acpi_gbl_root_table_list.tables[table_index].flags &= | ||
| 569 | ~ACPI_TABLE_IS_LOADED; | ||
| 570 | } | ||
| 571 | } | ||
| 572 | |||
| 573 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | ||
| 574 | } | ||
diff --git a/drivers/acpi/tables/tbutils.c b/drivers/acpi/tables/tbutils.c deleted file mode 100644 index 4eb7189974ca..000000000000 --- a/drivers/acpi/tables/tbutils.c +++ /dev/null | |||
| @@ -1,582 +0,0 @@ | |||
| 1 | /****************************************************************************** | ||
| 2 | * | ||
| 3 | * Module Name: tbutils - table utilities | ||
| 4 | * | ||
| 5 | *****************************************************************************/ | ||
| 6 | |||
| 7 | /* | ||
| 8 | * Copyright (C) 2000 - 2008, Intel Corp. | ||
| 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 <acpi/acpi.h> | ||
| 45 | #include <acpi/accommon.h> | ||
| 46 | #include <acpi/actables.h> | ||
| 47 | |||
| 48 | #define _COMPONENT ACPI_TABLES | ||
| 49 | ACPI_MODULE_NAME("tbutils") | ||
| 50 | |||
| 51 | /* Local prototypes */ | ||
| 52 | static acpi_physical_address | ||
| 53 | acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size); | ||
| 54 | |||
| 55 | /******************************************************************************* | ||
| 56 | * | ||
| 57 | * FUNCTION: acpi_tb_check_xsdt | ||
| 58 | * | ||
| 59 | * PARAMETERS: address - Pointer to the XSDT | ||
| 60 | * | ||
| 61 | * RETURN: status | ||
| 62 | * AE_OK - XSDT is okay | ||
| 63 | * AE_NO_MEMORY - can't map XSDT | ||
| 64 | * AE_INVALID_TABLE_LENGTH - invalid table length | ||
| 65 | * AE_NULL_ENTRY - XSDT has NULL entry | ||
| 66 | * | ||
| 67 | * DESCRIPTION: validate XSDT | ||
| 68 | ******************************************************************************/ | ||
| 69 | |||
| 70 | static acpi_status | ||
| 71 | acpi_tb_check_xsdt(acpi_physical_address address) | ||
| 72 | { | ||
| 73 | struct acpi_table_header *table; | ||
| 74 | u32 length; | ||
| 75 | u64 xsdt_entry_address; | ||
| 76 | u8 *table_entry; | ||
| 77 | u32 table_count; | ||
| 78 | int i; | ||
| 79 | |||
| 80 | table = acpi_os_map_memory(address, sizeof(struct acpi_table_header)); | ||
| 81 | if (!table) | ||
| 82 | return AE_NO_MEMORY; | ||
| 83 | |||
| 84 | length = table->length; | ||
| 85 | acpi_os_unmap_memory(table, sizeof(struct acpi_table_header)); | ||
| 86 | if (length < sizeof(struct acpi_table_header)) | ||
| 87 | return AE_INVALID_TABLE_LENGTH; | ||
| 88 | |||
| 89 | table = acpi_os_map_memory(address, length); | ||
| 90 | if (!table) | ||
| 91 | return AE_NO_MEMORY; | ||
| 92 | |||
| 93 | /* Calculate the number of tables described in XSDT */ | ||
| 94 | table_count = | ||
| 95 | (u32) ((table->length - | ||
| 96 | sizeof(struct acpi_table_header)) / sizeof(u64)); | ||
| 97 | table_entry = | ||
| 98 | ACPI_CAST_PTR(u8, table) + sizeof(struct acpi_table_header); | ||
| 99 | for (i = 0; i < table_count; i++) { | ||
| 100 | ACPI_MOVE_64_TO_64(&xsdt_entry_address, table_entry); | ||
| 101 | if (!xsdt_entry_address) { | ||
| 102 | /* XSDT has NULL entry */ | ||
| 103 | break; | ||
| 104 | } | ||
| 105 | table_entry += sizeof(u64); | ||
| 106 | } | ||
| 107 | acpi_os_unmap_memory(table, length); | ||
| 108 | |||
| 109 | if (i < table_count) | ||
| 110 | return AE_NULL_ENTRY; | ||
| 111 | else | ||
| 112 | return AE_OK; | ||
| 113 | } | ||
| 114 | |||
| 115 | /******************************************************************************* | ||
| 116 | * | ||
| 117 | * FUNCTION: acpi_tb_initialize_facs | ||
| 118 | * | ||
| 119 | * PARAMETERS: None | ||
| 120 | * | ||
| 121 | * RETURN: Status | ||
| 122 | * | ||
| 123 | * DESCRIPTION: Create a permanent mapping for the FADT and save it in a global | ||
| 124 | * for accessing the Global Lock and Firmware Waking Vector | ||
| 125 | * | ||
| 126 | ******************************************************************************/ | ||
| 127 | |||
| 128 | acpi_status acpi_tb_initialize_facs(void) | ||
| 129 | { | ||
| 130 | acpi_status status; | ||
| 131 | |||
| 132 | status = acpi_get_table_by_index(ACPI_TABLE_INDEX_FACS, | ||
| 133 | ACPI_CAST_INDIRECT_PTR(struct | ||
| 134 | acpi_table_header, | ||
| 135 | &acpi_gbl_FACS)); | ||
| 136 | return status; | ||
| 137 | } | ||
| 138 | |||
| 139 | /******************************************************************************* | ||
| 140 | * | ||
| 141 | * FUNCTION: acpi_tb_tables_loaded | ||
| 142 | * | ||
| 143 | * PARAMETERS: None | ||
| 144 | * | ||
| 145 | * RETURN: TRUE if required ACPI tables are loaded | ||
| 146 | * | ||
| 147 | * DESCRIPTION: Determine if the minimum required ACPI tables are present | ||
| 148 | * (FADT, FACS, DSDT) | ||
| 149 | * | ||
| 150 | ******************************************************************************/ | ||
| 151 | |||
| 152 | u8 acpi_tb_tables_loaded(void) | ||
| 153 | { | ||
| 154 | |||
| 155 | if (acpi_gbl_root_table_list.count >= 3) { | ||
| 156 | return (TRUE); | ||
| 157 | } | ||
| 158 | |||
| 159 | return (FALSE); | ||
| 160 | } | ||
| 161 | |||
| 162 | /******************************************************************************* | ||
| 163 | * | ||
| 164 | * FUNCTION: acpi_tb_print_table_header | ||
| 165 | * | ||
| 166 | * PARAMETERS: Address - Table physical address | ||
| 167 | * Header - Table header | ||
| 168 | * | ||
| 169 | * RETURN: None | ||
| 170 | * | ||
| 171 | * DESCRIPTION: Print an ACPI table header. Special cases for FACS and RSDP. | ||
| 172 | * | ||
| 173 | ******************************************************************************/ | ||
| 174 | |||
| 175 | void | ||
| 176 | acpi_tb_print_table_header(acpi_physical_address address, | ||
| 177 | struct acpi_table_header *header) | ||
| 178 | { | ||
| 179 | |||
| 180 | if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_FACS)) { | ||
| 181 | |||
| 182 | /* FACS only has signature and length fields of common table header */ | ||
| 183 | |||
| 184 | ACPI_INFO((AE_INFO, "%4.4s %08lX, %04X", | ||
| 185 | header->signature, (unsigned long)address, | ||
| 186 | header->length)); | ||
| 187 | } else if (ACPI_COMPARE_NAME(header->signature, ACPI_SIG_RSDP)) { | ||
| 188 | |||
| 189 | /* RSDP has no common fields */ | ||
| 190 | |||
| 191 | ACPI_INFO((AE_INFO, "RSDP %08lX, %04X (r%d %6.6s)", | ||
| 192 | (unsigned long)address, | ||
| 193 | (ACPI_CAST_PTR(struct acpi_table_rsdp, header)-> | ||
| 194 | revision > | ||
| 195 | 0) ? ACPI_CAST_PTR(struct acpi_table_rsdp, | ||
| 196 | header)->length : 20, | ||
| 197 | ACPI_CAST_PTR(struct acpi_table_rsdp, | ||
| 198 | header)->revision, | ||
| 199 | ACPI_CAST_PTR(struct acpi_table_rsdp, | ||
| 200 | header)->oem_id)); | ||
| 201 | } else { | ||
| 202 | /* Standard ACPI table with full common header */ | ||
| 203 | |||
| 204 | ACPI_INFO((AE_INFO, | ||
| 205 | "%4.4s %08lX, %04X (r%d %6.6s %8.8s %8X %4.4s %8X)", | ||
| 206 | header->signature, (unsigned long)address, | ||
| 207 | header->length, header->revision, header->oem_id, | ||
| 208 | header->oem_table_id, header->oem_revision, | ||
| 209 | header->asl_compiler_id, | ||
| 210 | header->asl_compiler_revision)); | ||
| 211 | } | ||
| 212 | } | ||
| 213 | |||
| 214 | /******************************************************************************* | ||
| 215 | * | ||
| 216 | * FUNCTION: acpi_tb_validate_checksum | ||
| 217 | * | ||
| 218 | * PARAMETERS: Table - ACPI table to verify | ||
| 219 | * Length - Length of entire table | ||
| 220 | * | ||
| 221 | * RETURN: Status | ||
| 222 | * | ||
| 223 | * DESCRIPTION: Verifies that the table checksums to zero. Optionally returns | ||
| 224 | * exception on bad checksum. | ||
| 225 | * | ||
| 226 | ******************************************************************************/ | ||
| 227 | |||
| 228 | acpi_status acpi_tb_verify_checksum(struct acpi_table_header *table, u32 length) | ||
| 229 | { | ||
| 230 | u8 checksum; | ||
| 231 | |||
| 232 | /* Compute the checksum on the table */ | ||
| 233 | |||
| 234 | checksum = acpi_tb_checksum(ACPI_CAST_PTR(u8, table), length); | ||
| 235 | |||
| 236 | /* Checksum ok? (should be zero) */ | ||
| 237 | |||
| 238 | if (checksum) { | ||
| 239 | ACPI_WARNING((AE_INFO, | ||
| 240 | "Incorrect checksum in table [%4.4s] - %2.2X, should be %2.2X", | ||
| 241 | table->signature, table->checksum, | ||
| 242 | (u8) (table->checksum - checksum))); | ||
| 243 | |||
| 244 | #if (ACPI_CHECKSUM_ABORT) | ||
| 245 | |||
| 246 | return (AE_BAD_CHECKSUM); | ||
| 247 | #endif | ||
| 248 | } | ||
| 249 | |||
| 250 | return (AE_OK); | ||
| 251 | } | ||
| 252 | |||
| 253 | /******************************************************************************* | ||
| 254 | * | ||
| 255 | * FUNCTION: acpi_tb_checksum | ||
| 256 | * | ||
| 257 | * PARAMETERS: Buffer - Pointer to memory region to be checked | ||
| 258 | * Length - Length of this memory region | ||
| 259 | * | ||
| 260 | * RETURN: Checksum (u8) | ||
| 261 | * | ||
| 262 | * DESCRIPTION: Calculates circular checksum of memory region. | ||
| 263 | * | ||
| 264 | ******************************************************************************/ | ||
| 265 | |||
| 266 | u8 acpi_tb_checksum(u8 *buffer, u32 length) | ||
| 267 | { | ||
| 268 | u8 sum = 0; | ||
| 269 | u8 *end = buffer + length; | ||
| 270 | |||
| 271 | while (buffer < end) { | ||
| 272 | sum = (u8) (sum + *(buffer++)); | ||
| 273 | } | ||
| 274 | |||
| 275 | return sum; | ||
| 276 | } | ||
| 277 | |||
| 278 | /******************************************************************************* | ||
| 279 | * | ||
| 280 | * FUNCTION: acpi_tb_install_table | ||
| 281 | * | ||
| 282 | * PARAMETERS: Address - Physical address of DSDT or FACS | ||
| 283 | * Flags - Flags | ||
| 284 | * Signature - Table signature, NULL if no need to | ||
| 285 | * match | ||
| 286 | * table_index - Index into root table array | ||
| 287 | * | ||
| 288 | * RETURN: None | ||
| 289 | * | ||
| 290 | * DESCRIPTION: Install an ACPI table into the global data structure. | ||
| 291 | * | ||
| 292 | ******************************************************************************/ | ||
| 293 | |||
| 294 | void | ||
| 295 | acpi_tb_install_table(acpi_physical_address address, | ||
| 296 | u8 flags, char *signature, u32 table_index) | ||
| 297 | { | ||
| 298 | struct acpi_table_header *table; | ||
| 299 | |||
| 300 | if (!address) { | ||
| 301 | ACPI_ERROR((AE_INFO, | ||
| 302 | "Null physical address for ACPI table [%s]", | ||
| 303 | signature)); | ||
| 304 | return; | ||
| 305 | } | ||
| 306 | |||
| 307 | /* Map just the table header */ | ||
| 308 | |||
| 309 | table = acpi_os_map_memory(address, sizeof(struct acpi_table_header)); | ||
| 310 | if (!table) { | ||
| 311 | return; | ||
| 312 | } | ||
| 313 | |||
| 314 | /* If a particular signature is expected, signature must match */ | ||
| 315 | |||
| 316 | if (signature && !ACPI_COMPARE_NAME(table->signature, signature)) { | ||
| 317 | ACPI_ERROR((AE_INFO, | ||
| 318 | "Invalid signature 0x%X for ACPI table [%s]", | ||
| 319 | *ACPI_CAST_PTR(u32, table->signature), signature)); | ||
| 320 | goto unmap_and_exit; | ||
| 321 | } | ||
| 322 | |||
| 323 | /* Initialize the table entry */ | ||
| 324 | |||
| 325 | acpi_gbl_root_table_list.tables[table_index].address = address; | ||
| 326 | acpi_gbl_root_table_list.tables[table_index].length = table->length; | ||
| 327 | acpi_gbl_root_table_list.tables[table_index].flags = flags; | ||
| 328 | |||
| 329 | ACPI_MOVE_32_TO_32(& | ||
| 330 | (acpi_gbl_root_table_list.tables[table_index]. | ||
| 331 | signature), table->signature); | ||
| 332 | |||
| 333 | acpi_tb_print_table_header(address, table); | ||
| 334 | |||
| 335 | if (table_index == ACPI_TABLE_INDEX_DSDT) { | ||
| 336 | |||
| 337 | /* Global integer width is based upon revision of the DSDT */ | ||
| 338 | |||
| 339 | acpi_ut_set_integer_width(table->revision); | ||
| 340 | } | ||
| 341 | |||
| 342 | unmap_and_exit: | ||
| 343 | acpi_os_unmap_memory(table, sizeof(struct acpi_table_header)); | ||
| 344 | } | ||
| 345 | |||
| 346 | /******************************************************************************* | ||
| 347 | * | ||
| 348 | * FUNCTION: acpi_tb_get_root_table_entry | ||
| 349 | * | ||
| 350 | * PARAMETERS: table_entry - Pointer to the RSDT/XSDT table entry | ||
| 351 | * table_entry_size - sizeof 32 or 64 (RSDT or XSDT) | ||
| 352 | * | ||
| 353 | * RETURN: Physical address extracted from the root table | ||
| 354 | * | ||
| 355 | * DESCRIPTION: Get one root table entry. Handles 32-bit and 64-bit cases on | ||
| 356 | * both 32-bit and 64-bit platforms | ||
| 357 | * | ||
| 358 | * NOTE: acpi_physical_address is 32-bit on 32-bit platforms, 64-bit on | ||
| 359 | * 64-bit platforms. | ||
| 360 | * | ||
| 361 | ******************************************************************************/ | ||
| 362 | |||
| 363 | static acpi_physical_address | ||
| 364 | acpi_tb_get_root_table_entry(u8 *table_entry, u32 table_entry_size) | ||
| 365 | { | ||
| 366 | u64 address64; | ||
| 367 | |||
| 368 | /* | ||
| 369 | * Get the table physical address (32-bit for RSDT, 64-bit for XSDT): | ||
| 370 | * Note: Addresses are 32-bit aligned (not 64) in both RSDT and XSDT | ||
| 371 | */ | ||
| 372 | if (table_entry_size == sizeof(u32)) { | ||
| 373 | /* | ||
| 374 | * 32-bit platform, RSDT: Return 32-bit table entry | ||
| 375 | * 64-bit platform, RSDT: Expand 32-bit to 64-bit and return | ||
| 376 | */ | ||
| 377 | return ((acpi_physical_address) | ||
| 378 | (*ACPI_CAST_PTR(u32, table_entry))); | ||
| 379 | } else { | ||
| 380 | /* | ||
| 381 | * 32-bit platform, XSDT: Truncate 64-bit to 32-bit and return | ||
| 382 | * 64-bit platform, XSDT: Move (unaligned) 64-bit to local, return 64-bit | ||
| 383 | */ | ||
| 384 | ACPI_MOVE_64_TO_64(&address64, table_entry); | ||
| 385 | |||
| 386 | #if ACPI_MACHINE_WIDTH == 32 | ||
| 387 | if (address64 > ACPI_UINT32_MAX) { | ||
| 388 | |||
| 389 | /* Will truncate 64-bit address to 32 bits, issue warning */ | ||
| 390 | |||
| 391 | ACPI_WARNING((AE_INFO, | ||
| 392 | "64-bit Physical Address in XSDT is too large (%8.8X%8.8X), truncating", | ||
| 393 | ACPI_FORMAT_UINT64(address64))); | ||
| 394 | } | ||
| 395 | #endif | ||
| 396 | return ((acpi_physical_address) (address64)); | ||
| 397 | } | ||
| 398 | } | ||
| 399 | |||
| 400 | /******************************************************************************* | ||
| 401 | * | ||
| 402 | * FUNCTION: acpi_tb_parse_root_table | ||
| 403 | * | ||
| 404 | * PARAMETERS: Rsdp - Pointer to the RSDP | ||
| 405 | * Flags - Flags | ||
| 406 | * | ||
| 407 | * RETURN: Status | ||
| 408 | * | ||
| 409 | * DESCRIPTION: This function is called to parse the Root System Description | ||
| 410 | * Table (RSDT or XSDT) | ||
| 411 | * | ||
| 412 | * NOTE: Tables are mapped (not copied) for efficiency. The FACS must | ||
| 413 | * be mapped and cannot be copied because it contains the actual | ||
| 414 | * memory location of the ACPI Global Lock. | ||
| 415 | * | ||
| 416 | ******************************************************************************/ | ||
| 417 | |||
| 418 | acpi_status __init | ||
| 419 | acpi_tb_parse_root_table(acpi_physical_address rsdp_address, u8 flags) | ||
| 420 | { | ||
| 421 | struct acpi_table_rsdp *rsdp; | ||
| 422 | u32 table_entry_size; | ||
| 423 | u32 i; | ||
| 424 | u32 table_count; | ||
| 425 | struct acpi_table_header *table; | ||
| 426 | acpi_physical_address address; | ||
| 427 | acpi_physical_address uninitialized_var(rsdt_address); | ||
| 428 | u32 length; | ||
| 429 | u8 *table_entry; | ||
| 430 | acpi_status status; | ||
| 431 | |||
| 432 | ACPI_FUNCTION_TRACE(tb_parse_root_table); | ||
| 433 | |||
| 434 | /* | ||
| 435 | * Map the entire RSDP and extract the address of the RSDT or XSDT | ||
| 436 | */ | ||
| 437 | rsdp = acpi_os_map_memory(rsdp_address, sizeof(struct acpi_table_rsdp)); | ||
| 438 | if (!rsdp) { | ||
| 439 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
| 440 | } | ||
| 441 | |||
| 442 | acpi_tb_print_table_header(rsdp_address, | ||
| 443 | ACPI_CAST_PTR(struct acpi_table_header, | ||
| 444 | rsdp)); | ||
| 445 | |||
| 446 | /* Differentiate between RSDT and XSDT root tables */ | ||
| 447 | |||
| 448 | if (rsdp->revision > 1 && rsdp->xsdt_physical_address) { | ||
| 449 | /* | ||
| 450 | * Root table is an XSDT (64-bit physical addresses). We must use the | ||
| 451 | * XSDT if the revision is > 1 and the XSDT pointer is present, as per | ||
| 452 | * the ACPI specification. | ||
| 453 | */ | ||
| 454 | address = (acpi_physical_address) rsdp->xsdt_physical_address; | ||
| 455 | table_entry_size = sizeof(u64); | ||
| 456 | rsdt_address = (acpi_physical_address) | ||
| 457 | rsdp->rsdt_physical_address; | ||
| 458 | } else { | ||
| 459 | /* Root table is an RSDT (32-bit physical addresses) */ | ||
| 460 | |||
| 461 | address = (acpi_physical_address) rsdp->rsdt_physical_address; | ||
| 462 | table_entry_size = sizeof(u32); | ||
| 463 | } | ||
| 464 | |||
| 465 | /* | ||
| 466 | * It is not possible to map more than one entry in some environments, | ||
| 467 | * so unmap the RSDP here before mapping other tables | ||
| 468 | */ | ||
| 469 | acpi_os_unmap_memory(rsdp, sizeof(struct acpi_table_rsdp)); | ||
| 470 | |||
| 471 | if (table_entry_size == sizeof(u64)) { | ||
| 472 | if (acpi_tb_check_xsdt(address) == AE_NULL_ENTRY) { | ||
| 473 | /* XSDT has NULL entry, RSDT is used */ | ||
| 474 | address = rsdt_address; | ||
| 475 | table_entry_size = sizeof(u32); | ||
| 476 | ACPI_WARNING((AE_INFO, "BIOS XSDT has NULL entry, " | ||
| 477 | "using RSDT")); | ||
| 478 | } | ||
| 479 | } | ||
| 480 | /* Map the RSDT/XSDT table header to get the full table length */ | ||
| 481 | |||
| 482 | table = acpi_os_map_memory(address, sizeof(struct acpi_table_header)); | ||
| 483 | if (!table) { | ||
| 484 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
| 485 | } | ||
| 486 | |||
| 487 | acpi_tb_print_table_header(address, table); | ||
| 488 | |||
| 489 | /* Get the length of the full table, verify length and map entire table */ | ||
| 490 | |||
| 491 | length = table->length; | ||
| 492 | acpi_os_unmap_memory(table, sizeof(struct acpi_table_header)); | ||
| 493 | |||
| 494 | if (length < sizeof(struct acpi_table_header)) { | ||
| 495 | ACPI_ERROR((AE_INFO, "Invalid length 0x%X in RSDT/XSDT", | ||
| 496 | length)); | ||
| 497 | return_ACPI_STATUS(AE_INVALID_TABLE_LENGTH); | ||
| 498 | } | ||
| 499 | |||
| 500 | table = acpi_os_map_memory(address, length); | ||
| 501 | if (!table) { | ||
| 502 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
| 503 | } | ||
| 504 | |||
| 505 | /* Validate the root table checksum */ | ||
| 506 | |||
| 507 | status = acpi_tb_verify_checksum(table, length); | ||
| 508 | if (ACPI_FAILURE(status)) { | ||
| 509 | acpi_os_unmap_memory(table, length); | ||
| 510 | return_ACPI_STATUS(status); | ||
| 511 | } | ||
| 512 | |||
| 513 | /* Calculate the number of tables described in the root table */ | ||
| 514 | |||
| 515 | table_count = | ||
| 516 | (u32) ((table->length - | ||
| 517 | sizeof(struct acpi_table_header)) / table_entry_size); | ||
| 518 | |||
| 519 | /* | ||
| 520 | * First two entries in the table array are reserved for the DSDT and FACS, | ||
| 521 | * which are not actually present in the RSDT/XSDT - they come from the FADT | ||
| 522 | */ | ||
| 523 | table_entry = | ||
| 524 | ACPI_CAST_PTR(u8, table) + sizeof(struct acpi_table_header); | ||
| 525 | acpi_gbl_root_table_list.count = 2; | ||
| 526 | |||
| 527 | /* | ||
| 528 | * Initialize the root table array from the RSDT/XSDT | ||
| 529 | */ | ||
| 530 | for (i = 0; i < table_count; i++) { | ||
| 531 | if (acpi_gbl_root_table_list.count >= | ||
| 532 | acpi_gbl_root_table_list.size) { | ||
| 533 | |||
| 534 | /* There is no more room in the root table array, attempt resize */ | ||
| 535 | |||
| 536 | status = acpi_tb_resize_root_table_list(); | ||
| 537 | if (ACPI_FAILURE(status)) { | ||
| 538 | ACPI_WARNING((AE_INFO, | ||
| 539 | "Truncating %u table entries!", | ||
| 540 | (unsigned) | ||
| 541 | (acpi_gbl_root_table_list.size - | ||
| 542 | acpi_gbl_root_table_list. | ||
| 543 | count))); | ||
| 544 | break; | ||
| 545 | } | ||
| 546 | } | ||
| 547 | |||
| 548 | /* Get the table physical address (32-bit for RSDT, 64-bit for XSDT) */ | ||
| 549 | |||
| 550 | acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count]. | ||
| 551 | address = | ||
| 552 | acpi_tb_get_root_table_entry(table_entry, table_entry_size); | ||
| 553 | |||
| 554 | table_entry += table_entry_size; | ||
| 555 | acpi_gbl_root_table_list.count++; | ||
| 556 | } | ||
| 557 | |||
| 558 | /* | ||
| 559 | * It is not possible to map more than one entry in some environments, | ||
| 560 | * so unmap the root table here before mapping other tables | ||
| 561 | */ | ||
| 562 | acpi_os_unmap_memory(table, length); | ||
| 563 | |||
| 564 | /* | ||
| 565 | * Complete the initialization of the root table array by examining | ||
| 566 | * the header of each table | ||
| 567 | */ | ||
| 568 | for (i = 2; i < acpi_gbl_root_table_list.count; i++) { | ||
| 569 | acpi_tb_install_table(acpi_gbl_root_table_list.tables[i]. | ||
| 570 | address, flags, NULL, i); | ||
| 571 | |||
| 572 | /* Special case for FADT - get the DSDT and FACS */ | ||
| 573 | |||
| 574 | if (ACPI_COMPARE_NAME | ||
| 575 | (&acpi_gbl_root_table_list.tables[i].signature, | ||
| 576 | ACPI_SIG_FADT)) { | ||
| 577 | acpi_tb_parse_fadt(i, flags); | ||
| 578 | } | ||
| 579 | } | ||
| 580 | |||
| 581 | return_ACPI_STATUS(AE_OK); | ||
| 582 | } | ||
diff --git a/drivers/acpi/tables/tbxface.c b/drivers/acpi/tables/tbxface.c deleted file mode 100644 index 115796694a2f..000000000000 --- a/drivers/acpi/tables/tbxface.c +++ /dev/null | |||
| @@ -1,735 +0,0 @@ | |||
| 1 | /****************************************************************************** | ||
| 2 | * | ||
| 3 | * Module Name: tbxface - Public interfaces to the ACPI subsystem | ||
| 4 | * ACPI table oriented interfaces | ||
| 5 | * | ||
| 6 | *****************************************************************************/ | ||
| 7 | |||
| 8 | /* | ||
| 9 | * Copyright (C) 2000 - 2008, Intel Corp. | ||
| 10 | * All rights reserved. | ||
| 11 | * | ||
| 12 | * Redistribution and use in source and binary forms, with or without | ||
| 13 | * modification, are permitted provided that the following conditions | ||
| 14 | * are met: | ||
| 15 | * 1. Redistributions of source code must retain the above copyright | ||
| 16 | * notice, this list of conditions, and the following disclaimer, | ||
| 17 | * without modification. | ||
| 18 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | ||
| 19 | * substantially similar to the "NO WARRANTY" disclaimer below | ||
| 20 | * ("Disclaimer") and any redistribution must be conditioned upon | ||
| 21 | * including a substantially similar Disclaimer requirement for further | ||
| 22 | * binary redistribution. | ||
| 23 | * 3. Neither the names of the above-listed copyright holders nor the names | ||
| 24 | * of any contributors may be used to endorse or promote products derived | ||
| 25 | * from this software without specific prior written permission. | ||
| 26 | * | ||
| 27 | * Alternatively, this software may be distributed under the terms of the | ||
| 28 | * GNU General Public License ("GPL") version 2 as published by the Free | ||
| 29 | * Software Foundation. | ||
| 30 | * | ||
| 31 | * NO WARRANTY | ||
| 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| 33 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| 34 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | ||
| 35 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
| 36 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
| 37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||
| 38 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
| 39 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
| 40 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | ||
| 41 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
| 42 | * POSSIBILITY OF SUCH DAMAGES. | ||
| 43 | */ | ||
| 44 | |||
| 45 | #include <acpi/acpi.h> | ||
| 46 | #include <acpi/accommon.h> | ||
| 47 | #include <acpi/acnamesp.h> | ||
| 48 | #include <acpi/actables.h> | ||
| 49 | |||
| 50 | #define _COMPONENT ACPI_TABLES | ||
| 51 | ACPI_MODULE_NAME("tbxface") | ||
| 52 | |||
| 53 | /* Local prototypes */ | ||
| 54 | static acpi_status acpi_tb_load_namespace(void); | ||
| 55 | |||
| 56 | static int no_auto_ssdt; | ||
| 57 | |||
| 58 | /******************************************************************************* | ||
| 59 | * | ||
| 60 | * FUNCTION: acpi_allocate_root_table | ||
| 61 | * | ||
| 62 | * PARAMETERS: initial_table_count - Size of initial_table_array, in number of | ||
| 63 | * struct acpi_table_desc structures | ||
| 64 | * | ||
| 65 | * RETURN: Status | ||
| 66 | * | ||
| 67 | * DESCRIPTION: Allocate a root table array. Used by i_aSL compiler and | ||
| 68 | * acpi_initialize_tables. | ||
| 69 | * | ||
| 70 | ******************************************************************************/ | ||
| 71 | |||
| 72 | acpi_status acpi_allocate_root_table(u32 initial_table_count) | ||
| 73 | { | ||
| 74 | |||
| 75 | acpi_gbl_root_table_list.size = initial_table_count; | ||
| 76 | acpi_gbl_root_table_list.flags = ACPI_ROOT_ALLOW_RESIZE; | ||
| 77 | |||
| 78 | return (acpi_tb_resize_root_table_list()); | ||
| 79 | } | ||
| 80 | |||
| 81 | /******************************************************************************* | ||
| 82 | * | ||
| 83 | * FUNCTION: acpi_initialize_tables | ||
| 84 | * | ||
| 85 | * PARAMETERS: initial_table_array - Pointer to an array of pre-allocated | ||
| 86 | * struct acpi_table_desc structures. If NULL, the | ||
| 87 | * array is dynamically allocated. | ||
| 88 | * initial_table_count - Size of initial_table_array, in number of | ||
| 89 | * struct acpi_table_desc structures | ||
| 90 | * allow_realloc - Flag to tell Table Manager if resize of | ||
| 91 | * pre-allocated array is allowed. Ignored | ||
| 92 | * if initial_table_array is NULL. | ||
| 93 | * | ||
| 94 | * RETURN: Status | ||
| 95 | * | ||
| 96 | * DESCRIPTION: Initialize the table manager, get the RSDP and RSDT/XSDT. | ||
| 97 | * | ||
| 98 | * NOTE: Allows static allocation of the initial table array in order | ||
| 99 | * to avoid the use of dynamic memory in confined environments | ||
| 100 | * such as the kernel boot sequence where it may not be available. | ||
| 101 | * | ||
| 102 | * If the host OS memory managers are initialized, use NULL for | ||
| 103 | * initial_table_array, and the table will be dynamically allocated. | ||
| 104 | * | ||
| 105 | ******************************************************************************/ | ||
| 106 | |||
| 107 | acpi_status __init | ||
| 108 | acpi_initialize_tables(struct acpi_table_desc * initial_table_array, | ||
| 109 | u32 initial_table_count, u8 allow_resize) | ||
| 110 | { | ||
| 111 | acpi_physical_address rsdp_address; | ||
| 112 | acpi_status status; | ||
| 113 | |||
| 114 | ACPI_FUNCTION_TRACE(acpi_initialize_tables); | ||
| 115 | |||
| 116 | /* | ||
| 117 | * Set up the Root Table Array | ||
| 118 | * Allocate the table array if requested | ||
| 119 | */ | ||
| 120 | if (!initial_table_array) { | ||
| 121 | status = acpi_allocate_root_table(initial_table_count); | ||
| 122 | if (ACPI_FAILURE(status)) { | ||
| 123 | return_ACPI_STATUS(status); | ||
| 124 | } | ||
| 125 | } else { | ||
| 126 | /* Root Table Array has been statically allocated by the host */ | ||
| 127 | |||
| 128 | ACPI_MEMSET(initial_table_array, 0, | ||
| 129 | (acpi_size) initial_table_count * | ||
| 130 | sizeof(struct acpi_table_desc)); | ||
| 131 | |||
| 132 | acpi_gbl_root_table_list.tables = initial_table_array; | ||
| 133 | acpi_gbl_root_table_list.size = initial_table_count; | ||
| 134 | acpi_gbl_root_table_list.flags = ACPI_ROOT_ORIGIN_UNKNOWN; | ||
| 135 | if (allow_resize) { | ||
| 136 | acpi_gbl_root_table_list.flags |= | ||
| 137 | ACPI_ROOT_ALLOW_RESIZE; | ||
| 138 | } | ||
| 139 | } | ||
| 140 | |||
| 141 | /* Get the address of the RSDP */ | ||
| 142 | |||
| 143 | rsdp_address = acpi_os_get_root_pointer(); | ||
| 144 | if (!rsdp_address) { | ||
| 145 | return_ACPI_STATUS(AE_NOT_FOUND); | ||
| 146 | } | ||
| 147 | |||
| 148 | /* | ||
| 149 | * Get the root table (RSDT or XSDT) and extract all entries to the local | ||
| 150 | * Root Table Array. This array contains the information of the RSDT/XSDT | ||
| 151 | * in a common, more useable format. | ||
| 152 | */ | ||
| 153 | status = | ||
| 154 | acpi_tb_parse_root_table(rsdp_address, ACPI_TABLE_ORIGIN_MAPPED); | ||
| 155 | return_ACPI_STATUS(status); | ||
| 156 | } | ||
| 157 | |||
| 158 | /******************************************************************************* | ||
| 159 | * | ||
| 160 | * FUNCTION: acpi_reallocate_root_table | ||
| 161 | * | ||
| 162 | * PARAMETERS: None | ||
| 163 | * | ||
| 164 | * RETURN: Status | ||
| 165 | * | ||
| 166 | * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the | ||
| 167 | * root list from the previously provided scratch area. Should | ||
| 168 | * be called once dynamic memory allocation is available in the | ||
| 169 | * kernel | ||
| 170 | * | ||
| 171 | ******************************************************************************/ | ||
| 172 | acpi_status acpi_reallocate_root_table(void) | ||
| 173 | { | ||
| 174 | struct acpi_table_desc *tables; | ||
| 175 | acpi_size new_size; | ||
| 176 | |||
| 177 | ACPI_FUNCTION_TRACE(acpi_reallocate_root_table); | ||
| 178 | |||
| 179 | /* | ||
| 180 | * Only reallocate the root table if the host provided a static buffer | ||
| 181 | * for the table array in the call to acpi_initialize_tables. | ||
| 182 | */ | ||
| 183 | if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { | ||
| 184 | return_ACPI_STATUS(AE_SUPPORT); | ||
| 185 | } | ||
| 186 | |||
| 187 | new_size = ((acpi_size) acpi_gbl_root_table_list.count + | ||
| 188 | ACPI_ROOT_TABLE_SIZE_INCREMENT) * | ||
| 189 | sizeof(struct acpi_table_desc); | ||
| 190 | |||
| 191 | /* Create new array and copy the old array */ | ||
| 192 | |||
| 193 | tables = ACPI_ALLOCATE_ZEROED(new_size); | ||
| 194 | if (!tables) { | ||
| 195 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
| 196 | } | ||
| 197 | |||
| 198 | ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables, new_size); | ||
| 199 | |||
| 200 | acpi_gbl_root_table_list.size = acpi_gbl_root_table_list.count; | ||
| 201 | acpi_gbl_root_table_list.tables = tables; | ||
| 202 | acpi_gbl_root_table_list.flags = | ||
| 203 | ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE; | ||
| 204 | |||
| 205 | return_ACPI_STATUS(AE_OK); | ||
| 206 | } | ||
| 207 | |||
| 208 | /******************************************************************************* | ||
| 209 | * | ||
| 210 | * FUNCTION: acpi_load_table | ||
| 211 | * | ||
| 212 | * PARAMETERS: table_ptr - pointer to a buffer containing the entire | ||
| 213 | * table to be loaded | ||
| 214 | * | ||
| 215 | * RETURN: Status | ||
| 216 | * | ||
| 217 | * DESCRIPTION: This function is called to load a table from the caller's | ||
| 218 | * buffer. The buffer must contain an entire ACPI Table including | ||
| 219 | * a valid header. The header fields will be verified, and if it | ||
| 220 | * is determined that the table is invalid, the call will fail. | ||
| 221 | * | ||
| 222 | ******************************************************************************/ | ||
| 223 | acpi_status acpi_load_table(struct acpi_table_header *table_ptr) | ||
| 224 | { | ||
| 225 | acpi_status status; | ||
| 226 | u32 table_index; | ||
| 227 | struct acpi_table_desc table_desc; | ||
| 228 | |||
| 229 | if (!table_ptr) | ||
| 230 | return AE_BAD_PARAMETER; | ||
| 231 | |||
| 232 | ACPI_MEMSET(&table_desc, 0, sizeof(struct acpi_table_desc)); | ||
| 233 | table_desc.pointer = table_ptr; | ||
| 234 | table_desc.length = table_ptr->length; | ||
| 235 | table_desc.flags = ACPI_TABLE_ORIGIN_UNKNOWN; | ||
| 236 | |||
| 237 | /* | ||
| 238 | * Install the new table into the local data structures | ||
| 239 | */ | ||
| 240 | status = acpi_tb_add_table(&table_desc, &table_index); | ||
| 241 | if (ACPI_FAILURE(status)) { | ||
| 242 | return status; | ||
| 243 | } | ||
| 244 | status = acpi_ns_load_table(table_index, acpi_gbl_root_node); | ||
| 245 | return status; | ||
| 246 | } | ||
| 247 | |||
| 248 | ACPI_EXPORT_SYMBOL(acpi_load_table) | ||
| 249 | |||
| 250 | /****************************************************************************** | ||
| 251 | * | ||
| 252 | * FUNCTION: acpi_get_table_header | ||
| 253 | * | ||
| 254 | * PARAMETERS: Signature - ACPI signature of needed table | ||
| 255 | * Instance - Which instance (for SSDTs) | ||
| 256 | * out_table_header - The pointer to the table header to fill | ||
| 257 | * | ||
| 258 | * RETURN: Status and pointer to mapped table header | ||
| 259 | * | ||
| 260 | * DESCRIPTION: Finds an ACPI table header. | ||
| 261 | * | ||
| 262 | * NOTE: Caller is responsible in unmapping the header with | ||
| 263 | * acpi_os_unmap_memory | ||
| 264 | * | ||
| 265 | *****************************************************************************/ | ||
| 266 | acpi_status | ||
| 267 | acpi_get_table_header(char *signature, | ||
| 268 | u32 instance, struct acpi_table_header *out_table_header) | ||
| 269 | { | ||
| 270 | u32 i; | ||
| 271 | u32 j; | ||
| 272 | struct acpi_table_header *header; | ||
| 273 | |||
| 274 | /* Parameter validation */ | ||
| 275 | |||
| 276 | if (!signature || !out_table_header) { | ||
| 277 | return (AE_BAD_PARAMETER); | ||
| 278 | } | ||
| 279 | |||
| 280 | /* | ||
| 281 | * Walk the root table list | ||
| 282 | */ | ||
| 283 | for (i = 0, j = 0; i < acpi_gbl_root_table_list.count; i++) { | ||
| 284 | if (!ACPI_COMPARE_NAME | ||
| 285 | (&(acpi_gbl_root_table_list.tables[i].signature), | ||
| 286 | signature)) { | ||
| 287 | continue; | ||
| 288 | } | ||
| 289 | |||
| 290 | if (++j < instance) { | ||
| 291 | continue; | ||
| 292 | } | ||
| 293 | |||
| 294 | if (!acpi_gbl_root_table_list.tables[i].pointer) { | ||
| 295 | if ((acpi_gbl_root_table_list.tables[i]. | ||
| 296 | flags & ACPI_TABLE_ORIGIN_MASK) == | ||
| 297 | ACPI_TABLE_ORIGIN_MAPPED) { | ||
| 298 | header = | ||
| 299 | acpi_os_map_memory(acpi_gbl_root_table_list. | ||
| 300 | tables[i].address, | ||
| 301 | sizeof(struct | ||
| 302 | acpi_table_header)); | ||
| 303 | if (!header) { | ||
| 304 | return AE_NO_MEMORY; | ||
| 305 | } | ||
| 306 | ACPI_MEMCPY(out_table_header, header, | ||
| 307 | sizeof(struct acpi_table_header)); | ||
| 308 | acpi_os_unmap_memory(header, | ||
| 309 | sizeof(struct | ||
| 310 | acpi_table_header)); | ||
| 311 | } else { | ||
| 312 | return AE_NOT_FOUND; | ||
| 313 | } | ||
| 314 | } else { | ||
| 315 | ACPI_MEMCPY(out_table_header, | ||
| 316 | acpi_gbl_root_table_list.tables[i].pointer, | ||
| 317 | sizeof(struct acpi_table_header)); | ||
| 318 | } | ||
| 319 | return (AE_OK); | ||
| 320 | } | ||
| 321 | |||
| 322 | return (AE_NOT_FOUND); | ||
| 323 | } | ||
| 324 | |||
| 325 | ACPI_EXPORT_SYMBOL(acpi_get_table_header) | ||
| 326 | |||
| 327 | /****************************************************************************** | ||
| 328 | * | ||
| 329 | * FUNCTION: acpi_unload_table_id | ||
| 330 | * | ||
| 331 | * PARAMETERS: id - Owner ID of the table to be removed. | ||
| 332 | * | ||
| 333 | * RETURN: Status | ||
| 334 | * | ||
| 335 | * DESCRIPTION: This routine is used to force the unload of a table (by id) | ||
| 336 | * | ||
| 337 | ******************************************************************************/ | ||
| 338 | acpi_status acpi_unload_table_id(acpi_owner_id id) | ||
| 339 | { | ||
| 340 | int i; | ||
| 341 | acpi_status status = AE_NOT_EXIST; | ||
| 342 | |||
| 343 | ACPI_FUNCTION_TRACE(acpi_unload_table_id); | ||
| 344 | |||
| 345 | /* Find table in the global table list */ | ||
| 346 | for (i = 0; i < acpi_gbl_root_table_list.count; ++i) { | ||
| 347 | if (id != acpi_gbl_root_table_list.tables[i].owner_id) { | ||
| 348 | continue; | ||
| 349 | } | ||
| 350 | /* | ||
| 351 | * Delete all namespace objects owned by this table. Note that these | ||
| 352 | * objects can appear anywhere in the namespace by virtue of the AML | ||
| 353 | * "Scope" operator. Thus, we need to track ownership by an ID, not | ||
| 354 | * simply a position within the hierarchy | ||
| 355 | */ | ||
| 356 | acpi_tb_delete_namespace_by_owner(i); | ||
| 357 | status = acpi_tb_release_owner_id(i); | ||
| 358 | acpi_tb_set_table_loaded_flag(i, FALSE); | ||
| 359 | break; | ||
| 360 | } | ||
| 361 | return_ACPI_STATUS(status); | ||
| 362 | } | ||
| 363 | |||
| 364 | ACPI_EXPORT_SYMBOL(acpi_unload_table_id) | ||
| 365 | |||
| 366 | /******************************************************************************* | ||
| 367 | * | ||
| 368 | * FUNCTION: acpi_get_table | ||
| 369 | * | ||
| 370 | * PARAMETERS: Signature - ACPI signature of needed table | ||
| 371 | * Instance - Which instance (for SSDTs) | ||
| 372 | * out_table - Where the pointer to the table is returned | ||
| 373 | * | ||
| 374 | * RETURN: Status and pointer to table | ||
| 375 | * | ||
| 376 | * DESCRIPTION: Finds and verifies an ACPI table. | ||
| 377 | * | ||
| 378 | *****************************************************************************/ | ||
| 379 | acpi_status | ||
| 380 | acpi_get_table(char *signature, | ||
| 381 | u32 instance, struct acpi_table_header **out_table) | ||
| 382 | { | ||
| 383 | u32 i; | ||
| 384 | u32 j; | ||
| 385 | acpi_status status; | ||
| 386 | |||
| 387 | /* Parameter validation */ | ||
| 388 | |||
| 389 | if (!signature || !out_table) { | ||
| 390 | return (AE_BAD_PARAMETER); | ||
| 391 | } | ||
| 392 | |||
| 393 | /* | ||
| 394 | * Walk the root table list | ||
| 395 | */ | ||
| 396 | for (i = 0, j = 0; i < acpi_gbl_root_table_list.count; i++) { | ||
| 397 | if (!ACPI_COMPARE_NAME | ||
| 398 | (&(acpi_gbl_root_table_list.tables[i].signature), | ||
| 399 | signature)) { | ||
| 400 | continue; | ||
| 401 | } | ||
| 402 | |||
| 403 | if (++j < instance) { | ||
| 404 | continue; | ||
| 405 | } | ||
| 406 | |||
| 407 | status = | ||
| 408 | acpi_tb_verify_table(&acpi_gbl_root_table_list.tables[i]); | ||
| 409 | if (ACPI_SUCCESS(status)) { | ||
| 410 | *out_table = acpi_gbl_root_table_list.tables[i].pointer; | ||
| 411 | } | ||
| 412 | |||
| 413 | if (!acpi_gbl_permanent_mmap) { | ||
| 414 | acpi_gbl_root_table_list.tables[i].pointer = NULL; | ||
| 415 | } | ||
| 416 | |||
| 417 | return (status); | ||
| 418 | } | ||
| 419 | |||
| 420 | return (AE_NOT_FOUND); | ||
| 421 | } | ||
| 422 | |||
| 423 | ACPI_EXPORT_SYMBOL(acpi_get_table) | ||
| 424 | |||
| 425 | /******************************************************************************* | ||
| 426 | * | ||
| 427 | * FUNCTION: acpi_get_table_by_index | ||
| 428 | * | ||
| 429 | * PARAMETERS: table_index - Table index | ||
| 430 | * Table - Where the pointer to the table is returned | ||
| 431 | * | ||
| 432 | * RETURN: Status and pointer to the table | ||
| 433 | * | ||
| 434 | * DESCRIPTION: Obtain a table by an index into the global table list. | ||
| 435 | * | ||
| 436 | ******************************************************************************/ | ||
| 437 | acpi_status | ||
| 438 | acpi_get_table_by_index(u32 table_index, struct acpi_table_header **table) | ||
| 439 | { | ||
| 440 | acpi_status status; | ||
| 441 | |||
| 442 | ACPI_FUNCTION_TRACE(acpi_get_table_by_index); | ||
| 443 | |||
| 444 | /* Parameter validation */ | ||
| 445 | |||
| 446 | if (!table) { | ||
| 447 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
| 448 | } | ||
| 449 | |||
| 450 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); | ||
| 451 | |||
| 452 | /* Validate index */ | ||
| 453 | |||
| 454 | if (table_index >= acpi_gbl_root_table_list.count) { | ||
| 455 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | ||
| 456 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
| 457 | } | ||
| 458 | |||
| 459 | if (!acpi_gbl_root_table_list.tables[table_index].pointer) { | ||
| 460 | |||
| 461 | /* Table is not mapped, map it */ | ||
| 462 | |||
| 463 | status = | ||
| 464 | acpi_tb_verify_table(&acpi_gbl_root_table_list. | ||
| 465 | tables[table_index]); | ||
| 466 | if (ACPI_FAILURE(status)) { | ||
| 467 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | ||
| 468 | return_ACPI_STATUS(status); | ||
| 469 | } | ||
| 470 | } | ||
| 471 | |||
| 472 | *table = acpi_gbl_root_table_list.tables[table_index].pointer; | ||
| 473 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | ||
| 474 | return_ACPI_STATUS(AE_OK); | ||
| 475 | } | ||
| 476 | |||
| 477 | ACPI_EXPORT_SYMBOL(acpi_get_table_by_index) | ||
| 478 | |||
| 479 | /******************************************************************************* | ||
| 480 | * | ||
| 481 | * FUNCTION: acpi_tb_load_namespace | ||
| 482 | * | ||
| 483 | * PARAMETERS: None | ||
| 484 | * | ||
| 485 | * RETURN: Status | ||
| 486 | * | ||
| 487 | * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in | ||
| 488 | * the RSDT/XSDT. | ||
| 489 | * | ||
| 490 | ******************************************************************************/ | ||
| 491 | static acpi_status acpi_tb_load_namespace(void) | ||
| 492 | { | ||
| 493 | acpi_status status; | ||
| 494 | struct acpi_table_header *table; | ||
| 495 | u32 i; | ||
| 496 | |||
| 497 | ACPI_FUNCTION_TRACE(tb_load_namespace); | ||
| 498 | |||
| 499 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); | ||
| 500 | |||
| 501 | /* | ||
| 502 | * Load the namespace. The DSDT is required, but any SSDT and PSDT tables | ||
| 503 | * are optional. | ||
| 504 | */ | ||
| 505 | if (!acpi_gbl_root_table_list.count || | ||
| 506 | !ACPI_COMPARE_NAME(& | ||
| 507 | (acpi_gbl_root_table_list. | ||
| 508 | tables[ACPI_TABLE_INDEX_DSDT].signature), | ||
| 509 | ACPI_SIG_DSDT) | ||
| 510 | || | ||
| 511 | ACPI_FAILURE(acpi_tb_verify_table | ||
| 512 | (&acpi_gbl_root_table_list. | ||
| 513 | tables[ACPI_TABLE_INDEX_DSDT]))) { | ||
| 514 | status = AE_NO_ACPI_TABLES; | ||
| 515 | goto unlock_and_exit; | ||
| 516 | } | ||
| 517 | |||
| 518 | /* | ||
| 519 | * Find DSDT table | ||
| 520 | */ | ||
| 521 | status = | ||
| 522 | acpi_os_table_override(acpi_gbl_root_table_list. | ||
| 523 | tables[ACPI_TABLE_INDEX_DSDT].pointer, | ||
| 524 | &table); | ||
| 525 | if (ACPI_SUCCESS(status) && table) { | ||
| 526 | /* | ||
| 527 | * DSDT table has been found | ||
| 528 | */ | ||
| 529 | acpi_tb_delete_table(&acpi_gbl_root_table_list. | ||
| 530 | tables[ACPI_TABLE_INDEX_DSDT]); | ||
| 531 | acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].pointer = | ||
| 532 | table; | ||
| 533 | acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].length = | ||
| 534 | table->length; | ||
| 535 | acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].flags = | ||
| 536 | ACPI_TABLE_ORIGIN_UNKNOWN; | ||
| 537 | |||
| 538 | ACPI_INFO((AE_INFO, "Table DSDT replaced by host OS")); | ||
| 539 | acpi_tb_print_table_header(0, table); | ||
| 540 | |||
| 541 | if (no_auto_ssdt == 0) { | ||
| 542 | printk(KERN_WARNING "ACPI: DSDT override uses original SSDTs unless \"acpi_no_auto_ssdt\"\n"); | ||
| 543 | } | ||
| 544 | } | ||
| 545 | |||
| 546 | status = | ||
| 547 | acpi_tb_verify_table(&acpi_gbl_root_table_list. | ||
| 548 | tables[ACPI_TABLE_INDEX_DSDT]); | ||
| 549 | if (ACPI_FAILURE(status)) { | ||
| 550 | |||
| 551 | /* A valid DSDT is required */ | ||
| 552 | |||
| 553 | status = AE_NO_ACPI_TABLES; | ||
| 554 | goto unlock_and_exit; | ||
| 555 | } | ||
| 556 | |||
| 557 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | ||
| 558 | |||
| 559 | /* | ||
| 560 | * Load and parse tables. | ||
| 561 | */ | ||
| 562 | status = acpi_ns_load_table(ACPI_TABLE_INDEX_DSDT, acpi_gbl_root_node); | ||
| 563 | if (ACPI_FAILURE(status)) { | ||
| 564 | return_ACPI_STATUS(status); | ||
| 565 | } | ||
| 566 | |||
| 567 | /* | ||
| 568 | * Load any SSDT or PSDT tables. Note: Loop leaves tables locked | ||
| 569 | */ | ||
| 570 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); | ||
| 571 | for (i = 0; i < acpi_gbl_root_table_list.count; ++i) { | ||
| 572 | if ((!ACPI_COMPARE_NAME | ||
| 573 | (&(acpi_gbl_root_table_list.tables[i].signature), | ||
| 574 | ACPI_SIG_SSDT) | ||
| 575 | && | ||
| 576 | !ACPI_COMPARE_NAME(& | ||
| 577 | (acpi_gbl_root_table_list.tables[i]. | ||
| 578 | signature), ACPI_SIG_PSDT)) | ||
| 579 | || | ||
| 580 | ACPI_FAILURE(acpi_tb_verify_table | ||
| 581 | (&acpi_gbl_root_table_list.tables[i]))) { | ||
| 582 | continue; | ||
| 583 | } | ||
| 584 | |||
| 585 | if (no_auto_ssdt) { | ||
| 586 | printk(KERN_WARNING "ACPI: SSDT ignored due to \"acpi_no_auto_ssdt\"\n"); | ||
| 587 | continue; | ||
| 588 | } | ||
| 589 | |||
| 590 | /* Ignore errors while loading tables, get as many as possible */ | ||
| 591 | |||
| 592 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | ||
| 593 | (void)acpi_ns_load_table(i, acpi_gbl_root_node); | ||
| 594 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); | ||
| 595 | } | ||
| 596 | |||
| 597 | ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI Tables successfully acquired\n")); | ||
| 598 | |||
| 599 | unlock_and_exit: | ||
| 600 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | ||
| 601 | return_ACPI_STATUS(status); | ||
| 602 | } | ||
| 603 | |||
| 604 | /******************************************************************************* | ||
| 605 | * | ||
| 606 | * FUNCTION: acpi_load_tables | ||
| 607 | * | ||
| 608 | * PARAMETERS: None | ||
| 609 | * | ||
| 610 | * RETURN: Status | ||
| 611 | * | ||
| 612 | * DESCRIPTION: Load the ACPI tables from the RSDT/XSDT | ||
| 613 | * | ||
| 614 | ******************************************************************************/ | ||
| 615 | |||
| 616 | acpi_status acpi_load_tables(void) | ||
| 617 | { | ||
| 618 | acpi_status status; | ||
| 619 | |||
| 620 | ACPI_FUNCTION_TRACE(acpi_load_tables); | ||
| 621 | |||
| 622 | /* | ||
| 623 | * Load the namespace from the tables | ||
| 624 | */ | ||
| 625 | status = acpi_tb_load_namespace(); | ||
| 626 | if (ACPI_FAILURE(status)) { | ||
| 627 | ACPI_EXCEPTION((AE_INFO, status, | ||
| 628 | "While loading namespace from ACPI tables")); | ||
| 629 | } | ||
| 630 | |||
| 631 | return_ACPI_STATUS(status); | ||
| 632 | } | ||
| 633 | |||
| 634 | ACPI_EXPORT_SYMBOL(acpi_load_tables) | ||
| 635 | |||
| 636 | |||
| 637 | /******************************************************************************* | ||
| 638 | * | ||
| 639 | * FUNCTION: acpi_install_table_handler | ||
| 640 | * | ||
| 641 | * PARAMETERS: Handler - Table event handler | ||
| 642 | * Context - Value passed to the handler on each event | ||
| 643 | * | ||
| 644 | * RETURN: Status | ||
| 645 | * | ||
| 646 | * DESCRIPTION: Install table event handler | ||
| 647 | * | ||
| 648 | ******************************************************************************/ | ||
| 649 | acpi_status | ||
| 650 | acpi_install_table_handler(acpi_tbl_handler handler, void *context) | ||
| 651 | { | ||
| 652 | acpi_status status; | ||
| 653 | |||
| 654 | ACPI_FUNCTION_TRACE(acpi_install_table_handler); | ||
| 655 | |||
| 656 | if (!handler) { | ||
| 657 | return_ACPI_STATUS(AE_BAD_PARAMETER); | ||
| 658 | } | ||
| 659 | |||
| 660 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); | ||
| 661 | if (ACPI_FAILURE(status)) { | ||
| 662 | return_ACPI_STATUS(status); | ||
| 663 | } | ||
| 664 | |||
| 665 | /* Don't allow more than one handler */ | ||
| 666 | |||
| 667 | if (acpi_gbl_table_handler) { | ||
| 668 | status = AE_ALREADY_EXISTS; | ||
| 669 | goto cleanup; | ||
| 670 | } | ||
| 671 | |||
| 672 | /* Install the handler */ | ||
| 673 | |||
| 674 | acpi_gbl_table_handler = handler; | ||
| 675 | acpi_gbl_table_handler_context = context; | ||
| 676 | |||
| 677 | cleanup: | ||
| 678 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); | ||
| 679 | return_ACPI_STATUS(status); | ||
| 680 | } | ||
| 681 | |||
| 682 | ACPI_EXPORT_SYMBOL(acpi_install_table_handler) | ||
| 683 | |||
| 684 | /******************************************************************************* | ||
| 685 | * | ||
| 686 | * FUNCTION: acpi_remove_table_handler | ||
| 687 | * | ||
| 688 | * PARAMETERS: Handler - Table event handler that was installed | ||
| 689 | * previously. | ||
| 690 | * | ||
| 691 | * RETURN: Status | ||
| 692 | * | ||
| 693 | * DESCRIPTION: Remove table event handler | ||
| 694 | * | ||
| 695 | ******************************************************************************/ | ||
| 696 | acpi_status acpi_remove_table_handler(acpi_tbl_handler handler) | ||
| 697 | { | ||
| 698 | acpi_status status; | ||
| 699 | |||
| 700 | ACPI_FUNCTION_TRACE(acpi_remove_table_handler); | ||
| 701 | |||
| 702 | status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS); | ||
| 703 | if (ACPI_FAILURE(status)) { | ||
| 704 | return_ACPI_STATUS(status); | ||
| 705 | } | ||
| 706 | |||
| 707 | /* Make sure that the installed handler is the same */ | ||
| 708 | |||
| 709 | if (!handler || handler != acpi_gbl_table_handler) { | ||
| 710 | status = AE_BAD_PARAMETER; | ||
| 711 | goto cleanup; | ||
| 712 | } | ||
| 713 | |||
| 714 | /* Remove the handler */ | ||
| 715 | |||
| 716 | acpi_gbl_table_handler = NULL; | ||
| 717 | |||
| 718 | cleanup: | ||
| 719 | (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS); | ||
| 720 | return_ACPI_STATUS(status); | ||
| 721 | } | ||
| 722 | |||
| 723 | ACPI_EXPORT_SYMBOL(acpi_remove_table_handler) | ||
| 724 | |||
| 725 | |||
| 726 | static int __init acpi_no_auto_ssdt_setup(char *s) { | ||
| 727 | |||
| 728 | printk(KERN_NOTICE "ACPI: SSDT auto-load disabled\n"); | ||
| 729 | |||
| 730 | no_auto_ssdt = 1; | ||
| 731 | |||
| 732 | return 1; | ||
| 733 | } | ||
| 734 | |||
| 735 | __setup("acpi_no_auto_ssdt", acpi_no_auto_ssdt_setup); | ||
diff --git a/drivers/acpi/tables/tbxfroot.c b/drivers/acpi/tables/tbxfroot.c deleted file mode 100644 index 3495dca4e86b..000000000000 --- a/drivers/acpi/tables/tbxfroot.c +++ /dev/null | |||
| @@ -1,274 +0,0 @@ | |||
| 1 | /****************************************************************************** | ||
| 2 | * | ||
| 3 | * Module Name: tbxfroot - Find the root ACPI table (RSDT) | ||
| 4 | * | ||
| 5 | *****************************************************************************/ | ||
| 6 | |||
| 7 | /* | ||
| 8 | * Copyright (C) 2000 - 2008, Intel Corp. | ||
| 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 <acpi/acpi.h> | ||
| 45 | #include <acpi/accommon.h> | ||
| 46 | #include <acpi/actables.h> | ||
| 47 | |||
| 48 | #define _COMPONENT ACPI_TABLES | ||
| 49 | ACPI_MODULE_NAME("tbxfroot") | ||
| 50 | |||
| 51 | /* Local prototypes */ | ||
| 52 | static u8 *acpi_tb_scan_memory_for_rsdp(u8 * start_address, u32 length); | ||
| 53 | |||
| 54 | static acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp); | ||
| 55 | |||
| 56 | /******************************************************************************* | ||
| 57 | * | ||
| 58 | * FUNCTION: acpi_tb_validate_rsdp | ||
| 59 | * | ||
| 60 | * PARAMETERS: Rsdp - Pointer to unvalidated RSDP | ||
| 61 | * | ||
| 62 | * RETURN: Status | ||
| 63 | * | ||
| 64 | * DESCRIPTION: Validate the RSDP (ptr) | ||
| 65 | * | ||
| 66 | ******************************************************************************/ | ||
| 67 | |||
| 68 | static acpi_status acpi_tb_validate_rsdp(struct acpi_table_rsdp *rsdp) | ||
| 69 | { | ||
| 70 | ACPI_FUNCTION_ENTRY(); | ||
| 71 | |||
| 72 | /* | ||
| 73 | * The signature and checksum must both be correct | ||
| 74 | * | ||
| 75 | * Note: Sometimes there exists more than one RSDP in memory; the valid | ||
| 76 | * RSDP has a valid checksum, all others have an invalid checksum. | ||
| 77 | */ | ||
| 78 | if (ACPI_STRNCMP((char *)rsdp, ACPI_SIG_RSDP, sizeof(ACPI_SIG_RSDP) - 1) | ||
| 79 | != 0) { | ||
| 80 | |||
| 81 | /* Nope, BAD Signature */ | ||
| 82 | |||
| 83 | return (AE_BAD_SIGNATURE); | ||
| 84 | } | ||
| 85 | |||
| 86 | /* Check the standard checksum */ | ||
| 87 | |||
| 88 | if (acpi_tb_checksum((u8 *) rsdp, ACPI_RSDP_CHECKSUM_LENGTH) != 0) { | ||
| 89 | return (AE_BAD_CHECKSUM); | ||
| 90 | } | ||
| 91 | |||
| 92 | /* Check extended checksum if table version >= 2 */ | ||
| 93 | |||
| 94 | if ((rsdp->revision >= 2) && | ||
| 95 | (acpi_tb_checksum((u8 *) rsdp, ACPI_RSDP_XCHECKSUM_LENGTH) != 0)) { | ||
| 96 | return (AE_BAD_CHECKSUM); | ||
| 97 | } | ||
| 98 | |||
| 99 | return (AE_OK); | ||
| 100 | } | ||
| 101 | |||
| 102 | /******************************************************************************* | ||
| 103 | * | ||
| 104 | * FUNCTION: acpi_find_root_pointer | ||
| 105 | * | ||
| 106 | * PARAMETERS: table_address - Where the table pointer is returned | ||
| 107 | * | ||
| 108 | * RETURN: Status, RSDP physical address | ||
| 109 | * | ||
| 110 | * DESCRIPTION: Search lower 1_mbyte of memory for the root system descriptor | ||
| 111 | * pointer structure. If it is found, set *RSDP to point to it. | ||
| 112 | * | ||
| 113 | * NOTE1: The RSDP must be either in the first 1_k of the Extended | ||
| 114 | * BIOS Data Area or between E0000 and FFFFF (From ACPI Spec.) | ||
| 115 | * Only a 32-bit physical address is necessary. | ||
| 116 | * | ||
| 117 | * NOTE2: This function is always available, regardless of the | ||
| 118 | * initialization state of the rest of ACPI. | ||
| 119 | * | ||
| 120 | ******************************************************************************/ | ||
| 121 | |||
| 122 | acpi_status acpi_find_root_pointer(acpi_size *table_address) | ||
| 123 | { | ||
| 124 | u8 *table_ptr; | ||
| 125 | u8 *mem_rover; | ||
| 126 | u32 physical_address; | ||
| 127 | |||
| 128 | ACPI_FUNCTION_TRACE(acpi_find_root_pointer); | ||
| 129 | |||
| 130 | /* 1a) Get the location of the Extended BIOS Data Area (EBDA) */ | ||
| 131 | |||
| 132 | table_ptr = acpi_os_map_memory((acpi_physical_address) | ||
| 133 | ACPI_EBDA_PTR_LOCATION, | ||
| 134 | ACPI_EBDA_PTR_LENGTH); | ||
| 135 | if (!table_ptr) { | ||
| 136 | ACPI_ERROR((AE_INFO, | ||
| 137 | "Could not map memory at %8.8X for length %X", | ||
| 138 | ACPI_EBDA_PTR_LOCATION, ACPI_EBDA_PTR_LENGTH)); | ||
| 139 | |||
| 140 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
| 141 | } | ||
| 142 | |||
| 143 | ACPI_MOVE_16_TO_32(&physical_address, table_ptr); | ||
| 144 | |||
| 145 | /* Convert segment part to physical address */ | ||
| 146 | |||
| 147 | physical_address <<= 4; | ||
| 148 | acpi_os_unmap_memory(table_ptr, ACPI_EBDA_PTR_LENGTH); | ||
| 149 | |||
| 150 | /* EBDA present? */ | ||
| 151 | |||
| 152 | if (physical_address > 0x400) { | ||
| 153 | /* | ||
| 154 | * 1b) Search EBDA paragraphs (EBDA is required to be a | ||
| 155 | * minimum of 1_k length) | ||
| 156 | */ | ||
| 157 | table_ptr = acpi_os_map_memory((acpi_physical_address) | ||
| 158 | physical_address, | ||
| 159 | ACPI_EBDA_WINDOW_SIZE); | ||
| 160 | if (!table_ptr) { | ||
| 161 | ACPI_ERROR((AE_INFO, | ||
| 162 | "Could not map memory at %8.8X for length %X", | ||
| 163 | physical_address, ACPI_EBDA_WINDOW_SIZE)); | ||
| 164 | |||
| 165 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
| 166 | } | ||
| 167 | |||
| 168 | mem_rover = | ||
| 169 | acpi_tb_scan_memory_for_rsdp(table_ptr, | ||
| 170 | ACPI_EBDA_WINDOW_SIZE); | ||
| 171 | acpi_os_unmap_memory(table_ptr, ACPI_EBDA_WINDOW_SIZE); | ||
| 172 | |||
| 173 | if (mem_rover) { | ||
| 174 | |||
| 175 | /* Return the physical address */ | ||
| 176 | |||
| 177 | physical_address += | ||
| 178 | (u32) ACPI_PTR_DIFF(mem_rover, table_ptr); | ||
| 179 | |||
| 180 | *table_address = physical_address; | ||
| 181 | return_ACPI_STATUS(AE_OK); | ||
| 182 | } | ||
| 183 | } | ||
| 184 | |||
| 185 | /* | ||
| 186 | * 2) Search upper memory: 16-byte boundaries in E0000h-FFFFFh | ||
| 187 | */ | ||
| 188 | table_ptr = acpi_os_map_memory((acpi_physical_address) | ||
| 189 | ACPI_HI_RSDP_WINDOW_BASE, | ||
| 190 | ACPI_HI_RSDP_WINDOW_SIZE); | ||
| 191 | |||
| 192 | if (!table_ptr) { | ||
| 193 | ACPI_ERROR((AE_INFO, | ||
| 194 | "Could not map memory at %8.8X for length %X", | ||
| 195 | ACPI_HI_RSDP_WINDOW_BASE, | ||
| 196 | ACPI_HI_RSDP_WINDOW_SIZE)); | ||
| 197 | |||
| 198 | return_ACPI_STATUS(AE_NO_MEMORY); | ||
| 199 | } | ||
| 200 | |||
| 201 | mem_rover = | ||
| 202 | acpi_tb_scan_memory_for_rsdp(table_ptr, ACPI_HI_RSDP_WINDOW_SIZE); | ||
| 203 | acpi_os_unmap_memory(table_ptr, ACPI_HI_RSDP_WINDOW_SIZE); | ||
| 204 | |||
| 205 | if (mem_rover) { | ||
| 206 | |||
| 207 | /* Return the physical address */ | ||
| 208 | |||
| 209 | physical_address = (u32) | ||
| 210 | (ACPI_HI_RSDP_WINDOW_BASE + | ||
| 211 | ACPI_PTR_DIFF(mem_rover, table_ptr)); | ||
| 212 | |||
| 213 | *table_address = physical_address; | ||
| 214 | return_ACPI_STATUS(AE_OK); | ||
| 215 | } | ||
| 216 | |||
| 217 | /* A valid RSDP was not found */ | ||
| 218 | |||
| 219 | ACPI_ERROR((AE_INFO, "A valid RSDP was not found")); | ||
| 220 | return_ACPI_STATUS(AE_NOT_FOUND); | ||
| 221 | } | ||
| 222 | |||
| 223 | /******************************************************************************* | ||
| 224 | * | ||
| 225 | * FUNCTION: acpi_tb_scan_memory_for_rsdp | ||
| 226 | * | ||
| 227 | * PARAMETERS: start_address - Starting pointer for search | ||
| 228 | * Length - Maximum length to search | ||
| 229 | * | ||
| 230 | * RETURN: Pointer to the RSDP if found, otherwise NULL. | ||
| 231 | * | ||
| 232 | * DESCRIPTION: Search a block of memory for the RSDP signature | ||
| 233 | * | ||
| 234 | ******************************************************************************/ | ||
| 235 | static u8 *acpi_tb_scan_memory_for_rsdp(u8 * start_address, u32 length) | ||
| 236 | { | ||
| 237 | acpi_status status; | ||
| 238 | u8 *mem_rover; | ||
| 239 | u8 *end_address; | ||
| 240 | |||
| 241 | ACPI_FUNCTION_TRACE(tb_scan_memory_for_rsdp); | ||
| 242 | |||
| 243 | end_address = start_address + length; | ||
| 244 | |||
| 245 | /* Search from given start address for the requested length */ | ||
| 246 | |||
| 247 | for (mem_rover = start_address; mem_rover < end_address; | ||
| 248 | mem_rover += ACPI_RSDP_SCAN_STEP) { | ||
| 249 | |||
| 250 | /* The RSDP signature and checksum must both be correct */ | ||
| 251 | |||
| 252 | status = | ||
| 253 | acpi_tb_validate_rsdp(ACPI_CAST_PTR | ||
| 254 | (struct acpi_table_rsdp, mem_rover)); | ||
| 255 | if (ACPI_SUCCESS(status)) { | ||
| 256 | |||
| 257 | /* Sig and checksum valid, we have found a real RSDP */ | ||
| 258 | |||
| 259 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
| 260 | "RSDP located at physical address %p\n", | ||
| 261 | mem_rover)); | ||
| 262 | return_PTR(mem_rover); | ||
| 263 | } | ||
| 264 | |||
| 265 | /* No sig match or bad checksum, keep searching */ | ||
| 266 | } | ||
| 267 | |||
| 268 | /* Searched entire block, no RSDP was found */ | ||
| 269 | |||
| 270 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, | ||
| 271 | "Searched entire block from %p, valid RSDP was not found\n", | ||
| 272 | start_address)); | ||
| 273 | return_PTR(NULL); | ||
| 274 | } | ||
