nsdump.c revision 229989
1139804Simp/******************************************************************************
21541Srgrimes *
31541Srgrimes * Module Name: nsdump - table dumping routines for debug
41541Srgrimes *
51541Srgrimes *****************************************************************************/
61541Srgrimes
71541Srgrimes/*
81541Srgrimes * Copyright (C) 2000 - 2012, Intel Corp.
91541Srgrimes * All rights reserved.
101541Srgrimes *
111541Srgrimes * Redistribution and use in source and binary forms, with or without
121541Srgrimes * modification, are permitted provided that the following conditions
131541Srgrimes * are met:
141541Srgrimes * 1. Redistributions of source code must retain the above copyright
151541Srgrimes *    notice, this list of conditions, and the following disclaimer,
161541Srgrimes *    without modification.
171541Srgrimes * 2. Redistributions in binary form must reproduce at minimum a disclaimer
181541Srgrimes *    substantially similar to the "NO WARRANTY" disclaimer below
191541Srgrimes *    ("Disclaimer") and any redistribution must be conditioned upon
201541Srgrimes *    including a substantially similar Disclaimer requirement for further
211541Srgrimes *    binary redistribution.
221541Srgrimes * 3. Neither the names of the above-listed copyright holders nor the names
231541Srgrimes *    of any contributors may be used to endorse or promote products derived
241541Srgrimes *    from this software without specific prior written permission.
251541Srgrimes *
261541Srgrimes * Alternatively, this software may be distributed under the terms of the
271541Srgrimes * GNU General Public License ("GPL") version 2 as published by the Free
281541Srgrimes * Software Foundation.
291541Srgrimes *
301541Srgrimes * NO WARRANTY
311541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
321541Srgrimes * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
331541Srgrimes * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
341541Srgrimes * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
351541Srgrimes * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
361541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37116182Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38116182Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39116182Sobrien * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
4013203Swollman * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41101127Srwatson * POSSIBILITY OF SUCH DAMAGES.
42144613Sjeff */
4313203Swollman
441541Srgrimes#define __NSDUMP_C__
452112Swollman
4669664Speter#include <contrib/dev/acpica/include/acpi.h>
4776166Smarkm#include <contrib/dev/acpica/include/accommon.h>
4889316Salfred#include <contrib/dev/acpica/include/acnamesp.h>
491541Srgrimes
501541Srgrimes
511541Srgrimes#define _COMPONENT          ACPI_NAMESPACE
521541Srgrimes        ACPI_MODULE_NAME    ("nsdump")
531541Srgrimes
54141471Sjhb/* Local prototypes */
55144613Sjeff
561541Srgrimes#ifdef ACPI_OBSOLETE_FUNCTIONS
571541Srgrimesvoid
581541SrgrimesAcpiNsDumpRootDevices (
591541Srgrimes    void);
60155334Srwatson
61163606Srwatsonstatic ACPI_STATUS
62155334SrwatsonAcpiNsDumpOneDevice (
6392751Sjeff    ACPI_HANDLE             ObjHandle,
6432011Sbde    UINT32                  Level,
65155168Sjeff    void                    *Context,
66138345Sphk    void                    **ReturnValue);
67138345Sphk#endif
681541Srgrimes
6969664Speter
7069664Speter#if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
7192751Sjeff/*******************************************************************************
7269664Speter *
7369664Speter * FUNCTION:    AcpiNsPrintPathname
7469664Speter *
7569664Speter * PARAMETERS:  NumSegments         - Number of ACPI name segments
7692654Sjeff *              Pathname            - The compressed (internal) path
7792654Sjeff *
7869664Speter * RETURN:      None
7969664Speter *
8069664Speter * DESCRIPTION: Print an object's full namespace pathname
8169664Speter *
82144613Sjeff ******************************************************************************/
83144613Sjeff
84144613Sjeffvoid
85144613SjeffAcpiNsPrintPathname (
86144613Sjeff    UINT32                  NumSegments,
87144613Sjeff    char                    *Pathname)
88144613Sjeff{
89144613Sjeff    UINT32                  i;
9069664Speter
91161010Srwatson
921541Srgrimes    ACPI_FUNCTION_NAME (NsPrintPathname);
931541Srgrimes
941541Srgrimes
951541Srgrimes    if (!(AcpiDbgLevel & ACPI_LV_NAMES) || !(AcpiDbgLayer & ACPI_NAMESPACE))
961541Srgrimes    {
971541Srgrimes        return;
981541Srgrimes    }
991541Srgrimes
1001541Srgrimes    /* Print the entire name */
1011541Srgrimes
1021541Srgrimes    ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "["));
1031541Srgrimes
1041541Srgrimes    while (NumSegments)
1051541Srgrimes    {
1061541Srgrimes        for (i = 0; i < 4; i++)
1071541Srgrimes        {
1081541Srgrimes            ACPI_IS_PRINT (Pathname[i]) ?
1091541Srgrimes                AcpiOsPrintf ("%c", Pathname[i]) :
1101541Srgrimes                AcpiOsPrintf ("?");
111161011Srwatson        }
1121541Srgrimes
113161011Srwatson        Pathname += ACPI_NAME_SIZE;
114161011Srwatson        NumSegments--;
115161011Srwatson        if (NumSegments)
1161541Srgrimes        {
1171541Srgrimes            AcpiOsPrintf (".");
1181541Srgrimes        }
1191541Srgrimes    }
12083366Sjulian
12183366Sjulian    AcpiOsPrintf ("]\n");
122140714Sjeff}
1231541Srgrimes
124150164Scsjp
125150164Scsjp/*******************************************************************************
12691419Sjhb *
12783366Sjulian * FUNCTION:    AcpiNsDumpPathname
12842408Seivind *
12942453Seivind * PARAMETERS:  Handle              - Object
13042408Seivind *              Msg                 - Prefix message
13142453Seivind *              Level               - Desired debug level
132144613Sjeff *              Component           - Caller's component ID
133144613Sjeff *
13483366Sjulian * RETURN:      None
1351541Srgrimes *
1361541Srgrimes * DESCRIPTION: Print an object's full namespace pathname
1371541Srgrimes *              Manages allocation/freeing of a pathname buffer
1381541Srgrimes *
1391541Srgrimes ******************************************************************************/
1401541Srgrimes
141111119Simpvoid
1421541SrgrimesAcpiNsDumpPathname (
1431541Srgrimes    ACPI_HANDLE             Handle,
14436735Sdfr    char                    *Msg,
1451541Srgrimes    UINT32                  Level,
1461541Srgrimes    UINT32                  Component)
14736735Sdfr{
14820069Sbde
149155334Srwatson    ACPI_FUNCTION_TRACE (NsDumpPathname);
150155334Srwatson
151155334Srwatson
152155334Srwatson    /* Do this only if the requested debug level and component are enabled */
153155334Srwatson
154155334Srwatson    if (!(AcpiDbgLevel & Level) || !(AcpiDbgLayer & Component))
15520069Sbde    {
15620069Sbde        return_VOID;
15720069Sbde    }
15820069Sbde
15920069Sbde    /* Convert handle to a full pathname and print it (with supplied message) */
16020069Sbde
1611541Srgrimes    AcpiNsPrintNodePathname (Handle, Msg);
16292751Sjeff    AcpiOsPrintf ("\n");
163100613Srwatson    return_VOID;
164100613Srwatson}
165100613Srwatson
166100613Srwatson
1671541Srgrimes/*******************************************************************************
1681541Srgrimes *
1691541Srgrimes * FUNCTION:    AcpiNsDumpOneObject
1701541Srgrimes *
1711541Srgrimes * PARAMETERS:  ObjHandle           - Node to be dumped
17297994Sjhb *              Level               - Nesting level of the handle
17397994Sjhb *              Context             - Passed into WalkNamespace
17497994Sjhb *              ReturnValue         - Not used
17597994Sjhb *
17697994Sjhb * RETURN:      Status
1771541Srgrimes *
1781541Srgrimes * DESCRIPTION: Dump a single Node
1791541Srgrimes *              This procedure is a UserFunction called by AcpiNsWalkNamespace.
1801541Srgrimes *
1811541Srgrimes ******************************************************************************/
18289306Salfred
18333360SdysonACPI_STATUS
18451649SphkAcpiNsDumpOneObject (
18533360Sdyson    ACPI_HANDLE             ObjHandle,
1861541Srgrimes    UINT32                  Level,
187140714Sjeff    void                    *Context,
1881541Srgrimes    void                    **ReturnValue)
18989306Salfred{
1901541Srgrimes    ACPI_WALK_INFO          *Info = (ACPI_WALK_INFO *) Context;
1911541Srgrimes    ACPI_NAMESPACE_NODE     *ThisNode;
1921541Srgrimes    ACPI_OPERAND_OBJECT     *ObjDesc = NULL;
1931541Srgrimes    ACPI_OBJECT_TYPE        ObjType;
1941541Srgrimes    ACPI_OBJECT_TYPE        Type;
1951541Srgrimes    UINT32                  BytesToDump;
1961541Srgrimes    UINT32                  DbgLevel;
1971541Srgrimes    UINT32                  i;
198140714Sjeff
1991541Srgrimes
2001541Srgrimes    ACPI_FUNCTION_NAME (NsDumpOneObject);
2011541Srgrimes
2021541Srgrimes
2031541Srgrimes    /* Is output enabled? */
204140714Sjeff
2051541Srgrimes    if (!(AcpiDbgLevel & Info->DebugLevel))
2061541Srgrimes    {
207140714Sjeff        return (AE_OK);
208140714Sjeff    }
2091541Srgrimes
2103148Sphk    if (!ObjHandle)
2113148Sphk    {
21292751Sjeff        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n"));
213100613Srwatson        return (AE_OK);
214100613Srwatson    }
215100613Srwatson
216100613Srwatson    ThisNode = AcpiNsValidateHandle (ObjHandle);
2171541Srgrimes    if (!ThisNode)
2181541Srgrimes    {
219140714Sjeff        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Invalid object handle %p\n",
220140714Sjeff            ObjHandle));
2211541Srgrimes        return (AE_OK);
2221541Srgrimes    }
2231541Srgrimes
2241541Srgrimes    Type = ThisNode->Type;
225100613Srwatson
22692751Sjeff    /* Check if the owner matches */
227100613Srwatson
228100613Srwatson    if ((Info->OwnerId != ACPI_OWNER_ID_MAX) &&
229100613Srwatson        (Info->OwnerId != ThisNode->OwnerId))
230100613Srwatson    {
231100613Srwatson        return (AE_OK);
2321541Srgrimes    }
23332286Sdyson
234140714Sjeff    if (!(Info->DisplayType & ACPI_DISPLAY_SHORT))
235140714Sjeff    {
236140714Sjeff        /* Indent the object according to the level */
237140714Sjeff
2381541Srgrimes        AcpiOsPrintf ("%2d%*s", (UINT32) Level - 1, (int) Level * 2, " ");
2391541Srgrimes
2401541Srgrimes        /* Check the node type and name */
2411541Srgrimes
2421541Srgrimes        if (Type > ACPI_TYPE_LOCAL_MAX)
2431541Srgrimes        {
244101127Srwatson            ACPI_WARNING ((AE_INFO, "Invalid ACPI Object Type 0x%08X", Type));
245105479Srwatson        }
246105479Srwatson
247105479Srwatson        AcpiOsPrintf ("%4.4s", AcpiUtGetNodeName (ThisNode));
248105479Srwatson    }
249105479Srwatson
250105479Srwatson    /* Now we can print out the pertinent information */
251101127Srwatson
2521541Srgrimes    AcpiOsPrintf (" %-12s %p %2.2X ",
253111119Simp            AcpiUtGetTypeName (Type), ThisNode, ThisNode->OwnerId);
2541541Srgrimes
2551541Srgrimes    DbgLevel = AcpiDbgLevel;
2561541Srgrimes    AcpiDbgLevel = 0;
2571541Srgrimes    ObjDesc = AcpiNsGetAttachedObject (ThisNode);
2581541Srgrimes    AcpiDbgLevel = DbgLevel;
2591541Srgrimes
2601541Srgrimes    /* Temp nodes are those nodes created by a control method */
2611541Srgrimes
2621541Srgrimes    if (ThisNode->Flags & ANOBJ_TEMPORARY)
26383366Sjulian    {
2641541Srgrimes        AcpiOsPrintf ("(T) ");
2653148Sphk    }
2663148Sphk
2671541Srgrimes    switch (Info->DisplayType & ACPI_DISPLAY_MASK)
26892751Sjeff    {
2691541Srgrimes    case ACPI_DISPLAY_SUMMARY:
2701541Srgrimes
2711541Srgrimes        if (!ObjDesc)
27278692Sdillon        {
27378692Sdillon            /* No attached object, we are done */
27492751Sjeff
27578692Sdillon            AcpiOsPrintf ("\n");
27678692Sdillon            return (AE_OK);
27778692Sdillon        }
2781541Srgrimes
2791541Srgrimes        switch (Type)
28092751Sjeff        {
2811541Srgrimes        case ACPI_TYPE_PROCESSOR:
2821541Srgrimes
2831541Srgrimes            AcpiOsPrintf ("ID %X Len %.4X Addr %p\n",
2841541Srgrimes                ObjDesc->Processor.ProcId, ObjDesc->Processor.Length,
2851541Srgrimes                ACPI_CAST_PTR (void, ObjDesc->Processor.Address));
28692751Sjeff            break;
2871541Srgrimes
2881541Srgrimes
2891541Srgrimes        case ACPI_TYPE_DEVICE:
2901541Srgrimes
2911541Srgrimes            AcpiOsPrintf ("Notify Object: %p\n", ObjDesc);
2921541Srgrimes            break;
2931541Srgrimes
29492751Sjeff
295100613Srwatson        case ACPI_TYPE_METHOD:
296100613Srwatson
297100613Srwatson            AcpiOsPrintf ("Args %X Len %.4X Aml %p\n",
298100613Srwatson                (UINT32) ObjDesc->Method.ParamCount,
299144833Sjeff                ObjDesc->Method.AmlLength, ObjDesc->Method.AmlStart);
300144833Sjeff            break;
3011541Srgrimes
302140714Sjeff
3031541Srgrimes        case ACPI_TYPE_INTEGER:
3041541Srgrimes
3051541Srgrimes            AcpiOsPrintf ("= %8.8X%8.8X\n",
306162288Smohans                ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
307162288Smohans            break;
308162288Smohans
309162310Smohans
310162310Smohans        case ACPI_TYPE_PACKAGE:
311162288Smohans
312162288Smohans            if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
313162288Smohans            {
314162288Smohans                AcpiOsPrintf ("Elements %.2X\n",
315162288Smohans                    ObjDesc->Package.Count);
316162288Smohans            }
3171541Srgrimes            else
3181541Srgrimes            {
3191541Srgrimes                AcpiOsPrintf ("[Length not yet evaluated]\n");
3201541Srgrimes            }
3211541Srgrimes            break;
3221541Srgrimes
3231541Srgrimes
3241541Srgrimes        case ACPI_TYPE_BUFFER:
3251541Srgrimes
3261541Srgrimes            if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
3271541Srgrimes            {
3281541Srgrimes                AcpiOsPrintf ("Len %.2X",
3291541Srgrimes                            ObjDesc->Buffer.Length);
3301541Srgrimes
3311541Srgrimes                /* Dump some of the buffer */
3321541Srgrimes
3331541Srgrimes                if (ObjDesc->Buffer.Length > 0)
3341541Srgrimes                {
3351541Srgrimes                    AcpiOsPrintf (" =");
3361541Srgrimes                    for (i = 0; (i < ObjDesc->Buffer.Length && i < 12); i++)
3371541Srgrimes                    {
3388876Srgrimes                        AcpiOsPrintf (" %.2hX", ObjDesc->Buffer.Pointer[i]);
3391541Srgrimes                    }
3401541Srgrimes                }
3411541Srgrimes                AcpiOsPrintf ("\n");
3421541Srgrimes            }
3431541Srgrimes            else
3441541Srgrimes            {
3451541Srgrimes                AcpiOsPrintf ("[Length not yet evaluated]\n");
3461541Srgrimes            }
3471541Srgrimes            break;
3481541Srgrimes
3491541Srgrimes
3501541Srgrimes        case ACPI_TYPE_STRING:
3511541Srgrimes
3521541Srgrimes            AcpiOsPrintf ("Len %.2X ", ObjDesc->String.Length);
3531541Srgrimes            AcpiUtPrintString (ObjDesc->String.Pointer, 32);
3541541Srgrimes            AcpiOsPrintf ("\n");
3551541Srgrimes            break;
356161011Srwatson
3571541Srgrimes
358161011Srwatson        case ACPI_TYPE_REGION:
359161011Srwatson
3601541Srgrimes            AcpiOsPrintf ("[%s]",
3611541Srgrimes                AcpiUtGetRegionName (ObjDesc->Region.SpaceId));
3621541Srgrimes            if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
3631541Srgrimes            {
3641541Srgrimes                AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n",
3659804Sbde                    ACPI_FORMAT_NATIVE_UINT (ObjDesc->Region.Address),
3661541Srgrimes                    ObjDesc->Region.Length);
36765805Sbp            }
3681541Srgrimes            else
36983366Sjulian            {
370158094Sjeff                AcpiOsPrintf (" [Address/Length not yet evaluated]\n");
371158094Sjeff            }
372140714Sjeff            break;
373162288Smohans
374162288Smohans
3751541Srgrimes        case ACPI_TYPE_LOCAL_REFERENCE:
3761541Srgrimes
3771541Srgrimes            AcpiOsPrintf ("[%s]\n", AcpiUtGetReferenceName (ObjDesc));
378158094Sjeff            break;
379158094Sjeff
380140714Sjeff
3811541Srgrimes        case ACPI_TYPE_BUFFER_FIELD:
382144229Sjeff
383144229Sjeff            if (ObjDesc->BufferField.BufferObj &&
3841541Srgrimes                ObjDesc->BufferField.BufferObj->Buffer.Node)
3851541Srgrimes            {
38622874Sbde                AcpiOsPrintf ("Buf [%4.4s]",
38722874Sbde                    AcpiUtGetNodeName (
3881541Srgrimes                        ObjDesc->BufferField.BufferObj->Buffer.Node));
3891541Srgrimes            }
390144286Sjeff            break;
3911541Srgrimes
392144286Sjeff
393144286Sjeff        case ACPI_TYPE_LOCAL_REGION_FIELD:
394144286Sjeff
395144286Sjeff            AcpiOsPrintf ("Rgn [%4.4s]",
396144613Sjeff                AcpiUtGetNodeName (
397144613Sjeff                    ObjDesc->CommonField.RegionObj->Region.Node));
398144613Sjeff            break;
399144613Sjeff
4001541Srgrimes
4011541Srgrimes        case ACPI_TYPE_LOCAL_BANK_FIELD:
402162288Smohans
4031541Srgrimes            AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]",
4041541Srgrimes                AcpiUtGetNodeName (
4051541Srgrimes                    ObjDesc->CommonField.RegionObj->Region.Node),
4061541Srgrimes                AcpiUtGetNodeName (
4071541Srgrimes                    ObjDesc->BankField.BankObj->CommonField.Node));
4081541Srgrimes            break;
4091541Srgrimes
4101541Srgrimes
4111541Srgrimes        case ACPI_TYPE_LOCAL_INDEX_FIELD:
4121541Srgrimes
4131541Srgrimes            AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]",
4141541Srgrimes                AcpiUtGetNodeName (
41551906Sphk                    ObjDesc->IndexField.IndexObj->CommonField.Node),
4161541Srgrimes                AcpiUtGetNodeName (
4171541Srgrimes                    ObjDesc->IndexField.DataObj->CommonField.Node));
4181541Srgrimes            break;
4191541Srgrimes
4201541Srgrimes
4211541Srgrimes        case ACPI_TYPE_LOCAL_ALIAS:
4221541Srgrimes        case ACPI_TYPE_LOCAL_METHOD_ALIAS:
4231541Srgrimes
4241541Srgrimes            AcpiOsPrintf ("Target %4.4s (%p)\n",
4251541Srgrimes                AcpiUtGetNodeName (ObjDesc), ObjDesc);
4261541Srgrimes            break;
4271541Srgrimes
4281541Srgrimes        default:
4299804Sbde
4309804Sbde            AcpiOsPrintf ("Object %p\n", ObjDesc);
4319804Sbde            break;
4329804Sbde        }
4339804Sbde
4349804Sbde        /* Common field handling */
4359804Sbde
4369804Sbde        switch (Type)
4379804Sbde        {
4389804Sbde        case ACPI_TYPE_BUFFER_FIELD:
4399804Sbde        case ACPI_TYPE_LOCAL_REGION_FIELD:
4409804Sbde        case ACPI_TYPE_LOCAL_BANK_FIELD:
4419804Sbde        case ACPI_TYPE_LOCAL_INDEX_FIELD:
4429804Sbde
4439804Sbde            AcpiOsPrintf (" Off %.3X Len %.2X Acc %.2hd\n",
4449804Sbde                (ObjDesc->CommonField.BaseByteOffset * 8)
4459804Sbde                    + ObjDesc->CommonField.StartFieldBitOffset,
4469804Sbde                ObjDesc->CommonField.BitLength,
4479804Sbde                ObjDesc->CommonField.AccessByteWidth);
4481541Srgrimes            break;
4491541Srgrimes
4501541Srgrimes        default:
4511541Srgrimes            break;
4521541Srgrimes        }
4531541Srgrimes        break;
4541541Srgrimes
4551541Srgrimes
4561541Srgrimes    case ACPI_DISPLAY_OBJECTS:
4571541Srgrimes
4581541Srgrimes        AcpiOsPrintf ("O:%p", ObjDesc);
4591541Srgrimes        if (!ObjDesc)
4601541Srgrimes        {
4611541Srgrimes            /* No attached object, we are done */
4621541Srgrimes
4631541Srgrimes            AcpiOsPrintf ("\n");
4641541Srgrimes            return (AE_OK);
4651541Srgrimes        }
4661541Srgrimes
4671541Srgrimes        AcpiOsPrintf ("(R%u)", ObjDesc->Common.ReferenceCount);
46822521Sdyson
46922521Sdyson        switch (Type)
47022521Sdyson        {
47122521Sdyson        case ACPI_TYPE_METHOD:
4721541Srgrimes
4731541Srgrimes            /* Name is a Method and its AML offset/length are set */
4741541Srgrimes
4751541Srgrimes            AcpiOsPrintf (" M:%p-%X\n", ObjDesc->Method.AmlStart,
4761541Srgrimes                ObjDesc->Method.AmlLength);
4771541Srgrimes            break;
4781541Srgrimes
4791541Srgrimes        case ACPI_TYPE_INTEGER:
4801541Srgrimes
481155334Srwatson            AcpiOsPrintf (" I:%8.8X8.8%X\n",
482155334Srwatson                ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
483155334Srwatson            break;
484155334Srwatson
485155334Srwatson        case ACPI_TYPE_STRING:
486155334Srwatson
4871541Srgrimes            AcpiOsPrintf (" S:%p-%X\n", ObjDesc->String.Pointer,
48883366Sjulian                ObjDesc->String.Length);
48954655Seivind            break;
4901541Srgrimes
4911541Srgrimes        case ACPI_TYPE_BUFFER:
492140714Sjeff
4931541Srgrimes            AcpiOsPrintf (" B:%p-%X\n", ObjDesc->Buffer.Pointer,
4941541Srgrimes                ObjDesc->Buffer.Length);
4951541Srgrimes            break;
496154649Struckman
497154649Struckman        default:
498154649Struckman
499154649Struckman            AcpiOsPrintf ("\n");
5001541Srgrimes            break;
5011541Srgrimes        }
502154649Struckman        break;
5031541Srgrimes
5041541Srgrimes
50596755Strhodes    default:
506154649Struckman        AcpiOsPrintf ("\n");
50751649Sphk        break;
5081541Srgrimes    }
5091541Srgrimes
510154649Struckman    /* If debug turned off, done */
511154649Struckman
512154690Struckman    if (!(AcpiDbgLevel & ACPI_LV_VALUES))
513154649Struckman    {
514154649Struckman        return (AE_OK);
5151541Srgrimes    }
51651649Sphk
51751649Sphk    /* If there is an attached object, display it */
51851649Sphk
5191541Srgrimes    DbgLevel     = AcpiDbgLevel;
5201541Srgrimes    AcpiDbgLevel = 0;
521158142Skris    ObjDesc      = AcpiNsGetAttachedObject (ThisNode);
5221541Srgrimes    AcpiDbgLevel = DbgLevel;
5231541Srgrimes
5241541Srgrimes    /* Dump attached objects */
525101308Sjeff
5261541Srgrimes    while (ObjDesc)
5271541Srgrimes    {
528155385Sjeff        ObjType = ACPI_TYPE_INVALID;
52969405Salfred        AcpiOsPrintf ("Attached Object %p: ", ObjDesc);
53069405Salfred
53169405Salfred        /* Decode the type of attached object and dump the contents */
5321541Srgrimes
533144833Sjeff        switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
534158094Sjeff        {
535158094Sjeff        case ACPI_DESC_TYPE_NAMED:
536144833Sjeff
5371541Srgrimes            AcpiOsPrintf ("(Ptr to Node)\n");
538140714Sjeff            BytesToDump = sizeof (ACPI_NAMESPACE_NODE);
539162288Smohans            ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
5401541Srgrimes            break;
5411541Srgrimes
5421541Srgrimes        case ACPI_DESC_TYPE_OPERAND:
5431541Srgrimes
5441541Srgrimes            ObjType = ObjDesc->Common.Type;
5451541Srgrimes
5461541Srgrimes            if (ObjType > ACPI_TYPE_LOCAL_MAX)
547101127Srwatson            {
548105479Srwatson                AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [UNKNOWN])\n",
549105479Srwatson                    ObjType);
550105479Srwatson                BytesToDump = 32;
551105479Srwatson            }
552105479Srwatson            else
553101127Srwatson            {
5541541Srgrimes                AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [%s])\n",
55522521Sdyson                    ObjType, AcpiUtGetTypeName (ObjType));
55624624Sdfr                BytesToDump = sizeof (ACPI_OPERAND_OBJECT);
557158094Sjeff            }
558144286Sjeff
559144286Sjeff            ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
560144286Sjeff            break;
561144286Sjeff
562144286Sjeff        default:
563144286Sjeff
564144286Sjeff            break;
565144286Sjeff        }
566144286Sjeff
567144286Sjeff        /* If value is NOT an internal object, we are done */
568144286Sjeff
569144286Sjeff        if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
570144286Sjeff        {
571144286Sjeff            goto Cleanup;
572138345Sphk        }
573138345Sphk
574138345Sphk        /* Valid object, get the pointer to next level, if any */
575162288Smohans
576162288Smohans        switch (ObjType)
57743301Sdillon        {
578162288Smohans        case ACPI_TYPE_BUFFER:
57942408Seivind        case ACPI_TYPE_STRING:
5801541Srgrimes            /*
5811541Srgrimes             * NOTE: takes advantage of common fields between string/buffer
5821541Srgrimes             */
5831541Srgrimes            BytesToDump = ObjDesc->String.Length;
584101308Sjeff            ObjDesc = (void *) ObjDesc->String.Pointer;
5851541Srgrimes            AcpiOsPrintf ( "(Buffer/String pointer %p length %X)\n",
5861541Srgrimes                ObjDesc, BytesToDump);
587144833Sjeff            ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
588158094Sjeff            goto Cleanup;
589158094Sjeff
590144833Sjeff        case ACPI_TYPE_BUFFER_FIELD:
591144203Sjeff            ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->BufferField.BufferObj;
592140714Sjeff            break;
593162288Smohans
5941541Srgrimes        case ACPI_TYPE_PACKAGE:
5951541Srgrimes            ObjDesc = (void *) ObjDesc->Package.Elements;
5961541Srgrimes            break;
5971541Srgrimes
5981541Srgrimes        case ACPI_TYPE_METHOD:
5991541Srgrimes            ObjDesc = (void *) ObjDesc->Method.AmlStart;
6001541Srgrimes            break;
6011541Srgrimes
6021541Srgrimes        case ACPI_TYPE_LOCAL_REGION_FIELD:
60311644Sdg            ObjDesc = (void *) ObjDesc->Field.RegionObj;
6041541Srgrimes            break;
6051541Srgrimes
6061541Srgrimes        case ACPI_TYPE_LOCAL_BANK_FIELD:
6079804Sbde            ObjDesc = (void *) ObjDesc->BankField.RegionObj;
6089804Sbde            break;
6099804Sbde
6109804Sbde        case ACPI_TYPE_LOCAL_INDEX_FIELD:
6119804Sbde            ObjDesc = (void *) ObjDesc->IndexField.IndexObj;
612144203Sjeff            break;
613144203Sjeff
6141541Srgrimes        default:
615144203Sjeff            goto Cleanup;
616144203Sjeff        }
617144203Sjeff
618144203Sjeff        ObjType = ACPI_TYPE_INVALID;   /* Terminate loop after next pass */
619144203Sjeff    }
620144203Sjeff
6211541SrgrimesCleanup:
6221541Srgrimes    AcpiOsPrintf ("\n");
623161010Srwatson    return (AE_OK);
6241541Srgrimes}
6251541Srgrimes
6261541Srgrimes
6271541Srgrimes/*******************************************************************************
6281541Srgrimes *
629140714Sjeff * FUNCTION:    AcpiNsDumpObjects
630162288Smohans *
631162288Smohans * PARAMETERS:  Type                - Object type to be dumped
6321541Srgrimes *              DisplayType         - 0 or ACPI_DISPLAY_SUMMARY
6331541Srgrimes *              MaxDepth            - Maximum depth of dump. Use ACPI_UINT32_MAX
6341541Srgrimes *                                    for an effectively unlimited depth.
635144203Sjeff *              OwnerId             - Dump only objects owned by this ID. Use
6361541Srgrimes *                                    ACPI_UINT32_MAX to match all owners.
6371541Srgrimes *              StartHandle         - Where in namespace to start/end search
6381541Srgrimes *
6391541Srgrimes * RETURN:      None
6401541Srgrimes *
6411541Srgrimes * DESCRIPTION: Dump typed objects within the loaded namespace. Uses
6421541Srgrimes *              AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject.
6431541Srgrimes *
6441541Srgrimes ******************************************************************************/
6451541Srgrimes
6461541Srgrimesvoid
647158094SjeffAcpiNsDumpObjects (
6481541Srgrimes    ACPI_OBJECT_TYPE        Type,
6491541Srgrimes    UINT8                   DisplayType,
6501541Srgrimes    UINT32                  MaxDepth,
65196755Strhodes    ACPI_OWNER_ID           OwnerId,
6521541Srgrimes    ACPI_HANDLE             StartHandle)
6531541Srgrimes{
6541541Srgrimes    ACPI_WALK_INFO          Info;
65583366Sjulian    ACPI_STATUS             Status;
6561541Srgrimes
657144833Sjeff
658158094Sjeff    ACPI_FUNCTION_ENTRY ();
659155168Sjeff
660158094Sjeff
661158094Sjeff    /*
662162288Smohans     * Just lock the entire namespace for the duration of the dump.
66383366Sjulian     * We don't want any changes to the namespace during this time,
664162288Smohans     * especially the temporary nodes since we are going to display
66565805Sbp     * them also.
66665805Sbp     */
6671541Srgrimes    Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
66865805Sbp    if (ACPI_FAILURE (Status))
6691541Srgrimes    {
6701541Srgrimes        AcpiOsPrintf ("Could not acquire namespace mutex\n");
6711541Srgrimes        return;
67210219Sdfr    }
67310219Sdfr
67410219Sdfr    Info.DebugLevel = ACPI_LV_TABLES;
67510219Sdfr    Info.OwnerId = OwnerId;
67610219Sdfr    Info.DisplayType = DisplayType;
67710219Sdfr
67810219Sdfr    (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
679155385Sjeff                ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,
68069405Salfred                AcpiNsDumpOneObject, NULL, (void *) &Info, NULL);
68169405Salfred
68269405Salfred    (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
68369405Salfred}
68469405Salfred
68535105Swosch
68635105Swosch/*******************************************************************************
68735105Swosch *
68835105Swosch * FUNCTION:    AcpiNsDumpEntry
689144833Sjeff *
690144833Sjeff * PARAMETERS:  Handle              - Node to be dumped
691144833Sjeff *              DebugLevel          - Output level
692144833Sjeff *
693144833Sjeff * RETURN:      None
694140714Sjeff *
69510219Sdfr * DESCRIPTION: Dump a single Node
69610219Sdfr *
69710219Sdfr ******************************************************************************/
69810219Sdfr
69910219Sdfrvoid
70010219SdfrAcpiNsDumpEntry (
70110219Sdfr    ACPI_HANDLE             Handle,
70210219Sdfr    UINT32                  DebugLevel)
70310219Sdfr{
70410219Sdfr    ACPI_WALK_INFO          Info;
7051541Srgrimes
7061541Srgrimes
7071541Srgrimes    ACPI_FUNCTION_ENTRY ();
7081541Srgrimes
7091541Srgrimes
710144203Sjeff    Info.DebugLevel = DebugLevel;
711144203Sjeff    Info.OwnerId = ACPI_OWNER_ID_MAX;
7121541Srgrimes    Info.DisplayType = ACPI_DISPLAY_SUMMARY;
7131541Srgrimes
7141541Srgrimes    (void) AcpiNsDumpOneObject (Handle, 1, &Info, NULL);
7151541Srgrimes}
7161541Srgrimes
7171541Srgrimes
718144833Sjeff#ifdef ACPI_ASL_COMPILER
719144833Sjeff/*******************************************************************************
720144833Sjeff *
721144833Sjeff * FUNCTION:    AcpiNsDumpTables
722155168Sjeff *
723158094Sjeff * PARAMETERS:  SearchBase          - Root of subtree to be dumped, or
724158094Sjeff *                                    NS_ALL to dump the entire namespace
7251541Srgrimes *              MaxDepth            - Maximum depth of dump.  Use INT_MAX
7261541Srgrimes *                                    for an effectively unlimited depth.
7271541Srgrimes *
72896755Strhodes * RETURN:      None
7291541Srgrimes *
73011644Sdg * DESCRIPTION: Dump the name space, or a portion of it.
73111644Sdg *
73211644Sdg ******************************************************************************/
73311644Sdg
7341541Srgrimesvoid
7351541SrgrimesAcpiNsDumpTables (
7361541Srgrimes    ACPI_HANDLE             SearchBase,
7371541Srgrimes    UINT32                  MaxDepth)
7381541Srgrimes{
739144833Sjeff    ACPI_HANDLE             SearchHandle = SearchBase;
740144833Sjeff
741144833Sjeff
742144833Sjeff    ACPI_FUNCTION_TRACE (NsDumpTables);
743144833Sjeff
744155168Sjeff
745155168Sjeff    if (!AcpiGbl_RootNode)
746144833Sjeff    {
747144833Sjeff        /*
74832071Sdyson         * If the name space has not been initialized,
749155334Srwatson         * there is nothing to dump.
750155334Srwatson         */
751155334Srwatson        ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "namespace not initialized!\n"));
752155334Srwatson        return_VOID;
753155334Srwatson    }
7541541Srgrimes
75583366Sjulian    if (ACPI_NS_ALL == SearchBase)
756140714Sjeff    {
757155168Sjeff        /* Entire namespace */
758155168Sjeff
759155168Sjeff        SearchHandle = AcpiGbl_RootNode;
760140714Sjeff        ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n"));
7611541Srgrimes    }
7621541Srgrimes
7631541Srgrimes    AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, MaxDepth,
764144833Sjeff            ACPI_OWNER_ID_MAX, SearchHandle);
765144203Sjeff    return_VOID;
766144203Sjeff}
767144203Sjeff#endif
7681541Srgrimes#endif
769144833Sjeff
77065805Sbp