]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blame - drivers/acpi/acpica/tbinstal.c
Merge branch 'docs-next' of git://git.lwn.net/linux-2.6
[mirror_ubuntu-hirsute-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/*
a8357b0c 8 * Copyright (C) 2000 - 2010, 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 }
f3d2e786
BM
78 if (!table_desc->pointer) {
79 return_ACPI_STATUS(AE_NO_MEMORY);
1da177e4 80 }
f3d2e786 81 }
1da177e4 82
f3d2e786 83 /* FACS is the odd table, has no standard ACPI header and no checksum */
52fc0b02 84
428f2112 85 if (!ACPI_COMPARE_NAME(&table_desc->signature, ACPI_SIG_FACS)) {
1da177e4 86
428f2112
AS
87 /* Always calculate checksum, ignore bad checksum if requested */
88
89 status =
90 acpi_tb_verify_checksum(table_desc->pointer,
91 table_desc->length);
92 }
1da177e4 93
c5fc42ac 94 return_ACPI_STATUS(status);
1da177e4
LT
95}
96
1da177e4
LT
97/*******************************************************************************
98 *
f3d2e786 99 * FUNCTION: acpi_tb_add_table
1da177e4 100 *
428f2112 101 * PARAMETERS: table_desc - Table descriptor
f3d2e786 102 * table_index - Where the table index is returned
1da177e4
LT
103 *
104 * RETURN: Status
105 *
d3ccaff8
BM
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.
1da177e4
LT
109 *
110 ******************************************************************************/
111
f3d2e786 112acpi_status
67a119f9 113acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index)
1da177e4 114{
67a119f9 115 u32 i;
f3d2e786 116 acpi_status status = AE_OK;
d3ccaff8 117 struct acpi_table_header *override_table = NULL;
1da177e4 118
f3d2e786 119 ACPI_FUNCTION_TRACE(tb_add_table);
1da177e4 120
428f2112
AS
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
bc45b1d3
BM
128 /*
129 * Originally, we checked the table signature for "SSDT" or "PSDT" here.
130 * Next, we added support for OEMx tables, signature "OEM".
131 * Valid tables were encountered with a null signature, so we've just
132 * given up on validating the signature, since it seems to be a waste
133 * of code. The original code was removed (05/2008).
134 */
428f2112 135
f3d2e786 136 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
1da177e4 137
f3d2e786
BM
138 /* Check if table is already registered */
139
b9ee2043 140 for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) {
f3d2e786
BM
141 if (!acpi_gbl_root_table_list.tables[i].pointer) {
142 status =
143 acpi_tb_verify_table(&acpi_gbl_root_table_list.
144 tables[i]);
145 if (ACPI_FAILURE(status)
146 || !acpi_gbl_root_table_list.tables[i].pointer) {
147 continue;
148 }
149 }
150
a6f30539
BM
151 /*
152 * Check for a table match on the entire table length,
153 * not just the header.
154 */
155 if (table_desc->length !=
156 acpi_gbl_root_table_list.tables[i].length) {
157 continue;
158 }
e56f5617 159
428f2112
AS
160 if (ACPI_MEMCMP(table_desc->pointer,
161 acpi_gbl_root_table_list.tables[i].pointer,
a6f30539 162 acpi_gbl_root_table_list.tables[i].length)) {
f3d2e786
BM
163 continue;
164 }
165
e56f5617
BM
166 /*
167 * Note: the current mechanism does not unregister a table if it is
168 * dynamically unloaded. The related namespace entries are deleted,
169 * but the table remains in the root table list.
170 *
171 * The assumption here is that the number of different tables that
172 * will be loaded is actually small, and there is minimal overhead
173 * in just keeping the table in case it is needed again.
174 *
175 * If this assumption changes in the future (perhaps on large
176 * machines with many table load/unload operations), tables will
177 * need to be unregistered when they are unloaded, and slots in the
178 * root table list should be reused when empty.
179 */
180
181 /*
182 * Table is already registered.
183 * We can delete the table that was passed as a parameter.
184 */
428f2112 185 acpi_tb_delete_table(table_desc);
f3d2e786 186 *table_index = i;
e56f5617
BM
187
188 if (acpi_gbl_root_table_list.tables[i].
189 flags & ACPI_TABLE_IS_LOADED) {
190
191 /* Table is still loaded, this is an error */
192
193 status = AE_ALREADY_EXISTS;
194 goto release;
195 } else {
196 /* Table was unloaded, allow it to be reloaded */
197
198 table_desc->pointer =
199 acpi_gbl_root_table_list.tables[i].pointer;
200 table_desc->address =
201 acpi_gbl_root_table_list.tables[i].address;
202 status = AE_OK;
203 goto print_header;
204 }
1da177e4
LT
205 }
206
d3ccaff8
BM
207 /*
208 * ACPI Table Override:
209 * Allow the host to override dynamically loaded tables.
210 */
211 status = acpi_os_table_override(table_desc->pointer, &override_table);
212 if (ACPI_SUCCESS(status) && override_table) {
213 ACPI_INFO((AE_INFO,
214 "%4.4s @ 0x%p Table override, replaced with:",
215 table_desc->pointer->signature,
216 ACPI_CAST_PTR(void, table_desc->address)));
217
218 /* We can delete the table that was passed as a parameter */
219
220 acpi_tb_delete_table(table_desc);
221
222 /* Setup descriptor for the new table */
223
224 table_desc->address = ACPI_PTR_TO_PHYSADDR(override_table);
225 table_desc->pointer = override_table;
226 table_desc->length = override_table->length;
227 table_desc->flags = ACPI_TABLE_ORIGIN_OVERRIDE;
228 }
229
e56f5617
BM
230 /* Add the table to the global root table list */
231
428f2112
AS
232 status = acpi_tb_store_table(table_desc->address, table_desc->pointer,
233 table_desc->length, table_desc->flags,
234 table_index);
4be44fcd 235 if (ACPI_FAILURE(status)) {
f3d2e786 236 goto release;
0c9938cc
RM
237 }
238
e56f5617 239 print_header:
428f2112 240 acpi_tb_print_table_header(table_desc->address, table_desc->pointer);
1da177e4 241
f3d2e786 242 release:
4be44fcd
LB
243 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
244 return_ACPI_STATUS(status);
1da177e4
LT
245}
246
1da177e4
LT
247/*******************************************************************************
248 *
f3d2e786 249 * FUNCTION: acpi_tb_resize_root_table_list
1da177e4 250 *
f3d2e786 251 * PARAMETERS: None
1da177e4
LT
252 *
253 * RETURN: Status
254 *
f3d2e786 255 * DESCRIPTION: Expand the size of global table array
1da177e4
LT
256 *
257 ******************************************************************************/
258
f3d2e786 259acpi_status acpi_tb_resize_root_table_list(void)
1da177e4 260{
f3d2e786 261 struct acpi_table_desc *tables;
1da177e4 262
f3d2e786 263 ACPI_FUNCTION_TRACE(tb_resize_root_table_list);
1da177e4 264
f3d2e786 265 /* allow_resize flag is a parameter to acpi_initialize_tables */
1da177e4 266
c5fc42ac 267 if (!(acpi_gbl_root_table_list.flags & ACPI_ROOT_ALLOW_RESIZE)) {
f3d2e786
BM
268 ACPI_ERROR((AE_INFO,
269 "Resize of Root Table Array is not allowed"));
270 return_ACPI_STATUS(AE_SUPPORT);
1da177e4
LT
271 }
272
f3d2e786
BM
273 /* Increase the Table Array size */
274
67a119f9 275 tables = ACPI_ALLOCATE_ZEROED(((acpi_size) acpi_gbl_root_table_list.
b9ee2043 276 max_table_count +
ec41f193
BM
277 ACPI_ROOT_TABLE_SIZE_INCREMENT) *
278 sizeof(struct acpi_table_desc));
f3d2e786
BM
279 if (!tables) {
280 ACPI_ERROR((AE_INFO,
281 "Could not allocate new root table array"));
282 return_ACPI_STATUS(AE_NO_MEMORY);
1da177e4
LT
283 }
284
f3d2e786
BM
285 /* Copy and free the previous table array */
286
287 if (acpi_gbl_root_table_list.tables) {
288 ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables,
b9ee2043
BM
289 (acpi_size) acpi_gbl_root_table_list.
290 max_table_count * sizeof(struct acpi_table_desc));
f3d2e786 291
c5fc42ac 292 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
f3d2e786
BM
293 ACPI_FREE(acpi_gbl_root_table_list.tables);
294 }
1da177e4
LT
295 }
296
f3d2e786 297 acpi_gbl_root_table_list.tables = tables;
b9ee2043
BM
298 acpi_gbl_root_table_list.max_table_count +=
299 ACPI_ROOT_TABLE_SIZE_INCREMENT;
300 acpi_gbl_root_table_list.flags |= (u8)ACPI_ROOT_ORIGIN_ALLOCATED;
1da177e4 301
f3d2e786 302 return_ACPI_STATUS(AE_OK);
1da177e4
LT
303}
304
1da177e4
LT
305/*******************************************************************************
306 *
f3d2e786 307 * FUNCTION: acpi_tb_store_table
1da177e4 308 *
f3d2e786
BM
309 * PARAMETERS: Address - Table address
310 * Table - Table header
311 * Length - Table length
312 * Flags - flags
1da177e4 313 *
f3d2e786 314 * RETURN: Status and table index.
1da177e4 315 *
f3d2e786 316 * DESCRIPTION: Add an ACPI table to the global table list
1da177e4
LT
317 *
318 ******************************************************************************/
319
320acpi_status
f3d2e786
BM
321acpi_tb_store_table(acpi_physical_address address,
322 struct acpi_table_header *table,
67a119f9 323 u32 length, u8 flags, u32 *table_index)
1da177e4 324{
b9ee2043
BM
325 acpi_status status;
326 struct acpi_table_desc *new_table;
1da177e4 327
f3d2e786 328 /* Ensure that there is room for the table in the Root Table List */
f9f4601f 329
b9ee2043
BM
330 if (acpi_gbl_root_table_list.current_table_count >=
331 acpi_gbl_root_table_list.max_table_count) {
f3d2e786
BM
332 status = acpi_tb_resize_root_table_list();
333 if (ACPI_FAILURE(status)) {
334 return (status);
335 }
f9f4601f
RM
336 }
337
b9ee2043
BM
338 new_table =
339 &acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.
340 current_table_count];
341
f3d2e786
BM
342 /* Initialize added table */
343
b9ee2043
BM
344 new_table->address = address;
345 new_table->pointer = table;
346 new_table->length = length;
347 new_table->owner_id = 0;
348 new_table->flags = flags;
349
350 ACPI_MOVE_32_TO_32(&new_table->signature, table->signature);
351
352 *table_index = acpi_gbl_root_table_list.current_table_count;
353 acpi_gbl_root_table_list.current_table_count++;
354 return (AE_OK);
f3d2e786 355}
1da177e4 356
f3d2e786
BM
357/*******************************************************************************
358 *
359 * FUNCTION: acpi_tb_delete_table
360 *
361 * PARAMETERS: table_index - Table index
362 *
363 * RETURN: None
364 *
365 * DESCRIPTION: Delete one internal ACPI table
366 *
367 ******************************************************************************/
1da177e4 368
428f2112 369void acpi_tb_delete_table(struct acpi_table_desc *table_desc)
f3d2e786 370{
f3d2e786 371 /* Table must be mapped or allocated */
f3d2e786
BM
372 if (!table_desc->pointer) {
373 return;
1da177e4 374 }
428f2112
AS
375 switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) {
376 case ACPI_TABLE_ORIGIN_MAPPED:
377 acpi_os_unmap_memory(table_desc->pointer, table_desc->length);
378 break;
379 case ACPI_TABLE_ORIGIN_ALLOCATED:
f3d2e786 380 ACPI_FREE(table_desc->pointer);
428f2112
AS
381 break;
382 default:;
1da177e4
LT
383 }
384
f3d2e786 385 table_desc->pointer = NULL;
1da177e4
LT
386}
387
1da177e4
LT
388/*******************************************************************************
389 *
f3d2e786 390 * FUNCTION: acpi_tb_terminate
1da177e4 391 *
f3d2e786 392 * PARAMETERS: None
1da177e4 393 *
f3d2e786 394 * RETURN: None
1da177e4
LT
395 *
396 * DESCRIPTION: Delete all internal ACPI tables
397 *
398 ******************************************************************************/
399
f3d2e786 400void acpi_tb_terminate(void)
1da177e4 401{
67a119f9 402 u32 i;
f3d2e786
BM
403
404 ACPI_FUNCTION_TRACE(tb_terminate);
405
406 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
407
408 /* Delete the individual tables */
409
b9ee2043 410 for (i = 0; i < acpi_gbl_root_table_list.current_table_count; i++) {
428f2112 411 acpi_tb_delete_table(&acpi_gbl_root_table_list.tables[i]);
f3d2e786 412 }
1da177e4
LT
413
414 /*
f3d2e786
BM
415 * Delete the root table array if allocated locally. Array cannot be
416 * mapped, so we don't need to check for that flag.
1da177e4 417 */
c5fc42ac 418 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
f3d2e786 419 ACPI_FREE(acpi_gbl_root_table_list.tables);
1da177e4 420 }
f3d2e786
BM
421
422 acpi_gbl_root_table_list.tables = NULL;
423 acpi_gbl_root_table_list.flags = 0;
b9ee2043 424 acpi_gbl_root_table_list.current_table_count = 0;
f3d2e786
BM
425
426 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n"));
427 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
1da177e4
LT
428}
429
1da177e4
LT
430/*******************************************************************************
431 *
f3d2e786 432 * FUNCTION: acpi_tb_delete_namespace_by_owner
1da177e4 433 *
f3d2e786 434 * PARAMETERS: table_index - Table index
1da177e4 435 *
8a335a23 436 * RETURN: Status
1da177e4 437 *
f3d2e786 438 * DESCRIPTION: Delete all namespace objects created when this table was loaded.
1da177e4
LT
439 *
440 ******************************************************************************/
441
8a335a23 442acpi_status acpi_tb_delete_namespace_by_owner(u32 table_index)
1da177e4 443{
f3d2e786 444 acpi_owner_id owner_id;
8a335a23
BM
445 acpi_status status;
446
447 ACPI_FUNCTION_TRACE(tb_delete_namespace_by_owner);
448
449 status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
450 if (ACPI_FAILURE(status)) {
451 return_ACPI_STATUS(status);
452 }
453
b9ee2043 454 if (table_index >= acpi_gbl_root_table_list.current_table_count) {
8a335a23
BM
455
456 /* The table index does not exist */
1da177e4 457
f3d2e786 458 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
8a335a23 459 return_ACPI_STATUS(AE_NOT_EXIST);
1da177e4
LT
460 }
461
8a335a23
BM
462 /* Get the owner ID for this table, used to delete namespace nodes */
463
464 owner_id = acpi_gbl_root_table_list.tables[table_index].owner_id;
f3d2e786 465 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
8a335a23
BM
466
467 /*
468 * Need to acquire the namespace writer lock to prevent interference
469 * with any concurrent namespace walks. The interpreter must be
470 * released during the deletion since the acquisition of the deletion
471 * lock may block, and also since the execution of a namespace walk
472 * must be allowed to use the interpreter.
473 */
e4c1ebfc 474 (void)acpi_ut_release_mutex(ACPI_MTX_INTERPRETER);
8a335a23
BM
475 status = acpi_ut_acquire_write_lock(&acpi_gbl_namespace_rw_lock);
476
f3d2e786 477 acpi_ns_delete_namespace_by_owner(owner_id);
8a335a23
BM
478 if (ACPI_FAILURE(status)) {
479 return_ACPI_STATUS(status);
480 }
481
482 acpi_ut_release_write_lock(&acpi_gbl_namespace_rw_lock);
483
484 status = acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER);
485 return_ACPI_STATUS(status);
f3d2e786 486}
1da177e4 487
f3d2e786
BM
488/*******************************************************************************
489 *
490 * FUNCTION: acpi_tb_allocate_owner_id
491 *
492 * PARAMETERS: table_index - Table index
493 *
494 * RETURN: Status
495 *
496 * DESCRIPTION: Allocates owner_id in table_desc
497 *
498 ******************************************************************************/
1da177e4 499
67a119f9 500acpi_status acpi_tb_allocate_owner_id(u32 table_index)
f3d2e786
BM
501{
502 acpi_status status = AE_BAD_PARAMETER;
1da177e4 503
f3d2e786 504 ACPI_FUNCTION_TRACE(tb_allocate_owner_id);
1da177e4 505
f3d2e786 506 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
b9ee2043 507 if (table_index < acpi_gbl_root_table_list.current_table_count) {
f3d2e786
BM
508 status = acpi_ut_allocate_owner_id
509 (&(acpi_gbl_root_table_list.tables[table_index].owner_id));
1da177e4
LT
510 }
511
4be44fcd 512 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
f3d2e786 513 return_ACPI_STATUS(status);
1da177e4
LT
514}
515
1da177e4
LT
516/*******************************************************************************
517 *
f3d2e786 518 * FUNCTION: acpi_tb_release_owner_id
1da177e4 519 *
f3d2e786 520 * PARAMETERS: table_index - Table index
1da177e4 521 *
f3d2e786 522 * RETURN: Status
1da177e4 523 *
f3d2e786 524 * DESCRIPTION: Releases owner_id in table_desc
1da177e4
LT
525 *
526 ******************************************************************************/
527
67a119f9 528acpi_status acpi_tb_release_owner_id(u32 table_index)
1da177e4 529{
f3d2e786 530 acpi_status status = AE_BAD_PARAMETER;
1da177e4 531
f3d2e786 532 ACPI_FUNCTION_TRACE(tb_release_owner_id);
1da177e4 533
f3d2e786 534 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
b9ee2043 535 if (table_index < acpi_gbl_root_table_list.current_table_count) {
f3d2e786
BM
536 acpi_ut_release_owner_id(&
537 (acpi_gbl_root_table_list.
538 tables[table_index].owner_id));
539 status = AE_OK;
1da177e4
LT
540 }
541
f3d2e786
BM
542 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
543 return_ACPI_STATUS(status);
1da177e4
LT
544}
545
1da177e4
LT
546/*******************************************************************************
547 *
f3d2e786 548 * FUNCTION: acpi_tb_get_owner_id
1da177e4 549 *
f3d2e786
BM
550 * PARAMETERS: table_index - Table index
551 * owner_id - Where the table owner_id is returned
1da177e4 552 *
f3d2e786 553 * RETURN: Status
1da177e4 554 *
f3d2e786 555 * DESCRIPTION: returns owner_id for the ACPI table
1da177e4
LT
556 *
557 ******************************************************************************/
558
67a119f9 559acpi_status acpi_tb_get_owner_id(u32 table_index, acpi_owner_id *owner_id)
1da177e4 560{
f3d2e786 561 acpi_status status = AE_BAD_PARAMETER;
1da177e4 562
f3d2e786 563 ACPI_FUNCTION_TRACE(tb_get_owner_id);
1da177e4 564
f3d2e786 565 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
b9ee2043 566 if (table_index < acpi_gbl_root_table_list.current_table_count) {
f3d2e786
BM
567 *owner_id =
568 acpi_gbl_root_table_list.tables[table_index].owner_id;
569 status = AE_OK;
1da177e4
LT
570 }
571
f3d2e786
BM
572 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
573 return_ACPI_STATUS(status);
574}
1da177e4 575
f3d2e786
BM
576/*******************************************************************************
577 *
578 * FUNCTION: acpi_tb_is_table_loaded
579 *
580 * PARAMETERS: table_index - Table index
581 *
582 * RETURN: Table Loaded Flag
583 *
584 ******************************************************************************/
1da177e4 585
67a119f9 586u8 acpi_tb_is_table_loaded(u32 table_index)
f3d2e786
BM
587{
588 u8 is_loaded = FALSE;
1da177e4 589
f3d2e786 590 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
b9ee2043 591 if (table_index < acpi_gbl_root_table_list.current_table_count) {
f3d2e786 592 is_loaded = (u8)
ec41f193
BM
593 (acpi_gbl_root_table_list.tables[table_index].flags &
594 ACPI_TABLE_IS_LOADED);
1da177e4
LT
595 }
596
f3d2e786
BM
597 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
598 return (is_loaded);
599}
f6dd9221 600
f3d2e786
BM
601/*******************************************************************************
602 *
603 * FUNCTION: acpi_tb_set_table_loaded_flag
604 *
605 * PARAMETERS: table_index - Table index
606 * is_loaded - TRUE if table is loaded, FALSE otherwise
607 *
608 * RETURN: None
609 *
610 * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE.
611 *
612 ******************************************************************************/
1da177e4 613
67a119f9 614void acpi_tb_set_table_loaded_flag(u32 table_index, u8 is_loaded)
f3d2e786 615{
1da177e4 616
f3d2e786 617 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
b9ee2043 618 if (table_index < acpi_gbl_root_table_list.current_table_count) {
f3d2e786
BM
619 if (is_loaded) {
620 acpi_gbl_root_table_list.tables[table_index].flags |=
c5fc42ac 621 ACPI_TABLE_IS_LOADED;
f3d2e786
BM
622 } else {
623 acpi_gbl_root_table_list.tables[table_index].flags &=
c5fc42ac 624 ~ACPI_TABLE_IS_LOADED;
f3d2e786
BM
625 }
626 }
1da177e4 627
f3d2e786 628 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
1da177e4 629}