Print this page
update to acpica-unix2-20140114
acpica-unix2-20130823
PANKOVs restructure
   1 /******************************************************************************
   2  *
   3  * Module Name: dswload2 - Dispatcher second pass namespace load callbacks
   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.


 219         case ACPI_TYPE_POWER:
 220         case ACPI_TYPE_PROCESSOR:
 221         case ACPI_TYPE_THERMAL:
 222 
 223             /* These are acceptable types */
 224             break;
 225 
 226         case ACPI_TYPE_INTEGER:
 227         case ACPI_TYPE_STRING:
 228         case ACPI_TYPE_BUFFER:
 229 
 230             /*
 231              * These types we will allow, but we will change the type.
 232              * This enables some existing code of the form:
 233              *
 234              *  Name (DEB, 0)
 235              *  Scope (DEB) { ... }
 236              */
 237             ACPI_WARNING ((AE_INFO,
 238                 "Type override - [%4.4s] had invalid type (%s) "
 239                 "for Scope operator, changed to type ANY\n",
 240                 AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type)));
 241 
 242             Node->Type = ACPI_TYPE_ANY;
 243             WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY;
 244             break;
 245 














 246         default:
 247 
 248             /* All other types are an error */
 249 
 250             ACPI_ERROR ((AE_INFO,
 251                 "Invalid type (%s) for target of "
 252                 "Scope operator [%4.4s] (Cannot override)",
 253                 AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node)));
 254 
 255             return (AE_AML_OPERAND_TYPE);
 256         }
 257         break;
 258 
 259     default:
 260 
 261         /* All other opcodes */
 262 
 263         if (Op && Op->Common.Node)
 264         {
 265             /* This op/node was previously entered into the namespace */
 266 
 267             Node = Op->Common.Node;
 268 
 269             if (AcpiNsOpensScope (ObjectType))
 270             {
 271                 Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);
 272                 if (ACPI_FAILURE (Status))
 273                 {
 274                     return_ACPI_STATUS (Status);
 275                 }


 465     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
 466         "Create-Load [%s] State=%p Op=%p NamedObj=%p\n",
 467         AcpiPsGetOpcodeName (Op->Common.AmlOpcode), WalkState, Op, Node));
 468 
 469     /* Decode the opcode */
 470 
 471     Arg = Op->Common.Value.Arg;
 472 
 473     switch (WalkState->OpInfo->Type)
 474     {
 475 #ifndef ACPI_NO_METHOD_EXECUTION
 476 
 477     case AML_TYPE_CREATE_FIELD:
 478         /*
 479          * Create the field object, but the field buffer and index must
 480          * be evaluated later during the execution phase
 481          */
 482         Status = AcpiDsCreateBufferField (Op, WalkState);
 483         break;
 484 
 485 
 486      case AML_TYPE_NAMED_FIELD:
 487         /*
 488          * If we are executing a method, initialize the field
 489          */
 490         if (WalkState->MethodNode)
 491         {
 492             Status = AcpiDsInitFieldObjects (Op, WalkState);
 493         }
 494 
 495         switch (Op->Common.AmlOpcode)
 496         {
 497         case AML_INDEX_FIELD_OP:
 498 
 499             Status = AcpiDsCreateIndexField (Op, (ACPI_HANDLE) Arg->Common.Node,
 500                         WalkState);
 501             break;
 502 
 503         case AML_BANK_FIELD_OP:
 504 
 505             Status = AcpiDsCreateBankField (Op, Arg->Common.Node, WalkState);
 506             break;
 507 
 508         case AML_FIELD_OP:
 509 
 510             Status = AcpiDsCreateField (Op, Arg->Common.Node, WalkState);
 511             break;
 512 
 513         default:

 514             /* All NAMED_FIELD opcodes must be handled above */
 515             break;
 516         }
 517         break;
 518 
 519 
 520      case AML_TYPE_NAMED_SIMPLE:
 521 
 522         Status = AcpiDsCreateOperands (WalkState, Arg);
 523         if (ACPI_FAILURE (Status))
 524         {
 525             goto Cleanup;
 526         }
 527 
 528         switch (Op->Common.AmlOpcode)
 529         {
 530         case AML_PROCESSOR_OP:
 531 
 532             Status = AcpiExCreateProcessor (WalkState);
 533             break;
 534 
 535         case AML_POWER_RES_OP:
 536 
 537             Status = AcpiExCreatePowerResource (WalkState);
 538             break;
 539 
 540         case AML_MUTEX_OP:
 541 
 542             Status = AcpiExCreateMutex (WalkState);
 543             break;
 544 
 545         case AML_EVENT_OP:
 546 
 547             Status = AcpiExCreateEvent (WalkState);
 548             break;
 549 
 550 
 551         case AML_ALIAS_OP:
 552 
 553             Status = AcpiExCreateAlias (WalkState);
 554             break;
 555 
 556         default:

 557             /* Unknown opcode */
 558 
 559             Status = AE_OK;
 560             goto Cleanup;
 561         }
 562 
 563         /* Delete operands */
 564 
 565         for (i = 1; i < WalkState->NumOperands; i++)
 566         {
 567             AcpiUtRemoveReference (WalkState->Operands[i]);
 568             WalkState->Operands[i] = NULL;
 569         }
 570 
 571         break;
 572 #endif /* ACPI_NO_METHOD_EXECUTION */
 573 
 574     case AML_TYPE_NAMED_COMPLEX:
 575 
 576         switch (Op->Common.AmlOpcode)


 594              * argument is the SpaceId. (We must save the address of the
 595              * AML of the address and length operands)
 596              *
 597              * If we have a valid region, initialize it. The namespace is
 598              * unlocked at this point.
 599              *
 600              * Need to unlock interpreter if it is locked (if we are running
 601              * a control method), in order to allow _REG methods to be run
 602              * during AcpiEvInitializeRegion.
 603              */
 604             if (WalkState->MethodNode)
 605             {
 606                 /*
 607                  * Executing a method: initialize the region and unlock
 608                  * the interpreter
 609                  */
 610                 Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length,
 611                             RegionSpace, WalkState);
 612                 if (ACPI_FAILURE (Status))
 613                 {
 614                     return (Status);
 615                 }
 616 
 617                 AcpiExExitInterpreter ();
 618             }
 619 
 620             Status = AcpiEvInitializeRegion (AcpiNsGetAttachedObject (Node),
 621                         FALSE);
 622             if (WalkState->MethodNode)
 623             {
 624                 AcpiExEnterInterpreter ();
 625             }
 626 
 627             if (ACPI_FAILURE (Status))
 628             {
 629                 /*
 630                  *  If AE_NOT_EXIST is returned, it is not fatal
 631                  *  because many regions get created before a handler
 632                  *  is installed for said region.
 633                  */
 634                 if (AE_NOT_EXIST == Status)
 635                 {
 636                     Status = AE_OK;
 637                 }
 638             }
 639             break;
 640 
 641 
 642         case AML_NAME_OP:
 643 
 644             Status = AcpiDsCreateNode (WalkState, Node, Op);
 645             break;
 646 
 647 
 648         case AML_METHOD_OP:
 649             /*
 650              * MethodOp PkgLength NameString MethodFlags TermList
 651              *
 652              * Note: We must create the method node/object pair as soon as we
 653              * see the method declaration. This allows later pass1 parsing
 654              * of invocations of the method (need to know the number of
 655              * arguments.)
 656              */
 657             ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
 658                 "LOADING-Method: State=%p Op=%p NamedObj=%p\n",
 659                 WalkState, Op, Op->Named.Node));
 660 
 661             if (!AcpiNsGetAttachedObject (Op->Named.Node))
 662             {
 663                 WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node);
 664                 WalkState->NumOperands = 1;
 665 
 666                 Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg);
 667                 if (ACPI_SUCCESS (Status))
 668                 {
 669                     Status = AcpiExCreateMethod (Op->Named.Data,
 670                                         Op->Named.Length, WalkState);
 671                 }
 672                 WalkState->Operands[0] = NULL;
 673                 WalkState->NumOperands = 0;
 674 
 675                 if (ACPI_FAILURE (Status))
 676                 {
 677                     return_ACPI_STATUS (Status);
 678                 }
 679             }
 680             break;
 681 
 682 #endif /* ACPI_NO_METHOD_EXECUTION */
 683 
 684         default:

 685             /* All NAMED_COMPLEX opcodes must be handled above */
 686             break;
 687         }
 688         break;
 689 
 690 
 691     case AML_CLASS_INTERNAL:
 692 
 693         /* case AML_INT_NAMEPATH_OP: */
 694         break;
 695 
 696 
 697     case AML_CLASS_METHOD_CALL:
 698 
 699         ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
 700             "RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n",
 701             WalkState, Op, Node));
 702 
 703         /*
 704          * Lookup the method name and save the Node
 705          */
 706         Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
 707                         ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2,
 708                         ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
 709                         WalkState, &(NewNode));
 710         if (ACPI_SUCCESS (Status))
 711         {
 712             /*
 713              * Make sure that what we found is indeed a method
 714              * We didn't search for a method on purpose, to see if the name
 715              * would resolve
 716              */
 717             if (NewNode->Type != ACPI_TYPE_METHOD)
 718             {
 719                 Status = AE_AML_OPERAND_TYPE;
 720             }
 721 
 722             /* We could put the returned object (Node) on the object stack for
 723              * later, but for now, we will put it in the "op" object that the
 724              * parser uses, so we can get it again at the end of this scope
 725              */
 726             Op->Common.Node = NewNode;
 727         }
 728         else
 729         {
 730             ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status);
 731         }
 732         break;
 733 
 734 
 735     default:

 736         break;
 737     }
 738 
 739 Cleanup:
 740 
 741     /* Remove the Node pushed at the very beginning */
 742 
 743     WalkState->Operands[0] = NULL;
 744     WalkState->NumOperands = 0;
 745     return_ACPI_STATUS (Status);
 746 }
 747 
   1 /******************************************************************************
   2  *
   3  * Module Name: dswload2 - Dispatcher second pass namespace load callbacks
   4  *
   5  *****************************************************************************/
   6 
   7 /*
   8  * Copyright (C) 2000 - 2014, 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.


 219         case ACPI_TYPE_POWER:
 220         case ACPI_TYPE_PROCESSOR:
 221         case ACPI_TYPE_THERMAL:
 222 
 223             /* These are acceptable types */
 224             break;
 225 
 226         case ACPI_TYPE_INTEGER:
 227         case ACPI_TYPE_STRING:
 228         case ACPI_TYPE_BUFFER:
 229 
 230             /*
 231              * These types we will allow, but we will change the type.
 232              * This enables some existing code of the form:
 233              *
 234              *  Name (DEB, 0)
 235              *  Scope (DEB) { ... }
 236              */
 237             ACPI_WARNING ((AE_INFO,
 238                 "Type override - [%4.4s] had invalid type (%s) "
 239                 "for Scope operator, changed to type ANY",
 240                 AcpiUtGetNodeName (Node), AcpiUtGetTypeName (Node->Type)));
 241 
 242             Node->Type = ACPI_TYPE_ANY;
 243             WalkState->ScopeInfo->Common.Value = ACPI_TYPE_ANY;
 244             break;
 245 
 246         case ACPI_TYPE_METHOD:
 247 
 248             /*
 249              * Allow scope change to root during execution of module-level
 250              * code. Root is typed METHOD during this time.
 251              */
 252             if ((Node == AcpiGbl_RootNode) &&
 253                 (WalkState->ParseFlags & ACPI_PARSE_MODULE_LEVEL))
 254             {
 255                 break;
 256             }
 257 
 258             /*lint -fallthrough */
 259 
 260         default:
 261 
 262             /* All other types are an error */
 263 
 264             ACPI_ERROR ((AE_INFO,
 265                 "Invalid type (%s) for target of "
 266                 "Scope operator [%4.4s] (Cannot override)",
 267                 AcpiUtGetTypeName (Node->Type), AcpiUtGetNodeName (Node)));
 268 
 269             return_ACPI_STATUS (AE_AML_OPERAND_TYPE);
 270         }
 271         break;
 272 
 273     default:
 274 
 275         /* All other opcodes */
 276 
 277         if (Op && Op->Common.Node)
 278         {
 279             /* This op/node was previously entered into the namespace */
 280 
 281             Node = Op->Common.Node;
 282 
 283             if (AcpiNsOpensScope (ObjectType))
 284             {
 285                 Status = AcpiDsScopeStackPush (Node, ObjectType, WalkState);
 286                 if (ACPI_FAILURE (Status))
 287                 {
 288                     return_ACPI_STATUS (Status);
 289                 }


 479     ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
 480         "Create-Load [%s] State=%p Op=%p NamedObj=%p\n",
 481         AcpiPsGetOpcodeName (Op->Common.AmlOpcode), WalkState, Op, Node));
 482 
 483     /* Decode the opcode */
 484 
 485     Arg = Op->Common.Value.Arg;
 486 
 487     switch (WalkState->OpInfo->Type)
 488     {
 489 #ifndef ACPI_NO_METHOD_EXECUTION
 490 
 491     case AML_TYPE_CREATE_FIELD:
 492         /*
 493          * Create the field object, but the field buffer and index must
 494          * be evaluated later during the execution phase
 495          */
 496         Status = AcpiDsCreateBufferField (Op, WalkState);
 497         break;
 498 

 499      case AML_TYPE_NAMED_FIELD:
 500         /*
 501          * If we are executing a method, initialize the field
 502          */
 503         if (WalkState->MethodNode)
 504         {
 505             Status = AcpiDsInitFieldObjects (Op, WalkState);
 506         }
 507 
 508         switch (Op->Common.AmlOpcode)
 509         {
 510         case AML_INDEX_FIELD_OP:
 511 
 512             Status = AcpiDsCreateIndexField (Op, (ACPI_HANDLE) Arg->Common.Node,
 513                         WalkState);
 514             break;
 515 
 516         case AML_BANK_FIELD_OP:
 517 
 518             Status = AcpiDsCreateBankField (Op, Arg->Common.Node, WalkState);
 519             break;
 520 
 521         case AML_FIELD_OP:
 522 
 523             Status = AcpiDsCreateField (Op, Arg->Common.Node, WalkState);
 524             break;
 525 
 526         default:
 527 
 528             /* All NAMED_FIELD opcodes must be handled above */
 529             break;
 530         }
 531         break;
 532 

 533      case AML_TYPE_NAMED_SIMPLE:
 534 
 535         Status = AcpiDsCreateOperands (WalkState, Arg);
 536         if (ACPI_FAILURE (Status))
 537         {
 538             goto Cleanup;
 539         }
 540 
 541         switch (Op->Common.AmlOpcode)
 542         {
 543         case AML_PROCESSOR_OP:
 544 
 545             Status = AcpiExCreateProcessor (WalkState);
 546             break;
 547 
 548         case AML_POWER_RES_OP:
 549 
 550             Status = AcpiExCreatePowerResource (WalkState);
 551             break;
 552 
 553         case AML_MUTEX_OP:
 554 
 555             Status = AcpiExCreateMutex (WalkState);
 556             break;
 557 
 558         case AML_EVENT_OP:
 559 
 560             Status = AcpiExCreateEvent (WalkState);
 561             break;
 562 

 563         case AML_ALIAS_OP:
 564 
 565             Status = AcpiExCreateAlias (WalkState);
 566             break;
 567 
 568         default:
 569 
 570             /* Unknown opcode */
 571 
 572             Status = AE_OK;
 573             goto Cleanup;
 574         }
 575 
 576         /* Delete operands */
 577 
 578         for (i = 1; i < WalkState->NumOperands; i++)
 579         {
 580             AcpiUtRemoveReference (WalkState->Operands[i]);
 581             WalkState->Operands[i] = NULL;
 582         }
 583 
 584         break;
 585 #endif /* ACPI_NO_METHOD_EXECUTION */
 586 
 587     case AML_TYPE_NAMED_COMPLEX:
 588 
 589         switch (Op->Common.AmlOpcode)


 607              * argument is the SpaceId. (We must save the address of the
 608              * AML of the address and length operands)
 609              *
 610              * If we have a valid region, initialize it. The namespace is
 611              * unlocked at this point.
 612              *
 613              * Need to unlock interpreter if it is locked (if we are running
 614              * a control method), in order to allow _REG methods to be run
 615              * during AcpiEvInitializeRegion.
 616              */
 617             if (WalkState->MethodNode)
 618             {
 619                 /*
 620                  * Executing a method: initialize the region and unlock
 621                  * the interpreter
 622                  */
 623                 Status = AcpiExCreateRegion (Op->Named.Data, Op->Named.Length,
 624                             RegionSpace, WalkState);
 625                 if (ACPI_FAILURE (Status))
 626                 {
 627                     return_ACPI_STATUS (Status);
 628                 }
 629 
 630                 AcpiExExitInterpreter ();
 631             }
 632 
 633             Status = AcpiEvInitializeRegion (AcpiNsGetAttachedObject (Node),
 634                         FALSE);
 635             if (WalkState->MethodNode)
 636             {
 637                 AcpiExEnterInterpreter ();
 638             }
 639 
 640             if (ACPI_FAILURE (Status))
 641             {
 642                 /*
 643                  *  If AE_NOT_EXIST is returned, it is not fatal
 644                  *  because many regions get created before a handler
 645                  *  is installed for said region.
 646                  */
 647                 if (AE_NOT_EXIST == Status)
 648                 {
 649                     Status = AE_OK;
 650                 }
 651             }
 652             break;
 653 

 654         case AML_NAME_OP:
 655 
 656             Status = AcpiDsCreateNode (WalkState, Node, Op);
 657             break;
 658 

 659         case AML_METHOD_OP:
 660             /*
 661              * MethodOp PkgLength NameString MethodFlags TermList
 662              *
 663              * Note: We must create the method node/object pair as soon as we
 664              * see the method declaration. This allows later pass1 parsing
 665              * of invocations of the method (need to know the number of
 666              * arguments.)
 667              */
 668             ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
 669                 "LOADING-Method: State=%p Op=%p NamedObj=%p\n",
 670                 WalkState, Op, Op->Named.Node));
 671 
 672             if (!AcpiNsGetAttachedObject (Op->Named.Node))
 673             {
 674                 WalkState->Operands[0] = ACPI_CAST_PTR (void, Op->Named.Node);
 675                 WalkState->NumOperands = 1;
 676 
 677                 Status = AcpiDsCreateOperands (WalkState, Op->Common.Value.Arg);
 678                 if (ACPI_SUCCESS (Status))
 679                 {
 680                     Status = AcpiExCreateMethod (Op->Named.Data,
 681                                         Op->Named.Length, WalkState);
 682                 }
 683                 WalkState->Operands[0] = NULL;
 684                 WalkState->NumOperands = 0;
 685 
 686                 if (ACPI_FAILURE (Status))
 687                 {
 688                     return_ACPI_STATUS (Status);
 689                 }
 690             }
 691             break;
 692 
 693 #endif /* ACPI_NO_METHOD_EXECUTION */
 694 
 695         default:
 696 
 697             /* All NAMED_COMPLEX opcodes must be handled above */
 698             break;
 699         }
 700         break;
 701 

 702     case AML_CLASS_INTERNAL:
 703 
 704         /* case AML_INT_NAMEPATH_OP: */
 705         break;
 706 

 707     case AML_CLASS_METHOD_CALL:
 708 
 709         ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
 710             "RESOLVING-MethodCall: State=%p Op=%p NamedObj=%p\n",
 711             WalkState, Op, Node));
 712 
 713         /*
 714          * Lookup the method name and save the Node
 715          */
 716         Status = AcpiNsLookup (WalkState->ScopeInfo, Arg->Common.Value.String,
 717                         ACPI_TYPE_ANY, ACPI_IMODE_LOAD_PASS2,
 718                         ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
 719                         WalkState, &(NewNode));
 720         if (ACPI_SUCCESS (Status))
 721         {
 722             /*
 723              * Make sure that what we found is indeed a method
 724              * We didn't search for a method on purpose, to see if the name
 725              * would resolve
 726              */
 727             if (NewNode->Type != ACPI_TYPE_METHOD)
 728             {
 729                 Status = AE_AML_OPERAND_TYPE;
 730             }
 731 
 732             /* We could put the returned object (Node) on the object stack for
 733              * later, but for now, we will put it in the "op" object that the
 734              * parser uses, so we can get it again at the end of this scope
 735              */
 736             Op->Common.Node = NewNode;
 737         }
 738         else
 739         {
 740             ACPI_ERROR_NAMESPACE (Arg->Common.Value.String, Status);
 741         }
 742         break;
 743 
 744 
 745     default:
 746 
 747         break;
 748     }
 749 
 750 Cleanup:
 751 
 752     /* Remove the Node pushed at the very beginning */
 753 
 754     WalkState->Operands[0] = NULL;
 755     WalkState->NumOperands = 0;
 756     return_ACPI_STATUS (Status);
 757 }