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 *****************************************************************************/
121 #include "acnamesp.h"
122 #include "acparser.h"
125 #define _COMPONENT ACPI_NAMESPACE
126 ACPI_MODULE_NAME ("nsdump")
129 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
131 /*******************************************************************************
133 * FUNCTION: AcpiNsPrintPathname
135 * PARAMETERS: NumSegment - Number of ACPI name segments
136 * Pathname - The compressed (internal) path
138 * DESCRIPTION: Print an object's full namespace pathname
140 ******************************************************************************/
143 AcpiNsPrintPathname (
147 ACPI_FUNCTION_NAME ("NsPrintPathname");
150 if (!(AcpiDbgLevel & ACPI_LV_NAMES) || !(AcpiDbgLayer & ACPI_NAMESPACE))
155 /* Print the entire name */
157 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "["));
161 AcpiOsPrintf ("%4.4s", Pathname);
162 Pathname += ACPI_NAME_SIZE;
171 AcpiOsPrintf ("]\n");
175 /*******************************************************************************
177 * FUNCTION: AcpiNsDumpPathname
179 * PARAMETERS: Handle - Object
180 * Msg - Prefix message
181 * Level - Desired debug level
182 * Component - Caller's component ID
184 * DESCRIPTION: Print an object's full namespace pathname
185 * Manages allocation/freeing of a pathname buffer
187 ******************************************************************************/
197 ACPI_FUNCTION_TRACE ("NsDumpPathname");
200 /* Do this only if the requested debug level and component are enabled */
202 if (!(AcpiDbgLevel & Level) || !(AcpiDbgLayer & Component))
207 /* Convert handle to a full pathname and print it (with supplied message) */
209 AcpiNsPrintNodePathname (Handle, Msg);
215 /*******************************************************************************
217 * FUNCTION: AcpiNsDumpOneObject
219 * PARAMETERS: Handle - Node to be dumped
220 * Level - Nesting level of the handle
221 * Context - Passed into WalkNamespace
223 * DESCRIPTION: Dump a single Node
224 * This procedure is a UserFunction called by AcpiNsWalkNamespace.
226 ******************************************************************************/
229 AcpiNsDumpOneObject (
230 ACPI_HANDLE ObjHandle,
235 ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context;
236 ACPI_NAMESPACE_NODE *ThisNode;
237 ACPI_OPERAND_OBJECT *ObjDesc = NULL;
238 ACPI_OBJECT_TYPE ObjType;
239 ACPI_OBJECT_TYPE Type;
245 ACPI_FUNCTION_NAME ("NsDumpOneObject");
248 /* Is output enabled? */
250 if (!(AcpiDbgLevel & Info->DebugLevel))
257 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n"));
261 ThisNode = AcpiNsMapHandleToNode (ObjHandle);
262 Type = ThisNode->Type;
264 /* Check if the owner matches */
266 if ((Info->OwnerId != ACPI_UINT32_MAX) &&
267 (Info->OwnerId != ThisNode->OwnerId))
272 /* Indent the object according to the level */
274 AcpiOsPrintf ("%2d%*s", (UINT32) Level - 1, (int) Level * 2, " ");
276 /* Check the node type and name */
278 if (Type > ACPI_TYPE_LOCAL_MAX)
280 ACPI_REPORT_WARNING (("Invalid ACPI Type %08X\n", Type));
283 if (!AcpiUtValidAcpiName (ThisNode->Name.Integer))
285 ACPI_REPORT_WARNING (("Invalid ACPI Name %08X\n", ThisNode->Name.Integer));
289 * Now we can print out the pertinent information
291 AcpiOsPrintf ("%4.4s %-12s %p ",
292 AcpiUtGetNodeName (ThisNode), AcpiUtGetTypeName (Type), ThisNode);
294 DbgLevel = AcpiDbgLevel;
296 ObjDesc = AcpiNsGetAttachedObject (ThisNode);
297 AcpiDbgLevel = DbgLevel;
299 switch (Info->DisplayType)
301 case ACPI_DISPLAY_SUMMARY:
305 /* No attached object, we are done */
313 case ACPI_TYPE_PROCESSOR:
315 AcpiOsPrintf ("ID %X Len %.4X Addr %p\n",
316 ObjDesc->Processor.ProcId,
317 ObjDesc->Processor.Length,
318 (char *) ObjDesc->Processor.Address);
322 case ACPI_TYPE_DEVICE:
324 AcpiOsPrintf ("Notify Object: %p\n", ObjDesc);
328 case ACPI_TYPE_METHOD:
330 AcpiOsPrintf ("Args %X Len %.4X Aml %p\n",
331 (UINT32) ObjDesc->Method.ParamCount,
332 ObjDesc->Method.AmlLength,
333 ObjDesc->Method.AmlStart);
337 case ACPI_TYPE_INTEGER:
339 AcpiOsPrintf ("= %8.8X%8.8X\n",
340 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
344 case ACPI_TYPE_PACKAGE:
346 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
348 AcpiOsPrintf ("Elements %.2X\n",
349 ObjDesc->Package.Count);
353 AcpiOsPrintf ("[Length not yet evaluated]\n");
358 case ACPI_TYPE_BUFFER:
360 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
362 AcpiOsPrintf ("Len %.2X",
363 ObjDesc->Buffer.Length);
365 /* Dump some of the buffer */
367 if (ObjDesc->Buffer.Length > 0)
370 for (i = 0; (i < ObjDesc->Buffer.Length && i < 12); i++)
372 AcpiOsPrintf (" %.2hX", ObjDesc->Buffer.Pointer[i]);
379 AcpiOsPrintf ("[Length not yet evaluated]\n");
384 case ACPI_TYPE_STRING:
386 AcpiOsPrintf ("Len %.2X ", ObjDesc->String.Length);
387 AcpiUtPrintString (ObjDesc->String.Pointer, 32);
392 case ACPI_TYPE_REGION:
394 AcpiOsPrintf ("[%s]", AcpiUtGetRegionName (ObjDesc->Region.SpaceId));
395 if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
397 AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n",
398 ACPI_FORMAT_UINT64 (ObjDesc->Region.Address),
399 ObjDesc->Region.Length);
403 AcpiOsPrintf (" [Address/Length not yet evaluated]\n");
408 case ACPI_TYPE_LOCAL_REFERENCE:
410 AcpiOsPrintf ("[%s]\n",
411 AcpiPsGetOpcodeName (ObjDesc->Reference.Opcode));
415 case ACPI_TYPE_BUFFER_FIELD:
417 if (ObjDesc->BufferField.BufferObj &&
418 ObjDesc->BufferField.BufferObj->Buffer.Node)
420 AcpiOsPrintf ("Buf [%4.4s]",
421 AcpiUtGetNodeName (ObjDesc->BufferField.BufferObj->Buffer.Node));
426 case ACPI_TYPE_LOCAL_REGION_FIELD:
428 AcpiOsPrintf ("Rgn [%4.4s]",
429 AcpiUtGetNodeName (ObjDesc->CommonField.RegionObj->Region.Node));
433 case ACPI_TYPE_LOCAL_BANK_FIELD:
435 AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]",
436 AcpiUtGetNodeName (ObjDesc->CommonField.RegionObj->Region.Node),
437 AcpiUtGetNodeName (ObjDesc->BankField.BankObj->CommonField.Node));
441 case ACPI_TYPE_LOCAL_INDEX_FIELD:
443 AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]",
444 AcpiUtGetNodeName (ObjDesc->IndexField.IndexObj->CommonField.Node),
445 AcpiUtGetNodeName (ObjDesc->IndexField.DataObj->CommonField.Node));
449 case ACPI_TYPE_LOCAL_ALIAS:
451 AcpiOsPrintf ("Target %4.4s (%p)\n", AcpiUtGetNodeName (ObjDesc), ObjDesc);
456 AcpiOsPrintf ("Object %p\n", ObjDesc);
460 /* Common field handling */
464 case ACPI_TYPE_BUFFER_FIELD:
465 case ACPI_TYPE_LOCAL_REGION_FIELD:
466 case ACPI_TYPE_LOCAL_BANK_FIELD:
467 case ACPI_TYPE_LOCAL_INDEX_FIELD:
469 AcpiOsPrintf (" Off %.3X Len %.2X Acc %.2hd\n",
470 (ObjDesc->CommonField.BaseByteOffset * 8)
471 + ObjDesc->CommonField.StartFieldBitOffset,
472 ObjDesc->CommonField.BitLength,
473 ObjDesc->CommonField.AccessByteWidth);
482 case ACPI_DISPLAY_OBJECTS:
484 AcpiOsPrintf ("O:%p", ObjDesc);
487 /* No attached object, we are done */
493 AcpiOsPrintf ("(R%d)",
494 ObjDesc->Common.ReferenceCount);
498 case ACPI_TYPE_METHOD:
500 /* Name is a Method and its AML offset/length are set */
502 AcpiOsPrintf (" M:%p-%X\n", ObjDesc->Method.AmlStart,
503 ObjDesc->Method.AmlLength);
506 case ACPI_TYPE_INTEGER:
508 AcpiOsPrintf (" I:%8.8X8.8%X\n",
509 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
512 case ACPI_TYPE_STRING:
514 AcpiOsPrintf (" S:%p-%X\n", ObjDesc->String.Pointer,
515 ObjDesc->String.Length);
518 case ACPI_TYPE_BUFFER:
520 AcpiOsPrintf (" B:%p-%X\n", ObjDesc->Buffer.Pointer,
521 ObjDesc->Buffer.Length);
537 /* If debug turned off, done */
539 if (!(AcpiDbgLevel & ACPI_LV_VALUES))
545 /* If there is an attached object, display it */
547 DbgLevel = AcpiDbgLevel;
549 ObjDesc = AcpiNsGetAttachedObject (ThisNode);
550 AcpiDbgLevel = DbgLevel;
552 /* Dump attached objects */
556 ObjType = ACPI_TYPE_INVALID;
557 AcpiOsPrintf (" Attached Object %p: ", ObjDesc);
559 /* Decode the type of attached object and dump the contents */
561 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
563 case ACPI_DESC_TYPE_NAMED:
565 AcpiOsPrintf ("(Ptr to Node)\n");
566 BytesToDump = sizeof (ACPI_NAMESPACE_NODE);
570 case ACPI_DESC_TYPE_OPERAND:
572 ObjType = ACPI_GET_OBJECT_TYPE (ObjDesc);
574 if (ObjType > ACPI_TYPE_LOCAL_MAX)
576 AcpiOsPrintf ("(Ptr to ACPI Object type %X [UNKNOWN])\n", ObjType);
581 AcpiOsPrintf ("(Ptr to ACPI Object type %s, %X)\n",
582 AcpiUtGetTypeName (ObjType), ObjType);
583 BytesToDump = sizeof (ACPI_OPERAND_OBJECT);
590 AcpiOsPrintf ("(String or Buffer ptr - not an object descriptor) [%s]\n",
591 AcpiUtGetDescriptorName (ObjDesc));
596 ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
598 /* If value is NOT an internal object, we are done */
600 if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
606 * Valid object, get the pointer to next level, if any
610 case ACPI_TYPE_STRING:
611 ObjDesc = (void *) ObjDesc->String.Pointer;
614 case ACPI_TYPE_BUFFER:
615 ObjDesc = (void *) ObjDesc->Buffer.Pointer;
618 case ACPI_TYPE_BUFFER_FIELD:
619 ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->BufferField.BufferObj;
622 case ACPI_TYPE_PACKAGE:
623 ObjDesc = (void *) ObjDesc->Package.Elements;
626 case ACPI_TYPE_METHOD:
627 ObjDesc = (void *) ObjDesc->Method.AmlStart;
630 case ACPI_TYPE_LOCAL_REGION_FIELD:
631 ObjDesc = (void *) ObjDesc->Field.RegionObj;
634 case ACPI_TYPE_LOCAL_BANK_FIELD:
635 ObjDesc = (void *) ObjDesc->BankField.RegionObj;
638 case ACPI_TYPE_LOCAL_INDEX_FIELD:
639 ObjDesc = (void *) ObjDesc->IndexField.IndexObj;
646 ObjType = ACPI_TYPE_INVALID; /* Terminate loop after next pass */
655 /*******************************************************************************
657 * FUNCTION: AcpiNsDumpObjects
659 * PARAMETERS: Type - Object type to be dumped
660 * MaxDepth - Maximum depth of dump. Use ACPI_UINT32_MAX
661 * for an effectively unlimited depth.
662 * OwnerId - Dump only objects owned by this ID. Use
663 * ACPI_UINT32_MAX to match all owners.
664 * StartHandle - Where in namespace to start/end search
666 * DESCRIPTION: Dump typed objects within the loaded namespace.
667 * Uses AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject.
669 ******************************************************************************/
673 ACPI_OBJECT_TYPE Type,
677 ACPI_HANDLE StartHandle)
682 ACPI_FUNCTION_ENTRY ();
685 Info.DebugLevel = ACPI_LV_TABLES;
686 Info.OwnerId = OwnerId;
687 Info.DisplayType = DisplayType;
689 (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
690 ACPI_NS_WALK_NO_UNLOCK, AcpiNsDumpOneObject,
691 (void *) &Info, NULL);
695 /*******************************************************************************
697 * FUNCTION: AcpiNsDumpTables
699 * PARAMETERS: SearchBase - Root of subtree to be dumped, or
700 * NS_ALL to dump the entire namespace
701 * MaxDepth - Maximum depth of dump. Use INT_MAX
702 * for an effectively unlimited depth.
704 * DESCRIPTION: Dump the name space, or a portion of it.
706 ******************************************************************************/
710 ACPI_HANDLE SearchBase,
713 ACPI_HANDLE SearchHandle = SearchBase;
716 ACPI_FUNCTION_TRACE ("NsDumpTables");
719 if (!AcpiGbl_RootNode)
722 * If the name space has not been initialized,
723 * there is nothing to dump.
725 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "namespace not initialized!\n"));
729 if (ACPI_NS_ALL == SearchBase)
731 /* entire namespace */
733 SearchHandle = AcpiGbl_RootNode;
734 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n"));
737 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, MaxDepth,
738 ACPI_UINT32_MAX, SearchHandle);
743 /*******************************************************************************
745 * FUNCTION: AcpiNsDumpEntry
747 * PARAMETERS: Handle - Node to be dumped
748 * DebugLevel - Output level
750 * DESCRIPTION: Dump a single Node
752 ******************************************************************************/
762 ACPI_FUNCTION_ENTRY ();
765 Info.DebugLevel = DebugLevel;
766 Info.OwnerId = ACPI_UINT32_MAX;
767 Info.DisplayType = ACPI_DISPLAY_SUMMARY;
769 (void) AcpiNsDumpOneObject (Handle, 1, &Info, NULL);