]>
Commit | Line | Data |
---|---|---|
c418ce19 BM |
1 | /****************************************************************************** |
2 | * | |
3 | * Module Name: tbdata - Table manager data structure functions | |
4 | * | |
5 | *****************************************************************************/ | |
6 | ||
7 | /* | |
8 | * Copyright (C) 2000 - 2014, Intel Corp. | |
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 | ||
44 | #include <acpi/acpi.h> | |
45 | #include "accommon.h" | |
46 | #include "acnamesp.h" | |
47 | #include "actables.h" | |
48 | ||
49 | #define _COMPONENT ACPI_TABLES | |
50 | ACPI_MODULE_NAME("tbdata") | |
51 | ||
52 | /******************************************************************************* | |
53 | * | |
54 | * FUNCTION: acpi_tb_init_table_descriptor | |
55 | * | |
56 | * PARAMETERS: table_desc - Table descriptor | |
57 | * address - Physical address of the table | |
58 | * flags - Allocation flags of the table | |
59 | * table - Pointer to the table | |
60 | * | |
61 | * RETURN: None | |
62 | * | |
63 | * DESCRIPTION: Initialize a new table descriptor | |
64 | * | |
65 | ******************************************************************************/ | |
66 | void | |
67 | acpi_tb_init_table_descriptor(struct acpi_table_desc *table_desc, | |
68 | acpi_physical_address address, | |
69 | u8 flags, struct acpi_table_header *table) | |
70 | { | |
71 | ||
72 | /* | |
73 | * Initialize the table descriptor. Set the pointer to NULL, since the | |
74 | * table is not fully mapped at this time. | |
75 | */ | |
76 | ACPI_MEMSET(table_desc, 0, sizeof(struct acpi_table_desc)); | |
77 | table_desc->address = address; | |
78 | table_desc->length = table->length; | |
79 | table_desc->flags = flags; | |
80 | ACPI_MOVE_32_TO_32(table_desc->signature.ascii, table->signature); | |
81 | } | |
82 | ||
83 | /******************************************************************************* | |
84 | * | |
85 | * FUNCTION: acpi_tb_acquire_table | |
86 | * | |
87 | * PARAMETERS: table_desc - Table descriptor | |
88 | * table_ptr - Where table is returned | |
89 | * table_length - Where table length is returned | |
90 | * table_flags - Where table allocation flags are returned | |
91 | * | |
92 | * RETURN: Status | |
93 | * | |
94 | * DESCRIPTION: Acquire an ACPI table. It can be used for tables not | |
95 | * maintained in the acpi_gbl_root_table_list. | |
96 | * | |
97 | ******************************************************************************/ | |
98 | ||
99 | acpi_status | |
100 | acpi_tb_acquire_table(struct acpi_table_desc *table_desc, | |
101 | struct acpi_table_header **table_ptr, | |
102 | u32 *table_length, u8 *table_flags) | |
103 | { | |
104 | struct acpi_table_header *table = NULL; | |
105 | ||
106 | switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) { | |
107 | case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL: | |
108 | ||
109 | table = | |
110 | acpi_os_map_memory(table_desc->address, table_desc->length); | |
111 | break; | |
112 | ||
113 | case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL: | |
114 | case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL: | |
115 | ||
116 | table = | |
117 | ACPI_CAST_PTR(struct acpi_table_header, | |
118 | table_desc->address); | |
119 | break; | |
120 | ||
121 | default: | |
122 | ||
123 | break; | |
124 | } | |
125 | ||
126 | /* Table is not valid yet */ | |
127 | ||
128 | if (!table) { | |
129 | return (AE_NO_MEMORY); | |
130 | } | |
131 | ||
132 | /* Fill the return values */ | |
133 | ||
134 | *table_ptr = table; | |
135 | *table_length = table_desc->length; | |
136 | *table_flags = table_desc->flags; | |
137 | return (AE_OK); | |
138 | } | |
139 | ||
140 | /******************************************************************************* | |
141 | * | |
142 | * FUNCTION: acpi_tb_release_table | |
143 | * | |
144 | * PARAMETERS: table - Pointer for the table | |
145 | * table_length - Length for the table | |
146 | * table_flags - Allocation flags for the table | |
147 | * | |
148 | * RETURN: None | |
149 | * | |
150 | * DESCRIPTION: Release a table. The inverse of acpi_tb_acquire_table(). | |
151 | * | |
152 | ******************************************************************************/ | |
153 | ||
154 | void | |
155 | acpi_tb_release_table(struct acpi_table_header *table, | |
156 | u32 table_length, u8 table_flags) | |
157 | { | |
158 | ||
159 | switch (table_flags & ACPI_TABLE_ORIGIN_MASK) { | |
160 | case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL: | |
161 | ||
162 | acpi_os_unmap_memory(table, table_length); | |
163 | break; | |
164 | ||
165 | case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL: | |
166 | case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL: | |
167 | default: | |
168 | ||
169 | break; | |
170 | } | |
171 | } | |
172 | ||
173 | /******************************************************************************* | |
174 | * | |
175 | * FUNCTION: acpi_tb_acquire_temp_table | |
176 | * | |
177 | * PARAMETERS: table_desc - Table descriptor to be acquired | |
178 | * address - Address of the table | |
179 | * flags - Allocation flags of the table | |
180 | * | |
181 | * RETURN: Status | |
182 | * | |
183 | * DESCRIPTION: This function validates the table header to obtain the length | |
184 | * of a table and fills the table descriptor to make its state as | |
185 | * "INSTALLED". Such a table descriptor is only used for verified | |
186 | * installation. | |
187 | * | |
188 | ******************************************************************************/ | |
189 | ||
190 | acpi_status | |
191 | acpi_tb_acquire_temp_table(struct acpi_table_desc *table_desc, | |
192 | acpi_physical_address address, u8 flags) | |
193 | { | |
194 | struct acpi_table_header *table_header; | |
195 | ||
196 | switch (flags & ACPI_TABLE_ORIGIN_MASK) { | |
197 | case ACPI_TABLE_ORIGIN_INTERNAL_PHYSICAL: | |
198 | ||
199 | /* Get the length of the full table from the header */ | |
200 | ||
201 | table_header = | |
202 | acpi_os_map_memory(address, | |
203 | sizeof(struct acpi_table_header)); | |
204 | if (!table_header) { | |
205 | return (AE_NO_MEMORY); | |
206 | } | |
207 | ||
208 | acpi_tb_init_table_descriptor(table_desc, address, flags, | |
209 | table_header); | |
210 | acpi_os_unmap_memory(table_header, | |
211 | sizeof(struct acpi_table_header)); | |
212 | return (AE_OK); | |
213 | ||
214 | case ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL: | |
215 | case ACPI_TABLE_ORIGIN_EXTERNAL_VIRTUAL: | |
216 | ||
217 | table_header = ACPI_CAST_PTR(struct acpi_table_header, address); | |
218 | if (!table_header) { | |
219 | return (AE_NO_MEMORY); | |
220 | } | |
221 | ||
222 | acpi_tb_init_table_descriptor(table_desc, address, flags, | |
223 | table_header); | |
224 | return (AE_OK); | |
225 | ||
226 | default: | |
227 | ||
228 | break; | |
229 | } | |
230 | ||
231 | /* Table is not valid yet */ | |
232 | ||
233 | return (AE_NO_MEMORY); | |
234 | } | |
235 | ||
236 | /******************************************************************************* | |
237 | * | |
238 | * FUNCTION: acpi_tb_release_temp_table | |
239 | * | |
240 | * PARAMETERS: table_desc - Table descriptor to be released | |
241 | * | |
242 | * RETURN: Status | |
243 | * | |
244 | * DESCRIPTION: The inverse of acpi_tb_acquire_temp_table(). | |
245 | * | |
246 | *****************************************************************************/ | |
247 | ||
248 | void acpi_tb_release_temp_table(struct acpi_table_desc *table_desc) | |
249 | { | |
250 | ||
251 | /* | |
252 | * Note that the .Address is maintained by the callers of | |
253 | * acpi_tb_acquire_temp_table(), thus do not invoke acpi_tb_uninstall_table() | |
254 | * where .Address will be freed. | |
255 | */ | |
256 | acpi_tb_invalidate_table(table_desc); | |
257 | } | |
258 | ||
259 | /****************************************************************************** | |
260 | * | |
261 | * FUNCTION: acpi_tb_validate_table | |
262 | * | |
263 | * PARAMETERS: table_desc - Table descriptor | |
264 | * | |
265 | * RETURN: Status | |
266 | * | |
267 | * DESCRIPTION: This function is called to validate the table, the returned | |
268 | * table descriptor is in "VALIDATED" state. | |
269 | * | |
270 | *****************************************************************************/ | |
271 | ||
272 | acpi_status acpi_tb_validate_table(struct acpi_table_desc *table_desc) | |
273 | { | |
274 | acpi_status status = AE_OK; | |
275 | ||
276 | ACPI_FUNCTION_TRACE(tb_validate_table); | |
277 | ||
278 | /* Validate the table if necessary */ | |
279 | ||
280 | if (!table_desc->pointer) { | |
281 | status = acpi_tb_acquire_table(table_desc, &table_desc->pointer, | |
282 | &table_desc->length, | |
283 | &table_desc->flags); | |
284 | if (!table_desc->pointer) { | |
285 | status = AE_NO_MEMORY; | |
286 | } | |
287 | } | |
288 | ||
289 | return_ACPI_STATUS(status); | |
290 | } | |
291 | ||
292 | /******************************************************************************* | |
293 | * | |
294 | * FUNCTION: acpi_tb_invalidate_table | |
295 | * | |
296 | * PARAMETERS: table_desc - Table descriptor | |
297 | * | |
298 | * RETURN: None | |
299 | * | |
300 | * DESCRIPTION: Invalidate one internal ACPI table, this is the inverse of | |
301 | * acpi_tb_validate_table(). | |
302 | * | |
303 | ******************************************************************************/ | |
304 | ||
305 | void acpi_tb_invalidate_table(struct acpi_table_desc *table_desc) | |
306 | { | |
307 | ||
308 | ACPI_FUNCTION_TRACE(tb_invalidate_table); | |
309 | ||
310 | /* Table must be validated */ | |
311 | ||
312 | if (!table_desc->pointer) { | |
313 | return_VOID; | |
314 | } | |
315 | ||
316 | acpi_tb_release_table(table_desc->pointer, table_desc->length, | |
317 | table_desc->flags); | |
318 | table_desc->pointer = NULL; | |
319 | ||
320 | return_VOID; | |
321 | } | |
322 | ||
323 | /****************************************************************************** | |
324 | * | |
325 | * FUNCTION: acpi_tb_verify_table | |
326 | * | |
327 | * PARAMETERS: table_desc - Table descriptor | |
328 | * signature - Table signature to verify | |
329 | * | |
330 | * RETURN: Status | |
331 | * | |
332 | * DESCRIPTION: This function is called to validate and verify the table, the | |
333 | * returned table descriptor is in "VALIDATED" state. | |
334 | * | |
335 | *****************************************************************************/ | |
336 | ||
337 | acpi_status | |
338 | acpi_tb_verify_table(struct acpi_table_desc *table_desc, char *signature) | |
339 | { | |
340 | acpi_status status = AE_OK; | |
341 | ||
342 | ACPI_FUNCTION_TRACE(tb_verify_table); | |
343 | ||
344 | /* Validate the table */ | |
345 | ||
346 | status = acpi_tb_validate_table(table_desc); | |
347 | if (ACPI_FAILURE(status)) { | |
348 | return_ACPI_STATUS(AE_NO_MEMORY); | |
349 | } | |
350 | ||
351 | /* If a particular signature is expected (DSDT/FACS), it must match */ | |
352 | ||
353 | if (signature && !ACPI_COMPARE_NAME(&table_desc->signature, signature)) { | |
354 | ACPI_BIOS_ERROR((AE_INFO, | |
355 | "Invalid signature 0x%X for ACPI table, expected [%s]", | |
356 | table_desc->signature.integer, signature)); | |
357 | status = AE_BAD_SIGNATURE; | |
358 | goto invalidate_and_exit; | |
359 | } | |
360 | ||
361 | /* Verify the checksum */ | |
362 | ||
363 | status = | |
364 | acpi_tb_verify_checksum(table_desc->pointer, table_desc->length); | |
365 | if (ACPI_FAILURE(status)) { | |
366 | ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY, | |
367 | "%4.4s " ACPI_PRINTF_UINT | |
368 | " Attempted table install failed", | |
369 | acpi_ut_valid_acpi_name(table_desc->signature. | |
370 | ascii) ? table_desc-> | |
371 | signature.ascii : "????", | |
372 | ACPI_FORMAT_TO_UINT(table_desc->address))); | |
373 | goto invalidate_and_exit; | |
374 | } | |
375 | ||
376 | return_ACPI_STATUS(AE_OK); | |
377 | ||
378 | invalidate_and_exit: | |
379 | acpi_tb_invalidate_table(table_desc); | |
380 | return_ACPI_STATUS(status); | |
381 | } | |
382 | ||
383 | /******************************************************************************* | |
384 | * | |
385 | * FUNCTION: acpi_tb_resize_root_table_list | |
386 | * | |
387 | * PARAMETERS: None | |
388 | * | |
389 | * RETURN: Status | |
390 | * | |
391 | * DESCRIPTION: Expand the size of global table array | |
392 | * | |
393 | ******************************************************************************/ | |
394 | ||
395 | acpi_status acpi_tb_resize_root_table_list(void) | |
396 | { | |
397 | struct acpi_table_desc *tables; | |
398 | u32 table_count; | |
399 | ||
400 | ACPI_FUNCTION_TRACE(tb_resize_root_table_list); | |
401 | ||
402 | /* allow_resize flag is a parameter to acpi_initialize_tables */ | |
403 | ||
404 | if (!(acpi_gbl_root_table_list.flags & ACPI_ROOT_ALLOW_RESIZE)) { | |
405 | ACPI_ERROR((AE_INFO, | |
406 | "Resize of Root Table Array is not allowed")); | |
407 | return_ACPI_STATUS(AE_SUPPORT); | |
408 | } | |
409 | ||
410 | /* Increase the Table Array size */ | |
411 | ||
412 | if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { | |
413 | table_count = acpi_gbl_root_table_list.max_table_count; | |
414 | } else { | |
415 | table_count = acpi_gbl_root_table_list.current_table_count; | |
416 | } | |
417 | ||
418 | tables = ACPI_ALLOCATE_ZEROED(((acpi_size) table_count + | |
419 | ACPI_ROOT_TABLE_SIZE_INCREMENT) * | |
420 | sizeof(struct acpi_table_desc)); | |
421 | if (!tables) { | |
422 | ACPI_ERROR((AE_INFO, | |
423 | "Could not allocate new root table array")); | |
424 | return_ACPI_STATUS(AE_NO_MEMORY); | |
425 | } | |
426 | ||
427 | /* Copy and free the previous table array */ | |
428 | ||
429 | if (acpi_gbl_root_table_list.tables) { | |
430 | ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables, | |
431 | (acpi_size) table_count * | |
432 | sizeof(struct acpi_table_desc)); | |
433 | ||
434 | if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { | |
435 | ACPI_FREE(acpi_gbl_root_table_list.tables); | |
436 | } | |
437 | } | |
438 | ||
439 | acpi_gbl_root_table_list.tables = tables; | |
440 | acpi_gbl_root_table_list.max_table_count = | |
441 | table_count + ACPI_ROOT_TABLE_SIZE_INCREMENT; | |
442 | acpi_gbl_root_table_list.flags |= ACPI_ROOT_ORIGIN_ALLOCATED; | |
443 | ||
444 | return_ACPI_STATUS(AE_OK); | |
445 | } | |
446 | ||
447 | /******************************************************************************* | |
448 | * | |
449 | * FUNCTION: acpi_tb_get_next_root_index | |
450 | * | |
451 | * PARAMETERS: table_index - Where table index is returned | |
452 | * | |
453 | * RETURN: Status and table index. | |
454 | * | |
455 | * DESCRIPTION: Allocate a new ACPI table entry to the global table list | |
456 | * | |
457 | ******************************************************************************/ | |
458 | ||
459 | acpi_status acpi_tb_get_next_root_index(u32 *table_index) | |
460 | { | |
461 | acpi_status status; | |
462 | ||
463 | /* Ensure that there is room for the table in the Root Table List */ | |
464 | ||
465 | if (acpi_gbl_root_table_list.current_table_count >= | |
466 | acpi_gbl_root_table_list.max_table_count) { | |
467 | status = acpi_tb_resize_root_table_list(); | |
468 | if (ACPI_FAILURE(status)) { | |
469 | return (status); | |
470 | } | |
471 | } | |
472 | ||
473 | *table_index = acpi_gbl_root_table_list.current_table_count; | |
474 | acpi_gbl_root_table_list.current_table_count++; | |
475 | return (AE_OK); | |
476 | } | |
477 | ||
478 | /******************************************************************************* | |
479 | * | |
480 | * FUNCTION: acpi_tb_terminate | |
481 | * | |
482 | * PARAMETERS: None | |
483 | * | |
484 | * RETURN: None | |
485 | * | |
486 | * DESCRIPTION: Delete all internal ACPI tables | |
487 | * | |
488 | ******************************************************************************/ | |
489 | ||
490 | void acpi_tb_terminate(void) | |
491 | { | |
492 | u32 i; | |
493 | ||
494 | ACPI_FUNCTION_TRACE(tb_terminate); | |
495 | ||
496 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); | |
497 | ||
498 | /* Delete the individual tables */ | |
499 | ||
500 | for (i = 0; i < acpi_gbl_root_table_list.current_table_count; i++) { | |
501 | acpi_tb_uninstall_table(&acpi_gbl_root_table_list.tables[i]); | |
502 | } | |
503 | ||
504 | /* | |
505 | * Delete the root table array if allocated locally. Array cannot be | |
506 | * mapped, so we don't need to check for that flag. | |
507 | */ | |
508 | if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { | |
509 | ACPI_FREE(acpi_gbl_root_table_list.tables); | |
510 | } | |
511 | ||
512 | acpi_gbl_root_table_list.tables = NULL; | |
513 | acpi_gbl_root_table_list.flags = 0; | |
514 | acpi_gbl_root_table_list.current_table_count = 0; | |
515 | ||
516 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n")); | |
517 | ||
518 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | |
519 | return_VOID; | |
520 | } | |
521 | ||
522 | /******************************************************************************* | |
523 | * | |
524 | * FUNCTION: acpi_tb_delete_namespace_by_owner | |
525 | * | |
526 | * PARAMETERS: table_index - Table index | |
527 | * | |
528 | * RETURN: Status | |
529 | * | |
530 | * DESCRIPTION: Delete all namespace objects created when this table was loaded. | |
531 | * | |
532 | ******************************************************************************/ | |
533 | ||
534 | acpi_status acpi_tb_delete_namespace_by_owner(u32 table_index) | |
535 | { | |
536 | acpi_owner_id owner_id; | |
537 | acpi_status status; | |
538 | ||
539 | ACPI_FUNCTION_TRACE(tb_delete_namespace_by_owner); | |
540 | ||
541 | status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES); | |
542 | if (ACPI_FAILURE(status)) { | |
543 | return_ACPI_STATUS(status); | |
544 | } | |
545 | ||
546 | if (table_index >= acpi_gbl_root_table_list.current_table_count) { | |
547 | ||
548 | /* The table index does not exist */ | |
549 | ||
550 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | |
551 | return_ACPI_STATUS(AE_NOT_EXIST); | |
552 | } | |
553 | ||
554 | /* Get the owner ID for this table, used to delete namespace nodes */ | |
555 | ||
556 | owner_id = acpi_gbl_root_table_list.tables[table_index].owner_id; | |
557 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | |
558 | ||
559 | /* | |
560 | * Need to acquire the namespace writer lock to prevent interference | |
561 | * with any concurrent namespace walks. The interpreter must be | |
562 | * released during the deletion since the acquisition of the deletion | |
563 | * lock may block, and also since the execution of a namespace walk | |
564 | * must be allowed to use the interpreter. | |
565 | */ | |
566 | (void)acpi_ut_release_mutex(ACPI_MTX_INTERPRETER); | |
567 | status = acpi_ut_acquire_write_lock(&acpi_gbl_namespace_rw_lock); | |
568 | ||
569 | acpi_ns_delete_namespace_by_owner(owner_id); | |
570 | if (ACPI_FAILURE(status)) { | |
571 | return_ACPI_STATUS(status); | |
572 | } | |
573 | ||
574 | acpi_ut_release_write_lock(&acpi_gbl_namespace_rw_lock); | |
575 | ||
576 | status = acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER); | |
577 | return_ACPI_STATUS(status); | |
578 | } | |
579 | ||
580 | /******************************************************************************* | |
581 | * | |
582 | * FUNCTION: acpi_tb_allocate_owner_id | |
583 | * | |
584 | * PARAMETERS: table_index - Table index | |
585 | * | |
586 | * RETURN: Status | |
587 | * | |
588 | * DESCRIPTION: Allocates owner_id in table_desc | |
589 | * | |
590 | ******************************************************************************/ | |
591 | ||
592 | acpi_status acpi_tb_allocate_owner_id(u32 table_index) | |
593 | { | |
594 | acpi_status status = AE_BAD_PARAMETER; | |
595 | ||
596 | ACPI_FUNCTION_TRACE(tb_allocate_owner_id); | |
597 | ||
598 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); | |
599 | if (table_index < acpi_gbl_root_table_list.current_table_count) { | |
600 | status = | |
601 | acpi_ut_allocate_owner_id(& | |
602 | (acpi_gbl_root_table_list. | |
603 | tables[table_index].owner_id)); | |
604 | } | |
605 | ||
606 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | |
607 | return_ACPI_STATUS(status); | |
608 | } | |
609 | ||
610 | /******************************************************************************* | |
611 | * | |
612 | * FUNCTION: acpi_tb_release_owner_id | |
613 | * | |
614 | * PARAMETERS: table_index - Table index | |
615 | * | |
616 | * RETURN: Status | |
617 | * | |
618 | * DESCRIPTION: Releases owner_id in table_desc | |
619 | * | |
620 | ******************************************************************************/ | |
621 | ||
622 | acpi_status acpi_tb_release_owner_id(u32 table_index) | |
623 | { | |
624 | acpi_status status = AE_BAD_PARAMETER; | |
625 | ||
626 | ACPI_FUNCTION_TRACE(tb_release_owner_id); | |
627 | ||
628 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); | |
629 | if (table_index < acpi_gbl_root_table_list.current_table_count) { | |
630 | acpi_ut_release_owner_id(& | |
631 | (acpi_gbl_root_table_list. | |
632 | tables[table_index].owner_id)); | |
633 | status = AE_OK; | |
634 | } | |
635 | ||
636 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | |
637 | return_ACPI_STATUS(status); | |
638 | } | |
639 | ||
640 | /******************************************************************************* | |
641 | * | |
642 | * FUNCTION: acpi_tb_get_owner_id | |
643 | * | |
644 | * PARAMETERS: table_index - Table index | |
645 | * owner_id - Where the table owner_id is returned | |
646 | * | |
647 | * RETURN: Status | |
648 | * | |
649 | * DESCRIPTION: returns owner_id for the ACPI table | |
650 | * | |
651 | ******************************************************************************/ | |
652 | ||
653 | acpi_status acpi_tb_get_owner_id(u32 table_index, acpi_owner_id * owner_id) | |
654 | { | |
655 | acpi_status status = AE_BAD_PARAMETER; | |
656 | ||
657 | ACPI_FUNCTION_TRACE(tb_get_owner_id); | |
658 | ||
659 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); | |
660 | if (table_index < acpi_gbl_root_table_list.current_table_count) { | |
661 | *owner_id = | |
662 | acpi_gbl_root_table_list.tables[table_index].owner_id; | |
663 | status = AE_OK; | |
664 | } | |
665 | ||
666 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | |
667 | return_ACPI_STATUS(status); | |
668 | } | |
669 | ||
670 | /******************************************************************************* | |
671 | * | |
672 | * FUNCTION: acpi_tb_is_table_loaded | |
673 | * | |
674 | * PARAMETERS: table_index - Index into the root table | |
675 | * | |
676 | * RETURN: Table Loaded Flag | |
677 | * | |
678 | ******************************************************************************/ | |
679 | ||
680 | u8 acpi_tb_is_table_loaded(u32 table_index) | |
681 | { | |
682 | u8 is_loaded = FALSE; | |
683 | ||
684 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); | |
685 | if (table_index < acpi_gbl_root_table_list.current_table_count) { | |
686 | is_loaded = (u8) | |
687 | (acpi_gbl_root_table_list.tables[table_index].flags & | |
688 | ACPI_TABLE_IS_LOADED); | |
689 | } | |
690 | ||
691 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | |
692 | return (is_loaded); | |
693 | } | |
694 | ||
695 | /******************************************************************************* | |
696 | * | |
697 | * FUNCTION: acpi_tb_set_table_loaded_flag | |
698 | * | |
699 | * PARAMETERS: table_index - Table index | |
700 | * is_loaded - TRUE if table is loaded, FALSE otherwise | |
701 | * | |
702 | * RETURN: None | |
703 | * | |
704 | * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE. | |
705 | * | |
706 | ******************************************************************************/ | |
707 | ||
708 | void acpi_tb_set_table_loaded_flag(u32 table_index, u8 is_loaded) | |
709 | { | |
710 | ||
711 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); | |
712 | if (table_index < acpi_gbl_root_table_list.current_table_count) { | |
713 | if (is_loaded) { | |
714 | acpi_gbl_root_table_list.tables[table_index].flags |= | |
715 | ACPI_TABLE_IS_LOADED; | |
716 | } else { | |
717 | acpi_gbl_root_table_list.tables[table_index].flags &= | |
718 | ~ACPI_TABLE_IS_LOADED; | |
719 | } | |
720 | } | |
721 | ||
722 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | |
723 | } |