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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/intel/io/acpica/disassembler/dmwalk.c
          +++ new/usr/src/common/acpica/components/disassembler/dmwalk.c
   1    1  /*******************************************************************************
   2    2   *
   3    3   * Module Name: dmwalk - AML disassembly tree walk
   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 ↓ 72 lines elided ↑ open up ↑
  91   91  /*******************************************************************************
  92   92   *
  93   93   * FUNCTION:    AcpiDmDisassemble
  94   94   *
  95   95   * PARAMETERS:  WalkState       - Current state
  96   96   *              Origin          - Starting object
  97   97   *              NumOpcodes      - Max number of opcodes to be displayed
  98   98   *
  99   99   * RETURN:      None
 100  100   *
 101      - * DESCRIPTION: Disassemble parser object and its children.  This is the
      101 + * DESCRIPTION: Disassemble parser object and its children. This is the
 102  102   *              main entry point of the disassembler.
 103  103   *
 104  104   ******************************************************************************/
 105  105  
 106  106  void
 107  107  AcpiDmDisassemble (
 108  108      ACPI_WALK_STATE         *WalkState,
 109  109      ACPI_PARSE_OBJECT       *Origin,
 110  110      UINT32                  NumOpcodes)
 111  111  {
↓ open down ↓ 322 lines elided ↑ open up ↑
 434  434          }
 435  435      }
 436  436      else if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) &&
 437  437               (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) &&
 438  438               (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP))
 439  439      {
 440  440              /*
 441  441               * This is a first-level element of a term list,
 442  442               * indent a new line
 443  443               */
 444      -            AcpiDmIndent (Level);
      444 +            switch (Op->Common.AmlOpcode)
      445 +            {
      446 +            case AML_NOOP_OP:
      447 +                /*
      448 +                 * Optionally just ignore this opcode. Some tables use
      449 +                 * NoOp opcodes for "padding" out packages that the BIOS
      450 +                 * changes dynamically. This can leave hundreds or
      451 +                 * thousands of NoOp opcodes that if disassembled,
      452 +                 * cannot be compiled because they are syntactically
      453 +                 * incorrect.
      454 +                 */
      455 +                if (AcpiGbl_IgnoreNoopOperator)
      456 +                {
      457 +                    Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
      458 +                    return (AE_OK);
      459 +                }
      460 +
      461 +                /* Fallthrough */
      462 +
      463 +            default:
      464 +
      465 +                AcpiDmIndent (Level);
      466 +                break;
      467 +            }
      468 +
 445  469              Info->LastLevel = Level;
 446  470              Info->Count = 0;
 447  471      }
 448  472  
 449  473      /*
 450  474       * This is an inexpensive mechanism to try and keep lines from getting
 451  475       * too long. When the limit is hit, start a new line at the previous
 452  476       * indent plus one. A better but more expensive mechanism would be to
 453  477       * keep track of the current column.
 454  478       */
 455  479      Info->Count++;
 456      -    if (Info->Count /*+Info->LastLevel*/ > 10)
      480 +    if (Info->Count /* +Info->LastLevel */ > 10)
 457  481      {
 458  482          Info->Count = 0;
 459  483          AcpiOsPrintf ("\n");
 460  484          AcpiDmIndent (Info->LastLevel + 1);
 461  485      }
 462  486  
 463  487      /* Print the opcode name */
 464  488  
 465  489      AcpiDmDisassembleOneOp (NULL, Info, Op);
 466  490  
 467      -    if (Op->Common.DisasmOpcode == ACPI_DASM_LNOT_PREFIX)
      491 +    if ((Op->Common.DisasmOpcode == ACPI_DASM_LNOT_PREFIX) ||
      492 +        (Op->Common.AmlOpcode == AML_INT_CONNECTION_OP))
 468  493      {
 469  494          return (AE_OK);
 470  495      }
 471  496  
 472  497      if ((Op->Common.AmlOpcode == AML_NAME_OP) ||
 473  498          (Op->Common.AmlOpcode == AML_RETURN_OP))
 474  499      {
 475  500          Info->Level--;
 476  501      }
 477  502  
