xref: /haiku/src/add-ons/kernel/bus_managers/acpi/acpica/components/namespace/nsdump.c (revision ca8ed5ea660fb6275799a3b7f138b201c41a667b)
1 /******************************************************************************
2  *
3  * Module Name: nsdump - table dumping routines for debug
4  *
5  *****************************************************************************/
6 
7 /******************************************************************************
8  *
9  * 1. Copyright Notice
10  *
11  * Some or all of this work - Copyright (c) 1999 - 2014, Intel Corp.
12  * All rights reserved.
13  *
14  * 2. License
15  *
16  * 2.1. This is your license from Intel Corp. under its intellectual property
17  * rights. You may have additional license terms from the party that provided
18  * you this software, covering your right to use that party's intellectual
19  * property rights.
20  *
21  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22  * copy of the source code appearing in this file ("Covered Code") an
23  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24  * base code distributed originally by Intel ("Original Intel Code") to copy,
25 
26  * make derivatives, distribute, use and display any portion of the Covered
27  * Code in any form, with the right to sublicense such rights; and
28  *
29  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30  * license (with the right to sublicense), under only those claims of Intel
31  * patents that are infringed by the Original Intel Code, to make, use, sell,
32  * offer to sell, and import the Covered Code and derivative works thereof
33  * solely to the minimum extent necessary to exercise the above copyright
34  * license, and in no event shall the patent license extend to any additions
35  * to or modifications of the Original Intel Code. No other license or right
36  * is granted directly or by implication, estoppel or otherwise;
37  *
38  * The above copyright and patent license is granted only if the following
39  * conditions are met:
40  *
41  * 3. Conditions
42  *
43  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44  * Redistribution of source code of any substantial portion of the Covered
45  * Code or modification with rights to further distribute source must include
46  * the above Copyright Notice, the above License, this list of Conditions,
47  * and the following Disclaimer and Export Compliance provision. In addition,
48  * Licensee must cause all Covered Code to which Licensee contributes to
49  * contain a file documenting the changes Licensee made to create that Covered
50  * Code and the date of any change. Licensee must include in that file the
51  * documentation of any changes made by any predecessor Licensee. Licensee
52  * must include a prominent statement that the modification is derived,
53  * directly or indirectly, from Original Intel Code.
54  *
55  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56  * Redistribution of source code of any substantial portion of the Covered
57  * Code or modification without rights to further distribute source must
58  * include the following Disclaimer and Export Compliance provision in the
59  * documentation and/or other materials provided with distribution. In
60  * addition, Licensee may not authorize further sublicense of source of any
61  * portion of the Covered Code, and must include terms to the effect that the
62  * license from Licensee to its licensee is limited to the intellectual
63  * property embodied in the software Licensee provides to its licensee, and
64  * not to intellectual property embodied in modifications its licensee may
65  * make.
66  *
67  * 3.3. Redistribution of Executable. Redistribution in executable form of any
68  * substantial portion of the Covered Code or modification must reproduce the
69  * above Copyright Notice, and the following Disclaimer and Export Compliance
70  * provision in the documentation and/or other materials provided with the
71  * distribution.
72  *
73  * 3.4. Intel retains all right, title, and interest in and to the Original
74  * Intel Code.
75  *
76  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77  * Intel shall be used in advertising or otherwise to promote the sale, use or
78  * other dealings in products derived from or relating to the Covered Code
79  * without prior written authorization from Intel.
80  *
81  * 4. Disclaimer and Export Compliance
82  *
83  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89  * PARTICULAR PURPOSE.
90  *
91  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98  * LIMITED REMEDY.
99  *
100  * 4.3. Licensee shall not export, either directly or indirectly, any of this
101  * software or system incorporating such software without first obtaining any
102  * required license or other approval from the U. S. Department of Commerce or
103  * any other agency or department of the United States Government. In the
104  * event Licensee exports any such software from the United States or
105  * re-exports any such software from a foreign destination, Licensee shall
106  * ensure that the distribution and export/re-export of the software is in
107  * compliance with all laws, regulations, orders, or other restrictions of the
108  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109  * any of its subsidiaries will export/re-export any technical data, process,
110  * software, or service, directly or indirectly, to any country for which the
111  * United States government or any agency thereof requires an export license,
112  * other governmental approval, or letter of assurance, without first obtaining
113  * such license, approval or letter.
114  *
115  *****************************************************************************/
116 
117 #define __NSDUMP_C__
118 
119 #include "acpi.h"
120 #include "accommon.h"
121 #include "acnamesp.h"
122 #include "acoutput.h"
123 
124 
125 #define _COMPONENT          ACPI_NAMESPACE
126         ACPI_MODULE_NAME    ("nsdump")
127 
128 /* Local prototypes */
129 
130 #ifdef ACPI_OBSOLETE_FUNCTIONS
131 void
132 AcpiNsDumpRootDevices (
133     void);
134 
135 static ACPI_STATUS
136 AcpiNsDumpOneDevice (
137     ACPI_HANDLE             ObjHandle,
138     UINT32                  Level,
139     void                    *Context,
140     void                    **ReturnValue);
141 #endif
142 
143 
144 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
145 
146 static ACPI_STATUS
147 AcpiNsDumpOneObjectPath (
148     ACPI_HANDLE             ObjHandle,
149     UINT32                  Level,
150     void                    *Context,
151     void                    **ReturnValue);
152 
153 static ACPI_STATUS
154 AcpiNsGetMaxDepth (
155     ACPI_HANDLE             ObjHandle,
156     UINT32                  Level,
157     void                    *Context,
158     void                    **ReturnValue);
159 
160 
161 /*******************************************************************************
162  *
163  * FUNCTION:    AcpiNsPrintPathname
164  *
165  * PARAMETERS:  NumSegments         - Number of ACPI name segments
166  *              Pathname            - The compressed (internal) path
167  *
168  * RETURN:      None
169  *
170  * DESCRIPTION: Print an object's full namespace pathname
171  *
172  ******************************************************************************/
173 
174 void
175 AcpiNsPrintPathname (
176     UINT32                  NumSegments,
177     char                    *Pathname)
178 {
179     UINT32                  i;
180 
181 
182     ACPI_FUNCTION_NAME (NsPrintPathname);
183 
184 
185     /* Check if debug output enabled */
186 
187     if (!ACPI_IS_DEBUG_ENABLED (ACPI_LV_NAMES, ACPI_NAMESPACE))
188     {
189         return;
190     }
191 
192     /* Print the entire name */
193 
194     ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "["));
195 
196     while (NumSegments)
197     {
198         for (i = 0; i < 4; i++)
199         {
200             ACPI_IS_PRINT (Pathname[i]) ?
201                 AcpiOsPrintf ("%c", Pathname[i]) :
202                 AcpiOsPrintf ("?");
203         }
204 
205         Pathname += ACPI_NAME_SIZE;
206         NumSegments--;
207         if (NumSegments)
208         {
209             AcpiOsPrintf (".");
210         }
211     }
212 
213     AcpiOsPrintf ("]\n");
214 }
215 
216 
217 /*******************************************************************************
218  *
219  * FUNCTION:    AcpiNsDumpPathname
220  *
221  * PARAMETERS:  Handle              - Object
222  *              Msg                 - Prefix message
223  *              Level               - Desired debug level
224  *              Component           - Caller's component ID
225  *
226  * RETURN:      None
227  *
228  * DESCRIPTION: Print an object's full namespace pathname
229  *              Manages allocation/freeing of a pathname buffer
230  *
231  ******************************************************************************/
232 
233 void
234 AcpiNsDumpPathname (
235     ACPI_HANDLE             Handle,
236     char                    *Msg,
237     UINT32                  Level,
238     UINT32                  Component)
239 {
240 
241     ACPI_FUNCTION_TRACE (NsDumpPathname);
242 
243 
244     /* Do this only if the requested debug level and component are enabled */
245 
246     if (!ACPI_IS_DEBUG_ENABLED (Level, Component))
247     {
248         return_VOID;
249     }
250 
251     /* Convert handle to a full pathname and print it (with supplied message) */
252 
253     AcpiNsPrintNodePathname (Handle, Msg);
254     AcpiOsPrintf ("\n");
255     return_VOID;
256 }
257 
258 
259 /*******************************************************************************
260  *
261  * FUNCTION:    AcpiNsDumpOneObject
262  *
263  * PARAMETERS:  ObjHandle           - Node to be dumped
264  *              Level               - Nesting level of the handle
265  *              Context             - Passed into WalkNamespace
266  *              ReturnValue         - Not used
267  *
268  * RETURN:      Status
269  *
270  * DESCRIPTION: Dump a single Node
271  *              This procedure is a UserFunction called by AcpiNsWalkNamespace.
272  *
273  ******************************************************************************/
274 
275 ACPI_STATUS
276 AcpiNsDumpOneObject (
277     ACPI_HANDLE             ObjHandle,
278     UINT32                  Level,
279     void                    *Context,
280     void                    **ReturnValue)
281 {
282     ACPI_WALK_INFO          *Info = (ACPI_WALK_INFO *) Context;
283     ACPI_NAMESPACE_NODE     *ThisNode;
284     ACPI_OPERAND_OBJECT     *ObjDesc = NULL;
285     ACPI_OBJECT_TYPE        ObjType;
286     ACPI_OBJECT_TYPE        Type;
287     UINT32                  BytesToDump;
288     UINT32                  DbgLevel;
289     UINT32                  i;
290 
291 
292     ACPI_FUNCTION_NAME (NsDumpOneObject);
293 
294 
295     /* Is output enabled? */
296 
297     if (!(AcpiDbgLevel & Info->DebugLevel))
298     {
299         return (AE_OK);
300     }
301 
302     if (!ObjHandle)
303     {
304         ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n"));
305         return (AE_OK);
306     }
307 
308     ThisNode = AcpiNsValidateHandle (ObjHandle);
309     if (!ThisNode)
310     {
311         ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Invalid object handle %p\n",
312             ObjHandle));
313         return (AE_OK);
314     }
315 
316     Type = ThisNode->Type;
317 
318     /* Check if the owner matches */
319 
320     if ((Info->OwnerId != ACPI_OWNER_ID_MAX) &&
321         (Info->OwnerId != ThisNode->OwnerId))
322     {
323         return (AE_OK);
324     }
325 
326     if (!(Info->DisplayType & ACPI_DISPLAY_SHORT))
327     {
328         /* Indent the object according to the level */
329 
330         AcpiOsPrintf ("%2d%*s", (UINT32) Level - 1, (int) Level * 2, " ");
331 
332         /* Check the node type and name */
333 
334         if (Type > ACPI_TYPE_LOCAL_MAX)
335         {
336             ACPI_WARNING ((AE_INFO, "Invalid ACPI Object Type 0x%08X", Type));
337         }
338 
339         AcpiOsPrintf ("%4.4s", AcpiUtGetNodeName (ThisNode));
340     }
341 
342     /* Now we can print out the pertinent information */
343 
344     AcpiOsPrintf (" %-12s %p %2.2X ",
345             AcpiUtGetTypeName (Type), ThisNode, ThisNode->OwnerId);
346 
347     DbgLevel = AcpiDbgLevel;
348     AcpiDbgLevel = 0;
349     ObjDesc = AcpiNsGetAttachedObject (ThisNode);
350     AcpiDbgLevel = DbgLevel;
351 
352     /* Temp nodes are those nodes created by a control method */
353 
354     if (ThisNode->Flags & ANOBJ_TEMPORARY)
355     {
356         AcpiOsPrintf ("(T) ");
357     }
358 
359     switch (Info->DisplayType & ACPI_DISPLAY_MASK)
360     {
361     case ACPI_DISPLAY_SUMMARY:
362 
363         if (!ObjDesc)
364         {
365             /* No attached object. Some types should always have an object */
366 
367             switch (Type)
368             {
369             case ACPI_TYPE_INTEGER:
370             case ACPI_TYPE_PACKAGE:
371             case ACPI_TYPE_BUFFER:
372             case ACPI_TYPE_STRING:
373             case ACPI_TYPE_METHOD:
374 
375                 AcpiOsPrintf ("<No attached object>");
376                 break;
377 
378             default:
379 
380                 break;
381             }
382 
383             AcpiOsPrintf ("\n");
384             return (AE_OK);
385         }
386 
387         switch (Type)
388         {
389         case ACPI_TYPE_PROCESSOR:
390 
391             AcpiOsPrintf ("ID %02X Len %02X Addr %p\n",
392                 ObjDesc->Processor.ProcId, ObjDesc->Processor.Length,
393                 ACPI_CAST_PTR (void, ObjDesc->Processor.Address));
394             break;
395 
396         case ACPI_TYPE_DEVICE:
397 
398             AcpiOsPrintf ("Notify Object: %p\n", ObjDesc);
399             break;
400 
401         case ACPI_TYPE_METHOD:
402 
403             AcpiOsPrintf ("Args %X Len %.4X Aml %p\n",
404                 (UINT32) ObjDesc->Method.ParamCount,
405                 ObjDesc->Method.AmlLength, ObjDesc->Method.AmlStart);
406             break;
407 
408         case ACPI_TYPE_INTEGER:
409 
410             AcpiOsPrintf ("= %8.8X%8.8X\n",
411                 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
412             break;
413 
414         case ACPI_TYPE_PACKAGE:
415 
416             if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
417             {
418                 AcpiOsPrintf ("Elements %.2X\n",
419                     ObjDesc->Package.Count);
420             }
421             else
422             {
423                 AcpiOsPrintf ("[Length not yet evaluated]\n");
424             }
425             break;
426 
427         case ACPI_TYPE_BUFFER:
428 
429             if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
430             {
431                 AcpiOsPrintf ("Len %.2X",
432                             ObjDesc->Buffer.Length);
433 
434                 /* Dump some of the buffer */
435 
436                 if (ObjDesc->Buffer.Length > 0)
437                 {
438                     AcpiOsPrintf (" =");
439                     for (i = 0; (i < ObjDesc->Buffer.Length && i < 12); i++)
440                     {
441                         AcpiOsPrintf (" %.2hX", ObjDesc->Buffer.Pointer[i]);
442                     }
443                 }
444                 AcpiOsPrintf ("\n");
445             }
446             else
447             {
448                 AcpiOsPrintf ("[Length not yet evaluated]\n");
449             }
450             break;
451 
452         case ACPI_TYPE_STRING:
453 
454             AcpiOsPrintf ("Len %.2X ", ObjDesc->String.Length);
455             AcpiUtPrintString (ObjDesc->String.Pointer, 32);
456             AcpiOsPrintf ("\n");
457             break;
458 
459         case ACPI_TYPE_REGION:
460 
461             AcpiOsPrintf ("[%s]",
462                 AcpiUtGetRegionName (ObjDesc->Region.SpaceId));
463             if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
464             {
465                 AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n",
466                     ACPI_FORMAT_NATIVE_UINT (ObjDesc->Region.Address),
467                     ObjDesc->Region.Length);
468             }
469             else
470             {
471                 AcpiOsPrintf (" [Address/Length not yet evaluated]\n");
472             }
473             break;
474 
475         case ACPI_TYPE_LOCAL_REFERENCE:
476 
477             AcpiOsPrintf ("[%s]\n", AcpiUtGetReferenceName (ObjDesc));
478             break;
479 
480         case ACPI_TYPE_BUFFER_FIELD:
481 
482             if (ObjDesc->BufferField.BufferObj &&
483                 ObjDesc->BufferField.BufferObj->Buffer.Node)
484             {
485                 AcpiOsPrintf ("Buf [%4.4s]",
486                     AcpiUtGetNodeName (
487                         ObjDesc->BufferField.BufferObj->Buffer.Node));
488             }
489             break;
490 
491         case ACPI_TYPE_LOCAL_REGION_FIELD:
492 
493             AcpiOsPrintf ("Rgn [%4.4s]",
494                 AcpiUtGetNodeName (
495                     ObjDesc->CommonField.RegionObj->Region.Node));
496             break;
497 
498         case ACPI_TYPE_LOCAL_BANK_FIELD:
499 
500             AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]",
501                 AcpiUtGetNodeName (
502                     ObjDesc->CommonField.RegionObj->Region.Node),
503                 AcpiUtGetNodeName (
504                     ObjDesc->BankField.BankObj->CommonField.Node));
505             break;
506 
507         case ACPI_TYPE_LOCAL_INDEX_FIELD:
508 
509             AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]",
510                 AcpiUtGetNodeName (
511                     ObjDesc->IndexField.IndexObj->CommonField.Node),
512                 AcpiUtGetNodeName (
513                     ObjDesc->IndexField.DataObj->CommonField.Node));
514             break;
515 
516         case ACPI_TYPE_LOCAL_ALIAS:
517         case ACPI_TYPE_LOCAL_METHOD_ALIAS:
518 
519             AcpiOsPrintf ("Target %4.4s (%p)\n",
520                 AcpiUtGetNodeName (ObjDesc), ObjDesc);
521             break;
522 
523         default:
524 
525             AcpiOsPrintf ("Object %p\n", ObjDesc);
526             break;
527         }
528 
529         /* Common field handling */
530 
531         switch (Type)
532         {
533         case ACPI_TYPE_BUFFER_FIELD:
534         case ACPI_TYPE_LOCAL_REGION_FIELD:
535         case ACPI_TYPE_LOCAL_BANK_FIELD:
536         case ACPI_TYPE_LOCAL_INDEX_FIELD:
537 
538             AcpiOsPrintf (" Off %.3X Len %.2X Acc %.2hd\n",
539                 (ObjDesc->CommonField.BaseByteOffset * 8)
540                     + ObjDesc->CommonField.StartFieldBitOffset,
541                 ObjDesc->CommonField.BitLength,
542                 ObjDesc->CommonField.AccessByteWidth);
543             break;
544 
545         default:
546 
547             break;
548         }
549         break;
550 
551     case ACPI_DISPLAY_OBJECTS:
552 
553         AcpiOsPrintf ("O:%p", ObjDesc);
554         if (!ObjDesc)
555         {
556             /* No attached object, we are done */
557 
558             AcpiOsPrintf ("\n");
559             return (AE_OK);
560         }
561 
562         AcpiOsPrintf ("(R%u)", ObjDesc->Common.ReferenceCount);
563 
564         switch (Type)
565         {
566         case ACPI_TYPE_METHOD:
567 
568             /* Name is a Method and its AML offset/length are set */
569 
570             AcpiOsPrintf (" M:%p-%X\n", ObjDesc->Method.AmlStart,
571                 ObjDesc->Method.AmlLength);
572             break;
573 
574         case ACPI_TYPE_INTEGER:
575 
576             AcpiOsPrintf (" I:%8.8X8.8%X\n",
577                 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
578             break;
579 
580         case ACPI_TYPE_STRING:
581 
582             AcpiOsPrintf (" S:%p-%X\n", ObjDesc->String.Pointer,
583                 ObjDesc->String.Length);
584             break;
585 
586         case ACPI_TYPE_BUFFER:
587 
588             AcpiOsPrintf (" B:%p-%X\n", ObjDesc->Buffer.Pointer,
589                 ObjDesc->Buffer.Length);
590             break;
591 
592         default:
593 
594             AcpiOsPrintf ("\n");
595             break;
596         }
597         break;
598 
599     default:
600         AcpiOsPrintf ("\n");
601         break;
602     }
603 
604     /* If debug turned off, done */
605 
606     if (!(AcpiDbgLevel & ACPI_LV_VALUES))
607     {
608         return (AE_OK);
609     }
610 
611     /* If there is an attached object, display it */
612 
613     DbgLevel     = AcpiDbgLevel;
614     AcpiDbgLevel = 0;
615     ObjDesc      = AcpiNsGetAttachedObject (ThisNode);
616     AcpiDbgLevel = DbgLevel;
617 
618     /* Dump attached objects */
619 
620     while (ObjDesc)
621     {
622         ObjType = ACPI_TYPE_INVALID;
623         AcpiOsPrintf ("Attached Object %p: ", ObjDesc);
624 
625         /* Decode the type of attached object and dump the contents */
626 
627         switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
628         {
629         case ACPI_DESC_TYPE_NAMED:
630 
631             AcpiOsPrintf ("(Ptr to Node)\n");
632             BytesToDump = sizeof (ACPI_NAMESPACE_NODE);
633             ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
634             break;
635 
636         case ACPI_DESC_TYPE_OPERAND:
637 
638             ObjType = ObjDesc->Common.Type;
639 
640             if (ObjType > ACPI_TYPE_LOCAL_MAX)
641             {
642                 AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [UNKNOWN])\n",
643                     ObjType);
644                 BytesToDump = 32;
645             }
646             else
647             {
648                 AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [%s])\n",
649                     ObjType, AcpiUtGetTypeName (ObjType));
650                 BytesToDump = sizeof (ACPI_OPERAND_OBJECT);
651             }
652 
653             ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
654             break;
655 
656         default:
657 
658             break;
659         }
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         /* Valid object, get the pointer to next level, if any */
669 
670         switch (ObjType)
671         {
672         case ACPI_TYPE_BUFFER:
673         case ACPI_TYPE_STRING:
674             /*
675              * NOTE: takes advantage of common fields between string/buffer
676              */
677             BytesToDump = ObjDesc->String.Length;
678             ObjDesc = (void *) ObjDesc->String.Pointer;
679             AcpiOsPrintf ( "(Buffer/String pointer %p length %X)\n",
680                 ObjDesc, BytesToDump);
681             ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
682             goto Cleanup;
683 
684         case ACPI_TYPE_BUFFER_FIELD:
685 
686             ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->BufferField.BufferObj;
687             break;
688 
689         case ACPI_TYPE_PACKAGE:
690 
691             ObjDesc = (void *) ObjDesc->Package.Elements;
692             break;
693 
694         case ACPI_TYPE_METHOD:
695 
696             ObjDesc = (void *) ObjDesc->Method.AmlStart;
697             break;
698 
699         case ACPI_TYPE_LOCAL_REGION_FIELD:
700 
701             ObjDesc = (void *) ObjDesc->Field.RegionObj;
702             break;
703 
704         case ACPI_TYPE_LOCAL_BANK_FIELD:
705 
706             ObjDesc = (void *) ObjDesc->BankField.RegionObj;
707             break;
708 
709         case ACPI_TYPE_LOCAL_INDEX_FIELD:
710 
711             ObjDesc = (void *) ObjDesc->IndexField.IndexObj;
712             break;
713 
714         default:
715 
716             goto Cleanup;
717         }
718 
719         ObjType = ACPI_TYPE_INVALID;   /* Terminate loop after next pass */
720     }
721 
722 Cleanup:
723     AcpiOsPrintf ("\n");
724     return (AE_OK);
725 }
726 
727 
728 /*******************************************************************************
729  *
730  * FUNCTION:    AcpiNsDumpObjects
731  *
732  * PARAMETERS:  Type                - Object type to be dumped
733  *              DisplayType         - 0 or ACPI_DISPLAY_SUMMARY
734  *              MaxDepth            - Maximum depth of dump. Use ACPI_UINT32_MAX
735  *                                    for an effectively unlimited depth.
736  *              OwnerId             - Dump only objects owned by this ID. Use
737  *                                    ACPI_UINT32_MAX to match all owners.
738  *              StartHandle         - Where in namespace to start/end search
739  *
740  * RETURN:      None
741  *
742  * DESCRIPTION: Dump typed objects within the loaded namespace. Uses
743  *              AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject.
744  *
745  ******************************************************************************/
746 
747 void
748 AcpiNsDumpObjects (
749     ACPI_OBJECT_TYPE        Type,
750     UINT8                   DisplayType,
751     UINT32                  MaxDepth,
752     ACPI_OWNER_ID           OwnerId,
753     ACPI_HANDLE             StartHandle)
754 {
755     ACPI_WALK_INFO          Info;
756     ACPI_STATUS             Status;
757 
758 
759     ACPI_FUNCTION_ENTRY ();
760 
761 
762     /*
763      * Just lock the entire namespace for the duration of the dump.
764      * We don't want any changes to the namespace during this time,
765      * especially the temporary nodes since we are going to display
766      * them also.
767      */
768     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
769     if (ACPI_FAILURE (Status))
770     {
771         AcpiOsPrintf ("Could not acquire namespace mutex\n");
772         return;
773     }
774 
775     Info.DebugLevel = ACPI_LV_TABLES;
776     Info.OwnerId = OwnerId;
777     Info.DisplayType = DisplayType;
778 
779     (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
780                 ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,
781                 AcpiNsDumpOneObject, NULL, (void *) &Info, NULL);
782 
783     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
784 }
785 
786 
787 /*******************************************************************************
788  *
789  * FUNCTION:    AcpiNsDumpOneObjectPath, AcpiNsGetMaxDepth
790  *
791  * PARAMETERS:  ObjHandle           - Node to be dumped
792  *              Level               - Nesting level of the handle
793  *              Context             - Passed into WalkNamespace
794  *              ReturnValue         - Not used
795  *
796  * RETURN:      Status
797  *
798  * DESCRIPTION: Dump the full pathname to a namespace object. AcpNsGetMaxDepth
799  *              computes the maximum nesting depth in the namespace tree, in
800  *              order to simplify formatting in AcpiNsDumpOneObjectPath.
801  *              These procedures are UserFunctions called by AcpiNsWalkNamespace.
802  *
803  ******************************************************************************/
804 
805 static ACPI_STATUS
806 AcpiNsDumpOneObjectPath (
807     ACPI_HANDLE             ObjHandle,
808     UINT32                  Level,
809     void                    *Context,
810     void                    **ReturnValue)
811 {
812     UINT32                  MaxLevel = *((UINT32 *) Context);
813     char                    *Pathname;
814     ACPI_NAMESPACE_NODE     *Node;
815     int                     PathIndent;
816 
817 
818     if (!ObjHandle)
819     {
820         return (AE_OK);
821     }
822 
823     Node = AcpiNsValidateHandle (ObjHandle);
824     if (!Node)
825     {
826         /* Ignore bad node during namespace walk */
827 
828         return (AE_OK);
829     }
830 
831     Pathname = AcpiNsGetExternalPathname (Node);
832 
833     PathIndent = 1;
834     if (Level <= MaxLevel)
835     {
836         PathIndent = MaxLevel - Level + 1;
837     }
838 
839     AcpiOsPrintf ("%2d%*s%-12s%*s",
840         Level, Level, " ", AcpiUtGetTypeName (Node->Type),
841         PathIndent, " ");
842 
843     AcpiOsPrintf ("%s\n", &Pathname[1]);
844     ACPI_FREE (Pathname);
845     return (AE_OK);
846 }
847 
848 
849 static ACPI_STATUS
850 AcpiNsGetMaxDepth (
851     ACPI_HANDLE             ObjHandle,
852     UINT32                  Level,
853     void                    *Context,
854     void                    **ReturnValue)
855 {
856     UINT32                  *MaxLevel = (UINT32 *) Context;
857 
858 
859     if (Level > *MaxLevel)
860     {
861         *MaxLevel = Level;
862     }
863     return (AE_OK);
864 }
865 
866 
867 /*******************************************************************************
868  *
869  * FUNCTION:    AcpiNsDumpObjectPaths
870  *
871  * PARAMETERS:  Type                - Object type to be dumped
872  *              DisplayType         - 0 or ACPI_DISPLAY_SUMMARY
873  *              MaxDepth            - Maximum depth of dump. Use ACPI_UINT32_MAX
874  *                                    for an effectively unlimited depth.
875  *              OwnerId             - Dump only objects owned by this ID. Use
876  *                                    ACPI_UINT32_MAX to match all owners.
877  *              StartHandle         - Where in namespace to start/end search
878  *
879  * RETURN:      None
880  *
881  * DESCRIPTION: Dump full object pathnames within the loaded namespace. Uses
882  *              AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObjectPath.
883  *
884  ******************************************************************************/
885 
886 void
887 AcpiNsDumpObjectPaths (
888     ACPI_OBJECT_TYPE        Type,
889     UINT8                   DisplayType,
890     UINT32                  MaxDepth,
891     ACPI_OWNER_ID           OwnerId,
892     ACPI_HANDLE             StartHandle)
893 {
894     ACPI_STATUS             Status;
895     UINT32                  MaxLevel = 0;
896 
897 
898     ACPI_FUNCTION_ENTRY ();
899 
900 
901     /*
902      * Just lock the entire namespace for the duration of the dump.
903      * We don't want any changes to the namespace during this time,
904      * especially the temporary nodes since we are going to display
905      * them also.
906      */
907     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
908     if (ACPI_FAILURE (Status))
909     {
910         AcpiOsPrintf ("Could not acquire namespace mutex\n");
911         return;
912     }
913 
914     /* Get the max depth of the namespace tree, for formatting later */
915 
916     (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
917                 ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,
918                 AcpiNsGetMaxDepth, NULL, (void *) &MaxLevel, NULL);
919 
920     /* Now dump the entire namespace */
921 
922     (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
923                 ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,
924                 AcpiNsDumpOneObjectPath, NULL, (void *) &MaxLevel, NULL);
925 
926     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
927 }
928 
929 
930 /*******************************************************************************
931  *
932  * FUNCTION:    AcpiNsDumpEntry
933  *
934  * PARAMETERS:  Handle              - Node to be dumped
935  *              DebugLevel          - Output level
936  *
937  * RETURN:      None
938  *
939  * DESCRIPTION: Dump a single Node
940  *
941  ******************************************************************************/
942 
943 void
944 AcpiNsDumpEntry (
945     ACPI_HANDLE             Handle,
946     UINT32                  DebugLevel)
947 {
948     ACPI_WALK_INFO          Info;
949 
950 
951     ACPI_FUNCTION_ENTRY ();
952 
953 
954     Info.DebugLevel = DebugLevel;
955     Info.OwnerId = ACPI_OWNER_ID_MAX;
956     Info.DisplayType = ACPI_DISPLAY_SUMMARY;
957 
958     (void) AcpiNsDumpOneObject (Handle, 1, &Info, NULL);
959 }
960 
961 
962 #ifdef ACPI_ASL_COMPILER
963 /*******************************************************************************
964  *
965  * FUNCTION:    AcpiNsDumpTables
966  *
967  * PARAMETERS:  SearchBase          - Root of subtree to be dumped, or
968  *                                    NS_ALL to dump the entire namespace
969  *              MaxDepth            - Maximum depth of dump. Use INT_MAX
970  *                                    for an effectively unlimited depth.
971  *
972  * RETURN:      None
973  *
974  * DESCRIPTION: Dump the name space, or a portion of it.
975  *
976  ******************************************************************************/
977 
978 void
979 AcpiNsDumpTables (
980     ACPI_HANDLE             SearchBase,
981     UINT32                  MaxDepth)
982 {
983     ACPI_HANDLE             SearchHandle = SearchBase;
984 
985 
986     ACPI_FUNCTION_TRACE (NsDumpTables);
987 
988 
989     if (!AcpiGbl_RootNode)
990     {
991         /*
992          * If the name space has not been initialized,
993          * there is nothing to dump.
994          */
995         ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "namespace not initialized!\n"));
996         return_VOID;
997     }
998 
999     if (ACPI_NS_ALL == SearchBase)
1000     {
1001         /* Entire namespace */
1002 
1003         SearchHandle = AcpiGbl_RootNode;
1004         ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n"));
1005     }
1006 
1007     AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, MaxDepth,
1008             ACPI_OWNER_ID_MAX, SearchHandle);
1009     return_VOID;
1010 }
1011 #endif
1012 #endif
1013