ACPICA: hide private headers
[linux-2.6/mini2440.git] / drivers / acpi / acpica / dsinit.c
blobeb144b13d8fa434f93618fb953f498771b7e3a87
1 /******************************************************************************
3 * Module Name: dsinit - Object initialization namespace walk
5 *****************************************************************************/
7 /*
8 * Copyright (C) 2000 - 2008, Intel Corp.
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 "accommon.h"
46 #include "acdispat.h"
47 #include "acnamesp.h"
48 #include "actables.h"
50 #define _COMPONENT ACPI_DISPATCHER
51 ACPI_MODULE_NAME("dsinit")
53 /* Local prototypes */
54 static acpi_status
55 acpi_ds_init_one_object(acpi_handle obj_handle,
56 u32 level, void *context, void **return_value);
58 /*******************************************************************************
60 * FUNCTION: acpi_ds_init_one_object
62 * PARAMETERS: obj_handle - Node for the object
63 * Level - Current nesting level
64 * Context - Points to a init info struct
65 * return_value - Not used
67 * RETURN: Status
69 * DESCRIPTION: Callback from acpi_walk_namespace. Invoked for every object
70 * within the namespace.
72 * Currently, the only objects that require initialization are:
73 * 1) Methods
74 * 2) Operation Regions
76 ******************************************************************************/
78 static acpi_status
79 acpi_ds_init_one_object(acpi_handle obj_handle,
80 u32 level, void *context, void **return_value)
82 struct acpi_init_walk_info *info =
83 (struct acpi_init_walk_info *)context;
84 struct acpi_namespace_node *node =
85 (struct acpi_namespace_node *)obj_handle;
86 acpi_object_type type;
87 acpi_status status;
89 ACPI_FUNCTION_ENTRY();
92 * We are only interested in NS nodes owned by the table that
93 * was just loaded
95 if (node->owner_id != info->owner_id) {
96 return (AE_OK);
99 info->object_count++;
101 /* And even then, we are only interested in a few object types */
103 type = acpi_ns_get_type(obj_handle);
105 switch (type) {
106 case ACPI_TYPE_REGION:
108 status = acpi_ds_initialize_region(obj_handle);
109 if (ACPI_FAILURE(status)) {
110 ACPI_EXCEPTION((AE_INFO, status,
111 "During Region initialization %p [%4.4s]",
112 obj_handle,
113 acpi_ut_get_node_name(obj_handle)));
116 info->op_region_count++;
117 break;
119 case ACPI_TYPE_METHOD:
121 info->method_count++;
122 break;
124 case ACPI_TYPE_DEVICE:
126 info->device_count++;
127 break;
129 default:
130 break;
134 * We ignore errors from above, and always return OK, since
135 * we don't want to abort the walk on a single error.
137 return (AE_OK);
140 /*******************************************************************************
142 * FUNCTION: acpi_ds_initialize_objects
144 * PARAMETERS: table_desc - Descriptor for parent ACPI table
145 * start_node - Root of subtree to be initialized.
147 * RETURN: Status
149 * DESCRIPTION: Walk the namespace starting at "StartNode" and perform any
150 * necessary initialization on the objects found therein
152 ******************************************************************************/
154 acpi_status
155 acpi_ds_initialize_objects(u32 table_index,
156 struct acpi_namespace_node * start_node)
158 acpi_status status;
159 struct acpi_init_walk_info info;
160 struct acpi_table_header *table;
161 acpi_owner_id owner_id;
163 ACPI_FUNCTION_TRACE(ds_initialize_objects);
165 status = acpi_tb_get_owner_id(table_index, &owner_id);
166 if (ACPI_FAILURE(status)) {
167 return_ACPI_STATUS(status);
170 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
171 "**** Starting initialization of namespace objects ****\n"));
172 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "Parsing all Control Methods:"));
174 info.method_count = 0;
175 info.op_region_count = 0;
176 info.object_count = 0;
177 info.device_count = 0;
178 info.table_index = table_index;
179 info.owner_id = owner_id;
181 /* Walk entire namespace from the supplied root */
183 status = acpi_walk_namespace(ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX,
184 acpi_ds_init_one_object, &info, NULL);
185 if (ACPI_FAILURE(status)) {
186 ACPI_EXCEPTION((AE_INFO, status, "During WalkNamespace"));
189 status = acpi_get_table_by_index(table_index, &table);
190 if (ACPI_FAILURE(status)) {
191 return_ACPI_STATUS(status);
194 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT,
195 "\nTable [%4.4s](id %4.4X) - %hd Objects with %hd Devices %hd Methods %hd Regions\n",
196 table->signature, owner_id, info.object_count,
197 info.device_count, info.method_count,
198 info.op_region_count));
200 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH,
201 "%hd Methods, %hd Regions\n", info.method_count,
202 info.op_region_count));
204 return_ACPI_STATUS(AE_OK);