Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /****************************************************************************** |
2 | * | |
3 | * Module Name: tbxface - Public interfaces to the ACPI subsystem | |
4 | * ACPI table oriented interfaces | |
5 | * | |
6 | *****************************************************************************/ | |
7 | ||
8 | /* | |
4a90c7e8 | 9 | * Copyright (C) 2000 - 2006, R. Byron Moore |
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 LT |
45 | #include <acpi/acpi.h> |
46 | #include <acpi/acnamesp.h> | |
47 | #include <acpi/actables.h> | |
48 | ||
1da177e4 | 49 | #define _COMPONENT ACPI_TABLES |
4be44fcd | 50 | ACPI_MODULE_NAME("tbxface") |
1da177e4 | 51 | |
f3d2e786 BM |
52 | /* Local prototypes */ |
53 | static acpi_status acpi_tb_load_namespace(void); | |
54 | ||
1da177e4 LT |
55 | /******************************************************************************* |
56 | * | |
f3d2e786 | 57 | * FUNCTION: acpi_initialize_tables |
1da177e4 | 58 | * |
f3d2e786 BM |
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. | |
1da177e4 LT |
67 | * |
68 | * RETURN: Status | |
69 | * | |
f3d2e786 BM |
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. | |
1da177e4 LT |
78 | * |
79 | ******************************************************************************/ | |
f3d2e786 BM |
80 | |
81 | acpi_status | |
82 | acpi_initialize_tables(struct acpi_table_desc *initial_table_array, | |
83 | u32 initial_table_count, u8 allow_resize) | |
1da177e4 | 84 | { |
f3d2e786 | 85 | acpi_physical_address address; |
4be44fcd | 86 | acpi_status status; |
f3d2e786 | 87 | struct acpi_table_rsdp *rsdp; |
1da177e4 | 88 | |
f3d2e786 | 89 | ACPI_FUNCTION_TRACE(acpi_initialize_tables); |
1da177e4 | 90 | |
f3d2e786 BM |
91 | /* |
92 | * Set up the Root Table Array | |
93 | * Allocate the table array if requested | |
94 | */ | |
95 | if (!initial_table_array) { | |
96 | acpi_gbl_root_table_list.size = initial_table_count; | |
97 | acpi_gbl_root_table_list.flags = ACPI_TABLE_FLAGS_ALLOW_RESIZE; | |
1da177e4 | 98 | |
f3d2e786 BM |
99 | status = acpi_tb_resize_root_table_list(); |
100 | if (ACPI_FAILURE(status)) { | |
101 | return_ACPI_STATUS(status); | |
102 | } | |
103 | } else { | |
104 | /* Root Table Array has been statically allocated by the host */ | |
105 | ||
106 | acpi_gbl_root_table_list.tables = initial_table_array; | |
107 | acpi_gbl_root_table_list.size = initial_table_count; | |
108 | acpi_gbl_root_table_list.flags = ACPI_TABLE_ORIGIN_UNKNOWN; | |
109 | if (allow_resize) { | |
110 | acpi_gbl_root_table_list.flags = | |
111 | ACPI_TABLE_FLAGS_ALLOW_RESIZE; | |
112 | } | |
1da177e4 LT |
113 | } |
114 | ||
f3d2e786 | 115 | /* Get the RSDP and map it */ |
1da177e4 | 116 | |
f3d2e786 BM |
117 | address = acpi_os_get_root_pointer(); |
118 | if (!address) { | |
119 | return_ACPI_STATUS(AE_NOT_FOUND); | |
120 | } | |
1da177e4 | 121 | |
f3d2e786 BM |
122 | rsdp = acpi_os_map_memory(address, sizeof(struct acpi_table_rsdp)); |
123 | if (!rsdp) { | |
124 | return_ACPI_STATUS(AE_NO_MEMORY); | |
1da177e4 LT |
125 | } |
126 | ||
f3d2e786 BM |
127 | ACPI_INFO((AE_INFO, "%.8s @ 0x%p", |
128 | rsdp->signature, ACPI_CAST_PTR(void, address))); | |
1da177e4 | 129 | |
f3d2e786 BM |
130 | /* |
131 | * Get the root table (RSDT or XSDT) and extract all entries to the local | |
132 | * Root Table Array. This array contains the information of the RSDT/XSDT | |
133 | * in a common, more useable format. | |
134 | */ | |
135 | status = acpi_tb_parse_root_table(rsdp, ACPI_TABLE_ORIGIN_MAPPED); | |
136 | acpi_os_unmap_memory(rsdp, sizeof(struct acpi_table_rsdp)); | |
137 | return_ACPI_STATUS(status); | |
138 | } | |
1da177e4 | 139 | |
f3d2e786 | 140 | ACPI_EXPORT_SYMBOL(acpi_initialize_tables) |
1da177e4 | 141 | |
f3d2e786 BM |
142 | /******************************************************************************* |
143 | * | |
144 | * FUNCTION: acpi_reallocate_root_table | |
145 | * | |
146 | * PARAMETERS: None | |
147 | * | |
148 | * RETURN: Status | |
149 | * | |
150 | * DESCRIPTION: Reallocate Root Table List into dynamic memory. Copies the | |
151 | * root list from the previously provided scratch area. Should | |
152 | * be called once dynamic memory allocation is available in the | |
153 | * kernel | |
154 | * | |
155 | ******************************************************************************/ | |
156 | acpi_status acpi_reallocate_root_table(void) | |
157 | { | |
158 | struct acpi_table_desc *tables; | |
159 | acpi_size new_size; | |
160 | ||
161 | ACPI_FUNCTION_TRACE(acpi_reallocate_root_table); | |
162 | ||
163 | /* | |
164 | * Only reallocate the root table if the host provided a static buffer | |
165 | * for the table array in the call to acpi_initialize_tables. | |
166 | */ | |
167 | if ((acpi_gbl_root_table_list.flags & ACPI_TABLE_ORIGIN_MASK) != | |
168 | ACPI_TABLE_ORIGIN_UNKNOWN) { | |
169 | return_ACPI_STATUS(AE_SUPPORT); | |
1da177e4 LT |
170 | } |
171 | ||
f3d2e786 BM |
172 | new_size = |
173 | (acpi_gbl_root_table_list.count + | |
174 | ACPI_ROOT_TABLE_SIZE_INCREMENT) * sizeof(struct acpi_table_desc); | |
1da177e4 | 175 | |
f3d2e786 | 176 | /* Create new array and copy the old array */ |
1da177e4 | 177 | |
f3d2e786 BM |
178 | tables = ACPI_ALLOCATE_ZEROED(new_size); |
179 | if (!tables) { | |
180 | return_ACPI_STATUS(AE_NO_MEMORY); | |
1da177e4 LT |
181 | } |
182 | ||
f3d2e786 | 183 | ACPI_MEMCPY(tables, acpi_gbl_root_table_list.tables, new_size); |
1da177e4 | 184 | |
f3d2e786 BM |
185 | acpi_gbl_root_table_list.size = acpi_gbl_root_table_list.count; |
186 | acpi_gbl_root_table_list.tables = tables; | |
187 | acpi_gbl_root_table_list.flags = | |
188 | ACPI_TABLE_ORIGIN_ALLOCATED | ACPI_TABLE_FLAGS_ALLOW_RESIZE; | |
8313524a | 189 | |
f3d2e786 BM |
190 | return_ACPI_STATUS(AE_OK); |
191 | } | |
1da177e4 LT |
192 | /******************************************************************************* |
193 | * | |
194 | * FUNCTION: acpi_load_table | |
195 | * | |
196 | * PARAMETERS: table_ptr - pointer to a buffer containing the entire | |
197 | * table to be loaded | |
198 | * | |
199 | * RETURN: Status | |
200 | * | |
201 | * DESCRIPTION: This function is called to load a table from the caller's | |
f6dd9221 BM |
202 | * buffer. The buffer must contain an entire ACPI Table including |
203 | * a valid header. The header fields will be verified, and if it | |
1da177e4 LT |
204 | * is determined that the table is invalid, the call will fail. |
205 | * | |
206 | ******************************************************************************/ | |
4be44fcd | 207 | acpi_status acpi_load_table(struct acpi_table_header *table_ptr) |
1da177e4 | 208 | { |
4be44fcd | 209 | acpi_status status; |
f3d2e786 | 210 | acpi_native_uint table_index; |
1da177e4 | 211 | |
f3d2e786 BM |
212 | /* |
213 | * Install the new table into the local data structures | |
214 | */ | |
215 | status = acpi_tb_add_table(table_ptr, &table_index); | |
4be44fcd LB |
216 | if (ACPI_FAILURE(status)) { |
217 | return_ACPI_STATUS(status); | |
0c9938cc | 218 | } |
f3d2e786 BM |
219 | status = acpi_ns_load_table(table_index, acpi_gbl_root_node); |
220 | return_ACPI_STATUS(status); | |
221 | } | |
0c9938cc | 222 | |
f3d2e786 | 223 | ACPI_EXPORT_SYMBOL(acpi_load_table) |
52fc0b02 | 224 | |
f3d2e786 BM |
225 | /****************************************************************************** |
226 | * | |
227 | * FUNCTION: acpi_get_table_header | |
228 | * | |
229 | * PARAMETERS: Signature - ACPI signature of needed table | |
230 | * Instance - Which instance (for SSDTs) | |
231 | * out_table_header - Where the pointer to the table header | |
232 | * is returned | |
233 | * | |
234 | * RETURN: Status and pointer to mapped table header | |
235 | * | |
236 | * DESCRIPTION: Finds an ACPI table header. | |
237 | * | |
238 | * NOTE: Caller is responsible in unmapping the header with | |
239 | * acpi_os_unmap_memory | |
240 | * | |
241 | *****************************************************************************/ | |
242 | acpi_status | |
243 | acpi_get_table_header(char *signature, | |
244 | acpi_native_uint instance, | |
245 | struct acpi_table_header **out_table_header) | |
246 | { | |
247 | acpi_native_uint i; | |
248 | acpi_native_uint j; | |
0c9938cc | 249 | |
f3d2e786 BM |
250 | /* |
251 | * Walk the root table list | |
252 | */ | |
253 | for (i = 0, j = 0; i < acpi_gbl_root_table_list.count; i++) { | |
254 | if (!ACPI_COMPARE_NAME | |
255 | (&(acpi_gbl_root_table_list.tables[i].signature), | |
256 | signature)) { | |
257 | continue; | |
0c9938cc RM |
258 | } |
259 | ||
f3d2e786 BM |
260 | if (++j < instance) { |
261 | continue; | |
262 | } | |
1da177e4 | 263 | |
f3d2e786 BM |
264 | *out_table_header = |
265 | acpi_tb_map(acpi_gbl_root_table_list.tables[i].address, | |
266 | (u32) sizeof(struct acpi_table_header), | |
267 | acpi_gbl_root_table_list.tables[i]. | |
268 | flags & ACPI_TABLE_ORIGIN_MASK); | |
52fc0b02 | 269 | |
f3d2e786 BM |
270 | if (!out_table_header) { |
271 | return (AE_NO_MEMORY); | |
272 | } | |
1da177e4 | 273 | |
f3d2e786 | 274 | return (AE_OK); |
1da177e4 LT |
275 | } |
276 | ||
f3d2e786 | 277 | return (AE_NOT_FOUND); |
1da177e4 LT |
278 | } |
279 | ||
f3d2e786 | 280 | ACPI_EXPORT_SYMBOL(acpi_get_table_header) |
8313524a | 281 | |
f3d2e786 BM |
282 | |
283 | /****************************************************************************** | |
0f0fe1a0 JK |
284 | * |
285 | * FUNCTION: acpi_unload_table_id | |
286 | * | |
f3d2e786 | 287 | * PARAMETERS: id - Owner ID of the table to be removed. |
0f0fe1a0 JK |
288 | * |
289 | * RETURN: Status | |
290 | * | |
291 | * DESCRIPTION: This routine is used to force the unload of a table (by id) | |
292 | * | |
293 | ******************************************************************************/ | |
f3d2e786 | 294 | acpi_status acpi_unload_table_id(acpi_owner_id id) |
0f0fe1a0 | 295 | { |
f3d2e786 BM |
296 | int i; |
297 | acpi_status status = AE_NOT_EXIST; | |
0f0fe1a0 JK |
298 | |
299 | ACPI_FUNCTION_TRACE(acpi_unload_table); | |
300 | ||
0f0fe1a0 | 301 | /* Find table from the requested type list */ |
f3d2e786 BM |
302 | for (i = 0; i < acpi_gbl_root_table_list.count; ++i) { |
303 | if (id != acpi_gbl_root_table_list.tables[i].owner_id) { | |
304 | continue; | |
305 | } | |
306 | /* | |
307 | * Delete all namespace objects owned by this table. Note that these | |
308 | * objects can appear anywhere in the namespace by virtue of the AML | |
309 | * "Scope" operator. Thus, we need to track ownership by an ID, not | |
310 | * simply a position within the hierarchy | |
311 | */ | |
312 | acpi_tb_delete_namespace_by_owner(i); | |
313 | acpi_tb_release_owner_id(i); | |
314 | acpi_tb_set_table_loaded_flag(i, FALSE); | |
315 | } | |
316 | return_ACPI_STATUS(status); | |
0f0fe1a0 JK |
317 | } |
318 | ||
319 | ACPI_EXPORT_SYMBOL(acpi_unload_table_id) | |
320 | ||
1da177e4 LT |
321 | /******************************************************************************* |
322 | * | |
f3d2e786 | 323 | * FUNCTION: acpi_get_table |
1da177e4 | 324 | * |
f3d2e786 BM |
325 | * PARAMETERS: Signature - ACPI signature of needed table |
326 | * Instance - Which instance (for SSDTs) | |
327 | * out_table - Where the pointer to the table is returned | |
1da177e4 | 328 | * |
f3d2e786 | 329 | * RETURN: Status and pointer to table |
1da177e4 | 330 | * |
f3d2e786 | 331 | * DESCRIPTION: Finds and verifies an ACPI table. |
1da177e4 | 332 | * |
f3d2e786 BM |
333 | *****************************************************************************/ |
334 | acpi_status | |
335 | acpi_get_table(char *signature, | |
336 | acpi_native_uint instance, struct acpi_table_header ** out_table) | |
1da177e4 | 337 | { |
f3d2e786 BM |
338 | acpi_native_uint i; |
339 | acpi_native_uint j; | |
340 | acpi_status status; | |
1da177e4 | 341 | |
f3d2e786 BM |
342 | /* |
343 | * Walk the root table list | |
344 | */ | |
345 | for (i = 0, j = 0; i < acpi_gbl_root_table_list.count; i++) { | |
346 | if (!ACPI_COMPARE_NAME | |
347 | (&(acpi_gbl_root_table_list.tables[i].signature), | |
348 | signature)) { | |
349 | continue; | |
350 | } | |
1da177e4 | 351 | |
f3d2e786 BM |
352 | if (++j < instance) { |
353 | continue; | |
354 | } | |
1da177e4 | 355 | |
f3d2e786 BM |
356 | status = |
357 | acpi_tb_verify_table(&acpi_gbl_root_table_list.tables[i]); | |
358 | if (ACPI_SUCCESS(status)) { | |
359 | *out_table = acpi_gbl_root_table_list.tables[i].pointer; | |
360 | } | |
f6dd9221 | 361 | |
f3d2e786 | 362 | return (status); |
1da177e4 LT |
363 | } |
364 | ||
f3d2e786 | 365 | return (AE_NOT_FOUND); |
1da177e4 LT |
366 | } |
367 | ||
f3d2e786 | 368 | ACPI_EXPORT_SYMBOL(acpi_get_table) |
8313524a | 369 | |
1da177e4 LT |
370 | /******************************************************************************* |
371 | * | |
f3d2e786 | 372 | * FUNCTION: acpi_get_table_by_index |
1da177e4 | 373 | * |
f3d2e786 BM |
374 | * PARAMETERS: table_index - Table index |
375 | * Table - Where the pointer to the table is returned | |
1da177e4 | 376 | * |
f3d2e786 | 377 | * RETURN: Status and pointer to the table |
1da177e4 | 378 | * |
f3d2e786 | 379 | * DESCRIPTION: Obtain a table by an index into the global table list. |
1da177e4 LT |
380 | * |
381 | ******************************************************************************/ | |
1da177e4 | 382 | acpi_status |
f3d2e786 BM |
383 | acpi_get_table_by_index(acpi_native_uint table_index, |
384 | struct acpi_table_header ** table) | |
1da177e4 | 385 | { |
4be44fcd | 386 | acpi_status status; |
1da177e4 | 387 | |
f3d2e786 | 388 | ACPI_FUNCTION_TRACE(acpi_get_table_by_index); |
1da177e4 | 389 | |
f3d2e786 | 390 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
1da177e4 | 391 | |
f3d2e786 | 392 | /* Validate index */ |
1da177e4 | 393 | |
f3d2e786 BM |
394 | if (table_index >= acpi_gbl_root_table_list.count) { |
395 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | |
4be44fcd | 396 | return_ACPI_STATUS(AE_BAD_PARAMETER); |
1da177e4 LT |
397 | } |
398 | ||
f3d2e786 | 399 | if (!acpi_gbl_root_table_list.tables[table_index].pointer) { |
1da177e4 | 400 | |
f3d2e786 | 401 | /* Table is not mapped, map it */ |
1da177e4 | 402 | |
f3d2e786 BM |
403 | status = |
404 | acpi_tb_verify_table(&acpi_gbl_root_table_list. | |
405 | tables[table_index]); | |
406 | if (ACPI_FAILURE(status)) { | |
407 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | |
408 | return_ACPI_STATUS(status); | |
409 | } | |
1da177e4 LT |
410 | } |
411 | ||
f3d2e786 BM |
412 | *table = acpi_gbl_root_table_list.tables[table_index].pointer; |
413 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | |
414 | return_ACPI_STATUS(AE_OK); | |
1da177e4 LT |
415 | } |
416 | ||
f3d2e786 | 417 | ACPI_EXPORT_SYMBOL(acpi_get_table_by_index) |
1da177e4 LT |
418 | |
419 | /******************************************************************************* | |
420 | * | |
f3d2e786 | 421 | * FUNCTION: acpi_tb_load_namespace |
1da177e4 | 422 | * |
f3d2e786 | 423 | * PARAMETERS: None |
1da177e4 LT |
424 | * |
425 | * RETURN: Status | |
426 | * | |
f3d2e786 BM |
427 | * DESCRIPTION: Load the namespace from the DSDT and all SSDTs/PSDTs found in |
428 | * the RSDT/XSDT. | |
1da177e4 LT |
429 | * |
430 | ******************************************************************************/ | |
f3d2e786 | 431 | static acpi_status acpi_tb_load_namespace(void) |
1da177e4 | 432 | { |
4be44fcd | 433 | acpi_status status; |
f3d2e786 BM |
434 | struct acpi_table_header *table; |
435 | acpi_native_uint i; | |
1da177e4 | 436 | |
f3d2e786 | 437 | ACPI_FUNCTION_TRACE(tb_load_namespace); |
1da177e4 | 438 | |
f3d2e786 | 439 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
1da177e4 | 440 | |
f3d2e786 BM |
441 | /* |
442 | * Load the namespace. The DSDT is required, but any SSDT and PSDT tables | |
443 | * are optional. | |
444 | */ | |
445 | if (!acpi_gbl_root_table_list.count || | |
446 | !ACPI_COMPARE_NAME(& | |
447 | (acpi_gbl_root_table_list. | |
448 | tables[ACPI_TABLE_INDEX_DSDT].signature), | |
449 | ACPI_SIG_DSDT) | |
450 | || | |
451 | ACPI_FAILURE(acpi_tb_verify_table | |
452 | (&acpi_gbl_root_table_list. | |
453 | tables[ACPI_TABLE_INDEX_DSDT]))) { | |
454 | status = AE_NO_ACPI_TABLES; | |
455 | goto unlock_and_exit; | |
1da177e4 LT |
456 | } |
457 | ||
f3d2e786 BM |
458 | /* |
459 | * Find DSDT table | |
460 | */ | |
461 | status = | |
462 | acpi_os_table_override(acpi_gbl_root_table_list. | |
463 | tables[ACPI_TABLE_INDEX_DSDT].pointer, | |
464 | &table); | |
465 | if (ACPI_SUCCESS(status) && table) { | |
466 | /* | |
467 | * DSDT table has been found | |
468 | */ | |
469 | acpi_tb_delete_table(ACPI_TABLE_INDEX_DSDT); | |
470 | acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].pointer = | |
471 | table; | |
472 | acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].length = | |
473 | table->length; | |
474 | acpi_gbl_root_table_list.tables[ACPI_TABLE_INDEX_DSDT].flags = | |
475 | ACPI_TABLE_ORIGIN_UNKNOWN; | |
476 | ||
477 | ACPI_INFO((AE_INFO, "Table DSDT replaced by host OS")); | |
478 | acpi_tb_print_table_header(0, table); | |
1da177e4 LT |
479 | } |
480 | ||
f3d2e786 BM |
481 | status = |
482 | acpi_tb_verify_table(&acpi_gbl_root_table_list. | |
483 | tables[ACPI_TABLE_INDEX_DSDT]); | |
484 | if (ACPI_FAILURE(status)) { | |
485 | ||
486 | /* A valid DSDT is required */ | |
1da177e4 | 487 | |
f3d2e786 BM |
488 | status = AE_NO_ACPI_TABLES; |
489 | goto unlock_and_exit; | |
1da177e4 LT |
490 | } |
491 | ||
f3d2e786 | 492 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); |
1da177e4 | 493 | |
f3d2e786 BM |
494 | /* |
495 | * Load and parse tables. | |
496 | */ | |
497 | status = acpi_ns_load_table(ACPI_TABLE_INDEX_DSDT, acpi_gbl_root_node); | |
4be44fcd LB |
498 | if (ACPI_FAILURE(status)) { |
499 | return_ACPI_STATUS(status); | |
1da177e4 LT |
500 | } |
501 | ||
502 | /* | |
f3d2e786 | 503 | * Load any SSDT or PSDT tables. Note: Loop leaves tables locked |
1da177e4 | 504 | */ |
f3d2e786 BM |
505 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); |
506 | for (i = 0; i < acpi_gbl_root_table_list.count; ++i) { | |
507 | if ((!ACPI_COMPARE_NAME | |
508 | (&(acpi_gbl_root_table_list.tables[i].signature), | |
509 | ACPI_SIG_SSDT) | |
510 | && | |
511 | !ACPI_COMPARE_NAME(& | |
512 | (acpi_gbl_root_table_list.tables[i]. | |
513 | signature), ACPI_SIG_PSDT)) | |
514 | || | |
515 | ACPI_FAILURE(acpi_tb_verify_table | |
516 | (&acpi_gbl_root_table_list.tables[i]))) { | |
517 | continue; | |
518 | } | |
519 | ||
520 | /* Ignore errors while loading tables, get as many as possible */ | |
521 | ||
522 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | |
523 | (void)acpi_ns_load_table(i, acpi_gbl_root_node); | |
524 | (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES); | |
1da177e4 LT |
525 | } |
526 | ||
f3d2e786 | 527 | ACPI_DEBUG_PRINT((ACPI_DB_INIT, "ACPI Tables successfully acquired\n")); |
1da177e4 | 528 | |
f3d2e786 BM |
529 | unlock_and_exit: |
530 | (void)acpi_ut_release_mutex(ACPI_MTX_TABLES); | |
531 | return_ACPI_STATUS(status); | |
532 | } | |
52fc0b02 | 533 | |
f3d2e786 BM |
534 | /******************************************************************************* |
535 | * | |
536 | * FUNCTION: acpi_load_tables | |
537 | * | |
538 | * PARAMETERS: None | |
539 | * | |
540 | * RETURN: Status | |
541 | * | |
542 | * DESCRIPTION: Load the ACPI tables from the RSDT/XSDT | |
543 | * | |
544 | ******************************************************************************/ | |
44f6c012 | 545 | |
f3d2e786 BM |
546 | acpi_status acpi_load_tables(void) |
547 | { | |
548 | acpi_status status; | |
1da177e4 | 549 | |
f3d2e786 | 550 | ACPI_FUNCTION_TRACE(acpi_load_tables); |
1da177e4 | 551 | |
f3d2e786 BM |
552 | /* |
553 | * Load the namespace from the tables | |
554 | */ | |
555 | status = acpi_tb_load_namespace(); | |
4be44fcd | 556 | if (ACPI_FAILURE(status)) { |
f3d2e786 BM |
557 | ACPI_EXCEPTION((AE_INFO, status, |
558 | "While loading namespace from ACPI tables")); | |
1da177e4 LT |
559 | } |
560 | ||
f3d2e786 | 561 | return_ACPI_STATUS(status); |
1da177e4 | 562 | } |
1da177e4 | 563 | |
f3d2e786 | 564 | ACPI_EXPORT_SYMBOL(acpi_load_tables) |