1 /******************************************************************************
3 * Module Name: nsdump - table dumping routines for debug
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2015, 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, "Invalid ACPI Object Type 0x%08X", Type));
264 AcpiOsPrintf ("%4.4s", AcpiUtGetNodeName (ThisNode));
267 /* Now we can print out the pertinent information */
269 AcpiOsPrintf (" %-12s %p %2.2X ",
270 AcpiUtGetTypeName (Type), ThisNode, ThisNode->OwnerId);
272 DbgLevel = AcpiDbgLevel;
274 ObjDesc = AcpiNsGetAttachedObject (ThisNode);
275 AcpiDbgLevel = DbgLevel;
277 /* Temp nodes are those nodes created by a control method */
279 if (ThisNode->Flags & ANOBJ_TEMPORARY)
281 AcpiOsPrintf ("(T) ");
284 switch (Info->DisplayType & ACPI_DISPLAY_MASK)
286 case ACPI_DISPLAY_SUMMARY:
290 /* No attached object. Some types should always have an object */
294 case ACPI_TYPE_INTEGER:
295 case ACPI_TYPE_PACKAGE:
296 case ACPI_TYPE_BUFFER:
297 case ACPI_TYPE_STRING:
298 case ACPI_TYPE_METHOD:
300 AcpiOsPrintf ("<No attached object>");
314 case ACPI_TYPE_PROCESSOR:
316 AcpiOsPrintf ("ID %02X Len %02X Addr %8.8X%8.8X\n",
317 ObjDesc->Processor.ProcId, ObjDesc->Processor.Length,
318 ACPI_FORMAT_UINT64 (ObjDesc->Processor.Address));
321 case ACPI_TYPE_DEVICE:
323 AcpiOsPrintf ("Notify Object: %p\n", ObjDesc);
326 case ACPI_TYPE_METHOD:
328 AcpiOsPrintf ("Args %X Len %.4X Aml %p\n",
329 (UINT32) ObjDesc->Method.ParamCount,
330 ObjDesc->Method.AmlLength, ObjDesc->Method.AmlStart);
333 case ACPI_TYPE_INTEGER:
335 AcpiOsPrintf ("= %8.8X%8.8X\n",
336 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
339 case ACPI_TYPE_PACKAGE:
341 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
343 AcpiOsPrintf ("Elements %.2X\n",
344 ObjDesc->Package.Count);
348 AcpiOsPrintf ("[Length not yet evaluated]\n");
352 case ACPI_TYPE_BUFFER:
354 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
356 AcpiOsPrintf ("Len %.2X",
357 ObjDesc->Buffer.Length);
359 /* Dump some of the buffer */
361 if (ObjDesc->Buffer.Length > 0)
364 for (i = 0; (i < ObjDesc->Buffer.Length && i < 12); i++)
366 AcpiOsPrintf (" %.2hX", ObjDesc->Buffer.Pointer[i]);
373 AcpiOsPrintf ("[Length not yet evaluated]\n");
377 case ACPI_TYPE_STRING:
379 AcpiOsPrintf ("Len %.2X ", ObjDesc->String.Length);
380 AcpiUtPrintString (ObjDesc->String.Pointer, 32);
384 case ACPI_TYPE_REGION:
386 AcpiOsPrintf ("[%s]",
387 AcpiUtGetRegionName (ObjDesc->Region.SpaceId));
388 if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
390 AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n",
391 ACPI_FORMAT_UINT64 (ObjDesc->Region.Address),
392 ObjDesc->Region.Length);
396 AcpiOsPrintf (" [Address/Length not yet evaluated]\n");
400 case ACPI_TYPE_LOCAL_REFERENCE:
402 AcpiOsPrintf ("[%s]\n", AcpiUtGetReferenceName (ObjDesc));
405 case ACPI_TYPE_BUFFER_FIELD:
407 if (ObjDesc->BufferField.BufferObj &&
408 ObjDesc->BufferField.BufferObj->Buffer.Node)
410 AcpiOsPrintf ("Buf [%4.4s]",
412 ObjDesc->BufferField.BufferObj->Buffer.Node));
416 case ACPI_TYPE_LOCAL_REGION_FIELD:
418 AcpiOsPrintf ("Rgn [%4.4s]",
420 ObjDesc->CommonField.RegionObj->Region.Node));
423 case ACPI_TYPE_LOCAL_BANK_FIELD:
425 AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]",
427 ObjDesc->CommonField.RegionObj->Region.Node),
429 ObjDesc->BankField.BankObj->CommonField.Node));
432 case ACPI_TYPE_LOCAL_INDEX_FIELD:
434 AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]",
436 ObjDesc->IndexField.IndexObj->CommonField.Node),
438 ObjDesc->IndexField.DataObj->CommonField.Node));
441 case ACPI_TYPE_LOCAL_ALIAS:
442 case ACPI_TYPE_LOCAL_METHOD_ALIAS:
444 AcpiOsPrintf ("Target %4.4s (%p)\n",
445 AcpiUtGetNodeName (ObjDesc), ObjDesc);
450 AcpiOsPrintf ("Object %p\n", ObjDesc);
454 /* Common field handling */
458 case ACPI_TYPE_BUFFER_FIELD:
459 case ACPI_TYPE_LOCAL_REGION_FIELD:
460 case ACPI_TYPE_LOCAL_BANK_FIELD:
461 case ACPI_TYPE_LOCAL_INDEX_FIELD:
463 AcpiOsPrintf (" Off %.3X Len %.2X Acc %.2hd\n",
464 (ObjDesc->CommonField.BaseByteOffset * 8)
465 + ObjDesc->CommonField.StartFieldBitOffset,
466 ObjDesc->CommonField.BitLength,
467 ObjDesc->CommonField.AccessByteWidth);
476 case ACPI_DISPLAY_OBJECTS:
478 AcpiOsPrintf ("O:%p", ObjDesc);
481 /* No attached object, we are done */
487 AcpiOsPrintf ("(R%u)", ObjDesc->Common.ReferenceCount);
491 case ACPI_TYPE_METHOD:
493 /* Name is a Method and its AML offset/length are set */
495 AcpiOsPrintf (" M:%p-%X\n", ObjDesc->Method.AmlStart,
496 ObjDesc->Method.AmlLength);
499 case ACPI_TYPE_INTEGER:
501 AcpiOsPrintf (" I:%8.8X8.8%X\n",
502 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
505 case ACPI_TYPE_STRING:
507 AcpiOsPrintf (" S:%p-%X\n", ObjDesc->String.Pointer,
508 ObjDesc->String.Length);
511 case ACPI_TYPE_BUFFER:
513 AcpiOsPrintf (" B:%p-%X\n", ObjDesc->Buffer.Pointer,
514 ObjDesc->Buffer.Length);
529 /* If debug turned off, done */
531 if (!(AcpiDbgLevel & ACPI_LV_VALUES))
536 /* If there is an attached object, display it */
538 DbgLevel = AcpiDbgLevel;
540 ObjDesc = AcpiNsGetAttachedObject (ThisNode);
541 AcpiDbgLevel = DbgLevel;
543 /* Dump attached objects */
547 ObjType = ACPI_TYPE_INVALID;
548 AcpiOsPrintf ("Attached Object %p: ", ObjDesc);
550 /* Decode the type of attached object and dump the contents */
552 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
554 case ACPI_DESC_TYPE_NAMED:
556 AcpiOsPrintf ("(Ptr to Node)\n");
557 BytesToDump = sizeof (ACPI_NAMESPACE_NODE);
558 ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
561 case ACPI_DESC_TYPE_OPERAND:
563 ObjType = ObjDesc->Common.Type;
565 if (ObjType > ACPI_TYPE_LOCAL_MAX)
567 AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [UNKNOWN])\n",
573 AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [%s])\n",
574 ObjType, AcpiUtGetTypeName (ObjType));
575 BytesToDump = sizeof (ACPI_OPERAND_OBJECT);
578 ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
586 /* If value is NOT an internal object, we are done */
588 if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
593 /* Valid object, get the pointer to next level, if any */
597 case ACPI_TYPE_BUFFER:
598 case ACPI_TYPE_STRING:
600 * NOTE: takes advantage of common fields between string/buffer
602 BytesToDump = ObjDesc->String.Length;
603 ObjDesc = (void *) ObjDesc->String.Pointer;
604 AcpiOsPrintf ( "(Buffer/String pointer %p length %X)\n",
605 ObjDesc, BytesToDump);
606 ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
609 case ACPI_TYPE_BUFFER_FIELD:
611 ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->BufferField.BufferObj;
614 case ACPI_TYPE_PACKAGE:
616 ObjDesc = (void *) ObjDesc->Package.Elements;
619 case ACPI_TYPE_METHOD:
621 ObjDesc = (void *) ObjDesc->Method.AmlStart;
624 case ACPI_TYPE_LOCAL_REGION_FIELD:
626 ObjDesc = (void *) ObjDesc->Field.RegionObj;
629 case ACPI_TYPE_LOCAL_BANK_FIELD:
631 ObjDesc = (void *) ObjDesc->BankField.RegionObj;
634 case ACPI_TYPE_LOCAL_INDEX_FIELD:
636 ObjDesc = (void *) ObjDesc->IndexField.IndexObj;
644 ObjType = ACPI_TYPE_INVALID; /* Terminate loop after next pass */
653 /*******************************************************************************
655 * FUNCTION: AcpiNsDumpObjects
657 * PARAMETERS: Type - Object type to be dumped
658 * DisplayType - 0 or ACPI_DISPLAY_SUMMARY
659 * MaxDepth - Maximum depth of dump. Use ACPI_UINT32_MAX
660 * for an effectively unlimited depth.
661 * OwnerId - Dump only objects owned by this ID. Use
662 * ACPI_UINT32_MAX to match all owners.
663 * StartHandle - Where in namespace to start/end search
667 * DESCRIPTION: Dump typed objects within the loaded namespace. Uses
668 * AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject.
670 ******************************************************************************/
674 ACPI_OBJECT_TYPE Type,
677 ACPI_OWNER_ID OwnerId,
678 ACPI_HANDLE StartHandle)
684 ACPI_FUNCTION_ENTRY ();
688 * Just lock the entire namespace for the duration of the dump.
689 * We don't want any changes to the namespace during this time,
690 * especially the temporary nodes since we are going to display
693 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
694 if (ACPI_FAILURE (Status))
696 AcpiOsPrintf ("Could not acquire namespace mutex\n");
700 Info.DebugLevel = ACPI_LV_TABLES;
701 Info.OwnerId = OwnerId;
702 Info.DisplayType = DisplayType;
704 (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
705 ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,
706 AcpiNsDumpOneObject, NULL, (void *) &Info, NULL);
708 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
712 /*******************************************************************************
714 * FUNCTION: AcpiNsDumpOneObjectPath, AcpiNsGetMaxDepth
716 * PARAMETERS: ObjHandle - Node to be dumped
717 * Level - Nesting level of the handle
718 * Context - Passed into WalkNamespace
719 * ReturnValue - Not used
723 * DESCRIPTION: Dump the full pathname to a namespace object. AcpNsGetMaxDepth
724 * computes the maximum nesting depth in the namespace tree, in
725 * order to simplify formatting in AcpiNsDumpOneObjectPath.
726 * These procedures are UserFunctions called by AcpiNsWalkNamespace.
728 ******************************************************************************/
731 AcpiNsDumpOneObjectPath (
732 ACPI_HANDLE ObjHandle,
737 UINT32 MaxLevel = *((UINT32 *) Context);
739 ACPI_NAMESPACE_NODE *Node;
748 Node = AcpiNsValidateHandle (ObjHandle);
751 /* Ignore bad node during namespace walk */
756 Pathname = AcpiNsGetExternalPathname (Node);
759 if (Level <= MaxLevel)
761 PathIndent = MaxLevel - Level + 1;
764 AcpiOsPrintf ("%2d%*s%-12s%*s",
765 Level, Level, " ", AcpiUtGetTypeName (Node->Type),
768 AcpiOsPrintf ("%s\n", &Pathname[1]);
769 ACPI_FREE (Pathname);
776 ACPI_HANDLE ObjHandle,
781 UINT32 *MaxLevel = (UINT32 *) Context;
784 if (Level > *MaxLevel)
792 /*******************************************************************************
794 * FUNCTION: AcpiNsDumpObjectPaths
796 * PARAMETERS: Type - Object type to be dumped
797 * DisplayType - 0 or ACPI_DISPLAY_SUMMARY
798 * MaxDepth - Maximum depth of dump. Use ACPI_UINT32_MAX
799 * for an effectively unlimited depth.
800 * OwnerId - Dump only objects owned by this ID. Use
801 * ACPI_UINT32_MAX to match all owners.
802 * StartHandle - Where in namespace to start/end search
806 * DESCRIPTION: Dump full object pathnames within the loaded namespace. Uses
807 * AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObjectPath.
809 ******************************************************************************/
812 AcpiNsDumpObjectPaths (
813 ACPI_OBJECT_TYPE Type,
816 ACPI_OWNER_ID OwnerId,
817 ACPI_HANDLE StartHandle)
823 ACPI_FUNCTION_ENTRY ();
827 * Just lock the entire namespace for the duration of the dump.
828 * We don't want any changes to the namespace during this time,
829 * especially the temporary nodes since we are going to display
832 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
833 if (ACPI_FAILURE (Status))
835 AcpiOsPrintf ("Could not acquire namespace mutex\n");
839 /* Get the max depth of the namespace tree, for formatting later */
841 (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
842 ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,
843 AcpiNsGetMaxDepth, NULL, (void *) &MaxLevel, NULL);
845 /* Now dump the entire namespace */
847 (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
848 ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,
849 AcpiNsDumpOneObjectPath, NULL, (void *) &MaxLevel, NULL);
851 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
855 /*******************************************************************************
857 * FUNCTION: AcpiNsDumpEntry
859 * PARAMETERS: Handle - Node to be dumped
860 * DebugLevel - Output level
864 * DESCRIPTION: Dump a single Node
866 ******************************************************************************/
876 ACPI_FUNCTION_ENTRY ();
879 Info.DebugLevel = DebugLevel;
880 Info.OwnerId = ACPI_OWNER_ID_MAX;
881 Info.DisplayType = ACPI_DISPLAY_SUMMARY;
883 (void) AcpiNsDumpOneObject (Handle, 1, &Info, NULL);
887 #ifdef ACPI_ASL_COMPILER
888 /*******************************************************************************
890 * FUNCTION: AcpiNsDumpTables
892 * PARAMETERS: SearchBase - Root of subtree to be dumped, or
893 * NS_ALL to dump the entire namespace
894 * MaxDepth - Maximum depth of dump. Use INT_MAX
895 * for an effectively unlimited depth.
899 * DESCRIPTION: Dump the name space, or a portion of it.
901 ******************************************************************************/
905 ACPI_HANDLE SearchBase,
908 ACPI_HANDLE SearchHandle = SearchBase;
911 ACPI_FUNCTION_TRACE (NsDumpTables);
914 if (!AcpiGbl_RootNode)
917 * If the name space has not been initialized,
918 * there is nothing to dump.
920 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "namespace not initialized!\n"));
924 if (ACPI_NS_ALL == SearchBase)
926 /* Entire namespace */
928 SearchHandle = AcpiGbl_RootNode;
929 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n"));
932 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, MaxDepth,
933 ACPI_OWNER_ID_MAX, SearchHandle);