Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[linux/fpc-iii.git] / drivers / acpi / acpica / tbdata.c
blobb0399e8f6d27df774b175cb2a3aa7c8f3cce7189
1 /******************************************************************************
3 * Module Name: tbdata - Table manager data structure functions
5 *****************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2016, Intel Corp.
9 * All rights reserved.
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.
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.
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.
44 #include <acpi/acpi.h>
45 #include "accommon.h"
46 #include "acnamesp.h"
47 #include "actables.h"
48 #include "acevents.h"
50 #define _COMPONENT ACPI_TABLES
51 ACPI_MODULE_NAME("tbdata")
53 /*******************************************************************************
55 * FUNCTION: acpi_tb_init_table_descriptor
57 * PARAMETERS: table_desc - Table descriptor
58 * address - Physical address of the table
59 * flags - Allocation flags of the table
60 * table - Pointer to the table
62 * RETURN: None
64 * DESCRIPTION: Initialize a new table descriptor
66 ******************************************************************************/
67 void
68 acpi_tb_init_table_descriptor(struct acpi_table_desc *table_desc,
69 acpi_physical_address address,
70 u8 flags, struct acpi_table_header *table)
74 * Initialize the table descriptor. Set the pointer to NULL, since the
75 * table is not fully mapped at this time.
77 memset(table_desc, 0, sizeof(struct acpi_table_desc));
78 table_desc->address = address;
79 table_desc->length = table->length;
80 table_desc->flags = flags;
81 ACPI_MOVE_32_TO_32(table_desc->signature.ascii, table->signature);
84 /*******************************************************************************
86 * FUNCTION: acpi_tb_acquire_table
88 * PARAMETERS: table_desc - Table descriptor
89 * table_ptr - Where table is returned
90 * table_length - Where table length is returned
91 * table_flags - Where table allocation flags are returned
93 * RETURN: Status
95 * DESCRIPTION: Acquire an ACPI table. It can be used for tables not
96 * maintained in the acpi_gbl_root_table_list.
98 ******************************************************************************/
100 acpi_status
101 acpi_tb_acquire_table(struct acpi_table_desc *table_desc,
102 struct acpi_table_header **table_ptr,
103 u32 *table_length, u8 *table_flags)
105 struct acpi_table_header *table = NULL;
107 switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) {
108 case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL:
110 table =
111 acpi_os_map_memory(table_desc->address, table_desc->length);
112 break;
114 case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL:
115 case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL:
117 table = ACPI_CAST_PTR(struct acpi_table_header,
118 ACPI_PHYSADDR_TO_PTR(table_desc->
119 address));
120 break;
122 default:
124 break;
127 /* Table is not valid yet */
129 if (!table) {
130 return (AE_NO_MEMORY);
133 /* Fill the return values */
135 *table_ptr = table;
136 *table_length = table_desc->length;
137 *table_flags = table_desc->flags;
138 return (AE_OK);
141 /*******************************************************************************
143 * FUNCTION: acpi_tb_release_table
145 * PARAMETERS: table - Pointer for the table
146 * table_length - Length for the table
147 * table_flags - Allocation flags for the table
149 * RETURN: None
151 * DESCRIPTION: Release a table. The inverse of acpi_tb_acquire_table().
153 ******************************************************************************/
155 void
156 acpi_tb_release_table(struct acpi_table_header *table,
157 u32 table_length, u8 table_flags)
160 switch (table_flags & ACPI_TABLE_ORIGIN_MASK) {
161 case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL:
163 acpi_os_unmap_memory(table, table_length);
164 break;
166 case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL:
167 case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL:
168 default:
170 break;
174 /*******************************************************************************
176 * FUNCTION: acpi_tb_acquire_temp_table
178 * PARAMETERS: table_desc - Table descriptor to be acquired
179 * address - Address of the table
180 * flags - Allocation flags of the table
182 * RETURN: Status
184 * DESCRIPTION: This function validates the table header to obtain the length
185 * of a table and fills the table descriptor to make its state as
186 * "INSTALLED". Such a table descriptor is only used for verified
187 * installation.
189 ******************************************************************************/
191 acpi_status
192 acpi_tb_acquire_temp_table(struct acpi_table_desc *table_desc,
193 acpi_physical_address address, u8 flags)
195 struct acpi_table_header *table_header;
197 switch (flags & ACPI_TABLE_ORIGIN_MASK) {
198 case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL:
200 /* Get the length of the full table from the header */
202 table_header =
203 acpi_os_map_memory(address,
204 sizeof(struct acpi_table_header));
205 if (!table_header) {
206 return (AE_NO_MEMORY);
209 acpi_tb_init_table_descriptor(table_desc, address, flags,
210 table_header);
211 acpi_os_unmap_memory(table_header,
212 sizeof(struct acpi_table_header));
213 return (AE_OK);
215 case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL:
216 case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL:
218 table_header = ACPI_CAST_PTR(struct acpi_table_header,
219 ACPI_PHYSADDR_TO_PTR(address));
220 if (!table_header) {
221 return (AE_NO_MEMORY);
224 acpi_tb_init_table_descriptor(table_desc, address, flags,
225 table_header);
226 return (AE_OK);
228 default:
230 break;
233 /* Table is not valid yet */
235 return (AE_NO_MEMORY);
238 /*******************************************************************************
240 * FUNCTION: acpi_tb_release_temp_table
242 * PARAMETERS: table_desc - Table descriptor to be released
244 * RETURN: Status
246 * DESCRIPTION: The inverse of acpi_tb_acquire_temp_table().
248 *****************************************************************************/
250 void acpi_tb_release_temp_table(struct acpi_table_desc *table_desc)
254 * Note that the .Address is maintained by the callers of
255 * acpi_tb_acquire_temp_table(), thus do not invoke acpi_tb_uninstall_table()
256 * where .Address will be freed.
258 acpi_tb_invalidate_table(table_desc);
261 /******************************************************************************
263 * FUNCTION: acpi_tb_validate_table
265 * PARAMETERS: table_desc - Table descriptor
267 * RETURN: Status
269 * DESCRIPTION: This function is called to validate the table, the returned
270 * table descriptor is in "VALIDATED" state.
272 *****************************************************************************/
274 acpi_status acpi_tb_validate_table(struct acpi_table_desc *table_desc)
276 acpi_status status = AE_OK;
278 ACPI_FUNCTION_TRACE(tb_validate_table);
280 /* Validate the table if necessary */
282 if (!table_desc->pointer) {
283 status = acpi_tb_acquire_table(table_desc, &table_desc->pointer,
284 &table_desc->length,
285 &table_desc->flags);
286 if (!table_desc->pointer) {
287 status = AE_NO_MEMORY;
291 return_ACPI_STATUS(status);
294 /*******************************************************************************
296 * FUNCTION: acpi_tb_invalidate_table
298 * PARAMETERS: table_desc - Table descriptor
300 * RETURN: None
302 * DESCRIPTION: Invalidate one internal ACPI table, this is the inverse of
303 * acpi_tb_validate_table().
305 ******************************************************************************/
307 void acpi_tb_invalidate_table(struct acpi_table_desc *table_desc)
310 ACPI_FUNCTION_TRACE(tb_invalidate_table);
312 /* Table must be validated */
314 if (!table_desc->pointer) {
315 return_VOID;
318 acpi_tb_release_table(table_desc->pointer, table_desc->length,
319 table_desc->flags);
320 table_desc->pointer = NULL;
322 return_VOID;
325 /******************************************************************************
327 * FUNCTION: acpi_tb_validate_temp_table
329 * PARAMETERS: table_desc - Table descriptor
331 * RETURN: Status
333 * DESCRIPTION: This function is called to validate the table, the returned
334 * table descriptor is in "VALIDATED" state.
336 *****************************************************************************/
338 acpi_status acpi_tb_validate_temp_table(struct acpi_table_desc *table_desc)
341 if (!table_desc->pointer && !acpi_gbl_verify_table_checksum) {
343 * Only validates the header of the table.
344 * Note that Length contains the size of the mapping after invoking
345 * this work around, this value is required by
346 * acpi_tb_release_temp_table().
347 * We can do this because in acpi_init_table_descriptor(), the Length
348 * field of the installed descriptor is filled with the actual
349 * table length obtaining from the table header.
351 table_desc->length = sizeof(struct acpi_table_header);
354 return (acpi_tb_validate_table(table_desc));
357 /******************************************************************************
359 * FUNCTION: acpi_tb_verify_temp_table
361 * PARAMETERS: table_desc - Table descriptor
362 * signature - Table signature to verify
364 * RETURN: Status
366 * DESCRIPTION: This function is called to validate and verify the table, the
367 * returned table descriptor is in "VALIDATED" state.
369 *****************************************************************************/
371 acpi_status
372 acpi_tb_verify_temp_table(struct acpi_table_desc *table_desc, char *signature)
374 acpi_status status = AE_OK;
376 ACPI_FUNCTION_TRACE(tb_verify_temp_table);
378 /* Validate the table */
380 status = acpi_tb_validate_temp_table(table_desc);
381 if (ACPI_FAILURE(status)) {
382 return_ACPI_STATUS(AE_NO_MEMORY);
385 /* If a particular signature is expected (DSDT/FACS), it must match */
387 if (signature && !ACPI_COMPARE_NAME(&table_desc->signature, signature)) {
388 ACPI_BIOS_ERROR((AE_INFO,
389 "Invalid signature 0x%X for ACPI table, expected [%s]",
390 table_desc->signature.integer, signature));
391 status = AE_BAD_SIGNATURE;
392 goto invalidate_and_exit;
395 /* Verify the checksum */
397 if (acpi_gbl_verify_table_checksum) {
398 status =
399 acpi_tb_verify_checksum(table_desc->pointer,
400 table_desc->length);
401 if (ACPI_FAILURE(status)) {
402 ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY,
403 "%4.4s 0x%8.8X%8.8X"
404 " Attempted table install failed",
405 acpi_ut_valid_nameseg(table_desc->
406 signature.
407 ascii) ?
408 table_desc->signature.ascii : "????",
409 ACPI_FORMAT_UINT64(table_desc->
410 address)));
412 goto invalidate_and_exit;
416 return_ACPI_STATUS(AE_OK);
418 invalidate_and_exit:
419 acpi_tb_invalidate_table(table_desc);
420 return_ACPI_STATUS(status);
423 /*******************************************************************************
425 * FUNCTION: acpi_tb_resize_root_table_list
427 * PARAMETERS: None
429 * RETURN: Status
431 * DESCRIPTION: Expand the size of global table array
433 ******************************************************************************/
435 acpi_status acpi_tb_resize_root_table_list(void)
437 struct acpi_table_desc *tables;
438 u32 table_count;
440 ACPI_FUNCTION_TRACE(tb_resize_root_table_list);
442 /* allow_resize flag is a parameter to acpi_initialize_tables */
444 if (!(acpi_gbl_root_table_list.flags & ACPI_ROOT_ALLOW_RESIZE)) {
445 ACPI_ERROR((AE_INFO,
446 "Resize of Root Table Array is not allowed"));
447 return_ACPI_STATUS(AE_SUPPORT);
450 /* Increase the Table Array size */
452 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
453 table_count = acpi_gbl_root_table_list.max_table_count;
454 } else {
455 table_count = acpi_gbl_root_table_list.current_table_count;
458 tables = ACPI_ALLOCATE_ZEROED(((acpi_size)table_count +
459 ACPI_ROOT_TABLE_SIZE_INCREMENT) *
460 sizeof(struct acpi_table_desc));
461 if (!tables) {
462 ACPI_ERROR((AE_INFO,
463 "Could not allocate new root table array"));
464 return_ACPI_STATUS(AE_NO_MEMORY);
467 /* Copy and free the previous table array */
469 if (acpi_gbl_root_table_list.tables) {
470 memcpy(tables, acpi_gbl_root_table_list.tables,
471 (acpi_size)table_count * sizeof(struct acpi_table_desc));
473 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
474 ACPI_FREE(acpi_gbl_root_table_list.tables);
478 acpi_gbl_root_table_list.tables = tables;
479 acpi_gbl_root_table_list.max_table_count =
480 table_count + ACPI_ROOT_TABLE_SIZE_INCREMENT;
481 acpi_gbl_root_table_list.flags |= ACPI_ROOT_ORIGIN_ALLOCATED;
483 return_ACPI_STATUS(AE_OK);
486 /*******************************************************************************
488 * FUNCTION: acpi_tb_get_next_table_descriptor
490 * PARAMETERS: table_index - Where table index is returned
491 * table_desc - Where table descriptor is returned
493 * RETURN: Status and table index/descriptor.
495 * DESCRIPTION: Allocate a new ACPI table entry to the global table list
497 ******************************************************************************/
499 acpi_status
500 acpi_tb_get_next_table_descriptor(u32 *table_index,
501 struct acpi_table_desc **table_desc)
503 acpi_status status;
504 u32 i;
506 /* Ensure that there is room for the table in the Root Table List */
508 if (acpi_gbl_root_table_list.current_table_count >=
509 acpi_gbl_root_table_list.max_table_count) {
510 status = acpi_tb_resize_root_table_list();
511 if (ACPI_FAILURE(status)) {
512 return (status);
516 i = acpi_gbl_root_table_list.current_table_count;
517 acpi_gbl_root_table_list.current_table_count++;
519 if (table_index) {
520 *table_index = i;
522 if (table_desc) {
523 *table_desc = &acpi_gbl_root_table_list.tables[i];
526 return (AE_OK);
529 /*******************************************************************************
531 * FUNCTION: acpi_tb_terminate
533 * PARAMETERS: None
535 * RETURN: None
537 * DESCRIPTION: Delete all internal ACPI tables
539 ******************************************************************************/
541 void acpi_tb_terminate(void)
543 u32 i;
545 ACPI_FUNCTION_TRACE(tb_terminate);
547 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
549 /* Delete the individual tables */
551 for (i = 0; i < acpi_gbl_root_table_list.current_table_count; i++) {
552 acpi_tb_uninstall_table(&acpi_gbl_root_table_list.tables[i]);
556 * Delete the root table array if allocated locally. Array cannot be
557 * mapped, so we don't need to check for that flag.
559 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
560 ACPI_FREE(acpi_gbl_root_table_list.tables);
563 acpi_gbl_root_table_list.tables = NULL;
564 acpi_gbl_root_table_list.flags = 0;
565 acpi_gbl_root_table_list.current_table_count = 0;
567 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n"));
569 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
570 return_VOID;
573 /*******************************************************************************
575 * FUNCTION: acpi_tb_delete_namespace_by_owner
577 * PARAMETERS: table_index - Table index
579 * RETURN: Status
581 * DESCRIPTION: Delete all namespace objects created when this table was loaded.
583 ******************************************************************************/
585 acpi_status acpi_tb_delete_namespace_by_owner(u32 table_index)
587 acpi_owner_id owner_id;
588 acpi_status status;
590 ACPI_FUNCTION_TRACE(tb_delete_namespace_by_owner);
592 status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
593 if (ACPI_FAILURE(status)) {
594 return_ACPI_STATUS(status);
597 if (table_index >= acpi_gbl_root_table_list.current_table_count) {
599 /* The table index does not exist */
601 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
602 return_ACPI_STATUS(AE_NOT_EXIST);
605 /* Get the owner ID for this table, used to delete namespace nodes */
607 owner_id = acpi_gbl_root_table_list.tables[table_index].owner_id;
608 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
611 * Need to acquire the namespace writer lock to prevent interference
612 * with any concurrent namespace walks. The interpreter must be
613 * released during the deletion since the acquisition of the deletion
614 * lock may block, and also since the execution of a namespace walk
615 * must be allowed to use the interpreter.
617 status = acpi_ut_acquire_write_lock(&acpi_gbl_namespace_rw_lock);
618 if (ACPI_FAILURE(status)) {
619 return_ACPI_STATUS(status);
621 acpi_ns_delete_namespace_by_owner(owner_id);
622 acpi_ut_release_write_lock(&acpi_gbl_namespace_rw_lock);
623 return_ACPI_STATUS(status);
626 /*******************************************************************************
628 * FUNCTION: acpi_tb_allocate_owner_id
630 * PARAMETERS: table_index - Table index
632 * RETURN: Status
634 * DESCRIPTION: Allocates owner_id in table_desc
636 ******************************************************************************/
638 acpi_status acpi_tb_allocate_owner_id(u32 table_index)
640 acpi_status status = AE_BAD_PARAMETER;
642 ACPI_FUNCTION_TRACE(tb_allocate_owner_id);
644 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
645 if (table_index < acpi_gbl_root_table_list.current_table_count) {
646 status =
647 acpi_ut_allocate_owner_id(&
648 (acpi_gbl_root_table_list.
649 tables[table_index].owner_id));
652 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
653 return_ACPI_STATUS(status);
656 /*******************************************************************************
658 * FUNCTION: acpi_tb_release_owner_id
660 * PARAMETERS: table_index - Table index
662 * RETURN: Status
664 * DESCRIPTION: Releases owner_id in table_desc
666 ******************************************************************************/
668 acpi_status acpi_tb_release_owner_id(u32 table_index)
670 acpi_status status = AE_BAD_PARAMETER;
672 ACPI_FUNCTION_TRACE(tb_release_owner_id);
674 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
675 if (table_index < acpi_gbl_root_table_list.current_table_count) {
676 acpi_ut_release_owner_id(&
677 (acpi_gbl_root_table_list.
678 tables[table_index].owner_id));
679 status = AE_OK;
682 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
683 return_ACPI_STATUS(status);
686 /*******************************************************************************
688 * FUNCTION: acpi_tb_get_owner_id
690 * PARAMETERS: table_index - Table index
691 * owner_id - Where the table owner_id is returned
693 * RETURN: Status
695 * DESCRIPTION: returns owner_id for the ACPI table
697 ******************************************************************************/
699 acpi_status acpi_tb_get_owner_id(u32 table_index, acpi_owner_id *owner_id)
701 acpi_status status = AE_BAD_PARAMETER;
703 ACPI_FUNCTION_TRACE(tb_get_owner_id);
705 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
706 if (table_index < acpi_gbl_root_table_list.current_table_count) {
707 *owner_id =
708 acpi_gbl_root_table_list.tables[table_index].owner_id;
709 status = AE_OK;
712 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
713 return_ACPI_STATUS(status);
716 /*******************************************************************************
718 * FUNCTION: acpi_tb_is_table_loaded
720 * PARAMETERS: table_index - Index into the root table
722 * RETURN: Table Loaded Flag
724 ******************************************************************************/
726 u8 acpi_tb_is_table_loaded(u32 table_index)
728 u8 is_loaded = FALSE;
730 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
731 if (table_index < acpi_gbl_root_table_list.current_table_count) {
732 is_loaded = (u8)
733 (acpi_gbl_root_table_list.tables[table_index].flags &
734 ACPI_TABLE_IS_LOADED);
737 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
738 return (is_loaded);
741 /*******************************************************************************
743 * FUNCTION: acpi_tb_set_table_loaded_flag
745 * PARAMETERS: table_index - Table index
746 * is_loaded - TRUE if table is loaded, FALSE otherwise
748 * RETURN: None
750 * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE.
752 ******************************************************************************/
754 void acpi_tb_set_table_loaded_flag(u32 table_index, u8 is_loaded)
757 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
758 if (table_index < acpi_gbl_root_table_list.current_table_count) {
759 if (is_loaded) {
760 acpi_gbl_root_table_list.tables[table_index].flags |=
761 ACPI_TABLE_IS_LOADED;
762 } else {
763 acpi_gbl_root_table_list.tables[table_index].flags &=
764 ~ACPI_TABLE_IS_LOADED;
768 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
771 /*******************************************************************************
773 * FUNCTION: acpi_tb_load_table
775 * PARAMETERS: table_index - Table index
776 * parent_node - Where table index is returned
778 * RETURN: Status
780 * DESCRIPTION: Load an ACPI table
782 ******************************************************************************/
784 acpi_status
785 acpi_tb_load_table(u32 table_index, struct acpi_namespace_node *parent_node)
787 struct acpi_table_header *table;
788 acpi_status status;
789 acpi_owner_id owner_id;
791 ACPI_FUNCTION_TRACE(tb_load_table);
794 * Note: Now table is "INSTALLED", it must be validated before
795 * using.
797 status = acpi_get_table_by_index(table_index, &table);
798 if (ACPI_FAILURE(status)) {
799 return_ACPI_STATUS(status);
802 status = acpi_ns_load_table(table_index, parent_node);
804 /* Execute any module-level code that was found in the table */
806 if (!acpi_gbl_parse_table_as_term_list
807 && acpi_gbl_group_module_level_code) {
808 acpi_ns_exec_module_code_list();
812 * Update GPEs for any new _Lxx/_Exx methods. Ignore errors. The host is
813 * responsible for discovering any new wake GPEs by running _PRW methods
814 * that may have been loaded by this table.
816 status = acpi_tb_get_owner_id(table_index, &owner_id);
817 if (ACPI_SUCCESS(status)) {
818 acpi_ev_update_gpes(owner_id);
821 /* Invoke table handler if present */
823 if (acpi_gbl_table_handler) {
824 (void)acpi_gbl_table_handler(ACPI_TABLE_EVENT_LOAD, table,
825 acpi_gbl_table_handler_context);
828 return_ACPI_STATUS(status);
831 /*******************************************************************************
833 * FUNCTION: acpi_tb_install_and_load_table
835 * PARAMETERS: address - Physical address of the table
836 * flags - Allocation flags of the table
837 * override - Whether override should be performed
838 * table_index - Where table index is returned
840 * RETURN: Status
842 * DESCRIPTION: Install and load an ACPI table
844 ******************************************************************************/
846 acpi_status
847 acpi_tb_install_and_load_table(acpi_physical_address address,
848 u8 flags, u8 override, u32 *table_index)
850 acpi_status status;
851 u32 i;
853 ACPI_FUNCTION_TRACE(tb_install_and_load_table);
855 /* Install the table and load it into the namespace */
857 status = acpi_tb_install_standard_table(address, flags, TRUE,
858 override, &i);
859 if (ACPI_FAILURE(status)) {
860 goto exit;
863 status = acpi_tb_load_table(i, acpi_gbl_root_node);
865 exit:
866 *table_index = i;
867 return_ACPI_STATUS(status);
870 /*******************************************************************************
872 * FUNCTION: acpi_tb_unload_table
874 * PARAMETERS: table_index - Table index
876 * RETURN: Status
878 * DESCRIPTION: Unload an ACPI table
880 ******************************************************************************/
882 acpi_status acpi_tb_unload_table(u32 table_index)
884 acpi_status status = AE_OK;
885 struct acpi_table_header *table;
887 ACPI_FUNCTION_TRACE(tb_unload_table);
889 /* Ensure the table is still loaded */
891 if (!acpi_tb_is_table_loaded(table_index)) {
892 return_ACPI_STATUS(AE_NOT_EXIST);
895 /* Invoke table handler if present */
897 if (acpi_gbl_table_handler) {
898 status = acpi_get_table_by_index(table_index, &table);
899 if (ACPI_SUCCESS(status)) {
900 (void)acpi_gbl_table_handler(ACPI_TABLE_EVENT_UNLOAD,
901 table,
902 acpi_gbl_table_handler_context);
906 /* Delete the portion of the namespace owned by this table */
908 status = acpi_tb_delete_namespace_by_owner(table_index);
909 if (ACPI_FAILURE(status)) {
910 return_ACPI_STATUS(status);
913 (void)acpi_tb_release_owner_id(table_index);
914 acpi_tb_set_table_loaded_flag(table_index, FALSE);
915 return_ACPI_STATUS(status);