nsdump.c revision 107325
167754Smsmith/******************************************************************************
267754Smsmith *
367754Smsmith * Module Name: nsdump - table dumping routines for debug
477424Smsmith *              $Revision: 146 $
567754Smsmith *
667754Smsmith *****************************************************************************/
767754Smsmith
867754Smsmith/******************************************************************************
967754Smsmith *
1067754Smsmith * 1. Copyright Notice
1167754Smsmith *
1271867Smsmith * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
1370243Smsmith * All rights reserved.
1467754Smsmith *
1567754Smsmith * 2. License
1667754Smsmith *
1767754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property
1867754Smsmith * rights.  You may have additional license terms from the party that provided
1967754Smsmith * you this software, covering your right to use that party's intellectual
2067754Smsmith * property rights.
2167754Smsmith *
2267754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
2367754Smsmith * copy of the source code appearing in this file ("Covered Code") an
2467754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the
2567754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy,
2667754Smsmith
2767754Smsmith * make derivatives, distribute, use and display any portion of the Covered
2867754Smsmith * Code in any form, with the right to sublicense such rights; and
2967754Smsmith *
3067754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
3167754Smsmith * license (with the right to sublicense), under only those claims of Intel
3267754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell,
3367754Smsmith * offer to sell, and import the Covered Code and derivative works thereof
3467754Smsmith * solely to the minimum extent necessary to exercise the above copyright
3567754Smsmith * license, and in no event shall the patent license extend to any additions
3667754Smsmith * to or modifications of the Original Intel Code.  No other license or right
3767754Smsmith * is granted directly or by implication, estoppel or otherwise;
3867754Smsmith *
3967754Smsmith * The above copyright and patent license is granted only if the following
4067754Smsmith * conditions are met:
4167754Smsmith *
4267754Smsmith * 3. Conditions
4367754Smsmith *
4467754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source.
4567754Smsmith * Redistribution of source code of any substantial portion of the Covered
4667754Smsmith * Code or modification with rights to further distribute source must include
4767754Smsmith * the above Copyright Notice, the above License, this list of Conditions,
4867754Smsmith * and the following Disclaimer and Export Compliance provision.  In addition,
4967754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to
5067754Smsmith * contain a file documenting the changes Licensee made to create that Covered
5167754Smsmith * Code and the date of any change.  Licensee must include in that file the
5267754Smsmith * documentation of any changes made by any predecessor Licensee.  Licensee
5367754Smsmith * must include a prominent statement that the modification is derived,
5467754Smsmith * directly or indirectly, from Original Intel Code.
5567754Smsmith *
5667754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
5767754Smsmith * Redistribution of source code of any substantial portion of the Covered
5867754Smsmith * Code or modification without rights to further distribute source must
5967754Smsmith * include the following Disclaimer and Export Compliance provision in the
6067754Smsmith * documentation and/or other materials provided with distribution.  In
6167754Smsmith * addition, Licensee may not authorize further sublicense of source of any
6267754Smsmith * portion of the Covered Code, and must include terms to the effect that the
6367754Smsmith * license from Licensee to its licensee is limited to the intellectual
6467754Smsmith * property embodied in the software Licensee provides to its licensee, and
6567754Smsmith * not to intellectual property embodied in modifications its licensee may
6667754Smsmith * make.
6767754Smsmith *
6867754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any
6967754Smsmith * substantial portion of the Covered Code or modification must reproduce the
7067754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance
7167754Smsmith * provision in the documentation and/or other materials provided with the
7267754Smsmith * distribution.
7367754Smsmith *
7467754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original
7567754Smsmith * Intel Code.
7667754Smsmith *
7767754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by
7867754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or
7967754Smsmith * other dealings in products derived from or relating to the Covered Code
8067754Smsmith * without prior written authorization from Intel.
8167754Smsmith *
8267754Smsmith * 4. Disclaimer and Export Compliance
8367754Smsmith *
8467754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
8567754Smsmith * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
8667754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
8767754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
8867754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
8967754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
9067754Smsmith * PARTICULAR PURPOSE.
9167754Smsmith *
9267754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
9367754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
9467754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
9567754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
9667754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
9767754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
9867754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
9967754Smsmith * LIMITED REMEDY.
10067754Smsmith *
10167754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this
10267754Smsmith * software or system incorporating such software without first obtaining any
10367754Smsmith * required license or other approval from the U. S. Department of Commerce or
10467754Smsmith * any other agency or department of the United States Government.  In the
10567754Smsmith * event Licensee exports any such software from the United States or
10667754Smsmith * re-exports any such software from a foreign destination, Licensee shall
10767754Smsmith * ensure that the distribution and export/re-export of the software is in
10867754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the
10967754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor
11067754Smsmith * any of its subsidiaries will export/re-export any technical data, process,
11167754Smsmith * software, or service, directly or indirectly, to any country for which the
11267754Smsmith * United States government or any agency thereof requires an export license,
11367754Smsmith * other governmental approval, or letter of assurance, without first obtaining
11467754Smsmith * such license, approval or letter.
11567754Smsmith *
11667754Smsmith *****************************************************************************/
11767754Smsmith
11867754Smsmith#define __NSDUMP_C__
11967754Smsmith
12067754Smsmith#include "acpi.h"
12167754Smsmith#include "acnamesp.h"
12267754Smsmith#include "acparser.h"
12367754Smsmith
12467754Smsmith
12567754Smsmith#define _COMPONENT          ACPI_NAMESPACE
12677424Smsmith        ACPI_MODULE_NAME    ("nsdump")
12767754Smsmith
12867754Smsmith#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
12967754Smsmith
13071867Smsmith
13167754Smsmith/*******************************************************************************
13277424Smsmith *
13367754Smsmith * FUNCTION:    AcpiNsPrintPathname
13467754Smsmith *
13567754Smsmith * PARAMETERS:  NumSegment          - Number of ACPI name segments
13667754Smsmith *              Pathname            - The compressed (internal) path
13767754Smsmith *
13867754Smsmith * DESCRIPTION: Print an object's full namespace pathname
13967754Smsmith *
14067754Smsmith ******************************************************************************/
14167754Smsmith
14267754Smsmithvoid
14367754SmsmithAcpiNsPrintPathname (
14477424Smsmith    UINT32                  NumSegments,
14567754Smsmith    char                    *Pathname)
14667754Smsmith{
14767754Smsmith    ACPI_FUNCTION_NAME ("NsPrintPathname");
14867754Smsmith
14967754Smsmith
15067754Smsmith    if (!(AcpiDbgLevel & ACPI_LV_NAMES) || !(AcpiDbgLayer & ACPI_NAMESPACE))
15167754Smsmith    {
15267754Smsmith        return;
15367754Smsmith    }
15467754Smsmith
15567754Smsmith        /* Print the entire name */
15667754Smsmith
15767754Smsmith    ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "["));
15867754Smsmith
15967754Smsmith    while (NumSegments)
16067754Smsmith    {
16167754Smsmith        AcpiOsPrintf ("%4.4s", Pathname);
16267754Smsmith        Pathname += ACPI_NAME_SIZE;
16367754Smsmith
16467754Smsmith        NumSegments--;
16567754Smsmith        if (NumSegments)
16677424Smsmith        {
16767754Smsmith            AcpiOsPrintf (".");
16867754Smsmith        }
16967754Smsmith    }
17067754Smsmith
17167754Smsmith    AcpiOsPrintf ("]\n");
17267754Smsmith}
17367754Smsmith
17467754Smsmith
17567754Smsmith/*******************************************************************************
17667754Smsmith *
17767754Smsmith * FUNCTION:    AcpiNsDumpPathname
17867754Smsmith *
17967754Smsmith * PARAMETERS:  Handle              - Object
18077424Smsmith *              Msg                 - Prefix message
18167754Smsmith *              Level               - Desired debug level
18267754Smsmith *              Component           - Caller's component ID
18367754Smsmith *
18467754Smsmith * DESCRIPTION: Print an object's full namespace pathname
18567754Smsmith *              Manages allocation/freeing of a pathname buffer
18677424Smsmith *
18767754Smsmith ******************************************************************************/
18867754Smsmith
18967754SmsmithACPI_STATUS
19067754SmsmithAcpiNsDumpPathname (
19167754Smsmith    ACPI_HANDLE             Handle,
19267754Smsmith    NATIVE_CHAR             *Msg,
19367754Smsmith    UINT32                  Level,
19467754Smsmith    UINT32                  Component)
19567754Smsmith{
19667754Smsmith    ACPI_BUFFER             Buffer;
19777424Smsmith    ACPI_STATUS             Status;
19867754Smsmith
19967754Smsmith
20067754Smsmith    ACPI_FUNCTION_TRACE ("NsDumpPathname");
20167754Smsmith
20267754Smsmith
20367754Smsmith    /* Do this only if the requested debug level and component are enabled */
20467754Smsmith
20567754Smsmith    if (!(AcpiDbgLevel & Level) || !(AcpiDbgLayer & Component))
20667754Smsmith    {
20767754Smsmith        return_ACPI_STATUS (AE_OK);
20867754Smsmith    }
20967754Smsmith
21077424Smsmith    /* Convert handle to a full pathname and print it (with supplied message) */
21177424Smsmith
21267754Smsmith    Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
21367754Smsmith
21467754Smsmith    Status = AcpiNsHandleToPathname (Handle, &Buffer);
21567754Smsmith    if (ACPI_SUCCESS (Status))
21667754Smsmith    {
21767754Smsmith        AcpiOsPrintf ("%s %s (Node %p)\n", Msg, (char *) Buffer.Pointer, Handle);
21867754Smsmith        ACPI_MEM_FREE (Buffer.Pointer);
21967754Smsmith    }
22067754Smsmith
22167754Smsmith    return_ACPI_STATUS (Status);
22267754Smsmith}
22367754Smsmith
22467754Smsmith
22567754Smsmith/*******************************************************************************
22667754Smsmith *
22767754Smsmith * FUNCTION:    AcpiNsDumpOneObject
22867754Smsmith *
22967754Smsmith * PARAMETERS:  Handle              - Node to be dumped
23067754Smsmith *              Level               - Nesting level of the handle
23167754Smsmith *              Context             - Passed into WalkNamespace
23277424Smsmith *
23367754Smsmith * DESCRIPTION: Dump a single Node
23467754Smsmith *              This procedure is a UserFunction called by AcpiNsWalkNamespace.
23567754Smsmith *
23667754Smsmith ******************************************************************************/
23767754Smsmith
23867754SmsmithACPI_STATUS
23967754SmsmithAcpiNsDumpOneObject (
24067754Smsmith    ACPI_HANDLE             ObjHandle,
24167754Smsmith    UINT32                  Level,
24267754Smsmith    void                    *Context,
24367754Smsmith    void                    **ReturnValue)
24467754Smsmith{
24567754Smsmith    ACPI_WALK_INFO          *Info = (ACPI_WALK_INFO *) Context;
24667754Smsmith    ACPI_NAMESPACE_NODE     *ThisNode;
24767754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc = NULL;
24867754Smsmith    ACPI_OBJECT_TYPE        ObjType;
24967754Smsmith    ACPI_OBJECT_TYPE        Type;
25067754Smsmith    UINT32                  BytesToDump;
25167754Smsmith    UINT32                  DbgLevel;
25267754Smsmith    UINT32                  i;
25367754Smsmith
25467754Smsmith
25567754Smsmith    ACPI_FUNCTION_NAME ("NsDumpOneObject");
25667754Smsmith
25767754Smsmith
25867754Smsmith    /* Is output enabled? */
25967754Smsmith
26067754Smsmith    if (!(AcpiDbgLevel & Info->DebugLevel))
26167754Smsmith    {
26267754Smsmith        return (AE_OK);
26367754Smsmith    }
26467754Smsmith
26567754Smsmith    if (!ObjHandle)
26667754Smsmith    {
26767754Smsmith        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n"));
26867754Smsmith        return (AE_OK);
26967754Smsmith    }
27067754Smsmith
27167754Smsmith    ThisNode = AcpiNsMapHandleToNode (ObjHandle);
27267754Smsmith    Type = ThisNode->Type;
27367754Smsmith
27467754Smsmith    /* Check if the owner matches */
27567754Smsmith
27667754Smsmith    if ((Info->OwnerId != ACPI_UINT32_MAX) &&
27767754Smsmith        (Info->OwnerId != ThisNode->OwnerId))
27867754Smsmith    {
27967754Smsmith        return (AE_OK);
28067754Smsmith    }
28167754Smsmith
28267754Smsmith    /* Indent the object according to the level */
28367754Smsmith
28467754Smsmith    AcpiOsPrintf ("%2d%*s", (UINT32) Level - 1, (int) Level * 2, " ");
28567754Smsmith
28667754Smsmith    /* Check the node type and name */
28767754Smsmith
28867754Smsmith    if (Type > ACPI_TYPE_LOCAL_MAX)
28967754Smsmith    {
29067754Smsmith        ACPI_REPORT_WARNING (("Invalid ACPI Type %08X\n", Type));
29167754Smsmith    }
29267754Smsmith
29367754Smsmith    if (!AcpiUtValidAcpiName (ThisNode->Name.Integer))
29467754Smsmith    {
29567754Smsmith        ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n", ThisNode->Name.Integer));
29667754Smsmith    }
29767754Smsmith
29867754Smsmith    /*
29967754Smsmith     * Now we can print out the pertinent information
30067754Smsmith     */
30167754Smsmith    AcpiOsPrintf ("%4.4s %-12s %p ",
30267754Smsmith            ThisNode->Name.Ascii, AcpiUtGetTypeName (Type), ThisNode);
30367754Smsmith
30467754Smsmith    DbgLevel = AcpiDbgLevel;
30567754Smsmith    AcpiDbgLevel = 0;
30677424Smsmith    ObjDesc = AcpiNsGetAttachedObject (ThisNode);
30767754Smsmith    AcpiDbgLevel = DbgLevel;
30869746Smsmith
30967754Smsmith    switch (Info->DisplayType)
31067754Smsmith    {
31167754Smsmith    case ACPI_DISPLAY_SUMMARY:
31267754Smsmith
31367754Smsmith        if (!ObjDesc)
31467754Smsmith        {
31577424Smsmith            /* No attached object, we are done */
31667754Smsmith
31767754Smsmith            AcpiOsPrintf ("\n");
31867754Smsmith            return (AE_OK);
31967754Smsmith        }
32067754Smsmith
32167754Smsmith        switch (Type)
32267754Smsmith        {
32367754Smsmith        case ACPI_TYPE_PROCESSOR:
32467754Smsmith
32567754Smsmith            AcpiOsPrintf ("ID %X Len %.4X Addr %p\n",
32667754Smsmith                        ObjDesc->Processor.ProcId,
32767754Smsmith                        ObjDesc->Processor.Length,
32867754Smsmith                        (char *) ObjDesc->Processor.Address);
32967754Smsmith            break;
33067754Smsmith
33167754Smsmith
33267754Smsmith        case ACPI_TYPE_DEVICE:
33367754Smsmith
33467754Smsmith            AcpiOsPrintf ("Notify object: %p", ObjDesc);
33567754Smsmith            break;
33667754Smsmith
33767754Smsmith
33867754Smsmith        case ACPI_TYPE_METHOD:
33967754Smsmith
34067754Smsmith            AcpiOsPrintf ("Args %X Len %.4X Aml %p\n",
34171867Smsmith                        (UINT32) ObjDesc->Method.ParamCount,
34267754Smsmith                        ObjDesc->Method.AmlLength,
34367754Smsmith                        ObjDesc->Method.AmlStart);
34471867Smsmith            break;
34567754Smsmith
34667754Smsmith
34767754Smsmith        case ACPI_TYPE_INTEGER:
34867754Smsmith
34967754Smsmith            AcpiOsPrintf ("= %8.8X%8.8X\n",
35067754Smsmith                        ACPI_HIDWORD (ObjDesc->Integer.Value),
35167754Smsmith                        ACPI_LODWORD (ObjDesc->Integer.Value));
35267754Smsmith            break;
35367754Smsmith
35467754Smsmith
35567754Smsmith        case ACPI_TYPE_PACKAGE:
35667754Smsmith
35767754Smsmith            if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
35867754Smsmith            {
35967754Smsmith                AcpiOsPrintf ("Elements %.2X\n",
36067754Smsmith                            ObjDesc->Package.Count);
36167754Smsmith            }
36267754Smsmith            else
36367754Smsmith            {
36467754Smsmith                AcpiOsPrintf ("[Length not yet evaluated]\n");
36567754Smsmith            }
36667754Smsmith            break;
36767754Smsmith
36867754Smsmith
36967754Smsmith        case ACPI_TYPE_BUFFER:
37067754Smsmith
37167754Smsmith            if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
37267754Smsmith            {
37367754Smsmith                AcpiOsPrintf ("Len %.2X",
37467754Smsmith                            ObjDesc->Buffer.Length);
37567754Smsmith
37667754Smsmith                /* Dump some of the buffer */
37767754Smsmith
37867754Smsmith                if (ObjDesc->Buffer.Length > 0)
37967754Smsmith                {
38067754Smsmith                    AcpiOsPrintf (" =");
38167754Smsmith                    for (i = 0; (i < ObjDesc->Buffer.Length && i < 12); i++)
38267754Smsmith                    {
38367754Smsmith                        AcpiOsPrintf (" %.2hX", ObjDesc->Buffer.Pointer[i]);
38467754Smsmith                    }
38567754Smsmith                }
38667754Smsmith                AcpiOsPrintf ("\n");
38767754Smsmith            }
38867754Smsmith            else
38967754Smsmith            {
39067754Smsmith                AcpiOsPrintf ("[Length not yet evaluated]\n");
39167754Smsmith            }
39267754Smsmith            break;
39367754Smsmith
39467754Smsmith
39567754Smsmith        case ACPI_TYPE_STRING:
39667754Smsmith
39767754Smsmith            AcpiOsPrintf ("Len %.2X ", ObjDesc->String.Length);
39867754Smsmith            AcpiUtPrintString (ObjDesc->String.Pointer, 32);
39967754Smsmith            AcpiOsPrintf ("\n");
40067754Smsmith            break;
40167754Smsmith
40267754Smsmith
40367754Smsmith        case ACPI_TYPE_REGION:
40467754Smsmith
40567754Smsmith            AcpiOsPrintf ("[%s]", AcpiUtGetRegionName (ObjDesc->Region.SpaceId));
40667754Smsmith            if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
40767754Smsmith            {
40867754Smsmith                AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n",
40967754Smsmith                            ACPI_HIDWORD (ObjDesc->Region.Address),
41067754Smsmith                            ACPI_LODWORD (ObjDesc->Region.Address),
41167754Smsmith                            ObjDesc->Region.Length);
41269746Smsmith            }
41367754Smsmith            else
41467754Smsmith            {
41567754Smsmith                AcpiOsPrintf (" [Address/Length not yet evaluated]\n");
41667754Smsmith            }
41767754Smsmith            break;
41869746Smsmith
41977424Smsmith
42067754Smsmith        case ACPI_TYPE_LOCAL_REFERENCE:
42167754Smsmith
42267754Smsmith            AcpiOsPrintf ("[%s]\n",
42367754Smsmith                    AcpiPsGetOpcodeName (ObjDesc->Reference.Opcode));
42467754Smsmith            break;
42567754Smsmith
42667754Smsmith
42767754Smsmith        case ACPI_TYPE_BUFFER_FIELD:
42867754Smsmith
42967754Smsmith            if (ObjDesc->BufferField.BufferObj &&
43067754Smsmith                ObjDesc->BufferField.BufferObj->Buffer.Node)
43167754Smsmith            {
43267754Smsmith                AcpiOsPrintf ("Buf [%4.4s]",
43367754Smsmith                        ObjDesc->BufferField.BufferObj->Buffer.Node->Name.Ascii);
43467754Smsmith            }
43567754Smsmith            break;
43667754Smsmith
43767754Smsmith
43867754Smsmith        case ACPI_TYPE_LOCAL_REGION_FIELD:
43967754Smsmith
44067754Smsmith            AcpiOsPrintf ("Rgn [%4.4s]",
44167754Smsmith                    ObjDesc->CommonField.RegionObj->Region.Node->Name.Ascii);
44267754Smsmith            break;
44367754Smsmith
44467754Smsmith
44567754Smsmith        case ACPI_TYPE_LOCAL_BANK_FIELD:
44667754Smsmith
44767754Smsmith            AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]",
44867754Smsmith                    ObjDesc->CommonField.RegionObj->Region.Node->Name.Ascii,
44967754Smsmith                    ObjDesc->BankField.BankObj->CommonField.Node->Name.Ascii);
45067754Smsmith            break;
45167754Smsmith
45267754Smsmith
45377424Smsmith        case ACPI_TYPE_LOCAL_INDEX_FIELD:
45477424Smsmith
45577424Smsmith            AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]",
45677424Smsmith                    ObjDesc->IndexField.IndexObj->CommonField.Node->Name.Ascii,
45767754Smsmith                    ObjDesc->IndexField.DataObj->CommonField.Node->Name.Ascii);
45867754Smsmith            break;
45967754Smsmith
46067754Smsmith
46167754Smsmith        case ACPI_TYPE_LOCAL_ALIAS:
46267754Smsmith
46367754Smsmith            AcpiOsPrintf ("Target %4.4s (%p)\n", ((ACPI_NAMESPACE_NODE *) ObjDesc)->Name.Ascii, ObjDesc);
46467754Smsmith            break;
46577424Smsmith
46677424Smsmith        default:
46767754Smsmith
46867754Smsmith            AcpiOsPrintf ("Object %p\n", ObjDesc);
46967754Smsmith            break;
47077424Smsmith        }
47167754Smsmith
47267754Smsmith        /* Common field handling */
47367754Smsmith
47477424Smsmith        switch (Type)
47567754Smsmith        {
47667754Smsmith        case ACPI_TYPE_BUFFER_FIELD:
47767754Smsmith        case ACPI_TYPE_LOCAL_REGION_FIELD:
47867754Smsmith        case ACPI_TYPE_LOCAL_BANK_FIELD:
47967754Smsmith        case ACPI_TYPE_LOCAL_INDEX_FIELD:
48067754Smsmith
48167754Smsmith            AcpiOsPrintf (" Off %.2X Len %.2X Acc %.2hd\n",
48267754Smsmith                    (ObjDesc->CommonField.BaseByteOffset * 8)
48367754Smsmith                        + ObjDesc->CommonField.StartFieldBitOffset,
48467754Smsmith                    ObjDesc->CommonField.BitLength,
48567754Smsmith                    ObjDesc->CommonField.AccessByteWidth);
48667754Smsmith            break;
48767754Smsmith
48867754Smsmith        default:
48967754Smsmith            break;
49077424Smsmith        }
49167754Smsmith        break;
49267754Smsmith
49367754Smsmith
49467754Smsmith    case ACPI_DISPLAY_OBJECTS:
49567754Smsmith
49667754Smsmith        AcpiOsPrintf ("O:%p", ObjDesc);
49767754Smsmith        if (!ObjDesc)
49867754Smsmith        {
49967754Smsmith            /* No attached object, we are done */
50067754Smsmith
50167754Smsmith            AcpiOsPrintf ("\n");
50267754Smsmith            return (AE_OK);
50367754Smsmith        }
50477424Smsmith
50567754Smsmith        AcpiOsPrintf ("(R%d)",
50667754Smsmith                ObjDesc->Common.ReferenceCount);
50767754Smsmith
50877424Smsmith        switch (Type)
50967754Smsmith        {
51067754Smsmith        case ACPI_TYPE_METHOD:
51167754Smsmith
51267754Smsmith            /* Name is a Method and its AML offset/length are set */
51367754Smsmith
51467754Smsmith            AcpiOsPrintf (" M:%p-%X\n", ObjDesc->Method.AmlStart,
51567754Smsmith                                        ObjDesc->Method.AmlLength);
51667754Smsmith            break;
51767754Smsmith
51867754Smsmith        case ACPI_TYPE_INTEGER:
51967754Smsmith
52067754Smsmith            AcpiOsPrintf (" N:%X%X\n", ACPI_HIDWORD(ObjDesc->Integer.Value),
52167754Smsmith                                       ACPI_LODWORD(ObjDesc->Integer.Value));
52267754Smsmith            break;
52367754Smsmith
52469450Smsmith        case ACPI_TYPE_STRING:
52577424Smsmith
52667754Smsmith            AcpiOsPrintf (" S:%p-%X\n", ObjDesc->String.Pointer,
52767754Smsmith                                        ObjDesc->String.Length);
52867754Smsmith            break;
52967754Smsmith
53067754Smsmith        case ACPI_TYPE_BUFFER:
53167754Smsmith
53267754Smsmith            AcpiOsPrintf (" B:%p-%X\n", ObjDesc->Buffer.Pointer,
53367754Smsmith                                        ObjDesc->Buffer.Length);
53467754Smsmith            break;
53567754Smsmith
53677424Smsmith        default:
53767754Smsmith
53867754Smsmith            AcpiOsPrintf ("\n");
53967754Smsmith            break;
54067754Smsmith        }
54167754Smsmith        break;
54267754Smsmith
54367754Smsmith
54467754Smsmith    default:
54567754Smsmith        AcpiOsPrintf ("\n");
54667754Smsmith        break;
54767754Smsmith    }
54867754Smsmith
54967754Smsmith    /* If debug turned off, done */
55067754Smsmith
55167754Smsmith    if (!(AcpiDbgLevel & ACPI_LV_VALUES))
55267754Smsmith    {
55367754Smsmith        return (AE_OK);
55467754Smsmith    }
55567754Smsmith
55667754Smsmith
55767754Smsmith    /* If there is an attached object, display it */
55867754Smsmith
55967754Smsmith    DbgLevel     = AcpiDbgLevel;
56067754Smsmith    AcpiDbgLevel = 0;
56167754Smsmith    ObjDesc      = AcpiNsGetAttachedObject (ThisNode);
56267754Smsmith    AcpiDbgLevel = DbgLevel;
56367754Smsmith
56467754Smsmith    /* Dump attached objects */
56567754Smsmith
56667754Smsmith    while (ObjDesc)
56767754Smsmith    {
56877424Smsmith        ObjType = ACPI_TYPE_INVALID;
56967754Smsmith        AcpiOsPrintf ("        Attached Object %p: ", ObjDesc);
57067754Smsmith
57167754Smsmith        /* Decode the type of attached object and dump the contents */
57267754Smsmith
57367754Smsmith        switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
57467754Smsmith        {
57567754Smsmith        case ACPI_DESC_TYPE_NAMED:
57677424Smsmith
57767754Smsmith            AcpiOsPrintf ("(Ptr to Node)\n");
57867754Smsmith            BytesToDump = sizeof (ACPI_NAMESPACE_NODE);
57967754Smsmith            break;
58067754Smsmith
58167754Smsmith
58267754Smsmith        case ACPI_DESC_TYPE_OPERAND:
58367754Smsmith
58467754Smsmith            ObjType = ACPI_GET_OBJECT_TYPE (ObjDesc);
58567754Smsmith
58667754Smsmith            if (ObjType > ACPI_TYPE_LOCAL_MAX)
58767754Smsmith            {
58867754Smsmith                AcpiOsPrintf ("(Ptr to ACPI Object type %X [UNKNOWN])\n", ObjType);
58967754Smsmith                BytesToDump = 32;
59067754Smsmith            }
59167754Smsmith            else
59267754Smsmith            {
59367754Smsmith                AcpiOsPrintf ("(Ptr to ACPI Object type %s, %X)\n",
59467754Smsmith                                    AcpiUtGetTypeName (ObjType), ObjType);
59567754Smsmith                BytesToDump = sizeof (ACPI_OPERAND_OBJECT);
59667754Smsmith            }
59767754Smsmith            break;
59869450Smsmith
59967754Smsmith
60077424Smsmith        default:
60167754Smsmith
60267754Smsmith            AcpiOsPrintf ("(String or Buffer ptr - not an object descriptor)\n");
60367754Smsmith            BytesToDump = 16;
60467754Smsmith            break;
60567754Smsmith        }
60667754Smsmith
60767754Smsmith        ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
60867754Smsmith
60967754Smsmith        /* If value is NOT an internal object, we are done */
61067754Smsmith
61177424Smsmith        if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
61267754Smsmith        {
61367754Smsmith            goto Cleanup;
61467754Smsmith        }
61567754Smsmith
61667754Smsmith        /*
61767754Smsmith         * Valid object, get the pointer to next level, if any
61867754Smsmith         */
61967754Smsmith        switch (ObjType)
62067754Smsmith        {
62167754Smsmith        case ACPI_TYPE_STRING:
62267754Smsmith            ObjDesc = (void *) ObjDesc->String.Pointer;
62367754Smsmith            break;
62467754Smsmith
62567754Smsmith        case ACPI_TYPE_BUFFER:
62667754Smsmith            ObjDesc = (void *) ObjDesc->Buffer.Pointer;
62767754Smsmith            break;
62867754Smsmith
62967754Smsmith        case ACPI_TYPE_BUFFER_FIELD:
63077424Smsmith            ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->BufferField.BufferObj;
63167754Smsmith            break;
63267754Smsmith
63367754Smsmith        case ACPI_TYPE_PACKAGE:
63467754Smsmith            ObjDesc = (void *) ObjDesc->Package.Elements;
63567754Smsmith            break;
63667754Smsmith
63767754Smsmith        case ACPI_TYPE_METHOD:
63867754Smsmith            ObjDesc = (void *) ObjDesc->Method.AmlStart;
63967754Smsmith            break;
64067754Smsmith
64167754Smsmith        case ACPI_TYPE_LOCAL_REGION_FIELD:
64267754Smsmith            ObjDesc = (void *) ObjDesc->Field.RegionObj;
64367754Smsmith            break;
64467754Smsmith
64567754Smsmith        case ACPI_TYPE_LOCAL_BANK_FIELD:
64667754Smsmith            ObjDesc = (void *) ObjDesc->BankField.RegionObj;
64767754Smsmith            break;
64877424Smsmith
64967754Smsmith        case ACPI_TYPE_LOCAL_INDEX_FIELD:
65067754Smsmith            ObjDesc = (void *) ObjDesc->IndexField.IndexObj;
65167754Smsmith            break;
65267754Smsmith
65367754Smsmith        default:
65467754Smsmith            goto Cleanup;
65567754Smsmith        }
65667754Smsmith
65777424Smsmith        ObjType = ACPI_TYPE_INVALID;   /* Terminate loop after next pass */
65867754Smsmith    }
65967754Smsmith
66067754SmsmithCleanup:
66167754Smsmith    AcpiOsPrintf ("\n");
66267754Smsmith    return (AE_OK);
66367754Smsmith}
66467754Smsmith
66567754Smsmith
66667754Smsmith/*******************************************************************************
66767754Smsmith *
66867754Smsmith * FUNCTION:    AcpiNsDumpObjects
66967754Smsmith *
67067754Smsmith * PARAMETERS:  Type                - Object type to be dumped
67167754Smsmith *              MaxDepth            - Maximum depth of dump.  Use ACPI_UINT32_MAX
67267754Smsmith *                                    for an effectively unlimited depth.
67367754Smsmith *              OwnerId             - Dump only objects owned by this ID.  Use
67467754Smsmith *                                    ACPI_UINT32_MAX to match all owners.
67567754Smsmith *              StartHandle         - Where in namespace to start/end search
67667754Smsmith *
67767754Smsmith * DESCRIPTION: Dump typed objects within the loaded namespace.
67867754Smsmith *              Uses AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject.
679 *
680 ******************************************************************************/
681
682void
683AcpiNsDumpObjects (
684    ACPI_OBJECT_TYPE        Type,
685    UINT8                   DisplayType,
686    UINT32                  MaxDepth,
687    UINT32                  OwnerId,
688    ACPI_HANDLE             StartHandle)
689{
690    ACPI_WALK_INFO          Info;
691
692
693    ACPI_FUNCTION_ENTRY ();
694
695
696    Info.DebugLevel = ACPI_LV_TABLES;
697    Info.OwnerId = OwnerId;
698    Info.DisplayType = DisplayType;
699
700
701    (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
702                ACPI_NS_WALK_NO_UNLOCK, AcpiNsDumpOneObject,
703                (void *) &Info, NULL);
704}
705
706
707/*******************************************************************************
708 *
709 * FUNCTION:    AcpiNsDumpTables
710 *
711 * PARAMETERS:  SearchBase          - Root of subtree to be dumped, or
712 *                                    NS_ALL to dump the entire namespace
713 *              MaxDepth            - Maximum depth of dump.  Use INT_MAX
714 *                                    for an effectively unlimited depth.
715 *
716 * DESCRIPTION: Dump the name space, or a portion of it.
717 *
718 ******************************************************************************/
719
720void
721AcpiNsDumpTables (
722    ACPI_HANDLE             SearchBase,
723    UINT32                  MaxDepth)
724{
725    ACPI_HANDLE             SearchHandle = SearchBase;
726
727
728    ACPI_FUNCTION_TRACE ("NsDumpTables");
729
730
731    if (!AcpiGbl_RootNode)
732    {
733        /*
734         * If the name space has not been initialized,
735         * there is nothing to dump.
736         */
737        ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "namespace not initialized!\n"));
738        return_VOID;
739    }
740
741    if (ACPI_NS_ALL == SearchBase)
742    {
743        /*  entire namespace    */
744
745        SearchHandle = AcpiGbl_RootNode;
746        ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n"));
747    }
748
749
750    AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, MaxDepth,
751            ACPI_UINT32_MAX, SearchHandle);
752    return_VOID;
753}
754
755
756/*******************************************************************************
757 *
758 * FUNCTION:    AcpiNsDumpEntry
759 *
760 * PARAMETERS:  Handle              - Node to be dumped
761 *              DebugLevel          - Output level
762 *
763 * DESCRIPTION: Dump a single Node
764 *
765 ******************************************************************************/
766
767void
768AcpiNsDumpEntry (
769    ACPI_HANDLE             Handle,
770    UINT32                  DebugLevel)
771{
772    ACPI_WALK_INFO          Info;
773
774
775    ACPI_FUNCTION_ENTRY ();
776
777
778    Info.DebugLevel = DebugLevel;
779    Info.OwnerId = ACPI_UINT32_MAX;
780    Info.DisplayType = ACPI_DISPLAY_SUMMARY;
781
782    (void) AcpiNsDumpOneObject (Handle, 1, &Info, NULL);
783}
784
785#endif
786
787