1 /******************************************************************************
3 * Module Name: nsdump - table dumping routines for debug
6 *****************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2003, 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 *****************************************************************************/
117 /* $DragonFly: src/sys/contrib/dev/acpica/Attic/nsdump.c,v 1.1 2003/09/24 03:32:16 drhodus Exp $ */
122 #include "acnamesp.h"
123 #include "acparser.h"
126 #define _COMPONENT ACPI_NAMESPACE
127 ACPI_MODULE_NAME ("nsdump")
129 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
132 /*******************************************************************************
134 * FUNCTION: AcpiNsPrintPathname
136 * PARAMETERS: NumSegment - Number of ACPI name segments
137 * Pathname - The compressed (internal) path
139 * DESCRIPTION: Print an object's full namespace pathname
141 ******************************************************************************/
144 AcpiNsPrintPathname (
148 ACPI_FUNCTION_NAME ("NsPrintPathname");
151 if (!(AcpiDbgLevel & ACPI_LV_NAMES) || !(AcpiDbgLayer & ACPI_NAMESPACE))
156 /* Print the entire name */
158 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "["));
162 AcpiOsPrintf ("%4.4s", Pathname);
163 Pathname += ACPI_NAME_SIZE;
172 AcpiOsPrintf ("]\n");
176 /*******************************************************************************
178 * FUNCTION: AcpiNsDumpPathname
180 * PARAMETERS: Handle - Object
181 * Msg - Prefix message
182 * Level - Desired debug level
183 * Component - Caller's component ID
185 * DESCRIPTION: Print an object's full namespace pathname
186 * Manages allocation/freeing of a pathname buffer
188 ******************************************************************************/
198 ACPI_FUNCTION_TRACE ("NsDumpPathname");
201 /* Do this only if the requested debug level and component are enabled */
203 if (!(AcpiDbgLevel & Level) || !(AcpiDbgLayer & Component))
208 /* Convert handle to a full pathname and print it (with supplied message) */
210 AcpiNsPrintNodePathname (Handle, Msg);
216 /*******************************************************************************
218 * FUNCTION: AcpiNsDumpOneObject
220 * PARAMETERS: Handle - Node to be dumped
221 * Level - Nesting level of the handle
222 * Context - Passed into WalkNamespace
224 * DESCRIPTION: Dump a single Node
225 * This procedure is a UserFunction called by AcpiNsWalkNamespace.
227 ******************************************************************************/
230 AcpiNsDumpOneObject (
231 ACPI_HANDLE ObjHandle,
236 ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context;
237 ACPI_NAMESPACE_NODE *ThisNode;
238 ACPI_OPERAND_OBJECT *ObjDesc = NULL;
239 ACPI_OBJECT_TYPE ObjType;
240 ACPI_OBJECT_TYPE Type;
246 ACPI_FUNCTION_NAME ("NsDumpOneObject");
249 /* Is output enabled? */
251 if (!(AcpiDbgLevel & Info->DebugLevel))
258 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n"));
262 ThisNode = AcpiNsMapHandleToNode (ObjHandle);
263 Type = ThisNode->Type;
265 /* Check if the owner matches */
267 if ((Info->OwnerId != ACPI_UINT32_MAX) &&
268 (Info->OwnerId != ThisNode->OwnerId))
273 /* Indent the object according to the level */
275 AcpiOsPrintf ("%2d%*s", (UINT32) Level - 1, (int) Level * 2, " ");
277 /* Check the node type and name */
279 if (Type > ACPI_TYPE_LOCAL_MAX)
281 ACPI_REPORT_WARNING (("Invalid ACPI Type %08X\n", Type));
284 if (!AcpiUtValidAcpiName (ThisNode->Name.Integer))
286 ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n", ThisNode->Name.Integer));
290 * Now we can print out the pertinent information
292 AcpiOsPrintf ("%4.4s %-12s %p ",
293 ThisNode->Name.Ascii, AcpiUtGetTypeName (Type), ThisNode);
295 DbgLevel = AcpiDbgLevel;
297 ObjDesc = AcpiNsGetAttachedObject (ThisNode);
298 AcpiDbgLevel = DbgLevel;
300 switch (Info->DisplayType)
302 case ACPI_DISPLAY_SUMMARY:
306 /* No attached object, we are done */
314 case ACPI_TYPE_PROCESSOR:
316 AcpiOsPrintf ("ID %X Len %.4X Addr %p\n",
317 ObjDesc->Processor.ProcId,
318 ObjDesc->Processor.Length,
319 (char *) ObjDesc->Processor.Address);
323 case ACPI_TYPE_DEVICE:
325 AcpiOsPrintf ("Notify object: %p", ObjDesc);
329 case ACPI_TYPE_METHOD:
331 AcpiOsPrintf ("Args %X Len %.4X Aml %p\n",
332 (UINT32) ObjDesc->Method.ParamCount,
333 ObjDesc->Method.AmlLength,
334 ObjDesc->Method.AmlStart);
338 case ACPI_TYPE_INTEGER:
340 AcpiOsPrintf ("= %8.8X%8.8X\n",
341 ACPI_HIDWORD (ObjDesc->Integer.Value),
342 ACPI_LODWORD (ObjDesc->Integer.Value));
346 case ACPI_TYPE_PACKAGE:
348 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
350 AcpiOsPrintf ("Elements %.2X\n",
351 ObjDesc->Package.Count);
355 AcpiOsPrintf ("[Length not yet evaluated]\n");
360 case ACPI_TYPE_BUFFER:
362 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
364 AcpiOsPrintf ("Len %.2X",
365 ObjDesc->Buffer.Length);
367 /* Dump some of the buffer */
369 if (ObjDesc->Buffer.Length > 0)
372 for (i = 0; (i < ObjDesc->Buffer.Length && i < 12); i++)
374 AcpiOsPrintf (" %.2hX", ObjDesc->Buffer.Pointer[i]);
381 AcpiOsPrintf ("[Length not yet evaluated]\n");
386 case ACPI_TYPE_STRING:
388 AcpiOsPrintf ("Len %.2X ", ObjDesc->String.Length);
389 AcpiUtPrintString (ObjDesc->String.Pointer, 32);
394 case ACPI_TYPE_REGION:
396 AcpiOsPrintf ("[%s]", AcpiUtGetRegionName (ObjDesc->Region.SpaceId));
397 if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
399 AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n",
400 ACPI_HIDWORD (ObjDesc->Region.Address),
401 ACPI_LODWORD (ObjDesc->Region.Address),
402 ObjDesc->Region.Length);
406 AcpiOsPrintf (" [Address/Length not yet evaluated]\n");
411 case ACPI_TYPE_LOCAL_REFERENCE:
413 AcpiOsPrintf ("[%s]\n",
414 AcpiPsGetOpcodeName (ObjDesc->Reference.Opcode));
418 case ACPI_TYPE_BUFFER_FIELD:
420 if (ObjDesc->BufferField.BufferObj &&
421 ObjDesc->BufferField.BufferObj->Buffer.Node)
423 AcpiOsPrintf ("Buf [%4.4s]",
424 ObjDesc->BufferField.BufferObj->Buffer.Node->Name.Ascii);
429 case ACPI_TYPE_LOCAL_REGION_FIELD:
431 AcpiOsPrintf ("Rgn [%4.4s]",
432 ObjDesc->CommonField.RegionObj->Region.Node->Name.Ascii);
436 case ACPI_TYPE_LOCAL_BANK_FIELD:
438 AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]",
439 ObjDesc->CommonField.RegionObj->Region.Node->Name.Ascii,
440 ObjDesc->BankField.BankObj->CommonField.Node->Name.Ascii);
444 case ACPI_TYPE_LOCAL_INDEX_FIELD:
446 AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]",
447 ObjDesc->IndexField.IndexObj->CommonField.Node->Name.Ascii,
448 ObjDesc->IndexField.DataObj->CommonField.Node->Name.Ascii);
452 case ACPI_TYPE_LOCAL_ALIAS:
454 AcpiOsPrintf ("Target %4.4s (%p)\n", ((ACPI_NAMESPACE_NODE *) ObjDesc)->Name.Ascii, ObjDesc);
459 AcpiOsPrintf ("Object %p\n", ObjDesc);
463 /* Common field handling */
467 case ACPI_TYPE_BUFFER_FIELD:
468 case ACPI_TYPE_LOCAL_REGION_FIELD:
469 case ACPI_TYPE_LOCAL_BANK_FIELD:
470 case ACPI_TYPE_LOCAL_INDEX_FIELD:
472 AcpiOsPrintf (" Off %.2X Len %.2X Acc %.2hd\n",
473 (ObjDesc->CommonField.BaseByteOffset * 8)
474 + ObjDesc->CommonField.StartFieldBitOffset,
475 ObjDesc->CommonField.BitLength,
476 ObjDesc->CommonField.AccessByteWidth);
485 case ACPI_DISPLAY_OBJECTS:
487 AcpiOsPrintf ("O:%p", ObjDesc);
490 /* No attached object, we are done */
496 AcpiOsPrintf ("(R%d)",
497 ObjDesc->Common.ReferenceCount);
501 case ACPI_TYPE_METHOD:
503 /* Name is a Method and its AML offset/length are set */
505 AcpiOsPrintf (" M:%p-%X\n", ObjDesc->Method.AmlStart,
506 ObjDesc->Method.AmlLength);
509 case ACPI_TYPE_INTEGER:
511 AcpiOsPrintf (" N:%X%X\n", ACPI_HIDWORD(ObjDesc->Integer.Value),
512 ACPI_LODWORD(ObjDesc->Integer.Value));
515 case ACPI_TYPE_STRING:
517 AcpiOsPrintf (" S:%p-%X\n", ObjDesc->String.Pointer,
518 ObjDesc->String.Length);
521 case ACPI_TYPE_BUFFER:
523 AcpiOsPrintf (" B:%p-%X\n", ObjDesc->Buffer.Pointer,
524 ObjDesc->Buffer.Length);
540 /* If debug turned off, done */
542 if (!(AcpiDbgLevel & ACPI_LV_VALUES))
548 /* If there is an attached object, display it */
550 DbgLevel = AcpiDbgLevel;
552 ObjDesc = AcpiNsGetAttachedObject (ThisNode);
553 AcpiDbgLevel = DbgLevel;
555 /* Dump attached objects */
559 ObjType = ACPI_TYPE_INVALID;
560 AcpiOsPrintf (" Attached Object %p: ", ObjDesc);
562 /* Decode the type of attached object and dump the contents */
564 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
566 case ACPI_DESC_TYPE_NAMED:
568 AcpiOsPrintf ("(Ptr to Node)\n");
569 BytesToDump = sizeof (ACPI_NAMESPACE_NODE);
573 case ACPI_DESC_TYPE_OPERAND:
575 ObjType = ACPI_GET_OBJECT_TYPE (ObjDesc);
577 if (ObjType > ACPI_TYPE_LOCAL_MAX)
579 AcpiOsPrintf ("(Ptr to ACPI Object type %X [UNKNOWN])\n", ObjType);
584 AcpiOsPrintf ("(Ptr to ACPI Object type %s, %X)\n",
585 AcpiUtGetTypeName (ObjType), ObjType);
586 BytesToDump = sizeof (ACPI_OPERAND_OBJECT);
593 AcpiOsPrintf ("(String or Buffer ptr - not an object descriptor)\n");
598 ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
600 /* If value is NOT an internal object, we are done */
602 if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
608 * Valid object, get the pointer to next level, if any
612 case ACPI_TYPE_STRING:
613 ObjDesc = (void *) ObjDesc->String.Pointer;
616 case ACPI_TYPE_BUFFER:
617 ObjDesc = (void *) ObjDesc->Buffer.Pointer;
620 case ACPI_TYPE_BUFFER_FIELD:
621 ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->BufferField.BufferObj;
624 case ACPI_TYPE_PACKAGE:
625 ObjDesc = (void *) ObjDesc->Package.Elements;
628 case ACPI_TYPE_METHOD:
629 ObjDesc = (void *) ObjDesc->Method.AmlStart;
632 case ACPI_TYPE_LOCAL_REGION_FIELD:
633 ObjDesc = (void *) ObjDesc->Field.RegionObj;
636 case ACPI_TYPE_LOCAL_BANK_FIELD:
637 ObjDesc = (void *) ObjDesc->BankField.RegionObj;
640 case ACPI_TYPE_LOCAL_INDEX_FIELD:
641 ObjDesc = (void *) ObjDesc->IndexField.IndexObj;
648 ObjType = ACPI_TYPE_INVALID; /* Terminate loop after next pass */
657 /*******************************************************************************
659 * FUNCTION: AcpiNsDumpObjects
661 * PARAMETERS: Type - Object type to be dumped
662 * MaxDepth - Maximum depth of dump. Use ACPI_UINT32_MAX
663 * for an effectively unlimited depth.
664 * OwnerId - Dump only objects owned by this ID. Use
665 * ACPI_UINT32_MAX to match all owners.
666 * StartHandle - Where in namespace to start/end search
668 * DESCRIPTION: Dump typed objects within the loaded namespace.
669 * Uses AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject.
671 ******************************************************************************/
675 ACPI_OBJECT_TYPE Type,
679 ACPI_HANDLE StartHandle)
684 ACPI_FUNCTION_ENTRY ();
687 Info.DebugLevel = ACPI_LV_TABLES;
688 Info.OwnerId = OwnerId;
689 Info.DisplayType = DisplayType;
692 (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
693 ACPI_NS_WALK_NO_UNLOCK, AcpiNsDumpOneObject,
694 (void *) &Info, NULL);
698 /*******************************************************************************
700 * FUNCTION: AcpiNsDumpTables
702 * PARAMETERS: SearchBase - Root of subtree to be dumped, or
703 * NS_ALL to dump the entire namespace
704 * MaxDepth - Maximum depth of dump. Use INT_MAX
705 * for an effectively unlimited depth.
707 * DESCRIPTION: Dump the name space, or a portion of it.
709 ******************************************************************************/
713 ACPI_HANDLE SearchBase,
716 ACPI_HANDLE SearchHandle = SearchBase;
719 ACPI_FUNCTION_TRACE ("NsDumpTables");
722 if (!AcpiGbl_RootNode)
725 * If the name space has not been initialized,
726 * there is nothing to dump.
728 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "namespace not initialized!\n"));
732 if (ACPI_NS_ALL == SearchBase)
734 /* entire namespace */
736 SearchHandle = AcpiGbl_RootNode;
737 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n"));
741 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, MaxDepth,
742 ACPI_UINT32_MAX, SearchHandle);
747 /*******************************************************************************
749 * FUNCTION: AcpiNsDumpEntry
751 * PARAMETERS: Handle - Node to be dumped
752 * DebugLevel - Output level
754 * DESCRIPTION: Dump a single Node
756 ******************************************************************************/
766 ACPI_FUNCTION_ENTRY ();
769 Info.DebugLevel = DebugLevel;
770 Info.OwnerId = ACPI_UINT32_MAX;
771 Info.DisplayType = ACPI_DISPLAY_SUMMARY;
773 (void) AcpiNsDumpOneObject (Handle, 1, &Info, NULL);