1 /******************************************************************************
3 * Module Name: nsdump - table dumping routines for debug
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2016, Intel Corp.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
50 #define _COMPONENT ACPI_NAMESPACE
51 ACPI_MODULE_NAME ("nsdump")
53 /* Local prototypes */
55 #ifdef ACPI_OBSOLETE_FUNCTIONS
57 AcpiNsDumpRootDevices (
62 ACPI_HANDLE ObjHandle,
69 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
72 AcpiNsDumpOneObjectPath (
73 ACPI_HANDLE ObjHandle,
80 ACPI_HANDLE ObjHandle,
86 /*******************************************************************************
88 * FUNCTION: AcpiNsPrintPathname
90 * PARAMETERS: NumSegments - Number of ACPI name segments
91 * Pathname - The compressed (internal) path
95 * DESCRIPTION: Print an object's full namespace pathname
97 ******************************************************************************/
100 AcpiNsPrintPathname (
107 ACPI_FUNCTION_NAME (NsPrintPathname);
110 /* Check if debug output enabled */
112 if (!ACPI_IS_DEBUG_ENABLED (ACPI_LV_NAMES, ACPI_NAMESPACE))
117 /* Print the entire name */
119 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "["));
123 for (i = 0; i < 4; i++)
125 isprint ((int) Pathname[i]) ?
126 AcpiOsPrintf ("%c", Pathname[i]) :
130 Pathname += ACPI_NAME_SIZE;
138 AcpiOsPrintf ("]\n");
142 /*******************************************************************************
144 * FUNCTION: AcpiNsDumpPathname
146 * PARAMETERS: Handle - Object
147 * Msg - Prefix message
148 * Level - Desired debug level
149 * Component - Caller's component ID
153 * DESCRIPTION: Print an object's full namespace pathname
154 * Manages allocation/freeing of a pathname buffer
156 ******************************************************************************/
166 ACPI_FUNCTION_TRACE (NsDumpPathname);
169 /* Do this only if the requested debug level and component are enabled */
171 if (!ACPI_IS_DEBUG_ENABLED (Level, Component))
176 /* Convert handle to a full pathname and print it (with supplied message) */
178 AcpiNsPrintNodePathname (Handle, Msg);
184 /*******************************************************************************
186 * FUNCTION: AcpiNsDumpOneObject
188 * PARAMETERS: ObjHandle - Node to be dumped
189 * Level - Nesting level of the handle
190 * Context - Passed into WalkNamespace
191 * ReturnValue - Not used
195 * DESCRIPTION: Dump a single Node
196 * This procedure is a UserFunction called by AcpiNsWalkNamespace.
198 ******************************************************************************/
201 AcpiNsDumpOneObject (
202 ACPI_HANDLE ObjHandle,
207 ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context;
208 ACPI_NAMESPACE_NODE *ThisNode;
209 ACPI_OPERAND_OBJECT *ObjDesc = NULL;
210 ACPI_OBJECT_TYPE ObjType;
211 ACPI_OBJECT_TYPE Type;
217 ACPI_FUNCTION_NAME (NsDumpOneObject);
220 /* Is output enabled? */
222 if (!(AcpiDbgLevel & Info->DebugLevel))
229 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n"));
233 ThisNode = AcpiNsValidateHandle (ObjHandle);
236 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Invalid object handle %p\n",
241 Type = ThisNode->Type;
243 /* Check if the owner matches */
245 if ((Info->OwnerId != ACPI_OWNER_ID_MAX) &&
246 (Info->OwnerId != ThisNode->OwnerId))
251 if (!(Info->DisplayType & ACPI_DISPLAY_SHORT))
253 /* Indent the object according to the level */
255 AcpiOsPrintf ("%2d%*s", (UINT32) Level - 1, (int) Level * 2, " ");
257 /* Check the node type and name */
259 if (Type > ACPI_TYPE_LOCAL_MAX)
261 ACPI_WARNING ((AE_INFO,
262 "Invalid ACPI Object Type 0x%08X", Type));
265 AcpiOsPrintf ("%4.4s", AcpiUtGetNodeName (ThisNode));
268 /* Now we can print out the pertinent information */
270 AcpiOsPrintf (" %-12s %p %2.2X ",
271 AcpiUtGetTypeName (Type), ThisNode, ThisNode->OwnerId);
273 DbgLevel = AcpiDbgLevel;
275 ObjDesc = AcpiNsGetAttachedObject (ThisNode);
276 AcpiDbgLevel = DbgLevel;
278 /* Temp nodes are those nodes created by a control method */
280 if (ThisNode->Flags & ANOBJ_TEMPORARY)
282 AcpiOsPrintf ("(T) ");
285 switch (Info->DisplayType & ACPI_DISPLAY_MASK)
287 case ACPI_DISPLAY_SUMMARY:
291 /* No attached object. Some types should always have an object */
295 case ACPI_TYPE_INTEGER:
296 case ACPI_TYPE_PACKAGE:
297 case ACPI_TYPE_BUFFER:
298 case ACPI_TYPE_STRING:
299 case ACPI_TYPE_METHOD:
301 AcpiOsPrintf ("<No attached object>");
315 case ACPI_TYPE_PROCESSOR:
317 AcpiOsPrintf ("ID %02X Len %02X Addr %8.8X%8.8X\n",
318 ObjDesc->Processor.ProcId, ObjDesc->Processor.Length,
319 ACPI_FORMAT_UINT64 (ObjDesc->Processor.Address));
322 case ACPI_TYPE_DEVICE:
324 AcpiOsPrintf ("Notify Object: %p\n", ObjDesc);
327 case ACPI_TYPE_METHOD:
329 AcpiOsPrintf ("Args %X Len %.4X Aml %p\n",
330 (UINT32) ObjDesc->Method.ParamCount,
331 ObjDesc->Method.AmlLength, ObjDesc->Method.AmlStart);
334 case ACPI_TYPE_INTEGER:
336 AcpiOsPrintf ("= %8.8X%8.8X\n",
337 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
340 case ACPI_TYPE_PACKAGE:
342 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
344 AcpiOsPrintf ("Elements %.2X\n",
345 ObjDesc->Package.Count);
349 AcpiOsPrintf ("[Length not yet evaluated]\n");
353 case ACPI_TYPE_BUFFER:
355 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
357 AcpiOsPrintf ("Len %.2X",
358 ObjDesc->Buffer.Length);
360 /* Dump some of the buffer */
362 if (ObjDesc->Buffer.Length > 0)
365 for (i = 0; (i < ObjDesc->Buffer.Length && i < 12); i++)
367 AcpiOsPrintf (" %.2hX", ObjDesc->Buffer.Pointer[i]);
374 AcpiOsPrintf ("[Length not yet evaluated]\n");
378 case ACPI_TYPE_STRING:
380 AcpiOsPrintf ("Len %.2X ", ObjDesc->String.Length);
381 AcpiUtPrintString (ObjDesc->String.Pointer, 32);
385 case ACPI_TYPE_REGION:
387 AcpiOsPrintf ("[%s]",
388 AcpiUtGetRegionName (ObjDesc->Region.SpaceId));
389 if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
391 AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n",
392 ACPI_FORMAT_UINT64 (ObjDesc->Region.Address),
393 ObjDesc->Region.Length);
397 AcpiOsPrintf (" [Address/Length not yet evaluated]\n");
401 case ACPI_TYPE_LOCAL_REFERENCE:
403 AcpiOsPrintf ("[%s]\n", AcpiUtGetReferenceName (ObjDesc));
406 case ACPI_TYPE_BUFFER_FIELD:
408 if (ObjDesc->BufferField.BufferObj &&
409 ObjDesc->BufferField.BufferObj->Buffer.Node)
411 AcpiOsPrintf ("Buf [%4.4s]",
413 ObjDesc->BufferField.BufferObj->Buffer.Node));
417 case ACPI_TYPE_LOCAL_REGION_FIELD:
419 AcpiOsPrintf ("Rgn [%4.4s]",
421 ObjDesc->CommonField.RegionObj->Region.Node));
424 case ACPI_TYPE_LOCAL_BANK_FIELD:
426 AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]",
428 ObjDesc->CommonField.RegionObj->Region.Node),
430 ObjDesc->BankField.BankObj->CommonField.Node));
433 case ACPI_TYPE_LOCAL_INDEX_FIELD:
435 AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]",
437 ObjDesc->IndexField.IndexObj->CommonField.Node),
439 ObjDesc->IndexField.DataObj->CommonField.Node));
442 case ACPI_TYPE_LOCAL_ALIAS:
443 case ACPI_TYPE_LOCAL_METHOD_ALIAS:
445 AcpiOsPrintf ("Target %4.4s (%p)\n",
446 AcpiUtGetNodeName (ObjDesc), ObjDesc);
451 AcpiOsPrintf ("Object %p\n", ObjDesc);
455 /* Common field handling */
459 case ACPI_TYPE_BUFFER_FIELD:
460 case ACPI_TYPE_LOCAL_REGION_FIELD:
461 case ACPI_TYPE_LOCAL_BANK_FIELD:
462 case ACPI_TYPE_LOCAL_INDEX_FIELD:
464 AcpiOsPrintf (" Off %.3X Len %.2X Acc %.2hd\n",
465 (ObjDesc->CommonField.BaseByteOffset * 8)
466 + ObjDesc->CommonField.StartFieldBitOffset,
467 ObjDesc->CommonField.BitLength,
468 ObjDesc->CommonField.AccessByteWidth);
477 case ACPI_DISPLAY_OBJECTS:
479 AcpiOsPrintf ("O:%p", ObjDesc);
482 /* No attached object, we are done */
488 AcpiOsPrintf ("(R%u)", ObjDesc->Common.ReferenceCount);
492 case ACPI_TYPE_METHOD:
494 /* Name is a Method and its AML offset/length are set */
496 AcpiOsPrintf (" M:%p-%X\n", ObjDesc->Method.AmlStart,
497 ObjDesc->Method.AmlLength);
500 case ACPI_TYPE_INTEGER:
502 AcpiOsPrintf (" I:%8.8X8.8%X\n",
503 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
506 case ACPI_TYPE_STRING:
508 AcpiOsPrintf (" S:%p-%X\n", ObjDesc->String.Pointer,
509 ObjDesc->String.Length);
512 case ACPI_TYPE_BUFFER:
514 AcpiOsPrintf (" B:%p-%X\n", ObjDesc->Buffer.Pointer,
515 ObjDesc->Buffer.Length);
530 /* If debug turned off, done */
532 if (!(AcpiDbgLevel & ACPI_LV_VALUES))
537 /* If there is an attached object, display it */
539 DbgLevel = AcpiDbgLevel;
541 ObjDesc = AcpiNsGetAttachedObject (ThisNode);
542 AcpiDbgLevel = DbgLevel;
544 /* Dump attached objects */
548 ObjType = ACPI_TYPE_INVALID;
549 AcpiOsPrintf ("Attached Object %p: ", ObjDesc);
551 /* Decode the type of attached object and dump the contents */
553 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
555 case ACPI_DESC_TYPE_NAMED:
557 AcpiOsPrintf ("(Ptr to Node)\n");
558 BytesToDump = sizeof (ACPI_NAMESPACE_NODE);
559 ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
562 case ACPI_DESC_TYPE_OPERAND:
564 ObjType = ObjDesc->Common.Type;
566 if (ObjType > ACPI_TYPE_LOCAL_MAX)
569 "(Pointer to ACPI Object type %.2X [UNKNOWN])\n",
577 "(Pointer to ACPI Object type %.2X [%s])\n",
578 ObjType, AcpiUtGetTypeName (ObjType));
580 BytesToDump = sizeof (ACPI_OPERAND_OBJECT);
583 ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
591 /* If value is NOT an internal object, we are done */
593 if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
598 /* Valid object, get the pointer to next level, if any */
602 case ACPI_TYPE_BUFFER:
603 case ACPI_TYPE_STRING:
605 * NOTE: takes advantage of common fields between string/buffer
607 BytesToDump = ObjDesc->String.Length;
608 ObjDesc = (void *) ObjDesc->String.Pointer;
610 AcpiOsPrintf ("(Buffer/String pointer %p length %X)\n",
611 ObjDesc, BytesToDump);
612 ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
615 case ACPI_TYPE_BUFFER_FIELD:
617 ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->BufferField.BufferObj;
620 case ACPI_TYPE_PACKAGE:
622 ObjDesc = (void *) ObjDesc->Package.Elements;
625 case ACPI_TYPE_METHOD:
627 ObjDesc = (void *) ObjDesc->Method.AmlStart;
630 case ACPI_TYPE_LOCAL_REGION_FIELD:
632 ObjDesc = (void *) ObjDesc->Field.RegionObj;
635 case ACPI_TYPE_LOCAL_BANK_FIELD:
637 ObjDesc = (void *) ObjDesc->BankField.RegionObj;
640 case ACPI_TYPE_LOCAL_INDEX_FIELD:
642 ObjDesc = (void *) ObjDesc->IndexField.IndexObj;
650 ObjType = ACPI_TYPE_INVALID; /* Terminate loop after next pass */
659 /*******************************************************************************
661 * FUNCTION: AcpiNsDumpObjects
663 * PARAMETERS: Type - Object type to be dumped
664 * DisplayType - 0 or ACPI_DISPLAY_SUMMARY
665 * MaxDepth - Maximum depth of dump. Use ACPI_UINT32_MAX
666 * for an effectively unlimited depth.
667 * OwnerId - Dump only objects owned by this ID. Use
668 * ACPI_UINT32_MAX to match all owners.
669 * StartHandle - Where in namespace to start/end search
673 * DESCRIPTION: Dump typed objects within the loaded namespace. Uses
674 * AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject.
676 ******************************************************************************/
680 ACPI_OBJECT_TYPE Type,
683 ACPI_OWNER_ID OwnerId,
684 ACPI_HANDLE StartHandle)
690 ACPI_FUNCTION_ENTRY ();
694 * Just lock the entire namespace for the duration of the dump.
695 * We don't want any changes to the namespace during this time,
696 * especially the temporary nodes since we are going to display
699 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
700 if (ACPI_FAILURE (Status))
702 AcpiOsPrintf ("Could not acquire namespace mutex\n");
706 Info.DebugLevel = ACPI_LV_TABLES;
707 Info.OwnerId = OwnerId;
708 Info.DisplayType = DisplayType;
710 (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
711 ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,
712 AcpiNsDumpOneObject, NULL, (void *) &Info, NULL);
714 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
718 /*******************************************************************************
720 * FUNCTION: AcpiNsDumpOneObjectPath, AcpiNsGetMaxDepth
722 * PARAMETERS: ObjHandle - Node to be dumped
723 * Level - Nesting level of the handle
724 * Context - Passed into WalkNamespace
725 * ReturnValue - Not used
729 * DESCRIPTION: Dump the full pathname to a namespace object. AcpNsGetMaxDepth
730 * computes the maximum nesting depth in the namespace tree, in
731 * order to simplify formatting in AcpiNsDumpOneObjectPath.
732 * These procedures are UserFunctions called by AcpiNsWalkNamespace.
734 ******************************************************************************/
737 AcpiNsDumpOneObjectPath (
738 ACPI_HANDLE ObjHandle,
743 UINT32 MaxLevel = *((UINT32 *) Context);
745 ACPI_NAMESPACE_NODE *Node;
754 Node = AcpiNsValidateHandle (ObjHandle);
757 /* Ignore bad node during namespace walk */
762 Pathname = AcpiNsGetNormalizedPathname (Node, TRUE);
765 if (Level <= MaxLevel)
767 PathIndent = MaxLevel - Level + 1;
770 AcpiOsPrintf ("%2d%*s%-12s%*s",
771 Level, Level, " ", AcpiUtGetTypeName (Node->Type),
774 AcpiOsPrintf ("%s\n", &Pathname[1]);
775 ACPI_FREE (Pathname);
782 ACPI_HANDLE ObjHandle,
787 UINT32 *MaxLevel = (UINT32 *) Context;
790 if (Level > *MaxLevel)
798 /*******************************************************************************
800 * FUNCTION: AcpiNsDumpObjectPaths
802 * PARAMETERS: Type - Object type to be dumped
803 * DisplayType - 0 or ACPI_DISPLAY_SUMMARY
804 * MaxDepth - Maximum depth of dump. Use ACPI_UINT32_MAX
805 * for an effectively unlimited depth.
806 * OwnerId - Dump only objects owned by this ID. Use
807 * ACPI_UINT32_MAX to match all owners.
808 * StartHandle - Where in namespace to start/end search
812 * DESCRIPTION: Dump full object pathnames within the loaded namespace. Uses
813 * AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObjectPath.
815 ******************************************************************************/
818 AcpiNsDumpObjectPaths (
819 ACPI_OBJECT_TYPE Type,
822 ACPI_OWNER_ID OwnerId,
823 ACPI_HANDLE StartHandle)
829 ACPI_FUNCTION_ENTRY ();
833 * Just lock the entire namespace for the duration of the dump.
834 * We don't want any changes to the namespace during this time,
835 * especially the temporary nodes since we are going to display
838 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
839 if (ACPI_FAILURE (Status))
841 AcpiOsPrintf ("Could not acquire namespace mutex\n");
845 /* Get the max depth of the namespace tree, for formatting later */
847 (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
848 ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,
849 AcpiNsGetMaxDepth, NULL, (void *) &MaxLevel, NULL);
851 /* Now dump the entire namespace */
853 (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
854 ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,
855 AcpiNsDumpOneObjectPath, NULL, (void *) &MaxLevel, NULL);
857 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
861 /*******************************************************************************
863 * FUNCTION: AcpiNsDumpEntry
865 * PARAMETERS: Handle - Node to be dumped
866 * DebugLevel - Output level
870 * DESCRIPTION: Dump a single Node
872 ******************************************************************************/
882 ACPI_FUNCTION_ENTRY ();
885 Info.DebugLevel = DebugLevel;
886 Info.OwnerId = ACPI_OWNER_ID_MAX;
887 Info.DisplayType = ACPI_DISPLAY_SUMMARY;
889 (void) AcpiNsDumpOneObject (Handle, 1, &Info, NULL);
893 #ifdef ACPI_ASL_COMPILER
894 /*******************************************************************************
896 * FUNCTION: AcpiNsDumpTables
898 * PARAMETERS: SearchBase - Root of subtree to be dumped, or
899 * NS_ALL to dump the entire namespace
900 * MaxDepth - Maximum depth of dump. Use INT_MAX
901 * for an effectively unlimited depth.
905 * DESCRIPTION: Dump the name space, or a portion of it.
907 ******************************************************************************/
911 ACPI_HANDLE SearchBase,
914 ACPI_HANDLE SearchHandle = SearchBase;
917 ACPI_FUNCTION_TRACE (NsDumpTables);
920 if (!AcpiGbl_RootNode)
923 * If the name space has not been initialized,
924 * there is nothing to dump.
926 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES,
927 "namespace not initialized!\n"));
931 if (ACPI_NS_ALL == SearchBase)
933 /* Entire namespace */
935 SearchHandle = AcpiGbl_RootNode;
936 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n"));
939 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, MaxDepth,
940 ACPI_OWNER_ID_MAX, SearchHandle);