xref: /haiku/src/add-ons/kernel/bus_managers/acpi/acpica/components/namespace/nsdump.c (revision 945566ff43583e4f8102b4440c88f53dae775cb4)
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 - 2016, 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 #include "acpi.h"
118 #include "accommon.h"
119 #include "acnamesp.h"
120 #include "acoutput.h"
121 
122 
123 #define _COMPONENT          ACPI_NAMESPACE
124         ACPI_MODULE_NAME    ("nsdump")
125 
126 /* Local prototypes */
127 
128 #ifdef ACPI_OBSOLETE_FUNCTIONS
129 void
130 AcpiNsDumpRootDevices (
131     void);
132 
133 static ACPI_STATUS
134 AcpiNsDumpOneDevice (
135     ACPI_HANDLE             ObjHandle,
136     UINT32                  Level,
137     void                    *Context,
138     void                    **ReturnValue);
139 #endif
140 
141 
142 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
143 
144 static ACPI_STATUS
145 AcpiNsDumpOneObjectPath (
146     ACPI_HANDLE             ObjHandle,
147     UINT32                  Level,
148     void                    *Context,
149     void                    **ReturnValue);
150 
151 static ACPI_STATUS
152 AcpiNsGetMaxDepth (
153     ACPI_HANDLE             ObjHandle,
154     UINT32                  Level,
155     void                    *Context,
156     void                    **ReturnValue);
157 
158 
159 /*******************************************************************************
160  *
161  * FUNCTION:    AcpiNsPrintPathname
162  *
163  * PARAMETERS:  NumSegments         - Number of ACPI name segments
164  *              Pathname            - The compressed (internal) path
165  *
166  * RETURN:      None
167  *
168  * DESCRIPTION: Print an object's full namespace pathname
169  *
170  ******************************************************************************/
171 
172 void
173 AcpiNsPrintPathname (
174     UINT32                  NumSegments,
175     const char              *Pathname)
176 {
177     UINT32                  i;
178 
179 
180     ACPI_FUNCTION_NAME (NsPrintPathname);
181 
182 
183     /* Check if debug output enabled */
184 
185     if (!ACPI_IS_DEBUG_ENABLED (ACPI_LV_NAMES, ACPI_NAMESPACE))
186     {
187         return;
188     }
189 
190     /* Print the entire name */
191 
192     ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "["));
193 
194     while (NumSegments)
195     {
196         for (i = 0; i < 4; i++)
197         {
198             isprint ((int) Pathname[i]) ?
199                 AcpiOsPrintf ("%c", Pathname[i]) :
200                 AcpiOsPrintf ("?");
201         }
202 
203         Pathname += ACPI_NAME_SIZE;
204         NumSegments--;
205         if (NumSegments)
206         {
207             AcpiOsPrintf (".");
208         }
209     }
210 
211     AcpiOsPrintf ("]\n");
212 }
213 
214 
215 #ifdef ACPI_OBSOLETE_FUNCTIONS
216 /* Not used at this time, perhaps later */
217 
218 /*******************************************************************************
219  *
220  * FUNCTION:    AcpiNsDumpPathname
221  *
222  * PARAMETERS:  Handle              - Object
223  *              Msg                 - Prefix message
224  *              Level               - Desired debug level
225  *              Component           - Caller's component ID
226  *
227  * RETURN:      None
228  *
229  * DESCRIPTION: Print an object's full namespace pathname
230  *              Manages allocation/freeing of a pathname buffer
231  *
232  ******************************************************************************/
233 
234 void
235 AcpiNsDumpPathname (
236     ACPI_HANDLE             Handle,
237     const char              *Msg,
238     UINT32                  Level,
239     UINT32                  Component)
240 {
241 
242     ACPI_FUNCTION_TRACE (NsDumpPathname);
243 
244 
245     /* Do this only if the requested debug level and component are enabled */
246 
247     if (!ACPI_IS_DEBUG_ENABLED (Level, Component))
248     {
249         return_VOID;
250     }
251 
252     /* Convert handle to a full pathname and print it (with supplied message) */
253 
254     AcpiNsPrintNodePathname (Handle, Msg);
255     AcpiOsPrintf ("\n");
256     return_VOID;
257 }
258 #endif
259 
260 /*******************************************************************************
261  *
262  * FUNCTION:    AcpiNsDumpOneObject
263  *
264  * PARAMETERS:  ObjHandle           - Node to be dumped
265  *              Level               - Nesting level of the handle
266  *              Context             - Passed into WalkNamespace
267  *              ReturnValue         - Not used
268  *
269  * RETURN:      Status
270  *
271  * DESCRIPTION: Dump a single Node
272  *              This procedure is a UserFunction called by AcpiNsWalkNamespace.
273  *
274  ******************************************************************************/
275 
276 ACPI_STATUS
277 AcpiNsDumpOneObject (
278     ACPI_HANDLE             ObjHandle,
279     UINT32                  Level,
280     void                    *Context,
281     void                    **ReturnValue)
282 {
283     ACPI_WALK_INFO          *Info = (ACPI_WALK_INFO *) Context;
284     ACPI_NAMESPACE_NODE     *ThisNode;
285     ACPI_OPERAND_OBJECT     *ObjDesc = NULL;
286     ACPI_OBJECT_TYPE        ObjType;
287     ACPI_OBJECT_TYPE        Type;
288     UINT32                  BytesToDump;
289     UINT32                  DbgLevel;
290     UINT32                  i;
291 
292 
293     ACPI_FUNCTION_NAME (NsDumpOneObject);
294 
295 
296     /* Is output enabled? */
297 
298     if (!(AcpiDbgLevel & Info->DebugLevel))
299     {
300         return (AE_OK);
301     }
302 
303     if (!ObjHandle)
304     {
305         ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n"));
306         return (AE_OK);
307     }
308 
309     ThisNode = AcpiNsValidateHandle (ObjHandle);
310     if (!ThisNode)
311     {
312         ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Invalid object handle %p\n",
313             ObjHandle));
314         return (AE_OK);
315     }
316 
317     Type = ThisNode->Type;
318 
319     /* Check if the owner matches */
320 
321     if ((Info->OwnerId != ACPI_OWNER_ID_MAX) &&
322         (Info->OwnerId != ThisNode->OwnerId))
323     {
324         return (AE_OK);
325     }
326 
327     if (!(Info->DisplayType & ACPI_DISPLAY_SHORT))
328     {
329         /* Indent the object according to the level */
330 
331         AcpiOsPrintf ("%2d%*s", (UINT32) Level - 1, (int) Level * 2, " ");
332 
333         /* Check the node type and name */
334 
335         if (Type > ACPI_TYPE_LOCAL_MAX)
336         {
337             ACPI_WARNING ((AE_INFO,
338                 "Invalid ACPI Object Type 0x%08X", Type));
339         }
340 
341         AcpiOsPrintf ("%4.4s", AcpiUtGetNodeName (ThisNode));
342     }
343 
344     /* Now we can print out the pertinent information */
345 
346     AcpiOsPrintf (" %-12s %p %2.2X ",
347         AcpiUtGetTypeName (Type), ThisNode, ThisNode->OwnerId);
348 
349     DbgLevel = AcpiDbgLevel;
350     AcpiDbgLevel = 0;
351     ObjDesc = AcpiNsGetAttachedObject (ThisNode);
352     AcpiDbgLevel = DbgLevel;
353 
354     /* Temp nodes are those nodes created by a control method */
355 
356     if (ThisNode->Flags & ANOBJ_TEMPORARY)
357     {
358         AcpiOsPrintf ("(T) ");
359     }
360 
361     switch (Info->DisplayType & ACPI_DISPLAY_MASK)
362     {
363     case ACPI_DISPLAY_SUMMARY:
364 
365         if (!ObjDesc)
366         {
367             /* No attached object. Some types should always have an object */
368 
369             switch (Type)
370             {
371             case ACPI_TYPE_INTEGER:
372             case ACPI_TYPE_PACKAGE:
373             case ACPI_TYPE_BUFFER:
374             case ACPI_TYPE_STRING:
375             case ACPI_TYPE_METHOD:
376 
377                 AcpiOsPrintf ("<No attached object>");
378                 break;
379 
380             default:
381 
382                 break;
383             }
384 
385             AcpiOsPrintf ("\n");
386             return (AE_OK);
387         }
388 
389         switch (Type)
390         {
391         case ACPI_TYPE_PROCESSOR:
392 
393             AcpiOsPrintf ("ID %02X Len %02X Addr %8.8X%8.8X\n",
394                 ObjDesc->Processor.ProcId, ObjDesc->Processor.Length,
395                 ACPI_FORMAT_UINT64 (ObjDesc->Processor.Address));
396             break;
397 
398         case ACPI_TYPE_DEVICE:
399 
400             AcpiOsPrintf ("Notify Object: %p\n", ObjDesc);
401             break;
402 
403         case ACPI_TYPE_METHOD:
404 
405             AcpiOsPrintf ("Args %X Len %.4X Aml %p\n",
406                 (UINT32) ObjDesc->Method.ParamCount,
407                 ObjDesc->Method.AmlLength, ObjDesc->Method.AmlStart);
408             break;
409 
410         case ACPI_TYPE_INTEGER:
411 
412             AcpiOsPrintf ("= %8.8X%8.8X\n",
413                 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
414             break;
415 
416         case ACPI_TYPE_PACKAGE:
417 
418             if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
419             {
420                 AcpiOsPrintf ("Elements %.2X\n",
421                     ObjDesc->Package.Count);
422             }
423             else
424             {
425                 AcpiOsPrintf ("[Length not yet evaluated]\n");
426             }
427             break;
428 
429         case ACPI_TYPE_BUFFER:
430 
431             if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
432             {
433                 AcpiOsPrintf ("Len %.2X",
434                     ObjDesc->Buffer.Length);
435 
436                 /* Dump some of the buffer */
437 
438                 if (ObjDesc->Buffer.Length > 0)
439                 {
440                     AcpiOsPrintf (" =");
441                     for (i = 0; (i < ObjDesc->Buffer.Length && i < 12); i++)
442                     {
443                         AcpiOsPrintf (" %.2hX", ObjDesc->Buffer.Pointer[i]);
444                     }
445                 }
446                 AcpiOsPrintf ("\n");
447             }
448             else
449             {
450                 AcpiOsPrintf ("[Length not yet evaluated]\n");
451             }
452             break;
453 
454         case ACPI_TYPE_STRING:
455 
456             AcpiOsPrintf ("Len %.2X ", ObjDesc->String.Length);
457             AcpiUtPrintString (ObjDesc->String.Pointer, 80);
458             AcpiOsPrintf ("\n");
459             break;
460 
461         case ACPI_TYPE_REGION:
462 
463             AcpiOsPrintf ("[%s]",
464                 AcpiUtGetRegionName (ObjDesc->Region.SpaceId));
465             if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
466             {
467                 AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n",
468                     ACPI_FORMAT_UINT64 (ObjDesc->Region.Address),
469                     ObjDesc->Region.Length);
470             }
471             else
472             {
473                 AcpiOsPrintf (" [Address/Length not yet evaluated]\n");
474             }
475             break;
476 
477         case ACPI_TYPE_LOCAL_REFERENCE:
478 
479             AcpiOsPrintf ("[%s]\n", AcpiUtGetReferenceName (ObjDesc));
480             break;
481 
482         case ACPI_TYPE_BUFFER_FIELD:
483 
484             if (ObjDesc->BufferField.BufferObj &&
485                 ObjDesc->BufferField.BufferObj->Buffer.Node)
486             {
487                 AcpiOsPrintf ("Buf [%4.4s]",
488                     AcpiUtGetNodeName (
489                         ObjDesc->BufferField.BufferObj->Buffer.Node));
490             }
491             break;
492 
493         case ACPI_TYPE_LOCAL_REGION_FIELD:
494 
495             AcpiOsPrintf ("Rgn [%4.4s]",
496                 AcpiUtGetNodeName (
497                     ObjDesc->CommonField.RegionObj->Region.Node));
498             break;
499 
500         case ACPI_TYPE_LOCAL_BANK_FIELD:
501 
502             AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]",
503                 AcpiUtGetNodeName (
504                     ObjDesc->CommonField.RegionObj->Region.Node),
505                 AcpiUtGetNodeName (
506                     ObjDesc->BankField.BankObj->CommonField.Node));
507             break;
508 
509         case ACPI_TYPE_LOCAL_INDEX_FIELD:
510 
511             AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]",
512                 AcpiUtGetNodeName (
513                     ObjDesc->IndexField.IndexObj->CommonField.Node),
514                 AcpiUtGetNodeName (
515                     ObjDesc->IndexField.DataObj->CommonField.Node));
516             break;
517 
518         case ACPI_TYPE_LOCAL_ALIAS:
519         case ACPI_TYPE_LOCAL_METHOD_ALIAS:
520 
521             AcpiOsPrintf ("Target %4.4s (%p)\n",
522                 AcpiUtGetNodeName (ObjDesc), ObjDesc);
523             break;
524 
525         default:
526 
527             AcpiOsPrintf ("Object %p\n", ObjDesc);
528             break;
529         }
530 
531         /* Common field handling */
532 
533         switch (Type)
534         {
535         case ACPI_TYPE_BUFFER_FIELD:
536         case ACPI_TYPE_LOCAL_REGION_FIELD:
537         case ACPI_TYPE_LOCAL_BANK_FIELD:
538         case ACPI_TYPE_LOCAL_INDEX_FIELD:
539 
540             AcpiOsPrintf (" Off %.3X Len %.2X Acc %.2hd\n",
541                 (ObjDesc->CommonField.BaseByteOffset * 8)
542                     + ObjDesc->CommonField.StartFieldBitOffset,
543                 ObjDesc->CommonField.BitLength,
544                 ObjDesc->CommonField.AccessByteWidth);
545             break;
546 
547         default:
548 
549             break;
550         }
551         break;
552 
553     case ACPI_DISPLAY_OBJECTS:
554 
555         AcpiOsPrintf ("O:%p", ObjDesc);
556         if (!ObjDesc)
557         {
558             /* No attached object, we are done */
559 
560             AcpiOsPrintf ("\n");
561             return (AE_OK);
562         }
563 
564         AcpiOsPrintf ("(R%u)", ObjDesc->Common.ReferenceCount);
565 
566         switch (Type)
567         {
568         case ACPI_TYPE_METHOD:
569 
570             /* Name is a Method and its AML offset/length are set */
571 
572             AcpiOsPrintf (" M:%p-%X\n", ObjDesc->Method.AmlStart,
573                 ObjDesc->Method.AmlLength);
574             break;
575 
576         case ACPI_TYPE_INTEGER:
577 
578             AcpiOsPrintf (" I:%8.8X8.8%X\n",
579                 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
580             break;
581 
582         case ACPI_TYPE_STRING:
583 
584             AcpiOsPrintf (" S:%p-%X\n", ObjDesc->String.Pointer,
585                 ObjDesc->String.Length);
586             break;
587 
588         case ACPI_TYPE_BUFFER:
589 
590             AcpiOsPrintf (" B:%p-%X\n", ObjDesc->Buffer.Pointer,
591                 ObjDesc->Buffer.Length);
592             break;
593 
594         default:
595 
596             AcpiOsPrintf ("\n");
597             break;
598         }
599         break;
600 
601     default:
602         AcpiOsPrintf ("\n");
603         break;
604     }
605 
606     /* If debug turned off, done */
607 
608     if (!(AcpiDbgLevel & ACPI_LV_VALUES))
609     {
610         return (AE_OK);
611     }
612 
613     /* If there is an attached object, display it */
614 
615     DbgLevel = AcpiDbgLevel;
616     AcpiDbgLevel = 0;
617     ObjDesc = AcpiNsGetAttachedObject (ThisNode);
618     AcpiDbgLevel = DbgLevel;
619 
620     /* Dump attached objects */
621 
622     while (ObjDesc)
623     {
624         ObjType = ACPI_TYPE_INVALID;
625         AcpiOsPrintf ("Attached Object %p: ", ObjDesc);
626 
627         /* Decode the type of attached object and dump the contents */
628 
629         switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
630         {
631         case ACPI_DESC_TYPE_NAMED:
632 
633             AcpiOsPrintf ("(Ptr to Node)\n");
634             BytesToDump = sizeof (ACPI_NAMESPACE_NODE);
635             ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
636             break;
637 
638         case ACPI_DESC_TYPE_OPERAND:
639 
640             ObjType = ObjDesc->Common.Type;
641 
642             if (ObjType > ACPI_TYPE_LOCAL_MAX)
643             {
644                 AcpiOsPrintf (
645                     "(Pointer to ACPI Object type %.2X [UNKNOWN])\n",
646                     ObjType);
647 
648                 BytesToDump = 32;
649             }
650             else
651             {
652                 AcpiOsPrintf (
653                     "(Pointer to ACPI Object type %.2X [%s])\n",
654                     ObjType, AcpiUtGetTypeName (ObjType));
655 
656                 BytesToDump = sizeof (ACPI_OPERAND_OBJECT);
657             }
658 
659             ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
660             break;
661 
662         default:
663 
664             break;
665         }
666 
667         /* If value is NOT an internal object, we are done */
668 
669         if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
670         {
671             goto Cleanup;
672         }
673 
674         /* Valid object, get the pointer to next level, if any */
675 
676         switch (ObjType)
677         {
678         case ACPI_TYPE_BUFFER:
679         case ACPI_TYPE_STRING:
680             /*
681              * NOTE: takes advantage of common fields between string/buffer
682              */
683             BytesToDump = ObjDesc->String.Length;
684             ObjDesc = (void *) ObjDesc->String.Pointer;
685 
686             AcpiOsPrintf ("(Buffer/String pointer %p length %X)\n",
687                 ObjDesc, BytesToDump);
688             ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
689             goto Cleanup;
690 
691         case ACPI_TYPE_BUFFER_FIELD:
692 
693             ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->BufferField.BufferObj;
694             break;
695 
696         case ACPI_TYPE_PACKAGE:
697 
698             ObjDesc = (void *) ObjDesc->Package.Elements;
699             break;
700 
701         case ACPI_TYPE_METHOD:
702 
703             ObjDesc = (void *) ObjDesc->Method.AmlStart;
704             break;
705 
706         case ACPI_TYPE_LOCAL_REGION_FIELD:
707 
708             ObjDesc = (void *) ObjDesc->Field.RegionObj;
709             break;
710 
711         case ACPI_TYPE_LOCAL_BANK_FIELD:
712 
713             ObjDesc = (void *) ObjDesc->BankField.RegionObj;
714             break;
715 
716         case ACPI_TYPE_LOCAL_INDEX_FIELD:
717 
718             ObjDesc = (void *) ObjDesc->IndexField.IndexObj;
719             break;
720 
721         default:
722 
723             goto Cleanup;
724         }
725 
726         ObjType = ACPI_TYPE_INVALID;   /* Terminate loop after next pass */
727     }
728 
729 Cleanup:
730     AcpiOsPrintf ("\n");
731     return (AE_OK);
732 }
733 
734 
735 /*******************************************************************************
736  *
737  * FUNCTION:    AcpiNsDumpObjects
738  *
739  * PARAMETERS:  Type                - Object type to be dumped
740  *              DisplayType         - 0 or ACPI_DISPLAY_SUMMARY
741  *              MaxDepth            - Maximum depth of dump. Use ACPI_UINT32_MAX
742  *                                    for an effectively unlimited depth.
743  *              OwnerId             - Dump only objects owned by this ID. Use
744  *                                    ACPI_UINT32_MAX to match all owners.
745  *              StartHandle         - Where in namespace to start/end search
746  *
747  * RETURN:      None
748  *
749  * DESCRIPTION: Dump typed objects within the loaded namespace. Uses
750  *              AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject.
751  *
752  ******************************************************************************/
753 
754 void
755 AcpiNsDumpObjects (
756     ACPI_OBJECT_TYPE        Type,
757     UINT8                   DisplayType,
758     UINT32                  MaxDepth,
759     ACPI_OWNER_ID           OwnerId,
760     ACPI_HANDLE             StartHandle)
761 {
762     ACPI_WALK_INFO          Info;
763     ACPI_STATUS             Status;
764 
765 
766     ACPI_FUNCTION_ENTRY ();
767 
768 
769     /*
770      * Just lock the entire namespace for the duration of the dump.
771      * We don't want any changes to the namespace during this time,
772      * especially the temporary nodes since we are going to display
773      * them also.
774      */
775     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
776     if (ACPI_FAILURE (Status))
777     {
778         AcpiOsPrintf ("Could not acquire namespace mutex\n");
779         return;
780     }
781 
782     Info.DebugLevel = ACPI_LV_TABLES;
783     Info.OwnerId = OwnerId;
784     Info.DisplayType = DisplayType;
785 
786     (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
787         ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,
788         AcpiNsDumpOneObject, NULL, (void *) &Info, NULL);
789 
790     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
791 }
792 
793 
794 /*******************************************************************************
795  *
796  * FUNCTION:    AcpiNsDumpOneObjectPath, AcpiNsGetMaxDepth
797  *
798  * PARAMETERS:  ObjHandle           - Node to be dumped
799  *              Level               - Nesting level of the handle
800  *              Context             - Passed into WalkNamespace
801  *              ReturnValue         - Not used
802  *
803  * RETURN:      Status
804  *
805  * DESCRIPTION: Dump the full pathname to a namespace object. AcpNsGetMaxDepth
806  *              computes the maximum nesting depth in the namespace tree, in
807  *              order to simplify formatting in AcpiNsDumpOneObjectPath.
808  *              These procedures are UserFunctions called by AcpiNsWalkNamespace.
809  *
810  ******************************************************************************/
811 
812 static ACPI_STATUS
813 AcpiNsDumpOneObjectPath (
814     ACPI_HANDLE             ObjHandle,
815     UINT32                  Level,
816     void                    *Context,
817     void                    **ReturnValue)
818 {
819     UINT32                  MaxLevel = *((UINT32 *) Context);
820     char                    *Pathname;
821     ACPI_NAMESPACE_NODE     *Node;
822     int                     PathIndent;
823 
824 
825     if (!ObjHandle)
826     {
827         return (AE_OK);
828     }
829 
830     Node = AcpiNsValidateHandle (ObjHandle);
831     if (!Node)
832     {
833         /* Ignore bad node during namespace walk */
834 
835         return (AE_OK);
836     }
837 
838     Pathname = AcpiNsGetNormalizedPathname (Node, TRUE);
839 
840     PathIndent = 1;
841     if (Level <= MaxLevel)
842     {
843         PathIndent = MaxLevel - Level + 1;
844     }
845 
846     AcpiOsPrintf ("%2d%*s%-12s%*s",
847         Level, Level, " ", AcpiUtGetTypeName (Node->Type),
848         PathIndent, " ");
849 
850     AcpiOsPrintf ("%s\n", &Pathname[1]);
851     ACPI_FREE (Pathname);
852     return (AE_OK);
853 }
854 
855 
856 static ACPI_STATUS
857 AcpiNsGetMaxDepth (
858     ACPI_HANDLE             ObjHandle,
859     UINT32                  Level,
860     void                    *Context,
861     void                    **ReturnValue)
862 {
863     UINT32                  *MaxLevel = (UINT32 *) Context;
864 
865 
866     if (Level > *MaxLevel)
867     {
868         *MaxLevel = Level;
869     }
870     return (AE_OK);
871 }
872 
873 
874 /*******************************************************************************
875  *
876  * FUNCTION:    AcpiNsDumpObjectPaths
877  *
878  * PARAMETERS:  Type                - Object type to be dumped
879  *              DisplayType         - 0 or ACPI_DISPLAY_SUMMARY
880  *              MaxDepth            - Maximum depth of dump. Use ACPI_UINT32_MAX
881  *                                    for an effectively unlimited depth.
882  *              OwnerId             - Dump only objects owned by this ID. Use
883  *                                    ACPI_UINT32_MAX to match all owners.
884  *              StartHandle         - Where in namespace to start/end search
885  *
886  * RETURN:      None
887  *
888  * DESCRIPTION: Dump full object pathnames within the loaded namespace. Uses
889  *              AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObjectPath.
890  *
891  ******************************************************************************/
892 
893 void
894 AcpiNsDumpObjectPaths (
895     ACPI_OBJECT_TYPE        Type,
896     UINT8                   DisplayType,
897     UINT32                  MaxDepth,
898     ACPI_OWNER_ID           OwnerId,
899     ACPI_HANDLE             StartHandle)
900 {
901     ACPI_STATUS             Status;
902     UINT32                  MaxLevel = 0;
903 
904 
905     ACPI_FUNCTION_ENTRY ();
906 
907 
908     /*
909      * Just lock the entire namespace for the duration of the dump.
910      * We don't want any changes to the namespace during this time,
911      * especially the temporary nodes since we are going to display
912      * them also.
913      */
914     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
915     if (ACPI_FAILURE (Status))
916     {
917         AcpiOsPrintf ("Could not acquire namespace mutex\n");
918         return;
919     }
920 
921     /* Get the max depth of the namespace tree, for formatting later */
922 
923     (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
924         ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,
925         AcpiNsGetMaxDepth, NULL, (void *) &MaxLevel, NULL);
926 
927     /* Now dump the entire namespace */
928 
929     (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
930         ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,
931         AcpiNsDumpOneObjectPath, NULL, (void *) &MaxLevel, NULL);
932 
933     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
934 }
935 
936 
937 /*******************************************************************************
938  *
939  * FUNCTION:    AcpiNsDumpEntry
940  *
941  * PARAMETERS:  Handle              - Node to be dumped
942  *              DebugLevel          - Output level
943  *
944  * RETURN:      None
945  *
946  * DESCRIPTION: Dump a single Node
947  *
948  ******************************************************************************/
949 
950 void
951 AcpiNsDumpEntry (
952     ACPI_HANDLE             Handle,
953     UINT32                  DebugLevel)
954 {
955     ACPI_WALK_INFO          Info;
956 
957 
958     ACPI_FUNCTION_ENTRY ();
959 
960 
961     Info.DebugLevel = DebugLevel;
962     Info.OwnerId = ACPI_OWNER_ID_MAX;
963     Info.DisplayType = ACPI_DISPLAY_SUMMARY;
964 
965     (void) AcpiNsDumpOneObject (Handle, 1, &Info, NULL);
966 }
967 
968 
969 #ifdef ACPI_ASL_COMPILER
970 /*******************************************************************************
971  *
972  * FUNCTION:    AcpiNsDumpTables
973  *
974  * PARAMETERS:  SearchBase          - Root of subtree to be dumped, or
975  *                                    NS_ALL to dump the entire namespace
976  *              MaxDepth            - Maximum depth of dump. Use INT_MAX
977  *                                    for an effectively unlimited depth.
978  *
979  * RETURN:      None
980  *
981  * DESCRIPTION: Dump the name space, or a portion of it.
982  *
983  ******************************************************************************/
984 
985 void
986 AcpiNsDumpTables (
987     ACPI_HANDLE             SearchBase,
988     UINT32                  MaxDepth)
989 {
990     ACPI_HANDLE             SearchHandle = SearchBase;
991 
992 
993     ACPI_FUNCTION_TRACE (NsDumpTables);
994 
995 
996     if (!AcpiGbl_RootNode)
997     {
998         /*
999          * If the name space has not been initialized,
1000          * there is nothing to dump.
1001          */
1002         ACPI_DEBUG_PRINT ((ACPI_DB_TABLES,
1003             "namespace not initialized!\n"));
1004         return_VOID;
1005     }
1006 
1007     if (ACPI_NS_ALL == SearchBase)
1008     {
1009         /* Entire namespace */
1010 
1011         SearchHandle = AcpiGbl_RootNode;
1012         ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n"));
1013     }
1014 
1015     AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, MaxDepth,
1016         ACPI_OWNER_ID_MAX, SearchHandle);
1017     return_VOID;
1018 }
1019 #endif
1020 #endif
1021