dsutils.c revision 69450
1/******************************************************************************* 2 * 3 * Module Name: dsutils - Dispatcher utilities 4 * $Revision: 48 $ 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 __DSUTILS_C__ 118 119#include "acpi.h" 120#include "acparser.h" 121#include "amlcode.h" 122#include "acdispat.h" 123#include "acinterp.h" 124#include "acnamesp.h" 125#include "acdebug.h" 126 127#define _COMPONENT PARSER 128 MODULE_NAME ("dsutils") 129 130 131/******************************************************************************* 132 * 133 * FUNCTION: AcpiDsIsResultUsed 134 * 135 * PARAMETERS: Op 136 * ResultObj 137 * WalkState 138 * 139 * RETURN: Status 140 * 141 * DESCRIPTION: Check if a result object will be used by the parent 142 * 143 ******************************************************************************/ 144 145BOOLEAN 146AcpiDsIsResultUsed ( 147 ACPI_PARSE_OBJECT *Op, 148 ACPI_WALK_STATE *WalkState) 149{ 150 ACPI_OPCODE_INFO *ParentInfo; 151 152 153 FUNCTION_TRACE_PTR ("DsIsResultUsed", Op); 154 155 156 /* Must have both an Op and a Result Object */ 157 158 if (!Op) 159 { 160 DEBUG_PRINT (ACPI_ERROR, ("DsIsResultUsed: Null Op\n")); 161 return_VALUE (TRUE); 162 } 163 164 165 /* 166 * If there is no parent, the result can't possibly be used! 167 * (An executing method typically has no parent, since each 168 * method is parsed separately) However, a method that is 169 * invoked from another method has a parent. 170 */ 171 if (!Op->Parent) 172 { 173 return_VALUE (FALSE); 174 } 175 176 177 /* 178 * Get info on the parent. The root Op is AML_SCOPE 179 */ 180 181 ParentInfo = AcpiPsGetOpcodeInfo (Op->Parent->Opcode); 182 if (ACPI_GET_OP_TYPE (ParentInfo) != ACPI_OP_TYPE_OPCODE) 183 { 184 DEBUG_PRINT (ACPI_ERROR, 185 ("DsIsResultUsed: Unknown parent opcode. Op=%X\n", 186 Op)); 187 188 return_VALUE (FALSE); 189 } 190 191 192 /* 193 * Decide what to do with the result based on the parent. If 194 * the parent opcode will not use the result, delete the object. 195 * Otherwise leave it as is, it will be deleted when it is used 196 * as an operand later. 197 */ 198 199 switch (ACPI_GET_OP_CLASS (ParentInfo)) 200 { 201 /* 202 * In these cases, the parent will never use the return object 203 */ 204 case OPTYPE_CONTROL: /* IF, ELSE, WHILE only */ 205 206 switch (Op->Parent->Opcode) 207 { 208 case AML_RETURN_OP: 209 210 /* Never delete the return value associated with a return opcode */ 211 212 DEBUG_PRINT (TRACE_DISPATCH, 213 ("DsIsResultUsed: Result used, [RETURN] opcode=%X Op=%X\n", 214 Op->Opcode, Op)); 215 return_VALUE (TRUE); 216 break; 217 218 case AML_IF_OP: 219 case AML_WHILE_OP: 220 221 /* 222 * If we are executing the predicate AND this is the predicate op, 223 * we will use the return value! 224 */ 225 226 if ((WalkState->ControlState->Common.State == CONTROL_PREDICATE_EXECUTING) && 227 (WalkState->ControlState->Control.PredicateOp == Op)) 228 { 229 DEBUG_PRINT (TRACE_DISPATCH, 230 ("DsIsResultUsed: Result used as a predicate, [IF/WHILE] opcode=%X Op=%X\n", 231 Op->Opcode, Op)); 232 return_VALUE (TRUE); 233 } 234 235 break; 236 } 237 238 239 /* Fall through to not used case below */ 240 241 242 case OPTYPE_NAMED_OBJECT: /* Scope, method, etc. */ 243 244 DEBUG_PRINT (TRACE_DISPATCH, 245 ("DsIsResultUsed: Result not used, Parent opcode=%X Op=%X\n", 246 Op->Opcode, Op)); 247 248 return_VALUE (FALSE); 249 break; 250 251 /* 252 * In all other cases. the parent will actually use the return 253 * object, so keep it. 254 */ 255 default: 256 break; 257 } 258 259 return_VALUE (TRUE); 260} 261 262 263/******************************************************************************* 264 * 265 * FUNCTION: AcpiDsDeleteResultIfNotUsed 266 * 267 * PARAMETERS: Op 268 * ResultObj 269 * WalkState 270 * 271 * RETURN: Status 272 * 273 * DESCRIPTION: Used after interpretation of an opcode. If there is an internal 274 * result descriptor, check if the parent opcode will actually use 275 * this result. If not, delete the result now so that it will 276 * not become orphaned. 277 * 278 ******************************************************************************/ 279 280void 281AcpiDsDeleteResultIfNotUsed ( 282 ACPI_PARSE_OBJECT *Op, 283 ACPI_OPERAND_OBJECT *ResultObj, 284 ACPI_WALK_STATE *WalkState) 285{ 286 ACPI_OPERAND_OBJECT *ObjDesc; 287 ACPI_STATUS Status; 288 289 290 FUNCTION_TRACE_PTR ("DsDeleteResultIfNotUsed", ResultObj); 291 292 293 if (!Op) 294 { 295 DEBUG_PRINT (ACPI_ERROR, 296 ("DsDeleteResultIfNotUsed: Null Op=%X\n", 297 Op)); 298 return_VOID; 299 } 300 301 if (!ResultObj) 302 { 303 return_VOID; 304 } 305 306 307 if (!AcpiDsIsResultUsed (Op, WalkState)) 308 { 309 /* 310 * Must pop the result stack (ObjDesc should be equal 311 * to ResultObj) 312 */ 313 314 Status = AcpiDsResultStackPop (&ObjDesc, WalkState); 315 if (ACPI_SUCCESS (Status)) 316 { 317 AcpiCmRemoveReference (ResultObj); 318 } 319 } 320 321 return_VOID; 322} 323 324 325/******************************************************************************* 326 * 327 * FUNCTION: AcpiDsCreateOperand 328 * 329 * PARAMETERS: WalkState 330 * Arg 331 * 332 * RETURN: Status 333 * 334 * DESCRIPTION: Translate a parse tree object that is an argument to an AML 335 * opcode to the equivalent interpreter object. This may include 336 * looking up a name or entering a new name into the internal 337 * namespace. 338 * 339 ******************************************************************************/ 340 341ACPI_STATUS 342AcpiDsCreateOperand ( 343 ACPI_WALK_STATE *WalkState, 344 ACPI_PARSE_OBJECT *Arg) 345{ 346 ACPI_STATUS Status = AE_OK; 347 NATIVE_CHAR *NameString; 348 UINT32 NameLength; 349 OBJECT_TYPE_INTERNAL DataType; 350 ACPI_OPERAND_OBJECT *ObjDesc; 351 ACPI_PARSE_OBJECT *ParentOp; 352 UINT16 Opcode; 353 UINT32 Flags; 354 OPERATING_MODE InterpreterMode; 355 356 357 FUNCTION_TRACE_PTR ("DsCreateOperand", Arg); 358 359 360 /* A valid name must be looked up in the namespace */ 361 362 if ((Arg->Opcode == AML_NAMEPATH_OP) && 363 (Arg->Value.String)) 364 { 365 DEBUG_PRINT (TRACE_DISPATCH, 366 ("DsCreateOperand: Getting a name: Arg=%p\n", Arg)); 367 368 /* Get the entire name string from the AML stream */ 369 370 Status = AcpiAmlGetNameString (ACPI_TYPE_ANY, 371 Arg->Value.Buffer, 372 &NameString, 373 &NameLength); 374 375 if (ACPI_FAILURE (Status)) 376 { 377 return_ACPI_STATUS (Status); 378 } 379 380 /* 381 * All prefixes have been handled, and the name is 382 * in NameString 383 */ 384 385 /* 386 * Differentiate between a namespace "create" operation 387 * versus a "lookup" operation (IMODE_LOAD_PASS2 vs. 388 * IMODE_EXECUTE) in order to support the creation of 389 * namespace objects during the execution of control methods. 390 */ 391 392 ParentOp = Arg->Parent; 393 if ((AcpiPsIsNodeOp (ParentOp->Opcode)) && 394 (ParentOp->Opcode != AML_METHODCALL_OP) && 395 (ParentOp->Opcode != AML_REGION_OP) && 396 (ParentOp->Opcode != AML_NAMEPATH_OP)) 397 { 398 /* Enter name into namespace if not found */ 399 400 InterpreterMode = IMODE_LOAD_PASS2; 401 } 402 403 else 404 { 405 /* Return a failure if name not found */ 406 407 InterpreterMode = IMODE_EXECUTE; 408 } 409 410 Status = AcpiNsLookup (WalkState->ScopeInfo, NameString, 411 ACPI_TYPE_ANY, InterpreterMode, 412 NS_SEARCH_PARENT | NS_DONT_OPEN_SCOPE, 413 WalkState, 414 (ACPI_NAMESPACE_NODE **) &ObjDesc); 415 416 /* Free the namestring created above */ 417 418 AcpiCmFree (NameString); 419 420 /* 421 * The only case where we pass through (ignore) a NOT_FOUND 422 * error is for the CondRefOf opcode. 423 */ 424 425 if (Status == AE_NOT_FOUND) 426 { 427 if (ParentOp->Opcode == AML_COND_REF_OF_OP) 428 { 429 /* 430 * For the Conditional Reference op, it's OK if 431 * the name is not found; We just need a way to 432 * indicate this to the interpreter, set the 433 * object to the root 434 */ 435 ObjDesc = (ACPI_OPERAND_OBJECT *) AcpiGbl_RootNode; 436 Status = AE_OK; 437 } 438 439 else 440 { 441 /* 442 * We just plain didn't find it -- which is a 443 * very serious error at this point 444 */ 445 Status = AE_AML_NAME_NOT_FOUND; 446 } 447 } 448 449 /* Check status from the lookup */ 450 451 if (ACPI_FAILURE (Status)) 452 { 453 return_ACPI_STATUS (Status); 454 } 455 456 /* Put the resulting object onto the current object stack */ 457 458 Status = AcpiDsObjStackPush (ObjDesc, WalkState); 459 if (ACPI_FAILURE (Status)) 460 { 461 return_ACPI_STATUS (Status); 462 } 463 DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (ObjDesc, WalkState)); 464 } 465 466 467 else 468 { 469 /* Check for null name case */ 470 471 if (Arg->Opcode == AML_NAMEPATH_OP) 472 { 473 /* 474 * If the name is null, this means that this is an 475 * optional result parameter that was not specified 476 * in the original ASL. Create an Reference for a 477 * placeholder 478 */ 479 Opcode = AML_ZERO_OP; /* Has no arguments! */ 480 481 DEBUG_PRINT (TRACE_DISPATCH, 482 ("DsCreateOperand: Null namepath: Arg=%p\n", Arg)); 483 484 /* 485 * TBD: [Investigate] anything else needed for the 486 * zero op lvalue? 487 */ 488 } 489 490 else 491 { 492 Opcode = Arg->Opcode; 493 } 494 495 496 /* Get the data type of the argument */ 497 498 DataType = AcpiDsMapOpcodeToDataType (Opcode, &Flags); 499 if (DataType == INTERNAL_TYPE_INVALID) 500 { 501 return_ACPI_STATUS (AE_NOT_IMPLEMENTED); 502 } 503 504 if (Flags & OP_HAS_RETURN_VALUE) 505 { 506 DEBUG_PRINT (TRACE_DISPATCH, 507 ("DsCreateOperand: Argument previously created, already stacked \n")); 508 509 DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (WalkState->Operands [WalkState->NumOperands - 1], WalkState)); 510 511 /* 512 * Use value that was already previously returned 513 * by the evaluation of this argument 514 */ 515 516 Status = AcpiDsResultStackPop (&ObjDesc, WalkState); 517 if (ACPI_FAILURE (Status)) 518 { 519 /* 520 * Only error is underflow, and this indicates 521 * a missing or null operand! 522 */ 523 DEBUG_PRINT (ACPI_ERROR, 524 ("DsCreateOperand: Missing or null operand, %s\n", AcpiCmFormatException (Status))); 525 return_ACPI_STATUS (Status); 526 } 527 528 } 529 530 else 531 { 532 /* Create an ACPI_INTERNAL_OBJECT for the argument */ 533 534 ObjDesc = AcpiCmCreateInternalObject (DataType); 535 if (!ObjDesc) 536 { 537 return_ACPI_STATUS (AE_NO_MEMORY); 538 } 539 540 /* Initialize the new object */ 541 542 Status = AcpiDsInitObjectFromOp (WalkState, Arg, 543 Opcode, &ObjDesc); 544 if (ACPI_FAILURE (Status)) 545 { 546 AcpiCmDeleteObjectDesc (ObjDesc); 547 return_ACPI_STATUS (Status); 548 } 549 } 550 551 /* Put the operand object on the object stack */ 552 553 Status = AcpiDsObjStackPush (ObjDesc, WalkState); 554 if (ACPI_FAILURE (Status)) 555 { 556 return_ACPI_STATUS (Status); 557 } 558 559 DEBUGGER_EXEC (AcpiDbDisplayArgumentObject (ObjDesc, WalkState)); 560 } 561 562 return_ACPI_STATUS (AE_OK); 563} 564 565 566/******************************************************************************* 567 * 568 * FUNCTION: AcpiDsCreateOperands 569 * 570 * PARAMETERS: FirstArg - First argument of a parser argument tree 571 * 572 * RETURN: Status 573 * 574 * DESCRIPTION: Convert an operator's arguments from a parse tree format to 575 * namespace objects and place those argument object on the object 576 * stack in preparation for evaluation by the interpreter. 577 * 578 ******************************************************************************/ 579 580ACPI_STATUS 581AcpiDsCreateOperands ( 582 ACPI_WALK_STATE *WalkState, 583 ACPI_PARSE_OBJECT *FirstArg) 584{ 585 ACPI_STATUS Status = AE_OK; 586 ACPI_PARSE_OBJECT *Arg; 587 UINT32 ArgsPushed = 0; 588 589 590 FUNCTION_TRACE_PTR ("DsCreateOperands", FirstArg); 591 592 Arg = FirstArg; 593 594 595 /* For all arguments in the list... */ 596 597 while (Arg) 598 { 599 600 Status = AcpiDsCreateOperand (WalkState, Arg); 601 if (ACPI_FAILURE (Status)) 602 { 603 goto Cleanup; 604 } 605 606 DEBUG_PRINT (TRACE_DISPATCH, 607 ("DsCreateOperands: Arg #%d (%p) done, Arg1=%p\n", 608 ArgsPushed, Arg, FirstArg)); 609 610 /* Move on to next argument, if any */ 611 612 Arg = Arg->Next; 613 ArgsPushed++; 614 } 615 616 return_ACPI_STATUS (Status); 617 618 619Cleanup: 620 /* 621 * We must undo everything done above; meaning that we must 622 * pop everything off of the operand stack and delete those 623 * objects 624 */ 625 626 AcpiDsObjStackPopAndDelete (ArgsPushed, WalkState); 627 628 DEBUG_PRINT (ACPI_ERROR, 629 ("DsCreateOperands: Error while creating Arg %d - %s\n", 630 (ArgsPushed+1), AcpiCmFormatException (Status))); 631 return_ACPI_STATUS (Status); 632} 633 634 635/******************************************************************************* 636 * 637 * FUNCTION: AcpiDsResolveOperands 638 * 639 * PARAMETERS: WalkState - Current walk state with operands on stack 640 * 641 * RETURN: Status 642 * 643 * DESCRIPTION: Resolve all operands to their values. Used to prepare 644 * arguments to a control method invocation (a call from one 645 * method to another.) 646 * 647 ******************************************************************************/ 648 649ACPI_STATUS 650AcpiDsResolveOperands ( 651 ACPI_WALK_STATE *WalkState) 652{ 653 UINT32 i; 654 ACPI_STATUS Status = AE_OK; 655 656 657 FUNCTION_TRACE_PTR ("DsResolveOperands", WalkState); 658 659 660 /* 661 * Attempt to resolve each of the valid operands 662 * Method arguments are passed by value, not by reference 663 */ 664 665 /* 666 * TBD: [Investigate] Note from previous parser: 667 * RefOf problem with AcpiAmlResolveToValue() conversion. 668 */ 669 670 for (i = 0; i < WalkState->NumOperands; i++) 671 { 672 Status = AcpiAmlResolveToValue (&WalkState->Operands[i], WalkState); 673 if (ACPI_FAILURE (Status)) 674 { 675 break; 676 } 677 } 678 679 return_ACPI_STATUS (Status); 680} 681 682 683/******************************************************************************* 684 * 685 * FUNCTION: AcpiDsMapOpcodeToDataType 686 * 687 * PARAMETERS: Opcode - AML opcode to map 688 * OutFlags - Additional info about the opcode 689 * 690 * RETURN: The ACPI type associated with the opcode 691 * 692 * DESCRIPTION: Convert a raw AML opcode to the associated ACPI data type, 693 * if any. If the opcode returns a value as part of the 694 * intepreter execution, a flag is returned in OutFlags. 695 * 696 ******************************************************************************/ 697 698OBJECT_TYPE_INTERNAL 699AcpiDsMapOpcodeToDataType ( 700 UINT16 Opcode, 701 UINT32 *OutFlags) 702{ 703 OBJECT_TYPE_INTERNAL DataType = INTERNAL_TYPE_INVALID; 704 ACPI_OPCODE_INFO *OpInfo; 705 UINT32 Flags = 0; 706 707 708 OpInfo = AcpiPsGetOpcodeInfo (Opcode); 709 if (ACPI_GET_OP_TYPE (OpInfo) != ACPI_OP_TYPE_OPCODE) 710 { 711 /* Unknown opcode */ 712 713 DEBUG_PRINT (ACPI_ERROR, 714 ("MapOpcode: Unknown AML opcode: %x\n", 715 Opcode)); 716 717 return (DataType); 718 } 719 720 switch (ACPI_GET_OP_CLASS (OpInfo)) 721 { 722 723 case OPTYPE_LITERAL: 724 725 switch (Opcode) 726 { 727 case AML_BYTE_OP: 728 case AML_WORD_OP: 729 case AML_DWORD_OP: 730 731 DataType = ACPI_TYPE_NUMBER; 732 break; 733 734 735 case AML_STRING_OP: 736 737 DataType = ACPI_TYPE_STRING; 738 break; 739 740 case AML_NAMEPATH_OP: 741 DataType = INTERNAL_TYPE_REFERENCE; 742 break; 743 744 default: 745 DEBUG_PRINT (ACPI_ERROR, 746 ("MapOpcode: Unknown (type LITERAL) AML opcode: %x\n", 747 Opcode)); 748 break; 749 } 750 break; 751 752 753 case OPTYPE_DATA_TERM: 754 755 switch (Opcode) 756 { 757 case AML_BUFFER_OP: 758 759 DataType = ACPI_TYPE_BUFFER; 760 break; 761 762 case AML_PACKAGE_OP: 763 764 DataType = ACPI_TYPE_PACKAGE; 765 break; 766 767 default: 768 DEBUG_PRINT (ACPI_ERROR, 769 ("MapOpcode: Unknown (type DATA_TERM) AML opcode: %x\n", 770 Opcode)); 771 break; 772 } 773 break; 774 775 776 case OPTYPE_CONSTANT: 777 case OPTYPE_METHOD_ARGUMENT: 778 case OPTYPE_LOCAL_VARIABLE: 779 780 DataType = INTERNAL_TYPE_REFERENCE; 781 break; 782 783 784 case OPTYPE_MONADIC2: 785 case OPTYPE_MONADIC2R: 786 case OPTYPE_DYADIC2: 787 case OPTYPE_DYADIC2R: 788 case OPTYPE_DYADIC2S: 789 case OPTYPE_INDEX: 790 case OPTYPE_MATCH: 791 case OPTYPE_RETURN: 792 793 Flags = OP_HAS_RETURN_VALUE; 794 DataType = ACPI_TYPE_ANY; 795 break; 796 797 case OPTYPE_METHOD_CALL: 798 799 Flags = OP_HAS_RETURN_VALUE; 800 DataType = ACPI_TYPE_METHOD; 801 break; 802 803 804 case OPTYPE_NAMED_OBJECT: 805 806 DataType = AcpiDsMapNamedOpcodeToDataType (Opcode); 807 break; 808 809 810 case OPTYPE_DYADIC1: 811 case OPTYPE_CONTROL: 812 813 /* No mapping needed at this time */ 814 815 break; 816 817 818 default: 819 820 DEBUG_PRINT (ACPI_ERROR, 821 ("MapOpcode: Unimplemented data type opcode: %x\n", 822 Opcode)); 823 break; 824 } 825 826 /* Return flags to caller if requested */ 827 828 if (OutFlags) 829 { 830 *OutFlags = Flags; 831 } 832 833 return (DataType); 834} 835 836 837/******************************************************************************* 838 * 839 * FUNCTION: AcpiDsMapNamedOpcodeToDataType 840 * 841 * PARAMETERS: Opcode - The Named AML opcode to map 842 * 843 * RETURN: The ACPI type associated with the named opcode 844 * 845 * DESCRIPTION: Convert a raw Named AML opcode to the associated data type. 846 * Named opcodes are a subsystem of the AML opcodes. 847 * 848 ******************************************************************************/ 849 850OBJECT_TYPE_INTERNAL 851AcpiDsMapNamedOpcodeToDataType ( 852 UINT16 Opcode) 853{ 854 OBJECT_TYPE_INTERNAL DataType; 855 856 857 /* Decode Opcode */ 858 859 switch (Opcode) 860 { 861 case AML_SCOPE_OP: 862 DataType = INTERNAL_TYPE_SCOPE; 863 break; 864 865 case AML_DEVICE_OP: 866 DataType = ACPI_TYPE_DEVICE; 867 break; 868 869 case AML_THERMAL_ZONE_OP: 870 DataType = ACPI_TYPE_THERMAL; 871 break; 872 873 case AML_METHOD_OP: 874 DataType = ACPI_TYPE_METHOD; 875 break; 876 877 case AML_POWER_RES_OP: 878 DataType = ACPI_TYPE_POWER; 879 break; 880 881 case AML_PROCESSOR_OP: 882 DataType = ACPI_TYPE_PROCESSOR; 883 break; 884 885 case AML_DEF_FIELD_OP: /* DefFieldOp */ 886 DataType = INTERNAL_TYPE_DEF_FIELD_DEFN; 887 break; 888 889 case AML_INDEX_FIELD_OP: /* IndexFieldOp */ 890 DataType = INTERNAL_TYPE_INDEX_FIELD_DEFN; 891 break; 892 893 case AML_BANK_FIELD_OP: /* BankFieldOp */ 894 DataType = INTERNAL_TYPE_BANK_FIELD_DEFN; 895 break; 896 897 case AML_NAMEDFIELD_OP: /* NO CASE IN ORIGINAL */ 898 DataType = ACPI_TYPE_ANY; 899 break; 900 901 case AML_NAME_OP: /* NameOp - special code in original */ 902 case AML_NAMEPATH_OP: 903 DataType = ACPI_TYPE_ANY; 904 break; 905 906 case AML_ALIAS_OP: 907 DataType = INTERNAL_TYPE_ALIAS; 908 break; 909 910 case AML_MUTEX_OP: 911 DataType = ACPI_TYPE_MUTEX; 912 break; 913 914 case AML_EVENT_OP: 915 DataType = ACPI_TYPE_EVENT; 916 break; 917 918 case AML_REGION_OP: 919 DataType = ACPI_TYPE_REGION; 920 break; 921 922 923 default: 924 DataType = ACPI_TYPE_ANY; 925 break; 926 927 } 928 929 return (DataType); 930} 931 932 933