Print this page
    
acpica-unix2-20130823
PANKOVs restructure
    
      
        | Split | Close | 
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/uts/intel/io/acpica/disassembler/dmobject.c
          +++ new/usr/src/common/acpica/components/disassembler/dmobject.c
   1    1  /*******************************************************************************
   2    2   *
   3    3   * Module Name: dmobject - ACPI object decode and display
   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
  19   19   *    ("Disclaimer") and any redistribution must be conditioned upon
  20   20   *    including a substantially similar Disclaimer requirement for further
  21   21   *    binary redistribution.
  22   22   * 3. Neither the names of the above-listed copyright holders nor the names
  23   23   *    of any contributors may be used to endorse or promote products derived
  24   24   *    from this software without specific prior written permission.
  25   25   *
  26   26   * Alternatively, this software may be distributed under the terms of the
  27   27   * GNU General Public License ("GPL") version 2 as published by the Free
  28   28   * Software Foundation.
  29   29   *
  30   30   * NO WARRANTY
  31   31   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  32   32   * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  33   33   * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
  34   34   * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  35   35   * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  36   36   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  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  #include "acpi.h"
  46   46  #include "accommon.h"
  47   47  #include "acnamesp.h"
  48   48  #include "acdisasm.h"
  49   49  
  50   50  
  51   51  #ifdef ACPI_DISASSEMBLER
  52   52  
  53   53  #define _COMPONENT          ACPI_CA_DEBUGGER
  54   54          ACPI_MODULE_NAME    ("dmnames")
  55   55  
  56   56  /* Local prototypes */
  57   57  
  58   58  static void
  59   59  AcpiDmDecodeNode (
  60   60      ACPI_NAMESPACE_NODE     *Node);
  61   61  
  62   62  
  63   63  /*******************************************************************************
  64   64   *
  65   65   * FUNCTION:    AcpiDmDumpMethodInfo
  66   66   *
  67   67   * PARAMETERS:  Status          - Method execution status
  68   68   *              WalkState       - Current state of the parse tree walk
  69   69   *              Op              - Executing parse op
  70   70   *
  71   71   * RETURN:      None
  72   72   *
  73   73   * DESCRIPTION: Called when a method has been aborted because of an error.
  74   74   *              Dumps the method execution stack, and the method locals/args,
  75   75   *              and disassembles the AML opcode that failed.
  76   76   *
  77   77   ******************************************************************************/
  78   78  
  79   79  void
  80   80  AcpiDmDumpMethodInfo (
  81   81      ACPI_STATUS             Status,
  82   82      ACPI_WALK_STATE         *WalkState,
  83   83      ACPI_PARSE_OBJECT       *Op)
  84   84  {
  85   85      ACPI_PARSE_OBJECT       *Next;
  86   86      ACPI_THREAD_STATE       *Thread;
  87   87      ACPI_WALK_STATE         *NextWalkState;
  88   88      ACPI_NAMESPACE_NODE     *PreviousMethod = NULL;
  89   89  
  90   90  
  91   91      /* Ignore control codes, they are not errors */
  92   92  
  93   93      if ((Status & AE_CODE_MASK) == AE_CODE_CONTROL)
  94   94      {
  95   95          return;
  96   96      }
  97   97  
  98   98      /* We may be executing a deferred opcode */
  99   99  
 100  100      if (WalkState->DeferredNode)
 101  101      {
 102  102          AcpiOsPrintf ("Executing subtree for Buffer/Package/Region\n");
 103  103          return;
 104  104      }
 105  105  
 106  106      /*
 107  107       * If there is no Thread, we are not actually executing a method.
 108  108       * This can happen when the iASL compiler calls the interpreter
 109  109       * to perform constant folding.
 110  110       */
 111  111      Thread = WalkState->Thread;
 112  112      if (!Thread)
 113  113      {
 114  114          return;
 115  115      }
 116  116  
 117  117      /* Display exception and method name */
 118  118  
 119  119      AcpiOsPrintf ("\n**** Exception %s during execution of method ",
 120  120          AcpiFormatException (Status));
 121  121      AcpiNsPrintNodePathname (WalkState->MethodNode, NULL);
 122  122  
 123  123      /* Display stack of executing methods */
 124  124  
 125  125      AcpiOsPrintf ("\n\nMethod Execution Stack:\n");
 126  126      NextWalkState = Thread->WalkStateList;
 127  127  
 128  128      /* Walk list of linked walk states */
 129  129  
 130  130      while (NextWalkState)
 131  131      {
 132  132          AcpiOsPrintf ("    Method [%4.4s] executing: ",
 133  133                  AcpiUtGetNodeName (NextWalkState->MethodNode));
 134  134  
 135  135          /* First method is the currently executing method */
 136  136  
 137  137          if (NextWalkState == WalkState)
 138  138          {
 139  139              if (Op)
 140  140              {
 141  141                  /* Display currently executing ASL statement */
 142  142  
 143  143                  Next = Op->Common.Next;
 144  144                  Op->Common.Next = NULL;
 145  145  
 146  146                  AcpiDmDisassemble (NextWalkState, Op, ACPI_UINT32_MAX);
 147  147                  Op->Common.Next = Next;
 148  148              }
 149  149          }
 150  150          else
 151  151          {
 152  152              /*
 153  153               * This method has called another method
 154  154               * NOTE: the method call parse subtree is already deleted at this
 155  155               * point, so we cannot disassemble the method invocation.
 156  156               */
 157  157              AcpiOsPrintf ("Call to method ");
 158  158              AcpiNsPrintNodePathname (PreviousMethod, NULL);
 159  159          }
 160  160  
 161  161          PreviousMethod = NextWalkState->MethodNode;
 162  162          NextWalkState = NextWalkState->Next;
 163  163          AcpiOsPrintf ("\n");
 164  164      }
 165  165  
 166  166      /* Display the method locals and arguments */
 167  167  
 168  168      AcpiOsPrintf ("\n");
 169  169      AcpiDmDisplayLocals (WalkState);
 170  170      AcpiOsPrintf ("\n");
 171  171      AcpiDmDisplayArguments (WalkState);
 172  172      AcpiOsPrintf ("\n");
 173  173  }
  
    | ↓ open down ↓ | 155 lines elided | ↑ open up ↑ | 
 174  174  
 175  175  
 176  176  /*******************************************************************************
 177  177   *
 178  178   * FUNCTION:    AcpiDmDecodeInternalObject
 179  179   *
 180  180   * PARAMETERS:  ObjDesc         - Object to be displayed
 181  181   *
 182  182   * RETURN:      None
 183  183   *
 184      - * DESCRIPTION: Short display of an internal object.  Numbers/Strings/Buffers.
      184 + * DESCRIPTION: Short display of an internal object. Numbers/Strings/Buffers.
 185  185   *
 186  186   ******************************************************************************/
 187  187  
 188  188  void
 189  189  AcpiDmDecodeInternalObject (
 190  190      ACPI_OPERAND_OBJECT     *ObjDesc)
 191  191  {
 192  192      UINT32                  i;
 193  193  
 194  194  
 195  195      if (!ObjDesc)
 196  196      {
 197  197          AcpiOsPrintf (" Uninitialized");
 198  198          return;
 199  199      }
 200  200  
 201  201      if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
 202  202      {
 203  203          AcpiOsPrintf (" %p [%s]", ObjDesc, AcpiUtGetDescriptorName (ObjDesc));
 204  204          return;
 205  205      }
 206  206  
  
    | ↓ open down ↓ | 12 lines elided | ↑ open up ↑ | 
 207  207      AcpiOsPrintf (" %s", AcpiUtGetObjectTypeName (ObjDesc));
 208  208  
 209  209      switch (ObjDesc->Common.Type)
 210  210      {
 211  211      case ACPI_TYPE_INTEGER:
 212  212  
 213  213          AcpiOsPrintf (" %8.8X%8.8X",
 214  214                  ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
 215  215          break;
 216  216  
 217      -
 218  217      case ACPI_TYPE_STRING:
 219  218  
 220  219          AcpiOsPrintf ("(%u) \"%.24s",
 221  220                  ObjDesc->String.Length, ObjDesc->String.Pointer);
 222  221  
 223  222          if (ObjDesc->String.Length > 24)
 224  223          {
 225  224              AcpiOsPrintf ("...");
 226  225          }
 227  226          else
 228  227          {
 229  228              AcpiOsPrintf ("\"");
 230  229          }
 231  230          break;
 232  231  
 233      -
 234  232      case ACPI_TYPE_BUFFER:
 235  233  
 236  234          AcpiOsPrintf ("(%u)", ObjDesc->Buffer.Length);
 237  235          for (i = 0; (i < 8) && (i < ObjDesc->Buffer.Length); i++)
 238  236          {
 239  237              AcpiOsPrintf (" %2.2X", ObjDesc->Buffer.Pointer[i]);
 240  238          }
 241  239          break;
 242  240  
 243      -
 244  241      default:
 245  242  
 246  243          AcpiOsPrintf (" %p", ObjDesc);
 247  244          break;
 248  245      }
 249  246  }
 250  247  
 251  248  
 252  249  /*******************************************************************************
 253  250   *
 254  251   * FUNCTION:    AcpiDmDecodeNode
 255  252   *
 256  253   * PARAMETERS:  Node        - Object to be displayed
 257  254   *
 258  255   * RETURN:      None
 259  256   *
 260  257   * DESCRIPTION: Short display of a namespace node
 261  258   *
 262  259   ******************************************************************************/
 263  260  
 264  261  static void
 265  262  AcpiDmDecodeNode (
 266  263      ACPI_NAMESPACE_NODE     *Node)
 267  264  {
 268  265  
 269  266      AcpiOsPrintf ("<Node>            Name %4.4s",
 270  267              AcpiUtGetNodeName (Node));
 271  268  
 272  269      if (Node->Flags & ANOBJ_METHOD_ARG)
 273  270      {
 274  271          AcpiOsPrintf (" [Method Arg]");
 275  272      }
  
    | ↓ open down ↓ | 22 lines elided | ↑ open up ↑ | 
 276  273      if (Node->Flags & ANOBJ_METHOD_LOCAL)
 277  274      {
 278  275          AcpiOsPrintf (" [Method Local]");
 279  276      }
 280  277  
 281  278      switch (Node->Type)
 282  279      {
 283  280      /* These types have no attached object */
 284  281  
 285  282      case ACPI_TYPE_DEVICE:
      283 +
 286  284          AcpiOsPrintf (" Device");
 287  285          break;
 288  286  
 289  287      case ACPI_TYPE_THERMAL:
      288 +
 290  289          AcpiOsPrintf (" Thermal Zone");
 291  290          break;
 292  291  
 293  292      default:
      293 +
 294  294          AcpiDmDecodeInternalObject (AcpiNsGetAttachedObject (Node));
 295  295          break;
 296  296      }
 297  297  }
 298  298  
 299  299  
 300  300  /*******************************************************************************
 301  301   *
 302  302   * FUNCTION:    AcpiDmDisplayInternalObject
 303  303   *
 304  304   * PARAMETERS:  ObjDesc         - Object to be displayed
 305  305   *              WalkState       - Current walk state
 306  306   *
 307  307   * RETURN:      None
 308  308   *
 309  309   * DESCRIPTION: Short display of an internal object
 310  310   *
 311  311   ******************************************************************************/
 312  312  
 313  313  void
 314  314  AcpiDmDisplayInternalObject (
 315  315      ACPI_OPERAND_OBJECT     *ObjDesc,
 316  316      ACPI_WALK_STATE         *WalkState)
 317  317  {
 318  318      UINT8                   Type;
 319  319  
 320  320  
 321  321      AcpiOsPrintf ("%p ", ObjDesc);
 322  322  
 323  323      if (!ObjDesc)
 324  324      {
 325  325          AcpiOsPrintf ("<Null Object>\n");
 326  326          return;
 327  327      }
  
    | ↓ open down ↓ | 24 lines elided | ↑ open up ↑ | 
 328  328  
 329  329      /* Decode the object type */
 330  330  
 331  331      switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
 332  332      {
 333  333      case ACPI_DESC_TYPE_PARSER:
 334  334  
 335  335          AcpiOsPrintf ("<Parser>  ");
 336  336          break;
 337  337  
 338      -
 339  338      case ACPI_DESC_TYPE_NAMED:
 340  339  
 341  340          AcpiDmDecodeNode ((ACPI_NAMESPACE_NODE *) ObjDesc);
 342  341          break;
 343  342  
 344      -
 345  343      case ACPI_DESC_TYPE_OPERAND:
 346  344  
 347  345          Type = ObjDesc->Common.Type;
 348  346          if (Type > ACPI_TYPE_LOCAL_MAX)
 349  347          {
 350  348              AcpiOsPrintf (" Type %X [Invalid Type]", (UINT32) Type);
 351  349              return;
 352  350          }
 353  351  
 354  352          /* Decode the ACPI object type */
 355  353  
 356  354          switch (ObjDesc->Common.Type)
 357  355          {
 358  356          case ACPI_TYPE_LOCAL_REFERENCE:
 359  357  
 360  358              AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (ObjDesc));
 361  359  
 362  360              /* Decode the refererence */
 363  361  
 364  362              switch (ObjDesc->Reference.Class)
 365  363              {
 366  364              case ACPI_REFCLASS_LOCAL:
 367  365  
  
    | ↓ open down ↓ | 13 lines elided | ↑ open up ↑ | 
 368  366                  AcpiOsPrintf ("%X ", ObjDesc->Reference.Value);
 369  367                  if (WalkState)
 370  368                  {
 371  369                      ObjDesc = WalkState->LocalVariables
 372  370                                  [ObjDesc->Reference.Value].Object;
 373  371                      AcpiOsPrintf ("%p", ObjDesc);
 374  372                      AcpiDmDecodeInternalObject (ObjDesc);
 375  373                  }
 376  374                  break;
 377  375  
 378      -
 379  376              case ACPI_REFCLASS_ARG:
 380  377  
 381  378                  AcpiOsPrintf ("%X ", ObjDesc->Reference.Value);
 382  379                  if (WalkState)
 383  380                  {
 384  381                      ObjDesc = WalkState->Arguments
 385  382                                  [ObjDesc->Reference.Value].Object;
 386  383                      AcpiOsPrintf ("%p", ObjDesc);
 387  384                      AcpiDmDecodeInternalObject (ObjDesc);
 388  385                  }
 389  386                  break;
 390  387  
 391      -
 392  388              case ACPI_REFCLASS_INDEX:
 393  389  
 394  390                  switch (ObjDesc->Reference.TargetType)
 395  391                  {
 396  392                  case ACPI_TYPE_BUFFER_FIELD:
 397  393  
 398  394                      AcpiOsPrintf ("%p", ObjDesc->Reference.Object);
 399  395                      AcpiDmDecodeInternalObject (ObjDesc->Reference.Object);
 400  396                      break;
 401  397  
 402  398                  case ACPI_TYPE_PACKAGE:
 403  399  
 404  400                      AcpiOsPrintf ("%p", ObjDesc->Reference.Where);
 405  401                      if (!ObjDesc->Reference.Where)
 406  402                      {
 407  403                          AcpiOsPrintf (" Uninitialized WHERE pointer");
 408  404                      }
 409  405                      else
 410  406                      {
 411  407                          AcpiDmDecodeInternalObject (
 412  408                              *(ObjDesc->Reference.Where));
  
    | ↓ open down ↓ | 11 lines elided | ↑ open up ↑ | 
 413  409                      }
 414  410                      break;
 415  411  
 416  412                  default:
 417  413  
 418  414                      AcpiOsPrintf ("Unknown index target type");
 419  415                      break;
 420  416                  }
 421  417                  break;
 422  418  
 423      -
 424  419              case ACPI_REFCLASS_REFOF:
 425  420  
 426  421                  if (!ObjDesc->Reference.Object)
 427  422                  {
 428  423                      AcpiOsPrintf ("Uninitialized reference subobject pointer");
 429  424                      break;
 430  425                  }
 431  426  
 432  427                  /* Reference can be to a Node or an Operand object */
 433  428  
 434  429                  switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc->Reference.Object))
 435  430                  {
 436  431                  case ACPI_DESC_TYPE_NAMED:
 437  432                      AcpiDmDecodeNode (ObjDesc->Reference.Object);
 438  433                      break;
  
    | ↓ open down ↓ | 5 lines elided | ↑ open up ↑ | 
 439  434  
 440  435                  case ACPI_DESC_TYPE_OPERAND:
 441  436                      AcpiDmDecodeInternalObject (ObjDesc->Reference.Object);
 442  437                      break;
 443  438  
 444  439                  default:
 445  440                      break;
 446  441                  }
 447  442                  break;
 448  443  
 449      -
 450  444              case ACPI_REFCLASS_NAME:
 451  445  
 452  446                  AcpiDmDecodeNode (ObjDesc->Reference.Node);
 453  447                  break;
 454  448  
 455      -
 456  449              case ACPI_REFCLASS_DEBUG:
 457  450              case ACPI_REFCLASS_TABLE:
 458  451  
 459  452                  AcpiOsPrintf ("\n");
 460  453                  break;
 461  454  
 462      -
 463  455              default:    /* Unknown reference class */
 464  456  
 465  457                  AcpiOsPrintf ("%2.2X\n", ObjDesc->Reference.Class);
 466  458                  break;
 467  459              }
 468  460              break;
 469  461  
 470      -
 471  462          default:
 472  463  
 473  464              AcpiOsPrintf ("<Obj>            ");
 474  465              AcpiDmDecodeInternalObject (ObjDesc);
 475  466              break;
 476  467          }
 477  468          break;
 478  469  
 479      -
 480  470      default:
 481  471  
 482  472          AcpiOsPrintf ("<Not a valid ACPI Object Descriptor> [%s]",
 483  473              AcpiUtGetDescriptorName (ObjDesc));
 484  474          break;
 485  475      }
 486  476  
 487  477      AcpiOsPrintf ("\n");
 488  478  }
 489  479  
 490  480  
 491  481  /*******************************************************************************
 492  482   *
 493  483   * FUNCTION:    AcpiDmDisplayLocals
 494  484   *
 495  485   * PARAMETERS:  WalkState       - State for current method
 496  486   *
 497  487   * RETURN:      None
 498  488   *
 499  489   * DESCRIPTION: Display all locals for the currently running control method
 500  490   *
 501  491   ******************************************************************************/
 502  492  
 503  493  void
 504  494  AcpiDmDisplayLocals (
 505  495      ACPI_WALK_STATE         *WalkState)
 506  496  {
 507  497      UINT32                  i;
 508  498      ACPI_OPERAND_OBJECT     *ObjDesc;
 509  499      ACPI_NAMESPACE_NODE     *Node;
 510  500  
 511  501  
 512  502      ObjDesc = WalkState->MethodDesc;
 513  503      Node    = WalkState->MethodNode;
 514  504      if (!Node)
 515  505      {
 516  506          AcpiOsPrintf (
 517  507              "No method node (Executing subtree for buffer or opregion)\n");
 518  508          return;
 519  509      }
 520  510  
 521  511      if (Node->Type != ACPI_TYPE_METHOD)
 522  512      {
 523  513          AcpiOsPrintf ("Executing subtree for Buffer/Package/Region\n");
 524  514          return;
 525  515      }
 526  516  
 527  517      AcpiOsPrintf ("Local Variables for method [%4.4s]:\n",
 528  518              AcpiUtGetNodeName (Node));
 529  519  
 530  520      for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++)
 531  521      {
 532  522          ObjDesc = WalkState->LocalVariables[i].Object;
 533  523          AcpiOsPrintf ("    Local%X: ", i);
 534  524          AcpiDmDisplayInternalObject (ObjDesc, WalkState);
 535  525      }
 536  526  }
 537  527  
 538  528  
 539  529  /*******************************************************************************
 540  530   *
 541  531   * FUNCTION:    AcpiDmDisplayArguments
 542  532   *
 543  533   * PARAMETERS:  WalkState       - State for current method
 544  534   *
 545  535   * RETURN:      None
 546  536   *
 547  537   * DESCRIPTION: Display all arguments for the currently running control method
 548  538   *
 549  539   ******************************************************************************/
 550  540  
 551  541  void
 552  542  AcpiDmDisplayArguments (
 553  543      ACPI_WALK_STATE         *WalkState)
 554  544  {
 555  545      UINT32                  i;
 556  546      ACPI_OPERAND_OBJECT     *ObjDesc;
 557  547      ACPI_NAMESPACE_NODE     *Node;
 558  548  
 559  549  
 560  550      ObjDesc = WalkState->MethodDesc;
 561  551      Node    = WalkState->MethodNode;
 562  552      if (!Node)
 563  553      {
 564  554          AcpiOsPrintf (
 565  555              "No method node (Executing subtree for buffer or opregion)\n");
 566  556          return;
 567  557      }
 568  558  
 569  559      if (Node->Type != ACPI_TYPE_METHOD)
 570  560      {
 571  561          AcpiOsPrintf ("Executing subtree for Buffer/Package/Region\n");
 572  562          return;
 573  563      }
 574  564  
 575  565      AcpiOsPrintf (
 576  566          "Arguments for Method [%4.4s]:  (%X arguments defined, max concurrency = %X)\n",
 577  567          AcpiUtGetNodeName (Node), ObjDesc->Method.ParamCount, ObjDesc->Method.SyncLevel);
  
    | ↓ open down ↓ | 88 lines elided | ↑ open up ↑ | 
 578  568  
 579  569      for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++)
 580  570      {
 581  571          ObjDesc = WalkState->Arguments[i].Object;
 582  572          AcpiOsPrintf ("    Arg%u:   ", i);
 583  573          AcpiDmDisplayInternalObject (ObjDesc, WalkState);
 584  574      }
 585  575  }
 586  576  
 587  577  #endif
 588      -
 589      -
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX