Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /****************************************************************************** |
2 | * | |
3 | * Module Name: tbinstal - ACPI table installation and removal | |
4 | * | |
5 | *****************************************************************************/ | |
6 | ||
7 | /* | |
fbb7a2dc | 8 | * Copyright (C) 2000 - 2014, 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> |
e2f7a777 LB |
45 | #include "accommon.h" |
46 | #include "acnamesp.h" | |
47 | #include "actables.h" | |
1da177e4 | 48 | |
1da177e4 | 49 | #define _COMPONENT ACPI_TABLES |
4be44fcd | 50 | ACPI_MODULE_NAME("tbinstal") |
1da177e4 | 51 | |
86dfc6f3 LZ |
52 | /* Local prototypes */ |
53 | static acpi_status | |
54 | acpi_tb_acquire_temporal_table(struct acpi_table_desc *table_desc, | |
55 | acpi_physical_address address, u8 flags); | |
56 | ||
57 | static void acpi_tb_release_temporal_table(struct acpi_table_desc *table_desc); | |
58 | ||
59 | static acpi_status acpi_tb_acquire_root_table_entry(u32 *table_index); | |
60 | ||
61 | static u8 | |
62 | acpi_tb_is_equivalent_table(struct acpi_table_desc *table_desc, | |
63 | u32 table_index); | |
64 | ||
7f9fc99c | 65 | /******************************************************************************* |
1da177e4 | 66 | * |
7f9fc99c | 67 | * FUNCTION: acpi_tb_acquire_table |
1da177e4 | 68 | * |
7f9fc99c LZ |
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 | |
1da177e4 LT |
73 | * |
74 | * RETURN: Status | |
75 | * | |
7f9fc99c LZ |
76 | * DESCRIPTION: Acquire a table. It can be used for tables not maintained in |
77 | * acpi_gbl_root_table_list. | |
1da177e4 | 78 | * |
7f9fc99c | 79 | ******************************************************************************/ |
86dfc6f3 | 80 | |
7f9fc99c LZ |
81 | acpi_status |
82 | acpi_tb_acquire_table(struct acpi_table_desc *table_desc, | |
83 | struct acpi_table_header **table_ptr, | |
84 | u32 *table_length, u8 *table_flags) | |
1da177e4 | 85 | { |
7f9fc99c | 86 | struct acpi_table_header *table = NULL; |
1da177e4 | 87 | |
7f9fc99c | 88 | switch (table_desc->flags & ACPI_TABLE_ORIGIN_MASK) { |
8a216d7f | 89 | case ACPI_TABLE_ORIGIN_INTERN_PHYSICAL: |
1da177e4 | 90 | |
7f9fc99c LZ |
91 | table = |
92 | acpi_os_map_memory(table_desc->address, table_desc->length); | |
93 | break; | |
44f6c012 | 94 | |
8a216d7f LZ |
95 | case ACPI_TABLE_ORIGIN_INTERN_VIRTUAL: |
96 | case ACPI_TABLE_ORIGIN_EXTERN_VIRTUAL: | |
dc156adf | 97 | |
7f9fc99c LZ |
98 | table = |
99 | ACPI_CAST_PTR(struct acpi_table_header, | |
100 | table_desc->address); | |
101 | break; | |
dc156adf | 102 | |
7f9fc99c | 103 | default: |
dc156adf | 104 | |
7f9fc99c LZ |
105 | break; |
106 | } | |
dc156adf | 107 | |
7f9fc99c | 108 | /* Table is not valid yet */ |
dc156adf | 109 | |
7f9fc99c LZ |
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 | ||
120 | return (AE_OK); | |
121 | } | |
122 | ||
123 | /******************************************************************************* | |
124 | * | |
125 | * FUNCTION: acpi_tb_release_table | |
126 | * | |
127 | * PARAMETERS: table - Pointer for the table | |
128 | * table_length - Length for the table | |
129 | * table_flags - Allocation flags for the table | |
130 | * | |
131 | * RETURN: None | |
132 | * | |
133 | * DESCRIPTION: Release a table. The reversal of acpi_tb_acquire_table(). | |
134 | * | |
135 | ******************************************************************************/ | |
136 | ||
137 | void | |
138 | acpi_tb_release_table(struct acpi_table_header *table, | |
139 | u32 table_length, u8 table_flags) | |
140 | { | |
141 | switch (table_flags & ACPI_TABLE_ORIGIN_MASK) { | |
8a216d7f | 142 | case ACPI_TABLE_ORIGIN_INTERN_PHYSICAL: |
7f9fc99c LZ |
143 | |
144 | acpi_os_unmap_memory(table, table_length); | |
145 | break; | |
146 | ||
8a216d7f LZ |
147 | case ACPI_TABLE_ORIGIN_INTERN_VIRTUAL: |
148 | case ACPI_TABLE_ORIGIN_EXTERN_VIRTUAL: | |
7f9fc99c LZ |
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 | * | |
86dfc6f3 LZ |
163 | * DESCRIPTION: This function is called to validate the table, the returned |
164 | * table descriptor is in "VALIDATED" state. | |
7f9fc99c LZ |
165 | * |
166 | *****************************************************************************/ | |
5582982d | 167 | |
7f9fc99c LZ |
168 | acpi_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); | |
86dfc6f3 LZ |
180 | if (!table_desc->pointer) { |
181 | status = AE_NO_MEMORY; | |
1da177e4 | 182 | } |
f3d2e786 | 183 | } |
1da177e4 | 184 | |
c5fc42ac | 185 | return_ACPI_STATUS(status); |
1da177e4 LT |
186 | } |
187 | ||
7f9fc99c LZ |
188 | /******************************************************************************* |
189 | * | |
190 | * FUNCTION: acpi_tb_invalidate_table | |
191 | * | |
192 | * PARAMETERS: table_desc - Table descriptor | |
193 | * | |
194 | * RETURN: None | |
195 | * | |
196 | * DESCRIPTION: Invalidate one internal ACPI table, this is reversal of | |
197 | * acpi_tb_validate_table(). | |
198 | * | |
199 | ******************************************************************************/ | |
200 | ||
201 | void acpi_tb_invalidate_table(struct acpi_table_desc *table_desc) | |
202 | { | |
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 | ||
86dfc6f3 | 219 | /****************************************************************************** |
1da177e4 | 220 | * |
86dfc6f3 | 221 | * FUNCTION: acpi_tb_verify_table |
1da177e4 | 222 | * |
428f2112 | 223 | * PARAMETERS: table_desc - Table descriptor |
86dfc6f3 | 224 | * signature - Table signature to verify |
1da177e4 LT |
225 | * |
226 | * RETURN: Status | |
227 | * | |
86dfc6f3 LZ |
228 | * DESCRIPTION: This function is called to validate and verify the table, the |
229 | * returned table descriptor is in "VALIDATED" state. | |
1da177e4 | 230 | * |
86dfc6f3 | 231 | *****************************************************************************/ |
1da177e4 | 232 | |
f3d2e786 | 233 | acpi_status |
86dfc6f3 | 234 | acpi_tb_verify_table(struct acpi_table_desc *table_desc, char *signature) |
1da177e4 | 235 | { |
f3d2e786 | 236 | acpi_status status = AE_OK; |
1da177e4 | 237 | |
86dfc6f3 | 238 | ACPI_FUNCTION_TRACE(tb_verify_table); |
1da177e4 | 239 | |
86dfc6f3 LZ |
240 | /* Validate the table */ |
241 | ||
242 | status = acpi_tb_validate_table(table_desc); | |
243 | if (ACPI_FAILURE(status)) { | |
244 | return_ACPI_STATUS(AE_NO_MEMORY); | |
428f2112 AS |
245 | } |
246 | ||
86dfc6f3 LZ |
247 | /* If a particular signature is expected (DSDT/FACS), it must match */ |
248 | ||
249 | if (signature && !ACPI_COMPARE_NAME(&table_desc->signature, signature)) { | |
3b3ea775 | 250 | ACPI_BIOS_ERROR((AE_INFO, |
86dfc6f3 LZ |
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; | |
c8cefe30 | 255 | } |
428f2112 | 256 | |
86dfc6f3 | 257 | /* Verify the checksum */ |
1da177e4 | 258 | |
86dfc6f3 LZ |
259 | status = |
260 | acpi_tb_verify_checksum(table_desc->pointer, table_desc->length); | |
261 | if (ACPI_FAILURE(status)) { | |
262 | ACPI_EXCEPTION((AE_INFO, AE_NO_MEMORY, | |
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 | } | |
f3d2e786 | 271 | |
86dfc6f3 | 272 | return_ACPI_STATUS(AE_OK); |
f3d2e786 | 273 | |
86dfc6f3 LZ |
274 | invalidate_and_exit: |
275 | acpi_tb_invalidate_table(table_desc); | |
276 | return_ACPI_STATUS(status); | |
277 | } | |
278 | ||
279 | /******************************************************************************* | |
280 | * | |
281 | * FUNCTION: acpi_tb_install_table | |
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: Install an ACPI table into the global data structure. | |
291 | * | |
292 | ******************************************************************************/ | |
293 | ||
294 | void | |
295 | acpi_tb_install_table(struct acpi_table_desc *table_desc, | |
296 | acpi_physical_address address, | |
297 | u8 flags, struct acpi_table_header *table) | |
298 | { | |
299 | /* | |
300 | * Initialize the table entry. Set the pointer to NULL, since the | |
301 | * table is not fully mapped at this time. | |
302 | */ | |
303 | ACPI_MEMSET(table_desc, 0, sizeof(struct acpi_table_desc)); | |
304 | table_desc->address = address; | |
305 | table_desc->length = table->length; | |
306 | table_desc->flags = flags; | |
307 | ACPI_MOVE_32_TO_32(table_desc->signature.ascii, table->signature); | |
308 | } | |
309 | ||
310 | /******************************************************************************* | |
311 | * | |
312 | * FUNCTION: acpi_tb_acquire_temporal_table | |
313 | * | |
314 | * PARAMETERS: table_desc - Table descriptor to be acquired | |
315 | * address - Address of the table | |
316 | * flags - Allocation flags of the table | |
317 | * | |
318 | * RETURN: Status | |
319 | * | |
320 | * DESCRIPTION: This function validates the table header to obtain the length | |
321 | * of a table and fills the table descriptor to make its state as | |
322 | * "INSTALLED". Such table descriptor is only used for verified | |
323 | * installation. | |
324 | * | |
325 | ******************************************************************************/ | |
326 | ||
327 | static acpi_status | |
328 | acpi_tb_acquire_temporal_table(struct acpi_table_desc *table_desc, | |
329 | acpi_physical_address address, u8 flags) | |
330 | { | |
331 | struct acpi_table_header *table_header; | |
332 | ||
333 | switch (flags & ACPI_TABLE_ORIGIN_MASK) { | |
8a216d7f | 334 | case ACPI_TABLE_ORIGIN_INTERN_PHYSICAL: |
86dfc6f3 LZ |
335 | |
336 | /* Try to obtain the length of the table */ | |
337 | ||
338 | table_header = | |
339 | acpi_os_map_memory(address, | |
340 | sizeof(struct acpi_table_header)); | |
341 | if (!table_header) { | |
342 | return (AE_NO_MEMORY); | |
a6f30539 | 343 | } |
86dfc6f3 LZ |
344 | acpi_tb_install_table(table_desc, address, flags, table_header); |
345 | acpi_os_unmap_memory(table_header, | |
346 | sizeof(struct acpi_table_header)); | |
347 | return (AE_OK); | |
348 | ||
8a216d7f LZ |
349 | case ACPI_TABLE_ORIGIN_INTERN_VIRTUAL: |
350 | case ACPI_TABLE_ORIGIN_EXTERN_VIRTUAL: | |
e56f5617 | 351 | |
86dfc6f3 LZ |
352 | table_header = ACPI_CAST_PTR(struct acpi_table_header, address); |
353 | if (!table_header) { | |
354 | return (AE_NO_MEMORY); | |
f3d2e786 | 355 | } |
86dfc6f3 LZ |
356 | acpi_tb_install_table(table_desc, address, flags, table_header); |
357 | return (AE_OK); | |
f3d2e786 | 358 | |
86dfc6f3 LZ |
359 | default: |
360 | ||
361 | break; | |
362 | } | |
e56f5617 | 363 | |
86dfc6f3 LZ |
364 | /* Table is not valid yet */ |
365 | ||
366 | return (AE_NO_MEMORY); | |
367 | } | |
e56f5617 | 368 | |
86dfc6f3 LZ |
369 | /******************************************************************************* |
370 | * | |
371 | * FUNCTION: acpi_tb_release_temporal_table | |
372 | * | |
373 | * PARAMETERS: table_desc - Table descriptor to be released | |
374 | * | |
375 | * RETURN: Status | |
376 | * | |
377 | * DESCRIPTION: The reversal of acpi_tb_acquire_temporal_table(). | |
378 | * | |
379 | ******************************************************************************/ | |
e56f5617 | 380 | |
86dfc6f3 LZ |
381 | static void acpi_tb_release_temporal_table(struct acpi_table_desc *table_desc) |
382 | { | |
383 | /* | |
384 | * Note that the .Address is maintained by the callers of | |
385 | * acpi_tb_acquire_temporal_table(), thus do not invoke acpi_tb_uninstall_table() | |
386 | * where .Address will be freed. | |
387 | */ | |
388 | acpi_tb_invalidate_table(table_desc); | |
389 | } | |
e56f5617 | 390 | |
86dfc6f3 LZ |
391 | /******************************************************************************* |
392 | * | |
393 | * FUNCTION: acpi_tb_install_and_override_table | |
394 | * | |
395 | * PARAMETERS: table_index - Index into root table array | |
396 | * new_table_desc - New table descriptor to install | |
397 | * | |
398 | * RETURN: None | |
399 | * | |
400 | * DESCRIPTION: Install an ACPI table into the global data structure. The | |
401 | * table override mechanism is called to allow the host | |
402 | * OS to replace any table before it is installed in the root | |
403 | * table array. | |
404 | * | |
405 | ******************************************************************************/ | |
406 | ||
407 | void | |
408 | acpi_tb_install_and_override_table(u32 table_index, | |
409 | struct acpi_table_desc *new_table_desc) | |
410 | { | |
411 | if (table_index >= acpi_gbl_root_table_list.current_table_count) { | |
412 | return; | |
1da177e4 LT |
413 | } |
414 | ||
d3ccaff8 BM |
415 | /* |
416 | * ACPI Table Override: | |
86dfc6f3 LZ |
417 | * |
418 | * Before we install the table, let the host OS override it with a new | |
419 | * one if desired. Any table within the RSDT/XSDT can be replaced, | |
420 | * including the DSDT which is pointed to by the FADT. | |
d3ccaff8 | 421 | */ |
86dfc6f3 | 422 | acpi_tb_override_table(new_table_desc); |
7f9fc99c | 423 | |
86dfc6f3 LZ |
424 | acpi_tb_install_table(&acpi_gbl_root_table_list.tables[table_index], |
425 | new_table_desc->address, new_table_desc->flags, | |
426 | new_table_desc->pointer); | |
7f9fc99c | 427 | |
86dfc6f3 LZ |
428 | acpi_tb_print_table_header(new_table_desc->address, |
429 | new_table_desc->pointer); | |
430 | ||
431 | /* Set the global integer width (based upon revision of the DSDT) */ | |
432 | ||
433 | if (table_index == ACPI_TABLE_INDEX_DSDT) { | |
434 | acpi_ut_set_integer_width(new_table_desc->pointer->revision); | |
435 | } | |
436 | } | |
437 | ||
438 | /******************************************************************************* | |
439 | * | |
440 | * FUNCTION: acpi_tb_install_fixed_table | |
441 | * | |
442 | * PARAMETERS: address - Physical address of DSDT or FACS | |
443 | * signature - Table signature, NULL if no need to | |
444 | * match | |
445 | * table_index - Index into root table array | |
446 | * | |
447 | * RETURN: Status | |
448 | * | |
449 | * DESCRIPTION: Install a fixed ACPI table (DSDT/FACS) into the global data | |
450 | * structure. | |
451 | * | |
452 | ******************************************************************************/ | |
453 | ||
454 | acpi_status | |
455 | acpi_tb_install_fixed_table(acpi_physical_address address, | |
456 | char *signature, u32 table_index) | |
457 | { | |
458 | struct acpi_table_desc new_table_desc; | |
459 | acpi_status status; | |
460 | ||
461 | ACPI_FUNCTION_TRACE(tb_install_fixed_table); | |
462 | ||
463 | if (!address) { | |
464 | ACPI_ERROR((AE_INFO, | |
465 | "Null physical address for ACPI table [%s]", | |
466 | signature)); | |
467 | return (AE_NO_MEMORY); | |
468 | } | |
469 | ||
470 | /* Fill a table descriptor for validation */ | |
471 | ||
472 | status = acpi_tb_acquire_temporal_table(&new_table_desc, address, | |
8a216d7f | 473 | ACPI_TABLE_ORIGIN_INTERN_PHYSICAL); |
86dfc6f3 LZ |
474 | if (ACPI_FAILURE(status)) { |
475 | ACPI_ERROR((AE_INFO, "Could not acquire table length at %p", | |
476 | ACPI_CAST_PTR(void, address))); | |
477 | return_ACPI_STATUS(status); | |
478 | } | |
479 | ||
480 | /* Validate and verify a table before installation */ | |
481 | ||
482 | status = acpi_tb_verify_table(&new_table_desc, signature); | |
483 | if (ACPI_FAILURE(status)) { | |
484 | goto release_and_exit; | |
485 | } | |
486 | ||
487 | acpi_tb_install_and_override_table(table_index, &new_table_desc); | |
488 | ||
489 | release_and_exit: | |
490 | ||
491 | /* Release the temporal table descriptor */ | |
492 | ||
493 | acpi_tb_release_temporal_table(&new_table_desc); | |
494 | return_ACPI_STATUS(status); | |
495 | } | |
496 | ||
497 | /******************************************************************************* | |
498 | * | |
499 | * FUNCTION: acpi_tb_is_equivalent_table | |
500 | * | |
501 | * PARAMETERS: table_desc - Table 1 descriptor to be compared | |
502 | * table_index - Index of table 2 to be compared | |
503 | * | |
504 | * RETURN: TRUE if 2 tables are equivalent | |
505 | * | |
506 | * DESCRIPTION: This function is called to compare a table with what have | |
507 | * already been installed in the root table list. | |
508 | * | |
509 | ******************************************************************************/ | |
510 | ||
511 | static u8 | |
512 | acpi_tb_is_equivalent_table(struct acpi_table_desc *table_desc, u32 table_index) | |
513 | { | |
514 | acpi_status status = AE_OK; | |
515 | u8 is_equivalent; | |
516 | struct acpi_table_header *table; | |
517 | u32 table_length; | |
518 | u8 table_flags; | |
519 | ||
520 | status = | |
521 | acpi_tb_acquire_table(&acpi_gbl_root_table_list.tables[table_index], | |
522 | &table, &table_length, &table_flags); | |
523 | if (ACPI_FAILURE(status)) { | |
524 | return (FALSE); | |
525 | } | |
526 | ||
527 | /* | |
528 | * Check for a table match on the entire table length, | |
529 | * not just the header. | |
530 | */ | |
531 | is_equivalent = (u8)((table_desc->length != table_length || | |
532 | ACPI_MEMCMP(table_desc->pointer, table, | |
533 | table_length)) ? FALSE : TRUE); | |
534 | ||
535 | /* Release the acquired table */ | |
536 | ||
537 | acpi_tb_release_table(table, table_length, table_flags); | |
538 | ||
539 | return (is_equivalent); | |
540 | } | |
541 | ||
542 | /******************************************************************************* | |
543 | * | |
544 | * FUNCTION: acpi_tb_install_non_fixed_table | |
545 | * | |
8a216d7f | 546 | * PARAMETERS: address - Address of the table (might be a virtual |
86dfc6f3 LZ |
547 | * address depending on the table_flags) |
548 | * flags - Flags for the table | |
549 | * reload - Whether reload should be performed | |
550 | * table_index - Where the table index is returned | |
551 | * | |
552 | * RETURN: Status | |
553 | * | |
554 | * DESCRIPTION: This function is called to install an ACPI table that is | |
555 | * neither DSDT nor FACS. | |
556 | * When this function is called by "Load" or "LoadTable" opcodes, | |
557 | * or by acpi_load_table() API, the "Reload" parameter is set. | |
558 | * After sucessfully returning from this function, table is | |
559 | * "INSTALLED" but not "VALIDATED". | |
560 | * | |
561 | ******************************************************************************/ | |
562 | ||
563 | acpi_status | |
564 | acpi_tb_install_non_fixed_table(acpi_physical_address address, | |
565 | u8 flags, u8 reload, u32 *table_index) | |
566 | { | |
567 | u32 i; | |
568 | acpi_status status = AE_OK; | |
569 | struct acpi_table_desc new_table_desc; | |
570 | ||
571 | ACPI_FUNCTION_TRACE(tb_install_non_fixed_table); | |
572 | ||
573 | /* Acquire a temporal table descriptor for validation */ | |
574 | ||
575 | status = | |
576 | acpi_tb_acquire_temporal_table(&new_table_desc, address, flags); | |
577 | if (ACPI_FAILURE(status)) { | |
578 | ACPI_ERROR((AE_INFO, "Could not acquire table length at %p", | |
579 | ACPI_CAST_PTR(void, address))); | |
580 | return_ACPI_STATUS(status); | |
581 | } | |
582 | ||
a94e88cd LZ |
583 | /* |
584 | * Optionally do not load any SSDTs from the RSDT/XSDT. This can | |
585 | * be useful for debugging ACPI problems on some machines. | |
586 | */ | |
587 | if (!reload && acpi_gbl_disable_ssdt_table_install && | |
588 | ACPI_COMPARE_NAME(&new_table_desc.signature, ACPI_SIG_SSDT)) { | |
589 | ACPI_INFO((AE_INFO, "Ignoring installation of %4.4s at %p", | |
590 | new_table_desc.signature.ascii, ACPI_CAST_PTR(void, | |
591 | address))); | |
592 | goto release_and_exit; | |
593 | } | |
594 | ||
86dfc6f3 LZ |
595 | /* Validate and verify a table before installation */ |
596 | ||
597 | status = acpi_tb_verify_table(&new_table_desc, NULL); | |
598 | if (ACPI_FAILURE(status)) { | |
599 | goto release_and_exit; | |
600 | } | |
601 | ||
602 | if (reload) { | |
603 | /* | |
604 | * Validate the incoming table signature. | |
605 | * | |
606 | * 1) Originally, we checked the table signature for "SSDT" or "PSDT". | |
607 | * 2) We added support for OEMx tables, signature "OEM". | |
608 | * 3) Valid tables were encountered with a null signature, so we just | |
609 | * gave up on validating the signature, (05/2008). | |
610 | * 4) We encountered non-AML tables such as the MADT, which caused | |
611 | * interpreter errors and kernel faults. So now, we once again allow | |
612 | * only "SSDT", "OEMx", and now, also a null signature. (05/2011). | |
613 | */ | |
614 | if ((new_table_desc.signature.ascii[0] != 0x00) && | |
615 | (!ACPI_COMPARE_NAME | |
616 | (&new_table_desc.signature, ACPI_SIG_SSDT)) | |
617 | && (ACPI_STRNCMP(new_table_desc.signature.ascii, "OEM", 3))) | |
618 | { | |
619 | ACPI_BIOS_ERROR((AE_INFO, | |
620 | "Table has invalid signature [%4.4s] (0x%8.8X), " | |
621 | "must be SSDT or OEMx", | |
622 | acpi_ut_valid_acpi_name(new_table_desc. | |
623 | signature. | |
624 | ascii) ? | |
625 | new_table_desc.signature. | |
626 | ascii : "????", | |
627 | new_table_desc.signature.integer)); | |
628 | ||
629 | status = AE_BAD_SIGNATURE; | |
630 | goto release_and_exit; | |
631 | } | |
632 | ||
633 | /* Check if table is already registered */ | |
634 | ||
635 | for (i = 0; i < acpi_gbl_root_table_list.current_table_count; | |
636 | ++i) { | |
637 | /* | |
638 | * Check for a table match on the entire table length, | |
639 | * not just the header. | |
640 | */ | |
641 | if (!acpi_tb_is_equivalent_table(&new_table_desc, i)) { | |
642 | continue; | |
643 | } | |
644 | ||
645 | /* | |
646 | * Note: the current mechanism does not unregister a table if it is | |
647 | * dynamically unloaded. The related namespace entries are deleted, | |
648 | * but the table remains in the root table list. | |
649 | * | |
650 | * The assumption here is that the number of different tables that | |
651 | * will be loaded is actually small, and there is minimal overhead | |
652 | * in just keeping the table in case it is needed again. | |
653 | * | |
654 | * If this assumption changes in the future (perhaps on large | |
655 | * machines with many table load/unload operations), tables will | |
656 | * need to be unregistered when they are unloaded, and slots in the | |
657 | * root table list should be reused when empty. | |
658 | */ | |
659 | if (acpi_gbl_root_table_list.tables[i]. | |
660 | flags & ACPI_TABLE_IS_LOADED) { | |
661 | ||
662 | /* Table is still loaded, this is an error */ | |
663 | ||
664 | status = AE_ALREADY_EXISTS; | |
665 | goto release_and_exit; | |
666 | } else { | |
667 | /* | |
668 | * Table was unloaded, allow it to be reloaded. | |
669 | * As we are going to return AE_OK to the caller, we should | |
670 | * take the responsibility of freeing the input descriptor. | |
671 | * Refill the input descriptor to ensure | |
672 | * acpi_tb_install_and_override_table() can be called again to | |
673 | * indicate the re-installation. | |
674 | */ | |
675 | acpi_tb_uninstall_table(&new_table_desc); | |
676 | *table_index = i; | |
677 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | |
678 | return_ACPI_STATUS(AE_OK); | |
679 | } | |
680 | } | |
7f9fc99c | 681 | } |
d3ccaff8 | 682 | |
e56f5617 BM |
683 | /* Add the table to the global root table list */ |
684 | ||
86dfc6f3 | 685 | status = acpi_tb_acquire_root_table_entry(&i); |
4be44fcd | 686 | if (ACPI_FAILURE(status)) { |
86dfc6f3 | 687 | goto release_and_exit; |
0c9938cc | 688 | } |
86dfc6f3 LZ |
689 | *table_index = i; |
690 | acpi_tb_install_and_override_table(i, &new_table_desc); | |
691 | ||
692 | release_and_exit: | |
0c9938cc | 693 | |
86dfc6f3 | 694 | /* Release the temporal table descriptor */ |
1da177e4 | 695 | |
86dfc6f3 | 696 | acpi_tb_release_temporal_table(&new_table_desc); |
4be44fcd | 697 | return_ACPI_STATUS(status); |
1da177e4 LT |
698 | } |
699 | ||
f7b004a1 BM |
700 | /******************************************************************************* |
701 | * | |
7f9fc99c | 702 | * FUNCTION: acpi_tb_override_table |
f7b004a1 | 703 | * |
86dfc6f3 LZ |
704 | * PARAMETERS: old_table_desc - Validated table descriptor to be |
705 | * overridden | |
f7b004a1 | 706 | * |
86dfc6f3 | 707 | * RETURN: None |
f7b004a1 BM |
708 | * |
709 | * DESCRIPTION: Attempt table override by calling the OSL override functions. | |
710 | * Note: If the table is overridden, then the entire new table | |
7f9fc99c | 711 | * is acquired and returned by this function. |
86dfc6f3 LZ |
712 | * Before/after invocation, the table descriptor is in a state |
713 | * that is "VALIDATED". | |
f7b004a1 BM |
714 | * |
715 | ******************************************************************************/ | |
716 | ||
86dfc6f3 | 717 | void acpi_tb_override_table(struct acpi_table_desc *old_table_desc) |
f7b004a1 BM |
718 | { |
719 | acpi_status status; | |
f7b004a1 | 720 | char *override_type; |
7f9fc99c | 721 | struct acpi_table_desc new_table_desc; |
86dfc6f3 LZ |
722 | struct acpi_table_header *table; |
723 | acpi_physical_address address; | |
724 | u32 length; | |
f7b004a1 BM |
725 | |
726 | /* (1) Attempt logical override (returns a logical address) */ | |
727 | ||
86dfc6f3 LZ |
728 | status = acpi_os_table_override(old_table_desc->pointer, &table); |
729 | if (ACPI_SUCCESS(status) && table) { | |
730 | acpi_tb_acquire_temporal_table(&new_table_desc, | |
731 | ACPI_PTR_TO_PHYSADDR(table), | |
8a216d7f | 732 | ACPI_TABLE_ORIGIN_EXTERN_VIRTUAL); |
f7b004a1 BM |
733 | override_type = "Logical"; |
734 | goto finish_override; | |
735 | } | |
736 | ||
737 | /* (2) Attempt physical override (returns a physical address) */ | |
738 | ||
86dfc6f3 LZ |
739 | status = acpi_os_physical_table_override(old_table_desc->pointer, |
740 | &address, &length); | |
741 | if (ACPI_SUCCESS(status) && address && length) { | |
742 | acpi_tb_acquire_temporal_table(&new_table_desc, address, | |
8a216d7f | 743 | ACPI_TABLE_ORIGIN_INTERN_PHYSICAL); |
f7b004a1 | 744 | override_type = "Physical"; |
f7b004a1 BM |
745 | goto finish_override; |
746 | } | |
747 | ||
86dfc6f3 | 748 | return; /* There was no override */ |
f7b004a1 | 749 | |
10622bf8 | 750 | finish_override: |
f7b004a1 | 751 | |
86dfc6f3 LZ |
752 | /* Validate and verify a table before overriding */ |
753 | ||
754 | status = acpi_tb_verify_table(&new_table_desc, NULL); | |
7f9fc99c | 755 | if (ACPI_FAILURE(status)) { |
86dfc6f3 | 756 | return; |
7f9fc99c LZ |
757 | } |
758 | ||
2e19f8d0 BM |
759 | ACPI_INFO((AE_INFO, "%4.4s " ACPI_PRINTF_UINT |
760 | " %s table override, new table: " ACPI_PRINTF_UINT, | |
86dfc6f3 LZ |
761 | old_table_desc->signature.ascii, |
762 | ACPI_FORMAT_TO_UINT(old_table_desc->address), | |
7f9fc99c | 763 | override_type, ACPI_FORMAT_TO_UINT(new_table_desc.address))); |
f7b004a1 | 764 | |
86dfc6f3 | 765 | /* We can now uninstall the original table */ |
f7b004a1 | 766 | |
86dfc6f3 | 767 | acpi_tb_uninstall_table(old_table_desc); |
f7b004a1 | 768 | |
86dfc6f3 LZ |
769 | /* |
770 | * Replace the original table descriptor and keep its state as | |
771 | * "VALIDATED". | |
772 | */ | |
773 | acpi_tb_install_table(old_table_desc, new_table_desc.address, | |
774 | new_table_desc.flags, new_table_desc.pointer); | |
775 | acpi_tb_validate_table(old_table_desc); | |
f7b004a1 | 776 | |
86dfc6f3 | 777 | /* Release the temporal table descriptor */ |
f7b004a1 | 778 | |
86dfc6f3 | 779 | acpi_tb_release_temporal_table(&new_table_desc); |
f7b004a1 BM |
780 | } |
781 | ||
1da177e4 LT |
782 | /******************************************************************************* |
783 | * | |
f3d2e786 | 784 | * FUNCTION: acpi_tb_resize_root_table_list |
1da177e4 | 785 | * |
f3d2e786 | 786 | * PARAMETERS: None |
1da177e4 LT |
787 | * |
788 | * RETURN: Status | |
789 | * | |
f3d2e786 | 790 | * DESCRIPTION: Expand the size of global table array |
1da177e4 LT |
791 | * |
792 | ******************************************************************************/ | |
793 | ||
f3d2e786 | 794 | acpi_status acpi_tb_resize_root_table_list(void) |
1da177e4 | 795 | { |
f3d2e786 | 796 | struct acpi_table_desc *tables; |
2bc198c1 | 797 | u32 table_count; |
1da177e4 | 798 | |
f3d2e786 | 799 | ACPI_FUNCTION_TRACE(tb_resize_root_table_list); |
1da177e4 | 800 | |
f3d2e786 | 801 | /* allow_resize flag is a parameter to acpi_initialize_tables */ |
1da177e4 | 802 | |
c5fc42ac | 803 | if (!(acpi_gbl_root_table_list.flags & ACPI_ROOT_ALLOW_RESIZE)) { |
f3d2e786 BM |
804 | ACPI_ERROR((AE_INFO, |
805 | "Resize of Root Table Array is not allowed")); | |
806 | return_ACPI_STATUS(AE_SUPPORT); | |
1da177e4 LT |
807 | } |
808 | ||
f3d2e786 BM |
809 | /* Increase the Table Array size */ |
810 | ||
2bc198c1 LZ |
811 | if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { |
812 | table_count = acpi_gbl_root_table_list.max_table_count; | |
813 | } else { | |
814 | table_count = acpi_gbl_root_table_list.current_table_count; | |
815 | } | |
816 | ||
817 | tables = ACPI_ALLOCATE_ZEROED(((acpi_size) table_count + | |
ec41f193 BM |
818 | ACPI_ROOT_TABLE_SIZE_INCREMENT) * |
819 | sizeof(struct acpi_table_desc)); | |
f3d2e786 BM |
820 | if (!tables) { |
821 | ACPI_ERROR((AE_INFO, | |
822 | "Could not allocate new root table array")); | |
823 | return_ACPI_STATUS(AE_NO_MEMORY); | |
1da177e4 LT |
824 | } |
825 | ||
f3d2e786 BM |
826 | /* Copy and free the previous table array */ |
827 | ||
828 | if (acpi_gbl_root_table_list.tables) { | |
829 | ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables, | |
2bc198c1 LZ |
830 | (acpi_size) table_count * |
831 | sizeof(struct acpi_table_desc)); | |
f3d2e786 | 832 | |
c5fc42ac | 833 | if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { |
f3d2e786 BM |
834 | ACPI_FREE(acpi_gbl_root_table_list.tables); |
835 | } | |
1da177e4 LT |
836 | } |
837 | ||
f3d2e786 | 838 | acpi_gbl_root_table_list.tables = tables; |
2bc198c1 LZ |
839 | acpi_gbl_root_table_list.max_table_count = |
840 | table_count + ACPI_ROOT_TABLE_SIZE_INCREMENT; | |
841 | acpi_gbl_root_table_list.flags |= ACPI_ROOT_ORIGIN_ALLOCATED; | |
1da177e4 | 842 | |
f3d2e786 | 843 | return_ACPI_STATUS(AE_OK); |
1da177e4 LT |
844 | } |
845 | ||
1da177e4 LT |
846 | /******************************************************************************* |
847 | * | |
86dfc6f3 | 848 | * FUNCTION: acpi_tb_acquire_root_table_entry |
1da177e4 | 849 | * |
86dfc6f3 | 850 | * PARAMETERS: table_index - Where table index is returned |
1da177e4 | 851 | * |
f3d2e786 | 852 | * RETURN: Status and table index. |
1da177e4 | 853 | * |
86dfc6f3 | 854 | * DESCRIPTION: Allocate a new ACPI table entry to the global table list |
1da177e4 LT |
855 | * |
856 | ******************************************************************************/ | |
857 | ||
86dfc6f3 | 858 | static acpi_status acpi_tb_acquire_root_table_entry(u32 *table_index) |
1da177e4 | 859 | { |
b9ee2043 | 860 | acpi_status status; |
1da177e4 | 861 | |
f3d2e786 | 862 | /* Ensure that there is room for the table in the Root Table List */ |
f9f4601f | 863 | |
b9ee2043 BM |
864 | if (acpi_gbl_root_table_list.current_table_count >= |
865 | acpi_gbl_root_table_list.max_table_count) { | |
f3d2e786 BM |
866 | status = acpi_tb_resize_root_table_list(); |
867 | if (ACPI_FAILURE(status)) { | |
868 | return (status); | |
869 | } | |
f9f4601f RM |
870 | } |
871 | ||
86dfc6f3 LZ |
872 | *table_index = acpi_gbl_root_table_list.current_table_count; |
873 | acpi_gbl_root_table_list.current_table_count++; | |
874 | return (AE_OK); | |
875 | } | |
b9ee2043 | 876 | |
86dfc6f3 LZ |
877 | /******************************************************************************* |
878 | * | |
879 | * FUNCTION: acpi_tb_store_table | |
880 | * | |
881 | * PARAMETERS: address - Table address | |
882 | * table - Table header | |
883 | * length - Table length | |
884 | * flags - flags | |
885 | * | |
886 | * RETURN: Status and table index. | |
887 | * | |
888 | * DESCRIPTION: Add an ACPI table to the global table list | |
889 | * | |
890 | ******************************************************************************/ | |
891 | ||
892 | acpi_status | |
893 | acpi_tb_store_table(acpi_physical_address address, | |
894 | struct acpi_table_header * table, | |
895 | u32 length, u8 flags, u32 *table_index) | |
896 | { | |
897 | acpi_status status; | |
898 | struct acpi_table_desc *table_desc; | |
899 | ||
900 | status = acpi_tb_acquire_root_table_entry(table_index); | |
901 | if (ACPI_FAILURE(status)) { | |
902 | return (status); | |
903 | } | |
f3d2e786 | 904 | |
86dfc6f3 | 905 | /* Initialize added table */ |
b9ee2043 | 906 | |
86dfc6f3 LZ |
907 | table_desc = &acpi_gbl_root_table_list.tables[*table_index]; |
908 | acpi_tb_install_table(table_desc, address, flags, table); | |
909 | table_desc->pointer = table; | |
b9ee2043 | 910 | |
b9ee2043 | 911 | return (AE_OK); |
f3d2e786 | 912 | } |
1da177e4 | 913 | |
f3d2e786 BM |
914 | /******************************************************************************* |
915 | * | |
7f9fc99c | 916 | * FUNCTION: acpi_tb_uninstall_table |
f3d2e786 | 917 | * |
7f9fc99c | 918 | * PARAMETERS: table_desc - Table descriptor |
f3d2e786 BM |
919 | * |
920 | * RETURN: None | |
921 | * | |
922 | * DESCRIPTION: Delete one internal ACPI table | |
923 | * | |
924 | ******************************************************************************/ | |
1da177e4 | 925 | |
7f9fc99c | 926 | void acpi_tb_uninstall_table(struct acpi_table_desc *table_desc) |
f3d2e786 | 927 | { |
5582982d | 928 | |
7f9fc99c | 929 | ACPI_FUNCTION_TRACE(tb_uninstall_table); |
5582982d | 930 | |
7f9fc99c | 931 | /* Table must be installed */ |
5582982d | 932 | |
7f9fc99c LZ |
933 | if (!table_desc->address) { |
934 | return_VOID; | |
935 | } | |
f7b004a1 | 936 | |
7f9fc99c | 937 | acpi_tb_invalidate_table(table_desc); |
1d1ea1b7 | 938 | |
7f9fc99c | 939 | if ((table_desc->flags & ACPI_TABLE_ORIGIN_MASK) == |
8a216d7f | 940 | ACPI_TABLE_ORIGIN_INTERN_VIRTUAL) { |
7f9fc99c | 941 | ACPI_FREE(ACPI_CAST_PTR(void, table_desc->address)); |
1da177e4 LT |
942 | } |
943 | ||
7f9fc99c LZ |
944 | table_desc->address = ACPI_PTR_TO_PHYSADDR(NULL); |
945 | ||
946 | return_VOID; | |
1da177e4 LT |
947 | } |
948 | ||
1da177e4 LT |
949 | /******************************************************************************* |
950 | * | |
f3d2e786 | 951 | * FUNCTION: acpi_tb_terminate |
1da177e4 | 952 | * |
f3d2e786 | 953 | * PARAMETERS: None |
1da177e4 | 954 | * |
f3d2e786 | 955 | * RETURN: None |
1da177e4 LT |
956 | * |
957 | * DESCRIPTION: Delete all internal ACPI tables | |
958 | * | |
959 | ******************************************************************************/ | |
960 | ||
f3d2e786 | 961 | void acpi_tb_terminate(void) |
1da177e4 | 962 | { |
67a119f9 | 963 | u32 i; |
f3d2e786 BM |
964 | |
965 | ACPI_FUNCTION_TRACE(tb_terminate); | |
966 | ||
967 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); | |
968 | ||
969 | /* Delete the individual tables */ | |
970 | ||
b9ee2043 | 971 | for (i = 0; i < acpi_gbl_root_table_list.current_table_count; i++) { |
7f9fc99c | 972 | acpi_tb_uninstall_table(&acpi_gbl_root_table_list.tables[i]); |
f3d2e786 | 973 | } |
1da177e4 LT |
974 | |
975 | /* | |
f3d2e786 BM |
976 | * Delete the root table array if allocated locally. Array cannot be |
977 | * mapped, so we don't need to check for that flag. | |
1da177e4 | 978 | */ |
c5fc42ac | 979 | if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) { |
f3d2e786 | 980 | ACPI_FREE(acpi_gbl_root_table_list.tables); |
1da177e4 | 981 | } |
f3d2e786 BM |
982 | |
983 | acpi_gbl_root_table_list.tables = NULL; | |
984 | acpi_gbl_root_table_list.flags = 0; | |
b9ee2043 | 985 | acpi_gbl_root_table_list.current_table_count = 0; |
f3d2e786 BM |
986 | |
987 | ACPI_DEBUG_PRINT((ACPI_DB_INFO, "ACPI Tables freed\n")); | |
988 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | |
68aafc35 BM |
989 | |
990 | return_VOID; | |
1da177e4 LT |
991 | } |
992 | ||
1da177e4 LT |
993 | /******************************************************************************* |
994 | * | |
f3d2e786 | 995 | * FUNCTION: acpi_tb_delete_namespace_by_owner |
1da177e4 | 996 | * |
f3d2e786 | 997 | * PARAMETERS: table_index - Table index |
1da177e4 | 998 | * |
8a335a23 | 999 | * RETURN: Status |
1da177e4 | 1000 | * |
f3d2e786 | 1001 | * DESCRIPTION: Delete all namespace objects created when this table was loaded. |
1da177e4 LT |
1002 | * |
1003 | ******************************************************************************/ | |
1004 | ||
8a335a23 | 1005 | acpi_status acpi_tb_delete_namespace_by_owner(u32 table_index) |
1da177e4 | 1006 | { |
f3d2e786 | 1007 | acpi_owner_id owner_id; |
8a335a23 BM |
1008 | acpi_status status; |
1009 | ||
1010 | ACPI_FUNCTION_TRACE(tb_delete_namespace_by_owner); | |
1011 | ||
1012 | status = acpi_ut_acquire_mutex(ACPI_MTX_TABLES); | |
1013 | if (ACPI_FAILURE(status)) { | |
1014 | return_ACPI_STATUS(status); | |
1015 | } | |
1016 | ||
b9ee2043 | 1017 | if (table_index >= acpi_gbl_root_table_list.current_table_count) { |
8a335a23 BM |
1018 | |
1019 | /* The table index does not exist */ | |
1da177e4 | 1020 | |
f3d2e786 | 1021 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
8a335a23 | 1022 | return_ACPI_STATUS(AE_NOT_EXIST); |
1da177e4 LT |
1023 | } |
1024 | ||
8a335a23 BM |
1025 | /* Get the owner ID for this table, used to delete namespace nodes */ |
1026 | ||
1027 | owner_id = acpi_gbl_root_table_list.tables[table_index].owner_id; | |
f3d2e786 | 1028 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
8a335a23 BM |
1029 | |
1030 | /* | |
1031 | * Need to acquire the namespace writer lock to prevent interference | |
1032 | * with any concurrent namespace walks. The interpreter must be | |
1033 | * released during the deletion since the acquisition of the deletion | |
1034 | * lock may block, and also since the execution of a namespace walk | |
1035 | * must be allowed to use the interpreter. | |
1036 | */ | |
e4c1ebfc | 1037 | (void)acpi_ut_release_mutex(ACPI_MTX_INTERPRETER); |
8a335a23 BM |
1038 | status = acpi_ut_acquire_write_lock(&acpi_gbl_namespace_rw_lock); |
1039 | ||
f3d2e786 | 1040 | acpi_ns_delete_namespace_by_owner(owner_id); |
8a335a23 BM |
1041 | if (ACPI_FAILURE(status)) { |
1042 | return_ACPI_STATUS(status); | |
1043 | } | |
1044 | ||
1045 | acpi_ut_release_write_lock(&acpi_gbl_namespace_rw_lock); | |
1046 | ||
1047 | status = acpi_ut_acquire_mutex(ACPI_MTX_INTERPRETER); | |
1048 | return_ACPI_STATUS(status); | |
f3d2e786 | 1049 | } |
1da177e4 | 1050 | |
f3d2e786 BM |
1051 | /******************************************************************************* |
1052 | * | |
1053 | * FUNCTION: acpi_tb_allocate_owner_id | |
1054 | * | |
1055 | * PARAMETERS: table_index - Table index | |
1056 | * | |
1057 | * RETURN: Status | |
1058 | * | |
1059 | * DESCRIPTION: Allocates owner_id in table_desc | |
1060 | * | |
1061 | ******************************************************************************/ | |
1da177e4 | 1062 | |
67a119f9 | 1063 | acpi_status acpi_tb_allocate_owner_id(u32 table_index) |
f3d2e786 BM |
1064 | { |
1065 | acpi_status status = AE_BAD_PARAMETER; | |
1da177e4 | 1066 | |
f3d2e786 | 1067 | ACPI_FUNCTION_TRACE(tb_allocate_owner_id); |
1da177e4 | 1068 | |
f3d2e786 | 1069 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
b9ee2043 | 1070 | if (table_index < acpi_gbl_root_table_list.current_table_count) { |
f3d2e786 BM |
1071 | status = acpi_ut_allocate_owner_id |
1072 | (&(acpi_gbl_root_table_list.tables[table_index].owner_id)); | |
1da177e4 LT |
1073 | } |
1074 | ||
4be44fcd | 1075 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
f3d2e786 | 1076 | return_ACPI_STATUS(status); |
1da177e4 LT |
1077 | } |
1078 | ||
1da177e4 LT |
1079 | /******************************************************************************* |
1080 | * | |
f3d2e786 | 1081 | * FUNCTION: acpi_tb_release_owner_id |
1da177e4 | 1082 | * |
f3d2e786 | 1083 | * PARAMETERS: table_index - Table index |
1da177e4 | 1084 | * |
f3d2e786 | 1085 | * RETURN: Status |
1da177e4 | 1086 | * |
f3d2e786 | 1087 | * DESCRIPTION: Releases owner_id in table_desc |
1da177e4 LT |
1088 | * |
1089 | ******************************************************************************/ | |
1090 | ||
67a119f9 | 1091 | acpi_status acpi_tb_release_owner_id(u32 table_index) |
1da177e4 | 1092 | { |
f3d2e786 | 1093 | acpi_status status = AE_BAD_PARAMETER; |
1da177e4 | 1094 | |
f3d2e786 | 1095 | ACPI_FUNCTION_TRACE(tb_release_owner_id); |
1da177e4 | 1096 | |
f3d2e786 | 1097 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
b9ee2043 | 1098 | if (table_index < acpi_gbl_root_table_list.current_table_count) { |
f3d2e786 BM |
1099 | acpi_ut_release_owner_id(& |
1100 | (acpi_gbl_root_table_list. | |
1101 | tables[table_index].owner_id)); | |
1102 | status = AE_OK; | |
1da177e4 LT |
1103 | } |
1104 | ||
f3d2e786 BM |
1105 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
1106 | return_ACPI_STATUS(status); | |
1da177e4 LT |
1107 | } |
1108 | ||
1da177e4 LT |
1109 | /******************************************************************************* |
1110 | * | |
f3d2e786 | 1111 | * FUNCTION: acpi_tb_get_owner_id |
1da177e4 | 1112 | * |
f3d2e786 BM |
1113 | * PARAMETERS: table_index - Table index |
1114 | * owner_id - Where the table owner_id is returned | |
1da177e4 | 1115 | * |
f3d2e786 | 1116 | * RETURN: Status |
1da177e4 | 1117 | * |
f3d2e786 | 1118 | * DESCRIPTION: returns owner_id for the ACPI table |
1da177e4 LT |
1119 | * |
1120 | ******************************************************************************/ | |
1121 | ||
5582982d | 1122 | acpi_status acpi_tb_get_owner_id(u32 table_index, acpi_owner_id * owner_id) |
1da177e4 | 1123 | { |
f3d2e786 | 1124 | acpi_status status = AE_BAD_PARAMETER; |
1da177e4 | 1125 | |
f3d2e786 | 1126 | ACPI_FUNCTION_TRACE(tb_get_owner_id); |
1da177e4 | 1127 | |
f3d2e786 | 1128 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
b9ee2043 | 1129 | if (table_index < acpi_gbl_root_table_list.current_table_count) { |
f3d2e786 BM |
1130 | *owner_id = |
1131 | acpi_gbl_root_table_list.tables[table_index].owner_id; | |
1132 | status = AE_OK; | |
1da177e4 LT |
1133 | } |
1134 | ||
f3d2e786 BM |
1135 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
1136 | return_ACPI_STATUS(status); | |
1137 | } | |
1da177e4 | 1138 | |
f3d2e786 BM |
1139 | /******************************************************************************* |
1140 | * | |
1141 | * FUNCTION: acpi_tb_is_table_loaded | |
1142 | * | |
1143 | * PARAMETERS: table_index - Table index | |
1144 | * | |
1145 | * RETURN: Table Loaded Flag | |
1146 | * | |
1147 | ******************************************************************************/ | |
1da177e4 | 1148 | |
67a119f9 | 1149 | u8 acpi_tb_is_table_loaded(u32 table_index) |
f3d2e786 BM |
1150 | { |
1151 | u8 is_loaded = FALSE; | |
1da177e4 | 1152 | |
f3d2e786 | 1153 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
b9ee2043 | 1154 | if (table_index < acpi_gbl_root_table_list.current_table_count) { |
f3d2e786 | 1155 | is_loaded = (u8) |
ec41f193 BM |
1156 | (acpi_gbl_root_table_list.tables[table_index].flags & |
1157 | ACPI_TABLE_IS_LOADED); | |
1da177e4 LT |
1158 | } |
1159 | ||
f3d2e786 BM |
1160 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
1161 | return (is_loaded); | |
1162 | } | |
f6dd9221 | 1163 | |
f3d2e786 BM |
1164 | /******************************************************************************* |
1165 | * | |
1166 | * FUNCTION: acpi_tb_set_table_loaded_flag | |
1167 | * | |
1168 | * PARAMETERS: table_index - Table index | |
1169 | * is_loaded - TRUE if table is loaded, FALSE otherwise | |
1170 | * | |
1171 | * RETURN: None | |
1172 | * | |
1173 | * DESCRIPTION: Sets the table loaded flag to either TRUE or FALSE. | |
1174 | * | |
1175 | ******************************************************************************/ | |
1da177e4 | 1176 | |
67a119f9 | 1177 | void acpi_tb_set_table_loaded_flag(u32 table_index, u8 is_loaded) |
f3d2e786 | 1178 | { |
1da177e4 | 1179 | |
f3d2e786 | 1180 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
b9ee2043 | 1181 | if (table_index < acpi_gbl_root_table_list.current_table_count) { |
f3d2e786 BM |
1182 | if (is_loaded) { |
1183 | acpi_gbl_root_table_list.tables[table_index].flags |= | |
c5fc42ac | 1184 | ACPI_TABLE_IS_LOADED; |
f3d2e786 BM |
1185 | } else { |
1186 | acpi_gbl_root_table_list.tables[table_index].flags &= | |
c5fc42ac | 1187 | ~ACPI_TABLE_IS_LOADED; |
f3d2e786 BM |
1188 | } |
1189 | } | |
1da177e4 | 1190 | |
f3d2e786 | 1191 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
1da177e4 | 1192 | } |