Print this page
acpica-unix2-20130823
PANKOVs restructure

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/intel/io/acpica/debugger/dbmethod.c
          +++ new/usr/src/common/acpica/components/debugger/dbmethod.c
   1    1  /*******************************************************************************
   2    2   *
   3    3   * Module Name: dbmethod - Debug commands for control methods
   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 ↓ 23 lines elided ↑ open up ↑
  42   42   */
  43   43  
  44   44  
  45   45  #include "acpi.h"
  46   46  #include "accommon.h"
  47   47  #include "acdispat.h"
  48   48  #include "acnamesp.h"
  49   49  #include "acdebug.h"
  50   50  #include "acdisasm.h"
  51   51  #include "acparser.h"
       52 +#include "acpredef.h"
  52   53  
  53   54  
  54   55  #ifdef ACPI_DEBUGGER
  55   56  
  56   57  #define _COMPONENT          ACPI_CA_DEBUGGER
  57   58          ACPI_MODULE_NAME    ("dbmethod")
  58   59  
  59   60  
  60   61  /* Local prototypes */
  61   62  
↓ open down ↓ 201 lines elided ↑ open up ↑
 263  264              goto Cleanup;
 264  265          }
 265  266  
 266  267          ObjDesc = WalkState->LocalVariables[Index].Object;
 267  268  
 268  269          AcpiOsPrintf ("Local%u: ", Index);
 269  270          AcpiDmDisplayInternalObject (ObjDesc, WalkState);
 270  271          break;
 271  272  
 272  273      default:
      274 +
 273  275          break;
 274  276      }
 275  277  
 276  278  Cleanup:
 277  279      AcpiUtRemoveReference (ObjDesc);
 278  280  }
 279  281  
 280  282  
 281  283  /*******************************************************************************
 282  284   *
↓ open down ↓ 55 lines elided ↑ open up ↑
 338  340      ACPI_OPERAND_OBJECT     *ObjDesc;
 339  341      ACPI_NAMESPACE_NODE     *Method;
 340  342  
 341  343  
 342  344      Method = AcpiDbConvertToNode (Name);
 343  345      if (!Method)
 344  346      {
 345  347          return (AE_BAD_PARAMETER);
 346  348      }
 347  349  
      350 +    if (Method->Type != ACPI_TYPE_METHOD)
      351 +    {
      352 +        ACPI_ERROR ((AE_INFO, "%s (%s): Object must be a control method",
      353 +            Name, AcpiUtGetTypeName (Method->Type)));
      354 +        return (AE_BAD_PARAMETER);
      355 +    }
      356 +
 348  357      ObjDesc = Method->Object;
 349  358  
 350  359      Op = AcpiPsCreateScopeOp ();
 351  360      if (!Op)
 352  361      {
 353  362          return (AE_NO_MEMORY);
 354  363      }
 355  364  
 356  365      /* Create and initialize a new walk state */
 357  366  
 358  367      WalkState = AcpiDsCreateWalkState (0, Op, NULL, NULL);
 359  368      if (!WalkState)
 360  369      {
 361  370          return (AE_NO_MEMORY);
 362  371      }
 363  372  
 364  373      Status = AcpiDsInitAmlWalk (WalkState, Op, NULL,
 365      -                    ObjDesc->Method.AmlStart,
 366      -                    ObjDesc->Method.AmlLength, NULL, ACPI_IMODE_LOAD_PASS1);
      374 +        ObjDesc->Method.AmlStart,
      375 +        ObjDesc->Method.AmlLength, NULL, ACPI_IMODE_LOAD_PASS1);
 367  376      if (ACPI_FAILURE (Status))
 368  377      {
 369  378          return (Status);
 370  379      }
 371  380  
 372      -    /* Parse the AML */
      381 +    Status = AcpiUtAllocateOwnerId (&ObjDesc->Method.OwnerId);
      382 +    WalkState->OwnerId = ObjDesc->Method.OwnerId;
 373  383  
      384 +    /* Push start scope on scope stack and make it current */
      385 +
      386 +    Status = AcpiDsScopeStackPush (Method,
      387 +        Method->Type, WalkState);
      388 +    if (ACPI_FAILURE (Status))
      389 +    {
      390 +        return (Status);
      391 +    }
      392 +
      393 +    /* Parse the entire method AML including deferred operators */
      394 +
 374  395      WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE;
 375  396      WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE;
      397 +
 376  398      Status = AcpiPsParseAml (WalkState);
      399 +    (void) AcpiDmParseDeferredOps (Op);
 377  400  
      401 +    /* Now we can disassemble the method */
      402 +
      403 +    AcpiGbl_DbOpt_verbose = FALSE;
 378  404      AcpiDmDisassemble (NULL, Op, 0);
      405 +    AcpiGbl_DbOpt_verbose = TRUE;
      406 +
 379  407      AcpiPsDeleteParseTree (Op);
      408 +
      409 +    /* Method cleanup */
      410 +
      411 +    AcpiNsDeleteNamespaceSubtree (Method);
      412 +    AcpiNsDeleteNamespaceByOwner (ObjDesc->Method.OwnerId);
      413 +    AcpiUtReleaseOwnerId (&ObjDesc->Method.OwnerId);
 380  414      return (AE_OK);
 381  415  }
 382  416  
 383  417  
 384  418  /*******************************************************************************
 385  419   *
 386  420   * FUNCTION:    AcpiDbWalkForExecute
 387  421   *
 388  422   * PARAMETERS:  Callback from WalkNamespace
 389  423   *
↓ open down ↓ 4 lines elided ↑ open up ↑
 394  428   *
 395  429   ******************************************************************************/
 396  430  
 397  431  static ACPI_STATUS
 398  432  AcpiDbWalkForExecute (
 399  433      ACPI_HANDLE             ObjHandle,
 400  434      UINT32                  NestingLevel,
 401  435      void                    *Context,
 402  436      void                    **ReturnValue)
 403  437  {
 404      -    ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
 405      -    ACPI_EXECUTE_WALK       *Info = (ACPI_EXECUTE_WALK *) Context;
 406      -    ACPI_BUFFER             ReturnObj;
 407      -    ACPI_STATUS             Status;
 408      -    char                    *Pathname;
 409      -    UINT32                  i;
 410      -    ACPI_DEVICE_INFO        *ObjInfo;
 411      -    ACPI_OBJECT_LIST        ParamObjects;
 412      -    ACPI_OBJECT             Params[ACPI_METHOD_NUM_ARGS];
 413      -    const ACPI_PREDEFINED_INFO *Predefined;
      438 +    ACPI_NAMESPACE_NODE         *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
      439 +    ACPI_DB_EXECUTE_WALK        *Info = (ACPI_DB_EXECUTE_WALK *) Context;
      440 +    char                        *Pathname;
      441 +    const ACPI_PREDEFINED_INFO  *Predefined;
      442 +    ACPI_DEVICE_INFO            *ObjInfo;
      443 +    ACPI_OBJECT_LIST            ParamObjects;
      444 +    ACPI_OBJECT                 Params[ACPI_METHOD_NUM_ARGS];
      445 +    ACPI_OBJECT                 *ThisParam;
      446 +    ACPI_BUFFER                 ReturnObj;
      447 +    ACPI_STATUS                 Status;
      448 +    UINT16                      ArgTypeList;
      449 +    UINT8                       ArgCount;
      450 +    UINT8                       ArgType;
      451 +    UINT32                      i;
 414  452  
 415  453  
 416      -    Predefined = AcpiNsCheckForPredefinedName (Node);
      454 +    /* The name must be a predefined ACPI name */
      455 +
      456 +    Predefined = AcpiUtMatchPredefinedMethod (Node->Name.Ascii);
 417  457      if (!Predefined)
 418  458      {
 419  459          return (AE_OK);
 420  460      }
 421  461  
 422  462      if (Node->Type == ACPI_TYPE_LOCAL_SCOPE)
 423  463      {
 424  464          return (AE_OK);
 425  465      }
 426  466  
↓ open down ↓ 4 lines elided ↑ open up ↑
 431  471      }
 432  472  
 433  473      /* Get the object info for number of method parameters */
 434  474  
 435  475      Status = AcpiGetObjectInfo (ObjHandle, &ObjInfo);
 436  476      if (ACPI_FAILURE (Status))
 437  477      {
 438  478          return (Status);
 439  479      }
 440  480  
      481 +    ParamObjects.Count = 0;
 441  482      ParamObjects.Pointer = NULL;
 442      -    ParamObjects.Count   = 0;
 443  483  
 444  484      if (ObjInfo->Type == ACPI_TYPE_METHOD)
 445  485      {
 446      -        /* Setup default parameters */
      486 +        /* Setup default parameters (with proper types) */
 447  487  
 448      -        for (i = 0; i < ObjInfo->ParamCount; i++)
      488 +        ArgTypeList = Predefined->Info.ArgumentList;
      489 +        ArgCount = METHOD_GET_ARG_COUNT (ArgTypeList);
      490 +
      491 +        /*
      492 +         * Setup the ACPI-required number of arguments, regardless of what
      493 +         * the actual method defines. If there is a difference, then the
      494 +         * method is wrong and a warning will be issued during execution.
      495 +         */
      496 +        ThisParam = Params;
      497 +        for (i = 0; i < ArgCount; i++)
 449  498          {
 450      -            Params[i].Type           = ACPI_TYPE_INTEGER;
 451      -            Params[i].Integer.Value  = 1;
      499 +            ArgType = METHOD_GET_NEXT_TYPE (ArgTypeList);
      500 +            ThisParam->Type = ArgType;
      501 +
      502 +            switch (ArgType)
      503 +            {
      504 +            case ACPI_TYPE_INTEGER:
      505 +
      506 +                ThisParam->Integer.Value = 1;
      507 +                break;
      508 +
      509 +            case ACPI_TYPE_STRING:
      510 +
      511 +                ThisParam->String.Pointer = "This is the default argument string";
      512 +                ThisParam->String.Length = ACPI_STRLEN (ThisParam->String.Pointer);
      513 +                break;
      514 +
      515 +            case ACPI_TYPE_BUFFER:
      516 +
      517 +                ThisParam->Buffer.Pointer = (UINT8 *) Params; /* just a garbage buffer */
      518 +                ThisParam->Buffer.Length = 48;
      519 +                break;
      520 +
      521 +             case ACPI_TYPE_PACKAGE:
      522 +
      523 +                ThisParam->Package.Elements = NULL;
      524 +                ThisParam->Package.Count = 0;
      525 +                break;
      526 +
      527 +           default:
      528 +
      529 +                AcpiOsPrintf ("%s: Unsupported argument type: %u\n",
      530 +                    Pathname, ArgType);
      531 +                break;
      532 +            }
      533 +
      534 +            ThisParam++;
 452  535          }
 453  536  
 454      -        ParamObjects.Pointer     = Params;
 455      -        ParamObjects.Count       = ObjInfo->ParamCount;
      537 +        ParamObjects.Count = ArgCount;
      538 +        ParamObjects.Pointer = Params;
 456  539      }
 457  540  
 458  541      ACPI_FREE (ObjInfo);
 459  542      ReturnObj.Pointer = NULL;
 460  543      ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
 461  544  
 462  545      /* Do the actual method execution */
 463  546  
 464  547      AcpiGbl_MethodExecuting = TRUE;
 465  548  
