Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6595 | serge | 1 | /****************************************************************************** |
2 | * |
||
3 | * Module Name: tbdata - Table manager data structure functions |
||
4 | * |
||
5 | *****************************************************************************/ |
||
6 | |||
7 | /* |
||
8 | * Copyright (C) 2000 - 2015, 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 |
||
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 | 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 = ACPI_CAST_PTR(struct acpi_table_header, |
||
117 | ACPI_PHYSADDR_TO_PTR(table_desc-> |
||
118 | 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, |
||
218 | ACPI_PHYSADDR_TO_PTR(address)); |
||
219 | if (!table_header) { |
||
220 | return (AE_NO_MEMORY); |
||
221 | } |
||
222 | |||
223 | acpi_tb_init_table_descriptor(table_desc, address, flags, |
||
224 | table_header); |
||
225 | return (AE_OK); |
||
226 | |||
227 | default: |
||
228 | |||
229 | break; |
||
230 | } |
||
231 | |||
232 | /* Table is not valid yet */ |
||
233 | |||
234 | return (AE_NO_MEMORY); |
||
235 | } |
||
236 | |||
237 | /******************************************************************************* |
||
238 | * |
||
239 | * FUNCTION: acpi_tb_release_temp_table |
||
240 | * |
||
241 | * PARAMETERS: table_desc - Table descriptor to be released |
||
242 | * |
||
243 | * RETURN: Status |
||
244 | * |
||
245 | * DESCRIPTION: The inverse of acpi_tb_acquire_temp_table(). |
||
246 | * |
||
247 | *****************************************************************************/ |
||
248 | |||
249 | void acpi_tb_release_temp_table(struct acpi_table_desc *table_desc) |
||
250 | { |
||
251 | |||
252 | /* |
||
253 | * Note that the .Address is maintained by the callers of |
||
254 | * acpi_tb_acquire_temp_table(), thus do not invoke acpi_tb_uninstall_table() |
||
255 | * where .Address will be freed. |
||
256 | */ |
||
257 | acpi_tb_invalidate_table(table_desc); |
||
258 | } |
||
259 | |||
260 | /****************************************************************************** |
||
261 | * |
||
262 | * FUNCTION: acpi_tb_validate_table |
||
263 | * |
||
264 | * PARAMETERS: table_desc - Table descriptor |
||
265 | * |
||
266 | * RETURN: Status |
||
267 | * |
||
268 | * DESCRIPTION: This function is called to validate the table, the returned |
||
269 | * table descriptor is in "VALIDATED" state. |
||
270 | * |
||
271 | *****************************************************************************/ |
||
272 | |||
273 | acpi_status acpi_tb_validate_table(struct acpi_table_desc *table_desc) |
||
274 | { |
||
275 | acpi_status status = AE_OK; |
||
276 | |||
277 | ACPI_FUNCTION_TRACE(tb_validate_table); |
||
278 | |||
279 | /* Validate the table if necessary */ |
||
280 | |||
281 | if (!table_desc->pointer) { |
||
282 | status = acpi_tb_acquire_table(table_desc, &table_desc->pointer, |
||
283 | &table_desc->length, |
||
284 | &table_desc->flags); |
||
285 | if (!table_desc->pointer) { |
||
286 | status = AE_NO_MEMORY; |
||
287 | } |
||
288 | } |
||
289 | |||
290 | return_ACPI_STATUS(status); |
||
291 | } |
||
292 | |||
293 | /******************************************************************************* |
||
294 | * |
||
295 | * FUNCTION: acpi_tb_invalidate_table |
||
296 | * |
||
297 | * PARAMETERS: table_desc - Table descriptor |
||
298 | * |
||
299 | * RETURN: None |
||
300 | * |
||
301 | * DESCRIPTION: Invalidate one internal ACPI table, this is the inverse of |
||
302 | * acpi_tb_validate_table(). |
||
303 | * |
||
304 | ******************************************************************************/ |
||
305 | |||
306 | void acpi_tb_invalidate_table(struct acpi_table_desc *table_desc) |
||
307 | { |
||
308 | |||
309 | ACPI_FUNCTION_TRACE(tb_invalidate_table); |
||
310 | |||
311 | /* Table must be validated */ |
||
312 | |||
313 | if (!table_desc->pointer) { |
||
314 | return_VOID; |
||
315 | } |
||
316 | |||
317 | acpi_tb_release_table(table_desc->pointer, table_desc->length, |
||
318 | table_desc->flags); |
||
319 | table_desc->pointer = NULL; |
||
320 | |||
321 | return_VOID; |
||
322 | } |
||
323 | |||
324 | /****************************************************************************** |
||
325 | * |
||
326 | * FUNCTION: acpi_tb_validate_temp_table |
||
327 | * |
||
328 | * PARAMETERS: table_desc - Table descriptor |
||
329 | * |
||
330 | * RETURN: Status |
||
331 | * |
||
332 | * DESCRIPTION: This function is called to validate the table, the returned |
||
333 | * table descriptor is in "VALIDATED" state. |
||
334 | * |
||
335 | *****************************************************************************/ |
||
336 | |||
337 | acpi_status acpi_tb_validate_temp_table(struct acpi_table_desc *table_desc) |
||
338 | { |
||
339 | |||
340 | if (!table_desc->pointer && !acpi_gbl_verify_table_checksum) { |
||
341 | /* |
||
342 | * Only validates the header of the table. |
||
343 | * Note that Length contains the size of the mapping after invoking |
||
344 | * this work around, this value is required by |
||
345 | * acpi_tb_release_temp_table(). |
||
346 | * We can do this because in acpi_init_table_descriptor(), the Length |
||
347 | * field of the installed descriptor is filled with the actual |
||
348 | * table length obtaining from the table header. |
||
349 | */ |
||
350 | table_desc->length = sizeof(struct acpi_table_header); |
||
351 | } |
||
352 | |||
353 | return (acpi_tb_validate_table(table_desc)); |
||
354 | } |
||
355 | |||
356 | /****************************************************************************** |
||
357 | * |
||
358 | * FUNCTION: acpi_tb_verify_temp_table |
||
359 | * |
||
360 | * PARAMETERS: table_desc - Table descriptor |
||
361 | * signature - Table signature to verify |
||
362 | * |
||
363 | * RETURN: Status |
||
364 | * |
||
365 | * DESCRIPTION: This function is called to validate and verify the table, the |
||
366 | * returned table descriptor is in "VALIDATED" state. |
||
367 | * |
||
368 | *****************************************************************************/ |
||
369 | |||
370 | acpi_status |
||
371 | acpi_tb_verify_temp_table(struct acpi_table_desc * table_desc, char *signature) |
||
372 | { |
||
373 | acpi_status status = AE_OK; |
||
374 | |||
375 | ACPI_FUNCTION_TRACE(tb_verify_temp_table); |
||
376 | |||
377 | /* Validate the table */ |
||
378 | |||
379 | status = acpi_tb_validate_temp_table(table_desc); |
||
380 | if (ACPI_FAILURE(status)) { |
||
381 | return_ACPI_STATUS(AE_NO_MEMORY); |
||
382 | } |
||
383 | |||
384 | /* If a particular signature is expected (DSDT/FACS), it must match */ |
||
385 | |||
386 | if (signature && !ACPI_COMPARE_NAME(&table_desc->signature, signature)) { |
||
387 | ACPI_BIOS_ERROR((AE_INFO, |
||
388 | "Invalid signature 0x%X for ACPI table, expected [%s]", |
||
389 | table_desc->signature.integer, signature)); |
||
390 | status = AE_BAD_SIGNATURE; |
||
391 | goto invalidate_and_exit; |
||
392 | } |
||
393 | |||
394 | /* Verify the checksum */ |
||
395 | |||
396 | if (acpi_gbl_verify_table_checksum) { |
||
397 | status = |
||
398 | acpi_tb_verify_checksum(table_desc->pointer, |
||
399 | table_desc->length); |
||
400 | if (ACPI_FAILURE(status)) { |
||
401 | ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY, |
||
402 | "%4.4s 0x%8.8X%8.8X" |
||
403 | " Attempted table install failed", |
||
404 | acpi_ut_valid_acpi_name(table_desc-> |
||
405 | signature. |
||
406 | ascii) ? |
||
407 | table_desc->signature.ascii : "????", |
||
408 | ACPI_FORMAT_UINT64(table_desc-> |
||
409 | address))); |
||
410 | goto invalidate_and_exit; |
||
411 | } |
||
412 | } |
||
413 | |||
414 | return_ACPI_STATUS(AE_OK); |
||
415 | |||
416 | invalidate_and_exit: |
||
417 | acpi_tb_invalidate_table(table_desc); |
||
418 | return_ACPI_STATUS(status); |
||
419 | } |
||
420 | |||
421 | /******************************************************************************* |
||
422 | * |
||
423 | * FUNCTION: acpi_tb_resize_root_table_list |
||
424 | * |
||
425 | * PARAMETERS: None |
||
426 | * |
||
427 | * RETURN: Status |
||
428 | * |
||
429 | * DESCRIPTION: Expand the size of global table array |
||
430 | * |
||
431 | ******************************************************************************/ |
||
432 | |||
433 | acpi_status acpi_tb_resize_root_table_list(void) |
||
434 | { |
||
435 | struct acpi_table_desc *tables; |
||
436 | u32 table_count; |
||
437 | |||
438 | ACPI_FUNCTION_TRACE(tb_resize_root_table_list); |
||
439 | |||
440 | /* allow_resize flag is a parameter to acpi_initialize_tables */ |
||
441 | |||
442 | if (!(acpi_gbl_root_table_list.flags & ACPI_ROOT_ALLOW_RESIZE)) { |
||
443 | ACPI_ERROR((AE_INFO, |
||
444 | "Resize of Root Table Array is not allowed")); |
||
445 | return_ACPI_STATUS(AE_SUPPORT); |
||
446 | } |
||
447 | |||
448 | /* Increase the Table Array size */ |
||
449 | |||
450 | if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { |
||
451 | table_count = acpi_gbl_root_table_list.max_table_count; |
||
452 | } else { |
||
453 | table_count = acpi_gbl_root_table_list.current_table_count; |
||
454 | } |
||
455 | |||
456 | tables = ACPI_ALLOCATE_ZEROED(((acpi_size) table_count + |
||
457 | ACPI_ROOT_TABLE_SIZE_INCREMENT) * |
||
458 | sizeof(struct acpi_table_desc)); |
||
459 | if (!tables) { |
||
460 | ACPI_ERROR((AE_INFO, |
||
461 | "Could not allocate new root table array")); |
||
462 | return_ACPI_STATUS(AE_NO_MEMORY); |
||
463 | } |
||
464 | |||
465 | /* Copy and free the previous table array */ |
||
466 | |||
467 | if (acpi_gbl_root_table_list.tables) { |
||
468 | memcpy(tables, acpi_gbl_root_table_list.tables, |
||
469 | (acpi_size) table_count * |
||
470 | sizeof(struct acpi_table_desc)); |
||
471 | |||
472 | if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { |
||
473 | ACPI_FREE(acpi_gbl_root_table_list.tables); |
||
474 | } |
||
475 | } |
||
476 | |||
477 | acpi_gbl_root_table_list.tables = tables; |
||
478 | acpi_gbl_root_table_list.max_table_count = |
||
479 | table_count + ACPI_ROOT_TABLE_SIZE_INCREMENT; |
||
480 | acpi_gbl_root_table_list.flags |= ACPI_ROOT_ORIGIN_ALLOCATED; |
||
481 | |||
482 | return_ACPI_STATUS(AE_OK); |
||
483 | } |
||
484 | |||
485 | /******************************************************************************* |
||
486 | * |
||
487 | * FUNCTION: acpi_tb_get_next_table_descriptor |
||
488 | * |
||
489 | * PARAMETERS: table_index - Where table index is returned |
||
490 | * table_desc - Where table descriptor is returned |
||
491 | * |
||
492 | * RETURN: Status and table index/descriptor. |
||
493 | * |
||
494 | * DESCRIPTION: Allocate a new ACPI table entry to the global table list |
||
495 | * |
||
496 | ******************************************************************************/ |
||
497 | |||
498 | acpi_status |
||
499 | acpi_tb_get_next_table_descriptor(u32 *table_index, |
||
500 | struct acpi_table_desc **table_desc) |
||
501 | { |
||
502 | acpi_status status; |
||
503 | u32 i; |
||
504 | |||
505 | /* Ensure that there is room for the table in the Root Table List */ |
||
506 | |||
507 | if (acpi_gbl_root_table_list.current_table_count >= |
||
508 | acpi_gbl_root_table_list.max_table_count) { |
||
509 | status = acpi_tb_resize_root_table_list(); |
||
510 | if (ACPI_FAILURE(status)) { |
||
511 | return (status); |
||
512 | } |
||
513 | } |
||
514 | |||
515 | i = acpi_gbl_root_table_list.current_table_count; |
||
516 | acpi_gbl_root_table_list.current_table_count++; |
||
517 | |||
518 | if (table_index) { |
||
519 | *table_index = i; |
||
520 | } |
||
521 | if (table_desc) { |
||
522 | *table_desc = &acpi_gbl_root_table_list.tables[i]; |
||
523 | } |
||
524 | |||
525 | return (AE_OK); |
||
526 | } |
||
527 | |||
528 | /******************************************************************************* |
||
529 | * |
||
530 | * FUNCTION: acpi_tb_terminate |
||
531 | * |
||
532 | * PARAMETERS: None |
||
533 | * |
||
534 | * RETURN: None |
||
535 | * |
||
536 | * DESCRIPTION: Delete all internal ACPI tables |
||
537 | * |
||
538 | ******************************************************************************/ |
||
539 | |||
540 | void acpi_tb_terminate(void) |
||
541 | { |
||
542 | u32 i; |
||
543 | |||
544 | ACPI_FUNCTION_TRACE(tb_terminate); |
||
545 | |||
546 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
||
547 | |||
548 | /* Delete the individual tables */ |
||
549 | |||
550 | for (i = 0; i < acpi_gbl_root_table_list.current_table_count; i++) { |
||
551 | acpi_tb_uninstall_table(&acpi_gbl_root_table_list.tables[i]); |
||
552 | } |
||
553 | |||
554 | /* |
||
555 | * Delete the root table array if allocated locally. Array cannot be |
||
556 | * mapped, so we don't need to check for that flag. |
||
557 | */ |
||
558 | if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { |
||
559 | ACPI_FREE(acpi_gbl_root_table_list.tables); |
||
560 | } |
||
561 | |||
562 | acpi_gbl_root_table_list.tables = NULL; |
||
563 | acpi_gbl_root_table_list.flags = 0; |
||
564 | acpi_gbl_root_table_list.current_table_count = 0; |
||
565 | |||
566 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n")); |
||
567 | |||
568 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
||
569 | return_VOID; |
||
570 | } |
||
571 | |||
572 | /******************************************************************************* |
||
573 | * |
||
574 | * FUNCTION: acpi_tb_delete_namespace_by_owner |
||
575 | * |
||
576 | * PARAMETERS: table_index - Table index |
||
577 | * |
||
578 | * RETURN: Status |
||
579 | * |
||
580 | * DESCRIPTION: Delete all namespace objects created when this table was loaded. |
||
581 | * |
||
582 | ******************************************************************************/ |
||
583 | |||
584 | acpi_status acpi_tb_delete_namespace_by_owner(u32 table_index) |
||
585 | { |
||
586 | acpi_owner_id owner_id; |
||
587 | acpi_status status; |
||
588 | |||
589 | ACPI_FUNCTION_TRACE(tb_delete_namespace_by_owner); |
||
590 | |||
591 | status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
||
592 | if (ACPI_FAILURE(status)) { |
||
593 | return_ACPI_STATUS(status); |
||
594 | } |
||
595 | |||
596 | if (table_index >= acpi_gbl_root_table_list.current_table_count) { |
||
597 | |||
598 | /* The table index does not exist */ |
||
599 | |||
600 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
||
601 | return_ACPI_STATUS(AE_NOT_EXIST); |
||
602 | } |
||
603 | |||
604 | /* Get the owner ID for this table, used to delete namespace nodes */ |
||
605 | |||
606 | owner_id = acpi_gbl_root_table_list.tables[table_index].owner_id; |
||
607 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
||
608 | |||
609 | /* |
||
610 | * Need to acquire the namespace writer lock to prevent interference |
||
611 | * with any concurrent namespace walks. The interpreter must be |
||
612 | * released during the deletion since the acquisition of the deletion |
||
613 | * lock may block, and also since the execution of a namespace walk |
||
614 | * must be allowed to use the interpreter. |
||
615 | */ |
||
616 | (void)acpi_ut_release_mutex(ACPI_MTX_INTERPRETER); |
||
617 | status = acpi_ut_acquire_write_lock(&acpi_gbl_namespace_rw_lock); |
||
618 | |||
619 | acpi_ns_delete_namespace_by_owner(owner_id); |
||
620 | if (ACPI_FAILURE(status)) { |
||
621 | return_ACPI_STATUS(status); |
||
622 | } |
||
623 | |||
624 | acpi_ut_release_write_lock(&acpi_gbl_namespace_rw_lock); |
||
625 | |||
626 | status = acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER); |
||
627 | return_ACPI_STATUS(status); |
||
628 | } |
||
629 | |||
630 | /******************************************************************************* |
||
631 | * |
||
632 | * FUNCTION: acpi_tb_allocate_owner_id |
||
633 | * |
||
634 | * PARAMETERS: table_index - Table index |
||
635 | * |
||
636 | * RETURN: Status |
||
637 | * |
||
638 | * DESCRIPTION: Allocates owner_id in table_desc |
||
639 | * |
||
640 | ******************************************************************************/ |
||
641 | |||
642 | acpi_status acpi_tb_allocate_owner_id(u32 table_index) |
||
643 | { |
||
644 | acpi_status status = AE_BAD_PARAMETER; |
||
645 | |||
646 | ACPI_FUNCTION_TRACE(tb_allocate_owner_id); |
||
647 | |||
648 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
||
649 | if (table_index < acpi_gbl_root_table_list.current_table_count) { |
||
650 | status = |
||
651 | acpi_ut_allocate_owner_id(& |
||
652 | (acpi_gbl_root_table_list. |
||
653 | tables[table_index].owner_id)); |
||
654 | } |
||
655 | |||
656 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
||
657 | return_ACPI_STATUS(status); |
||
658 | } |
||
659 | |||
660 | /******************************************************************************* |
||
661 | * |
||
662 | * FUNCTION: acpi_tb_release_owner_id |
||
663 | * |
||
664 | * PARAMETERS: table_index - Table index |
||
665 | * |
||
666 | * RETURN: Status |
||
667 | * |
||
668 | * DESCRIPTION: Releases owner_id in table_desc |
||
669 | * |
||
670 | ******************************************************************************/ |
||
671 | |||
672 | acpi_status acpi_tb_release_owner_id(u32 table_index) |
||
673 | { |
||
674 | acpi_status status = AE_BAD_PARAMETER; |
||
675 | |||
676 | ACPI_FUNCTION_TRACE(tb_release_owner_id); |
||
677 | |||
678 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
||
679 | if (table_index < acpi_gbl_root_table_list.current_table_count) { |
||
680 | acpi_ut_release_owner_id(& |
||
681 | (acpi_gbl_root_table_list. |
||
682 | tables[table_index].owner_id)); |
||
683 | status = AE_OK; |
||
684 | } |
||
685 | |||
686 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
||
687 | return_ACPI_STATUS(status); |
||
688 | } |
||
689 | |||
690 | /******************************************************************************* |
||
691 | * |
||
692 | * FUNCTION: acpi_tb_get_owner_id |
||
693 | * |
||
694 | * PARAMETERS: table_index - Table index |
||
695 | * owner_id - Where the table owner_id is returned |
||
696 | * |
||
697 | * RETURN: Status |
||
698 | * |
||
699 | * DESCRIPTION: returns owner_id for the ACPI table |
||
700 | * |
||
701 | ******************************************************************************/ |
||
702 | |||
703 | acpi_status acpi_tb_get_owner_id(u32 table_index, acpi_owner_id * owner_id) |
||
704 | { |
||
705 | acpi_status status = AE_BAD_PARAMETER; |
||
706 | |||
707 | ACPI_FUNCTION_TRACE(tb_get_owner_id); |
||
708 | |||
709 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
||
710 | if (table_index < acpi_gbl_root_table_list.current_table_count) { |
||
711 | *owner_id = |
||
712 | acpi_gbl_root_table_list.tables[table_index].owner_id; |
||
713 | status = AE_OK; |
||
714 | } |
||
715 | |||
716 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
||
717 | return_ACPI_STATUS(status); |
||
718 | } |
||
719 | |||
720 | /******************************************************************************* |
||
721 | * |
||
722 | * FUNCTION: acpi_tb_is_table_loaded |
||
723 | * |
||
724 | * PARAMETERS: table_index - Index into the root table |
||
725 | * |
||
726 | * RETURN: Table Loaded Flag |
||
727 | * |
||
728 | ******************************************************************************/ |
||
729 | |||
730 | u8 acpi_tb_is_table_loaded(u32 table_index) |
||
731 | { |
||
732 | u8 is_loaded = FALSE; |
||
733 | |||
734 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
||
735 | if (table_index < acpi_gbl_root_table_list.current_table_count) { |
||
736 | is_loaded = (u8) |
||
737 | (acpi_gbl_root_table_list.tables[table_index].flags & |
||
738 | ACPI_TABLE_IS_LOADED); |
||
739 | } |
||
740 | |||
741 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
||
742 | return (is_loaded); |
||
743 | } |
||
744 | |||
745 | /******************************************************************************* |
||
746 | * |
||
747 | * FUNCTION: acpi_tb_set_table_loaded_flag |
||
748 | * |
||
749 | * PARAMETERS: table_index - Table index |
||
750 | * is_loaded - TRUE if table is loaded, FALSE otherwise |
||
751 | * |
||
752 | * RETURN: None |
||
753 | * |
||
754 | * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE. |
||
755 | * |
||
756 | ******************************************************************************/ |
||
757 | |||
758 | void acpi_tb_set_table_loaded_flag(u32 table_index, u8 is_loaded) |
||
759 | { |
||
760 | |||
761 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
||
762 | if (table_index < acpi_gbl_root_table_list.current_table_count) { |
||
763 | if (is_loaded) { |
||
764 | acpi_gbl_root_table_list.tables[table_index].flags |= |
||
765 | ACPI_TABLE_IS_LOADED; |
||
766 | } else { |
||
767 | acpi_gbl_root_table_list.tables[table_index].flags &= |
||
768 | ~ACPI_TABLE_IS_LOADED; |
||
769 | } |
||
770 | } |
||
771 | |||
772 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
||
773 | }>>>>>> |