nsdump.c revision 99679
1/******************************************************************************
2 *
3 * Module Name: nsdump - table dumping routines for debug
4 *              $Revision: 136 $
5 *
6 *****************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2002, Intel Corp.
13 * All rights reserved.
14 *
15 * 2. License
16 *
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights.  You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
20 * property rights.
21 *
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26
27 * make derivatives, distribute, use and display any portion of the Covered
28 * Code in any form, with the right to sublicense such rights; and
29 *
30 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
31 * license (with the right to sublicense), under only those claims of Intel
32 * patents that are infringed by the Original Intel Code, to make, use, sell,
33 * offer to sell, and import the Covered Code and derivative works thereof
34 * solely to the minimum extent necessary to exercise the above copyright
35 * license, and in no event shall the patent license extend to any additions
36 * to or modifications of the Original Intel Code.  No other license or right
37 * is granted directly or by implication, estoppel or otherwise;
38 *
39 * The above copyright and patent license is granted only if the following
40 * conditions are met:
41 *
42 * 3. Conditions
43 *
44 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
45 * Redistribution of source code of any substantial portion of the Covered
46 * Code or modification with rights to further distribute source must include
47 * the above Copyright Notice, the above License, this list of Conditions,
48 * and the following Disclaimer and Export Compliance provision.  In addition,
49 * Licensee must cause all Covered Code to which Licensee contributes to
50 * contain a file documenting the changes Licensee made to create that Covered
51 * Code and the date of any change.  Licensee must include in that file the
52 * documentation of any changes made by any predecessor Licensee.  Licensee
53 * must include a prominent statement that the modification is derived,
54 * directly or indirectly, from Original Intel Code.
55 *
56 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
57 * Redistribution of source code of any substantial portion of the Covered
58 * Code or modification without rights to further distribute source must
59 * include the following Disclaimer and Export Compliance provision in the
60 * documentation and/or other materials provided with distribution.  In
61 * addition, Licensee may not authorize further sublicense of source of any
62 * portion of the Covered Code, and must include terms to the effect that the
63 * license from Licensee to its licensee is limited to the intellectual
64 * property embodied in the software Licensee provides to its licensee, and
65 * not to intellectual property embodied in modifications its licensee may
66 * make.
67 *
68 * 3.3. Redistribution of Executable. Redistribution in executable form of any
69 * substantial portion of the Covered Code or modification must reproduce the
70 * above Copyright Notice, and the following Disclaimer and Export Compliance
71 * provision in the documentation and/or other materials provided with the
72 * distribution.
73 *
74 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * Intel Code.
76 *
77 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
78 * Intel shall be used in advertising or otherwise to promote the sale, use or
79 * other dealings in products derived from or relating to the Covered Code
80 * without prior written authorization from Intel.
81 *
82 * 4. Disclaimer and Export Compliance
83 *
84 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
85 * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
86 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
87 * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
88 * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
89 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * PARTICULAR PURPOSE.
91 *
92 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
93 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
94 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
95 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
96 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
97 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
98 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * LIMITED REMEDY.
100 *
101 * 4.3. Licensee shall not export, either directly or indirectly, any of this
102 * software or system incorporating such software without first obtaining any
103 * required license or other approval from the U. S. Department of Commerce or
104 * any other agency or department of the United States Government.  In the
105 * event Licensee exports any such software from the United States or
106 * re-exports any such software from a foreign destination, Licensee shall
107 * ensure that the distribution and export/re-export of the software is in
108 * compliance with all laws, regulations, orders, or other restrictions of the
109 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
110 * any of its subsidiaries will export/re-export any technical data, process,
111 * software, or service, directly or indirectly, to any country for which the
112 * United States government or any agency thereof requires an export license,
113 * other governmental approval, or letter of assurance, without first obtaining
114 * such license, approval or letter.
115 *
116 *****************************************************************************/
117
118#define __NSDUMP_C__
119
120#include "acpi.h"
121#include "acnamesp.h"
122#include "acparser.h"
123
124
125#define _COMPONENT          ACPI_NAMESPACE
126        ACPI_MODULE_NAME    ("nsdump")
127
128#if defined(ACPI_DEBUG) || defined(ENABLE_DEBUGGER)
129
130
131/*******************************************************************************
132 *
133 * FUNCTION:    AcpiNsPrintPathname
134 *
135 * PARAMETERS:  NumSegment          - Number of ACPI name segments
136 *              Pathname            - The compressed (internal) path
137 *
138 * DESCRIPTION: Print an object's full namespace pathname
139 *
140 ******************************************************************************/
141
142void
143AcpiNsPrintPathname (
144    UINT32                  NumSegments,
145    char                    *Pathname)
146{
147    ACPI_FUNCTION_NAME ("NsPrintPathname");
148
149
150    if (!(AcpiDbgLevel & ACPI_LV_NAMES) || !(AcpiDbgLayer & ACPI_NAMESPACE))
151    {
152        return;
153    }
154
155        /* Print the entire name */
156
157    ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "["));
158
159    while (NumSegments)
160    {
161        AcpiOsPrintf ("%4.4s", Pathname);
162        Pathname += ACPI_NAME_SIZE;
163
164        NumSegments--;
165        if (NumSegments)
166        {
167            AcpiOsPrintf (".");
168        }
169    }
170
171    AcpiOsPrintf ("]\n");
172}
173
174
175/*******************************************************************************
176 *
177 * FUNCTION:    AcpiNsDumpPathname
178 *
179 * PARAMETERS:  Handle              - Object
180 *              Msg                 - Prefix message
181 *              Level               - Desired debug level
182 *              Component           - Caller's component ID
183 *
184 * DESCRIPTION: Print an object's full namespace pathname
185 *              Manages allocation/freeing of a pathname buffer
186 *
187 ******************************************************************************/
188
189ACPI_STATUS
190AcpiNsDumpPathname (
191    ACPI_HANDLE             Handle,
192    NATIVE_CHAR             *Msg,
193    UINT32                  Level,
194    UINT32                  Component)
195{
196    ACPI_BUFFER             Buffer;
197    ACPI_STATUS             Status;
198
199
200    ACPI_FUNCTION_TRACE ("NsDumpPathname");
201
202
203    /* Do this only if the requested debug level and component are enabled */
204
205    if (!(AcpiDbgLevel & Level) || !(AcpiDbgLayer & Component))
206    {
207        return_ACPI_STATUS (AE_OK);
208    }
209
210    /* Convert handle to a full pathname and print it (with supplied message) */
211
212    Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
213
214    Status = AcpiNsHandleToPathname (Handle, &Buffer);
215    if (ACPI_SUCCESS (Status))
216    {
217        AcpiOsPrintf ("%s %s (Node %p)\n", Msg, Buffer.Pointer, Handle);
218        ACPI_MEM_FREE (Buffer.Pointer);
219    }
220
221    return_ACPI_STATUS (Status);
222}
223
224
225/*******************************************************************************
226 *
227 * FUNCTION:    AcpiNsDumpOneObject
228 *
229 * PARAMETERS:  Handle              - Node to be dumped
230 *              Level               - Nesting level of the handle
231 *              Context             - Passed into WalkNamespace
232 *
233 * DESCRIPTION: Dump a single Node
234 *              This procedure is a UserFunction called by AcpiNsWalkNamespace.
235 *
236 ******************************************************************************/
237
238ACPI_STATUS
239AcpiNsDumpOneObject (
240    ACPI_HANDLE             ObjHandle,
241    UINT32                  Level,
242    void                    *Context,
243    void                    **ReturnValue)
244{
245    ACPI_WALK_INFO          *Info = (ACPI_WALK_INFO *) Context;
246    ACPI_NAMESPACE_NODE     *ThisNode;
247    ACPI_OPERAND_OBJECT     *ObjDesc = NULL;
248    ACPI_OBJECT_TYPE        ObjType;
249    ACPI_OBJECT_TYPE        Type;
250    UINT32                  BytesToDump;
251    UINT32                  DownstreamSiblingMask = 0;
252    UINT32                  LevelTmp;
253    UINT32                  WhichBit;
254    UINT32                  i;
255    UINT32                  DbgLevel;
256
257
258    ACPI_FUNCTION_NAME ("NsDumpOneObject");
259
260
261    ThisNode = AcpiNsMapHandleToNode (ObjHandle);
262
263    LevelTmp    = Level;
264    Type        = ThisNode->Type;
265    WhichBit    = 1;
266
267
268    if (!(AcpiDbgLevel & Info->DebugLevel))
269    {
270        return (AE_OK);
271    }
272
273    if (!ObjHandle)
274    {
275        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n"));
276        return (AE_OK);
277    }
278
279    /* Check if the owner matches */
280
281    if ((Info->OwnerId != ACPI_UINT32_MAX) &&
282        (Info->OwnerId != ThisNode->OwnerId))
283    {
284        return (AE_OK);
285    }
286
287    /* Indent the object according to the level */
288
289    while (LevelTmp--)
290    {
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