nsdump.c revision 199337
167754Smsmith/******************************************************************************
267754Smsmith *
367754Smsmith * Module Name: nsdump - table dumping routines for debug
467754Smsmith *
567754Smsmith *****************************************************************************/
667754Smsmith
767754Smsmith/******************************************************************************
867754Smsmith *
967754Smsmith * 1. Copyright Notice
1067754Smsmith *
11193267Sjkim * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
1270243Smsmith * All rights reserved.
1367754Smsmith *
1467754Smsmith * 2. License
1567754Smsmith *
1667754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property
1767754Smsmith * rights.  You may have additional license terms from the party that provided
1867754Smsmith * you this software, covering your right to use that party's intellectual
1967754Smsmith * property rights.
2067754Smsmith *
2167754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
2267754Smsmith * copy of the source code appearing in this file ("Covered Code") an
2367754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the
2467754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy,
2567754Smsmith
2667754Smsmith * make derivatives, distribute, use and display any portion of the Covered
2767754Smsmith * Code in any form, with the right to sublicense such rights; and
2867754Smsmith *
2967754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
3067754Smsmith * license (with the right to sublicense), under only those claims of Intel
3167754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell,
3267754Smsmith * offer to sell, and import the Covered Code and derivative works thereof
3367754Smsmith * solely to the minimum extent necessary to exercise the above copyright
3467754Smsmith * license, and in no event shall the patent license extend to any additions
3567754Smsmith * to or modifications of the Original Intel Code.  No other license or right
3667754Smsmith * is granted directly or by implication, estoppel or otherwise;
3767754Smsmith *
3867754Smsmith * The above copyright and patent license is granted only if the following
3967754Smsmith * conditions are met:
4067754Smsmith *
4167754Smsmith * 3. Conditions
4267754Smsmith *
4367754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source.
4467754Smsmith * Redistribution of source code of any substantial portion of the Covered
4567754Smsmith * Code or modification with rights to further distribute source must include
4667754Smsmith * the above Copyright Notice, the above License, this list of Conditions,
4767754Smsmith * and the following Disclaimer and Export Compliance provision.  In addition,
4867754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to
4967754Smsmith * contain a file documenting the changes Licensee made to create that Covered
5067754Smsmith * Code and the date of any change.  Licensee must include in that file the
5167754Smsmith * documentation of any changes made by any predecessor Licensee.  Licensee
5267754Smsmith * must include a prominent statement that the modification is derived,
5367754Smsmith * directly or indirectly, from Original Intel Code.
5467754Smsmith *
5567754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
5667754Smsmith * Redistribution of source code of any substantial portion of the Covered
5767754Smsmith * Code or modification without rights to further distribute source must
5867754Smsmith * include the following Disclaimer and Export Compliance provision in the
5967754Smsmith * documentation and/or other materials provided with distribution.  In
6067754Smsmith * addition, Licensee may not authorize further sublicense of source of any
6167754Smsmith * portion of the Covered Code, and must include terms to the effect that the
6267754Smsmith * license from Licensee to its licensee is limited to the intellectual
6367754Smsmith * property embodied in the software Licensee provides to its licensee, and
6467754Smsmith * not to intellectual property embodied in modifications its licensee may
6567754Smsmith * make.
6667754Smsmith *
6767754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any
6867754Smsmith * substantial portion of the Covered Code or modification must reproduce the
6967754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance
7067754Smsmith * provision in the documentation and/or other materials provided with the
7167754Smsmith * distribution.
7267754Smsmith *
7367754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original
7467754Smsmith * Intel Code.
7567754Smsmith *
7667754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by
7767754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or
7867754Smsmith * other dealings in products derived from or relating to the Covered Code
7967754Smsmith * without prior written authorization from Intel.
8067754Smsmith *
8167754Smsmith * 4. Disclaimer and Export Compliance
8267754Smsmith *
8367754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
8467754Smsmith * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
8567754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
8667754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
8767754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
8867754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
8967754Smsmith * PARTICULAR PURPOSE.
9067754Smsmith *
9167754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
9267754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
9367754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
9467754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
9567754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
9667754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
9767754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
9867754Smsmith * LIMITED REMEDY.
9967754Smsmith *
10067754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this
10167754Smsmith * software or system incorporating such software without first obtaining any
10267754Smsmith * required license or other approval from the U. S. Department of Commerce or
10367754Smsmith * any other agency or department of the United States Government.  In the
10467754Smsmith * event Licensee exports any such software from the United States or
10567754Smsmith * re-exports any such software from a foreign destination, Licensee shall
10667754Smsmith * ensure that the distribution and export/re-export of the software is in
10767754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the
10867754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor
10967754Smsmith * any of its subsidiaries will export/re-export any technical data, process,
11067754Smsmith * software, or service, directly or indirectly, to any country for which the
11167754Smsmith * United States government or any agency thereof requires an export license,
11267754Smsmith * other governmental approval, or letter of assurance, without first obtaining
11367754Smsmith * such license, approval or letter.
11467754Smsmith *
11567754Smsmith *****************************************************************************/
11667754Smsmith
11767754Smsmith#define __NSDUMP_C__
11867754Smsmith
119193341Sjkim#include <contrib/dev/acpica/include/acpi.h>
120193341Sjkim#include <contrib/dev/acpica/include/accommon.h>
121193341Sjkim#include <contrib/dev/acpica/include/acnamesp.h>
12267754Smsmith
12367754Smsmith
12477424Smsmith#define _COMPONENT          ACPI_NAMESPACE
12591116Smsmith        ACPI_MODULE_NAME    ("nsdump")
12667754Smsmith
127151937Sjkim/* Local prototypes */
128123315Snjl
129151937Sjkim#ifdef ACPI_OBSOLETE_FUNCTIONS
130151937Sjkimvoid
131151937SjkimAcpiNsDumpRootDevices (
132151937Sjkim    void);
133151937Sjkim
134151937Sjkimstatic ACPI_STATUS
135151937SjkimAcpiNsDumpOneDevice (
136151937Sjkim    ACPI_HANDLE             ObjHandle,
137151937Sjkim    UINT32                  Level,
138151937Sjkim    void                    *Context,
139151937Sjkim    void                    **ReturnValue);
140151937Sjkim#endif
141151937Sjkim
142151937Sjkim
143102550Siwasaki#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
14477424Smsmith/*******************************************************************************
14567754Smsmith *
14687031Smsmith * FUNCTION:    AcpiNsPrintPathname
14787031Smsmith *
148151937Sjkim * PARAMETERS:  NumSegments         - Number of ACPI name segments
14987031Smsmith *              Pathname            - The compressed (internal) path
15087031Smsmith *
151151937Sjkim * RETURN:      None
152151937Sjkim *
15387031Smsmith * DESCRIPTION: Print an object's full namespace pathname
15487031Smsmith *
15587031Smsmith ******************************************************************************/
15687031Smsmith
15787031Smsmithvoid
15887031SmsmithAcpiNsPrintPathname (
15987031Smsmith    UINT32                  NumSegments,
16087031Smsmith    char                    *Pathname)
16187031Smsmith{
162193267Sjkim    UINT32                  i;
163151937Sjkim
164151937Sjkim
165167802Sjkim    ACPI_FUNCTION_NAME (NsPrintPathname);
16687031Smsmith
16787031Smsmith
16887031Smsmith    if (!(AcpiDbgLevel & ACPI_LV_NAMES) || !(AcpiDbgLayer & ACPI_NAMESPACE))
16987031Smsmith    {
17087031Smsmith        return;
17187031Smsmith    }
17287031Smsmith
173123315Snjl    /* Print the entire name */
17487031Smsmith
17587031Smsmith    ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "["));
17687031Smsmith
17791116Smsmith    while (NumSegments)
17887031Smsmith    {
179151937Sjkim        for (i = 0; i < 4; i++)
180151937Sjkim        {
181151937Sjkim            ACPI_IS_PRINT (Pathname[i]) ?
182151937Sjkim                AcpiOsPrintf ("%c", Pathname[i]) :
183151937Sjkim                AcpiOsPrintf ("?");
184151937Sjkim        }
185151937Sjkim
18691116Smsmith        Pathname += ACPI_NAME_SIZE;
18791116Smsmith        NumSegments--;
18891116Smsmith        if (NumSegments)
18991116Smsmith        {
19091116Smsmith            AcpiOsPrintf (".");
19191116Smsmith        }
19287031Smsmith    }
19387031Smsmith
19487031Smsmith    AcpiOsPrintf ("]\n");
19587031Smsmith}
19687031Smsmith
19787031Smsmith
19887031Smsmith/*******************************************************************************
19987031Smsmith *
20067754Smsmith * FUNCTION:    AcpiNsDumpPathname
20167754Smsmith *
20267754Smsmith * PARAMETERS:  Handle              - Object
20367754Smsmith *              Msg                 - Prefix message
20467754Smsmith *              Level               - Desired debug level
20567754Smsmith *              Component           - Caller's component ID
20667754Smsmith *
207151937Sjkim * RETURN:      None
208151937Sjkim *
20967754Smsmith * DESCRIPTION: Print an object's full namespace pathname
21067754Smsmith *              Manages allocation/freeing of a pathname buffer
21167754Smsmith *
21277424Smsmith ******************************************************************************/
21367754Smsmith
214114237Snjlvoid
21567754SmsmithAcpiNsDumpPathname (
21667754Smsmith    ACPI_HANDLE             Handle,
217114237Snjl    char                    *Msg,
21867754Smsmith    UINT32                  Level,
21967754Smsmith    UINT32                  Component)
22067754Smsmith{
22167754Smsmith
222167802Sjkim    ACPI_FUNCTION_TRACE (NsDumpPathname);
22367754Smsmith
22483174Smsmith
22567754Smsmith    /* Do this only if the requested debug level and component are enabled */
22667754Smsmith
22767754Smsmith    if (!(AcpiDbgLevel & Level) || !(AcpiDbgLayer & Component))
22867754Smsmith    {
229114237Snjl        return_VOID;
23067754Smsmith    }
23167754Smsmith
23267754Smsmith    /* Convert handle to a full pathname and print it (with supplied message) */
23367754Smsmith
234114237Snjl    AcpiNsPrintNodePathname (Handle, Msg);
235114237Snjl    AcpiOsPrintf ("\n");
236114237Snjl    return_VOID;
23767754Smsmith}
23867754Smsmith
23967754Smsmith
24077424Smsmith/*******************************************************************************
24167754Smsmith *
24267754Smsmith * FUNCTION:    AcpiNsDumpOneObject
24367754Smsmith *
244151937Sjkim * PARAMETERS:  ObjHandle           - Node to be dumped
24567754Smsmith *              Level               - Nesting level of the handle
24667754Smsmith *              Context             - Passed into WalkNamespace
247151937Sjkim *              ReturnValue         - Not used
24867754Smsmith *
249151937Sjkim * RETURN:      Status
250151937Sjkim *
25167754Smsmith * DESCRIPTION: Dump a single Node
25267754Smsmith *              This procedure is a UserFunction called by AcpiNsWalkNamespace.
25367754Smsmith *
25477424Smsmith ******************************************************************************/
25567754Smsmith
25667754SmsmithACPI_STATUS
25767754SmsmithAcpiNsDumpOneObject (
25867754Smsmith    ACPI_HANDLE             ObjHandle,
25967754Smsmith    UINT32                  Level,
26067754Smsmith    void                    *Context,
26167754Smsmith    void                    **ReturnValue)
26267754Smsmith{
26367754Smsmith    ACPI_WALK_INFO          *Info = (ACPI_WALK_INFO *) Context;
26467754Smsmith    ACPI_NAMESPACE_NODE     *ThisNode;
26567754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc = NULL;
26691116Smsmith    ACPI_OBJECT_TYPE        ObjType;
26791116Smsmith    ACPI_OBJECT_TYPE        Type;
26867754Smsmith    UINT32                  BytesToDump;
269107325Siwasaki    UINT32                  DbgLevel;
27085756Smsmith    UINT32                  i;
27167754Smsmith
27267754Smsmith
273167802Sjkim    ACPI_FUNCTION_NAME (NsDumpOneObject);
27482367Smsmith
27582367Smsmith
276107325Siwasaki    /* Is output enabled? */
27767754Smsmith
27867754Smsmith    if (!(AcpiDbgLevel & Info->DebugLevel))
27967754Smsmith    {
28067754Smsmith        return (AE_OK);
28167754Smsmith    }
28267754Smsmith
28367754Smsmith    if (!ObjHandle)
28467754Smsmith    {
28582367Smsmith        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n"));
28667754Smsmith        return (AE_OK);
28767754Smsmith    }
28867754Smsmith
289107325Siwasaki    ThisNode = AcpiNsMapHandleToNode (ObjHandle);
290193267Sjkim    if (!ThisNode)
291193267Sjkim    {
292193267Sjkim        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Invalid object handle %p\n",
293193267Sjkim            ObjHandle));
294193267Sjkim        return (AE_OK);
295193267Sjkim    }
296193267Sjkim
297107325Siwasaki    Type = ThisNode->Type;
298107325Siwasaki
29967754Smsmith    /* Check if the owner matches */
30067754Smsmith
301151937Sjkim    if ((Info->OwnerId != ACPI_OWNER_ID_MAX) &&
30267754Smsmith        (Info->OwnerId != ThisNode->OwnerId))
30367754Smsmith    {
30467754Smsmith        return (AE_OK);
30567754Smsmith    }
30667754Smsmith
307151937Sjkim    if (!(Info->DisplayType & ACPI_DISPLAY_SHORT))
308151937Sjkim    {
309151937Sjkim        /* Indent the object according to the level */
31067754Smsmith
311151937Sjkim        AcpiOsPrintf ("%2d%*s", (UINT32) Level - 1, (int) Level * 2, " ");
31267754Smsmith
313151937Sjkim        /* Check the node type and name */
31467754Smsmith
315151937Sjkim        if (Type > ACPI_TYPE_LOCAL_MAX)
316151937Sjkim        {
317167802Sjkim            ACPI_WARNING ((AE_INFO, "Invalid ACPI Object Type %08X", Type));
318151937Sjkim        }
31967754Smsmith
320151937Sjkim        AcpiOsPrintf ("%4.4s", AcpiUtGetNodeName (ThisNode));
32167754Smsmith    }
32267754Smsmith
323193267Sjkim    /* Now we can print out the pertinent information */
324193267Sjkim
325167802Sjkim    AcpiOsPrintf (" %-12s %p %2.2X ",
326167802Sjkim            AcpiUtGetTypeName (Type), ThisNode, ThisNode->OwnerId);
32767754Smsmith
32891116Smsmith    DbgLevel = AcpiDbgLevel;
32991116Smsmith    AcpiDbgLevel = 0;
33087031Smsmith    ObjDesc = AcpiNsGetAttachedObject (ThisNode);
33191116Smsmith    AcpiDbgLevel = DbgLevel;
33267754Smsmith
333167802Sjkim    /* Temp nodes are those nodes created by a control method */
334167802Sjkim
335167802Sjkim    if (ThisNode->Flags & ANOBJ_TEMPORARY)
336167802Sjkim    {
337167802Sjkim        AcpiOsPrintf ("(T) ");
338167802Sjkim    }
339167802Sjkim
340151937Sjkim    switch (Info->DisplayType & ACPI_DISPLAY_MASK)
34167754Smsmith    {
34285756Smsmith    case ACPI_DISPLAY_SUMMARY:
34367754Smsmith
34485756Smsmith        if (!ObjDesc)
34585756Smsmith        {
34685756Smsmith            /* No attached object, we are done */
34767754Smsmith
34887031Smsmith            AcpiOsPrintf ("\n");
34985756Smsmith            return (AE_OK);
35085756Smsmith        }
35167754Smsmith
35285756Smsmith        switch (Type)
35385756Smsmith        {
35485756Smsmith        case ACPI_TYPE_PROCESSOR:
355102550Siwasaki
356107325Siwasaki            AcpiOsPrintf ("ID %X Len %.4X Addr %p\n",
357138287Smarks                ObjDesc->Processor.ProcId, ObjDesc->Processor.Length,
358193267Sjkim                ACPI_CAST_PTR (void, ObjDesc->Processor.Address));
35985756Smsmith            break;
36067754Smsmith
36199146Siwasaki
36285756Smsmith        case ACPI_TYPE_DEVICE:
363102550Siwasaki
364123315Snjl            AcpiOsPrintf ("Notify Object: %p\n", ObjDesc);
36585756Smsmith            break;
36667754Smsmith
36799146Siwasaki
36885756Smsmith        case ACPI_TYPE_METHOD:
369102550Siwasaki
370107325Siwasaki            AcpiOsPrintf ("Args %X Len %.4X Aml %p\n",
371138287Smarks                (UINT32) ObjDesc->Method.ParamCount,
372138287Smarks                ObjDesc->Method.AmlLength, ObjDesc->Method.AmlStart);
37385756Smsmith            break;
37467754Smsmith
37599146Siwasaki
37685756Smsmith        case ACPI_TYPE_INTEGER:
377102550Siwasaki
378107325Siwasaki            AcpiOsPrintf ("= %8.8X%8.8X\n",
379138287Smarks                ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
38085756Smsmith            break;
38167754Smsmith
38299146Siwasaki
38385756Smsmith        case ACPI_TYPE_PACKAGE:
38499146Siwasaki
38599146Siwasaki            if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
38699146Siwasaki            {
387107325Siwasaki                AcpiOsPrintf ("Elements %.2X\n",
388138287Smarks                    ObjDesc->Package.Count);
38999146Siwasaki            }
39099146Siwasaki            else
39199146Siwasaki            {
392107325Siwasaki                AcpiOsPrintf ("[Length not yet evaluated]\n");
39399146Siwasaki            }
39485756Smsmith            break;
39567754Smsmith
39699146Siwasaki
39785756Smsmith        case ACPI_TYPE_BUFFER:
39867754Smsmith
39999146Siwasaki            if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
40099146Siwasaki            {
401107325Siwasaki                AcpiOsPrintf ("Len %.2X",
40299146Siwasaki                            ObjDesc->Buffer.Length);
40367754Smsmith
40499146Siwasaki                /* Dump some of the buffer */
40599146Siwasaki
40699146Siwasaki                if (ObjDesc->Buffer.Length > 0)
40785756Smsmith                {
40899146Siwasaki                    AcpiOsPrintf (" =");
40999146Siwasaki                    for (i = 0; (i < ObjDesc->Buffer.Length && i < 12); i++)
41099146Siwasaki                    {
41199679Siwasaki                        AcpiOsPrintf (" %.2hX", ObjDesc->Buffer.Pointer[i]);
41299146Siwasaki                    }
41385756Smsmith                }
41499146Siwasaki                AcpiOsPrintf ("\n");
41585756Smsmith            }
41699146Siwasaki            else
41799146Siwasaki            {
418107325Siwasaki                AcpiOsPrintf ("[Length not yet evaluated]\n");
41999146Siwasaki            }
42085756Smsmith            break;
42167754Smsmith
42299146Siwasaki
42385756Smsmith        case ACPI_TYPE_STRING:
424102550Siwasaki
425107325Siwasaki            AcpiOsPrintf ("Len %.2X ", ObjDesc->String.Length);
426107325Siwasaki            AcpiUtPrintString (ObjDesc->String.Pointer, 32);
42787031Smsmith            AcpiOsPrintf ("\n");
42885756Smsmith            break;
42967754Smsmith
43099146Siwasaki
43185756Smsmith        case ACPI_TYPE_REGION:
432102550Siwasaki
433138287Smarks            AcpiOsPrintf ("[%s]",
434138287Smarks                AcpiUtGetRegionName (ObjDesc->Region.SpaceId));
43585756Smsmith            if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
43685756Smsmith            {
43787031Smsmith                AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n",
438193267Sjkim                    ACPI_FORMAT_NATIVE_UINT (ObjDesc->Region.Address),
439138287Smarks                    ObjDesc->Region.Length);
44085756Smsmith            }
44185756Smsmith            else
44285756Smsmith            {
44399146Siwasaki                AcpiOsPrintf (" [Address/Length not yet evaluated]\n");
44485756Smsmith            }
44585756Smsmith            break;
44667754Smsmith
44799146Siwasaki
448107325Siwasaki        case ACPI_TYPE_LOCAL_REFERENCE:
449102550Siwasaki
450193267Sjkim            AcpiOsPrintf ("[%s]\n", AcpiUtGetReferenceName (ObjDesc));
45185756Smsmith            break;
45267754Smsmith
45399146Siwasaki
45485756Smsmith        case ACPI_TYPE_BUFFER_FIELD:
455102550Siwasaki
45687031Smsmith            if (ObjDesc->BufferField.BufferObj &&
45787031Smsmith                ObjDesc->BufferField.BufferObj->Buffer.Node)
45887031Smsmith            {
459107325Siwasaki                AcpiOsPrintf ("Buf [%4.4s]",
460193267Sjkim                    AcpiUtGetNodeName (
461193267Sjkim                        ObjDesc->BufferField.BufferObj->Buffer.Node));
46287031Smsmith            }
46385756Smsmith            break;
46485756Smsmith
46599146Siwasaki
466107325Siwasaki        case ACPI_TYPE_LOCAL_REGION_FIELD:
467102550Siwasaki
468107325Siwasaki            AcpiOsPrintf ("Rgn [%4.4s]",
469193267Sjkim                AcpiUtGetNodeName (
470193267Sjkim                    ObjDesc->CommonField.RegionObj->Region.Node));
47185756Smsmith            break;
47285756Smsmith
47399146Siwasaki
474107325Siwasaki        case ACPI_TYPE_LOCAL_BANK_FIELD:
475102550Siwasaki
476107325Siwasaki            AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]",
477193267Sjkim                AcpiUtGetNodeName (
478193267Sjkim                    ObjDesc->CommonField.RegionObj->Region.Node),
479193267Sjkim                AcpiUtGetNodeName (
480193267Sjkim                    ObjDesc->BankField.BankObj->CommonField.Node));
48185756Smsmith            break;
48285756Smsmith
48399146Siwasaki
484107325Siwasaki        case ACPI_TYPE_LOCAL_INDEX_FIELD:
485102550Siwasaki
486107325Siwasaki            AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]",
487193267Sjkim                AcpiUtGetNodeName (
488193267Sjkim                    ObjDesc->IndexField.IndexObj->CommonField.Node),
489193267Sjkim                AcpiUtGetNodeName (
490193267Sjkim                    ObjDesc->IndexField.DataObj->CommonField.Node));
49185756Smsmith            break;
49285756Smsmith
49399146Siwasaki
494107325Siwasaki        case ACPI_TYPE_LOCAL_ALIAS:
495128212Snjl        case ACPI_TYPE_LOCAL_METHOD_ALIAS:
496104470Siwasaki
497138287Smarks            AcpiOsPrintf ("Target %4.4s (%p)\n",
498138287Smarks                AcpiUtGetNodeName (ObjDesc), ObjDesc);
499104470Siwasaki            break;
500104470Siwasaki
50185756Smsmith        default:
502102550Siwasaki
503107325Siwasaki            AcpiOsPrintf ("Object %p\n", ObjDesc);
50485756Smsmith            break;
50585756Smsmith        }
50685756Smsmith
50785756Smsmith        /* Common field handling */
50885756Smsmith
50985756Smsmith        switch (Type)
51085756Smsmith        {
51185756Smsmith        case ACPI_TYPE_BUFFER_FIELD:
512107325Siwasaki        case ACPI_TYPE_LOCAL_REGION_FIELD:
513107325Siwasaki        case ACPI_TYPE_LOCAL_BANK_FIELD:
514107325Siwasaki        case ACPI_TYPE_LOCAL_INDEX_FIELD:
515107325Siwasaki
516123315Snjl            AcpiOsPrintf (" Off %.3X Len %.2X Acc %.2hd\n",
517138287Smarks                (ObjDesc->CommonField.BaseByteOffset * 8)
518138287Smarks                    + ObjDesc->CommonField.StartFieldBitOffset,
519138287Smarks                ObjDesc->CommonField.BitLength,
520138287Smarks                ObjDesc->CommonField.AccessByteWidth);
52185756Smsmith            break;
522102550Siwasaki
52399679Siwasaki        default:
52499679Siwasaki            break;
52585756Smsmith        }
52667754Smsmith        break;
52767754Smsmith
52867754Smsmith
52985756Smsmith    case ACPI_DISPLAY_OBJECTS:
53067754Smsmith
531107325Siwasaki        AcpiOsPrintf ("O:%p", ObjDesc);
53285756Smsmith        if (!ObjDesc)
53385756Smsmith        {
53485756Smsmith            /* No attached object, we are done */
53585756Smsmith
53687031Smsmith            AcpiOsPrintf ("\n");
53785756Smsmith            return (AE_OK);
53885756Smsmith        }
53985756Smsmith
540151937Sjkim        AcpiOsPrintf ("(R%d)", ObjDesc->Common.ReferenceCount);
54185756Smsmith
54285756Smsmith        switch (Type)
54385756Smsmith        {
54485756Smsmith        case ACPI_TYPE_METHOD:
54585756Smsmith
54685756Smsmith            /* Name is a Method and its AML offset/length are set */
54785756Smsmith
54887031Smsmith            AcpiOsPrintf (" M:%p-%X\n", ObjDesc->Method.AmlStart,
549193267Sjkim                ObjDesc->Method.AmlLength);
55085756Smsmith            break;
55185756Smsmith
55285756Smsmith        case ACPI_TYPE_INTEGER:
55385756Smsmith
554123315Snjl            AcpiOsPrintf (" I:%8.8X8.8%X\n",
555193267Sjkim                ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
55685756Smsmith            break;
55785756Smsmith
55885756Smsmith        case ACPI_TYPE_STRING:
55985756Smsmith
56087031Smsmith            AcpiOsPrintf (" S:%p-%X\n", ObjDesc->String.Pointer,
561193267Sjkim                ObjDesc->String.Length);
56285756Smsmith            break;
56385756Smsmith
56485756Smsmith        case ACPI_TYPE_BUFFER:
56585756Smsmith
56687031Smsmith            AcpiOsPrintf (" B:%p-%X\n", ObjDesc->Buffer.Pointer,
567193267Sjkim                ObjDesc->Buffer.Length);
56885756Smsmith            break;
56985756Smsmith
57085756Smsmith        default:
57185756Smsmith
57287031Smsmith            AcpiOsPrintf ("\n");
57385756Smsmith            break;
57485756Smsmith        }
57567754Smsmith        break;
57687031Smsmith
57787031Smsmith
57887031Smsmith    default:
57987031Smsmith        AcpiOsPrintf ("\n");
58087031Smsmith        break;
58167754Smsmith    }
58267754Smsmith
58367754Smsmith    /* If debug turned off, done */
58467754Smsmith
58582367Smsmith    if (!(AcpiDbgLevel & ACPI_LV_VALUES))
58667754Smsmith    {
58767754Smsmith        return (AE_OK);
58867754Smsmith    }
58967754Smsmith
59067754Smsmith    /* If there is an attached object, display it */
59167754Smsmith
592104470Siwasaki    DbgLevel     = AcpiDbgLevel;
59391116Smsmith    AcpiDbgLevel = 0;
594104470Siwasaki    ObjDesc      = AcpiNsGetAttachedObject (ThisNode);
59591116Smsmith    AcpiDbgLevel = DbgLevel;
59667754Smsmith
59767754Smsmith    /* Dump attached objects */
59867754Smsmith
59985756Smsmith    while (ObjDesc)
60067754Smsmith    {
601107325Siwasaki        ObjType = ACPI_TYPE_INVALID;
602151937Sjkim        AcpiOsPrintf ("Attached Object %p: ", ObjDesc);
60367754Smsmith
60467754Smsmith        /* Decode the type of attached object and dump the contents */
60567754Smsmith
60691116Smsmith        switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
60791116Smsmith        {
60891116Smsmith        case ACPI_DESC_TYPE_NAMED:
60967754Smsmith
61087031Smsmith            AcpiOsPrintf ("(Ptr to Node)\n");
61167754Smsmith            BytesToDump = sizeof (ACPI_NAMESPACE_NODE);
612151937Sjkim            ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
61391116Smsmith            break;
61467754Smsmith
61599679Siwasaki        case ACPI_DESC_TYPE_OPERAND:
61691116Smsmith
617193267Sjkim            ObjType = ObjDesc->Common.Type;
61867754Smsmith
619107325Siwasaki            if (ObjType > ACPI_TYPE_LOCAL_MAX)
62067754Smsmith            {
621193267Sjkim                AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [UNKNOWN])\n",
622138287Smarks                    ObjType);
62367754Smsmith                BytesToDump = 32;
62467754Smsmith            }
62567754Smsmith            else
62667754Smsmith            {
627193267Sjkim                AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [%s])\n",
628151937Sjkim                    ObjType, AcpiUtGetTypeName (ObjType));
62967754Smsmith                BytesToDump = sizeof (ACPI_OPERAND_OBJECT);
63067754Smsmith            }
631151937Sjkim
632151937Sjkim            ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
63391116Smsmith            break;
63491116Smsmith
63591116Smsmith        default:
63691116Smsmith
63791116Smsmith            break;
63867754Smsmith        }
63967754Smsmith
64067754Smsmith        /* If value is NOT an internal object, we are done */
64167754Smsmith
64299679Siwasaki        if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
64367754Smsmith        {
64467754Smsmith            goto Cleanup;
64567754Smsmith        }
64667754Smsmith
647193267Sjkim        /* Valid object, get the pointer to next level, if any */
648193267Sjkim
64967754Smsmith        switch (ObjType)
65067754Smsmith        {
651151937Sjkim        case ACPI_TYPE_BUFFER:
65267754Smsmith        case ACPI_TYPE_STRING:
653151937Sjkim            /*
654151937Sjkim             * NOTE: takes advantage of common fields between string/buffer
655151937Sjkim             */
656151937Sjkim            BytesToDump = ObjDesc->String.Length;
65799679Siwasaki            ObjDesc = (void *) ObjDesc->String.Pointer;
658151937Sjkim            AcpiOsPrintf ( "(Buffer/String pointer %p length %X)\n",
659151937Sjkim                ObjDesc, BytesToDump);
660151937Sjkim            ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
661151937Sjkim            goto Cleanup;
66267754Smsmith
66377424Smsmith        case ACPI_TYPE_BUFFER_FIELD:
66485756Smsmith            ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->BufferField.BufferObj;
66577424Smsmith            break;
66677424Smsmith
66767754Smsmith        case ACPI_TYPE_PACKAGE:
66899679Siwasaki            ObjDesc = (void *) ObjDesc->Package.Elements;
66967754Smsmith            break;
67067754Smsmith
67167754Smsmith        case ACPI_TYPE_METHOD:
67299679Siwasaki            ObjDesc = (void *) ObjDesc->Method.AmlStart;
67367754Smsmith            break;
67467754Smsmith
675107325Siwasaki        case ACPI_TYPE_LOCAL_REGION_FIELD:
67699679Siwasaki            ObjDesc = (void *) ObjDesc->Field.RegionObj;
67767754Smsmith            break;
67867754Smsmith
679107325Siwasaki        case ACPI_TYPE_LOCAL_BANK_FIELD:
68099679Siwasaki            ObjDesc = (void *) ObjDesc->BankField.RegionObj;
68167754Smsmith            break;
68267754Smsmith
683107325Siwasaki        case ACPI_TYPE_LOCAL_INDEX_FIELD:
68499679Siwasaki            ObjDesc = (void *) ObjDesc->IndexField.IndexObj;
68567754Smsmith            break;
68667754Smsmith
68799679Siwasaki        default:
68867754Smsmith            goto Cleanup;
68967754Smsmith        }
69067754Smsmith
691107325Siwasaki        ObjType = ACPI_TYPE_INVALID;   /* Terminate loop after next pass */
69267754Smsmith    }
69367754Smsmith
69467754SmsmithCleanup:
69587031Smsmith    AcpiOsPrintf ("\n");
69667754Smsmith    return (AE_OK);
69767754Smsmith}
69867754Smsmith
69967754Smsmith
70077424Smsmith/*******************************************************************************
70167754Smsmith *
70267754Smsmith * FUNCTION:    AcpiNsDumpObjects
70367754Smsmith *
70467754Smsmith * PARAMETERS:  Type                - Object type to be dumped
705151937Sjkim *              DisplayType         - 0 or ACPI_DISPLAY_SUMMARY
706138287Smarks *              MaxDepth            - Maximum depth of dump. Use ACPI_UINT32_MAX
70767754Smsmith *                                    for an effectively unlimited depth.
708193267Sjkim *              OwnerId             - Dump only objects owned by this ID. Use
70967754Smsmith *                                    ACPI_UINT32_MAX to match all owners.
71067754Smsmith *              StartHandle         - Where in namespace to start/end search
71167754Smsmith *
712151937Sjkim * RETURN:      None
713151937Sjkim *
714193267Sjkim * DESCRIPTION: Dump typed objects within the loaded namespace. Uses
715193267Sjkim *              AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject.
71667754Smsmith *
71777424Smsmith ******************************************************************************/
71867754Smsmith
71967754Smsmithvoid
72067754SmsmithAcpiNsDumpObjects (
72191116Smsmith    ACPI_OBJECT_TYPE        Type,
72285756Smsmith    UINT8                   DisplayType,
72367754Smsmith    UINT32                  MaxDepth,
724151937Sjkim    ACPI_OWNER_ID           OwnerId,
72567754Smsmith    ACPI_HANDLE             StartHandle)
72667754Smsmith{
72767754Smsmith    ACPI_WALK_INFO          Info;
72867754Smsmith
72967754Smsmith
73091116Smsmith    ACPI_FUNCTION_ENTRY ();
73183174Smsmith
73283174Smsmith
73382367Smsmith    Info.DebugLevel = ACPI_LV_TABLES;
73467754Smsmith    Info.OwnerId = OwnerId;
73585756Smsmith    Info.DisplayType = DisplayType;
73667754Smsmith
737102550Siwasaki    (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
738167802Sjkim                ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,
739199337Sjkim                AcpiNsDumpOneObject, NULL, (void *) &Info, NULL);
74067754Smsmith}
74167754Smsmith
74267754Smsmith
74377424Smsmith/*******************************************************************************
74467754Smsmith *
745151937Sjkim * FUNCTION:    AcpiNsDumpEntry
746151937Sjkim *
747151937Sjkim * PARAMETERS:  Handle              - Node to be dumped
748151937Sjkim *              DebugLevel          - Output level
749151937Sjkim *
750151937Sjkim * RETURN:      None
751151937Sjkim *
752151937Sjkim * DESCRIPTION: Dump a single Node
753151937Sjkim *
754151937Sjkim ******************************************************************************/
755151937Sjkim
756151937Sjkimvoid
757151937SjkimAcpiNsDumpEntry (
758151937Sjkim    ACPI_HANDLE             Handle,
759151937Sjkim    UINT32                  DebugLevel)
760151937Sjkim{
761151937Sjkim    ACPI_WALK_INFO          Info;
762151937Sjkim
763151937Sjkim
764151937Sjkim    ACPI_FUNCTION_ENTRY ();
765151937Sjkim
766151937Sjkim
767151937Sjkim    Info.DebugLevel = DebugLevel;
768151937Sjkim    Info.OwnerId = ACPI_OWNER_ID_MAX;
769151937Sjkim    Info.DisplayType = ACPI_DISPLAY_SUMMARY;
770151937Sjkim
771151937Sjkim    (void) AcpiNsDumpOneObject (Handle, 1, &Info, NULL);
772151937Sjkim}
773151937Sjkim
774151937Sjkim
775151937Sjkim#ifdef ACPI_ASL_COMPILER
776151937Sjkim/*******************************************************************************
777151937Sjkim *
77867754Smsmith * FUNCTION:    AcpiNsDumpTables
77967754Smsmith *
78067754Smsmith * PARAMETERS:  SearchBase          - Root of subtree to be dumped, or
78167754Smsmith *                                    NS_ALL to dump the entire namespace
78267754Smsmith *              MaxDepth            - Maximum depth of dump.  Use INT_MAX
78367754Smsmith *                                    for an effectively unlimited depth.
78467754Smsmith *
785151937Sjkim * RETURN:      None
786151937Sjkim *
78767754Smsmith * DESCRIPTION: Dump the name space, or a portion of it.
78867754Smsmith *
78977424Smsmith ******************************************************************************/
79067754Smsmith
79167754Smsmithvoid
79267754SmsmithAcpiNsDumpTables (
79367754Smsmith    ACPI_HANDLE             SearchBase,
79467754Smsmith    UINT32                  MaxDepth)
79567754Smsmith{
79667754Smsmith    ACPI_HANDLE             SearchHandle = SearchBase;
79767754Smsmith
79867754Smsmith
799167802Sjkim    ACPI_FUNCTION_TRACE (NsDumpTables);
80067754Smsmith
80167754Smsmith
80267754Smsmith    if (!AcpiGbl_RootNode)
80367754Smsmith    {
80467754Smsmith        /*
80567754Smsmith         * If the name space has not been initialized,
80667754Smsmith         * there is nothing to dump.
80767754Smsmith         */
808104470Siwasaki        ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "namespace not initialized!\n"));
80967754Smsmith        return_VOID;
81067754Smsmith    }
81167754Smsmith
81291116Smsmith    if (ACPI_NS_ALL == SearchBase)
81367754Smsmith    {
814151937Sjkim        /* Entire namespace */
81567754Smsmith
81667754Smsmith        SearchHandle = AcpiGbl_RootNode;
81782367Smsmith        ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n"));
81867754Smsmith    }
81967754Smsmith
82087031Smsmith    AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, MaxDepth,
821151937Sjkim            ACPI_OWNER_ID_MAX, SearchHandle);
82267754Smsmith    return_VOID;
82367754Smsmith}
82467754Smsmith#endif
825151937Sjkim#endif
82667754Smsmith
827