Print this page
acpica-unix2-20130823
PANKOVs restructure
   1 /******************************************************************************
   2  *
   3  * Module Name: uteval - Object evaluation
   4  *
   5  *****************************************************************************/
   6 
   7 /*
   8  * Copyright (C) 2000 - 2011, Intel Corp.
   9  * All rights reserved.
  10  *
  11  * Redistribution and use in source and binary forms, with or without
  12  * modification, are permitted provided that the following conditions
  13  * are met:
  14  * 1. Redistributions of source code must retain the above copyright
  15  *    notice, this list of conditions, and the following disclaimer,
  16  *    without modification.
  17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  18  *    substantially similar to the "NO WARRANTY" disclaimer below
  19  *    ("Disclaimer") and any redistribution must be conditioned upon
  20  *    including a substantially similar Disclaimer requirement for further
  21  *    binary redistribution.
  22  * 3. Neither the names of the above-listed copyright holders nor the names
  23  *    of any contributors may be used to endorse or promote products derived
  24  *    from this software without specific prior written permission.
  25  *
  26  * Alternatively, this software may be distributed under the terms of the
  27  * GNU General Public License ("GPL") version 2 as published by the Free
  28  * Software Foundation.


  78     UINT32                  ExpectedReturnBtypes,
  79     ACPI_OPERAND_OBJECT     **ReturnDesc)
  80 {
  81     ACPI_EVALUATE_INFO      *Info;
  82     ACPI_STATUS             Status;
  83     UINT32                  ReturnBtype;
  84 
  85 
  86     ACPI_FUNCTION_TRACE (UtEvaluateObject);
  87 
  88 
  89     /* Allocate the evaluation information block */
  90 
  91     Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
  92     if (!Info)
  93     {
  94         return_ACPI_STATUS (AE_NO_MEMORY);
  95     }
  96 
  97     Info->PrefixNode = PrefixNode;
  98     Info->Pathname = Path;
  99 
 100     /* Evaluate the object/method */
 101 
 102     Status = AcpiNsEvaluate (Info);
 103     if (ACPI_FAILURE (Status))
 104     {
 105         if (Status == AE_NOT_FOUND)
 106         {
 107             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s.%s] was not found\n",
 108                 AcpiUtGetNodeName (PrefixNode), Path));
 109         }
 110         else
 111         {
 112             ACPI_ERROR_METHOD ("Method execution failed",
 113                 PrefixNode, Path, Status);
 114         }
 115 
 116         goto Cleanup;
 117     }
 118 
 119     /* Did we get a return object? */
 120 
 121     if (!Info->ReturnObject)
 122     {
 123         if (ExpectedReturnBtypes)
 124         {
 125             ACPI_ERROR_METHOD ("No object was returned from",
 126                 PrefixNode, Path, AE_NOT_EXIST);
 127 
 128             Status = AE_NOT_EXIST;
 129         }
 130 
 131         goto Cleanup;
 132     }
 133 
 134     /* Map the return object type to the bitmapped type */
 135 
 136     switch ((Info->ReturnObject)->Common.Type)
 137     {
 138     case ACPI_TYPE_INTEGER:

 139         ReturnBtype = ACPI_BTYPE_INTEGER;
 140         break;
 141 
 142     case ACPI_TYPE_BUFFER:

 143         ReturnBtype = ACPI_BTYPE_BUFFER;
 144         break;
 145 
 146     case ACPI_TYPE_STRING:

 147         ReturnBtype = ACPI_BTYPE_STRING;
 148         break;
 149 
 150     case ACPI_TYPE_PACKAGE:

 151         ReturnBtype = ACPI_BTYPE_PACKAGE;
 152         break;
 153 
 154     default:

 155         ReturnBtype = 0;
 156         break;
 157     }
 158 
 159     if ((AcpiGbl_EnableInterpreterSlack) &&
 160         (!ExpectedReturnBtypes))
 161     {
 162         /*
 163          * We received a return object, but one was not expected. This can
 164          * happen frequently if the "implicit return" feature is enabled.
 165          * Just delete the return object and return AE_OK.
 166          */
 167         AcpiUtRemoveReference (Info->ReturnObject);
 168         goto Cleanup;
 169     }
 170 
 171     /* Is the return object one of the expected types? */
 172 
 173     if (!(ExpectedReturnBtypes & ReturnBtype))
 174     {


 238 
 239     *Value = ObjDesc->Integer.Value;
 240 
 241     /* On exit, we must delete the return object */
 242 
 243     AcpiUtRemoveReference (ObjDesc);
 244     return_ACPI_STATUS (Status);
 245 }
 246 
 247 
 248 /*******************************************************************************
 249  *
 250  * FUNCTION:    AcpiUtExecute_STA
 251  *
 252  * PARAMETERS:  DeviceNode          - Node for the device
 253  *              Flags               - Where the status flags are returned
 254  *
 255  * RETURN:      Status
 256  *
 257  * DESCRIPTION: Executes _STA for selected device and stores results in
 258  *              *Flags.

 259  *
 260  *              NOTE: Internal function, no parameter validation
 261  *
 262  ******************************************************************************/
 263 
 264 ACPI_STATUS
 265 AcpiUtExecute_STA (
 266     ACPI_NAMESPACE_NODE     *DeviceNode,
 267     UINT32                  *Flags)
 268 {
 269     ACPI_OPERAND_OBJECT     *ObjDesc;
 270     ACPI_STATUS             Status;
 271 
 272 
 273     ACPI_FUNCTION_TRACE (UtExecute_STA);
 274 
 275 
 276     Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__STA,
 277                 ACPI_BTYPE_INTEGER, &ObjDesc);
 278     if (ACPI_FAILURE (Status))
 279     {
 280         if (AE_NOT_FOUND == Status)
 281         {





 282             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
 283                 "_STA on %4.4s was not found, assuming device is present\n",
 284                 AcpiUtGetNodeName (DeviceNode)));
 285 
 286             *Flags = ACPI_UINT32_MAX;
 287             Status = AE_OK;
 288         }
 289 
 290         return_ACPI_STATUS (Status);
 291     }
 292 
 293     /* Extract the status flags */
 294 
 295     *Flags = (UINT32) ObjDesc->Integer.Value;
 296 
 297     /* On exit, we must delete the return object */
 298 
 299     AcpiUtRemoveReference (ObjDesc);
 300     return_ACPI_STATUS (Status);
 301 }


   1 /******************************************************************************
   2  *
   3  * Module Name: uteval - Object evaluation
   4  *
   5  *****************************************************************************/
   6 
   7 /*
   8  * Copyright (C) 2000 - 2013, Intel Corp.
   9  * All rights reserved.
  10  *
  11  * Redistribution and use in source and binary forms, with or without
  12  * modification, are permitted provided that the following conditions
  13  * are met:
  14  * 1. Redistributions of source code must retain the above copyright
  15  *    notice, this list of conditions, and the following disclaimer,
  16  *    without modification.
  17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  18  *    substantially similar to the "NO WARRANTY" disclaimer below
  19  *    ("Disclaimer") and any redistribution must be conditioned upon
  20  *    including a substantially similar Disclaimer requirement for further
  21  *    binary redistribution.
  22  * 3. Neither the names of the above-listed copyright holders nor the names
  23  *    of any contributors may be used to endorse or promote products derived
  24  *    from this software without specific prior written permission.
  25  *
  26  * Alternatively, this software may be distributed under the terms of the
  27  * GNU General Public License ("GPL") version 2 as published by the Free
  28  * Software Foundation.


  78     UINT32                  ExpectedReturnBtypes,
  79     ACPI_OPERAND_OBJECT     **ReturnDesc)
  80 {
  81     ACPI_EVALUATE_INFO      *Info;
  82     ACPI_STATUS             Status;
  83     UINT32                  ReturnBtype;
  84 
  85 
  86     ACPI_FUNCTION_TRACE (UtEvaluateObject);
  87 
  88 
  89     /* Allocate the evaluation information block */
  90 
  91     Info = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_EVALUATE_INFO));
  92     if (!Info)
  93     {
  94         return_ACPI_STATUS (AE_NO_MEMORY);
  95     }
  96 
  97     Info->PrefixNode = PrefixNode;
  98     Info->RelativePathname = Path;
  99 
 100     /* Evaluate the object/method */
 101 
 102     Status = AcpiNsEvaluate (Info);
 103     if (ACPI_FAILURE (Status))
 104     {
 105         if (Status == AE_NOT_FOUND)
 106         {
 107             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "[%4.4s.%s] was not found\n",
 108                 AcpiUtGetNodeName (PrefixNode), Path));
 109         }
 110         else
 111         {
 112             ACPI_ERROR_METHOD ("Method execution failed",
 113                 PrefixNode, Path, Status);
 114         }
 115 
 116         goto Cleanup;
 117     }
 118 
 119     /* Did we get a return object? */
 120 
 121     if (!Info->ReturnObject)
 122     {
 123         if (ExpectedReturnBtypes)
 124         {
 125             ACPI_ERROR_METHOD ("No object was returned from",
 126                 PrefixNode, Path, AE_NOT_EXIST);
 127 
 128             Status = AE_NOT_EXIST;
 129         }
 130 
 131         goto Cleanup;
 132     }
 133 
 134     /* Map the return object type to the bitmapped type */
 135 
 136     switch ((Info->ReturnObject)->Common.Type)
 137     {
 138     case ACPI_TYPE_INTEGER:
 139 
 140         ReturnBtype = ACPI_BTYPE_INTEGER;
 141         break;
 142 
 143     case ACPI_TYPE_BUFFER:
 144 
 145         ReturnBtype = ACPI_BTYPE_BUFFER;
 146         break;
 147 
 148     case ACPI_TYPE_STRING:
 149 
 150         ReturnBtype = ACPI_BTYPE_STRING;
 151         break;
 152 
 153     case ACPI_TYPE_PACKAGE:
 154 
 155         ReturnBtype = ACPI_BTYPE_PACKAGE;
 156         break;
 157 
 158     default:
 159 
 160         ReturnBtype = 0;
 161         break;
 162     }
 163 
 164     if ((AcpiGbl_EnableInterpreterSlack) &&
 165         (!ExpectedReturnBtypes))
 166     {
 167         /*
 168          * We received a return object, but one was not expected. This can
 169          * happen frequently if the "implicit return" feature is enabled.
 170          * Just delete the return object and return AE_OK.
 171          */
 172         AcpiUtRemoveReference (Info->ReturnObject);
 173         goto Cleanup;
 174     }
 175 
 176     /* Is the return object one of the expected types? */
 177 
 178     if (!(ExpectedReturnBtypes & ReturnBtype))
 179     {


 243 
 244     *Value = ObjDesc->Integer.Value;
 245 
 246     /* On exit, we must delete the return object */
 247 
 248     AcpiUtRemoveReference (ObjDesc);
 249     return_ACPI_STATUS (Status);
 250 }
 251 
 252 
 253 /*******************************************************************************
 254  *
 255  * FUNCTION:    AcpiUtExecute_STA
 256  *
 257  * PARAMETERS:  DeviceNode          - Node for the device
 258  *              Flags               - Where the status flags are returned
 259  *
 260  * RETURN:      Status
 261  *
 262  * DESCRIPTION: Executes _STA for selected device and stores results in
 263  *              *Flags. If _STA does not exist, then the device is assumed
 264  *              to be present/functional/enabled (as per the ACPI spec).
 265  *
 266  *              NOTE: Internal function, no parameter validation
 267  *
 268  ******************************************************************************/
 269 
 270 ACPI_STATUS
 271 AcpiUtExecute_STA (
 272     ACPI_NAMESPACE_NODE     *DeviceNode,
 273     UINT32                  *Flags)
 274 {
 275     ACPI_OPERAND_OBJECT     *ObjDesc;
 276     ACPI_STATUS             Status;
 277 
 278 
 279     ACPI_FUNCTION_TRACE (UtExecute_STA);
 280 
 281 
 282     Status = AcpiUtEvaluateObject (DeviceNode, METHOD_NAME__STA,
 283                 ACPI_BTYPE_INTEGER, &ObjDesc);
 284     if (ACPI_FAILURE (Status))
 285     {
 286         if (AE_NOT_FOUND == Status)
 287         {
 288             /*
 289              * if _STA does not exist, then (as per the ACPI specification),
 290              * the returned flags will indicate that the device is present,
 291              * functional, and enabled.
 292              */
 293             ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
 294                 "_STA on %4.4s was not found, assuming device is present\n",
 295                 AcpiUtGetNodeName (DeviceNode)));
 296 
 297             *Flags = ACPI_UINT32_MAX;
 298             Status = AE_OK;
 299         }
 300 
 301         return_ACPI_STATUS (Status);
 302     }
 303 
 304     /* Extract the status flags */
 305 
 306     *Flags = (UINT32) ObjDesc->Integer.Value;
 307 
 308     /* On exit, we must delete the return object */
 309 
 310     AcpiUtRemoveReference (ObjDesc);
 311     return_ACPI_STATUS (Status);
 312 }