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