nsdump.c revision 99679
18813Srgallard/******************************************************************************
212442Smfang *
312442Smfang * Module Name: nsdump - table dumping routines for debug
412442Smfang *              $Revision: 136 $
512442Smfang *
612442Smfang *****************************************************************************/
712442Smfang
812442Smfang/******************************************************************************
912442Smfang *
1012442Smfang * 1. Copyright Notice
1112442Smfang *
1212442Smfang * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
1312442Smfang * All rights reserved.
1412442Smfang *
1512442Smfang * 2. License
1612442Smfang *
1712442Smfang * 2.1. This is your license from Intel Corp. under its intellectual property
1812442Smfang * rights.  You may have additional license terms from the party that provided
1912442Smfang * you this software, covering your right to use that party's intellectual
2012442Smfang * property rights.
2112442Smfang *
2212442Smfang * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
238813Srgallard * copy of the source code appearing in this file ("Covered Code") an
248813Srgallard * irrevocable, perpetual, worldwide license under Intel's copyrights in the
258813Srgallard * base code distributed originally by Intel ("Original Intel Code") to copy,
268813Srgallard
278813Srgallard * make derivatives, distribute, use and display any portion of the Covered
288813Srgallard * Code in any form, with the right to sublicense such rights; and
298813Srgallard *
308813Srgallard * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
3112442Smfang * license (with the right to sublicense), under only those claims of Intel
3212442Smfang * patents that are infringed by the Original Intel Code, to make, use, sell,
3312442Smfang * offer to sell, and import the Covered Code and derivative works thereof
3412442Smfang * solely to the minimum extent necessary to exercise the above copyright
3512442Smfang * license, and in no event shall the patent license extend to any additions
3612442Smfang * to or modifications of the Original Intel Code.  No other license or right
3712442Smfang * is granted directly or by implication, estoppel or otherwise;
3812442Smfang *
3912442Smfang * The above copyright and patent license is granted only if the following
4012442Smfang * conditions are met:
4112442Smfang *
4212442Smfang * 3. Conditions
4312442Smfang *
4412442Smfang * 3.1. Redistribution of Source with Rights to Further Distribute Source.
4512442Smfang * Redistribution of source code of any substantial portion of the Covered
4612442Smfang * Code or modification with rights to further distribute source must include
4712442Smfang * the above Copyright Notice, the above License, this list of Conditions,
4812442Smfang * and the following Disclaimer and Export Compliance provision.  In addition,
4912442Smfang * Licensee must cause all Covered Code to which Licensee contributes to
500Sduke * contain a file documenting the changes Licensee made to create that Covered
518813Srgallard * Code and the date of any change.  Licensee must include in that file the
528813Srgallard * documentation of any changes made by any predecessor Licensee.  Licensee
538813Srgallard * must include a prominent statement that the modification is derived,
548813Srgallard * directly or indirectly, from Original Intel Code.
558813Srgallard *
561178Stbell * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
578813Srgallard * Redistribution of source code of any substantial portion of the Covered
588813Srgallard * Code or modification without rights to further distribute source must
598813Srgallard * include the following Disclaimer and Export Compliance provision in the
608813Srgallard * documentation and/or other materials provided with distribution.  In
618813Srgallard * addition, Licensee may not authorize further sublicense of source of any
628813Srgallard * portion of the Covered Code, and must include terms to the effect that the
638813Srgallard * license from Licensee to its licensee is limited to the intellectual
648813Srgallard * property embodied in the software Licensee provides to its licensee, and
658813Srgallard * not to intellectual property embodied in modifications its licensee may
668813Srgallard * make.
678813Srgallard *
688813Srgallard * 3.3. Redistribution of Executable. Redistribution in executable form of any
698813Srgallard * substantial portion of the Covered Code or modification must reproduce the
708813Srgallard * above Copyright Notice, and the following Disclaimer and Export Compliance
718813Srgallard * provision in the documentation and/or other materials provided with the
728813Srgallard * distribution.
738813Srgallard *
748813Srgallard * 3.4. Intel retains all right, title, and interest in and to the Original
758813Srgallard * Intel Code.
768813Srgallard *
778813Srgallard * 3.5. Neither the name Intel nor any other trademark owned or controlled by
788813Srgallard * Intel shall be used in advertising or otherwise to promote the sale, use or
798813Srgallard * other dealings in products derived from or relating to the Covered Code
808813Srgallard * without prior written authorization from Intel.
818813Srgallard *
828813Srgallard * 4. Disclaimer and Export Compliance
838813Srgallard *
848813Srgallard * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
850Sduke * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
868813Srgallard * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
878813Srgallard * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
888813Srgallard * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
898813Srgallard * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
908813Srgallard * PARTICULAR PURPOSE.
918813Srgallard *
928813Srgallard * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
938813Srgallard * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
948813Srgallard * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
958813Srgallard * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
968813Srgallard * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
978813Srgallard * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
988813Srgallard * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
991178Stbell * LIMITED REMEDY.
1008813Srgallard *
1018813Srgallard * 4.3. Licensee shall not export, either directly or indirectly, any of this
1028813Srgallard * software or system incorporating such software without first obtaining any
1038813Srgallard * required license or other approval from the U. S. Department of Commerce or
1048813Srgallard * any other agency or department of the United States Government.  In the
1058813Srgallard * event Licensee exports any such software from the United States or
1068813Srgallard * re-exports any such software from a foreign destination, Licensee shall
1078813Srgallard * ensure that the distribution and export/re-export of the software is in
1088813Srgallard * compliance with all laws, regulations, orders, or other restrictions of the
1098813Srgallard * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1108813Srgallard * any of its subsidiaries will export/re-export any technical data, process,
1118813Srgallard * software, or service, directly or indirectly, to any country for which the
1128813Srgallard * United States government or any agency thereof requires an export license,
1131178Stbell * other governmental approval, or letter of assurance, without first obtaining
1148813Srgallard * such license, approval or letter.
1158813Srgallard *
1168813Srgallard *****************************************************************************/
1178813Srgallard
1188813Srgallard#define __NSDUMP_C__
1198813Srgallard
1208813Srgallard#include "acpi.h"
1218813Srgallard#include "acnamesp.h"
1228813Srgallard#include "acparser.h"
1238813Srgallard
1248813Srgallard
1258813Srgallard#define _COMPONENT          ACPI_NAMESPACE
1268813Srgallard        ACPI_MODULE_NAME    ("nsdump")
1278813Srgallard
1288813Srgallard#if defined(ACPI_DEBUG) || defined(ENABLE_DEBUGGER)
1298813Srgallard
1308813Srgallard
1318813Srgallard/*******************************************************************************
1328813Srgallard *
1338813Srgallard * FUNCTION:    AcpiNsPrintPathname
1348813Srgallard *
1358813Srgallard * PARAMETERS:  NumSegment          - Number of ACPI name segments
1368813Srgallard *              Pathname            - The compressed (internal) path
1378813Srgallard *
1388813Srgallard * DESCRIPTION: Print an object's full namespace pathname
1398813Srgallard *
1401178Stbell ******************************************************************************/
1418813Srgallard
1428813Srgallardvoid
1438813SrgallardAcpiNsPrintPathname (
1448813Srgallard    UINT32                  NumSegments,
1458813Srgallard    char                    *Pathname)
1468813Srgallard{
1478813Srgallard    ACPI_FUNCTION_NAME ("NsPrintPathname");
1481178Stbell
1498813Srgallard
1508813Srgallard    if (!(AcpiDbgLevel & ACPI_LV_NAMES) || !(AcpiDbgLayer & ACPI_NAMESPACE))
1518813Srgallard    {
1520Sduke        return;
1538813Srgallard    }
1548813Srgallard
1558813Srgallard        /* Print the entire name */
1568813Srgallard
1578813Srgallard    ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "["));
1588813Srgallard
1598813Srgallard    while (NumSegments)
1600Sduke    {
1618813Srgallard        AcpiOsPrintf ("%4.4s", Pathname);
1628813Srgallard        Pathname += ACPI_NAME_SIZE;
1638813Srgallard
1640Sduke        NumSegments--;
1658813Srgallard        if (NumSegments)
1668813Srgallard        {
1678813Srgallard            AcpiOsPrintf (".");
1688813Srgallard        }
1698813Srgallard    }
1701178Stbell
1718813Srgallard    AcpiOsPrintf ("]\n");
1728813Srgallard}
1738813Srgallard
1748813Srgallard
1750Sduke/*******************************************************************************
1768813Srgallard *
1778813Srgallard * FUNCTION:    AcpiNsDumpPathname
1788813Srgallard *
1798813Srgallard * PARAMETERS:  Handle              - Object
1808813Srgallard *              Msg                 - Prefix message
1818813Srgallard *              Level               - Desired debug level
1828813Srgallard *              Component           - Caller's component ID
1838813Srgallard *
1848813Srgallard * DESCRIPTION: Print an object's full namespace pathname
1858813Srgallard *              Manages allocation/freeing of a pathname buffer
1868813Srgallard *
1870Sduke ******************************************************************************/
1888813Srgallard
1898813SrgallardACPI_STATUS
1908813SrgallardAcpiNsDumpPathname (
1918813Srgallard    ACPI_HANDLE             Handle,
1928813Srgallard    NATIVE_CHAR             *Msg,
1930Sduke    UINT32                  Level,
1948813Srgallard    UINT32                  Component)
1958813Srgallard{
1968813Srgallard    ACPI_BUFFER             Buffer;
1978813Srgallard    ACPI_STATUS             Status;
1988813Srgallard
1998813Srgallard
2008813Srgallard    ACPI_FUNCTION_TRACE ("NsDumpPathname");
2018813Srgallard
2028813Srgallard
2038813Srgallard    /* Do this only if the requested debug level and component are enabled */
2048813Srgallard
2058813Srgallard    if (!(AcpiDbgLevel & Level) || !(AcpiDbgLayer & Component))
2060Sduke    {
2078813Srgallard        return_ACPI_STATUS (AE_OK);
2088813Srgallard    }
2098813Srgallard
2108813Srgallard    /* Convert handle to a full pathname and print it (with supplied message) */
2118813Srgallard
2128813Srgallard    Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
2138813Srgallard
2148813Srgallard    Status = AcpiNsHandleToPathname (Handle, &Buffer);
2158813Srgallard    if (ACPI_SUCCESS (Status))
2168813Srgallard    {
2178813Srgallard        AcpiOsPrintf ("%s %s (Node %p)\n", Msg, Buffer.Pointer, Handle);
2188813Srgallard        ACPI_MEM_FREE (Buffer.Pointer);
2198813Srgallard    }
2208813Srgallard
2218813Srgallard    return_ACPI_STATUS (Status);
2228813Srgallard}
2238813Srgallard
2248813Srgallard
2258813Srgallard/*******************************************************************************
2268813Srgallard *
2278813Srgallard * FUNCTION:    AcpiNsDumpOneObject
2288813Srgallard *
2298813Srgallard * PARAMETERS:  Handle              - Node to be dumped
2308813Srgallard *              Level               - Nesting level of the handle
2318813Srgallard *              Context             - Passed into WalkNamespace
2328813Srgallard *
2338813Srgallard * DESCRIPTION: Dump a single Node
2348813Srgallard *              This procedure is a UserFunction called by AcpiNsWalkNamespace.
2358813Srgallard *
2368813Srgallard ******************************************************************************/
2378813Srgallard
2388813SrgallardACPI_STATUS
2398813SrgallardAcpiNsDumpOneObject (
2408813Srgallard    ACPI_HANDLE             ObjHandle,
2418813Srgallard    UINT32                  Level,
2428813Srgallard    void                    *Context,
2438813Srgallard    void                    **ReturnValue)
2448813Srgallard{
2458813Srgallard    ACPI_WALK_INFO          *Info = (ACPI_WALK_INFO *) Context;
2460Sduke    ACPI_NAMESPACE_NODE     *ThisNode;
2478813Srgallard    ACPI_OPERAND_OBJECT     *ObjDesc = NULL;
2488813Srgallard    ACPI_OBJECT_TYPE        ObjType;
2498813Srgallard    ACPI_OBJECT_TYPE        Type;
2508813Srgallard    UINT32                  BytesToDump;
2518813Srgallard    UINT32                  DownstreamSiblingMask = 0;
2528813Srgallard    UINT32                  LevelTmp;
2538813Srgallard    UINT32                  WhichBit;
2548813Srgallard    UINT32                  i;
2558813Srgallard    UINT32                  DbgLevel;
2568813Srgallard
2578813Srgallard
2588813Srgallard    ACPI_FUNCTION_NAME ("NsDumpOneObject");
2598813Srgallard
2608813Srgallard
2618813Srgallard    ThisNode = AcpiNsMapHandleToNode (ObjHandle);
2628813Srgallard
2638813Srgallard    LevelTmp    = Level;
2648813Srgallard    Type        = ThisNode->Type;
2658813Srgallard    WhichBit    = 1;
2668813Srgallard
2678813Srgallard
2688813Srgallard    if (!(AcpiDbgLevel & Info->DebugLevel))
2698813Srgallard    {
2708813Srgallard        return (AE_OK);
2718813Srgallard    }
2728813Srgallard
2738813Srgallard    if (!ObjHandle)
2748813Srgallard    {
2758813Srgallard        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n"));
2768813Srgallard        return (AE_OK);
2778813Srgallard    }
2788813Srgallard
2798813Srgallard    /* Check if the owner matches */
2808813Srgallard
2818813Srgallard    if ((Info->OwnerId != ACPI_UINT32_MAX) &&
2828813Srgallard        (Info->OwnerId != ThisNode->OwnerId))
2838813Srgallard    {
2848813Srgallard        return (AE_OK);
2858813Srgallard    }
2868813Srgallard
28712442Smfang    /* Indent the object according to the level */
28812442Smfang
28912442Smfang    while (LevelTmp--)
29012442Smfang    {
291        /* Print appropriate characters to form tree structure */
292
293        if (LevelTmp)
294        {
295            if (DownstreamSiblingMask & WhichBit)
296            {
297                AcpiOsPrintf ("|");
298            }
299            else
300            {
301                AcpiOsPrintf (" ");
302            }
303
304            WhichBit <<= 1;
305        }
306        else
307        {
308            if (AcpiNsExistDownstreamSibling (ThisNode + 1))
309            {
310                DownstreamSiblingMask |= ((UINT32) 1 << (Level - 1));
311                AcpiOsPrintf ("+");
312            }
313            else
314            {
315                DownstreamSiblingMask &= ACPI_UINT32_MAX ^ ((UINT32) 1 << (Level - 1));
316                AcpiOsPrintf ("+");
317            }
318
319            if (ThisNode->Child == NULL)
320            {
321                AcpiOsPrintf ("-");
322            }
323            else if (AcpiNsExistDownstreamSibling (ThisNode->Child))
324            {
325                AcpiOsPrintf ("+");
326            }
327            else
328            {
329                AcpiOsPrintf ("-");
330            }
331        }
332    }
333
334    /* Check the integrity of our data */
335
336    if (Type > INTERNAL_TYPE_MAX)
337    {
338        Type = INTERNAL_TYPE_DEF_ANY;  /* prints as *ERROR* */
339    }
340
341    if (!AcpiUtValidAcpiName (ThisNode->Name.Integer))
342    {
343        ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n", ThisNode->Name.Integer));
344    }
345
346    /*
347     * Now we can print out the pertinent information
348     */
349    AcpiOsPrintf (" %4.4s %-12s %p",
350            ThisNode->Name.Ascii, AcpiUtGetTypeName (Type), ThisNode);
351
352    DbgLevel = AcpiDbgLevel;
353    AcpiDbgLevel = 0;
354    ObjDesc = AcpiNsGetAttachedObject (ThisNode);
355    AcpiDbgLevel = DbgLevel;
356
357    switch (Info->DisplayType)
358    {
359    case ACPI_DISPLAY_SUMMARY:
360
361        if (!ObjDesc)
362        {
363            /* No attached object, we are done */
364
365            AcpiOsPrintf ("\n");
366            return (AE_OK);
367        }
368
369        switch (Type)
370        {
371        case ACPI_TYPE_PROCESSOR:
372
373            AcpiOsPrintf (" ID %hd Addr %.4X Len %.4X\n",
374                        ObjDesc->Processor.ProcId,
375                        ObjDesc->Processor.Address,
376                        ObjDesc->Processor.Length);
377            break;
378
379
380        case ACPI_TYPE_DEVICE:
381
382            AcpiOsPrintf (" Notification object: %p", ObjDesc);
383            break;
384
385
386        case ACPI_TYPE_METHOD:
387
388            AcpiOsPrintf (" Args %hd Len %.4X Aml %p \n",
389                        ObjDesc->Method.ParamCount,
390                        ObjDesc->Method.AmlLength,
391                        ObjDesc->Method.AmlStart);
392            break;
393
394
395        case ACPI_TYPE_INTEGER:
396
397            AcpiOsPrintf (" = %8.8X%8.8X\n",
398                        ACPI_HIDWORD (ObjDesc->Integer.Value),
399                        ACPI_LODWORD (ObjDesc->Integer.Value));
400            break;
401
402
403        case ACPI_TYPE_PACKAGE:
404
405            if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
406            {
407                AcpiOsPrintf (" Elements %.2X\n",
408                            ObjDesc->Package.Count);
409            }
410            else
411            {
412                AcpiOsPrintf (" [Length not yet evaluated]\n");
413            }
414            break;
415
416
417        case ACPI_TYPE_BUFFER:
418
419            if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
420            {
421                AcpiOsPrintf (" Len %.2X",
422                            ObjDesc->Buffer.Length);
423
424                /* Dump some of the buffer */
425
426                if (ObjDesc->Buffer.Length > 0)
427                {
428                    AcpiOsPrintf (" =");
429                    for (i = 0; (i < ObjDesc->Buffer.Length && i < 12); i++)
430                    {
431                        AcpiOsPrintf (" %.2hX", ObjDesc->Buffer.Pointer[i]);
432                    }
433                }
434                AcpiOsPrintf ("\n");
435            }
436            else
437            {
438                AcpiOsPrintf (" [Length not yet evaluated]\n");
439            }
440            break;
441
442
443        case ACPI_TYPE_STRING:
444
445            AcpiOsPrintf (" Len %.2X", ObjDesc->String.Length);
446
447            if (ObjDesc->String.Length > 0)
448            {
449                AcpiOsPrintf (" = \"%.32s\"", ObjDesc->String.Pointer);
450                if (ObjDesc->String.Length > 32)
451                {
452                    AcpiOsPrintf ("...");
453                }
454            }
455            AcpiOsPrintf ("\n");
456            break;
457
458
459        case ACPI_TYPE_REGION:
460
461            AcpiOsPrintf (" [%s]", AcpiUtGetRegionName (ObjDesc->Region.SpaceId));
462            if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
463            {
464                AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n",
465                            ACPI_HIDWORD (ObjDesc->Region.Address),
466                            ACPI_LODWORD (ObjDesc->Region.Address),
467                            ObjDesc->Region.Length);
468            }
469            else
470            {
471                AcpiOsPrintf (" [Address/Length not yet evaluated]\n");
472            }
473            break;
474
475
476        case INTERNAL_TYPE_REFERENCE:
477
478            AcpiOsPrintf (" [%s]\n",
479                    AcpiPsGetOpcodeName (ObjDesc->Reference.Opcode));
480            break;
481
482
483        case ACPI_TYPE_BUFFER_FIELD:
484
485            if (ObjDesc->BufferField.BufferObj &&
486                ObjDesc->BufferField.BufferObj->Buffer.Node)
487            {
488                AcpiOsPrintf (" Buf [%4.4s]",
489                        ObjDesc->BufferField.BufferObj->Buffer.Node->Name.Ascii);
490            }
491            break;
492
493
494        case INTERNAL_TYPE_REGION_FIELD:
495
496            AcpiOsPrintf (" Rgn [%4.4s]",
497                    ObjDesc->CommonField.RegionObj->Region.Node->Name.Ascii);
498            break;
499
500
501        case INTERNAL_TYPE_BANK_FIELD:
502
503            AcpiOsPrintf (" Rgn [%4.4s] Bnk [%4.4s]",
504                    ObjDesc->CommonField.RegionObj->Region.Node->Name.Ascii,
505                    ObjDesc->BankField.BankObj->CommonField.Node->Name.Ascii);
506            break;
507
508
509        case INTERNAL_TYPE_INDEX_FIELD:
510
511            AcpiOsPrintf (" Idx [%4.4s] Dat [%4.4s]",
512                    ObjDesc->IndexField.IndexObj->CommonField.Node->Name.Ascii,
513                    ObjDesc->IndexField.DataObj->CommonField.Node->Name.Ascii);
514            break;
515
516
517        default:
518
519            AcpiOsPrintf (" Object %p\n", ObjDesc);
520            break;
521        }
522
523        /* Common field handling */
524
525        switch (Type)
526        {
527        case ACPI_TYPE_BUFFER_FIELD:
528        case INTERNAL_TYPE_REGION_FIELD:
529        case INTERNAL_TYPE_BANK_FIELD:
530        case INTERNAL_TYPE_INDEX_FIELD:
531            AcpiOsPrintf (" Off %.2X Len %.2X Acc %.2hd\n",
532                    (ObjDesc->CommonField.BaseByteOffset * 8)
533                        + ObjDesc->CommonField.StartFieldBitOffset,
534                    ObjDesc->CommonField.BitLength,
535                    ObjDesc->CommonField.AccessByteWidth);
536            break;
537
538        default:
539            break;
540        }
541        break;
542
543
544    case ACPI_DISPLAY_OBJECTS:
545
546        AcpiOsPrintf ("%p O:%p",
547                ThisNode, ObjDesc);
548
549        if (!ObjDesc)
550        {
551            /* No attached object, we are done */
552
553            AcpiOsPrintf ("\n");
554            return (AE_OK);
555        }
556
557        AcpiOsPrintf ("(R%d)",
558                ObjDesc->Common.ReferenceCount);
559
560        switch (Type)
561        {
562        case ACPI_TYPE_METHOD:
563
564            /* Name is a Method and its AML offset/length are set */
565
566            AcpiOsPrintf (" M:%p-%X\n", ObjDesc->Method.AmlStart,
567                                        ObjDesc->Method.AmlLength);
568            break;
569
570        case ACPI_TYPE_INTEGER:
571
572            AcpiOsPrintf (" N:%X%X\n", ACPI_HIDWORD(ObjDesc->Integer.Value),
573                                       ACPI_LODWORD(ObjDesc->Integer.Value));
574            break;
575
576        case ACPI_TYPE_STRING:
577
578            AcpiOsPrintf (" S:%p-%X\n", ObjDesc->String.Pointer,
579                                        ObjDesc->String.Length);
580            break;
581
582        case ACPI_TYPE_BUFFER:
583
584            AcpiOsPrintf (" B:%p-%X\n", ObjDesc->Buffer.Pointer,
585                                        ObjDesc->Buffer.Length);
586            break;
587
588        default:
589
590            AcpiOsPrintf ("\n");
591            break;
592        }
593        break;
594
595
596    default:
597        AcpiOsPrintf ("\n");
598        break;
599    }
600
601    /* If debug turned off, done */
602
603    if (!(AcpiDbgLevel & ACPI_LV_VALUES))
604    {
605        return (AE_OK);
606    }
607
608
609    /* If there is an attached object, display it */
610
611    DbgLevel = AcpiDbgLevel;
612    AcpiDbgLevel = 0;
613    ObjDesc = AcpiNsGetAttachedObject (ThisNode);
614    AcpiDbgLevel = DbgLevel;
615
616    /* Dump attached objects */
617
618    while (ObjDesc)
619    {
620        ObjType = INTERNAL_TYPE_INVALID;
621        AcpiOsPrintf ("        Attached Object %p: ", ObjDesc);
622
623        /* Decode the type of attached object and dump the contents */
624
625        switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
626        {
627        case ACPI_DESC_TYPE_NAMED:
628
629            AcpiOsPrintf ("(Ptr to Node)\n");
630            BytesToDump = sizeof (ACPI_NAMESPACE_NODE);
631            break;
632
633
634        case ACPI_DESC_TYPE_OPERAND:
635
636            ObjType = ACPI_GET_OBJECT_TYPE (ObjDesc);
637
638            if (ObjType > INTERNAL_TYPE_MAX)
639            {
640                AcpiOsPrintf ("(Ptr to ACPI Object type %X [UNKNOWN])\n", ObjType);
641                BytesToDump = 32;
642            }
643            else
644            {
645                AcpiOsPrintf ("(Ptr to ACPI Object type %s, %X)\n",
646                                    AcpiUtGetTypeName (ObjType), ObjType);
647                BytesToDump = sizeof (ACPI_OPERAND_OBJECT);
648            }
649            break;
650
651
652        default:
653
654            AcpiOsPrintf ("(String or Buffer ptr - not an object descriptor)\n");
655            BytesToDump = 16;
656            break;
657        }
658
659        ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
660
661        /* If value is NOT an internal object, we are done */
662
663        if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
664        {
665            goto Cleanup;
666        }
667
668        /*
669         * Valid object, get the pointer to next level, if any
670         */
671        switch (ObjType)
672        {
673        case ACPI_TYPE_STRING:
674            ObjDesc = (void *) ObjDesc->String.Pointer;
675            break;
676
677        case ACPI_TYPE_BUFFER:
678            ObjDesc = (void *) ObjDesc->Buffer.Pointer;
679            break;
680
681        case ACPI_TYPE_BUFFER_FIELD:
682            ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->BufferField.BufferObj;
683            break;
684
685        case ACPI_TYPE_PACKAGE:
686            ObjDesc = (void *) ObjDesc->Package.Elements;
687            break;
688
689        case ACPI_TYPE_METHOD:
690            ObjDesc = (void *) ObjDesc->Method.AmlStart;
691            break;
692
693        case INTERNAL_TYPE_REGION_FIELD:
694            ObjDesc = (void *) ObjDesc->Field.RegionObj;
695            break;
696
697        case INTERNAL_TYPE_BANK_FIELD:
698            ObjDesc = (void *) ObjDesc->BankField.RegionObj;
699            break;
700
701        case INTERNAL_TYPE_INDEX_FIELD:
702            ObjDesc = (void *) ObjDesc->IndexField.IndexObj;
703            break;
704
705        default:
706            goto Cleanup;
707        }
708
709        ObjType = INTERNAL_TYPE_INVALID;   /* Terminate loop after next pass */
710    }
711
712Cleanup:
713    AcpiOsPrintf ("\n");
714    return (AE_OK);
715}
716
717
718/*******************************************************************************
719 *
720 * FUNCTION:    AcpiNsDumpObjects
721 *
722 * PARAMETERS:  Type                - Object type to be dumped
723 *              MaxDepth            - Maximum depth of dump.  Use ACPI_UINT32_MAX
724 *                                    for an effectively unlimited depth.
725 *              OwnerId             - Dump only objects owned by this ID.  Use
726 *                                    ACPI_UINT32_MAX to match all owners.
727 *              StartHandle         - Where in namespace to start/end search
728 *
729 * DESCRIPTION: Dump typed objects within the loaded namespace.
730 *              Uses AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject.
731 *
732 ******************************************************************************/
733
734void
735AcpiNsDumpObjects (
736    ACPI_OBJECT_TYPE        Type,
737    UINT8                   DisplayType,
738    UINT32                  MaxDepth,
739    UINT32                  OwnerId,
740    ACPI_HANDLE             StartHandle)
741{
742    ACPI_WALK_INFO          Info;
743
744
745    ACPI_FUNCTION_ENTRY ();
746
747
748    Info.DebugLevel = ACPI_LV_TABLES;
749    Info.OwnerId = OwnerId;
750    Info.DisplayType = DisplayType;
751
752
753    (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
754                ACPI_NS_WALK_NO_UNLOCK, AcpiNsDumpOneObject,
755                (void *) &Info, NULL);
756}
757
758
759#ifndef _ACPI_ASL_COMPILER
760/*******************************************************************************
761 *
762 * FUNCTION:    AcpiNsDumpOneDevice
763 *
764 * PARAMETERS:  Handle              - Node to be dumped
765 *              Level               - Nesting level of the handle
766 *              Context             - Passed into WalkNamespace
767 *
768 * DESCRIPTION: Dump a single Node that represents a device
769 *              This procedure is a UserFunction called by AcpiNsWalkNamespace.
770 *
771 ******************************************************************************/
772
773ACPI_STATUS
774AcpiNsDumpOneDevice (
775    ACPI_HANDLE             ObjHandle,
776    UINT32                  Level,
777    void                    *Context,
778    void                    **ReturnValue)
779{
780    ACPI_DEVICE_INFO        Info;
781    ACPI_STATUS             Status;
782    UINT32                  i;
783
784
785    ACPI_FUNCTION_NAME ("NsDumpOneDevice");
786
787
788    Status = AcpiNsDumpOneObject (ObjHandle, Level, Context, ReturnValue);
789
790    Status = AcpiGetObjectInfo (ObjHandle, &Info);
791    if (ACPI_SUCCESS (Status))
792    {
793        for (i = 0; i < Level; i++)
794        {
795            ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " "));
796        }
797
798        ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "    HID: %s, ADR: %8.8X%8.8X, Status: %X\n",
799                        Info.HardwareId,
800                        ACPI_HIDWORD (Info.Address), ACPI_LODWORD (Info.Address),
801                        Info.CurrentStatus));
802    }
803
804    return (Status);
805}
806
807
808/*******************************************************************************
809 *
810 * FUNCTION:    AcpiNsDumpRootDevices
811 *
812 * PARAMETERS:  None
813 *
814 * DESCRIPTION: Dump all objects of type "device"
815 *
816 ******************************************************************************/
817
818void
819AcpiNsDumpRootDevices (void)
820{
821    ACPI_HANDLE             SysBusHandle;
822    ACPI_STATUS             Status;
823
824
825    ACPI_FUNCTION_NAME ("NsDumpRootDevices");
826
827
828    /* Only dump the table if tracing is enabled */
829
830    if (!(ACPI_LV_TABLES & AcpiDbgLevel))
831    {
832        return;
833    }
834
835    Status = AcpiGetHandle (0, ACPI_NS_SYSTEM_BUS, &SysBusHandle);
836    if (ACPI_FAILURE (Status))
837    {
838        return;
839    }
840
841    ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Display of all devices in the namespace:\n"));
842
843    Status = AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, SysBusHandle,
844                ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK,
845                AcpiNsDumpOneDevice, NULL, NULL);
846}
847
848#endif
849
850/*******************************************************************************
851 *
852 * FUNCTION:    AcpiNsDumpTables
853 *
854 * PARAMETERS:  SearchBase          - Root of subtree to be dumped, or
855 *                                    NS_ALL to dump the entire namespace
856 *              MaxDepth            - Maximum depth of dump.  Use INT_MAX
857 *                                    for an effectively unlimited depth.
858 *
859 * DESCRIPTION: Dump the name space, or a portion of it.
860 *
861 ******************************************************************************/
862
863void
864AcpiNsDumpTables (
865    ACPI_HANDLE             SearchBase,
866    UINT32                  MaxDepth)
867{
868    ACPI_HANDLE             SearchHandle = SearchBase;
869
870
871    ACPI_FUNCTION_TRACE ("NsDumpTables");
872
873
874    if (!AcpiGbl_RootNode)
875    {
876        /*
877         * If the name space has not been initialized,
878         * there is nothing to dump.
879         */
880        ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "name space not initialized!\n"));
881        return_VOID;
882    }
883
884    if (ACPI_NS_ALL == SearchBase)
885    {
886        /*  entire namespace    */
887
888        SearchHandle = AcpiGbl_RootNode;
889        ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n"));
890    }
891
892
893    AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, MaxDepth,
894            ACPI_UINT32_MAX, SearchHandle);
895    return_VOID;
896}
897
898
899/*******************************************************************************
900 *
901 * FUNCTION:    AcpiNsDumpEntry
902 *
903 * PARAMETERS:  Handle              - Node to be dumped
904 *              DebugLevel          - Output level
905 *
906 * DESCRIPTION: Dump a single Node
907 *
908 ******************************************************************************/
909
910void
911AcpiNsDumpEntry (
912    ACPI_HANDLE             Handle,
913    UINT32                  DebugLevel)
914{
915    ACPI_WALK_INFO          Info;
916
917
918    ACPI_FUNCTION_ENTRY ();
919
920
921    Info.DebugLevel = DebugLevel;
922    Info.OwnerId = ACPI_UINT32_MAX;
923    Info.DisplayType = ACPI_DISPLAY_SUMMARY;
924
925    (void) AcpiNsDumpOneObject (Handle, 1, &Info, NULL);
926}
927
928#endif
929
930