blob: 94544a60640dd276f5302353bbc2bf8a39abfec5 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/******************************************************************************
2 *
3 * Module Name: tbxface - Public interfaces to the ACPI subsystem
4 * ACPI table oriented interfaces
5 *
6 *****************************************************************************/
7
8/*
Bob Moore4a90c7e2006-01-13 16:22:00 -05009 * Copyright (C) 2000 - 2006, R. Byron Moore
Linus Torvalds1da177e2005-04-16 15:20:36 -070010 * 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
Linus Torvalds1da177e2005-04-16 15:20:36 -070045#include <acpi/acpi.h>
46#include <acpi/acnamesp.h>
47#include <acpi/actables.h>
48
Linus Torvalds1da177e2005-04-16 15:20:36 -070049#define _COMPONENT ACPI_TABLES
Len Brown4be44fc2005-08-05 00:44:28 -040050ACPI_MODULE_NAME("tbxface")
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
Bob Mooref3d2e782007-02-02 19:48:18 +030052/* Local prototypes */
53static acpi_status acpi_tb_load_namespace(void);
54
Linus Torvalds1da177e2005-04-16 15:20:36 -070055/*******************************************************************************
56 *
Bob Mooref3d2e782007-02-02 19:48:18 +030057 * FUNCTION: acpi_initialize_tables
58 *
59 * PARAMETERS: initial_table_array - Pointer to an array of pre-allocated
60 * struct acpi_table_desc structures. If NULL, the
61 * array is dynamically allocated.
62 * initial_table_count - Size of initial_table_array, in number of
63 * struct acpi_table_desc structures
64 * allow_realloc - Flag to tell Table Manager if resize of
65 * pre-allocated array is allowed. Ignored
66 * if initial_table_array is NULL.
67 *
68 * RETURN: Status
69 *
70 * DESCRIPTION: Initialize the table manager, get the RSDP and RSDT/XSDT.
71 *
72 * NOTE: Allows static allocation of the initial table array in order
73 * to avoid the use of dynamic memory in confined environments
74 * such as the kernel boot sequence where it may not be available.
75 *
76 * If the host OS memory managers are initialized, use NULL for
77 * initial_table_array, and the table will be dynamically allocated.
78 *
79 ******************************************************************************/
80
Alexey Starikovskiyad71860a2007-02-02 19:48:19 +030081acpi_status __init
Bob Mooref3d2e782007-02-02 19:48:18 +030082acpi_initialize_tables(struct acpi_table_desc *initial_table_array,
83 u32 initial_table_count, u8 allow_resize)
84{
Bob Moorec5fc42a2007-02-02 19:48:19 +030085 acpi_physical_address rsdp_address;
Bob Mooref3d2e782007-02-02 19:48:18 +030086 acpi_status status;
Bob Mooref3d2e782007-02-02 19:48:18 +030087
88 ACPI_FUNCTION_TRACE(acpi_initialize_tables);
89
90 /*
91 * Set up the Root Table Array
92 * Allocate the table array if requested
93 */
94 if (!initial_table_array) {
95 acpi_gbl_root_table_list.size = initial_table_count;
Bob Moorec5fc42a2007-02-02 19:48:19 +030096 acpi_gbl_root_table_list.flags = ACPI_ROOT_ALLOW_RESIZE;
Bob Mooref3d2e782007-02-02 19:48:18 +030097
98 status = acpi_tb_resize_root_table_list();
99 if (ACPI_FAILURE(status)) {
100 return_ACPI_STATUS(status);
101 }
102 } else {
103 /* Root Table Array has been statically allocated by the host */
104
Bob Moorea4bbb812007-02-02 19:48:19 +0300105 ACPI_MEMSET(initial_table_array, 0,
Bob Moorec5fc42a2007-02-02 19:48:19 +0300106 initial_table_count *
Bob Moorea4bbb812007-02-02 19:48:19 +0300107 sizeof(struct acpi_table_desc));
Bob Moorec5fc42a2007-02-02 19:48:19 +0300108
Bob Mooref3d2e782007-02-02 19:48:18 +0300109 acpi_gbl_root_table_list.tables = initial_table_array;
110 acpi_gbl_root_table_list.size = initial_table_count;
Bob Moorec5fc42a2007-02-02 19:48:19 +0300111 acpi_gbl_root_table_list.flags = ACPI_ROOT_ORIGIN_UNKNOWN;
Bob Mooref3d2e782007-02-02 19:48:18 +0300112 if (allow_resize) {
Bob Moorec5fc42a2007-02-02 19:48:19 +0300113 acpi_gbl_root_table_list.flags |=
114 ACPI_ROOT_ALLOW_RESIZE;
Bob Mooref3d2e782007-02-02 19:48:18 +0300115 }
116 }
117
Bob Moorec5fc42a2007-02-02 19:48:19 +0300118 /* Get the address of the RSDP */
Bob Mooref3d2e782007-02-02 19:48:18 +0300119
Bob Moorec5fc42a2007-02-02 19:48:19 +0300120 rsdp_address = acpi_os_get_root_pointer();
121 if (!rsdp_address) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300122 return_ACPI_STATUS(AE_NOT_FOUND);
123 }
124
Bob Mooref3d2e782007-02-02 19:48:18 +0300125 /*
126 * Get the root table (RSDT or XSDT) and extract all entries to the local
127 * Root Table Array. This array contains the information of the RSDT/XSDT
128 * in a common, more useable format.
129 */
Bob Moorec5fc42a2007-02-02 19:48:19 +0300130 status =
131 acpi_tb_parse_root_table(rsdp_address, ACPI_TABLE_ORIGIN_MAPPED);
Bob Mooref3d2e782007-02-02 19:48:18 +0300132 return_ACPI_STATUS(status);
133}
134
Bob Mooref3d2e782007-02-02 19:48:18 +0300135/*******************************************************************************
136 *
137 * FUNCTION: acpi_reallocate_root_table
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 *
139 * PARAMETERS: None
140 *
141 * RETURN: Status
142 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300143 * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the
144 * root list from the previously provided scratch area. Should
145 * be called once dynamic memory allocation is available in the
146 * kernel
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 *
148 ******************************************************************************/
Bob Mooref3d2e782007-02-02 19:48:18 +0300149acpi_status acpi_reallocate_root_table(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150{
Bob Mooref3d2e782007-02-02 19:48:18 +0300151 struct acpi_table_desc *tables;
152 acpi_size new_size;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153
Bob Mooref3d2e782007-02-02 19:48:18 +0300154 ACPI_FUNCTION_TRACE(acpi_reallocate_root_table);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155
Bob Mooref3d2e782007-02-02 19:48:18 +0300156 /*
157 * Only reallocate the root table if the host provided a static buffer
158 * for the table array in the call to acpi_initialize_tables.
159 */
Bob Moorec5fc42a2007-02-02 19:48:19 +0300160 if (acpi_gbl_root_table_list.flags & ACPI_ROOT_ORIGIN_ALLOCATED) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300161 return_ACPI_STATUS(AE_SUPPORT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700162 }
163
Bob Mooref3d2e782007-02-02 19:48:18 +0300164 new_size =
165 (acpi_gbl_root_table_list.count +
166 ACPI_ROOT_TABLE_SIZE_INCREMENT) * sizeof(struct acpi_table_desc);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700167
Bob Mooref3d2e782007-02-02 19:48:18 +0300168 /* Create new array and copy the old array */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169
Bob Mooref3d2e782007-02-02 19:48:18 +0300170 tables = ACPI_ALLOCATE_ZEROED(new_size);
171 if (!tables) {
172 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173 }
174
Bob Mooref3d2e782007-02-02 19:48:18 +0300175 ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables, new_size);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176
Bob Mooref3d2e782007-02-02 19:48:18 +0300177 acpi_gbl_root_table_list.size = acpi_gbl_root_table_list.count;
178 acpi_gbl_root_table_list.tables = tables;
179 acpi_gbl_root_table_list.flags =
Bob Moorec5fc42a2007-02-02 19:48:19 +0300180 ACPI_ROOT_ORIGIN_ALLOCATED | ACPI_ROOT_ALLOW_RESIZE;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181
Len Brown4be44fc2005-08-05 00:44:28 -0400182 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184/*******************************************************************************
185 *
186 * FUNCTION: acpi_load_table
187 *
188 * PARAMETERS: table_ptr - pointer to a buffer containing the entire
189 * table to be loaded
190 *
191 * RETURN: Status
192 *
193 * DESCRIPTION: This function is called to load a table from the caller's
Bob Mooref6dd9222006-07-07 20:44:38 -0400194 * buffer. The buffer must contain an entire ACPI Table including
195 * a valid header. The header fields will be verified, and if it
Linus Torvalds1da177e2005-04-16 15:20:36 -0700196 * is determined that the table is invalid, the call will fail.
197 *
198 ******************************************************************************/
Len Brown4be44fc2005-08-05 00:44:28 -0400199acpi_status acpi_load_table(struct acpi_table_header *table_ptr)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200{
Len Brown4be44fc2005-08-05 00:44:28 -0400201 acpi_status status;
Bob Mooref3d2e782007-02-02 19:48:18 +0300202 acpi_native_uint table_index;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203
Bob Mooref3d2e782007-02-02 19:48:18 +0300204 /*
205 * Install the new table into the local data structures
206 */
207 status = acpi_tb_add_table(table_ptr, &table_index);
Len Brown4be44fc2005-08-05 00:44:28 -0400208 if (ACPI_FAILURE(status)) {
209 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 }
Bob Mooref3d2e782007-02-02 19:48:18 +0300211 status = acpi_ns_load_table(table_index, acpi_gbl_root_node);
Len Brown4be44fc2005-08-05 00:44:28 -0400212 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700213}
214
Bob Moore83135242006-10-03 00:00:00 -0400215ACPI_EXPORT_SYMBOL(acpi_load_table)
216
Bob Mooref3d2e782007-02-02 19:48:18 +0300217/******************************************************************************
218 *
219 * FUNCTION: acpi_get_table_header
220 *
221 * PARAMETERS: Signature - ACPI signature of needed table
222 * Instance - Which instance (for SSDTs)
223 * out_table_header - Where the pointer to the table header
224 * is returned
225 *
226 * RETURN: Status and pointer to mapped table header
227 *
228 * DESCRIPTION: Finds an ACPI table header.
229 *
230 * NOTE: Caller is responsible in unmapping the header with
231 * acpi_os_unmap_memory
232 *
233 *****************************************************************************/
234acpi_status
235acpi_get_table_header(char *signature,
236 acpi_native_uint instance,
237 struct acpi_table_header **out_table_header)
238{
239 acpi_native_uint i;
240 acpi_native_uint j;
241
Bob Moorec5fc42a2007-02-02 19:48:19 +0300242 /* Parameter validation */
243
244 if (!signature || !out_table_header) {
245 return (AE_BAD_PARAMETER);
246 }
247
Bob Mooref3d2e782007-02-02 19:48:18 +0300248 /*
249 * Walk the root table list
250 */
251 for (i = 0, j = 0; i < acpi_gbl_root_table_list.count; i++) {
252 if (!ACPI_COMPARE_NAME
253 (&(acpi_gbl_root_table_list.tables[i].signature),
254 signature)) {
255 continue;
256 }
257
258 if (++j < instance) {
259 continue;
260 }
261
262 *out_table_header =
263 acpi_tb_map(acpi_gbl_root_table_list.tables[i].address,
264 (u32) sizeof(struct acpi_table_header),
265 acpi_gbl_root_table_list.tables[i].
266 flags & ACPI_TABLE_ORIGIN_MASK);
267
Bob Moorec5fc42a2007-02-02 19:48:19 +0300268 if (!(*out_table_header)) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300269 return (AE_NO_MEMORY);
270 }
271
272 return (AE_OK);
273 }
274
275 return (AE_NOT_FOUND);
276}
277
278ACPI_EXPORT_SYMBOL(acpi_get_table_header)
279
280
281/******************************************************************************
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282 *
John Keller0f0fe1a2006-12-19 12:56:19 -0800283 * FUNCTION: acpi_unload_table_id
284 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300285 * PARAMETERS: id - Owner ID of the table to be removed.
John Keller0f0fe1a2006-12-19 12:56:19 -0800286 *
287 * RETURN: Status
288 *
289 * DESCRIPTION: This routine is used to force the unload of a table (by id)
290 *
291 ******************************************************************************/
Bob Mooref3d2e782007-02-02 19:48:18 +0300292acpi_status acpi_unload_table_id(acpi_owner_id id)
John Keller0f0fe1a2006-12-19 12:56:19 -0800293{
Bob Mooref3d2e782007-02-02 19:48:18 +0300294 int i;
295 acpi_status status = AE_NOT_EXIST;
John Keller0f0fe1a2006-12-19 12:56:19 -0800296
297 ACPI_FUNCTION_TRACE(acpi_unload_table);
298
John Keller0f0fe1a2006-12-19 12:56:19 -0800299 /* Find table from the requested type list */
Bob Mooref3d2e782007-02-02 19:48:18 +0300300 for (i = 0; i < acpi_gbl_root_table_list.count; ++i) {
301 if (id != acpi_gbl_root_table_list.tables[i].owner_id) {
302 continue;
303 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700304 /*
Bob Mooref3d2e782007-02-02 19:48:18 +0300305 * Delete all namespace objects owned by this table. Note that these
306 * objects can appear anywhere in the namespace by virtue of the AML
307 * "Scope" operator. Thus, we need to track ownership by an ID, not
308 * simply a position within the hierarchy
309 */
310 acpi_tb_delete_namespace_by_owner(i);
311 acpi_tb_release_owner_id(i);
312 acpi_tb_set_table_loaded_flag(i, FALSE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313 }
Len Brown4be44fc2005-08-05 00:44:28 -0400314 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315}
316
Bob Mooref3d2e782007-02-02 19:48:18 +0300317ACPI_EXPORT_SYMBOL(acpi_unload_table_id)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700318
319/*******************************************************************************
320 *
321 * FUNCTION: acpi_get_table
322 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300323 * PARAMETERS: Signature - ACPI signature of needed table
324 * Instance - Which instance (for SSDTs)
325 * out_table - Where the pointer to the table is returned
Linus Torvalds1da177e2005-04-16 15:20:36 -0700326 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300327 * RETURN: Status and pointer to table
Linus Torvalds1da177e2005-04-16 15:20:36 -0700328 *
Bob Mooref3d2e782007-02-02 19:48:18 +0300329 * DESCRIPTION: Finds and verifies an ACPI table.
330 *
331 *****************************************************************************/
332acpi_status
333acpi_get_table(char *signature,
334 acpi_native_uint instance, struct acpi_table_header ** out_table)
335{
336 acpi_native_uint i;
337 acpi_native_uint j;
338 acpi_status status;
339
Bob Moorec5fc42a2007-02-02 19:48:19 +0300340 /* Parameter validation */
341
342 if (!signature || !out_table) {
343 return (AE_BAD_PARAMETER);
344 }
345
Bob Mooref3d2e782007-02-02 19:48:18 +0300346 /*
347 * Walk the root table list
348 */
349 for (i = 0, j = 0; i < acpi_gbl_root_table_list.count; i++) {
350 if (!ACPI_COMPARE_NAME
351 (&(acpi_gbl_root_table_list.tables[i].signature),
352 signature)) {
353 continue;
354 }
355
356 if (++j < instance) {
357 continue;
358 }
359
360 status =
361 acpi_tb_verify_table(&acpi_gbl_root_table_list.tables[i]);
362 if (ACPI_SUCCESS(status)) {
363 *out_table = acpi_gbl_root_table_list.tables[i].pointer;
364 }
365
Alexey Starikovskiyad71860a2007-02-02 19:48:19 +0300366 if (!acpi_gbl_permanent_mmap) {
367 acpi_gbl_root_table_list.tables[i].pointer = 0;
368 }
369
Bob Mooref3d2e782007-02-02 19:48:18 +0300370 return (status);
371 }
372
373 return (AE_NOT_FOUND);
374}
375
376ACPI_EXPORT_SYMBOL(acpi_get_table)
377
378/*******************************************************************************
379 *
380 * FUNCTION: acpi_get_table_by_index
381 *
382 * PARAMETERS: table_index - Table index
383 * Table - Where the pointer to the table is returned
384 *
385 * RETURN: Status and pointer to the table
386 *
387 * DESCRIPTION: Obtain a table by an index into the global table list.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700388 *
389 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390acpi_status
Bob Mooref3d2e782007-02-02 19:48:18 +0300391acpi_get_table_by_index(acpi_native_uint table_index,
392 struct acpi_table_header ** table)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393{
Len Brown4be44fc2005-08-05 00:44:28 -0400394 acpi_status status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700395
Bob Mooref3d2e782007-02-02 19:48:18 +0300396 ACPI_FUNCTION_TRACE(acpi_get_table_by_index);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700397
Bob Moorec5fc42a2007-02-02 19:48:19 +0300398 /* Parameter validation */
399
400 if (!table) {
401 return_ACPI_STATUS(AE_BAD_PARAMETER);
402 }
403
Bob Mooref3d2e782007-02-02 19:48:18 +0300404 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700405
Bob Mooref3d2e782007-02-02 19:48:18 +0300406 /* Validate index */
407
408 if (table_index >= acpi_gbl_root_table_list.count) {
409 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Len Brown4be44fc2005-08-05 00:44:28 -0400410 return_ACPI_STATUS(AE_BAD_PARAMETER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700411 }
412
Bob Mooref3d2e782007-02-02 19:48:18 +0300413 if (!acpi_gbl_root_table_list.tables[table_index].pointer) {
414
415 /* Table is not mapped, map it */
416
417 status =
418 acpi_tb_verify_table(&acpi_gbl_root_table_list.
419 tables[table_index]);
420 if (ACPI_FAILURE(status)) {
421 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
422 return_ACPI_STATUS(status);
423 }
424 }
425
426 *table = acpi_gbl_root_table_list.tables[table_index].pointer;
427 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
428 return_ACPI_STATUS(AE_OK);
429}
430
431ACPI_EXPORT_SYMBOL(acpi_get_table_by_index)
432
433/*******************************************************************************
434 *
435 * FUNCTION: acpi_tb_load_namespace
436 *
437 * PARAMETERS: None
438 *
439 * RETURN: Status
440 *
441 * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in
442 * the RSDT/XSDT.
443 *
444 ******************************************************************************/
445static acpi_status acpi_tb_load_namespace(void)
446{
447 acpi_status status;
448 struct acpi_table_header *table;
449 acpi_native_uint i;
450
451 ACPI_FUNCTION_TRACE(tb_load_namespace);
452
453 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
454
455 /*
456 * Load the namespace. The DSDT is required, but any SSDT and PSDT tables
457 * are optional.
458 */
459 if (!acpi_gbl_root_table_list.count ||
460 !ACPI_COMPARE_NAME(&
461 (acpi_gbl_root_table_list.
462 tables[ACPI_TABLE_INDEX_DSDT].signature),
463 ACPI_SIG_DSDT)
464 ||
465 ACPI_FAILURE(acpi_tb_verify_table
466 (&acpi_gbl_root_table_list.
467 tables[ACPI_TABLE_INDEX_DSDT]))) {
468 status = AE_NO_ACPI_TABLES;
469 goto unlock_and_exit;
470 }
471
472 /*
473 * Find DSDT table
474 */
475 status =
476 acpi_os_table_override(acpi_gbl_root_table_list.
477 tables[ACPI_TABLE_INDEX_DSDT].pointer,
478 &table);
479 if (ACPI_SUCCESS(status) && table) {
480 /*
481 * DSDT table has been found
482 */
483 acpi_tb_delete_table(ACPI_TABLE_INDEX_DSDT);
484 acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].pointer =
485 table;
486 acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].length =
487 table->length;
488 acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].flags =
489 ACPI_TABLE_ORIGIN_UNKNOWN;
490
491 ACPI_INFO((AE_INFO, "Table DSDT replaced by host OS"));
492 acpi_tb_print_table_header(0, table);
493 }
494
495 status =
496 acpi_tb_verify_table(&acpi_gbl_root_table_list.
497 tables[ACPI_TABLE_INDEX_DSDT]);
Len Brown4be44fc2005-08-05 00:44:28 -0400498 if (ACPI_FAILURE(status)) {
Bob Mooref3d2e782007-02-02 19:48:18 +0300499
500 /* A valid DSDT is required */
501
502 status = AE_NO_ACPI_TABLES;
503 goto unlock_and_exit;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700504 }
505
Bob Mooref3d2e782007-02-02 19:48:18 +0300506 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507
Bob Mooref3d2e782007-02-02 19:48:18 +0300508 /*
509 * Load and parse tables.
510 */
511 status = acpi_ns_load_table(ACPI_TABLE_INDEX_DSDT, acpi_gbl_root_node);
Len Brown4be44fc2005-08-05 00:44:28 -0400512 if (ACPI_FAILURE(status)) {
513 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514 }
515
516 /*
Bob Mooref3d2e782007-02-02 19:48:18 +0300517 * Load any SSDT or PSDT tables. Note: Loop leaves tables locked
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518 */
Bob Mooref3d2e782007-02-02 19:48:18 +0300519 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
520 for (i = 0; i < acpi_gbl_root_table_list.count; ++i) {
521 if ((!ACPI_COMPARE_NAME
522 (&(acpi_gbl_root_table_list.tables[i].signature),
523 ACPI_SIG_SSDT)
524 &&
525 !ACPI_COMPARE_NAME(&
526 (acpi_gbl_root_table_list.tables[i].
527 signature), ACPI_SIG_PSDT))
528 ||
529 ACPI_FAILURE(acpi_tb_verify_table
530 (&acpi_gbl_root_table_list.tables[i]))) {
531 continue;
532 }
533
534 /* Ignore errors while loading tables, get as many as possible */
535
536 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
537 (void)acpi_ns_load_table(i, acpi_gbl_root_node);
538 (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539 }
540
Bob Mooref3d2e782007-02-02 19:48:18 +0300541 ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI Tables successfully acquired\n"));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700542
Bob Mooref3d2e782007-02-02 19:48:18 +0300543 unlock_and_exit:
544 (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
545 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700546}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700547
Bob Mooref3d2e782007-02-02 19:48:18 +0300548/*******************************************************************************
549 *
550 * FUNCTION: acpi_load_tables
551 *
552 * PARAMETERS: None
553 *
554 * RETURN: Status
555 *
556 * DESCRIPTION: Load the ACPI tables from the RSDT/XSDT
557 *
558 ******************************************************************************/
559
560acpi_status acpi_load_tables(void)
561{
562 acpi_status status;
563
564 ACPI_FUNCTION_TRACE(acpi_load_tables);
565
566 /*
567 * Load the namespace from the tables
568 */
569 status = acpi_tb_load_namespace();
570 if (ACPI_FAILURE(status)) {
571 ACPI_EXCEPTION((AE_INFO, status,
572 "While loading namespace from ACPI tables"));
573 }
574
575 return_ACPI_STATUS(status);
576}
577
578ACPI_EXPORT_SYMBOL(acpi_load_tables)