uteval.c revision 102550
1/****************************************************************************** 2 * 3 * Module Name: uteval - Object evaluation 4 * $Revision: 41 $ 5 * 6 *****************************************************************************/ 7 8/****************************************************************************** 9 * 10 * 1. Copyright Notice 11 * 12 * Some or all of this work - Copyright (c) 1999 - 2002, 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: AcpiUtEvaluateNumericObject 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 146AcpiUtEvaluateNumericObject ( 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 ACPI_FUNCTION_TRACE ("UtEvaluateNumericObject"); 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 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "%s on %4.4s was not found\n", 166 ObjectName, DeviceNode->Name.Ascii)); 167 } 168 else 169 { 170 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "%s on %4.4s failed with status %s\n", 171 ObjectName, DeviceNode->Name.Ascii, 172 AcpiFormatException (Status))); 173 } 174 175 return_ACPI_STATUS (Status); 176 } 177 178 179 /* Did we get a return object? */ 180 181 if (!ObjDesc) 182 { 183 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No object was returned from %s\n", 184 ObjectName)); 185 return_ACPI_STATUS (AE_TYPE); 186 } 187 188 /* Is the return object of the correct type? */ 189 190 if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_INTEGER) 191 { 192 Status = AE_TYPE; 193 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 194 "Type returned from %s was not an Integer: %X \n", 195 ObjectName, ACPI_GET_OBJECT_TYPE (ObjDesc))); 196 } 197 else 198 { 199 /* 200 * Since the structure is a union, setting any field will set all 201 * of the variables in the union 202 */ 203 *Address = ObjDesc->Integer.Value; 204 } 205 206 /* On exit, we must delete the return object */ 207 208 AcpiUtRemoveReference (ObjDesc); 209 210 return_ACPI_STATUS (Status); 211} 212 213 214/******************************************************************************* 215 * 216 * FUNCTION: AcpiUtExecute_HID 217 * 218 * PARAMETERS: DeviceNode - Node for the device 219 * *Hid - Where the HID is returned 220 * 221 * RETURN: Status 222 * 223 * DESCRIPTION: Executes the _HID control method that returns the hardware 224 * ID of the device. 225 * 226 * NOTE: Internal function, no parameter validation 227 * 228 ******************************************************************************/ 229 230ACPI_STATUS 231AcpiUtExecute_HID ( 232 ACPI_NAMESPACE_NODE *DeviceNode, 233 ACPI_DEVICE_ID *Hid) 234{ 235 ACPI_OPERAND_OBJECT *ObjDesc; 236 ACPI_STATUS Status; 237 238 239 ACPI_FUNCTION_TRACE ("UtExecute_HID"); 240 241 242 /* Execute the method */ 243 244 Status = AcpiNsEvaluateRelative (DeviceNode, 245 METHOD_NAME__HID, NULL, &ObjDesc); 246 if (ACPI_FAILURE (Status)) 247 { 248 if (Status == AE_NOT_FOUND) 249 { 250 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "_HID on %4.4s was not found\n", 251 DeviceNode->Name.Ascii)); 252 } 253 else 254 { 255 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "_HID on %4.4s failed %s\n", 256 DeviceNode->Name.Ascii, AcpiFormatException (Status))); 257 } 258 259 return_ACPI_STATUS (Status); 260 } 261 262 /* Did we get a return object? */ 263 264 if (!ObjDesc) 265 { 266 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No object was returned from _HID\n")); 267 return_ACPI_STATUS (AE_TYPE); 268 } 269 270 /* 271 * A _HID can return either a Number (32 bit compressed EISA ID) or 272 * a string 273 */ 274 if ((ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_INTEGER) && 275 (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_STRING)) 276 { 277 Status = AE_TYPE; 278 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 279 "Type returned from _HID not a number or string: %s(%X) \n", 280 AcpiUtGetObjectTypeName (ObjDesc), 281 ACPI_GET_OBJECT_TYPE (ObjDesc))); 282 } 283 else 284 { 285 if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER) 286 { 287 /* Convert the Numeric HID to string */ 288 289 AcpiExEisaIdToString ((UINT32) ObjDesc->Integer.Value, Hid->Buffer); 290 } 291 else 292 { 293 /* Copy the String HID from the returned object */ 294 295 ACPI_STRNCPY (Hid->Buffer, ObjDesc->String.Pointer, sizeof(Hid->Buffer)); 296 } 297 } 298 299 /* On exit, we must delete the return object */ 300 301 AcpiUtRemoveReference (ObjDesc); 302 303 return_ACPI_STATUS (Status); 304} 305 306 307/******************************************************************************* 308 * 309 * FUNCTION: AcpiUtExecute_CID 310 * 311 * PARAMETERS: DeviceNode - Node for the device 312 * *Cid - Where the CID is returned 313 * 314 * RETURN: Status 315 * 316 * DESCRIPTION: Executes the _CID control method that returns one or more 317 * compatible hardware IDs for the device. 318 * 319 * NOTE: Internal function, no parameter validation 320 * 321 ******************************************************************************/ 322 323ACPI_STATUS 324AcpiUtExecute_CID ( 325 ACPI_NAMESPACE_NODE *DeviceNode, 326 ACPI_DEVICE_ID *Cid) 327{ 328 ACPI_OPERAND_OBJECT *ObjDesc; 329 ACPI_STATUS Status; 330 331 332 ACPI_FUNCTION_TRACE ("UtExecute_CID"); 333 334 /* Execute the method */ 335 336 Status = AcpiNsEvaluateRelative (DeviceNode, 337 METHOD_NAME__CID, NULL, &ObjDesc); 338 if (ACPI_FAILURE (Status)) 339 { 340 if (Status == AE_NOT_FOUND) 341 { 342 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "_CID on %4.4s was not found\n", 343 DeviceNode->Name.Ascii)); 344 } 345 else 346 { 347 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "_CID on %4.4s failed %s\n", 348 DeviceNode->Name.Ascii, AcpiFormatException (Status))); 349 } 350 351 return_ACPI_STATUS (Status); 352 } 353 354 /* Did we get a return object? */ 355 356 if (!ObjDesc) 357 { 358 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No object was returned from _CID\n")); 359 return_ACPI_STATUS (AE_TYPE); 360 } 361 362 /* 363 * A _CID can return either a single compatible ID or a package of compatible 364 * IDs. Each compatible ID can be a Number (32 bit compressed EISA ID) or 365 * string (PCI ID format, e.g. "PCI\VEN_vvvv&DEV_dddd&SUBSYS_ssssssss"). 366 */ 367 switch (ACPI_GET_OBJECT_TYPE (ObjDesc)) 368 { 369 case ACPI_TYPE_INTEGER: 370 371 /* Convert the Numeric CID to string */ 372 373 AcpiExEisaIdToString ((UINT32) ObjDesc->Integer.Value, Cid->Buffer); 374 break; 375 376 case ACPI_TYPE_STRING: 377 378 /* Copy the String CID from the returned object */ 379 380 ACPI_STRNCPY (Cid->Buffer, ObjDesc->String.Pointer, sizeof(Cid->Buffer)); 381 break; 382 383 case ACPI_TYPE_PACKAGE: 384 385 /* TBD: Parse package elements; need different return struct, etc. */ 386 break; 387 388 default: 389 390 Status = AE_TYPE; 391 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 392 "Type returned from _CID not a number, string, or package: %s(%X) \n", 393 AcpiUtGetObjectTypeName (ObjDesc), 394 ACPI_GET_OBJECT_TYPE (ObjDesc))); 395 break; 396 } 397 398 /* On exit, we must delete the return object */ 399 400 AcpiUtRemoveReference (ObjDesc); 401 402 return_ACPI_STATUS (Status); 403} 404 405 406/******************************************************************************* 407 * 408 * FUNCTION: AcpiUtExecute_UID 409 * 410 * PARAMETERS: DeviceNode - Node for the device 411 * *Uid - Where the UID is returned 412 * 413 * RETURN: Status 414 * 415 * DESCRIPTION: Executes the _UID control method that returns the hardware 416 * ID of the device. 417 * 418 * NOTE: Internal function, no parameter validation 419 * 420 ******************************************************************************/ 421 422ACPI_STATUS 423AcpiUtExecute_UID ( 424 ACPI_NAMESPACE_NODE *DeviceNode, 425 ACPI_DEVICE_ID *Uid) 426{ 427 ACPI_OPERAND_OBJECT *ObjDesc; 428 ACPI_STATUS Status; 429 430 431 ACPI_FUNCTION_NAME ("UtExecute_UID"); 432 433 434 /* Execute the method */ 435 436 Status = AcpiNsEvaluateRelative (DeviceNode, 437 METHOD_NAME__UID, NULL, &ObjDesc); 438 if (ACPI_FAILURE (Status)) 439 { 440 if (Status == AE_NOT_FOUND) 441 { 442 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, "_UID on %4.4s was not found\n", 443 DeviceNode->Name.Ascii)); 444 } 445 else 446 { 447 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 448 "_UID on %4.4s failed %s\n", 449 DeviceNode->Name.Ascii, AcpiFormatException (Status))); 450 } 451 452 return (Status); 453 } 454 455 /* Did we get a return object? */ 456 457 if (!ObjDesc) 458 { 459 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No object was returned from _UID\n")); 460 return (AE_TYPE); 461 } 462 463 /* 464 * A _UID can return either a Number (32 bit compressed EISA ID) or 465 * a string 466 */ 467 if ((ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_INTEGER) && 468 (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_STRING)) 469 { 470 Status = AE_TYPE; 471 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 472 "Type returned from _UID was not a number or string: %X \n", 473 ACPI_GET_OBJECT_TYPE (ObjDesc))); 474 } 475 else 476 { 477 if (ACPI_GET_OBJECT_TYPE (ObjDesc) == ACPI_TYPE_INTEGER) 478 { 479 /* Convert the Numeric UID to string */ 480 481 AcpiExUnsignedIntegerToString (ObjDesc->Integer.Value, Uid->Buffer); 482 } 483 else 484 { 485 /* Copy the String UID from the returned object */ 486 487 ACPI_STRNCPY (Uid->Buffer, ObjDesc->String.Pointer, sizeof(Uid->Buffer)); 488 } 489 } 490 491 492 /* On exit, we must delete the return object */ 493 494 AcpiUtRemoveReference (ObjDesc); 495 496 return (Status); 497} 498 499 500/******************************************************************************* 501 * 502 * FUNCTION: AcpiUtExecute_STA 503 * 504 * PARAMETERS: DeviceNode - Node for the device 505 * *Flags - Where the status flags are returned 506 * 507 * RETURN: Status 508 * 509 * DESCRIPTION: Executes _STA for selected device and stores results in 510 * *Flags. 511 * 512 * NOTE: Internal function, no parameter validation 513 * 514 ******************************************************************************/ 515 516ACPI_STATUS 517AcpiUtExecute_STA ( 518 ACPI_NAMESPACE_NODE *DeviceNode, 519 UINT32 *Flags) 520{ 521 ACPI_OPERAND_OBJECT *ObjDesc; 522 ACPI_STATUS Status; 523 524 525 ACPI_FUNCTION_TRACE ("UtExecute_STA"); 526 527 528 /* Execute the method */ 529 530 Status = AcpiNsEvaluateRelative (DeviceNode, 531 METHOD_NAME__STA, NULL, &ObjDesc); 532 if (AE_NOT_FOUND == Status) 533 { 534 ACPI_DEBUG_PRINT ((ACPI_DB_EXEC, 535 "_STA on %4.4s was not found, assuming present.\n", 536 DeviceNode->Name.Ascii)); 537 538 *Flags = 0x0F; 539 Status = AE_OK; 540 } 541 542 else if (ACPI_FAILURE (Status)) 543 { 544 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "_STA on %4.4s failed %s\n", 545 DeviceNode->Name.Ascii, 546 AcpiFormatException (Status))); 547 } 548 549 else /* success */ 550 { 551 /* Did we get a return object? */ 552 553 if (!ObjDesc) 554 { 555 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, "No object was returned from _STA\n")); 556 return_ACPI_STATUS (AE_TYPE); 557 } 558 559 /* Is the return object of the correct type? */ 560 561 if (ACPI_GET_OBJECT_TYPE (ObjDesc) != ACPI_TYPE_INTEGER) 562 { 563 Status = AE_TYPE; 564 ACPI_DEBUG_PRINT ((ACPI_DB_ERROR, 565 "Type returned from _STA was not a number: %X \n", 566 ACPI_GET_OBJECT_TYPE (ObjDesc))); 567 } 568 else 569 { 570 /* Extract the status flags */ 571 572 *Flags = (UINT32) ObjDesc->Integer.Value; 573 } 574 575 /* On exit, we must delete the return object */ 576 577 AcpiUtRemoveReference (ObjDesc); 578 } 579 580 return_ACPI_STATUS (Status); 581} 582