]>
Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /****************************************************************************** |
2 | * | |
3 | * Module Name: uteval - Object evaluation | |
4 | * | |
5 | *****************************************************************************/ | |
6 | ||
7 | /* | |
4a90c7e8 | 8 | * Copyright (C) 2000 - 2006, R. Byron Moore |
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 LT |
44 | #include <acpi/acpi.h> |
45 | #include <acpi/acnamesp.h> | |
46 | #include <acpi/acinterp.h> | |
47 | ||
1da177e4 | 48 | #define _COMPONENT ACPI_UTILITIES |
4be44fcd | 49 | ACPI_MODULE_NAME("uteval") |
1da177e4 | 50 | |
44f6c012 | 51 | /* Local prototypes */ |
44f6c012 | 52 | static void |
4be44fcd | 53 | acpi_ut_copy_id_string(char *destination, char *source, acpi_size max_length); |
44f6c012 RM |
54 | |
55 | static acpi_status | |
4be44fcd LB |
56 | acpi_ut_translate_one_cid(union acpi_operand_object *obj_desc, |
57 | struct acpi_compatible_id *one_cid); | |
1da177e4 LT |
58 | |
59 | /******************************************************************************* | |
60 | * | |
61 | * FUNCTION: acpi_ut_osi_implementation | |
62 | * | |
63 | * PARAMETERS: walk_state - Current walk state | |
64 | * | |
65 | * RETURN: Status | |
66 | * | |
67 | * DESCRIPTION: Implementation of _OSI predefined control method | |
68 | * Supported = _OSI (String) | |
69 | * | |
70 | ******************************************************************************/ | |
71 | ||
4be44fcd | 72 | acpi_status acpi_ut_osi_implementation(struct acpi_walk_state *walk_state) |
1da177e4 | 73 | { |
4be44fcd LB |
74 | union acpi_operand_object *string_desc; |
75 | union acpi_operand_object *return_desc; | |
76 | acpi_native_uint i; | |
1da177e4 | 77 | |
4be44fcd | 78 | ACPI_FUNCTION_TRACE("ut_osi_implementation"); |
1da177e4 LT |
79 | |
80 | /* Validate the string input argument */ | |
81 | ||
82 | string_desc = walk_state->arguments[0].object; | |
83 | if (!string_desc || (string_desc->common.type != ACPI_TYPE_STRING)) { | |
4be44fcd | 84 | return_ACPI_STATUS(AE_TYPE); |
1da177e4 LT |
85 | } |
86 | ||
87 | /* Create a return object (Default value = 0) */ | |
88 | ||
4be44fcd | 89 | return_desc = acpi_ut_create_internal_object(ACPI_TYPE_INTEGER); |
1da177e4 | 90 | if (!return_desc) { |
4be44fcd | 91 | return_ACPI_STATUS(AE_NO_MEMORY); |
1da177e4 LT |
92 | } |
93 | ||
94 | /* Compare input string to table of supported strings */ | |
95 | ||
96 | for (i = 0; i < ACPI_NUM_OSI_STRINGS; i++) { | |
4be44fcd | 97 | if (!ACPI_STRCMP(string_desc->string.pointer, |
defba1d8 BM |
98 | ACPI_CAST_PTR(char, |
99 | acpi_gbl_valid_osi_strings[i]))) | |
100 | { | |
52fc0b02 | 101 | |
1da177e4 LT |
102 | /* This string is supported */ |
103 | ||
104 | return_desc->integer.value = 0xFFFFFFFF; | |
105 | break; | |
106 | } | |
107 | } | |
108 | ||
109 | walk_state->return_desc = return_desc; | |
4be44fcd | 110 | return_ACPI_STATUS(AE_CTRL_TERMINATE); |
1da177e4 LT |
111 | } |
112 | ||
1da177e4 LT |
113 | /******************************************************************************* |
114 | * | |
115 | * FUNCTION: acpi_ut_evaluate_object | |
116 | * | |
117 | * PARAMETERS: prefix_node - Starting node | |
118 | * Path - Path to object from starting node | |
119 | * expected_return_types - Bitmap of allowed return types | |
120 | * return_desc - Where a return value is stored | |
121 | * | |
122 | * RETURN: Status | |
123 | * | |
124 | * DESCRIPTION: Evaluates a namespace object and verifies the type of the | |
125 | * return object. Common code that simplifies accessing objects | |
126 | * that have required return objects of fixed types. | |
127 | * | |
128 | * NOTE: Internal function, no parameter validation | |
129 | * | |
130 | ******************************************************************************/ | |
131 | ||
132 | acpi_status | |
4be44fcd LB |
133 | acpi_ut_evaluate_object(struct acpi_namespace_node *prefix_node, |
134 | char *path, | |
135 | u32 expected_return_btypes, | |
136 | union acpi_operand_object **return_desc) | |
1da177e4 | 137 | { |
4be44fcd LB |
138 | struct acpi_parameter_info info; |
139 | acpi_status status; | |
140 | u32 return_btype; | |
1da177e4 | 141 | |
4be44fcd | 142 | ACPI_FUNCTION_TRACE("ut_evaluate_object"); |
1da177e4 LT |
143 | |
144 | info.node = prefix_node; | |
145 | info.parameters = NULL; | |
146 | info.parameter_type = ACPI_PARAM_ARGS; | |
147 | ||
148 | /* Evaluate the object/method */ | |
149 | ||
4be44fcd LB |
150 | status = acpi_ns_evaluate_relative(path, &info); |
151 | if (ACPI_FAILURE(status)) { | |
1da177e4 | 152 | if (status == AE_NOT_FOUND) { |
4be44fcd LB |
153 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
154 | "[%4.4s.%s] was not found\n", | |
155 | acpi_ut_get_node_name(prefix_node), | |
156 | path)); | |
157 | } else { | |
b8e4d893 BM |
158 | ACPI_ERROR_METHOD("Method execution failed", |
159 | prefix_node, path, status); | |
1da177e4 LT |
160 | } |
161 | ||
4be44fcd | 162 | return_ACPI_STATUS(status); |
1da177e4 LT |
163 | } |
164 | ||
165 | /* Did we get a return object? */ | |
166 | ||
167 | if (!info.return_object) { | |
168 | if (expected_return_btypes) { | |
b8e4d893 BM |
169 | ACPI_ERROR_METHOD("No object was returned from", |
170 | prefix_node, path, AE_NOT_EXIST); | |
1da177e4 | 171 | |
4be44fcd | 172 | return_ACPI_STATUS(AE_NOT_EXIST); |
1da177e4 LT |
173 | } |
174 | ||
4be44fcd | 175 | return_ACPI_STATUS(AE_OK); |
1da177e4 LT |
176 | } |
177 | ||
178 | /* Map the return object type to the bitmapped type */ | |
179 | ||
4be44fcd | 180 | switch (ACPI_GET_OBJECT_TYPE(info.return_object)) { |
1da177e4 LT |
181 | case ACPI_TYPE_INTEGER: |
182 | return_btype = ACPI_BTYPE_INTEGER; | |
183 | break; | |
184 | ||
185 | case ACPI_TYPE_BUFFER: | |
186 | return_btype = ACPI_BTYPE_BUFFER; | |
187 | break; | |
188 | ||
189 | case ACPI_TYPE_STRING: | |
190 | return_btype = ACPI_BTYPE_STRING; | |
191 | break; | |
192 | ||
193 | case ACPI_TYPE_PACKAGE: | |
194 | return_btype = ACPI_BTYPE_PACKAGE; | |
195 | break; | |
196 | ||
197 | default: | |
198 | return_btype = 0; | |
199 | break; | |
200 | } | |
201 | ||
4be44fcd | 202 | if ((acpi_gbl_enable_interpreter_slack) && (!expected_return_btypes)) { |
1da177e4 LT |
203 | /* |
204 | * We received a return object, but one was not expected. This can | |
205 | * happen frequently if the "implicit return" feature is enabled. | |
206 | * Just delete the return object and return AE_OK. | |
207 | */ | |
4be44fcd LB |
208 | acpi_ut_remove_reference(info.return_object); |
209 | return_ACPI_STATUS(AE_OK); | |
1da177e4 LT |
210 | } |
211 | ||
212 | /* Is the return object one of the expected types? */ | |
213 | ||
214 | if (!(expected_return_btypes & return_btype)) { | |
b8e4d893 BM |
215 | ACPI_ERROR_METHOD("Return object type is incorrect", |
216 | prefix_node, path, AE_TYPE); | |
217 | ||
218 | ACPI_ERROR((AE_INFO, | |
219 | "Type returned from %s was incorrect: %s, expected Btypes: %X", | |
220 | path, | |
221 | acpi_ut_get_object_type_name(info.return_object), | |
222 | expected_return_btypes)); | |
1da177e4 LT |
223 | |
224 | /* On error exit, we must delete the return object */ | |
225 | ||
4be44fcd LB |
226 | acpi_ut_remove_reference(info.return_object); |
227 | return_ACPI_STATUS(AE_TYPE); | |
1da177e4 LT |
228 | } |
229 | ||
230 | /* Object type is OK, return it */ | |
231 | ||
232 | *return_desc = info.return_object; | |
4be44fcd | 233 | return_ACPI_STATUS(AE_OK); |
1da177e4 LT |
234 | } |
235 | ||
1da177e4 LT |
236 | /******************************************************************************* |
237 | * | |
238 | * FUNCTION: acpi_ut_evaluate_numeric_object | |
239 | * | |
44f6c012 | 240 | * PARAMETERS: object_name - Object name to be evaluated |
1da177e4 | 241 | * device_node - Node for the device |
44f6c012 | 242 | * Address - Where the value is returned |
1da177e4 LT |
243 | * |
244 | * RETURN: Status | |
245 | * | |
246 | * DESCRIPTION: Evaluates a numeric namespace object for a selected device | |
247 | * and stores result in *Address. | |
248 | * | |
249 | * NOTE: Internal function, no parameter validation | |
250 | * | |
251 | ******************************************************************************/ | |
252 | ||
253 | acpi_status | |
4be44fcd LB |
254 | acpi_ut_evaluate_numeric_object(char *object_name, |
255 | struct acpi_namespace_node *device_node, | |
256 | acpi_integer * address) | |
1da177e4 | 257 | { |
4be44fcd LB |
258 | union acpi_operand_object *obj_desc; |
259 | acpi_status status; | |
1da177e4 | 260 | |
4be44fcd | 261 | ACPI_FUNCTION_TRACE("ut_evaluate_numeric_object"); |
1da177e4 | 262 | |
4be44fcd LB |
263 | status = acpi_ut_evaluate_object(device_node, object_name, |
264 | ACPI_BTYPE_INTEGER, &obj_desc); | |
265 | if (ACPI_FAILURE(status)) { | |
266 | return_ACPI_STATUS(status); | |
1da177e4 LT |
267 | } |
268 | ||
269 | /* Get the returned Integer */ | |
270 | ||
271 | *address = obj_desc->integer.value; | |
272 | ||
273 | /* On exit, we must delete the return object */ | |
274 | ||
4be44fcd LB |
275 | acpi_ut_remove_reference(obj_desc); |
276 | return_ACPI_STATUS(status); | |
1da177e4 LT |
277 | } |
278 | ||
1da177e4 LT |
279 | /******************************************************************************* |
280 | * | |
281 | * FUNCTION: acpi_ut_copy_id_string | |
282 | * | |
283 | * PARAMETERS: Destination - Where to copy the string | |
284 | * Source - Source string | |
285 | * max_length - Length of the destination buffer | |
286 | * | |
287 | * RETURN: None | |
288 | * | |
289 | * DESCRIPTION: Copies an ID string for the _HID, _CID, and _UID methods. | |
290 | * Performs removal of a leading asterisk if present -- workaround | |
291 | * for a known issue on a bunch of machines. | |
292 | * | |
293 | ******************************************************************************/ | |
294 | ||
295 | static void | |
4be44fcd | 296 | acpi_ut_copy_id_string(char *destination, char *source, acpi_size max_length) |
1da177e4 LT |
297 | { |
298 | ||
1da177e4 LT |
299 | /* |
300 | * Workaround for ID strings that have a leading asterisk. This construct | |
301 | * is not allowed by the ACPI specification (ID strings must be | |
302 | * alphanumeric), but enough existing machines have this embedded in their | |
303 | * ID strings that the following code is useful. | |
304 | */ | |
305 | if (*source == '*') { | |
306 | source++; | |
307 | } | |
308 | ||
309 | /* Do the actual copy */ | |
310 | ||
4be44fcd | 311 | ACPI_STRNCPY(destination, source, max_length); |
1da177e4 LT |
312 | } |
313 | ||
1da177e4 LT |
314 | /******************************************************************************* |
315 | * | |
316 | * FUNCTION: acpi_ut_execute_HID | |
317 | * | |
318 | * PARAMETERS: device_node - Node for the device | |
44f6c012 | 319 | * Hid - Where the HID is returned |
1da177e4 LT |
320 | * |
321 | * RETURN: Status | |
322 | * | |
323 | * DESCRIPTION: Executes the _HID control method that returns the hardware | |
324 | * ID of the device. | |
325 | * | |
326 | * NOTE: Internal function, no parameter validation | |
327 | * | |
328 | ******************************************************************************/ | |
329 | ||
330 | acpi_status | |
4be44fcd LB |
331 | acpi_ut_execute_HID(struct acpi_namespace_node *device_node, |
332 | struct acpi_device_id *hid) | |
1da177e4 | 333 | { |
4be44fcd LB |
334 | union acpi_operand_object *obj_desc; |
335 | acpi_status status; | |
1da177e4 | 336 | |
4be44fcd | 337 | ACPI_FUNCTION_TRACE("ut_execute_HID"); |
1da177e4 | 338 | |
4be44fcd LB |
339 | status = acpi_ut_evaluate_object(device_node, METHOD_NAME__HID, |
340 | ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, | |
341 | &obj_desc); | |
342 | if (ACPI_FAILURE(status)) { | |
343 | return_ACPI_STATUS(status); | |
1da177e4 LT |
344 | } |
345 | ||
4be44fcd | 346 | if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { |
52fc0b02 | 347 | |
1da177e4 LT |
348 | /* Convert the Numeric HID to string */ |
349 | ||
4be44fcd LB |
350 | acpi_ex_eisa_id_to_string((u32) obj_desc->integer.value, |
351 | hid->value); | |
352 | } else { | |
1da177e4 LT |
353 | /* Copy the String HID from the returned object */ |
354 | ||
4be44fcd LB |
355 | acpi_ut_copy_id_string(hid->value, obj_desc->string.pointer, |
356 | sizeof(hid->value)); | |
1da177e4 LT |
357 | } |
358 | ||
359 | /* On exit, we must delete the return object */ | |
360 | ||
4be44fcd LB |
361 | acpi_ut_remove_reference(obj_desc); |
362 | return_ACPI_STATUS(status); | |
1da177e4 LT |
363 | } |
364 | ||
1da177e4 LT |
365 | /******************************************************************************* |
366 | * | |
367 | * FUNCTION: acpi_ut_translate_one_cid | |
368 | * | |
369 | * PARAMETERS: obj_desc - _CID object, must be integer or string | |
370 | * one_cid - Where the CID string is returned | |
371 | * | |
372 | * RETURN: Status | |
373 | * | |
374 | * DESCRIPTION: Return a numeric or string _CID value as a string. | |
375 | * (Compatible ID) | |
376 | * | |
377 | * NOTE: Assumes a maximum _CID string length of | |
378 | * ACPI_MAX_CID_LENGTH. | |
379 | * | |
380 | ******************************************************************************/ | |
381 | ||
382 | static acpi_status | |
4be44fcd LB |
383 | acpi_ut_translate_one_cid(union acpi_operand_object *obj_desc, |
384 | struct acpi_compatible_id *one_cid) | |
1da177e4 LT |
385 | { |
386 | ||
4be44fcd | 387 | switch (ACPI_GET_OBJECT_TYPE(obj_desc)) { |
1da177e4 LT |
388 | case ACPI_TYPE_INTEGER: |
389 | ||
390 | /* Convert the Numeric CID to string */ | |
391 | ||
4be44fcd LB |
392 | acpi_ex_eisa_id_to_string((u32) obj_desc->integer.value, |
393 | one_cid->value); | |
1da177e4 LT |
394 | return (AE_OK); |
395 | ||
396 | case ACPI_TYPE_STRING: | |
397 | ||
398 | if (obj_desc->string.length > ACPI_MAX_CID_LENGTH) { | |
399 | return (AE_AML_STRING_LIMIT); | |
400 | } | |
401 | ||
402 | /* Copy the String CID from the returned object */ | |
403 | ||
4be44fcd LB |
404 | acpi_ut_copy_id_string(one_cid->value, obj_desc->string.pointer, |
405 | ACPI_MAX_CID_LENGTH); | |
1da177e4 LT |
406 | return (AE_OK); |
407 | ||
408 | default: | |
409 | ||
410 | return (AE_TYPE); | |
411 | } | |
412 | } | |
413 | ||
1da177e4 LT |
414 | /******************************************************************************* |
415 | * | |
416 | * FUNCTION: acpi_ut_execute_CID | |
417 | * | |
418 | * PARAMETERS: device_node - Node for the device | |
44f6c012 | 419 | * return_cid_list - Where the CID list is returned |
1da177e4 LT |
420 | * |
421 | * RETURN: Status | |
422 | * | |
423 | * DESCRIPTION: Executes the _CID control method that returns one or more | |
424 | * compatible hardware IDs for the device. | |
425 | * | |
426 | * NOTE: Internal function, no parameter validation | |
427 | * | |
428 | ******************************************************************************/ | |
429 | ||
430 | acpi_status | |
4be44fcd LB |
431 | acpi_ut_execute_CID(struct acpi_namespace_node * device_node, |
432 | struct acpi_compatible_id_list ** return_cid_list) | |
1da177e4 | 433 | { |
4be44fcd LB |
434 | union acpi_operand_object *obj_desc; |
435 | acpi_status status; | |
436 | u32 count; | |
437 | u32 size; | |
1da177e4 | 438 | struct acpi_compatible_id_list *cid_list; |
4be44fcd | 439 | acpi_native_uint i; |
1da177e4 | 440 | |
4be44fcd | 441 | ACPI_FUNCTION_TRACE("ut_execute_CID"); |
1da177e4 LT |
442 | |
443 | /* Evaluate the _CID method for this device */ | |
444 | ||
4be44fcd LB |
445 | status = acpi_ut_evaluate_object(device_node, METHOD_NAME__CID, |
446 | ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | |
447 | | ACPI_BTYPE_PACKAGE, &obj_desc); | |
448 | if (ACPI_FAILURE(status)) { | |
449 | return_ACPI_STATUS(status); | |
1da177e4 LT |
450 | } |
451 | ||
452 | /* Get the number of _CIDs returned */ | |
453 | ||
454 | count = 1; | |
4be44fcd | 455 | if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) { |
1da177e4 LT |
456 | count = obj_desc->package.count; |
457 | } | |
458 | ||
459 | /* Allocate a worst-case buffer for the _CIDs */ | |
460 | ||
4be44fcd LB |
461 | size = (((count - 1) * sizeof(struct acpi_compatible_id)) + |
462 | sizeof(struct acpi_compatible_id_list)); | |
1da177e4 | 463 | |
4be44fcd | 464 | cid_list = ACPI_MEM_CALLOCATE((acpi_size) size); |
1da177e4 | 465 | if (!cid_list) { |
4be44fcd | 466 | return_ACPI_STATUS(AE_NO_MEMORY); |
1da177e4 LT |
467 | } |
468 | ||
469 | /* Init CID list */ | |
470 | ||
471 | cid_list->count = count; | |
472 | cid_list->size = size; | |
473 | ||
474 | /* | |
44f6c012 RM |
475 | * A _CID can return either a single compatible ID or a package of |
476 | * compatible IDs. Each compatible ID can be one of the following: | |
477 | * 1) Integer (32 bit compressed EISA ID) or | |
478 | * 2) String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss") | |
1da177e4 LT |
479 | */ |
480 | ||
481 | /* The _CID object can be either a single CID or a package (list) of CIDs */ | |
482 | ||
4be44fcd | 483 | if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_PACKAGE) { |
52fc0b02 | 484 | |
1da177e4 LT |
485 | /* Translate each package element */ |
486 | ||
487 | for (i = 0; i < count; i++) { | |
4be44fcd LB |
488 | status = |
489 | acpi_ut_translate_one_cid(obj_desc->package. | |
490 | elements[i], | |
491 | &cid_list->id[i]); | |
492 | if (ACPI_FAILURE(status)) { | |
1da177e4 LT |
493 | break; |
494 | } | |
495 | } | |
4be44fcd | 496 | } else { |
1da177e4 LT |
497 | /* Only one CID, translate to a string */ |
498 | ||
4be44fcd | 499 | status = acpi_ut_translate_one_cid(obj_desc, cid_list->id); |
1da177e4 LT |
500 | } |
501 | ||
502 | /* Cleanup on error */ | |
503 | ||
4be44fcd LB |
504 | if (ACPI_FAILURE(status)) { |
505 | ACPI_MEM_FREE(cid_list); | |
506 | } else { | |
1da177e4 LT |
507 | *return_cid_list = cid_list; |
508 | } | |
509 | ||
510 | /* On exit, we must delete the _CID return object */ | |
511 | ||
4be44fcd LB |
512 | acpi_ut_remove_reference(obj_desc); |
513 | return_ACPI_STATUS(status); | |
1da177e4 LT |
514 | } |
515 | ||
1da177e4 LT |
516 | /******************************************************************************* |
517 | * | |
518 | * FUNCTION: acpi_ut_execute_UID | |
519 | * | |
520 | * PARAMETERS: device_node - Node for the device | |
44f6c012 | 521 | * Uid - Where the UID is returned |
1da177e4 LT |
522 | * |
523 | * RETURN: Status | |
524 | * | |
525 | * DESCRIPTION: Executes the _UID control method that returns the hardware | |
526 | * ID of the device. | |
527 | * | |
528 | * NOTE: Internal function, no parameter validation | |
529 | * | |
530 | ******************************************************************************/ | |
531 | ||
532 | acpi_status | |
4be44fcd LB |
533 | acpi_ut_execute_UID(struct acpi_namespace_node *device_node, |
534 | struct acpi_device_id *uid) | |
1da177e4 | 535 | { |
4be44fcd LB |
536 | union acpi_operand_object *obj_desc; |
537 | acpi_status status; | |
1da177e4 | 538 | |
4be44fcd | 539 | ACPI_FUNCTION_TRACE("ut_execute_UID"); |
1da177e4 | 540 | |
4be44fcd LB |
541 | status = acpi_ut_evaluate_object(device_node, METHOD_NAME__UID, |
542 | ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, | |
543 | &obj_desc); | |
544 | if (ACPI_FAILURE(status)) { | |
545 | return_ACPI_STATUS(status); | |
1da177e4 LT |
546 | } |
547 | ||
4be44fcd | 548 | if (ACPI_GET_OBJECT_TYPE(obj_desc) == ACPI_TYPE_INTEGER) { |
52fc0b02 | 549 | |
1da177e4 LT |
550 | /* Convert the Numeric UID to string */ |
551 | ||
4be44fcd LB |
552 | acpi_ex_unsigned_integer_to_string(obj_desc->integer.value, |
553 | uid->value); | |
554 | } else { | |
1da177e4 LT |
555 | /* Copy the String UID from the returned object */ |
556 | ||
4be44fcd LB |
557 | acpi_ut_copy_id_string(uid->value, obj_desc->string.pointer, |
558 | sizeof(uid->value)); | |
1da177e4 LT |
559 | } |
560 | ||
561 | /* On exit, we must delete the return object */ | |
562 | ||
4be44fcd LB |
563 | acpi_ut_remove_reference(obj_desc); |
564 | return_ACPI_STATUS(status); | |
1da177e4 LT |
565 | } |
566 | ||
1da177e4 LT |
567 | /******************************************************************************* |
568 | * | |
569 | * FUNCTION: acpi_ut_execute_STA | |
570 | * | |
571 | * PARAMETERS: device_node - Node for the device | |
44f6c012 | 572 | * Flags - Where the status flags are returned |
1da177e4 LT |
573 | * |
574 | * RETURN: Status | |
575 | * | |
576 | * DESCRIPTION: Executes _STA for selected device and stores results in | |
577 | * *Flags. | |
578 | * | |
579 | * NOTE: Internal function, no parameter validation | |
580 | * | |
581 | ******************************************************************************/ | |
582 | ||
583 | acpi_status | |
4be44fcd | 584 | acpi_ut_execute_STA(struct acpi_namespace_node *device_node, u32 * flags) |
1da177e4 | 585 | { |
4be44fcd LB |
586 | union acpi_operand_object *obj_desc; |
587 | acpi_status status; | |
1da177e4 | 588 | |
4be44fcd | 589 | ACPI_FUNCTION_TRACE("ut_execute_STA"); |
1da177e4 | 590 | |
4be44fcd LB |
591 | status = acpi_ut_evaluate_object(device_node, METHOD_NAME__STA, |
592 | ACPI_BTYPE_INTEGER, &obj_desc); | |
593 | if (ACPI_FAILURE(status)) { | |
1da177e4 | 594 | if (AE_NOT_FOUND == status) { |
4be44fcd LB |
595 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
596 | "_STA on %4.4s was not found, assuming device is present\n", | |
597 | acpi_ut_get_node_name(device_node))); | |
1da177e4 | 598 | |
defba1d8 | 599 | *flags = ACPI_UINT32_MAX; |
1da177e4 LT |
600 | status = AE_OK; |
601 | } | |
602 | ||
4be44fcd | 603 | return_ACPI_STATUS(status); |
1da177e4 LT |
604 | } |
605 | ||
606 | /* Extract the status flags */ | |
607 | ||
608 | *flags = (u32) obj_desc->integer.value; | |
609 | ||
610 | /* On exit, we must delete the return object */ | |
611 | ||
4be44fcd LB |
612 | acpi_ut_remove_reference(obj_desc); |
613 | return_ACPI_STATUS(status); | |
1da177e4 LT |
614 | } |
615 | ||
1da177e4 LT |
616 | /******************************************************************************* |
617 | * | |
618 | * FUNCTION: acpi_ut_execute_Sxds | |
619 | * | |
620 | * PARAMETERS: device_node - Node for the device | |
44f6c012 | 621 | * Flags - Where the status flags are returned |
1da177e4 LT |
622 | * |
623 | * RETURN: Status | |
624 | * | |
625 | * DESCRIPTION: Executes _STA for selected device and stores results in | |
626 | * *Flags. | |
627 | * | |
628 | * NOTE: Internal function, no parameter validation | |
629 | * | |
630 | ******************************************************************************/ | |
631 | ||
632 | acpi_status | |
4be44fcd | 633 | acpi_ut_execute_sxds(struct acpi_namespace_node *device_node, u8 * highest) |
1da177e4 | 634 | { |
4be44fcd LB |
635 | union acpi_operand_object *obj_desc; |
636 | acpi_status status; | |
637 | u32 i; | |
1da177e4 | 638 | |
4be44fcd | 639 | ACPI_FUNCTION_TRACE("ut_execute_Sxds"); |
1da177e4 LT |
640 | |
641 | for (i = 0; i < 4; i++) { | |
642 | highest[i] = 0xFF; | |
4be44fcd | 643 | status = acpi_ut_evaluate_object(device_node, |
defba1d8 BM |
644 | ACPI_CAST_PTR(char, |
645 | acpi_gbl_highest_dstate_names | |
646 | [i]), | |
647 | ACPI_BTYPE_INTEGER, &obj_desc); | |
4be44fcd | 648 | if (ACPI_FAILURE(status)) { |
1da177e4 | 649 | if (status != AE_NOT_FOUND) { |
4be44fcd LB |
650 | ACPI_DEBUG_PRINT((ACPI_DB_EXEC, |
651 | "%s on Device %4.4s, %s\n", | |
defba1d8 BM |
652 | ACPI_CAST_PTR(char, |
653 | acpi_gbl_highest_dstate_names | |
654 | [i]), | |
4be44fcd LB |
655 | acpi_ut_get_node_name |
656 | (device_node), | |
657 | acpi_format_exception | |
658 | (status))); | |
659 | ||
660 | return_ACPI_STATUS(status); | |
1da177e4 | 661 | } |
4be44fcd | 662 | } else { |
1da177e4 LT |
663 | /* Extract the Dstate value */ |
664 | ||
665 | highest[i] = (u8) obj_desc->integer.value; | |
666 | ||
667 | /* Delete the return object */ | |
668 | ||
4be44fcd | 669 | acpi_ut_remove_reference(obj_desc); |
1da177e4 LT |
670 | } |
671 | } | |
672 | ||
4be44fcd | 673 | return_ACPI_STATUS(AE_OK); |
1da177e4 | 674 | } |