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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/intel/io/acpica/debugger/dbnames.c
          +++ new/usr/src/common/acpica/components/debugger/dbnames.c
   1    1  /*******************************************************************************
   2    2   *
   3    3   * Module Name: dbnames - Debugger commands for the acpi namespace
   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 ↓ 20 lines elided ↑ open up ↑
  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 "acdebug.h"
       49 +#include "acpredef.h"
  49   50  
  50   51  
  51   52  #ifdef ACPI_DEBUGGER
  52   53  
  53   54  #define _COMPONENT          ACPI_CA_DEBUGGER
  54   55          ACPI_MODULE_NAME    ("dbnames")
  55   56  
  56   57  
  57   58  /* Local prototypes */
  58   59  
↓ open down ↓ 36 lines elided ↑ open up ↑
  95   96  AcpiDbBusWalk (
  96   97      ACPI_HANDLE             ObjHandle,
  97   98      UINT32                  NestingLevel,
  98   99      void                    *Context,
  99  100      void                    **ReturnValue);
 100  101  
 101  102  /*
 102  103   * Arguments for the Objects command
 103  104   * These object types map directly to the ACPI_TYPES
 104  105   */
 105      -static ARGUMENT_INFO        AcpiDbObjectTypes [] =
      106 +static ACPI_DB_ARGUMENT_INFO    AcpiDbObjectTypes [] =
 106  107  {
 107  108      {"ANY"},
 108  109      {"INTEGERS"},
 109  110      {"STRINGS"},
 110  111      {"BUFFERS"},
 111  112      {"PACKAGES"},
 112  113      {"FIELDS"},
 113  114      {"DEVICES"},
 114  115      {"EVENTS"},
 115  116      {"METHODS"},
↓ open down ↓ 36 lines elided ↑ open up ↑
 152  153  
 153  154  
 154  155      if (!Name || Name[0] == 0)
 155  156      {
 156  157          AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf);
 157  158          return;
 158  159      }
 159  160  
 160  161      AcpiDbPrepNamestring (Name);
 161  162  
 162      -    if (Name[0] == '\\')
      163 +    if (ACPI_IS_ROOT_PREFIX (Name[0]))
 163  164      {
 164  165          /* Validate new scope from the root */
 165  166  
 166  167          Status = AcpiNsGetNode (AcpiGbl_RootNode, Name, ACPI_NS_NO_UPSEARCH,
 167  168                      &Node);
 168  169          if (ACPI_FAILURE (Status))
 169  170          {
 170  171              goto ErrorExit;
 171  172          }
 172  173  
 173      -        ACPI_STRCPY (AcpiGbl_DbScopeBuf, Name);
 174      -        ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
      174 +        AcpiGbl_DbScopeBuf[0] = 0;
 175  175      }
 176  176      else
 177  177      {
 178  178          /* Validate new scope relative to old scope */
 179  179  
 180  180          Status = AcpiNsGetNode (AcpiGbl_DbScopeNode, Name, ACPI_NS_NO_UPSEARCH,
 181  181                      &Node);
 182  182          if (ACPI_FAILURE (Status))
 183  183          {
 184  184              goto ErrorExit;
 185  185          }
      186 +    }
 186  187  
 187      -        ACPI_STRCAT (AcpiGbl_DbScopeBuf, Name);
 188      -        ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
      188 +    /* Build the final pathname */
      189 +
      190 +    if (AcpiUtSafeStrcat (AcpiGbl_DbScopeBuf, sizeof (AcpiGbl_DbScopeBuf),
      191 +        Name))
      192 +    {
      193 +        Status = AE_BUFFER_OVERFLOW;
      194 +        goto ErrorExit;
 189  195      }
 190  196  
      197 +    if (AcpiUtSafeStrcat (AcpiGbl_DbScopeBuf, sizeof (AcpiGbl_DbScopeBuf),
      198 +        "\\"))
      199 +    {
      200 +        Status = AE_BUFFER_OVERFLOW;
      201 +        goto ErrorExit;
      202 +    }
      203 +
 191  204      AcpiGbl_DbScopeNode = Node;
 192  205      AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf);
 193  206      return;
 194  207  
 195  208  ErrorExit:
 196  209  
 197  210      AcpiOsPrintf ("Could not attach scope: %s, %s\n",
 198  211          Name, AcpiFormatException (Status));
 199  212  }
 200  213  
 201  214  
 202  215  /*******************************************************************************
 203  216   *
 204  217   * FUNCTION:    AcpiDbDumpNamespace
 205  218   *
 206  219   * PARAMETERS:  StartArg        - Node to begin namespace dump
 207  220   *              DepthArg        - Maximum tree depth to be dumped
 208  221   *
 209  222   * RETURN:      None
 210  223   *
 211      - * DESCRIPTION: Dump entire namespace or a subtree.  Each node is displayed
      224 + * DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed
 212  225   *              with type and other information.
 213  226   *
 214  227   ******************************************************************************/
 215  228  
 216  229  void
 217  230  AcpiDbDumpNamespace (
 218  231      char                    *StartArg,
 219  232      char                    *DepthArg)
 220  233  {
 221  234      ACPI_HANDLE             SubtreeEntry = AcpiGbl_RootNode;
↓ open down ↓ 26 lines elided ↑ open up ↑
 248  261  
 249  262      AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
 250  263      AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth,
 251  264          ACPI_OWNER_ID_MAX, SubtreeEntry);
 252  265      AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
 253  266  }
 254  267  
 255  268  
 256  269  /*******************************************************************************
 257  270   *
      271 + * FUNCTION:    AcpiDbDumpNamespacePaths
      272 + *
      273 + * PARAMETERS:  None
      274 + *
      275 + * RETURN:      None
      276 + *
      277 + * DESCRIPTION: Dump entire namespace with full object pathnames and object
      278 + *              type information. Alternative to "namespace" command.
      279 + *
      280 + ******************************************************************************/
      281 +
      282 +void
      283 +AcpiDbDumpNamespacePaths (
      284 +    void)
      285 +{
      286 +
      287 +    AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
      288 +    AcpiOsPrintf ("ACPI Namespace (from root):\n");
      289 +
      290 +    /* Display the entire namespace */
      291 +
      292 +    AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
      293 +    AcpiNsDumpObjectPaths (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY,
      294 +        ACPI_UINT32_MAX, ACPI_OWNER_ID_MAX, AcpiGbl_RootNode);
      295 +
      296 +    AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
      297 +}
      298 +
      299 +
      300 +/*******************************************************************************
      301 + *
 258  302   * FUNCTION:    AcpiDbDumpNamespaceByOwner
 259  303   *
 260  304   * PARAMETERS:  OwnerArg        - Owner ID whose nodes will be displayed
 261  305   *              DepthArg        - Maximum tree depth to be dumped
 262  306   *
 263  307   * RETURN:      None
 264  308   *
 265  309   * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId.
 266  310   *
 267  311   ******************************************************************************/
