Sync ACPICA with Intel's version 20180508 (from previously 20170831).
[dragonfly.git] / sys / contrib / dev / acpica / source / components / debugger / dbnames.c
blob51b9fb293f369b6fcf219d96e677ef782525b478
1 /*******************************************************************************
3 * Module Name: dbnames - Debugger commands for the acpi namespace
5 ******************************************************************************/
7 /******************************************************************************
9 * 1. Copyright Notice
11 * Some or all of this work - Copyright (c) 1999 - 2018, Intel Corp.
12 * All rights reserved.
14 * 2. License
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
19 * property rights.
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
38 * conditions are met:
40 * 3. Conditions
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
64 * make.
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
70 * distribution.
72 * 3.4. Intel retains all right, title, and interest in and to the Original
73 * Intel Code.
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
88 * PARTICULAR PURPOSE.
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
97 * LIMITED REMEDY.
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
117 * following license:
119 * Redistribution and use in source and binary forms, with or without
120 * modification, are permitted provided that the following conditions
121 * are met:
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 "acpi.h"
153 #include "accommon.h"
154 #include "acnamesp.h"
155 #include "acdebug.h"
156 #include "acpredef.h"
159 #ifdef ACPI_DEBUGGER
161 #define _COMPONENT ACPI_CA_DEBUGGER
162 ACPI_MODULE_NAME ("dbnames")
165 /* Local prototypes */
167 static ACPI_STATUS
168 AcpiDbWalkAndMatchName (
169 ACPI_HANDLE ObjHandle,
170 UINT32 NestingLevel,
171 void *Context,
172 void **ReturnValue);
174 static ACPI_STATUS
175 AcpiDbWalkForPredefinedNames (
176 ACPI_HANDLE ObjHandle,
177 UINT32 NestingLevel,
178 void *Context,
179 void **ReturnValue);
181 static ACPI_STATUS
182 AcpiDbWalkForSpecificObjects (
183 ACPI_HANDLE ObjHandle,
184 UINT32 NestingLevel,
185 void *Context,
186 void **ReturnValue);
188 static ACPI_STATUS
189 AcpiDbWalkForObjectCounts (
190 ACPI_HANDLE ObjHandle,
191 UINT32 NestingLevel,
192 void *Context,
193 void **ReturnValue);
195 static ACPI_STATUS
196 AcpiDbIntegrityWalk (
197 ACPI_HANDLE ObjHandle,
198 UINT32 NestingLevel,
199 void *Context,
200 void **ReturnValue);
202 static ACPI_STATUS
203 AcpiDbWalkForReferences (
204 ACPI_HANDLE ObjHandle,
205 UINT32 NestingLevel,
206 void *Context,
207 void **ReturnValue);
209 static ACPI_STATUS
210 AcpiDbBusWalk (
211 ACPI_HANDLE ObjHandle,
212 UINT32 NestingLevel,
213 void *Context,
214 void **ReturnValue);
217 * Arguments for the Objects command
218 * These object types map directly to the ACPI_TYPES
220 static ACPI_DB_ARGUMENT_INFO AcpiDbObjectTypes [] =
222 {"ANY"},
223 {"INTEGERS"},
224 {"STRINGS"},
225 {"BUFFERS"},
226 {"PACKAGES"},
227 {"FIELDS"},
228 {"DEVICES"},
229 {"EVENTS"},
230 {"METHODS"},
231 {"MUTEXES"},
232 {"REGIONS"},
233 {"POWERRESOURCES"},
234 {"PROCESSORS"},
235 {"THERMALZONES"},
236 {"BUFFERFIELDS"},
237 {"DDBHANDLES"},
238 {"DEBUG"},
239 {"REGIONFIELDS"},
240 {"BANKFIELDS"},
241 {"INDEXFIELDS"},
242 {"REFERENCES"},
243 {"ALIASES"},
244 {"METHODALIASES"},
245 {"NOTIFY"},
246 {"ADDRESSHANDLER"},
247 {"RESOURCE"},
248 {"RESOURCEFIELD"},
249 {"SCOPES"},
250 {NULL} /* Must be null terminated */
254 /*******************************************************************************
256 * FUNCTION: AcpiDbSetScope
258 * PARAMETERS: Name - New scope path
260 * RETURN: Status
262 * DESCRIPTION: Set the "current scope" as maintained by this utility.
263 * The scope is used as a prefix to ACPI paths.
265 ******************************************************************************/
267 void
268 AcpiDbSetScope (
269 char *Name)
271 ACPI_STATUS Status;
272 ACPI_NAMESPACE_NODE *Node;
275 if (!Name || Name[0] == 0)
277 AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf);
278 return;
281 AcpiDbPrepNamestring (Name);
283 if (ACPI_IS_ROOT_PREFIX (Name[0]))
285 /* Validate new scope from the root */
287 Status = AcpiNsGetNode (AcpiGbl_RootNode, Name,
288 ACPI_NS_NO_UPSEARCH, &Node);
289 if (ACPI_FAILURE (Status))
291 goto ErrorExit;
294 AcpiGbl_DbScopeBuf[0] = 0;
296 else
298 /* Validate new scope relative to old scope */
300 Status = AcpiNsGetNode (AcpiGbl_DbScopeNode, Name,
301 ACPI_NS_NO_UPSEARCH, &Node);
302 if (ACPI_FAILURE (Status))
304 goto ErrorExit;
308 /* Build the final pathname */
310 if (AcpiUtSafeStrcat (AcpiGbl_DbScopeBuf, sizeof (AcpiGbl_DbScopeBuf),
311 Name))
313 Status = AE_BUFFER_OVERFLOW;
314 goto ErrorExit;
317 if (AcpiUtSafeStrcat (AcpiGbl_DbScopeBuf, sizeof (AcpiGbl_DbScopeBuf),
318 "\\"))
320 Status = AE_BUFFER_OVERFLOW;
321 goto ErrorExit;
324 AcpiGbl_DbScopeNode = Node;
325 AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf);
326 return;
328 ErrorExit:
330 AcpiOsPrintf ("Could not attach scope: %s, %s\n",
331 Name, AcpiFormatException (Status));
335 /*******************************************************************************
337 * FUNCTION: AcpiDbDumpNamespace
339 * PARAMETERS: StartArg - Node to begin namespace dump
340 * DepthArg - Maximum tree depth to be dumped
342 * RETURN: None
344 * DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed
345 * with type and other information.
347 ******************************************************************************/
349 void
350 AcpiDbDumpNamespace (
351 char *StartArg,
352 char *DepthArg)
354 ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode;
355 UINT32 MaxDepth = ACPI_UINT32_MAX;
358 /* No argument given, just start at the root and dump entire namespace */
360 if (StartArg)
362 SubtreeEntry = AcpiDbConvertToNode (StartArg);
363 if (!SubtreeEntry)
365 return;
368 /* Now we can check for the depth argument */
370 if (DepthArg)
372 MaxDepth = strtoul (DepthArg, NULL, 0);
376 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
378 if (((ACPI_NAMESPACE_NODE *) SubtreeEntry)->Parent)
380 AcpiOsPrintf ("ACPI Namespace (from %4.4s (%p) subtree):\n",
381 ((ACPI_NAMESPACE_NODE *) SubtreeEntry)->Name.Ascii, SubtreeEntry);
383 else
385 AcpiOsPrintf ("ACPI Namespace (from %s):\n",
386 ACPI_NAMESPACE_ROOT);
389 /* Display the subtree */
391 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
392 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth,
393 ACPI_OWNER_ID_MAX, SubtreeEntry);
394 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
398 /*******************************************************************************
400 * FUNCTION: AcpiDbDumpNamespacePaths
402 * PARAMETERS: None
404 * RETURN: None
406 * DESCRIPTION: Dump entire namespace with full object pathnames and object
407 * type information. Alternative to "namespace" command.
409 ******************************************************************************/
411 void
412 AcpiDbDumpNamespacePaths (
413 void)
416 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
417 AcpiOsPrintf ("ACPI Namespace (from root):\n");
419 /* Display the entire namespace */
421 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
422 AcpiNsDumpObjectPaths (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY,
423 ACPI_UINT32_MAX, ACPI_OWNER_ID_MAX, AcpiGbl_RootNode);
425 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
429 /*******************************************************************************
431 * FUNCTION: AcpiDbDumpNamespaceByOwner
433 * PARAMETERS: OwnerArg - Owner ID whose nodes will be displayed
434 * DepthArg - Maximum tree depth to be dumped
436 * RETURN: None
438 * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId.
440 ******************************************************************************/
442 void
443 AcpiDbDumpNamespaceByOwner (
444 char *OwnerArg,
445 char *DepthArg)
447 ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode;
448 UINT32 MaxDepth = ACPI_UINT32_MAX;
449 ACPI_OWNER_ID OwnerId;
452 OwnerId = (ACPI_OWNER_ID) strtoul (OwnerArg, NULL, 0);
454 /* Now we can check for the depth argument */
456 if (DepthArg)
458 MaxDepth = strtoul (DepthArg, NULL, 0);
461 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
462 AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId);
464 /* Display the subtree */
466 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
467 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth,
468 OwnerId, SubtreeEntry);
469 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
473 /*******************************************************************************
475 * FUNCTION: AcpiDbWalkAndMatchName
477 * PARAMETERS: Callback from WalkNamespace
479 * RETURN: Status
481 * DESCRIPTION: Find a particular name/names within the namespace. Wildcards
482 * are supported -- '?' matches any character.
484 ******************************************************************************/
486 static ACPI_STATUS
487 AcpiDbWalkAndMatchName (
488 ACPI_HANDLE ObjHandle,
489 UINT32 NestingLevel,
490 void *Context,
491 void **ReturnValue)
493 ACPI_STATUS Status;
494 char *RequestedName = (char *) Context;
495 UINT32 i;
496 ACPI_BUFFER Buffer;
497 ACPI_WALK_INFO Info;
500 /* Check for a name match */
502 for (i = 0; i < 4; i++)
504 /* Wildcard support */
506 if ((RequestedName[i] != '?') &&
507 (RequestedName[i] != ((ACPI_NAMESPACE_NODE *)
508 ObjHandle)->Name.Ascii[i]))
510 /* No match, just exit */
512 return (AE_OK);
516 /* Get the full pathname to this object */
518 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
519 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer, TRUE);
520 if (ACPI_FAILURE (Status))
522 AcpiOsPrintf ("Could Not get pathname for object %p\n",
523 ObjHandle);
525 else
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);
536 return (AE_OK);
540 /*******************************************************************************
542 * FUNCTION: AcpiDbFindNameInNamespace
544 * PARAMETERS: NameArg - The 4-character ACPI name to find.
545 * wildcards are supported.
547 * RETURN: None
549 * DESCRIPTION: Search the namespace for a given name (with wildcards)
551 ******************************************************************************/
553 ACPI_STATUS
554 AcpiDbFindNameInNamespace (
555 char *NameArg)
557 char AcpiName[5] = "____";
558 char *AcpiNamePtr = AcpiName;
561 if (strlen (NameArg) > ACPI_NAME_SIZE)
563 AcpiOsPrintf ("Name must be no longer than 4 characters\n");
564 return (AE_OK);
567 /* Pad out name with underscores as necessary to create a 4-char name */
569 AcpiUtStrupr (NameArg);
570 while (*NameArg)
572 *AcpiNamePtr = *NameArg;
573 AcpiNamePtr++;
574 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);
583 return (AE_OK);
587 /*******************************************************************************
589 * FUNCTION: AcpiDbWalkForPredefinedNames
591 * PARAMETERS: Callback from WalkNamespace
593 * RETURN: Status
595 * DESCRIPTION: Detect and display predefined ACPI names (names that start with
596 * an underscore)
598 ******************************************************************************/
600 static ACPI_STATUS
601 AcpiDbWalkForPredefinedNames (
602 ACPI_HANDLE ObjHandle,
603 UINT32 NestingLevel,
604 void *Context,
605 void **ReturnValue)
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;
611 char *Pathname;
612 char StringBuffer[48];
615 Predefined = AcpiUtMatchPredefinedMethod (Node->Name.Ascii);
616 if (!Predefined)
618 return (AE_OK);
621 Pathname = AcpiNsGetNormalizedPathname (Node, TRUE);
622 if (!Pathname)
624 return (AE_OK);
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),
639 StringBuffer);
641 if (Package)
643 AcpiOsPrintf (" (PkgType %2.2X, ObjType %2.2X, Count %2.2X)",
644 Package->RetInfo.Type, Package->RetInfo.ObjectType1,
645 Package->RetInfo.Count1);
648 AcpiOsPrintf("\n");
650 /* Check that the declared argument count matches the ACPI spec */
652 AcpiNsCheckAcpiCompliance (Pathname, Node, Predefined);
654 ACPI_FREE (Pathname);
655 (*Count)++;
656 return (AE_OK);
660 /*******************************************************************************
662 * FUNCTION: AcpiDbCheckPredefinedNames
664 * PARAMETERS: None
666 * RETURN: None
668 * DESCRIPTION: Validate all predefined names in the namespace
670 ******************************************************************************/
672 void
673 AcpiDbCheckPredefinedNames (
674 void)
676 UINT32 Count = 0;
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
695 * RETURN: Status
697 * DESCRIPTION: Display short info about objects in the namespace
699 ******************************************************************************/
701 static ACPI_STATUS
702 AcpiDbWalkForObjectCounts (
703 ACPI_HANDLE ObjHandle,
704 UINT32 NestingLevel,
705 void *Context,
706 void **ReturnValue)
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);
717 else
719 Info->Types[Node->Type]++;
722 return (AE_OK);
726 /*******************************************************************************
728 * FUNCTION: AcpiDbWalkForSpecificObjects
730 * PARAMETERS: Callback from WalkNamespace
732 * RETURN: Status
734 * DESCRIPTION: Display short info about objects in the namespace
736 ******************************************************************************/
738 static ACPI_STATUS
739 AcpiDbWalkForSpecificObjects (
740 ACPI_HANDLE ObjHandle,
741 UINT32 NestingLevel,
742 void *Context,
743 void **ReturnValue)
745 ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context;
746 ACPI_BUFFER Buffer;
747 ACPI_STATUS Status;
750 Info->Count++;
752 /* Get and display the full pathname to this object */
754 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
755 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer, TRUE);
756 if (ACPI_FAILURE (Status))
758 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
759 return (AE_OK);
762 AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);
763 ACPI_FREE (Buffer.Pointer);
765 /* Dump short info about the object */
767 (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, Info, NULL);
768 return (AE_OK);
772 /*******************************************************************************
774 * FUNCTION: AcpiDbDisplayObjects
776 * PARAMETERS: ObjTypeArg - Type of object to display
777 * DisplayCountArg - Max depth to display
779 * RETURN: None
781 * DESCRIPTION: Display objects in the namespace of the requested type
783 ******************************************************************************/
785 ACPI_STATUS
786 AcpiDbDisplayObjects (
787 char *ObjTypeArg,
788 char *DisplayCountArg)
790 ACPI_WALK_INFO Info;
791 ACPI_OBJECT_TYPE Type;
792 ACPI_OBJECT_INFO *ObjectInfo;
793 UINT32 i;
794 UINT32 TotalObjects = 0;
797 /* No argument means display summary/count of all object types */
799 if (!ObjTypeArg)
801 ObjectInfo = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_OBJECT_INFO));
803 /* Walk the namespace from the root */
805 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
806 ACPI_UINT32_MAX, AcpiDbWalkForObjectCounts, NULL,
807 (void *) ObjectInfo, NULL);
809 AcpiOsPrintf ("\nSummary of namespace objects:\n\n");
811 for (i = 0; i < ACPI_TOTAL_TYPES; i++)
813 AcpiOsPrintf ("%8u %s\n", ObjectInfo->Types[i],
814 AcpiUtGetTypeName (i));
816 TotalObjects += ObjectInfo->Types[i];
819 AcpiOsPrintf ("\n%8u Total namespace objects\n\n",
820 TotalObjects);
822 ACPI_FREE (ObjectInfo);
823 return (AE_OK);
826 /* Get the object type */
828 Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes);
829 if (Type == ACPI_TYPE_NOT_FOUND)
831 AcpiOsPrintf ("Invalid or unsupported argument\n");
832 return (AE_OK);
835 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
836 AcpiOsPrintf (
837 "Objects of type [%s] defined in the current ACPI Namespace:\n",
838 AcpiUtGetTypeName (Type));
840 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
842 Info.Count = 0;
843 Info.OwnerId = ACPI_OWNER_ID_MAX;
844 Info.DebugLevel = ACPI_UINT32_MAX;
845 Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
847 /* Walk the namespace from the root */
849 (void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
850 AcpiDbWalkForSpecificObjects, NULL, (void *) &Info, NULL);
852 AcpiOsPrintf (
853 "\nFound %u objects of type [%s] in the current ACPI Namespace\n",
854 Info.Count, AcpiUtGetTypeName (Type));
856 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
857 return (AE_OK);
861 /*******************************************************************************
863 * FUNCTION: AcpiDbIntegrityWalk
865 * PARAMETERS: Callback from WalkNamespace
867 * RETURN: Status
869 * DESCRIPTION: Examine one NS node for valid values.
871 ******************************************************************************/
873 static ACPI_STATUS
874 AcpiDbIntegrityWalk (
875 ACPI_HANDLE ObjHandle,
876 UINT32 NestingLevel,
877 void *Context,
878 void **ReturnValue)
880 ACPI_INTEGRITY_INFO *Info = (ACPI_INTEGRITY_INFO *) Context;
881 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
882 ACPI_OPERAND_OBJECT *Object;
883 BOOLEAN Alias = TRUE;
886 Info->Nodes++;
888 /* Verify the NS node, and dereference aliases */
890 while (Alias)
892 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
894 AcpiOsPrintf (
895 "Invalid Descriptor Type for Node %p [%s] - "
896 "is %2.2X should be %2.2X\n",
897 Node, AcpiUtGetDescriptorName (Node),
898 ACPI_GET_DESCRIPTOR_TYPE (Node), ACPI_DESC_TYPE_NAMED);
899 return (AE_OK);
902 if ((Node->Type == ACPI_TYPE_LOCAL_ALIAS) ||
903 (Node->Type == ACPI_TYPE_LOCAL_METHOD_ALIAS))
905 Node = (ACPI_NAMESPACE_NODE *) Node->Object;
907 else
909 Alias = FALSE;
913 if (Node->Type > ACPI_TYPE_LOCAL_MAX)
915 AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n",
916 Node, Node->Type);
917 return (AE_OK);
920 if (!AcpiUtValidNameseg (Node->Name.Ascii))
922 AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node);
923 return (AE_OK);
926 Object = AcpiNsGetAttachedObject (Node);
927 if (Object)
929 Info->Objects++;
930 if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
932 AcpiOsPrintf ("Invalid Descriptor Type for Object %p [%s]\n",
933 Object, AcpiUtGetDescriptorName (Object));
937 return (AE_OK);
941 /*******************************************************************************
943 * FUNCTION: AcpiDbCheckIntegrity
945 * PARAMETERS: None
947 * RETURN: None
949 * DESCRIPTION: Check entire namespace for data structure integrity
951 ******************************************************************************/
953 void
954 AcpiDbCheckIntegrity (
955 void)
957 ACPI_INTEGRITY_INFO Info = {0,0};
959 /* Search all nodes in namespace */
961 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
962 ACPI_UINT32_MAX, AcpiDbIntegrityWalk, NULL, (void *) &Info, NULL);
964 AcpiOsPrintf ("Verified %u namespace nodes with %u Objects\n",
965 Info.Nodes, Info.Objects);
969 /*******************************************************************************
971 * FUNCTION: AcpiDbWalkForReferences
973 * PARAMETERS: Callback from WalkNamespace
975 * RETURN: Status
977 * DESCRIPTION: Check if this namespace object refers to the target object
978 * that is passed in as the context value.
980 * Note: Currently doesn't check subobjects within the Node's object
982 ******************************************************************************/
984 static ACPI_STATUS
985 AcpiDbWalkForReferences (
986 ACPI_HANDLE ObjHandle,
987 UINT32 NestingLevel,
988 void *Context,
989 void **ReturnValue)
991 ACPI_OPERAND_OBJECT *ObjDesc = (ACPI_OPERAND_OBJECT *) Context;
992 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
995 /* Check for match against the namespace node itself */
997 if (Node == (void *) ObjDesc)
999 AcpiOsPrintf ("Object is a Node [%4.4s]\n",
1000 AcpiUtGetNodeName (Node));
1003 /* Check for match against the object attached to the node */
1005 if (AcpiNsGetAttachedObject (Node) == ObjDesc)
1007 AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n",
1008 Node, AcpiUtGetNodeName (Node));
1011 return (AE_OK);
1015 /*******************************************************************************
1017 * FUNCTION: AcpiDbFindReferences
1019 * PARAMETERS: ObjectArg - String with hex value of the object
1021 * RETURN: None
1023 * DESCRIPTION: Search namespace for all references to the input object
1025 ******************************************************************************/
1027 void
1028 AcpiDbFindReferences (
1029 char *ObjectArg)
1031 ACPI_OPERAND_OBJECT *ObjDesc;
1032 ACPI_SIZE Address;
1035 /* Convert string to object pointer */
1037 Address = strtoul (ObjectArg, NULL, 16);
1038 ObjDesc = ACPI_TO_POINTER (Address);
1040 /* Search all nodes in namespace */
1042 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
1043 ACPI_UINT32_MAX, AcpiDbWalkForReferences, NULL,
1044 (void *) ObjDesc, NULL);
1048 /*******************************************************************************
1050 * FUNCTION: AcpiDbBusWalk
1052 * PARAMETERS: Callback from WalkNamespace
1054 * RETURN: Status
1056 * DESCRIPTION: Display info about device objects that have a corresponding
1057 * _PRT method.
1059 ******************************************************************************/
1061 static ACPI_STATUS
1062 AcpiDbBusWalk (
1063 ACPI_HANDLE ObjHandle,
1064 UINT32 NestingLevel,
1065 void *Context,
1066 void **ReturnValue)
1068 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
1069 ACPI_STATUS Status;
1070 ACPI_BUFFER Buffer;
1071 ACPI_NAMESPACE_NODE *TempNode;
1072 ACPI_DEVICE_INFO *Info;
1073 UINT32 i;
1076 if ((Node->Type != ACPI_TYPE_DEVICE) &&
1077 (Node->Type != ACPI_TYPE_PROCESSOR))
1079 return (AE_OK);
1082 /* Exit if there is no _PRT under this device */
1084 Status = AcpiGetHandle (Node, METHOD_NAME__PRT,
1085 ACPI_CAST_PTR (ACPI_HANDLE, &TempNode));
1086 if (ACPI_FAILURE (Status))
1088 return (AE_OK);
1091 /* Get the full path to this device object */
1093 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1094 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer, TRUE);
1095 if (ACPI_FAILURE (Status))
1097 AcpiOsPrintf ("Could Not get pathname for object %p\n",
1098 ObjHandle);
1099 return (AE_OK);
1102 Status = AcpiGetObjectInfo (ObjHandle, &Info);
1103 if (ACPI_FAILURE (Status))
1105 return (AE_OK);
1108 /* Display the full path */
1110 AcpiOsPrintf ("%-32s Type %X", (char *) Buffer.Pointer, Node->Type);
1111 ACPI_FREE (Buffer.Pointer);
1113 if (Info->Flags & ACPI_PCI_ROOT_BRIDGE)
1115 AcpiOsPrintf (" - Is PCI Root Bridge");
1117 AcpiOsPrintf ("\n");
1119 /* _PRT info */
1121 AcpiOsPrintf ("_PRT: %p\n", TempNode);
1123 /* Dump _ADR, _HID, _UID, _CID */
1125 if (Info->Valid & ACPI_VALID_ADR)
1127 AcpiOsPrintf ("_ADR: %8.8X%8.8X\n",
1128 ACPI_FORMAT_UINT64 (Info->Address));
1130 else
1132 AcpiOsPrintf ("_ADR: <Not Present>\n");
1135 if (Info->Valid & ACPI_VALID_HID)
1137 AcpiOsPrintf ("_HID: %s\n", Info->HardwareId.String);
1139 else
1141 AcpiOsPrintf ("_HID: <Not Present>\n");
1144 if (Info->Valid & ACPI_VALID_UID)
1146 AcpiOsPrintf ("_UID: %s\n", Info->UniqueId.String);
1148 else
1150 AcpiOsPrintf ("_UID: <Not Present>\n");
1153 if (Info->Valid & ACPI_VALID_CID)
1155 for (i = 0; i < Info->CompatibleIdList.Count; i++)
1157 AcpiOsPrintf ("_CID: %s\n",
1158 Info->CompatibleIdList.Ids[i].String);
1161 else
1163 AcpiOsPrintf ("_CID: <Not Present>\n");
1166 ACPI_FREE (Info);
1167 return (AE_OK);
1171 /*******************************************************************************
1173 * FUNCTION: AcpiDbGetBusInfo
1175 * PARAMETERS: None
1177 * RETURN: None
1179 * DESCRIPTION: Display info about system busses.
1181 ******************************************************************************/
1183 void
1184 AcpiDbGetBusInfo (
1185 void)
1187 /* Search all nodes in namespace */
1189 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
1190 ACPI_UINT32_MAX, AcpiDbBusWalk, NULL, NULL, NULL);
1193 #endif /* ACPI_DEBUGGER */