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