1 /******************************************************************************
3 * Module Name: tbdata - Table manager data structure functions
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2018, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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.
50 #define _COMPONENT ACPI_TABLES
51 ACPI_MODULE_NAME ("tbdata")
53 /* Local prototypes */
56 AcpiTbCheckDuplication (
57 ACPI_TABLE_DESC
*TableDesc
,
62 ACPI_TABLE_DESC
*TableDesc
,
66 /*******************************************************************************
68 * FUNCTION: AcpiTbCompareTables
70 * PARAMETERS: TableDesc - Table 1 descriptor to be compared
71 * TableIndex - Index of table 2 to be compared
73 * RETURN: TRUE if both tables are identical.
75 * DESCRIPTION: This function compares a table with another table that has
76 * already been installed in the root table list.
78 ******************************************************************************/
82 ACPI_TABLE_DESC
*TableDesc
,
85 ACPI_STATUS Status
= AE_OK
;
87 ACPI_TABLE_HEADER
*Table
;
92 Status
= AcpiTbAcquireTable (&AcpiGbl_RootTableList
.Tables
[TableIndex
],
93 &Table
, &TableLength
, &TableFlags
);
94 if (ACPI_FAILURE (Status
))
100 * Check for a table match on the entire table length,
101 * not just the header.
103 IsIdentical
= (BOOLEAN
)((TableDesc
->Length
!= TableLength
||
104 memcmp (TableDesc
->Pointer
, Table
, TableLength
)) ?
107 /* Release the acquired table */
109 AcpiTbReleaseTable (Table
, TableLength
, TableFlags
);
110 return (IsIdentical
);
114 /*******************************************************************************
116 * FUNCTION: AcpiTbInitTableDescriptor
118 * PARAMETERS: TableDesc - Table descriptor
119 * Address - Physical address of the table
120 * Flags - Allocation flags of the table
121 * Table - Pointer to the table
125 * DESCRIPTION: Initialize a new table descriptor
127 ******************************************************************************/
130 AcpiTbInitTableDescriptor (
131 ACPI_TABLE_DESC
*TableDesc
,
132 ACPI_PHYSICAL_ADDRESS Address
,
134 ACPI_TABLE_HEADER
*Table
)
138 * Initialize the table descriptor. Set the pointer to NULL, since the
139 * table is not fully mapped at this time.
141 memset (TableDesc
, 0, sizeof (ACPI_TABLE_DESC
));
142 TableDesc
->Address
= Address
;
143 TableDesc
->Length
= Table
->Length
;
144 TableDesc
->Flags
= Flags
;
145 ACPI_MOVE_32_TO_32 (TableDesc
->Signature
.Ascii
, Table
->Signature
);
149 /*******************************************************************************
151 * FUNCTION: AcpiTbAcquireTable
153 * PARAMETERS: TableDesc - Table descriptor
154 * TablePtr - Where table is returned
155 * TableLength - Where table length is returned
156 * TableFlags - Where table allocation flags are returned
160 * DESCRIPTION: Acquire an ACPI table. It can be used for tables not
161 * maintained in the AcpiGbl_RootTableList.
163 ******************************************************************************/
167 ACPI_TABLE_DESC
*TableDesc
,
168 ACPI_TABLE_HEADER
**TablePtr
,
172 ACPI_TABLE_HEADER
*Table
= NULL
;
175 switch (TableDesc
->Flags
& ACPI_TABLE_ORIGIN_MASK
)
177 case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL
:
179 Table
= AcpiOsMapMemory (TableDesc
->Address
, TableDesc
->Length
);
182 case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL
:
183 case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL
:
185 Table
= ACPI_CAST_PTR (ACPI_TABLE_HEADER
,
186 ACPI_PHYSADDR_TO_PTR (TableDesc
->Address
));
194 /* Table is not valid yet */
198 return (AE_NO_MEMORY
);
201 /* Fill the return values */
204 *TableLength
= TableDesc
->Length
;
205 *TableFlags
= TableDesc
->Flags
;
210 /*******************************************************************************
212 * FUNCTION: AcpiTbReleaseTable
214 * PARAMETERS: Table - Pointer for the table
215 * TableLength - Length for the table
216 * TableFlags - Allocation flags for the table
220 * DESCRIPTION: Release a table. The inverse of AcpiTbAcquireTable().
222 ******************************************************************************/
226 ACPI_TABLE_HEADER
*Table
,
231 switch (TableFlags
& ACPI_TABLE_ORIGIN_MASK
)
233 case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL
:
235 AcpiOsUnmapMemory (Table
, TableLength
);
238 case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL
:
239 case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL
:
247 /*******************************************************************************
249 * FUNCTION: AcpiTbAcquireTempTable
251 * PARAMETERS: TableDesc - Table descriptor to be acquired
252 * Address - Address of the table
253 * Flags - Allocation flags of the table
257 * DESCRIPTION: This function validates the table header to obtain the length
258 * of a table and fills the table descriptor to make its state as
259 * "INSTALLED". Such a table descriptor is only used for verified
262 ******************************************************************************/
265 AcpiTbAcquireTempTable (
266 ACPI_TABLE_DESC
*TableDesc
,
267 ACPI_PHYSICAL_ADDRESS Address
,
270 ACPI_TABLE_HEADER
*TableHeader
;
273 switch (Flags
& ACPI_TABLE_ORIGIN_MASK
)
275 case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL
:
277 /* Get the length of the full table from the header */
279 TableHeader
= AcpiOsMapMemory (Address
, sizeof (ACPI_TABLE_HEADER
));
282 return (AE_NO_MEMORY
);
285 AcpiTbInitTableDescriptor (TableDesc
, Address
, Flags
, TableHeader
);
286 AcpiOsUnmapMemory (TableHeader
, sizeof (ACPI_TABLE_HEADER
));
289 case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL
:
290 case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL
:
292 TableHeader
= ACPI_CAST_PTR (ACPI_TABLE_HEADER
,
293 ACPI_PHYSADDR_TO_PTR (Address
));
296 return (AE_NO_MEMORY
);
299 AcpiTbInitTableDescriptor (TableDesc
, Address
, Flags
, TableHeader
);
307 /* Table is not valid yet */
309 return (AE_NO_MEMORY
);
313 /*******************************************************************************
315 * FUNCTION: AcpiTbReleaseTempTable
317 * PARAMETERS: TableDesc - Table descriptor to be released
321 * DESCRIPTION: The inverse of AcpiTbAcquireTempTable().
323 *****************************************************************************/
326 AcpiTbReleaseTempTable (
327 ACPI_TABLE_DESC
*TableDesc
)
331 * Note that the .Address is maintained by the callers of
332 * AcpiTbAcquireTempTable(), thus do not invoke AcpiTbUninstallTable()
333 * where .Address will be freed.
335 AcpiTbInvalidateTable (TableDesc
);
339 /******************************************************************************
341 * FUNCTION: AcpiTbValidateTable
343 * PARAMETERS: TableDesc - Table descriptor
347 * DESCRIPTION: This function is called to validate the table, the returned
348 * table descriptor is in "VALIDATED" state.
350 *****************************************************************************/
353 AcpiTbValidateTable (
354 ACPI_TABLE_DESC
*TableDesc
)
356 ACPI_STATUS Status
= AE_OK
;
359 ACPI_FUNCTION_TRACE (TbValidateTable
);
362 /* Validate the table if necessary */
364 if (!TableDesc
->Pointer
)
366 Status
= AcpiTbAcquireTable (TableDesc
, &TableDesc
->Pointer
,
367 &TableDesc
->Length
, &TableDesc
->Flags
);
368 if (!TableDesc
->Pointer
)
370 Status
= AE_NO_MEMORY
;
374 return_ACPI_STATUS (Status
);
378 /*******************************************************************************
380 * FUNCTION: AcpiTbInvalidateTable
382 * PARAMETERS: TableDesc - Table descriptor
386 * DESCRIPTION: Invalidate one internal ACPI table, this is the inverse of
387 * AcpiTbValidateTable().
389 ******************************************************************************/
392 AcpiTbInvalidateTable (
393 ACPI_TABLE_DESC
*TableDesc
)
396 ACPI_FUNCTION_TRACE (TbInvalidateTable
);
399 /* Table must be validated */
401 if (!TableDesc
->Pointer
)
406 AcpiTbReleaseTable (TableDesc
->Pointer
, TableDesc
->Length
,
408 TableDesc
->Pointer
= NULL
;
414 /******************************************************************************
416 * FUNCTION: AcpiTbValidateTempTable
418 * PARAMETERS: TableDesc - Table descriptor
422 * DESCRIPTION: This function is called to validate the table, the returned
423 * table descriptor is in "VALIDATED" state.
425 *****************************************************************************/
428 AcpiTbValidateTempTable (
429 ACPI_TABLE_DESC
*TableDesc
)
432 if (!TableDesc
->Pointer
&& !AcpiGbl_EnableTableValidation
)
435 * Only validates the header of the table.
436 * Note that Length contains the size of the mapping after invoking
437 * this work around, this value is required by
438 * AcpiTbReleaseTempTable().
439 * We can do this because in AcpiInitTableDescriptor(), the Length
440 * field of the installed descriptor is filled with the actual
441 * table length obtaining from the table header.
443 TableDesc
->Length
= sizeof (ACPI_TABLE_HEADER
);
446 return (AcpiTbValidateTable (TableDesc
));
450 /*******************************************************************************
452 * FUNCTION: AcpiTbCheckDuplication
454 * PARAMETERS: TableDesc - Table descriptor
455 * TableIndex - Where the table index is returned
459 * DESCRIPTION: Avoid installing duplicated tables. However table override and
460 * user aided dynamic table load is allowed, thus comparing the
461 * address of the table is not sufficient, and checking the entire
462 * table content is required.
464 ******************************************************************************/
467 AcpiTbCheckDuplication (
468 ACPI_TABLE_DESC
*TableDesc
,
474 ACPI_FUNCTION_TRACE (TbCheckDuplication
);
477 /* Check if table is already registered */
479 for (i
= 0; i
< AcpiGbl_RootTableList
.CurrentTableCount
; ++i
)
481 /* Do not compare with unverified tables */
483 if (!(AcpiGbl_RootTableList
.Tables
[i
].Flags
& ACPI_TABLE_IS_VERIFIED
))
489 * Check for a table match on the entire table length,
490 * not just the header.
492 if (!AcpiTbCompareTables (TableDesc
, i
))
498 * Note: the current mechanism does not unregister a table if it is
499 * dynamically unloaded. The related namespace entries are deleted,
500 * but the table remains in the root table list.
502 * The assumption here is that the number of different tables that
503 * will be loaded is actually small, and there is minimal overhead
504 * in just keeping the table in case it is needed again.
506 * If this assumption changes in the future (perhaps on large
507 * machines with many table load/unload operations), tables will
508 * need to be unregistered when they are unloaded, and slots in the
509 * root table list should be reused when empty.
511 if (AcpiGbl_RootTableList
.Tables
[i
].Flags
&
512 ACPI_TABLE_IS_LOADED
)
514 /* Table is still loaded, this is an error */
516 return_ACPI_STATUS (AE_ALREADY_EXISTS
);
521 return_ACPI_STATUS (AE_CTRL_TERMINATE
);
525 /* Indicate no duplication to the caller */
527 return_ACPI_STATUS (AE_OK
);
531 /******************************************************************************
533 * FUNCTION: AcpiTbVerifyTempTable
535 * PARAMETERS: TableDesc - Table descriptor
536 * Signature - Table signature to verify
537 * TableIndex - Where the table index is returned
541 * DESCRIPTION: This function is called to validate and verify the table, the
542 * returned table descriptor is in "VALIDATED" state.
543 * Note that 'TableIndex' is required to be set to !NULL to
544 * enable duplication check.
546 *****************************************************************************/
549 AcpiTbVerifyTempTable (
550 ACPI_TABLE_DESC
*TableDesc
,
554 ACPI_STATUS Status
= AE_OK
;
557 ACPI_FUNCTION_TRACE (TbVerifyTempTable
);
560 /* Validate the table */
562 Status
= AcpiTbValidateTempTable (TableDesc
);
563 if (ACPI_FAILURE (Status
))
565 return_ACPI_STATUS (AE_NO_MEMORY
);
568 /* If a particular signature is expected (DSDT/FACS), it must match */
571 !ACPI_COMPARE_NAME (&TableDesc
->Signature
, Signature
))
573 ACPI_BIOS_ERROR ((AE_INFO
,
574 "Invalid signature 0x%X for ACPI table, expected [%s]",
575 TableDesc
->Signature
.Integer
, Signature
));
576 Status
= AE_BAD_SIGNATURE
;
577 goto InvalidateAndExit
;
580 if (AcpiGbl_EnableTableValidation
)
582 /* Verify the checksum */
584 Status
= AcpiTbVerifyChecksum (TableDesc
->Pointer
, TableDesc
->Length
);
585 if (ACPI_FAILURE (Status
))
587 ACPI_EXCEPTION ((AE_INFO
, AE_NO_MEMORY
,
589 " Attempted table install failed",
590 AcpiUtValidNameseg (TableDesc
->Signature
.Ascii
) ?
591 TableDesc
->Signature
.Ascii
: "????",
592 ACPI_FORMAT_UINT64 (TableDesc
->Address
)));
594 goto InvalidateAndExit
;
597 /* Avoid duplications */
601 Status
= AcpiTbCheckDuplication (TableDesc
, TableIndex
);
602 if (ACPI_FAILURE (Status
))
604 if (Status
!= AE_CTRL_TERMINATE
)
606 ACPI_EXCEPTION ((AE_INFO
, AE_NO_MEMORY
,
608 " Table is duplicated",
609 AcpiUtValidNameseg (TableDesc
->Signature
.Ascii
) ?
610 TableDesc
->Signature
.Ascii
: "????",
611 ACPI_FORMAT_UINT64 (TableDesc
->Address
)));
614 goto InvalidateAndExit
;
618 TableDesc
->Flags
|= ACPI_TABLE_IS_VERIFIED
;
621 return_ACPI_STATUS (Status
);
624 AcpiTbInvalidateTable (TableDesc
);
625 return_ACPI_STATUS (Status
);
629 /*******************************************************************************
631 * FUNCTION: AcpiTbResizeRootTableList
637 * DESCRIPTION: Expand the size of global table array
639 ******************************************************************************/
642 AcpiTbResizeRootTableList (
645 ACPI_TABLE_DESC
*Tables
;
647 UINT32 CurrentTableCount
, MaxTableCount
;
651 ACPI_FUNCTION_TRACE (TbResizeRootTableList
);
654 /* AllowResize flag is a parameter to AcpiInitializeTables */
656 if (!(AcpiGbl_RootTableList
.Flags
& ACPI_ROOT_ALLOW_RESIZE
))
658 ACPI_ERROR ((AE_INFO
, "Resize of Root Table Array is not allowed"));
659 return_ACPI_STATUS (AE_SUPPORT
);
662 /* Increase the Table Array size */
664 if (AcpiGbl_RootTableList
.Flags
& ACPI_ROOT_ORIGIN_ALLOCATED
)
666 TableCount
= AcpiGbl_RootTableList
.MaxTableCount
;
670 TableCount
= AcpiGbl_RootTableList
.CurrentTableCount
;
673 MaxTableCount
= TableCount
+ ACPI_ROOT_TABLE_SIZE_INCREMENT
;
674 Tables
= ACPI_ALLOCATE_ZEROED (
675 ((ACPI_SIZE
) MaxTableCount
) * sizeof (ACPI_TABLE_DESC
));
678 ACPI_ERROR ((AE_INFO
, "Could not allocate new root table array"));
679 return_ACPI_STATUS (AE_NO_MEMORY
);
682 /* Copy and free the previous table array */
684 CurrentTableCount
= 0;
685 if (AcpiGbl_RootTableList
.Tables
)
687 for (i
= 0; i
< TableCount
; i
++)
689 if (AcpiGbl_RootTableList
.Tables
[i
].Address
)
691 memcpy (Tables
+ CurrentTableCount
,
692 AcpiGbl_RootTableList
.Tables
+ i
,
693 sizeof (ACPI_TABLE_DESC
));
698 if (AcpiGbl_RootTableList
.Flags
& ACPI_ROOT_ORIGIN_ALLOCATED
)
700 ACPI_FREE (AcpiGbl_RootTableList
.Tables
);
704 AcpiGbl_RootTableList
.Tables
= Tables
;
705 AcpiGbl_RootTableList
.MaxTableCount
= MaxTableCount
;
706 AcpiGbl_RootTableList
.CurrentTableCount
= CurrentTableCount
;
707 AcpiGbl_RootTableList
.Flags
|= ACPI_ROOT_ORIGIN_ALLOCATED
;
709 return_ACPI_STATUS (AE_OK
);
713 /*******************************************************************************
715 * FUNCTION: AcpiTbGetNextTableDescriptor
717 * PARAMETERS: TableIndex - Where table index is returned
718 * TableDesc - Where table descriptor is returned
720 * RETURN: Status and table index/descriptor.
722 * DESCRIPTION: Allocate a new ACPI table entry to the global table list
724 ******************************************************************************/
727 AcpiTbGetNextTableDescriptor (
729 ACPI_TABLE_DESC
**TableDesc
)
735 /* Ensure that there is room for the table in the Root Table List */
737 if (AcpiGbl_RootTableList
.CurrentTableCount
>=
738 AcpiGbl_RootTableList
.MaxTableCount
)
740 Status
= AcpiTbResizeRootTableList();
741 if (ACPI_FAILURE (Status
))
747 i
= AcpiGbl_RootTableList
.CurrentTableCount
;
748 AcpiGbl_RootTableList
.CurrentTableCount
++;
756 *TableDesc
= &AcpiGbl_RootTableList
.Tables
[i
];
763 /*******************************************************************************
765 * FUNCTION: AcpiTbTerminate
771 * DESCRIPTION: Delete all internal ACPI tables
773 ******************************************************************************/
782 ACPI_FUNCTION_TRACE (TbTerminate
);
785 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES
);
787 /* Delete the individual tables */
789 for (i
= 0; i
< AcpiGbl_RootTableList
.CurrentTableCount
; i
++)
791 AcpiTbUninstallTable (&AcpiGbl_RootTableList
.Tables
[i
]);
795 * Delete the root table array if allocated locally. Array cannot be
796 * mapped, so we don't need to check for that flag.
798 if (AcpiGbl_RootTableList
.Flags
& ACPI_ROOT_ORIGIN_ALLOCATED
)
800 ACPI_FREE (AcpiGbl_RootTableList
.Tables
);
803 AcpiGbl_RootTableList
.Tables
= NULL
;
804 AcpiGbl_RootTableList
.Flags
= 0;
805 AcpiGbl_RootTableList
.CurrentTableCount
= 0;
807 ACPI_DEBUG_PRINT ((ACPI_DB_INFO
, "ACPI Tables freed\n"));
809 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES
);
814 /*******************************************************************************
816 * FUNCTION: AcpiTbDeleteNamespaceByOwner
818 * PARAMETERS: TableIndex - Table index
822 * DESCRIPTION: Delete all namespace objects created when this table was loaded.
824 ******************************************************************************/
827 AcpiTbDeleteNamespaceByOwner (
830 ACPI_OWNER_ID OwnerId
;
834 ACPI_FUNCTION_TRACE (TbDeleteNamespaceByOwner
);
837 Status
= AcpiUtAcquireMutex (ACPI_MTX_TABLES
);
838 if (ACPI_FAILURE (Status
))
840 return_ACPI_STATUS (Status
);
843 if (TableIndex
>= AcpiGbl_RootTableList
.CurrentTableCount
)
845 /* The table index does not exist */
847 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES
);
848 return_ACPI_STATUS (AE_NOT_EXIST
);
851 /* Get the owner ID for this table, used to delete namespace nodes */
853 OwnerId
= AcpiGbl_RootTableList
.Tables
[TableIndex
].OwnerId
;
854 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES
);
857 * Need to acquire the namespace writer lock to prevent interference
858 * with any concurrent namespace walks. The interpreter must be
859 * released during the deletion since the acquisition of the deletion
860 * lock may block, and also since the execution of a namespace walk
861 * must be allowed to use the interpreter.
863 Status
= AcpiUtAcquireWriteLock (&AcpiGbl_NamespaceRwLock
);
864 if (ACPI_FAILURE (Status
))
866 return_ACPI_STATUS (Status
);
868 AcpiNsDeleteNamespaceByOwner (OwnerId
);
869 AcpiUtReleaseWriteLock (&AcpiGbl_NamespaceRwLock
);
870 return_ACPI_STATUS (Status
);
874 /*******************************************************************************
876 * FUNCTION: AcpiTbAllocateOwnerId
878 * PARAMETERS: TableIndex - Table index
882 * DESCRIPTION: Allocates OwnerId in TableDesc
884 ******************************************************************************/
887 AcpiTbAllocateOwnerId (
890 ACPI_STATUS Status
= AE_BAD_PARAMETER
;
893 ACPI_FUNCTION_TRACE (TbAllocateOwnerId
);
896 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES
);
897 if (TableIndex
< AcpiGbl_RootTableList
.CurrentTableCount
)
899 Status
= AcpiUtAllocateOwnerId (
900 &(AcpiGbl_RootTableList
.Tables
[TableIndex
].OwnerId
));
903 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES
);
904 return_ACPI_STATUS (Status
);
908 /*******************************************************************************
910 * FUNCTION: AcpiTbReleaseOwnerId
912 * PARAMETERS: TableIndex - Table index
916 * DESCRIPTION: Releases OwnerId in TableDesc
918 ******************************************************************************/
921 AcpiTbReleaseOwnerId (
924 ACPI_STATUS Status
= AE_BAD_PARAMETER
;
927 ACPI_FUNCTION_TRACE (TbReleaseOwnerId
);
930 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES
);
931 if (TableIndex
< AcpiGbl_RootTableList
.CurrentTableCount
)
933 AcpiUtReleaseOwnerId (
934 &(AcpiGbl_RootTableList
.Tables
[TableIndex
].OwnerId
));
938 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES
);
939 return_ACPI_STATUS (Status
);
943 /*******************************************************************************
945 * FUNCTION: AcpiTbGetOwnerId
947 * PARAMETERS: TableIndex - Table index
948 * OwnerId - Where the table OwnerId is returned
952 * DESCRIPTION: returns OwnerId for the ACPI table
954 ******************************************************************************/
959 ACPI_OWNER_ID
*OwnerId
)
961 ACPI_STATUS Status
= AE_BAD_PARAMETER
;
964 ACPI_FUNCTION_TRACE (TbGetOwnerId
);
967 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES
);
968 if (TableIndex
< AcpiGbl_RootTableList
.CurrentTableCount
)
970 *OwnerId
= AcpiGbl_RootTableList
.Tables
[TableIndex
].OwnerId
;
974 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES
);
975 return_ACPI_STATUS (Status
);
979 /*******************************************************************************
981 * FUNCTION: AcpiTbIsTableLoaded
983 * PARAMETERS: TableIndex - Index into the root table
985 * RETURN: Table Loaded Flag
987 ******************************************************************************/
990 AcpiTbIsTableLoaded (
993 BOOLEAN IsLoaded
= FALSE
;
996 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES
);
997 if (TableIndex
< AcpiGbl_RootTableList
.CurrentTableCount
)
1000 (AcpiGbl_RootTableList
.Tables
[TableIndex
].Flags
&
1001 ACPI_TABLE_IS_LOADED
);
1004 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES
);
1009 /*******************************************************************************
1011 * FUNCTION: AcpiTbSetTableLoadedFlag
1013 * PARAMETERS: TableIndex - Table index
1014 * IsLoaded - TRUE if table is loaded, FALSE otherwise
1018 * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE.
1020 ******************************************************************************/
1023 AcpiTbSetTableLoadedFlag (
1028 (void) AcpiUtAcquireMutex (ACPI_MTX_TABLES
);
1029 if (TableIndex
< AcpiGbl_RootTableList
.CurrentTableCount
)
1033 AcpiGbl_RootTableList
.Tables
[TableIndex
].Flags
|=
1034 ACPI_TABLE_IS_LOADED
;
1038 AcpiGbl_RootTableList
.Tables
[TableIndex
].Flags
&=
1039 ~ACPI_TABLE_IS_LOADED
;
1043 (void) AcpiUtReleaseMutex (ACPI_MTX_TABLES
);
1047 /*******************************************************************************
1049 * FUNCTION: AcpiTbLoadTable
1051 * PARAMETERS: TableIndex - Table index
1052 * ParentNode - Where table index is returned
1056 * DESCRIPTION: Load an ACPI table
1058 ******************************************************************************/
1063 ACPI_NAMESPACE_NODE
*ParentNode
)
1065 ACPI_TABLE_HEADER
*Table
;
1067 ACPI_OWNER_ID OwnerId
;
1070 ACPI_FUNCTION_TRACE (TbLoadTable
);
1074 * Note: Now table is "INSTALLED", it must be validated before
1077 Status
= AcpiGetTableByIndex (TableIndex
, &Table
);
1078 if (ACPI_FAILURE (Status
))
1080 return_ACPI_STATUS (Status
);
1083 Status
= AcpiNsLoadTable (TableIndex
, ParentNode
);
1085 /* Execute any module-level code that was found in the table */
1087 if (!AcpiGbl_ParseTableAsTermList
&& AcpiGbl_GroupModuleLevelCode
)
1089 AcpiNsExecModuleCodeList ();
1093 * Update GPEs for any new _Lxx/_Exx methods. Ignore errors. The host is
1094 * responsible for discovering any new wake GPEs by running _PRW methods
1095 * that may have been loaded by this table.
1097 Status
= AcpiTbGetOwnerId (TableIndex
, &OwnerId
);
1098 if (ACPI_SUCCESS (Status
))
1100 AcpiEvUpdateGpes (OwnerId
);
1103 /* Invoke table handler */
1105 AcpiTbNotifyTable (ACPI_TABLE_EVENT_LOAD
, Table
);
1106 return_ACPI_STATUS (Status
);
1110 /*******************************************************************************
1112 * FUNCTION: AcpiTbInstallAndLoadTable
1114 * PARAMETERS: Address - Physical address of the table
1115 * Flags - Allocation flags of the table
1116 * Override - Whether override should be performed
1117 * TableIndex - Where table index is returned
1121 * DESCRIPTION: Install and load an ACPI table
1123 ******************************************************************************/
1126 AcpiTbInstallAndLoadTable (
1127 ACPI_PHYSICAL_ADDRESS Address
,
1136 ACPI_FUNCTION_TRACE (TbInstallAndLoadTable
);
1139 /* Install the table and load it into the namespace */
1141 Status
= AcpiTbInstallStandardTable (Address
, Flags
, TRUE
,
1143 if (ACPI_FAILURE (Status
))
1148 Status
= AcpiTbLoadTable (i
, AcpiGbl_RootNode
);
1152 return_ACPI_STATUS (Status
);
1156 /*******************************************************************************
1158 * FUNCTION: AcpiTbUnloadTable
1160 * PARAMETERS: TableIndex - Table index
1164 * DESCRIPTION: Unload an ACPI table
1166 ******************************************************************************/
1172 ACPI_STATUS Status
= AE_OK
;
1173 ACPI_TABLE_HEADER
*Table
;
1176 ACPI_FUNCTION_TRACE (TbUnloadTable
);
1179 /* Ensure the table is still loaded */
1181 if (!AcpiTbIsTableLoaded (TableIndex
))
1183 return_ACPI_STATUS (AE_NOT_EXIST
);
1186 /* Invoke table handler */
1188 Status
= AcpiGetTableByIndex (TableIndex
, &Table
);
1189 if (ACPI_SUCCESS (Status
))
1191 AcpiTbNotifyTable (ACPI_TABLE_EVENT_UNLOAD
, Table
);
1194 /* Delete the portion of the namespace owned by this table */
1196 Status
= AcpiTbDeleteNamespaceByOwner (TableIndex
);
1197 if (ACPI_FAILURE (Status
))
1199 return_ACPI_STATUS (Status
);
1202 (void) AcpiTbReleaseOwnerId (TableIndex
);
1203 AcpiTbSetTableLoadedFlag (TableIndex
, FALSE
);
1204 return_ACPI_STATUS (Status
);
1208 /*******************************************************************************
1210 * FUNCTION: AcpiTbNotifyTable
1212 * PARAMETERS: Event - Table event
1213 * Table - Validated table pointer
1217 * DESCRIPTION: Notify a table event to the users.
1219 ******************************************************************************/
1226 /* Invoke table handler if present */
1228 if (AcpiGbl_TableHandler
)
1230 (void) AcpiGbl_TableHandler (Event
, Table
,
1231 AcpiGbl_TableHandlerContext
);