1 // SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
2 /******************************************************************************
4 * Module Name: tbdata - Table manager data structure functions
6 * Copyright (C) 2000 - 2023, Intel Corp.
8 *****************************************************************************/
10 #include <acpi/acpi.h>
16 #define _COMPONENT ACPI_TABLES
17 ACPI_MODULE_NAME("tbdata")
19 /* Local prototypes */
21 acpi_tb_check_duplication(struct acpi_table_desc
*table_desc
, u32
*table_index
);
24 acpi_tb_compare_tables(struct acpi_table_desc
*table_desc
, u32 table_index
);
26 /*******************************************************************************
28 * FUNCTION: acpi_tb_compare_tables
30 * PARAMETERS: table_desc - Table 1 descriptor to be compared
31 * table_index - Index of table 2 to be compared
33 * RETURN: TRUE if both tables are identical.
35 * DESCRIPTION: This function compares a table with another table that has
36 * already been installed in the root table list.
38 ******************************************************************************/
41 acpi_tb_compare_tables(struct acpi_table_desc
*table_desc
, u32 table_index
)
43 acpi_status status
= AE_OK
;
45 struct acpi_table_header
*table
;
50 acpi_tb_acquire_table(&acpi_gbl_root_table_list
.tables
[table_index
],
51 &table
, &table_length
, &table_flags
);
52 if (ACPI_FAILURE(status
)) {
57 * Check for a table match on the entire table length,
58 * not just the header.
60 is_identical
= (u8
)((table_desc
->length
!= table_length
||
61 memcmp(table_desc
->pointer
, table
, table_length
)) ?
64 /* Release the acquired table */
66 acpi_tb_release_table(table
, table_length
, table_flags
);
67 return (is_identical
);
70 /*******************************************************************************
72 * FUNCTION: acpi_tb_init_table_descriptor
74 * PARAMETERS: table_desc - Table descriptor
75 * address - Physical address of the table
76 * flags - Allocation flags of the table
77 * table - Pointer to the table
81 * DESCRIPTION: Initialize a new table descriptor
83 ******************************************************************************/
86 acpi_tb_init_table_descriptor(struct acpi_table_desc
*table_desc
,
87 acpi_physical_address address
,
88 u8 flags
, struct acpi_table_header
*table
)
92 * Initialize the table descriptor. Set the pointer to NULL for external
93 * tables, since the table is not fully mapped at this time.
95 memset(table_desc
, 0, sizeof(struct acpi_table_desc
));
96 table_desc
->address
= address
;
97 table_desc
->length
= table
->length
;
98 table_desc
->flags
= flags
;
99 ACPI_MOVE_32_TO_32(table_desc
->signature
.ascii
, table
->signature
);
101 switch (table_desc
->flags
& ACPI_TABLE_ORIGIN_MASK
) {
102 case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL
:
103 case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL
:
105 table_desc
->pointer
= table
;
108 case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL
:
115 /*******************************************************************************
117 * FUNCTION: acpi_tb_acquire_table
119 * PARAMETERS: table_desc - Table descriptor
120 * table_ptr - Where table is returned
121 * table_length - Where table length is returned
122 * table_flags - Where table allocation flags are returned
126 * DESCRIPTION: Acquire an ACPI table. It can be used for tables not
127 * maintained in the acpi_gbl_root_table_list.
129 ******************************************************************************/
132 acpi_tb_acquire_table(struct acpi_table_desc
*table_desc
,
133 struct acpi_table_header
**table_ptr
,
134 u32
*table_length
, u8
*table_flags
)
136 struct acpi_table_header
*table
= NULL
;
138 switch (table_desc
->flags
& ACPI_TABLE_ORIGIN_MASK
) {
139 case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL
:
142 acpi_os_map_memory(table_desc
->address
, table_desc
->length
);
145 case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL
:
146 case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL
:
148 table
= table_desc
->pointer
;
156 /* Table is not valid yet */
159 return (AE_NO_MEMORY
);
162 /* Fill the return values */
165 *table_length
= table_desc
->length
;
166 *table_flags
= table_desc
->flags
;
170 /*******************************************************************************
172 * FUNCTION: acpi_tb_release_table
174 * PARAMETERS: table - Pointer for the table
175 * table_length - Length for the table
176 * table_flags - Allocation flags for the table
180 * DESCRIPTION: Release a table. The inverse of acpi_tb_acquire_table().
182 ******************************************************************************/
185 acpi_tb_release_table(struct acpi_table_header
*table
,
186 u32 table_length
, u8 table_flags
)
189 switch (table_flags
& ACPI_TABLE_ORIGIN_MASK
) {
190 case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL
:
192 acpi_os_unmap_memory(table
, table_length
);
195 case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL
:
196 case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL
:
203 /*******************************************************************************
205 * FUNCTION: acpi_tb_acquire_temp_table
207 * PARAMETERS: table_desc - Table descriptor to be acquired
208 * address - Address of the table
209 * flags - Allocation flags of the table
210 * table - Pointer to the table (required for virtual
211 * origins, optional for physical)
215 * DESCRIPTION: This function validates the table header to obtain the length
216 * of a table and fills the table descriptor to make its state as
217 * "INSTALLED". Such a table descriptor is only used for verified
220 ******************************************************************************/
223 acpi_tb_acquire_temp_table(struct acpi_table_desc
*table_desc
,
224 acpi_physical_address address
,
225 u8 flags
, struct acpi_table_header
*table
)
227 u8 mapped_table
= FALSE
;
229 switch (flags
& ACPI_TABLE_ORIGIN_MASK
) {
230 case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL
:
232 /* Get the length of the full table from the header */
236 acpi_os_map_memory(address
,
240 return (AE_NO_MEMORY
);
248 case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL
:
249 case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL
:
252 return (AE_BAD_PARAMETER
);
259 /* Table is not valid yet */
261 return (AE_NO_MEMORY
);
264 acpi_tb_init_table_descriptor(table_desc
, address
, flags
, table
);
266 acpi_os_unmap_memory(table
, sizeof(struct acpi_table_header
));
272 /*******************************************************************************
274 * FUNCTION: acpi_tb_release_temp_table
276 * PARAMETERS: table_desc - Table descriptor to be released
280 * DESCRIPTION: The inverse of acpi_tb_acquire_temp_table().
282 *****************************************************************************/
284 void acpi_tb_release_temp_table(struct acpi_table_desc
*table_desc
)
288 * Note that the .Address is maintained by the callers of
289 * acpi_tb_acquire_temp_table(), thus do not invoke acpi_tb_uninstall_table()
290 * where .Address will be freed.
292 acpi_tb_invalidate_table(table_desc
);
295 /******************************************************************************
297 * FUNCTION: acpi_tb_validate_table
299 * PARAMETERS: table_desc - Table descriptor
303 * DESCRIPTION: This function is called to validate the table, the returned
304 * table descriptor is in "VALIDATED" state.
306 *****************************************************************************/
308 acpi_status
acpi_tb_validate_table(struct acpi_table_desc
*table_desc
)
310 acpi_status status
= AE_OK
;
312 ACPI_FUNCTION_TRACE(tb_validate_table
);
314 /* Validate the table if necessary */
316 if (!table_desc
->pointer
) {
317 status
= acpi_tb_acquire_table(table_desc
, &table_desc
->pointer
,
320 if (!table_desc
->pointer
) {
321 status
= AE_NO_MEMORY
;
325 return_ACPI_STATUS(status
);
328 /*******************************************************************************
330 * FUNCTION: acpi_tb_invalidate_table
332 * PARAMETERS: table_desc - Table descriptor
336 * DESCRIPTION: Invalidate one internal ACPI table, this is the inverse of
337 * acpi_tb_validate_table().
339 ******************************************************************************/
341 void acpi_tb_invalidate_table(struct acpi_table_desc
*table_desc
)
344 ACPI_FUNCTION_TRACE(tb_invalidate_table
);
346 /* Table must be validated */
348 if (!table_desc
->pointer
) {
352 acpi_tb_release_table(table_desc
->pointer
, table_desc
->length
,
355 switch (table_desc
->flags
& ACPI_TABLE_ORIGIN_MASK
) {
356 case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL
:
358 table_desc
->pointer
= NULL
;
361 case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL
:
362 case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL
:
371 /******************************************************************************
373 * FUNCTION: acpi_tb_validate_temp_table
375 * PARAMETERS: table_desc - Table descriptor
379 * DESCRIPTION: This function is called to validate the table, the returned
380 * table descriptor is in "VALIDATED" state.
382 *****************************************************************************/
384 acpi_status
acpi_tb_validate_temp_table(struct acpi_table_desc
*table_desc
)
387 if (!table_desc
->pointer
&& !acpi_gbl_enable_table_validation
) {
389 * Only validates the header of the table.
390 * Note that Length contains the size of the mapping after invoking
391 * this work around, this value is required by
392 * acpi_tb_release_temp_table().
393 * We can do this because in acpi_init_table_descriptor(), the Length
394 * field of the installed descriptor is filled with the actual
395 * table length obtaining from the table header.
397 table_desc
->length
= sizeof(struct acpi_table_header
);
400 return (acpi_tb_validate_table(table_desc
));
403 /*******************************************************************************
405 * FUNCTION: acpi_tb_check_duplication
407 * PARAMETERS: table_desc - Table descriptor
408 * table_index - Where the table index is returned
412 * DESCRIPTION: Avoid installing duplicated tables. However table override and
413 * user aided dynamic table load is allowed, thus comparing the
414 * address of the table is not sufficient, and checking the entire
415 * table content is required.
417 ******************************************************************************/
420 acpi_tb_check_duplication(struct acpi_table_desc
*table_desc
, u32
*table_index
)
424 ACPI_FUNCTION_TRACE(tb_check_duplication
);
426 /* Check if table is already registered */
428 for (i
= 0; i
< acpi_gbl_root_table_list
.current_table_count
; ++i
) {
430 /* Do not compare with unverified tables */
433 (acpi_gbl_root_table_list
.tables
[i
].
434 flags
& ACPI_TABLE_IS_VERIFIED
)) {
439 * Check for a table match on the entire table length,
440 * not just the header.
442 if (!acpi_tb_compare_tables(table_desc
, i
)) {
447 * Note: the current mechanism does not unregister a table if it is
448 * dynamically unloaded. The related namespace entries are deleted,
449 * but the table remains in the root table list.
451 * The assumption here is that the number of different tables that
452 * will be loaded is actually small, and there is minimal overhead
453 * in just keeping the table in case it is needed again.
455 * If this assumption changes in the future (perhaps on large
456 * machines with many table load/unload operations), tables will
457 * need to be unregistered when they are unloaded, and slots in the
458 * root table list should be reused when empty.
460 if (acpi_gbl_root_table_list
.tables
[i
].flags
&
461 ACPI_TABLE_IS_LOADED
) {
463 /* Table is still loaded, this is an error */
465 return_ACPI_STATUS(AE_ALREADY_EXISTS
);
468 return_ACPI_STATUS(AE_CTRL_TERMINATE
);
472 /* Indicate no duplication to the caller */
474 return_ACPI_STATUS(AE_OK
);
477 /******************************************************************************
479 * FUNCTION: acpi_tb_verify_temp_table
481 * PARAMETERS: table_desc - Table descriptor
482 * signature - Table signature to verify
483 * table_index - Where the table index is returned
487 * DESCRIPTION: This function is called to validate and verify the table, the
488 * returned table descriptor is in "VALIDATED" state.
489 * Note that 'TableIndex' is required to be set to !NULL to
490 * enable duplication check.
492 *****************************************************************************/
495 acpi_tb_verify_temp_table(struct acpi_table_desc
*table_desc
,
496 char *signature
, u32
*table_index
)
498 acpi_status status
= AE_OK
;
500 ACPI_FUNCTION_TRACE(tb_verify_temp_table
);
502 /* Validate the table */
504 status
= acpi_tb_validate_temp_table(table_desc
);
505 if (ACPI_FAILURE(status
)) {
506 return_ACPI_STATUS(AE_NO_MEMORY
);
509 /* If a particular signature is expected (DSDT/FACS), it must match */
512 !ACPI_COMPARE_NAMESEG(&table_desc
->signature
, signature
)) {
513 ACPI_BIOS_ERROR((AE_INFO
,
514 "Invalid signature 0x%X for ACPI table, expected [%s]",
515 table_desc
->signature
.integer
, signature
));
516 status
= AE_BAD_SIGNATURE
;
517 goto invalidate_and_exit
;
520 if (acpi_gbl_enable_table_validation
) {
522 /* Verify the checksum */
525 acpi_ut_verify_checksum(table_desc
->pointer
,
527 if (ACPI_FAILURE(status
)) {
528 ACPI_EXCEPTION((AE_INFO
, AE_NO_MEMORY
,
530 " Attempted table install failed",
531 acpi_ut_valid_nameseg(table_desc
->
534 table_desc
->signature
.ascii
: "????",
535 ACPI_FORMAT_UINT64(table_desc
->
538 goto invalidate_and_exit
;
541 /* Avoid duplications */
545 acpi_tb_check_duplication(table_desc
, table_index
);
546 if (ACPI_FAILURE(status
)) {
547 if (status
!= AE_CTRL_TERMINATE
) {
548 ACPI_EXCEPTION((AE_INFO
, status
,
550 " Table is already loaded",
551 acpi_ut_valid_nameseg
552 (table_desc
->signature
.
553 ascii
) ? table_desc
->
557 (table_desc
->address
)));
560 goto invalidate_and_exit
;
564 table_desc
->flags
|= ACPI_TABLE_IS_VERIFIED
;
567 return_ACPI_STATUS(status
);
570 acpi_tb_invalidate_table(table_desc
);
571 return_ACPI_STATUS(status
);
574 /*******************************************************************************
576 * FUNCTION: acpi_tb_resize_root_table_list
582 * DESCRIPTION: Expand the size of global table array
584 ******************************************************************************/
586 acpi_status
acpi_tb_resize_root_table_list(void)
588 struct acpi_table_desc
*tables
;
590 u32 current_table_count
, max_table_count
;
593 ACPI_FUNCTION_TRACE(tb_resize_root_table_list
);
595 /* allow_resize flag is a parameter to acpi_initialize_tables */
597 if (!(acpi_gbl_root_table_list
.flags
& ACPI_ROOT_ALLOW_RESIZE
)) {
599 "Resize of Root Table Array is not allowed"));
600 return_ACPI_STATUS(AE_SUPPORT
);
603 /* Increase the Table Array size */
605 if (acpi_gbl_root_table_list
.flags
& ACPI_ROOT_ORIGIN_ALLOCATED
) {
606 table_count
= acpi_gbl_root_table_list
.max_table_count
;
608 table_count
= acpi_gbl_root_table_list
.current_table_count
;
611 max_table_count
= table_count
+ ACPI_ROOT_TABLE_SIZE_INCREMENT
;
612 tables
= ACPI_ALLOCATE_ZEROED(((acpi_size
)max_table_count
) *
613 sizeof(struct acpi_table_desc
));
616 "Could not allocate new root table array"));
617 return_ACPI_STATUS(AE_NO_MEMORY
);
620 /* Copy and free the previous table array */
622 current_table_count
= 0;
623 if (acpi_gbl_root_table_list
.tables
) {
624 for (i
= 0; i
< table_count
; i
++) {
625 if (acpi_gbl_root_table_list
.tables
[i
].address
) {
626 memcpy(tables
+ current_table_count
,
627 acpi_gbl_root_table_list
.tables
+ i
,
628 sizeof(struct acpi_table_desc
));
629 current_table_count
++;
633 if (acpi_gbl_root_table_list
.flags
& ACPI_ROOT_ORIGIN_ALLOCATED
) {
634 ACPI_FREE(acpi_gbl_root_table_list
.tables
);
638 acpi_gbl_root_table_list
.tables
= tables
;
639 acpi_gbl_root_table_list
.max_table_count
= max_table_count
;
640 acpi_gbl_root_table_list
.current_table_count
= current_table_count
;
641 acpi_gbl_root_table_list
.flags
|= ACPI_ROOT_ORIGIN_ALLOCATED
;
643 return_ACPI_STATUS(AE_OK
);
646 /*******************************************************************************
648 * FUNCTION: acpi_tb_get_next_table_descriptor
650 * PARAMETERS: table_index - Where table index is returned
651 * table_desc - Where table descriptor is returned
653 * RETURN: Status and table index/descriptor.
655 * DESCRIPTION: Allocate a new ACPI table entry to the global table list
657 ******************************************************************************/
660 acpi_tb_get_next_table_descriptor(u32
*table_index
,
661 struct acpi_table_desc
**table_desc
)
666 /* Ensure that there is room for the table in the Root Table List */
668 if (acpi_gbl_root_table_list
.current_table_count
>=
669 acpi_gbl_root_table_list
.max_table_count
) {
670 status
= acpi_tb_resize_root_table_list();
671 if (ACPI_FAILURE(status
)) {
676 i
= acpi_gbl_root_table_list
.current_table_count
;
677 acpi_gbl_root_table_list
.current_table_count
++;
683 *table_desc
= &acpi_gbl_root_table_list
.tables
[i
];
689 /*******************************************************************************
691 * FUNCTION: acpi_tb_terminate
697 * DESCRIPTION: Delete all internal ACPI tables
699 ******************************************************************************/
701 void acpi_tb_terminate(void)
705 ACPI_FUNCTION_TRACE(tb_terminate
);
707 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES
);
709 /* Delete the individual tables */
711 for (i
= 0; i
< acpi_gbl_root_table_list
.current_table_count
; i
++) {
712 acpi_tb_uninstall_table(&acpi_gbl_root_table_list
.tables
[i
]);
716 * Delete the root table array if allocated locally. Array cannot be
717 * mapped, so we don't need to check for that flag.
719 if (acpi_gbl_root_table_list
.flags
& ACPI_ROOT_ORIGIN_ALLOCATED
) {
720 ACPI_FREE(acpi_gbl_root_table_list
.tables
);
723 acpi_gbl_root_table_list
.tables
= NULL
;
724 acpi_gbl_root_table_list
.flags
= 0;
725 acpi_gbl_root_table_list
.current_table_count
= 0;
727 ACPI_DEBUG_PRINT((ACPI_DB_INFO
, "ACPI Tables freed\n"));
729 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES
);
733 /*******************************************************************************
735 * FUNCTION: acpi_tb_delete_namespace_by_owner
737 * PARAMETERS: table_index - Table index
741 * DESCRIPTION: Delete all namespace objects created when this table was loaded.
743 ******************************************************************************/
745 acpi_status
acpi_tb_delete_namespace_by_owner(u32 table_index
)
747 acpi_owner_id owner_id
;
750 ACPI_FUNCTION_TRACE(tb_delete_namespace_by_owner
);
752 status
= acpi_ut_acquire_mutex(ACPI_MTX_TABLES
);
753 if (ACPI_FAILURE(status
)) {
754 return_ACPI_STATUS(status
);
757 if (table_index
>= acpi_gbl_root_table_list
.current_table_count
) {
759 /* The table index does not exist */
761 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES
);
762 return_ACPI_STATUS(AE_NOT_EXIST
);
765 /* Get the owner ID for this table, used to delete namespace nodes */
767 owner_id
= acpi_gbl_root_table_list
.tables
[table_index
].owner_id
;
768 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES
);
771 * Need to acquire the namespace writer lock to prevent interference
772 * with any concurrent namespace walks. The interpreter must be
773 * released during the deletion since the acquisition of the deletion
774 * lock may block, and also since the execution of a namespace walk
775 * must be allowed to use the interpreter.
777 status
= acpi_ut_acquire_write_lock(&acpi_gbl_namespace_rw_lock
);
778 if (ACPI_FAILURE(status
)) {
779 return_ACPI_STATUS(status
);
782 acpi_ns_delete_namespace_by_owner(owner_id
);
783 acpi_ut_release_write_lock(&acpi_gbl_namespace_rw_lock
);
784 return_ACPI_STATUS(status
);
787 /*******************************************************************************
789 * FUNCTION: acpi_tb_allocate_owner_id
791 * PARAMETERS: table_index - Table index
795 * DESCRIPTION: Allocates owner_id in table_desc
797 ******************************************************************************/
799 acpi_status
acpi_tb_allocate_owner_id(u32 table_index
)
801 acpi_status status
= AE_BAD_PARAMETER
;
803 ACPI_FUNCTION_TRACE(tb_allocate_owner_id
);
805 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES
);
806 if (table_index
< acpi_gbl_root_table_list
.current_table_count
) {
808 acpi_ut_allocate_owner_id(&
809 (acpi_gbl_root_table_list
.
810 tables
[table_index
].owner_id
));
813 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES
);
814 return_ACPI_STATUS(status
);
817 /*******************************************************************************
819 * FUNCTION: acpi_tb_release_owner_id
821 * PARAMETERS: table_index - Table index
825 * DESCRIPTION: Releases owner_id in table_desc
827 ******************************************************************************/
829 acpi_status
acpi_tb_release_owner_id(u32 table_index
)
831 acpi_status status
= AE_BAD_PARAMETER
;
833 ACPI_FUNCTION_TRACE(tb_release_owner_id
);
835 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES
);
836 if (table_index
< acpi_gbl_root_table_list
.current_table_count
) {
837 acpi_ut_release_owner_id(&
838 (acpi_gbl_root_table_list
.
839 tables
[table_index
].owner_id
));
843 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES
);
844 return_ACPI_STATUS(status
);
847 /*******************************************************************************
849 * FUNCTION: acpi_tb_get_owner_id
851 * PARAMETERS: table_index - Table index
852 * owner_id - Where the table owner_id is returned
856 * DESCRIPTION: returns owner_id for the ACPI table
858 ******************************************************************************/
860 acpi_status
acpi_tb_get_owner_id(u32 table_index
, acpi_owner_id
*owner_id
)
862 acpi_status status
= AE_BAD_PARAMETER
;
864 ACPI_FUNCTION_TRACE(tb_get_owner_id
);
866 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES
);
867 if (table_index
< acpi_gbl_root_table_list
.current_table_count
) {
869 acpi_gbl_root_table_list
.tables
[table_index
].owner_id
;
873 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES
);
874 return_ACPI_STATUS(status
);
877 /*******************************************************************************
879 * FUNCTION: acpi_tb_is_table_loaded
881 * PARAMETERS: table_index - Index into the root table
883 * RETURN: Table Loaded Flag
885 ******************************************************************************/
887 u8
acpi_tb_is_table_loaded(u32 table_index
)
889 u8 is_loaded
= FALSE
;
891 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES
);
892 if (table_index
< acpi_gbl_root_table_list
.current_table_count
) {
894 (acpi_gbl_root_table_list
.tables
[table_index
].flags
&
895 ACPI_TABLE_IS_LOADED
);
898 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES
);
902 /*******************************************************************************
904 * FUNCTION: acpi_tb_set_table_loaded_flag
906 * PARAMETERS: table_index - Table index
907 * is_loaded - TRUE if table is loaded, FALSE otherwise
911 * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE.
913 ******************************************************************************/
915 void acpi_tb_set_table_loaded_flag(u32 table_index
, u8 is_loaded
)
918 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES
);
919 if (table_index
< acpi_gbl_root_table_list
.current_table_count
) {
921 acpi_gbl_root_table_list
.tables
[table_index
].flags
|=
922 ACPI_TABLE_IS_LOADED
;
924 acpi_gbl_root_table_list
.tables
[table_index
].flags
&=
925 ~ACPI_TABLE_IS_LOADED
;
929 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES
);
932 /*******************************************************************************
934 * FUNCTION: acpi_tb_load_table
936 * PARAMETERS: table_index - Table index
937 * parent_node - Where table index is returned
941 * DESCRIPTION: Load an ACPI table
943 ******************************************************************************/
946 acpi_tb_load_table(u32 table_index
, struct acpi_namespace_node
*parent_node
)
948 struct acpi_table_header
*table
;
950 acpi_owner_id owner_id
;
952 ACPI_FUNCTION_TRACE(tb_load_table
);
955 * Note: Now table is "INSTALLED", it must be validated before
958 status
= acpi_get_table_by_index(table_index
, &table
);
959 if (ACPI_FAILURE(status
)) {
960 return_ACPI_STATUS(status
);
963 status
= acpi_ns_load_table(table_index
, parent_node
);
964 if (ACPI_FAILURE(status
)) {
965 return_ACPI_STATUS(status
);
969 * Update GPEs for any new _Lxx/_Exx methods. Ignore errors. The host is
970 * responsible for discovering any new wake GPEs by running _PRW methods
971 * that may have been loaded by this table.
973 status
= acpi_tb_get_owner_id(table_index
, &owner_id
);
974 if (ACPI_SUCCESS(status
)) {
975 acpi_ev_update_gpes(owner_id
);
978 /* Invoke table handler */
980 acpi_tb_notify_table(ACPI_TABLE_EVENT_LOAD
, table
);
981 return_ACPI_STATUS(status
);
984 /*******************************************************************************
986 * FUNCTION: acpi_tb_install_and_load_table
988 * PARAMETERS: address - Physical address of the table
989 * flags - Allocation flags of the table
990 * table - Pointer to the table (required for
991 * virtual origins, optional for
993 * override - Whether override should be performed
994 * table_index - Where table index is returned
998 * DESCRIPTION: Install and load an ACPI table
1000 ******************************************************************************/
1003 acpi_tb_install_and_load_table(acpi_physical_address address
,
1005 struct acpi_table_header
*table
,
1006 u8 override
, u32
*table_index
)
1011 ACPI_FUNCTION_TRACE(tb_install_and_load_table
);
1013 /* Install the table and load it into the namespace */
1015 status
= acpi_tb_install_standard_table(address
, flags
, table
, TRUE
,
1017 if (ACPI_FAILURE(status
)) {
1021 status
= acpi_tb_load_table(i
, acpi_gbl_root_node
);
1025 return_ACPI_STATUS(status
);
1028 ACPI_EXPORT_SYMBOL(acpi_tb_install_and_load_table
)
1030 /*******************************************************************************
1032 * FUNCTION: acpi_tb_unload_table
1034 * PARAMETERS: table_index - Table index
1038 * DESCRIPTION: Unload an ACPI table
1040 ******************************************************************************/
1042 acpi_status
acpi_tb_unload_table(u32 table_index
)
1044 acpi_status status
= AE_OK
;
1045 struct acpi_table_header
*table
;
1047 ACPI_FUNCTION_TRACE(tb_unload_table
);
1049 /* Ensure the table is still loaded */
1051 if (!acpi_tb_is_table_loaded(table_index
)) {
1052 return_ACPI_STATUS(AE_NOT_EXIST
);
1055 /* Invoke table handler */
1057 status
= acpi_get_table_by_index(table_index
, &table
);
1058 if (ACPI_SUCCESS(status
)) {
1059 acpi_tb_notify_table(ACPI_TABLE_EVENT_UNLOAD
, table
);
1062 /* Delete the portion of the namespace owned by this table */
1064 status
= acpi_tb_delete_namespace_by_owner(table_index
);
1065 if (ACPI_FAILURE(status
)) {
1066 return_ACPI_STATUS(status
);
1069 (void)acpi_tb_release_owner_id(table_index
);
1070 acpi_tb_set_table_loaded_flag(table_index
, FALSE
);
1071 return_ACPI_STATUS(status
);
1074 ACPI_EXPORT_SYMBOL(acpi_tb_unload_table
)
1076 /*******************************************************************************
1078 * FUNCTION: acpi_tb_notify_table
1080 * PARAMETERS: event - Table event
1081 * table - Validated table pointer
1085 * DESCRIPTION: Notify a table event to the users.
1087 ******************************************************************************/
1089 void acpi_tb_notify_table(u32 event
, void *table
)
1091 /* Invoke table handler if present */
1093 if (acpi_gbl_table_handler
) {
1094 (void)acpi_gbl_table_handler(event
, table
,
1095 acpi_gbl_table_handler_context
);