aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/acpica/tbinstal.c
diff options
context:
space:
mode:
authorBob Moore <robert.moore@intel.com>2014-04-04 00:39:34 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2014-04-20 16:59:39 -0400
commitc418ce19030f8cd9304b4e97c8e0dd580a81ace5 (patch)
tree9e207efd52fa276a4dac66268f380d2b7047522a /drivers/acpi/acpica/tbinstal.c
parented6f1d44dae8a4eec42a74acae95cc177ee2e1ad (diff)
ACPICA: Table Manager: Split tbinstal.c into two files.
New file is tbdata.c -- management functions for ACPICA table manager data structures. Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lv Zheng <lv.zheng@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/acpica/tbinstal.c')
-rw-r--r--drivers/acpi/acpica/tbinstal.c738
1 files changed, 27 insertions, 711 deletions
diff --git a/drivers/acpi/acpica/tbinstal.c b/drivers/acpi/acpica/tbinstal.c
index 50a6f229633c..d4d6029fef44 100644
--- a/drivers/acpi/acpica/tbinstal.c
+++ b/drivers/acpi/acpica/tbinstal.c
@@ -43,355 +43,57 @@
43 43
44#include <acpi/acpi.h> 44#include <acpi/acpi.h>
45#include "accommon.h" 45#include "accommon.h"
46#include "acnamesp.h"
47#include "actables.h" 46#include "actables.h"
48 47
49#define _COMPONENT ACPI_TABLES 48#define _COMPONENT ACPI_TABLES
50ACPI_MODULE_NAME("tbinstal") 49ACPI_MODULE_NAME("tbinstal")
51 50
52/* Local prototypes */ 51/* Local prototypes */
53static acpi_status
54acpi_tb_acquire_temp_table(struct acpi_table_desc *table_desc,
55 acpi_physical_address address, u8 flags);
56
57static void acpi_tb_release_temp_table(struct acpi_table_desc *table_desc);
58
59static acpi_status acpi_tb_get_root_table_entry(u32 *table_index);
60
61static u8 52static u8
62acpi_tb_is_equivalent_table(struct acpi_table_desc *table_desc, 53acpi_tb_compare_tables(struct acpi_table_desc *table_desc, u32 table_index);
63 u32 table_index);
64
65/*******************************************************************************
66 *
67 * FUNCTION: acpi_tb_acquire_table
68 *
69 * PARAMETERS: table_desc - Table descriptor
70 * table_ptr - Where table is returned
71 * table_length - Where table length is returned
72 * table_flags - Where table allocation flags are returned
73 *
74 * RETURN: Status
75 *
76 * DESCRIPTION: Acquire an ACPI table. It can be used for tables not
77 * maintained in the acpi_gbl_root_table_list.
78 *
79 ******************************************************************************/
80
81acpi_status
82acpi_tb_acquire_table(struct acpi_table_desc *table_desc,
83 struct acpi_table_header **table_ptr,
84 u32 *table_length, u8 *table_flags)
85{
86 struct acpi_table_header *table = NULL;
87
88 switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) {
89 case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL:
90
91 table =
92 acpi_os_map_memory(table_desc->address, table_desc->length);
93 break;
94
95 case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL:
96 case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL:
97
98 table =
99 ACPI_CAST_PTR(struct acpi_table_header,
100 table_desc->address);
101 break;
102
103 default:
104
105 break;
106 }
107
108 /* Table is not valid yet */
109
110 if (!table) {
111 return (AE_NO_MEMORY);
112 }
113
114 /* Fill the return values */
115
116 *table_ptr = table;
117 *table_length = table_desc->length;
118 *table_flags = table_desc->flags;
119 return (AE_OK);
120}
121
122/*******************************************************************************
123 *
124 * FUNCTION: acpi_tb_release_table
125 *
126 * PARAMETERS: table - Pointer for the table
127 * table_length - Length for the table
128 * table_flags - Allocation flags for the table
129 *
130 * RETURN: None
131 *
132 * DESCRIPTION: Release a table. The inverse of acpi_tb_acquire_table().
133 *
134 ******************************************************************************/
135
136void
137acpi_tb_release_table(struct acpi_table_header *table,
138 u32 table_length, u8 table_flags)
139{
140
141 switch (table_flags & ACPI_TABLE_ORIGIN_MASK) {
142 case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL:
143
144 acpi_os_unmap_memory(table, table_length);
145 break;
146
147 case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL:
148 case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL:
149 default:
150
151 break;
152 }
153}
154
155/******************************************************************************
156 *
157 * FUNCTION: acpi_tb_validate_table
158 *
159 * PARAMETERS: table_desc - Table descriptor
160 *
161 * RETURN: Status
162 *
163 * DESCRIPTION: This function is called to validate the table, the returned
164 * table descriptor is in "VALIDATED" state.
165 *
166 *****************************************************************************/
167
168acpi_status acpi_tb_validate_table(struct acpi_table_desc *table_desc)
169{
170 acpi_status status = AE_OK;
171
172 ACPI_FUNCTION_TRACE(tb_validate_table);
173
174 /* Validate the table if necessary */
175
176 if (!table_desc->pointer) {
177 status = acpi_tb_acquire_table(table_desc, &table_desc->pointer,
178 &table_desc->length,
179 &table_desc->flags);
180 if (!table_desc->pointer) {
181 status = AE_NO_MEMORY;
182 }
183 }
184
185 return_ACPI_STATUS(status);
186}
187 54
188/******************************************************************************* 55/*******************************************************************************
189 * 56 *
190 * FUNCTION: acpi_tb_invalidate_table 57 * FUNCTION: acpi_tb_compare_tables
191 * 58 *
192 * PARAMETERS: table_desc - Table descriptor 59 * PARAMETERS: table_desc - Table 1 descriptor to be compared
60 * table_index - Index of table 2 to be compared
193 * 61 *
194 * RETURN: None 62 * RETURN: TRUE if both tables are identical.
195 * 63 *
196 * DESCRIPTION: Invalidate one internal ACPI table, this is the inverse of 64 * DESCRIPTION: This function compares a table with another table that has
197 * acpi_tb_validate_table(). 65 * already been installed in the root table list.
198 * 66 *
199 ******************************************************************************/ 67 ******************************************************************************/
200 68
201void acpi_tb_invalidate_table(struct acpi_table_desc *table_desc) 69static u8
202{ 70acpi_tb_compare_tables(struct acpi_table_desc *table_desc, u32 table_index)
203
204 ACPI_FUNCTION_TRACE(tb_invalidate_table);
205
206 /* Table must be validated */
207
208 if (!table_desc->pointer) {
209 return_VOID;
210 }
211
212 acpi_tb_release_table(table_desc->pointer, table_desc->length,
213 table_desc->flags);
214 table_desc->pointer = NULL;
215
216 return_VOID;
217}
218
219/******************************************************************************
220 *
221 * FUNCTION: acpi_tb_verify_table
222 *
223 * PARAMETERS: table_desc - Table descriptor
224 * signature - Table signature to verify
225 *
226 * RETURN: Status
227 *
228 * DESCRIPTION: This function is called to validate and verify the table, the
229 * returned table descriptor is in "VALIDATED" state.
230 *
231 *****************************************************************************/
232
233acpi_status
234acpi_tb_verify_table(struct acpi_table_desc *table_desc, char *signature)
235{ 71{
236 acpi_status status = AE_OK; 72 acpi_status status = AE_OK;
237 73 u8 is_identical;
238 ACPI_FUNCTION_TRACE(tb_verify_table); 74 struct acpi_table_header *table;
239 75 u32 table_length;
240 /* Validate the table */ 76 u8 table_flags;
241
242 status = acpi_tb_validate_table(table_desc);
243 if (ACPI_FAILURE(status)) {
244 return_ACPI_STATUS(AE_NO_MEMORY);
245 }
246
247 /* If a particular signature is expected (DSDT/FACS), it must match */
248
249 if (signature && !ACPI_COMPARE_NAME(&table_desc->signature, signature)) {
250 ACPI_BIOS_ERROR((AE_INFO,
251 "Invalid signature 0x%X for ACPI table, expected [%s]",
252 table_desc->signature.integer, signature));
253 status = AE_BAD_SIGNATURE;
254 goto invalidate_and_exit;
255 }
256
257 /* Verify the checksum */
258 77
259 status = 78 status =
260 acpi_tb_verify_checksum(table_desc->pointer, table_desc->length); 79 acpi_tb_acquire_table(&acpi_gbl_root_table_list.tables[table_index],
80 &table, &table_length, &table_flags);
261 if (ACPI_FAILURE(status)) { 81 if (ACPI_FAILURE(status)) {
262 ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY, 82 return (FALSE);
263 "%4.4s " ACPI_PRINTF_UINT
264 " Attempted table install failed",
265 acpi_ut_valid_acpi_name(table_desc->signature.
266 ascii) ? table_desc->
267 signature.ascii : "????",
268 ACPI_FORMAT_TO_UINT(table_desc->address)));
269 goto invalidate_and_exit;
270 } 83 }
271 84
272 return_ACPI_STATUS(AE_OK);
273
274invalidate_and_exit:
275 acpi_tb_invalidate_table(table_desc);
276 return_ACPI_STATUS(status);
277}
278
279/*******************************************************************************
280 *
281 * FUNCTION: acpi_tb_init_table_descriptor
282 *
283 * PARAMETERS: table_desc - Table descriptor
284 * address - Physical address of the table
285 * flags - Allocation flags of the table
286 * table - Pointer to the table
287 *
288 * RETURN: None
289 *
290 * DESCRIPTION: Initialize a new table descriptor
291 *
292 ******************************************************************************/
293
294void
295acpi_tb_init_table_descriptor(struct acpi_table_desc *table_desc,
296 acpi_physical_address address,
297 u8 flags, struct acpi_table_header *table)
298{
299
300 /* 85 /*
301 * Initialize the table descriptor. Set the pointer to NULL, since the 86 * Check for a table match on the entire table length,
302 * table is not fully mapped at this time. 87 * not just the header.
303 */ 88 */
304 ACPI_MEMSET(table_desc, 0, sizeof(struct acpi_table_desc)); 89 is_identical = (u8)((table_desc->length != table_length ||
305 table_desc->address = address; 90 ACPI_MEMCMP(table_desc->pointer, table,
306 table_desc->length = table->length; 91 table_length)) ? FALSE : TRUE);
307 table_desc->flags = flags;
308 ACPI_MOVE_32_TO_32(table_desc->signature.ascii, table->signature);
309}
310
311/*******************************************************************************
312 *
313 * FUNCTION: acpi_tb_acquire_temp_table
314 *
315 * PARAMETERS: table_desc - Table descriptor to be acquired
316 * address - Address of the table
317 * flags - Allocation flags of the table
318 *
319 * RETURN: Status
320 *
321 * DESCRIPTION: This function validates the table header to obtain the length
322 * of a table and fills the table descriptor to make its state as
323 * "INSTALLED". Such a table descriptor is only used for verified
324 * installation.
325 *
326 ******************************************************************************/
327
328static acpi_status
329acpi_tb_acquire_temp_table(struct acpi_table_desc *table_desc,
330 acpi_physical_address address, u8 flags)
331{
332 struct acpi_table_header *table_header;
333
334 switch (flags & ACPI_TABLE_ORIGIN_MASK) {
335 case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL:
336
337 /* Get the length of the full table from the header */
338
339 table_header =
340 acpi_os_map_memory(address,
341 sizeof(struct acpi_table_header));
342 if (!table_header) {
343 return (AE_NO_MEMORY);
344 }
345
346 acpi_tb_init_table_descriptor(table_desc, address, flags,
347 table_header);
348 acpi_os_unmap_memory(table_header,
349 sizeof(struct acpi_table_header));
350 return (AE_OK);
351
352 case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL:
353 case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL:
354 92
355 table_header = ACPI_CAST_PTR(struct acpi_table_header, address); 93 /* Release the acquired table */
356 if (!table_header) {
357 return (AE_NO_MEMORY);
358 }
359
360 acpi_tb_init_table_descriptor(table_desc, address, flags,
361 table_header);
362 return (AE_OK);
363
364 default:
365
366 break;
367 }
368
369 /* Table is not valid yet */
370
371 return (AE_NO_MEMORY);
372}
373
374/*******************************************************************************
375 *
376 * FUNCTION: acpi_tb_release_temp_table
377 *
378 * PARAMETERS: table_desc - Table descriptor to be released
379 *
380 * RETURN: Status
381 *
382 * DESCRIPTION: The inverse of acpi_tb_acquire_temp_table().
383 *
384 ******************************************************************************/
385
386static void acpi_tb_release_temp_table(struct acpi_table_desc *table_desc)
387{
388 94
389 /* 95 acpi_tb_release_table(table, table_length, table_flags);
390 * Note that the .Address is maintained by the callers of 96 return (is_identical);
391 * acpi_tb_acquire_temp_table(), thus do not invoke acpi_tb_uninstall_table()
392 * where .Address will be freed.
393 */
394 acpi_tb_invalidate_table(table_desc);
395} 97}
396 98
397/******************************************************************************* 99/*******************************************************************************
@@ -509,50 +211,6 @@ release_and_exit:
509 211
510/******************************************************************************* 212/*******************************************************************************
511 * 213 *
512 * FUNCTION: acpi_tb_is_equivalent_table
513 *
514 * PARAMETERS: table_desc - Table 1 descriptor to be compared
515 * table_index - Index of table 2 to be compared
516 *
517 * RETURN: TRUE if 2 tables are equivalent
518 *
519 * DESCRIPTION: This function is called to compare a table with what have
520 * already been installed in the root table list.
521 *
522 ******************************************************************************/
523
524static u8
525acpi_tb_is_equivalent_table(struct acpi_table_desc *table_desc, u32 table_index)
526{
527 acpi_status status = AE_OK;
528 u8 is_equivalent;
529 struct acpi_table_header *table;
530 u32 table_length;
531 u8 table_flags;
532
533 status =
534 acpi_tb_acquire_table(&acpi_gbl_root_table_list.tables[table_index],
535 &table, &table_length, &table_flags);
536 if (ACPI_FAILURE(status)) {
537 return (FALSE);
538 }
539
540 /*
541 * Check for a table match on the entire table length,
542 * not just the header.
543 */
544 is_equivalent = (u8)((table_desc->length != table_length ||
545 ACPI_MEMCMP(table_desc->pointer, table,
546 table_length)) ? FALSE : TRUE);
547
548 /* Release the acquired table */
549
550 acpi_tb_release_table(table, table_length, table_flags);
551 return (is_equivalent);
552}
553
554/*******************************************************************************
555 *
556 * FUNCTION: acpi_tb_install_standard_table 214 * FUNCTION: acpi_tb_install_standard_table
557 * 215 *
558 * PARAMETERS: address - Address of the table (might be a virtual 216 * PARAMETERS: address - Address of the table (might be a virtual
@@ -652,7 +310,7 @@ acpi_tb_install_standard_table(acpi_physical_address address,
652 * Check for a table match on the entire table length, 310 * Check for a table match on the entire table length,
653 * not just the header. 311 * not just the header.
654 */ 312 */
655 if (!acpi_tb_is_equivalent_table(&new_table_desc, i)) { 313 if (!acpi_tb_compare_tables(&new_table_desc, i)) {
656 continue; 314 continue;
657 } 315 }
658 316
@@ -696,7 +354,7 @@ acpi_tb_install_standard_table(acpi_physical_address address,
696 354
697 /* Add the table to the global root table list */ 355 /* Add the table to the global root table list */
698 356
699 status = acpi_tb_get_root_table_entry(&i); 357 status = acpi_tb_get_next_root_index(&i);
700 if (ACPI_FAILURE(status)) { 358 if (ACPI_FAILURE(status)) {
701 goto release_and_exit; 359 goto release_and_exit;
702 } 360 }
@@ -797,101 +455,6 @@ finish_override:
797 455
798/******************************************************************************* 456/*******************************************************************************
799 * 457 *
800 * FUNCTION: acpi_tb_resize_root_table_list
801 *
802 * PARAMETERS: None
803 *
804 * RETURN: Status
805 *
806 * DESCRIPTION: Expand the size of global table array
807 *
808 ******************************************************************************/
809
810acpi_status acpi_tb_resize_root_table_list(void)
811{
812 struct acpi_table_desc *tables;
813 u32 table_count;
814
815 ACPI_FUNCTION_TRACE(tb_resize_root_table_list);
816
817 /* allow_resize flag is a parameter to acpi_initialize_tables */
818
819 if (!(acpi_gbl_root_table_list.flags & ACPI_ROOT_ALLOW_RESIZE)) {
820 ACPI_ERROR((AE_INFO,
821 "Resize of Root Table Array is not allowed"));
822 return_ACPI_STATUS(AE_SUPPORT);
823 }
824
825 /* Increase the Table Array size */
826
827 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
828 table_count = acpi_gbl_root_table_list.max_table_count;
829 } else {
830 table_count = acpi_gbl_root_table_list.current_table_count;
831 }
832
833 tables = ACPI_ALLOCATE_ZEROED(((acpi_size) table_count +
834 ACPI_ROOT_TABLE_SIZE_INCREMENT) *
835 sizeof(struct acpi_table_desc));
836 if (!tables) {
837 ACPI_ERROR((AE_INFO,
838 "Could not allocate new root table array"));
839 return_ACPI_STATUS(AE_NO_MEMORY);
840 }
841
842 /* Copy and free the previous table array */
843
844 if (acpi_gbl_root_table_list.tables) {
845 ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables,
846 (acpi_size) table_count *
847 sizeof(struct acpi_table_desc));
848
849 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
850 ACPI_FREE(acpi_gbl_root_table_list.tables);
851 }
852 }
853
854 acpi_gbl_root_table_list.tables = tables;
855 acpi_gbl_root_table_list.max_table_count =
856 table_count + ACPI_ROOT_TABLE_SIZE_INCREMENT;
857 acpi_gbl_root_table_list.flags |= ACPI_ROOT_ORIGIN_ALLOCATED;
858
859 return_ACPI_STATUS(AE_OK);
860}
861
862/*******************************************************************************
863 *
864 * FUNCTION: acpi_tb_get_root_table_entry
865 *
866 * PARAMETERS: table_index - Where table index is returned
867 *
868 * RETURN: Status and table index.
869 *
870 * DESCRIPTION: Allocate a new ACPI table entry to the global table list
871 *
872 ******************************************************************************/
873
874static acpi_status acpi_tb_get_root_table_entry(u32 *table_index)
875{
876 acpi_status status;
877
878 /* Ensure that there is room for the table in the Root Table List */
879
880 if (acpi_gbl_root_table_list.current_table_count >=
881 acpi_gbl_root_table_list.max_table_count) {
882 status = acpi_tb_resize_root_table_list();
883 if (ACPI_FAILURE(status)) {
884 return (status);
885 }
886 }
887
888 *table_index = acpi_gbl_root_table_list.current_table_count;
889 acpi_gbl_root_table_list.current_table_count++;
890 return (AE_OK);
891}
892
893/*******************************************************************************
894 *
895 * FUNCTION: acpi_tb_store_table 458 * FUNCTION: acpi_tb_store_table
896 * 459 *
897 * PARAMETERS: address - Table address 460 * PARAMETERS: address - Table address
@@ -914,7 +477,7 @@ acpi_tb_store_table(acpi_physical_address address,
914 acpi_status status; 477 acpi_status status;
915 struct acpi_table_desc *table_desc; 478 struct acpi_table_desc *table_desc;
916 479
917 status = acpi_tb_get_root_table_entry(table_index); 480 status = acpi_tb_get_next_root_index(table_index);
918 if (ACPI_FAILURE(status)) { 481 if (ACPI_FAILURE(status)) {
919 return (status); 482 return (status);
920 } 483 }
@@ -960,250 +523,3 @@ void acpi_tb_uninstall_table(struct acpi_table_desc *table_desc)
960 table_desc->address = ACPI_PTR_TO_PHYSADDR(NULL); 523 table_desc->address = ACPI_PTR_TO_PHYSADDR(NULL);
961 return_VOID; 524 return_VOID;
962} 525}
963
964/*******************************************************************************
965 *
966 * FUNCTION: acpi_tb_terminate
967 *
968 * PARAMETERS: None
969 *
970 * RETURN: None
971 *
972 * DESCRIPTION: Delete all internal ACPI tables
973 *
974 ******************************************************************************/
975
976void acpi_tb_terminate(void)
977{
978 u32 i;
979
980 ACPI_FUNCTION_TRACE(tb_terminate);
981
982 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
983
984 /* Delete the individual tables */
985
986 for (i = 0; i < acpi_gbl_root_table_list.current_table_count; i++) {
987 acpi_tb_uninstall_table(&acpi_gbl_root_table_list.tables[i]);
988 }
989
990 /*
991 * Delete the root table array if allocated locally. Array cannot be
992 * mapped, so we don't need to check for that flag.
993 */
994 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
995 ACPI_FREE(acpi_gbl_root_table_list.tables);
996 }
997
998 acpi_gbl_root_table_list.tables = NULL;
999 acpi_gbl_root_table_list.flags = 0;
1000 acpi_gbl_root_table_list.current_table_count = 0;
1001
1002 ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n"));
1003
1004 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
1005 return_VOID;
1006}
1007
1008/*******************************************************************************
1009 *
1010 * FUNCTION: acpi_tb_delete_namespace_by_owner
1011 *
1012 * PARAMETERS: table_index - Table index
1013 *
1014 * RETURN: Status
1015 *
1016 * DESCRIPTION: Delete all namespace objects created when this table was loaded.
1017 *
1018 ******************************************************************************/
1019
1020acpi_status acpi_tb_delete_namespace_by_owner(u32 table_index)
1021{
1022 acpi_owner_id owner_id;
1023 acpi_status status;
1024
1025 ACPI_FUNCTION_TRACE(tb_delete_namespace_by_owner);
1026
1027 status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
1028 if (ACPI_FAILURE(status)) {
1029 return_ACPI_STATUS(status);
1030 }
1031
1032 if (table_index >= acpi_gbl_root_table_list.current_table_count) {
1033
1034 /* The table index does not exist */
1035
1036 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
1037 return_ACPI_STATUS(AE_NOT_EXIST);
1038 }
1039
1040 /* Get the owner ID for this table, used to delete namespace nodes */
1041
1042 owner_id = acpi_gbl_root_table_list.tables[table_index].owner_id;
1043 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
1044
1045 /*
1046 * Need to acquire the namespace writer lock to prevent interference
1047 * with any concurrent namespace walks. The interpreter must be
1048 * released during the deletion since the acquisition of the deletion
1049 * lock may block, and also since the execution of a namespace walk
1050 * must be allowed to use the interpreter.
1051 */
1052 (void)acpi_ut_release_mutex(ACPI_MTX_INTERPRETER);
1053 status = acpi_ut_acquire_write_lock(&acpi_gbl_namespace_rw_lock);
1054
1055 acpi_ns_delete_namespace_by_owner(owner_id);
1056 if (ACPI_FAILURE(status)) {
1057 return_ACPI_STATUS(status);
1058 }
1059
1060 acpi_ut_release_write_lock(&acpi_gbl_namespace_rw_lock);
1061
1062 status = acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER);
1063 return_ACPI_STATUS(status);
1064}
1065
1066/*******************************************************************************
1067 *
1068 * FUNCTION: acpi_tb_allocate_owner_id
1069 *
1070 * PARAMETERS: table_index - Table index
1071 *
1072 * RETURN: Status
1073 *
1074 * DESCRIPTION: Allocates owner_id in table_desc
1075 *
1076 ******************************************************************************/
1077
1078acpi_status acpi_tb_allocate_owner_id(u32 table_index)
1079{
1080 acpi_status status = AE_BAD_PARAMETER;
1081
1082 ACPI_FUNCTION_TRACE(tb_allocate_owner_id);
1083
1084 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
1085 if (table_index < acpi_gbl_root_table_list.current_table_count) {
1086 status =
1087 acpi_ut_allocate_owner_id(&
1088 (acpi_gbl_root_table_list.
1089 tables[table_index].owner_id));
1090 }
1091
1092 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
1093 return_ACPI_STATUS(status);
1094}
1095
1096/*******************************************************************************
1097 *
1098 * FUNCTION: acpi_tb_release_owner_id
1099 *
1100 * PARAMETERS: table_index - Table index
1101 *
1102 * RETURN: Status
1103 *
1104 * DESCRIPTION: Releases owner_id in table_desc
1105 *
1106 ******************************************************************************/
1107
1108acpi_status acpi_tb_release_owner_id(u32 table_index)
1109{
1110 acpi_status status = AE_BAD_PARAMETER;
1111
1112 ACPI_FUNCTION_TRACE(tb_release_owner_id);
1113
1114 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
1115 if (table_index < acpi_gbl_root_table_list.current_table_count) {
1116 acpi_ut_release_owner_id(&
1117 (acpi_gbl_root_table_list.
1118 tables[table_index].owner_id));
1119 status = AE_OK;
1120 }
1121
1122 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
1123 return_ACPI_STATUS(status);
1124}
1125
1126/*******************************************************************************
1127 *
1128 * FUNCTION: acpi_tb_get_owner_id
1129 *
1130 * PARAMETERS: table_index - Table index
1131 * owner_id - Where the table owner_id is returned
1132 *
1133 * RETURN: Status
1134 *
1135 * DESCRIPTION: returns owner_id for the ACPI table
1136 *
1137 ******************************************************************************/
1138
1139acpi_status acpi_tb_get_owner_id(u32 table_index, acpi_owner_id * owner_id)
1140{
1141 acpi_status status = AE_BAD_PARAMETER;
1142
1143 ACPI_FUNCTION_TRACE(tb_get_owner_id);
1144
1145 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
1146 if (table_index < acpi_gbl_root_table_list.current_table_count) {
1147 *owner_id =
1148 acpi_gbl_root_table_list.tables[table_index].owner_id;
1149 status = AE_OK;
1150 }
1151
1152 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
1153 return_ACPI_STATUS(status);
1154}
1155
1156/*******************************************************************************
1157 *
1158 * FUNCTION: acpi_tb_is_table_loaded
1159 *
1160 * PARAMETERS: table_index - Index into the root table
1161 *
1162 * RETURN: Table Loaded Flag
1163 *
1164 ******************************************************************************/
1165
1166u8 acpi_tb_is_table_loaded(u32 table_index)
1167{
1168 u8 is_loaded = FALSE;
1169
1170 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
1171 if (table_index < acpi_gbl_root_table_list.current_table_count) {
1172 is_loaded = (u8)
1173 (acpi_gbl_root_table_list.tables[table_index].flags &
1174 ACPI_TABLE_IS_LOADED);
1175 }
1176
1177 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
1178 return (is_loaded);
1179}
1180
1181/*******************************************************************************
1182 *
1183 * FUNCTION: acpi_tb_set_table_loaded_flag
1184 *
1185 * PARAMETERS: table_index - Table index
1186 * is_loaded - TRUE if table is loaded, FALSE otherwise
1187 *
1188 * RETURN: None
1189 *
1190 * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE.
1191 *
1192 ******************************************************************************/
1193
1194void acpi_tb_set_table_loaded_flag(u32 table_index, u8 is_loaded)
1195{
1196
1197 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
1198 if (table_index < acpi_gbl_root_table_list.current_table_count) {
1199 if (is_loaded) {
1200 acpi_gbl_root_table_list.tables[table_index].flags |=
1201 ACPI_TABLE_IS_LOADED;
1202 } else {
1203 acpi_gbl_root_table_list.tables[table_index].flags &=
1204 ~ACPI_TABLE_IS_LOADED;
1205 }
1206 }
1207
1208 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
1209}