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 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 52 | /****************************************************************************** |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 54 | * FUNCTION: acpi_tb_verify_table |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 56 | * PARAMETERS: table_desc - table |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | * |
| 58 | * RETURN: Status |
| 59 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 60 | * DESCRIPTION: this function is called to verify and map table |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 62 | *****************************************************************************/ |
| 63 | acpi_status acpi_tb_verify_table(struct acpi_table_desc *table_desc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | { |
Alexey Starikovskiy | 428f211 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 65 | acpi_status status = AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 67 | ACPI_FUNCTION_TRACE(tb_verify_table); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 69 | /* Map the table if necessary */ |
Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 70 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 71 | if (!table_desc->pointer) { |
Alexey Starikovskiy | 428f211 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 72 | if ((table_desc->flags & ACPI_TABLE_ORIGIN_MASK) == |
| 73 | ACPI_TABLE_ORIGIN_MAPPED) { |
| 74 | table_desc->pointer = |
| 75 | acpi_os_map_memory(table_desc->address, |
| 76 | table_desc->length); |
| 77 | } |
Lv Zheng | 5582982 | 2014-04-04 12:38:18 +0800 | [diff] [blame^] | 78 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 79 | if (!table_desc->pointer) { |
| 80 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | } |
| 82 | } |
| 83 | |
Lv Zheng | 94d4be6 | 2013-09-23 09:52:29 +0800 | [diff] [blame] | 84 | /* Always calculate checksum, ignore bad checksum if requested */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | |
Lv Zheng | 94d4be6 | 2013-09-23 09:52:29 +0800 | [diff] [blame] | 86 | status = |
| 87 | acpi_tb_verify_checksum(table_desc->pointer, table_desc->length); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 88 | |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 89 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | } |
| 91 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | /******************************************************************************* |
| 93 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 94 | * FUNCTION: acpi_tb_add_table |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | * |
Alexey Starikovskiy | 428f211 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 96 | * PARAMETERS: table_desc - Table descriptor |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 97 | * table_index - Where the table index is returned |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 98 | * |
| 99 | * RETURN: Status |
| 100 | * |
Bob Moore | d3ccaff | 2009-02-03 14:43:04 +0800 | [diff] [blame] | 101 | * DESCRIPTION: This function is called to add an ACPI table. It is used to |
| 102 | * dynamically load tables via the Load and load_table AML |
| 103 | * operators. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | * |
| 105 | ******************************************************************************/ |
| 106 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 107 | acpi_status |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 108 | acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 109 | { |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 110 | u32 i; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 111 | acpi_status status = AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 113 | ACPI_FUNCTION_TRACE(tb_add_table); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | |
Alexey Starikovskiy | 428f211 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 115 | if (!table_desc->pointer) { |
| 116 | status = acpi_tb_verify_table(table_desc); |
| 117 | if (ACPI_FAILURE(status) || !table_desc->pointer) { |
| 118 | return_ACPI_STATUS(status); |
| 119 | } |
| 120 | } |
| 121 | |
Bob Moore | bc45b1d | 2008-06-10 14:12:50 +0800 | [diff] [blame] | 122 | /* |
Bob Moore | c8cefe3 | 2011-06-14 10:42:53 +0800 | [diff] [blame] | 123 | * Validate the incoming table signature. |
| 124 | * |
| 125 | * 1) Originally, we checked the table signature for "SSDT" or "PSDT". |
| 126 | * 2) We added support for OEMx tables, signature "OEM". |
| 127 | * 3) Valid tables were encountered with a null signature, so we just |
| 128 | * gave up on validating the signature, (05/2008). |
| 129 | * 4) We encountered non-AML tables such as the MADT, which caused |
| 130 | * interpreter errors and kernel faults. So now, we once again allow |
| 131 | * only "SSDT", "OEMx", and now, also a null signature. (05/2011). |
Bob Moore | bc45b1d | 2008-06-10 14:12:50 +0800 | [diff] [blame] | 132 | */ |
Bob Moore | c8cefe3 | 2011-06-14 10:42:53 +0800 | [diff] [blame] | 133 | if ((table_desc->pointer->signature[0] != 0x00) && |
| 134 | (!ACPI_COMPARE_NAME(table_desc->pointer->signature, ACPI_SIG_SSDT)) |
| 135 | && (ACPI_STRNCMP(table_desc->pointer->signature, "OEM", 3))) { |
Bob Moore | 3b3ea77 | 2012-07-16 09:39:54 +0800 | [diff] [blame] | 136 | ACPI_BIOS_ERROR((AE_INFO, |
| 137 | "Table has invalid signature [%4.4s] (0x%8.8X), " |
| 138 | "must be SSDT or OEMx", |
Bob Moore | de8e7db | 2013-06-08 00:59:44 +0000 | [diff] [blame] | 139 | acpi_ut_valid_acpi_name(table_desc->pointer-> |
Bob Moore | 3b3ea77 | 2012-07-16 09:39:54 +0800 | [diff] [blame] | 140 | signature) ? |
| 141 | table_desc->pointer->signature : "????", |
| 142 | *(u32 *)table_desc->pointer->signature)); |
Bob Moore | c8cefe3 | 2011-06-14 10:42:53 +0800 | [diff] [blame] | 143 | |
| 144 | return_ACPI_STATUS(AE_BAD_SIGNATURE); |
| 145 | } |
Alexey Starikovskiy | 428f211 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 146 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 147 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 148 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 149 | /* Check if table is already registered */ |
| 150 | |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 151 | for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 152 | if (!acpi_gbl_root_table_list.tables[i].pointer) { |
| 153 | status = |
| 154 | acpi_tb_verify_table(&acpi_gbl_root_table_list. |
| 155 | tables[i]); |
| 156 | if (ACPI_FAILURE(status) |
| 157 | || !acpi_gbl_root_table_list.tables[i].pointer) { |
| 158 | continue; |
| 159 | } |
| 160 | } |
| 161 | |
Bob Moore | a6f3053 | 2008-07-04 10:57:51 +0800 | [diff] [blame] | 162 | /* |
| 163 | * Check for a table match on the entire table length, |
| 164 | * not just the header. |
| 165 | */ |
| 166 | if (table_desc->length != |
| 167 | acpi_gbl_root_table_list.tables[i].length) { |
| 168 | continue; |
| 169 | } |
Bob Moore | e56f561 | 2008-07-04 10:48:43 +0800 | [diff] [blame] | 170 | |
Alexey Starikovskiy | 428f211 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 171 | if (ACPI_MEMCMP(table_desc->pointer, |
| 172 | acpi_gbl_root_table_list.tables[i].pointer, |
Bob Moore | a6f3053 | 2008-07-04 10:57:51 +0800 | [diff] [blame] | 173 | acpi_gbl_root_table_list.tables[i].length)) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 174 | continue; |
| 175 | } |
| 176 | |
Bob Moore | e56f561 | 2008-07-04 10:48:43 +0800 | [diff] [blame] | 177 | /* |
| 178 | * Note: the current mechanism does not unregister a table if it is |
| 179 | * dynamically unloaded. The related namespace entries are deleted, |
| 180 | * but the table remains in the root table list. |
| 181 | * |
| 182 | * The assumption here is that the number of different tables that |
| 183 | * will be loaded is actually small, and there is minimal overhead |
| 184 | * in just keeping the table in case it is needed again. |
| 185 | * |
| 186 | * If this assumption changes in the future (perhaps on large |
| 187 | * machines with many table load/unload operations), tables will |
| 188 | * need to be unregistered when they are unloaded, and slots in the |
| 189 | * root table list should be reused when empty. |
| 190 | */ |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 191 | |
Bob Moore | e56f561 | 2008-07-04 10:48:43 +0800 | [diff] [blame] | 192 | /* |
| 193 | * Table is already registered. |
| 194 | * We can delete the table that was passed as a parameter. |
| 195 | */ |
Alexey Starikovskiy | 428f211 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 196 | acpi_tb_delete_table(table_desc); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 197 | *table_index = i; |
Bob Moore | e56f561 | 2008-07-04 10:48:43 +0800 | [diff] [blame] | 198 | |
| 199 | if (acpi_gbl_root_table_list.tables[i]. |
| 200 | flags & ACPI_TABLE_IS_LOADED) { |
| 201 | |
| 202 | /* Table is still loaded, this is an error */ |
| 203 | |
| 204 | status = AE_ALREADY_EXISTS; |
| 205 | goto release; |
| 206 | } else { |
| 207 | /* Table was unloaded, allow it to be reloaded */ |
| 208 | |
| 209 | table_desc->pointer = |
| 210 | acpi_gbl_root_table_list.tables[i].pointer; |
| 211 | table_desc->address = |
| 212 | acpi_gbl_root_table_list.tables[i].address; |
| 213 | status = AE_OK; |
| 214 | goto print_header; |
| 215 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | } |
| 217 | |
Bob Moore | d3ccaff | 2009-02-03 14:43:04 +0800 | [diff] [blame] | 218 | /* |
| 219 | * ACPI Table Override: |
| 220 | * Allow the host to override dynamically loaded tables. |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 221 | * NOTE: the table is fully mapped at this point, and the mapping will |
| 222 | * be deleted by tb_table_override if the table is actually overridden. |
Bob Moore | d3ccaff | 2009-02-03 14:43:04 +0800 | [diff] [blame] | 223 | */ |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 224 | (void)acpi_tb_table_override(table_desc->pointer, table_desc); |
Bob Moore | d3ccaff | 2009-02-03 14:43:04 +0800 | [diff] [blame] | 225 | |
Bob Moore | e56f561 | 2008-07-04 10:48:43 +0800 | [diff] [blame] | 226 | /* Add the table to the global root table list */ |
| 227 | |
Alexey Starikovskiy | 428f211 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 228 | status = acpi_tb_store_table(table_desc->address, table_desc->pointer, |
| 229 | table_desc->length, table_desc->flags, |
| 230 | table_index); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 231 | if (ACPI_FAILURE(status)) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 232 | goto release; |
Robert Moore | 0c9938c | 2005-07-29 15:15:00 -0700 | [diff] [blame] | 233 | } |
| 234 | |
Lv Zheng | 10622bf | 2013-10-29 09:30:02 +0800 | [diff] [blame] | 235 | print_header: |
Alexey Starikovskiy | 428f211 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 236 | acpi_tb_print_table_header(table_desc->address, table_desc->pointer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | |
Lv Zheng | 10622bf | 2013-10-29 09:30:02 +0800 | [diff] [blame] | 238 | release: |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 239 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
| 240 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | } |
| 242 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 243 | /******************************************************************************* |
| 244 | * |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 245 | * FUNCTION: acpi_tb_table_override |
| 246 | * |
| 247 | * PARAMETERS: table_header - Header for the original table |
| 248 | * table_desc - Table descriptor initialized for the |
| 249 | * original table. May or may not be mapped. |
| 250 | * |
| 251 | * RETURN: Pointer to the entire new table. NULL if table not overridden. |
| 252 | * If overridden, installs the new table within the input table |
| 253 | * descriptor. |
| 254 | * |
| 255 | * DESCRIPTION: Attempt table override by calling the OSL override functions. |
| 256 | * Note: If the table is overridden, then the entire new table |
| 257 | * is mapped and returned by this function. |
| 258 | * |
| 259 | ******************************************************************************/ |
| 260 | |
| 261 | struct acpi_table_header *acpi_tb_table_override(struct acpi_table_header |
| 262 | *table_header, |
| 263 | struct acpi_table_desc |
| 264 | *table_desc) |
| 265 | { |
| 266 | acpi_status status; |
| 267 | struct acpi_table_header *new_table = NULL; |
| 268 | acpi_physical_address new_address = 0; |
| 269 | u32 new_table_length = 0; |
| 270 | u8 new_flags; |
| 271 | char *override_type; |
| 272 | |
| 273 | /* (1) Attempt logical override (returns a logical address) */ |
| 274 | |
| 275 | status = acpi_os_table_override(table_header, &new_table); |
| 276 | if (ACPI_SUCCESS(status) && new_table) { |
| 277 | new_address = ACPI_PTR_TO_PHYSADDR(new_table); |
| 278 | new_table_length = new_table->length; |
| 279 | new_flags = ACPI_TABLE_ORIGIN_OVERRIDE; |
| 280 | override_type = "Logical"; |
| 281 | goto finish_override; |
| 282 | } |
| 283 | |
| 284 | /* (2) Attempt physical override (returns a physical address) */ |
| 285 | |
| 286 | status = acpi_os_physical_table_override(table_header, |
| 287 | &new_address, |
| 288 | &new_table_length); |
| 289 | if (ACPI_SUCCESS(status) && new_address && new_table_length) { |
| 290 | |
| 291 | /* Map the entire new table */ |
| 292 | |
| 293 | new_table = acpi_os_map_memory(new_address, new_table_length); |
| 294 | if (!new_table) { |
| 295 | ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY, |
Bob Moore | 2e19f8d | 2014-02-08 09:42:07 +0800 | [diff] [blame] | 296 | "%4.4s " ACPI_PRINTF_UINT |
| 297 | " Attempted physical table override failed", |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 298 | table_header->signature, |
Bob Moore | 2e19f8d | 2014-02-08 09:42:07 +0800 | [diff] [blame] | 299 | ACPI_FORMAT_TO_UINT(table_desc-> |
| 300 | address))); |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 301 | return (NULL); |
| 302 | } |
| 303 | |
| 304 | override_type = "Physical"; |
| 305 | new_flags = ACPI_TABLE_ORIGIN_MAPPED; |
| 306 | goto finish_override; |
| 307 | } |
| 308 | |
| 309 | return (NULL); /* There was no override */ |
| 310 | |
Lv Zheng | 10622bf | 2013-10-29 09:30:02 +0800 | [diff] [blame] | 311 | finish_override: |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 312 | |
Bob Moore | 2e19f8d | 2014-02-08 09:42:07 +0800 | [diff] [blame] | 313 | ACPI_INFO((AE_INFO, "%4.4s " ACPI_PRINTF_UINT |
| 314 | " %s table override, new table: " ACPI_PRINTF_UINT, |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 315 | table_header->signature, |
Bob Moore | 2e19f8d | 2014-02-08 09:42:07 +0800 | [diff] [blame] | 316 | ACPI_FORMAT_TO_UINT(table_desc->address), |
| 317 | override_type, ACPI_FORMAT_TO_UINT(new_table))); |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 318 | |
| 319 | /* We can now unmap/delete the original table (if fully mapped) */ |
| 320 | |
| 321 | acpi_tb_delete_table(table_desc); |
| 322 | |
| 323 | /* Setup descriptor for the new table */ |
| 324 | |
| 325 | table_desc->address = new_address; |
| 326 | table_desc->pointer = new_table; |
| 327 | table_desc->length = new_table_length; |
| 328 | table_desc->flags = new_flags; |
| 329 | |
| 330 | return (new_table); |
| 331 | } |
| 332 | |
| 333 | /******************************************************************************* |
| 334 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 335 | * FUNCTION: acpi_tb_resize_root_table_list |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 336 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 337 | * PARAMETERS: None |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 338 | * |
| 339 | * RETURN: Status |
| 340 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 341 | * DESCRIPTION: Expand the size of global table array |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | * |
| 343 | ******************************************************************************/ |
| 344 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 345 | acpi_status acpi_tb_resize_root_table_list(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 346 | { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 347 | struct acpi_table_desc *tables; |
Lv Zheng | 2bc198c | 2012-09-13 09:29:06 -0700 | [diff] [blame] | 348 | u32 table_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 349 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 350 | ACPI_FUNCTION_TRACE(tb_resize_root_table_list); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 351 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 352 | /* allow_resize flag is a parameter to acpi_initialize_tables */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 353 | |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 354 | if (!(acpi_gbl_root_table_list.flags & ACPI_ROOT_ALLOW_RESIZE)) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 355 | ACPI_ERROR((AE_INFO, |
| 356 | "Resize of Root Table Array is not allowed")); |
| 357 | return_ACPI_STATUS(AE_SUPPORT); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | } |
| 359 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 360 | /* Increase the Table Array size */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | |
Lv Zheng | 2bc198c | 2012-09-13 09:29:06 -0700 | [diff] [blame] | 362 | if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { |
| 363 | table_count = acpi_gbl_root_table_list.max_table_count; |
| 364 | } else { |
| 365 | table_count = acpi_gbl_root_table_list.current_table_count; |
| 366 | } |
| 367 | |
| 368 | tables = ACPI_ALLOCATE_ZEROED(((acpi_size) table_count + |
Bob Moore | ec41f19 | 2009-02-18 15:03:30 +0800 | [diff] [blame] | 369 | ACPI_ROOT_TABLE_SIZE_INCREMENT) * |
| 370 | sizeof(struct acpi_table_desc)); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 371 | if (!tables) { |
| 372 | ACPI_ERROR((AE_INFO, |
| 373 | "Could not allocate new root table array")); |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 374 | return_ACPI_STATUS(AE_NO_MEMORY); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 375 | } |
| 376 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 377 | /* Copy and free the previous table array */ |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 378 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 379 | if (acpi_gbl_root_table_list.tables) { |
| 380 | ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables, |
Lv Zheng | 2bc198c | 2012-09-13 09:29:06 -0700 | [diff] [blame] | 381 | (acpi_size) table_count * |
| 382 | sizeof(struct acpi_table_desc)); |
Robert Moore | f9f4601 | 2005-07-08 00:00:00 -0400 | [diff] [blame] | 383 | |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 384 | if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 385 | ACPI_FREE(acpi_gbl_root_table_list.tables); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 386 | } |
| 387 | } |
| 388 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 389 | acpi_gbl_root_table_list.tables = tables; |
Lv Zheng | 2bc198c | 2012-09-13 09:29:06 -0700 | [diff] [blame] | 390 | acpi_gbl_root_table_list.max_table_count = |
| 391 | table_count + ACPI_ROOT_TABLE_SIZE_INCREMENT; |
| 392 | acpi_gbl_root_table_list.flags |= ACPI_ROOT_ORIGIN_ALLOCATED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 393 | |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 394 | return_ACPI_STATUS(AE_OK); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 395 | } |
| 396 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 397 | /******************************************************************************* |
| 398 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 399 | * FUNCTION: acpi_tb_store_table |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | * |
Bob Moore | ba494be | 2012-07-12 09:40:10 +0800 | [diff] [blame] | 401 | * PARAMETERS: address - Table address |
| 402 | * table - Table header |
| 403 | * length - Table length |
| 404 | * flags - flags |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 405 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 406 | * RETURN: Status and table index. |
| 407 | * |
| 408 | * DESCRIPTION: Add an ACPI table to the global table list |
| 409 | * |
| 410 | ******************************************************************************/ |
| 411 | |
| 412 | acpi_status |
| 413 | acpi_tb_store_table(acpi_physical_address address, |
| 414 | struct acpi_table_header *table, |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 415 | u32 length, u8 flags, u32 *table_index) |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 416 | { |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 417 | acpi_status status; |
| 418 | struct acpi_table_desc *new_table; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 419 | |
| 420 | /* Ensure that there is room for the table in the Root Table List */ |
| 421 | |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 422 | if (acpi_gbl_root_table_list.current_table_count >= |
| 423 | acpi_gbl_root_table_list.max_table_count) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 424 | status = acpi_tb_resize_root_table_list(); |
| 425 | if (ACPI_FAILURE(status)) { |
| 426 | return (status); |
| 427 | } |
| 428 | } |
| 429 | |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 430 | new_table = |
| 431 | &acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list. |
| 432 | current_table_count]; |
| 433 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 434 | /* Initialize added table */ |
| 435 | |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 436 | new_table->address = address; |
| 437 | new_table->pointer = table; |
| 438 | new_table->length = length; |
| 439 | new_table->owner_id = 0; |
| 440 | new_table->flags = flags; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 441 | |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 442 | ACPI_MOVE_32_TO_32(&new_table->signature, table->signature); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 443 | |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 444 | *table_index = acpi_gbl_root_table_list.current_table_count; |
| 445 | acpi_gbl_root_table_list.current_table_count++; |
| 446 | return (AE_OK); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 447 | } |
| 448 | |
| 449 | /******************************************************************************* |
| 450 | * |
| 451 | * FUNCTION: acpi_tb_delete_table |
| 452 | * |
| 453 | * PARAMETERS: table_index - Table index |
| 454 | * |
| 455 | * RETURN: None |
| 456 | * |
| 457 | * DESCRIPTION: Delete one internal ACPI table |
| 458 | * |
| 459 | ******************************************************************************/ |
| 460 | |
Alexey Starikovskiy | 428f211 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 461 | void acpi_tb_delete_table(struct acpi_table_desc *table_desc) |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 462 | { |
Lv Zheng | 5582982 | 2014-04-04 12:38:18 +0800 | [diff] [blame^] | 463 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 464 | /* Table must be mapped or allocated */ |
Lv Zheng | 5582982 | 2014-04-04 12:38:18 +0800 | [diff] [blame^] | 465 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 466 | if (!table_desc->pointer) { |
| 467 | return; |
| 468 | } |
Lv Zheng | 5582982 | 2014-04-04 12:38:18 +0800 | [diff] [blame^] | 469 | |
Alexey Starikovskiy | 428f211 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 470 | switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) { |
| 471 | case ACPI_TABLE_ORIGIN_MAPPED: |
Chao Guan | 1d1ea1b | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 472 | |
Alexey Starikovskiy | 428f211 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 473 | acpi_os_unmap_memory(table_desc->pointer, table_desc->length); |
| 474 | break; |
Chao Guan | 1d1ea1b | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 475 | |
Alexey Starikovskiy | 428f211 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 476 | case ACPI_TABLE_ORIGIN_ALLOCATED: |
Chao Guan | 1d1ea1b | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 477 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 478 | ACPI_FREE(table_desc->pointer); |
Alexey Starikovskiy | 428f211 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 479 | break; |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 480 | |
| 481 | /* Not mapped or allocated, there is nothing we can do */ |
| 482 | |
| 483 | default: |
Chao Guan | 1d1ea1b | 2013-06-08 00:58:14 +0000 | [diff] [blame] | 484 | |
Bob Moore | f7b004a | 2012-02-14 18:31:56 +0800 | [diff] [blame] | 485 | return; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 486 | } |
| 487 | |
| 488 | table_desc->pointer = NULL; |
| 489 | } |
| 490 | |
| 491 | /******************************************************************************* |
| 492 | * |
| 493 | * FUNCTION: acpi_tb_terminate |
| 494 | * |
| 495 | * PARAMETERS: None |
| 496 | * |
| 497 | * RETURN: None |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 498 | * |
| 499 | * DESCRIPTION: Delete all internal ACPI tables |
| 500 | * |
| 501 | ******************************************************************************/ |
| 502 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 503 | void acpi_tb_terminate(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 504 | { |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 505 | u32 i; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 506 | |
| 507 | ACPI_FUNCTION_TRACE(tb_terminate); |
| 508 | |
| 509 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
| 510 | |
| 511 | /* Delete the individual tables */ |
| 512 | |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 513 | for (i = 0; i < acpi_gbl_root_table_list.current_table_count; i++) { |
Alexey Starikovskiy | 428f211 | 2007-02-02 19:48:22 +0300 | [diff] [blame] | 514 | acpi_tb_delete_table(&acpi_gbl_root_table_list.tables[i]); |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 515 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 516 | |
| 517 | /* |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 518 | * Delete the root table array if allocated locally. Array cannot be |
| 519 | * mapped, so we don't need to check for that flag. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 520 | */ |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 521 | if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 522 | ACPI_FREE(acpi_gbl_root_table_list.tables); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 523 | } |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 524 | |
| 525 | acpi_gbl_root_table_list.tables = NULL; |
| 526 | acpi_gbl_root_table_list.flags = 0; |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 527 | acpi_gbl_root_table_list.current_table_count = 0; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 528 | |
| 529 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n")); |
| 530 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
Bob Moore | 68aafc3 | 2012-10-31 02:26:01 +0000 | [diff] [blame] | 531 | |
| 532 | return_VOID; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 533 | } |
| 534 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 535 | /******************************************************************************* |
| 536 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 537 | * FUNCTION: acpi_tb_delete_namespace_by_owner |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 538 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 539 | * PARAMETERS: table_index - Table index |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | * |
Bob Moore | 8a335a23 | 2009-03-09 16:31:04 +0800 | [diff] [blame] | 541 | * RETURN: Status |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 542 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 543 | * DESCRIPTION: Delete all namespace objects created when this table was loaded. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 544 | * |
| 545 | ******************************************************************************/ |
| 546 | |
Bob Moore | 8a335a23 | 2009-03-09 16:31:04 +0800 | [diff] [blame] | 547 | acpi_status acpi_tb_delete_namespace_by_owner(u32 table_index) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 548 | { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 549 | acpi_owner_id owner_id; |
Bob Moore | 8a335a23 | 2009-03-09 16:31:04 +0800 | [diff] [blame] | 550 | acpi_status status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | |
Bob Moore | 8a335a23 | 2009-03-09 16:31:04 +0800 | [diff] [blame] | 552 | ACPI_FUNCTION_TRACE(tb_delete_namespace_by_owner); |
| 553 | |
| 554 | status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
| 555 | if (ACPI_FAILURE(status)) { |
| 556 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 557 | } |
| 558 | |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 559 | if (table_index >= acpi_gbl_root_table_list.current_table_count) { |
Bob Moore | 8a335a23 | 2009-03-09 16:31:04 +0800 | [diff] [blame] | 560 | |
| 561 | /* The table index does not exist */ |
| 562 | |
| 563 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
| 564 | return_ACPI_STATUS(AE_NOT_EXIST); |
| 565 | } |
| 566 | |
| 567 | /* Get the owner ID for this table, used to delete namespace nodes */ |
| 568 | |
| 569 | owner_id = acpi_gbl_root_table_list.tables[table_index].owner_id; |
Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 570 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
Bob Moore | 8a335a23 | 2009-03-09 16:31:04 +0800 | [diff] [blame] | 571 | |
| 572 | /* |
| 573 | * Need to acquire the namespace writer lock to prevent interference |
| 574 | * with any concurrent namespace walks. The interpreter must be |
| 575 | * released during the deletion since the acquisition of the deletion |
| 576 | * lock may block, and also since the execution of a namespace walk |
| 577 | * must be allowed to use the interpreter. |
| 578 | */ |
Bob Moore | e4c1ebf | 2009-04-22 13:02:06 +0800 | [diff] [blame] | 579 | (void)acpi_ut_release_mutex(ACPI_MTX_INTERPRETER); |
Bob Moore | 8a335a23 | 2009-03-09 16:31:04 +0800 | [diff] [blame] | 580 | status = acpi_ut_acquire_write_lock(&acpi_gbl_namespace_rw_lock); |
| 581 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 582 | acpi_ns_delete_namespace_by_owner(owner_id); |
Bob Moore | 8a335a23 | 2009-03-09 16:31:04 +0800 | [diff] [blame] | 583 | if (ACPI_FAILURE(status)) { |
| 584 | return_ACPI_STATUS(status); |
| 585 | } |
| 586 | |
| 587 | acpi_ut_release_write_lock(&acpi_gbl_namespace_rw_lock); |
| 588 | |
| 589 | status = acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER); |
| 590 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 591 | } |
| 592 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 593 | /******************************************************************************* |
| 594 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 595 | * FUNCTION: acpi_tb_allocate_owner_id |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 596 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 597 | * PARAMETERS: table_index - Table index |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 598 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 599 | * RETURN: Status |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 600 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 601 | * DESCRIPTION: Allocates owner_id in table_desc |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 602 | * |
| 603 | ******************************************************************************/ |
| 604 | |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 605 | acpi_status acpi_tb_allocate_owner_id(u32 table_index) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 606 | { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 607 | acpi_status status = AE_BAD_PARAMETER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 608 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 609 | ACPI_FUNCTION_TRACE(tb_allocate_owner_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 611 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 612 | if (table_index < acpi_gbl_root_table_list.current_table_count) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 613 | status = acpi_ut_allocate_owner_id |
| 614 | (&(acpi_gbl_root_table_list.tables[table_index].owner_id)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 615 | } |
| 616 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 617 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
| 618 | return_ACPI_STATUS(status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 619 | } |
| 620 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 621 | /******************************************************************************* |
| 622 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 623 | * FUNCTION: acpi_tb_release_owner_id |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 624 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 625 | * PARAMETERS: table_index - Table index |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 626 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 627 | * RETURN: Status |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 628 | * |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 629 | * DESCRIPTION: Releases owner_id in table_desc |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 630 | * |
| 631 | ******************************************************************************/ |
| 632 | |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 633 | acpi_status acpi_tb_release_owner_id(u32 table_index) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 634 | { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 635 | acpi_status status = AE_BAD_PARAMETER; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 636 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 637 | ACPI_FUNCTION_TRACE(tb_release_owner_id); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 638 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 639 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 640 | if (table_index < acpi_gbl_root_table_list.current_table_count) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 641 | acpi_ut_release_owner_id(& |
| 642 | (acpi_gbl_root_table_list. |
| 643 | tables[table_index].owner_id)); |
| 644 | status = AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 645 | } |
| 646 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 647 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
| 648 | return_ACPI_STATUS(status); |
| 649 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 650 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 651 | /******************************************************************************* |
| 652 | * |
| 653 | * FUNCTION: acpi_tb_get_owner_id |
| 654 | * |
| 655 | * PARAMETERS: table_index - Table index |
| 656 | * owner_id - Where the table owner_id is returned |
| 657 | * |
| 658 | * RETURN: Status |
| 659 | * |
| 660 | * DESCRIPTION: returns owner_id for the ACPI table |
| 661 | * |
| 662 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 663 | |
Lv Zheng | 5582982 | 2014-04-04 12:38:18 +0800 | [diff] [blame^] | 664 | 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] | 665 | { |
| 666 | acpi_status status = AE_BAD_PARAMETER; |
| 667 | |
| 668 | ACPI_FUNCTION_TRACE(tb_get_owner_id); |
| 669 | |
| 670 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 671 | if (table_index < acpi_gbl_root_table_list.current_table_count) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 672 | *owner_id = |
| 673 | acpi_gbl_root_table_list.tables[table_index].owner_id; |
| 674 | status = AE_OK; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | } |
| 676 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 677 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
| 678 | return_ACPI_STATUS(status); |
| 679 | } |
| 680 | |
| 681 | /******************************************************************************* |
| 682 | * |
| 683 | * FUNCTION: acpi_tb_is_table_loaded |
| 684 | * |
| 685 | * PARAMETERS: table_index - Table index |
| 686 | * |
| 687 | * RETURN: Table Loaded Flag |
| 688 | * |
| 689 | ******************************************************************************/ |
| 690 | |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 691 | u8 acpi_tb_is_table_loaded(u32 table_index) |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 692 | { |
| 693 | u8 is_loaded = FALSE; |
| 694 | |
| 695 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 696 | if (table_index < acpi_gbl_root_table_list.current_table_count) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 697 | is_loaded = (u8) |
Bob Moore | ec41f19 | 2009-02-18 15:03:30 +0800 | [diff] [blame] | 698 | (acpi_gbl_root_table_list.tables[table_index].flags & |
| 699 | ACPI_TABLE_IS_LOADED); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 700 | } |
| 701 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 702 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
| 703 | return (is_loaded); |
| 704 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 705 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 706 | /******************************************************************************* |
| 707 | * |
| 708 | * FUNCTION: acpi_tb_set_table_loaded_flag |
| 709 | * |
| 710 | * PARAMETERS: table_index - Table index |
| 711 | * is_loaded - TRUE if table is loaded, FALSE otherwise |
| 712 | * |
| 713 | * RETURN: None |
| 714 | * |
| 715 | * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE. |
| 716 | * |
| 717 | ******************************************************************************/ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 718 | |
Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 719 | 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] | 720 | { |
Bob Moore | f6dd922 | 2006-07-07 20:44:38 -0400 | [diff] [blame] | 721 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 722 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
Bob Moore | b9ee204 | 2010-04-27 11:16:14 +0800 | [diff] [blame] | 723 | if (table_index < acpi_gbl_root_table_list.current_table_count) { |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 724 | if (is_loaded) { |
| 725 | acpi_gbl_root_table_list.tables[table_index].flags |= |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 726 | ACPI_TABLE_IS_LOADED; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 727 | } else { |
| 728 | acpi_gbl_root_table_list.tables[table_index].flags &= |
Bob Moore | c5fc42a | 2007-02-02 19:48:19 +0300 | [diff] [blame] | 729 | ~ACPI_TABLE_IS_LOADED; |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 730 | } |
| 731 | } |
Bob Moore | f6dd922 | 2006-07-07 20:44:38 -0400 | [diff] [blame] | 732 | |
Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 733 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 734 | } |