uteval.c revision 67754
1/****************************************************************************** 2 * 3 * Module Name: cmeval - Object evaluation 4 * $Revision: 18 $ 5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999, Intel Corp. All rights 13 * 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 __CMEVAL_C__ 118 119#include "acpi.h" 120#include "acnamesp.h" 121#include "acinterp.h" 122 123 124#define _COMPONENT MISCELLANEOUS 125 MODULE_NAME ("cmeval") 126 127 128/**************************************************************************** 129 * 130 * FUNCTION: AcpiCmEvaluateNumericObject 131 * 132 * PARAMETERS: *ObjectName - Object name to be evaluated 133 * DeviceNode - Node for the device 134 * *Address - Where the value is returned 135 * 136 * RETURN: Status 137 * 138 * DESCRIPTION: evaluates a numeric namespace object for a selected device 139 * and stores results in *Address. 140 * 141 * NOTE: Internal function, no parameter validation 142 * 143 ***************************************************************************/ 144 145ACPI_STATUS 146AcpiCmEvaluateNumericObject ( 147 NATIVE_CHAR *ObjectName, 148 ACPI_NAMESPACE_NODE *DeviceNode, 149 ACPI_INTEGER *Address) 150{ 151 ACPI_OPERAND_OBJECT *ObjDesc; 152 ACPI_STATUS Status; 153 154 155 FUNCTION_TRACE ("CmEvaluateNumericObject"); 156 157 158 /* Execute the method */ 159 160 Status = AcpiNsEvaluateRelative (DeviceNode, ObjectName, NULL, &ObjDesc); 161 if (ACPI_FAILURE (Status)) 162 { 163 if (Status == AE_NOT_FOUND) 164 { 165 DEBUG_PRINT (ACPI_INFO, 166 ("%s on %4.4s was not found\n", ObjectName, 167 &DeviceNode->Name)); 168 } 169 else 170 { 171 DEBUG_PRINT (ACPI_ERROR, 172 ("%s on %4.4s failed with status %4.4x\n", ObjectName, 173 &DeviceNode->Name, 174 AcpiCmFormatException (Status))); 175 } 176 177 return_ACPI_STATUS (Status); 178 } 179 180 181 /* Did we get a return object? */ 182 183 if (!ObjDesc) 184 { 185 DEBUG_PRINT (ACPI_ERROR, 186 ("No object was returned from %s\n", ObjectName)); 187 return_ACPI_STATUS (AE_TYPE); 188 } 189 190 /* Is the return object of the correct type? */ 191 192 if (ObjDesc->Common.Type != ACPI_TYPE_NUMBER) 193 { 194 Status = AE_TYPE; 195 DEBUG_PRINT (ACPI_ERROR, 196 ("Type returned from %s was not a number: %d \n", 197 ObjectName, ObjDesc->Common.Type)); 198 } 199 else 200 { 201 /* 202 * Since the structure is a union, setting any field will set all 203 * of the variables in the union 204 */ 205 *Address = ObjDesc->Number.Value; 206 } 207 208 /* On exit, we must delete the return object */ 209 210 AcpiCmRemoveReference (ObjDesc); 211 212 return_ACPI_STATUS (Status); 213} 214 215 216/**************************************************************************** 217 * 218 * FUNCTION: AcpiCmExecute_HID 219 * 220 * PARAMETERS: DeviceNode - Node for the device 221 * *Hid - Where the HID is returned 222 * 223 * RETURN: Status 224 * 225 * DESCRIPTION: Executes the _HID control method that returns the hardware 226 * ID of the device. 227 * 228 * NOTE: Internal function, no parameter validation 229 * 230 ***************************************************************************/ 231 232ACPI_STATUS 233AcpiCmExecute_HID ( 234 ACPI_NAMESPACE_NODE *DeviceNode, 235 DEVICE_ID *Hid) 236{ 237 ACPI_OPERAND_OBJECT *ObjDesc; 238 ACPI_STATUS Status; 239 240 241 FUNCTION_TRACE ("CmExecute_HID"); 242 243 244 /* Execute the method */ 245 246 Status = AcpiNsEvaluateRelative (DeviceNode, 247 METHOD_NAME__HID, NULL, &ObjDesc); 248 if (ACPI_FAILURE (Status)) 249 { 250 if (Status == AE_NOT_FOUND) 251 { 252 DEBUG_PRINT (ACPI_INFO, 253 ("_HID on %4.4s was not found\n", 254 &DeviceNode->Name)); 255 } 256 257 else 258 { 259 DEBUG_PRINT (ACPI_ERROR, 260 ("_HID on %4.4s failed with status %4.4x\n", 261 &DeviceNode->Name, 262 AcpiCmFormatException (Status))); 263 } 264 265 return_ACPI_STATUS (Status); 266 } 267 268 /* Did we get a return object? */ 269 270 if (!ObjDesc) 271 { 272 DEBUG_PRINT (ACPI_ERROR, ("No object was returned from _HID\n")); 273 return_ACPI_STATUS (AE_TYPE); 274 } 275 276 /* 277 * A _HID can return either a Number (32 bit compressed EISA ID) or 278 * a string 279 */ 280 281 if ((ObjDesc->Common.Type != ACPI_TYPE_NUMBER) && 282 (ObjDesc->Common.Type != ACPI_TYPE_STRING)) 283 { 284 Status = AE_TYPE; 285 DEBUG_PRINT (ACPI_ERROR, 286 ("Type returned from _HID was not a number or string: [0x%X] \n", 287 ObjDesc->Common.Type)); 288 } 289 290 else 291 { 292 if (ObjDesc->Common.Type == ACPI_TYPE_NUMBER) 293 { 294 /* Convert the Numeric HID to string */ 295 296 AcpiAmlEisaIdToString ((UINT32) ObjDesc->Number.Value, Hid->Buffer); 297 } 298 299 else 300 { 301 /* Copy the String HID from the returned object */ 302 303 STRNCPY(Hid->Buffer, ObjDesc->String.Pointer, sizeof(Hid->Buffer)); 304 } 305 } 306 307 308 /* On exit, we must delete the return object */ 309 310 AcpiCmRemoveReference (ObjDesc); 311 312 return_ACPI_STATUS (Status); 313} 314 315 316/**************************************************************************** 317 * 318 * FUNCTION: AcpiCmExecute_UID 319 * 320 * PARAMETERS: DeviceNode - Node for the device 321 * *Uid - Where the UID is returned 322 * 323 * RETURN: Status 324 * 325 * DESCRIPTION: Executes the _UID control method that returns the hardware 326 * ID of the device. 327 * 328 * NOTE: Internal function, no parameter validation 329 * 330 ***************************************************************************/ 331 332ACPI_STATUS 333AcpiCmExecute_UID ( 334 ACPI_NAMESPACE_NODE *DeviceNode, 335 DEVICE_ID *Uid) 336{ 337 ACPI_OPERAND_OBJECT *ObjDesc; 338 ACPI_STATUS Status; 339 340 341 /* Execute the method */ 342 343 Status = AcpiNsEvaluateRelative (DeviceNode, 344 METHOD_NAME__UID, NULL, &ObjDesc); 345 if (ACPI_FAILURE (Status)) 346 { 347 if (Status == AE_NOT_FOUND) 348 { 349 DEBUG_PRINT (ACPI_INFO, 350 ("_UID on %4.4s was not found\n", 351 &DeviceNode->Name)); 352 } 353 354 else 355 { 356 DEBUG_PRINT (ACPI_ERROR, 357 ("_UID on %4.4s failed with status %4.4x\n", 358 &DeviceNode->Name, 359 AcpiCmFormatException (Status))); 360 } 361 362 return (Status); 363 } 364 365 /* Did we get a return object? */ 366 367 if (!ObjDesc) 368 { 369 DEBUG_PRINT (ACPI_ERROR, ("No object was returned from _UID\n")); 370 return (AE_TYPE); 371 } 372 373 /* 374 * A _UID can return either a Number (32 bit compressed EISA ID) or 375 * a string 376 */ 377 378 if ((ObjDesc->Common.Type != ACPI_TYPE_NUMBER) && 379 (ObjDesc->Common.Type != ACPI_TYPE_STRING)) 380 { 381 Status = AE_TYPE; 382 DEBUG_PRINT (ACPI_ERROR, 383 ("Type returned from _UID was not a number or string: %d \n", 384 ObjDesc->Common.Type)); 385 } 386 387 else 388 { 389 if (ObjDesc->Common.Type == ACPI_TYPE_NUMBER) 390 { 391 /* Convert the Numeric UID to string */ 392 393 AcpiAmlUnsignedIntegerToString (ObjDesc->Number.Value, Uid->Buffer); 394 } 395 396 else 397 { 398 /* Copy the String UID from the returned object */ 399 400 STRNCPY(Uid->Buffer, ObjDesc->String.Pointer, sizeof(Uid->Buffer)); 401 } 402 } 403 404 405 /* On exit, we must delete the return object */ 406 407 AcpiCmRemoveReference (ObjDesc); 408 409 return (Status); 410} 411 412/**************************************************************************** 413 * 414 * FUNCTION: AcpiCmExecute_STA 415 * 416 * PARAMETERS: DeviceNode - Node for the device 417 * *Flags - Where the status flags are returned 418 * 419 * RETURN: Status 420 * 421 * DESCRIPTION: Executes _STA for selected device and stores results in 422 * *Flags. 423 * 424 * NOTE: Internal function, no parameter validation 425 * 426 ***************************************************************************/ 427 428ACPI_STATUS 429AcpiCmExecute_STA ( 430 ACPI_NAMESPACE_NODE *DeviceNode, 431 UINT32 *Flags) 432{ 433 ACPI_OPERAND_OBJECT *ObjDesc; 434 ACPI_STATUS Status; 435 436 437 FUNCTION_TRACE ("CmExecute_STA"); 438 439 /* Execute the method */ 440 441 Status = AcpiNsEvaluateRelative (DeviceNode, 442 METHOD_NAME__STA, NULL, &ObjDesc); 443 if (AE_NOT_FOUND == Status) 444 { 445 DEBUG_PRINT (ACPI_INFO, 446 ("_STA on %4.4s was not found, assuming present.\n", 447 &DeviceNode->Name)); 448 449 *Flags = 0x0F; 450 Status = AE_OK; 451 } 452 453 else if (ACPI_FAILURE (Status)) 454 { 455 DEBUG_PRINT (ACPI_ERROR, 456 ("_STA on %4.4s failed with status %s\n", 457 &DeviceNode->Name, 458 AcpiCmFormatException (Status))); 459 } 460 461 else /* success */ 462 { 463 /* Did we get a return object? */ 464 465 if (!ObjDesc) 466 { 467 DEBUG_PRINT (ACPI_ERROR, ("No object was returned from _STA\n")); 468 return_ACPI_STATUS (AE_TYPE); 469 } 470 471 /* Is the return object of the correct type? */ 472 473 if (ObjDesc->Common.Type != ACPI_TYPE_NUMBER) 474 { 475 Status = AE_TYPE; 476 DEBUG_PRINT (ACPI_ERROR, 477 ("Type returned from _STA was not a number: %d \n", 478 ObjDesc->Common.Type)); 479 } 480 481 else 482 { 483 /* Extract the status flags */ 484 485 *Flags = (UINT32) ObjDesc->Number.Value; 486 } 487 488 /* On exit, we must delete the return object */ 489 490 AcpiCmRemoveReference (ObjDesc); 491 } 492 493 return_ACPI_STATUS (Status); 494} 495