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