↓ open down ↓ 29 lines elided ↑ open up ↑
 495  578   *
 496  579   * DESCRIPTION: Namespace batch execution. Execute predefined names in the
 497  580   *              namespace, up to the max count, if specified.
 498  581   *
 499  582   ******************************************************************************/
 500  583  
 501  584  void
 502  585  AcpiDbBatchExecute (
 503  586      char                    *CountArg)
 504  587  {
 505      -    ACPI_EXECUTE_WALK       Info;
      588 +    ACPI_DB_EXECUTE_WALK    Info;
 506  589  
 507  590  
 508  591      Info.Count = 0;
 509  592      Info.MaxCount = ACPI_UINT32_MAX;
 510  593  
 511  594      if (CountArg)
 512  595      {
 513  596          Info.MaxCount = ACPI_STRTOUL (CountArg, NULL, 0);
 514  597      }
 515  598  
 516  599  
 517  600      /* Search all nodes in namespace */
 518  601  
 519  602      (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
 520  603                  AcpiDbWalkForExecute, NULL, (void *) &Info, NULL);
 521  604  
 522      -    AcpiOsPrintf ("Executed %u predefined names in the namespace\n", Info.Count);
      605 +    AcpiOsPrintf ("Evaluated %u predefined names in the namespace\n", Info.Count);
 523  606  }
 524  607  
 525  608  #endif /* ACPI_DEBUGGER */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX