1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44#include <acpi/acpi.h>
45#include "accommon.h"
46#include "acdispat.h"
47#include "acinterp.h"
48#include "acnamesp.h"
49
50#define _COMPONENT ACPI_EXECUTER
51ACPI_MODULE_NAME("exresnte")
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78acpi_status
79acpi_ex_resolve_node_to_value(struct acpi_namespace_node **object_ptr,
80 struct acpi_walk_state *walk_state)
81{
82 acpi_status status = AE_OK;
83 union acpi_operand_object *source_desc;
84 union acpi_operand_object *obj_desc = NULL;
85 struct acpi_namespace_node *node;
86 acpi_object_type entry_type;
87
88 ACPI_FUNCTION_TRACE(ex_resolve_node_to_value);
89
90
91
92
93
94 node = *object_ptr;
95 source_desc = acpi_ns_get_attached_object(node);
96 entry_type = acpi_ns_get_type((acpi_handle) node);
97
98 ACPI_DEBUG_PRINT((ACPI_DB_EXEC, "Entry=%p SourceDesc=%p [%s]\n",
99 node, source_desc,
100 acpi_ut_get_type_name(entry_type)));
101
102 if ((entry_type == ACPI_TYPE_LOCAL_ALIAS) ||
103 (entry_type == ACPI_TYPE_LOCAL_METHOD_ALIAS)) {
104
105
106
107 node = ACPI_CAST_PTR(struct acpi_namespace_node, node->object);
108 source_desc = acpi_ns_get_attached_object(node);
109 entry_type = acpi_ns_get_type((acpi_handle) node);
110 *object_ptr = node;
111 }
112
113
114
115
116
117
118
119 if ((entry_type == ACPI_TYPE_DEVICE) ||
120 (entry_type == ACPI_TYPE_THERMAL) ||
121 (entry_type == ACPI_TYPE_METHOD) ||
122 (node->flags & (ANOBJ_METHOD_ARG | ANOBJ_METHOD_LOCAL))) {
123 return_ACPI_STATUS(AE_OK);
124 }
125
126 if (!source_desc) {
127 ACPI_ERROR((AE_INFO, "No object attached to node [%4.4s] %p",
128 node->name.ascii, node));
129 return_ACPI_STATUS(AE_AML_NO_OPERAND);
130 }
131
132
133
134
135
136 switch (entry_type) {
137 case ACPI_TYPE_PACKAGE:
138
139 if (source_desc->common.type != ACPI_TYPE_PACKAGE) {
140 ACPI_ERROR((AE_INFO, "Object not a Package, type %s",
141 acpi_ut_get_object_type_name(source_desc)));
142 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
143 }
144
145 status = acpi_ds_get_package_arguments(source_desc);
146 if (ACPI_SUCCESS(status)) {
147
148
149
150 obj_desc = source_desc;
151 acpi_ut_add_reference(obj_desc);
152 }
153 break;
154
155 case ACPI_TYPE_BUFFER:
156
157 if (source_desc->common.type != ACPI_TYPE_BUFFER) {
158 ACPI_ERROR((AE_INFO, "Object not a Buffer, type %s",
159 acpi_ut_get_object_type_name(source_desc)));
160 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
161 }
162
163 status = acpi_ds_get_buffer_arguments(source_desc);
164 if (ACPI_SUCCESS(status)) {
165
166
167
168 obj_desc = source_desc;
169 acpi_ut_add_reference(obj_desc);
170 }
171 break;
172
173 case ACPI_TYPE_STRING:
174
175 if (source_desc->common.type != ACPI_TYPE_STRING) {
176 ACPI_ERROR((AE_INFO, "Object not a String, type %s",
177 acpi_ut_get_object_type_name(source_desc)));
178 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
179 }
180
181
182
183 obj_desc = source_desc;
184 acpi_ut_add_reference(obj_desc);
185 break;
186
187 case ACPI_TYPE_INTEGER:
188
189 if (source_desc->common.type != ACPI_TYPE_INTEGER) {
190 ACPI_ERROR((AE_INFO, "Object not a Integer, type %s",
191 acpi_ut_get_object_type_name(source_desc)));
192 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
193 }
194
195
196
197 obj_desc = source_desc;
198 acpi_ut_add_reference(obj_desc);
199 break;
200
201 case ACPI_TYPE_BUFFER_FIELD:
202 case ACPI_TYPE_LOCAL_REGION_FIELD:
203 case ACPI_TYPE_LOCAL_BANK_FIELD:
204 case ACPI_TYPE_LOCAL_INDEX_FIELD:
205
206 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
207 "FieldRead Node=%p SourceDesc=%p Type=%X\n",
208 node, source_desc, entry_type));
209
210 status =
211 acpi_ex_read_data_from_field(walk_state, source_desc,
212 &obj_desc);
213 break;
214
215
216
217 case ACPI_TYPE_MUTEX:
218 case ACPI_TYPE_POWER:
219 case ACPI_TYPE_PROCESSOR:
220 case ACPI_TYPE_EVENT:
221 case ACPI_TYPE_REGION:
222
223
224
225 obj_desc = source_desc;
226 acpi_ut_add_reference(obj_desc);
227 break;
228
229
230
231 case ACPI_TYPE_ANY:
232
233 ACPI_ERROR((AE_INFO,
234 "Untyped entry %p, no attached object!", node));
235
236 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
237
238 case ACPI_TYPE_LOCAL_REFERENCE:
239
240 switch (source_desc->reference.class) {
241 case ACPI_REFCLASS_TABLE:
242 case ACPI_REFCLASS_REFOF:
243 case ACPI_REFCLASS_INDEX:
244
245
246
247 obj_desc = source_desc;
248 acpi_ut_add_reference(obj_desc);
249 break;
250
251 default:
252
253
254
255 ACPI_ERROR((AE_INFO,
256 "Unsupported Reference type 0x%X",
257 source_desc->reference.class));
258
259 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
260 }
261 break;
262
263 default:
264
265
266
267 ACPI_ERROR((AE_INFO,
268 "Node %p - Unknown object type 0x%X",
269 node, entry_type));
270
271 return_ACPI_STATUS(AE_AML_OPERAND_TYPE);
272
273 }
274
275
276
277 *object_ptr = (void *)obj_desc;
278 return_ACPI_STATUS(status);
279}
280