1 /*******************************************************************************
3 * Module Name: dbcmds - debug commands and output routines
6 ******************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
13 * All rights reserved.
17 * 2.1. This is your license from Intel Corp. under its intellectual property
18 * rights. You may have additional license terms from the party that provided
19 * you this software, covering your right to use that party's intellectual
22 * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23 * copy of the source code appearing in this file ("Covered Code") an
24 * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25 * base code distributed originally by Intel ("Original Intel Code") to copy,
26 * make derivatives, distribute, use and display any portion of the Covered
27 * Code in any form, with the right to sublicense such rights; and
29 * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30 * license (with the right to sublicense), under only those claims of Intel
31 * patents that are infringed by the Original Intel Code, to make, use, sell,
32 * offer to sell, and import the Covered Code and derivative works thereof
33 * solely to the minimum extent necessary to exercise the above copyright
34 * license, and in no event shall the patent license extend to any additions
35 * to or modifications of the Original Intel Code. No other license or right
36 * is granted directly or by implication, estoppel or otherwise;
38 * The above copyright and patent license is granted only if the following
43 * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44 * Redistribution of source code of any substantial portion of the Covered
45 * Code or modification with rights to further distribute source must include
46 * the above Copyright Notice, the above License, this list of Conditions,
47 * and the following Disclaimer and Export Compliance provision. In addition,
48 * Licensee must cause all Covered Code to which Licensee contributes to
49 * contain a file documenting the changes Licensee made to create that Covered
50 * Code and the date of any change. Licensee must include in that file the
51 * documentation of any changes made by any predecessor Licensee. Licensee
52 * must include a prominent statement that the modification is derived,
53 * directly or indirectly, from Original Intel Code.
55 * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56 * Redistribution of source code of any substantial portion of the Covered
57 * Code or modification without rights to further distribute source must
58 * include the following Disclaimer and Export Compliance provision in the
59 * documentation and/or other materials provided with distribution. In
60 * addition, Licensee may not authorize further sublicense of source of any
61 * portion of the Covered Code, and must include terms to the effect that the
62 * license from Licensee to its licensee is limited to the intellectual
63 * property embodied in the software Licensee provides to its licensee, and
64 * not to intellectual property embodied in modifications its licensee may
67 * 3.3. Redistribution of Executable. Redistribution in executable form of any
68 * substantial portion of the Covered Code or modification must reproduce the
69 * above Copyright Notice, and the following Disclaimer and Export Compliance
70 * provision in the documentation and/or other materials provided with the
73 * 3.4. Intel retains all right, title, and interest in and to the Original
76 * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77 * Intel shall be used in advertising or otherwise to promote the sale, use or
78 * other dealings in products derived from or relating to the Covered Code
79 * without prior written authorization from Intel.
81 * 4. Disclaimer and Export Compliance
83 * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84 * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85 * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
86 * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
87 * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
88 * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
91 * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92 * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93 * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94 * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95 * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96 * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
97 * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
100 * 4.3. Licensee shall not export, either directly or indirectly, any of this
101 * software or system incorporating such software without first obtaining any
102 * required license or other approval from the U. S. Department of Commerce or
103 * any other agency or department of the United States Government. In the
104 * event Licensee exports any such software from the United States or
105 * re-exports any such software from a foreign destination, Licensee shall
106 * ensure that the distribution and export/re-export of the software is in
107 * compliance with all laws, regulations, orders, or other restrictions of the
108 * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109 * any of its subsidiaries will export/re-export any technical data, process,
110 * software, or service, directly or indirectly, to any country for which the
111 * United States government or any agency thereof requires an export license,
112 * other governmental approval, or letter of assurance, without first obtaining
113 * such license, approval or letter.
115 *****************************************************************************/
116 /* $DragonFly: src/sys/contrib/dev/acpica/Attic/dbcmds.c,v 1.1 2003/09/24 03:32:15 drhodus Exp $ */
119 #include "acdispat.h"
121 #include "acnamesp.h"
122 #include "acevents.h"
125 #include "acdisasm.h"
129 #define _COMPONENT ACPI_CA_DEBUGGER
130 ACPI_MODULE_NAME ("dbcmds")
134 * Arguments for the Objects command
135 * These object types map directly to the ACPI_TYPES
138 static ARGUMENT_INFO AcpiDbObjectTypes [] =
156 {NULL} /* Must be null terminated */
160 /*******************************************************************************
162 * FUNCTION: AcpiDbWalkForReferences
164 * PARAMETERS: Callback from WalkNamespace
168 * DESCRIPTION: Check if this namespace object refers to the target object
169 * that is passed in as the context value.
171 * Note: Currently doesn't check subobjects within the Node's object
173 ******************************************************************************/
176 AcpiDbWalkForReferences (
177 ACPI_HANDLE ObjHandle,
182 ACPI_OPERAND_OBJECT *ObjDesc = (ACPI_OPERAND_OBJECT *) Context;
183 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
186 /* Check for match against the namespace node itself */
188 if (Node == (void *) ObjDesc)
190 AcpiOsPrintf ("Object is a Node [%4.4s]\n", Node->Name.Ascii);
193 /* Check for match against the object attached to the node */
195 if (AcpiNsGetAttachedObject (Node) == ObjDesc)
197 AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n", Node, Node->Name.Ascii);
204 /*******************************************************************************
206 * FUNCTION: AcpiDbFindReferences
208 * PARAMETERS: ObjectArg - String with hex value of the object
212 * DESCRIPTION: Search namespace for all references to the input object
214 ******************************************************************************/
217 AcpiDbFindReferences (
220 ACPI_OPERAND_OBJECT *ObjDesc;
223 /* Convert string to object pointer */
225 ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16));
227 /* Search all nodes in namespace */
229 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
230 AcpiDbWalkForReferences, (void *) ObjDesc, NULL);
234 /*******************************************************************************
236 * FUNCTION: AcpiDbDisplayLocks
242 * DESCRIPTION: Display information about internal mutexes.
244 ******************************************************************************/
247 AcpiDbDisplayLocks (void)
252 for (i = 0; i < MAX_MTX; i++)
254 AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i),
255 AcpiGbl_AcpiMutexInfo[i].OwnerId == ACPI_MUTEX_NOT_ACQUIRED
256 ? "Locked" : "Unlocked");
261 /*******************************************************************************
263 * FUNCTION: AcpiDbDisplayTableInfo
265 * PARAMETERS: TableArg - String with name of table to be displayed
269 * DESCRIPTION: Display information about loaded tables. Current
270 * implementation displays all loaded tables.
272 ******************************************************************************/
275 AcpiDbDisplayTableInfo (
281 for (i = 0; i < NUM_ACPI_TABLES; i++)
283 if (AcpiGbl_AcpiTables[i].Pointer)
285 AcpiOsPrintf ("%s at %p length %X\n", AcpiGbl_AcpiTableData[i].Name,
286 AcpiGbl_AcpiTables[i].Pointer,
287 (UINT32) AcpiGbl_AcpiTables[i].Length);
293 /*******************************************************************************
295 * FUNCTION: AcpiDbUnloadAcpiTable
297 * PARAMETERS: TableArg - Name of the table to be unloaded
298 * InstanceArg - Which instance of the table to unload (if
299 * there are multiple tables of the same type)
303 * DESCRIPTION: Unload an ACPI table.
304 * Instance is not implemented
306 ******************************************************************************/
309 AcpiDbUnloadAcpiTable (
317 /* Search all tables for the target type */
319 for (i = 0; i < NUM_ACPI_TABLES; i++)
321 if (!ACPI_STRNCMP (TableArg, AcpiGbl_AcpiTableData[i].Signature,
322 AcpiGbl_AcpiTableData[i].SigLength))
324 /* Found the table, unload it */
326 Status = AcpiUnloadTable (i);
327 if (ACPI_SUCCESS (Status))
329 AcpiOsPrintf ("[%s] unloaded and uninstalled\n", TableArg);
333 AcpiOsPrintf ("%s, while unloading [%s]\n",
334 AcpiFormatException (Status), TableArg);
341 AcpiOsPrintf ("Unknown table type [%s]\n", TableArg);
345 /*******************************************************************************
347 * FUNCTION: AcpiDbSetMethodBreakpoint
349 * PARAMETERS: Location - AML offset of breakpoint
350 * WalkState - Current walk info
351 * Op - Current Op (from parse walk)
355 * DESCRIPTION: Set a breakpoint in a control method at the specified
358 ******************************************************************************/
361 AcpiDbSetMethodBreakpoint (
363 ACPI_WALK_STATE *WalkState,
364 ACPI_PARSE_OBJECT *Op)
371 AcpiOsPrintf ("There is no method currently executing\n");
375 /* Get and verify the breakpoint address */
377 Address = ACPI_STRTOUL (Location, NULL, 16);
378 if (Address <= Op->Common.AmlOffset)
380 AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n", Address, Op->Common.AmlOffset);
383 /* Save breakpoint in current walk */
385 WalkState->UserBreakpoint = Address;
386 AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address);
390 /*******************************************************************************
392 * FUNCTION: AcpiDbSetMethodCallBreakpoint
394 * PARAMETERS: Op - Current Op (from parse walk)
398 * DESCRIPTION: Set a breakpoint in a control method at the specified
401 ******************************************************************************/
404 AcpiDbSetMethodCallBreakpoint (
405 ACPI_PARSE_OBJECT *Op)
411 AcpiOsPrintf ("There is no method currently executing\n");
415 AcpiGbl_StepToNextCall = TRUE;
419 /*******************************************************************************
421 * FUNCTION: AcpiDbDisassembleAml
423 * PARAMETERS: Statements - Number of statements to disassemble
424 * Op - Current Op (from parse walk)
428 * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
429 * of statements specified.
431 ******************************************************************************/
434 AcpiDbDisassembleAml (
436 ACPI_PARSE_OBJECT *Op)
438 UINT32 NumStatements = 8;
443 AcpiOsPrintf ("There is no method currently executing\n");
449 NumStatements = ACPI_STRTOUL (Statements, NULL, 0);
452 #ifdef ACPI_DISASSEMBLER
453 AcpiDmDisassemble (NULL, Op, NumStatements);
458 /*******************************************************************************
460 * FUNCTION: AcpiDbDumpNamespace
462 * PARAMETERS: StartArg - Node to begin namespace dump
463 * DepthArg - Maximum tree depth to be dumped
467 * DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed
468 * with type and other information.
470 ******************************************************************************/
473 AcpiDbDumpNamespace (
477 ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode;
478 UINT32 MaxDepth = ACPI_UINT32_MAX;
481 /* No argument given, just start at the root and dump entire namespace */
485 /* Check if numeric argument, must be a Node */
487 if ((StartArg[0] >= 0x30) && (StartArg[0] <= 0x39))
489 SubtreeEntry = ACPI_TO_POINTER (ACPI_STRTOUL (StartArg, NULL, 16));
490 if (!AcpiOsReadable (SubtreeEntry, sizeof (ACPI_NAMESPACE_NODE)))
492 AcpiOsPrintf ("Address %p is invalid in this address space\n", SubtreeEntry);
496 if (ACPI_GET_DESCRIPTOR_TYPE (SubtreeEntry) != ACPI_DESC_TYPE_NAMED)
498 AcpiOsPrintf ("Address %p is not a valid Named object\n", SubtreeEntry);
507 /* The parameter is a name string that must be resolved to a Named obj*/
509 SubtreeEntry = AcpiDbLocalNsLookup (StartArg);
512 SubtreeEntry = AcpiGbl_RootNode;
516 /* Now we can check for the depth argument */
520 MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
524 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
525 AcpiOsPrintf ("ACPI Namespace (from %p subtree):\n", SubtreeEntry);
527 /* Display the subtree */
529 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
530 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, ACPI_UINT32_MAX, SubtreeEntry);
531 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
535 /*******************************************************************************
537 * FUNCTION: AcpiDbDumpNamespaceByOwner
539 * PARAMETERS: OwnerArg - Owner ID whose nodes will be displayed
540 * DepthArg - Maximum tree depth to be dumped
544 * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId.
546 ******************************************************************************/
549 AcpiDbDumpNamespaceByOwner (
553 ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode;
554 UINT32 MaxDepth = ACPI_UINT32_MAX;
558 OwnerId = (UINT16) ACPI_STRTOUL (OwnerArg, NULL, 0);
560 /* Now we can check for the depth argument */
564 MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
567 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
568 AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId);
570 /* Display the subtree */
572 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
573 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId, SubtreeEntry);
574 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
578 /*******************************************************************************
580 * FUNCTION: AcpiDbSendNotify
582 * PARAMETERS: Name - Name of ACPI object to send the notify to
583 * Value - Value of the notify to send.
587 * DESCRIPTION: Send an ACPI notification. The value specified is sent to the
588 * named object as an ACPI notify.
590 ******************************************************************************/
597 ACPI_NAMESPACE_NODE *Node;
601 /* Translate name to an Named object */
603 Node = AcpiDbLocalNsLookup (Name);
609 /* Decode Named object type */
613 case ACPI_TYPE_DEVICE:
614 case ACPI_TYPE_THERMAL:
616 /* Send the notify */
618 Status = AcpiEvQueueNotifyRequest (Node, Value);
619 if (ACPI_FAILURE (Status))
621 AcpiOsPrintf ("Could not queue notify\n");
626 AcpiOsPrintf ("Named object is not a device or a thermal object\n");
633 /*******************************************************************************
635 * FUNCTION: AcpiDbSetMethodData
637 * PARAMETERS: TypeArg - L for local, A for argument
638 * IndexArg - which one
639 * ValueArg - Value to set.
643 * DESCRIPTION: Set a local or argument for the running control method.
644 * NOTE: only object supported is Number.
646 ******************************************************************************/
649 AcpiDbSetMethodData (
657 ACPI_WALK_STATE *WalkState;
658 ACPI_OPERAND_OBJECT *ObjDesc;
662 /* Validate TypeArg */
664 ACPI_STRUPR (TypeArg);
669 AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg);
673 /* Get the index and value */
675 Index = ACPI_STRTOUL (IndexArg, NULL, 16);
676 Value = ACPI_STRTOUL (ValueArg, NULL, 16);
678 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
681 AcpiOsPrintf ("There is no method currently executing\n");
686 /* Create and initialize the new object */
688 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
691 AcpiOsPrintf ("Could not create an internal object\n");
695 ObjDesc->Integer.Value = Value;
698 /* Store the new object into the target */
704 /* Set a method argument */
706 if (Index > ACPI_METHOD_MAX_ARG)
708 AcpiOsPrintf ("Arg%d - Invalid argument name\n", Index);
712 Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Index, ObjDesc, WalkState);
713 if (ACPI_FAILURE (Status))
718 ObjDesc = WalkState->Arguments[Index].Object;
720 AcpiOsPrintf ("Arg%d: ", Index);
721 AcpiDbDisplayInternalObject (ObjDesc, WalkState);
726 /* Set a method local */
728 if (Index > ACPI_METHOD_MAX_LOCAL)
730 AcpiOsPrintf ("Local%d - Invalid local variable name\n", Index);
734 Status = AcpiDsStoreObjectToLocal (AML_LOCAL_OP, Index, ObjDesc, WalkState);
735 if (ACPI_FAILURE (Status))
740 ObjDesc = WalkState->LocalVariables[Index].Object;
742 AcpiOsPrintf ("Local%d: ", Index);
743 AcpiDbDisplayInternalObject (ObjDesc, WalkState);
752 /*******************************************************************************
754 * FUNCTION: AcpiDbWalkForSpecificObjects
756 * PARAMETERS: Callback from WalkNamespace
760 * DESCRIPTION: Display short info about objects in the namespace
762 ******************************************************************************/
765 AcpiDbWalkForSpecificObjects (
766 ACPI_HANDLE ObjHandle,
771 ACPI_OPERAND_OBJECT *ObjDesc;
776 ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjHandle);
778 /* Get and display the full pathname to this object */
780 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
781 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
782 if (ACPI_FAILURE (Status))
784 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
788 AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);
789 ACPI_MEM_FREE (Buffer.Pointer);
792 /* Display short information about the object */
796 switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
798 case ACPI_TYPE_METHOD:
799 AcpiOsPrintf (" #Args %d Concurrency %X",
800 ObjDesc->Method.ParamCount, ObjDesc->Method.Concurrency);
803 case ACPI_TYPE_INTEGER:
804 AcpiOsPrintf (" Value %8.8X%8.8X",
805 ACPI_HIDWORD (ObjDesc->Integer.Value),
806 ACPI_LODWORD (ObjDesc->Integer.Value));
809 case ACPI_TYPE_STRING:
810 AcpiOsPrintf (" \"%s\"", ObjDesc->String.Pointer);
813 case ACPI_TYPE_REGION:
814 AcpiOsPrintf (" SpaceId %X Length %X Address %8.8X%8.8X",
815 ObjDesc->Region.SpaceId,
816 ObjDesc->Region.Length,
817 ACPI_HIDWORD (ObjDesc->Region.Address),
818 ACPI_LODWORD (ObjDesc->Region.Address));
821 case ACPI_TYPE_PACKAGE:
822 AcpiOsPrintf (" #Elements %X", ObjDesc->Package.Count);
825 case ACPI_TYPE_BUFFER:
826 AcpiOsPrintf (" Length %X", ObjDesc->Buffer.Length);
830 /* Ignore other object types */
840 /*******************************************************************************
842 * FUNCTION: AcpiDbDisplayObjects
844 * PARAMETERS: ObjTypeArg - Type of object to display
845 * DisplayCountArg - Max depth to display
849 * DESCRIPTION: Display objects in the namespace of the requested type
851 ******************************************************************************/
854 AcpiDbDisplayObjects (
856 char *DisplayCountArg)
858 ACPI_OBJECT_TYPE Type;
861 /* Get the object type */
863 Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes);
864 if (Type == ACPI_TYPE_NOT_FOUND)
866 AcpiOsPrintf ("Invalid or unsupported argument\n");
870 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
871 AcpiOsPrintf ("Objects of type [%s] defined in the current ACPI Namespace: \n",
872 AcpiUtGetTypeName (Type));
874 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
876 /* Walk the namespace from the root */
878 (void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
879 AcpiDbWalkForSpecificObjects, (void *) &Type, NULL);
881 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
886 /*******************************************************************************
888 * FUNCTION: AcpiDbWalkAndMatchName
890 * PARAMETERS: Callback from WalkNamespace
894 * DESCRIPTION: Find a particular name/names within the namespace. Wildcards
895 * are supported -- '?' matches any character.
897 ******************************************************************************/
900 AcpiDbWalkAndMatchName (
901 ACPI_HANDLE ObjHandle,
907 char *RequestedName = (char *) Context;
912 /* Check for a name match */
914 for (i = 0; i < 4; i++)
916 /* Wildcard support */
918 if ((RequestedName[i] != '?') &&
919 (RequestedName[i] != ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii[i]))
921 /* No match, just exit */
928 /* Get the full pathname to this object */
930 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
931 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
932 if (ACPI_FAILURE (Status))
934 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
938 AcpiOsPrintf ("%32s (%p) - %s\n", (char *) Buffer.Pointer, ObjHandle,
939 AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) ObjHandle)->Type));
940 ACPI_MEM_FREE (Buffer.Pointer);
947 /*******************************************************************************
949 * FUNCTION: AcpiDbFindNameInNamespace
951 * PARAMETERS: NameArg - The 4-character ACPI name to find.
952 * wildcards are supported.
956 * DESCRIPTION: Search the namespace for a given name (with wildcards)
958 ******************************************************************************/
961 AcpiDbFindNameInNamespace (
965 if (ACPI_STRLEN (NameArg) > 4)
967 AcpiOsPrintf ("Name must be no longer than 4 characters\n");
971 /* Walk the namespace from the root */
973 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
974 AcpiDbWalkAndMatchName, NameArg, NULL);
976 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
981 /*******************************************************************************
983 * FUNCTION: AcpiDbSetScope
985 * PARAMETERS: Name - New scope path
989 * DESCRIPTION: Set the "current scope" as maintained by this utility.
990 * The scope is used as a prefix to ACPI paths.
992 ******************************************************************************/
999 ACPI_NAMESPACE_NODE *Node;
1002 if (!Name || Name[0] == 0)
1004 AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf);
1008 AcpiDbPrepNamestring (Name);
1011 if (Name[0] == '\\')
1013 /* Validate new scope from the root */
1015 Status = AcpiNsGetNodeByPath (Name, AcpiGbl_RootNode, ACPI_NS_NO_UPSEARCH, &Node);
1016 if (ACPI_FAILURE (Status))
1021 ACPI_STRCPY (AcpiGbl_DbScopeBuf, Name);
1022 ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
1026 /* Validate new scope relative to old scope */
1028 Status = AcpiNsGetNodeByPath (Name, AcpiGbl_DbScopeNode, ACPI_NS_NO_UPSEARCH, &Node);
1029 if (ACPI_FAILURE (Status))
1034 ACPI_STRCAT (AcpiGbl_DbScopeBuf, Name);
1035 ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
1038 AcpiGbl_DbScopeNode = Node;
1039 AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf);
1045 AcpiOsPrintf ("Could not attach scope: %s, %s\n", Name, AcpiFormatException (Status));
1049 /*******************************************************************************
1051 * FUNCTION: AcpiDbDisplayResources
1053 * PARAMETERS: ObjectArg - String with hex value of the object
1057 * DESCRIPTION: Display the resource objects associated with a device.
1059 ******************************************************************************/
1062 AcpiDbDisplayResources (
1065 #if ACPI_MACHINE_WIDTH != 16
1067 ACPI_OPERAND_OBJECT *ObjDesc;
1069 ACPI_BUFFER ReturnObj;
1072 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
1073 AcpiDbgLevel |= ACPI_LV_RESOURCES;
1075 /* Convert string to object pointer */
1077 ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16));
1079 /* Prepare for a return object of arbitrary size */
1081 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1082 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1086 AcpiOsPrintf ("Evaluating _PRT\n");
1088 Status = AcpiEvaluateObject (ObjDesc, "_PRT", NULL, &ReturnObj);
1089 if (ACPI_FAILURE (Status))
1091 AcpiOsPrintf ("Could not obtain _PRT: %s\n", AcpiFormatException (Status));
1095 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1096 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1098 Status = AcpiGetIrqRoutingTable (ObjDesc, &ReturnObj);
1099 if (ACPI_FAILURE (Status))
1101 AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n", AcpiFormatException (Status));
1106 AcpiRsDumpIrqList ((UINT8 *) AcpiGbl_DbBuffer);
1113 AcpiOsPrintf ("Evaluating _CRS\n");
1115 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1116 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1118 Status = AcpiEvaluateObject (ObjDesc, "_CRS", NULL, &ReturnObj);
1119 if (ACPI_FAILURE (Status))
1121 AcpiOsPrintf ("Could not obtain _CRS: %s\n", AcpiFormatException (Status));
1125 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1126 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1128 Status = AcpiGetCurrentResources (ObjDesc, &ReturnObj);
1129 if (ACPI_FAILURE (Status))
1131 AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", AcpiFormatException (Status));
1137 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer));
1140 Status = AcpiSetCurrentResources (ObjDesc, &ReturnObj);
1141 if (ACPI_FAILURE (Status))
1143 AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n", AcpiFormatException (Status));
1151 AcpiOsPrintf ("Evaluating _PRS\n");
1153 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1154 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1156 Status = AcpiEvaluateObject (ObjDesc, "_PRS", NULL, &ReturnObj);
1157 if (ACPI_FAILURE (Status))
1159 AcpiOsPrintf ("Could not obtain _PRS: %s\n", AcpiFormatException (Status));
1163 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1164 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1166 Status = AcpiGetPossibleResources (ObjDesc, &ReturnObj);
1167 if (ACPI_FAILURE (Status))
1169 AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n", AcpiFormatException (Status));
1174 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer));
1180 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1187 /*******************************************************************************
1189 * FUNCTION: AcpiDbIntegrityWalk
1191 * PARAMETERS: Callback from WalkNamespace
1195 * DESCRIPTION: Examine one NS node for valid values.
1197 ******************************************************************************/
1200 AcpiDbIntegrityWalk (
1201 ACPI_HANDLE ObjHandle,
1202 UINT32 NestingLevel,
1206 ACPI_INTEGRITY_INFO *Info = (ACPI_INTEGRITY_INFO *) Context;
1207 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
1208 ACPI_OPERAND_OBJECT *Object;
1212 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
1214 AcpiOsPrintf ("Invalid Descriptor Type for Node %p, Type = %X\n",
1215 Node, ACPI_GET_DESCRIPTOR_TYPE (Node));
1218 if (Node->Type > ACPI_TYPE_LOCAL_MAX)
1220 AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n",
1224 if (!AcpiUtValidAcpiName (Node->Name.Integer))
1226 AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node);
1229 Object = AcpiNsGetAttachedObject (Node);
1233 if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
1235 AcpiOsPrintf ("Invalid Descriptor Type for Object %p, Type = %X\n",
1236 Object, ACPI_GET_DESCRIPTOR_TYPE (Object));
1245 /*******************************************************************************
1247 * FUNCTION: AcpiDbCheckIntegrity
1253 * DESCRIPTION: Check entire namespace for data structure integrity
1255 ******************************************************************************/
1258 AcpiDbCheckIntegrity (void)
1260 ACPI_INTEGRITY_INFO Info = {0,0};
1262 /* Search all nodes in namespace */
1264 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
1265 AcpiDbIntegrityWalk, (void *) &Info, NULL);
1267 AcpiOsPrintf ("Verified %d namespace nodes with %d Objects\n", Info.Nodes, Info.Objects);
1272 /*******************************************************************************
1274 * FUNCTION: AcpiDbGenerateGpe
1280 * DESCRIPTION: Generate a GPE
1282 ******************************************************************************/
1291 ACPI_GPE_EVENT_INFO *GpeEventInfo;
1294 GpeNumber = ACPI_STRTOUL (GpeArg, NULL, 10);
1295 BlockNumber = ACPI_STRTOUL (BlockArg, NULL, 10);
1298 GpeEventInfo = AcpiEvGetGpeEventInfo (GpeNumber);
1301 AcpiOsPrintf ("Invalid GPE\n");
1305 AcpiEvGpeDispatch (GpeEventInfo);
1309 #endif /* ACPI_DEBUGGER */