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