Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Module Name: tbinstal - ACPI table installation and removal |
| 4 | * |
| 5 | *****************************************************************************/ |
| 6 | |
| 7 | /* |
Bob Moore | fbb7a2d | 2014-02-08 09:42:25 +0800 | [diff] [blame] | 8 | * Copyright (C) 2000 - 2014, Intel Corp. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * All rights reserved. |
| 10 | * |
| 11 | * Redistribution and use in source and binary forms, with or without |
| 12 | * modification, are permitted provided that the following conditions |
| 13 | * are met: |
| 14 | * 1. Redistributions of source code must retain the above copyright |
| 15 | * notice, this list of conditions, and the following disclaimer, |
| 16 | * without modification. |
| 17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer |
| 18 | * substantially similar to the "NO WARRANTY" disclaimer below |
| 19 | * ("Disclaimer") and any redistribution must be conditioned upon |
| 20 | * including a substantially similar Disclaimer requirement for further |
| 21 | * binary redistribution. |
| 22 | * 3. Neither the names of the above-listed copyright holders nor the names |
| 23 | * of any contributors may be used to endorse or promote products derived |
| 24 | * from this software without specific prior written permission. |
| 25 | * |
| 26 | * Alternatively, this software may be distributed under the terms of the |
| 27 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 28 | * Software Foundation. |
| 29 | * |
| 30 | * NO WARRANTY |
| 31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR |
| 34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING |
| 40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 41 | * POSSIBILITY OF SUCH DAMAGES. |
| 42 | */ |
| 43 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 44 | #include <acpi/acpi.h> |
Len Brown | e2f7a77 | 2009-01-09 00:30:03 -0500 | [diff] [blame] | 45 | #include "accommon.h" |
Len Brown | e2f7a77 | 2009-01-09 00:30:03 -0500 | [diff] [blame] | 46 | #include "actables.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | #define _COMPONENT ACPI_TABLES |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 49 | ACPI_MODULE_NAME("tbinstal") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 51 | /* Local prototypes */ |
Bob Moore | c418ce1 | 2014-04-04 12:39:34 +0800 | [diff] [blame] | 52 | static u8 |
| 53 | acpi_tb_compare_tables(struct acpi_table_desc *table_desc, u32 table_index); |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 54 | |
Bob Moore | c418ce1 | 2014-04-04 12:39:34 +0800 | [diff] [blame] | 55 | /******************************************************************************* |
| 56 | * |
| 57 | * FUNCTION: acpi_tb_compare_tables |
| 58 | * |
| 59 | * PARAMETERS: table_desc - Table 1 descriptor to be compared |
| 60 | * table_index - Index of table 2 to be compared |
| 61 | * |
| 62 | * RETURN: TRUE if both tables are identical. |
| 63 | * |
| 64 | * DESCRIPTION: This function compares a table with another table that has |
| 65 | * already been installed in the root table list. |
| 66 | * |
| 67 | ******************************************************************************/ |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 68 | |
| 69 | static u8 |
Bob Moore | c418ce1 | 2014-04-04 12:39:34 +0800 | [diff] [blame] | 70 | acpi_tb_compare_tables(struct acpi_table_desc *table_desc, u32 table_index) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | { |
Alexey Starikovskiy | 428f211 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 72 | acpi_status status = AE_OK; |
Bob Moore | c418ce1 | 2014-04-04 12:39:34 +0800 | [diff] [blame] | 73 | u8 is_identical; |
| 74 | struct acpi_table_header *table; |
| 75 | u32 table_length; |
| 76 | u8 table_flags; |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 77 | |
| 78 | status = |
Bob Moore | c418ce1 | 2014-04-04 12:39:34 +0800 | [diff] [blame] | 79 | acpi_tb_acquire_table(&acpi_gbl_root_table_list.tables[table_index], |
| 80 | &table, &table_length, &table_flags); |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 81 | if (ACPI_FAILURE(status)) { |
Bob Moore | c418ce1 | 2014-04-04 12:39:34 +0800 | [diff] [blame] | 82 | return (FALSE); |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 83 | } |
| 84 | |
Bob Moore | bc45b1d | 2008-06-10 14:12:50 +0800 | [diff] [blame] | 85 | /* |
Bob Moore | c418ce1 | 2014-04-04 12:39:34 +0800 | [diff] [blame] | 86 | * Check for a table match on the entire table length, |
| 87 | * not just the header. |
Bob Moore | bc45b1d | 2008-06-10 14:12:50 +0800 | [diff] [blame] | 88 | */ |
Bob Moore | c418ce1 | 2014-04-04 12:39:34 +0800 | [diff] [blame] | 89 | is_identical = (u8)((table_desc->length != table_length || |
| 90 | ACPI_MEMCMP(table_desc->pointer, table, |
| 91 | table_length)) ? FALSE : TRUE); |
Bob Moore | c8cefe3 | 2011-06-14 10:42:53 +0800 | [diff] [blame] | 92 | |
Bob Moore | c418ce1 | 2014-04-04 12:39:34 +0800 | [diff] [blame] | 93 | /* Release the acquired table */ |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 94 | |
Bob Moore | c418ce1 | 2014-04-04 12:39:34 +0800 | [diff] [blame] | 95 | acpi_tb_release_table(table, table_length, table_flags); |
| 96 | return (is_identical); |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 97 | } |
Bob Moore | e56f561 | 2008-07-04 10:48:43 +0800 | [diff] [blame] | 98 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 99 | /******************************************************************************* |
| 100 | * |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 101 | * FUNCTION: acpi_tb_install_table_with_override |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 102 | * |
| 103 | * PARAMETERS: table_index - Index into root table array |
| 104 | * new_table_desc - New table descriptor to install |
Lv Zheng | caf4a15 | 2014-04-04 12:39:18 +0800 | [diff] [blame] | 105 | * override - Whether override should be performed |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 106 | * |
| 107 | * RETURN: None |
| 108 | * |
| 109 | * DESCRIPTION: Install an ACPI table into the global data structure. The |
| 110 | * table override mechanism is called to allow the host |
| 111 | * OS to replace any table before it is installed in the root |
| 112 | * table array. |
| 113 | * |
| 114 | ******************************************************************************/ |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 115 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 116 | void |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 117 | acpi_tb_install_table_with_override(u32 table_index, |
| 118 | struct acpi_table_desc *new_table_desc, |
| 119 | u8 override) |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 120 | { |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 121 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 122 | if (table_index >= acpi_gbl_root_table_list.current_table_count) { |
| 123 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 124 | } |
| 125 | |
Bob Moore | d3ccaff | 2009-02-03 14:43:04 +0800 | [diff] [blame] | 126 | /* |
| 127 | * ACPI Table Override: |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 128 | * |
| 129 | * Before we install the table, let the host OS override it with a new |
| 130 | * one if desired. Any table within the RSDT/XSDT can be replaced, |
| 131 | * including the DSDT which is pointed to by the FADT. |
Bob Moore | d3ccaff | 2009-02-03 14:43:04 +0800 | [diff] [blame] | 132 | */ |
Lv Zheng | caf4a15 | 2014-04-04 12:39:18 +0800 | [diff] [blame] | 133 | if (override) { |
| 134 | acpi_tb_override_table(new_table_desc); |
| 135 | } |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 136 | |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 137 | acpi_tb_init_table_descriptor(&acpi_gbl_root_table_list. |
| 138 | tables[table_index], |
| 139 | new_table_desc->address, |
| 140 | new_table_desc->flags, |
| 141 | new_table_desc->pointer); |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 142 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 143 | acpi_tb_print_table_header(new_table_desc->address, |
| 144 | new_table_desc->pointer); |
| 145 | |
| 146 | /* Set the global integer width (based upon revision of the DSDT) */ |
| 147 | |
| 148 | if (table_index == ACPI_TABLE_INDEX_DSDT) { |
| 149 | acpi_ut_set_integer_width(new_table_desc->pointer->revision); |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | /******************************************************************************* |
| 154 | * |
| 155 | * FUNCTION: acpi_tb_install_fixed_table |
| 156 | * |
| 157 | * PARAMETERS: address - Physical address of DSDT or FACS |
| 158 | * signature - Table signature, NULL if no need to |
| 159 | * match |
| 160 | * table_index - Index into root table array |
| 161 | * |
| 162 | * RETURN: Status |
| 163 | * |
| 164 | * DESCRIPTION: Install a fixed ACPI table (DSDT/FACS) into the global data |
| 165 | * structure. |
| 166 | * |
| 167 | ******************************************************************************/ |
| 168 | |
| 169 | acpi_status |
| 170 | acpi_tb_install_fixed_table(acpi_physical_address address, |
| 171 | char *signature, u32 table_index) |
| 172 | { |
| 173 | struct acpi_table_desc new_table_desc; |
| 174 | acpi_status status; |
| 175 | |
| 176 | ACPI_FUNCTION_TRACE(tb_install_fixed_table); |
| 177 | |
| 178 | if (!address) { |
| 179 | ACPI_ERROR((AE_INFO, |
| 180 | "Null physical address for ACPI table [%s]", |
| 181 | signature)); |
| 182 | return (AE_NO_MEMORY); |
| 183 | } |
| 184 | |
| 185 | /* Fill a table descriptor for validation */ |
| 186 | |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 187 | status = acpi_tb_acquire_temp_table(&new_table_desc, address, |
| 188 | ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL); |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 189 | if (ACPI_FAILURE(status)) { |
| 190 | ACPI_ERROR((AE_INFO, "Could not acquire table length at %p", |
| 191 | ACPI_CAST_PTR(void, address))); |
| 192 | return_ACPI_STATUS(status); |
| 193 | } |
| 194 | |
| 195 | /* Validate and verify a table before installation */ |
| 196 | |
Lv Zheng | 47d68c7 | 2014-05-31 08:14:44 +0800 | [diff] [blame^] | 197 | status = acpi_tb_verify_temp_table(&new_table_desc, signature); |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 198 | if (ACPI_FAILURE(status)) { |
| 199 | goto release_and_exit; |
| 200 | } |
| 201 | |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 202 | acpi_tb_install_table_with_override(table_index, &new_table_desc, TRUE); |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 203 | |
| 204 | release_and_exit: |
| 205 | |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 206 | /* Release the temporary table descriptor */ |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 207 | |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 208 | acpi_tb_release_temp_table(&new_table_desc); |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 209 | return_ACPI_STATUS(status); |
| 210 | } |
| 211 | |
| 212 | /******************************************************************************* |
| 213 | * |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 214 | * FUNCTION: acpi_tb_install_standard_table |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 215 | * |
Lv Zheng | 8a216d7 | 2014-04-04 12:39:04 +0800 | [diff] [blame] | 216 | * PARAMETERS: address - Address of the table (might be a virtual |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 217 | * address depending on the table_flags) |
| 218 | * flags - Flags for the table |
| 219 | * reload - Whether reload should be performed |
Lv Zheng | caf4a15 | 2014-04-04 12:39:18 +0800 | [diff] [blame] | 220 | * override - Whether override should be performed |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 221 | * table_index - Where the table index is returned |
| 222 | * |
| 223 | * RETURN: Status |
| 224 | * |
| 225 | * DESCRIPTION: This function is called to install an ACPI table that is |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 226 | * neither DSDT nor FACS (a "standard" table.) |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 227 | * When this function is called by "Load" or "LoadTable" opcodes, |
| 228 | * or by acpi_load_table() API, the "Reload" parameter is set. |
| 229 | * After sucessfully returning from this function, table is |
| 230 | * "INSTALLED" but not "VALIDATED". |
| 231 | * |
| 232 | ******************************************************************************/ |
| 233 | |
| 234 | acpi_status |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 235 | acpi_tb_install_standard_table(acpi_physical_address address, |
| 236 | u8 flags, |
| 237 | u8 reload, u8 override, u32 *table_index) |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 238 | { |
| 239 | u32 i; |
| 240 | acpi_status status = AE_OK; |
| 241 | struct acpi_table_desc new_table_desc; |
| 242 | |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 243 | ACPI_FUNCTION_TRACE(tb_install_standard_table); |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 244 | |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 245 | /* Acquire a temporary table descriptor for validation */ |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 246 | |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 247 | status = acpi_tb_acquire_temp_table(&new_table_desc, address, flags); |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 248 | if (ACPI_FAILURE(status)) { |
| 249 | ACPI_ERROR((AE_INFO, "Could not acquire table length at %p", |
| 250 | ACPI_CAST_PTR(void, address))); |
| 251 | return_ACPI_STATUS(status); |
| 252 | } |
| 253 | |
Lv Zheng | a94e88c | 2014-04-04 12:39:11 +0800 | [diff] [blame] | 254 | /* |
| 255 | * Optionally do not load any SSDTs from the RSDT/XSDT. This can |
| 256 | * be useful for debugging ACPI problems on some machines. |
| 257 | */ |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 258 | if (!reload && |
| 259 | acpi_gbl_disable_ssdt_table_install && |
Lv Zheng | a94e88c | 2014-04-04 12:39:11 +0800 | [diff] [blame] | 260 | ACPI_COMPARE_NAME(&new_table_desc.signature, ACPI_SIG_SSDT)) { |
| 261 | ACPI_INFO((AE_INFO, "Ignoring installation of %4.4s at %p", |
| 262 | new_table_desc.signature.ascii, ACPI_CAST_PTR(void, |
| 263 | address))); |
| 264 | goto release_and_exit; |
| 265 | } |
| 266 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 267 | /* Validate and verify a table before installation */ |
| 268 | |
Lv Zheng | 47d68c7 | 2014-05-31 08:14:44 +0800 | [diff] [blame^] | 269 | status = acpi_tb_verify_temp_table(&new_table_desc, NULL); |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 270 | if (ACPI_FAILURE(status)) { |
| 271 | goto release_and_exit; |
| 272 | } |
| 273 | |
| 274 | if (reload) { |
| 275 | /* |
| 276 | * Validate the incoming table signature. |
| 277 | * |
| 278 | * 1) Originally, we checked the table signature for "SSDT" or "PSDT". |
| 279 | * 2) We added support for OEMx tables, signature "OEM". |
| 280 | * 3) Valid tables were encountered with a null signature, so we just |
| 281 | * gave up on validating the signature, (05/2008). |
| 282 | * 4) We encountered non-AML tables such as the MADT, which caused |
| 283 | * interpreter errors and kernel faults. So now, we once again allow |
| 284 | * only "SSDT", "OEMx", and now, also a null signature. (05/2011). |
| 285 | */ |
| 286 | if ((new_table_desc.signature.ascii[0] != 0x00) && |
| 287 | (!ACPI_COMPARE_NAME |
| 288 | (&new_table_desc.signature, ACPI_SIG_SSDT)) |
| 289 | && (ACPI_STRNCMP(new_table_desc.signature.ascii, "OEM", 3))) |
| 290 | { |
| 291 | ACPI_BIOS_ERROR((AE_INFO, |
| 292 | "Table has invalid signature [%4.4s] (0x%8.8X), " |
| 293 | "must be SSDT or OEMx", |
| 294 | acpi_ut_valid_acpi_name(new_table_desc. |
| 295 | signature. |
| 296 | ascii) ? |
| 297 | new_table_desc.signature. |
| 298 | ascii : "????", |
| 299 | new_table_desc.signature.integer)); |
| 300 | |
| 301 | status = AE_BAD_SIGNATURE; |
| 302 | goto release_and_exit; |
| 303 | } |
| 304 | |
| 305 | /* Check if table is already registered */ |
| 306 | |
| 307 | for (i = 0; i < acpi_gbl_root_table_list.current_table_count; |
| 308 | ++i) { |
| 309 | /* |
| 310 | * Check for a table match on the entire table length, |
| 311 | * not just the header. |
| 312 | */ |
Bob Moore | c418ce1 | 2014-04-04 12:39:34 +0800 | [diff] [blame] | 313 | if (!acpi_tb_compare_tables(&new_table_desc, i)) { |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 314 | continue; |
| 315 | } |
| 316 | |
| 317 | /* |
| 318 | * Note: the current mechanism does not unregister a table if it is |
| 319 | * dynamically unloaded. The related namespace entries are deleted, |
| 320 | * but the table remains in the root table list. |
| 321 | * |
| 322 | * The assumption here is that the number of different tables that |
| 323 | * will be loaded is actually small, and there is minimal overhead |
| 324 | * in just keeping the table in case it is needed again. |
| 325 | * |
| 326 | * If this assumption changes in the future (perhaps on large |
| 327 | * machines with many table load/unload operations), tables will |
| 328 | * need to be unregistered when they are unloaded, and slots in the |
| 329 | * root table list should be reused when empty. |
| 330 | */ |
| 331 | if (acpi_gbl_root_table_list.tables[i]. |
| 332 | flags & ACPI_TABLE_IS_LOADED) { |
| 333 | |
| 334 | /* Table is still loaded, this is an error */ |
| 335 | |
| 336 | status = AE_ALREADY_EXISTS; |
| 337 | goto release_and_exit; |
| 338 | } else { |
| 339 | /* |
| 340 | * Table was unloaded, allow it to be reloaded. |
| 341 | * As we are going to return AE_OK to the caller, we should |
| 342 | * take the responsibility of freeing the input descriptor. |
| 343 | * Refill the input descriptor to ensure |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 344 | * acpi_tb_install_table_with_override() can be called again to |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 345 | * indicate the re-installation. |
| 346 | */ |
| 347 | acpi_tb_uninstall_table(&new_table_desc); |
| 348 | *table_index = i; |
| 349 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
| 350 | return_ACPI_STATUS(AE_OK); |
| 351 | } |
| 352 | } |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 353 | } |
Bob Moore | d3ccaff | 2009-02-03 14:43:04 +0800 | [diff] [blame] | 354 | |
Bob Moore | e56f561 | 2008-07-04 10:48:43 +0800 | [diff] [blame] | 355 | /* Add the table to the global root table list */ |
| 356 | |
Bob Moore | c418ce1 | 2014-04-04 12:39:34 +0800 | [diff] [blame] | 357 | status = acpi_tb_get_next_root_index(&i); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 358 | if (ACPI_FAILURE(status)) { |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 359 | goto release_and_exit; |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 360 | } |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 361 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 362 | *table_index = i; |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 363 | acpi_tb_install_table_with_override(i, &new_table_desc, override); |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 364 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 365 | release_and_exit: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 366 | |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 367 | /* Release the temporary table descriptor */ |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 368 | |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 369 | acpi_tb_release_temp_table(&new_table_desc); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 370 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | } |
| 372 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 373 | /******************************************************************************* |
| 374 | * |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 375 | * FUNCTION: acpi_tb_override_table |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 376 | * |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 377 | * PARAMETERS: old_table_desc - Validated table descriptor to be |
| 378 | * overridden |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 379 | * |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 380 | * RETURN: None |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 381 | * |
| 382 | * DESCRIPTION: Attempt table override by calling the OSL override functions. |
| 383 | * Note: If the table is overridden, then the entire new table |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 384 | * is acquired and returned by this function. |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 385 | * Before/after invocation, the table descriptor is in a state |
| 386 | * that is "VALIDATED". |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 387 | * |
| 388 | ******************************************************************************/ |
| 389 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 390 | void acpi_tb_override_table(struct acpi_table_desc *old_table_desc) |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 391 | { |
| 392 | acpi_status status; |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 393 | char *override_type; |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 394 | struct acpi_table_desc new_table_desc; |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 395 | struct acpi_table_header *table; |
| 396 | acpi_physical_address address; |
| 397 | u32 length; |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 398 | |
| 399 | /* (1) Attempt logical override (returns a logical address) */ |
| 400 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 401 | status = acpi_os_table_override(old_table_desc->pointer, &table); |
| 402 | if (ACPI_SUCCESS(status) && table) { |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 403 | acpi_tb_acquire_temp_table(&new_table_desc, |
| 404 | ACPI_PTR_TO_PHYSADDR(table), |
| 405 | ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL); |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 406 | override_type = "Logical"; |
| 407 | goto finish_override; |
| 408 | } |
| 409 | |
| 410 | /* (2) Attempt physical override (returns a physical address) */ |
| 411 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 412 | status = acpi_os_physical_table_override(old_table_desc->pointer, |
| 413 | &address, &length); |
| 414 | if (ACPI_SUCCESS(status) && address && length) { |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 415 | acpi_tb_acquire_temp_table(&new_table_desc, address, |
| 416 | ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL); |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 417 | override_type = "Physical"; |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 418 | goto finish_override; |
| 419 | } |
| 420 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 421 | return; /* There was no override */ |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 422 | |
Lv Zheng | 10622bf | 2013-10-29 09:30:02 +0800 | [diff] [blame] | 423 | finish_override: |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 424 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 425 | /* Validate and verify a table before overriding */ |
| 426 | |
Lv Zheng | 47d68c7 | 2014-05-31 08:14:44 +0800 | [diff] [blame^] | 427 | status = acpi_tb_verify_temp_table(&new_table_desc, NULL); |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 428 | if (ACPI_FAILURE(status)) { |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 429 | return; |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 430 | } |
| 431 | |
Bob Moore | 2e19f8d | 2014-02-08 09:42:07 +0800 | [diff] [blame] | 432 | ACPI_INFO((AE_INFO, "%4.4s " ACPI_PRINTF_UINT |
| 433 | " %s table override, new table: " ACPI_PRINTF_UINT, |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 434 | old_table_desc->signature.ascii, |
| 435 | ACPI_FORMAT_TO_UINT(old_table_desc->address), |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 436 | override_type, ACPI_FORMAT_TO_UINT(new_table_desc.address))); |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 437 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 438 | /* We can now uninstall the original table */ |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 439 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 440 | acpi_tb_uninstall_table(old_table_desc); |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 441 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 442 | /* |
| 443 | * Replace the original table descriptor and keep its state as |
| 444 | * "VALIDATED". |
| 445 | */ |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 446 | acpi_tb_init_table_descriptor(old_table_desc, new_table_desc.address, |
| 447 | new_table_desc.flags, |
| 448 | new_table_desc.pointer); |
Lv Zheng | 47d68c7 | 2014-05-31 08:14:44 +0800 | [diff] [blame^] | 449 | acpi_tb_validate_temp_table(old_table_desc); |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 450 | |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 451 | /* Release the temporary table descriptor */ |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 452 | |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 453 | acpi_tb_release_temp_table(&new_table_desc); |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 454 | } |
| 455 | |
| 456 | /******************************************************************************* |
| 457 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 458 | * FUNCTION: acpi_tb_store_table |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | * |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 460 | * PARAMETERS: address - Table address |
| 461 | * table - Table header |
| 462 | * length - Table length |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 463 | * flags - Install flags |
| 464 | * table_index - Where the table index is returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 466 | * RETURN: Status and table index. |
| 467 | * |
| 468 | * DESCRIPTION: Add an ACPI table to the global table list |
| 469 | * |
| 470 | ******************************************************************************/ |
| 471 | |
| 472 | acpi_status |
| 473 | acpi_tb_store_table(acpi_physical_address address, |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 474 | struct acpi_table_header * table, |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 475 | u32 length, u8 flags, u32 *table_index) |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 476 | { |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 477 | acpi_status status; |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 478 | struct acpi_table_desc *table_desc; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 479 | |
Bob Moore | c418ce1 | 2014-04-04 12:39:34 +0800 | [diff] [blame] | 480 | status = acpi_tb_get_next_root_index(table_index); |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 481 | if (ACPI_FAILURE(status)) { |
| 482 | return (status); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 483 | } |
| 484 | |
| 485 | /* Initialize added table */ |
| 486 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 487 | table_desc = &acpi_gbl_root_table_list.tables[*table_index]; |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 488 | acpi_tb_init_table_descriptor(table_desc, address, flags, table); |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 489 | table_desc->pointer = table; |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 490 | return (AE_OK); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 491 | } |
| 492 | |
| 493 | /******************************************************************************* |
| 494 | * |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 495 | * FUNCTION: acpi_tb_uninstall_table |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 496 | * |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 497 | * PARAMETERS: table_desc - Table descriptor |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 498 | * |
| 499 | * RETURN: None |
| 500 | * |
| 501 | * DESCRIPTION: Delete one internal ACPI table |
| 502 | * |
| 503 | ******************************************************************************/ |
| 504 | |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 505 | void acpi_tb_uninstall_table(struct acpi_table_desc *table_desc) |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 506 | { |
Lv Zheng | 5582982 | 2014-04-04 12:38:18 +0800 | [diff] [blame] | 507 | |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 508 | ACPI_FUNCTION_TRACE(tb_uninstall_table); |
Lv Zheng | 5582982 | 2014-04-04 12:38:18 +0800 | [diff] [blame] | 509 | |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 510 | /* Table must be installed */ |
| 511 | |
| 512 | if (!table_desc->address) { |
| 513 | return_VOID; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 514 | } |
Lv Zheng | 5582982 | 2014-04-04 12:38:18 +0800 | [diff] [blame] | 515 | |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 516 | acpi_tb_invalidate_table(table_desc); |
Chao Guan | 1d1ea1b | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 517 | |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 518 | if ((table_desc->flags & ACPI_TABLE_ORIGIN_MASK) == |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 519 | ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL) { |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 520 | ACPI_FREE(ACPI_CAST_PTR(void, table_desc->address)); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 521 | } |
| 522 | |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 523 | table_desc->address = ACPI_PTR_TO_PHYSADDR(NULL); |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 524 | return_VOID; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 525 | } |