xref: /minix3/minix/drivers/power/acpi/namespace/nsdump.c (revision 29492bb71c7148a089a5afafa0c99409161218df)
1433d6423SLionel Sambuc /******************************************************************************
2433d6423SLionel Sambuc  *
3433d6423SLionel Sambuc  * Module Name: nsdump - table dumping routines for debug
4433d6423SLionel Sambuc  *
5433d6423SLionel Sambuc  *****************************************************************************/
6433d6423SLionel Sambuc 
7*29492bb7SDavid van Moolenbroek /*
8*29492bb7SDavid van Moolenbroek  * Copyright (C) 2000 - 2014, Intel Corp.
9433d6423SLionel Sambuc  * All rights reserved.
10433d6423SLionel Sambuc  *
11*29492bb7SDavid van Moolenbroek  * Redistribution and use in source and binary forms, with or without
12*29492bb7SDavid van Moolenbroek  * modification, are permitted provided that the following conditions
13*29492bb7SDavid van Moolenbroek  * are met:
14*29492bb7SDavid van Moolenbroek  * 1. Redistributions of source code must retain the above copyright
15*29492bb7SDavid van Moolenbroek  *    notice, this list of conditions, and the following disclaimer,
16*29492bb7SDavid van Moolenbroek  *    without modification.
17*29492bb7SDavid van Moolenbroek  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18*29492bb7SDavid van Moolenbroek  *    substantially similar to the "NO WARRANTY" disclaimer below
19*29492bb7SDavid van Moolenbroek  *    ("Disclaimer") and any redistribution must be conditioned upon
20*29492bb7SDavid van Moolenbroek  *    including a substantially similar Disclaimer requirement for further
21*29492bb7SDavid van Moolenbroek  *    binary redistribution.
22*29492bb7SDavid van Moolenbroek  * 3. Neither the names of the above-listed copyright holders nor the names
23*29492bb7SDavid van Moolenbroek  *    of any contributors may be used to endorse or promote products derived
24*29492bb7SDavid van Moolenbroek  *    from this software without specific prior written permission.
25433d6423SLionel Sambuc  *
26*29492bb7SDavid van Moolenbroek  * Alternatively, this software may be distributed under the terms of the
27*29492bb7SDavid van Moolenbroek  * GNU General Public License ("GPL") version 2 as published by the Free
28*29492bb7SDavid van Moolenbroek  * Software Foundation.
29433d6423SLionel Sambuc  *
30*29492bb7SDavid van Moolenbroek  * NO WARRANTY
31*29492bb7SDavid van Moolenbroek  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32*29492bb7SDavid van Moolenbroek  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33*29492bb7SDavid van Moolenbroek  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34*29492bb7SDavid van Moolenbroek  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35*29492bb7SDavid van Moolenbroek  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36*29492bb7SDavid van Moolenbroek  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37*29492bb7SDavid van Moolenbroek  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38*29492bb7SDavid van Moolenbroek  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39*29492bb7SDavid van Moolenbroek  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40*29492bb7SDavid van Moolenbroek  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41*29492bb7SDavid van Moolenbroek  * POSSIBILITY OF SUCH DAMAGES.
42*29492bb7SDavid van Moolenbroek  */
43433d6423SLionel Sambuc 
44433d6423SLionel Sambuc #include "acpi.h"
45433d6423SLionel Sambuc #include "accommon.h"
46433d6423SLionel Sambuc #include "acnamesp.h"
47*29492bb7SDavid van Moolenbroek #include "acoutput.h"
48433d6423SLionel Sambuc 
49433d6423SLionel Sambuc 
50433d6423SLionel Sambuc #define _COMPONENT          ACPI_NAMESPACE
51433d6423SLionel Sambuc         ACPI_MODULE_NAME    ("nsdump")
52433d6423SLionel Sambuc 
53433d6423SLionel Sambuc /* Local prototypes */
54433d6423SLionel Sambuc 
55433d6423SLionel Sambuc #ifdef ACPI_OBSOLETE_FUNCTIONS
56433d6423SLionel Sambuc void
57433d6423SLionel Sambuc AcpiNsDumpRootDevices (
58433d6423SLionel Sambuc     void);
59433d6423SLionel Sambuc 
60433d6423SLionel Sambuc static ACPI_STATUS
61433d6423SLionel Sambuc AcpiNsDumpOneDevice (
62433d6423SLionel Sambuc     ACPI_HANDLE             ObjHandle,
63433d6423SLionel Sambuc     UINT32                  Level,
64433d6423SLionel Sambuc     void                    *Context,
65433d6423SLionel Sambuc     void                    **ReturnValue);
66433d6423SLionel Sambuc #endif
67433d6423SLionel Sambuc 
68433d6423SLionel Sambuc 
69433d6423SLionel Sambuc #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
70*29492bb7SDavid van Moolenbroek 
71*29492bb7SDavid van Moolenbroek static ACPI_STATUS
72*29492bb7SDavid van Moolenbroek AcpiNsDumpOneObjectPath (
73*29492bb7SDavid van Moolenbroek     ACPI_HANDLE             ObjHandle,
74*29492bb7SDavid van Moolenbroek     UINT32                  Level,
75*29492bb7SDavid van Moolenbroek     void                    *Context,
76*29492bb7SDavid van Moolenbroek     void                    **ReturnValue);
77*29492bb7SDavid van Moolenbroek 
78*29492bb7SDavid van Moolenbroek static ACPI_STATUS
79*29492bb7SDavid van Moolenbroek AcpiNsGetMaxDepth (
80*29492bb7SDavid van Moolenbroek     ACPI_HANDLE             ObjHandle,
81*29492bb7SDavid van Moolenbroek     UINT32                  Level,
82*29492bb7SDavid van Moolenbroek     void                    *Context,
83*29492bb7SDavid van Moolenbroek     void                    **ReturnValue);
84*29492bb7SDavid van Moolenbroek 
85*29492bb7SDavid van Moolenbroek 
86433d6423SLionel Sambuc /*******************************************************************************
87433d6423SLionel Sambuc  *
88433d6423SLionel Sambuc  * FUNCTION:    AcpiNsPrintPathname
89433d6423SLionel Sambuc  *
90433d6423SLionel Sambuc  * PARAMETERS:  NumSegments         - Number of ACPI name segments
91433d6423SLionel Sambuc  *              Pathname            - The compressed (internal) path
92433d6423SLionel Sambuc  *
93433d6423SLionel Sambuc  * RETURN:      None
94433d6423SLionel Sambuc  *
95433d6423SLionel Sambuc  * DESCRIPTION: Print an object's full namespace pathname
96433d6423SLionel Sambuc  *
97433d6423SLionel Sambuc  ******************************************************************************/
98433d6423SLionel Sambuc 
99433d6423SLionel Sambuc void
AcpiNsPrintPathname(UINT32 NumSegments,char * Pathname)100433d6423SLionel Sambuc AcpiNsPrintPathname (
101433d6423SLionel Sambuc     UINT32                  NumSegments,
102433d6423SLionel Sambuc     char                    *Pathname)
103433d6423SLionel Sambuc {
104433d6423SLionel Sambuc     UINT32                  i;
105433d6423SLionel Sambuc 
106433d6423SLionel Sambuc 
107433d6423SLionel Sambuc     ACPI_FUNCTION_NAME (NsPrintPathname);
108433d6423SLionel Sambuc 
109433d6423SLionel Sambuc 
110*29492bb7SDavid van Moolenbroek     /* Check if debug output enabled */
111*29492bb7SDavid van Moolenbroek 
112*29492bb7SDavid van Moolenbroek     if (!ACPI_IS_DEBUG_ENABLED (ACPI_LV_NAMES, ACPI_NAMESPACE))
113433d6423SLionel Sambuc     {
114433d6423SLionel Sambuc         return;
115433d6423SLionel Sambuc     }
116433d6423SLionel Sambuc 
117433d6423SLionel Sambuc     /* Print the entire name */
118433d6423SLionel Sambuc 
119433d6423SLionel Sambuc     ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "["));
120433d6423SLionel Sambuc 
121433d6423SLionel Sambuc     while (NumSegments)
122433d6423SLionel Sambuc     {
123433d6423SLionel Sambuc         for (i = 0; i < 4; i++)
124433d6423SLionel Sambuc         {
125433d6423SLionel Sambuc             ACPI_IS_PRINT (Pathname[i]) ?
126433d6423SLionel Sambuc                 AcpiOsPrintf ("%c", Pathname[i]) :
127433d6423SLionel Sambuc                 AcpiOsPrintf ("?");
128433d6423SLionel Sambuc         }
129433d6423SLionel Sambuc 
130433d6423SLionel Sambuc         Pathname += ACPI_NAME_SIZE;
131433d6423SLionel Sambuc         NumSegments--;
132433d6423SLionel Sambuc         if (NumSegments)
133433d6423SLionel Sambuc         {
134433d6423SLionel Sambuc             AcpiOsPrintf (".");
135433d6423SLionel Sambuc         }
136433d6423SLionel Sambuc     }
137433d6423SLionel Sambuc 
138433d6423SLionel Sambuc     AcpiOsPrintf ("]\n");
139433d6423SLionel Sambuc }
140433d6423SLionel Sambuc 
141433d6423SLionel Sambuc 
142433d6423SLionel Sambuc /*******************************************************************************
143433d6423SLionel Sambuc  *
144433d6423SLionel Sambuc  * FUNCTION:    AcpiNsDumpPathname
145433d6423SLionel Sambuc  *
146433d6423SLionel Sambuc  * PARAMETERS:  Handle              - Object
147433d6423SLionel Sambuc  *              Msg                 - Prefix message
148433d6423SLionel Sambuc  *              Level               - Desired debug level
149433d6423SLionel Sambuc  *              Component           - Caller's component ID
150433d6423SLionel Sambuc  *
151433d6423SLionel Sambuc  * RETURN:      None
152433d6423SLionel Sambuc  *
153433d6423SLionel Sambuc  * DESCRIPTION: Print an object's full namespace pathname
154433d6423SLionel Sambuc  *              Manages allocation/freeing of a pathname buffer
155433d6423SLionel Sambuc  *
156433d6423SLionel Sambuc  ******************************************************************************/
157433d6423SLionel Sambuc 
158433d6423SLionel Sambuc void
AcpiNsDumpPathname(ACPI_HANDLE Handle,char * Msg,UINT32 Level,UINT32 Component)159433d6423SLionel Sambuc AcpiNsDumpPathname (
160433d6423SLionel Sambuc     ACPI_HANDLE             Handle,
161433d6423SLionel Sambuc     char                    *Msg,
162433d6423SLionel Sambuc     UINT32                  Level,
163433d6423SLionel Sambuc     UINT32                  Component)
164433d6423SLionel Sambuc {
165433d6423SLionel Sambuc 
166433d6423SLionel Sambuc     ACPI_FUNCTION_TRACE (NsDumpPathname);
167433d6423SLionel Sambuc 
168433d6423SLionel Sambuc 
169433d6423SLionel Sambuc     /* Do this only if the requested debug level and component are enabled */
170433d6423SLionel Sambuc 
171*29492bb7SDavid van Moolenbroek     if (!ACPI_IS_DEBUG_ENABLED (Level, Component))
172433d6423SLionel Sambuc     {
173433d6423SLionel Sambuc         return_VOID;
174433d6423SLionel Sambuc     }
175433d6423SLionel Sambuc 
176433d6423SLionel Sambuc     /* Convert handle to a full pathname and print it (with supplied message) */
177433d6423SLionel Sambuc 
178433d6423SLionel Sambuc     AcpiNsPrintNodePathname (Handle, Msg);
179433d6423SLionel Sambuc     AcpiOsPrintf ("\n");
180433d6423SLionel Sambuc     return_VOID;
181433d6423SLionel Sambuc }
182433d6423SLionel Sambuc 
183433d6423SLionel Sambuc 
184433d6423SLionel Sambuc /*******************************************************************************
185433d6423SLionel Sambuc  *
186433d6423SLionel Sambuc  * FUNCTION:    AcpiNsDumpOneObject
187433d6423SLionel Sambuc  *
188433d6423SLionel Sambuc  * PARAMETERS:  ObjHandle           - Node to be dumped
189433d6423SLionel Sambuc  *              Level               - Nesting level of the handle
190433d6423SLionel Sambuc  *              Context             - Passed into WalkNamespace
191433d6423SLionel Sambuc  *              ReturnValue         - Not used
192433d6423SLionel Sambuc  *
193433d6423SLionel Sambuc  * RETURN:      Status
194433d6423SLionel Sambuc  *
195433d6423SLionel Sambuc  * DESCRIPTION: Dump a single Node
196433d6423SLionel Sambuc  *              This procedure is a UserFunction called by AcpiNsWalkNamespace.
197433d6423SLionel Sambuc  *
198433d6423SLionel Sambuc  ******************************************************************************/
199433d6423SLionel Sambuc 
200433d6423SLionel Sambuc ACPI_STATUS
AcpiNsDumpOneObject(ACPI_HANDLE ObjHandle,UINT32 Level,void * Context,void ** ReturnValue)201433d6423SLionel Sambuc AcpiNsDumpOneObject (
202433d6423SLionel Sambuc     ACPI_HANDLE             ObjHandle,
203433d6423SLionel Sambuc     UINT32                  Level,
204433d6423SLionel Sambuc     void                    *Context,
205433d6423SLionel Sambuc     void                    **ReturnValue)
206433d6423SLionel Sambuc {
207433d6423SLionel Sambuc     ACPI_WALK_INFO          *Info = (ACPI_WALK_INFO *) Context;
208433d6423SLionel Sambuc     ACPI_NAMESPACE_NODE     *ThisNode;
209433d6423SLionel Sambuc     ACPI_OPERAND_OBJECT     *ObjDesc = NULL;
210433d6423SLionel Sambuc     ACPI_OBJECT_TYPE        ObjType;
211433d6423SLionel Sambuc     ACPI_OBJECT_TYPE        Type;
212433d6423SLionel Sambuc     UINT32                  BytesToDump;
213433d6423SLionel Sambuc     UINT32                  DbgLevel;
214433d6423SLionel Sambuc     UINT32                  i;
215433d6423SLionel Sambuc 
216433d6423SLionel Sambuc 
217433d6423SLionel Sambuc     ACPI_FUNCTION_NAME (NsDumpOneObject);
218433d6423SLionel Sambuc 
219433d6423SLionel Sambuc 
220433d6423SLionel Sambuc     /* Is output enabled? */
221433d6423SLionel Sambuc 
222433d6423SLionel Sambuc     if (!(AcpiDbgLevel & Info->DebugLevel))
223433d6423SLionel Sambuc     {
224433d6423SLionel Sambuc         return (AE_OK);
225433d6423SLionel Sambuc     }
226433d6423SLionel Sambuc 
227433d6423SLionel Sambuc     if (!ObjHandle)
228433d6423SLionel Sambuc     {
229433d6423SLionel Sambuc         ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n"));
230433d6423SLionel Sambuc         return (AE_OK);
231433d6423SLionel Sambuc     }
232433d6423SLionel Sambuc 
233433d6423SLionel Sambuc     ThisNode = AcpiNsValidateHandle (ObjHandle);
234433d6423SLionel Sambuc     if (!ThisNode)
235433d6423SLionel Sambuc     {
236433d6423SLionel Sambuc         ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Invalid object handle %p\n",
237433d6423SLionel Sambuc             ObjHandle));
238433d6423SLionel Sambuc         return (AE_OK);
239433d6423SLionel Sambuc     }
240433d6423SLionel Sambuc 
241433d6423SLionel Sambuc     Type = ThisNode->Type;
242433d6423SLionel Sambuc 
243433d6423SLionel Sambuc     /* Check if the owner matches */
244433d6423SLionel Sambuc 
245433d6423SLionel Sambuc     if ((Info->OwnerId != ACPI_OWNER_ID_MAX) &&
246433d6423SLionel Sambuc         (Info->OwnerId != ThisNode->OwnerId))
247433d6423SLionel Sambuc     {
248433d6423SLionel Sambuc         return (AE_OK);
249433d6423SLionel Sambuc     }
250433d6423SLionel Sambuc 
251433d6423SLionel Sambuc     if (!(Info->DisplayType & ACPI_DISPLAY_SHORT))
252433d6423SLionel Sambuc     {
253433d6423SLionel Sambuc         /* Indent the object according to the level */
254433d6423SLionel Sambuc 
255433d6423SLionel Sambuc         AcpiOsPrintf ("%2d%*s", (UINT32) Level - 1, (int) Level * 2, " ");
256433d6423SLionel Sambuc 
257433d6423SLionel Sambuc         /* Check the node type and name */
258433d6423SLionel Sambuc 
259433d6423SLionel Sambuc         if (Type > ACPI_TYPE_LOCAL_MAX)
260433d6423SLionel Sambuc         {
261433d6423SLionel Sambuc             ACPI_WARNING ((AE_INFO, "Invalid ACPI Object Type 0x%08X", Type));
262433d6423SLionel Sambuc         }
263433d6423SLionel Sambuc 
264433d6423SLionel Sambuc         AcpiOsPrintf ("%4.4s", AcpiUtGetNodeName (ThisNode));
265433d6423SLionel Sambuc     }
266433d6423SLionel Sambuc 
267433d6423SLionel Sambuc     /* Now we can print out the pertinent information */
268433d6423SLionel Sambuc 
269433d6423SLionel Sambuc     AcpiOsPrintf (" %-12s %p %2.2X ",
270433d6423SLionel Sambuc             AcpiUtGetTypeName (Type), ThisNode, ThisNode->OwnerId);
271433d6423SLionel Sambuc 
272433d6423SLionel Sambuc     DbgLevel = AcpiDbgLevel;
273433d6423SLionel Sambuc     AcpiDbgLevel = 0;
274433d6423SLionel Sambuc     ObjDesc = AcpiNsGetAttachedObject (ThisNode);
275433d6423SLionel Sambuc     AcpiDbgLevel = DbgLevel;
276433d6423SLionel Sambuc 
277433d6423SLionel Sambuc     /* Temp nodes are those nodes created by a control method */
278433d6423SLionel Sambuc 
279433d6423SLionel Sambuc     if (ThisNode->Flags & ANOBJ_TEMPORARY)
280433d6423SLionel Sambuc     {
281433d6423SLionel Sambuc         AcpiOsPrintf ("(T) ");
282433d6423SLionel Sambuc     }
283433d6423SLionel Sambuc 
284433d6423SLionel Sambuc     switch (Info->DisplayType & ACPI_DISPLAY_MASK)
285433d6423SLionel Sambuc     {
286433d6423SLionel Sambuc     case ACPI_DISPLAY_SUMMARY:
287433d6423SLionel Sambuc 
288433d6423SLionel Sambuc         if (!ObjDesc)
289433d6423SLionel Sambuc         {
290*29492bb7SDavid van Moolenbroek             /* No attached object. Some types should always have an object */
291*29492bb7SDavid van Moolenbroek 
292*29492bb7SDavid van Moolenbroek             switch (Type)
293*29492bb7SDavid van Moolenbroek             {
294*29492bb7SDavid van Moolenbroek             case ACPI_TYPE_INTEGER:
295*29492bb7SDavid van Moolenbroek             case ACPI_TYPE_PACKAGE:
296*29492bb7SDavid van Moolenbroek             case ACPI_TYPE_BUFFER:
297*29492bb7SDavid van Moolenbroek             case ACPI_TYPE_STRING:
298*29492bb7SDavid van Moolenbroek             case ACPI_TYPE_METHOD:
299*29492bb7SDavid van Moolenbroek 
300*29492bb7SDavid van Moolenbroek                 AcpiOsPrintf ("<No attached object>");
301*29492bb7SDavid van Moolenbroek                 break;
302*29492bb7SDavid van Moolenbroek 
303*29492bb7SDavid van Moolenbroek             default:
304*29492bb7SDavid van Moolenbroek 
305*29492bb7SDavid van Moolenbroek                 break;
306*29492bb7SDavid van Moolenbroek             }
307433d6423SLionel Sambuc 
308433d6423SLionel Sambuc             AcpiOsPrintf ("\n");
309433d6423SLionel Sambuc             return (AE_OK);
310433d6423SLionel Sambuc         }
311433d6423SLionel Sambuc 
312433d6423SLionel Sambuc         switch (Type)
313433d6423SLionel Sambuc         {
314433d6423SLionel Sambuc         case ACPI_TYPE_PROCESSOR:
315433d6423SLionel Sambuc 
316*29492bb7SDavid van Moolenbroek             AcpiOsPrintf ("ID %02X Len %02X Addr %p\n",
317433d6423SLionel Sambuc                 ObjDesc->Processor.ProcId, ObjDesc->Processor.Length,
318433d6423SLionel Sambuc                 ACPI_CAST_PTR (void, ObjDesc->Processor.Address));
319433d6423SLionel Sambuc             break;
320433d6423SLionel Sambuc 
321433d6423SLionel Sambuc         case ACPI_TYPE_DEVICE:
322433d6423SLionel Sambuc 
323433d6423SLionel Sambuc             AcpiOsPrintf ("Notify Object: %p\n", ObjDesc);
324433d6423SLionel Sambuc             break;
325433d6423SLionel Sambuc 
326433d6423SLionel Sambuc         case ACPI_TYPE_METHOD:
327433d6423SLionel Sambuc 
328433d6423SLionel Sambuc             AcpiOsPrintf ("Args %X Len %.4X Aml %p\n",
329433d6423SLionel Sambuc                 (UINT32) ObjDesc->Method.ParamCount,
330433d6423SLionel Sambuc                 ObjDesc->Method.AmlLength, ObjDesc->Method.AmlStart);
331433d6423SLionel Sambuc             break;
332433d6423SLionel Sambuc 
333433d6423SLionel Sambuc         case ACPI_TYPE_INTEGER:
334433d6423SLionel Sambuc 
335433d6423SLionel Sambuc             AcpiOsPrintf ("= %8.8X%8.8X\n",
336433d6423SLionel Sambuc                 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
337433d6423SLionel Sambuc             break;
338433d6423SLionel Sambuc 
339433d6423SLionel Sambuc         case ACPI_TYPE_PACKAGE:
340433d6423SLionel Sambuc 
341433d6423SLionel Sambuc             if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
342433d6423SLionel Sambuc             {
343433d6423SLionel Sambuc                 AcpiOsPrintf ("Elements %.2X\n",
344433d6423SLionel Sambuc                     ObjDesc->Package.Count);
345433d6423SLionel Sambuc             }
346433d6423SLionel Sambuc             else
347433d6423SLionel Sambuc             {
348433d6423SLionel Sambuc                 AcpiOsPrintf ("[Length not yet evaluated]\n");
349433d6423SLionel Sambuc             }
350433d6423SLionel Sambuc             break;
351433d6423SLionel Sambuc 
352433d6423SLionel Sambuc         case ACPI_TYPE_BUFFER:
353433d6423SLionel Sambuc 
354433d6423SLionel Sambuc             if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
355433d6423SLionel Sambuc             {
356433d6423SLionel Sambuc                 AcpiOsPrintf ("Len %.2X",
357433d6423SLionel Sambuc                             ObjDesc->Buffer.Length);
358433d6423SLionel Sambuc 
359433d6423SLionel Sambuc                 /* Dump some of the buffer */
360433d6423SLionel Sambuc 
361433d6423SLionel Sambuc                 if (ObjDesc->Buffer.Length > 0)
362433d6423SLionel Sambuc                 {
363433d6423SLionel Sambuc                     AcpiOsPrintf (" =");
364433d6423SLionel Sambuc                     for (i = 0; (i < ObjDesc->Buffer.Length && i < 12); i++)
365433d6423SLionel Sambuc                     {
366433d6423SLionel Sambuc                         AcpiOsPrintf (" %.2hX", ObjDesc->Buffer.Pointer[i]);
367433d6423SLionel Sambuc                     }
368433d6423SLionel Sambuc                 }
369433d6423SLionel Sambuc                 AcpiOsPrintf ("\n");
370433d6423SLionel Sambuc             }
371433d6423SLionel Sambuc             else
372433d6423SLionel Sambuc             {
373433d6423SLionel Sambuc                 AcpiOsPrintf ("[Length not yet evaluated]\n");
374433d6423SLionel Sambuc             }
375433d6423SLionel Sambuc             break;
376433d6423SLionel Sambuc 
377433d6423SLionel Sambuc         case ACPI_TYPE_STRING:
378433d6423SLionel Sambuc 
379433d6423SLionel Sambuc             AcpiOsPrintf ("Len %.2X ", ObjDesc->String.Length);
380433d6423SLionel Sambuc             AcpiUtPrintString (ObjDesc->String.Pointer, 32);
381433d6423SLionel Sambuc             AcpiOsPrintf ("\n");
382433d6423SLionel Sambuc             break;
383433d6423SLionel Sambuc 
384433d6423SLionel Sambuc         case ACPI_TYPE_REGION:
385433d6423SLionel Sambuc 
386433d6423SLionel Sambuc             AcpiOsPrintf ("[%s]",
387433d6423SLionel Sambuc                 AcpiUtGetRegionName (ObjDesc->Region.SpaceId));
388433d6423SLionel Sambuc             if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
389433d6423SLionel Sambuc             {
390433d6423SLionel Sambuc                 AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n",
391433d6423SLionel Sambuc                     ACPI_FORMAT_NATIVE_UINT (ObjDesc->Region.Address),
392433d6423SLionel Sambuc                     ObjDesc->Region.Length);
393433d6423SLionel Sambuc             }
394433d6423SLionel Sambuc             else
395433d6423SLionel Sambuc             {
396433d6423SLionel Sambuc                 AcpiOsPrintf (" [Address/Length not yet evaluated]\n");
397433d6423SLionel Sambuc             }
398433d6423SLionel Sambuc             break;
399433d6423SLionel Sambuc 
400433d6423SLionel Sambuc         case ACPI_TYPE_LOCAL_REFERENCE:
401433d6423SLionel Sambuc 
402433d6423SLionel Sambuc             AcpiOsPrintf ("[%s]\n", AcpiUtGetReferenceName (ObjDesc));
403433d6423SLionel Sambuc             break;
404433d6423SLionel Sambuc 
405433d6423SLionel Sambuc         case ACPI_TYPE_BUFFER_FIELD:
406433d6423SLionel Sambuc 
407433d6423SLionel Sambuc             if (ObjDesc->BufferField.BufferObj &&
408433d6423SLionel Sambuc                 ObjDesc->BufferField.BufferObj->Buffer.Node)
409433d6423SLionel Sambuc             {
410433d6423SLionel Sambuc                 AcpiOsPrintf ("Buf [%4.4s]",
411433d6423SLionel Sambuc                     AcpiUtGetNodeName (
412433d6423SLionel Sambuc                         ObjDesc->BufferField.BufferObj->Buffer.Node));
413433d6423SLionel Sambuc             }
414433d6423SLionel Sambuc             break;
415433d6423SLionel Sambuc 
416433d6423SLionel Sambuc         case ACPI_TYPE_LOCAL_REGION_FIELD:
417433d6423SLionel Sambuc 
418433d6423SLionel Sambuc             AcpiOsPrintf ("Rgn [%4.4s]",
419433d6423SLionel Sambuc                 AcpiUtGetNodeName (
420433d6423SLionel Sambuc                     ObjDesc->CommonField.RegionObj->Region.Node));
421433d6423SLionel Sambuc             break;
422433d6423SLionel Sambuc 
423433d6423SLionel Sambuc         case ACPI_TYPE_LOCAL_BANK_FIELD:
424433d6423SLionel Sambuc 
425433d6423SLionel Sambuc             AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]",
426433d6423SLionel Sambuc                 AcpiUtGetNodeName (
427433d6423SLionel Sambuc                     ObjDesc->CommonField.RegionObj->Region.Node),
428433d6423SLionel Sambuc                 AcpiUtGetNodeName (
429433d6423SLionel Sambuc                     ObjDesc->BankField.BankObj->CommonField.Node));
430433d6423SLionel Sambuc             break;
431433d6423SLionel Sambuc 
432433d6423SLionel Sambuc         case ACPI_TYPE_LOCAL_INDEX_FIELD:
433433d6423SLionel Sambuc 
434433d6423SLionel Sambuc             AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]",
435433d6423SLionel Sambuc                 AcpiUtGetNodeName (
436433d6423SLionel Sambuc                     ObjDesc->IndexField.IndexObj->CommonField.Node),
437433d6423SLionel Sambuc                 AcpiUtGetNodeName (
438433d6423SLionel Sambuc                     ObjDesc->IndexField.DataObj->CommonField.Node));
439433d6423SLionel Sambuc             break;
440433d6423SLionel Sambuc 
441433d6423SLionel Sambuc         case ACPI_TYPE_LOCAL_ALIAS:
442433d6423SLionel Sambuc         case ACPI_TYPE_LOCAL_METHOD_ALIAS:
443433d6423SLionel Sambuc 
444433d6423SLionel Sambuc             AcpiOsPrintf ("Target %4.4s (%p)\n",
445433d6423SLionel Sambuc                 AcpiUtGetNodeName (ObjDesc), ObjDesc);
446433d6423SLionel Sambuc             break;
447433d6423SLionel Sambuc 
448433d6423SLionel Sambuc         default:
449433d6423SLionel Sambuc 
450433d6423SLionel Sambuc             AcpiOsPrintf ("Object %p\n", ObjDesc);
451433d6423SLionel Sambuc             break;
452433d6423SLionel Sambuc         }
453433d6423SLionel Sambuc 
454433d6423SLionel Sambuc         /* Common field handling */
455433d6423SLionel Sambuc 
456433d6423SLionel Sambuc         switch (Type)
457433d6423SLionel Sambuc         {
458433d6423SLionel Sambuc         case ACPI_TYPE_BUFFER_FIELD:
459433d6423SLionel Sambuc         case ACPI_TYPE_LOCAL_REGION_FIELD:
460433d6423SLionel Sambuc         case ACPI_TYPE_LOCAL_BANK_FIELD:
461433d6423SLionel Sambuc         case ACPI_TYPE_LOCAL_INDEX_FIELD:
462433d6423SLionel Sambuc 
463433d6423SLionel Sambuc             AcpiOsPrintf (" Off %.3X Len %.2X Acc %.2hd\n",
464433d6423SLionel Sambuc                 (ObjDesc->CommonField.BaseByteOffset * 8)
465433d6423SLionel Sambuc                     + ObjDesc->CommonField.StartFieldBitOffset,
466433d6423SLionel Sambuc                 ObjDesc->CommonField.BitLength,
467433d6423SLionel Sambuc                 ObjDesc->CommonField.AccessByteWidth);
468433d6423SLionel Sambuc             break;
469433d6423SLionel Sambuc 
470433d6423SLionel Sambuc         default:
471*29492bb7SDavid van Moolenbroek 
472433d6423SLionel Sambuc             break;
473433d6423SLionel Sambuc         }
474433d6423SLionel Sambuc         break;
475433d6423SLionel Sambuc 
476433d6423SLionel Sambuc     case ACPI_DISPLAY_OBJECTS:
477433d6423SLionel Sambuc 
478433d6423SLionel Sambuc         AcpiOsPrintf ("O:%p", ObjDesc);
479433d6423SLionel Sambuc         if (!ObjDesc)
480433d6423SLionel Sambuc         {
481433d6423SLionel Sambuc             /* No attached object, we are done */
482433d6423SLionel Sambuc 
483433d6423SLionel Sambuc             AcpiOsPrintf ("\n");
484433d6423SLionel Sambuc             return (AE_OK);
485433d6423SLionel Sambuc         }
486433d6423SLionel Sambuc 
487433d6423SLionel Sambuc         AcpiOsPrintf ("(R%u)", ObjDesc->Common.ReferenceCount);
488433d6423SLionel Sambuc 
489433d6423SLionel Sambuc         switch (Type)
490433d6423SLionel Sambuc         {
491433d6423SLionel Sambuc         case ACPI_TYPE_METHOD:
492433d6423SLionel Sambuc 
493433d6423SLionel Sambuc             /* Name is a Method and its AML offset/length are set */
494433d6423SLionel Sambuc 
495433d6423SLionel Sambuc             AcpiOsPrintf (" M:%p-%X\n", ObjDesc->Method.AmlStart,
496433d6423SLionel Sambuc                 ObjDesc->Method.AmlLength);
497433d6423SLionel Sambuc             break;
498433d6423SLionel Sambuc 
499433d6423SLionel Sambuc         case ACPI_TYPE_INTEGER:
500433d6423SLionel Sambuc 
501433d6423SLionel Sambuc             AcpiOsPrintf (" I:%8.8X8.8%X\n",
502433d6423SLionel Sambuc                 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
503433d6423SLionel Sambuc             break;
504433d6423SLionel Sambuc 
505433d6423SLionel Sambuc         case ACPI_TYPE_STRING:
506433d6423SLionel Sambuc 
507433d6423SLionel Sambuc             AcpiOsPrintf (" S:%p-%X\n", ObjDesc->String.Pointer,
508433d6423SLionel Sambuc                 ObjDesc->String.Length);
509433d6423SLionel Sambuc             break;
510433d6423SLionel Sambuc 
511433d6423SLionel Sambuc         case ACPI_TYPE_BUFFER:
512433d6423SLionel Sambuc 
513433d6423SLionel Sambuc             AcpiOsPrintf (" B:%p-%X\n", ObjDesc->Buffer.Pointer,
514433d6423SLionel Sambuc                 ObjDesc->Buffer.Length);
515433d6423SLionel Sambuc             break;
516433d6423SLionel Sambuc 
517433d6423SLionel Sambuc         default:
518433d6423SLionel Sambuc 
519433d6423SLionel Sambuc             AcpiOsPrintf ("\n");
520433d6423SLionel Sambuc             break;
521433d6423SLionel Sambuc         }
522433d6423SLionel Sambuc         break;
523433d6423SLionel Sambuc 
524433d6423SLionel Sambuc     default:
525433d6423SLionel Sambuc         AcpiOsPrintf ("\n");
526433d6423SLionel Sambuc         break;
527433d6423SLionel Sambuc     }
528433d6423SLionel Sambuc 
529433d6423SLionel Sambuc     /* If debug turned off, done */
530433d6423SLionel Sambuc 
531433d6423SLionel Sambuc     if (!(AcpiDbgLevel & ACPI_LV_VALUES))
532433d6423SLionel Sambuc     {
533433d6423SLionel Sambuc         return (AE_OK);
534433d6423SLionel Sambuc     }
535433d6423SLionel Sambuc 
536433d6423SLionel Sambuc     /* If there is an attached object, display it */
537433d6423SLionel Sambuc 
538433d6423SLionel Sambuc     DbgLevel     = AcpiDbgLevel;
539433d6423SLionel Sambuc     AcpiDbgLevel = 0;
540433d6423SLionel Sambuc     ObjDesc      = AcpiNsGetAttachedObject (ThisNode);
541433d6423SLionel Sambuc     AcpiDbgLevel = DbgLevel;
542433d6423SLionel Sambuc 
543433d6423SLionel Sambuc     /* Dump attached objects */
544433d6423SLionel Sambuc 
545433d6423SLionel Sambuc     while (ObjDesc)
546433d6423SLionel Sambuc     {
547433d6423SLionel Sambuc         ObjType = ACPI_TYPE_INVALID;
548433d6423SLionel Sambuc         AcpiOsPrintf ("Attached Object %p: ", ObjDesc);
549433d6423SLionel Sambuc 
550433d6423SLionel Sambuc         /* Decode the type of attached object and dump the contents */
551433d6423SLionel Sambuc 
552433d6423SLionel Sambuc         switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
553433d6423SLionel Sambuc         {
554433d6423SLionel Sambuc         case ACPI_DESC_TYPE_NAMED:
555433d6423SLionel Sambuc 
556433d6423SLionel Sambuc             AcpiOsPrintf ("(Ptr to Node)\n");
557433d6423SLionel Sambuc             BytesToDump = sizeof (ACPI_NAMESPACE_NODE);
558433d6423SLionel Sambuc             ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
559433d6423SLionel Sambuc             break;
560433d6423SLionel Sambuc 
561433d6423SLionel Sambuc         case ACPI_DESC_TYPE_OPERAND:
562433d6423SLionel Sambuc 
563433d6423SLionel Sambuc             ObjType = ObjDesc->Common.Type;
564433d6423SLionel Sambuc 
565433d6423SLionel Sambuc             if (ObjType > ACPI_TYPE_LOCAL_MAX)
566433d6423SLionel Sambuc             {
567433d6423SLionel Sambuc                 AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [UNKNOWN])\n",
568433d6423SLionel Sambuc                     ObjType);
569433d6423SLionel Sambuc                 BytesToDump = 32;
570433d6423SLionel Sambuc             }
571433d6423SLionel Sambuc             else
572433d6423SLionel Sambuc             {
573433d6423SLionel Sambuc                 AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [%s])\n",
574433d6423SLionel Sambuc                     ObjType, AcpiUtGetTypeName (ObjType));
575433d6423SLionel Sambuc                 BytesToDump = sizeof (ACPI_OPERAND_OBJECT);
576433d6423SLionel Sambuc             }
577433d6423SLionel Sambuc 
578433d6423SLionel Sambuc             ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
579433d6423SLionel Sambuc             break;
580433d6423SLionel Sambuc 
581433d6423SLionel Sambuc         default:
582433d6423SLionel Sambuc 
583433d6423SLionel Sambuc             break;
584433d6423SLionel Sambuc         }
585433d6423SLionel Sambuc 
586433d6423SLionel Sambuc         /* If value is NOT an internal object, we are done */
587433d6423SLionel Sambuc 
588433d6423SLionel Sambuc         if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
589433d6423SLionel Sambuc         {
590433d6423SLionel Sambuc             goto Cleanup;
591433d6423SLionel Sambuc         }
592433d6423SLionel Sambuc 
593433d6423SLionel Sambuc         /* Valid object, get the pointer to next level, if any */
594433d6423SLionel Sambuc 
595433d6423SLionel Sambuc         switch (ObjType)
596433d6423SLionel Sambuc         {
597433d6423SLionel Sambuc         case ACPI_TYPE_BUFFER:
598433d6423SLionel Sambuc         case ACPI_TYPE_STRING:
599433d6423SLionel Sambuc             /*
600433d6423SLionel Sambuc              * NOTE: takes advantage of common fields between string/buffer
601433d6423SLionel Sambuc              */
602433d6423SLionel Sambuc             BytesToDump = ObjDesc->String.Length;
603433d6423SLionel Sambuc             ObjDesc = (void *) ObjDesc->String.Pointer;
604433d6423SLionel Sambuc             AcpiOsPrintf ( "(Buffer/String pointer %p length %X)\n",
605433d6423SLionel Sambuc                 ObjDesc, BytesToDump);
606433d6423SLionel Sambuc             ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
607433d6423SLionel Sambuc             goto Cleanup;
608433d6423SLionel Sambuc 
609433d6423SLionel Sambuc         case ACPI_TYPE_BUFFER_FIELD:
610*29492bb7SDavid van Moolenbroek 
611433d6423SLionel Sambuc             ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->BufferField.BufferObj;
612433d6423SLionel Sambuc             break;
613433d6423SLionel Sambuc 
614433d6423SLionel Sambuc         case ACPI_TYPE_PACKAGE:
615*29492bb7SDavid van Moolenbroek 
616433d6423SLionel Sambuc             ObjDesc = (void *) ObjDesc->Package.Elements;
617433d6423SLionel Sambuc             break;
618433d6423SLionel Sambuc 
619433d6423SLionel Sambuc         case ACPI_TYPE_METHOD:
620*29492bb7SDavid van Moolenbroek 
621433d6423SLionel Sambuc             ObjDesc = (void *) ObjDesc->Method.AmlStart;
622433d6423SLionel Sambuc             break;
623433d6423SLionel Sambuc 
624433d6423SLionel Sambuc         case ACPI_TYPE_LOCAL_REGION_FIELD:
625*29492bb7SDavid van Moolenbroek 
626433d6423SLionel Sambuc             ObjDesc = (void *) ObjDesc->Field.RegionObj;
627433d6423SLionel Sambuc             break;
628433d6423SLionel Sambuc 
629433d6423SLionel Sambuc         case ACPI_TYPE_LOCAL_BANK_FIELD:
630*29492bb7SDavid van Moolenbroek 
631433d6423SLionel Sambuc             ObjDesc = (void *) ObjDesc->BankField.RegionObj;
632433d6423SLionel Sambuc             break;
633433d6423SLionel Sambuc 
634433d6423SLionel Sambuc         case ACPI_TYPE_LOCAL_INDEX_FIELD:
635*29492bb7SDavid van Moolenbroek 
636433d6423SLionel Sambuc             ObjDesc = (void *) ObjDesc->IndexField.IndexObj;
637433d6423SLionel Sambuc             break;
638433d6423SLionel Sambuc 
639433d6423SLionel Sambuc         default:
640*29492bb7SDavid van Moolenbroek 
641433d6423SLionel Sambuc             goto Cleanup;
642433d6423SLionel Sambuc         }
643433d6423SLionel Sambuc 
644433d6423SLionel Sambuc         ObjType = ACPI_TYPE_INVALID;   /* Terminate loop after next pass */
645433d6423SLionel Sambuc     }
646433d6423SLionel Sambuc 
647433d6423SLionel Sambuc Cleanup:
648433d6423SLionel Sambuc     AcpiOsPrintf ("\n");
649433d6423SLionel Sambuc     return (AE_OK);
650433d6423SLionel Sambuc }
651433d6423SLionel Sambuc 
652433d6423SLionel Sambuc 
653433d6423SLionel Sambuc /*******************************************************************************
654433d6423SLionel Sambuc  *
655433d6423SLionel Sambuc  * FUNCTION:    AcpiNsDumpObjects
656433d6423SLionel Sambuc  *
657433d6423SLionel Sambuc  * PARAMETERS:  Type                - Object type to be dumped
658433d6423SLionel Sambuc  *              DisplayType         - 0 or ACPI_DISPLAY_SUMMARY
659433d6423SLionel Sambuc  *              MaxDepth            - Maximum depth of dump. Use ACPI_UINT32_MAX
660433d6423SLionel Sambuc  *                                    for an effectively unlimited depth.
661433d6423SLionel Sambuc  *              OwnerId             - Dump only objects owned by this ID. Use
662433d6423SLionel Sambuc  *                                    ACPI_UINT32_MAX to match all owners.
663433d6423SLionel Sambuc  *              StartHandle         - Where in namespace to start/end search
664433d6423SLionel Sambuc  *
665433d6423SLionel Sambuc  * RETURN:      None
666433d6423SLionel Sambuc  *
667433d6423SLionel Sambuc  * DESCRIPTION: Dump typed objects within the loaded namespace. Uses
668433d6423SLionel Sambuc  *              AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject.
669433d6423SLionel Sambuc  *
670433d6423SLionel Sambuc  ******************************************************************************/
671433d6423SLionel Sambuc 
672433d6423SLionel Sambuc void
AcpiNsDumpObjects(ACPI_OBJECT_TYPE Type,UINT8 DisplayType,UINT32 MaxDepth,ACPI_OWNER_ID OwnerId,ACPI_HANDLE StartHandle)673433d6423SLionel Sambuc AcpiNsDumpObjects (
674433d6423SLionel Sambuc     ACPI_OBJECT_TYPE        Type,
675433d6423SLionel Sambuc     UINT8                   DisplayType,
676433d6423SLionel Sambuc     UINT32                  MaxDepth,
677433d6423SLionel Sambuc     ACPI_OWNER_ID           OwnerId,
678433d6423SLionel Sambuc     ACPI_HANDLE             StartHandle)
679433d6423SLionel Sambuc {
680433d6423SLionel Sambuc     ACPI_WALK_INFO          Info;
681*29492bb7SDavid van Moolenbroek     ACPI_STATUS             Status;
682433d6423SLionel Sambuc 
683433d6423SLionel Sambuc 
684433d6423SLionel Sambuc     ACPI_FUNCTION_ENTRY ();
685433d6423SLionel Sambuc 
686433d6423SLionel Sambuc 
687*29492bb7SDavid van Moolenbroek     /*
688*29492bb7SDavid van Moolenbroek      * Just lock the entire namespace for the duration of the dump.
689*29492bb7SDavid van Moolenbroek      * We don't want any changes to the namespace during this time,
690*29492bb7SDavid van Moolenbroek      * especially the temporary nodes since we are going to display
691*29492bb7SDavid van Moolenbroek      * them also.
692*29492bb7SDavid van Moolenbroek      */
693*29492bb7SDavid van Moolenbroek     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
694*29492bb7SDavid van Moolenbroek     if (ACPI_FAILURE (Status))
695*29492bb7SDavid van Moolenbroek     {
696*29492bb7SDavid van Moolenbroek         AcpiOsPrintf ("Could not acquire namespace mutex\n");
697*29492bb7SDavid van Moolenbroek         return;
698*29492bb7SDavid van Moolenbroek     }
699*29492bb7SDavid van Moolenbroek 
700433d6423SLionel Sambuc     Info.DebugLevel = ACPI_LV_TABLES;
701433d6423SLionel Sambuc     Info.OwnerId = OwnerId;
702433d6423SLionel Sambuc     Info.DisplayType = DisplayType;
703433d6423SLionel Sambuc 
704433d6423SLionel Sambuc     (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
705433d6423SLionel Sambuc                 ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,
706433d6423SLionel Sambuc                 AcpiNsDumpOneObject, NULL, (void *) &Info, NULL);
707*29492bb7SDavid van Moolenbroek 
708*29492bb7SDavid van Moolenbroek     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
709*29492bb7SDavid van Moolenbroek }
710*29492bb7SDavid van Moolenbroek 
711*29492bb7SDavid van Moolenbroek 
712*29492bb7SDavid van Moolenbroek /*******************************************************************************
713*29492bb7SDavid van Moolenbroek  *
714*29492bb7SDavid van Moolenbroek  * FUNCTION:    AcpiNsDumpOneObjectPath, AcpiNsGetMaxDepth
715*29492bb7SDavid van Moolenbroek  *
716*29492bb7SDavid van Moolenbroek  * PARAMETERS:  ObjHandle           - Node to be dumped
717*29492bb7SDavid van Moolenbroek  *              Level               - Nesting level of the handle
718*29492bb7SDavid van Moolenbroek  *              Context             - Passed into WalkNamespace
719*29492bb7SDavid van Moolenbroek  *              ReturnValue         - Not used
720*29492bb7SDavid van Moolenbroek  *
721*29492bb7SDavid van Moolenbroek  * RETURN:      Status
722*29492bb7SDavid van Moolenbroek  *
723*29492bb7SDavid van Moolenbroek  * DESCRIPTION: Dump the full pathname to a namespace object. AcpNsGetMaxDepth
724*29492bb7SDavid van Moolenbroek  *              computes the maximum nesting depth in the namespace tree, in
725*29492bb7SDavid van Moolenbroek  *              order to simplify formatting in AcpiNsDumpOneObjectPath.
726*29492bb7SDavid van Moolenbroek  *              These procedures are UserFunctions called by AcpiNsWalkNamespace.
727*29492bb7SDavid van Moolenbroek  *
728*29492bb7SDavid van Moolenbroek  ******************************************************************************/
729*29492bb7SDavid van Moolenbroek 
730*29492bb7SDavid van Moolenbroek static ACPI_STATUS
AcpiNsDumpOneObjectPath(ACPI_HANDLE ObjHandle,UINT32 Level,void * Context,void ** ReturnValue)731*29492bb7SDavid van Moolenbroek AcpiNsDumpOneObjectPath (
732*29492bb7SDavid van Moolenbroek     ACPI_HANDLE             ObjHandle,
733*29492bb7SDavid van Moolenbroek     UINT32                  Level,
734*29492bb7SDavid van Moolenbroek     void                    *Context,
735*29492bb7SDavid van Moolenbroek     void                    **ReturnValue)
736*29492bb7SDavid van Moolenbroek {
737*29492bb7SDavid van Moolenbroek     UINT32                  MaxLevel = *((UINT32 *) Context);
738*29492bb7SDavid van Moolenbroek     char                    *Pathname;
739*29492bb7SDavid van Moolenbroek     ACPI_NAMESPACE_NODE     *Node;
740*29492bb7SDavid van Moolenbroek     int                     PathIndent;
741*29492bb7SDavid van Moolenbroek 
742*29492bb7SDavid van Moolenbroek 
743*29492bb7SDavid van Moolenbroek     if (!ObjHandle)
744*29492bb7SDavid van Moolenbroek     {
745*29492bb7SDavid van Moolenbroek         return (AE_OK);
746*29492bb7SDavid van Moolenbroek     }
747*29492bb7SDavid van Moolenbroek 
748*29492bb7SDavid van Moolenbroek     Node = AcpiNsValidateHandle (ObjHandle);
749*29492bb7SDavid van Moolenbroek     if (!Node)
750*29492bb7SDavid van Moolenbroek     {
751*29492bb7SDavid van Moolenbroek         /* Ignore bad node during namespace walk */
752*29492bb7SDavid van Moolenbroek 
753*29492bb7SDavid van Moolenbroek         return (AE_OK);
754*29492bb7SDavid van Moolenbroek     }
755*29492bb7SDavid van Moolenbroek 
756*29492bb7SDavid van Moolenbroek     Pathname = AcpiNsGetExternalPathname (Node);
757*29492bb7SDavid van Moolenbroek 
758*29492bb7SDavid van Moolenbroek     PathIndent = 1;
759*29492bb7SDavid van Moolenbroek     if (Level <= MaxLevel)
760*29492bb7SDavid van Moolenbroek     {
761*29492bb7SDavid van Moolenbroek         PathIndent = MaxLevel - Level + 1;
762*29492bb7SDavid van Moolenbroek     }
763*29492bb7SDavid van Moolenbroek 
764*29492bb7SDavid van Moolenbroek     AcpiOsPrintf ("%2d%*s%-12s%*s",
765*29492bb7SDavid van Moolenbroek         Level, Level, " ", AcpiUtGetTypeName (Node->Type),
766*29492bb7SDavid van Moolenbroek         PathIndent, " ");
767*29492bb7SDavid van Moolenbroek 
768*29492bb7SDavid van Moolenbroek     AcpiOsPrintf ("%s\n", &Pathname[1]);
769*29492bb7SDavid van Moolenbroek     ACPI_FREE (Pathname);
770*29492bb7SDavid van Moolenbroek     return (AE_OK);
771*29492bb7SDavid van Moolenbroek }
772*29492bb7SDavid van Moolenbroek 
773*29492bb7SDavid van Moolenbroek 
774*29492bb7SDavid van Moolenbroek static ACPI_STATUS
AcpiNsGetMaxDepth(ACPI_HANDLE ObjHandle,UINT32 Level,void * Context,void ** ReturnValue)775*29492bb7SDavid van Moolenbroek AcpiNsGetMaxDepth (
776*29492bb7SDavid van Moolenbroek     ACPI_HANDLE             ObjHandle,
777*29492bb7SDavid van Moolenbroek     UINT32                  Level,
778*29492bb7SDavid van Moolenbroek     void                    *Context,
779*29492bb7SDavid van Moolenbroek     void                    **ReturnValue)
780*29492bb7SDavid van Moolenbroek {
781*29492bb7SDavid van Moolenbroek     UINT32                  *MaxLevel = (UINT32 *) Context;
782*29492bb7SDavid van Moolenbroek 
783*29492bb7SDavid van Moolenbroek 
784*29492bb7SDavid van Moolenbroek     if (Level > *MaxLevel)
785*29492bb7SDavid van Moolenbroek     {
786*29492bb7SDavid van Moolenbroek         *MaxLevel = Level;
787*29492bb7SDavid van Moolenbroek     }
788*29492bb7SDavid van Moolenbroek     return (AE_OK);
789*29492bb7SDavid van Moolenbroek }
790*29492bb7SDavid van Moolenbroek 
791*29492bb7SDavid van Moolenbroek 
792*29492bb7SDavid van Moolenbroek /*******************************************************************************
793*29492bb7SDavid van Moolenbroek  *
794*29492bb7SDavid van Moolenbroek  * FUNCTION:    AcpiNsDumpObjectPaths
795*29492bb7SDavid van Moolenbroek  *
796*29492bb7SDavid van Moolenbroek  * PARAMETERS:  Type                - Object type to be dumped
797*29492bb7SDavid van Moolenbroek  *              DisplayType         - 0 or ACPI_DISPLAY_SUMMARY
798*29492bb7SDavid van Moolenbroek  *              MaxDepth            - Maximum depth of dump. Use ACPI_UINT32_MAX
799*29492bb7SDavid van Moolenbroek  *                                    for an effectively unlimited depth.
800*29492bb7SDavid van Moolenbroek  *              OwnerId             - Dump only objects owned by this ID. Use
801*29492bb7SDavid van Moolenbroek  *                                    ACPI_UINT32_MAX to match all owners.
802*29492bb7SDavid van Moolenbroek  *              StartHandle         - Where in namespace to start/end search
803*29492bb7SDavid van Moolenbroek  *
804*29492bb7SDavid van Moolenbroek  * RETURN:      None
805*29492bb7SDavid van Moolenbroek  *
806*29492bb7SDavid van Moolenbroek  * DESCRIPTION: Dump full object pathnames within the loaded namespace. Uses
807*29492bb7SDavid van Moolenbroek  *              AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObjectPath.
808*29492bb7SDavid van Moolenbroek  *
809*29492bb7SDavid van Moolenbroek  ******************************************************************************/
810*29492bb7SDavid van Moolenbroek 
811*29492bb7SDavid van Moolenbroek void
AcpiNsDumpObjectPaths(ACPI_OBJECT_TYPE Type,UINT8 DisplayType,UINT32 MaxDepth,ACPI_OWNER_ID OwnerId,ACPI_HANDLE StartHandle)812*29492bb7SDavid van Moolenbroek AcpiNsDumpObjectPaths (
813*29492bb7SDavid van Moolenbroek     ACPI_OBJECT_TYPE        Type,
814*29492bb7SDavid van Moolenbroek     UINT8                   DisplayType,
815*29492bb7SDavid van Moolenbroek     UINT32                  MaxDepth,
816*29492bb7SDavid van Moolenbroek     ACPI_OWNER_ID           OwnerId,
817*29492bb7SDavid van Moolenbroek     ACPI_HANDLE             StartHandle)
818*29492bb7SDavid van Moolenbroek {
819*29492bb7SDavid van Moolenbroek     ACPI_STATUS             Status;
820*29492bb7SDavid van Moolenbroek     UINT32                  MaxLevel = 0;
821*29492bb7SDavid van Moolenbroek 
822*29492bb7SDavid van Moolenbroek 
823*29492bb7SDavid van Moolenbroek     ACPI_FUNCTION_ENTRY ();
824*29492bb7SDavid van Moolenbroek 
825*29492bb7SDavid van Moolenbroek 
826*29492bb7SDavid van Moolenbroek     /*
827*29492bb7SDavid van Moolenbroek      * Just lock the entire namespace for the duration of the dump.
828*29492bb7SDavid van Moolenbroek      * We don't want any changes to the namespace during this time,
829*29492bb7SDavid van Moolenbroek      * especially the temporary nodes since we are going to display
830*29492bb7SDavid van Moolenbroek      * them also.
831*29492bb7SDavid van Moolenbroek      */
832*29492bb7SDavid van Moolenbroek     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
833*29492bb7SDavid van Moolenbroek     if (ACPI_FAILURE (Status))
834*29492bb7SDavid van Moolenbroek     {
835*29492bb7SDavid van Moolenbroek         AcpiOsPrintf ("Could not acquire namespace mutex\n");
836*29492bb7SDavid van Moolenbroek         return;
837*29492bb7SDavid van Moolenbroek     }
838*29492bb7SDavid van Moolenbroek 
839*29492bb7SDavid van Moolenbroek     /* Get the max depth of the namespace tree, for formatting later */
840*29492bb7SDavid van Moolenbroek 
841*29492bb7SDavid van Moolenbroek     (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
842*29492bb7SDavid van Moolenbroek                 ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,
843*29492bb7SDavid van Moolenbroek                 AcpiNsGetMaxDepth, NULL, (void *) &MaxLevel, NULL);
844*29492bb7SDavid van Moolenbroek 
845*29492bb7SDavid van Moolenbroek     /* Now dump the entire namespace */
846*29492bb7SDavid van Moolenbroek 
847*29492bb7SDavid van Moolenbroek     (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
848*29492bb7SDavid van Moolenbroek                 ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,
849*29492bb7SDavid van Moolenbroek                 AcpiNsDumpOneObjectPath, NULL, (void *) &MaxLevel, NULL);
850*29492bb7SDavid van Moolenbroek 
851*29492bb7SDavid van Moolenbroek     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
852433d6423SLionel Sambuc }
853433d6423SLionel Sambuc 
854433d6423SLionel Sambuc 
855433d6423SLionel Sambuc /*******************************************************************************
856433d6423SLionel Sambuc  *
857433d6423SLionel Sambuc  * FUNCTION:    AcpiNsDumpEntry
858433d6423SLionel Sambuc  *
859433d6423SLionel Sambuc  * PARAMETERS:  Handle              - Node to be dumped
860433d6423SLionel Sambuc  *              DebugLevel          - Output level
861433d6423SLionel Sambuc  *
862433d6423SLionel Sambuc  * RETURN:      None
863433d6423SLionel Sambuc  *
864433d6423SLionel Sambuc  * DESCRIPTION: Dump a single Node
865433d6423SLionel Sambuc  *
866433d6423SLionel Sambuc  ******************************************************************************/
867433d6423SLionel Sambuc 
868433d6423SLionel Sambuc void
AcpiNsDumpEntry(ACPI_HANDLE Handle,UINT32 DebugLevel)869433d6423SLionel Sambuc AcpiNsDumpEntry (
870433d6423SLionel Sambuc     ACPI_HANDLE             Handle,
871433d6423SLionel Sambuc     UINT32                  DebugLevel)
872433d6423SLionel Sambuc {
873433d6423SLionel Sambuc     ACPI_WALK_INFO          Info;
874433d6423SLionel Sambuc 
875433d6423SLionel Sambuc 
876433d6423SLionel Sambuc     ACPI_FUNCTION_ENTRY ();
877433d6423SLionel Sambuc 
878433d6423SLionel Sambuc 
879433d6423SLionel Sambuc     Info.DebugLevel = DebugLevel;
880433d6423SLionel Sambuc     Info.OwnerId = ACPI_OWNER_ID_MAX;
881433d6423SLionel Sambuc     Info.DisplayType = ACPI_DISPLAY_SUMMARY;
882433d6423SLionel Sambuc 
883433d6423SLionel Sambuc     (void) AcpiNsDumpOneObject (Handle, 1, &Info, NULL);
884433d6423SLionel Sambuc }
885433d6423SLionel Sambuc 
886433d6423SLionel Sambuc 
887433d6423SLionel Sambuc #ifdef ACPI_ASL_COMPILER
888433d6423SLionel Sambuc /*******************************************************************************
889433d6423SLionel Sambuc  *
890433d6423SLionel Sambuc  * FUNCTION:    AcpiNsDumpTables
891433d6423SLionel Sambuc  *
892433d6423SLionel Sambuc  * PARAMETERS:  SearchBase          - Root of subtree to be dumped, or
893433d6423SLionel Sambuc  *                                    NS_ALL to dump the entire namespace
894433d6423SLionel Sambuc  *              MaxDepth            - Maximum depth of dump. Use INT_MAX
895433d6423SLionel Sambuc  *                                    for an effectively unlimited depth.
896433d6423SLionel Sambuc  *
897433d6423SLionel Sambuc  * RETURN:      None
898433d6423SLionel Sambuc  *
899433d6423SLionel Sambuc  * DESCRIPTION: Dump the name space, or a portion of it.
900433d6423SLionel Sambuc  *
901433d6423SLionel Sambuc  ******************************************************************************/
902433d6423SLionel Sambuc 
903433d6423SLionel Sambuc void
AcpiNsDumpTables(ACPI_HANDLE SearchBase,UINT32 MaxDepth)904433d6423SLionel Sambuc AcpiNsDumpTables (
905433d6423SLionel Sambuc     ACPI_HANDLE             SearchBase,
906433d6423SLionel Sambuc     UINT32                  MaxDepth)
907433d6423SLionel Sambuc {
908433d6423SLionel Sambuc     ACPI_HANDLE             SearchHandle = SearchBase;
909433d6423SLionel Sambuc 
910433d6423SLionel Sambuc 
911433d6423SLionel Sambuc     ACPI_FUNCTION_TRACE (NsDumpTables);
912433d6423SLionel Sambuc 
913433d6423SLionel Sambuc 
914433d6423SLionel Sambuc     if (!AcpiGbl_RootNode)
915433d6423SLionel Sambuc     {
916433d6423SLionel Sambuc         /*
917433d6423SLionel Sambuc          * If the name space has not been initialized,
918433d6423SLionel Sambuc          * there is nothing to dump.
919433d6423SLionel Sambuc          */
920433d6423SLionel Sambuc         ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "namespace not initialized!\n"));
921433d6423SLionel Sambuc         return_VOID;
922433d6423SLionel Sambuc     }
923433d6423SLionel Sambuc 
924433d6423SLionel Sambuc     if (ACPI_NS_ALL == SearchBase)
925433d6423SLionel Sambuc     {
926433d6423SLionel Sambuc         /* Entire namespace */
927433d6423SLionel Sambuc 
928433d6423SLionel Sambuc         SearchHandle = AcpiGbl_RootNode;
929433d6423SLionel Sambuc         ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n"));
930433d6423SLionel Sambuc     }
931433d6423SLionel Sambuc 
932433d6423SLionel Sambuc     AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, MaxDepth,
933433d6423SLionel Sambuc             ACPI_OWNER_ID_MAX, SearchHandle);
934433d6423SLionel Sambuc     return_VOID;
935433d6423SLionel Sambuc }
936433d6423SLionel Sambuc #endif
937433d6423SLionel Sambuc #endif
938