[TG3]: Set minimal hw interrupt mitigation.
[linux-2.6/verdex.git] / drivers / acpi / namespace / nsload.c
blob1d7aedf68a7787b7d2947bffc1480dfe5aea8735
1 /******************************************************************************
3 * Module Name: nsload - namespace loading/expanding/contracting procedures
5 *****************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2005, R. Byron Moore
9 * All rights reserved.
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.
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.
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.
45 #include <acpi/acpi.h>
46 #include <acpi/acnamesp.h>
47 #include <acpi/acdispat.h>
50 #define _COMPONENT ACPI_NAMESPACE
51 ACPI_MODULE_NAME ("nsload")
54 #ifndef ACPI_NO_METHOD_EXECUTION
56 /*******************************************************************************
58 * FUNCTION: acpi_ns_load_table
60 * PARAMETERS: table_desc - Descriptor for table to be loaded
61 * Node - Owning NS node
63 * RETURN: Status
65 * DESCRIPTION: Load one ACPI table into the namespace
67 ******************************************************************************/
69 acpi_status
70 acpi_ns_load_table (
71 struct acpi_table_desc *table_desc,
72 struct acpi_namespace_node *node)
74 acpi_status status;
77 ACPI_FUNCTION_TRACE ("ns_load_table");
80 /* Check if table contains valid AML (must be DSDT, PSDT, SSDT, etc.) */
82 if (!(acpi_gbl_table_data[table_desc->type].flags & ACPI_TABLE_EXECUTABLE)) {
83 /* Just ignore this table */
85 return_ACPI_STATUS (AE_OK);
88 /* Check validity of the AML start and length */
90 if (!table_desc->aml_start) {
91 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Null AML pointer\n"));
92 return_ACPI_STATUS (AE_BAD_PARAMETER);
95 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "AML block at %p\n",
96 table_desc->aml_start));
98 /* Ignore table if there is no AML contained within */
100 if (!table_desc->aml_length) {
101 ACPI_REPORT_WARNING (("Zero-length AML block in table [%4.4s]\n",
102 table_desc->pointer->signature));
103 return_ACPI_STATUS (AE_OK);
107 * Parse the table and load the namespace with all named
108 * objects found within. Control methods are NOT parsed
109 * at this time. In fact, the control methods cannot be
110 * parsed until the entire namespace is loaded, because
111 * if a control method makes a forward reference (call)
112 * to another control method, we can't continue parsing
113 * because we don't know how many arguments to parse next!
115 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
116 "**** Loading table into namespace ****\n"));
118 status = acpi_ut_acquire_mutex (ACPI_MTX_NAMESPACE);
119 if (ACPI_FAILURE (status)) {
120 return_ACPI_STATUS (status);
123 status = acpi_ns_parse_table (table_desc, node->child);
124 (void) acpi_ut_release_mutex (ACPI_MTX_NAMESPACE);
126 if (ACPI_FAILURE (status)) {
127 return_ACPI_STATUS (status);
131 * Now we can parse the control methods. We always parse
132 * them here for a sanity check, and if configured for
133 * just-in-time parsing, we delete the control method
134 * parse trees.
136 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
137 "**** Begin Table Method Parsing and Object Initialization ****\n"));
139 status = acpi_ds_initialize_objects (table_desc, node);
141 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
142 "**** Completed Table Method Parsing and Object Initialization ****\n"));
144 return_ACPI_STATUS (status);
148 /*******************************************************************************
150 * FUNCTION: acpi_ns_load_table_by_type
152 * PARAMETERS: table_type - Id of the table type to load
154 * RETURN: Status
156 * DESCRIPTION: Load an ACPI table or tables into the namespace. All tables
157 * of the given type are loaded. The mechanism allows this
158 * routine to be called repeatedly.
160 ******************************************************************************/
162 acpi_status
163 acpi_ns_load_table_by_type (
164 acpi_table_type table_type)
166 u32 i;
167 acpi_status status;
168 struct acpi_table_desc *table_desc;
171 ACPI_FUNCTION_TRACE ("ns_load_table_by_type");
174 status = acpi_ut_acquire_mutex (ACPI_MTX_TABLES);
175 if (ACPI_FAILURE (status)) {
176 return_ACPI_STATUS (status);
180 * Table types supported are:
181 * DSDT (one), SSDT/PSDT (multiple)
183 switch (table_type) {
184 case ACPI_TABLE_DSDT:
186 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Loading DSDT\n"));
188 table_desc = acpi_gbl_table_lists[ACPI_TABLE_DSDT].next;
190 /* If table already loaded into namespace, just return */
192 if (table_desc->loaded_into_namespace) {
193 goto unlock_and_exit;
196 /* Now load the single DSDT */
198 status = acpi_ns_load_table (table_desc, acpi_gbl_root_node);
199 if (ACPI_SUCCESS (status)) {
200 table_desc->loaded_into_namespace = TRUE;
202 break;
205 case ACPI_TABLE_SSDT:
207 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Loading %d SSDTs\n",
208 acpi_gbl_table_lists[ACPI_TABLE_SSDT].count));
211 * Traverse list of SSDT tables
213 table_desc = acpi_gbl_table_lists[ACPI_TABLE_SSDT].next;
214 for (i = 0; i < acpi_gbl_table_lists[ACPI_TABLE_SSDT].count; i++) {
216 * Only attempt to load table if it is not
217 * already loaded!
219 if (!table_desc->loaded_into_namespace) {
220 status = acpi_ns_load_table (table_desc, acpi_gbl_root_node);
221 if (ACPI_FAILURE (status)) {
222 break;
225 table_desc->loaded_into_namespace = TRUE;
228 table_desc = table_desc->next;
230 break;
233 case ACPI_TABLE_PSDT:
235 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Loading %d PSDTs\n",
236 acpi_gbl_table_lists[ACPI_TABLE_PSDT].count));
239 * Traverse list of PSDT tables
241 table_desc = acpi_gbl_table_lists[ACPI_TABLE_PSDT].next;
243 for (i = 0; i < acpi_gbl_table_lists[ACPI_TABLE_PSDT].count; i++) {
244 /* Only attempt to load table if it is not already loaded! */
246 if (!table_desc->loaded_into_namespace) {
247 status = acpi_ns_load_table (table_desc, acpi_gbl_root_node);
248 if (ACPI_FAILURE (status)) {
249 break;
252 table_desc->loaded_into_namespace = TRUE;
255 table_desc = table_desc->next;
257 break;
260 default:
261 status = AE_SUPPORT;
262 break;
266 unlock_and_exit:
267 (void) acpi_ut_release_mutex (ACPI_MTX_TABLES);
268 return_ACPI_STATUS (status);
272 /*******************************************************************************
274 * FUNCTION: acpi_load_namespace
276 * PARAMETERS: None
278 * RETURN: Status
280 * DESCRIPTION: Load the name space from what ever is pointed to by DSDT.
281 * (DSDT points to either the BIOS or a buffer.)
283 ******************************************************************************/
285 acpi_status
286 acpi_ns_load_namespace (
287 void)
289 acpi_status status;
292 ACPI_FUNCTION_TRACE ("acpi_load_name_space");
295 /* There must be at least a DSDT installed */
297 if (acpi_gbl_DSDT == NULL) {
298 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "DSDT is not in memory\n"));
299 return_ACPI_STATUS (AE_NO_ACPI_TABLES);
303 * Load the namespace. The DSDT is required,
304 * but the SSDT and PSDT tables are optional.
306 status = acpi_ns_load_table_by_type (ACPI_TABLE_DSDT);
307 if (ACPI_FAILURE (status)) {
308 return_ACPI_STATUS (status);
311 /* Ignore exceptions from these */
313 (void) acpi_ns_load_table_by_type (ACPI_TABLE_SSDT);
314 (void) acpi_ns_load_table_by_type (ACPI_TABLE_PSDT);
316 ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
317 "ACPI Namespace successfully loaded at root %p\n",
318 acpi_gbl_root_node));
320 return_ACPI_STATUS (status);
324 #ifdef ACPI_FUTURE_USAGE
326 /*******************************************************************************
328 * FUNCTION: acpi_ns_delete_subtree
330 * PARAMETERS: start_handle - Handle in namespace where search begins
332 * RETURNS Status
334 * DESCRIPTION: Walks the namespace starting at the given handle and deletes
335 * all objects, entries, and scopes in the entire subtree.
337 * Namespace/Interpreter should be locked or the subsystem should
338 * be in shutdown before this routine is called.
340 ******************************************************************************/
342 acpi_status
343 acpi_ns_delete_subtree (
344 acpi_handle start_handle)
346 acpi_status status;
347 acpi_handle child_handle;
348 acpi_handle parent_handle;
349 acpi_handle next_child_handle;
350 acpi_handle dummy;
351 u32 level;
354 ACPI_FUNCTION_TRACE ("ns_delete_subtree");
357 parent_handle = start_handle;
358 child_handle = NULL;
359 level = 1;
362 * Traverse the tree of objects until we bubble back up
363 * to where we started.
365 while (level > 0) {
366 /* Attempt to get the next object in this scope */
368 status = acpi_get_next_object (ACPI_TYPE_ANY, parent_handle,
369 child_handle, &next_child_handle);
371 child_handle = next_child_handle;
373 /* Did we get a new object? */
375 if (ACPI_SUCCESS (status)) {
376 /* Check if this object has any children */
378 if (ACPI_SUCCESS (acpi_get_next_object (ACPI_TYPE_ANY, child_handle,
379 NULL, &dummy))) {
381 * There is at least one child of this object,
382 * visit the object
384 level++;
385 parent_handle = child_handle;
386 child_handle = NULL;
389 else {
391 * No more children in this object, go back up to
392 * the object's parent
394 level--;
396 /* Delete all children now */
398 acpi_ns_delete_children (child_handle);
400 child_handle = parent_handle;
401 status = acpi_get_parent (parent_handle, &parent_handle);
402 if (ACPI_FAILURE (status)) {
403 return_ACPI_STATUS (status);
408 /* Now delete the starting object, and we are done */
410 acpi_ns_delete_node (child_handle);
412 return_ACPI_STATUS (AE_OK);
416 /*******************************************************************************
418 * FUNCTION: acpi_ns_unload_name_space
420 * PARAMETERS: Handle - Root of namespace subtree to be deleted
422 * RETURN: Status
424 * DESCRIPTION: Shrinks the namespace, typically in response to an undocking
425 * event. Deletes an entire subtree starting from (and
426 * including) the given handle.
428 ******************************************************************************/
430 acpi_status
431 acpi_ns_unload_namespace (
432 acpi_handle handle)
434 acpi_status status;
437 ACPI_FUNCTION_TRACE ("ns_unload_name_space");
440 /* Parameter validation */
442 if (!acpi_gbl_root_node) {
443 return_ACPI_STATUS (AE_NO_NAMESPACE);
446 if (!handle) {
447 return_ACPI_STATUS (AE_BAD_PARAMETER);
450 /* This function does the real work */
452 status = acpi_ns_delete_subtree (handle);
454 return_ACPI_STATUS (status);
457 #endif /* ACPI_FUTURE_USAGE */
459 #endif