↓ open down ↓ 30 lines elided ↑ open up ↑
 298  342  
 299  343  
 300  344  /*******************************************************************************
 301  345   *
 302  346   * FUNCTION:    AcpiDbWalkAndMatchName
 303  347   *
 304  348   * PARAMETERS:  Callback from WalkNamespace
 305  349   *
 306  350   * RETURN:      Status
 307  351   *
 308      - * DESCRIPTION: Find a particular name/names within the namespace.  Wildcards
      352 + * DESCRIPTION: Find a particular name/names within the namespace. Wildcards
 309  353   *              are supported -- '?' matches any character.
 310  354   *
 311  355   ******************************************************************************/
 312  356  
 313  357  static ACPI_STATUS
 314  358  AcpiDbWalkAndMatchName (
 315  359      ACPI_HANDLE             ObjHandle,
 316  360      UINT32                  NestingLevel,
 317  361      void                    *Context,
 318  362      void                    **ReturnValue)
↓ open down ↓ 108 lines elided ↑ open up ↑
 427  471      ACPI_HANDLE             ObjHandle,
 428  472      UINT32                  NestingLevel,
 429  473      void                    *Context,
 430  474      void                    **ReturnValue)
 431  475  {
 432  476      ACPI_NAMESPACE_NODE         *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
 433  477      UINT32                      *Count = (UINT32 *) Context;
 434  478      const ACPI_PREDEFINED_INFO  *Predefined;
 435  479      const ACPI_PREDEFINED_INFO  *Package = NULL;
 436  480      char                        *Pathname;
      481 +    char                        StringBuffer[48];
 437  482  
 438  483  
 439      -    Predefined = AcpiNsCheckForPredefinedName (Node);
      484 +    Predefined = AcpiUtMatchPredefinedMethod (Node->Name.Ascii);
 440  485      if (!Predefined)
 441  486      {
 442  487          return (AE_OK);
 443  488      }
 444  489  
 445  490      Pathname = AcpiNsGetExternalPathname (Node);
 446  491      if (!Pathname)
 447  492      {
 448  493          return (AE_OK);
 449  494      }
 450  495  
 451  496      /* If method returns a package, the info is in the next table entry */
 452  497  
 453      -    if (Predefined->Info.ExpectedBtypes & ACPI_BTYPE_PACKAGE)
      498 +    if (Predefined->Info.ExpectedBtypes & ACPI_RTYPE_PACKAGE)
 454  499      {
 455  500          Package = Predefined + 1;
 456  501      }
 457  502  
 458      -    AcpiOsPrintf ("%-32s arg %X ret %2.2X", Pathname,
 459      -        Predefined->Info.ParamCount, Predefined->Info.ExpectedBtypes);
      503 +    AcpiUtGetExpectedReturnTypes (StringBuffer,
      504 +        Predefined->Info.ExpectedBtypes);
 460  505  
      506 +    AcpiOsPrintf ("%-32s Arguments %X, Return Types: %s", Pathname,
      507 +        METHOD_GET_ARG_COUNT (Predefined->Info.ArgumentList),
      508 +        StringBuffer);
      509 +
 461  510      if (Package)
 462  511      {
 463      -        AcpiOsPrintf (" PkgType %2.2X ObjType %2.2X Count %2.2X",
      512 +        AcpiOsPrintf (" (PkgType %2.2X, ObjType %2.2X, Count %2.2X)",
 464  513              Package->RetInfo.Type, Package->RetInfo.ObjectType1,
 465  514              Package->RetInfo.Count1);
 466  515      }
 467  516  
 468  517      AcpiOsPrintf("\n");
 469  518  
 470      -    AcpiNsCheckParameterCount (Pathname, Node, ACPI_UINT32_MAX, Predefined);
      519 +    /* Check that the declared argument count matches the ACPI spec */
      520 +
      521 +    AcpiNsCheckAcpiCompliance (Pathname, Node, Predefined);
      522 +
 471  523      ACPI_FREE (Pathname);
 472  524      (*Count)++;
 473      -
 474  525      return (AE_OK);
 475  526  }
 476  527  
 477  528  
 478  529  /*******************************************************************************
 479  530   *
 480  531   * FUNCTION:    AcpiDbCheckPredefinedNames
 481  532   *
 482  533   * PARAMETERS:  None
 483  534   *
↓ open down ↓ 172 lines elided ↑ open up ↑
 656  707          }
 657  708      }
 658  709  
 659  710      if (Node->Type > ACPI_TYPE_LOCAL_MAX)
 660  711      {
 661  712          AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n",
 662  713              Node, Node->Type);
 663  714          return (AE_OK);
 664  715      }
 665  716  
 666      -    if (!AcpiUtValidAcpiName (Node->Name.Integer))
      717 +    if (!AcpiUtValidAcpiName (Node->Name.Ascii))
 667  718      {
 668  719          AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node);
 669  720          return (AE_OK);
 670  721      }
 671  722  
 672  723      Object = AcpiNsGetAttachedObject (Node);
 673  724      if (Object)
 674  725      {
 675  726          Info->Objects++;
 676  727          if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
↓ open down ↓ 91 lines elided ↑ open up ↑
 768  819   *
 769  820   * DESCRIPTION: Search namespace for all references to the input object
 770  821   *
 771  822   ******************************************************************************/
 772  823  
 773  824  void
 774  825  AcpiDbFindReferences (
 775  826      char                    *ObjectArg)
 776  827  {
 777  828      ACPI_OPERAND_OBJECT     *ObjDesc;
      829 +    ACPI_SIZE               Address;
 778  830  
 779  831  
 780  832      /* Convert string to object pointer */
 781  833  
 782      -    ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16));
      834 +    Address = ACPI_STRTOUL (ObjectArg, NULL, 16);
      835 +    ObjDesc = ACPI_TO_POINTER (Address);
 783  836  
 784  837      /* Search all nodes in namespace */
 785  838  
 786  839      (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
 787  840                      AcpiDbWalkForReferences, NULL, (void *) ObjDesc, NULL);
 788  841  }
 789  842  
 790  843  
 791  844  /*******************************************************************************
 792  845   *
↓ open down ↓ 142 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX