ACPICA: hide private headers
[deliverable/linux.git] / drivers / acpi / acpica / tbxface.c
CommitLineData
1da177e4
LT
1/******************************************************************************
2 *
3 * Module Name: tbxface - Public interfaces to the ACPI subsystem
4 * ACPI table oriented interfaces
5 *
6 *****************************************************************************/
7
8/*
75a44ce0 9 * Copyright (C) 2000 - 2008, Intel Corp.
1da177e4
LT
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions, and the following disclaimer,
17 * without modification.
18 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 * substantially similar to the "NO WARRANTY" disclaimer below
20 * ("Disclaimer") and any redistribution must be conditioned upon
21 * including a substantially similar Disclaimer requirement for further
22 * binary redistribution.
23 * 3. Neither the names of the above-listed copyright holders nor the names
24 * of any contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
26 *
27 * Alternatively, this software may be distributed under the terms of the
28 * GNU General Public License ("GPL") version 2 as published by the Free
29 * Software Foundation.
30 *
31 * NO WARRANTY
32 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 * POSSIBILITY OF SUCH DAMAGES.
43 */
44
1da177e4 45#include <acpi/acpi.h>
e2f7a777
LB
46#include "accommon.h"
47#include "acnamesp.h"
48#include "actables.h"
1da177e4 49
1da177e4 50#define _COMPONENT ACPI_TABLES
4be44fcd 51ACPI_MODULE_NAME("tbxface")
1da177e4 52
f3d2e786
BM
53/* Local prototypes */
54static acpi_status acpi_tb_load_namespace(void);
55
67effe8f
LB
56static int no_auto_ssdt;
57
77389e12
BM
58/*******************************************************************************
59 *
60 * FUNCTION: acpi_allocate_root_table
61 *
62 * PARAMETERS: initial_table_count - Size of initial_table_array, in number of
63 * struct acpi_table_desc structures
64 *
65 * RETURN: Status
66 *
67 * DESCRIPTION: Allocate a root table array. Used by i_aSL compiler and
68 * acpi_initialize_tables.
69 *
70 ******************************************************************************/
71
72acpi_status acpi_allocate_root_table(u32 initial_table_count)
73{
74
75 acpi_gbl_root_table_list.size = initial_table_count;
76 acpi_gbl_root_table_list.flags = ACPI_ROOT_ALLOW_RESIZE;
77
78 return (acpi_tb_resize_root_table_list());
79}
80
1da177e4
LT
81/*******************************************************************************
82 *
f3d2e786 83 * FUNCTION: acpi_initialize_tables
1da177e4 84 *
f3d2e786
BM
85 * PARAMETERS: initial_table_array - Pointer to an array of pre-allocated
86 * struct acpi_table_desc structures. If NULL, the
87 * array is dynamically allocated.
88 * initial_table_count - Size of initial_table_array, in number of
89 * struct acpi_table_desc structures
90 * allow_realloc - Flag to tell Table Manager if resize of
91 * pre-allocated array is allowed. Ignored
92 * if initial_table_array is NULL.
1da177e4
LT
93 *
94 * RETURN: Status
95 *
f3d2e786
BM
96 * DESCRIPTION: Initialize the table manager, get the RSDP and RSDT/XSDT.
97 *
98 * NOTE: Allows static allocation of the initial table array in order
99 * to avoid the use of dynamic memory in confined environments
100 * such as the kernel boot sequence where it may not be available.
101 *
102 * If the host OS memory managers are initialized, use NULL for
103 * initial_table_array, and the table will be dynamically allocated.
1da177e4
LT
104 *
105 ******************************************************************************/
f3d2e786 106
ad71860a 107acpi_status __init
77389e12 108acpi_initialize_tables(struct acpi_table_desc * initial_table_array,
f3d2e786 109 u32 initial_table_count, u8 allow_resize)
1da177e4 110{
c5fc42ac 111 acpi_physical_address rsdp_address;
4be44fcd 112 acpi_status status;
1da177e4 113
f3d2e786 114 ACPI_FUNCTION_TRACE(acpi_initialize_tables);
1da177e4 115
f3d2e786
BM
116 /*
117 * Set up the Root Table Array
118 * Allocate the table array if requested
119 */
120 if (!initial_table_array) {
77389e12 121 status = acpi_allocate_root_table(initial_table_count);
f3d2e786
BM
122 if (ACPI_FAILURE(status)) {
123 return_ACPI_STATUS(status);
124 }
125 } else {
126 /* Root Table Array has been statically allocated by the host */
127
a4bbb810 128 ACPI_MEMSET(initial_table_array, 0,
67a119f9 129 (acpi_size) initial_table_count *
a4bbb810 130 sizeof(struct acpi_table_desc));
c5fc42ac 131
f3d2e786
BM
132 acpi_gbl_root_table_list.tables = initial_table_array;
133 acpi_gbl_root_table_list.size = initial_table_count;
c5fc42ac 134 acpi_gbl_root_table_list.flags = ACPI_ROOT_ORIGIN_UNKNOWN;
f3d2e786 135 if (allow_resize) {
c5fc42ac
BM
136 acpi_gbl_root_table_list.flags |=
137 ACPI_ROOT_ALLOW_RESIZE;
f3d2e786 138 }
1da177e4
LT
139 }
140
c5fc42ac 141 /* Get the address of the RSDP */
1da177e4 142
c5fc42ac
BM
143 rsdp_address = acpi_os_get_root_pointer();
144 if (!rsdp_address) {
f3d2e786
BM
145 return_ACPI_STATUS(AE_NOT_FOUND);
146 }
1da177e4 147
f3d2e786
BM
148 /*
149 * Get the root table (RSDT or XSDT) and extract all entries to the local
150 * Root Table Array. This array contains the information of the RSDT/XSDT
151 * in a common, more useable format.
152 */
c5fc42ac
BM
153 status =
154 acpi_tb_parse_root_table(rsdp_address, ACPI_TABLE_ORIGIN_MAPPED);
f3d2e786
BM
155 return_ACPI_STATUS(status);
156}
1da177e4 157
f3d2e786
BM
158/*******************************************************************************
159 *
160 * FUNCTION: acpi_reallocate_root_table
161 *
162 * PARAMETERS: None
163 *
164 * RETURN: Status
165 *
166 * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the
167 * root list from the previously provided scratch area. Should
168 * be called once dynamic memory allocation is available in the
169 * kernel
170 *
171 ******************************************************************************/
172acpi_status acpi_reallocate_root_table(void)
173{
174 struct acpi_table_desc *tables;
175 acpi_size new_size;
176
177 ACPI_FUNCTION_TRACE(acpi_reallocate_root_table);
178
179 /*
180 * Only reallocate the root table if the host provided a static buffer
181 * for the table array in the call to acpi_initialize_tables.
182 */
c5fc42ac 183 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
f3d2e786 184 return_ACPI_STATUS(AE_SUPPORT);
1da177e4
LT
185 }
186
67a119f9
BM
187 new_size = ((acpi_size) acpi_gbl_root_table_list.count +
188 ACPI_ROOT_TABLE_SIZE_INCREMENT) *
189 sizeof(struct acpi_table_desc);
1da177e4 190
f3d2e786 191 /* Create new array and copy the old array */
1da177e4 192
f3d2e786
BM
193 tables = ACPI_ALLOCATE_ZEROED(new_size);
194 if (!tables) {
195 return_ACPI_STATUS(AE_NO_MEMORY);
1da177e4
LT
196 }
197
f3d2e786 198 ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables, new_size);
1da177e4 199
f3d2e786
BM
200 acpi_gbl_root_table_list.size = acpi_gbl_root_table_list.count;
201 acpi_gbl_root_table_list.tables = tables;
202 acpi_gbl_root_table_list.flags =
c5fc42ac 203 ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE;
8313524a 204
f3d2e786
BM
205 return_ACPI_STATUS(AE_OK);
206}
fd350943 207
1da177e4
LT
208/*******************************************************************************
209 *
210 * FUNCTION: acpi_load_table
211 *
212 * PARAMETERS: table_ptr - pointer to a buffer containing the entire
213 * table to be loaded
214 *
215 * RETURN: Status
216 *
217 * DESCRIPTION: This function is called to load a table from the caller's
f6dd9221
BM
218 * buffer. The buffer must contain an entire ACPI Table including
219 * a valid header. The header fields will be verified, and if it
1da177e4
LT
220 * is determined that the table is invalid, the call will fail.
221 *
222 ******************************************************************************/
4be44fcd 223acpi_status acpi_load_table(struct acpi_table_header *table_ptr)
1da177e4 224{
4be44fcd 225 acpi_status status;
67a119f9 226 u32 table_index;
428f2112
AS
227 struct acpi_table_desc table_desc;
228
229 if (!table_ptr)
230 return AE_BAD_PARAMETER;
231
232 ACPI_MEMSET(&table_desc, 0, sizeof(struct acpi_table_desc));
233 table_desc.pointer = table_ptr;
234 table_desc.length = table_ptr->length;
235 table_desc.flags = ACPI_TABLE_ORIGIN_UNKNOWN;
1da177e4 236
f3d2e786
BM
237 /*
238 * Install the new table into the local data structures
239 */
428f2112 240 status = acpi_tb_add_table(&table_desc, &table_index);
4be44fcd 241 if (ACPI_FAILURE(status)) {
428f2112 242 return status;
0c9938cc 243 }
f3d2e786 244 status = acpi_ns_load_table(table_index, acpi_gbl_root_node);
428f2112 245 return status;
f3d2e786 246}
0c9938cc 247
f3d2e786 248ACPI_EXPORT_SYMBOL(acpi_load_table)
52fc0b02 249
f3d2e786
BM
250/******************************************************************************
251 *
252 * FUNCTION: acpi_get_table_header
253 *
254 * PARAMETERS: Signature - ACPI signature of needed table
255 * Instance - Which instance (for SSDTs)
428f2112 256 * out_table_header - The pointer to the table header to fill
f3d2e786
BM
257 *
258 * RETURN: Status and pointer to mapped table header
259 *
260 * DESCRIPTION: Finds an ACPI table header.
261 *
262 * NOTE: Caller is responsible in unmapping the header with
263 * acpi_os_unmap_memory
264 *
265 *****************************************************************************/
266acpi_status
267acpi_get_table_header(char *signature,
67a119f9 268 u32 instance, struct acpi_table_header *out_table_header)
f3d2e786 269{
67a119f9
BM
270 u32 i;
271 u32 j;
428f2112 272 struct acpi_table_header *header;
0c9938cc 273
c5fc42ac
BM
274 /* Parameter validation */
275
276 if (!signature || !out_table_header) {
277 return (AE_BAD_PARAMETER);
278 }
279
f3d2e786
BM
280 /*
281 * Walk the root table list
282 */
283 for (i = 0, j = 0; i < acpi_gbl_root_table_list.count; i++) {
284 if (!ACPI_COMPARE_NAME
285 (&(acpi_gbl_root_table_list.tables[i].signature),
286 signature)) {
287 continue;
0c9938cc
RM
288 }
289
f3d2e786
BM
290 if (++j < instance) {
291 continue;
292 }
1da177e4 293
428f2112
AS
294 if (!acpi_gbl_root_table_list.tables[i].pointer) {
295 if ((acpi_gbl_root_table_list.tables[i].
296 flags & ACPI_TABLE_ORIGIN_MASK) ==
297 ACPI_TABLE_ORIGIN_MAPPED) {
298 header =
299 acpi_os_map_memory(acpi_gbl_root_table_list.
300 tables[i].address,
301 sizeof(struct
302 acpi_table_header));
303 if (!header) {
304 return AE_NO_MEMORY;
305 }
306 ACPI_MEMCPY(out_table_header, header,
307 sizeof(struct acpi_table_header));
308 acpi_os_unmap_memory(header,
309 sizeof(struct
310 acpi_table_header));
311 } else {
312 return AE_NOT_FOUND;
313 }
314 } else {
315 ACPI_MEMCPY(out_table_header,
316 acpi_gbl_root_table_list.tables[i].pointer,
317 sizeof(struct acpi_table_header));
f3d2e786 318 }
f3d2e786 319 return (AE_OK);
1da177e4
LT
320 }
321
f3d2e786 322 return (AE_NOT_FOUND);
1da177e4
LT
323}
324
f3d2e786 325ACPI_EXPORT_SYMBOL(acpi_get_table_header)
8313524a 326
f3d2e786 327/******************************************************************************
0f0fe1a0
JK
328 *
329 * FUNCTION: acpi_unload_table_id
330 *
f3d2e786 331 * PARAMETERS: id - Owner ID of the table to be removed.
0f0fe1a0
JK
332 *
333 * RETURN: Status
334 *
335 * DESCRIPTION: This routine is used to force the unload of a table (by id)
336 *
337 ******************************************************************************/
f3d2e786 338acpi_status acpi_unload_table_id(acpi_owner_id id)
0f0fe1a0 339{
f3d2e786
BM
340 int i;
341 acpi_status status = AE_NOT_EXIST;
0f0fe1a0 342
ecb5f752 343 ACPI_FUNCTION_TRACE(acpi_unload_table_id);
0f0fe1a0 344
ecb5f752 345 /* Find table in the global table list */
f3d2e786
BM
346 for (i = 0; i < acpi_gbl_root_table_list.count; ++i) {
347 if (id != acpi_gbl_root_table_list.tables[i].owner_id) {
348 continue;
349 }
350 /*
fd350943
LB
351 * Delete all namespace objects owned by this table. Note that these
352 * objects can appear anywhere in the namespace by virtue of the AML
353 * "Scope" operator. Thus, we need to track ownership by an ID, not
354 * simply a position within the hierarchy
355 */
f3d2e786 356 acpi_tb_delete_namespace_by_owner(i);
ecb5f752 357 status = acpi_tb_release_owner_id(i);
f3d2e786 358 acpi_tb_set_table_loaded_flag(i, FALSE);
ecb5f752 359 break;
f3d2e786
BM
360 }
361 return_ACPI_STATUS(status);
0f0fe1a0
JK
362}
363
364ACPI_EXPORT_SYMBOL(acpi_unload_table_id)
365
1da177e4
LT
366/*******************************************************************************
367 *
f3d2e786 368 * FUNCTION: acpi_get_table
1da177e4 369 *
f3d2e786
BM
370 * PARAMETERS: Signature - ACPI signature of needed table
371 * Instance - Which instance (for SSDTs)
372 * out_table - Where the pointer to the table is returned
1da177e4 373 *
f3d2e786 374 * RETURN: Status and pointer to table
1da177e4 375 *
f3d2e786 376 * DESCRIPTION: Finds and verifies an ACPI table.
1da177e4 377 *
f3d2e786
BM
378 *****************************************************************************/
379acpi_status
380acpi_get_table(char *signature,
67a119f9 381 u32 instance, struct acpi_table_header **out_table)
1da177e4 382{
67a119f9
BM
383 u32 i;
384 u32 j;
f3d2e786 385 acpi_status status;
1da177e4 386
c5fc42ac
BM
387 /* Parameter validation */
388
389 if (!signature || !out_table) {
390 return (AE_BAD_PARAMETER);
391 }
392
f3d2e786
BM
393 /*
394 * Walk the root table list
395 */
396 for (i = 0, j = 0; i < acpi_gbl_root_table_list.count; i++) {
397 if (!ACPI_COMPARE_NAME
398 (&(acpi_gbl_root_table_list.tables[i].signature),
399 signature)) {
400 continue;
401 }
1da177e4 402
f3d2e786
BM
403 if (++j < instance) {
404 continue;
405 }
1da177e4 406
f3d2e786
BM
407 status =
408 acpi_tb_verify_table(&acpi_gbl_root_table_list.tables[i]);
409 if (ACPI_SUCCESS(status)) {
410 *out_table = acpi_gbl_root_table_list.tables[i].pointer;
411 }
f6dd9221 412
ad71860a 413 if (!acpi_gbl_permanent_mmap) {
70c0846e 414 acpi_gbl_root_table_list.tables[i].pointer = NULL;
ad71860a
AS
415 }
416
f3d2e786 417 return (status);
1da177e4
LT
418 }
419
f3d2e786 420 return (AE_NOT_FOUND);
1da177e4
LT
421}
422
f3d2e786 423ACPI_EXPORT_SYMBOL(acpi_get_table)
8313524a 424
1da177e4
LT
425/*******************************************************************************
426 *
f3d2e786 427 * FUNCTION: acpi_get_table_by_index
1da177e4 428 *
f3d2e786
BM
429 * PARAMETERS: table_index - Table index
430 * Table - Where the pointer to the table is returned
1da177e4 431 *
f3d2e786 432 * RETURN: Status and pointer to the table
1da177e4 433 *
f3d2e786 434 * DESCRIPTION: Obtain a table by an index into the global table list.
1da177e4
LT
435 *
436 ******************************************************************************/
1da177e4 437acpi_status
67a119f9 438acpi_get_table_by_index(u32 table_index, struct acpi_table_header **table)
1da177e4 439{
4be44fcd 440 acpi_status status;
1da177e4 441
f3d2e786 442 ACPI_FUNCTION_TRACE(acpi_get_table_by_index);
1da177e4 443
c5fc42ac
BM
444 /* Parameter validation */
445
446 if (!table) {
447 return_ACPI_STATUS(AE_BAD_PARAMETER);
448 }
449
f3d2e786 450 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
1da177e4 451
f3d2e786 452 /* Validate index */
1da177e4 453
f3d2e786
BM
454 if (table_index >= acpi_gbl_root_table_list.count) {
455 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
4be44fcd 456 return_ACPI_STATUS(AE_BAD_PARAMETER);
1da177e4
LT
457 }
458
f3d2e786 459 if (!acpi_gbl_root_table_list.tables[table_index].pointer) {
1da177e4 460
f3d2e786 461 /* Table is not mapped, map it */
1da177e4 462
f3d2e786
BM
463 status =
464 acpi_tb_verify_table(&acpi_gbl_root_table_list.
465 tables[table_index]);
466 if (ACPI_FAILURE(status)) {
467 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
468 return_ACPI_STATUS(status);
469 }
1da177e4
LT
470 }
471
f3d2e786
BM
472 *table = acpi_gbl_root_table_list.tables[table_index].pointer;
473 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
474 return_ACPI_STATUS(AE_OK);
1da177e4
LT
475}
476
f3d2e786 477ACPI_EXPORT_SYMBOL(acpi_get_table_by_index)
1da177e4
LT
478
479/*******************************************************************************
480 *
f3d2e786 481 * FUNCTION: acpi_tb_load_namespace
1da177e4 482 *
f3d2e786 483 * PARAMETERS: None
1da177e4
LT
484 *
485 * RETURN: Status
486 *
f3d2e786
BM
487 * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in
488 * the RSDT/XSDT.
1da177e4
LT
489 *
490 ******************************************************************************/
f3d2e786 491static acpi_status acpi_tb_load_namespace(void)
1da177e4 492{
4be44fcd 493 acpi_status status;
f3d2e786 494 struct acpi_table_header *table;
67a119f9 495 u32 i;
1da177e4 496
f3d2e786 497 ACPI_FUNCTION_TRACE(tb_load_namespace);
1da177e4 498
f3d2e786 499 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
1da177e4 500
f3d2e786
BM
501 /*
502 * Load the namespace. The DSDT is required, but any SSDT and PSDT tables
503 * are optional.
504 */
505 if (!acpi_gbl_root_table_list.count ||
506 !ACPI_COMPARE_NAME(&
507 (acpi_gbl_root_table_list.
508 tables[ACPI_TABLE_INDEX_DSDT].signature),
509 ACPI_SIG_DSDT)
510 ||
511 ACPI_FAILURE(acpi_tb_verify_table
512 (&acpi_gbl_root_table_list.
513 tables[ACPI_TABLE_INDEX_DSDT]))) {
514 status = AE_NO_ACPI_TABLES;
515 goto unlock_and_exit;
1da177e4
LT
516 }
517
f3d2e786
BM
518 /*
519 * Find DSDT table
520 */
521 status =
522 acpi_os_table_override(acpi_gbl_root_table_list.
523 tables[ACPI_TABLE_INDEX_DSDT].pointer,
524 &table);
525 if (ACPI_SUCCESS(status) && table) {
526 /*
527 * DSDT table has been found
528 */
035f994b
BM
529 acpi_tb_delete_table(&acpi_gbl_root_table_list.
530 tables[ACPI_TABLE_INDEX_DSDT]);
f3d2e786
BM
531 acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].pointer =
532 table;
533 acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].length =
534 table->length;
535 acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].flags =
536 ACPI_TABLE_ORIGIN_UNKNOWN;
537
538 ACPI_INFO((AE_INFO, "Table DSDT replaced by host OS"));
539 acpi_tb_print_table_header(0, table);
67effe8f
LB
540
541 if (no_auto_ssdt == 0) {
c21d1e7f 542 printk(KERN_WARNING "ACPI: DSDT override uses original SSDTs unless \"acpi_no_auto_ssdt\"\n");
67effe8f 543 }
1da177e4
LT
544 }
545
f3d2e786
BM
546 status =
547 acpi_tb_verify_table(&acpi_gbl_root_table_list.
548 tables[ACPI_TABLE_INDEX_DSDT]);
549 if (ACPI_FAILURE(status)) {
550
551 /* A valid DSDT is required */
1da177e4 552
f3d2e786
BM
553 status = AE_NO_ACPI_TABLES;
554 goto unlock_and_exit;
1da177e4
LT
555 }
556
f3d2e786 557 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
1da177e4 558
f3d2e786
BM
559 /*
560 * Load and parse tables.
561 */
562 status = acpi_ns_load_table(ACPI_TABLE_INDEX_DSDT, acpi_gbl_root_node);
4be44fcd
LB
563 if (ACPI_FAILURE(status)) {
564 return_ACPI_STATUS(status);
1da177e4
LT
565 }
566
567 /*
f3d2e786 568 * Load any SSDT or PSDT tables. Note: Loop leaves tables locked
1da177e4 569 */
f3d2e786
BM
570 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
571 for (i = 0; i < acpi_gbl_root_table_list.count; ++i) {
572 if ((!ACPI_COMPARE_NAME
573 (&(acpi_gbl_root_table_list.tables[i].signature),
574 ACPI_SIG_SSDT)
575 &&
576 !ACPI_COMPARE_NAME(&
577 (acpi_gbl_root_table_list.tables[i].
578 signature), ACPI_SIG_PSDT))
579 ||
580 ACPI_FAILURE(acpi_tb_verify_table
581 (&acpi_gbl_root_table_list.tables[i]))) {
582 continue;
583 }
584
67effe8f
LB
585 if (no_auto_ssdt) {
586 printk(KERN_WARNING "ACPI: SSDT ignored due to \"acpi_no_auto_ssdt\"\n");
587 continue;
588 }
589
f3d2e786
BM
590 /* Ignore errors while loading tables, get as many as possible */
591
592 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
593 (void)acpi_ns_load_table(i, acpi_gbl_root_node);
594 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
1da177e4
LT
595 }
596
f3d2e786 597 ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI Tables successfully acquired\n"));
1da177e4 598
f3d2e786
BM
599 unlock_and_exit:
600 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
601 return_ACPI_STATUS(status);
602}
52fc0b02 603
f3d2e786
BM
604/*******************************************************************************
605 *
606 * FUNCTION: acpi_load_tables
607 *
608 * PARAMETERS: None
609 *
610 * RETURN: Status
611 *
612 * DESCRIPTION: Load the ACPI tables from the RSDT/XSDT
613 *
614 ******************************************************************************/
44f6c012 615
f3d2e786
BM
616acpi_status acpi_load_tables(void)
617{
618 acpi_status status;
1da177e4 619
f3d2e786 620 ACPI_FUNCTION_TRACE(acpi_load_tables);
1da177e4 621
f3d2e786
BM
622 /*
623 * Load the namespace from the tables
624 */
625 status = acpi_tb_load_namespace();
4be44fcd 626 if (ACPI_FAILURE(status)) {
f3d2e786
BM
627 ACPI_EXCEPTION((AE_INFO, status,
628 "While loading namespace from ACPI tables"));
1da177e4
LT
629 }
630
f3d2e786 631 return_ACPI_STATUS(status);
1da177e4 632}
1da177e4 633
f3d2e786 634ACPI_EXPORT_SYMBOL(acpi_load_tables)
67effe8f
LB
635
636
3e08e2d2
LM
637/*******************************************************************************
638 *
639 * FUNCTION: acpi_install_table_handler
640 *
641 * PARAMETERS: Handler - Table event handler
642 * Context - Value passed to the handler on each event
643 *
644 * RETURN: Status
645 *
646 * DESCRIPTION: Install table event handler
647 *
648 ******************************************************************************/
649acpi_status
650acpi_install_table_handler(acpi_tbl_handler handler, void *context)
651{
652 acpi_status status;
653
654 ACPI_FUNCTION_TRACE(acpi_install_table_handler);
655
656 if (!handler) {
657 return_ACPI_STATUS(AE_BAD_PARAMETER);
658 }
659
660 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
661 if (ACPI_FAILURE(status)) {
662 return_ACPI_STATUS(status);
663 }
664
665 /* Don't allow more than one handler */
666
667 if (acpi_gbl_table_handler) {
668 status = AE_ALREADY_EXISTS;
669 goto cleanup;
670 }
671
672 /* Install the handler */
673
674 acpi_gbl_table_handler = handler;
675 acpi_gbl_table_handler_context = context;
676
677 cleanup:
678 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
679 return_ACPI_STATUS(status);
680}
681
682ACPI_EXPORT_SYMBOL(acpi_install_table_handler)
683
684/*******************************************************************************
685 *
686 * FUNCTION: acpi_remove_table_handler
687 *
688 * PARAMETERS: Handler - Table event handler that was installed
689 * previously.
690 *
691 * RETURN: Status
692 *
693 * DESCRIPTION: Remove table event handler
694 *
695 ******************************************************************************/
696acpi_status acpi_remove_table_handler(acpi_tbl_handler handler)
697{
698 acpi_status status;
699
700 ACPI_FUNCTION_TRACE(acpi_remove_table_handler);
701
702 status = acpi_ut_acquire_mutex(ACPI_MTX_EVENTS);
703 if (ACPI_FAILURE(status)) {
704 return_ACPI_STATUS(status);
705 }
706
707 /* Make sure that the installed handler is the same */
708
709 if (!handler || handler != acpi_gbl_table_handler) {
710 status = AE_BAD_PARAMETER;
711 goto cleanup;
712 }
713
714 /* Remove the handler */
715
716 acpi_gbl_table_handler = NULL;
717
718 cleanup:
719 (void)acpi_ut_release_mutex(ACPI_MTX_EVENTS);
720 return_ACPI_STATUS(status);
721}
722
723ACPI_EXPORT_SYMBOL(acpi_remove_table_handler)
724
725
67effe8f
LB
726static int __init acpi_no_auto_ssdt_setup(char *s) {
727
728 printk(KERN_NOTICE "ACPI: SSDT auto-load disabled\n");
729
730 no_auto_ssdt = 1;
731
732 return 1;
733}
734
735__setup("acpi_no_auto_ssdt", acpi_no_auto_ssdt_setup);
This page took 0.41827 seconds and 5 git commands to generate.