Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /****************************************************************************** |
2 | * | |
3 | * Module Name: dsinit - Object initialization namespace walk | |
4 | * | |
5 | *****************************************************************************/ | |
6 | ||
7 | /* | |
c8100dc4 | 8 | * Copyright (C) 2000 - 2016, Intel Corp. |
1da177e4 LT |
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 | ||
1da177e4 | 44 | #include <acpi/acpi.h> |
e2f7a777 LB |
45 | #include "accommon.h" |
46 | #include "acdispat.h" | |
47 | #include "acnamesp.h" | |
48 | #include "actables.h" | |
8633db6b | 49 | #include "acinterp.h" |
1da177e4 LT |
50 | |
51 | #define _COMPONENT ACPI_DISPATCHER | |
4be44fcd | 52 | ACPI_MODULE_NAME("dsinit") |
1da177e4 | 53 | |
44f6c012 | 54 | /* Local prototypes */ |
44f6c012 | 55 | static acpi_status |
4be44fcd LB |
56 | acpi_ds_init_one_object(acpi_handle obj_handle, |
57 | u32 level, void *context, void **return_value); | |
1da177e4 LT |
58 | |
59 | /******************************************************************************* | |
60 | * | |
61 | * FUNCTION: acpi_ds_init_one_object | |
62 | * | |
44f6c012 | 63 | * PARAMETERS: obj_handle - Node for the object |
ba494bee BM |
64 | * level - Current nesting level |
65 | * context - Points to a init info struct | |
1da177e4 LT |
66 | * return_value - Not used |
67 | * | |
68 | * RETURN: Status | |
69 | * | |
70 | * DESCRIPTION: Callback from acpi_walk_namespace. Invoked for every object | |
71 | * within the namespace. | |
72 | * | |
73 | * Currently, the only objects that require initialization are: | |
74 | * 1) Methods | |
75 | * 2) Operation Regions | |
76 | * | |
77 | ******************************************************************************/ | |
78 | ||
44f6c012 | 79 | static acpi_status |
4be44fcd LB |
80 | acpi_ds_init_one_object(acpi_handle obj_handle, |
81 | u32 level, void *context, void **return_value) | |
1da177e4 | 82 | { |
4be44fcd LB |
83 | struct acpi_init_walk_info *info = |
84 | (struct acpi_init_walk_info *)context; | |
85 | struct acpi_namespace_node *node = | |
86 | (struct acpi_namespace_node *)obj_handle; | |
4be44fcd | 87 | acpi_status status; |
22b5afce | 88 | union acpi_operand_object *obj_desc; |
1da177e4 | 89 | |
4a90c7e8 | 90 | ACPI_FUNCTION_ENTRY(); |
1da177e4 LT |
91 | |
92 | /* | |
0c9938cc | 93 | * We are only interested in NS nodes owned by the table that |
1da177e4 LT |
94 | * was just loaded |
95 | */ | |
f3d2e786 | 96 | if (node->owner_id != info->owner_id) { |
1da177e4 LT |
97 | return (AE_OK); |
98 | } | |
99 | ||
100 | info->object_count++; | |
101 | ||
102 | /* And even then, we are only interested in a few object types */ | |
103 | ||
22b5afce | 104 | switch (acpi_ns_get_type(obj_handle)) { |
1da177e4 LT |
105 | case ACPI_TYPE_REGION: |
106 | ||
4be44fcd LB |
107 | status = acpi_ds_initialize_region(obj_handle); |
108 | if (ACPI_FAILURE(status)) { | |
b8e4d893 BM |
109 | ACPI_EXCEPTION((AE_INFO, status, |
110 | "During Region initialization %p [%4.4s]", | |
111 | obj_handle, | |
112 | acpi_ut_get_node_name(obj_handle))); | |
1da177e4 LT |
113 | } |
114 | ||
115 | info->op_region_count++; | |
116 | break; | |
117 | ||
1da177e4 | 118 | case ACPI_TYPE_METHOD: |
22b5afce BM |
119 | /* |
120 | * Auto-serialization support. We will examine each method that is | |
121 | * not_serialized to determine if it creates any Named objects. If | |
122 | * it does, it will be marked serialized to prevent problems if | |
123 | * the method is entered by two or more threads and an attempt is | |
124 | * made to create the same named object twice -- which results in | |
125 | * an AE_ALREADY_EXISTS exception and method abort. | |
126 | */ | |
0c9938cc | 127 | info->method_count++; |
22b5afce BM |
128 | obj_desc = acpi_ns_get_attached_object(node); |
129 | if (!obj_desc) { | |
130 | break; | |
131 | } | |
132 | ||
133 | /* Ignore if already serialized */ | |
134 | ||
135 | if (obj_desc->method.info_flags & ACPI_METHOD_SERIALIZED) { | |
136 | info->serial_method_count++; | |
137 | break; | |
138 | } | |
139 | ||
140 | if (acpi_gbl_auto_serialize_methods) { | |
141 | ||
142 | /* Parse/scan method and serialize it if necessary */ | |
143 | ||
144 | acpi_ds_auto_serialize_method(node, obj_desc); | |
145 | if (obj_desc->method. | |
146 | info_flags & ACPI_METHOD_SERIALIZED) { | |
147 | ||
148 | /* Method was just converted to Serialized */ | |
149 | ||
150 | info->serial_method_count++; | |
151 | info->serialized_method_count++; | |
152 | break; | |
153 | } | |
154 | } | |
155 | ||
156 | info->non_serial_method_count++; | |
1da177e4 LT |
157 | break; |
158 | ||
1da177e4 LT |
159 | case ACPI_TYPE_DEVICE: |
160 | ||
161 | info->device_count++; | |
162 | break; | |
163 | ||
1da177e4 | 164 | default: |
1d1ea1b7 | 165 | |
1da177e4 LT |
166 | break; |
167 | } | |
168 | ||
169 | /* | |
170 | * We ignore errors from above, and always return OK, since | |
171 | * we don't want to abort the walk on a single error. | |
172 | */ | |
173 | return (AE_OK); | |
174 | } | |
175 | ||
1da177e4 LT |
176 | /******************************************************************************* |
177 | * | |
178 | * FUNCTION: acpi_ds_initialize_objects | |
179 | * | |
180 | * PARAMETERS: table_desc - Descriptor for parent ACPI table | |
181 | * start_node - Root of subtree to be initialized. | |
182 | * | |
183 | * RETURN: Status | |
184 | * | |
b229cf92 | 185 | * DESCRIPTION: Walk the namespace starting at "StartNode" and perform any |
1da177e4 LT |
186 | * necessary initialization on the objects found therein |
187 | * | |
188 | ******************************************************************************/ | |
189 | ||
190 | acpi_status | |
67a119f9 | 191 | acpi_ds_initialize_objects(u32 table_index, |
f5c1e1c5 | 192 | struct acpi_namespace_node *start_node) |
1da177e4 | 193 | { |
4be44fcd LB |
194 | acpi_status status; |
195 | struct acpi_init_walk_info info; | |
f3d2e786 BM |
196 | struct acpi_table_header *table; |
197 | acpi_owner_id owner_id; | |
1da177e4 | 198 | |
b229cf92 | 199 | ACPI_FUNCTION_TRACE(ds_initialize_objects); |
1da177e4 | 200 | |
f3d2e786 BM |
201 | status = acpi_tb_get_owner_id(table_index, &owner_id); |
202 | if (ACPI_FAILURE(status)) { | |
203 | return_ACPI_STATUS(status); | |
204 | } | |
205 | ||
4be44fcd LB |
206 | ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, |
207 | "**** Starting initialization of namespace objects ****\n")); | |
1da177e4 | 208 | |
96b7b7ad AS |
209 | /* Set all init info to zero */ |
210 | ||
4fa4616e | 211 | memset(&info, 0, sizeof(struct acpi_init_walk_info)); |
96b7b7ad | 212 | |
f3d2e786 | 213 | info.owner_id = owner_id; |
96b7b7ad | 214 | info.table_index = table_index; |
1da177e4 LT |
215 | |
216 | /* Walk entire namespace from the supplied root */ | |
217 | ||
8a335a23 BM |
218 | /* |
219 | * We don't use acpi_walk_namespace since we do not want to acquire | |
220 | * the namespace reader lock. | |
221 | */ | |
222 | status = | |
223 | acpi_ns_walk_namespace(ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX, | |
8633db6b LZ |
224 | 0, acpi_ds_init_one_object, NULL, &info, |
225 | NULL); | |
4be44fcd | 226 | if (ACPI_FAILURE(status)) { |
b229cf92 | 227 | ACPI_EXCEPTION((AE_INFO, status, "During WalkNamespace")); |
1da177e4 LT |
228 | } |
229 | ||
f3d2e786 BM |
230 | status = acpi_get_table_by_index(table_index, &table); |
231 | if (ACPI_FAILURE(status)) { | |
232 | return_ACPI_STATUS(status); | |
233 | } | |
234 | ||
92b21a95 BM |
235 | /* DSDT is always the first AML table */ |
236 | ||
237 | if (ACPI_COMPARE_NAME(table->signature, ACPI_SIG_DSDT)) { | |
238 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, | |
239 | "\nInitializing Namespace objects:\n")); | |
240 | } | |
241 | ||
242 | /* Summary of objects initialized */ | |
243 | ||
4be44fcd | 244 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, |
1fad8738 | 245 | "Table [%4.4s: %-8.8s] (id %.2X) - %4u Objects with %3u Devices, " |
3c0503dd BM |
246 | "%3u Regions, %4u Methods (%u/%u/%u Serial/Non/Cvt)\n", |
247 | table->signature, table->oem_table_id, owner_id, | |
248 | info.object_count, info.device_count, | |
249 | info.op_region_count, info.method_count, | |
250 | info.serial_method_count, | |
22b5afce BM |
251 | info.non_serial_method_count, |
252 | info.serialized_method_count)); | |
1da177e4 | 253 | |
22b5afce BM |
254 | ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, "%u Methods, %u Regions\n", |
255 | info.method_count, info.op_region_count)); | |
1da177e4 | 256 | |
4be44fcd | 257 | return_ACPI_STATUS(AE_OK); |
1da177e4 | 258 | } |