↓ open down ↓ 47 lines elided ↑ open up ↑
 525  550                  }
 526  551                  break;
 527  552              }
 528  553  
 529  554              switch (Op->Common.AmlOpcode)
 530  555              {
 531  556              case AML_METHOD_OP:
 532  557  
 533  558                  AcpiDmMethodFlags (Op);
 534  559                  AcpiOsPrintf (")");
      560 +
      561 +                /* Emit description comment for Method() with a predefined ACPI name */
      562 +
      563 +                AcpiDmPredefinedDescription (Op);
 535  564                  break;
 536  565  
 537  566  
 538  567              case AML_NAME_OP:
 539  568  
 540  569                  /* Check for _HID and related EISAID() */
 541  570  
 542  571                  AcpiDmIsEisaId (Op);
 543  572                  AcpiOsPrintf (", ");
 544  573                  break;
↓ open down ↓ 50 lines elided ↑ open up ↑
 595  624              case AML_SCOPE_OP:
 596  625              case AML_DEVICE_OP:
 597  626              case AML_THERMAL_ZONE_OP:
 598  627  
 599  628                  AcpiOsPrintf (")");
 600  629                  break;
 601  630  
 602  631  
 603  632              default:
 604  633  
 605      -                AcpiOsPrintf ("*** Unhandled named opcode %X\n", Op->Common.AmlOpcode);
      634 +                AcpiOsPrintf ("*** Unhandled named opcode %X\n",
      635 +                    Op->Common.AmlOpcode);
 606  636                  break;
 607  637              }
 608  638          }
 609  639  
 610  640          else switch (Op->Common.AmlOpcode)
 611  641          {
 612  642          case AML_FIELD_OP:
 613  643          case AML_BANK_FIELD_OP:
 614  644          case AML_INDEX_FIELD_OP:
 615  645  
↓ open down ↓ 20 lines elided ↑ open up ↑
 636  666                  /*
 637  667                   * Bank Value. This is a TermArg in the middle of the parameter
 638  668                   * list, must handle it here.
 639  669                   *
 640  670                   * Disassemble the TermArg parse tree. ACPI_PARSEOP_PARAMLIST
 641  671                   * eliminates newline in the output.
 642  672                   */
 643  673                  NextOp = NextOp->Common.Next;
 644  674  
 645  675                  Info->Flags = ACPI_PARSEOP_PARAMLIST;
 646      -                AcpiDmWalkParseTree (NextOp, AcpiDmDescendingOp, AcpiDmAscendingOp, Info);
      676 +                AcpiDmWalkParseTree (NextOp, AcpiDmDescendingOp,
      677 +                    AcpiDmAscendingOp, Info);
 647  678                  Info->Flags = 0;
 648  679                  Info->Level = Level;
 649  680  
 650  681                  NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
 651  682                  AcpiOsPrintf (", ");
 652  683                  break;
 653  684  
 654  685              case AML_INDEX_FIELD_OP:
 655  686  
 656  687                  /* Namestring - Data Name */
↓ open down ↓ 5 lines elided ↑ open up ↑
 662  693                  break;
 663  694  
 664  695              default:
 665  696  
 666  697                  break;
 667  698              }
 668  699  
 669  700              AcpiDmFieldFlags (NextOp);
 670  701              break;
 671  702  
 672      -
 673  703          case AML_BUFFER_OP:
 674  704  
 675  705              /* The next op is the size parameter */
 676  706  
 677  707              NextOp = AcpiPsGetDepthNext (NULL, Op);
 678  708              if (!NextOp)
 679  709              {
 680  710                  /* Single-step support */
 681  711  
 682  712                  return (AE_OK);
 683  713              }
 684  714  
 685  715              if (Op->Common.DisasmOpcode == ACPI_DASM_RESOURCE)
 686  716              {
 687  717                  /*
 688      -                 * We have a resource list.  Don't need to output
 689      -                 * the buffer size Op.  Open up a new block
      718 +                 * We have a resource list. Don't need to output
      719 +                 * the buffer size Op. Open up a new block
 690  720                   */
 691  721                  NextOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
 692  722                  NextOp = NextOp->Common.Next;
 693      -                AcpiOsPrintf (")\n");
      723 +                AcpiOsPrintf (")");
      724 +
      725 +                /* Emit description comment for Name() with a predefined ACPI name */
      726 +
      727 +                AcpiDmPredefinedDescription (Op->Asl.Parent);
      728 +
      729 +                AcpiOsPrintf ("\n");
 694  730                  AcpiDmIndent (Info->Level);
 695  731                  AcpiOsPrintf ("{\n");
 696  732                  return (AE_OK);
 697  733              }
 698  734  
 699  735              /* Normal Buffer, mark size as in the parameter list */
 700  736  
 701  737              NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST;
 702  738              return (AE_OK);
 703  739  
 704      -
 705  740          case AML_VAR_PACKAGE_OP:
 706  741          case AML_IF_OP:
 707  742          case AML_WHILE_OP:
 708  743  
 709  744              /* The next op is the size or predicate parameter */
 710  745  
 711  746              NextOp = AcpiPsGetDepthNext (NULL, Op);
 712  747              if (NextOp)
 713  748              {
 714  749                  NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST;
 715  750              }
 716  751              return (AE_OK);
 717  752  
 718      -
 719  753          case AML_PACKAGE_OP:
 720  754  
 721      -            /* The next op is the size or predicate parameter */
      755 +            /* The next op is the size parameter */
 722  756  
 723  757              NextOp = AcpiPsGetDepthNext (NULL, Op);
 724  758              if (NextOp)
 725  759              {
 726  760                  NextOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMLIST;
 727  761              }
 728  762              return (AE_OK);
 729  763  
 730      -
 731  764          case AML_MATCH_OP:
 732  765  
 733  766              AcpiDmMatchOp (Op);
 734  767              break;
 735  768  
 736      -
 737  769          default:
 738  770  
 739  771              break;
 740  772          }
 741  773  
 742  774          if (AcpiDmBlockType (Op) & BLOCK_BRACE)
 743  775          {
 744  776              AcpiOsPrintf ("\n");
 745  777              AcpiDmIndent (Level);
 746  778              AcpiOsPrintf ("{\n");
↓ open down ↓ 6 lines elided ↑ open up ↑
 753  785  
 754  786  /*******************************************************************************
 755  787   *
 756  788   * FUNCTION:    AcpiDmAscendingOp
 757  789   *
 758  790   * PARAMETERS:  ASL_WALK_CALLBACK
 759  791   *
 760  792   * RETURN:      Status
 761  793   *
 762  794   * DESCRIPTION: Second visitation of a parse object, during ascent of parse
 763      - *              tree.  Close out any parameter lists and complete the opcode.
      795 + *              tree. Close out any parameter lists and complete the opcode.
 764  796   *
 765  797   ******************************************************************************/
 766  798  
 767  799  static ACPI_STATUS
 768  800  AcpiDmAscendingOp (
 769  801      ACPI_PARSE_OBJECT       *Op,
 770  802      UINT32                  Level,
 771  803      void                    *Context)
 772  804  {
 773  805      ACPI_OP_WALK_INFO       *Info = Context;
      806 +    ACPI_PARSE_OBJECT       *ParentOp;
 774  807  
 775  808  
 776  809      if (Op->Common.DisasmFlags & ACPI_PARSEOP_IGNORE)
 777  810      {
 778  811          /* Ignore this op -- it was handled elsewhere */
 779  812  
 780  813          return (AE_OK);
 781  814      }
 782  815  
 783  816      if ((Level == 0) && (Op->Common.AmlOpcode == AML_SCOPE_OP))
↓ open down ↓ 5 lines elided ↑ open up ↑
 789  822      }
 790  823  
 791  824      switch (AcpiDmBlockType (Op))
 792  825      {
 793  826      case BLOCK_PAREN:
 794  827  
 795  828          /* Completed an op that has arguments, add closing paren */
 796  829  
 797  830          AcpiOsPrintf (")");
 798  831  
      832 +        if (Op->Common.AmlOpcode == AML_NAME_OP)
      833 +        {
      834 +            /* Emit description comment for Name() with a predefined ACPI name */
      835 +
      836 +            AcpiDmPredefinedDescription (Op);
      837 +        }
      838 +        else
      839 +        {
      840 +            /* For Create* operators, attempt to emit resource tag description */
      841 +
      842 +            AcpiDmFieldPredefinedDescription (Op);
      843 +        }
      844 +
 799  845          /* Could be a nested operator, check if comma required */
 800  846  
 801  847          if (!AcpiDmCommaIfListMember (Op))
 802  848          {
 803  849              if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) &&
 804  850                       (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) &&
 805  851                       (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP))
 806  852              {
 807  853                  /*
 808  854                   * This is a first-level element of a term list
 809  855                   * start a new line
 810  856                   */
 811  857                  if (!(Info->Flags & ACPI_PARSEOP_PARAMLIST))
 812  858                  {
 813  859                      AcpiOsPrintf ("\n");
 814  860                  }
 815  861              }
 816  862          }
 817  863          break;
 818  864  
 819      -
 820  865      case BLOCK_BRACE:
 821  866      case (BLOCK_BRACE | BLOCK_PAREN):
 822  867  
 823  868          /* Completed an op that has a term list, add closing brace */
 824  869  
 825  870          if (Op->Common.DisasmFlags & ACPI_PARSEOP_EMPTY_TERMLIST)
 826  871          {
 827  872              AcpiOsPrintf ("}");
 828  873          }
 829  874          else
