1 /*******************************************************************************
3 * Module Name: dbnames - Debugger commands for the acpi namespace
5 ******************************************************************************/
8 * Copyright (C) 2000 - 2014, 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.
54 #define _COMPONENT ACPI_CA_DEBUGGER
55 ACPI_MODULE_NAME ("dbnames")
58 /* Local prototypes */
61 AcpiDbWalkAndMatchName (
62 ACPI_HANDLE ObjHandle,
68 AcpiDbWalkForPredefinedNames (
69 ACPI_HANDLE ObjHandle,
75 AcpiDbWalkForSpecificObjects (
76 ACPI_HANDLE ObjHandle,
83 ACPI_HANDLE ObjHandle,
89 AcpiDbWalkForReferences (
90 ACPI_HANDLE ObjHandle,
97 ACPI_HANDLE ObjHandle,
103 * Arguments for the Objects command
104 * These object types map directly to the ACPI_TYPES
106 static ACPI_DB_ARGUMENT_INFO AcpiDbObjectTypes [] =
130 {NULL} /* Must be null terminated */
134 /*******************************************************************************
136 * FUNCTION: AcpiDbSetScope
138 * PARAMETERS: Name - New scope path
142 * DESCRIPTION: Set the "current scope" as maintained by this utility.
143 * The scope is used as a prefix to ACPI paths.
145 ******************************************************************************/
152 ACPI_NAMESPACE_NODE *Node;
155 if (!Name || Name[0] == 0)
157 AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf);
161 AcpiDbPrepNamestring (Name);
163 if (ACPI_IS_ROOT_PREFIX (Name[0]))
165 /* Validate new scope from the root */
167 Status = AcpiNsGetNode (AcpiGbl_RootNode, Name, ACPI_NS_NO_UPSEARCH,
169 if (ACPI_FAILURE (Status))
174 AcpiGbl_DbScopeBuf[0] = 0;
178 /* Validate new scope relative to old scope */
180 Status = AcpiNsGetNode (AcpiGbl_DbScopeNode, Name, ACPI_NS_NO_UPSEARCH,
182 if (ACPI_FAILURE (Status))
188 /* Build the final pathname */
190 if (AcpiUtSafeStrcat (AcpiGbl_DbScopeBuf, sizeof (AcpiGbl_DbScopeBuf),
193 Status = AE_BUFFER_OVERFLOW;
197 if (AcpiUtSafeStrcat (AcpiGbl_DbScopeBuf, sizeof (AcpiGbl_DbScopeBuf),
200 Status = AE_BUFFER_OVERFLOW;
204 AcpiGbl_DbScopeNode = Node;
205 AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf);
210 AcpiOsPrintf ("Could not attach scope: %s, %s\n",
211 Name, AcpiFormatException (Status));
215 /*******************************************************************************
217 * FUNCTION: AcpiDbDumpNamespace
219 * PARAMETERS: StartArg - Node to begin namespace dump
220 * DepthArg - Maximum tree depth to be dumped
224 * DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed
225 * with type and other information.
227 ******************************************************************************/
230 AcpiDbDumpNamespace (
234 ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode;
235 UINT32 MaxDepth = ACPI_UINT32_MAX;
238 /* No argument given, just start at the root and dump entire namespace */
242 SubtreeEntry = AcpiDbConvertToNode (StartArg);
248 /* Now we can check for the depth argument */
252 MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
256 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
257 AcpiOsPrintf ("ACPI Namespace (from %4.4s (%p) subtree):\n",
258 ((ACPI_NAMESPACE_NODE *) SubtreeEntry)->Name.Ascii, SubtreeEntry);
260 /* Display the subtree */
262 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
263 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth,
264 ACPI_OWNER_ID_MAX, SubtreeEntry);
265 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
269 /*******************************************************************************
271 * FUNCTION: AcpiDbDumpNamespacePaths
277 * DESCRIPTION: Dump entire namespace with full object pathnames and object
278 * type information. Alternative to "namespace" command.
280 ******************************************************************************/
283 AcpiDbDumpNamespacePaths (
287 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
288 AcpiOsPrintf ("ACPI Namespace (from root):\n");
290 /* Display the entire namespace */
292 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
293 AcpiNsDumpObjectPaths (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY,
294 ACPI_UINT32_MAX, ACPI_OWNER_ID_MAX, AcpiGbl_RootNode);
296 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
300 /*******************************************************************************
302 * FUNCTION: AcpiDbDumpNamespaceByOwner
304 * PARAMETERS: OwnerArg - Owner ID whose nodes will be displayed
305 * DepthArg - Maximum tree depth to be dumped
309 * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId.
311 ******************************************************************************/
314 AcpiDbDumpNamespaceByOwner (
318 ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode;
319 UINT32 MaxDepth = ACPI_UINT32_MAX;
320 ACPI_OWNER_ID OwnerId;
323 OwnerId = (ACPI_OWNER_ID) ACPI_STRTOUL (OwnerArg, NULL, 0);
325 /* Now we can check for the depth argument */
329 MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
332 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
333 AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId);
335 /* Display the subtree */
337 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
338 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId,
340 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
344 /*******************************************************************************
346 * FUNCTION: AcpiDbWalkAndMatchName
348 * PARAMETERS: Callback from WalkNamespace
352 * DESCRIPTION: Find a particular name/names within the namespace. Wildcards
353 * are supported -- '?' matches any character.
355 ******************************************************************************/
358 AcpiDbWalkAndMatchName (
359 ACPI_HANDLE ObjHandle,
365 char *RequestedName = (char *) Context;
371 /* Check for a name match */
373 for (i = 0; i < 4; i++)
375 /* Wildcard support */
377 if ((RequestedName[i] != '?') &&
378 (RequestedName[i] != ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii[i]))
380 /* No match, just exit */
386 /* Get the full pathname to this object */
388 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
389 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
390 if (ACPI_FAILURE (Status))
392 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
396 Info.OwnerId = ACPI_OWNER_ID_MAX;
397 Info.DebugLevel = ACPI_UINT32_MAX;
398 Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
400 AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);
401 (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, &Info, NULL);
402 ACPI_FREE (Buffer.Pointer);
409 /*******************************************************************************
411 * FUNCTION: AcpiDbFindNameInNamespace
413 * PARAMETERS: NameArg - The 4-character ACPI name to find.
414 * wildcards are supported.
418 * DESCRIPTION: Search the namespace for a given name (with wildcards)
420 ******************************************************************************/
423 AcpiDbFindNameInNamespace (
426 char AcpiName[5] = "____";
427 char *AcpiNamePtr = AcpiName;
430 if (ACPI_STRLEN (NameArg) > 4)
432 AcpiOsPrintf ("Name must be no longer than 4 characters\n");
436 /* Pad out name with underscores as necessary to create a 4-char name */
438 AcpiUtStrupr (NameArg);
441 *AcpiNamePtr = *NameArg;
446 /* Walk the namespace from the root */
448 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
449 AcpiDbWalkAndMatchName, NULL, AcpiName, NULL);
451 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
456 /*******************************************************************************
458 * FUNCTION: AcpiDbWalkForPredefinedNames
460 * PARAMETERS: Callback from WalkNamespace
464 * DESCRIPTION: Detect and display predefined ACPI names (names that start with
467 ******************************************************************************/
470 AcpiDbWalkForPredefinedNames (
471 ACPI_HANDLE ObjHandle,
476 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
477 UINT32 *Count = (UINT32 *) Context;
478 const ACPI_PREDEFINED_INFO *Predefined;
479 const ACPI_PREDEFINED_INFO *Package = NULL;
481 char StringBuffer[48];
484 Predefined = AcpiUtMatchPredefinedMethod (Node->Name.Ascii);
490 Pathname = AcpiNsGetExternalPathname (Node);
496 /* If method returns a package, the info is in the next table entry */
498 if (Predefined->Info.ExpectedBtypes & ACPI_RTYPE_PACKAGE)
500 Package = Predefined + 1;
503 AcpiUtGetExpectedReturnTypes (StringBuffer,
504 Predefined->Info.ExpectedBtypes);
506 AcpiOsPrintf ("%-32s Arguments %X, Return Types: %s", Pathname,
507 METHOD_GET_ARG_COUNT (Predefined->Info.ArgumentList),
512 AcpiOsPrintf (" (PkgType %2.2X, ObjType %2.2X, Count %2.2X)",
513 Package->RetInfo.Type, Package->RetInfo.ObjectType1,
514 Package->RetInfo.Count1);
519 /* Check that the declared argument count matches the ACPI spec */
521 AcpiNsCheckAcpiCompliance (Pathname, Node, Predefined);
523 ACPI_FREE (Pathname);
529 /*******************************************************************************
531 * FUNCTION: AcpiDbCheckPredefinedNames
537 * DESCRIPTION: Validate all predefined names in the namespace
539 ******************************************************************************/
542 AcpiDbCheckPredefinedNames (
548 /* Search all nodes in namespace */
550 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
551 AcpiDbWalkForPredefinedNames, NULL, (void *) &Count, NULL);
553 AcpiOsPrintf ("Found %u predefined names in the namespace\n", Count);
557 /*******************************************************************************
559 * FUNCTION: AcpiDbWalkForSpecificObjects
561 * PARAMETERS: Callback from WalkNamespace
565 * DESCRIPTION: Display short info about objects in the namespace
567 ******************************************************************************/
570 AcpiDbWalkForSpecificObjects (
571 ACPI_HANDLE ObjHandle,
576 ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context;
583 /* Get and display the full pathname to this object */
585 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
586 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
587 if (ACPI_FAILURE (Status))
589 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
593 AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);
594 ACPI_FREE (Buffer.Pointer);
596 /* Dump short info about the object */
598 (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, Info, NULL);
603 /*******************************************************************************
605 * FUNCTION: AcpiDbDisplayObjects
607 * PARAMETERS: ObjTypeArg - Type of object to display
608 * DisplayCountArg - Max depth to display
612 * DESCRIPTION: Display objects in the namespace of the requested type
614 ******************************************************************************/
617 AcpiDbDisplayObjects (
619 char *DisplayCountArg)
622 ACPI_OBJECT_TYPE Type;
625 /* Get the object type */
627 Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes);
628 if (Type == ACPI_TYPE_NOT_FOUND)
630 AcpiOsPrintf ("Invalid or unsupported argument\n");
634 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
636 "Objects of type [%s] defined in the current ACPI Namespace:\n",
637 AcpiUtGetTypeName (Type));
639 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
642 Info.OwnerId = ACPI_OWNER_ID_MAX;
643 Info.DebugLevel = ACPI_UINT32_MAX;
644 Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
646 /* Walk the namespace from the root */
648 (void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
649 AcpiDbWalkForSpecificObjects, NULL, (void *) &Info, NULL);
652 "\nFound %u objects of type [%s] in the current ACPI Namespace\n",
653 Info.Count, AcpiUtGetTypeName (Type));
655 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
660 /*******************************************************************************
662 * FUNCTION: AcpiDbIntegrityWalk
664 * PARAMETERS: Callback from WalkNamespace
668 * DESCRIPTION: Examine one NS node for valid values.
670 ******************************************************************************/
673 AcpiDbIntegrityWalk (
674 ACPI_HANDLE ObjHandle,
679 ACPI_INTEGRITY_INFO *Info = (ACPI_INTEGRITY_INFO *) Context;
680 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
681 ACPI_OPERAND_OBJECT *Object;
682 BOOLEAN Alias = TRUE;
687 /* Verify the NS node, and dereference aliases */
691 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
693 AcpiOsPrintf ("Invalid Descriptor Type for Node %p [%s] - is %2.2X should be %2.2X\n",
694 Node, AcpiUtGetDescriptorName (Node), ACPI_GET_DESCRIPTOR_TYPE (Node),
695 ACPI_DESC_TYPE_NAMED);
699 if ((Node->Type == ACPI_TYPE_LOCAL_ALIAS) ||
700 (Node->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS))
702 Node = (ACPI_NAMESPACE_NODE *) Node->Object;
710 if (Node->Type > ACPI_TYPE_LOCAL_MAX)
712 AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n",
717 if (!AcpiUtValidAcpiName (Node->Name.Ascii))
719 AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node);
723 Object = AcpiNsGetAttachedObject (Node);
727 if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
729 AcpiOsPrintf ("Invalid Descriptor Type for Object %p [%s]\n",
730 Object, AcpiUtGetDescriptorName (Object));
738 /*******************************************************************************
740 * FUNCTION: AcpiDbCheckIntegrity
746 * DESCRIPTION: Check entire namespace for data structure integrity
748 ******************************************************************************/
751 AcpiDbCheckIntegrity (
754 ACPI_INTEGRITY_INFO Info = {0,0};
756 /* Search all nodes in namespace */
758 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
759 AcpiDbIntegrityWalk, NULL, (void *) &Info, NULL);
761 AcpiOsPrintf ("Verified %u namespace nodes with %u Objects\n",
762 Info.Nodes, Info.Objects);
766 /*******************************************************************************
768 * FUNCTION: AcpiDbWalkForReferences
770 * PARAMETERS: Callback from WalkNamespace
774 * DESCRIPTION: Check if this namespace object refers to the target object
775 * that is passed in as the context value.
777 * Note: Currently doesn't check subobjects within the Node's object
779 ******************************************************************************/
782 AcpiDbWalkForReferences (
783 ACPI_HANDLE ObjHandle,
788 ACPI_OPERAND_OBJECT *ObjDesc = (ACPI_OPERAND_OBJECT *) Context;
789 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
792 /* Check for match against the namespace node itself */
794 if (Node == (void *) ObjDesc)
796 AcpiOsPrintf ("Object is a Node [%4.4s]\n",
797 AcpiUtGetNodeName (Node));
800 /* Check for match against the object attached to the node */
802 if (AcpiNsGetAttachedObject (Node) == ObjDesc)
804 AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n",
805 Node, AcpiUtGetNodeName (Node));
812 /*******************************************************************************
814 * FUNCTION: AcpiDbFindReferences
816 * PARAMETERS: ObjectArg - String with hex value of the object
820 * DESCRIPTION: Search namespace for all references to the input object
822 ******************************************************************************/
825 AcpiDbFindReferences (
828 ACPI_OPERAND_OBJECT *ObjDesc;
832 /* Convert string to object pointer */
834 Address = ACPI_STRTOUL (ObjectArg, NULL, 16);
835 ObjDesc = ACPI_TO_POINTER (Address);
837 /* Search all nodes in namespace */
839 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
840 AcpiDbWalkForReferences, NULL, (void *) ObjDesc, NULL);
844 /*******************************************************************************
846 * FUNCTION: AcpiDbBusWalk
848 * PARAMETERS: Callback from WalkNamespace
852 * DESCRIPTION: Display info about device objects that have a corresponding
855 ******************************************************************************/
859 ACPI_HANDLE ObjHandle,
864 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
867 ACPI_NAMESPACE_NODE *TempNode;
868 ACPI_DEVICE_INFO *Info;
872 if ((Node->Type != ACPI_TYPE_DEVICE) &&
873 (Node->Type != ACPI_TYPE_PROCESSOR))
878 /* Exit if there is no _PRT under this device */
880 Status = AcpiGetHandle (Node, METHOD_NAME__PRT,
881 ACPI_CAST_PTR (ACPI_HANDLE, &TempNode));
882 if (ACPI_FAILURE (Status))
887 /* Get the full path to this device object */
889 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
890 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
891 if (ACPI_FAILURE (Status))
893 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
897 Status = AcpiGetObjectInfo (ObjHandle, &Info);
898 if (ACPI_FAILURE (Status))
903 /* Display the full path */
905 AcpiOsPrintf ("%-32s Type %X", (char *) Buffer.Pointer, Node->Type);
906 ACPI_FREE (Buffer.Pointer);
908 if (Info->Flags & ACPI_PCI_ROOT_BRIDGE)
910 AcpiOsPrintf (" - Is PCI Root Bridge");
916 AcpiOsPrintf ("_PRT: %p\n", TempNode);
918 /* Dump _ADR, _HID, _UID, _CID */
920 if (Info->Valid & ACPI_VALID_ADR)
922 AcpiOsPrintf ("_ADR: %8.8X%8.8X\n", ACPI_FORMAT_UINT64 (Info->Address));
926 AcpiOsPrintf ("_ADR: <Not Present>\n");
929 if (Info->Valid & ACPI_VALID_HID)
931 AcpiOsPrintf ("_HID: %s\n", Info->HardwareId.String);
935 AcpiOsPrintf ("_HID: <Not Present>\n");
938 if (Info->Valid & ACPI_VALID_UID)
940 AcpiOsPrintf ("_UID: %s\n", Info->UniqueId.String);
944 AcpiOsPrintf ("_UID: <Not Present>\n");
947 if (Info->Valid & ACPI_VALID_CID)
949 for (i = 0; i < Info->CompatibleIdList.Count; i++)
951 AcpiOsPrintf ("_CID: %s\n",
952 Info->CompatibleIdList.Ids[i].String);
957 AcpiOsPrintf ("_CID: <Not Present>\n");
965 /*******************************************************************************
967 * FUNCTION: AcpiDbGetBusInfo
973 * DESCRIPTION: Display info about system busses.
975 ******************************************************************************/
981 /* Search all nodes in namespace */
983 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
984 AcpiDbBusWalk, NULL, NULL, NULL);
987 #endif /* ACPI_DEBUGGER */