1 /******************************************************************************
3 * Module Name: nsdump - table dumping routines for debug
5 *****************************************************************************/
8 * Copyright (C) 2000 - 2011, 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.
46 #include <contrib/dev/acpica/include/acpi.h>
47 #include <contrib/dev/acpica/include/accommon.h>
48 #include <contrib/dev/acpica/include/acnamesp.h>
51 #define _COMPONENT ACPI_NAMESPACE
52 ACPI_MODULE_NAME ("nsdump")
54 /* Local prototypes */
56 #ifdef ACPI_OBSOLETE_FUNCTIONS
58 AcpiNsDumpRootDevices (
63 ACPI_HANDLE ObjHandle,
70 #if defined(ACPI_DEBUG_OUTPUT) || defined(ACPI_DEBUGGER)
71 /*******************************************************************************
73 * FUNCTION: AcpiNsPrintPathname
75 * PARAMETERS: NumSegments - Number of ACPI name segments
76 * Pathname - The compressed (internal) path
80 * DESCRIPTION: Print an object's full namespace pathname
82 ******************************************************************************/
92 ACPI_FUNCTION_NAME (NsPrintPathname);
95 if (!(AcpiDbgLevel & ACPI_LV_NAMES) || !(AcpiDbgLayer & ACPI_NAMESPACE))
100 /* Print the entire name */
102 ACPI_DEBUG_PRINT ((ACPI_DB_NAMES, "["));
106 for (i = 0; i < 4; i++)
108 ACPI_IS_PRINT (Pathname[i]) ?
109 AcpiOsPrintf ("%c", Pathname[i]) :
113 Pathname += ACPI_NAME_SIZE;
121 AcpiOsPrintf ("]\n");
125 /*******************************************************************************
127 * FUNCTION: AcpiNsDumpPathname
129 * PARAMETERS: Handle - Object
130 * Msg - Prefix message
131 * Level - Desired debug level
132 * Component - Caller's component ID
136 * DESCRIPTION: Print an object's full namespace pathname
137 * Manages allocation/freeing of a pathname buffer
139 ******************************************************************************/
149 ACPI_FUNCTION_TRACE (NsDumpPathname);
152 /* Do this only if the requested debug level and component are enabled */
154 if (!(AcpiDbgLevel & Level) || !(AcpiDbgLayer & Component))
159 /* Convert handle to a full pathname and print it (with supplied message) */
161 AcpiNsPrintNodePathname (Handle, Msg);
167 /*******************************************************************************
169 * FUNCTION: AcpiNsDumpOneObject
171 * PARAMETERS: ObjHandle - Node to be dumped
172 * Level - Nesting level of the handle
173 * Context - Passed into WalkNamespace
174 * ReturnValue - Not used
178 * DESCRIPTION: Dump a single Node
179 * This procedure is a UserFunction called by AcpiNsWalkNamespace.
181 ******************************************************************************/
184 AcpiNsDumpOneObject (
185 ACPI_HANDLE ObjHandle,
190 ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context;
191 ACPI_NAMESPACE_NODE *ThisNode;
192 ACPI_OPERAND_OBJECT *ObjDesc = NULL;
193 ACPI_OBJECT_TYPE ObjType;
194 ACPI_OBJECT_TYPE Type;
200 ACPI_FUNCTION_NAME (NsDumpOneObject);
203 /* Is output enabled? */
205 if (!(AcpiDbgLevel & Info->DebugLevel))
212 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Null object handle\n"));
216 ThisNode = AcpiNsValidateHandle (ObjHandle);
219 ACPI_DEBUG_PRINT ((ACPI_DB_INFO, "Invalid object handle %p\n",
224 Type = ThisNode->Type;
226 /* Check if the owner matches */
228 if ((Info->OwnerId != ACPI_OWNER_ID_MAX) &&
229 (Info->OwnerId != ThisNode->OwnerId))
234 if (!(Info->DisplayType & ACPI_DISPLAY_SHORT))
236 /* Indent the object according to the level */
238 AcpiOsPrintf ("%2d%*s", (UINT32) Level - 1, (int) Level * 2, " ");
240 /* Check the node type and name */
242 if (Type > ACPI_TYPE_LOCAL_MAX)
244 ACPI_WARNING ((AE_INFO, "Invalid ACPI Object Type 0x%08X", Type));
247 AcpiOsPrintf ("%4.4s", AcpiUtGetNodeName (ThisNode));
250 /* Now we can print out the pertinent information */
252 AcpiOsPrintf (" %-12s %p %2.2X ",
253 AcpiUtGetTypeName (Type), ThisNode, ThisNode->OwnerId);
255 DbgLevel = AcpiDbgLevel;
257 ObjDesc = AcpiNsGetAttachedObject (ThisNode);
258 AcpiDbgLevel = DbgLevel;
260 /* Temp nodes are those nodes created by a control method */
262 if (ThisNode->Flags & ANOBJ_TEMPORARY)
264 AcpiOsPrintf ("(T) ");
267 switch (Info->DisplayType & ACPI_DISPLAY_MASK)
269 case ACPI_DISPLAY_SUMMARY:
273 /* No attached object, we are done */
281 case ACPI_TYPE_PROCESSOR:
283 AcpiOsPrintf ("ID %X Len %.4X Addr %p\n",
284 ObjDesc->Processor.ProcId, ObjDesc->Processor.Length,
285 ACPI_CAST_PTR (void, ObjDesc->Processor.Address));
289 case ACPI_TYPE_DEVICE:
291 AcpiOsPrintf ("Notify Object: %p\n", ObjDesc);
295 case ACPI_TYPE_METHOD:
297 AcpiOsPrintf ("Args %X Len %.4X Aml %p\n",
298 (UINT32) ObjDesc->Method.ParamCount,
299 ObjDesc->Method.AmlLength, ObjDesc->Method.AmlStart);
303 case ACPI_TYPE_INTEGER:
305 AcpiOsPrintf ("= %8.8X%8.8X\n",
306 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
310 case ACPI_TYPE_PACKAGE:
312 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
314 AcpiOsPrintf ("Elements %.2X\n",
315 ObjDesc->Package.Count);
319 AcpiOsPrintf ("[Length not yet evaluated]\n");
324 case ACPI_TYPE_BUFFER:
326 if (ObjDesc->Common.Flags & AOPOBJ_DATA_VALID)
328 AcpiOsPrintf ("Len %.2X",
329 ObjDesc->Buffer.Length);
331 /* Dump some of the buffer */
333 if (ObjDesc->Buffer.Length > 0)
336 for (i = 0; (i < ObjDesc->Buffer.Length && i < 12); i++)
338 AcpiOsPrintf (" %.2hX", ObjDesc->Buffer.Pointer[i]);
345 AcpiOsPrintf ("[Length not yet evaluated]\n");
350 case ACPI_TYPE_STRING:
352 AcpiOsPrintf ("Len %.2X ", ObjDesc->String.Length);
353 AcpiUtPrintString (ObjDesc->String.Pointer, 32);
358 case ACPI_TYPE_REGION:
360 AcpiOsPrintf ("[%s]",
361 AcpiUtGetRegionName (ObjDesc->Region.SpaceId));
362 if (ObjDesc->Region.Flags & AOPOBJ_DATA_VALID)
364 AcpiOsPrintf (" Addr %8.8X%8.8X Len %.4X\n",
365 ACPI_FORMAT_NATIVE_UINT (ObjDesc->Region.Address),
366 ObjDesc->Region.Length);
370 AcpiOsPrintf (" [Address/Length not yet evaluated]\n");
375 case ACPI_TYPE_LOCAL_REFERENCE:
377 AcpiOsPrintf ("[%s]\n", AcpiUtGetReferenceName (ObjDesc));
381 case ACPI_TYPE_BUFFER_FIELD:
383 if (ObjDesc->BufferField.BufferObj &&
384 ObjDesc->BufferField.BufferObj->Buffer.Node)
386 AcpiOsPrintf ("Buf [%4.4s]",
388 ObjDesc->BufferField.BufferObj->Buffer.Node));
393 case ACPI_TYPE_LOCAL_REGION_FIELD:
395 AcpiOsPrintf ("Rgn [%4.4s]",
397 ObjDesc->CommonField.RegionObj->Region.Node));
401 case ACPI_TYPE_LOCAL_BANK_FIELD:
403 AcpiOsPrintf ("Rgn [%4.4s] Bnk [%4.4s]",
405 ObjDesc->CommonField.RegionObj->Region.Node),
407 ObjDesc->BankField.BankObj->CommonField.Node));
411 case ACPI_TYPE_LOCAL_INDEX_FIELD:
413 AcpiOsPrintf ("Idx [%4.4s] Dat [%4.4s]",
415 ObjDesc->IndexField.IndexObj->CommonField.Node),
417 ObjDesc->IndexField.DataObj->CommonField.Node));
421 case ACPI_TYPE_LOCAL_ALIAS:
422 case ACPI_TYPE_LOCAL_METHOD_ALIAS:
424 AcpiOsPrintf ("Target %4.4s (%p)\n",
425 AcpiUtGetNodeName (ObjDesc), ObjDesc);
430 AcpiOsPrintf ("Object %p\n", ObjDesc);
434 /* Common field handling */
438 case ACPI_TYPE_BUFFER_FIELD:
439 case ACPI_TYPE_LOCAL_REGION_FIELD:
440 case ACPI_TYPE_LOCAL_BANK_FIELD:
441 case ACPI_TYPE_LOCAL_INDEX_FIELD:
443 AcpiOsPrintf (" Off %.3X Len %.2X Acc %.2hd\n",
444 (ObjDesc->CommonField.BaseByteOffset * 8)
445 + ObjDesc->CommonField.StartFieldBitOffset,
446 ObjDesc->CommonField.BitLength,
447 ObjDesc->CommonField.AccessByteWidth);
456 case ACPI_DISPLAY_OBJECTS:
458 AcpiOsPrintf ("O:%p", ObjDesc);
461 /* No attached object, we are done */
467 AcpiOsPrintf ("(R%u)", ObjDesc->Common.ReferenceCount);
471 case ACPI_TYPE_METHOD:
473 /* Name is a Method and its AML offset/length are set */
475 AcpiOsPrintf (" M:%p-%X\n", ObjDesc->Method.AmlStart,
476 ObjDesc->Method.AmlLength);
479 case ACPI_TYPE_INTEGER:
481 AcpiOsPrintf (" I:%8.8X8.8%X\n",
482 ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
485 case ACPI_TYPE_STRING:
487 AcpiOsPrintf (" S:%p-%X\n", ObjDesc->String.Pointer,
488 ObjDesc->String.Length);
491 case ACPI_TYPE_BUFFER:
493 AcpiOsPrintf (" B:%p-%X\n", ObjDesc->Buffer.Pointer,
494 ObjDesc->Buffer.Length);
510 /* If debug turned off, done */
512 if (!(AcpiDbgLevel & ACPI_LV_VALUES))
517 /* If there is an attached object, display it */
519 DbgLevel = AcpiDbgLevel;
521 ObjDesc = AcpiNsGetAttachedObject (ThisNode);
522 AcpiDbgLevel = DbgLevel;
524 /* Dump attached objects */
528 ObjType = ACPI_TYPE_INVALID;
529 AcpiOsPrintf ("Attached Object %p: ", ObjDesc);
531 /* Decode the type of attached object and dump the contents */
533 switch (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc))
535 case ACPI_DESC_TYPE_NAMED:
537 AcpiOsPrintf ("(Ptr to Node)\n");
538 BytesToDump = sizeof (ACPI_NAMESPACE_NODE);
539 ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
542 case ACPI_DESC_TYPE_OPERAND:
544 ObjType = ObjDesc->Common.Type;
546 if (ObjType > ACPI_TYPE_LOCAL_MAX)
548 AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [UNKNOWN])\n",
554 AcpiOsPrintf ("(Pointer to ACPI Object type %.2X [%s])\n",
555 ObjType, AcpiUtGetTypeName (ObjType));
556 BytesToDump = sizeof (ACPI_OPERAND_OBJECT);
559 ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
567 /* If value is NOT an internal object, we are done */
569 if (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND)
574 /* Valid object, get the pointer to next level, if any */
578 case ACPI_TYPE_BUFFER:
579 case ACPI_TYPE_STRING:
581 * NOTE: takes advantage of common fields between string/buffer
583 BytesToDump = ObjDesc->String.Length;
584 ObjDesc = (void *) ObjDesc->String.Pointer;
585 AcpiOsPrintf ( "(Buffer/String pointer %p length %X)\n",
586 ObjDesc, BytesToDump);
587 ACPI_DUMP_BUFFER (ObjDesc, BytesToDump);
590 case ACPI_TYPE_BUFFER_FIELD:
591 ObjDesc = (ACPI_OPERAND_OBJECT *) ObjDesc->BufferField.BufferObj;
594 case ACPI_TYPE_PACKAGE:
595 ObjDesc = (void *) ObjDesc->Package.Elements;
598 case ACPI_TYPE_METHOD:
599 ObjDesc = (void *) ObjDesc->Method.AmlStart;
602 case ACPI_TYPE_LOCAL_REGION_FIELD:
603 ObjDesc = (void *) ObjDesc->Field.RegionObj;
606 case ACPI_TYPE_LOCAL_BANK_FIELD:
607 ObjDesc = (void *) ObjDesc->BankField.RegionObj;
610 case ACPI_TYPE_LOCAL_INDEX_FIELD:
611 ObjDesc = (void *) ObjDesc->IndexField.IndexObj;
618 ObjType = ACPI_TYPE_INVALID; /* Terminate loop after next pass */
627 /*******************************************************************************
629 * FUNCTION: AcpiNsDumpObjects
631 * PARAMETERS: Type - Object type to be dumped
632 * DisplayType - 0 or ACPI_DISPLAY_SUMMARY
633 * MaxDepth - Maximum depth of dump. Use ACPI_UINT32_MAX
634 * for an effectively unlimited depth.
635 * OwnerId - Dump only objects owned by this ID. Use
636 * ACPI_UINT32_MAX to match all owners.
637 * StartHandle - Where in namespace to start/end search
641 * DESCRIPTION: Dump typed objects within the loaded namespace. Uses
642 * AcpiNsWalkNamespace in conjunction with AcpiNsDumpOneObject.
644 ******************************************************************************/
648 ACPI_OBJECT_TYPE Type,
651 ACPI_OWNER_ID OwnerId,
652 ACPI_HANDLE StartHandle)
658 ACPI_FUNCTION_ENTRY ();
662 * Just lock the entire namespace for the duration of the dump.
663 * We don't want any changes to the namespace during this time,
664 * especially the temporary nodes since we are going to display
667 Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
668 if (ACPI_FAILURE (Status))
670 AcpiOsPrintf ("Could not acquire namespace mutex\n");
674 Info.DebugLevel = ACPI_LV_TABLES;
675 Info.OwnerId = OwnerId;
676 Info.DisplayType = DisplayType;
678 (void) AcpiNsWalkNamespace (Type, StartHandle, MaxDepth,
679 ACPI_NS_WALK_NO_UNLOCK | ACPI_NS_WALK_TEMP_NODES,
680 AcpiNsDumpOneObject, NULL, (void *) &Info, NULL);
682 (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
686 /*******************************************************************************
688 * FUNCTION: AcpiNsDumpEntry
690 * PARAMETERS: Handle - Node to be dumped
691 * DebugLevel - Output level
695 * DESCRIPTION: Dump a single Node
697 ******************************************************************************/
707 ACPI_FUNCTION_ENTRY ();
710 Info.DebugLevel = DebugLevel;
711 Info.OwnerId = ACPI_OWNER_ID_MAX;
712 Info.DisplayType = ACPI_DISPLAY_SUMMARY;
714 (void) AcpiNsDumpOneObject (Handle, 1, &Info, NULL);
718 #ifdef ACPI_ASL_COMPILER
719 /*******************************************************************************
721 * FUNCTION: AcpiNsDumpTables
723 * PARAMETERS: SearchBase - Root of subtree to be dumped, or
724 * NS_ALL to dump the entire namespace
725 * MaxDepth - Maximum depth of dump. Use INT_MAX
726 * for an effectively unlimited depth.
730 * DESCRIPTION: Dump the name space, or a portion of it.
732 ******************************************************************************/
736 ACPI_HANDLE SearchBase,
739 ACPI_HANDLE SearchHandle = SearchBase;
742 ACPI_FUNCTION_TRACE (NsDumpTables);
745 if (!AcpiGbl_RootNode)
748 * If the name space has not been initialized,
749 * there is nothing to dump.
751 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "namespace not initialized!\n"));
755 if (ACPI_NS_ALL == SearchBase)
757 /* Entire namespace */
759 SearchHandle = AcpiGbl_RootNode;
760 ACPI_DEBUG_PRINT ((ACPI_DB_TABLES, "\\\n"));
763 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_OBJECTS, MaxDepth,
764 ACPI_OWNER_ID_MAX, SearchHandle);