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