1 /*******************************************************************************
3 * Module Name: dbnames - Debugger commands for the acpi namespace
5 ******************************************************************************/
7 /******************************************************************************
11 * Some or all of this work - Copyright (c) 1999 - 2020, Intel Corp.
12 * All rights reserved.
16 * 2.1. This is your license from Intel Corp. under its intellectual property
17 * rights. You may have additional license terms from the party that provided
18 * you this software, covering your right to use that party's intellectual
21 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
22 * copy of the source code appearing in this file ("Covered Code") an
23 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
24 * base code distributed originally by Intel ("Original Intel Code") to copy,
25 * make derivatives, distribute, use and display any portion of the Covered
26 * Code in any form, with the right to sublicense such rights; and
28 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
29 * license (with the right to sublicense), under only those claims of Intel
30 * patents that are infringed by the Original Intel Code, to make, use, sell,
31 * offer to sell, and import the Covered Code and derivative works thereof
32 * solely to the minimum extent necessary to exercise the above copyright
33 * license, and in no event shall the patent license extend to any additions
34 * to or modifications of the Original Intel Code. No other license or right
35 * is granted directly or by implication, estoppel or otherwise;
37 * The above copyright and patent license is granted only if the following
42 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
43 * Redistribution of source code of any substantial portion of the Covered
44 * Code or modification with rights to further distribute source must include
45 * the above Copyright Notice, the above License, this list of Conditions,
46 * and the following Disclaimer and Export Compliance provision. In addition,
47 * Licensee must cause all Covered Code to which Licensee contributes to
48 * contain a file documenting the changes Licensee made to create that Covered
49 * Code and the date of any change. Licensee must include in that file the
50 * documentation of any changes made by any predecessor Licensee. Licensee
51 * must include a prominent statement that the modification is derived,
52 * directly or indirectly, from Original Intel Code.
54 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
55 * Redistribution of source code of any substantial portion of the Covered
56 * Code or modification without rights to further distribute source must
57 * include the following Disclaimer and Export Compliance provision in the
58 * documentation and/or other materials provided with distribution. In
59 * addition, Licensee may not authorize further sublicense of source of any
60 * portion of the Covered Code, and must include terms to the effect that the
61 * license from Licensee to its licensee is limited to the intellectual
62 * property embodied in the software Licensee provides to its licensee, and
63 * not to intellectual property embodied in modifications its licensee may
66 * 3.3. Redistribution of Executable. Redistribution in executable form of any
67 * substantial portion of the Covered Code or modification must reproduce the
68 * above Copyright Notice, and the following Disclaimer and Export Compliance
69 * provision in the documentation and/or other materials provided with the
72 * 3.4. Intel retains all right, title, and interest in and to the Original
75 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
76 * Intel shall be used in advertising or otherwise to promote the sale, use or
77 * other dealings in products derived from or relating to the Covered Code
78 * without prior written authorization from Intel.
80 * 4. Disclaimer and Export Compliance
82 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
83 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
84 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
85 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
86 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
87 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
90 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
91 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
92 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
93 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
94 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
95 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
96 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
99 * 4.3. Licensee shall not export, either directly or indirectly, any of this
100 * software or system incorporating such software without first obtaining any
101 * required license or other approval from the U. S. Department of Commerce or
102 * any other agency or department of the United States Government. In the
103 * event Licensee exports any such software from the United States or
104 * re-exports any such software from a foreign destination, Licensee shall
105 * ensure that the distribution and export/re-export of the software is in
106 * compliance with all laws, regulations, orders, or other restrictions of the
107 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
108 * any of its subsidiaries will export/re-export any technical data, process,
109 * software, or service, directly or indirectly, to any country for which the
110 * United States government or any agency thereof requires an export license,
111 * other governmental approval, or letter of assurance, without first obtaining
112 * such license, approval or letter.
114 *****************************************************************************
116 * Alternatively, you may choose to be licensed under the terms of the
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
122 * 1. Redistributions of source code must retain the above copyright
123 * notice, this list of conditions, and the following disclaimer,
124 * without modification.
125 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126 * substantially similar to the "NO WARRANTY" disclaimer below
127 * ("Disclaimer") and any redistribution must be conditioned upon
128 * including a substantially similar Disclaimer requirement for further
129 * binary redistribution.
130 * 3. Neither the names of the above-listed copyright holders nor the names
131 * of any contributors may be used to endorse or promote products derived
132 * from this software without specific prior written permission.
134 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
146 * Alternatively, you may choose to be licensed under the terms of the
147 * GNU General Public License ("GPL") version 2 as published by the Free
148 * Software Foundation.
150 *****************************************************************************/
152 #include <contrib/dev/acpica/include/acpi.h>
153 #include <contrib/dev/acpica/include/accommon.h>
154 #include <contrib/dev/acpica/include/acnamesp.h>
155 #include <contrib/dev/acpica/include/acdebug.h>
156 #include <contrib/dev/acpica/include/acpredef.h>
157 #include <contrib/dev/acpica/include/acinterp.h>
160 #define _COMPONENT ACPI_CA_DEBUGGER
161 ACPI_MODULE_NAME ("dbnames")
164 /* Local prototypes */
167 AcpiDbWalkAndMatchName (
168 ACPI_HANDLE ObjHandle,
174 AcpiDbWalkForPredefinedNames (
175 ACPI_HANDLE ObjHandle,
181 AcpiDbWalkForSpecificObjects (
182 ACPI_HANDLE ObjHandle,
188 AcpiDbWalkForObjectCounts (
189 ACPI_HANDLE ObjHandle,
195 AcpiDbIntegrityWalk (
196 ACPI_HANDLE ObjHandle,
202 AcpiDbWalkForReferences (
203 ACPI_HANDLE ObjHandle,
210 ACPI_HANDLE ObjHandle,
216 * Arguments for the Objects command
217 * These object types map directly to the ACPI_TYPES
219 static ACPI_DB_ARGUMENT_INFO AcpiDbObjectTypes [] =
249 {NULL} /* Must be null terminated */
253 /*******************************************************************************
255 * FUNCTION: AcpiDbSetScope
257 * PARAMETERS: Name - New scope path
261 * DESCRIPTION: Set the "current scope" as maintained by this utility.
262 * The scope is used as a prefix to ACPI paths.
264 ******************************************************************************/
271 ACPI_NAMESPACE_NODE *Node;
274 if (!Name || Name[0] == 0)
276 AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf);
280 AcpiDbPrepNamestring (Name);
282 if (ACPI_IS_ROOT_PREFIX (Name[0]))
284 /* Validate new scope from the root */
286 Status = AcpiNsGetNode (AcpiGbl_RootNode, Name,
287 ACPI_NS_NO_UPSEARCH, &Node);
288 if (ACPI_FAILURE (Status))
293 AcpiGbl_DbScopeBuf[0] = 0;
297 /* Validate new scope relative to old scope */
299 Status = AcpiNsGetNode (AcpiGbl_DbScopeNode, Name,
300 ACPI_NS_NO_UPSEARCH, &Node);
301 if (ACPI_FAILURE (Status))
307 /* Build the final pathname */
309 if (AcpiUtSafeStrcat (AcpiGbl_DbScopeBuf, sizeof (AcpiGbl_DbScopeBuf),
312 Status = AE_BUFFER_OVERFLOW;
316 if (AcpiUtSafeStrcat (AcpiGbl_DbScopeBuf, sizeof (AcpiGbl_DbScopeBuf),
319 Status = AE_BUFFER_OVERFLOW;
323 AcpiGbl_DbScopeNode = Node;
324 AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf);
329 AcpiOsPrintf ("Could not attach scope: %s, %s\n",
330 Name, AcpiFormatException (Status));
334 /*******************************************************************************
336 * FUNCTION: AcpiDbDumpNamespace
338 * PARAMETERS: StartArg - Node to begin namespace dump
339 * DepthArg - Maximum tree depth to be dumped
343 * DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed
344 * with type and other information.
346 ******************************************************************************/
349 AcpiDbDumpNamespace (
353 ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode;
354 UINT32 MaxDepth = ACPI_UINT32_MAX;
357 /* No argument given, just start at the root and dump entire namespace */
361 SubtreeEntry = AcpiDbConvertToNode (StartArg);
367 /* Now we can check for the depth argument */
371 MaxDepth = strtoul (DepthArg, NULL, 0);
375 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
377 if (((ACPI_NAMESPACE_NODE *) SubtreeEntry)->Parent)
379 AcpiOsPrintf ("ACPI Namespace (from %4.4s (%p) subtree):\n",
380 ((ACPI_NAMESPACE_NODE *) SubtreeEntry)->Name.Ascii, SubtreeEntry);
384 AcpiOsPrintf ("ACPI Namespace (from %s):\n",
385 ACPI_NAMESPACE_ROOT);
388 /* Display the subtree */
390 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
391 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth,
392 ACPI_OWNER_ID_MAX, SubtreeEntry);
393 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
397 /*******************************************************************************
399 * FUNCTION: AcpiDbDumpNamespacePaths
405 * DESCRIPTION: Dump entire namespace with full object pathnames and object
406 * type information. Alternative to "namespace" command.
408 ******************************************************************************/
411 AcpiDbDumpNamespacePaths (
415 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
416 AcpiOsPrintf ("ACPI Namespace (from root):\n");
418 /* Display the entire namespace */
420 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
421 AcpiNsDumpObjectPaths (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY,
422 ACPI_UINT32_MAX, ACPI_OWNER_ID_MAX, AcpiGbl_RootNode);
424 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
428 /*******************************************************************************
430 * FUNCTION: AcpiDbDumpNamespaceByOwner
432 * PARAMETERS: OwnerArg - Owner ID whose nodes will be displayed
433 * DepthArg - Maximum tree depth to be dumped
437 * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId.
439 ******************************************************************************/
442 AcpiDbDumpNamespaceByOwner (
446 ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode;
447 UINT32 MaxDepth = ACPI_UINT32_MAX;
448 ACPI_OWNER_ID OwnerId;
451 OwnerId = (ACPI_OWNER_ID) strtoul (OwnerArg, NULL, 0);
453 /* Now we can check for the depth argument */
457 MaxDepth = strtoul (DepthArg, NULL, 0);
460 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
461 AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId);
463 /* Display the subtree */
465 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
466 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth,
467 OwnerId, SubtreeEntry);
468 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
472 /*******************************************************************************
474 * FUNCTION: AcpiDbWalkAndMatchName
476 * PARAMETERS: Callback from WalkNamespace
480 * DESCRIPTION: Find a particular name/names within the namespace. Wildcards
481 * are supported -- '?' matches any character.
483 ******************************************************************************/
486 AcpiDbWalkAndMatchName (
487 ACPI_HANDLE ObjHandle,
493 char *RequestedName = (char *) Context;
499 /* Check for a name match */
501 for (i = 0; i < 4; i++)
503 /* Wildcard support */
505 if ((RequestedName[i] != '?') &&
506 (RequestedName[i] != ((ACPI_NAMESPACE_NODE *)
507 ObjHandle)->Name.Ascii[i]))
509 /* No match, just exit */
515 /* Get the full pathname to this object */
517 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
518 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer, TRUE);
519 if (ACPI_FAILURE (Status))
521 AcpiOsPrintf ("Could Not get pathname for object %p\n",
527 Info.OwnerId = ACPI_OWNER_ID_MAX;
528 Info.DebugLevel = ACPI_UINT32_MAX;
529 Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
531 AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);
532 (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, &Info, NULL);
533 ACPI_FREE (Buffer.Pointer);
540 /*******************************************************************************
542 * FUNCTION: AcpiDbFindNameInNamespace
544 * PARAMETERS: NameArg - The 4-character ACPI name to find.
545 * wildcards are supported.
549 * DESCRIPTION: Search the namespace for a given name (with wildcards)
551 ******************************************************************************/
554 AcpiDbFindNameInNamespace (
557 char AcpiName[5] = "____";
558 char *AcpiNamePtr = AcpiName;
561 if (strlen (NameArg) > ACPI_NAMESEG_SIZE)
563 AcpiOsPrintf ("Name must be no longer than 4 characters\n");
567 /* Pad out name with underscores as necessary to create a 4-char name */
569 AcpiUtStrupr (NameArg);
572 *AcpiNamePtr = *NameArg;
577 /* Walk the namespace from the root */
579 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
580 ACPI_UINT32_MAX, AcpiDbWalkAndMatchName, NULL, AcpiName, NULL);
582 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
587 /*******************************************************************************
589 * FUNCTION: AcpiDbWalkForPredefinedNames
591 * PARAMETERS: Callback from WalkNamespace
595 * DESCRIPTION: Detect and display predefined ACPI names (names that start with
598 ******************************************************************************/
601 AcpiDbWalkForPredefinedNames (
602 ACPI_HANDLE ObjHandle,
607 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
608 UINT32 *Count = (UINT32 *) Context;
609 const ACPI_PREDEFINED_INFO *Predefined;
610 const ACPI_PREDEFINED_INFO *Package = NULL;
612 char StringBuffer[48];
615 Predefined = AcpiUtMatchPredefinedMethod (Node->Name.Ascii);
621 Pathname = AcpiNsGetNormalizedPathname (Node, TRUE);
627 /* If method returns a package, the info is in the next table entry */
629 if (Predefined->Info.ExpectedBtypes & ACPI_RTYPE_PACKAGE)
631 Package = Predefined + 1;
634 AcpiUtGetExpectedReturnTypes (StringBuffer,
635 Predefined->Info.ExpectedBtypes);
637 AcpiOsPrintf ("%-32s Arguments %X, Return Types: %s", Pathname,
638 METHOD_GET_ARG_COUNT (Predefined->Info.ArgumentList),
643 AcpiOsPrintf (" (PkgType %2.2X, ObjType %2.2X, Count %2.2X)",
644 Package->RetInfo.Type, Package->RetInfo.ObjectType1,
645 Package->RetInfo.Count1);
650 /* Check that the declared argument count matches the ACPI spec */
652 AcpiNsCheckAcpiCompliance (Pathname, Node, Predefined);
654 ACPI_FREE (Pathname);
660 /*******************************************************************************
662 * FUNCTION: AcpiDbCheckPredefinedNames
668 * DESCRIPTION: Validate all predefined names in the namespace
670 ******************************************************************************/
673 AcpiDbCheckPredefinedNames (
679 /* Search all nodes in namespace */
681 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
682 ACPI_UINT32_MAX, AcpiDbWalkForPredefinedNames,
683 NULL, (void *) &Count, NULL);
685 AcpiOsPrintf ("Found %u predefined names in the namespace\n", Count);
689 /*******************************************************************************
691 * FUNCTION: AcpiDbWalkForObjectCounts
693 * PARAMETERS: Callback from WalkNamespace
697 * DESCRIPTION: Display short info about objects in the namespace
699 ******************************************************************************/
702 AcpiDbWalkForObjectCounts (
703 ACPI_HANDLE ObjHandle,
708 ACPI_OBJECT_INFO *Info = (ACPI_OBJECT_INFO *) Context;
709 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
712 if (Node->Type > ACPI_TYPE_NS_NODE_MAX)
714 AcpiOsPrintf ("[%4.4s]: Unknown object type %X\n",
715 Node->Name.Ascii, Node->Type);
719 Info->Types[Node->Type]++;
726 /*******************************************************************************
728 * FUNCTION: AcpiDbWalkForFields
730 * PARAMETERS: Callback from WalkNamespace
734 * DESCRIPTION: Display short info about objects in the namespace
736 ******************************************************************************/
739 AcpiDbWalkForFields (
740 ACPI_HANDLE ObjHandle,
745 ACPI_OBJECT *RetValue;
746 ACPI_REGION_WALK_INFO *Info = (ACPI_REGION_WALK_INFO *) Context;
749 ACPI_NAMESPACE_NODE *Node = AcpiNsValidateHandle (ObjHandle);
756 if (Node->Object->Field.RegionObj->Region.SpaceId != Info->AddressSpaceId)
763 /* Get and display the full pathname to this object */
765 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
766 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer, TRUE);
767 if (ACPI_FAILURE (Status))
769 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
773 AcpiOsPrintf ("%s ", (char *) Buffer.Pointer);
774 ACPI_FREE (Buffer.Pointer);
776 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
777 AcpiEvaluateObject (ObjHandle, NULL, NULL, &Buffer);
780 * Since this is a field unit, surround the output in braces
784 RetValue = (ACPI_OBJECT *) Buffer.Pointer;
785 switch (RetValue->Type)
787 case ACPI_TYPE_INTEGER:
789 AcpiOsPrintf ("%8.8X%8.8X", ACPI_FORMAT_UINT64 (RetValue->Integer.Value));
792 case ACPI_TYPE_BUFFER:
794 AcpiUtDumpBuffer (RetValue->Buffer.Pointer,
795 RetValue->Buffer.Length, DB_DISPLAY_DATA_ONLY | DB_BYTE_DISPLAY, 0);
803 AcpiOsPrintf ("}\n");
805 ACPI_FREE (Buffer.Pointer);
810 /*******************************************************************************
812 * FUNCTION: AcpiDbWalkForSpecificObjects
814 * PARAMETERS: Callback from WalkNamespace
818 * DESCRIPTION: Display short info about objects in the namespace
820 ******************************************************************************/
823 AcpiDbWalkForSpecificObjects (
824 ACPI_HANDLE ObjHandle,
829 ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context;
836 /* Get and display the full pathname to this object */
838 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
839 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer, TRUE);
840 if (ACPI_FAILURE (Status))
842 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
846 AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);
847 ACPI_FREE (Buffer.Pointer);
849 /* Dump short info about the object */
851 (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, Info, NULL);
856 /*******************************************************************************
858 * FUNCTION: AcpiDbDisplayObjects
860 * PARAMETERS: ObjTypeArg - Type of object to display
861 * DisplayCountArg - Max depth to display
865 * DESCRIPTION: Display objects in the namespace of the requested type
867 ******************************************************************************/
870 AcpiDbDisplayObjects (
872 char *DisplayCountArg)
875 ACPI_OBJECT_TYPE Type;
876 ACPI_OBJECT_INFO *ObjectInfo;
878 UINT32 TotalObjects = 0;
881 /* No argument means display summary/count of all object types */
885 ObjectInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_OBJECT_INFO));
887 /* Walk the namespace from the root */
889 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
890 ACPI_UINT32_MAX, AcpiDbWalkForObjectCounts, NULL,
891 (void *) ObjectInfo, NULL);
893 AcpiOsPrintf ("\nSummary of namespace objects:\n\n");
895 for (i = 0; i < ACPI_TOTAL_TYPES; i++)
897 AcpiOsPrintf ("%8u %s\n", ObjectInfo->Types[i],
898 AcpiUtGetTypeName (i));
900 TotalObjects += ObjectInfo->Types[i];
903 AcpiOsPrintf ("\n%8u Total namespace objects\n\n",
906 ACPI_FREE (ObjectInfo);
910 /* Get the object type */
912 Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes);
913 if (Type == ACPI_TYPE_NOT_FOUND)
915 AcpiOsPrintf ("Invalid or unsupported argument\n");
919 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
921 "Objects of type [%s] defined in the current ACPI Namespace:\n",
922 AcpiUtGetTypeName (Type));
924 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
927 Info.OwnerId = ACPI_OWNER_ID_MAX;
928 Info.DebugLevel = ACPI_UINT32_MAX;
929 Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
931 /* Walk the namespace from the root */
933 (void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
934 AcpiDbWalkForSpecificObjects, NULL, (void *) &Info, NULL);
937 "\nFound %u objects of type [%s] in the current ACPI Namespace\n",
938 Info.Count, AcpiUtGetTypeName (Type));
940 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
945 /*******************************************************************************
947 * FUNCTION: AcpiDbDisplayFields
949 * PARAMETERS: ObjTypeArg - Type of object to display
950 * DisplayCountArg - Max depth to display
954 * DESCRIPTION: Display objects in the namespace of the requested type
956 ******************************************************************************/
959 AcpiDbDisplayFields (
960 UINT32 AddressSpaceId)
962 ACPI_REGION_WALK_INFO Info;
966 Info.OwnerId = ACPI_OWNER_ID_MAX;
967 Info.DebugLevel = ACPI_UINT32_MAX;
968 Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
969 Info.AddressSpaceId = AddressSpaceId;
971 /* Walk the namespace from the root */
973 (void) AcpiWalkNamespace (ACPI_TYPE_LOCAL_REGION_FIELD, ACPI_ROOT_OBJECT,
974 ACPI_UINT32_MAX, AcpiDbWalkForFields, NULL,
975 (void *) &Info, NULL);
981 /*******************************************************************************
983 * FUNCTION: AcpiDbIntegrityWalk
985 * PARAMETERS: Callback from WalkNamespace
989 * DESCRIPTION: Examine one NS node for valid values.
991 ******************************************************************************/
994 AcpiDbIntegrityWalk (
995 ACPI_HANDLE ObjHandle,
1000 ACPI_INTEGRITY_INFO *Info = (ACPI_INTEGRITY_INFO *) Context;
1001 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
1002 ACPI_OPERAND_OBJECT *Object;
1003 BOOLEAN Alias = TRUE;
1008 /* Verify the NS node, and dereference aliases */
1012 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
1015 "Invalid Descriptor Type for Node %p [%s] - "
1016 "is %2.2X should be %2.2X\n",
1017 Node, AcpiUtGetDescriptorName (Node),
1018 ACPI_GET_DESCRIPTOR_TYPE (Node), ACPI_DESC_TYPE_NAMED);
1022 if ((Node->Type == ACPI_TYPE_LOCAL_ALIAS) ||
1023 (Node->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS))
1025 Node = (ACPI_NAMESPACE_NODE *) Node->Object;
1033 if (Node->Type > ACPI_TYPE_LOCAL_MAX)
1035 AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n",
1040 if (!AcpiUtValidNameseg (Node->Name.Ascii))
1042 AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node);
1046 Object = AcpiNsGetAttachedObject (Node);
1050 if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
1052 AcpiOsPrintf ("Invalid Descriptor Type for Object %p [%s]\n",
1053 Object, AcpiUtGetDescriptorName (Object));
1061 /*******************************************************************************
1063 * FUNCTION: AcpiDbCheckIntegrity
1069 * DESCRIPTION: Check entire namespace for data structure integrity
1071 ******************************************************************************/
1074 AcpiDbCheckIntegrity (
1077 ACPI_INTEGRITY_INFO Info = {0,0};
1079 /* Search all nodes in namespace */
1081 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
1082 ACPI_UINT32_MAX, AcpiDbIntegrityWalk, NULL, (void *) &Info, NULL);
1084 AcpiOsPrintf ("Verified %u namespace nodes with %u Objects\n",
1085 Info.Nodes, Info.Objects);
1089 /*******************************************************************************
1091 * FUNCTION: AcpiDbWalkForReferences
1093 * PARAMETERS: Callback from WalkNamespace
1097 * DESCRIPTION: Check if this namespace object refers to the target object
1098 * that is passed in as the context value.
1100 * Note: Currently doesn't check subobjects within the Node's object
1102 ******************************************************************************/
1105 AcpiDbWalkForReferences (
1106 ACPI_HANDLE ObjHandle,
1107 UINT32 NestingLevel,
1111 ACPI_OPERAND_OBJECT *ObjDesc = (ACPI_OPERAND_OBJECT *) Context;
1112 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
1115 /* Check for match against the namespace node itself */
1117 if (Node == (void *) ObjDesc)
1119 AcpiOsPrintf ("Object is a Node [%4.4s]\n",
1120 AcpiUtGetNodeName (Node));
1123 /* Check for match against the object attached to the node */
1125 if (AcpiNsGetAttachedObject (Node) == ObjDesc)
1127 AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n",
1128 Node, AcpiUtGetNodeName (Node));
1135 /*******************************************************************************
1137 * FUNCTION: AcpiDbFindReferences
1139 * PARAMETERS: ObjectArg - String with hex value of the object
1143 * DESCRIPTION: Search namespace for all references to the input object
1145 ******************************************************************************/
1148 AcpiDbFindReferences (
1151 ACPI_OPERAND_OBJECT *ObjDesc;
1155 /* Convert string to object pointer */
1157 Address = strtoul (ObjectArg, NULL, 16);
1158 ObjDesc = ACPI_TO_POINTER (Address);
1160 /* Search all nodes in namespace */
1162 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
1163 ACPI_UINT32_MAX, AcpiDbWalkForReferences, NULL,
1164 (void *) ObjDesc, NULL);
1168 /*******************************************************************************
1170 * FUNCTION: AcpiDbBusWalk
1172 * PARAMETERS: Callback from WalkNamespace
1176 * DESCRIPTION: Display info about device objects that have a corresponding
1179 ******************************************************************************/
1183 ACPI_HANDLE ObjHandle,
1184 UINT32 NestingLevel,
1188 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
1191 ACPI_NAMESPACE_NODE *TempNode;
1192 ACPI_DEVICE_INFO *Info;
1196 if ((Node->Type != ACPI_TYPE_DEVICE) &&
1197 (Node->Type != ACPI_TYPE_PROCESSOR))
1202 /* Exit if there is no _PRT under this device */
1204 Status = AcpiGetHandle (Node, METHOD_NAME__PRT,
1205 ACPI_CAST_PTR (ACPI_HANDLE, &TempNode));
1206 if (ACPI_FAILURE (Status))
1211 /* Get the full path to this device object */
1213 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1214 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer, TRUE);
1215 if (ACPI_FAILURE (Status))
1217 AcpiOsPrintf ("Could Not get pathname for object %p\n",
1222 Status = AcpiGetObjectInfo (ObjHandle, &Info);
1223 if (ACPI_FAILURE (Status))
1228 /* Display the full path */
1230 AcpiOsPrintf ("%-32s Type %X", (char *) Buffer.Pointer, Node->Type);
1231 ACPI_FREE (Buffer.Pointer);
1233 if (Info->Flags & ACPI_PCI_ROOT_BRIDGE)
1235 AcpiOsPrintf (" - Is PCI Root Bridge");
1237 AcpiOsPrintf ("\n");
1241 AcpiOsPrintf ("_PRT: %p\n", TempNode);
1243 /* Dump _ADR, _HID, _UID, _CID */
1245 if (Info->Valid & ACPI_VALID_ADR)
1247 AcpiOsPrintf ("_ADR: %8.8X%8.8X\n",
1248 ACPI_FORMAT_UINT64 (Info->Address));
1252 AcpiOsPrintf ("_ADR: <Not Present>\n");
1255 if (Info->Valid & ACPI_VALID_HID)
1257 AcpiOsPrintf ("_HID: %s\n", Info->HardwareId.String);
1261 AcpiOsPrintf ("_HID: <Not Present>\n");
1264 if (Info->Valid & ACPI_VALID_UID)
1266 AcpiOsPrintf ("_UID: %s\n", Info->UniqueId.String);
1270 AcpiOsPrintf ("_UID: <Not Present>\n");
1273 if (Info->Valid & ACPI_VALID_CID)
1275 for (i = 0; i < Info->CompatibleIdList.Count; i++)
1277 AcpiOsPrintf ("_CID: %s\n",
1278 Info->CompatibleIdList.Ids[i].String);
1283 AcpiOsPrintf ("_CID: <Not Present>\n");
1291 /*******************************************************************************
1293 * FUNCTION: AcpiDbGetBusInfo
1299 * DESCRIPTION: Display info about system buses.
1301 ******************************************************************************/
1307 /* Search all nodes in namespace */
1309 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
1310 ACPI_UINT32_MAX, AcpiDbBusWalk, NULL, NULL, NULL);