uteval.c revision 193335
1/******************************************************************************
2 *
3 * Module Name: uteval - Object evaluation
4 *
5 *****************************************************************************/
6
7/******************************************************************************
8 *
9 * 1. Copyright Notice
10 *
11 * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
12 * All rights reserved.
13 *
14 * 2. License
15 *
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights.  You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
19 * property rights.
20 *
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
27 *
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code.  No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
36 *
37 * The above copyright and patent license is granted only if the following
38 * conditions are met:
39 *
40 * 3. Conditions
41 *
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision.  In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change.  Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee.  Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
53 *
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution.  In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
64 * make.
65 *
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
70 * distribution.
71 *
72 * 3.4. Intel retains all right, title, and interest in and to the Original
73 * Intel Code.
74 *
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
79 *
80 * 4. Disclaimer and Export Compliance
81 *
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
88 * PARTICULAR PURPOSE.
89 *
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
97 * LIMITED REMEDY.
98 *
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government.  In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
113 *
114 *****************************************************************************/
115
116#define __UTEVAL_C__
117
118#include "acpi.h"
119#include "accommon.h"
120#include "acnamesp.h"
121#include "acinterp.h"
122
123
124#define _COMPONENT          ACPI_UTILITIES
125        ACPI_MODULE_NAME    ("uteval")
126
127/* Local prototypes */
128
129static void
130AcpiUtCopyIdString (
131    char                    *Destination,
132    char                    *Source,
133    ACPI_SIZE               MaxLength);
134
135static ACPI_STATUS
136AcpiUtTranslateOneCid (
137    ACPI_OPERAND_OBJECT     *ObjDesc,
138    ACPI_COMPATIBLE_ID      *OneCid);
139
140
141/*
142 * Strings supported by the _OSI predefined (internal) method.
143 *
144 * March 2009: Removed "Linux" as this host no longer wants to respond true
145 * for this string. Basically, the only safe OS strings are windows-related
146 * and in many or most cases represent the only test path within the
147 * BIOS-provided ASL code.
148 *
149 * The second element of each entry is used to track the newest version of
150 * Windows that the BIOS has requested.
151 */
152static const ACPI_INTERFACE_INFO    AcpiInterfacesSupported[] =
153{
154    /* Operating System Vendor Strings */
155
156    {"Windows 2000",        ACPI_OSI_WIN_2000},         /* Windows 2000 */
157    {"Windows 2001",        ACPI_OSI_WIN_XP},           /* Windows XP */
158    {"Windows 2001 SP1",    ACPI_OSI_WIN_XP_SP1},       /* Windows XP SP1 */
159    {"Windows 2001.1",      ACPI_OSI_WINSRV_2003},      /* Windows Server 2003 */
160    {"Windows 2001 SP2",    ACPI_OSI_WIN_XP_SP2},       /* Windows XP SP2 */
161    {"Windows 2001.1 SP1",  ACPI_OSI_WINSRV_2003_SP1},  /* Windows Server 2003 SP1 - Added 03/2006 */
162    {"Windows 2006",        ACPI_OSI_WIN_VISTA},        /* Windows Vista - Added 03/2006 */
163
164    /* Feature Group Strings */
165
166    {"Extended Address Space Descriptor", 0}
167
168    /*
169     * All "optional" feature group strings (features that are implemented
170     * by the host) should be implemented in the host version of
171     * AcpiOsValidateInterface and should not be added here.
172     */
173};
174
175
176/*******************************************************************************
177 *
178 * FUNCTION:    AcpiUtOsiImplementation
179 *
180 * PARAMETERS:  WalkState           - Current walk state
181 *
182 * RETURN:      Status
183 *
184 * DESCRIPTION: Implementation of the _OSI predefined control method
185 *
186 ******************************************************************************/
187
188ACPI_STATUS
189AcpiUtOsiImplementation (
190    ACPI_WALK_STATE         *WalkState)
191{
192    ACPI_STATUS             Status;
193    ACPI_OPERAND_OBJECT     *StringDesc;
194    ACPI_OPERAND_OBJECT     *ReturnDesc;
195    UINT32                  ReturnValue;
196    UINT32                  i;
197
198
199    ACPI_FUNCTION_TRACE (UtOsiImplementation);
200
201
202    /* Validate the string input argument */
203
204    StringDesc = WalkState->Arguments[0].Object;
205    if (!StringDesc || (StringDesc->Common.Type != ACPI_TYPE_STRING))
206    {
207        return_ACPI_STATUS (AE_TYPE);
208    }
209
210    /* Create a return object */
211
212    ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
213    if (!ReturnDesc)
214    {
215        return_ACPI_STATUS (AE_NO_MEMORY);
216    }
217
218    /* Default return value is 0, NOT SUPPORTED */
219
220    ReturnValue = 0;
221
222    /* Compare input string to static table of supported interfaces */
223
224    for (i = 0; i < ACPI_ARRAY_LENGTH (AcpiInterfacesSupported); i++)
225    {
226        if (!ACPI_STRCMP (StringDesc->String.Pointer,
227                AcpiInterfacesSupported[i].Name))
228        {
229            /*
230             * The interface is supported.
231             * Update the OsiData if necessary. We keep track of the latest
232             * version of Windows that has been requested by the BIOS.
233             */
234            if (AcpiInterfacesSupported[i].Value > AcpiGbl_OsiData)
235            {
236                AcpiGbl_OsiData = AcpiInterfacesSupported[i].Value;
237            }
238
239            ReturnValue = ACPI_UINT32_MAX;
240            goto Exit;
241        }
242    }
243
244    /*
245     * Did not match the string in the static table, call the host OSL to
246     * check for a match with one of the optional strings (such as
247     * "Module Device", "3.0 Thermal Model", etc.)
248     */
249    Status = AcpiOsValidateInterface (StringDesc->String.Pointer);
250    if (ACPI_SUCCESS (Status))
251    {
252        /* The interface is supported */
253
254        ReturnValue = ACPI_UINT32_MAX;
255    }
256
257
258Exit:
259    ACPI_DEBUG_PRINT_RAW ((ACPI_DB_INFO,
260        "ACPI: BIOS _OSI(%s) is %ssupported\n",
261        StringDesc->String.Pointer, ReturnValue == 0 ? "not " : ""));
262
263    /* Complete the return value */
264
265    ReturnDesc->Integer.Value = ReturnValue;
266    WalkState->ReturnDesc = ReturnDesc;
267    return_ACPI_STATUS (AE_OK);
268}
269
270
271/*******************************************************************************
272 *
273 * FUNCTION:    AcpiUtEvaluateObject
274 *
275 * PARAMETERS:  PrefixNode          - Starting node
276 *              Path                - Path to object from starting node
277 *              ExpectedReturnTypes - Bitmap of allowed return types
278 *              ReturnDesc          - Where a return value is stored
279 *
280 * RETURN:      Status
281 *
282 * DESCRIPTION: Evaluates a namespace object and verifies the type of the
283 *              return object.  Common code that simplifies accessing objects
284 *              that have required return objects of fixed types.
285 *
286 *              NOTE: Internal function, no parameter validation
287 *
288 ******************************************************************************/
289
290ACPI_STATUS
291AcpiUtEvaluateObject (
292    ACPI_NAMESPACE_NODE     *PrefixNode,
293    char                    *Path,
294    UINT32                  ExpectedReturnBtypes,
295    ACPI_OPERAND_OBJECT     **ReturnDesc)
296{
297    ACPI_EVALUATE_INFO      *Info;
298    ACPI_STATUS             Status;
299    UINT32                  ReturnBtype;
300
301
302    ACPI_FUNCTION_TRACE (UtEvaluateObject);
303
304
305    /* Allocate the evaluation information block */
306
307    Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
308    if (!Info)
309    {
310        return_ACPI_STATUS (AE_NO_MEMORY);
311    }
312
313    Info->PrefixNode = PrefixNode;
314    Info->Pathname = Path;
315
316    /* Evaluate the object/method */
317
318    Status = AcpiNsEvaluate (Info);
319    if (ACPI_FAILURE (Status))
320    {
321        if (Status == AE_NOT_FOUND)
322        {
323            ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s.%s] was not found\n",
324                AcpiUtGetNodeName (PrefixNode), Path));
325        }
326        else
327        {
328            ACPI_ERROR_METHOD ("Method execution failed",
329                PrefixNode, Path, Status);
330        }
331
332        goto Cleanup;
333    }
334
335    /* Did we get a return object? */
336
337    if (!Info->ReturnObject)
338    {
339        if (ExpectedReturnBtypes)
340        {
341            ACPI_ERROR_METHOD ("No object was returned from",
342                PrefixNode, Path, AE_NOT_EXIST);
343
344            Status = AE_NOT_EXIST;
345        }
346
347        goto Cleanup;
348    }
349
350    /* Map the return object type to the bitmapped type */
351
352    switch ((Info->ReturnObject)->Common.Type)
353    {
354    case ACPI_TYPE_INTEGER:
355        ReturnBtype = ACPI_BTYPE_INTEGER;
356        break;
357
358    case ACPI_TYPE_BUFFER:
359        ReturnBtype = ACPI_BTYPE_BUFFER;
360        break;
361
362    case ACPI_TYPE_STRING:
363        ReturnBtype = ACPI_BTYPE_STRING;
364        break;
365
366    case ACPI_TYPE_PACKAGE:
367        ReturnBtype = ACPI_BTYPE_PACKAGE;
368        break;
369
370    default:
371        ReturnBtype = 0;
372        break;
373    }
374
375    if ((AcpiGbl_EnableInterpreterSlack) &&
376        (!ExpectedReturnBtypes))
377    {
378        /*
379         * We received a return object, but one was not expected.  This can
380         * happen frequently if the "implicit return" feature is enabled.
381         * Just delete the return object and return AE_OK.
382         */
383        AcpiUtRemoveReference (Info->ReturnObject);
384        goto Cleanup;
385    }
386
387    /* Is the return object one of the expected types? */
388
389    if (!(ExpectedReturnBtypes & ReturnBtype))
390    {
391        ACPI_ERROR_METHOD ("Return object type is incorrect",
392            PrefixNode, Path, AE_TYPE);
393
394        ACPI_ERROR ((AE_INFO,
395            "Type returned from %s was incorrect: %s, expected Btypes: %X",
396            Path, AcpiUtGetObjectTypeName (Info->ReturnObject),
397            ExpectedReturnBtypes));
398
399        /* On error exit, we must delete the return object */
400
401        AcpiUtRemoveReference (Info->ReturnObject);
402        Status = AE_TYPE;
403        goto Cleanup;
404    }
405
406    /* Object type is OK, return it */
407
408    *ReturnDesc = Info->ReturnObject;
409
410Cleanup:
411    ACPI_FREE (Info);
412    return_ACPI_STATUS (Status);
413}
414
415
416/*******************************************************************************
417 *
418 * FUNCTION:    AcpiUtEvaluateNumericObject
419 *
420 * PARAMETERS:  ObjectName          - Object name to be evaluated
421 *              DeviceNode          - Node for the device
422 *              Address             - Where the value is returned
423 *
424 * RETURN:      Status
425 *
426 * DESCRIPTION: Evaluates a numeric namespace object for a selected device
427 *              and stores result in *Address.
428 *
429 *              NOTE: Internal function, no parameter validation
430 *
431 ******************************************************************************/
432
433ACPI_STATUS
434AcpiUtEvaluateNumericObject (
435    char                    *ObjectName,
436    ACPI_NAMESPACE_NODE     *DeviceNode,
437    ACPI_INTEGER            *Address)
438{
439    ACPI_OPERAND_OBJECT     *ObjDesc;
440    ACPI_STATUS             Status;
441
442
443    ACPI_FUNCTION_TRACE (UtEvaluateNumericObject);
444
445
446    Status = AcpiUtEvaluateObject (DeviceNode, ObjectName,
447                ACPI_BTYPE_INTEGER, &ObjDesc);
448    if (ACPI_FAILURE (Status))
449    {
450        return_ACPI_STATUS (Status);
451    }
452
453    /* Get the returned Integer */
454
455    *Address = ObjDesc->Integer.Value;
456
457    /* On exit, we must delete the return object */
458
459    AcpiUtRemoveReference (ObjDesc);
460    return_ACPI_STATUS (Status);
461}
462
463
464/*******************************************************************************
465 *
466 * FUNCTION:    AcpiUtCopyIdString
467 *
468 * PARAMETERS:  Destination         - Where to copy the string
469 *              Source              - Source string
470 *              MaxLength           - Length of the destination buffer
471 *
472 * RETURN:      None
473 *
474 * DESCRIPTION: Copies an ID string for the _HID, _CID, and _UID methods.
475 *              Performs removal of a leading asterisk if present -- workaround
476 *              for a known issue on a bunch of machines.
477 *
478 ******************************************************************************/
479
480static void
481AcpiUtCopyIdString (
482    char                    *Destination,
483    char                    *Source,
484    ACPI_SIZE               MaxLength)
485{
486
487    /*
488     * Workaround for ID strings that have a leading asterisk. This construct
489     * is not allowed by the ACPI specification  (ID strings must be
490     * alphanumeric), but enough existing machines have this embedded in their
491     * ID strings that the following code is useful.
492     */
493    if (*Source == '*')
494    {
495        Source++;
496    }
497
498    /* Do the actual copy */
499
500    ACPI_STRNCPY (Destination, Source, MaxLength);
501}
502
503
504/*******************************************************************************
505 *
506 * FUNCTION:    AcpiUtExecute_HID
507 *
508 * PARAMETERS:  DeviceNode          - Node for the device
509 *              Hid                 - Where the HID is returned
510 *
511 * RETURN:      Status
512 *
513 * DESCRIPTION: Executes the _HID control method that returns the hardware
514 *              ID of the device.
515 *
516 *              NOTE: Internal function, no parameter validation
517 *
518 ******************************************************************************/
519
520ACPI_STATUS
521AcpiUtExecute_HID (
522    ACPI_NAMESPACE_NODE     *DeviceNode,
523    ACPI_DEVICE_ID          *Hid)
524{
525    ACPI_OPERAND_OBJECT     *ObjDesc;
526    ACPI_STATUS             Status;
527
528
529    ACPI_FUNCTION_TRACE (UtExecute_HID);
530
531
532    Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__HID,
533                ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc);
534    if (ACPI_FAILURE (Status))
535    {
536        return_ACPI_STATUS (Status);
537    }
538
539    if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER)
540    {
541        /* Convert the Numeric HID to string */
542
543        AcpiExEisaIdToString ((UINT32) ObjDesc->Integer.Value, Hid->Value);
544    }
545    else
546    {
547        /* Copy the String HID from the returned object */
548
549        AcpiUtCopyIdString (Hid->Value, ObjDesc->String.Pointer,
550                sizeof (Hid->Value));
551    }
552
553    /* On exit, we must delete the return object */
554
555    AcpiUtRemoveReference (ObjDesc);
556    return_ACPI_STATUS (Status);
557}
558
559
560/*******************************************************************************
561 *
562 * FUNCTION:    AcpiUtTranslateOneCid
563 *
564 * PARAMETERS:  ObjDesc             - _CID object, must be integer or string
565 *              OneCid              - Where the CID string is returned
566 *
567 * RETURN:      Status
568 *
569 * DESCRIPTION: Return a numeric or string _CID value as a string.
570 *              (Compatible ID)
571 *
572 *              NOTE:  Assumes a maximum _CID string length of
573 *                     ACPI_MAX_CID_LENGTH.
574 *
575 ******************************************************************************/
576
577static ACPI_STATUS
578AcpiUtTranslateOneCid (
579    ACPI_OPERAND_OBJECT     *ObjDesc,
580    ACPI_COMPATIBLE_ID      *OneCid)
581{
582
583
584    switch (ObjDesc->Common.Type)
585    {
586    case ACPI_TYPE_INTEGER:
587
588        /* Convert the Numeric CID to string */
589
590        AcpiExEisaIdToString ((UINT32) ObjDesc->Integer.Value, OneCid->Value);
591        return (AE_OK);
592
593    case ACPI_TYPE_STRING:
594
595        if (ObjDesc->String.Length > ACPI_MAX_CID_LENGTH)
596        {
597            return (AE_AML_STRING_LIMIT);
598        }
599
600        /* Copy the String CID from the returned object */
601
602        AcpiUtCopyIdString (OneCid->Value, ObjDesc->String.Pointer,
603                ACPI_MAX_CID_LENGTH);
604        return (AE_OK);
605
606    default:
607
608        return (AE_TYPE);
609    }
610}
611
612
613/*******************************************************************************
614 *
615 * FUNCTION:    AcpiUtExecute_CID
616 *
617 * PARAMETERS:  DeviceNode          - Node for the device
618 *              ReturnCidList       - Where the CID list is returned
619 *
620 * RETURN:      Status
621 *
622 * DESCRIPTION: Executes the _CID control method that returns one or more
623 *              compatible hardware IDs for the device.
624 *
625 *              NOTE: Internal function, no parameter validation
626 *
627 ******************************************************************************/
628
629ACPI_STATUS
630AcpiUtExecute_CID (
631    ACPI_NAMESPACE_NODE     *DeviceNode,
632    ACPI_COMPATIBLE_ID_LIST **ReturnCidList)
633{
634    ACPI_OPERAND_OBJECT     *ObjDesc;
635    ACPI_STATUS             Status;
636    UINT32                  Count;
637    UINT32                  Size;
638    ACPI_COMPATIBLE_ID_LIST *CidList;
639    UINT32                  i;
640
641
642    ACPI_FUNCTION_TRACE (UtExecute_CID);
643
644
645    /* Evaluate the _CID method for this device */
646
647    Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__CID,
648                ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_PACKAGE,
649                &ObjDesc);
650    if (ACPI_FAILURE (Status))
651    {
652        return_ACPI_STATUS (Status);
653    }
654
655    /* Get the number of _CIDs returned */
656
657    Count = 1;
658    if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE)
659    {
660        Count = ObjDesc->Package.Count;
661    }
662
663    /* Allocate a worst-case buffer for the _CIDs */
664
665    Size = (((Count - 1) * sizeof (ACPI_COMPATIBLE_ID)) +
666                           sizeof (ACPI_COMPATIBLE_ID_LIST));
667
668    CidList = ACPI_ALLOCATE_ZEROED ((ACPI_SIZE) Size);
669    if (!CidList)
670    {
671        return_ACPI_STATUS (AE_NO_MEMORY);
672    }
673
674    /* Init CID list */
675
676    CidList->Count = Count;
677    CidList->Size  = Size;
678
679    /*
680     *  A _CID can return either a single compatible ID or a package of
681     *  compatible IDs.  Each compatible ID can be one of the following:
682     *  1) Integer (32 bit compressed EISA ID) or
683     *  2) String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss")
684     */
685
686    /* The _CID object can be either a single CID or a package (list) of CIDs */
687
688    if (ObjDesc->Common.Type == ACPI_TYPE_PACKAGE)
689    {
690        /* Translate each package element */
691
692        for (i = 0; i < Count; i++)
693        {
694            Status = AcpiUtTranslateOneCid (ObjDesc->Package.Elements[i],
695                            &CidList->Id[i]);
696            if (ACPI_FAILURE (Status))
697            {
698                break;
699            }
700        }
701    }
702    else
703    {
704        /* Only one CID, translate to a string */
705
706        Status = AcpiUtTranslateOneCid (ObjDesc, CidList->Id);
707    }
708
709    /* Cleanup on error */
710
711    if (ACPI_FAILURE (Status))
712    {
713        ACPI_FREE (CidList);
714    }
715    else
716    {
717        *ReturnCidList = CidList;
718    }
719
720    /* On exit, we must delete the _CID return object */
721
722    AcpiUtRemoveReference (ObjDesc);
723    return_ACPI_STATUS (Status);
724}
725
726
727/*******************************************************************************
728 *
729 * FUNCTION:    AcpiUtExecute_UID
730 *
731 * PARAMETERS:  DeviceNode          - Node for the device
732 *              Uid                 - Where the UID is returned
733 *
734 * RETURN:      Status
735 *
736 * DESCRIPTION: Executes the _UID control method that returns the hardware
737 *              ID of the device.
738 *
739 *              NOTE: Internal function, no parameter validation
740 *
741 ******************************************************************************/
742
743ACPI_STATUS
744AcpiUtExecute_UID (
745    ACPI_NAMESPACE_NODE     *DeviceNode,
746    ACPI_DEVICE_ID          *Uid)
747{
748    ACPI_OPERAND_OBJECT     *ObjDesc;
749    ACPI_STATUS             Status;
750
751
752    ACPI_FUNCTION_TRACE (UtExecute_UID);
753
754
755    Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__UID,
756                ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc);
757    if (ACPI_FAILURE (Status))
758    {
759        return_ACPI_STATUS (Status);
760    }
761
762    if (ObjDesc->Common.Type == ACPI_TYPE_INTEGER)
763    {
764        /* Convert the Numeric UID to string */
765
766        AcpiExUnsignedIntegerToString (ObjDesc->Integer.Value, Uid->Value);
767    }
768    else
769    {
770        /* Copy the String UID from the returned object */
771
772        AcpiUtCopyIdString (Uid->Value, ObjDesc->String.Pointer,
773                sizeof (Uid->Value));
774    }
775
776    /* On exit, we must delete the return object */
777
778    AcpiUtRemoveReference (ObjDesc);
779    return_ACPI_STATUS (Status);
780}
781
782
783/*******************************************************************************
784 *
785 * FUNCTION:    AcpiUtExecute_STA
786 *
787 * PARAMETERS:  DeviceNode          - Node for the device
788 *              Flags               - Where the status flags are returned
789 *
790 * RETURN:      Status
791 *
792 * DESCRIPTION: Executes _STA for selected device and stores results in
793 *              *Flags.
794 *
795 *              NOTE: Internal function, no parameter validation
796 *
797 ******************************************************************************/
798
799ACPI_STATUS
800AcpiUtExecute_STA (
801    ACPI_NAMESPACE_NODE     *DeviceNode,
802    UINT32                  *Flags)
803{
804    ACPI_OPERAND_OBJECT     *ObjDesc;
805    ACPI_STATUS             Status;
806
807
808    ACPI_FUNCTION_TRACE (UtExecute_STA);
809
810
811    Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__STA,
812                ACPI_BTYPE_INTEGER, &ObjDesc);
813    if (ACPI_FAILURE (Status))
814    {
815        if (AE_NOT_FOUND == Status)
816        {
817            ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
818                "_STA on %4.4s was not found, assuming device is present\n",
819                AcpiUtGetNodeName (DeviceNode)));
820
821            *Flags = ACPI_UINT32_MAX;
822            Status = AE_OK;
823        }
824
825        return_ACPI_STATUS (Status);
826    }
827
828    /* Extract the status flags */
829
830    *Flags = (UINT32) ObjDesc->Integer.Value;
831
832    /* On exit, we must delete the return object */
833
834    AcpiUtRemoveReference (ObjDesc);
835    return_ACPI_STATUS (Status);
836}
837
838
839/*******************************************************************************
840 *
841 * FUNCTION:    AcpiUtExecute_Sxds
842 *
843 * PARAMETERS:  DeviceNode          - Node for the device
844 *              Flags               - Where the status flags are returned
845 *
846 * RETURN:      Status
847 *
848 * DESCRIPTION: Executes _STA for selected device and stores results in
849 *              *Flags.
850 *
851 *              NOTE: Internal function, no parameter validation
852 *
853 ******************************************************************************/
854
855ACPI_STATUS
856AcpiUtExecute_Sxds (
857    ACPI_NAMESPACE_NODE     *DeviceNode,
858    UINT8                   *Highest)
859{
860    ACPI_OPERAND_OBJECT     *ObjDesc;
861    ACPI_STATUS             Status;
862    UINT32                  i;
863
864
865    ACPI_FUNCTION_TRACE (UtExecute_Sxds);
866
867
868    for (i = 0; i < 4; i++)
869    {
870        Highest[i] = 0xFF;
871        Status = AcpiUtEvaluateObject (DeviceNode,
872                    ACPI_CAST_PTR (char, AcpiGbl_HighestDstateNames[i]),
873                    ACPI_BTYPE_INTEGER, &ObjDesc);
874        if (ACPI_FAILURE (Status))
875        {
876            if (Status != AE_NOT_FOUND)
877            {
878                ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
879                    "%s on Device %4.4s, %s\n",
880                    ACPI_CAST_PTR (char, AcpiGbl_HighestDstateNames[i]),
881                    AcpiUtGetNodeName (DeviceNode),
882                    AcpiFormatException (Status)));
883
884                return_ACPI_STATUS (Status);
885            }
886        }
887        else
888        {
889            /* Extract the Dstate value */
890
891            Highest[i] = (UINT8) ObjDesc->Integer.Value;
892
893            /* Delete the return object */
894
895            AcpiUtRemoveReference (ObjDesc);
896        }
897    }
898
899    return_ACPI_STATUS (AE_OK);
900}
901