Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /****************************************************************************** |
2 | * | |
3 | * Module Name: tbinstal - ACPI table installation and removal | |
4 | * | |
5 | *****************************************************************************/ | |
6 | ||
7 | /* | |
75a44ce0 | 8 | * Copyright (C) 2000 - 2008, Intel Corp. |
1da177e4 LT |
9 | * All rights reserved. |
10 | * | |
11 | * Redistribution and use in source and binary forms, with or without | |
12 | * modification, are permitted provided that the following conditions | |
13 | * are met: | |
14 | * 1. Redistributions of source code must retain the above copyright | |
15 | * notice, this list of conditions, and the following disclaimer, | |
16 | * without modification. | |
17 | * 2. Redistributions in binary form must reproduce at minimum a disclaimer | |
18 | * substantially similar to the "NO WARRANTY" disclaimer below | |
19 | * ("Disclaimer") and any redistribution must be conditioned upon | |
20 | * including a substantially similar Disclaimer requirement for further | |
21 | * binary redistribution. | |
22 | * 3. Neither the names of the above-listed copyright holders nor the names | |
23 | * of any contributors may be used to endorse or promote products derived | |
24 | * from this software without specific prior written permission. | |
25 | * | |
26 | * Alternatively, this software may be distributed under the terms of the | |
27 | * GNU General Public License ("GPL") version 2 as published by the Free | |
28 | * Software Foundation. | |
29 | * | |
30 | * NO WARRANTY | |
31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
32 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
33 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | |
34 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
35 | * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
36 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
37 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
38 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
39 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | |
40 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
41 | * POSSIBILITY OF SUCH DAMAGES. | |
42 | */ | |
43 | ||
1da177e4 | 44 | #include <acpi/acpi.h> |
f3d2e786 | 45 | #include <acpi/acnamesp.h> |
1da177e4 LT |
46 | #include <acpi/actables.h> |
47 | ||
1da177e4 | 48 | #define _COMPONENT ACPI_TABLES |
4be44fcd | 49 | ACPI_MODULE_NAME("tbinstal") |
1da177e4 | 50 | |
f3d2e786 | 51 | /****************************************************************************** |
1da177e4 | 52 | * |
f3d2e786 | 53 | * FUNCTION: acpi_tb_verify_table |
1da177e4 | 54 | * |
f3d2e786 | 55 | * PARAMETERS: table_desc - table |
1da177e4 LT |
56 | * |
57 | * RETURN: Status | |
58 | * | |
f3d2e786 | 59 | * DESCRIPTION: this function is called to verify and map table |
1da177e4 | 60 | * |
f3d2e786 BM |
61 | *****************************************************************************/ |
62 | acpi_status acpi_tb_verify_table(struct acpi_table_desc *table_desc) | |
1da177e4 | 63 | { |
428f2112 | 64 | acpi_status status = AE_OK; |
1da177e4 | 65 | |
f3d2e786 | 66 | ACPI_FUNCTION_TRACE(tb_verify_table); |
1da177e4 | 67 | |
f3d2e786 | 68 | /* Map the table if necessary */ |
44f6c012 | 69 | |
f3d2e786 | 70 | if (!table_desc->pointer) { |
428f2112 AS |
71 | if ((table_desc->flags & ACPI_TABLE_ORIGIN_MASK) == |
72 | ACPI_TABLE_ORIGIN_MAPPED) { | |
73 | table_desc->pointer = | |
74 | acpi_os_map_memory(table_desc->address, | |
75 | table_desc->length); | |
76 | } | |
f3d2e786 BM |
77 | if (!table_desc->pointer) { |
78 | return_ACPI_STATUS(AE_NO_MEMORY); | |
1da177e4 | 79 | } |
f3d2e786 | 80 | } |
1da177e4 | 81 | |
f3d2e786 | 82 | /* FACS is the odd table, has no standard ACPI header and no checksum */ |
52fc0b02 | 83 | |
428f2112 | 84 | if (!ACPI_COMPARE_NAME(&table_desc->signature, ACPI_SIG_FACS)) { |
1da177e4 | 85 | |
428f2112 AS |
86 | /* Always calculate checksum, ignore bad checksum if requested */ |
87 | ||
88 | status = | |
89 | acpi_tb_verify_checksum(table_desc->pointer, | |
90 | table_desc->length); | |
91 | } | |
1da177e4 | 92 | |
c5fc42ac | 93 | return_ACPI_STATUS(status); |
1da177e4 LT |
94 | } |
95 | ||
1da177e4 LT |
96 | /******************************************************************************* |
97 | * | |
f3d2e786 | 98 | * FUNCTION: acpi_tb_add_table |
1da177e4 | 99 | * |
428f2112 | 100 | * PARAMETERS: table_desc - Table descriptor |
f3d2e786 | 101 | * table_index - Where the table index is returned |
1da177e4 LT |
102 | * |
103 | * RETURN: Status | |
104 | * | |
f3d2e786 | 105 | * DESCRIPTION: This function is called to add the ACPI table |
1da177e4 LT |
106 | * |
107 | ******************************************************************************/ | |
108 | ||
f3d2e786 | 109 | acpi_status |
67a119f9 | 110 | acpi_tb_add_table(struct acpi_table_desc *table_desc, u32 *table_index) |
1da177e4 | 111 | { |
67a119f9 | 112 | u32 i; |
f3d2e786 | 113 | acpi_status status = AE_OK; |
1da177e4 | 114 | |
f3d2e786 | 115 | ACPI_FUNCTION_TRACE(tb_add_table); |
1da177e4 | 116 | |
428f2112 AS |
117 | if (!table_desc->pointer) { |
118 | status = acpi_tb_verify_table(table_desc); | |
119 | if (ACPI_FAILURE(status) || !table_desc->pointer) { | |
120 | return_ACPI_STATUS(status); | |
121 | } | |
122 | } | |
123 | ||
bc45b1d3 BM |
124 | /* |
125 | * Originally, we checked the table signature for "SSDT" or "PSDT" here. | |
126 | * Next, we added support for OEMx tables, signature "OEM". | |
127 | * Valid tables were encountered with a null signature, so we've just | |
128 | * given up on validating the signature, since it seems to be a waste | |
129 | * of code. The original code was removed (05/2008). | |
130 | */ | |
428f2112 | 131 | |
f3d2e786 | 132 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
1da177e4 | 133 | |
f3d2e786 BM |
134 | /* Check if table is already registered */ |
135 | ||
136 | for (i = 0; i < acpi_gbl_root_table_list.count; ++i) { | |
137 | if (!acpi_gbl_root_table_list.tables[i].pointer) { | |
138 | status = | |
139 | acpi_tb_verify_table(&acpi_gbl_root_table_list. | |
140 | tables[i]); | |
141 | if (ACPI_FAILURE(status) | |
142 | || !acpi_gbl_root_table_list.tables[i].pointer) { | |
143 | continue; | |
144 | } | |
145 | } | |
146 | ||
a6f30539 BM |
147 | /* |
148 | * Check for a table match on the entire table length, | |
149 | * not just the header. | |
150 | */ | |
151 | if (table_desc->length != | |
152 | acpi_gbl_root_table_list.tables[i].length) { | |
153 | continue; | |
154 | } | |
e56f5617 | 155 | |
428f2112 AS |
156 | if (ACPI_MEMCMP(table_desc->pointer, |
157 | acpi_gbl_root_table_list.tables[i].pointer, | |
a6f30539 | 158 | acpi_gbl_root_table_list.tables[i].length)) { |
f3d2e786 BM |
159 | continue; |
160 | } | |
161 | ||
e56f5617 BM |
162 | /* |
163 | * Note: the current mechanism does not unregister a table if it is | |
164 | * dynamically unloaded. The related namespace entries are deleted, | |
165 | * but the table remains in the root table list. | |
166 | * | |
167 | * The assumption here is that the number of different tables that | |
168 | * will be loaded is actually small, and there is minimal overhead | |
169 | * in just keeping the table in case it is needed again. | |
170 | * | |
171 | * If this assumption changes in the future (perhaps on large | |
172 | * machines with many table load/unload operations), tables will | |
173 | * need to be unregistered when they are unloaded, and slots in the | |
174 | * root table list should be reused when empty. | |
175 | */ | |
176 | ||
177 | /* | |
178 | * Table is already registered. | |
179 | * We can delete the table that was passed as a parameter. | |
180 | */ | |
428f2112 | 181 | acpi_tb_delete_table(table_desc); |
f3d2e786 | 182 | *table_index = i; |
e56f5617 BM |
183 | |
184 | if (acpi_gbl_root_table_list.tables[i]. | |
185 | flags & ACPI_TABLE_IS_LOADED) { | |
186 | ||
187 | /* Table is still loaded, this is an error */ | |
188 | ||
189 | status = AE_ALREADY_EXISTS; | |
190 | goto release; | |
191 | } else { | |
192 | /* Table was unloaded, allow it to be reloaded */ | |
193 | ||
194 | table_desc->pointer = | |
195 | acpi_gbl_root_table_list.tables[i].pointer; | |
196 | table_desc->address = | |
197 | acpi_gbl_root_table_list.tables[i].address; | |
198 | status = AE_OK; | |
199 | goto print_header; | |
200 | } | |
1da177e4 LT |
201 | } |
202 | ||
e56f5617 BM |
203 | /* Add the table to the global root table list */ |
204 | ||
428f2112 AS |
205 | status = acpi_tb_store_table(table_desc->address, table_desc->pointer, |
206 | table_desc->length, table_desc->flags, | |
207 | table_index); | |
4be44fcd | 208 | if (ACPI_FAILURE(status)) { |
f3d2e786 | 209 | goto release; |
0c9938cc RM |
210 | } |
211 | ||
e56f5617 | 212 | print_header: |
428f2112 | 213 | acpi_tb_print_table_header(table_desc->address, table_desc->pointer); |
1da177e4 | 214 | |
f3d2e786 | 215 | release: |
4be44fcd LB |
216 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
217 | return_ACPI_STATUS(status); | |
1da177e4 LT |
218 | } |
219 | ||
1da177e4 LT |
220 | /******************************************************************************* |
221 | * | |
f3d2e786 | 222 | * FUNCTION: acpi_tb_resize_root_table_list |
1da177e4 | 223 | * |
f3d2e786 | 224 | * PARAMETERS: None |
1da177e4 LT |
225 | * |
226 | * RETURN: Status | |
227 | * | |
f3d2e786 | 228 | * DESCRIPTION: Expand the size of global table array |
1da177e4 LT |
229 | * |
230 | ******************************************************************************/ | |
231 | ||
f3d2e786 | 232 | acpi_status acpi_tb_resize_root_table_list(void) |
1da177e4 | 233 | { |
f3d2e786 | 234 | struct acpi_table_desc *tables; |
1da177e4 | 235 | |
f3d2e786 | 236 | ACPI_FUNCTION_TRACE(tb_resize_root_table_list); |
1da177e4 | 237 | |
f3d2e786 | 238 | /* allow_resize flag is a parameter to acpi_initialize_tables */ |
1da177e4 | 239 | |
c5fc42ac | 240 | if (!(acpi_gbl_root_table_list.flags & ACPI_ROOT_ALLOW_RESIZE)) { |
f3d2e786 BM |
241 | ACPI_ERROR((AE_INFO, |
242 | "Resize of Root Table Array is not allowed")); | |
243 | return_ACPI_STATUS(AE_SUPPORT); | |
1da177e4 LT |
244 | } |
245 | ||
f3d2e786 BM |
246 | /* Increase the Table Array size */ |
247 | ||
67a119f9 BM |
248 | tables = ACPI_ALLOCATE_ZEROED(((acpi_size) acpi_gbl_root_table_list. |
249 | size + ACPI_ROOT_TABLE_SIZE_INCREMENT) | |
f3d2e786 BM |
250 | * sizeof(struct acpi_table_desc)); |
251 | if (!tables) { | |
252 | ACPI_ERROR((AE_INFO, | |
253 | "Could not allocate new root table array")); | |
254 | return_ACPI_STATUS(AE_NO_MEMORY); | |
1da177e4 LT |
255 | } |
256 | ||
f3d2e786 BM |
257 | /* Copy and free the previous table array */ |
258 | ||
259 | if (acpi_gbl_root_table_list.tables) { | |
260 | ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables, | |
67a119f9 | 261 | (acpi_size) acpi_gbl_root_table_list.size * |
f3d2e786 BM |
262 | sizeof(struct acpi_table_desc)); |
263 | ||
c5fc42ac | 264 | if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { |
f3d2e786 BM |
265 | ACPI_FREE(acpi_gbl_root_table_list.tables); |
266 | } | |
1da177e4 LT |
267 | } |
268 | ||
f3d2e786 BM |
269 | acpi_gbl_root_table_list.tables = tables; |
270 | acpi_gbl_root_table_list.size += ACPI_ROOT_TABLE_SIZE_INCREMENT; | |
c5fc42ac | 271 | acpi_gbl_root_table_list.flags |= (u8) ACPI_ROOT_ORIGIN_ALLOCATED; |
1da177e4 | 272 | |
f3d2e786 | 273 | return_ACPI_STATUS(AE_OK); |
1da177e4 LT |
274 | } |
275 | ||
1da177e4 LT |
276 | /******************************************************************************* |
277 | * | |
f3d2e786 | 278 | * FUNCTION: acpi_tb_store_table |
1da177e4 | 279 | * |
f3d2e786 BM |
280 | * PARAMETERS: Address - Table address |
281 | * Table - Table header | |
282 | * Length - Table length | |
283 | * Flags - flags | |
1da177e4 | 284 | * |
f3d2e786 | 285 | * RETURN: Status and table index. |
1da177e4 | 286 | * |
f3d2e786 | 287 | * DESCRIPTION: Add an ACPI table to the global table list |
1da177e4 LT |
288 | * |
289 | ******************************************************************************/ | |
290 | ||
291 | acpi_status | |
f3d2e786 BM |
292 | acpi_tb_store_table(acpi_physical_address address, |
293 | struct acpi_table_header *table, | |
67a119f9 | 294 | u32 length, u8 flags, u32 *table_index) |
1da177e4 | 295 | { |
f3d2e786 | 296 | acpi_status status = AE_OK; |
1da177e4 | 297 | |
f3d2e786 | 298 | /* Ensure that there is room for the table in the Root Table List */ |
f9f4601f | 299 | |
f3d2e786 BM |
300 | if (acpi_gbl_root_table_list.count >= acpi_gbl_root_table_list.size) { |
301 | status = acpi_tb_resize_root_table_list(); | |
302 | if (ACPI_FAILURE(status)) { | |
303 | return (status); | |
304 | } | |
f9f4601f RM |
305 | } |
306 | ||
f3d2e786 BM |
307 | /* Initialize added table */ |
308 | ||
309 | acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count]. | |
310 | address = address; | |
311 | acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count]. | |
312 | pointer = table; | |
313 | acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].length = | |
314 | length; | |
315 | acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count]. | |
316 | owner_id = 0; | |
317 | acpi_gbl_root_table_list.tables[acpi_gbl_root_table_list.count].flags = | |
318 | flags; | |
319 | ||
320 | ACPI_MOVE_32_TO_32(& | |
321 | (acpi_gbl_root_table_list. | |
322 | tables[acpi_gbl_root_table_list.count].signature), | |
323 | table->signature); | |
324 | ||
325 | *table_index = acpi_gbl_root_table_list.count; | |
326 | acpi_gbl_root_table_list.count++; | |
327 | return (status); | |
328 | } | |
1da177e4 | 329 | |
f3d2e786 BM |
330 | /******************************************************************************* |
331 | * | |
332 | * FUNCTION: acpi_tb_delete_table | |
333 | * | |
334 | * PARAMETERS: table_index - Table index | |
335 | * | |
336 | * RETURN: None | |
337 | * | |
338 | * DESCRIPTION: Delete one internal ACPI table | |
339 | * | |
340 | ******************************************************************************/ | |
1da177e4 | 341 | |
428f2112 | 342 | void acpi_tb_delete_table(struct acpi_table_desc *table_desc) |
f3d2e786 | 343 | { |
f3d2e786 | 344 | /* Table must be mapped or allocated */ |
f3d2e786 BM |
345 | if (!table_desc->pointer) { |
346 | return; | |
1da177e4 | 347 | } |
428f2112 AS |
348 | switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) { |
349 | case ACPI_TABLE_ORIGIN_MAPPED: | |
350 | acpi_os_unmap_memory(table_desc->pointer, table_desc->length); | |
351 | break; | |
352 | case ACPI_TABLE_ORIGIN_ALLOCATED: | |
f3d2e786 | 353 | ACPI_FREE(table_desc->pointer); |
428f2112 AS |
354 | break; |
355 | default:; | |
1da177e4 LT |
356 | } |
357 | ||
f3d2e786 | 358 | table_desc->pointer = NULL; |
1da177e4 LT |
359 | } |
360 | ||
1da177e4 LT |
361 | /******************************************************************************* |
362 | * | |
f3d2e786 | 363 | * FUNCTION: acpi_tb_terminate |
1da177e4 | 364 | * |
f3d2e786 | 365 | * PARAMETERS: None |
1da177e4 | 366 | * |
f3d2e786 | 367 | * RETURN: None |
1da177e4 LT |
368 | * |
369 | * DESCRIPTION: Delete all internal ACPI tables | |
370 | * | |
371 | ******************************************************************************/ | |
372 | ||
f3d2e786 | 373 | void acpi_tb_terminate(void) |
1da177e4 | 374 | { |
67a119f9 | 375 | u32 i; |
f3d2e786 BM |
376 | |
377 | ACPI_FUNCTION_TRACE(tb_terminate); | |
378 | ||
379 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); | |
380 | ||
381 | /* Delete the individual tables */ | |
382 | ||
383 | for (i = 0; i < acpi_gbl_root_table_list.count; ++i) { | |
428f2112 | 384 | acpi_tb_delete_table(&acpi_gbl_root_table_list.tables[i]); |
f3d2e786 | 385 | } |
1da177e4 LT |
386 | |
387 | /* | |
f3d2e786 BM |
388 | * Delete the root table array if allocated locally. Array cannot be |
389 | * mapped, so we don't need to check for that flag. | |
1da177e4 | 390 | */ |
c5fc42ac | 391 | if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { |
f3d2e786 | 392 | ACPI_FREE(acpi_gbl_root_table_list.tables); |
1da177e4 | 393 | } |
f3d2e786 BM |
394 | |
395 | acpi_gbl_root_table_list.tables = NULL; | |
396 | acpi_gbl_root_table_list.flags = 0; | |
397 | acpi_gbl_root_table_list.count = 0; | |
398 | ||
399 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n")); | |
400 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | |
1da177e4 LT |
401 | } |
402 | ||
1da177e4 LT |
403 | /******************************************************************************* |
404 | * | |
f3d2e786 | 405 | * FUNCTION: acpi_tb_delete_namespace_by_owner |
1da177e4 | 406 | * |
f3d2e786 | 407 | * PARAMETERS: table_index - Table index |
1da177e4 | 408 | * |
f3d2e786 | 409 | * RETURN: None |
1da177e4 | 410 | * |
f3d2e786 | 411 | * DESCRIPTION: Delete all namespace objects created when this table was loaded. |
1da177e4 LT |
412 | * |
413 | ******************************************************************************/ | |
414 | ||
67a119f9 | 415 | void acpi_tb_delete_namespace_by_owner(u32 table_index) |
1da177e4 | 416 | { |
f3d2e786 | 417 | acpi_owner_id owner_id; |
1da177e4 | 418 | |
f3d2e786 BM |
419 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
420 | if (table_index < acpi_gbl_root_table_list.count) { | |
421 | owner_id = | |
422 | acpi_gbl_root_table_list.tables[table_index].owner_id; | |
423 | } else { | |
424 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | |
1da177e4 LT |
425 | return; |
426 | } | |
427 | ||
f3d2e786 BM |
428 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
429 | acpi_ns_delete_namespace_by_owner(owner_id); | |
430 | } | |
1da177e4 | 431 | |
f3d2e786 BM |
432 | /******************************************************************************* |
433 | * | |
434 | * FUNCTION: acpi_tb_allocate_owner_id | |
435 | * | |
436 | * PARAMETERS: table_index - Table index | |
437 | * | |
438 | * RETURN: Status | |
439 | * | |
440 | * DESCRIPTION: Allocates owner_id in table_desc | |
441 | * | |
442 | ******************************************************************************/ | |
1da177e4 | 443 | |
67a119f9 | 444 | acpi_status acpi_tb_allocate_owner_id(u32 table_index) |
f3d2e786 BM |
445 | { |
446 | acpi_status status = AE_BAD_PARAMETER; | |
1da177e4 | 447 | |
f3d2e786 | 448 | ACPI_FUNCTION_TRACE(tb_allocate_owner_id); |
1da177e4 | 449 | |
f3d2e786 BM |
450 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
451 | if (table_index < acpi_gbl_root_table_list.count) { | |
452 | status = acpi_ut_allocate_owner_id | |
453 | (&(acpi_gbl_root_table_list.tables[table_index].owner_id)); | |
1da177e4 LT |
454 | } |
455 | ||
4be44fcd | 456 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
f3d2e786 | 457 | return_ACPI_STATUS(status); |
1da177e4 LT |
458 | } |
459 | ||
1da177e4 LT |
460 | /******************************************************************************* |
461 | * | |
f3d2e786 | 462 | * FUNCTION: acpi_tb_release_owner_id |
1da177e4 | 463 | * |
f3d2e786 | 464 | * PARAMETERS: table_index - Table index |
1da177e4 | 465 | * |
f3d2e786 | 466 | * RETURN: Status |
1da177e4 | 467 | * |
f3d2e786 | 468 | * DESCRIPTION: Releases owner_id in table_desc |
1da177e4 LT |
469 | * |
470 | ******************************************************************************/ | |
471 | ||
67a119f9 | 472 | acpi_status acpi_tb_release_owner_id(u32 table_index) |
1da177e4 | 473 | { |
f3d2e786 | 474 | acpi_status status = AE_BAD_PARAMETER; |
1da177e4 | 475 | |
f3d2e786 | 476 | ACPI_FUNCTION_TRACE(tb_release_owner_id); |
1da177e4 | 477 | |
f3d2e786 BM |
478 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
479 | if (table_index < acpi_gbl_root_table_list.count) { | |
480 | acpi_ut_release_owner_id(& | |
481 | (acpi_gbl_root_table_list. | |
482 | tables[table_index].owner_id)); | |
483 | status = AE_OK; | |
1da177e4 LT |
484 | } |
485 | ||
f3d2e786 BM |
486 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
487 | return_ACPI_STATUS(status); | |
1da177e4 LT |
488 | } |
489 | ||
1da177e4 LT |
490 | /******************************************************************************* |
491 | * | |
f3d2e786 | 492 | * FUNCTION: acpi_tb_get_owner_id |
1da177e4 | 493 | * |
f3d2e786 BM |
494 | * PARAMETERS: table_index - Table index |
495 | * owner_id - Where the table owner_id is returned | |
1da177e4 | 496 | * |
f3d2e786 | 497 | * RETURN: Status |
1da177e4 | 498 | * |
f3d2e786 | 499 | * DESCRIPTION: returns owner_id for the ACPI table |
1da177e4 LT |
500 | * |
501 | ******************************************************************************/ | |
502 | ||
67a119f9 | 503 | acpi_status acpi_tb_get_owner_id(u32 table_index, acpi_owner_id *owner_id) |
1da177e4 | 504 | { |
f3d2e786 | 505 | acpi_status status = AE_BAD_PARAMETER; |
1da177e4 | 506 | |
f3d2e786 | 507 | ACPI_FUNCTION_TRACE(tb_get_owner_id); |
1da177e4 | 508 | |
f3d2e786 BM |
509 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
510 | if (table_index < acpi_gbl_root_table_list.count) { | |
511 | *owner_id = | |
512 | acpi_gbl_root_table_list.tables[table_index].owner_id; | |
513 | status = AE_OK; | |
1da177e4 LT |
514 | } |
515 | ||
f3d2e786 BM |
516 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
517 | return_ACPI_STATUS(status); | |
518 | } | |
1da177e4 | 519 | |
f3d2e786 BM |
520 | /******************************************************************************* |
521 | * | |
522 | * FUNCTION: acpi_tb_is_table_loaded | |
523 | * | |
524 | * PARAMETERS: table_index - Table index | |
525 | * | |
526 | * RETURN: Table Loaded Flag | |
527 | * | |
528 | ******************************************************************************/ | |
1da177e4 | 529 | |
67a119f9 | 530 | u8 acpi_tb_is_table_loaded(u32 table_index) |
f3d2e786 BM |
531 | { |
532 | u8 is_loaded = FALSE; | |
1da177e4 | 533 | |
f3d2e786 BM |
534 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
535 | if (table_index < acpi_gbl_root_table_list.count) { | |
536 | is_loaded = (u8) | |
537 | (acpi_gbl_root_table_list.tables[table_index]. | |
c5fc42ac | 538 | flags & ACPI_TABLE_IS_LOADED); |
1da177e4 LT |
539 | } |
540 | ||
f3d2e786 BM |
541 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
542 | return (is_loaded); | |
543 | } | |
f6dd9221 | 544 | |
f3d2e786 BM |
545 | /******************************************************************************* |
546 | * | |
547 | * FUNCTION: acpi_tb_set_table_loaded_flag | |
548 | * | |
549 | * PARAMETERS: table_index - Table index | |
550 | * is_loaded - TRUE if table is loaded, FALSE otherwise | |
551 | * | |
552 | * RETURN: None | |
553 | * | |
554 | * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE. | |
555 | * | |
556 | ******************************************************************************/ | |
1da177e4 | 557 | |
67a119f9 | 558 | void acpi_tb_set_table_loaded_flag(u32 table_index, u8 is_loaded) |
f3d2e786 | 559 | { |
1da177e4 | 560 | |
f3d2e786 BM |
561 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
562 | if (table_index < acpi_gbl_root_table_list.count) { | |
563 | if (is_loaded) { | |
564 | acpi_gbl_root_table_list.tables[table_index].flags |= | |
c5fc42ac | 565 | ACPI_TABLE_IS_LOADED; |
f3d2e786 BM |
566 | } else { |
567 | acpi_gbl_root_table_list.tables[table_index].flags &= | |
c5fc42ac | 568 | ~ACPI_TABLE_IS_LOADED; |
f3d2e786 BM |
569 | } |
570 | } | |
1da177e4 | 571 | |
f3d2e786 | 572 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
1da177e4 | 573 | } |