Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /****************************************************************************** |
2 | * | |
3 | * Module Name: dsinit - Object initialization namespace walk | |
4 | * | |
5 | *****************************************************************************/ | |
6 | ||
7 | /* | |
25f044e6 | 8 | * Copyright (C) 2000 - 2013, 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" | |
1da177e4 LT |
49 | |
50 | #define _COMPONENT ACPI_DISPATCHER | |
4be44fcd | 51 | ACPI_MODULE_NAME("dsinit") |
1da177e4 | 52 | |
44f6c012 | 53 | /* Local prototypes */ |
44f6c012 | 54 | static acpi_status |
4be44fcd LB |
55 | acpi_ds_init_one_object(acpi_handle obj_handle, |
56 | u32 level, void *context, void **return_value); | |
1da177e4 LT |
57 | |
58 | /******************************************************************************* | |
59 | * | |
60 | * FUNCTION: acpi_ds_init_one_object | |
61 | * | |
44f6c012 | 62 | * PARAMETERS: obj_handle - Node for the object |
ba494bee BM |
63 | * level - Current nesting level |
64 | * context - Points to a init info struct | |
1da177e4 LT |
65 | * return_value - Not used |
66 | * | |
67 | * RETURN: Status | |
68 | * | |
69 | * DESCRIPTION: Callback from acpi_walk_namespace. Invoked for every object | |
70 | * within the namespace. | |
71 | * | |
72 | * Currently, the only objects that require initialization are: | |
73 | * 1) Methods | |
74 | * 2) Operation Regions | |
75 | * | |
76 | ******************************************************************************/ | |
77 | ||
44f6c012 | 78 | static acpi_status |
4be44fcd LB |
79 | acpi_ds_init_one_object(acpi_handle obj_handle, |
80 | u32 level, void *context, void **return_value) | |
1da177e4 | 81 | { |
4be44fcd LB |
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; | |
86 | acpi_object_type type; | |
87 | acpi_status status; | |
1da177e4 | 88 | |
4a90c7e8 | 89 | ACPI_FUNCTION_ENTRY(); |
1da177e4 LT |
90 | |
91 | /* | |
0c9938cc | 92 | * We are only interested in NS nodes owned by the table that |
1da177e4 LT |
93 | * was just loaded |
94 | */ | |
f3d2e786 | 95 | if (node->owner_id != info->owner_id) { |
1da177e4 LT |
96 | return (AE_OK); |
97 | } | |
98 | ||
99 | info->object_count++; | |
100 | ||
101 | /* And even then, we are only interested in a few object types */ | |
102 | ||
4be44fcd | 103 | type = acpi_ns_get_type(obj_handle); |
1da177e4 LT |
104 | |
105 | switch (type) { | |
106 | case ACPI_TYPE_REGION: | |
107 | ||
4be44fcd LB |
108 | status = acpi_ds_initialize_region(obj_handle); |
109 | if (ACPI_FAILURE(status)) { | |
b8e4d893 BM |
110 | ACPI_EXCEPTION((AE_INFO, status, |
111 | "During Region initialization %p [%4.4s]", | |
112 | obj_handle, | |
113 | acpi_ut_get_node_name(obj_handle))); | |
1da177e4 LT |
114 | } |
115 | ||
116 | info->op_region_count++; | |
117 | break; | |
118 | ||
1da177e4 LT |
119 | case ACPI_TYPE_METHOD: |
120 | ||
0c9938cc | 121 | info->method_count++; |
1da177e4 LT |
122 | break; |
123 | ||
1da177e4 LT |
124 | case ACPI_TYPE_DEVICE: |
125 | ||
126 | info->device_count++; | |
127 | break; | |
128 | ||
1da177e4 | 129 | default: |
1d1ea1b7 | 130 | |
1da177e4 LT |
131 | break; |
132 | } | |
133 | ||
134 | /* | |
135 | * We ignore errors from above, and always return OK, since | |
136 | * we don't want to abort the walk on a single error. | |
137 | */ | |
138 | return (AE_OK); | |
139 | } | |
140 | ||
1da177e4 LT |
141 | /******************************************************************************* |
142 | * | |
143 | * FUNCTION: acpi_ds_initialize_objects | |
144 | * | |
145 | * PARAMETERS: table_desc - Descriptor for parent ACPI table | |
146 | * start_node - Root of subtree to be initialized. | |
147 | * | |
148 | * RETURN: Status | |
149 | * | |
b229cf92 | 150 | * DESCRIPTION: Walk the namespace starting at "StartNode" and perform any |
1da177e4 LT |
151 | * necessary initialization on the objects found therein |
152 | * | |
153 | ******************************************************************************/ | |
154 | ||
155 | acpi_status | |
67a119f9 | 156 | acpi_ds_initialize_objects(u32 table_index, |
4be44fcd | 157 | struct acpi_namespace_node * start_node) |
1da177e4 | 158 | { |
4be44fcd LB |
159 | acpi_status status; |
160 | struct acpi_init_walk_info info; | |
f3d2e786 BM |
161 | struct acpi_table_header *table; |
162 | acpi_owner_id owner_id; | |
1da177e4 | 163 | |
b229cf92 | 164 | ACPI_FUNCTION_TRACE(ds_initialize_objects); |
1da177e4 | 165 | |
f3d2e786 BM |
166 | status = acpi_tb_get_owner_id(table_index, &owner_id); |
167 | if (ACPI_FAILURE(status)) { | |
168 | return_ACPI_STATUS(status); | |
169 | } | |
170 | ||
4be44fcd LB |
171 | ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, |
172 | "**** Starting initialization of namespace objects ****\n")); | |
173 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, "Parsing all Control Methods:")); | |
1da177e4 | 174 | |
96b7b7ad AS |
175 | /* Set all init info to zero */ |
176 | ||
177 | ACPI_MEMSET(&info, 0, sizeof(struct acpi_init_walk_info)); | |
178 | ||
f3d2e786 | 179 | info.owner_id = owner_id; |
96b7b7ad | 180 | info.table_index = table_index; |
1da177e4 LT |
181 | |
182 | /* Walk entire namespace from the supplied root */ | |
183 | ||
8a335a23 BM |
184 | status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE); |
185 | if (ACPI_FAILURE(status)) { | |
186 | return_ACPI_STATUS(status); | |
187 | } | |
188 | ||
189 | /* | |
190 | * We don't use acpi_walk_namespace since we do not want to acquire | |
191 | * the namespace reader lock. | |
192 | */ | |
193 | status = | |
194 | acpi_ns_walk_namespace(ACPI_TYPE_ANY, start_node, ACPI_UINT32_MAX, | |
195 | ACPI_NS_WALK_UNLOCK, acpi_ds_init_one_object, | |
2263576c | 196 | NULL, &info, NULL); |
4be44fcd | 197 | if (ACPI_FAILURE(status)) { |
b229cf92 | 198 | ACPI_EXCEPTION((AE_INFO, status, "During WalkNamespace")); |
1da177e4 | 199 | } |
8a335a23 | 200 | (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE); |
1da177e4 | 201 | |
f3d2e786 BM |
202 | status = acpi_get_table_by_index(table_index, &table); |
203 | if (ACPI_FAILURE(status)) { | |
204 | return_ACPI_STATUS(status); | |
205 | } | |
206 | ||
4be44fcd | 207 | ACPI_DEBUG_PRINT_RAW((ACPI_DB_INIT, |
96b7b7ad | 208 | "\nTable [%4.4s](id %4.4X) - %u Objects with %u Devices %u Methods %u Regions\n", |
f3d2e786 | 209 | table->signature, owner_id, info.object_count, |
4be44fcd LB |
210 | info.device_count, info.method_count, |
211 | info.op_region_count)); | |
1da177e4 | 212 | |
4be44fcd | 213 | ACPI_DEBUG_PRINT((ACPI_DB_DISPATCH, |
96b7b7ad | 214 | "%u Methods, %u Regions\n", info.method_count, |
4be44fcd | 215 | info.op_region_count)); |
1da177e4 | 216 | |
4be44fcd | 217 | return_ACPI_STATUS(AE_OK); |
1da177e4 | 218 | } |