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