nsdump.c revision 91116
1/******************************************************************************
2 *
3 * Module Name: nsdump - table dumping routines for debug
4 *              $Revision: 127 $
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 "acinterp.h"
122#include "acnamesp.h"
123#include "actables.h"
124#include "acparser.h"
125
126
127#define _COMPONENT          ACPI_NAMESPACE
128        ACPI_MODULE_NAME    ("nsdump")
129
130#if defined(ACPI_DEBUG) || defined(ENABLE_DEBUGGER)
131
132
133/*******************************************************************************
134 *
135 * FUNCTION:    AcpiNsPrintPathname
136 *
137 * PARAMETERS:  NumSegment          - Number of ACPI name segments
138 *              Pathname            - The compressed (internal) path
139 *
140 * DESCRIPTION: Print an object's full namespace pathname
141 *
142 ******************************************************************************/
143
144void
145AcpiNsPrintPathname (
146    UINT32                  NumSegments,
147    char                    *Pathname)
148{
149    ACPI_FUNCTION_NAME ("AcpiNsPrintPathname");
150
151
152    if (!(AcpiDbgLevel & ACPI_LV_NAMES) || !(AcpiDbgLayer & ACPI_NAMESPACE))
153    {
154        return;
155    }
156
157        /* Print the entire name */
158
159    ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "["));
160
161    while (NumSegments)
162    {
163        AcpiOsPrintf ("%4.4s", Pathname);
164        Pathname += ACPI_NAME_SIZE;
165
166        NumSegments--;
167        if (NumSegments)
168        {
169            AcpiOsPrintf (".");
170        }
171    }
172
173    AcpiOsPrintf ("]\n");
174}
175
176
177/*******************************************************************************
178 *
179 * FUNCTION:    AcpiNsDumpPathname
180 *
181 * PARAMETERS:  Handle              - Object
182 *              Msg                 - Prefix message
183 *              Level               - Desired debug level
184 *              Component           - Caller's component ID
185 *
186 * DESCRIPTION: Print an object's full namespace pathname
187 *              Manages allocation/freeing of a pathname buffer
188 *
189 ******************************************************************************/
190
191ACPI_STATUS
192AcpiNsDumpPathname (
193    ACPI_HANDLE             Handle,
194    NATIVE_CHAR             *Msg,
195    UINT32                  Level,
196    UINT32                  Component)
197{
198    ACPI_BUFFER             Buffer;
199    ACPI_STATUS             Status;
200
201
202    ACPI_FUNCTION_TRACE ("NsDumpPathname");
203
204
205    /* Do this only if the requested debug level and component are enabled */
206
207    if (!(AcpiDbgLevel & Level) || !(AcpiDbgLayer & Component))
208    {
209        return_ACPI_STATUS (AE_OK);
210    }
211
212    /* Convert handle to a full pathname and print it (with supplied message) */
213
214    Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
215
216    Status = AcpiNsHandleToPathname (Handle, &Buffer);
217    if (ACPI_SUCCESS (Status))
218    {
219        AcpiOsPrintf ("%s %s (Node %p)\n", Msg, Buffer.Pointer, Handle);
220        ACPI_MEM_FREE (Buffer.Pointer);
221    }
222
223    return_ACPI_STATUS (Status);
224}
225
226
227/*******************************************************************************
228 *
229 * FUNCTION:    AcpiNsDumpOneObject
230 *
231 * PARAMETERS:  Handle              - Node to be dumped
232 *              Level               - Nesting level of the handle
233 *              Context             - Passed into WalkNamespace
234 *
235 * DESCRIPTION: Dump a single Node
236 *              This procedure is a UserFunction called by AcpiNsWalkNamespace.
237 *
238 ******************************************************************************/
239
240ACPI_STATUS
241AcpiNsDumpOneObject (
242    ACPI_HANDLE             ObjHandle,
243    UINT32                  Level,
244    void                    *Context,
245    void                    **ReturnValue)
246{
247    ACPI_WALK_INFO          *Info = (ACPI_WALK_INFO *) Context;
248    ACPI_NAMESPACE_NODE     *ThisNode;
249    ACPI_OPERAND_OBJECT     *ObjDesc = NULL;
250    ACPI_OBJECT_TYPE        ObjType;
251    ACPI_OBJECT_TYPE        Type;
252    UINT32                  BytesToDump;
253    UINT32                  DownstreamSiblingMask = 0;
254    UINT32                  LevelTmp;
255    UINT32                  WhichBit;
256    UINT32                  i;
257    UINT32                  DbgLevel;
258
259
260    ACPI_FUNCTION_NAME ("NsDumpOneObject");
261
262
263    ThisNode = AcpiNsMapHandleToNode (ObjHandle);
264
265    LevelTmp    = Level;
266    Type        = ThisNode->Type;
267    WhichBit    = 1;
268
269
270    if (!(AcpiDbgLevel & Info->DebugLevel))
271    {
272        return (AE_OK);
273    }
274
275    if (!ObjHandle)
276    {
277        ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n"));
278        return (AE_OK);
279    }
280
281    /* Check if the owner matches */
282
283    if ((Info->OwnerId != ACPI_UINT32_MAX) &&
284        (Info->OwnerId != ThisNode->OwnerId))
285    {
286        return (AE_OK);
287    }
288
289    /* Indent the object according to the level */
290
291    while (LevelTmp--)
292    {
293        /* Print appropriate characters to form tree structure */
294
295        if (LevelTmp)
296        {
297            if (DownstreamSiblingMask & WhichBit)
298            {
299                AcpiOsPrintf ("|");
300            }
301            else
302            {
303                AcpiOsPrintf (" ");
304            }
305
306            WhichBit <<= 1;
307        }
308        else
309        {
310            if (AcpiNsExistDownstreamSibling (ThisNode + 1))
311            {
312                DownstreamSiblingMask |= (1 << (Level - 1));
313                AcpiOsPrintf ("+");
314            }
315            else
316            {
317                DownstreamSiblingMask &= ACPI_UINT32_MAX ^ (1 << (Level - 1));
318                AcpiOsPrintf ("+");
319            }
320
321            if (ThisNode->Child == NULL)
322            {
323                AcpiOsPrintf ("-");
324            }
325            else if (AcpiNsExistDownstreamSibling (ThisNode->Child))
326            {
327                AcpiOsPrintf ("+");
328            }
329            else
330            {
331                AcpiOsPrintf ("-");
332            }
333        }
334    }
335
336    /* Check the integrity of our data */
337
338    if (Type > INTERNAL_TYPE_MAX)
339    {
340        Type = INTERNAL_TYPE_DEF_ANY;  /* prints as *ERROR* */
341    }
342
343    if (!AcpiUtValidAcpiName (ThisNode->Name))
344    {
345        ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n", ThisNode->Name));
346    }
347
348    /*
349     * Now we can print out the pertinent information
350     */
351    AcpiOsPrintf (" %4.4s %-12s %p",
352            (char *) &ThisNode->Name, AcpiUtGetTypeName (Type), ThisNode);
353
354    DbgLevel = AcpiDbgLevel;
355    AcpiDbgLevel = 0;
356    ObjDesc = AcpiNsGetAttachedObject (ThisNode);
357    AcpiDbgLevel = DbgLevel;
358
359    switch (Info->DisplayType)
360    {
361    case ACPI_DISPLAY_SUMMARY:
362
363        if (!ObjDesc)
364        {
365            /* No attached object, we are done */
366
367            AcpiOsPrintf ("\n");
368            return (AE_OK);
369        }
370
371        switch (Type)
372        {
373        case ACPI_TYPE_PROCESSOR:
374            AcpiOsPrintf (" ID %d Addr %.4X Len %.4X\n",
375                        ObjDesc->Processor.ProcId,
376                        ObjDesc->Processor.Address,
377                        ObjDesc->Processor.Length);
378            break;
379
380        case ACPI_TYPE_DEVICE:
381            AcpiOsPrintf (" Notification object: %p", ObjDesc);
382            break;
383
384        case ACPI_TYPE_METHOD:
385            AcpiOsPrintf (" Args %d Len %.4X Aml %p \n",
386                        ObjDesc->Method.ParamCount,
387                        ObjDesc->Method.AmlLength,
388                        ObjDesc->Method.AmlStart);
389            break;
390
391        case ACPI_TYPE_INTEGER:
392            AcpiOsPrintf (" = %8.8X%8.8X\n",
393                        ACPI_HIDWORD (ObjDesc->Integer.Value),
394                        ACPI_LODWORD (ObjDesc->Integer.Value));
395            break;
396
397        case ACPI_TYPE_PACKAGE:
398            AcpiOsPrintf (" Elements %.2X\n",
399                        ObjDesc->Package.Count);
400            break;
401
402        case ACPI_TYPE_BUFFER:
403            AcpiOsPrintf (" Len %.2X",
404                        ObjDesc->Buffer.Length);
405
406            /* Dump some of the buffer */
407
408            if (ObjDesc->Buffer.Length > 0)
409            {
410                AcpiOsPrintf (" =");
411                for (i = 0; (i < ObjDesc->Buffer.Length && i < 12); i++)
412                {
413                    AcpiOsPrintf (" %.2X", ObjDesc->Buffer.Pointer[i]);
414                }
415            }
416            AcpiOsPrintf ("\n");
417            break;
418
419        case ACPI_TYPE_STRING:
420            AcpiOsPrintf (" Len %.2X", ObjDesc->String.Length);
421
422            if (ObjDesc->String.Length > 0)
423            {
424                 AcpiOsPrintf (" = \"%.32s\"...", ObjDesc->String.Pointer);
425            }
426            AcpiOsPrintf ("\n");
427            break;
428
429        case ACPI_TYPE_REGION:
430            AcpiOsPrintf (" [%s]", AcpiUtGetRegionName (ObjDesc->Region.SpaceId));
431            if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
432            {
433                AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n",
434                            ACPI_HIDWORD (ObjDesc->Region.Address),
435                            ACPI_LODWORD (ObjDesc->Region.Address),
436                            ObjDesc->Region.Length);
437            }
438            else
439            {
440                AcpiOsPrintf (" [Address/Length not evaluated]\n");
441            }
442            break;
443
444        case INTERNAL_TYPE_REFERENCE:
445            AcpiOsPrintf (" [%s]\n",
446                    AcpiPsGetOpcodeName (ObjDesc->Reference.Opcode));
447            break;
448
449        case ACPI_TYPE_BUFFER_FIELD:
450            if (ObjDesc->BufferField.BufferObj &&
451                ObjDesc->BufferField.BufferObj->Buffer.Node)
452            {
453                AcpiOsPrintf (" Buf [%4.4s]",
454                        (char *) &ObjDesc->BufferField.BufferObj->Buffer.Node->Name);
455            }
456            break;
457
458        case INTERNAL_TYPE_REGION_FIELD:
459            AcpiOsPrintf (" Rgn [%4.4s]",
460                    (char *) &ObjDesc->CommonField.RegionObj->Region.Node->Name);
461            break;
462
463        case INTERNAL_TYPE_BANK_FIELD:
464            AcpiOsPrintf (" Rgn [%4.4s] Bnk [%4.4s]",
465                    (char *) &ObjDesc->CommonField.RegionObj->Region.Node->Name,
466                    (char *) &ObjDesc->BankField.BankObj->CommonField.Node->Name);
467            break;
468
469        case INTERNAL_TYPE_INDEX_FIELD:
470            AcpiOsPrintf (" Idx [%4.4s] Dat [%4.4s]",
471                    (char *) &ObjDesc->IndexField.IndexObj->CommonField.Node->Name,
472                    (char *) &ObjDesc->IndexField.DataObj->CommonField.Node->Name);
473            break;
474
475        default:
476            AcpiOsPrintf (" Object %p\n", ObjDesc);
477            break;
478        }
479
480        /* Common field handling */
481
482        switch (Type)
483        {
484        case ACPI_TYPE_BUFFER_FIELD:
485        case INTERNAL_TYPE_REGION_FIELD:
486        case INTERNAL_TYPE_BANK_FIELD:
487        case INTERNAL_TYPE_INDEX_FIELD:
488            AcpiOsPrintf (" Off %.2X Len %.2X Acc %.2d\n",
489                    (ObjDesc->CommonField.BaseByteOffset * 8)
490                        + ObjDesc->CommonField.StartFieldBitOffset,
491                    ObjDesc->CommonField.BitLength,
492                    ObjDesc->CommonField.AccessByteWidth);
493            break;
494        }
495
496        break;
497
498
499    case ACPI_DISPLAY_OBJECTS:
500
501        AcpiOsPrintf ("%p O:%p",
502                ThisNode, ObjDesc);
503
504        if (!ObjDesc)
505        {
506            /* No attached object, we are done */
507
508            AcpiOsPrintf ("\n");
509            return (AE_OK);
510        }
511
512        AcpiOsPrintf ("(R%d)",
513                ObjDesc->Common.ReferenceCount);
514
515        switch (Type)
516        {
517        case ACPI_TYPE_METHOD:
518
519            /* Name is a Method and its AML offset/length are set */
520
521            AcpiOsPrintf (" M:%p-%X\n", ObjDesc->Method.AmlStart,
522                                        ObjDesc->Method.AmlLength);
523            break;
524
525        case ACPI_TYPE_INTEGER:
526
527            AcpiOsPrintf (" N:%X%X\n", ACPI_HIDWORD(ObjDesc->Integer.Value),
528                                       ACPI_LODWORD(ObjDesc->Integer.Value));
529            break;
530
531        case ACPI_TYPE_STRING:
532
533            AcpiOsPrintf (" S:%p-%X\n", ObjDesc->String.Pointer,
534                                        ObjDesc->String.Length);
535            break;
536
537        case ACPI_TYPE_BUFFER:
538
539            AcpiOsPrintf (" B:%p-%X\n", ObjDesc->Buffer.Pointer,
540                                        ObjDesc->Buffer.Length);
541            break;
542
543        default:
544
545            AcpiOsPrintf ("\n");
546            break;
547        }
548        break;
549
550
551    default:
552        AcpiOsPrintf ("\n");
553        break;
554    }
555
556    /* If debug turned off, done */
557
558    if (!(AcpiDbgLevel & ACPI_LV_VALUES))
559    {
560        return (AE_OK);
561    }
562
563
564    /* If there is an attached object, display it */
565
566    DbgLevel = AcpiDbgLevel;
567    AcpiDbgLevel = 0;
568    ObjDesc = AcpiNsGetAttachedObject (ThisNode);
569    AcpiDbgLevel = DbgLevel;
570
571    /* Dump attached objects */
572
573    while (ObjDesc)
574    {
575        ObjType = INTERNAL_TYPE_INVALID;
576        AcpiOsPrintf ("        Attached Object %p: ", ObjDesc);
577
578        /* Decode the type of attached object and dump the contents */
579
580        switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
581        {
582        case ACPI_DESC_TYPE_NAMED:
583
584            AcpiOsPrintf ("(Ptr to Node)\n");
585            BytesToDump = sizeof (ACPI_NAMESPACE_NODE);
586            break;
587
588
589        case ACPI_DESC_TYPE_INTERNAL:
590
591            ObjType = ObjDesc->Common.Type;
592
593            if (ObjType > INTERNAL_TYPE_MAX)
594            {
595                AcpiOsPrintf ("(Ptr to ACPI Object type %X [UNKNOWN])\n", ObjType);
596                BytesToDump = 32;
597            }
598            else
599            {
600                AcpiOsPrintf ("(Ptr to ACPI Object type %2.2X [%s])\n",
601                                    ObjType, AcpiUtGetTypeName (ObjType));
602                BytesToDump = sizeof (ACPI_OPERAND_OBJECT);
603            }
604            break;
605
606
607        default:
608
609            AcpiOsPrintf ("(String or Buffer ptr - not an object descriptor)\n");
610            BytesToDump = 16;
611            break;
612        }
613
614        ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
615
616        /* If value is NOT an internal object, we are done */
617
618        if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_INTERNAL)
619        {
620            goto Cleanup;
621        }
622
623        /*
624         * Valid object, get the pointer to next level, if any
625         */
626        switch (ObjType)
627        {
628        case ACPI_TYPE_STRING:
629            ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->String.Pointer;
630            break;
631
632        case ACPI_TYPE_BUFFER:
633            ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->Buffer.Pointer;
634            break;
635
636        case ACPI_TYPE_BUFFER_FIELD:
637            ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->BufferField.BufferObj;
638            break;
639
640        case ACPI_TYPE_PACKAGE:
641            ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->Package.Elements;
642            break;
643
644        case ACPI_TYPE_METHOD:
645            ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->Method.AmlStart;
646            break;
647
648        case INTERNAL_TYPE_REGION_FIELD:
649            ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->Field.RegionObj;
650            break;
651
652        case INTERNAL_TYPE_BANK_FIELD:
653            ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->BankField.RegionObj;
654            break;
655
656        case INTERNAL_TYPE_INDEX_FIELD:
657            ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->IndexField.IndexObj;
658            break;
659
660       default:
661            goto Cleanup;
662        }
663
664        ObjType = INTERNAL_TYPE_INVALID;   /* Terminate loop after next pass */
665    }
666
667Cleanup:
668    AcpiOsPrintf ("\n");
669    return (AE_OK);
670}
671
672
673/*******************************************************************************
674 *
675 * FUNCTION:    AcpiNsDumpObjects
676 *
677 * PARAMETERS:  Type                - Object type to be dumped
678 *              MaxDepth            - Maximum depth of dump.  Use ACPI_UINT32_MAX
679 *                                    for an effectively unlimited depth.
680 *              OwnerId             - Dump only objects owned by this ID.  Use
681 *                                    ACPI_UINT32_MAX to match all owners.
682 *              StartHandle         - Where in namespace to start/end search
683 *
684 * DESCRIPTION: Dump typed objects within the loaded namespace.
685 *              Uses AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject.
686 *
687 ******************************************************************************/
688
689void
690AcpiNsDumpObjects (
691    ACPI_OBJECT_TYPE        Type,
692    UINT8                   DisplayType,
693    UINT32                  MaxDepth,
694    UINT32                  OwnerId,
695    ACPI_HANDLE             StartHandle)
696{
697    ACPI_WALK_INFO          Info;
698
699
700    ACPI_FUNCTION_ENTRY ();
701
702
703    Info.DebugLevel = ACPI_LV_TABLES;
704    Info.OwnerId = OwnerId;
705    Info.DisplayType = DisplayType;
706
707
708    AcpiNsWalkNamespace (Type, StartHandle, MaxDepth, ACPI_NS_WALK_NO_UNLOCK, AcpiNsDumpOneObject,
709                        (void *) &Info, NULL);
710}
711
712
713#ifndef _ACPI_ASL_COMPILER
714/*******************************************************************************
715 *
716 * FUNCTION:    AcpiNsDumpOneDevice
717 *
718 * PARAMETERS:  Handle              - Node to be dumped
719 *              Level               - Nesting level of the handle
720 *              Context             - Passed into WalkNamespace
721 *
722 * DESCRIPTION: Dump a single Node that represents a device
723 *              This procedure is a UserFunction called by AcpiNsWalkNamespace.
724 *
725 ******************************************************************************/
726
727ACPI_STATUS
728AcpiNsDumpOneDevice (
729    ACPI_HANDLE             ObjHandle,
730    UINT32                  Level,
731    void                    *Context,
732    void                    **ReturnValue)
733{
734    ACPI_DEVICE_INFO        Info;
735    ACPI_STATUS             Status;
736    UINT32                  i;
737
738
739    ACPI_FUNCTION_NAME ("NsDumpOneDevice");
740
741
742    Status = AcpiNsDumpOneObject (ObjHandle, Level, Context, ReturnValue);
743
744    Status = AcpiGetObjectInfo (ObjHandle, &Info);
745    if (ACPI_SUCCESS (Status))
746    {
747        for (i = 0; i < Level; i++)
748        {
749            ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, " "));
750        }
751
752        ACPI_DEBUG_PRINT_RAW ((ACPI_DB_TABLES, "    HID: %s, ADR: %8.8X%8.8X, Status: %x\n",
753                        Info.HardwareId,
754                        ACPI_HIDWORD (Info.Address), ACPI_LODWORD (Info.Address),
755                        Info.CurrentStatus));
756    }
757
758    return (Status);
759}
760
761
762/*******************************************************************************
763 *
764 * FUNCTION:    AcpiNsDumpRootDevices
765 *
766 * PARAMETERS:  None
767 *
768 * DESCRIPTION: Dump all objects of type "device"
769 *
770 ******************************************************************************/
771
772void
773AcpiNsDumpRootDevices (void)
774{
775    ACPI_HANDLE             SysBusHandle;
776
777
778    ACPI_FUNCTION_NAME ("NsDumpRootDevices");
779
780
781    /* Only dump the table if tracing is enabled */
782
783    if (!(ACPI_LV_TABLES & AcpiDbgLevel))
784    {
785        return;
786    }
787
788    AcpiGetHandle (0, ACPI_NS_SYSTEM_BUS, &SysBusHandle);
789
790    ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "Display of all devices in the namespace:\n"));
791    AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, SysBusHandle, ACPI_UINT32_MAX, ACPI_NS_WALK_NO_UNLOCK,
792                        AcpiNsDumpOneDevice, NULL, NULL);
793}
794
795#endif
796
797/*******************************************************************************
798 *
799 * FUNCTION:    AcpiNsDumpTables
800 *
801 * PARAMETERS:  SearchBase          - Root of subtree to be dumped, or
802 *                                    NS_ALL to dump the entire namespace
803 *              MaxDepth            - Maximum depth of dump.  Use INT_MAX
804 *                                    for an effectively unlimited depth.
805 *
806 * DESCRIPTION: Dump the name space, or a portion of it.
807 *
808 ******************************************************************************/
809
810void
811AcpiNsDumpTables (
812    ACPI_HANDLE             SearchBase,
813    UINT32                  MaxDepth)
814{
815    ACPI_HANDLE             SearchHandle = SearchBase;
816
817
818    ACPI_FUNCTION_TRACE ("NsDumpTables");
819
820
821    if (!AcpiGbl_RootNode)
822    {
823        /*
824         * If the name space has not been initialized,
825         * there is nothing to dump.
826         */
827        ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "name space not initialized!\n"));
828        return_VOID;
829    }
830
831    if (ACPI_NS_ALL == SearchBase)
832    {
833        /*  entire namespace    */
834
835        SearchHandle = AcpiGbl_RootNode;
836        ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n"));
837    }
838
839
840    AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, MaxDepth,
841            ACPI_UINT32_MAX, SearchHandle);
842    return_VOID;
843}
844
845
846/*******************************************************************************
847 *
848 * FUNCTION:    AcpiNsDumpEntry
849 *
850 * PARAMETERS:  Handle              - Node to be dumped
851 *              DebugLevel          - Output level
852 *
853 * DESCRIPTION: Dump a single Node
854 *
855 ******************************************************************************/
856
857void
858AcpiNsDumpEntry (
859    ACPI_HANDLE             Handle,
860    UINT32                  DebugLevel)
861{
862    ACPI_WALK_INFO          Info;
863
864
865    ACPI_FUNCTION_ENTRY ();
866
867
868    Info.DebugLevel = DebugLevel;
869    Info.OwnerId = ACPI_UINT32_MAX;
870    Info.DisplayType = ACPI_DISPLAY_SUMMARY;
871
872    AcpiNsDumpOneObject (Handle, 1, &Info, NULL);
873}
874
875#endif
876
877