1 |
1275 |
phoenix |
/******************************************************************************
|
2 |
|
|
*
|
3 |
|
|
* Module Name: dsinit - Object initialization namespace walk
|
4 |
|
|
*
|
5 |
|
|
*****************************************************************************/
|
6 |
|
|
|
7 |
|
|
/*
|
8 |
|
|
* Copyright (C) 2000 - 2004, R. Byron Moore
|
9 |
|
|
* All rights reserved.
|
10 |
|
|
*
|
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.
|
25 |
|
|
*
|
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.
|
29 |
|
|
*
|
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.
|
42 |
|
|
*/
|
43 |
|
|
|
44 |
|
|
|
45 |
|
|
#include <acpi/acpi.h>
|
46 |
|
|
#include <acpi/acdispat.h>
|
47 |
|
|
#include <acpi/acnamesp.h>
|
48 |
|
|
|
49 |
|
|
#define _COMPONENT ACPI_DISPATCHER
|
50 |
|
|
ACPI_MODULE_NAME ("dsinit")
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
/*******************************************************************************
|
54 |
|
|
*
|
55 |
|
|
* FUNCTION: acpi_ds_init_one_object
|
56 |
|
|
*
|
57 |
|
|
* PARAMETERS: obj_handle - Node
|
58 |
|
|
* Level - Current nesting level
|
59 |
|
|
* Context - Points to a init info struct
|
60 |
|
|
* return_value - Not used
|
61 |
|
|
*
|
62 |
|
|
* RETURN: Status
|
63 |
|
|
*
|
64 |
|
|
* DESCRIPTION: Callback from acpi_walk_namespace. Invoked for every object
|
65 |
|
|
* within the namespace.
|
66 |
|
|
*
|
67 |
|
|
* Currently, the only objects that require initialization are:
|
68 |
|
|
* 1) Methods
|
69 |
|
|
* 2) Operation Regions
|
70 |
|
|
*
|
71 |
|
|
******************************************************************************/
|
72 |
|
|
|
73 |
|
|
acpi_status
|
74 |
|
|
acpi_ds_init_one_object (
|
75 |
|
|
acpi_handle obj_handle,
|
76 |
|
|
u32 level,
|
77 |
|
|
void *context,
|
78 |
|
|
void **return_value)
|
79 |
|
|
{
|
80 |
|
|
acpi_object_type type;
|
81 |
|
|
acpi_status status;
|
82 |
|
|
struct acpi_init_walk_info *info = (struct acpi_init_walk_info *) context;
|
83 |
|
|
|
84 |
|
|
|
85 |
|
|
ACPI_FUNCTION_NAME ("ds_init_one_object");
|
86 |
|
|
|
87 |
|
|
|
88 |
|
|
/*
|
89 |
|
|
* We are only interested in objects owned by the table that
|
90 |
|
|
* was just loaded
|
91 |
|
|
*/
|
92 |
|
|
if (((struct acpi_namespace_node *) obj_handle)->owner_id !=
|
93 |
|
|
info->table_desc->table_id) {
|
94 |
|
|
return (AE_OK);
|
95 |
|
|
}
|
96 |
|
|
|
97 |
|
|
info->object_count++;
|
98 |
|
|
|
99 |
|
|
/* And even then, we are only interested in a few object types */
|
100 |
|
|
|
101 |
|
|
type = acpi_ns_get_type (obj_handle);
|
102 |
|
|
|
103 |
|
|
switch (type) {
|
104 |
|
|
case ACPI_TYPE_REGION:
|
105 |
|
|
|
106 |
|
|
status = acpi_ds_initialize_region (obj_handle);
|
107 |
|
|
if (ACPI_FAILURE (status)) {
|
108 |
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Region %p [%4.4s] - Init failure, %s\n",
|
109 |
|
|
obj_handle, acpi_ut_get_node_name (obj_handle),
|
110 |
|
|
acpi_format_exception (status)));
|
111 |
|
|
}
|
112 |
|
|
|
113 |
|
|
info->op_region_count++;
|
114 |
|
|
break;
|
115 |
|
|
|
116 |
|
|
|
117 |
|
|
case ACPI_TYPE_METHOD:
|
118 |
|
|
|
119 |
|
|
info->method_count++;
|
120 |
|
|
|
121 |
|
|
/* Print a dot for each method unless we are going to print the entire pathname */
|
122 |
|
|
|
123 |
|
|
if (!(acpi_dbg_level & ACPI_LV_INIT_NAMES)) {
|
124 |
|
|
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "."));
|
125 |
|
|
}
|
126 |
|
|
|
127 |
|
|
/*
|
128 |
|
|
* Set the execution data width (32 or 64) based upon the
|
129 |
|
|
* revision number of the parent ACPI table.
|
130 |
|
|
* TBD: This is really for possible future support of integer width
|
131 |
|
|
* on a per-table basis. Currently, we just use a global for the width.
|
132 |
|
|
*/
|
133 |
|
|
if (info->table_desc->pointer->revision == 1) {
|
134 |
|
|
((struct acpi_namespace_node *) obj_handle)->flags |= ANOBJ_DATA_WIDTH_32;
|
135 |
|
|
}
|
136 |
|
|
|
137 |
|
|
/*
|
138 |
|
|
* Always parse methods to detect errors, we will delete
|
139 |
|
|
* the parse tree below
|
140 |
|
|
*/
|
141 |
|
|
status = acpi_ds_parse_method (obj_handle);
|
142 |
|
|
if (ACPI_FAILURE (status)) {
|
143 |
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "Method %p [%4.4s] - parse failure, %s\n",
|
144 |
|
|
obj_handle, acpi_ut_get_node_name (obj_handle),
|
145 |
|
|
acpi_format_exception (status)));
|
146 |
|
|
|
147 |
|
|
/* This parse failed, but we will continue parsing more methods */
|
148 |
|
|
|
149 |
|
|
break;
|
150 |
|
|
}
|
151 |
|
|
|
152 |
|
|
/*
|
153 |
|
|
* Delete the parse tree. We simply re-parse the method
|
154 |
|
|
* for every execution since there isn't much overhead
|
155 |
|
|
*/
|
156 |
|
|
acpi_ns_delete_namespace_subtree (obj_handle);
|
157 |
|
|
acpi_ns_delete_namespace_by_owner (((struct acpi_namespace_node *) obj_handle)->object->method.owning_id);
|
158 |
|
|
break;
|
159 |
|
|
|
160 |
|
|
|
161 |
|
|
case ACPI_TYPE_DEVICE:
|
162 |
|
|
|
163 |
|
|
info->device_count++;
|
164 |
|
|
break;
|
165 |
|
|
|
166 |
|
|
|
167 |
|
|
default:
|
168 |
|
|
break;
|
169 |
|
|
}
|
170 |
|
|
|
171 |
|
|
/*
|
172 |
|
|
* We ignore errors from above, and always return OK, since
|
173 |
|
|
* we don't want to abort the walk on a single error.
|
174 |
|
|
*/
|
175 |
|
|
return (AE_OK);
|
176 |
|
|
}
|
177 |
|
|
|
178 |
|
|
|
179 |
|
|
/*******************************************************************************
|
180 |
|
|
*
|
181 |
|
|
* FUNCTION: acpi_ds_initialize_objects
|
182 |
|
|
*
|
183 |
|
|
* PARAMETERS: table_desc - Descriptor for parent ACPI table
|
184 |
|
|
* start_node - Root of subtree to be initialized.
|
185 |
|
|
*
|
186 |
|
|
* RETURN: Status
|
187 |
|
|
*
|
188 |
|
|
* DESCRIPTION: Walk the namespace starting at "start_node" and perform any
|
189 |
|
|
* necessary initialization on the objects found therein
|
190 |
|
|
*
|
191 |
|
|
******************************************************************************/
|
192 |
|
|
|
193 |
|
|
acpi_status
|
194 |
|
|
acpi_ds_initialize_objects (
|
195 |
|
|
struct acpi_table_desc *table_desc,
|
196 |
|
|
struct acpi_namespace_node *start_node)
|
197 |
|
|
{
|
198 |
|
|
acpi_status status;
|
199 |
|
|
struct acpi_init_walk_info info;
|
200 |
|
|
|
201 |
|
|
|
202 |
|
|
ACPI_FUNCTION_TRACE ("ds_initialize_objects");
|
203 |
|
|
|
204 |
|
|
|
205 |
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
|
206 |
|
|
"**** Starting initialization of namespace objects ****\n"));
|
207 |
|
|
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT, "Parsing all Control Methods:"));
|
208 |
|
|
|
209 |
|
|
info.method_count = 0;
|
210 |
|
|
info.op_region_count = 0;
|
211 |
|
|
info.object_count = 0;
|
212 |
|
|
info.device_count = 0;
|
213 |
|
|
info.table_desc = table_desc;
|
214 |
|
|
|
215 |
|
|
/* Walk entire namespace from the supplied root */
|
216 |
|
|
|
217 |
|
|
status = acpi_walk_namespace (ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX,
|
218 |
|
|
acpi_ds_init_one_object, &info, NULL);
|
219 |
|
|
if (ACPI_FAILURE (status)) {
|
220 |
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "walk_namespace failed, %s\n",
|
221 |
|
|
acpi_format_exception (status)));
|
222 |
|
|
}
|
223 |
|
|
|
224 |
|
|
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INIT,
|
225 |
|
|
"\nTable [%4.4s](id %4.4X) - %hd Objects with %hd Devices %hd Methods %hd Regions\n",
|
226 |
|
|
table_desc->pointer->signature, table_desc->table_id, info.object_count,
|
227 |
|
|
info.device_count, info.method_count, info.op_region_count));
|
228 |
|
|
|
229 |
|
|
ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
|
230 |
|
|
"%hd Methods, %hd Regions\n", info.method_count, info.op_region_count));
|
231 |
|
|
|
232 |
|
|
return_ACPI_STATUS (AE_OK);
|
233 |
|
|
}
|
234 |
|
|
|
235 |
|
|
|