dbdisply.c revision 87031
11558Srgrimes/*******************************************************************************
21558Srgrimes *
31558Srgrimes * Module Name: dbdisply - debug display commands
41558Srgrimes *              $Revision: 60 $
51558Srgrimes *
61558Srgrimes ******************************************************************************/
71558Srgrimes
81558Srgrimes/******************************************************************************
91558Srgrimes *
101558Srgrimes * 1. Copyright Notice
111558Srgrimes *
121558Srgrimes * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
131558Srgrimes * All rights reserved.
141558Srgrimes *
151558Srgrimes * 2. License
161558Srgrimes *
171558Srgrimes * 2.1. This is your license from Intel Corp. under its intellectual property
181558Srgrimes * rights.  You may have additional license terms from the party that provided
191558Srgrimes * you this software, covering your right to use that party's intellectual
201558Srgrimes * property rights.
211558Srgrimes *
221558Srgrimes * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
231558Srgrimes * copy of the source code appearing in this file ("Covered Code") an
241558Srgrimes * irrevocable, perpetual, worldwide license under Intel's copyrights in the
251558Srgrimes * base code distributed originally by Intel ("Original Intel Code") to copy,
261558Srgrimes * make derivatives, distribute, use and display any portion of the Covered
271558Srgrimes * Code in any form, with the right to sublicense such rights; and
281558Srgrimes *
291558Srgrimes * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
301558Srgrimes * license (with the right to sublicense), under only those claims of Intel
311558Srgrimes * patents that are infringed by the Original Intel Code, to make, use, sell,
321558Srgrimes * offer to sell, and import the Covered Code and derivative works thereof
331558Srgrimes * solely to the minimum extent necessary to exercise the above copyright
341558Srgrimes * license, and in no event shall the patent license extend to any additions
3538040Scharnier * to or modifications of the Original Intel Code.  No other license or right
361558Srgrimes * is granted directly or by implication, estoppel or otherwise;
371558Srgrimes *
381558Srgrimes * The above copyright and patent license is granted only if the following
391558Srgrimes * conditions are met:
401558Srgrimes *
4138040Scharnier * 3. Conditions
421558Srgrimes *
4338040Scharnier * 3.1. Redistribution of Source with Rights to Further Distribute Source.
4438040Scharnier * Redistribution of source code of any substantial portion of the Covered
4542873Sluoqi * Code or modification with rights to further distribute source must include
461558Srgrimes * the above Copyright Notice, the above License, this list of Conditions,
471558Srgrimes * and the following Disclaimer and Export Compliance provision.  In addition,
481558Srgrimes * Licensee must cause all Covered Code to which Licensee contributes to
491558Srgrimes * contain a file documenting the changes Licensee made to create that Covered
501558Srgrimes * Code and the date of any change.  Licensee must include in that file the
511558Srgrimes * documentation of any changes made by any predecessor Licensee.  Licensee
5242873Sluoqi * must include a prominent statement that the modification is derived,
531558Srgrimes * directly or indirectly, from Original Intel Code.
541558Srgrimes *
551558Srgrimes * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
5642873Sluoqi * Redistribution of source code of any substantial portion of the Covered
571558Srgrimes * Code or modification without rights to further distribute source must
581558Srgrimes * include the following Disclaimer and Export Compliance provision in the
591558Srgrimes * documentation and/or other materials provided with distribution.  In
601558Srgrimes * addition, Licensee may not authorize further sublicense of source of any
6138040Scharnier * portion of the Covered Code, and must include terms to the effect that the
621558Srgrimes * license from Licensee to its licensee is limited to the intellectual
631558Srgrimes * property embodied in the software Licensee provides to its licensee, and
6442873Sluoqi * not to intellectual property embodied in modifications its licensee may
651558Srgrimes * make.
661558Srgrimes *
671558Srgrimes * 3.3. Redistribution of Executable. Redistribution in executable form of any
681558Srgrimes * substantial portion of the Covered Code or modification must reproduce the
691558Srgrimes * above Copyright Notice, and the following Disclaimer and Export Compliance
701558Srgrimes * provision in the documentation and/or other materials provided with the
711558Srgrimes * distribution.
721558Srgrimes *
731558Srgrimes * 3.4. Intel retains all right, title, and interest in and to the Original
741558Srgrimes * Intel Code.
751558Srgrimes *
761558Srgrimes * 3.5. Neither the name Intel nor any other trademark owned or controlled by
771558Srgrimes * Intel shall be used in advertising or otherwise to promote the sale, use or
781558Srgrimes * other dealings in products derived from or relating to the Covered Code
791558Srgrimes * without prior written authorization from Intel.
801558Srgrimes *
811558Srgrimes * 4. Disclaimer and Export Compliance
821558Srgrimes *
839315Sjoerg * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
8442873Sluoqi * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
851558Srgrimes * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
861558Srgrimes * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
871558Srgrimes * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
881558Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
891558Srgrimes * PARTICULAR PURPOSE.
901558Srgrimes *
9134266Sjulian * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
921558Srgrimes * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
931558Srgrimes * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
9442873Sluoqi * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
951558Srgrimes * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
961558Srgrimes * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
9742873Sluoqi * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
9842873Sluoqi * LIMITED REMEDY.
991558Srgrimes *
1008871Srgrimes * 4.3. Licensee shall not export, either directly or indirectly, any of this
1011558Srgrimes * software or system incorporating such software without first obtaining any
1021558Srgrimes * required license or other approval from the U. S. Department of Commerce or
1031558Srgrimes * any other agency or department of the United States Government.  In the
1041558Srgrimes * event Licensee exports any such software from the United States or
10542873Sluoqi * re-exports any such software from a foreign destination, Licensee shall
10642873Sluoqi * ensure that the distribution and export/re-export of the software is in
10742873Sluoqi * compliance with all laws, regulations, orders, or other restrictions of the
10842873Sluoqi * U.S. Export Administration Regulations. Licensee agrees that neither it nor
10942873Sluoqi * any of its subsidiaries will export/re-export any technical data, process,
11042873Sluoqi * software, or service, directly or indirectly, to any country for which the
11142873Sluoqi * United States government or any agency thereof requires an export license,
11242873Sluoqi * other governmental approval, or letter of assurance, without first obtaining
11342873Sluoqi * such license, approval or letter.
11442873Sluoqi *
1151558Srgrimes *****************************************************************************/
1161558Srgrimes
1171558Srgrimes
1181558Srgrimes#include "acpi.h"
1191558Srgrimes#include "acparser.h"
1201558Srgrimes#include "amlcode.h"
1211558Srgrimes#include "acdispat.h"
1221558Srgrimes#include "acnamesp.h"
1231558Srgrimes#include "acparser.h"
1241558Srgrimes#include "acevents.h"
1251558Srgrimes#include "acinterp.h"
1261558Srgrimes#include "acdebug.h"
1271558Srgrimes
1281558Srgrimes
1291558Srgrimes#ifdef ENABLE_DEBUGGER
1301558Srgrimes
1311558Srgrimes
1321558Srgrimes#define _COMPONENT          ACPI_DEBUGGER
1331558Srgrimes        MODULE_NAME         ("dbdisply")
1341558Srgrimes
1351558Srgrimes
1361558Srgrimes/******************************************************************************
1371558Srgrimes *
1389315Sjoerg * FUNCTION:    AcpiDbGetPointer
1399315Sjoerg *
1409315Sjoerg * PARAMETERS:  Target          - Pointer to string to be converted
1419315Sjoerg *
1421558Srgrimes * RETURN:      Converted pointer
1431558Srgrimes *
1441558Srgrimes * DESCRIPTION: Convert an ascii pointer value to a real value
1451558Srgrimes *
1461558Srgrimes *****************************************************************************/
1471558Srgrimes
1481558Srgrimesvoid *
1491558SrgrimesAcpiDbGetPointer (
1501558Srgrimes    void                    *Target)
1511558Srgrimes{
1521558Srgrimes    void                    *ObjPtr;
1531558Srgrimes
1541558Srgrimes
1551558Srgrimes#ifdef _IA16
1561558Srgrimes#include <stdio.h>
1571558Srgrimes
1581558Srgrimes    /* Have to handle 16-bit pointers of the form segment:offset */
1591558Srgrimes
1601558Srgrimes    if (!sscanf (Target, "%p", &ObjPtr))
1611558Srgrimes    {
1621558Srgrimes        AcpiOsPrintf ("Invalid pointer: %s\n", Target);
1631558Srgrimes        return (NULL);
1641558Srgrimes    }
1651558Srgrimes
1661558Srgrimes#else
1671558Srgrimes
1681558Srgrimes    /* Simple flat pointer */
1691558Srgrimes
1701558Srgrimes    ObjPtr = (void *) STRTOUL (Target, NULL, 16);
1711558Srgrimes#endif
1721558Srgrimes
1731558Srgrimes    return (ObjPtr);
1741558Srgrimes}
1751558Srgrimes
1761558Srgrimes
1771558Srgrimes/*******************************************************************************
1781558Srgrimes *
1791558Srgrimes * FUNCTION:    AcpiDbDumpParserDescriptor
1801558Srgrimes *
1811558Srgrimes * PARAMETERS:  Op              - A parser Op descriptor
1821558Srgrimes *
1831558Srgrimes * RETURN:      None
1841558Srgrimes *
1851558Srgrimes * DESCRIPTION: Display a formatted parser object
1861558Srgrimes *
1871558Srgrimes ******************************************************************************/
1881558Srgrimes
1891558Srgrimesvoid
1901558SrgrimesAcpiDbDumpParserDescriptor (
1911558Srgrimes    ACPI_PARSE_OBJECT       *Op)
1921558Srgrimes{
1931558Srgrimes    const ACPI_OPCODE_INFO  *Info;
1941558Srgrimes
1951558Srgrimes
1961558Srgrimes    Info = AcpiPsGetOpcodeInfo (Op->Opcode);
1971558Srgrimes
1981558Srgrimes    AcpiOsPrintf ("Parser Op Descriptor:\n");
1991558Srgrimes    AcpiOsPrintf ("%20.20s : %4.4X\n", "Opcode", Op->Opcode);
2001558Srgrimes
2011558Srgrimes    DEBUG_ONLY_MEMBERS (AcpiOsPrintf ("%20.20s : %s\n", "Opcode Name", Info->Name));
20234266Sjulian
20334266Sjulian    AcpiOsPrintf ("%20.20s : %p\n", "Value/ArgList", Op->Value);
20434266Sjulian    AcpiOsPrintf ("%20.20s : %p\n", "Parent", Op->Parent);
20534266Sjulian    AcpiOsPrintf ("%20.20s : %p\n", "NextOp", Op->Next);
20634266Sjulian}
20734266Sjulian
20834266Sjulian
20934266Sjulian/*******************************************************************************
21034266Sjulian *
21134266Sjulian * FUNCTION:    AcpiDbDecodeAndDisplayObject
21234266Sjulian *
21334266Sjulian * PARAMETERS:  Target          - String with object to be displayed.  Names
21434266Sjulian *                                and hex pointers are supported.
21534266Sjulian *              OutputType      - Byte, Word, Dword, or Qword (B|W|D|Q)
21634266Sjulian *
21734266Sjulian * RETURN:      None
21834266Sjulian *
21934266Sjulian * DESCRIPTION: Display a formatted ACPI object
2201558Srgrimes *
2211558Srgrimes ******************************************************************************/
2221558Srgrimes
2231558Srgrimesvoid
2241558SrgrimesAcpiDbDecodeAndDisplayObject (
2251558Srgrimes    NATIVE_CHAR             *Target,
2261558Srgrimes    NATIVE_CHAR             *OutputType)
2271558Srgrimes{
2281558Srgrimes    void                    *ObjPtr;
2291558Srgrimes    ACPI_NAMESPACE_NODE     *Node;
2301558Srgrimes    ACPI_OPERAND_OBJECT     *ObjDesc;
2311558Srgrimes    UINT32                  Display = DB_BYTE_DISPLAY;
2321558Srgrimes    NATIVE_CHAR             Buffer[80];
2331558Srgrimes    ACPI_BUFFER             RetBuf;
2341558Srgrimes    ACPI_STATUS             Status;
2351558Srgrimes    UINT32                  Size;
2361558Srgrimes
2371558Srgrimes
2381558Srgrimes    if (!Target)
2391558Srgrimes    {
2401558Srgrimes        return;
2411558Srgrimes    }
2421558Srgrimes
2431558Srgrimes    /* Decode the output type */
2441558Srgrimes
2451558Srgrimes    if (OutputType)
2461558Srgrimes    {
2471558Srgrimes        STRUPR (OutputType);
2481558Srgrimes        if (OutputType[0] == 'W')
2491558Srgrimes        {
2501558Srgrimes            Display = DB_WORD_DISPLAY;
2511558Srgrimes        }
2521558Srgrimes        else if (OutputType[0] == 'D')
2531558Srgrimes        {
2541558Srgrimes            Display = DB_DWORD_DISPLAY;
2551558Srgrimes        }
2561558Srgrimes        else if (OutputType[0] == 'Q')
2571558Srgrimes        {
2581558Srgrimes            Display = DB_QWORD_DISPLAY;
2591558Srgrimes        }
2601558Srgrimes    }
2611558Srgrimes
26242873Sluoqi    RetBuf.Length = sizeof (Buffer);
26342873Sluoqi    RetBuf.Pointer = Buffer;
26442873Sluoqi
26542873Sluoqi    /* Differentiate between a number and a name */
26642873Sluoqi
26742873Sluoqi    if ((Target[0] >= 0x30) && (Target[0] <= 0x39))
26842873Sluoqi    {
2691558Srgrimes        ObjPtr = AcpiDbGetPointer (Target);
2701558Srgrimes        if (!AcpiOsReadable (ObjPtr, 16))
2711558Srgrimes        {
2721558Srgrimes            AcpiOsPrintf ("Address %p is invalid in this address space\n", ObjPtr);
2731558Srgrimes            return;
2741558Srgrimes        }
27538040Scharnier
27638040Scharnier        /* Decode the object type */
27738040Scharnier
27838040Scharnier        if (VALID_DESCRIPTOR_TYPE ((ObjPtr), ACPI_DESC_TYPE_NAMED))
2791558Srgrimes        {
2801558Srgrimes            /* This is a Node */
2811558Srgrimes
2821558Srgrimes            if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_NAMESPACE_NODE)))
2831558Srgrimes            {
2841558Srgrimes                AcpiOsPrintf ("Cannot read entire Named object at address %p\n", ObjPtr);
2851558Srgrimes                return;
2861558Srgrimes            }
2871558Srgrimes
2881558Srgrimes            Node = ObjPtr;
2891558Srgrimes            goto DumpNte;
2901558Srgrimes        }
2911558Srgrimes
2921558Srgrimes        else if (VALID_DESCRIPTOR_TYPE ((ObjPtr), ACPI_DESC_TYPE_INTERNAL))
2931558Srgrimes        {
2941558Srgrimes            /* This is an ACPI OBJECT */
2951558Srgrimes
2961558Srgrimes            if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_OPERAND_OBJECT)))
2971558Srgrimes            {
2981558Srgrimes                AcpiOsPrintf ("Cannot read entire ACPI object at address %p\n", ObjPtr);
2999315Sjoerg                return;
3009315Sjoerg            }
30134266Sjulian
30234266Sjulian            AcpiUtDumpBuffer (ObjPtr, sizeof (ACPI_OPERAND_OBJECT), Display, ACPI_UINT32_MAX);
3039315Sjoerg            AcpiExDumpObjectDescriptor (ObjPtr, 1);
3049315Sjoerg        }
3059315Sjoerg
3069315Sjoerg        else if (VALID_DESCRIPTOR_TYPE ((ObjPtr), ACPI_DESC_TYPE_PARSER))
3079315Sjoerg        {
3089315Sjoerg            /* This is an Parser Op object */
3099315Sjoerg
3109315Sjoerg            if (!AcpiOsReadable (ObjPtr, sizeof (ACPI_PARSE_OBJECT)))
3119315Sjoerg            {
3129315Sjoerg                AcpiOsPrintf ("Cannot read entire Parser object at address %p\n", ObjPtr);
3139315Sjoerg                return;
3149315Sjoerg            }
3159315Sjoerg
3169315Sjoerg            AcpiUtDumpBuffer (ObjPtr, sizeof (ACPI_PARSE_OBJECT), Display, ACPI_UINT32_MAX);
3179315Sjoerg            AcpiDbDumpParserDescriptor ((ACPI_PARSE_OBJECT *) ObjPtr);
3189315Sjoerg        }
3199315Sjoerg
3209315Sjoerg        else
3219315Sjoerg        {
3221558Srgrimes            Size = 16;
3231558Srgrimes            if (AcpiOsReadable (ObjPtr, 64))
3241558Srgrimes            {
3251558Srgrimes                Size = 64;
3261558Srgrimes            }
3271558Srgrimes
3281558Srgrimes            /* Just dump some memory */
3291558Srgrimes
3301558Srgrimes            AcpiUtDumpBuffer (ObjPtr, Size, Display, ACPI_UINT32_MAX);
3311558Srgrimes        }
3321558Srgrimes
3331558Srgrimes        return;
3341558Srgrimes    }
3351558Srgrimes
3361558Srgrimes
3371558Srgrimes    /* The parameter is a name string that must be resolved to a Named obj */
3381558Srgrimes
3391558Srgrimes    Node = AcpiDbLocalNsLookup (Target);
3401558Srgrimes    if (!Node)
3411558Srgrimes    {
3421558Srgrimes        return;
3431558Srgrimes    }
3441558Srgrimes
3451558Srgrimes
3461558SrgrimesDumpNte:
3471558Srgrimes    /* Now dump the Named obj */
3481558Srgrimes
3491558Srgrimes    Status = AcpiGetName (Node, ACPI_FULL_PATHNAME, &RetBuf);
3501558Srgrimes    if (ACPI_FAILURE (Status))
35142873Sluoqi    {
35242873Sluoqi        AcpiOsPrintf ("Could not convert name to pathname\n");
35342873Sluoqi    }
35442873Sluoqi
35542873Sluoqi    else
35642873Sluoqi    {
35742873Sluoqi        AcpiOsPrintf ("Object (%p) Pathname:  %s\n", Node, RetBuf.Pointer);
35842873Sluoqi    }
35942873Sluoqi
36042873Sluoqi    if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE)))
36142873Sluoqi    {
36242873Sluoqi        AcpiOsPrintf ("Invalid Named object at address %p\n", Node);
36342873Sluoqi        return;
36442873Sluoqi    }
36542873Sluoqi
36642873Sluoqi    AcpiUtDumpBuffer ((void *) Node, sizeof (ACPI_NAMESPACE_NODE), Display, ACPI_UINT32_MAX);
36742873Sluoqi    AcpiExDumpNode (Node, 1);
36842873Sluoqi
36942873Sluoqi    ObjDesc = AcpiNsGetAttachedObject (Node);
37042873Sluoqi    if (ObjDesc)
37142873Sluoqi    {
37242873Sluoqi        AcpiOsPrintf ("\nAttached Object (%p):\n", ObjDesc);
373        if (!AcpiOsReadable (ObjDesc, sizeof (ACPI_OPERAND_OBJECT)))
374        {
375            AcpiOsPrintf ("Invalid internal ACPI Object at address %p\n", ObjDesc);
376            return;
377        }
378
379        AcpiUtDumpBuffer ((void *) ObjDesc, sizeof (ACPI_OPERAND_OBJECT), Display, ACPI_UINT32_MAX);
380        AcpiExDumpObjectDescriptor (ObjDesc, 1);
381    }
382}
383
384
385/*******************************************************************************
386 *
387 * FUNCTION:    AcpiDbDecodeInternalObject
388 *
389 * PARAMETERS:  ObjDesc         - Object to be displayed
390 *
391 * RETURN:      None
392 *
393 * DESCRIPTION: Short display of an internal object.  Numbers and Strings.
394 *
395 ******************************************************************************/
396
397void
398AcpiDbDecodeInternalObject (
399    ACPI_OPERAND_OBJECT     *ObjDesc)
400{
401    UINT32                  i;
402
403
404    if (!ObjDesc)
405    {
406        return;
407    }
408
409    AcpiOsPrintf (" %s", AcpiUtGetTypeName (ObjDesc->Common.Type));
410
411    switch (ObjDesc->Common.Type)
412    {
413    case ACPI_TYPE_INTEGER:
414
415        AcpiOsPrintf (" %.8X%.8X", HIDWORD (ObjDesc->Integer.Value),
416                                   LODWORD (ObjDesc->Integer.Value));
417        break;
418
419
420    case ACPI_TYPE_STRING:
421
422        AcpiOsPrintf ("(%d) \"%.24s",
423                ObjDesc->String.Length, ObjDesc->String.Pointer);
424
425        if (ObjDesc->String.Length > 24)
426        {
427            AcpiOsPrintf ("...");
428        }
429        else
430        {
431            AcpiOsPrintf ("\"");
432        }
433        break;
434
435
436    case ACPI_TYPE_BUFFER:
437
438        AcpiOsPrintf ("(%d)", ObjDesc->Buffer.Length);
439        for (i = 0; (i < 8) && (i < ObjDesc->Buffer.Length); i++)
440        {
441            AcpiOsPrintf (" %2.2X", ObjDesc->Buffer.Pointer[i]);
442        }
443        break;
444    }
445}
446
447
448/*******************************************************************************
449 *
450 * FUNCTION:    AcpiDbDisplayInternalObject
451 *
452 * PARAMETERS:  ObjDesc         - Object to be displayed
453 *              WalkState       - Current walk state
454 *
455 * RETURN:      None
456 *
457 * DESCRIPTION: Short display of an internal object
458 *
459 ******************************************************************************/
460
461void
462AcpiDbDisplayInternalObject (
463    ACPI_OPERAND_OBJECT     *ObjDesc,
464    ACPI_WALK_STATE         *WalkState)
465{
466    UINT8                   Type;
467
468
469    AcpiOsPrintf ("%p ", ObjDesc);
470
471    if (!ObjDesc)
472    {
473        AcpiOsPrintf ("<NullObj>\n");
474        return;
475    }
476
477    /* Decode the object type */
478
479    else if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_PARSER))
480    {
481        AcpiOsPrintf ("<Parser>  ");
482    }
483
484    else if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_NAMED))
485    {
486        AcpiOsPrintf ("<Node>            Name %4.4s Type-%s",
487                        &((ACPI_NAMESPACE_NODE *)ObjDesc)->Name,
488                        AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) ObjDesc)->Type));
489
490        if (((ACPI_NAMESPACE_NODE *) ObjDesc)->Flags & ANOBJ_METHOD_ARG)
491        {
492            AcpiOsPrintf (" [Method Arg]");
493        }
494        if (((ACPI_NAMESPACE_NODE *) ObjDesc)->Flags & ANOBJ_METHOD_LOCAL)
495        {
496            AcpiOsPrintf (" [Method Local]");
497        }
498    }
499
500    else if (VALID_DESCRIPTOR_TYPE (ObjDesc, ACPI_DESC_TYPE_INTERNAL))
501    {
502        Type = ObjDesc->Common.Type;
503        if (Type > INTERNAL_TYPE_MAX)
504        {
505            AcpiOsPrintf (" Type %x [Invalid Type]", Type);
506            return;
507        }
508
509        /* Decode the ACPI object type */
510
511        switch (ObjDesc->Common.Type)
512        {
513        case INTERNAL_TYPE_REFERENCE:
514            switch (ObjDesc->Reference.Opcode)
515            {
516            case AML_ZERO_OP:
517                AcpiOsPrintf ("[Const]           Zero (0) [Null Target]", 0);
518                break;
519
520            case AML_ONES_OP:
521                AcpiOsPrintf ("[Const]           Ones (0xFFFFFFFFFFFFFFFF) [No Limit]");
522                break;
523
524            case AML_ONE_OP:
525                AcpiOsPrintf ("[Const]           One (1)");
526                break;
527
528            case AML_REVISION_OP:
529                AcpiOsPrintf ("[Const]           Revision (%X)", ACPI_CA_SUPPORT_LEVEL);
530                break;
531
532            case AML_LOCAL_OP:
533                AcpiOsPrintf ("[Local%d]", ObjDesc->Reference.Offset);
534                if (WalkState)
535                {
536                    ObjDesc = WalkState->LocalVariables[ObjDesc->Reference.Offset].Object;
537                    AcpiOsPrintf (" %p", ObjDesc);
538                    AcpiDbDecodeInternalObject (ObjDesc);
539                }
540                break;
541
542            case AML_ARG_OP:
543                AcpiOsPrintf ("[Arg%d]  ", ObjDesc->Reference.Offset);
544                if (WalkState)
545                {
546                    ObjDesc = WalkState->Arguments[ObjDesc->Reference.Offset].Object;
547                    AcpiOsPrintf (" %p", ObjDesc);
548                    AcpiDbDecodeInternalObject (ObjDesc);
549                }
550                break;
551
552            case AML_DEBUG_OP:
553                AcpiOsPrintf ("[Debug]  ");
554                break;
555
556            case AML_INDEX_OP:
557                AcpiOsPrintf ("[Index]     ");
558                AcpiDbDecodeInternalObject (ObjDesc->Reference.Object);
559                break;
560
561            default:
562                break;
563
564            }
565            break;
566
567        default:
568            AcpiOsPrintf ("<Obj> ");
569            AcpiOsPrintf ("           ");
570            AcpiDbDecodeInternalObject (ObjDesc);
571            break;
572        }
573    }
574
575    else
576    {
577        AcpiOsPrintf ("<Not a valid ACPI Object Descriptor> ");
578    }
579
580    AcpiOsPrintf ("\n");
581}
582
583
584/*******************************************************************************
585 *
586 * FUNCTION:    AcpiDbDisplayMethodInfo
587 *
588 * PARAMETERS:  StartOp         - Root of the control method parse tree
589 *
590 * RETURN:      None
591 *
592 * DESCRIPTION: Display information about the current method
593 *
594 ******************************************************************************/
595
596void
597AcpiDbDisplayMethodInfo (
598    ACPI_PARSE_OBJECT       *StartOp)
599{
600    ACPI_WALK_STATE         *WalkState;
601    ACPI_OPERAND_OBJECT     *ObjDesc;
602    ACPI_NAMESPACE_NODE     *Node;
603    ACPI_PARSE_OBJECT       *RootOp;
604    ACPI_PARSE_OBJECT       *Op;
605    const ACPI_OPCODE_INFO  *OpInfo;
606    UINT32                  NumOps = 0;
607    UINT32                  NumOperands = 0;
608    UINT32                  NumOperators = 0;
609    UINT32                  NumRemainingOps = 0;
610    UINT32                  NumRemainingOperands = 0;
611    UINT32                  NumRemainingOperators = 0;
612    UINT32                  NumArgs;
613    UINT32                  Concurrency;
614    BOOLEAN                 CountRemaining = FALSE;
615
616
617    WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
618    if (!WalkState)
619    {
620        AcpiOsPrintf ("There is no method currently executing\n");
621        return;
622    }
623
624    ObjDesc = WalkState->MethodDesc;
625    Node    = WalkState->MethodNode;
626
627    NumArgs     = ObjDesc->Method.ParamCount;
628    Concurrency = ObjDesc->Method.Concurrency;
629
630    AcpiOsPrintf ("Currently executing control method is [%4.4s]\n", &Node->Name);
631    AcpiOsPrintf ("%X arguments, max concurrency = %X\n", NumArgs, Concurrency);
632
633
634    RootOp = StartOp;
635    while (RootOp->Parent)
636    {
637        RootOp = RootOp->Parent;
638    }
639
640    Op = RootOp;
641
642    while (Op)
643    {
644        if (Op == StartOp)
645        {
646            CountRemaining = TRUE;
647        }
648
649        NumOps++;
650        if (CountRemaining)
651        {
652            NumRemainingOps++;
653        }
654
655        /* Decode the opcode */
656
657        OpInfo = AcpiPsGetOpcodeInfo (Op->Opcode);
658        switch (OpInfo->Class)
659        {
660        case AML_CLASS_ARGUMENT:
661            if (CountRemaining)
662            {
663                NumRemainingOperands++;
664            }
665
666            NumOperands++;
667            break;
668
669        case AML_CLASS_UNKNOWN:
670            /* Bad opcode or ASCII character */
671
672            continue;
673
674        default:
675            if (CountRemaining)
676            {
677                NumRemainingOperators++;
678            }
679
680            NumOperators++;
681            break;
682        }
683
684        Op = AcpiPsGetDepthNext (StartOp, Op);
685    }
686
687    AcpiOsPrintf ("Method contains:       %X AML Opcodes - %X Operators, %X Operands\n",
688                NumOps, NumOperators, NumOperands);
689
690    AcpiOsPrintf ("Remaining to execute:  %X AML Opcodes - %X Operators, %X Operands\n",
691                NumRemainingOps, NumRemainingOperators, NumRemainingOperands);
692}
693
694
695/*******************************************************************************
696 *
697 * FUNCTION:    AcpiDbDisplayLocals
698 *
699 * PARAMETERS:  None
700 *
701 * RETURN:      None
702 *
703 * DESCRIPTION: Display all locals for the currently running control method
704 *
705 ******************************************************************************/
706
707void
708AcpiDbDisplayLocals (void)
709{
710    UINT32                  i;
711    ACPI_WALK_STATE         *WalkState;
712    ACPI_OPERAND_OBJECT     *ObjDesc;
713    ACPI_NAMESPACE_NODE     *Node;
714
715
716    WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
717    if (!WalkState)
718    {
719        AcpiOsPrintf ("There is no method currently executing\n");
720        return;
721    }
722
723    ObjDesc = WalkState->MethodDesc;
724    Node = WalkState->MethodNode;
725    AcpiOsPrintf ("Local Variables for method [%4.4s]:\n", &Node->Name);
726
727    for (i = 0; i < MTH_NUM_LOCALS; i++)
728    {
729        ObjDesc = WalkState->LocalVariables[i].Object;
730        AcpiOsPrintf ("Local%d: ", i);
731        AcpiDbDisplayInternalObject (ObjDesc, WalkState);
732    }
733}
734
735
736/*******************************************************************************
737 *
738 * FUNCTION:    AcpiDbDisplayArguments
739 *
740 * PARAMETERS:  None
741 *
742 * RETURN:      None
743 *
744 * DESCRIPTION: Display all arguments for the currently running control method
745 *
746 ******************************************************************************/
747
748void
749AcpiDbDisplayArguments (void)
750{
751    UINT32                  i;
752    ACPI_WALK_STATE         *WalkState;
753    ACPI_OPERAND_OBJECT     *ObjDesc;
754    UINT32                  NumArgs;
755    UINT32                  Concurrency;
756    ACPI_NAMESPACE_NODE     *Node;
757
758
759    WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
760    if (!WalkState)
761    {
762        AcpiOsPrintf ("There is no method currently executing\n");
763        return;
764    }
765
766    ObjDesc = WalkState->MethodDesc;
767    Node    = WalkState->MethodNode;
768
769    NumArgs     = ObjDesc->Method.ParamCount;
770    Concurrency = ObjDesc->Method.Concurrency;
771
772    AcpiOsPrintf ("Method [%4.4s] has %X arguments, max concurrency = %X\n",
773            &Node->Name, NumArgs, Concurrency);
774
775    for (i = 0; i < NumArgs; i++)
776    {
777        ObjDesc = WalkState->Arguments[i].Object;
778        AcpiOsPrintf ("Arg%d: ", i);
779        AcpiDbDisplayInternalObject (ObjDesc, WalkState);
780    }
781}
782
783
784/*******************************************************************************
785 *
786 * FUNCTION:    AcpiDbDisplayResults
787 *
788 * PARAMETERS:  None
789 *
790 * RETURN:      None
791 *
792 * DESCRIPTION: Display current contents of a method result stack
793 *
794 ******************************************************************************/
795
796void
797AcpiDbDisplayResults (void)
798{
799    UINT32                  i;
800    ACPI_WALK_STATE         *WalkState;
801    ACPI_OPERAND_OBJECT     *ObjDesc;
802    UINT32                  NumResults = 0;
803    ACPI_NAMESPACE_NODE     *Node;
804
805
806    WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
807    if (!WalkState)
808    {
809        AcpiOsPrintf ("There is no method currently executing\n");
810        return;
811    }
812
813    ObjDesc = WalkState->MethodDesc;
814    Node = WalkState->MethodNode;
815
816    if (WalkState->Results)
817    {
818        NumResults = WalkState->Results->Results.NumResults;
819    }
820
821    AcpiOsPrintf ("Method [%4.4s] has %X stacked result objects\n",
822        &Node->Name, NumResults);
823
824    for (i = 0; i < NumResults; i++)
825    {
826        ObjDesc = WalkState->Results->Results.ObjDesc[i];
827        AcpiOsPrintf ("Result%d: ", i);
828        AcpiDbDisplayInternalObject (ObjDesc, WalkState);
829    }
830}
831
832
833/*******************************************************************************
834 *
835 * FUNCTION:    AcpiDbDisplayCallingTree
836 *
837 * PARAMETERS:  None
838 *
839 * RETURN:      None
840 *
841 * DESCRIPTION: Display current calling tree of nested control methods
842 *
843 ******************************************************************************/
844
845void
846AcpiDbDisplayCallingTree (void)
847{
848    UINT32                  i;
849    ACPI_WALK_STATE         *WalkState;
850    ACPI_NAMESPACE_NODE     *Node;
851
852
853    WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
854    if (!WalkState)
855    {
856        AcpiOsPrintf ("There is no method currently executing\n");
857        return;
858    }
859
860    Node = WalkState->MethodNode;
861    AcpiOsPrintf ("Current Control Method Call Tree\n");
862
863    for (i = 0; WalkState; i++)
864    {
865        Node = WalkState->MethodNode;
866
867        AcpiOsPrintf ("    [%4.4s]\n", &Node->Name);
868
869        WalkState = WalkState->Next;
870    }
871}
872
873
874/*******************************************************************************
875 *
876 * FUNCTION:    AcpiDbDisplayResultObject
877 *
878 * PARAMETERS:  ObjDesc         - Object to be displayed
879 *              WalkState       - Current walk state
880 *
881 * RETURN:      None
882 *
883 * DESCRIPTION: Display the result of an AML opcode
884 *
885 ******************************************************************************/
886
887void
888AcpiDbDisplayResultObject (
889    ACPI_OPERAND_OBJECT     *ObjDesc,
890    ACPI_WALK_STATE         *WalkState)
891{
892
893    /* TBD: [Future] We don't always want to display the result.
894     * For now, only display if single stepping
895     * however, this output is very useful in other contexts also
896     */
897    if (!AcpiGbl_CmSingleStep)
898    {
899        return;
900    }
901
902    AcpiOsPrintf ("ResultObj: ");
903    AcpiDbDisplayInternalObject (ObjDesc, WalkState);
904    AcpiOsPrintf ("\n");
905}
906
907
908/*******************************************************************************
909 *
910 * FUNCTION:    AcpiDbDisplayArgumentObject
911 *
912 * PARAMETERS:  ObjDesc         - Object to be displayed
913 *              WalkState       - Current walk state
914 *
915 * RETURN:      None
916 *
917 * DESCRIPTION: Display the result of an AML opcode
918 *
919 ******************************************************************************/
920
921void
922AcpiDbDisplayArgumentObject (
923    ACPI_OPERAND_OBJECT     *ObjDesc,
924    ACPI_WALK_STATE         *WalkState)
925{
926
927    if (!AcpiGbl_CmSingleStep)
928    {
929        return;
930    }
931
932    AcpiOsPrintf ("ArgObj:    ");
933    AcpiDbDisplayInternalObject (ObjDesc, WalkState);
934}
935
936#endif /* ENABLE_DEBUGGER */
937
938