Import acpica-20050211 from Intel.
[dragonfly.git] / sys / contrib / dev / acpica-unix-20050211 / utilities / uteval.c
1 /******************************************************************************
2  *
3  * Module Name: uteval - Object evaluation
4  *              $Revision: 57 $
5  *
6  *****************************************************************************/
7
8 /******************************************************************************
9  *
10  * 1. Copyright Notice
11  *
12  * Some or all of this work - Copyright (c) 1999 - 2005, 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
128 /*******************************************************************************
129  *
130  * FUNCTION:    AcpiUtOsiImplementation
131  *
132  * PARAMETERS:  WalkState           - Current walk state
133  *
134  * RETURN:      Status
135  *
136  * DESCRIPTION: Implementation of _OSI predefined control method
137  *              Supported = _OSI (String)
138  *
139  ******************************************************************************/
140
141 ACPI_STATUS
142 AcpiUtOsiImplementation (
143     ACPI_WALK_STATE         *WalkState)
144 {
145     ACPI_OPERAND_OBJECT     *StringDesc;
146     ACPI_OPERAND_OBJECT     *ReturnDesc;
147     ACPI_NATIVE_UINT        i;
148
149
150     ACPI_FUNCTION_TRACE ("UtOsiImplementation");
151
152
153     /* Validate the string input argument */
154
155     StringDesc = WalkState->Arguments[0].Object;
156     if (!StringDesc || (StringDesc->Common.Type != ACPI_TYPE_STRING))
157     {
158         return_ACPI_STATUS (AE_TYPE);
159     }
160
161     /* Create a return object (Default value = 0) */
162
163     ReturnDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
164     if (!ReturnDesc)
165     {
166         return_ACPI_STATUS (AE_NO_MEMORY);
167     }
168
169     /* Compare input string to table of supported strings */
170
171     for (i = 0; i < ACPI_NUM_OSI_STRINGS; i++)
172     {
173         if (!ACPI_STRCMP (StringDesc->String.Pointer,
174                             (char *) AcpiGbl_ValidOsiStrings[i]))
175         {
176             /* This string is supported */
177
178             ReturnDesc->Integer.Value = 0xFFFFFFFF;
179             break;
180         }
181     }
182
183     WalkState->ReturnDesc = ReturnDesc;
184     return_ACPI_STATUS (AE_CTRL_TERMINATE);
185 }
186
187
188 /*******************************************************************************
189  *
190  * FUNCTION:    AcpiUtEvaluateObject
191  *
192  * PARAMETERS:  PrefixNode          - Starting node
193  *              Path                - Path to object from starting node
194  *              ExpectedReturnTypes - Bitmap of allowed return types
195  *              ReturnDesc          - Where a return value is stored
196  *
197  * RETURN:      Status
198  *
199  * DESCRIPTION: Evaluates a namespace object and verifies the type of the
200  *              return object.  Common code that simplifies accessing objects
201  *              that have required return objects of fixed types.
202  *
203  *              NOTE: Internal function, no parameter validation
204  *
205  ******************************************************************************/
206
207 ACPI_STATUS
208 AcpiUtEvaluateObject (
209     ACPI_NAMESPACE_NODE     *PrefixNode,
210     char                    *Path,
211     UINT32                  ExpectedReturnBtypes,
212     ACPI_OPERAND_OBJECT     **ReturnDesc)
213 {
214     ACPI_PARAMETER_INFO     Info;
215     ACPI_STATUS             Status;
216     UINT32                  ReturnBtype;
217
218
219     ACPI_FUNCTION_TRACE ("UtEvaluateObject");
220
221
222     Info.Node = PrefixNode;
223     Info.Parameters = NULL;
224     Info.ParameterType = ACPI_PARAM_ARGS;
225
226     /* Evaluate the object/method */
227
228     Status = AcpiNsEvaluateRelative (Path, &Info);
229     if (ACPI_FAILURE (Status))
230     {
231         if (Status == AE_NOT_FOUND)
232         {
233             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s.%s] was not found\n",
234                 AcpiUtGetNodeName (PrefixNode), Path));
235         }
236         else
237         {
238             ACPI_REPORT_METHOD_ERROR ("Method execution failed",
239                 PrefixNode, Path, Status);
240         }
241
242         return_ACPI_STATUS (Status);
243     }
244
245     /* Did we get a return object? */
246
247     if (!Info.ReturnObject)
248     {
249         if (ExpectedReturnBtypes)
250         {
251             ACPI_REPORT_METHOD_ERROR ("No object was returned from",
252                 PrefixNode, Path, AE_NOT_EXIST);
253
254             return_ACPI_STATUS (AE_NOT_EXIST);
255         }
256
257         return_ACPI_STATUS (AE_OK);
258     }
259
260     /* Map the return object type to the bitmapped type */
261
262     switch (ACPI_GET_OBJECT_TYPE (Info.ReturnObject))
263     {
264     case ACPI_TYPE_INTEGER:
265         ReturnBtype = ACPI_BTYPE_INTEGER;
266         break;
267
268     case ACPI_TYPE_BUFFER:
269         ReturnBtype = ACPI_BTYPE_BUFFER;
270         break;
271
272     case ACPI_TYPE_STRING:
273         ReturnBtype = ACPI_BTYPE_STRING;
274         break;
275
276     case ACPI_TYPE_PACKAGE:
277         ReturnBtype = ACPI_BTYPE_PACKAGE;
278         break;
279
280     default:
281         ReturnBtype = 0;
282         break;
283     }
284
285     if ((AcpiGbl_EnableInterpreterSlack) &&
286         (!ExpectedReturnBtypes))
287     {
288         /*
289          * We received a return object, but one was not expected.  This can
290          * happen frequently if the "implicit return" feature is enabled.
291          * Just delete the return object and return AE_OK.
292          */
293         AcpiUtRemoveReference (Info.ReturnObject);
294         return_ACPI_STATUS (AE_OK);
295     }
296
297     /* Is the return object one of the expected types? */
298
299     if (!(ExpectedReturnBtypes & ReturnBtype))
300     {
301         ACPI_REPORT_METHOD_ERROR ("Return object type is incorrect",
302             PrefixNode, Path, AE_TYPE);
303
304         ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
305             "Type returned from %s was incorrect: %s, expected Btypes: %X\n",
306             Path, AcpiUtGetObjectTypeName (Info.ReturnObject),
307             ExpectedReturnBtypes));
308
309         /* On error exit, we must delete the return object */
310
311         AcpiUtRemoveReference (Info.ReturnObject);
312         return_ACPI_STATUS (AE_TYPE);
313     }
314
315     /* Object type is OK, return it */
316
317     *ReturnDesc = Info.ReturnObject;
318     return_ACPI_STATUS (AE_OK);
319 }
320
321
322 /*******************************************************************************
323  *
324  * FUNCTION:    AcpiUtEvaluateNumericObject
325  *
326  * PARAMETERS:  *ObjectName         - Object name to be evaluated
327  *              DeviceNode          - Node for the device
328  *              *Address            - Where the value is returned
329  *
330  * RETURN:      Status
331  *
332  * DESCRIPTION: Evaluates a numeric namespace object for a selected device
333  *              and stores result in *Address.
334  *
335  *              NOTE: Internal function, no parameter validation
336  *
337  ******************************************************************************/
338
339 ACPI_STATUS
340 AcpiUtEvaluateNumericObject (
341     char                    *ObjectName,
342     ACPI_NAMESPACE_NODE     *DeviceNode,
343     ACPI_INTEGER            *Address)
344 {
345     ACPI_OPERAND_OBJECT     *ObjDesc;
346     ACPI_STATUS             Status;
347
348
349     ACPI_FUNCTION_TRACE ("UtEvaluateNumericObject");
350
351
352     Status = AcpiUtEvaluateObject (DeviceNode, ObjectName,
353                 ACPI_BTYPE_INTEGER, &ObjDesc);
354     if (ACPI_FAILURE (Status))
355     {
356         return_ACPI_STATUS (Status);
357     }
358
359     /* Get the returned Integer */
360
361     *Address = ObjDesc->Integer.Value;
362
363     /* On exit, we must delete the return object */
364
365     AcpiUtRemoveReference (ObjDesc);
366     return_ACPI_STATUS (Status);
367 }
368
369
370 /*******************************************************************************
371  *
372  * FUNCTION:    AcpiUtCopyIdString
373  *
374  * PARAMETERS:  Destination         - Where to copy the string
375  *              Source              - Source string
376  *              MaxLength           - Length of the destination buffer
377  *
378  * RETURN:      None
379  *
380  * DESCRIPTION: Copies an ID string for the _HID, _CID, and _UID methods.
381  *              Performs removal of a leading asterisk if present -- workaround
382  *              for a known issue on a bunch of machines.
383  *
384  ******************************************************************************/
385
386 static void
387 AcpiUtCopyIdString (
388     char                    *Destination,
389     char                    *Source,
390     ACPI_SIZE               MaxLength)
391 {
392
393
394     /*
395      * Workaround for ID strings that have a leading asterisk. This construct
396      * is not allowed by the ACPI specification  (ID strings must be
397      * alphanumeric), but enough existing machines have this embedded in their
398      * ID strings that the following code is useful.
399      */
400     if (*Source == '*')
401     {
402         Source++;
403     }
404
405     /* Do the actual copy */
406
407     ACPI_STRNCPY (Destination, Source, MaxLength);
408 }
409
410
411 /*******************************************************************************
412  *
413  * FUNCTION:    AcpiUtExecute_HID
414  *
415  * PARAMETERS:  DeviceNode          - Node for the device
416  *              *Hid                - Where the HID is returned
417  *
418  * RETURN:      Status
419  *
420  * DESCRIPTION: Executes the _HID control method that returns the hardware
421  *              ID of the device.
422  *
423  *              NOTE: Internal function, no parameter validation
424  *
425  ******************************************************************************/
426
427 ACPI_STATUS
428 AcpiUtExecute_HID (
429     ACPI_NAMESPACE_NODE     *DeviceNode,
430     ACPI_DEVICE_ID          *Hid)
431 {
432     ACPI_OPERAND_OBJECT     *ObjDesc;
433     ACPI_STATUS             Status;
434
435
436     ACPI_FUNCTION_TRACE ("UtExecute_HID");
437
438
439     Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__HID,
440                 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc);
441     if (ACPI_FAILURE (Status))
442     {
443         return_ACPI_STATUS (Status);
444     }
445
446     if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER)
447     {
448         /* Convert the Numeric HID to string */
449
450         AcpiExEisaIdToString ((UINT32) ObjDesc->Integer.Value, Hid->Value);
451     }
452     else
453     {
454         /* Copy the String HID from the returned object */
455
456         AcpiUtCopyIdString (Hid->Value, ObjDesc->String.Pointer,
457                 sizeof (Hid->Value));
458     }
459
460     /* On exit, we must delete the return object */
461
462     AcpiUtRemoveReference (ObjDesc);
463     return_ACPI_STATUS (Status);
464 }
465
466
467 /*******************************************************************************
468  *
469  * FUNCTION:    AcpiUtTranslateOneCid
470  *
471  * PARAMETERS:  ObjDesc             - _CID object, must be integer or string
472  *              OneCid              - Where the CID string is returned
473  *
474  * RETURN:      Status
475  *
476  * DESCRIPTION: Return a numeric or string _CID value as a string.
477  *              (Compatible ID)
478  *
479  *              NOTE:  Assumes a maximum _CID string length of
480  *                     ACPI_MAX_CID_LENGTH.
481  *
482  ******************************************************************************/
483
484 static ACPI_STATUS
485 AcpiUtTranslateOneCid (
486     ACPI_OPERAND_OBJECT     *ObjDesc,
487     ACPI_COMPATIBLE_ID      *OneCid)
488 {
489
490
491     switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
492     {
493     case ACPI_TYPE_INTEGER:
494
495         /* Convert the Numeric CID to string */
496
497         AcpiExEisaIdToString ((UINT32) ObjDesc->Integer.Value, OneCid->Value);
498         return (AE_OK);
499
500     case ACPI_TYPE_STRING:
501
502         if (ObjDesc->String.Length > ACPI_MAX_CID_LENGTH)
503         {
504             return (AE_AML_STRING_LIMIT);
505         }
506
507         /* Copy the String CID from the returned object */
508
509         AcpiUtCopyIdString (OneCid->Value, ObjDesc->String.Pointer,
510                 ACPI_MAX_CID_LENGTH);
511         return (AE_OK);
512
513     default:
514
515         return (AE_TYPE);
516     }
517 }
518
519
520 /*******************************************************************************
521  *
522  * FUNCTION:    AcpiUtExecute_CID
523  *
524  * PARAMETERS:  DeviceNode          - Node for the device
525  *              *Cid                - Where the CID is returned
526  *
527  * RETURN:      Status
528  *
529  * DESCRIPTION: Executes the _CID control method that returns one or more
530  *              compatible hardware IDs for the device.
531  *
532  *              NOTE: Internal function, no parameter validation
533  *
534  ******************************************************************************/
535
536 ACPI_STATUS
537 AcpiUtExecute_CID (
538     ACPI_NAMESPACE_NODE     *DeviceNode,
539     ACPI_COMPATIBLE_ID_LIST **ReturnCidList)
540 {
541     ACPI_OPERAND_OBJECT     *ObjDesc;
542     ACPI_STATUS             Status;
543     UINT32                  Count;
544     UINT32                  Size;
545     ACPI_COMPATIBLE_ID_LIST *CidList;
546     ACPI_NATIVE_UINT        i;
547
548
549     ACPI_FUNCTION_TRACE ("UtExecute_CID");
550
551
552     /* Evaluate the _CID method for this device */
553
554     Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__CID,
555                 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING | ACPI_BTYPE_PACKAGE,
556                 &ObjDesc);
557     if (ACPI_FAILURE (Status))
558     {
559         return_ACPI_STATUS (Status);
560     }
561
562     /* Get the number of _CIDs returned */
563
564     Count = 1;
565     if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_PACKAGE)
566     {
567         Count = ObjDesc->Package.Count;
568     }
569
570     /* Allocate a worst-case buffer for the _CIDs */
571
572     Size = (((Count - 1) * sizeof (ACPI_COMPATIBLE_ID)) +
573                            sizeof (ACPI_COMPATIBLE_ID_LIST));
574
575     CidList = ACPI_MEM_CALLOCATE ((ACPI_SIZE) Size);
576     if (!CidList)
577     {
578         return_ACPI_STATUS (AE_NO_MEMORY);
579     }
580
581     /* Init CID list */
582
583     CidList->Count = Count;
584     CidList->Size  = Size;
585
586     /*
587      *  A _CID can return either a single compatible ID or a package of compatible
588      *  IDs.  Each compatible ID can be one of the following:
589      *  -- Number (32 bit compressed EISA ID) or
590      *  -- String (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss").
591      */
592
593     /* The _CID object can be either a single CID or a package (list) of CIDs */
594
595     if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_PACKAGE)
596     {
597         /* Translate each package element */
598
599         for (i = 0; i < Count; i++)
600         {
601             Status = AcpiUtTranslateOneCid (ObjDesc->Package.Elements[i],
602                             &CidList->Id[i]);
603             if (ACPI_FAILURE (Status))
604             {
605                 break;
606             }
607         }
608     }
609     else
610     {
611         /* Only one CID, translate to a string */
612
613         Status = AcpiUtTranslateOneCid (ObjDesc, CidList->Id);
614     }
615
616     /* Cleanup on error */
617
618     if (ACPI_FAILURE (Status))
619     {
620         ACPI_MEM_FREE (CidList);
621     }
622     else
623     {
624         *ReturnCidList = CidList;
625     }
626
627     /* On exit, we must delete the _CID return object */
628
629     AcpiUtRemoveReference (ObjDesc);
630     return_ACPI_STATUS (Status);
631 }
632
633
634 /*******************************************************************************
635  *
636  * FUNCTION:    AcpiUtExecute_UID
637  *
638  * PARAMETERS:  DeviceNode          - Node for the device
639  *              *Uid                - Where the UID is returned
640  *
641  * RETURN:      Status
642  *
643  * DESCRIPTION: Executes the _UID control method that returns the hardware
644  *              ID of the device.
645  *
646  *              NOTE: Internal function, no parameter validation
647  *
648  ******************************************************************************/
649
650 ACPI_STATUS
651 AcpiUtExecute_UID (
652     ACPI_NAMESPACE_NODE     *DeviceNode,
653     ACPI_DEVICE_ID          *Uid)
654 {
655     ACPI_OPERAND_OBJECT     *ObjDesc;
656     ACPI_STATUS             Status;
657
658
659     ACPI_FUNCTION_TRACE ("UtExecute_UID");
660
661
662     Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__UID,
663                 ACPI_BTYPE_INTEGER | ACPI_BTYPE_STRING, &ObjDesc);
664     if (ACPI_FAILURE (Status))
665     {
666         return_ACPI_STATUS (Status);
667     }
668
669     if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER)
670     {
671         /* Convert the Numeric UID to string */
672
673         AcpiExUnsignedIntegerToString (ObjDesc->Integer.Value, Uid->Value);
674     }
675     else
676     {
677         /* Copy the String UID from the returned object */
678
679         AcpiUtCopyIdString (Uid->Value, ObjDesc->String.Pointer,
680                 sizeof (Uid->Value));
681     }
682
683     /* On exit, we must delete the return object */
684
685     AcpiUtRemoveReference (ObjDesc);
686     return_ACPI_STATUS (Status);
687 }
688
689
690 /*******************************************************************************
691  *
692  * FUNCTION:    AcpiUtExecute_STA
693  *
694  * PARAMETERS:  DeviceNode          - Node for the device
695  *              *Flags              - Where the status flags are returned
696  *
697  * RETURN:      Status
698  *
699  * DESCRIPTION: Executes _STA for selected device and stores results in
700  *              *Flags.
701  *
702  *              NOTE: Internal function, no parameter validation
703  *
704  ******************************************************************************/
705
706 ACPI_STATUS
707 AcpiUtExecute_STA (
708     ACPI_NAMESPACE_NODE     *DeviceNode,
709     UINT32                  *Flags)
710 {
711     ACPI_OPERAND_OBJECT     *ObjDesc;
712     ACPI_STATUS             Status;
713
714
715     ACPI_FUNCTION_TRACE ("UtExecute_STA");
716
717
718     Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__STA,
719                 ACPI_BTYPE_INTEGER, &ObjDesc);
720     if (ACPI_FAILURE (Status))
721     {
722         if (AE_NOT_FOUND == Status)
723         {
724             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
725                 "_STA on %4.4s was not found, assuming device is present\n",
726                 AcpiUtGetNodeName (DeviceNode)));
727
728             *Flags = 0x0F;
729             Status = AE_OK;
730         }
731
732         return_ACPI_STATUS (Status);
733     }
734
735     /* Extract the status flags */
736
737     *Flags = (UINT32) ObjDesc->Integer.Value;
738
739     /* On exit, we must delete the return object */
740
741     AcpiUtRemoveReference (ObjDesc);
742     return_ACPI_STATUS (Status);
743 }
744
745
746 /*******************************************************************************
747  *
748  * FUNCTION:    AcpiUtExecute_Sxds
749  *
750  * PARAMETERS:  DeviceNode          - Node for the device
751  *              *Flags              - Where the status flags are returned
752  *
753  * RETURN:      Status
754  *
755  * DESCRIPTION: Executes _STA for selected device and stores results in
756  *              *Flags.
757  *
758  *              NOTE: Internal function, no parameter validation
759  *
760  ******************************************************************************/
761
762 ACPI_STATUS
763 AcpiUtExecute_Sxds (
764     ACPI_NAMESPACE_NODE     *DeviceNode,
765     UINT8                   *Highest)
766 {
767     ACPI_OPERAND_OBJECT     *ObjDesc;
768     ACPI_STATUS             Status;
769     UINT32                  i;
770
771
772     ACPI_FUNCTION_TRACE ("UtExecute_Sxds");
773
774
775     for (i = 0; i < 4; i++)
776     {
777         Highest[i] = 0xFF;
778         Status = AcpiUtEvaluateObject (DeviceNode,
779                     (char *) AcpiGbl_HighestDstateNames[i],
780                     ACPI_BTYPE_INTEGER, &ObjDesc);
781         if (ACPI_FAILURE (Status))
782         {
783             if (Status != AE_NOT_FOUND)
784             {
785                 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
786                     "%s on Device %4.4s, %s\n",
787                     (char *) AcpiGbl_HighestDstateNames[i],
788                     AcpiUtGetNodeName (DeviceNode),
789                     AcpiFormatException (Status)));
790
791                 return_ACPI_STATUS (Status);
792             }
793         }
794         else
795         {
796             /* Extract the Dstate value */
797
798             Highest[i] = (UINT8) ObjDesc->Integer.Value;
799
800             /* Delete the return object */
801
802             AcpiUtRemoveReference (ObjDesc);
803         }
804     }
805
806     return_ACPI_STATUS (AE_OK);
807 }