1 /******************************************************************************
3 * Module Name: dsinit - Object initialization namespace walk
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2015, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
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.
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>
50 #define _COMPONENT ACPI_DISPATCHER
51 ACPI_MODULE_NAME("dsinit")
53 /* Local prototypes */
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
69 * DESCRIPTION: Callback from acpi_walk_namespace. Invoked for every object
70 * within the namespace.
72 * Currently, the only objects that require initialization are:
74 * 2) Operation Regions
76 ******************************************************************************/
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
;
87 union acpi_operand_object
*obj_desc
;
89 ACPI_FUNCTION_ENTRY();
92 * We are only interested in NS nodes owned by the table that
95 if (node
->owner_id
!= info
->owner_id
) {
101 /* And even then, we are only interested in a few object types */
103 switch (acpi_ns_get_type(obj_handle
)) {
104 case ACPI_TYPE_REGION
:
106 status
= acpi_ds_initialize_region(obj_handle
);
107 if (ACPI_FAILURE(status
)) {
108 ACPI_EXCEPTION((AE_INFO
, status
,
109 "During Region initialization %p [%4.4s]",
111 acpi_ut_get_node_name(obj_handle
)));
114 info
->op_region_count
++;
117 case ACPI_TYPE_METHOD
:
119 * Auto-serialization support. We will examine each method that is
120 * not_serialized to determine if it creates any Named objects. If
121 * it does, it will be marked serialized to prevent problems if
122 * the method is entered by two or more threads and an attempt is
123 * made to create the same named object twice -- which results in
124 * an AE_ALREADY_EXISTS exception and method abort.
126 info
->method_count
++;
127 obj_desc
= acpi_ns_get_attached_object(node
);
132 /* Ignore if already serialized */
134 if (obj_desc
->method
.info_flags
& ACPI_METHOD_SERIALIZED
) {
135 info
->serial_method_count
++;
139 if (acpi_gbl_auto_serialize_methods
) {
141 /* Parse/scan method and serialize it if necessary */
143 acpi_ds_auto_serialize_method(node
, obj_desc
);
144 if (obj_desc
->method
.
145 info_flags
& ACPI_METHOD_SERIALIZED
) {
147 /* Method was just converted to Serialized */
149 info
->serial_method_count
++;
150 info
->serialized_method_count
++;
155 info
->non_serial_method_count
++;
158 case ACPI_TYPE_DEVICE
:
160 info
->device_count
++;
169 * We ignore errors from above, and always return OK, since
170 * we don't want to abort the walk on a single error.
175 /*******************************************************************************
177 * FUNCTION: acpi_ds_initialize_objects
179 * PARAMETERS: table_desc - Descriptor for parent ACPI table
180 * start_node - Root of subtree to be initialized.
184 * DESCRIPTION: Walk the namespace starting at "StartNode" and perform any
185 * necessary initialization on the objects found therein
187 ******************************************************************************/
190 acpi_ds_initialize_objects(u32 table_index
,
191 struct acpi_namespace_node
* start_node
)
194 struct acpi_init_walk_info info
;
195 struct acpi_table_header
*table
;
196 acpi_owner_id owner_id
;
198 ACPI_FUNCTION_TRACE(ds_initialize_objects
);
200 status
= acpi_tb_get_owner_id(table_index
, &owner_id
);
201 if (ACPI_FAILURE(status
)) {
202 return_ACPI_STATUS(status
);
205 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH
,
206 "**** Starting initialization of namespace objects ****\n"));
208 /* Set all init info to zero */
210 memset(&info
, 0, sizeof(struct acpi_init_walk_info
));
212 info
.owner_id
= owner_id
;
213 info
.table_index
= table_index
;
215 /* Walk entire namespace from the supplied root */
217 status
= acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE
);
218 if (ACPI_FAILURE(status
)) {
219 return_ACPI_STATUS(status
);
223 * We don't use acpi_walk_namespace since we do not want to acquire
224 * the namespace reader lock.
227 acpi_ns_walk_namespace(ACPI_TYPE_ANY
, start_node
, ACPI_UINT32_MAX
,
228 ACPI_NS_WALK_UNLOCK
, acpi_ds_init_one_object
,
230 if (ACPI_FAILURE(status
)) {
231 ACPI_EXCEPTION((AE_INFO
, status
, "During WalkNamespace"));
233 (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE
);
235 status
= acpi_get_table_by_index(table_index
, &table
);
236 if (ACPI_FAILURE(status
)) {
237 return_ACPI_STATUS(status
);
240 /* DSDT is always the first AML table */
242 if (ACPI_COMPARE_NAME(table
->signature
, ACPI_SIG_DSDT
)) {
243 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT
,
244 "\nInitializing Namespace objects:\n"));
247 /* Summary of objects initialized */
249 ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT
,
250 "Table [%4.4s:%8.8s] (id %.2X) - %4u Objects with %3u Devices, "
251 "%3u Regions, %4u Methods (%u/%u/%u Serial/Non/Cvt)\n",
252 table
->signature
, table
->oem_table_id
, owner_id
,
253 info
.object_count
, info
.device_count
,
254 info
.op_region_count
, info
.method_count
,
255 info
.serial_method_count
,
256 info
.non_serial_method_count
,
257 info
.serialized_method_count
));
259 ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH
, "%u Methods, %u Regions\n",
260 info
.method_count
, info
.op_region_count
));
262 return_ACPI_STATUS(AE_OK
);