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 | 7735ca0 | 2017-02-08 11:00:08 +0800 | [diff] [blame] | 8 | * Copyright (C) 2000 - 2017, 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 || |
Bob Moore | 4fa4616 | 2015-07-01 14:45:11 +0800 | [diff] [blame] | 90 | memcmp(table_desc->pointer, table, table_length)) ? |
| 91 | 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 | * |
Lv Zheng | 8ec3f45 | 2015-08-25 10:29:01 +0800 | [diff] [blame] | 103 | * PARAMETERS: new_table_desc - New table descriptor to install |
Lv Zheng | caf4a15 | 2014-04-04 12:39:18 +0800 | [diff] [blame] | 104 | * override - Whether override should be performed |
Lv Zheng | 8ec3f45 | 2015-08-25 10:29:01 +0800 | [diff] [blame] | 105 | * table_index - Where the table index is returned |
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 |
Lv Zheng | 8ec3f45 | 2015-08-25 10:29:01 +0800 | [diff] [blame] | 117 | acpi_tb_install_table_with_override(struct acpi_table_desc *new_table_desc, |
| 118 | u8 override, u32 *table_index) |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 119 | { |
Lv Zheng | 8ec3f45 | 2015-08-25 10:29:01 +0800 | [diff] [blame] | 120 | u32 i; |
| 121 | acpi_status status; |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 122 | |
Lv Zheng | 8ec3f45 | 2015-08-25 10:29:01 +0800 | [diff] [blame] | 123 | status = acpi_tb_get_next_table_descriptor(&i, NULL); |
| 124 | if (ACPI_FAILURE(status)) { |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 125 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | } |
| 127 | |
Bob Moore | d3ccaff | 2009-02-03 14:43:04 +0800 | [diff] [blame] | 128 | /* |
| 129 | * ACPI Table Override: |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 130 | * |
| 131 | * Before we install the table, let the host OS override it with a new |
| 132 | * one if desired. Any table within the RSDT/XSDT can be replaced, |
| 133 | * including the DSDT which is pointed to by the FADT. |
Bob Moore | d3ccaff | 2009-02-03 14:43:04 +0800 | [diff] [blame] | 134 | */ |
Lv Zheng | caf4a15 | 2014-04-04 12:39:18 +0800 | [diff] [blame] | 135 | if (override) { |
| 136 | acpi_tb_override_table(new_table_desc); |
| 137 | } |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 138 | |
Lv Zheng | 8ec3f45 | 2015-08-25 10:29:01 +0800 | [diff] [blame] | 139 | acpi_tb_init_table_descriptor(&acpi_gbl_root_table_list.tables[i], |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 140 | new_table_desc->address, |
| 141 | new_table_desc->flags, |
| 142 | new_table_desc->pointer); |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 143 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 144 | acpi_tb_print_table_header(new_table_desc->address, |
| 145 | new_table_desc->pointer); |
| 146 | |
Lv Zheng | 8ec3f45 | 2015-08-25 10:29:01 +0800 | [diff] [blame] | 147 | /* This synchronizes acpi_gbl_dsdt_index */ |
| 148 | |
| 149 | *table_index = i; |
| 150 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 151 | /* Set the global integer width (based upon revision of the DSDT) */ |
| 152 | |
Lv Zheng | 8ec3f45 | 2015-08-25 10:29:01 +0800 | [diff] [blame] | 153 | if (i == acpi_gbl_dsdt_index) { |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 154 | acpi_ut_set_integer_width(new_table_desc->pointer->revision); |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | /******************************************************************************* |
| 159 | * |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 160 | * FUNCTION: acpi_tb_install_standard_table |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 161 | * |
Lv Zheng | 8a216d7 | 2014-04-04 12:39:04 +0800 | [diff] [blame] | 162 | * PARAMETERS: address - Address of the table (might be a virtual |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 163 | * address depending on the table_flags) |
| 164 | * flags - Flags for the table |
| 165 | * reload - Whether reload should be performed |
Lv Zheng | caf4a15 | 2014-04-04 12:39:18 +0800 | [diff] [blame] | 166 | * override - Whether override should be performed |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 167 | * table_index - Where the table index is returned |
| 168 | * |
| 169 | * RETURN: Status |
| 170 | * |
Lv Zheng | 752db10 | 2016-09-07 14:06:17 +0800 | [diff] [blame] | 171 | * DESCRIPTION: This function is called to verify and install an ACPI table. |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 172 | * When this function is called by "Load" or "LoadTable" opcodes, |
| 173 | * or by acpi_load_table() API, the "Reload" parameter is set. |
| 174 | * After sucessfully returning from this function, table is |
| 175 | * "INSTALLED" but not "VALIDATED". |
| 176 | * |
| 177 | ******************************************************************************/ |
| 178 | |
| 179 | acpi_status |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 180 | acpi_tb_install_standard_table(acpi_physical_address address, |
| 181 | u8 flags, |
| 182 | u8 reload, u8 override, u32 *table_index) |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 183 | { |
| 184 | u32 i; |
| 185 | acpi_status status = AE_OK; |
| 186 | struct acpi_table_desc new_table_desc; |
| 187 | |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 188 | ACPI_FUNCTION_TRACE(tb_install_standard_table); |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 189 | |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 190 | /* Acquire a temporary table descriptor for validation */ |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 191 | |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 192 | status = acpi_tb_acquire_temp_table(&new_table_desc, address, flags); |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 193 | if (ACPI_FAILURE(status)) { |
Lv Zheng | cc2080b | 2015-04-13 11:48:46 +0800 | [diff] [blame] | 194 | ACPI_ERROR((AE_INFO, |
| 195 | "Could not acquire table length at %8.8X%8.8X", |
| 196 | ACPI_FORMAT_UINT64(address))); |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 197 | return_ACPI_STATUS(status); |
| 198 | } |
| 199 | |
Lv Zheng | a94e88c | 2014-04-04 12:39:11 +0800 | [diff] [blame] | 200 | /* |
| 201 | * Optionally do not load any SSDTs from the RSDT/XSDT. This can |
| 202 | * be useful for debugging ACPI problems on some machines. |
| 203 | */ |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 204 | if (!reload && |
| 205 | acpi_gbl_disable_ssdt_table_install && |
Lv Zheng | a94e88c | 2014-04-04 12:39:11 +0800 | [diff] [blame] | 206 | ACPI_COMPARE_NAME(&new_table_desc.signature, ACPI_SIG_SSDT)) { |
Bob Moore | 05fb04b | 2016-02-19 14:16:42 +0800 | [diff] [blame] | 207 | ACPI_INFO(("Ignoring installation of %4.4s at %8.8X%8.8X", |
Lv Zheng | 6d3fd3c | 2015-04-13 11:48:37 +0800 | [diff] [blame] | 208 | new_table_desc.signature.ascii, |
Lv Zheng | cc2080b | 2015-04-13 11:48:46 +0800 | [diff] [blame] | 209 | ACPI_FORMAT_UINT64(address))); |
Lv Zheng | a94e88c | 2014-04-04 12:39:11 +0800 | [diff] [blame] | 210 | goto release_and_exit; |
| 211 | } |
| 212 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 213 | /* Validate and verify a table before installation */ |
| 214 | |
Lv Zheng | 47d68c7 | 2014-05-31 08:14:44 +0800 | [diff] [blame] | 215 | status = acpi_tb_verify_temp_table(&new_table_desc, NULL); |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 216 | if (ACPI_FAILURE(status)) { |
| 217 | goto release_and_exit; |
| 218 | } |
| 219 | |
Lv Zheng | 7a37052 | 2017-01-19 15:21:34 +0800 | [diff] [blame] | 220 | /* Acquire the table lock */ |
| 221 | |
| 222 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
| 223 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 224 | if (reload) { |
| 225 | /* |
| 226 | * Validate the incoming table signature. |
| 227 | * |
| 228 | * 1) Originally, we checked the table signature for "SSDT" or "PSDT". |
| 229 | * 2) We added support for OEMx tables, signature "OEM". |
| 230 | * 3) Valid tables were encountered with a null signature, so we just |
| 231 | * gave up on validating the signature, (05/2008). |
| 232 | * 4) We encountered non-AML tables such as the MADT, which caused |
| 233 | * interpreter errors and kernel faults. So now, we once again allow |
| 234 | * only "SSDT", "OEMx", and now, also a null signature. (05/2011). |
| 235 | */ |
| 236 | if ((new_table_desc.signature.ascii[0] != 0x00) && |
| 237 | (!ACPI_COMPARE_NAME |
| 238 | (&new_table_desc.signature, ACPI_SIG_SSDT)) |
Bob Moore | 4fa4616 | 2015-07-01 14:45:11 +0800 | [diff] [blame] | 239 | && (strncmp(new_table_desc.signature.ascii, "OEM", 3))) { |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 240 | ACPI_BIOS_ERROR((AE_INFO, |
| 241 | "Table has invalid signature [%4.4s] (0x%8.8X), " |
| 242 | "must be SSDT or OEMx", |
Bob Moore | 6a0df32 | 2016-05-05 13:00:36 +0800 | [diff] [blame] | 243 | acpi_ut_valid_nameseg(new_table_desc. |
| 244 | signature. |
| 245 | ascii) ? |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 246 | new_table_desc.signature. |
| 247 | ascii : "????", |
| 248 | new_table_desc.signature.integer)); |
| 249 | |
| 250 | status = AE_BAD_SIGNATURE; |
Lv Zheng | 7a37052 | 2017-01-19 15:21:34 +0800 | [diff] [blame] | 251 | goto unlock_and_exit; |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | /* Check if table is already registered */ |
| 255 | |
| 256 | for (i = 0; i < acpi_gbl_root_table_list.current_table_count; |
| 257 | ++i) { |
| 258 | /* |
| 259 | * Check for a table match on the entire table length, |
| 260 | * not just the header. |
| 261 | */ |
Bob Moore | c418ce1 | 2014-04-04 12:39:34 +0800 | [diff] [blame] | 262 | if (!acpi_tb_compare_tables(&new_table_desc, i)) { |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 263 | continue; |
| 264 | } |
| 265 | |
| 266 | /* |
| 267 | * Note: the current mechanism does not unregister a table if it is |
| 268 | * dynamically unloaded. The related namespace entries are deleted, |
| 269 | * but the table remains in the root table list. |
| 270 | * |
| 271 | * The assumption here is that the number of different tables that |
| 272 | * will be loaded is actually small, and there is minimal overhead |
| 273 | * in just keeping the table in case it is needed again. |
| 274 | * |
| 275 | * If this assumption changes in the future (perhaps on large |
| 276 | * machines with many table load/unload operations), tables will |
| 277 | * need to be unregistered when they are unloaded, and slots in the |
| 278 | * root table list should be reused when empty. |
| 279 | */ |
Bob Moore | 1fad873 | 2015-12-29 13:54:36 +0800 | [diff] [blame] | 280 | if (acpi_gbl_root_table_list.tables[i].flags & |
| 281 | ACPI_TABLE_IS_LOADED) { |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 282 | |
| 283 | /* Table is still loaded, this is an error */ |
| 284 | |
| 285 | status = AE_ALREADY_EXISTS; |
Lv Zheng | 7a37052 | 2017-01-19 15:21:34 +0800 | [diff] [blame] | 286 | goto unlock_and_exit; |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 287 | } else { |
| 288 | /* |
| 289 | * Table was unloaded, allow it to be reloaded. |
| 290 | * As we are going to return AE_OK to the caller, we should |
| 291 | * take the responsibility of freeing the input descriptor. |
| 292 | * Refill the input descriptor to ensure |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 293 | * acpi_tb_install_table_with_override() can be called again to |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 294 | * indicate the re-installation. |
| 295 | */ |
| 296 | acpi_tb_uninstall_table(&new_table_desc); |
Lv Zheng | 7a37052 | 2017-01-19 15:21:34 +0800 | [diff] [blame] | 297 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 298 | *table_index = i; |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 299 | return_ACPI_STATUS(AE_OK); |
| 300 | } |
| 301 | } |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 302 | } |
Bob Moore | d3ccaff | 2009-02-03 14:43:04 +0800 | [diff] [blame] | 303 | |
Bob Moore | e56f561 | 2008-07-04 10:48:43 +0800 | [diff] [blame] | 304 | /* Add the table to the global root table list */ |
| 305 | |
Lv Zheng | 8ec3f45 | 2015-08-25 10:29:01 +0800 | [diff] [blame] | 306 | acpi_tb_install_table_with_override(&new_table_desc, override, |
| 307 | table_index); |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 308 | |
Lv Zheng | 9b019b0 | 2017-07-10 15:23:28 +0800 | [diff] [blame^] | 309 | /* Invoke table handler */ |
Lv Zheng | bdbe5df | 2016-09-07 14:06:32 +0800 | [diff] [blame] | 310 | |
Lv Zheng | 7a37052 | 2017-01-19 15:21:34 +0800 | [diff] [blame] | 311 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
Lv Zheng | 9b019b0 | 2017-07-10 15:23:28 +0800 | [diff] [blame^] | 312 | acpi_tb_notify_table(ACPI_TABLE_EVENT_INSTALL, new_table_desc.pointer); |
Lv Zheng | 7a37052 | 2017-01-19 15:21:34 +0800 | [diff] [blame] | 313 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
| 314 | |
| 315 | unlock_and_exit: |
| 316 | |
| 317 | /* Release the table lock */ |
| 318 | |
| 319 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
Lv Zheng | bdbe5df | 2016-09-07 14:06:32 +0800 | [diff] [blame] | 320 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 321 | release_and_exit: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 323 | /* Release the temporary table descriptor */ |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 324 | |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 325 | acpi_tb_release_temp_table(&new_table_desc); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 326 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 327 | } |
| 328 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | /******************************************************************************* |
| 330 | * |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 331 | * FUNCTION: acpi_tb_override_table |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 332 | * |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 333 | * PARAMETERS: old_table_desc - Validated table descriptor to be |
| 334 | * overridden |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 335 | * |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 336 | * RETURN: None |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 337 | * |
| 338 | * DESCRIPTION: Attempt table override by calling the OSL override functions. |
| 339 | * Note: If the table is overridden, then the entire new table |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 340 | * is acquired and returned by this function. |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 341 | * Before/after invocation, the table descriptor is in a state |
| 342 | * that is "VALIDATED". |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 343 | * |
| 344 | ******************************************************************************/ |
| 345 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 346 | void acpi_tb_override_table(struct acpi_table_desc *old_table_desc) |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 347 | { |
| 348 | acpi_status status; |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 349 | char *override_type; |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 350 | struct acpi_table_desc new_table_desc; |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 351 | struct acpi_table_header *table; |
| 352 | acpi_physical_address address; |
| 353 | u32 length; |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 354 | |
| 355 | /* (1) Attempt logical override (returns a logical address) */ |
| 356 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 357 | status = acpi_os_table_override(old_table_desc->pointer, &table); |
| 358 | if (ACPI_SUCCESS(status) && table) { |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 359 | acpi_tb_acquire_temp_table(&new_table_desc, |
| 360 | ACPI_PTR_TO_PHYSADDR(table), |
| 361 | ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL); |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 362 | override_type = "Logical"; |
| 363 | goto finish_override; |
| 364 | } |
| 365 | |
| 366 | /* (2) Attempt physical override (returns a physical address) */ |
| 367 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 368 | status = acpi_os_physical_table_override(old_table_desc->pointer, |
| 369 | &address, &length); |
| 370 | if (ACPI_SUCCESS(status) && address && length) { |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 371 | acpi_tb_acquire_temp_table(&new_table_desc, address, |
| 372 | ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL); |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 373 | override_type = "Physical"; |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 374 | goto finish_override; |
| 375 | } |
| 376 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 377 | return; /* There was no override */ |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 378 | |
Lv Zheng | 10622bf | 2013-10-29 09:30:02 +0800 | [diff] [blame] | 379 | finish_override: |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 380 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 381 | /* Validate and verify a table before overriding */ |
| 382 | |
Lv Zheng | 47d68c7 | 2014-05-31 08:14:44 +0800 | [diff] [blame] | 383 | status = acpi_tb_verify_temp_table(&new_table_desc, NULL); |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 384 | if (ACPI_FAILURE(status)) { |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 385 | return; |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 386 | } |
| 387 | |
Bob Moore | 05fb04b | 2016-02-19 14:16:42 +0800 | [diff] [blame] | 388 | ACPI_INFO(("%4.4s 0x%8.8X%8.8X" |
Lv Zheng | 1d0a0b2 | 2015-04-13 11:48:52 +0800 | [diff] [blame] | 389 | " %s table override, new table: 0x%8.8X%8.8X", |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 390 | old_table_desc->signature.ascii, |
Lv Zheng | 1d0a0b2 | 2015-04-13 11:48:52 +0800 | [diff] [blame] | 391 | ACPI_FORMAT_UINT64(old_table_desc->address), |
| 392 | override_type, ACPI_FORMAT_UINT64(new_table_desc.address))); |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 393 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 394 | /* We can now uninstall the original table */ |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 395 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 396 | acpi_tb_uninstall_table(old_table_desc); |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 397 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 398 | /* |
| 399 | * Replace the original table descriptor and keep its state as |
| 400 | * "VALIDATED". |
| 401 | */ |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 402 | acpi_tb_init_table_descriptor(old_table_desc, new_table_desc.address, |
| 403 | new_table_desc.flags, |
| 404 | new_table_desc.pointer); |
Lv Zheng | 47d68c7 | 2014-05-31 08:14:44 +0800 | [diff] [blame] | 405 | acpi_tb_validate_temp_table(old_table_desc); |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 406 | |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 407 | /* Release the temporary table descriptor */ |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 408 | |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 409 | acpi_tb_release_temp_table(&new_table_desc); |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 410 | } |
| 411 | |
| 412 | /******************************************************************************* |
| 413 | * |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 414 | * FUNCTION: acpi_tb_uninstall_table |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 415 | * |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 416 | * PARAMETERS: table_desc - Table descriptor |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 417 | * |
| 418 | * RETURN: None |
| 419 | * |
| 420 | * DESCRIPTION: Delete one internal ACPI table |
| 421 | * |
| 422 | ******************************************************************************/ |
| 423 | |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 424 | void acpi_tb_uninstall_table(struct acpi_table_desc *table_desc) |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 425 | { |
Lv Zheng | 5582982 | 2014-04-04 12:38:18 +0800 | [diff] [blame] | 426 | |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 427 | ACPI_FUNCTION_TRACE(tb_uninstall_table); |
Lv Zheng | 5582982 | 2014-04-04 12:38:18 +0800 | [diff] [blame] | 428 | |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 429 | /* Table must be installed */ |
| 430 | |
| 431 | if (!table_desc->address) { |
| 432 | return_VOID; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 433 | } |
Lv Zheng | 5582982 | 2014-04-04 12:38:18 +0800 | [diff] [blame] | 434 | |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 435 | acpi_tb_invalidate_table(table_desc); |
Chao Guan | 1d1ea1b | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 436 | |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 437 | if ((table_desc->flags & ACPI_TABLE_ORIGIN_MASK) == |
Bob Moore | ed6f1d4 | 2014-04-04 12:39:26 +0800 | [diff] [blame] | 438 | ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL) { |
Lv Zheng | 6d3fd3c | 2015-04-13 11:48:37 +0800 | [diff] [blame] | 439 | ACPI_FREE(ACPI_PHYSADDR_TO_PTR(table_desc->address)); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 440 | } |
| 441 | |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 442 | table_desc->address = ACPI_PTR_TO_PHYSADDR(NULL); |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 443 | return_VOID; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 444 | } |