Print this page
acpica-unix2-20130823
PANKOVs restructure

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/intel/io/acpica/parser/psparse.c
          +++ new/usr/src/common/acpica/components/parser/psparse.c
   1    1  /******************************************************************************
   2    2   *
   3    3   * Module Name: psparse - Parser top level AML parse routines
   4    4   *
   5    5   *****************************************************************************/
   6    6  
   7    7  /*
   8      - * Copyright (C) 2000 - 2011, Intel Corp.
        8 + * Copyright (C) 2000 - 2013, Intel Corp.
   9    9   * All rights reserved.
  10   10   *
  11   11   * Redistribution and use in source and binary forms, with or without
  12   12   * modification, are permitted provided that the following conditions
  13   13   * are met:
  14   14   * 1. Redistributions of source code must retain the above copyright
  15   15   *    notice, this list of conditions, and the following disclaimer,
  16   16   *    without modification.
  17   17   * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  18   18   *    substantially similar to the "NO WARRANTY" disclaimer below
↓ open down ↓ 18 lines elided ↑ open up ↑
  37   37   * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  38   38   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  39   39   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  40   40   * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  41   41   * POSSIBILITY OF SUCH DAMAGES.
  42   42   */
  43   43  
  44   44  
  45   45  /*
  46   46   * Parse the AML and build an operation tree as most interpreters,
  47      - * like Perl, do.  Parsing is done by hand rather than with a YACC
       47 + * like Perl, do. Parsing is done by hand rather than with a YACC
  48   48   * generated parser to tightly constrain stack and dynamic memory
  49      - * usage.  At the same time, parsing is kept flexible and the code
       49 + * usage. At the same time, parsing is kept flexible and the code
  50   50   * fairly compact by parsing based on a list of AML opcode
  51   51   * templates in AmlOpInfo[]
  52   52   */
  53   53  
  54   54  #include "acpi.h"
  55   55  #include "accommon.h"
  56   56  #include "acparser.h"
  57   57  #include "acdispat.h"
  58   58  #include "amlcode.h"
  59   59  #include "acinterp.h"
