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