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