1 /******************************************************************************
3 * Module Name: nsdump - table dumping routines for debug
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
12 * All rights reserved.
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
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,
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
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;
38 * The above copyright and patent license is granted only if the following
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.
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
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
73 * 3.4. Intel retains all right, title, and interest in and to the Original
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.
81 * 4. Disclaimer and Export Compliance
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
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
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.
115 *****************************************************************************/
120 #include "accommon.h"
121 #include "acnamesp.h"
124 #define _COMPONENT ACPI_NAMESPACE
125 ACPI_MODULE_NAME ("nsdump")
127 /* Local prototypes */
129 #ifdef ACPI_OBSOLETE_FUNCTIONS
131 AcpiNsDumpRootDevices (
135 AcpiNsDumpOneDevice (
136 ACPI_HANDLE ObjHandle
,
143 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
144 /*******************************************************************************
146 * FUNCTION: AcpiNsPrintPathname
148 * PARAMETERS: NumSegments - Number of ACPI name segments
149 * Pathname - The compressed (internal) path
153 * DESCRIPTION: Print an object's full namespace pathname
155 ******************************************************************************/
158 AcpiNsPrintPathname (
165 ACPI_FUNCTION_NAME (NsPrintPathname
);
168 if (!(AcpiDbgLevel
& ACPI_LV_NAMES
) || !(AcpiDbgLayer
& ACPI_NAMESPACE
))
173 /* Print the entire name */
175 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES
, "["));
179 for (i
= 0; i
< 4; i
++)
181 ACPI_IS_PRINT (Pathname
[i
]) ?
182 AcpiOsPrintf ("%c", Pathname
[i
]) :
186 Pathname
+= ACPI_NAME_SIZE
;
194 AcpiOsPrintf ("]\n");
198 /*******************************************************************************
200 * FUNCTION: AcpiNsDumpPathname
202 * PARAMETERS: Handle - Object
203 * Msg - Prefix message
204 * Level - Desired debug level
205 * Component - Caller's component ID
209 * DESCRIPTION: Print an object's full namespace pathname
210 * Manages allocation/freeing of a pathname buffer
212 ******************************************************************************/
222 ACPI_FUNCTION_TRACE (NsDumpPathname
);
225 /* Do this only if the requested debug level and component are enabled */
227 if (!(AcpiDbgLevel
& Level
) || !(AcpiDbgLayer
& Component
))
232 /* Convert handle to a full pathname and print it (with supplied message) */
234 AcpiNsPrintNodePathname (Handle
, Msg
);
240 /*******************************************************************************
242 * FUNCTION: AcpiNsDumpOneObject
244 * PARAMETERS: ObjHandle - Node to be dumped
245 * Level - Nesting level of the handle
246 * Context - Passed into WalkNamespace
247 * ReturnValue - Not used
251 * DESCRIPTION: Dump a single Node
252 * This procedure is a UserFunction called by AcpiNsWalkNamespace.
254 ******************************************************************************/
257 AcpiNsDumpOneObject (
258 ACPI_HANDLE ObjHandle
,
263 ACPI_WALK_INFO
*Info
= (ACPI_WALK_INFO
*) Context
;
264 ACPI_NAMESPACE_NODE
*ThisNode
;
265 ACPI_OPERAND_OBJECT
*ObjDesc
= NULL
;
266 ACPI_OBJECT_TYPE ObjType
;
267 ACPI_OBJECT_TYPE Type
;
273 ACPI_FUNCTION_NAME (NsDumpOneObject
);
276 /* Is output enabled? */
278 if (!(AcpiDbgLevel
& Info
->DebugLevel
))
285 ACPI_DEBUG_PRINT ((ACPI_DB_INFO
, "Null object handle\n"));
289 ThisNode
= AcpiNsMapHandleToNode (ObjHandle
);
292 ACPI_DEBUG_PRINT ((ACPI_DB_INFO
, "Invalid object handle %p\n",
297 Type
= ThisNode
->Type
;
299 /* Check if the owner matches */
301 if ((Info
->OwnerId
!= ACPI_OWNER_ID_MAX
) &&
302 (Info
->OwnerId
!= ThisNode
->OwnerId
))
307 if (!(Info
->DisplayType
& ACPI_DISPLAY_SHORT
))
309 /* Indent the object according to the level */
311 AcpiOsPrintf ("%2d%*s", (UINT32
) Level
- 1, (int) Level
* 2, " ");
313 /* Check the node type and name */
315 if (Type
> ACPI_TYPE_LOCAL_MAX
)
317 ACPI_WARNING ((AE_INFO
, "Invalid ACPI Object Type %08X", Type
));
320 AcpiOsPrintf ("%4.4s", AcpiUtGetNodeName (ThisNode
));
323 /* Now we can print out the pertinent information */
325 AcpiOsPrintf (" %-12s %p %2.2X ",
326 AcpiUtGetTypeName (Type
), ThisNode
, ThisNode
->OwnerId
);
328 DbgLevel
= AcpiDbgLevel
;
330 ObjDesc
= AcpiNsGetAttachedObject (ThisNode
);
331 AcpiDbgLevel
= DbgLevel
;
333 /* Temp nodes are those nodes created by a control method */
335 if (ThisNode
->Flags
& ANOBJ_TEMPORARY
)
337 AcpiOsPrintf ("(T) ");
340 switch (Info
->DisplayType
& ACPI_DISPLAY_MASK
)
342 case ACPI_DISPLAY_SUMMARY
:
346 /* No attached object, we are done */
354 case ACPI_TYPE_PROCESSOR
:
356 AcpiOsPrintf ("ID %X Len %.4X Addr %p\n",
357 ObjDesc
->Processor
.ProcId
, ObjDesc
->Processor
.Length
,
358 ACPI_CAST_PTR (void, ObjDesc
->Processor
.Address
));
362 case ACPI_TYPE_DEVICE
:
364 AcpiOsPrintf ("Notify Object: %p\n", ObjDesc
);
368 case ACPI_TYPE_METHOD
:
370 AcpiOsPrintf ("Args %X Len %.4X Aml %p\n",
371 (UINT32
) ObjDesc
->Method
.ParamCount
,
372 ObjDesc
->Method
.AmlLength
, ObjDesc
->Method
.AmlStart
);
376 case ACPI_TYPE_INTEGER
:
378 AcpiOsPrintf ("= %8.8X%8.8X\n",
379 ACPI_FORMAT_UINT64 (ObjDesc
->Integer
.Value
));
383 case ACPI_TYPE_PACKAGE
:
385 if (ObjDesc
->Common
.Flags
& AOPOBJ_DATA_VALID
)
387 AcpiOsPrintf ("Elements %.2X\n",
388 ObjDesc
->Package
.Count
);
392 AcpiOsPrintf ("[Length not yet evaluated]\n");
397 case ACPI_TYPE_BUFFER
:
399 if (ObjDesc
->Common
.Flags
& AOPOBJ_DATA_VALID
)
401 AcpiOsPrintf ("Len %.2X",
402 ObjDesc
->Buffer
.Length
);
404 /* Dump some of the buffer */
406 if (ObjDesc
->Buffer
.Length
> 0)
409 for (i
= 0; (i
< ObjDesc
->Buffer
.Length
&& i
< 12); i
++)
411 AcpiOsPrintf (" %.2hX", ObjDesc
->Buffer
.Pointer
[i
]);
418 AcpiOsPrintf ("[Length not yet evaluated]\n");
423 case ACPI_TYPE_STRING
:
425 AcpiOsPrintf ("Len %.2X ", ObjDesc
->String
.Length
);
426 AcpiUtPrintString (ObjDesc
->String
.Pointer
, 32);
431 case ACPI_TYPE_REGION
:
433 AcpiOsPrintf ("[%s]",
434 AcpiUtGetRegionName (ObjDesc
->Region
.SpaceId
));
435 if (ObjDesc
->Region
.Flags
& AOPOBJ_DATA_VALID
)
437 AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n",
438 ACPI_FORMAT_NATIVE_UINT (ObjDesc
->Region
.Address
),
439 ObjDesc
->Region
.Length
);
443 AcpiOsPrintf (" [Address/Length not yet evaluated]\n");
448 case ACPI_TYPE_LOCAL_REFERENCE
:
450 AcpiOsPrintf ("[%s]\n", AcpiUtGetReferenceName (ObjDesc
));
454 case ACPI_TYPE_BUFFER_FIELD
:
456 if (ObjDesc
->BufferField
.BufferObj
&&
457 ObjDesc
->BufferField
.BufferObj
->Buffer
.Node
)
459 AcpiOsPrintf ("Buf [%4.4s]",
461 ObjDesc
->BufferField
.BufferObj
->Buffer
.Node
));
466 case ACPI_TYPE_LOCAL_REGION_FIELD
:
468 AcpiOsPrintf ("Rgn [%4.4s]",
470 ObjDesc
->CommonField
.RegionObj
->Region
.Node
));
474 case ACPI_TYPE_LOCAL_BANK_FIELD
:
476 AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]",
478 ObjDesc
->CommonField
.RegionObj
->Region
.Node
),
480 ObjDesc
->BankField
.BankObj
->CommonField
.Node
));
484 case ACPI_TYPE_LOCAL_INDEX_FIELD
:
486 AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]",
488 ObjDesc
->IndexField
.IndexObj
->CommonField
.Node
),
490 ObjDesc
->IndexField
.DataObj
->CommonField
.Node
));
494 case ACPI_TYPE_LOCAL_ALIAS
:
495 case ACPI_TYPE_LOCAL_METHOD_ALIAS
:
497 AcpiOsPrintf ("Target %4.4s (%p)\n",
498 AcpiUtGetNodeName (ObjDesc
), ObjDesc
);
503 AcpiOsPrintf ("Object %p\n", ObjDesc
);
507 /* Common field handling */
511 case ACPI_TYPE_BUFFER_FIELD
:
512 case ACPI_TYPE_LOCAL_REGION_FIELD
:
513 case ACPI_TYPE_LOCAL_BANK_FIELD
:
514 case ACPI_TYPE_LOCAL_INDEX_FIELD
:
516 AcpiOsPrintf (" Off %.3X Len %.2X Acc %.2hd\n",
517 (ObjDesc
->CommonField
.BaseByteOffset
* 8)
518 + ObjDesc
->CommonField
.StartFieldBitOffset
,
519 ObjDesc
->CommonField
.BitLength
,
520 ObjDesc
->CommonField
.AccessByteWidth
);
529 case ACPI_DISPLAY_OBJECTS
:
531 AcpiOsPrintf ("O:%p", ObjDesc
);
534 /* No attached object, we are done */
540 AcpiOsPrintf ("(R%d)", ObjDesc
->Common
.ReferenceCount
);
544 case ACPI_TYPE_METHOD
:
546 /* Name is a Method and its AML offset/length are set */
548 AcpiOsPrintf (" M:%p-%X\n", ObjDesc
->Method
.AmlStart
,
549 ObjDesc
->Method
.AmlLength
);
552 case ACPI_TYPE_INTEGER
:
554 AcpiOsPrintf (" I:%8.8X8.8%X\n",
555 ACPI_FORMAT_UINT64 (ObjDesc
->Integer
.Value
));
558 case ACPI_TYPE_STRING
:
560 AcpiOsPrintf (" S:%p-%X\n", ObjDesc
->String
.Pointer
,
561 ObjDesc
->String
.Length
);
564 case ACPI_TYPE_BUFFER
:
566 AcpiOsPrintf (" B:%p-%X\n", ObjDesc
->Buffer
.Pointer
,
567 ObjDesc
->Buffer
.Length
);
583 /* If debug turned off, done */
585 if (!(AcpiDbgLevel
& ACPI_LV_VALUES
))
590 /* If there is an attached object, display it */
592 DbgLevel
= AcpiDbgLevel
;
594 ObjDesc
= AcpiNsGetAttachedObject (ThisNode
);
595 AcpiDbgLevel
= DbgLevel
;
597 /* Dump attached objects */
601 ObjType
= ACPI_TYPE_INVALID
;
602 AcpiOsPrintf ("Attached Object %p: ", ObjDesc
);
604 /* Decode the type of attached object and dump the contents */
606 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc
))
608 case ACPI_DESC_TYPE_NAMED
:
610 AcpiOsPrintf ("(Ptr to Node)\n");
611 BytesToDump
= sizeof (ACPI_NAMESPACE_NODE
);
612 ACPI_DUMP_BUFFER (ObjDesc
, BytesToDump
);
615 case ACPI_DESC_TYPE_OPERAND
:
617 ObjType
= ObjDesc
->Common
.Type
;
619 if (ObjType
> ACPI_TYPE_LOCAL_MAX
)
621 AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [UNKNOWN])\n",
627 AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [%s])\n",
628 ObjType
, AcpiUtGetTypeName (ObjType
));
629 BytesToDump
= sizeof (ACPI_OPERAND_OBJECT
);
632 ACPI_DUMP_BUFFER (ObjDesc
, BytesToDump
);
640 /* If value is NOT an internal object, we are done */
642 if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc
) != ACPI_DESC_TYPE_OPERAND
)
647 /* Valid object, get the pointer to next level, if any */
651 case ACPI_TYPE_BUFFER
:
652 case ACPI_TYPE_STRING
:
654 * NOTE: takes advantage of common fields between string/buffer
656 BytesToDump
= ObjDesc
->String
.Length
;
657 ObjDesc
= (void *) ObjDesc
->String
.Pointer
;
658 AcpiOsPrintf ( "(Buffer/String pointer %p length %X)\n",
659 ObjDesc
, BytesToDump
);
660 ACPI_DUMP_BUFFER (ObjDesc
, BytesToDump
);
663 case ACPI_TYPE_BUFFER_FIELD
:
664 ObjDesc
= (ACPI_OPERAND_OBJECT
*) ObjDesc
->BufferField
.BufferObj
;
667 case ACPI_TYPE_PACKAGE
:
668 ObjDesc
= (void *) ObjDesc
->Package
.Elements
;
671 case ACPI_TYPE_METHOD
:
672 ObjDesc
= (void *) ObjDesc
->Method
.AmlStart
;
675 case ACPI_TYPE_LOCAL_REGION_FIELD
:
676 ObjDesc
= (void *) ObjDesc
->Field
.RegionObj
;
679 case ACPI_TYPE_LOCAL_BANK_FIELD
:
680 ObjDesc
= (void *) ObjDesc
->BankField
.RegionObj
;
683 case ACPI_TYPE_LOCAL_INDEX_FIELD
:
684 ObjDesc
= (void *) ObjDesc
->IndexField
.IndexObj
;
691 ObjType
= ACPI_TYPE_INVALID
; /* Terminate loop after next pass */
700 /*******************************************************************************
702 * FUNCTION: AcpiNsDumpObjects
704 * PARAMETERS: Type - Object type to be dumped
705 * DisplayType - 0 or ACPI_DISPLAY_SUMMARY
706 * MaxDepth - Maximum depth of dump. Use ACPI_UINT32_MAX
707 * for an effectively unlimited depth.
708 * OwnerId - Dump only objects owned by this ID. Use
709 * ACPI_UINT32_MAX to match all owners.
710 * StartHandle - Where in namespace to start/end search
714 * DESCRIPTION: Dump typed objects within the loaded namespace. Uses
715 * AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject.
717 ******************************************************************************/
721 ACPI_OBJECT_TYPE Type
,
724 ACPI_OWNER_ID OwnerId
,
725 ACPI_HANDLE StartHandle
)
730 ACPI_FUNCTION_ENTRY ();
733 Info
.DebugLevel
= ACPI_LV_TABLES
;
734 Info
.OwnerId
= OwnerId
;
735 Info
.DisplayType
= DisplayType
;
737 (void) AcpiNsWalkNamespace (Type
, StartHandle
, MaxDepth
,
738 ACPI_NS_WALK_NO_UNLOCK
| ACPI_NS_WALK_TEMP_NODES
,
739 AcpiNsDumpOneObject
, (void *) &Info
, NULL
);
743 /*******************************************************************************
745 * FUNCTION: AcpiNsDumpEntry
747 * PARAMETERS: Handle - Node to be dumped
748 * DebugLevel - Output level
752 * DESCRIPTION: Dump a single Node
754 ******************************************************************************/
764 ACPI_FUNCTION_ENTRY ();
767 Info
.DebugLevel
= DebugLevel
;
768 Info
.OwnerId
= ACPI_OWNER_ID_MAX
;
769 Info
.DisplayType
= ACPI_DISPLAY_SUMMARY
;
771 (void) AcpiNsDumpOneObject (Handle
, 1, &Info
, NULL
);
775 #ifdef ACPI_ASL_COMPILER
776 /*******************************************************************************
778 * FUNCTION: AcpiNsDumpTables
780 * PARAMETERS: SearchBase - Root of subtree to be dumped, or
781 * NS_ALL to dump the entire namespace
782 * MaxDepth - Maximum depth of dump. Use INT_MAX
783 * for an effectively unlimited depth.
787 * DESCRIPTION: Dump the name space, or a portion of it.
789 ******************************************************************************/
793 ACPI_HANDLE SearchBase
,
796 ACPI_HANDLE SearchHandle
= SearchBase
;
799 ACPI_FUNCTION_TRACE (NsDumpTables
);
802 if (!AcpiGbl_RootNode
)
805 * If the name space has not been initialized,
806 * there is nothing to dump.
808 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES
, "namespace not initialized!\n"));
812 if (ACPI_NS_ALL
== SearchBase
)
814 /* Entire namespace */
816 SearchHandle
= AcpiGbl_RootNode
;
817 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES
, "\\\n"));
820 AcpiNsDumpObjects (ACPI_TYPE_ANY
, ACPI_DISPLAY_OBJECTS
, MaxDepth
,
821 ACPI_OWNER_ID_MAX
, SearchHandle
);