Print this page
update to acpica-unix2-20140114
update to acpica-unix2-20131218
acpica-unix2-20130823
PANKOVs restructure

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/intel/io/acpica/dispatcher/dsutils.c
          +++ new/usr/src/common/acpica/components/dispatcher/dsutils.c
   1    1  /*******************************************************************************
   2    2   *
   3    3   * Module Name: dsutils - Dispatcher utilities
   4    4   *
   5    5   ******************************************************************************/
   6    6  
   7    7  /*
   8      - * Copyright (C) 2000 - 2011, Intel Corp.
        8 + * Copyright (C) 2000 - 2014, 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 ↓ 38 lines elided ↑ open up ↑
  57   57  
  58   58  
  59   59  /*******************************************************************************
  60   60   *
  61   61   * FUNCTION:    AcpiDsClearImplicitReturn
  62   62   *
  63   63   * PARAMETERS:  WalkState           - Current State
  64   64   *
  65   65   * RETURN:      None.
  66   66   *
  67      - * DESCRIPTION: Clear and remove a reference on an implicit return value.  Used
       67 + * DESCRIPTION: Clear and remove a reference on an implicit return value. Used
  68   68   *              to delete "stale" return values (if enabled, the return value
  69   69   *              from every operator is saved at least momentarily, in case the
  70   70   *              parent method exits.)
  71   71   *
  72   72   ******************************************************************************/
  73   73  
  74   74  void
  75   75  AcpiDsClearImplicitReturn (
  76   76      ACPI_WALK_STATE         *WalkState)
  77   77  {
↓ open down ↓ 32 lines elided ↑ open up ↑
 110  110   *
 111  111   * PARAMETERS:  ReturnDesc          - The return value
 112  112   *              WalkState           - Current State
 113  113   *              AddReference        - True if a reference should be added to the
 114  114   *                                    return object
 115  115   *
 116  116   * RETURN:      TRUE if implicit return enabled, FALSE otherwise
 117  117   *
 118  118   * DESCRIPTION: Implements the optional "implicit return".  We save the result
 119  119   *              of every ASL operator and control method invocation in case the
 120      - *              parent method exit.  Before storing a new return value, we
      120 + *              parent method exit. Before storing a new return value, we
 121  121   *              delete the previous return value.
 122  122   *
 123  123   ******************************************************************************/
 124  124  
 125  125  BOOLEAN
 126  126  AcpiDsDoImplicitReturn (
 127  127      ACPI_OPERAND_OBJECT     *ReturnDesc,
 128  128      ACPI_WALK_STATE         *WalkState,
 129  129      BOOLEAN                 AddReference)
 130  130  {
↓ open down ↓ 82 lines elided ↑ open up ↑
 213  213       * NOTE: this is optional because the ASL language does not actually
 214  214       * support this behavior.
 215  215       */
 216  216      (void) AcpiDsDoImplicitReturn (WalkState->ResultObj, WalkState, TRUE);
 217  217  
 218  218      /*
 219  219       * Now determine if the parent will use the result
 220  220       *
 221  221       * If there is no parent, or the parent is a ScopeOp, we are executing
 222  222       * at the method level. An executing method typically has no parent,
 223      -     * since each method is parsed separately.  A method invoked externally
      223 +     * since each method is parsed separately. A method invoked externally
 224  224       * via ExecuteControlMethod has a ScopeOp as the parent.
 225  225       */
 226  226      if ((!Op->Common.Parent) ||
 227  227          (Op->Common.Parent->Common.AmlOpcode == AML_SCOPE_OP))
 228  228      {
 229  229          /* No parent, the return value cannot possibly be used */
 230  230  
 231  231          ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
 232  232              "At Method level, result of [%s] not used\n",
 233  233              AcpiPsGetOpcodeName (Op->Common.AmlOpcode)));
↓ open down ↓ 4 lines elided ↑ open up ↑
 238  238  
 239  239      ParentInfo = AcpiPsGetOpcodeInfo (Op->Common.Parent->Common.AmlOpcode);
 240  240      if (ParentInfo->Class == AML_CLASS_UNKNOWN)
 241  241      {
 242  242          ACPI_ERROR ((AE_INFO,
 243  243              "Unknown parent opcode Op=%p", Op));
 244  244          return_UINT8 (FALSE);
 245  245      }
 246  246  
 247  247      /*
 248      -     * Decide what to do with the result based on the parent.  If
      248 +     * Decide what to do with the result based on the parent. If
 249  249       * the parent opcode will not use the result, delete the object.
 250  250       * Otherwise leave it as is, it will be deleted when it is used
 251  251       * as an operand later.
 252  252       */
 253  253      switch (ParentInfo->Class)
 254  254      {
 255  255      case AML_CLASS_CONTROL:
 256  256  
 257  257          switch (Op->Common.Parent->Common.AmlOpcode)
 258  258          {
 259  259          case AML_RETURN_OP:
 260  260  
 261  261              /* Never delete the return value associated with a return opcode */
 262  262  
 263  263              goto ResultUsed;
 264  264  
 265  265          case AML_IF_OP:
 266  266          case AML_WHILE_OP:
 267      -
 268  267              /*
 269  268               * If we are executing the predicate AND this is the predicate op,
 270  269               * we will use the return value
 271  270               */
 272  271              if ((WalkState->ControlState->Common.State == ACPI_CONTROL_PREDICATE_EXECUTING) &&
 273  272                  (WalkState->ControlState->Control.PredicateOp == Op))
 274  273              {
 275  274                  goto ResultUsed;
 276  275              }
 277  276              break;
 278  277  
 279  278          default:
      279 +
 280  280              /* Ignore other control opcodes */
      281 +
 281  282              break;
 282  283          }
 283  284  
 284  285          /* The general control opcode returns no result */
 285  286  
 286  287          goto ResultNotUsed;
 287  288  
 288      -
 289  289      case AML_CLASS_CREATE:
 290      -
 291  290          /*
 292  291           * These opcodes allow TermArg(s) as operands and therefore
 293      -         * the operands can be method calls.  The result is used.
      292 +         * the operands can be method calls. The result is used.
 294  293           */
 295  294          goto ResultUsed;
 296  295  
 297      -
 298  296      case AML_CLASS_NAMED_OBJECT:
 299  297  
 300  298          if ((Op->Common.Parent->Common.AmlOpcode == AML_REGION_OP)       ||
 301  299              (Op->Common.Parent->Common.AmlOpcode == AML_DATA_REGION_OP)  ||
 302  300              (Op->Common.Parent->Common.AmlOpcode == AML_PACKAGE_OP)      ||
 303  301              (Op->Common.Parent->Common.AmlOpcode == AML_VAR_PACKAGE_OP)  ||
 304  302              (Op->Common.Parent->Common.AmlOpcode == AML_BUFFER_OP)       ||
 305  303              (Op->Common.Parent->Common.AmlOpcode == AML_INT_EVAL_SUBTREE_OP) ||
 306  304              (Op->Common.Parent->Common.AmlOpcode == AML_BANK_FIELD_OP))
 307  305          {
 308  306              /*
 309  307               * These opcodes allow TermArg(s) as operands and therefore
 310      -             * the operands can be method calls.  The result is used.
      308 +             * the operands can be method calls. The result is used.
 311  309               */
 312  310              goto ResultUsed;
 313  311          }
 314  312  
 315  313          goto ResultNotUsed;
 316  314  
 317      -
 318  315      default:
 319      -
 320  316          /*
 321  317           * In all other cases. the parent will actually use the return
 322  318           * object, so keep it.
 323  319           */
 324  320          goto ResultUsed;
 325  321      }
 326  322  
 327  323  
 328  324  ResultUsed:
 329  325      ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
↓ open down ↓ 17 lines elided ↑ open up ↑
 347  343  /*******************************************************************************
 348  344   *
 349  345   * FUNCTION:    AcpiDsDeleteResultIfNotUsed
 350  346   *
 351  347   * PARAMETERS:  Op              - Current parse Op
 352  348   *              ResultObj       - Result of the operation
 353  349   *              WalkState       - Current state
 354  350   *
 355  351   * RETURN:      Status
 356  352   *
 357      - * DESCRIPTION: Used after interpretation of an opcode.  If there is an internal
      353 + * DESCRIPTION: Used after interpretation of an opcode. If there is an internal
 358  354   *              result descriptor, check if the parent opcode will actually use
 359      - *              this result.  If not, delete the result now so that it will
      355 + *              this result. If not, delete the result now so that it will
 360  356   *              not become orphaned.
 361  357   *
 362  358   ******************************************************************************/
 363  359  
 364  360  void
 365  361  AcpiDsDeleteResultIfNotUsed (
 366  362      ACPI_PARSE_OBJECT       *Op,
 367  363      ACPI_OPERAND_OBJECT     *ResultObj,
 368  364      ACPI_WALK_STATE         *WalkState)
 369  365  {
↓ open down ↓ 31 lines elided ↑ open up ↑
 401  397  
 402  398  
 403  399  /*******************************************************************************
 404  400   *
 405  401   * FUNCTION:    AcpiDsResolveOperands
 406  402   *
 407  403   * PARAMETERS:  WalkState           - Current walk state with operands on stack
 408  404   *
 409  405   * RETURN:      Status
 410  406   *
 411      - * DESCRIPTION: Resolve all operands to their values.  Used to prepare
      407 + * DESCRIPTION: Resolve all operands to their values. Used to prepare
 412  408   *              arguments to a control method invocation (a call from one
 413  409   *              method to another.)
 414  410   *
 415  411   ******************************************************************************/
 416  412  
 417  413  ACPI_STATUS
 418  414  AcpiDsResolveOperands (
 419  415      ACPI_WALK_STATE         *WalkState)
 420  416  {
 421  417      UINT32                  i;
 422  418      ACPI_STATUS             Status = AE_OK;
 423  419  
 424  420  
 425  421      ACPI_FUNCTION_TRACE_PTR (DsResolveOperands, WalkState);
 426  422  
 427  423  
 428  424      /*
 429  425       * Attempt to resolve each of the valid operands
 430      -     * Method arguments are passed by reference, not by value.  This means
      426 +     * Method arguments are passed by reference, not by value. This means
 431  427       * that the actual objects are passed, not copies of the objects.
 432  428       */
 433  429      for (i = 0; i < WalkState->NumOperands; i++)
 434  430      {
 435  431          Status = AcpiExResolveToValue (&WalkState->Operands[i], WalkState);
 436  432          if (ACPI_FAILURE (Status))
 437  433          {
 438  434              break;
 439  435          }
 440  436      }
↓ open down ↓ 46 lines elided ↑ open up ↑
 487  483   *
 488  484   * FUNCTION:    AcpiDsCreateOperand
 489  485   *
 490  486   * PARAMETERS:  WalkState       - Current walk state
 491  487   *              Arg             - Parse object for the argument
 492  488   *              ArgIndex        - Which argument (zero based)
 493  489   *
 494  490   * RETURN:      Status
 495  491   *
 496  492   * DESCRIPTION: Translate a parse tree object that is an argument to an AML
 497      - *              opcode to the equivalent interpreter object.  This may include
      493 + *              opcode to the equivalent interpreter object. This may include
 498  494   *              looking up a name or entering a new name into the internal
 499  495   *              namespace.
 500  496   *
 501  497   ******************************************************************************/
 502  498  
 503  499  ACPI_STATUS
 504  500  AcpiDsCreateOperand (
 505  501      ACPI_WALK_STATE         *WalkState,
 506  502      ACPI_PARSE_OBJECT       *Arg,
 507  503      UINT32                  ArgIndex)
↓ open down ↓ 25 lines elided ↑ open up ↑
 533  529                          &NameString, &NameLength);
 534  530  
 535  531          if (ACPI_FAILURE (Status))
 536  532          {
 537  533              return_ACPI_STATUS (Status);
 538  534          }
 539  535  
 540  536          /* All prefixes have been handled, and the name is in NameString */
 541  537  
 542  538          /*
 543      -         * Special handling for BufferField declarations.  This is a deferred
      539 +         * Special handling for BufferField declarations. This is a deferred
 544  540           * opcode that unfortunately defines the field name as the last
 545      -         * parameter instead of the first.  We get here when we are performing
      541 +         * parameter instead of the first. We get here when we are performing
 546  542           * the deferred execution, so the actual name of the field is already
 547      -         * in the namespace.  We don't want to attempt to look it up again
      543 +         * in the namespace. We don't want to attempt to look it up again
 548  544           * because we may be executing in a different scope than where the
 549  545           * actual opcode exists.
 550  546           */
 551  547          if ((WalkState->DeferredNode) &&
 552  548              (WalkState->DeferredNode->Type == ACPI_TYPE_BUFFER_FIELD) &&
 553  549              (ArgIndex == (UINT32) ((WalkState->Opcode == AML_CREATE_FIELD_OP) ? 3 : 2)))
 554  550          {
 555  551              ObjDesc = ACPI_CAST_PTR (
 556  552                          ACPI_OPERAND_OBJECT, WalkState->DeferredNode);
 557  553              Status = AE_OK;
↓ open down ↓ 86 lines elided ↑ open up ↑
 644  640      else
 645  641      {
 646  642          /* Check for null name case */
 647  643  
 648  644          if ((Arg->Common.AmlOpcode == AML_INT_NAMEPATH_OP) &&
 649  645              !(Arg->Common.Flags & ACPI_PARSEOP_IN_STACK))
 650  646          {
 651  647              /*
 652  648               * If the name is null, this means that this is an
 653  649               * optional result parameter that was not specified
 654      -             * in the original ASL.  Create a Zero Constant for a
 655      -             * placeholder.  (Store to a constant is a Noop.)
      650 +             * in the original ASL. Create a Zero Constant for a
      651 +             * placeholder. (Store to a constant is a Noop.)
 656  652               */
 657  653              Opcode = AML_ZERO_OP;       /* Has no arguments! */
 658  654  
 659  655              ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
 660  656                  "Null namepath: Arg=%p\n", Arg));
 661  657          }
 662  658          else
 663  659          {
 664  660              Opcode = Arg->Common.AmlOpcode;
 665  661          }
↓ open down ↓ 110 lines elided ↑ open up ↑
 776  772          Arguments[Index] = Arg;
 777  773          WalkState->Operands [Index] = NULL;
 778  774  
 779  775          /* Move on to next argument, if any */
 780  776  
 781  777          Arg = Arg->Common.Next;
 782  778          ArgCount++;
 783  779          Index++;
 784  780      }
 785  781  
 786      -    Index--;
      782 +    ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
      783 +        "NumOperands %d, ArgCount %d, Index %d\n",
      784 +        WalkState->NumOperands, ArgCount, Index));
 787  785  
 788      -    /* It is the appropriate order to get objects from the Result stack */
      786 +    /* Create the interpreter arguments, in reverse order */
 789  787  
      788 +    Index--;
 790  789      for (i = 0; i < ArgCount; i++)
 791  790      {
 792  791          Arg = Arguments[Index];
 793      -
 794      -        /* Force the filling of the operand stack in inverse order */
 795      -
 796  792          WalkState->OperandIndex = (UINT8) Index;
 797  793  
 798  794          Status = AcpiDsCreateOperand (WalkState, Arg, Index);
 799  795          if (ACPI_FAILURE (Status))
 800  796          {
 801  797              goto Cleanup;
 802  798          }
 803  799  
      800 +        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH,
      801 +            "Created Arg #%u (%p) %u args total\n",
      802 +            Index, Arg, ArgCount));
 804  803          Index--;
 805      -
 806      -        ACPI_DEBUG_PRINT ((ACPI_DB_DISPATCH, "Arg #%u (%p) done, Arg1=%p\n",
 807      -            Index, Arg, FirstArg));
 808  804      }
 809  805  
 810  806      return_ACPI_STATUS (Status);
 811  807  
 812  808  
 813  809  Cleanup:
 814  810      /*
 815  811       * We must undo everything done above; meaning that we must
 816  812       * pop everything off of the operand stack and delete those
 817  813       * objects
↓ open down ↓ 120 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX