[ACPI] ACPICA 20051117
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / acpi / dispatcher / dsinit.c
blob4fa80abfe6c06ebe52d46dae85ffe9e45c79395d
1 /******************************************************************************
3 * Module Name: dsinit - Object initialization namespace walk
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.
44 #include <acpi/acpi.h>
45 #include <acpi/acdispat.h>
46 #include <acpi/acnamesp.h>
48 #define _COMPONENT ACPI_DISPATCHER
49 ACPI_MODULE_NAME("dsinit")
51 /* Local prototypes */
52 static acpi_status
53 acpi_ds_init_one_object(acpi_handle obj_handle,
54 u32 level, void *context, void **return_value);
56 /*******************************************************************************
58 * FUNCTION: acpi_ds_init_one_object
60 * PARAMETERS: obj_handle - Node for the object
61 * Level - Current nesting level
62 * Context - Points to a init info struct
63 * return_value - Not used
65 * RETURN: Status
67 * DESCRIPTION: Callback from acpi_walk_namespace. Invoked for every object
68 * within the namespace.
70 * Currently, the only objects that require initialization are:
71 * 1) Methods
72 * 2) Operation Regions
74 ******************************************************************************/
76 static acpi_status
77 acpi_ds_init_one_object(acpi_handle obj_handle,
78 u32 level, void *context, void **return_value)
80 struct acpi_init_walk_info *info =
81 (struct acpi_init_walk_info *)context;
82 struct acpi_namespace_node *node =
83 (struct acpi_namespace_node *)obj_handle;
84 acpi_object_type type;
85 acpi_status status;
87 ACPI_FUNCTION_NAME("ds_init_one_object");
90 * We are only interested in NS nodes owned by the table that
91 * was just loaded
93 if (node->owner_id != info->table_desc->owner_id) {
94 return (AE_OK);
97 info->object_count++;
99 /* And even then, we are only interested in a few object types */
101 type = acpi_ns_get_type(obj_handle);
103 switch (type) {
104 case ACPI_TYPE_REGION:
106 status = acpi_ds_initialize_region(obj_handle);
107 if (ACPI_FAILURE(status)) {
108 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
109 "Region %p [%4.4s] - Init failure, %s\n",
110 obj_handle,
111 acpi_ut_get_node_name(obj_handle),
112 acpi_format_exception(status)));
115 info->op_region_count++;
116 break;
118 case ACPI_TYPE_METHOD:
121 * Set the execution data width (32 or 64) based upon the
122 * revision number of the parent ACPI table.
123 * TBD: This is really for possible future support of integer width
124 * on a per-table basis. Currently, we just use a global for the width.
126 if (info->table_desc->pointer->revision == 1) {
127 node->flags |= ANOBJ_DATA_WIDTH_32;
129 #ifdef ACPI_INIT_PARSE_METHODS
131 * Note 11/2005: Removed this code to parse all methods during table
132 * load because it causes problems if there are any errors during the
133 * parse. Also, it seems like overkill and we probably don't want to
134 * abort a table load because of an issue with a single method.
138 * Print a dot for each method unless we are going to print
139 * the entire pathname
141 if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
142 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "."));
146 * Always parse methods to detect errors, we will delete
147 * the parse tree below
149 status = acpi_ds_parse_method(obj_handle);
150 if (ACPI_FAILURE(status)) {
151 ACPI_DEBUG_PRINT((ACPI_DB_ERROR,
152 "\n+Method %p [%4.4s] - parse failure, %s\n",
153 obj_handle,
154 acpi_ut_get_node_name(obj_handle),
155 acpi_format_exception(status)));
157 /* This parse failed, but we will continue parsing more methods */
159 #endif
160 info->method_count++;
161 break;
163 case ACPI_TYPE_DEVICE:
165 info->device_count++;
166 break;
168 default:
169 break;
173 * We ignore errors from above, and always return OK, since
174 * we don't want to abort the walk on a single error.
176 return (AE_OK);
179 /*******************************************************************************
181 * FUNCTION: acpi_ds_initialize_objects
183 * PARAMETERS: table_desc - Descriptor for parent ACPI table
184 * start_node - Root of subtree to be initialized.
186 * RETURN: Status
188 * DESCRIPTION: Walk the namespace starting at "start_node" and perform any
189 * necessary initialization on the objects found therein
191 ******************************************************************************/
193 acpi_status
194 acpi_ds_initialize_objects(struct acpi_table_desc * table_desc,
195 struct acpi_namespace_node * start_node)
197 acpi_status status;
198 struct acpi_init_walk_info info;
200 ACPI_FUNCTION_TRACE("ds_initialize_objects");
202 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
203 "**** Starting initialization of namespace objects ****\n"));
204 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "Parsing all Control Methods:"));
206 info.method_count = 0;
207 info.op_region_count = 0;
208 info.object_count = 0;
209 info.device_count = 0;
210 info.table_desc = table_desc;
212 /* Walk entire namespace from the supplied root */
214 status = acpi_walk_namespace(ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX,
215 acpi_ds_init_one_object, &info, NULL);
216 if (ACPI_FAILURE(status)) {
217 ACPI_DEBUG_PRINT((ACPI_DB_ERROR, "walk_namespace failed, %s\n",
218 acpi_format_exception(status)));
221 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
222 "\nTable [%4.4s](id %4.4X) - %hd Objects with %hd Devices %hd Methods %hd Regions\n",
223 table_desc->pointer->signature,
224 table_desc->owner_id, info.object_count,
225 info.device_count, info.method_count,
226 info.op_region_count));
228 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
229 "%hd Methods, %hd Regions\n", info.method_count,
230 info.op_region_count));
232 return_ACPI_STATUS(AE_OK);