xref: /titanic_52/usr/src/uts/intel/io/acpica/namespace/nsdump.c (revision fc30d4661fdf50c4c69dacbc572af35439c28cd8)
1 /******************************************************************************
2  *
3  * Module Name: nsdump - table dumping routines for debug
4  *
5  *****************************************************************************/
6 
7 /*
8  * Copyright (C) 2000 - 2016, Intel Corp.
9  * All rights reserved.
10  *
11  * Redistribution and use in source and binary forms, with or without
12  * modification, are permitted provided that the following conditions
13  * are met:
14  * 1. Redistributions of source code must retain the above copyright
15  *    notice, this list of conditions, and the following disclaimer,
16  *    without modification.
17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18  *    substantially similar to the "NO WARRANTY" disclaimer below
19  *    ("Disclaimer") and any redistribution must be conditioned upon
20  *    including a substantially similar Disclaimer requirement for further
21  *    binary redistribution.
22  * 3. Neither the names of the above-listed copyright holders nor the names
23  *    of any contributors may be used to endorse or promote products derived
24  *    from this software without specific prior written permission.
25  *
26  * Alternatively, this software may be distributed under the terms of the
27  * GNU General Public License ("GPL") version 2 as published by the Free
28  * Software Foundation.
29  *
30  * NO WARRANTY
31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41  * POSSIBILITY OF SUCH DAMAGES.
42  */
43 
44 #include "acpi.h"
45 #include "accommon.h"
46 #include "acnamesp.h"
47 #include "acoutput.h"
48 
49 
50 #define _COMPONENT          ACPI_NAMESPACE
51         ACPI_MODULE_NAME    ("nsdump")
52 
53 /* Local prototypes */
54 
55 #ifdef ACPI_OBSOLETE_FUNCTIONS
56 void
57 AcpiNsDumpRootDevices (
58     void);
59 
60 static ACPI_STATUS
61 AcpiNsDumpOneDevice (
62     ACPI_HANDLE             ObjHandle,
63     UINT32                  Level,
64     void                    *Context,
65     void                    **ReturnValue);
66 #endif
67 
68 
69 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
70 
71 static ACPI_STATUS
72 AcpiNsDumpOneObjectPath (
73     ACPI_HANDLE             ObjHandle,
74     UINT32                  Level,
75     void                    *Context,
76     void                    **ReturnValue);
77 
78 static ACPI_STATUS
79 AcpiNsGetMaxDepth (
80     ACPI_HANDLE             ObjHandle,
81     UINT32                  Level,
82     void                    *Context,
83     void                    **ReturnValue);
84 
85 
86 /*******************************************************************************
87  *
88  * FUNCTION:    AcpiNsPrintPathname
89  *
90  * PARAMETERS:  NumSegments         - Number of ACPI name segments
91  *              Pathname            - The compressed (internal) path
92  *
93  * RETURN:      None
94  *
95  * DESCRIPTION: Print an object's full namespace pathname
96  *
97  ******************************************************************************/
98 
99 void
100 AcpiNsPrintPathname (
101     UINT32                  NumSegments,
102     const char              *Pathname)
103 {
104     UINT32                  i;
105 
106 
107     ACPI_FUNCTION_NAME (NsPrintPathname);
108 
109 
110     /* Check if debug output enabled */
111 
112     if (!ACPI_IS_DEBUG_ENABLED (ACPI_LV_NAMES, ACPI_NAMESPACE))
113     {
114         return;
115     }
116 
117     /* Print the entire name */
118 
119     ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "["));
120 
121     while (NumSegments)
122     {
123         for (i = 0; i < 4; i++)
124         {
125             isprint ((int) Pathname[i]) ?
126                 AcpiOsPrintf ("%c", Pathname[i]) :
127                 AcpiOsPrintf ("?");
128         }
129 
130         Pathname += ACPI_NAME_SIZE;
131         NumSegments--;
132         if (NumSegments)
133         {
134             AcpiOsPrintf (".");
135         }
136     }
137 
138     AcpiOsPrintf ("]\n");
139 }
140 
141 
142 #ifdef ACPI_OBSOLETE_FUNCTIONS
143 /* Not used at this time, perhaps later */
144 
145 /*******************************************************************************
146  *
147  * FUNCTION:    AcpiNsDumpPathname
148  *
149  * PARAMETERS:  Handle              - Object
150  *              Msg                 - Prefix message
151  *              Level               - Desired debug level
152  *              Component           - Caller's component ID
153  *
154  * RETURN:      None
155  *
156  * DESCRIPTION: Print an object's full namespace pathname
157  *              Manages allocation/freeing of a pathname buffer
158  *
159  ******************************************************************************/
160 
161 void
162 AcpiNsDumpPathname (
163     ACPI_HANDLE             Handle,
164     const char              *Msg,
165     UINT32                  Level,
166     UINT32                  Component)
167 {
168 
169     ACPI_FUNCTION_TRACE (NsDumpPathname);
170 
171 
172     /* Do this only if the requested debug level and component are enabled */
173 
174     if (!ACPI_IS_DEBUG_ENABLED (Level, Component))
175     {
176         return_VOID;
177     }
178 
179     /* Convert handle to a full pathname and print it (with supplied message) */
180 
181     AcpiNsPrintNodePathname (Handle, Msg);
182     AcpiOsPrintf ("\n");
183     return_VOID;
184 }
185 #endif
186 
187 /*******************************************************************************
188  *
189  * FUNCTION:    AcpiNsDumpOneObject
190  *
191  * PARAMETERS:  ObjHandle           - Node to be dumped
192  *              Level               - Nesting level of the handle
193  *              Context             - Passed into WalkNamespace
194  *              ReturnValue         - Not used
195  *
196  * RETURN:      Status
197  *
198  * DESCRIPTION: Dump a single Node
199  *              This procedure is a UserFunction called by AcpiNsWalkNamespace.
200  *
201  ******************************************************************************/
202 
203 ACPI_STATUS
204 AcpiNsDumpOneObject (
205     ACPI_HANDLE             ObjHandle,
206     UINT32                  Level,
207     void                    *Context,
208     void                    **ReturnValue)
209 {
210     ACPI_WALK_INFO          *Info = (ACPI_WALK_INFO *) Context;
211     ACPI_NAMESPACE_NODE     *ThisNode;
212     ACPI_OPERAND_OBJECT     *ObjDesc = NULL;
213     ACPI_OBJECT_TYPE        ObjType;
214     ACPI_OBJECT_TYPE        Type;
215     UINT32                  BytesToDump;
216     UINT32                  DbgLevel;
217     UINT32                  i;
218 
219 
220     ACPI_FUNCTION_NAME (NsDumpOneObject);
221 
222 
223     /* Is output enabled? */
224 
225     if (!(AcpiDbgLevel & Info->DebugLevel))
226     {
227         return (AE_OK);
228     }
229 
230     if (!ObjHandle)
231     {
232         ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n"));
233         return (AE_OK);
234     }
235 
236     ThisNode = AcpiNsValidateHandle (ObjHandle);
237     if (!ThisNode)
238     {
239         ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Invalid object handle %p\n",
240             ObjHandle));
241         return (AE_OK);
242     }
243 
244     Type = ThisNode->Type;
245 
246     /* Check if the owner matches */
247 
248     if ((Info->OwnerId != ACPI_OWNER_ID_MAX) &&
249         (Info->OwnerId != ThisNode->OwnerId))
250     {
251         return (AE_OK);
252     }
253 
254     if (!(Info->DisplayType & ACPI_DISPLAY_SHORT))
255     {
256         /* Indent the object according to the level */
257 
258         AcpiOsPrintf ("%2d%*s", (UINT32) Level - 1, (int) Level * 2, " ");
259 
260         /* Check the node type and name */
261 
262         if (Type > ACPI_TYPE_LOCAL_MAX)
263         {
264             ACPI_WARNING ((AE_INFO,
265                 "Invalid ACPI Object Type 0x%08X", Type));
266         }
267 
268         AcpiOsPrintf ("%4.4s", AcpiUtGetNodeName (ThisNode));
269     }
270 
271     /* Now we can print out the pertinent information */
272 
273     AcpiOsPrintf (" %-12s %p %2.2X ",
274         AcpiUtGetTypeName (Type), ThisNode, ThisNode->OwnerId);
275 
276     DbgLevel = AcpiDbgLevel;
277     AcpiDbgLevel = 0;
278     ObjDesc = AcpiNsGetAttachedObject (ThisNode);
279     AcpiDbgLevel = DbgLevel;
280 
281     /* Temp nodes are those nodes created by a control method */
282 
283     if (ThisNode->Flags & ANOBJ_TEMPORARY)
284     {
285         AcpiOsPrintf ("(T) ");
286     }
287 
288     switch (Info->DisplayType & ACPI_DISPLAY_MASK)
289     {
290     case ACPI_DISPLAY_SUMMARY:
291 
292         if (!ObjDesc)
293         {
294             /* No attached object. Some types should always have an object */
295 
296             switch (Type)
297             {
298             case ACPI_TYPE_INTEGER:
299             case ACPI_TYPE_PACKAGE:
300             case ACPI_TYPE_BUFFER:
301             case ACPI_TYPE_STRING:
302             case ACPI_TYPE_METHOD:
303 
304                 AcpiOsPrintf ("<No attached object>");
305                 break;
306 
307             default:
308 
309                 break;
310             }
311 
312             AcpiOsPrintf ("\n");
313             return (AE_OK);
314         }
315 
316         switch (Type)
317         {
318         case ACPI_TYPE_PROCESSOR:
319 
320             AcpiOsPrintf ("ID %02X Len %02X Addr %8.8X%8.8X\n",
321                 ObjDesc->Processor.ProcId, ObjDesc->Processor.Length,
322                 ACPI_FORMAT_UINT64 (ObjDesc->Processor.Address));
323             break;
324 
325         case ACPI_TYPE_DEVICE:
326 
327             AcpiOsPrintf ("Notify Object: %p\n", ObjDesc);
328             break;
329 
330         case ACPI_TYPE_METHOD:
331 
332             AcpiOsPrintf ("Args %X Len %.4X Aml %p\n",
333                 (UINT32) ObjDesc->Method.ParamCount,
334                 ObjDesc->Method.AmlLength, ObjDesc->Method.AmlStart);
335             break;
336 
337         case ACPI_TYPE_INTEGER:
338 
339             AcpiOsPrintf ("= %8.8X%8.8X\n",
340                 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
341             break;
342 
343         case ACPI_TYPE_PACKAGE:
344 
345             if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
346             {
347                 AcpiOsPrintf ("Elements %.2X\n",
348                     ObjDesc->Package.Count);
349             }
350             else
351             {
352                 AcpiOsPrintf ("[Length not yet evaluated]\n");
353             }
354             break;
355 
356         case ACPI_TYPE_BUFFER:
357 
358             if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
359             {
360                 AcpiOsPrintf ("Len %.2X",
361                     ObjDesc->Buffer.Length);
362 
363                 /* Dump some of the buffer */
364 
365                 if (ObjDesc->Buffer.Length > 0)
366                 {
367                     AcpiOsPrintf (" =");
368                     for (i = 0; (i < ObjDesc->Buffer.Length && i < 12); i++)
369                     {
370                         AcpiOsPrintf (" %.2hX", ObjDesc->Buffer.Pointer[i]);
371                     }
372                 }
373                 AcpiOsPrintf ("\n");
374             }
375             else
376             {
377                 AcpiOsPrintf ("[Length not yet evaluated]\n");
378             }
379             break;
380 
381         case ACPI_TYPE_STRING:
382 
383             AcpiOsPrintf ("Len %.2X ", ObjDesc->String.Length);
384             AcpiUtPrintString (ObjDesc->String.Pointer, 80);
385             AcpiOsPrintf ("\n");
386             break;
387 
388         case ACPI_TYPE_REGION:
389 
390             AcpiOsPrintf ("[%s]",
391                 AcpiUtGetRegionName (ObjDesc->Region.SpaceId));
392             if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
393             {
394                 AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n",
395                     ACPI_FORMAT_UINT64 (ObjDesc->Region.Address),
396                     ObjDesc->Region.Length);
397             }
398             else
399             {
400                 AcpiOsPrintf (" [Address/Length not yet evaluated]\n");
401             }
402             break;
403 
404         case ACPI_TYPE_LOCAL_REFERENCE:
405 
406             AcpiOsPrintf ("[%s]\n", AcpiUtGetReferenceName (ObjDesc));
407             break;
408 
409         case ACPI_TYPE_BUFFER_FIELD:
410 
411             if (ObjDesc->BufferField.BufferObj &&
412                 ObjDesc->BufferField.BufferObj->Buffer.Node)
413             {
414                 AcpiOsPrintf ("Buf [%4.4s]",
415                     AcpiUtGetNodeName (
416                         ObjDesc->BufferField.BufferObj->Buffer.Node));
417             }
418             break;
419 
420         case ACPI_TYPE_LOCAL_REGION_FIELD:
421 
422             AcpiOsPrintf ("Rgn [%4.4s]",
423                 AcpiUtGetNodeName (
424                     ObjDesc->CommonField.RegionObj->Region.Node));
425             break;
426 
427         case ACPI_TYPE_LOCAL_BANK_FIELD:
428 
429             AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]",
430                 AcpiUtGetNodeName (
431                     ObjDesc->CommonField.RegionObj->Region.Node),
432                 AcpiUtGetNodeName (
433                     ObjDesc->BankField.BankObj->CommonField.Node));
434             break;
435 
436         case ACPI_TYPE_LOCAL_INDEX_FIELD:
437 
438             AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]",
439                 AcpiUtGetNodeName (
440                     ObjDesc->IndexField.IndexObj->CommonField.Node),
441                 AcpiUtGetNodeName (
442                     ObjDesc->IndexField.DataObj->CommonField.Node));
443             break;
444 
445         case ACPI_TYPE_LOCAL_ALIAS:
446         case ACPI_TYPE_LOCAL_METHOD_ALIAS:
447 
448             AcpiOsPrintf ("Target %4.4s (%p)\n",
449                 AcpiUtGetNodeName (ObjDesc), ObjDesc);
450             break;
451 
452         default:
453 
454             AcpiOsPrintf ("Object %p\n", ObjDesc);
455             break;
456         }
457 
458         /* Common field handling */
459 
460         switch (Type)
461         {
462         case ACPI_TYPE_BUFFER_FIELD:
463         case ACPI_TYPE_LOCAL_REGION_FIELD:
464         case ACPI_TYPE_LOCAL_BANK_FIELD:
465         case ACPI_TYPE_LOCAL_INDEX_FIELD:
466 
467             AcpiOsPrintf (" Off %.3X Len %.2X Acc %.2hd\n",
468                 (ObjDesc->CommonField.BaseByteOffset * 8)
469                     + ObjDesc->CommonField.StartFieldBitOffset,
470                 ObjDesc->CommonField.BitLength,
471                 ObjDesc->CommonField.AccessByteWidth);
472             break;
473 
474         default:
475 
476             break;
477         }
478         break;
479 
480     case ACPI_DISPLAY_OBJECTS:
481 
482         AcpiOsPrintf ("O:%p", ObjDesc);
483         if (!ObjDesc)
484         {
485             /* No attached object, we are done */
486 
487             AcpiOsPrintf ("\n");
488             return (AE_OK);
489         }
490 
491         AcpiOsPrintf ("(R%u)", ObjDesc->Common.ReferenceCount);
492 
493         switch (Type)
494         {
495         case ACPI_TYPE_METHOD:
496 
497             /* Name is a Method and its AML offset/length are set */
498 
499             AcpiOsPrintf (" M:%p-%X\n", ObjDesc->Method.AmlStart,
500                 ObjDesc->Method.AmlLength);
501             break;
502 
503         case ACPI_TYPE_INTEGER:
504 
505             AcpiOsPrintf (" I:%8.8X8.8%X\n",
506                 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
507             break;
508 
509         case ACPI_TYPE_STRING:
510 
511             AcpiOsPrintf (" S:%p-%X\n", ObjDesc->String.Pointer,
512                 ObjDesc->String.Length);
513             break;
514 
515         case ACPI_TYPE_BUFFER:
516 
517             AcpiOsPrintf (" B:%p-%X\n", ObjDesc->Buffer.Pointer,
518                 ObjDesc->Buffer.Length);
519             break;
520 
521         default:
522 
523             AcpiOsPrintf ("\n");
524             break;
525         }
526         break;
527 
528     default:
529         AcpiOsPrintf ("\n");
530         break;
531     }
532 
533     /* If debug turned off, done */
534 
535     if (!(AcpiDbgLevel & ACPI_LV_VALUES))
536     {
537         return (AE_OK);
538     }
539 
540     /* If there is an attached object, display it */
541 
542     DbgLevel = AcpiDbgLevel;
543     AcpiDbgLevel = 0;
544     ObjDesc = AcpiNsGetAttachedObject (ThisNode);
545     AcpiDbgLevel = DbgLevel;
546 
547     /* Dump attached objects */
548 
549     while (ObjDesc)
550     {
551         ObjType = ACPI_TYPE_INVALID;
552         AcpiOsPrintf ("Attached Object %p: ", ObjDesc);
553 
554         /* Decode the type of attached object and dump the contents */
555 
556         switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
557         {
558         case ACPI_DESC_TYPE_NAMED:
559 
560             AcpiOsPrintf ("(Ptr to Node)\n");
561             BytesToDump = sizeof (ACPI_NAMESPACE_NODE);
562             ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
563             break;
564 
565         case ACPI_DESC_TYPE_OPERAND:
566 
567             ObjType = ObjDesc->Common.Type;
568 
569             if (ObjType > ACPI_TYPE_LOCAL_MAX)
570             {
571                 AcpiOsPrintf (
572                     "(Pointer to ACPI Object type %.2X [UNKNOWN])\n",
573                     ObjType);
574 
575                 BytesToDump = 32;
576             }
577             else
578             {
579                 AcpiOsPrintf (
580                     "(Pointer to ACPI Object type %.2X [%s])\n",
581                     ObjType, AcpiUtGetTypeName (ObjType));
582 
583                 BytesToDump = sizeof (ACPI_OPERAND_OBJECT);
584             }
585 
586             ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
587             break;
588 
589         default:
590 
591             break;
592         }
593 
594         /* If value is NOT an internal object, we are done */
595 
596         if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
597         {
598             goto Cleanup;
599         }
600 
601         /* Valid object, get the pointer to next level, if any */
602 
603         switch (ObjType)
604         {
605         case ACPI_TYPE_BUFFER:
606         case ACPI_TYPE_STRING:
607             /*
608              * NOTE: takes advantage of common fields between string/buffer
609              */
610             BytesToDump = ObjDesc->String.Length;
611             ObjDesc = (void *) ObjDesc->String.Pointer;
612 
613             AcpiOsPrintf ("(Buffer/String pointer %p length %X)\n",
614                 ObjDesc, BytesToDump);
615             ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
616             goto Cleanup;
617 
618         case ACPI_TYPE_BUFFER_FIELD:
619 
620             ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->BufferField.BufferObj;
621             break;
622 
623         case ACPI_TYPE_PACKAGE:
624 
625             ObjDesc = (void *) ObjDesc->Package.Elements;
626             break;
627 
628         case ACPI_TYPE_METHOD:
629 
630             ObjDesc = (void *) ObjDesc->Method.AmlStart;
631             break;
632 
633         case ACPI_TYPE_LOCAL_REGION_FIELD:
634 
635             ObjDesc = (void *) ObjDesc->Field.RegionObj;
636             break;
637 
638         case ACPI_TYPE_LOCAL_BANK_FIELD:
639 
640             ObjDesc = (void *) ObjDesc->BankField.RegionObj;
641             break;
642 
643         case ACPI_TYPE_LOCAL_INDEX_FIELD:
644 
645             ObjDesc = (void *) ObjDesc->IndexField.IndexObj;
646             break;
647 
648         default:
649 
650             goto Cleanup;
651         }
652 
653         ObjType = ACPI_TYPE_INVALID;   /* Terminate loop after next pass */
654     }
655 
656 Cleanup:
657     AcpiOsPrintf ("\n");
658     return (AE_OK);
659 }
660 
661 
662 /*******************************************************************************
663  *
664  * FUNCTION:    AcpiNsDumpObjects
665  *
666  * PARAMETERS:  Type                - Object type to be dumped
667  *              DisplayType         - 0 or ACPI_DISPLAY_SUMMARY
668  *              MaxDepth            - Maximum depth of dump. Use ACPI_UINT32_MAX
669  *                                    for an effectively unlimited depth.
670  *              OwnerId             - Dump only objects owned by this ID. Use
671  *                                    ACPI_UINT32_MAX to match all owners.
672  *              StartHandle         - Where in namespace to start/end search
673  *
674  * RETURN:      None
675  *
676  * DESCRIPTION: Dump typed objects within the loaded namespace. Uses
677  *              AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject.
678  *
679  ******************************************************************************/
680 
681 void
682 AcpiNsDumpObjects (
683     ACPI_OBJECT_TYPE        Type,
684     UINT8                   DisplayType,
685     UINT32                  MaxDepth,
686     ACPI_OWNER_ID           OwnerId,
687     ACPI_HANDLE             StartHandle)
688 {
689     ACPI_WALK_INFO          Info;
690     ACPI_STATUS             Status;
691 
692 
693     ACPI_FUNCTION_ENTRY ();
694 
695 
696     /*
697      * Just lock the entire namespace for the duration of the dump.
698      * We don't want any changes to the namespace during this time,
699      * especially the temporary nodes since we are going to display
700      * them also.
701      */
702     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
703     if (ACPI_FAILURE (Status))
704     {
705         AcpiOsPrintf ("Could not acquire namespace mutex\n");
706         return;
707     }
708 
709     Info.DebugLevel = ACPI_LV_TABLES;
710     Info.OwnerId = OwnerId;
711     Info.DisplayType = DisplayType;
712 
713     (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
714         ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,
715         AcpiNsDumpOneObject, NULL, (void *) &Info, NULL);
716 
717     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
718 }
719 
720 
721 /*******************************************************************************
722  *
723  * FUNCTION:    AcpiNsDumpOneObjectPath, AcpiNsGetMaxDepth
724  *
725  * PARAMETERS:  ObjHandle           - Node to be dumped
726  *              Level               - Nesting level of the handle
727  *              Context             - Passed into WalkNamespace
728  *              ReturnValue         - Not used
729  *
730  * RETURN:      Status
731  *
732  * DESCRIPTION: Dump the full pathname to a namespace object. AcpNsGetMaxDepth
733  *              computes the maximum nesting depth in the namespace tree, in
734  *              order to simplify formatting in AcpiNsDumpOneObjectPath.
735  *              These procedures are UserFunctions called by AcpiNsWalkNamespace.
736  *
737  ******************************************************************************/
738 
739 static ACPI_STATUS
740 AcpiNsDumpOneObjectPath (
741     ACPI_HANDLE             ObjHandle,
742     UINT32                  Level,
743     void                    *Context,
744     void                    **ReturnValue)
745 {
746     UINT32                  MaxLevel = *((UINT32 *) Context);
747     char                    *Pathname;
748     ACPI_NAMESPACE_NODE     *Node;
749     int                     PathIndent;
750 
751 
752     if (!ObjHandle)
753     {
754         return (AE_OK);
755     }
756 
757     Node = AcpiNsValidateHandle (ObjHandle);
758     if (!Node)
759     {
760         /* Ignore bad node during namespace walk */
761 
762         return (AE_OK);
763     }
764 
765     Pathname = AcpiNsGetNormalizedPathname (Node, TRUE);
766 
767     PathIndent = 1;
768     if (Level <= MaxLevel)
769     {
770         PathIndent = MaxLevel - Level + 1;
771     }
772 
773     AcpiOsPrintf ("%2d%*s%-12s%*s",
774         Level, Level, " ", AcpiUtGetTypeName (Node->Type),
775         PathIndent, " ");
776 
777     AcpiOsPrintf ("%s\n", &Pathname[1]);
778     ACPI_FREE (Pathname);
779     return (AE_OK);
780 }
781 
782 
783 static ACPI_STATUS
784 AcpiNsGetMaxDepth (
785     ACPI_HANDLE             ObjHandle,
786     UINT32                  Level,
787     void                    *Context,
788     void                    **ReturnValue)
789 {
790     UINT32                  *MaxLevel = (UINT32 *) Context;
791 
792 
793     if (Level > *MaxLevel)
794     {
795         *MaxLevel = Level;
796     }
797     return (AE_OK);
798 }
799 
800 
801 /*******************************************************************************
802  *
803  * FUNCTION:    AcpiNsDumpObjectPaths
804  *
805  * PARAMETERS:  Type                - Object type to be dumped
806  *              DisplayType         - 0 or ACPI_DISPLAY_SUMMARY
807  *              MaxDepth            - Maximum depth of dump. Use ACPI_UINT32_MAX
808  *                                    for an effectively unlimited depth.
809  *              OwnerId             - Dump only objects owned by this ID. Use
810  *                                    ACPI_UINT32_MAX to match all owners.
811  *              StartHandle         - Where in namespace to start/end search
812  *
813  * RETURN:      None
814  *
815  * DESCRIPTION: Dump full object pathnames within the loaded namespace. Uses
816  *              AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObjectPath.
817  *
818  ******************************************************************************/
819 
820 void
821 AcpiNsDumpObjectPaths (
822     ACPI_OBJECT_TYPE        Type,
823     UINT8                   DisplayType,
824     UINT32                  MaxDepth,
825     ACPI_OWNER_ID           OwnerId,
826     ACPI_HANDLE             StartHandle)
827 {
828     ACPI_STATUS             Status;
829     UINT32                  MaxLevel = 0;
830 
831 
832     ACPI_FUNCTION_ENTRY ();
833 
834 
835     /*
836      * Just lock the entire namespace for the duration of the dump.
837      * We don't want any changes to the namespace during this time,
838      * especially the temporary nodes since we are going to display
839      * them also.
840      */
841     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
842     if (ACPI_FAILURE (Status))
843     {
844         AcpiOsPrintf ("Could not acquire namespace mutex\n");
845         return;
846     }
847 
848     /* Get the max depth of the namespace tree, for formatting later */
849 
850     (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
851         ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,
852         AcpiNsGetMaxDepth, NULL, (void *) &MaxLevel, NULL);
853 
854     /* Now dump the entire namespace */
855 
856     (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
857         ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,
858         AcpiNsDumpOneObjectPath, NULL, (void *) &MaxLevel, NULL);
859 
860     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
861 }
862 
863 
864 /*******************************************************************************
865  *
866  * FUNCTION:    AcpiNsDumpEntry
867  *
868  * PARAMETERS:  Handle              - Node to be dumped
869  *              DebugLevel          - Output level
870  *
871  * RETURN:      None
872  *
873  * DESCRIPTION: Dump a single Node
874  *
875  ******************************************************************************/
876 
877 void
878 AcpiNsDumpEntry (
879     ACPI_HANDLE             Handle,
880     UINT32                  DebugLevel)
881 {
882     ACPI_WALK_INFO          Info;
883 
884 
885     ACPI_FUNCTION_ENTRY ();
886 
887 
888     Info.DebugLevel = DebugLevel;
889     Info.OwnerId = ACPI_OWNER_ID_MAX;
890     Info.DisplayType = ACPI_DISPLAY_SUMMARY;
891 
892     (void) AcpiNsDumpOneObject (Handle, 1, &Info, NULL);
893 }
894 
895 
896 #ifdef ACPI_ASL_COMPILER
897 /*******************************************************************************
898  *
899  * FUNCTION:    AcpiNsDumpTables
900  *
901  * PARAMETERS:  SearchBase          - Root of subtree to be dumped, or
902  *                                    NS_ALL to dump the entire namespace
903  *              MaxDepth            - Maximum depth of dump. Use INT_MAX
904  *                                    for an effectively unlimited depth.
905  *
906  * RETURN:      None
907  *
908  * DESCRIPTION: Dump the name space, or a portion of it.
909  *
910  ******************************************************************************/
911 
912 void
913 AcpiNsDumpTables (
914     ACPI_HANDLE             SearchBase,
915     UINT32                  MaxDepth)
916 {
917     ACPI_HANDLE             SearchHandle = SearchBase;
918 
919 
920     ACPI_FUNCTION_TRACE (NsDumpTables);
921 
922 
923     if (!AcpiGbl_RootNode)
924     {
925         /*
926          * If the name space has not been initialized,
927          * there is nothing to dump.
928          */
929         ACPI_DEBUG_PRINT ((ACPI_DB_TABLES,
930             "namespace not initialized!\n"));
931         return_VOID;
932     }
933 
934     if (ACPI_NS_ALL == SearchBase)
935     {
936         /* Entire namespace */
937 
938         SearchHandle = AcpiGbl_RootNode;
939         ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n"));
940     }
941 
942     AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, MaxDepth,
943         ACPI_OWNER_ID_MAX, SearchHandle);
944     return_VOID;
945 }
946 #endif
947 #endif
948