This source file includes following definitions.
- ACPI_MODULE_NAME
- acpi_ut_evaluate_numeric_object
- acpi_ut_execute_STA
- acpi_ut_execute_power_methods
1
2
3
4
5
6
7
8
9
10 #include <acpi/acpi.h>
11 #include "accommon.h"
12 #include "acnamesp.h"
13
14 #define _COMPONENT ACPI_UTILITIES
15 ACPI_MODULE_NAME("uteval")
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36 acpi_status
37 acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node,
38 const char *path,
39 u32 expected_return_btypes,
40 union acpi_operand_object **return_desc)
41 {
42 struct acpi_evaluate_info *info;
43 acpi_status status;
44 u32 return_btype;
45
46 ACPI_FUNCTION_TRACE(ut_evaluate_object);
47
48
49
50 info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_evaluate_info));
51 if (!info) {
52 return_ACPI_STATUS(AE_NO_MEMORY);
53 }
54
55 info->prefix_node = prefix_node;
56 info->relative_pathname = path;
57
58
59
60 status = acpi_ns_evaluate(info);
61 if (ACPI_FAILURE(status)) {
62 if (status == AE_NOT_FOUND) {
63 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
64 "[%4.4s.%s] was not found\n",
65 acpi_ut_get_node_name(prefix_node),
66 path));
67 } else {
68 ACPI_ERROR_METHOD("Method execution failed",
69 prefix_node, path, status);
70 }
71
72 goto cleanup;
73 }
74
75
76
77 if (!info->return_object) {
78 if (expected_return_btypes) {
79 ACPI_ERROR_METHOD("No object was returned from",
80 prefix_node, path, AE_NOT_EXIST);
81
82 status = AE_NOT_EXIST;
83 }
84
85 goto cleanup;
86 }
87
88
89
90 switch ((info->return_object)->common.type) {
91 case ACPI_TYPE_INTEGER:
92
93 return_btype = ACPI_BTYPE_INTEGER;
94 break;
95
96 case ACPI_TYPE_BUFFER:
97
98 return_btype = ACPI_BTYPE_BUFFER;
99 break;
100
101 case ACPI_TYPE_STRING:
102
103 return_btype = ACPI_BTYPE_STRING;
104 break;
105
106 case ACPI_TYPE_PACKAGE:
107
108 return_btype = ACPI_BTYPE_PACKAGE;
109 break;
110
111 default:
112
113 return_btype = 0;
114 break;
115 }
116
117 if ((acpi_gbl_enable_interpreter_slack) && (!expected_return_btypes)) {
118
119
120
121
122
123 acpi_ut_remove_reference(info->return_object);
124 goto cleanup;
125 }
126
127
128
129 if (!(expected_return_btypes & return_btype)) {
130 ACPI_ERROR_METHOD("Return object type is incorrect",
131 prefix_node, path, AE_TYPE);
132
133 ACPI_ERROR((AE_INFO,
134 "Type returned from %s was incorrect: %s, expected Btypes: 0x%X",
135 path,
136 acpi_ut_get_object_type_name(info->return_object),
137 expected_return_btypes));
138
139
140
141 acpi_ut_remove_reference(info->return_object);
142 status = AE_TYPE;
143 goto cleanup;
144 }
145
146
147
148 *return_desc = info->return_object;
149
150 cleanup:
151 ACPI_FREE(info);
152 return_ACPI_STATUS(status);
153 }
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172 acpi_status
173 acpi_ut_evaluate_numeric_object(const char *object_name,
174 struct acpi_namespace_node *device_node,
175 u64 *value)
176 {
177 union acpi_operand_object *obj_desc;
178 acpi_status status;
179
180 ACPI_FUNCTION_TRACE(ut_evaluate_numeric_object);
181
182 status = acpi_ut_evaluate_object(device_node, object_name,
183 ACPI_BTYPE_INTEGER, &obj_desc);
184 if (ACPI_FAILURE(status)) {
185 return_ACPI_STATUS(status);
186 }
187
188
189
190 *value = obj_desc->integer.value;
191
192
193
194 acpi_ut_remove_reference(obj_desc);
195 return_ACPI_STATUS(status);
196 }
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215 acpi_status
216 acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 * flags)
217 {
218 union acpi_operand_object *obj_desc;
219 acpi_status status;
220
221 ACPI_FUNCTION_TRACE(ut_execute_STA);
222
223 status = acpi_ut_evaluate_object(device_node, METHOD_NAME__STA,
224 ACPI_BTYPE_INTEGER, &obj_desc);
225 if (ACPI_FAILURE(status)) {
226 if (AE_NOT_FOUND == status) {
227
228
229
230
231
232 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
233 "_STA on %4.4s was not found, assuming device is present\n",
234 acpi_ut_get_node_name(device_node)));
235
236 *flags = ACPI_UINT32_MAX;
237 status = AE_OK;
238 }
239
240 return_ACPI_STATUS(status);
241 }
242
243
244
245 *flags = (u32) obj_desc->integer.value;
246
247
248
249 acpi_ut_remove_reference(obj_desc);
250 return_ACPI_STATUS(status);
251 }
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271 acpi_status
272 acpi_ut_execute_power_methods(struct acpi_namespace_node *device_node,
273 const char **method_names,
274 u8 method_count, u8 *out_values)
275 {
276 union acpi_operand_object *obj_desc;
277 acpi_status status;
278 acpi_status final_status = AE_NOT_FOUND;
279 u32 i;
280
281 ACPI_FUNCTION_TRACE(ut_execute_power_methods);
282
283 for (i = 0; i < method_count; i++) {
284
285
286
287
288 status = acpi_ut_evaluate_object(device_node,
289 ACPI_CAST_PTR(char,
290 method_names[i]),
291 ACPI_BTYPE_INTEGER, &obj_desc);
292 if (ACPI_SUCCESS(status)) {
293 out_values[i] = (u8)obj_desc->integer.value;
294
295
296
297 acpi_ut_remove_reference(obj_desc);
298 final_status = AE_OK;
299 continue;
300 }
301
302 out_values[i] = ACPI_UINT8_MAX;
303 if (status == AE_NOT_FOUND) {
304 continue;
305 }
306
307 ACPI_DEBUG_PRINT((ACPI_DB_EXEC,
308 "Failed %s on Device %4.4s, %s\n",
309 ACPI_CAST_PTR(char, method_names[i]),
310 acpi_ut_get_node_name(device_node),
311 acpi_format_exception(status)));
312 }
313
314 return_ACPI_STATUS(final_status);
315 }