1 /******************************************************************************
3 * Module Name: nsdump - table dumping routines for debug
5 *****************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2012, 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
= AcpiNsValidateHandle (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 0x%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. Some types should always have an object */
350 case ACPI_TYPE_INTEGER
:
351 case ACPI_TYPE_PACKAGE
:
352 case ACPI_TYPE_BUFFER
:
353 case ACPI_TYPE_STRING
:
354 case ACPI_TYPE_METHOD
:
355 AcpiOsPrintf ("<No attached object>");
368 case ACPI_TYPE_PROCESSOR
:
370 AcpiOsPrintf ("ID %02X Len %02X Addr %p\n",
371 ObjDesc
->Processor
.ProcId
, ObjDesc
->Processor
.Length
,
372 ACPI_CAST_PTR (void, ObjDesc
->Processor
.Address
));
376 case ACPI_TYPE_DEVICE
:
378 AcpiOsPrintf ("Notify Object: %p\n", ObjDesc
);
382 case ACPI_TYPE_METHOD
:
384 AcpiOsPrintf ("Args %X Len %.4X Aml %p\n",
385 (UINT32
) ObjDesc
->Method
.ParamCount
,
386 ObjDesc
->Method
.AmlLength
, ObjDesc
->Method
.AmlStart
);
390 case ACPI_TYPE_INTEGER
:
392 AcpiOsPrintf ("= %8.8X%8.8X\n",
393 ACPI_FORMAT_UINT64 (ObjDesc
->Integer
.Value
));
397 case ACPI_TYPE_PACKAGE
:
399 if (ObjDesc
->Common
.Flags
& AOPOBJ_DATA_VALID
)
401 AcpiOsPrintf ("Elements %.2X\n",
402 ObjDesc
->Package
.Count
);
406 AcpiOsPrintf ("[Length not yet evaluated]\n");
411 case ACPI_TYPE_BUFFER
:
413 if (ObjDesc
->Common
.Flags
& AOPOBJ_DATA_VALID
)
415 AcpiOsPrintf ("Len %.2X",
416 ObjDesc
->Buffer
.Length
);
418 /* Dump some of the buffer */
420 if (ObjDesc
->Buffer
.Length
> 0)
423 for (i
= 0; (i
< ObjDesc
->Buffer
.Length
&& i
< 12); i
++)
425 AcpiOsPrintf (" %.2hX", ObjDesc
->Buffer
.Pointer
[i
]);
432 AcpiOsPrintf ("[Length not yet evaluated]\n");
437 case ACPI_TYPE_STRING
:
439 AcpiOsPrintf ("Len %.2X ", ObjDesc
->String
.Length
);
440 AcpiUtPrintString (ObjDesc
->String
.Pointer
, 32);
445 case ACPI_TYPE_REGION
:
447 AcpiOsPrintf ("[%s]",
448 AcpiUtGetRegionName (ObjDesc
->Region
.SpaceId
));
449 if (ObjDesc
->Region
.Flags
& AOPOBJ_DATA_VALID
)
451 AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n",
452 ACPI_FORMAT_NATIVE_UINT (ObjDesc
->Region
.Address
),
453 ObjDesc
->Region
.Length
);
457 AcpiOsPrintf (" [Address/Length not yet evaluated]\n");
462 case ACPI_TYPE_LOCAL_REFERENCE
:
464 AcpiOsPrintf ("[%s]\n", AcpiUtGetReferenceName (ObjDesc
));
468 case ACPI_TYPE_BUFFER_FIELD
:
470 if (ObjDesc
->BufferField
.BufferObj
&&
471 ObjDesc
->BufferField
.BufferObj
->Buffer
.Node
)
473 AcpiOsPrintf ("Buf [%4.4s]",
475 ObjDesc
->BufferField
.BufferObj
->Buffer
.Node
));
480 case ACPI_TYPE_LOCAL_REGION_FIELD
:
482 AcpiOsPrintf ("Rgn [%4.4s]",
484 ObjDesc
->CommonField
.RegionObj
->Region
.Node
));
488 case ACPI_TYPE_LOCAL_BANK_FIELD
:
490 AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]",
492 ObjDesc
->CommonField
.RegionObj
->Region
.Node
),
494 ObjDesc
->BankField
.BankObj
->CommonField
.Node
));
498 case ACPI_TYPE_LOCAL_INDEX_FIELD
:
500 AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]",
502 ObjDesc
->IndexField
.IndexObj
->CommonField
.Node
),
504 ObjDesc
->IndexField
.DataObj
->CommonField
.Node
));
508 case ACPI_TYPE_LOCAL_ALIAS
:
509 case ACPI_TYPE_LOCAL_METHOD_ALIAS
:
511 AcpiOsPrintf ("Target %4.4s (%p)\n",
512 AcpiUtGetNodeName (ObjDesc
), ObjDesc
);
517 AcpiOsPrintf ("Object %p\n", ObjDesc
);
521 /* Common field handling */
525 case ACPI_TYPE_BUFFER_FIELD
:
526 case ACPI_TYPE_LOCAL_REGION_FIELD
:
527 case ACPI_TYPE_LOCAL_BANK_FIELD
:
528 case ACPI_TYPE_LOCAL_INDEX_FIELD
:
530 AcpiOsPrintf (" Off %.3X Len %.2X Acc %.2hd\n",
531 (ObjDesc
->CommonField
.BaseByteOffset
* 8)
532 + ObjDesc
->CommonField
.StartFieldBitOffset
,
533 ObjDesc
->CommonField
.BitLength
,
534 ObjDesc
->CommonField
.AccessByteWidth
);
543 case ACPI_DISPLAY_OBJECTS
:
545 AcpiOsPrintf ("O:%p", ObjDesc
);
548 /* No attached object, we are done */
554 AcpiOsPrintf ("(R%u)", ObjDesc
->Common
.ReferenceCount
);
558 case ACPI_TYPE_METHOD
:
560 /* Name is a Method and its AML offset/length are set */
562 AcpiOsPrintf (" M:%p-%X\n", ObjDesc
->Method
.AmlStart
,
563 ObjDesc
->Method
.AmlLength
);
566 case ACPI_TYPE_INTEGER
:
568 AcpiOsPrintf (" I:%8.8X8.8%X\n",
569 ACPI_FORMAT_UINT64 (ObjDesc
->Integer
.Value
));
572 case ACPI_TYPE_STRING
:
574 AcpiOsPrintf (" S:%p-%X\n", ObjDesc
->String
.Pointer
,
575 ObjDesc
->String
.Length
);
578 case ACPI_TYPE_BUFFER
:
580 AcpiOsPrintf (" B:%p-%X\n", ObjDesc
->Buffer
.Pointer
,
581 ObjDesc
->Buffer
.Length
);
597 /* If debug turned off, done */
599 if (!(AcpiDbgLevel
& ACPI_LV_VALUES
))
604 /* If there is an attached object, display it */
606 DbgLevel
= AcpiDbgLevel
;
608 ObjDesc
= AcpiNsGetAttachedObject (ThisNode
);
609 AcpiDbgLevel
= DbgLevel
;
611 /* Dump attached objects */
615 ObjType
= ACPI_TYPE_INVALID
;
616 AcpiOsPrintf ("Attached Object %p: ", ObjDesc
);
618 /* Decode the type of attached object and dump the contents */
620 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc
))
622 case ACPI_DESC_TYPE_NAMED
:
624 AcpiOsPrintf ("(Ptr to Node)\n");
625 BytesToDump
= sizeof (ACPI_NAMESPACE_NODE
);
626 ACPI_DUMP_BUFFER (ObjDesc
, BytesToDump
);
629 case ACPI_DESC_TYPE_OPERAND
:
631 ObjType
= ObjDesc
->Common
.Type
;
633 if (ObjType
> ACPI_TYPE_LOCAL_MAX
)
635 AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [UNKNOWN])\n",
641 AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [%s])\n",
642 ObjType
, AcpiUtGetTypeName (ObjType
));
643 BytesToDump
= sizeof (ACPI_OPERAND_OBJECT
);
646 ACPI_DUMP_BUFFER (ObjDesc
, BytesToDump
);
654 /* If value is NOT an internal object, we are done */
656 if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc
) != ACPI_DESC_TYPE_OPERAND
)
661 /* Valid object, get the pointer to next level, if any */
665 case ACPI_TYPE_BUFFER
:
666 case ACPI_TYPE_STRING
:
668 * NOTE: takes advantage of common fields between string/buffer
670 BytesToDump
= ObjDesc
->String
.Length
;
671 ObjDesc
= (void *) ObjDesc
->String
.Pointer
;
672 AcpiOsPrintf ( "(Buffer/String pointer %p length %X)\n",
673 ObjDesc
, BytesToDump
);
674 ACPI_DUMP_BUFFER (ObjDesc
, BytesToDump
);
677 case ACPI_TYPE_BUFFER_FIELD
:
678 ObjDesc
= (ACPI_OPERAND_OBJECT
*) ObjDesc
->BufferField
.BufferObj
;
681 case ACPI_TYPE_PACKAGE
:
682 ObjDesc
= (void *) ObjDesc
->Package
.Elements
;
685 case ACPI_TYPE_METHOD
:
686 ObjDesc
= (void *) ObjDesc
->Method
.AmlStart
;
689 case ACPI_TYPE_LOCAL_REGION_FIELD
:
690 ObjDesc
= (void *) ObjDesc
->Field
.RegionObj
;
693 case ACPI_TYPE_LOCAL_BANK_FIELD
:
694 ObjDesc
= (void *) ObjDesc
->BankField
.RegionObj
;
697 case ACPI_TYPE_LOCAL_INDEX_FIELD
:
698 ObjDesc
= (void *) ObjDesc
->IndexField
.IndexObj
;
705 ObjType
= ACPI_TYPE_INVALID
; /* Terminate loop after next pass */
714 /*******************************************************************************
716 * FUNCTION: AcpiNsDumpObjects
718 * PARAMETERS: Type - Object type to be dumped
719 * DisplayType - 0 or ACPI_DISPLAY_SUMMARY
720 * MaxDepth - Maximum depth of dump. Use ACPI_UINT32_MAX
721 * for an effectively unlimited depth.
722 * OwnerId - Dump only objects owned by this ID. Use
723 * ACPI_UINT32_MAX to match all owners.
724 * StartHandle - Where in namespace to start/end search
728 * DESCRIPTION: Dump typed objects within the loaded namespace. Uses
729 * AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject.
731 ******************************************************************************/
735 ACPI_OBJECT_TYPE Type
,
738 ACPI_OWNER_ID OwnerId
,
739 ACPI_HANDLE StartHandle
)
745 ACPI_FUNCTION_ENTRY ();
749 * Just lock the entire namespace for the duration of the dump.
750 * We don't want any changes to the namespace during this time,
751 * especially the temporary nodes since we are going to display
754 Status
= AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE
);
755 if (ACPI_FAILURE (Status
))
757 AcpiOsPrintf ("Could not acquire namespace mutex\n");
761 Info
.DebugLevel
= ACPI_LV_TABLES
;
762 Info
.OwnerId
= OwnerId
;
763 Info
.DisplayType
= DisplayType
;
765 (void) AcpiNsWalkNamespace (Type
, StartHandle
, MaxDepth
,
766 ACPI_NS_WALK_NO_UNLOCK
| ACPI_NS_WALK_TEMP_NODES
,
767 AcpiNsDumpOneObject
, NULL
, (void *) &Info
, NULL
);
769 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE
);
773 /*******************************************************************************
775 * FUNCTION: AcpiNsDumpEntry
777 * PARAMETERS: Handle - Node to be dumped
778 * DebugLevel - Output level
782 * DESCRIPTION: Dump a single Node
784 ******************************************************************************/
794 ACPI_FUNCTION_ENTRY ();
797 Info
.DebugLevel
= DebugLevel
;
798 Info
.OwnerId
= ACPI_OWNER_ID_MAX
;
799 Info
.DisplayType
= ACPI_DISPLAY_SUMMARY
;
801 (void) AcpiNsDumpOneObject (Handle
, 1, &Info
, NULL
);
805 #ifdef ACPI_ASL_COMPILER
806 /*******************************************************************************
808 * FUNCTION: AcpiNsDumpTables
810 * PARAMETERS: SearchBase - Root of subtree to be dumped, or
811 * NS_ALL to dump the entire namespace
812 * MaxDepth - Maximum depth of dump. Use INT_MAX
813 * for an effectively unlimited depth.
817 * DESCRIPTION: Dump the name space, or a portion of it.
819 ******************************************************************************/
823 ACPI_HANDLE SearchBase
,
826 ACPI_HANDLE SearchHandle
= SearchBase
;
829 ACPI_FUNCTION_TRACE (NsDumpTables
);
832 if (!AcpiGbl_RootNode
)
835 * If the name space has not been initialized,
836 * there is nothing to dump.
838 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES
, "namespace not initialized!\n"));
842 if (ACPI_NS_ALL
== SearchBase
)
844 /* Entire namespace */
846 SearchHandle
= AcpiGbl_RootNode
;
847 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES
, "\\\n"));
850 AcpiNsDumpObjects (ACPI_TYPE_ANY
, ACPI_DISPLAY_OBJECTS
, MaxDepth
,
851 ACPI_OWNER_ID_MAX
, SearchHandle
);