1 /******************************************************************************
3 * Module Name: nsinit - namespace initialization
6 *****************************************************************************/
9 * Copyright (C) 2000, 2001 R. Byron Moore
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
31 #define _COMPONENT ACPI_NAMESPACE
32 MODULE_NAME ("nsinit")
35 /*******************************************************************************
37 * FUNCTION: Acpi_ns_initialize_objects
43 * DESCRIPTION: Walk the entire namespace and perform any necessary
44 * initialization on the objects found therein
46 ******************************************************************************/
49 acpi_ns_initialize_objects (
53 ACPI_INIT_WALK_INFO info
;
58 info
.op_region_count
= 0;
59 info
.op_region_init
= 0;
60 info
.object_count
= 0;
63 /* Walk entire namespace from the supplied root */
65 status
= acpi_walk_namespace (ACPI_TYPE_ANY
, ACPI_ROOT_OBJECT
,
66 ACPI_UINT32_MAX
, acpi_ns_init_one_object
,
73 /*******************************************************************************
75 * FUNCTION: Acpi_ns_initialize_devices
81 * DESCRIPTION: Walk the entire namespace and initialize all ACPI devices.
82 * This means running _INI on all present devices.
84 * Note: We install PCI config space handler on region access,
87 ******************************************************************************/
90 acpi_ns_initialize_devices (
94 ACPI_DEVICE_WALK_INFO info
;
97 info
.device_count
= 0;
102 status
= acpi_ns_walk_namespace (ACPI_TYPE_DEVICE
, ACPI_ROOT_OBJECT
,
103 ACPI_UINT32_MAX
, FALSE
, acpi_ns_init_one_device
, &info
, NULL
);
111 /*******************************************************************************
113 * FUNCTION: Acpi_ns_init_one_object
115 * PARAMETERS: Obj_handle - Node
116 * Level - Current nesting level
117 * Context - Points to a init info struct
118 * Return_value - Not used
122 * DESCRIPTION: Callback from Acpi_walk_namespace. Invoked for every object
123 * within the namespace.
125 * Currently, the only objects that require initialization are:
129 ******************************************************************************/
132 acpi_ns_init_one_object (
133 ACPI_HANDLE obj_handle
,
138 OBJECT_TYPE_INTERNAL type
;
140 ACPI_INIT_WALK_INFO
*info
= (ACPI_INIT_WALK_INFO
*) context
;
141 ACPI_NAMESPACE_NODE
*node
= (ACPI_NAMESPACE_NODE
*) obj_handle
;
142 ACPI_OPERAND_OBJECT
*obj_desc
;
145 info
->object_count
++;
148 /* And even then, we are only interested in a few object types */
150 type
= acpi_ns_get_type (obj_handle
);
151 obj_desc
= node
->object
;
158 case ACPI_TYPE_REGION
:
160 info
->op_region_count
++;
161 if (obj_desc
->common
.flags
& AOPOBJ_DATA_VALID
) {
165 info
->op_region_init
++;
166 status
= acpi_ds_get_region_arguments (obj_desc
);
172 case ACPI_TYPE_FIELD_UNIT
:
175 if (obj_desc
->common
.flags
& AOPOBJ_DATA_VALID
) {
180 status
= acpi_ds_get_field_unit_arguments (obj_desc
);
190 * We ignore errors from above, and always return OK, since
191 * we don't want to abort the walk on a single error.
197 /*******************************************************************************
199 * FUNCTION: Acpi_ns_init_one_device
201 * PARAMETERS: WALK_CALLBACK
203 * RETURN: ACPI_STATUS
205 * DESCRIPTION: This is called once per device soon after ACPI is enabled
206 * to initialize each device. It determines if the device is
207 * present, and if so, calls _INI.
209 ******************************************************************************/
212 acpi_ns_init_one_device (
213 ACPI_HANDLE obj_handle
,
219 ACPI_NAMESPACE_NODE
*node
;
221 ACPI_DEVICE_WALK_INFO
*info
= (ACPI_DEVICE_WALK_INFO
*) context
;
225 info
->device_count
++;
227 acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE
);
229 node
= acpi_ns_convert_handle_to_entry (obj_handle
);
231 acpi_cm_release_mutex (ACPI_MTX_NAMESPACE
);
232 return (AE_BAD_PARAMETER
);
235 acpi_cm_release_mutex (ACPI_MTX_NAMESPACE
);
238 * Run _STA to determine if we can run _INI on the device.
241 status
= acpi_cm_execute_STA (node
, &flags
);
242 if (ACPI_FAILURE (status
)) {
243 /* Ignore error and move on to next device */
250 if (!(flags
& 0x01)) {
251 /* don't look at children of a not present device */
252 return(AE_CTRL_DEPTH
);
257 * The device is present. Run _INI.
260 status
= acpi_ns_evaluate_relative (obj_handle
, "_INI", NULL
, NULL
);
261 if (AE_NOT_FOUND
== status
) {
262 /* No _INI means device requires no initialization */
266 else if (ACPI_FAILURE (status
)) {
267 /* Ignore error and move on to next device */
272 /* Count of successful INIs */