blob: d3e1db225cb2d1ecdb10a6180b98e6aaef761c49 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/******************************************************************************
2 *
3 * Module Name: tbinstal - ACPI table installation and removal
4 *
5 *****************************************************************************/
6
7/*
Bob Moorefbb7a2d2014-02-08 09:42:25 +08008 * Copyright (C) 2000 - 2014, Intel Corp.
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * 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 Torvalds1da177e2005-04-16 15:20:36 -070044#include <acpi/acpi.h>
Len Browne2f7a772009-01-09 00:30:03 -050045#include "accommon.h"
46#include "acnamesp.h"
47#include "actables.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
Linus Torvalds1da177e2005-04-16 15:20:36 -070049#define _COMPONENT ACPI_TABLES
Len Brown4be44fc2005-08-05 00:44:28 -040050ACPI_MODULE_NAME("tbinstal")
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
Lv Zheng7f9fc992014-04-04 12:38:42 +080052/*******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -070053 *
Lv Zheng7f9fc992014-04-04 12:38:42 +080054 * FUNCTION: acpi_tb_acquire_table
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 *
Lv Zheng7f9fc992014-04-04 12:38:42 +080056 * PARAMETERS: table_desc - Table descriptor
57 * table_ptr - Where table is returned
58 * table_length - Where table length is returned
59 * table_flags - Where table allocation flags are returned
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 *
61 * RETURN: Status
62 *
Lv Zheng7f9fc992014-04-04 12:38:42 +080063 * DESCRIPTION: Acquire a table. It can be used for tables not maintained in
64 * acpi_gbl_root_table_list.
65 *
66 ******************************************************************************/
67acpi_status
68acpi_tb_acquire_table(struct acpi_table_desc *table_desc,
69 struct acpi_table_header **table_ptr,
70 u32 *table_length, u8 *table_flags)
71{
72 struct acpi_table_header *table = NULL;
73
74 switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) {
75 case ACPI_TABLE_ORIGIN_MAPPED:
76
77 table =
78 acpi_os_map_memory(table_desc->address, table_desc->length);
79 break;
80
81 case ACPI_TABLE_ORIGIN_ALLOCATED:
82 case ACPI_TABLE_ORIGIN_UNKNOWN:
83 case ACPI_TABLE_ORIGIN_OVERRIDE:
84
85 table =
86 ACPI_CAST_PTR(struct acpi_table_header,
87 table_desc->address);
88 break;
89
90 default:
91
92 break;
93 }
94
95 /* Table is not valid yet */
96
97 if (!table) {
98 return (AE_NO_MEMORY);
99 }
100
101 /* Fill the return values */
102
103 *table_ptr = table;
104 *table_length = table_desc->length;
105 *table_flags = table_desc->flags;
106
107 return (AE_OK);
108}
109
110/*******************************************************************************
111 *
112 * FUNCTION: acpi_tb_release_table
113 *
114 * PARAMETERS: table - Pointer for the table
115 * table_length - Length for the table
116 * table_flags - Allocation flags for the table
117 *
118 * RETURN: None
119 *
120 * DESCRIPTION: Release a table. The reversal of acpi_tb_acquire_table().
121 *
122 ******************************************************************************/
123
124void
125acpi_tb_release_table(struct acpi_table_header *table,
126 u32 table_length, u8 table_flags)
127{
128 switch (table_flags & ACPI_TABLE_ORIGIN_MASK) {
129 case ACPI_TABLE_ORIGIN_MAPPED:
130
131 acpi_os_unmap_memory(table, table_length);
132 break;
133
134 case ACPI_TABLE_ORIGIN_ALLOCATED:
135 case ACPI_TABLE_ORIGIN_UNKNOWN:
136 case ACPI_TABLE_ORIGIN_OVERRIDE:
137 default:
138
139 break;
140 }
141}
142
143/******************************************************************************
144 *
145 * FUNCTION: acpi_tb_validate_table
146 *
147 * PARAMETERS: table_desc - Table descriptor
148 *
149 * RETURN: Status
150 *
151 * DESCRIPTION: This function is called to validate (ensure Pointer is valid)
152 * and verify the table.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300154 *****************************************************************************/
Lv Zheng7f9fc992014-04-04 12:38:42 +0800155
156acpi_status acpi_tb_validate_table(struct acpi_table_desc *table_desc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157{
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300158 acpi_status status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700159
Lv Zheng7f9fc992014-04-04 12:38:42 +0800160 ACPI_FUNCTION_TRACE(tb_validate_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161
Lv Zheng7f9fc992014-04-04 12:38:42 +0800162 /* Validate the table if necessary */
Robert Moore44f6c012005-04-18 22:49:35 -0400163
Bob Mooref3d2e782007-02-02 19:48:18 +0300164 if (!table_desc->pointer) {
Lv Zheng7f9fc992014-04-04 12:38:42 +0800165 status = acpi_tb_acquire_table(table_desc, &table_desc->pointer,
166 &table_desc->length,
167 &table_desc->flags);
168 if (ACPI_FAILURE(status) || !table_desc->pointer) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300169 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 }
171 }
172
Lv Zheng94d4be62013-09-23 09:52:29 +0800173 /* Always calculate checksum, ignore bad checksum if requested */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174
Lv Zheng94d4be62013-09-23 09:52:29 +0800175 status =
176 acpi_tb_verify_checksum(table_desc->pointer, table_desc->length);
Bob Mooref3d2e782007-02-02 19:48:18 +0300177
Bob Moorec5fc42a2007-02-02 19:48:19 +0300178 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179}
180
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181/*******************************************************************************
182 *
Lv Zheng7f9fc992014-04-04 12:38:42 +0800183 * FUNCTION: acpi_tb_invalidate_table
184 *
185 * PARAMETERS: table_desc - Table descriptor
186 *
187 * RETURN: None
188 *
189 * DESCRIPTION: Invalidate one internal ACPI table, this is reversal of
190 * acpi_tb_validate_table().
191 *
192 ******************************************************************************/
193
194void acpi_tb_invalidate_table(struct acpi_table_desc *table_desc)
195{
196
197 ACPI_FUNCTION_TRACE(tb_invalidate_table);
198
199 /* Table must be validated */
200
201 if (!table_desc->pointer) {
202 return_VOID;
203 }
204
205 acpi_tb_release_table(table_desc->pointer, table_desc->length,
206 table_desc->flags);
207 table_desc->pointer = NULL;
208
209 return_VOID;
210}
211
212/*******************************************************************************
213 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300214 * FUNCTION: acpi_tb_add_table
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215 *
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300216 * PARAMETERS: table_desc - Table descriptor
Bob Mooref3d2e782007-02-02 19:48:18 +0300217 * table_index - Where the table index is returned
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 *
219 * RETURN: Status
220 *
Bob Moored3ccaff2009-02-03 14:43:04 +0800221 * DESCRIPTION: This function is called to add an ACPI table. It is used to
222 * dynamically load tables via the Load and load_table AML
223 * operators.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224 *
225 ******************************************************************************/
226
Bob Mooref3d2e782007-02-02 19:48:18 +0300227acpi_status
Bob Moore67a119f2008-06-10 13:42:13 +0800228acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229{
Bob Moore67a119f2008-06-10 13:42:13 +0800230 u32 i;
Bob Mooref3d2e782007-02-02 19:48:18 +0300231 acpi_status status = AE_OK;
Lv Zheng7f9fc992014-04-04 12:38:42 +0800232 struct acpi_table_header *final_table;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233
Bob Mooref3d2e782007-02-02 19:48:18 +0300234 ACPI_FUNCTION_TRACE(tb_add_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300236 if (!table_desc->pointer) {
Lv Zheng7f9fc992014-04-04 12:38:42 +0800237 status = acpi_tb_validate_table(table_desc);
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300238 if (ACPI_FAILURE(status) || !table_desc->pointer) {
Lv Zhengeb0c65b2014-04-04 12:38:50 +0800239 acpi_tb_invalidate_table(table_desc);
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300240 return_ACPI_STATUS(status);
241 }
242 }
243
Bob Moorebc45b1d2008-06-10 14:12:50 +0800244 /*
Bob Moorec8cefe32011-06-14 10:42:53 +0800245 * Validate the incoming table signature.
246 *
247 * 1) Originally, we checked the table signature for "SSDT" or "PSDT".
248 * 2) We added support for OEMx tables, signature "OEM".
249 * 3) Valid tables were encountered with a null signature, so we just
250 * gave up on validating the signature, (05/2008).
251 * 4) We encountered non-AML tables such as the MADT, which caused
252 * interpreter errors and kernel faults. So now, we once again allow
253 * only "SSDT", "OEMx", and now, also a null signature. (05/2011).
Bob Moorebc45b1d2008-06-10 14:12:50 +0800254 */
Bob Moorec8cefe32011-06-14 10:42:53 +0800255 if ((table_desc->pointer->signature[0] != 0x00) &&
256 (!ACPI_COMPARE_NAME(table_desc->pointer->signature, ACPI_SIG_SSDT))
257 && (ACPI_STRNCMP(table_desc->pointer->signature, "OEM", 3))) {
Bob Moore3b3ea772012-07-16 09:39:54 +0800258 ACPI_BIOS_ERROR((AE_INFO,
259 "Table has invalid signature [%4.4s] (0x%8.8X), "
260 "must be SSDT or OEMx",
Bob Moorede8e7db2013-06-08 00:59:44 +0000261 acpi_ut_valid_acpi_name(table_desc->pointer->
Bob Moore3b3ea772012-07-16 09:39:54 +0800262 signature) ?
263 table_desc->pointer->signature : "????",
264 *(u32 *)table_desc->pointer->signature));
Bob Moorec8cefe32011-06-14 10:42:53 +0800265
266 return_ACPI_STATUS(AE_BAD_SIGNATURE);
267 }
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300268
Bob Mooref3d2e782007-02-02 19:48:18 +0300269 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270
Bob Mooref3d2e782007-02-02 19:48:18 +0300271 /* Check if table is already registered */
272
Bob Mooreb9ee2042010-04-27 11:16:14 +0800273 for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300274 if (!acpi_gbl_root_table_list.tables[i].pointer) {
275 status =
Lv Zheng7f9fc992014-04-04 12:38:42 +0800276 acpi_tb_validate_table(&acpi_gbl_root_table_list.
277 tables[i]);
Bob Mooref3d2e782007-02-02 19:48:18 +0300278 if (ACPI_FAILURE(status)
279 || !acpi_gbl_root_table_list.tables[i].pointer) {
280 continue;
281 }
282 }
283
Bob Moorea6f30532008-07-04 10:57:51 +0800284 /*
285 * Check for a table match on the entire table length,
286 * not just the header.
287 */
288 if (table_desc->length !=
289 acpi_gbl_root_table_list.tables[i].length) {
290 continue;
291 }
Bob Mooree56f5612008-07-04 10:48:43 +0800292
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300293 if (ACPI_MEMCMP(table_desc->pointer,
294 acpi_gbl_root_table_list.tables[i].pointer,
Bob Moorea6f30532008-07-04 10:57:51 +0800295 acpi_gbl_root_table_list.tables[i].length)) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300296 continue;
297 }
298
Bob Mooree56f5612008-07-04 10:48:43 +0800299 /*
300 * Note: the current mechanism does not unregister a table if it is
301 * dynamically unloaded. The related namespace entries are deleted,
302 * but the table remains in the root table list.
303 *
304 * The assumption here is that the number of different tables that
305 * will be loaded is actually small, and there is minimal overhead
306 * in just keeping the table in case it is needed again.
307 *
308 * If this assumption changes in the future (perhaps on large
309 * machines with many table load/unload operations), tables will
310 * need to be unregistered when they are unloaded, and slots in the
311 * root table list should be reused when empty.
312 */
Bob Mooref3d2e782007-02-02 19:48:18 +0300313 *table_index = i;
Bob Mooree56f5612008-07-04 10:48:43 +0800314
315 if (acpi_gbl_root_table_list.tables[i].
316 flags & ACPI_TABLE_IS_LOADED) {
317
318 /* Table is still loaded, this is an error */
319
320 status = AE_ALREADY_EXISTS;
321 goto release;
322 } else {
323 /* Table was unloaded, allow it to be reloaded */
324
Lv Zheng7f9fc992014-04-04 12:38:42 +0800325 acpi_tb_uninstall_table(table_desc);
Bob Mooree56f5612008-07-04 10:48:43 +0800326 table_desc->pointer =
327 acpi_gbl_root_table_list.tables[i].pointer;
328 table_desc->address =
329 acpi_gbl_root_table_list.tables[i].address;
330 status = AE_OK;
331 goto print_header;
332 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 }
334
Bob Moored3ccaff2009-02-03 14:43:04 +0800335 /*
336 * ACPI Table Override:
337 * Allow the host to override dynamically loaded tables.
Bob Mooref7b004a2012-02-14 18:31:56 +0800338 * NOTE: the table is fully mapped at this point, and the mapping will
Lv Zheng7f9fc992014-04-04 12:38:42 +0800339 * be deleted by acpi_tb_override_table if the table is actually overridden.
Bob Moored3ccaff2009-02-03 14:43:04 +0800340 */
Lv Zheng7f9fc992014-04-04 12:38:42 +0800341 final_table = acpi_tb_override_table(table_desc->pointer, table_desc);
342 if (final_table) {
343
344 /* Ensure table descriptor is in "VALIDATED" state */
345
346 table_desc->pointer = final_table;
347 }
Bob Moored3ccaff2009-02-03 14:43:04 +0800348
Bob Mooree56f5612008-07-04 10:48:43 +0800349 /* Add the table to the global root table list */
350
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300351 status = acpi_tb_store_table(table_desc->address, table_desc->pointer,
352 table_desc->length, table_desc->flags,
353 table_index);
Len Brown4be44fc2005-08-05 00:44:28 -0400354 if (ACPI_FAILURE(status)) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300355 goto release;
Robert Moore0c9938c2005-07-29 15:15:00 -0700356 }
357
Lv Zheng10622bf2013-10-29 09:30:02 +0800358print_header:
Alexey Starikovskiy428f2112007-02-02 19:48:22 +0300359 acpi_tb_print_table_header(table_desc->address, table_desc->pointer);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700360
Lv Zheng10622bf2013-10-29 09:30:02 +0800361release:
Len Brown4be44fc2005-08-05 00:44:28 -0400362 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
363 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364}
365
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366/*******************************************************************************
367 *
Lv Zheng7f9fc992014-04-04 12:38:42 +0800368 * FUNCTION: acpi_tb_override_table
Bob Mooref7b004a2012-02-14 18:31:56 +0800369 *
370 * PARAMETERS: table_header - Header for the original table
371 * table_desc - Table descriptor initialized for the
372 * original table. May or may not be mapped.
373 *
374 * RETURN: Pointer to the entire new table. NULL if table not overridden.
375 * If overridden, installs the new table within the input table
376 * descriptor.
377 *
378 * DESCRIPTION: Attempt table override by calling the OSL override functions.
379 * Note: If the table is overridden, then the entire new table
Lv Zheng7f9fc992014-04-04 12:38:42 +0800380 * is acquired and returned by this function.
381 * After invocation, the table descriptor is in a state that is
382 * "INSTALLED" but not "VALIDATED", thus the "Pointer" member is
383 * kept NULL.
Bob Mooref7b004a2012-02-14 18:31:56 +0800384 *
385 ******************************************************************************/
386
Lv Zheng7f9fc992014-04-04 12:38:42 +0800387struct acpi_table_header *acpi_tb_override_table(struct acpi_table_header
Bob Mooref7b004a2012-02-14 18:31:56 +0800388 *table_header,
389 struct acpi_table_desc
390 *table_desc)
391{
392 acpi_status status;
Lv Zheng7f9fc992014-04-04 12:38:42 +0800393 struct acpi_table_header *new_table;
394 u32 new_table_length;
Bob Mooref7b004a2012-02-14 18:31:56 +0800395 u8 new_flags;
396 char *override_type;
Lv Zheng7f9fc992014-04-04 12:38:42 +0800397 struct acpi_table_desc new_table_desc;
398
399 ACPI_MEMSET(&new_table_desc, 0, sizeof(struct acpi_table_desc));
Bob Mooref7b004a2012-02-14 18:31:56 +0800400
401 /* (1) Attempt logical override (returns a logical address) */
402
Lv Zheng7f9fc992014-04-04 12:38:42 +0800403 status = acpi_os_table_override(table_header, &new_table_desc.pointer);
404 if (ACPI_SUCCESS(status) && new_table_desc.pointer) {
405 new_table_desc.address =
406 ACPI_PTR_TO_PHYSADDR(new_table_desc.pointer);
407 new_table_desc.length = new_table_desc.pointer->length;
408 new_table_desc.flags = ACPI_TABLE_ORIGIN_OVERRIDE;
Bob Mooref7b004a2012-02-14 18:31:56 +0800409 override_type = "Logical";
410 goto finish_override;
411 }
412
413 /* (2) Attempt physical override (returns a physical address) */
414
415 status = acpi_os_physical_table_override(table_header,
Lv Zheng7f9fc992014-04-04 12:38:42 +0800416 &new_table_desc.address,
417 &new_table_desc.length);
418 if (ACPI_SUCCESS(status) && new_table_desc.address
419 && new_table_desc.length) {
Bob Mooref7b004a2012-02-14 18:31:56 +0800420 override_type = "Physical";
Lv Zheng7f9fc992014-04-04 12:38:42 +0800421 new_table_desc.flags = ACPI_TABLE_ORIGIN_MAPPED;
Bob Mooref7b004a2012-02-14 18:31:56 +0800422 goto finish_override;
423 }
424
425 return (NULL); /* There was no override */
426
Lv Zheng10622bf2013-10-29 09:30:02 +0800427finish_override:
Bob Mooref7b004a2012-02-14 18:31:56 +0800428
Lv Zheng7f9fc992014-04-04 12:38:42 +0800429 /*
430 * Acquire the entire new table to indicate overridden.
431 * Note that this is required by the callers of this function.
432 */
433 status = acpi_tb_acquire_table(&new_table_desc, &new_table,
434 &new_table_length, &new_flags);
435 if (ACPI_FAILURE(status)) {
436 ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY,
437 "%4.4s " ACPI_PRINTF_UINT
438 " Attempted table override failed",
439 table_header->signature,
440 ACPI_FORMAT_TO_UINT(table_desc->address)));
441 return (NULL);
442 }
443
Bob Moore2e19f8d2014-02-08 09:42:07 +0800444 ACPI_INFO((AE_INFO, "%4.4s " ACPI_PRINTF_UINT
445 " %s table override, new table: " ACPI_PRINTF_UINT,
Bob Mooref7b004a2012-02-14 18:31:56 +0800446 table_header->signature,
Bob Moore2e19f8d2014-02-08 09:42:07 +0800447 ACPI_FORMAT_TO_UINT(table_desc->address),
Lv Zheng7f9fc992014-04-04 12:38:42 +0800448 override_type, ACPI_FORMAT_TO_UINT(new_table_desc.address)));
Bob Mooref7b004a2012-02-14 18:31:56 +0800449
Lv Zheng7f9fc992014-04-04 12:38:42 +0800450 /* We can now uninstall the original table (if fully mapped) */
Bob Mooref7b004a2012-02-14 18:31:56 +0800451
Lv Zheng7f9fc992014-04-04 12:38:42 +0800452 acpi_tb_uninstall_table(table_desc);
Bob Mooref7b004a2012-02-14 18:31:56 +0800453
Lv Zheng7f9fc992014-04-04 12:38:42 +0800454 /* Install the new table */
Bob Mooref7b004a2012-02-14 18:31:56 +0800455
Lv Zheng7f9fc992014-04-04 12:38:42 +0800456 table_desc->address = new_table_desc.address;
457 table_desc->length = new_table_desc.length;
458 table_desc->flags = new_table_desc.flags;
Bob Mooref7b004a2012-02-14 18:31:56 +0800459
460 return (new_table);
461}
462
463/*******************************************************************************
464 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300465 * FUNCTION: acpi_tb_resize_root_table_list
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300467 * PARAMETERS: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468 *
469 * RETURN: Status
470 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300471 * DESCRIPTION: Expand the size of global table array
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 *
473 ******************************************************************************/
474
Bob Mooref3d2e782007-02-02 19:48:18 +0300475acpi_status acpi_tb_resize_root_table_list(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476{
Bob Mooref3d2e782007-02-02 19:48:18 +0300477 struct acpi_table_desc *tables;
Lv Zheng2bc198c2012-09-13 09:29:06 -0700478 u32 table_count;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479
Bob Mooref3d2e782007-02-02 19:48:18 +0300480 ACPI_FUNCTION_TRACE(tb_resize_root_table_list);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700481
Bob Mooref3d2e782007-02-02 19:48:18 +0300482 /* allow_resize flag is a parameter to acpi_initialize_tables */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483
Bob Moorec5fc42a2007-02-02 19:48:19 +0300484 if (!(acpi_gbl_root_table_list.flags & ACPI_ROOT_ALLOW_RESIZE)) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300485 ACPI_ERROR((AE_INFO,
486 "Resize of Root Table Array is not allowed"));
487 return_ACPI_STATUS(AE_SUPPORT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488 }
489
Bob Mooref3d2e782007-02-02 19:48:18 +0300490 /* Increase the Table Array size */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700491
Lv Zheng2bc198c2012-09-13 09:29:06 -0700492 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
493 table_count = acpi_gbl_root_table_list.max_table_count;
494 } else {
495 table_count = acpi_gbl_root_table_list.current_table_count;
496 }
497
498 tables = ACPI_ALLOCATE_ZEROED(((acpi_size) table_count +
Bob Mooreec41f192009-02-18 15:03:30 +0800499 ACPI_ROOT_TABLE_SIZE_INCREMENT) *
500 sizeof(struct acpi_table_desc));
Bob Mooref3d2e782007-02-02 19:48:18 +0300501 if (!tables) {
502 ACPI_ERROR((AE_INFO,
503 "Could not allocate new root table array"));
Len Brown4be44fc2005-08-05 00:44:28 -0400504 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505 }
506
Bob Mooref3d2e782007-02-02 19:48:18 +0300507 /* Copy and free the previous table array */
Robert Mooref9f46012005-07-08 00:00:00 -0400508
Bob Mooref3d2e782007-02-02 19:48:18 +0300509 if (acpi_gbl_root_table_list.tables) {
510 ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables,
Lv Zheng2bc198c2012-09-13 09:29:06 -0700511 (acpi_size) table_count *
512 sizeof(struct acpi_table_desc));
Robert Mooref9f46012005-07-08 00:00:00 -0400513
Bob Moorec5fc42a2007-02-02 19:48:19 +0300514 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300515 ACPI_FREE(acpi_gbl_root_table_list.tables);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516 }
517 }
518
Bob Mooref3d2e782007-02-02 19:48:18 +0300519 acpi_gbl_root_table_list.tables = tables;
Lv Zheng2bc198c2012-09-13 09:29:06 -0700520 acpi_gbl_root_table_list.max_table_count =
521 table_count + ACPI_ROOT_TABLE_SIZE_INCREMENT;
522 acpi_gbl_root_table_list.flags |= ACPI_ROOT_ORIGIN_ALLOCATED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523
Len Brown4be44fc2005-08-05 00:44:28 -0400524 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525}
526
Linus Torvalds1da177e2005-04-16 15:20:36 -0700527/*******************************************************************************
528 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300529 * FUNCTION: acpi_tb_store_table
Linus Torvalds1da177e2005-04-16 15:20:36 -0700530 *
Bob Mooreba494be2012-07-12 09:40:10 +0800531 * PARAMETERS: address - Table address
532 * table - Table header
533 * length - Table length
534 * flags - flags
Linus Torvalds1da177e2005-04-16 15:20:36 -0700535 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300536 * RETURN: Status and table index.
537 *
538 * DESCRIPTION: Add an ACPI table to the global table list
539 *
540 ******************************************************************************/
541
542acpi_status
543acpi_tb_store_table(acpi_physical_address address,
544 struct acpi_table_header *table,
Bob Moore67a119f2008-06-10 13:42:13 +0800545 u32 length, u8 flags, u32 *table_index)
Bob Mooref3d2e782007-02-02 19:48:18 +0300546{
Bob Mooreb9ee2042010-04-27 11:16:14 +0800547 acpi_status status;
548 struct acpi_table_desc *new_table;
Bob Mooref3d2e782007-02-02 19:48:18 +0300549
550 /* Ensure that there is room for the table in the Root Table List */
551
Bob Mooreb9ee2042010-04-27 11:16:14 +0800552 if (acpi_gbl_root_table_list.current_table_count >=
553 acpi_gbl_root_table_list.max_table_count) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300554 status = acpi_tb_resize_root_table_list();
555 if (ACPI_FAILURE(status)) {
556 return (status);
557 }
558 }
559
Bob Mooreb9ee2042010-04-27 11:16:14 +0800560 new_table =
561 &acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.
562 current_table_count];
563
Bob Mooref3d2e782007-02-02 19:48:18 +0300564 /* Initialize added table */
565
Bob Mooreb9ee2042010-04-27 11:16:14 +0800566 new_table->address = address;
567 new_table->pointer = table;
568 new_table->length = length;
569 new_table->owner_id = 0;
570 new_table->flags = flags;
Bob Mooref3d2e782007-02-02 19:48:18 +0300571
Bob Mooreb9ee2042010-04-27 11:16:14 +0800572 ACPI_MOVE_32_TO_32(&new_table->signature, table->signature);
Bob Mooref3d2e782007-02-02 19:48:18 +0300573
Bob Mooreb9ee2042010-04-27 11:16:14 +0800574 *table_index = acpi_gbl_root_table_list.current_table_count;
575 acpi_gbl_root_table_list.current_table_count++;
576 return (AE_OK);
Bob Mooref3d2e782007-02-02 19:48:18 +0300577}
578
579/*******************************************************************************
580 *
Lv Zheng7f9fc992014-04-04 12:38:42 +0800581 * FUNCTION: acpi_tb_uninstall_table
Bob Mooref3d2e782007-02-02 19:48:18 +0300582 *
Lv Zheng7f9fc992014-04-04 12:38:42 +0800583 * PARAMETERS: table_desc - Table descriptor
Bob Mooref3d2e782007-02-02 19:48:18 +0300584 *
585 * RETURN: None
586 *
587 * DESCRIPTION: Delete one internal ACPI table
588 *
589 ******************************************************************************/
590
Lv Zheng7f9fc992014-04-04 12:38:42 +0800591void acpi_tb_uninstall_table(struct acpi_table_desc *table_desc)
Bob Mooref3d2e782007-02-02 19:48:18 +0300592{
Lv Zheng55829822014-04-04 12:38:18 +0800593
Lv Zheng7f9fc992014-04-04 12:38:42 +0800594 ACPI_FUNCTION_TRACE(tb_uninstall_table);
Lv Zheng55829822014-04-04 12:38:18 +0800595
Lv Zheng7f9fc992014-04-04 12:38:42 +0800596 /* Table must be installed */
597
598 if (!table_desc->address) {
599 return_VOID;
Bob Mooref3d2e782007-02-02 19:48:18 +0300600 }
Lv Zheng55829822014-04-04 12:38:18 +0800601
Lv Zheng7f9fc992014-04-04 12:38:42 +0800602 acpi_tb_invalidate_table(table_desc);
Chao Guan1d1ea1b2013-06-08 00:58:14 +0000603
Lv Zheng7f9fc992014-04-04 12:38:42 +0800604 if ((table_desc->flags & ACPI_TABLE_ORIGIN_MASK) ==
605 ACPI_TABLE_ORIGIN_ALLOCATED) {
606 ACPI_FREE(ACPI_CAST_PTR(void, table_desc->address));
Bob Mooref3d2e782007-02-02 19:48:18 +0300607 }
608
Lv Zheng7f9fc992014-04-04 12:38:42 +0800609 table_desc->address = ACPI_PTR_TO_PHYSADDR(NULL);
610
611 return_VOID;
Bob Mooref3d2e782007-02-02 19:48:18 +0300612}
613
614/*******************************************************************************
615 *
616 * FUNCTION: acpi_tb_terminate
617 *
618 * PARAMETERS: None
619 *
620 * RETURN: None
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621 *
622 * DESCRIPTION: Delete all internal ACPI tables
623 *
624 ******************************************************************************/
625
Bob Mooref3d2e782007-02-02 19:48:18 +0300626void acpi_tb_terminate(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627{
Bob Moore67a119f2008-06-10 13:42:13 +0800628 u32 i;
Bob Mooref3d2e782007-02-02 19:48:18 +0300629
630 ACPI_FUNCTION_TRACE(tb_terminate);
631
632 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
633
634 /* Delete the individual tables */
635
Bob Mooreb9ee2042010-04-27 11:16:14 +0800636 for (i = 0; i < acpi_gbl_root_table_list.current_table_count; i++) {
Lv Zheng7f9fc992014-04-04 12:38:42 +0800637 acpi_tb_uninstall_table(&acpi_gbl_root_table_list.tables[i]);
Bob Mooref3d2e782007-02-02 19:48:18 +0300638 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700639
640 /*
Bob Mooref3d2e782007-02-02 19:48:18 +0300641 * Delete the root table array if allocated locally. Array cannot be
642 * mapped, so we don't need to check for that flag.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643 */
Bob Moorec5fc42a2007-02-02 19:48:19 +0300644 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300645 ACPI_FREE(acpi_gbl_root_table_list.tables);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 }
Bob Mooref3d2e782007-02-02 19:48:18 +0300647
648 acpi_gbl_root_table_list.tables = NULL;
649 acpi_gbl_root_table_list.flags = 0;
Bob Mooreb9ee2042010-04-27 11:16:14 +0800650 acpi_gbl_root_table_list.current_table_count = 0;
Bob Mooref3d2e782007-02-02 19:48:18 +0300651
652 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n"));
653 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Bob Moore68aafc32012-10-31 02:26:01 +0000654
655 return_VOID;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656}
657
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658/*******************************************************************************
659 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300660 * FUNCTION: acpi_tb_delete_namespace_by_owner
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300662 * PARAMETERS: table_index - Table index
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663 *
Bob Moore8a335a232009-03-09 16:31:04 +0800664 * RETURN: Status
Linus Torvalds1da177e2005-04-16 15:20:36 -0700665 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300666 * DESCRIPTION: Delete all namespace objects created when this table was loaded.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700667 *
668 ******************************************************************************/
669
Bob Moore8a335a232009-03-09 16:31:04 +0800670acpi_status acpi_tb_delete_namespace_by_owner(u32 table_index)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700671{
Bob Mooref3d2e782007-02-02 19:48:18 +0300672 acpi_owner_id owner_id;
Bob Moore8a335a232009-03-09 16:31:04 +0800673 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674
Bob Moore8a335a232009-03-09 16:31:04 +0800675 ACPI_FUNCTION_TRACE(tb_delete_namespace_by_owner);
676
677 status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
678 if (ACPI_FAILURE(status)) {
679 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680 }
681
Bob Mooreb9ee2042010-04-27 11:16:14 +0800682 if (table_index >= acpi_gbl_root_table_list.current_table_count) {
Bob Moore8a335a232009-03-09 16:31:04 +0800683
684 /* The table index does not exist */
685
686 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
687 return_ACPI_STATUS(AE_NOT_EXIST);
688 }
689
690 /* Get the owner ID for this table, used to delete namespace nodes */
691
692 owner_id = acpi_gbl_root_table_list.tables[table_index].owner_id;
Len Brown4be44fc2005-08-05 00:44:28 -0400693 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Bob Moore8a335a232009-03-09 16:31:04 +0800694
695 /*
696 * Need to acquire the namespace writer lock to prevent interference
697 * with any concurrent namespace walks. The interpreter must be
698 * released during the deletion since the acquisition of the deletion
699 * lock may block, and also since the execution of a namespace walk
700 * must be allowed to use the interpreter.
701 */
Bob Mooree4c1ebf2009-04-22 13:02:06 +0800702 (void)acpi_ut_release_mutex(ACPI_MTX_INTERPRETER);
Bob Moore8a335a232009-03-09 16:31:04 +0800703 status = acpi_ut_acquire_write_lock(&acpi_gbl_namespace_rw_lock);
704
Bob Mooref3d2e782007-02-02 19:48:18 +0300705 acpi_ns_delete_namespace_by_owner(owner_id);
Bob Moore8a335a232009-03-09 16:31:04 +0800706 if (ACPI_FAILURE(status)) {
707 return_ACPI_STATUS(status);
708 }
709
710 acpi_ut_release_write_lock(&acpi_gbl_namespace_rw_lock);
711
712 status = acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER);
713 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700714}
715
Linus Torvalds1da177e2005-04-16 15:20:36 -0700716/*******************************************************************************
717 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300718 * FUNCTION: acpi_tb_allocate_owner_id
Linus Torvalds1da177e2005-04-16 15:20:36 -0700719 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300720 * PARAMETERS: table_index - Table index
Linus Torvalds1da177e2005-04-16 15:20:36 -0700721 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300722 * RETURN: Status
Linus Torvalds1da177e2005-04-16 15:20:36 -0700723 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300724 * DESCRIPTION: Allocates owner_id in table_desc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700725 *
726 ******************************************************************************/
727
Bob Moore67a119f2008-06-10 13:42:13 +0800728acpi_status acpi_tb_allocate_owner_id(u32 table_index)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700729{
Bob Mooref3d2e782007-02-02 19:48:18 +0300730 acpi_status status = AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700731
Bob Mooref3d2e782007-02-02 19:48:18 +0300732 ACPI_FUNCTION_TRACE(tb_allocate_owner_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700733
Bob Mooref3d2e782007-02-02 19:48:18 +0300734 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
Bob Mooreb9ee2042010-04-27 11:16:14 +0800735 if (table_index < acpi_gbl_root_table_list.current_table_count) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300736 status = acpi_ut_allocate_owner_id
737 (&(acpi_gbl_root_table_list.tables[table_index].owner_id));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700738 }
739
Bob Mooref3d2e782007-02-02 19:48:18 +0300740 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
741 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700742}
743
Linus Torvalds1da177e2005-04-16 15:20:36 -0700744/*******************************************************************************
745 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300746 * FUNCTION: acpi_tb_release_owner_id
Linus Torvalds1da177e2005-04-16 15:20:36 -0700747 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300748 * PARAMETERS: table_index - Table index
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300750 * RETURN: Status
Linus Torvalds1da177e2005-04-16 15:20:36 -0700751 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300752 * DESCRIPTION: Releases owner_id in table_desc
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753 *
754 ******************************************************************************/
755
Bob Moore67a119f2008-06-10 13:42:13 +0800756acpi_status acpi_tb_release_owner_id(u32 table_index)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757{
Bob Mooref3d2e782007-02-02 19:48:18 +0300758 acpi_status status = AE_BAD_PARAMETER;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700759
Bob Mooref3d2e782007-02-02 19:48:18 +0300760 ACPI_FUNCTION_TRACE(tb_release_owner_id);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700761
Bob Mooref3d2e782007-02-02 19:48:18 +0300762 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
Bob Mooreb9ee2042010-04-27 11:16:14 +0800763 if (table_index < acpi_gbl_root_table_list.current_table_count) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300764 acpi_ut_release_owner_id(&
765 (acpi_gbl_root_table_list.
766 tables[table_index].owner_id));
767 status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700768 }
769
Bob Mooref3d2e782007-02-02 19:48:18 +0300770 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
771 return_ACPI_STATUS(status);
772}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700773
Bob Mooref3d2e782007-02-02 19:48:18 +0300774/*******************************************************************************
775 *
776 * FUNCTION: acpi_tb_get_owner_id
777 *
778 * PARAMETERS: table_index - Table index
779 * owner_id - Where the table owner_id is returned
780 *
781 * RETURN: Status
782 *
783 * DESCRIPTION: returns owner_id for the ACPI table
784 *
785 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700786
Lv Zheng55829822014-04-04 12:38:18 +0800787acpi_status acpi_tb_get_owner_id(u32 table_index, acpi_owner_id * owner_id)
Bob Mooref3d2e782007-02-02 19:48:18 +0300788{
789 acpi_status status = AE_BAD_PARAMETER;
790
791 ACPI_FUNCTION_TRACE(tb_get_owner_id);
792
793 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
Bob Mooreb9ee2042010-04-27 11:16:14 +0800794 if (table_index < acpi_gbl_root_table_list.current_table_count) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300795 *owner_id =
796 acpi_gbl_root_table_list.tables[table_index].owner_id;
797 status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700798 }
799
Bob Mooref3d2e782007-02-02 19:48:18 +0300800 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
801 return_ACPI_STATUS(status);
802}
803
804/*******************************************************************************
805 *
806 * FUNCTION: acpi_tb_is_table_loaded
807 *
808 * PARAMETERS: table_index - Table index
809 *
810 * RETURN: Table Loaded Flag
811 *
812 ******************************************************************************/
813
Bob Moore67a119f2008-06-10 13:42:13 +0800814u8 acpi_tb_is_table_loaded(u32 table_index)
Bob Mooref3d2e782007-02-02 19:48:18 +0300815{
816 u8 is_loaded = FALSE;
817
818 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
Bob Mooreb9ee2042010-04-27 11:16:14 +0800819 if (table_index < acpi_gbl_root_table_list.current_table_count) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300820 is_loaded = (u8)
Bob Mooreec41f192009-02-18 15:03:30 +0800821 (acpi_gbl_root_table_list.tables[table_index].flags &
822 ACPI_TABLE_IS_LOADED);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700823 }
824
Bob Mooref3d2e782007-02-02 19:48:18 +0300825 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
826 return (is_loaded);
827}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828
Bob Mooref3d2e782007-02-02 19:48:18 +0300829/*******************************************************************************
830 *
831 * FUNCTION: acpi_tb_set_table_loaded_flag
832 *
833 * PARAMETERS: table_index - Table index
834 * is_loaded - TRUE if table is loaded, FALSE otherwise
835 *
836 * RETURN: None
837 *
838 * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE.
839 *
840 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700841
Bob Moore67a119f2008-06-10 13:42:13 +0800842void acpi_tb_set_table_loaded_flag(u32 table_index, u8 is_loaded)
Bob Mooref3d2e782007-02-02 19:48:18 +0300843{
Bob Mooref6dd9222006-07-07 20:44:38 -0400844
Bob Mooref3d2e782007-02-02 19:48:18 +0300845 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
Bob Mooreb9ee2042010-04-27 11:16:14 +0800846 if (table_index < acpi_gbl_root_table_list.current_table_count) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300847 if (is_loaded) {
848 acpi_gbl_root_table_list.tables[table_index].flags |=
Bob Moorec5fc42a2007-02-02 19:48:19 +0300849 ACPI_TABLE_IS_LOADED;
Bob Mooref3d2e782007-02-02 19:48:18 +0300850 } else {
851 acpi_gbl_root_table_list.tables[table_index].flags &=
Bob Moorec5fc42a2007-02-02 19:48:19 +0300852 ~ACPI_TABLE_IS_LOADED;
Bob Mooref3d2e782007-02-02 19:48:18 +0300853 }
854 }
Bob Mooref6dd9222006-07-07 20:44:38 -0400855
Bob Mooref3d2e782007-02-02 19:48:18 +0300856 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857}