↓ open down ↓ 19 lines elided ↑ open up ↑
 849  894                  if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) &&
 850  895                      (!Op->Common.Next))
 851  896                  {
 852  897                      break;
 853  898                  }
 854  899                  AcpiOsPrintf ("\n");
 855  900              }
 856  901          }
 857  902          break;
 858  903  
 859      -
 860  904      case BLOCK_NONE:
 861  905      default:
 862  906  
 863  907          /* Could be a nested operator, check if comma required */
 864  908  
 865  909          if (!AcpiDmCommaIfListMember (Op))
 866  910          {
 867  911              if ((AcpiDmBlockType (Op->Common.Parent) & BLOCK_BRACE) &&
 868  912                       (!(Op->Common.DisasmFlags & ACPI_PARSEOP_PARAMLIST)) &&
 869  913                       (Op->Common.AmlOpcode != AML_INT_BYTELIST_OP))
↓ open down ↓ 33 lines elided ↑ open up ↑
 903  947          {
 904  948              return (AE_OK);
 905  949          }
 906  950  
 907  951          /*
 908  952           * Just completed a parameter node for something like "Buffer (param)".
 909  953           * Close the paren and open up the term list block with a brace
 910  954           */
 911  955          if (Op->Common.Next)
 912  956          {
 913      -            AcpiOsPrintf (")\n");
      957 +            AcpiOsPrintf (")");
      958 +
      959 +            /* Emit description comment for Name() with a predefined ACPI name */
      960 +
      961 +            ParentOp = Op->Common.Parent;
      962 +            if (ParentOp)
      963 +            {
      964 +                ParentOp = ParentOp->Common.Parent;
      965 +                if (ParentOp && ParentOp->Asl.AmlOpcode == AML_NAME_OP)
      966 +                {
      967 +                    AcpiDmPredefinedDescription (ParentOp);
      968 +                }
      969 +            }
      970 +            AcpiOsPrintf ("\n");
 914  971              AcpiDmIndent (Level - 1);
 915  972              AcpiOsPrintf ("{\n");
 916  973          }
 917  974          else
 918  975          {
 919  976              Op->Common.Parent->Common.DisasmFlags |=
 920  977                                      ACPI_PARSEOP_EMPTY_TERMLIST;
 921  978              AcpiOsPrintf (") {");
 922  979          }
 923  980      }
↓ open down ↓ 11 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX