ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

uteval.c
Go to the documentation of this file.
00001 /******************************************************************************
00002  *
00003  * Module Name: uteval - Object evaluation
00004  *
00005  *****************************************************************************/
00006 
00007 /******************************************************************************
00008  *
00009  * 1. Copyright Notice
00010  *
00011  * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp.
00012  * All rights reserved.
00013  *
00014  * 2. License
00015  *
00016  * 2.1. This is your license from Intel Corp. under its intellectual property
00017  * rights.  You may have additional license terms from the party that provided
00018  * you this software, covering your right to use that party's intellectual
00019  * property rights.
00020  *
00021  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
00022  * copy of the source code appearing in this file ("Covered Code") an
00023  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
00024  * base code distributed originally by Intel ("Original Intel Code") to copy,
00025  * make derivatives, distribute, use and display any portion of the Covered
00026  * Code in any form, with the right to sublicense such rights; and
00027  *
00028  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
00029  * license (with the right to sublicense), under only those claims of Intel
00030  * patents that are infringed by the Original Intel Code, to make, use, sell,
00031  * offer to sell, and import the Covered Code and derivative works thereof
00032  * solely to the minimum extent necessary to exercise the above copyright
00033  * license, and in no event shall the patent license extend to any additions
00034  * to or modifications of the Original Intel Code.  No other license or right
00035  * is granted directly or by implication, estoppel or otherwise;
00036  *
00037  * The above copyright and patent license is granted only if the following
00038  * conditions are met:
00039  *
00040  * 3. Conditions
00041  *
00042  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
00043  * Redistribution of source code of any substantial portion of the Covered
00044  * Code or modification with rights to further distribute source must include
00045  * the above Copyright Notice, the above License, this list of Conditions,
00046  * and the following Disclaimer and Export Compliance provision.  In addition,
00047  * Licensee must cause all Covered Code to which Licensee contributes to
00048  * contain a file documenting the changes Licensee made to create that Covered
00049  * Code and the date of any change.  Licensee must include in that file the
00050  * documentation of any changes made by any predecessor Licensee.  Licensee
00051  * must include a prominent statement that the modification is derived,
00052  * directly or indirectly, from Original Intel Code.
00053  *
00054  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
00055  * Redistribution of source code of any substantial portion of the Covered
00056  * Code or modification without rights to further distribute source must
00057  * include the following Disclaimer and Export Compliance provision in the
00058  * documentation and/or other materials provided with distribution.  In
00059  * addition, Licensee may not authorize further sublicense of source of any
00060  * portion of the Covered Code, and must include terms to the effect that the
00061  * license from Licensee to its licensee is limited to the intellectual
00062  * property embodied in the software Licensee provides to its licensee, and
00063  * not to intellectual property embodied in modifications its licensee may
00064  * make.
00065  *
00066  * 3.3. Redistribution of Executable. Redistribution in executable form of any
00067  * substantial portion of the Covered Code or modification must reproduce the
00068  * above Copyright Notice, and the following Disclaimer and Export Compliance
00069  * provision in the documentation and/or other materials provided with the
00070  * distribution.
00071  *
00072  * 3.4. Intel retains all right, title, and interest in and to the Original
00073  * Intel Code.
00074  *
00075  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
00076  * Intel shall be used in advertising or otherwise to promote the sale, use or
00077  * other dealings in products derived from or relating to the Covered Code
00078  * without prior written authorization from Intel.
00079  *
00080  * 4. Disclaimer and Export Compliance
00081  *
00082  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
00083  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
00084  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
00085  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
00086  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
00087  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
00088  * PARTICULAR PURPOSE.
00089  *
00090  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
00091  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
00092  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
00093  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
00094  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
00095  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
00096  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
00097  * LIMITED REMEDY.
00098  *
00099  * 4.3. Licensee shall not export, either directly or indirectly, any of this
00100  * software or system incorporating such software without first obtaining any
00101  * required license or other approval from the U. S. Department of Commerce or
00102  * any other agency or department of the United States Government.  In the
00103  * event Licensee exports any such software from the United States or
00104  * re-exports any such software from a foreign destination, Licensee shall
00105  * ensure that the distribution and export/re-export of the software is in
00106  * compliance with all laws, regulations, orders, or other restrictions of the
00107  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
00108  * any of its subsidiaries will export/re-export any technical data, process,
00109  * software, or service, directly or indirectly, to any country for which the
00110  * United States government or any agency thereof requires an export license,
00111  * other governmental approval, or letter of assurance, without first obtaining
00112  * such license, approval or letter.
00113  *
00114  *****************************************************************************/
00115 
00116 #define __UTEVAL_C__
00117 
00118 #include "acpi.h"
00119 #include "accommon.h"
00120 #include "acnamesp.h"
00121 
00122 
00123 #define _COMPONENT          ACPI_UTILITIES
00124         ACPI_MODULE_NAME    ("uteval")
00125 
00126 
00127 /*******************************************************************************
00128  *
00129  * FUNCTION:    AcpiUtEvaluateObject
00130  *
00131  * PARAMETERS:  PrefixNode          - Starting node
00132  *              Path                - Path to object from starting node
00133  *              ExpectedReturnTypes - Bitmap of allowed return types
00134  *              ReturnDesc          - Where a return value is stored
00135  *
00136  * RETURN:      Status
00137  *
00138  * DESCRIPTION: Evaluates a namespace object and verifies the type of the
00139  *              return object. Common code that simplifies accessing objects
00140  *              that have required return objects of fixed types.
00141  *
00142  *              NOTE: Internal function, no parameter validation
00143  *
00144  ******************************************************************************/
00145 
00146 ACPI_STATUS
00147 AcpiUtEvaluateObject (
00148     ACPI_NAMESPACE_NODE     *PrefixNode,
00149     char                    *Path,
00150     UINT32                  ExpectedReturnBtypes,
00151     ACPI_OPERAND_OBJECT     **ReturnDesc)
00152 {
00153     ACPI_EVALUATE_INFO      *Info;
00154     ACPI_STATUS             Status;
00155     UINT32                  ReturnBtype;
00156 
00157 
00158     ACPI_FUNCTION_TRACE (UtEvaluateObject);
00159 
00160 
00161     /* Allocate the evaluation information block */
00162 
00163     Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
00164     if (!Info)
00165     {
00166         return_ACPI_STATUS (AE_NO_MEMORY);
00167     }
00168 
00169     Info->PrefixNode = PrefixNode;
00170     Info->Pathname = Path;
00171 
00172     /* Evaluate the object/method */
00173 
00174     Status = AcpiNsEvaluate (Info);
00175     if (ACPI_FAILURE (Status))
00176     {
00177         if (Status == AE_NOT_FOUND)
00178         {
00179             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s.%s] was not found\n",
00180                 AcpiUtGetNodeName (PrefixNode), Path));
00181         }
00182         else
00183         {
00184             ACPI_ERROR_METHOD ("Method execution failed",
00185                 PrefixNode, Path, Status);
00186         }
00187 
00188         goto Cleanup;
00189     }
00190 
00191     /* Did we get a return object? */
00192 
00193     if (!Info->ReturnObject)
00194     {
00195         if (ExpectedReturnBtypes)
00196         {
00197             ACPI_ERROR_METHOD ("No object was returned from",
00198                 PrefixNode, Path, AE_NOT_EXIST);
00199 
00200             Status = AE_NOT_EXIST;
00201         }
00202 
00203         goto Cleanup;
00204     }
00205 
00206     /* Map the return object type to the bitmapped type */
00207 
00208     switch ((Info->ReturnObject)->Common.Type)
00209     {
00210     case ACPI_TYPE_INTEGER:
00211         ReturnBtype = ACPI_BTYPE_INTEGER;
00212         break;
00213 
00214     case ACPI_TYPE_BUFFER:
00215         ReturnBtype = ACPI_BTYPE_BUFFER;
00216         break;
00217 
00218     case ACPI_TYPE_STRING:
00219         ReturnBtype = ACPI_BTYPE_STRING;
00220         break;
00221 
00222     case ACPI_TYPE_PACKAGE:
00223         ReturnBtype = ACPI_BTYPE_PACKAGE;
00224         break;
00225 
00226     default:
00227         ReturnBtype = 0;
00228         break;
00229     }
00230 
00231     if ((AcpiGbl_EnableInterpreterSlack) &&
00232         (!ExpectedReturnBtypes))
00233     {
00234         /*
00235          * We received a return object, but one was not expected. This can
00236          * happen frequently if the "implicit return" feature is enabled.
00237          * Just delete the return object and return AE_OK.
00238          */
00239         AcpiUtRemoveReference (Info->ReturnObject);
00240         goto Cleanup;
00241     }
00242 
00243     /* Is the return object one of the expected types? */
00244 
00245     if (!(ExpectedReturnBtypes & ReturnBtype))
00246     {
00247         ACPI_ERROR_METHOD ("Return object type is incorrect",
00248             PrefixNode, Path, AE_TYPE);
00249 
00250         ACPI_ERROR ((AE_INFO,
00251             "Type returned from %s was incorrect: %s, expected Btypes: 0x%X",
00252             Path, AcpiUtGetObjectTypeName (Info->ReturnObject),
00253             ExpectedReturnBtypes));
00254 
00255         /* On error exit, we must delete the return object */
00256 
00257         AcpiUtRemoveReference (Info->ReturnObject);
00258         Status = AE_TYPE;
00259         goto Cleanup;
00260     }
00261 
00262     /* Object type is OK, return it */
00263 
00264     *ReturnDesc = Info->ReturnObject;
00265 
00266 Cleanup:
00267     ACPI_FREE (Info);
00268     return_ACPI_STATUS (Status);
00269 }
00270 
00271 
00272 /*******************************************************************************
00273  *
00274  * FUNCTION:    AcpiUtEvaluateNumericObject
00275  *
00276  * PARAMETERS:  ObjectName          - Object name to be evaluated
00277  *              DeviceNode          - Node for the device
00278  *              Value               - Where the value is returned
00279  *
00280  * RETURN:      Status
00281  *
00282  * DESCRIPTION: Evaluates a numeric namespace object for a selected device
00283  *              and stores result in *Value.
00284  *
00285  *              NOTE: Internal function, no parameter validation
00286  *
00287  ******************************************************************************/
00288 
00289 ACPI_STATUS
00290 AcpiUtEvaluateNumericObject (
00291     char                    *ObjectName,
00292     ACPI_NAMESPACE_NODE     *DeviceNode,
00293     UINT64                  *Value)
00294 {
00295     ACPI_OPERAND_OBJECT     *ObjDesc;
00296     ACPI_STATUS             Status;
00297 
00298 
00299     ACPI_FUNCTION_TRACE (UtEvaluateNumericObject);
00300 
00301 
00302     Status = AcpiUtEvaluateObject (DeviceNode, ObjectName,
00303                 ACPI_BTYPE_INTEGER, &ObjDesc);
00304     if (ACPI_FAILURE (Status))
00305     {
00306         return_ACPI_STATUS (Status);
00307     }
00308 
00309     /* Get the returned Integer */
00310 
00311     *Value = ObjDesc->Integer.Value;
00312 
00313     /* On exit, we must delete the return object */
00314 
00315     AcpiUtRemoveReference (ObjDesc);
00316     return_ACPI_STATUS (Status);
00317 }
00318 
00319 
00320 /*******************************************************************************
00321  *
00322  * FUNCTION:    AcpiUtExecute_STA
00323  *
00324  * PARAMETERS:  DeviceNode          - Node for the device
00325  *              Flags               - Where the status flags are returned
00326  *
00327  * RETURN:      Status
00328  *
00329  * DESCRIPTION: Executes _STA for selected device and stores results in
00330  *              *Flags.
00331  *
00332  *              NOTE: Internal function, no parameter validation
00333  *
00334  ******************************************************************************/
00335 
00336 ACPI_STATUS
00337 AcpiUtExecute_STA (
00338     ACPI_NAMESPACE_NODE     *DeviceNode,
00339     UINT32                  *Flags)
00340 {
00341     ACPI_OPERAND_OBJECT     *ObjDesc;
00342     ACPI_STATUS             Status;
00343 
00344 
00345     ACPI_FUNCTION_TRACE (UtExecute_STA);
00346 
00347 
00348     Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__STA,
00349                 ACPI_BTYPE_INTEGER, &ObjDesc);
00350     if (ACPI_FAILURE (Status))
00351     {
00352         if (AE_NOT_FOUND == Status)
00353         {
00354             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
00355                 "_STA on %4.4s was not found, assuming device is present\n",
00356                 AcpiUtGetNodeName (DeviceNode)));
00357 
00358             *Flags = ACPI_UINT32_MAX;
00359             Status = AE_OK;
00360         }
00361 
00362         return_ACPI_STATUS (Status);
00363     }
00364 
00365     /* Extract the status flags */
00366 
00367     *Flags = (UINT32) ObjDesc->Integer.Value;
00368 
00369     /* On exit, we must delete the return object */
00370 
00371     AcpiUtRemoveReference (ObjDesc);
00372     return_ACPI_STATUS (Status);
00373 }
00374 
00375 
00376 /*******************************************************************************
00377  *
00378  * FUNCTION:    AcpiUtExecutePowerMethods
00379  *
00380  * PARAMETERS:  DeviceNode          - Node for the device
00381  *              MethodNames         - Array of power method names
00382  *              MethodCount         - Number of methods to execute
00383  *              OutValues           - Where the power method values are returned
00384  *
00385  * RETURN:      Status, OutValues
00386  *
00387  * DESCRIPTION: Executes the specified power methods for the device and returns
00388  *              the result(s).
00389  *
00390  *              NOTE: Internal function, no parameter validation
00391  *
00392  ******************************************************************************/
00393 
00394 ACPI_STATUS
00395 AcpiUtExecutePowerMethods (
00396     ACPI_NAMESPACE_NODE     *DeviceNode,
00397     const char              **MethodNames,
00398     UINT8                   MethodCount,
00399     UINT8                   *OutValues)
00400 {
00401     ACPI_OPERAND_OBJECT     *ObjDesc;
00402     ACPI_STATUS             Status;
00403     ACPI_STATUS             FinalStatus = AE_NOT_FOUND;
00404     UINT32                  i;
00405 
00406 
00407     ACPI_FUNCTION_TRACE (UtExecutePowerMethods);
00408 
00409 
00410     for (i = 0; i < MethodCount; i++)
00411     {
00412         /*
00413          * Execute the power method (_SxD or _SxW). The only allowable
00414          * return type is an Integer.
00415          */
00416         Status = AcpiUtEvaluateObject (DeviceNode,
00417                     ACPI_CAST_PTR (char, MethodNames[i]),
00418                     ACPI_BTYPE_INTEGER, &ObjDesc);
00419         if (ACPI_SUCCESS (Status))
00420         {
00421             OutValues[i] = (UINT8) ObjDesc->Integer.Value;
00422 
00423             /* Delete the return object */
00424 
00425             AcpiUtRemoveReference (ObjDesc);
00426             FinalStatus = AE_OK;            /* At least one value is valid */
00427             continue;
00428         }
00429 
00430         OutValues[i] = ACPI_UINT8_MAX;
00431         if (Status == AE_NOT_FOUND)
00432         {
00433             continue; /* Ignore if not found */
00434         }
00435 
00436         ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "Failed %s on Device %4.4s, %s\n",
00437             ACPI_CAST_PTR (char, MethodNames[i]),
00438             AcpiUtGetNodeName (DeviceNode), AcpiFormatException (Status)));
00439     }
00440 
00441     return_ACPI_STATUS (FinalStatus);
00442 }

Generated on Sun May 27 2012 04:27:23 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.