↓ open down ↓ 124 lines elided ↑ open up ↑
 184  184  
 185  185          /*
 186  186           * Check if we need to replace the operator and its subtree
 187  187           * with a return value op (placeholder op)
 188  188           */
 189  189          ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode);
 190  190  
 191  191          switch (ParentInfo->Class)
 192  192          {
 193  193          case AML_CLASS_CONTROL:
      194 +
 194  195              break;
 195  196  
 196  197          case AML_CLASS_CREATE:
 197      -
 198  198              /*
 199      -             * These opcodes contain TermArg operands.  The current
      199 +             * These opcodes contain TermArg operands. The current
 200  200               * op must be replaced by a placeholder return op
 201  201               */
 202  202              ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
 203  203              if (!ReplacementOp)
 204  204              {
 205  205                  Status = AE_NO_MEMORY;
 206  206              }
 207  207              break;
 208  208  
 209  209          case AML_CLASS_NAMED_OBJECT:
 210      -
 211  210              /*
 212      -             * These opcodes contain TermArg operands.  The current
      211 +             * These opcodes contain TermArg operands. The current
 213  212               * op must be replaced by a placeholder return op
 214  213               */
 215  214              if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP)       ||
 216  215                  (Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP)  ||
 217  216                  (Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP)       ||
 218  217                  (Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP)      ||
 219  218                  (Op->Common.Parent->Common.AmlOpcode == AML_BANK_FIELD_OP)   ||
 220  219                  (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP))
 221  220              {
 222  221                  ReplacementOp = AcpiPsAllocOp (AML_INT_RETURN_VALUE_OP);
↓ open down ↓ 122 lines elided ↑ open up ↑
 345  344      {
 346  345      case AE_CTRL_TERMINATE:
 347  346          /*
 348  347           * A control method was terminated via a RETURN statement.
 349  348           * The walk of this method is complete.
 350  349           */
 351  350          ParserState->Aml = ParserState->AmlEnd;
 352  351          Status = AE_CTRL_TERMINATE;
 353  352          break;
 354  353  
 355      -
 356  354      case AE_CTRL_BREAK:
 357  355  
 358  356          ParserState->Aml = WalkState->AmlLastWhile;
 359  357          WalkState->ControlState->Common.Value = FALSE;
 360  358          Status = AE_CTRL_BREAK;
 361  359          break;
 362  360  
 363      -
 364  361      case AE_CTRL_CONTINUE:
 365  362  
 366  363          ParserState->Aml = WalkState->AmlLastWhile;
 367  364          Status = AE_CTRL_CONTINUE;
 368  365          break;
 369  366  
 370      -
 371  367      case AE_CTRL_PENDING:
 372  368  
 373  369          ParserState->Aml = WalkState->AmlLastWhile;
 374  370          break;
 375  371  
 376  372  #if 0
 377  373      case AE_CTRL_SKIP:
 378  374  
 379  375          ParserState->Aml = ParserState->Scope->ParseScope.PkgEnd;
 380  376          Status = AE_OK;
↓ open down ↓ 2 lines elided ↑ open up ↑
 383  379  
 384  380      case AE_CTRL_TRUE:
 385  381          /*
 386  382           * Predicate of an IF was true, and we are at the matching ELSE.
 387  383           * Just close out this package
 388  384           */
 389  385          ParserState->Aml = AcpiPsGetNextPackageEnd (ParserState);
 390  386          Status = AE_CTRL_PENDING;
 391  387          break;
 392  388  
 393      -
 394  389      case AE_CTRL_FALSE:
 395  390          /*
 396  391           * Either an IF/WHILE Predicate was false or we encountered a BREAK
 397      -         * opcode.  In both cases, we do not execute the rest of the
      392 +         * opcode. In both cases, we do not execute the rest of the
 398  393           * package;  We simply close out the parent (finishing the walk of
 399  394           * this branch of the tree) and continue execution at the parent
 400  395           * level.
 401  396           */
 402  397          ParserState->Aml = ParserState->Scope->ParseScope.PkgEnd;
 403  398  
 404  399          /* In the case of a BREAK, just force a predicate (if any) to FALSE */
 405  400  
 406  401          WalkState->ControlState->Common.Value = FALSE;
 407  402          Status = AE_CTRL_END;
 408  403          break;
 409  404  
 410      -
 411  405      case AE_CTRL_TRANSFER:
 412  406  
 413  407          /* A method call (invocation) -- transfer control */
 414  408  
 415  409          Status = AE_CTRL_TRANSFER;
 416  410          WalkState->PrevOp = Op;
 417  411          WalkState->MethodCallOp = Op;
 418  412          WalkState->MethodCallNode = (Op->Common.Value.Arg)->Common.Node;
 419  413  
 420  414          /* Will return value (if any) be used by the caller? */
 421  415  
 422  416          WalkState->ReturnUsed = AcpiDsIsResultUsed (Op, WalkState);
 423  417          break;
 424  418  
 425      -
 426  419      default:
 427  420  
 428  421          Status = CallbackStatus;
 429  422          if ((CallbackStatus & AE_CODE_MASK) == AE_CODE_CONTROL)
 430  423          {
 431  424              Status = AE_OK;
 432  425          }
 433  426          break;
 434  427      }
 435  428  
↓ open down ↓ 65 lines elided ↑ open up ↑
 501  494  
 502  495      AcpiDsPushWalkState (WalkState, Thread);
 503  496  
 504  497      /*
 505  498       * This global allows the AML debugger to get a handle to the currently
 506  499       * executing control method.
 507  500       */
 508  501      AcpiGbl_CurrentWalkList = Thread;
 509  502  
 510  503      /*
 511      -     * Execute the walk loop as long as there is a valid Walk State.  This
      504 +     * Execute the walk loop as long as there is a valid Walk State. This
 512  505       * handles nested control method invocations without recursion.
 513  506       */
 514  507      ACPI_DEBUG_PRINT ((ACPI_DB_PARSE, "State=%p\n", WalkState));
 515  508  
 516  509      Status = AE_OK;
 517  510      while (WalkState)
 518  511      {
 519  512          if (ACPI_SUCCESS (Status))
 520  513          {
 521  514              /*
↓ open down ↓ 178 lines elided ↑ open up ↑
 700  693          AcpiDsDeleteWalkState (PreviousWalkState);
 701  694      }
 702  695  
 703  696      /* Normal exit */
 704  697  
 705  698      AcpiExReleaseAllMutexes (Thread);
 706  699      AcpiUtDeleteGenericState (ACPI_CAST_PTR (ACPI_GENERIC_STATE, Thread));
 707  700      AcpiGbl_CurrentWalkList = PrevWalkList;
 708  701      return_ACPI_STATUS (Status);
 709  702  }
 710      -
 711      -
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX