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
29 #define _COMPONENT ACPI_NAMESPACE
30 MODULE_NAME ("nsinit")
33 /*******************************************************************************
35 * FUNCTION: Acpi_ns_initialize_objects
41 * DESCRIPTION: Walk the entire namespace and perform any necessary
42 * initialization on the objects found therein
44 ******************************************************************************/
47 acpi_ns_initialize_objects (
51 ACPI_INIT_WALK_INFO info
;
56 info
.op_region_count
= 0;
57 info
.op_region_init
= 0;
58 info
.object_count
= 0;
61 /* Walk entire namespace from the supplied root */
63 status
= acpi_walk_namespace (ACPI_TYPE_ANY
, ACPI_ROOT_OBJECT
,
64 ACPI_UINT32_MAX
, acpi_ns_init_one_object
,
71 /*******************************************************************************
73 * FUNCTION: Acpi_ns_initialize_devices
79 * DESCRIPTION: Walk the entire namespace and initialize all ACPI devices.
80 * This means running _INI on all present devices.
82 * Note: We install PCI config space handler on region access,
85 ******************************************************************************/
88 acpi_ns_initialize_devices (
92 ACPI_DEVICE_WALK_INFO info
;
95 info
.device_count
= 0;
100 status
= acpi_ns_walk_namespace (ACPI_TYPE_DEVICE
, ACPI_ROOT_OBJECT
,
101 ACPI_UINT32_MAX
, FALSE
, acpi_ns_init_one_device
, &info
, NULL
);
109 /*******************************************************************************
111 * FUNCTION: Acpi_ns_init_one_object
113 * PARAMETERS: Obj_handle - Node
114 * Level - Current nesting level
115 * Context - Points to a init info struct
116 * Return_value - Not used
120 * DESCRIPTION: Callback from Acpi_walk_namespace. Invoked for every object
121 * within the namespace.
123 * Currently, the only objects that require initialization are:
127 ******************************************************************************/
130 acpi_ns_init_one_object (
131 ACPI_HANDLE obj_handle
,
136 OBJECT_TYPE_INTERNAL type
;
138 ACPI_INIT_WALK_INFO
*info
= (ACPI_INIT_WALK_INFO
*) context
;
139 ACPI_NAMESPACE_NODE
*node
= (ACPI_NAMESPACE_NODE
*) obj_handle
;
140 ACPI_OPERAND_OBJECT
*obj_desc
;
143 info
->object_count
++;
146 /* And even then, we are only interested in a few object types */
148 type
= acpi_ns_get_type (obj_handle
);
149 obj_desc
= node
->object
;
156 case ACPI_TYPE_REGION
:
158 info
->op_region_count
++;
159 if (obj_desc
->common
.flags
& AOPOBJ_DATA_VALID
) {
163 info
->op_region_init
++;
164 status
= acpi_ds_get_region_arguments (obj_desc
);
170 case ACPI_TYPE_FIELD_UNIT
:
173 if (obj_desc
->common
.flags
& AOPOBJ_DATA_VALID
) {
178 status
= acpi_ds_get_field_unit_arguments (obj_desc
);
188 * We ignore errors from above, and always return OK, since
189 * we don't want to abort the walk on a single error.
195 /*******************************************************************************
197 * FUNCTION: Acpi_ns_init_one_device
199 * PARAMETERS: WALK_CALLBACK
201 * RETURN: ACPI_STATUS
203 * DESCRIPTION: This is called once per device soon after ACPI is enabled
204 * to initialize each device. It determines if the device is
205 * present, and if so, calls _INI.
207 ******************************************************************************/
210 acpi_ns_init_one_device (
211 ACPI_HANDLE obj_handle
,
217 ACPI_NAMESPACE_NODE
*node
;
219 ACPI_DEVICE_WALK_INFO
*info
= (ACPI_DEVICE_WALK_INFO
*) context
;
223 info
->device_count
++;
225 acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE
);
227 node
= acpi_ns_convert_handle_to_entry (obj_handle
);
229 acpi_cm_release_mutex (ACPI_MTX_NAMESPACE
);
230 return (AE_BAD_PARAMETER
);
233 acpi_cm_release_mutex (ACPI_MTX_NAMESPACE
);
236 * Run _STA to determine if we can run _INI on the device.
239 status
= acpi_cm_execute_STA (node
, &flags
);
240 if (ACPI_FAILURE (status
)) {
241 /* Ignore error and move on to next device */
248 if (!(flags
& 0x01)) {
249 /* don't look at children of a not present device */
250 return(AE_CTRL_DEPTH
);
255 * The device is present. Run _INI.
258 status
= acpi_ns_evaluate_relative (obj_handle
, "_INI", NULL
, NULL
);
259 if (AE_NOT_FOUND
== status
) {
260 /* No _INI means device requires no initialization */
264 else if (ACPI_FAILURE (status
)) {
265 /* Ignore error and move on to next device */
270 /* Count of successful INIs */