1 /******************************************************************************
3 * Module Name: nsdump - table dumping routines for debug
6 *****************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2007, Intel Corp.
13 * All rights reserved.
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
27 * make derivatives, distribute, use and display any portion of the Covered
28 * Code in any form, with the right to sublicense such rights; and
30 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
31 * license (with the right to sublicense), under only those claims of Intel
32 * patents that are infringed by the Original Intel Code, to make, use, sell,
33 * offer to sell, and import the Covered Code and derivative works thereof
34 * solely to the minimum extent necessary to exercise the above copyright
35 * license, and in no event shall the patent license extend to any additions
36 * to or modifications of the Original Intel Code. No other license or right
37 * is granted directly or by implication, estoppel or otherwise;
39 * The above copyright and patent license is granted only if the following
44 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
45 * Redistribution of source code of any substantial portion of the Covered
46 * Code or modification with rights to further distribute source must include
47 * the above Copyright Notice, the above License, this list of Conditions,
48 * and the following Disclaimer and Export Compliance provision. In addition,
49 * Licensee must cause all Covered Code to which Licensee contributes to
50 * contain a file documenting the changes Licensee made to create that Covered
51 * Code and the date of any change. Licensee must include in that file the
52 * documentation of any changes made by any predecessor Licensee. Licensee
53 * must include a prominent statement that the modification is derived,
54 * directly or indirectly, from Original Intel Code.
56 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
57 * Redistribution of source code of any substantial portion of the Covered
58 * Code or modification without rights to further distribute source must
59 * include the following Disclaimer and Export Compliance provision in the
60 * documentation and/or other materials provided with distribution. In
61 * addition, Licensee may not authorize further sublicense of source of any
62 * portion of the Covered Code, and must include terms to the effect that the
63 * license from Licensee to its licensee is limited to the intellectual
64 * property embodied in the software Licensee provides to its licensee, and
65 * not to intellectual property embodied in modifications its licensee may
68 * 3.3. Redistribution of Executable. Redistribution in executable form of any
69 * substantial portion of the Covered Code or modification must reproduce the
70 * above Copyright Notice, and the following Disclaimer and Export Compliance
71 * provision in the documentation and/or other materials provided with the
74 * 3.4. Intel retains all right, title, and interest in and to the Original
77 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
78 * Intel shall be used in advertising or otherwise to promote the sale, use or
79 * other dealings in products derived from or relating to the Covered Code
80 * without prior written authorization from Intel.
82 * 4. Disclaimer and Export Compliance
84 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
85 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
86 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
87 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
88 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
89 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
92 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
93 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
94 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
95 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
96 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
97 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
98 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
101 * 4.3. Licensee shall not export, either directly or indirectly, any of this
102 * software or system incorporating such software without first obtaining any
103 * required license or other approval from the U. S. Department of Commerce or
104 * any other agency or department of the United States Government. In the
105 * event Licensee exports any such software from the United States or
106 * re-exports any such software from a foreign destination, Licensee shall
107 * ensure that the distribution and export/re-export of the software is in
108 * compliance with all laws, regulations, orders, or other restrictions of the
109 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
110 * any of its subsidiaries will export/re-export any technical data, process,
111 * software, or service, directly or indirectly, to any country for which the
112 * United States government or any agency thereof requires an export license,
113 * other governmental approval, or letter of assurance, without first obtaining
114 * such license, approval or letter.
116 *****************************************************************************/
120 #include <contrib/dev/acpica/acpi.h>
121 #include <contrib/dev/acpica/acnamesp.h>
122 #include <contrib/dev/acpica/acparser.h>
125 #define _COMPONENT ACPI_NAMESPACE
126 ACPI_MODULE_NAME ("nsdump")
128 /* Local prototypes */
130 #ifdef ACPI_OBSOLETE_FUNCTIONS
132 AcpiNsDumpRootDevices (
136 AcpiNsDumpOneDevice (
137 ACPI_HANDLE ObjHandle,
144 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
145 /*******************************************************************************
147 * FUNCTION: AcpiNsPrintPathname
149 * PARAMETERS: NumSegments - Number of ACPI name segments
150 * Pathname - The compressed (internal) path
154 * DESCRIPTION: Print an object's full namespace pathname
156 ******************************************************************************/
159 AcpiNsPrintPathname (
166 ACPI_FUNCTION_NAME (NsPrintPathname);
169 if (!(AcpiDbgLevel & ACPI_LV_NAMES) || !(AcpiDbgLayer & ACPI_NAMESPACE))
174 /* Print the entire name */
176 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "["));
180 for (i = 0; i < 4; i++)
182 ACPI_IS_PRINT (Pathname[i]) ?
183 AcpiOsPrintf ("%c", Pathname[i]) :
187 Pathname += ACPI_NAME_SIZE;
195 AcpiOsPrintf ("]\n");
199 /*******************************************************************************
201 * FUNCTION: AcpiNsDumpPathname
203 * PARAMETERS: Handle - Object
204 * Msg - Prefix message
205 * Level - Desired debug level
206 * Component - Caller's component ID
210 * DESCRIPTION: Print an object's full namespace pathname
211 * Manages allocation/freeing of a pathname buffer
213 ******************************************************************************/
223 ACPI_FUNCTION_TRACE (NsDumpPathname);
226 /* Do this only if the requested debug level and component are enabled */
228 if (!(AcpiDbgLevel & Level) || !(AcpiDbgLayer & Component))
233 /* Convert handle to a full pathname and print it (with supplied message) */
235 AcpiNsPrintNodePathname (Handle, Msg);
241 /*******************************************************************************
243 * FUNCTION: AcpiNsDumpOneObject
245 * PARAMETERS: ObjHandle - Node to be dumped
246 * Level - Nesting level of the handle
247 * Context - Passed into WalkNamespace
248 * ReturnValue - Not used
252 * DESCRIPTION: Dump a single Node
253 * This procedure is a UserFunction called by AcpiNsWalkNamespace.
255 ******************************************************************************/
258 AcpiNsDumpOneObject (
259 ACPI_HANDLE ObjHandle,
264 ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context;
265 ACPI_NAMESPACE_NODE *ThisNode;
266 ACPI_OPERAND_OBJECT *ObjDesc = NULL;
267 ACPI_OBJECT_TYPE ObjType;
268 ACPI_OBJECT_TYPE Type;
274 ACPI_FUNCTION_NAME (NsDumpOneObject);
277 /* Is output enabled? */
279 if (!(AcpiDbgLevel & Info->DebugLevel))
286 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n"));
290 ThisNode = AcpiNsMapHandleToNode (ObjHandle);
291 Type = ThisNode->Type;
293 /* Check if the owner matches */
295 if ((Info->OwnerId != ACPI_OWNER_ID_MAX) &&
296 (Info->OwnerId != ThisNode->OwnerId))
301 if (!(Info->DisplayType & ACPI_DISPLAY_SHORT))
303 /* Indent the object according to the level */
305 AcpiOsPrintf ("%2d%*s", (UINT32) Level - 1, (int) Level * 2, " ");
307 /* Check the node type and name */
309 if (Type > ACPI_TYPE_LOCAL_MAX)
311 ACPI_WARNING ((AE_INFO, "Invalid ACPI Object Type %08X", Type));
314 if (!AcpiUtValidAcpiName (ThisNode->Name.Integer))
316 ThisNode->Name.Integer = AcpiUtRepairName (ThisNode->Name.Ascii);
318 ACPI_WARNING ((AE_INFO, "Invalid ACPI Name %08X",
319 ThisNode->Name.Integer));
322 AcpiOsPrintf ("%4.4s", AcpiUtGetNodeName (ThisNode));
326 * Now we can print out the pertinent information
328 AcpiOsPrintf (" %-12s %p %2.2X ",
329 AcpiUtGetTypeName (Type), ThisNode, ThisNode->OwnerId);
331 DbgLevel = AcpiDbgLevel;
333 ObjDesc = AcpiNsGetAttachedObject (ThisNode);
334 AcpiDbgLevel = DbgLevel;
336 /* Temp nodes are those nodes created by a control method */
338 if (ThisNode->Flags & ANOBJ_TEMPORARY)
340 AcpiOsPrintf ("(T) ");
343 switch (Info->DisplayType & ACPI_DISPLAY_MASK)
345 case ACPI_DISPLAY_SUMMARY:
349 /* No attached object, we are done */
357 case ACPI_TYPE_PROCESSOR:
359 AcpiOsPrintf ("ID %X Len %.4X Addr %p\n",
360 ObjDesc->Processor.ProcId, ObjDesc->Processor.Length,
361 (char *) ObjDesc->Processor.Address);
365 case ACPI_TYPE_DEVICE:
367 AcpiOsPrintf ("Notify Object: %p\n", ObjDesc);
371 case ACPI_TYPE_METHOD:
373 AcpiOsPrintf ("Args %X Len %.4X Aml %p\n",
374 (UINT32) ObjDesc->Method.ParamCount,
375 ObjDesc->Method.AmlLength, ObjDesc->Method.AmlStart);
379 case ACPI_TYPE_INTEGER:
381 AcpiOsPrintf ("= %8.8X%8.8X\n",
382 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
386 case ACPI_TYPE_PACKAGE:
388 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
390 AcpiOsPrintf ("Elements %.2X\n",
391 ObjDesc->Package.Count);
395 AcpiOsPrintf ("[Length not yet evaluated]\n");
400 case ACPI_TYPE_BUFFER:
402 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
404 AcpiOsPrintf ("Len %.2X",
405 ObjDesc->Buffer.Length);
407 /* Dump some of the buffer */
409 if (ObjDesc->Buffer.Length > 0)
412 for (i = 0; (i < ObjDesc->Buffer.Length && i < 12); i++)
414 AcpiOsPrintf (" %.2hX", ObjDesc->Buffer.Pointer[i]);
421 AcpiOsPrintf ("[Length not yet evaluated]\n");
426 case ACPI_TYPE_STRING:
428 AcpiOsPrintf ("Len %.2X ", ObjDesc->String.Length);
429 AcpiUtPrintString (ObjDesc->String.Pointer, 32);
434 case ACPI_TYPE_REGION:
436 AcpiOsPrintf ("[%s]",
437 AcpiUtGetRegionName (ObjDesc->Region.SpaceId));
438 if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
440 AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n",
441 ACPI_FORMAT_UINT64 (ObjDesc->Region.Address),
442 ObjDesc->Region.Length);
446 AcpiOsPrintf (" [Address/Length not yet evaluated]\n");
451 case ACPI_TYPE_LOCAL_REFERENCE:
453 AcpiOsPrintf ("[%s]\n",
454 AcpiPsGetOpcodeName (ObjDesc->Reference.Opcode));
458 case ACPI_TYPE_BUFFER_FIELD:
460 if (ObjDesc->BufferField.BufferObj &&
461 ObjDesc->BufferField.BufferObj->Buffer.Node)
463 AcpiOsPrintf ("Buf [%4.4s]",
464 AcpiUtGetNodeName (ObjDesc->BufferField.BufferObj->Buffer.Node));
469 case ACPI_TYPE_LOCAL_REGION_FIELD:
471 AcpiOsPrintf ("Rgn [%4.4s]",
472 AcpiUtGetNodeName (ObjDesc->CommonField.RegionObj->Region.Node));
476 case ACPI_TYPE_LOCAL_BANK_FIELD:
478 AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]",
479 AcpiUtGetNodeName (ObjDesc->CommonField.RegionObj->Region.Node),
480 AcpiUtGetNodeName (ObjDesc->BankField.BankObj->CommonField.Node));
484 case ACPI_TYPE_LOCAL_INDEX_FIELD:
486 AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]",
487 AcpiUtGetNodeName (ObjDesc->IndexField.IndexObj->CommonField.Node),
488 AcpiUtGetNodeName (ObjDesc->IndexField.DataObj->CommonField.Node));
492 case ACPI_TYPE_LOCAL_ALIAS:
493 case ACPI_TYPE_LOCAL_METHOD_ALIAS:
495 AcpiOsPrintf ("Target %4.4s (%p)\n",
496 AcpiUtGetNodeName (ObjDesc), ObjDesc);
501 AcpiOsPrintf ("Object %p\n", ObjDesc);
505 /* Common field handling */
509 case ACPI_TYPE_BUFFER_FIELD:
510 case ACPI_TYPE_LOCAL_REGION_FIELD:
511 case ACPI_TYPE_LOCAL_BANK_FIELD:
512 case ACPI_TYPE_LOCAL_INDEX_FIELD:
514 AcpiOsPrintf (" Off %.3X Len %.2X Acc %.2hd\n",
515 (ObjDesc->CommonField.BaseByteOffset * 8)
516 + ObjDesc->CommonField.StartFieldBitOffset,
517 ObjDesc->CommonField.BitLength,
518 ObjDesc->CommonField.AccessByteWidth);
527 case ACPI_DISPLAY_OBJECTS:
529 AcpiOsPrintf ("O:%p", ObjDesc);
532 /* No attached object, we are done */
538 AcpiOsPrintf ("(R%d)", ObjDesc->Common.ReferenceCount);
542 case ACPI_TYPE_METHOD:
544 /* Name is a Method and its AML offset/length are set */
546 AcpiOsPrintf (" M:%p-%X\n", ObjDesc->Method.AmlStart,
547 ObjDesc->Method.AmlLength);
550 case ACPI_TYPE_INTEGER:
552 AcpiOsPrintf (" I:%8.8X8.8%X\n",
553 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
556 case ACPI_TYPE_STRING:
558 AcpiOsPrintf (" S:%p-%X\n", ObjDesc->String.Pointer,
559 ObjDesc->String.Length);
562 case ACPI_TYPE_BUFFER:
564 AcpiOsPrintf (" B:%p-%X\n", ObjDesc->Buffer.Pointer,
565 ObjDesc->Buffer.Length);
581 /* If debug turned off, done */
583 if (!(AcpiDbgLevel & ACPI_LV_VALUES))
589 /* If there is an attached object, display it */
591 DbgLevel = AcpiDbgLevel;
593 ObjDesc = AcpiNsGetAttachedObject (ThisNode);
594 AcpiDbgLevel = DbgLevel;
596 /* Dump attached objects */
600 ObjType = ACPI_TYPE_INVALID;
601 AcpiOsPrintf ("Attached Object %p: ", ObjDesc);
603 /* Decode the type of attached object and dump the contents */
605 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
607 case ACPI_DESC_TYPE_NAMED:
609 AcpiOsPrintf ("(Ptr to Node)\n");
610 BytesToDump = sizeof (ACPI_NAMESPACE_NODE);
611 ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
614 case ACPI_DESC_TYPE_OPERAND:
616 ObjType = ACPI_GET_OBJECT_TYPE (ObjDesc);
618 if (ObjType > ACPI_TYPE_LOCAL_MAX)
620 AcpiOsPrintf ("(Ptr to ACPI Object type %X [UNKNOWN])\n",
626 AcpiOsPrintf ("(Ptr to ACPI Object type %X [%s])\n",
627 ObjType, AcpiUtGetTypeName (ObjType));
628 BytesToDump = sizeof (ACPI_OPERAND_OBJECT);
631 ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
639 /* If value is NOT an internal object, we are done */
641 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.
715 * Uses 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);