nsdump.c revision 202771
111894Speter/******************************************************************************
211894Speter *
311894Speter * Module Name: nsdump - table dumping routines for debug
411894Speter *
59Sjkh *****************************************************************************/
69Sjkh
79Sjkh/******************************************************************************
89Sjkh *
99Sjkh * 1. Copyright Notice
109Sjkh *
119Sjkh * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp.
129Sjkh * All rights reserved.
139Sjkh *
149Sjkh * 2. License
159Sjkh *
169Sjkh * 2.1. This is your license from Intel Corp. under its intellectual property
179Sjkh * rights.  You may have additional license terms from the party that provided
189Sjkh * you this software, covering your right to use that party's intellectual
199Sjkh * property rights.
2011894Speter *
2111894Speter * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
2211894Speter * copy of the source code appearing in this file ("Covered Code") an
239Sjkh * irrevocable, perpetual, worldwide license under Intel's copyrights in the
249Sjkh * base code distributed originally by Intel ("Original Intel Code") to copy,
259Sjkh
269Sjkh * make derivatives, distribute, use and display any portion of the Covered
279Sjkh * Code in any form, with the right to sublicense such rights; and
289Sjkh *
299Sjkh * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
3011894Speter * license (with the right to sublicense), under only those claims of Intel
3111894Speter * patents that are infringed by the Original Intel Code, to make, use, sell,
3211894Speter * offer to sell, and import the Covered Code and derivative works thereof
338858Srgrimes * solely to the minimum extent necessary to exercise the above copyright
3411894Speter * license, and in no event shall the patent license extend to any additions
3511894Speter * to or modifications of the Original Intel Code.  No other license or right
3611894Speter * is granted directly or by implication, estoppel or otherwise;
3711894Speter *
3811894Speter * The above copyright and patent license is granted only if the following
3911894Speter * conditions are met:
4011894Speter *
4111894Speter * 3. Conditions
4211894Speter *
4311894Speter * 3.1. Redistribution of Source with Rights to Further Distribute Source.
4411894Speter * Redistribution of source code of any substantial portion of the Covered
4511894Speter * Code or modification with rights to further distribute source must include
4611894Speter * the above Copyright Notice, the above License, this list of Conditions,
4711894Speter * and the following Disclaimer and Export Compliance provision.  In addition,
4811894Speter * Licensee must cause all Covered Code to which Licensee contributes to
4911894Speter * contain a file documenting the changes Licensee made to create that Covered
5011894Speter * Code and the date of any change.  Licensee must include in that file the
5111894Speter * documentation of any changes made by any predecessor Licensee.  Licensee
5211894Speter * must include a prominent statement that the modification is derived,
5311894Speter * directly or indirectly, from Original Intel Code.
5411894Speter *
5511894Speter * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
5611894Speter * Redistribution of source code of any substantial portion of the Covered
5711894Speter * Code or modification without rights to further distribute source must
5811894Speter * include the following Disclaimer and Export Compliance provision in the
5911894Speter * documentation and/or other materials provided with distribution.  In
6011894Speter * addition, Licensee may not authorize further sublicense of source of any
6111894Speter * portion of the Covered Code, and must include terms to the effect that the
6211894Speter * license from Licensee to its licensee is limited to the intellectual
6311894Speter * property embodied in the software Licensee provides to its licensee, and
6411894Speter * not to intellectual property embodied in modifications its licensee may
6511894Speter * make.
6611894Speter *
6711894Speter * 3.3. Redistribution of Executable. Redistribution in executable form of any
689Sjkh * substantial portion of the Covered Code or modification must reproduce the
699Sjkh * above Copyright Notice, and the following Disclaimer and Export Compliance
709Sjkh * provision in the documentation and/or other materials provided with the
719Sjkh * distribution.
729Sjkh *
739Sjkh * 3.4. Intel retains all right, title, and interest in and to the Original
749Sjkh * Intel Code.
759Sjkh *
769Sjkh * 3.5. Neither the name Intel nor any other trademark owned or controlled by
779Sjkh * Intel shall be used in advertising or otherwise to promote the sale, use or
789Sjkh * other dealings in products derived from or relating to the Covered Code
799Sjkh * without prior written authorization from Intel.
809Sjkh *
819Sjkh * 4. Disclaimer and Export Compliance
829Sjkh *
839Sjkh * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
849Sjkh * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
859Sjkh * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
869Sjkh * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
879Sjkh * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
889Sjkh * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
899Sjkh * PARTICULAR PURPOSE.
909Sjkh *
919Sjkh * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
929Sjkh * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
939Sjkh * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
949Sjkh * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
959Sjkh * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
969Sjkh * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
979Sjkh * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
989Sjkh * LIMITED REMEDY.
999Sjkh *
1009Sjkh * 4.3. Licensee shall not export, either directly or indirectly, any of this
1019Sjkh * software or system incorporating such software without first obtaining any
1029Sjkh * required license or other approval from the U. S. Department of Commerce or
1039Sjkh * any other agency or department of the United States Government.  In the
1049Sjkh * event Licensee exports any such software from the United States or
1059Sjkh * re-exports any such software from a foreign destination, Licensee shall
1069Sjkh * ensure that the distribution and export/re-export of the software is in
1079Sjkh * compliance with all laws, regulations, orders, or other restrictions of the
1089Sjkh * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1099Sjkh * any of its subsidiaries will export/re-export any technical data, process,
1109Sjkh * software, or service, directly or indirectly, to any country for which the
1119Sjkh * United States government or any agency thereof requires an export license,
1129Sjkh * other governmental approval, or letter of assurance, without first obtaining
1139Sjkh * such license, approval or letter.
1148858Srgrimes *
1159Sjkh *****************************************************************************/
1169Sjkh
1178858Srgrimes#define __NSDUMP_C__
1189Sjkh
1199Sjkh#include <contrib/dev/acpica/include/acpi.h>
1209Sjkh#include <contrib/dev/acpica/include/accommon.h>
1218858Srgrimes#include <contrib/dev/acpica/include/acnamesp.h>
1229Sjkh
1239Sjkh
1249Sjkh#define _COMPONENT          ACPI_NAMESPACE
1258858Srgrimes        ACPI_MODULE_NAME    ("nsdump")
1269Sjkh
1279Sjkh/* Local prototypes */
1288858Srgrimes
1299Sjkh#ifdef ACPI_OBSOLETE_FUNCTIONS
1308858Srgrimesvoid
1319SjkhAcpiNsDumpRootDevices (
1328858Srgrimes    void);
1339Sjkh
1348858Srgrimesstatic ACPI_STATUS
1359SjkhAcpiNsDumpOneDevice (
1368858Srgrimes    ACPI_HANDLE             ObjHandle,
1379Sjkh    UINT32                  Level,
1389Sjkh    void                    *Context,
1398858Srgrimes    void                    **ReturnValue);
1409Sjkh#endif
1419Sjkh
1428858Srgrimes
1439Sjkh#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
1449Sjkh/*******************************************************************************
1458858Srgrimes *
1469Sjkh * FUNCTION:    AcpiNsPrintPathname
1479Sjkh *
1489Sjkh * PARAMETERS:  NumSegments         - Number of ACPI name segments
1498858Srgrimes *              Pathname            - The compressed (internal) path
1509Sjkh *
1519Sjkh * RETURN:      None
1529Sjkh *
1539Sjkh * DESCRIPTION: Print an object's full namespace pathname
1549Sjkh *
1559Sjkh ******************************************************************************/
1569Sjkh
1578858Srgrimesvoid
1589SjkhAcpiNsPrintPathname (
1599Sjkh    UINT32                  NumSegments,
1608858Srgrimes    char                    *Pathname)
1619Sjkh{
1629Sjkh    UINT32                  i;
1639Sjkh
1649Sjkh
1659Sjkh    ACPI_FUNCTION_NAME (NsPrintPathname);
1669Sjkh
1679Sjkh
1689Sjkh    if (!(AcpiDbgLevel & ACPI_LV_NAMES) || !(AcpiDbgLayer & ACPI_NAMESPACE))
1699Sjkh    {
1709Sjkh        return;
1719Sjkh    }
1729Sjkh
1739Sjkh    /* Print the entire name */
1749Sjkh
1759Sjkh    ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "["));
1769Sjkh
1779Sjkh    while (NumSegments)
1789Sjkh    {
1799Sjkh        for (i = 0; i < 4; i++)
1809Sjkh        {
1819Sjkh            ACPI_IS_PRINT (Pathname[i]) ?
1829Sjkh                AcpiOsPrintf ("%c", Pathname[i]) :
1839Sjkh                AcpiOsPrintf ("?");
1849Sjkh        }
1859Sjkh
1869Sjkh        Pathname += ACPI_NAME_SIZE;
1879Sjkh        NumSegments--;
1889Sjkh        if (NumSegments)
1899Sjkh        {
1909Sjkh            AcpiOsPrintf (".");
1919Sjkh        }
1929Sjkh    }
1939Sjkh
1949Sjkh    AcpiOsPrintf ("]\n");
1959Sjkh}
1969Sjkh
1979Sjkh
1989Sjkh/*******************************************************************************
1999Sjkh *
2009Sjkh * FUNCTION:    AcpiNsDumpPathname
2019Sjkh *
2029Sjkh * PARAMETERS:  Handle              - Object
2039Sjkh *              Msg                 - Prefix message
2049Sjkh *              Level               - Desired debug level
2059Sjkh *              Component           - Caller's component ID
2069Sjkh *
2079Sjkh * RETURN:      None
2089Sjkh *
2099Sjkh * DESCRIPTION: Print an object's full namespace pathname
2109Sjkh *              Manages allocation/freeing of a pathname buffer
2119Sjkh *
2129Sjkh ******************************************************************************/
2139Sjkh
2149Sjkhvoid
2159SjkhAcpiNsDumpPathname (
2169Sjkh    ACPI_HANDLE             Handle,
2179Sjkh    char                    *Msg,
2189Sjkh    UINT32                  Level,
2199Sjkh    UINT32                  Component)
2209Sjkh{
2219Sjkh
2229Sjkh    ACPI_FUNCTION_TRACE (NsDumpPathname);
2239Sjkh
2249Sjkh
2259Sjkh    /* Do this only if the requested debug level and component are enabled */
2269Sjkh
2279Sjkh    if (!(AcpiDbgLevel & Level) || !(AcpiDbgLayer & Component))
2289Sjkh    {
2299Sjkh        return_VOID;
2309Sjkh    }
2319Sjkh
2329Sjkh    /* Convert handle to a full pathname and print it (with supplied message) */
2339Sjkh
2349Sjkh    AcpiNsPrintNodePathname (Handle, Msg);
2359Sjkh    AcpiOsPrintf ("\n");
2369Sjkh    return_VOID;
2379Sjkh}
2389Sjkh
2399Sjkh
2409Sjkh/*******************************************************************************
2419Sjkh *
24211894Speter * FUNCTION:    AcpiNsDumpOneObject
24311894Speter *
2449Sjkh * PARAMETERS:  ObjHandle           - Node to be dumped
24511894Speter *              Level               - Nesting level of the handle
24611894Speter *              Context             - Passed into WalkNamespace
24711894Speter *              ReturnValue         - Not used
24811894Speter *
24911894Speter * RETURN:      Status
2509Sjkh *
2519Sjkh * DESCRIPTION: Dump a single Node
25211894Speter *              This procedure is a UserFunction called by AcpiNsWalkNamespace.
25311894Speter *
25411894Speter ******************************************************************************/
2559Sjkh
2569SjkhACPI_STATUS
2579SjkhAcpiNsDumpOneObject (
2589Sjkh    ACPI_HANDLE             ObjHandle,
2599Sjkh    UINT32                  Level,
2609Sjkh    void                    *Context,
2619Sjkh    void                    **ReturnValue)
2629Sjkh{
2639Sjkh    ACPI_WALK_INFO          *Info = (ACPI_WALK_INFO *) Context;
2649Sjkh    ACPI_NAMESPACE_NODE     *ThisNode;
2659Sjkh    ACPI_OPERAND_OBJECT     *ObjDesc = NULL;
2669Sjkh    ACPI_OBJECT_TYPE        ObjType;
2679Sjkh    ACPI_OBJECT_TYPE        Type;
26811894Speter    UINT32                  BytesToDump;
2699Sjkh    UINT32                  DbgLevel;
27011894Speter    UINT32                  i;
27111894Speter
27211894Speter
2739Sjkh    ACPI_FUNCTION_NAME (NsDumpOneObject);
2749Sjkh
2759Sjkh
2769Sjkh    /* Is output enabled? */
2779Sjkh
27850472Speter    if (!(AcpiDbgLevel & Info->DebugLevel))
2799Sjkh    {
2809Sjkh        return (AE_OK);
28111894Speter    }
2829Sjkh
2839Sjkh    if (!ObjHandle)
2849Sjkh    {
28511894Speter        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n"));
28611894Speter        return (AE_OK);
28711894Speter    }
28811894Speter
2899Sjkh    ThisNode = AcpiNsValidateHandle (ObjHandle);
29011894Speter    if (!ThisNode)
29111894Speter    {
2929Sjkh        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Invalid object handle %p\n",
2939Sjkh            ObjHandle));
2949Sjkh        return (AE_OK);
2959Sjkh    }
29611894Speter
2979Sjkh    Type = ThisNode->Type;
29811894Speter
29911894Speter    /* Check if the owner matches */
30011894Speter
3019Sjkh    if ((Info->OwnerId != ACPI_OWNER_ID_MAX) &&
3029Sjkh        (Info->OwnerId != ThisNode->OwnerId))
30311894Speter    {
30411894Speter        return (AE_OK);
30511894Speter    }
3069Sjkh
3079Sjkh    if (!(Info->DisplayType & ACPI_DISPLAY_SHORT))
3089Sjkh    {
3099Sjkh        /* Indent the object according to the level */
31011894Speter
3119Sjkh        AcpiOsPrintf ("%2d%*s", (UINT32) Level - 1, (int) Level * 2, " ");
3129Sjkh
31311894Speter        /* Check the node type and name */
31411894Speter
31511894Speter        if (Type > ACPI_TYPE_LOCAL_MAX)
3169Sjkh        {
3179Sjkh            ACPI_WARNING ((AE_INFO, "Invalid ACPI Object Type %08X", Type));
3189Sjkh        }
3199Sjkh
3209Sjkh        AcpiOsPrintf ("%4.4s", AcpiUtGetNodeName (ThisNode));
3219Sjkh    }
3229Sjkh
3239Sjkh    /* Now we can print out the pertinent information */
3249Sjkh
3259Sjkh    AcpiOsPrintf (" %-12s %p %2.2X ",
3269Sjkh            AcpiUtGetTypeName (Type), ThisNode, ThisNode->OwnerId);
3279Sjkh
3289Sjkh    DbgLevel = AcpiDbgLevel;
3299Sjkh    AcpiDbgLevel = 0;
3309Sjkh    ObjDesc = AcpiNsGetAttachedObject (ThisNode);
3319Sjkh    AcpiDbgLevel = DbgLevel;
3329Sjkh
3339Sjkh    /* Temp nodes are those nodes created by a control method */
33411894Speter
3359Sjkh    if (ThisNode->Flags & ANOBJ_TEMPORARY)
3369Sjkh    {
3379Sjkh        AcpiOsPrintf ("(T) ");
3389Sjkh    }
3399Sjkh
3409Sjkh    switch (Info->DisplayType & ACPI_DISPLAY_MASK)
3419Sjkh    {
3429Sjkh    case ACPI_DISPLAY_SUMMARY:
34311894Speter
3449Sjkh        if (!ObjDesc)
3459Sjkh        {
3469Sjkh            /* No attached object, we are done */
34711894Speter
3489Sjkh            AcpiOsPrintf ("\n");
3499Sjkh            return (AE_OK);
3509Sjkh        }
3519Sjkh
3529Sjkh        switch (Type)
3539Sjkh        {
3549Sjkh        case ACPI_TYPE_PROCESSOR:
3559Sjkh
3569Sjkh            AcpiOsPrintf ("ID %X Len %.4X Addr %p\n",
3579Sjkh                ObjDesc->Processor.ProcId, ObjDesc->Processor.Length,
3589Sjkh                ACPI_CAST_PTR (void, ObjDesc->Processor.Address));
3599Sjkh            break;
3609Sjkh
3619Sjkh
3629Sjkh        case ACPI_TYPE_DEVICE:
3639Sjkh
3649Sjkh            AcpiOsPrintf ("Notify Object: %p\n", ObjDesc);
3659Sjkh            break;
36611894Speter
3679Sjkh
36811894Speter        case ACPI_TYPE_METHOD:
36911894Speter
3709Sjkh            AcpiOsPrintf ("Args %X Len %.4X Aml %p\n",
3719Sjkh                (UINT32) ObjDesc->Method.ParamCount,
3729Sjkh                ObjDesc->Method.AmlLength, ObjDesc->Method.AmlStart);
3739Sjkh            break;
3749Sjkh
3759Sjkh
3769Sjkh        case ACPI_TYPE_INTEGER:
37711894Speter
3789Sjkh            AcpiOsPrintf ("= %8.8X%8.8X\n",
37911894Speter                ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
38011894Speter            break;
38111894Speter
3829Sjkh
3839Sjkh        case ACPI_TYPE_PACKAGE:
3849Sjkh
38511894Speter            if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
3869Sjkh            {
38711894Speter                AcpiOsPrintf ("Elements %.2X\n",
3889Sjkh                    ObjDesc->Package.Count);
3899Sjkh            }
39011894Speter            else
3919Sjkh            {
3929Sjkh                AcpiOsPrintf ("[Length not yet evaluated]\n");
3939Sjkh            }
39411894Speter            break;
3959Sjkh
39611894Speter
3979Sjkh        case ACPI_TYPE_BUFFER:
39811894Speter
3999Sjkh            if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
4009Sjkh            {
4019Sjkh                AcpiOsPrintf ("Len %.2X",
4029Sjkh                            ObjDesc->Buffer.Length);
4039Sjkh
4049Sjkh                /* Dump some of the buffer */
4059Sjkh
4069Sjkh                if (ObjDesc->Buffer.Length > 0)
4079Sjkh                {
4089Sjkh                    AcpiOsPrintf (" =");
4099Sjkh                    for (i = 0; (i < ObjDesc->Buffer.Length && i < 12); i++)
4109Sjkh                    {
4119Sjkh                        AcpiOsPrintf (" %.2hX", ObjDesc->Buffer.Pointer[i]);
4129Sjkh                    }
4139Sjkh                }
4149Sjkh                AcpiOsPrintf ("\n");
4159Sjkh            }
4169Sjkh            else
4179Sjkh            {
4189Sjkh                AcpiOsPrintf ("[Length not yet evaluated]\n");
4199Sjkh            }
4209Sjkh            break;
42111894Speter
42211894Speter
42311894Speter        case ACPI_TYPE_STRING:
42411894Speter
4259Sjkh            AcpiOsPrintf ("Len %.2X ", ObjDesc->String.Length);
4269Sjkh            AcpiUtPrintString (ObjDesc->String.Pointer, 32);
4279Sjkh            AcpiOsPrintf ("\n");
4289Sjkh            break;
4299Sjkh
4309Sjkh
4319Sjkh        case ACPI_TYPE_REGION:
4329Sjkh
4339Sjkh            AcpiOsPrintf ("[%s]",
4349Sjkh                AcpiUtGetRegionName (ObjDesc->Region.SpaceId));
4359Sjkh            if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
4369Sjkh            {
4379Sjkh                AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n",
4389Sjkh                    ACPI_FORMAT_NATIVE_UINT (ObjDesc->Region.Address),
4399Sjkh                    ObjDesc->Region.Length);
4409Sjkh            }
4419Sjkh            else
4429Sjkh            {
4439Sjkh                AcpiOsPrintf (" [Address/Length not yet evaluated]\n");
4449Sjkh            }
4459Sjkh            break;
4469Sjkh
4479Sjkh
4489Sjkh        case ACPI_TYPE_LOCAL_REFERENCE:
4499Sjkh
45011894Speter            AcpiOsPrintf ("[%s]\n", AcpiUtGetReferenceName (ObjDesc));
45111894Speter            break;
45211894Speter
45311894Speter
45411894Speter        case ACPI_TYPE_BUFFER_FIELD:
45511894Speter
4569Sjkh            if (ObjDesc->BufferField.BufferObj &&
4579Sjkh                ObjDesc->BufferField.BufferObj->Buffer.Node)
4589Sjkh            {
4599Sjkh                AcpiOsPrintf ("Buf [%4.4s]",
4609Sjkh                    AcpiUtGetNodeName (
4619Sjkh                        ObjDesc->BufferField.BufferObj->Buffer.Node));
4629Sjkh            }
4639Sjkh            break;
4649Sjkh
4659Sjkh
4669Sjkh        case ACPI_TYPE_LOCAL_REGION_FIELD:
4679Sjkh
4689Sjkh            AcpiOsPrintf ("Rgn [%4.4s]",
4699Sjkh                AcpiUtGetNodeName (
4709Sjkh                    ObjDesc->CommonField.RegionObj->Region.Node));
4719Sjkh            break;
47211894Speter
47311894Speter
47411894Speter        case ACPI_TYPE_LOCAL_BANK_FIELD:
47511894Speter
4769Sjkh            AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]",
4779Sjkh                AcpiUtGetNodeName (
4789Sjkh                    ObjDesc->CommonField.RegionObj->Region.Node),
4799Sjkh                AcpiUtGetNodeName (
4809Sjkh                    ObjDesc->BankField.BankObj->CommonField.Node));
4819Sjkh            break;
48211894Speter
48311894Speter
4849Sjkh        case ACPI_TYPE_LOCAL_INDEX_FIELD:
4859Sjkh
4869Sjkh            AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]",
48711894Speter                AcpiUtGetNodeName (
48811894Speter                    ObjDesc->IndexField.IndexObj->CommonField.Node),
48911894Speter                AcpiUtGetNodeName (
49011894Speter                    ObjDesc->IndexField.DataObj->CommonField.Node));
4919Sjkh            break;
4929Sjkh
4939Sjkh
4949Sjkh        case ACPI_TYPE_LOCAL_ALIAS:
49511894Speter        case ACPI_TYPE_LOCAL_METHOD_ALIAS:
4969Sjkh
4979Sjkh            AcpiOsPrintf ("Target %4.4s (%p)\n",
49811894Speter                AcpiUtGetNodeName (ObjDesc), ObjDesc);
4999Sjkh            break;
5009Sjkh
5019Sjkh        default:
5029Sjkh
50311894Speter            AcpiOsPrintf ("Object %p\n", ObjDesc);
5049Sjkh            break;
5059Sjkh        }
5069Sjkh
5079Sjkh        /* Common field handling */
5089Sjkh
5099Sjkh        switch (Type)
5109Sjkh        {
51111894Speter        case ACPI_TYPE_BUFFER_FIELD:
51211894Speter        case ACPI_TYPE_LOCAL_REGION_FIELD:
51311894Speter        case ACPI_TYPE_LOCAL_BANK_FIELD:
5149Sjkh        case ACPI_TYPE_LOCAL_INDEX_FIELD:
5159Sjkh
5169Sjkh            AcpiOsPrintf (" Off %.3X Len %.2X Acc %.2hd\n",
5179Sjkh                (ObjDesc->CommonField.BaseByteOffset * 8)
51811894Speter                    + ObjDesc->CommonField.StartFieldBitOffset,
5199Sjkh                ObjDesc->CommonField.BitLength,
52011894Speter                ObjDesc->CommonField.AccessByteWidth);
52111894Speter            break;
52211894Speter
5239Sjkh        default:
5249Sjkh            break;
5259Sjkh        }
5269Sjkh        break;
5279Sjkh
52811894Speter
52911894Speter    case ACPI_DISPLAY_OBJECTS:
53011894Speter
53111894Speter        AcpiOsPrintf ("O:%p", ObjDesc);
53211894Speter        if (!ObjDesc)
53311894Speter        {
53411894Speter            /* No attached object, we are done */
53511894Speter
53611894Speter            AcpiOsPrintf ("\n");
53711894Speter            return (AE_OK);
53811894Speter        }
5399Sjkh
5409Sjkh        AcpiOsPrintf ("(R%d)", ObjDesc->Common.ReferenceCount);
54111894Speter
5429Sjkh        switch (Type)
54311894Speter        {
54411894Speter        case ACPI_TYPE_METHOD:
54511894Speter
54611894Speter            /* Name is a Method and its AML offset/length are set */
5479Sjkh
5489Sjkh            AcpiOsPrintf (" M:%p-%X\n", ObjDesc->Method.AmlStart,
5499Sjkh                ObjDesc->Method.AmlLength);
5509Sjkh            break;
55111894Speter
55211894Speter        case ACPI_TYPE_INTEGER:
55311894Speter
55411894Speter            AcpiOsPrintf (" I:%8.8X8.8%X\n",
5559Sjkh                ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
55611894Speter            break;
55711894Speter
55811894Speter        case ACPI_TYPE_STRING:
55911894Speter
56011894Speter            AcpiOsPrintf (" S:%p-%X\n", ObjDesc->String.Pointer,
5619Sjkh                ObjDesc->String.Length);
56211894Speter            break;
5639Sjkh
56411894Speter        case ACPI_TYPE_BUFFER:
5659Sjkh
56611894Speter            AcpiOsPrintf (" B:%p-%X\n", ObjDesc->Buffer.Pointer,
5679Sjkh                ObjDesc->Buffer.Length);
56811894Speter            break;
5699Sjkh
5709Sjkh        default:
5719Sjkh
5729Sjkh            AcpiOsPrintf ("\n");
57311894Speter            break;
57411894Speter        }
57511894Speter        break;
57611894Speter
57711894Speter
57811894Speter    default:
57911894Speter        AcpiOsPrintf ("\n");
58011894Speter        break;
58111894Speter    }
5829Sjkh
58311894Speter    /* If debug turned off, done */
58411894Speter
5859Sjkh    if (!(AcpiDbgLevel & ACPI_LV_VALUES))
58611894Speter    {
5879Sjkh        return (AE_OK);
5889Sjkh    }
5899Sjkh
59011894Speter    /* If there is an attached object, display it */
59111894Speter
59211894Speter    DbgLevel     = AcpiDbgLevel;
59311894Speter    AcpiDbgLevel = 0;
5949Sjkh    ObjDesc      = AcpiNsGetAttachedObject (ThisNode);
59511894Speter    AcpiDbgLevel = DbgLevel;
59611894Speter
5979Sjkh    /* Dump attached objects */
5989Sjkh
5999Sjkh    while (ObjDesc)
6009Sjkh    {
6019Sjkh        ObjType = ACPI_TYPE_INVALID;
60211894Speter        AcpiOsPrintf ("Attached Object %p: ", ObjDesc);
6039Sjkh
6049Sjkh        /* Decode the type of attached object and dump the contents */
6059Sjkh
6069Sjkh        switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
6079Sjkh        {
60811894Speter        case ACPI_DESC_TYPE_NAMED:
6099Sjkh
6109Sjkh            AcpiOsPrintf ("(Ptr to Node)\n");
61111894Speter            BytesToDump = sizeof (ACPI_NAMESPACE_NODE);
6129Sjkh            ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
61311894Speter            break;
6149Sjkh
6159Sjkh        case ACPI_DESC_TYPE_OPERAND:
6169Sjkh
6179Sjkh            ObjType = ObjDesc->Common.Type;
61811894Speter
61911894Speter            if (ObjType > ACPI_TYPE_LOCAL_MAX)
62011894Speter            {
62111894Speter                AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [UNKNOWN])\n",
62211894Speter                    ObjType);
62311894Speter                BytesToDump = 32;
62411894Speter            }
62511894Speter            else
62611894Speter            {
62711894Speter                AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [%s])\n",
62811894Speter                    ObjType, AcpiUtGetTypeName (ObjType));
62911894Speter                BytesToDump = sizeof (ACPI_OPERAND_OBJECT);
63011894Speter            }
63111894Speter
63211894Speter            ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
63311894Speter            break;
63411894Speter
63511894Speter        default:
63611894Speter
63711894Speter            break;
63811894Speter        }
63911894Speter
6409Sjkh        /* If value is NOT an internal object, we are done */
6419Sjkh
6429Sjkh        if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
6439Sjkh        {
6449Sjkh            goto Cleanup;
6459Sjkh        }
6469Sjkh
6479Sjkh        /* Valid object, get the pointer to next level, if any */
6489Sjkh
6499Sjkh        switch (ObjType)
65011894Speter        {
6519Sjkh        case ACPI_TYPE_BUFFER:
6529Sjkh        case ACPI_TYPE_STRING:
6539Sjkh            /*
65411894Speter             * NOTE: takes advantage of common fields between string/buffer
6559Sjkh             */
6569Sjkh            BytesToDump = ObjDesc->String.Length;
65711894Speter            ObjDesc = (void *) ObjDesc->String.Pointer;
6589Sjkh            AcpiOsPrintf ( "(Buffer/String pointer %p length %X)\n",
6599Sjkh                ObjDesc, BytesToDump);
6609Sjkh            ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
6619Sjkh            goto Cleanup;
6629Sjkh
6639Sjkh        case ACPI_TYPE_BUFFER_FIELD:
6649Sjkh            ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->BufferField.BufferObj;
6659Sjkh            break;
6669Sjkh
6679Sjkh        case ACPI_TYPE_PACKAGE:
6689Sjkh            ObjDesc = (void *) ObjDesc->Package.Elements;
6699Sjkh            break;
6709Sjkh
6719Sjkh        case ACPI_TYPE_METHOD:
6729Sjkh            ObjDesc = (void *) ObjDesc->Method.AmlStart;
6739Sjkh            break;
6749Sjkh
6759Sjkh        case ACPI_TYPE_LOCAL_REGION_FIELD:
67611894Speter            ObjDesc = (void *) ObjDesc->Field.RegionObj;
67711894Speter            break;
6789Sjkh
67911894Speter        case ACPI_TYPE_LOCAL_BANK_FIELD:
6809Sjkh            ObjDesc = (void *) ObjDesc->BankField.RegionObj;
6819Sjkh            break;
6829Sjkh
6839Sjkh        case ACPI_TYPE_LOCAL_INDEX_FIELD:
6849Sjkh            ObjDesc = (void *) ObjDesc->IndexField.IndexObj;
6859Sjkh            break;
6869Sjkh
6879Sjkh        default:
6889Sjkh            goto Cleanup;
6899Sjkh        }
6909Sjkh
6919Sjkh        ObjType = ACPI_TYPE_INVALID;   /* Terminate loop after next pass */
69211894Speter    }
6939Sjkh
69411894SpeterCleanup:
69511894Speter    AcpiOsPrintf ("\n");
6969Sjkh    return (AE_OK);
6979Sjkh}
69811894Speter
69911894Speter
70011894Speter/*******************************************************************************
7019Sjkh *
7029Sjkh * FUNCTION:    AcpiNsDumpObjects
7039Sjkh *
7049Sjkh * PARAMETERS:  Type                - Object type to be dumped
7059Sjkh *              DisplayType         - 0 or ACPI_DISPLAY_SUMMARY
7069Sjkh *              MaxDepth            - Maximum depth of dump. Use ACPI_UINT32_MAX
7079Sjkh *                                    for an effectively unlimited depth.
7089Sjkh *              OwnerId             - Dump only objects owned by this ID. Use
7099Sjkh *                                    ACPI_UINT32_MAX to match all owners.
7109Sjkh *              StartHandle         - Where in namespace to start/end search
71111894Speter *
7129Sjkh * RETURN:      None
7139Sjkh *
71411894Speter * DESCRIPTION: Dump typed objects within the loaded namespace. Uses
71511894Speter *              AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject.
7169Sjkh *
7179Sjkh ******************************************************************************/
7189Sjkh
7199Sjkhvoid
7209SjkhAcpiNsDumpObjects (
7219Sjkh    ACPI_OBJECT_TYPE        Type,
7229Sjkh    UINT8                   DisplayType,
7239Sjkh    UINT32                  MaxDepth,
7249Sjkh    ACPI_OWNER_ID           OwnerId,
7259Sjkh    ACPI_HANDLE             StartHandle)
7269Sjkh{
7279Sjkh    ACPI_WALK_INFO          Info;
7289Sjkh
7299Sjkh
7309Sjkh    ACPI_FUNCTION_ENTRY ();
7319Sjkh
7329Sjkh
7339Sjkh    Info.DebugLevel = ACPI_LV_TABLES;
73411894Speter    Info.OwnerId = OwnerId;
73511894Speter    Info.DisplayType = DisplayType;
7369Sjkh
7379Sjkh    (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
73811894Speter                ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,
7399Sjkh                AcpiNsDumpOneObject, NULL, (void *) &Info, NULL);
7409Sjkh}
7419Sjkh
7429Sjkh
7439Sjkh/*******************************************************************************
7449Sjkh *
7459Sjkh * FUNCTION:    AcpiNsDumpEntry
7469Sjkh *
7479Sjkh * PARAMETERS:  Handle              - Node to be dumped
7489Sjkh *              DebugLevel          - Output level
7499Sjkh *
7509Sjkh * RETURN:      None
7519Sjkh *
7529Sjkh * DESCRIPTION: Dump a single Node
7539Sjkh *
7549Sjkh ******************************************************************************/
7559Sjkh
7569Sjkhvoid
7579SjkhAcpiNsDumpEntry (
7589Sjkh    ACPI_HANDLE             Handle,
7599Sjkh    UINT32                  DebugLevel)
7609Sjkh{
7619Sjkh    ACPI_WALK_INFO          Info;
7629Sjkh
7639Sjkh
7649Sjkh    ACPI_FUNCTION_ENTRY ();
7659Sjkh
7669Sjkh
7679Sjkh    Info.DebugLevel = DebugLevel;
7689Sjkh    Info.OwnerId = ACPI_OWNER_ID_MAX;
7699Sjkh    Info.DisplayType = ACPI_DISPLAY_SUMMARY;
7709Sjkh
7719Sjkh    (void) AcpiNsDumpOneObject (Handle, 1, &Info, NULL);
7729Sjkh}
7739Sjkh
7749Sjkh
7759Sjkh#ifdef ACPI_ASL_COMPILER
77611894Speter/*******************************************************************************
77711894Speter *
7789Sjkh * FUNCTION:    AcpiNsDumpTables
7799Sjkh *
7809Sjkh * PARAMETERS:  SearchBase          - Root of subtree to be dumped, or
7819Sjkh *                                    NS_ALL to dump the entire namespace
7829Sjkh *              MaxDepth            - Maximum depth of dump.  Use INT_MAX
7839Sjkh *                                    for an effectively unlimited depth.
7849Sjkh *
7859Sjkh * RETURN:      None
7869Sjkh *
7879Sjkh * DESCRIPTION: Dump the name space, or a portion of it.
7889Sjkh *
7899Sjkh ******************************************************************************/
7909Sjkh
7919Sjkhvoid
79211894SpeterAcpiNsDumpTables (
79311894Speter    ACPI_HANDLE             SearchBase,
7949Sjkh    UINT32                  MaxDepth)
7959Sjkh{
7969Sjkh    ACPI_HANDLE             SearchHandle = SearchBase;
7979Sjkh
7989Sjkh
7999Sjkh    ACPI_FUNCTION_TRACE (NsDumpTables);
8009Sjkh
8019Sjkh
8029Sjkh    if (!AcpiGbl_RootNode)
8039Sjkh    {
8049Sjkh        /*
8059Sjkh         * If the name space has not been initialized,
8069Sjkh         * there is nothing to dump.
8079Sjkh         */
8089Sjkh        ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "namespace not initialized!\n"));
80911894Speter        return_VOID;
81011894Speter    }
8119Sjkh
8129Sjkh    if (ACPI_NS_ALL == SearchBase)
8139Sjkh    {
81411894Speter        /* Entire namespace */
81511894Speter
81611894Speter        SearchHandle = AcpiGbl_RootNode;
8179Sjkh        ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n"));
8189Sjkh    }
8199Sjkh
8209Sjkh    AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, MaxDepth,
8219Sjkh            ACPI_OWNER_ID_MAX, SearchHandle);
8229Sjkh    return_VOID;
8239Sjkh}
8249Sjkh#endif
8259Sjkh#endif
8269Sjkh
8279Sjkh