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" |
| 46 | #include "acnamesp.h" |
| 47 | #include "actables.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | #define _COMPONENT ACPI_TABLES |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 50 | ACPI_MODULE_NAME("tbinstal") |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 52 | /* Local prototypes */ |
| 53 | static acpi_status |
| 54 | acpi_tb_acquire_temporal_table(struct acpi_table_desc *table_desc, |
| 55 | acpi_physical_address address, u8 flags); |
| 56 | |
| 57 | static void acpi_tb_release_temporal_table(struct acpi_table_desc *table_desc); |
| 58 | |
| 59 | static acpi_status acpi_tb_acquire_root_table_entry(u32 *table_index); |
| 60 | |
| 61 | static u8 |
| 62 | acpi_tb_is_equivalent_table(struct acpi_table_desc *table_desc, |
| 63 | u32 table_index); |
| 64 | |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 65 | /******************************************************************************* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | * |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 67 | * FUNCTION: acpi_tb_acquire_table |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | * |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 69 | * PARAMETERS: table_desc - Table descriptor |
| 70 | * table_ptr - Where table is returned |
| 71 | * table_length - Where table length is returned |
| 72 | * table_flags - Where table allocation flags are returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | * |
| 74 | * RETURN: Status |
| 75 | * |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 76 | * DESCRIPTION: Acquire a table. It can be used for tables not maintained in |
| 77 | * acpi_gbl_root_table_list. |
| 78 | * |
| 79 | ******************************************************************************/ |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 80 | |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 81 | acpi_status |
| 82 | acpi_tb_acquire_table(struct acpi_table_desc *table_desc, |
| 83 | struct acpi_table_header **table_ptr, |
| 84 | u32 *table_length, u8 *table_flags) |
| 85 | { |
| 86 | struct acpi_table_header *table = NULL; |
| 87 | |
| 88 | switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) { |
Lv Zheng | 8a216d7 | 2014-04-04 12:39:04 +0800 | [diff] [blame] | 89 | case ACPI_TABLE_ORIGIN_INTERN_PHYSICAL: |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 90 | |
| 91 | table = |
| 92 | acpi_os_map_memory(table_desc->address, table_desc->length); |
| 93 | break; |
| 94 | |
Lv Zheng | 8a216d7 | 2014-04-04 12:39:04 +0800 | [diff] [blame] | 95 | case ACPI_TABLE_ORIGIN_INTERN_VIRTUAL: |
| 96 | case ACPI_TABLE_ORIGIN_EXTERN_VIRTUAL: |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 97 | |
| 98 | table = |
| 99 | ACPI_CAST_PTR(struct acpi_table_header, |
| 100 | table_desc->address); |
| 101 | break; |
| 102 | |
| 103 | default: |
| 104 | |
| 105 | break; |
| 106 | } |
| 107 | |
| 108 | /* Table is not valid yet */ |
| 109 | |
| 110 | if (!table) { |
| 111 | return (AE_NO_MEMORY); |
| 112 | } |
| 113 | |
| 114 | /* Fill the return values */ |
| 115 | |
| 116 | *table_ptr = table; |
| 117 | *table_length = table_desc->length; |
| 118 | *table_flags = table_desc->flags; |
| 119 | |
| 120 | return (AE_OK); |
| 121 | } |
| 122 | |
| 123 | /******************************************************************************* |
| 124 | * |
| 125 | * FUNCTION: acpi_tb_release_table |
| 126 | * |
| 127 | * PARAMETERS: table - Pointer for the table |
| 128 | * table_length - Length for the table |
| 129 | * table_flags - Allocation flags for the table |
| 130 | * |
| 131 | * RETURN: None |
| 132 | * |
| 133 | * DESCRIPTION: Release a table. The reversal of acpi_tb_acquire_table(). |
| 134 | * |
| 135 | ******************************************************************************/ |
| 136 | |
| 137 | void |
| 138 | acpi_tb_release_table(struct acpi_table_header *table, |
| 139 | u32 table_length, u8 table_flags) |
| 140 | { |
| 141 | switch (table_flags & ACPI_TABLE_ORIGIN_MASK) { |
Lv Zheng | 8a216d7 | 2014-04-04 12:39:04 +0800 | [diff] [blame] | 142 | case ACPI_TABLE_ORIGIN_INTERN_PHYSICAL: |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 143 | |
| 144 | acpi_os_unmap_memory(table, table_length); |
| 145 | break; |
| 146 | |
Lv Zheng | 8a216d7 | 2014-04-04 12:39:04 +0800 | [diff] [blame] | 147 | case ACPI_TABLE_ORIGIN_INTERN_VIRTUAL: |
| 148 | case ACPI_TABLE_ORIGIN_EXTERN_VIRTUAL: |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 149 | default: |
| 150 | |
| 151 | break; |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | /****************************************************************************** |
| 156 | * |
| 157 | * FUNCTION: acpi_tb_validate_table |
| 158 | * |
| 159 | * PARAMETERS: table_desc - Table descriptor |
| 160 | * |
| 161 | * RETURN: Status |
| 162 | * |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 163 | * DESCRIPTION: This function is called to validate the table, the returned |
| 164 | * table descriptor is in "VALIDATED" state. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 166 | *****************************************************************************/ |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 167 | |
| 168 | acpi_status acpi_tb_validate_table(struct acpi_table_desc *table_desc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 169 | { |
Alexey Starikovskiy | 428f211 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 170 | acpi_status status = AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 172 | ACPI_FUNCTION_TRACE(tb_validate_table); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 173 | |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 174 | /* Validate the table if necessary */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 175 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 176 | if (!table_desc->pointer) { |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 177 | status = acpi_tb_acquire_table(table_desc, &table_desc->pointer, |
| 178 | &table_desc->length, |
| 179 | &table_desc->flags); |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 180 | if (!table_desc->pointer) { |
| 181 | status = AE_NO_MEMORY; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | } |
| 183 | } |
| 184 | |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 185 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 186 | } |
| 187 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | /******************************************************************************* |
| 189 | * |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 190 | * FUNCTION: acpi_tb_invalidate_table |
| 191 | * |
| 192 | * PARAMETERS: table_desc - Table descriptor |
| 193 | * |
| 194 | * RETURN: None |
| 195 | * |
| 196 | * DESCRIPTION: Invalidate one internal ACPI table, this is reversal of |
| 197 | * acpi_tb_validate_table(). |
| 198 | * |
| 199 | ******************************************************************************/ |
| 200 | |
| 201 | void acpi_tb_invalidate_table(struct acpi_table_desc *table_desc) |
| 202 | { |
| 203 | |
| 204 | ACPI_FUNCTION_TRACE(tb_invalidate_table); |
| 205 | |
| 206 | /* Table must be validated */ |
| 207 | |
| 208 | if (!table_desc->pointer) { |
| 209 | return_VOID; |
| 210 | } |
| 211 | |
| 212 | acpi_tb_release_table(table_desc->pointer, table_desc->length, |
| 213 | table_desc->flags); |
| 214 | table_desc->pointer = NULL; |
| 215 | |
| 216 | return_VOID; |
| 217 | } |
| 218 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 219 | /****************************************************************************** |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 220 | * |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 221 | * FUNCTION: acpi_tb_verify_table |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | * |
Alexey Starikovskiy | 428f211 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 223 | * PARAMETERS: table_desc - Table descriptor |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 224 | * signature - Table signature to verify |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | * |
| 226 | * RETURN: Status |
| 227 | * |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 228 | * DESCRIPTION: This function is called to validate and verify the table, the |
| 229 | * returned table descriptor is in "VALIDATED" state. |
| 230 | * |
| 231 | *****************************************************************************/ |
| 232 | |
| 233 | acpi_status |
| 234 | acpi_tb_verify_table(struct acpi_table_desc *table_desc, char *signature) |
| 235 | { |
| 236 | acpi_status status = AE_OK; |
| 237 | |
| 238 | ACPI_FUNCTION_TRACE(tb_verify_table); |
| 239 | |
| 240 | /* Validate the table */ |
| 241 | |
| 242 | status = acpi_tb_validate_table(table_desc); |
| 243 | if (ACPI_FAILURE(status)) { |
| 244 | return_ACPI_STATUS(AE_NO_MEMORY); |
| 245 | } |
| 246 | |
| 247 | /* If a particular signature is expected (DSDT/FACS), it must match */ |
| 248 | |
| 249 | if (signature && !ACPI_COMPARE_NAME(&table_desc->signature, signature)) { |
| 250 | ACPI_BIOS_ERROR((AE_INFO, |
| 251 | "Invalid signature 0x%X for ACPI table, expected [%s]", |
| 252 | table_desc->signature.integer, signature)); |
| 253 | status = AE_BAD_SIGNATURE; |
| 254 | goto invalidate_and_exit; |
| 255 | } |
| 256 | |
| 257 | /* Verify the checksum */ |
| 258 | |
| 259 | status = |
| 260 | acpi_tb_verify_checksum(table_desc->pointer, table_desc->length); |
| 261 | if (ACPI_FAILURE(status)) { |
| 262 | ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY, |
| 263 | "%4.4s " ACPI_PRINTF_UINT |
| 264 | " Attempted table install failed", |
| 265 | acpi_ut_valid_acpi_name(table_desc->signature. |
| 266 | ascii) ? table_desc-> |
| 267 | signature.ascii : "????", |
| 268 | ACPI_FORMAT_TO_UINT(table_desc->address))); |
| 269 | goto invalidate_and_exit; |
| 270 | } |
| 271 | |
| 272 | return_ACPI_STATUS(AE_OK); |
| 273 | |
| 274 | invalidate_and_exit: |
| 275 | acpi_tb_invalidate_table(table_desc); |
| 276 | return_ACPI_STATUS(status); |
| 277 | } |
| 278 | |
| 279 | /******************************************************************************* |
| 280 | * |
| 281 | * FUNCTION: acpi_tb_install_table |
| 282 | * |
| 283 | * PARAMETERS: table_desc - Table descriptor |
| 284 | * address - Physical address of the table |
| 285 | * flags - Allocation flags of the table |
| 286 | * table - Pointer to the table |
| 287 | * |
| 288 | * RETURN: None |
| 289 | * |
| 290 | * DESCRIPTION: Install an ACPI table into the global data structure. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | * |
| 292 | ******************************************************************************/ |
| 293 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 294 | void |
| 295 | acpi_tb_install_table(struct acpi_table_desc *table_desc, |
| 296 | acpi_physical_address address, |
| 297 | u8 flags, struct acpi_table_header *table) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | { |
Bob Moore | bc45b1d | 2008-06-10 14:12:50 +0800 | [diff] [blame] | 299 | /* |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 300 | * Initialize the table entry. Set the pointer to NULL, since the |
| 301 | * table is not fully mapped at this time. |
Bob Moore | bc45b1d | 2008-06-10 14:12:50 +0800 | [diff] [blame] | 302 | */ |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 303 | ACPI_MEMSET(table_desc, 0, sizeof(struct acpi_table_desc)); |
| 304 | table_desc->address = address; |
| 305 | table_desc->length = table->length; |
| 306 | table_desc->flags = flags; |
| 307 | ACPI_MOVE_32_TO_32(table_desc->signature.ascii, table->signature); |
| 308 | } |
Bob Moore | c8cefe3 | 2011-06-14 10:42:53 +0800 | [diff] [blame] | 309 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 310 | /******************************************************************************* |
| 311 | * |
| 312 | * FUNCTION: acpi_tb_acquire_temporal_table |
| 313 | * |
| 314 | * PARAMETERS: table_desc - Table descriptor to be acquired |
| 315 | * address - Address of the table |
| 316 | * flags - Allocation flags of the table |
| 317 | * |
| 318 | * RETURN: Status |
| 319 | * |
| 320 | * DESCRIPTION: This function validates the table header to obtain the length |
| 321 | * of a table and fills the table descriptor to make its state as |
| 322 | * "INSTALLED". Such table descriptor is only used for verified |
| 323 | * installation. |
| 324 | * |
| 325 | ******************************************************************************/ |
| 326 | |
| 327 | static acpi_status |
| 328 | acpi_tb_acquire_temporal_table(struct acpi_table_desc *table_desc, |
| 329 | acpi_physical_address address, u8 flags) |
| 330 | { |
| 331 | struct acpi_table_header *table_header; |
| 332 | |
| 333 | switch (flags & ACPI_TABLE_ORIGIN_MASK) { |
Lv Zheng | 8a216d7 | 2014-04-04 12:39:04 +0800 | [diff] [blame] | 334 | case ACPI_TABLE_ORIGIN_INTERN_PHYSICAL: |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 335 | |
| 336 | /* Try to obtain the length of the table */ |
| 337 | |
| 338 | table_header = |
| 339 | acpi_os_map_memory(address, |
| 340 | sizeof(struct acpi_table_header)); |
| 341 | if (!table_header) { |
| 342 | return (AE_NO_MEMORY); |
| 343 | } |
| 344 | acpi_tb_install_table(table_desc, address, flags, table_header); |
| 345 | acpi_os_unmap_memory(table_header, |
| 346 | sizeof(struct acpi_table_header)); |
| 347 | return (AE_OK); |
| 348 | |
Lv Zheng | 8a216d7 | 2014-04-04 12:39:04 +0800 | [diff] [blame] | 349 | case ACPI_TABLE_ORIGIN_INTERN_VIRTUAL: |
| 350 | case ACPI_TABLE_ORIGIN_EXTERN_VIRTUAL: |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 351 | |
| 352 | table_header = ACPI_CAST_PTR(struct acpi_table_header, address); |
| 353 | if (!table_header) { |
| 354 | return (AE_NO_MEMORY); |
| 355 | } |
| 356 | acpi_tb_install_table(table_desc, address, flags, table_header); |
| 357 | return (AE_OK); |
| 358 | |
| 359 | default: |
| 360 | |
| 361 | break; |
Bob Moore | c8cefe3 | 2011-06-14 10:42:53 +0800 | [diff] [blame] | 362 | } |
Alexey Starikovskiy | 428f211 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 363 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 364 | /* Table is not valid yet */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 365 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 366 | return (AE_NO_MEMORY); |
| 367 | } |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 368 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 369 | /******************************************************************************* |
| 370 | * |
| 371 | * FUNCTION: acpi_tb_release_temporal_table |
| 372 | * |
| 373 | * PARAMETERS: table_desc - Table descriptor to be released |
| 374 | * |
| 375 | * RETURN: Status |
| 376 | * |
| 377 | * DESCRIPTION: The reversal of acpi_tb_acquire_temporal_table(). |
| 378 | * |
| 379 | ******************************************************************************/ |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 380 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 381 | static void acpi_tb_release_temporal_table(struct acpi_table_desc *table_desc) |
| 382 | { |
| 383 | /* |
| 384 | * Note that the .Address is maintained by the callers of |
| 385 | * acpi_tb_acquire_temporal_table(), thus do not invoke acpi_tb_uninstall_table() |
| 386 | * where .Address will be freed. |
| 387 | */ |
| 388 | acpi_tb_invalidate_table(table_desc); |
| 389 | } |
Bob Moore | e56f561 | 2008-07-04 10:48:43 +0800 | [diff] [blame] | 390 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 391 | /******************************************************************************* |
| 392 | * |
| 393 | * FUNCTION: acpi_tb_install_and_override_table |
| 394 | * |
| 395 | * PARAMETERS: table_index - Index into root table array |
| 396 | * new_table_desc - New table descriptor to install |
Lv Zheng | caf4a15 | 2014-04-04 12:39:18 +0800 | [diff] [blame^] | 397 | * override - Whether override should be performed |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 398 | * |
| 399 | * RETURN: None |
| 400 | * |
| 401 | * DESCRIPTION: Install an ACPI table into the global data structure. The |
| 402 | * table override mechanism is called to allow the host |
| 403 | * OS to replace any table before it is installed in the root |
| 404 | * table array. |
| 405 | * |
| 406 | ******************************************************************************/ |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 407 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 408 | void |
| 409 | acpi_tb_install_and_override_table(u32 table_index, |
Lv Zheng | caf4a15 | 2014-04-04 12:39:18 +0800 | [diff] [blame^] | 410 | struct acpi_table_desc *new_table_desc, |
| 411 | u8 override) |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 412 | { |
| 413 | if (table_index >= acpi_gbl_root_table_list.current_table_count) { |
| 414 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | } |
| 416 | |
Bob Moore | d3ccaff | 2009-02-03 14:43:04 +0800 | [diff] [blame] | 417 | /* |
| 418 | * ACPI Table Override: |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 419 | * |
| 420 | * Before we install the table, let the host OS override it with a new |
| 421 | * one if desired. Any table within the RSDT/XSDT can be replaced, |
| 422 | * including the DSDT which is pointed to by the FADT. |
Bob Moore | d3ccaff | 2009-02-03 14:43:04 +0800 | [diff] [blame] | 423 | */ |
Lv Zheng | caf4a15 | 2014-04-04 12:39:18 +0800 | [diff] [blame^] | 424 | if (override) { |
| 425 | acpi_tb_override_table(new_table_desc); |
| 426 | } |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 427 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 428 | acpi_tb_install_table(&acpi_gbl_root_table_list.tables[table_index], |
| 429 | new_table_desc->address, new_table_desc->flags, |
| 430 | new_table_desc->pointer); |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 431 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 432 | acpi_tb_print_table_header(new_table_desc->address, |
| 433 | new_table_desc->pointer); |
| 434 | |
| 435 | /* Set the global integer width (based upon revision of the DSDT) */ |
| 436 | |
| 437 | if (table_index == ACPI_TABLE_INDEX_DSDT) { |
| 438 | acpi_ut_set_integer_width(new_table_desc->pointer->revision); |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | /******************************************************************************* |
| 443 | * |
| 444 | * FUNCTION: acpi_tb_install_fixed_table |
| 445 | * |
| 446 | * PARAMETERS: address - Physical address of DSDT or FACS |
| 447 | * signature - Table signature, NULL if no need to |
| 448 | * match |
| 449 | * table_index - Index into root table array |
| 450 | * |
| 451 | * RETURN: Status |
| 452 | * |
| 453 | * DESCRIPTION: Install a fixed ACPI table (DSDT/FACS) into the global data |
| 454 | * structure. |
| 455 | * |
| 456 | ******************************************************************************/ |
| 457 | |
| 458 | acpi_status |
| 459 | acpi_tb_install_fixed_table(acpi_physical_address address, |
| 460 | char *signature, u32 table_index) |
| 461 | { |
| 462 | struct acpi_table_desc new_table_desc; |
| 463 | acpi_status status; |
| 464 | |
| 465 | ACPI_FUNCTION_TRACE(tb_install_fixed_table); |
| 466 | |
| 467 | if (!address) { |
| 468 | ACPI_ERROR((AE_INFO, |
| 469 | "Null physical address for ACPI table [%s]", |
| 470 | signature)); |
| 471 | return (AE_NO_MEMORY); |
| 472 | } |
| 473 | |
| 474 | /* Fill a table descriptor for validation */ |
| 475 | |
| 476 | status = acpi_tb_acquire_temporal_table(&new_table_desc, address, |
Lv Zheng | 8a216d7 | 2014-04-04 12:39:04 +0800 | [diff] [blame] | 477 | ACPI_TABLE_ORIGIN_INTERN_PHYSICAL); |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 478 | if (ACPI_FAILURE(status)) { |
| 479 | ACPI_ERROR((AE_INFO, "Could not acquire table length at %p", |
| 480 | ACPI_CAST_PTR(void, address))); |
| 481 | return_ACPI_STATUS(status); |
| 482 | } |
| 483 | |
| 484 | /* Validate and verify a table before installation */ |
| 485 | |
| 486 | status = acpi_tb_verify_table(&new_table_desc, signature); |
| 487 | if (ACPI_FAILURE(status)) { |
| 488 | goto release_and_exit; |
| 489 | } |
| 490 | |
Lv Zheng | caf4a15 | 2014-04-04 12:39:18 +0800 | [diff] [blame^] | 491 | acpi_tb_install_and_override_table(table_index, &new_table_desc, TRUE); |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 492 | |
| 493 | release_and_exit: |
| 494 | |
| 495 | /* Release the temporal table descriptor */ |
| 496 | |
| 497 | acpi_tb_release_temporal_table(&new_table_desc); |
| 498 | return_ACPI_STATUS(status); |
| 499 | } |
| 500 | |
| 501 | /******************************************************************************* |
| 502 | * |
| 503 | * FUNCTION: acpi_tb_is_equivalent_table |
| 504 | * |
| 505 | * PARAMETERS: table_desc - Table 1 descriptor to be compared |
| 506 | * table_index - Index of table 2 to be compared |
| 507 | * |
| 508 | * RETURN: TRUE if 2 tables are equivalent |
| 509 | * |
| 510 | * DESCRIPTION: This function is called to compare a table with what have |
| 511 | * already been installed in the root table list. |
| 512 | * |
| 513 | ******************************************************************************/ |
| 514 | |
| 515 | static u8 |
| 516 | acpi_tb_is_equivalent_table(struct acpi_table_desc *table_desc, u32 table_index) |
| 517 | { |
| 518 | acpi_status status = AE_OK; |
| 519 | u8 is_equivalent; |
| 520 | struct acpi_table_header *table; |
| 521 | u32 table_length; |
| 522 | u8 table_flags; |
| 523 | |
| 524 | status = |
| 525 | acpi_tb_acquire_table(&acpi_gbl_root_table_list.tables[table_index], |
| 526 | &table, &table_length, &table_flags); |
| 527 | if (ACPI_FAILURE(status)) { |
| 528 | return (FALSE); |
| 529 | } |
| 530 | |
| 531 | /* |
| 532 | * Check for a table match on the entire table length, |
| 533 | * not just the header. |
| 534 | */ |
| 535 | is_equivalent = (u8)((table_desc->length != table_length || |
| 536 | ACPI_MEMCMP(table_desc->pointer, table, |
| 537 | table_length)) ? FALSE : TRUE); |
| 538 | |
| 539 | /* Release the acquired table */ |
| 540 | |
| 541 | acpi_tb_release_table(table, table_length, table_flags); |
| 542 | |
| 543 | return (is_equivalent); |
| 544 | } |
| 545 | |
| 546 | /******************************************************************************* |
| 547 | * |
| 548 | * FUNCTION: acpi_tb_install_non_fixed_table |
| 549 | * |
Lv Zheng | 8a216d7 | 2014-04-04 12:39:04 +0800 | [diff] [blame] | 550 | * PARAMETERS: address - Address of the table (might be a virtual |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 551 | * address depending on the table_flags) |
| 552 | * flags - Flags for the table |
| 553 | * reload - Whether reload should be performed |
Lv Zheng | caf4a15 | 2014-04-04 12:39:18 +0800 | [diff] [blame^] | 554 | * override - Whether override should be performed |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 555 | * table_index - Where the table index is returned |
| 556 | * |
| 557 | * RETURN: Status |
| 558 | * |
| 559 | * DESCRIPTION: This function is called to install an ACPI table that is |
| 560 | * neither DSDT nor FACS. |
| 561 | * When this function is called by "Load" or "LoadTable" opcodes, |
| 562 | * or by acpi_load_table() API, the "Reload" parameter is set. |
| 563 | * After sucessfully returning from this function, table is |
| 564 | * "INSTALLED" but not "VALIDATED". |
| 565 | * |
| 566 | ******************************************************************************/ |
| 567 | |
| 568 | acpi_status |
| 569 | acpi_tb_install_non_fixed_table(acpi_physical_address address, |
Lv Zheng | caf4a15 | 2014-04-04 12:39:18 +0800 | [diff] [blame^] | 570 | u8 flags, |
| 571 | u8 reload, u8 override, u32 *table_index) |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 572 | { |
| 573 | u32 i; |
| 574 | acpi_status status = AE_OK; |
| 575 | struct acpi_table_desc new_table_desc; |
| 576 | |
| 577 | ACPI_FUNCTION_TRACE(tb_install_non_fixed_table); |
| 578 | |
| 579 | /* Acquire a temporal table descriptor for validation */ |
| 580 | |
| 581 | status = |
| 582 | acpi_tb_acquire_temporal_table(&new_table_desc, address, flags); |
| 583 | if (ACPI_FAILURE(status)) { |
| 584 | ACPI_ERROR((AE_INFO, "Could not acquire table length at %p", |
| 585 | ACPI_CAST_PTR(void, address))); |
| 586 | return_ACPI_STATUS(status); |
| 587 | } |
| 588 | |
Lv Zheng | a94e88c | 2014-04-04 12:39:11 +0800 | [diff] [blame] | 589 | /* |
| 590 | * Optionally do not load any SSDTs from the RSDT/XSDT. This can |
| 591 | * be useful for debugging ACPI problems on some machines. |
| 592 | */ |
| 593 | if (!reload && acpi_gbl_disable_ssdt_table_install && |
| 594 | ACPI_COMPARE_NAME(&new_table_desc.signature, ACPI_SIG_SSDT)) { |
| 595 | ACPI_INFO((AE_INFO, "Ignoring installation of %4.4s at %p", |
| 596 | new_table_desc.signature.ascii, ACPI_CAST_PTR(void, |
| 597 | address))); |
| 598 | goto release_and_exit; |
| 599 | } |
| 600 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 601 | /* Validate and verify a table before installation */ |
| 602 | |
| 603 | status = acpi_tb_verify_table(&new_table_desc, NULL); |
| 604 | if (ACPI_FAILURE(status)) { |
| 605 | goto release_and_exit; |
| 606 | } |
| 607 | |
| 608 | if (reload) { |
| 609 | /* |
| 610 | * Validate the incoming table signature. |
| 611 | * |
| 612 | * 1) Originally, we checked the table signature for "SSDT" or "PSDT". |
| 613 | * 2) We added support for OEMx tables, signature "OEM". |
| 614 | * 3) Valid tables were encountered with a null signature, so we just |
| 615 | * gave up on validating the signature, (05/2008). |
| 616 | * 4) We encountered non-AML tables such as the MADT, which caused |
| 617 | * interpreter errors and kernel faults. So now, we once again allow |
| 618 | * only "SSDT", "OEMx", and now, also a null signature. (05/2011). |
| 619 | */ |
| 620 | if ((new_table_desc.signature.ascii[0] != 0x00) && |
| 621 | (!ACPI_COMPARE_NAME |
| 622 | (&new_table_desc.signature, ACPI_SIG_SSDT)) |
| 623 | && (ACPI_STRNCMP(new_table_desc.signature.ascii, "OEM", 3))) |
| 624 | { |
| 625 | ACPI_BIOS_ERROR((AE_INFO, |
| 626 | "Table has invalid signature [%4.4s] (0x%8.8X), " |
| 627 | "must be SSDT or OEMx", |
| 628 | acpi_ut_valid_acpi_name(new_table_desc. |
| 629 | signature. |
| 630 | ascii) ? |
| 631 | new_table_desc.signature. |
| 632 | ascii : "????", |
| 633 | new_table_desc.signature.integer)); |
| 634 | |
| 635 | status = AE_BAD_SIGNATURE; |
| 636 | goto release_and_exit; |
| 637 | } |
| 638 | |
| 639 | /* Check if table is already registered */ |
| 640 | |
| 641 | for (i = 0; i < acpi_gbl_root_table_list.current_table_count; |
| 642 | ++i) { |
| 643 | /* |
| 644 | * Check for a table match on the entire table length, |
| 645 | * not just the header. |
| 646 | */ |
| 647 | if (!acpi_tb_is_equivalent_table(&new_table_desc, i)) { |
| 648 | continue; |
| 649 | } |
| 650 | |
| 651 | /* |
| 652 | * Note: the current mechanism does not unregister a table if it is |
| 653 | * dynamically unloaded. The related namespace entries are deleted, |
| 654 | * but the table remains in the root table list. |
| 655 | * |
| 656 | * The assumption here is that the number of different tables that |
| 657 | * will be loaded is actually small, and there is minimal overhead |
| 658 | * in just keeping the table in case it is needed again. |
| 659 | * |
| 660 | * If this assumption changes in the future (perhaps on large |
| 661 | * machines with many table load/unload operations), tables will |
| 662 | * need to be unregistered when they are unloaded, and slots in the |
| 663 | * root table list should be reused when empty. |
| 664 | */ |
| 665 | if (acpi_gbl_root_table_list.tables[i]. |
| 666 | flags & ACPI_TABLE_IS_LOADED) { |
| 667 | |
| 668 | /* Table is still loaded, this is an error */ |
| 669 | |
| 670 | status = AE_ALREADY_EXISTS; |
| 671 | goto release_and_exit; |
| 672 | } else { |
| 673 | /* |
| 674 | * Table was unloaded, allow it to be reloaded. |
| 675 | * As we are going to return AE_OK to the caller, we should |
| 676 | * take the responsibility of freeing the input descriptor. |
| 677 | * Refill the input descriptor to ensure |
| 678 | * acpi_tb_install_and_override_table() can be called again to |
| 679 | * indicate the re-installation. |
| 680 | */ |
| 681 | acpi_tb_uninstall_table(&new_table_desc); |
| 682 | *table_index = i; |
| 683 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
| 684 | return_ACPI_STATUS(AE_OK); |
| 685 | } |
| 686 | } |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 687 | } |
Bob Moore | d3ccaff | 2009-02-03 14:43:04 +0800 | [diff] [blame] | 688 | |
Bob Moore | e56f561 | 2008-07-04 10:48:43 +0800 | [diff] [blame] | 689 | /* Add the table to the global root table list */ |
| 690 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 691 | status = acpi_tb_acquire_root_table_entry(&i); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 692 | if (ACPI_FAILURE(status)) { |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 693 | goto release_and_exit; |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 694 | } |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 695 | *table_index = i; |
Lv Zheng | caf4a15 | 2014-04-04 12:39:18 +0800 | [diff] [blame^] | 696 | acpi_tb_install_and_override_table(i, &new_table_desc, override); |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 697 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 698 | release_and_exit: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 699 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 700 | /* Release the temporal table descriptor */ |
| 701 | |
| 702 | acpi_tb_release_temporal_table(&new_table_desc); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 703 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 704 | } |
| 705 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 706 | /******************************************************************************* |
| 707 | * |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 708 | * FUNCTION: acpi_tb_override_table |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 709 | * |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 710 | * PARAMETERS: old_table_desc - Validated table descriptor to be |
| 711 | * overridden |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 712 | * |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 713 | * RETURN: None |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 714 | * |
| 715 | * DESCRIPTION: Attempt table override by calling the OSL override functions. |
| 716 | * Note: If the table is overridden, then the entire new table |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 717 | * is acquired and returned by this function. |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 718 | * Before/after invocation, the table descriptor is in a state |
| 719 | * that is "VALIDATED". |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 720 | * |
| 721 | ******************************************************************************/ |
| 722 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 723 | void acpi_tb_override_table(struct acpi_table_desc *old_table_desc) |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 724 | { |
| 725 | acpi_status status; |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 726 | char *override_type; |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 727 | struct acpi_table_desc new_table_desc; |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 728 | struct acpi_table_header *table; |
| 729 | acpi_physical_address address; |
| 730 | u32 length; |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 731 | |
| 732 | /* (1) Attempt logical override (returns a logical address) */ |
| 733 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 734 | status = acpi_os_table_override(old_table_desc->pointer, &table); |
| 735 | if (ACPI_SUCCESS(status) && table) { |
| 736 | acpi_tb_acquire_temporal_table(&new_table_desc, |
| 737 | ACPI_PTR_TO_PHYSADDR(table), |
Lv Zheng | 8a216d7 | 2014-04-04 12:39:04 +0800 | [diff] [blame] | 738 | ACPI_TABLE_ORIGIN_EXTERN_VIRTUAL); |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 739 | override_type = "Logical"; |
| 740 | goto finish_override; |
| 741 | } |
| 742 | |
| 743 | /* (2) Attempt physical override (returns a physical address) */ |
| 744 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 745 | status = acpi_os_physical_table_override(old_table_desc->pointer, |
| 746 | &address, &length); |
| 747 | if (ACPI_SUCCESS(status) && address && length) { |
| 748 | acpi_tb_acquire_temporal_table(&new_table_desc, address, |
Lv Zheng | 8a216d7 | 2014-04-04 12:39:04 +0800 | [diff] [blame] | 749 | ACPI_TABLE_ORIGIN_INTERN_PHYSICAL); |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 750 | override_type = "Physical"; |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 751 | goto finish_override; |
| 752 | } |
| 753 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 754 | return; /* There was no override */ |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 755 | |
Lv Zheng | 10622bf | 2013-10-29 09:30:02 +0800 | [diff] [blame] | 756 | finish_override: |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 757 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 758 | /* Validate and verify a table before overriding */ |
| 759 | |
| 760 | status = acpi_tb_verify_table(&new_table_desc, NULL); |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 761 | if (ACPI_FAILURE(status)) { |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 762 | return; |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 763 | } |
| 764 | |
Bob Moore | 2e19f8d | 2014-02-08 09:42:07 +0800 | [diff] [blame] | 765 | ACPI_INFO((AE_INFO, "%4.4s " ACPI_PRINTF_UINT |
| 766 | " %s table override, new table: " ACPI_PRINTF_UINT, |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 767 | old_table_desc->signature.ascii, |
| 768 | ACPI_FORMAT_TO_UINT(old_table_desc->address), |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 769 | override_type, ACPI_FORMAT_TO_UINT(new_table_desc.address))); |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 770 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 771 | /* We can now uninstall the original table */ |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 772 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 773 | acpi_tb_uninstall_table(old_table_desc); |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 774 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 775 | /* |
| 776 | * Replace the original table descriptor and keep its state as |
| 777 | * "VALIDATED". |
| 778 | */ |
| 779 | acpi_tb_install_table(old_table_desc, new_table_desc.address, |
| 780 | new_table_desc.flags, new_table_desc.pointer); |
| 781 | acpi_tb_validate_table(old_table_desc); |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 782 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 783 | /* Release the temporal table descriptor */ |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 784 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 785 | acpi_tb_release_temporal_table(&new_table_desc); |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 786 | } |
| 787 | |
| 788 | /******************************************************************************* |
| 789 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 790 | * FUNCTION: acpi_tb_resize_root_table_list |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 791 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 792 | * PARAMETERS: None |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 793 | * |
| 794 | * RETURN: Status |
| 795 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 796 | * DESCRIPTION: Expand the size of global table array |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 797 | * |
| 798 | ******************************************************************************/ |
| 799 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 800 | acpi_status acpi_tb_resize_root_table_list(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 801 | { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 802 | struct acpi_table_desc *tables; |
Lv Zheng | 2bc198c | 2012-09-13 09:29:06 -0700 | [diff] [blame] | 803 | u32 table_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 804 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 805 | ACPI_FUNCTION_TRACE(tb_resize_root_table_list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 806 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 807 | /* allow_resize flag is a parameter to acpi_initialize_tables */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 808 | |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 809 | if (!(acpi_gbl_root_table_list.flags & ACPI_ROOT_ALLOW_RESIZE)) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 810 | ACPI_ERROR((AE_INFO, |
| 811 | "Resize of Root Table Array is not allowed")); |
| 812 | return_ACPI_STATUS(AE_SUPPORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 813 | } |
| 814 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 815 | /* Increase the Table Array size */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 816 | |
Lv Zheng | 2bc198c | 2012-09-13 09:29:06 -0700 | [diff] [blame] | 817 | if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { |
| 818 | table_count = acpi_gbl_root_table_list.max_table_count; |
| 819 | } else { |
| 820 | table_count = acpi_gbl_root_table_list.current_table_count; |
| 821 | } |
| 822 | |
| 823 | tables = ACPI_ALLOCATE_ZEROED(((acpi_size) table_count + |
Bob Moore | ec41f19 | 2009-02-18 15:03:30 +0800 | [diff] [blame] | 824 | ACPI_ROOT_TABLE_SIZE_INCREMENT) * |
| 825 | sizeof(struct acpi_table_desc)); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 826 | if (!tables) { |
| 827 | ACPI_ERROR((AE_INFO, |
| 828 | "Could not allocate new root table array")); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 829 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 830 | } |
| 831 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 832 | /* Copy and free the previous table array */ |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 833 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 834 | if (acpi_gbl_root_table_list.tables) { |
| 835 | ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables, |
Lv Zheng | 2bc198c | 2012-09-13 09:29:06 -0700 | [diff] [blame] | 836 | (acpi_size) table_count * |
| 837 | sizeof(struct acpi_table_desc)); |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 838 | |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 839 | if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 840 | ACPI_FREE(acpi_gbl_root_table_list.tables); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 841 | } |
| 842 | } |
| 843 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 844 | acpi_gbl_root_table_list.tables = tables; |
Lv Zheng | 2bc198c | 2012-09-13 09:29:06 -0700 | [diff] [blame] | 845 | acpi_gbl_root_table_list.max_table_count = |
| 846 | table_count + ACPI_ROOT_TABLE_SIZE_INCREMENT; |
| 847 | acpi_gbl_root_table_list.flags |= ACPI_ROOT_ORIGIN_ALLOCATED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 848 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 849 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 850 | } |
| 851 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 852 | /******************************************************************************* |
| 853 | * |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 854 | * FUNCTION: acpi_tb_acquire_root_table_entry |
| 855 | * |
| 856 | * PARAMETERS: table_index - Where table index is returned |
| 857 | * |
| 858 | * RETURN: Status and table index. |
| 859 | * |
| 860 | * DESCRIPTION: Allocate a new ACPI table entry to the global table list |
| 861 | * |
| 862 | ******************************************************************************/ |
| 863 | |
| 864 | static acpi_status acpi_tb_acquire_root_table_entry(u32 *table_index) |
| 865 | { |
| 866 | acpi_status status; |
| 867 | |
| 868 | /* Ensure that there is room for the table in the Root Table List */ |
| 869 | |
| 870 | if (acpi_gbl_root_table_list.current_table_count >= |
| 871 | acpi_gbl_root_table_list.max_table_count) { |
| 872 | status = acpi_tb_resize_root_table_list(); |
| 873 | if (ACPI_FAILURE(status)) { |
| 874 | return (status); |
| 875 | } |
| 876 | } |
| 877 | |
| 878 | *table_index = acpi_gbl_root_table_list.current_table_count; |
| 879 | acpi_gbl_root_table_list.current_table_count++; |
| 880 | return (AE_OK); |
| 881 | } |
| 882 | |
| 883 | /******************************************************************************* |
| 884 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 885 | * FUNCTION: acpi_tb_store_table |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 886 | * |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 887 | * PARAMETERS: address - Table address |
| 888 | * table - Table header |
| 889 | * length - Table length |
| 890 | * flags - flags |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 891 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 892 | * RETURN: Status and table index. |
| 893 | * |
| 894 | * DESCRIPTION: Add an ACPI table to the global table list |
| 895 | * |
| 896 | ******************************************************************************/ |
| 897 | |
| 898 | acpi_status |
| 899 | acpi_tb_store_table(acpi_physical_address address, |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 900 | struct acpi_table_header * table, |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 901 | u32 length, u8 flags, u32 *table_index) |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 902 | { |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 903 | acpi_status status; |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 904 | struct acpi_table_desc *table_desc; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 905 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 906 | status = acpi_tb_acquire_root_table_entry(table_index); |
| 907 | if (ACPI_FAILURE(status)) { |
| 908 | return (status); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 909 | } |
| 910 | |
| 911 | /* Initialize added table */ |
| 912 | |
Lv Zheng | 86dfc6f3 | 2014-04-04 12:38:57 +0800 | [diff] [blame] | 913 | table_desc = &acpi_gbl_root_table_list.tables[*table_index]; |
| 914 | acpi_tb_install_table(table_desc, address, flags, table); |
| 915 | table_desc->pointer = table; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 916 | |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 917 | return (AE_OK); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 918 | } |
| 919 | |
| 920 | /******************************************************************************* |
| 921 | * |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 922 | * FUNCTION: acpi_tb_uninstall_table |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 923 | * |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 924 | * PARAMETERS: table_desc - Table descriptor |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 925 | * |
| 926 | * RETURN: None |
| 927 | * |
| 928 | * DESCRIPTION: Delete one internal ACPI table |
| 929 | * |
| 930 | ******************************************************************************/ |
| 931 | |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 932 | void acpi_tb_uninstall_table(struct acpi_table_desc *table_desc) |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 933 | { |
Lv Zheng | 5582982 | 2014-04-04 12:38:18 +0800 | [diff] [blame] | 934 | |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 935 | ACPI_FUNCTION_TRACE(tb_uninstall_table); |
Lv Zheng | 5582982 | 2014-04-04 12:38:18 +0800 | [diff] [blame] | 936 | |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 937 | /* Table must be installed */ |
| 938 | |
| 939 | if (!table_desc->address) { |
| 940 | return_VOID; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 941 | } |
Lv Zheng | 5582982 | 2014-04-04 12:38:18 +0800 | [diff] [blame] | 942 | |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 943 | acpi_tb_invalidate_table(table_desc); |
Chao Guan | 1d1ea1b | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 944 | |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 945 | if ((table_desc->flags & ACPI_TABLE_ORIGIN_MASK) == |
Lv Zheng | 8a216d7 | 2014-04-04 12:39:04 +0800 | [diff] [blame] | 946 | ACPI_TABLE_ORIGIN_INTERN_VIRTUAL) { |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 947 | ACPI_FREE(ACPI_CAST_PTR(void, table_desc->address)); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 948 | } |
| 949 | |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 950 | table_desc->address = ACPI_PTR_TO_PHYSADDR(NULL); |
| 951 | |
| 952 | return_VOID; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 953 | } |
| 954 | |
| 955 | /******************************************************************************* |
| 956 | * |
| 957 | * FUNCTION: acpi_tb_terminate |
| 958 | * |
| 959 | * PARAMETERS: None |
| 960 | * |
| 961 | * RETURN: None |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 962 | * |
| 963 | * DESCRIPTION: Delete all internal ACPI tables |
| 964 | * |
| 965 | ******************************************************************************/ |
| 966 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 967 | void acpi_tb_terminate(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 968 | { |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 969 | u32 i; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 970 | |
| 971 | ACPI_FUNCTION_TRACE(tb_terminate); |
| 972 | |
| 973 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
| 974 | |
| 975 | /* Delete the individual tables */ |
| 976 | |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 977 | for (i = 0; i < acpi_gbl_root_table_list.current_table_count; i++) { |
Lv Zheng | 7f9fc99 | 2014-04-04 12:38:42 +0800 | [diff] [blame] | 978 | acpi_tb_uninstall_table(&acpi_gbl_root_table_list.tables[i]); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 979 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 980 | |
| 981 | /* |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 982 | * Delete the root table array if allocated locally. Array cannot be |
| 983 | * mapped, so we don't need to check for that flag. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 984 | */ |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 985 | if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 986 | ACPI_FREE(acpi_gbl_root_table_list.tables); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 987 | } |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 988 | |
| 989 | acpi_gbl_root_table_list.tables = NULL; |
| 990 | acpi_gbl_root_table_list.flags = 0; |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 991 | acpi_gbl_root_table_list.current_table_count = 0; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 992 | |
| 993 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n")); |
| 994 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
Bob Moore | 68aafc3 | 2012-10-31 02:26:01 +0000 | [diff] [blame] | 995 | |
| 996 | return_VOID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 997 | } |
| 998 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 999 | /******************************************************************************* |
| 1000 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1001 | * FUNCTION: acpi_tb_delete_namespace_by_owner |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1002 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1003 | * PARAMETERS: table_index - Table index |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1004 | * |
Bob Moore | 8a335a23 | 2009-03-09 16:31:04 +0800 | [diff] [blame] | 1005 | * RETURN: Status |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1006 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1007 | * DESCRIPTION: Delete all namespace objects created when this table was loaded. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1008 | * |
| 1009 | ******************************************************************************/ |
| 1010 | |
Bob Moore | 8a335a23 | 2009-03-09 16:31:04 +0800 | [diff] [blame] | 1011 | acpi_status acpi_tb_delete_namespace_by_owner(u32 table_index) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1012 | { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1013 | acpi_owner_id owner_id; |
Bob Moore | 8a335a23 | 2009-03-09 16:31:04 +0800 | [diff] [blame] | 1014 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1015 | |
Bob Moore | 8a335a23 | 2009-03-09 16:31:04 +0800 | [diff] [blame] | 1016 | ACPI_FUNCTION_TRACE(tb_delete_namespace_by_owner); |
| 1017 | |
| 1018 | status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
| 1019 | if (ACPI_FAILURE(status)) { |
| 1020 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1021 | } |
| 1022 | |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 1023 | if (table_index >= acpi_gbl_root_table_list.current_table_count) { |
Bob Moore | 8a335a23 | 2009-03-09 16:31:04 +0800 | [diff] [blame] | 1024 | |
| 1025 | /* The table index does not exist */ |
| 1026 | |
| 1027 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
| 1028 | return_ACPI_STATUS(AE_NOT_EXIST); |
| 1029 | } |
| 1030 | |
| 1031 | /* Get the owner ID for this table, used to delete namespace nodes */ |
| 1032 | |
| 1033 | owner_id = acpi_gbl_root_table_list.tables[table_index].owner_id; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 1034 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
Bob Moore | 8a335a23 | 2009-03-09 16:31:04 +0800 | [diff] [blame] | 1035 | |
| 1036 | /* |
| 1037 | * Need to acquire the namespace writer lock to prevent interference |
| 1038 | * with any concurrent namespace walks. The interpreter must be |
| 1039 | * released during the deletion since the acquisition of the deletion |
| 1040 | * lock may block, and also since the execution of a namespace walk |
| 1041 | * must be allowed to use the interpreter. |
| 1042 | */ |
Bob Moore | e4c1ebf | 2009-04-22 13:02:06 +0800 | [diff] [blame] | 1043 | (void)acpi_ut_release_mutex(ACPI_MTX_INTERPRETER); |
Bob Moore | 8a335a23 | 2009-03-09 16:31:04 +0800 | [diff] [blame] | 1044 | status = acpi_ut_acquire_write_lock(&acpi_gbl_namespace_rw_lock); |
| 1045 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1046 | acpi_ns_delete_namespace_by_owner(owner_id); |
Bob Moore | 8a335a23 | 2009-03-09 16:31:04 +0800 | [diff] [blame] | 1047 | if (ACPI_FAILURE(status)) { |
| 1048 | return_ACPI_STATUS(status); |
| 1049 | } |
| 1050 | |
| 1051 | acpi_ut_release_write_lock(&acpi_gbl_namespace_rw_lock); |
| 1052 | |
| 1053 | status = acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER); |
| 1054 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1055 | } |
| 1056 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1057 | /******************************************************************************* |
| 1058 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1059 | * FUNCTION: acpi_tb_allocate_owner_id |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1060 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1061 | * PARAMETERS: table_index - Table index |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1062 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1063 | * RETURN: Status |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1064 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1065 | * DESCRIPTION: Allocates owner_id in table_desc |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1066 | * |
| 1067 | ******************************************************************************/ |
| 1068 | |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 1069 | acpi_status acpi_tb_allocate_owner_id(u32 table_index) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1070 | { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1071 | acpi_status status = AE_BAD_PARAMETER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1072 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1073 | ACPI_FUNCTION_TRACE(tb_allocate_owner_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1074 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1075 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 1076 | if (table_index < acpi_gbl_root_table_list.current_table_count) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1077 | status = acpi_ut_allocate_owner_id |
| 1078 | (&(acpi_gbl_root_table_list.tables[table_index].owner_id)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1079 | } |
| 1080 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1081 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
| 1082 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1083 | } |
| 1084 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1085 | /******************************************************************************* |
| 1086 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1087 | * FUNCTION: acpi_tb_release_owner_id |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1088 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1089 | * PARAMETERS: table_index - Table index |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1090 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1091 | * RETURN: Status |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1092 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1093 | * DESCRIPTION: Releases owner_id in table_desc |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1094 | * |
| 1095 | ******************************************************************************/ |
| 1096 | |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 1097 | acpi_status acpi_tb_release_owner_id(u32 table_index) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1098 | { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1099 | acpi_status status = AE_BAD_PARAMETER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1100 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1101 | ACPI_FUNCTION_TRACE(tb_release_owner_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1102 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1103 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 1104 | if (table_index < acpi_gbl_root_table_list.current_table_count) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1105 | acpi_ut_release_owner_id(& |
| 1106 | (acpi_gbl_root_table_list. |
| 1107 | tables[table_index].owner_id)); |
| 1108 | status = AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1109 | } |
| 1110 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1111 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
| 1112 | return_ACPI_STATUS(status); |
| 1113 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1114 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1115 | /******************************************************************************* |
| 1116 | * |
| 1117 | * FUNCTION: acpi_tb_get_owner_id |
| 1118 | * |
| 1119 | * PARAMETERS: table_index - Table index |
| 1120 | * owner_id - Where the table owner_id is returned |
| 1121 | * |
| 1122 | * RETURN: Status |
| 1123 | * |
| 1124 | * DESCRIPTION: returns owner_id for the ACPI table |
| 1125 | * |
| 1126 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1127 | |
Lv Zheng | 5582982 | 2014-04-04 12:38:18 +0800 | [diff] [blame] | 1128 | acpi_status acpi_tb_get_owner_id(u32 table_index, acpi_owner_id * owner_id) |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1129 | { |
| 1130 | acpi_status status = AE_BAD_PARAMETER; |
| 1131 | |
| 1132 | ACPI_FUNCTION_TRACE(tb_get_owner_id); |
| 1133 | |
| 1134 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 1135 | if (table_index < acpi_gbl_root_table_list.current_table_count) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1136 | *owner_id = |
| 1137 | acpi_gbl_root_table_list.tables[table_index].owner_id; |
| 1138 | status = AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1139 | } |
| 1140 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1141 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
| 1142 | return_ACPI_STATUS(status); |
| 1143 | } |
| 1144 | |
| 1145 | /******************************************************************************* |
| 1146 | * |
| 1147 | * FUNCTION: acpi_tb_is_table_loaded |
| 1148 | * |
| 1149 | * PARAMETERS: table_index - Table index |
| 1150 | * |
| 1151 | * RETURN: Table Loaded Flag |
| 1152 | * |
| 1153 | ******************************************************************************/ |
| 1154 | |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 1155 | u8 acpi_tb_is_table_loaded(u32 table_index) |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1156 | { |
| 1157 | u8 is_loaded = FALSE; |
| 1158 | |
| 1159 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 1160 | if (table_index < acpi_gbl_root_table_list.current_table_count) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1161 | is_loaded = (u8) |
Bob Moore | ec41f19 | 2009-02-18 15:03:30 +0800 | [diff] [blame] | 1162 | (acpi_gbl_root_table_list.tables[table_index].flags & |
| 1163 | ACPI_TABLE_IS_LOADED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1164 | } |
| 1165 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1166 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
| 1167 | return (is_loaded); |
| 1168 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1169 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1170 | /******************************************************************************* |
| 1171 | * |
| 1172 | * FUNCTION: acpi_tb_set_table_loaded_flag |
| 1173 | * |
| 1174 | * PARAMETERS: table_index - Table index |
| 1175 | * is_loaded - TRUE if table is loaded, FALSE otherwise |
| 1176 | * |
| 1177 | * RETURN: None |
| 1178 | * |
| 1179 | * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE. |
| 1180 | * |
| 1181 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1182 | |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 1183 | void acpi_tb_set_table_loaded_flag(u32 table_index, u8 is_loaded) |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1184 | { |
Bob Moore | f6dd922 | 2006-07-07 20:44:38 -0400 | [diff] [blame] | 1185 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1186 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 1187 | if (table_index < acpi_gbl_root_table_list.current_table_count) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1188 | if (is_loaded) { |
| 1189 | acpi_gbl_root_table_list.tables[table_index].flags |= |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 1190 | ACPI_TABLE_IS_LOADED; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1191 | } else { |
| 1192 | acpi_gbl_root_table_list.tables[table_index].flags &= |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 1193 | ~ACPI_TABLE_IS_LOADED; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1194 | } |
| 1195 | } |
Bob Moore | f6dd922 | 2006-07-07 20:44:38 -0400 | [diff] [blame] | 1196 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 1197 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1198 | } |