1 /******************************************************************************
3 * Module Name: nsinit - namespace initialization
6 *****************************************************************************/
9 * Copyright (C) 2000 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 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 * Also: Install PCI config space handler for all PCI root bridges.
85 * A PCI root bridge is found by searching for devices containing
86 * a HID with the value EISAID("PNP0A03")
88 *****************************************************************************/
91 acpi_ns_initialize_devices (
95 ACPI_DEVICE_WALK_INFO info
;
99 info
.device_count
= 0;
104 status
= acpi_ns_walk_namespace (ACPI_TYPE_DEVICE
, ACPI_ROOT_OBJECT
, ACPI_UINT32_MAX
,
105 FALSE
, acpi_ns_init_one_device
, &info
, NULL
);
113 /*******************************************************************************
115 * FUNCTION: Acpi_ns_init_one_object
117 * PARAMETERS: Obj_handle - Node
118 * Level - Current nesting level
119 * Context - Points to a init info struct
120 * Return_value - Not used
124 * DESCRIPTION: Callback from Acpi_walk_namespace. Invoked for every object
125 * within the namespace.
127 * Currently, the only objects that require initialization are:
131 ******************************************************************************/
134 acpi_ns_init_one_object (
135 ACPI_HANDLE obj_handle
,
140 OBJECT_TYPE_INTERNAL type
;
142 ACPI_INIT_WALK_INFO
*info
= (ACPI_INIT_WALK_INFO
*) context
;
143 ACPI_NAMESPACE_NODE
*node
= (ACPI_NAMESPACE_NODE
*) obj_handle
;
144 ACPI_OPERAND_OBJECT
*obj_desc
;
147 info
->object_count
++;
150 /* And even then, we are only interested in a few object types */
152 type
= acpi_ns_get_type (obj_handle
);
153 obj_desc
= node
->object
;
161 case ACPI_TYPE_REGION
:
163 info
->op_region_count
++;
164 if (obj_desc
->common
.flags
& AOPOBJ_DATA_VALID
) {
168 info
->op_region_init
++;
169 status
= acpi_ds_get_region_arguments (obj_desc
);
174 case ACPI_TYPE_FIELD_UNIT
:
177 if (obj_desc
->common
.flags
& AOPOBJ_DATA_VALID
) {
182 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: The usual "I'm a namespace callback" stuff
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
;
224 info
->device_count
++;
226 acpi_cm_acquire_mutex (ACPI_MTX_NAMESPACE
);
228 node
= acpi_ns_convert_handle_to_entry (obj_handle
);
230 acpi_cm_release_mutex (ACPI_MTX_NAMESPACE
);
231 return (AE_BAD_PARAMETER
);
234 acpi_cm_release_mutex (ACPI_MTX_NAMESPACE
);
237 * Run _STA to determine if we can run _INI on the device.
240 status
= acpi_cm_execute_STA (node
, &flags
);
241 if (ACPI_FAILURE (status
)) {
247 if (!(flags
& 0x01)) {
248 /* don't look at children of a not present device */
249 return(AE_CTRL_DEPTH
);
253 * The device is present. Run _INI.
256 status
= acpi_ns_evaluate_relative (obj_handle
, "_INI", NULL
, NULL
);
257 if (AE_NOT_FOUND
== status
) {
258 /* No _INI means device requires no initialization */
262 else if (ACPI_FAILURE (status
)) {