1 /*******************************************************************************
3 * Module Name: dbcmds - debug commands and output routines
6 ******************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2007, 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 *****************************************************************************/
118 #include <contrib/dev/acpica/acpi.h>
119 #include <contrib/dev/acpica/acdispat.h>
120 #include <contrib/dev/acpica/amlcode.h>
121 #include <contrib/dev/acpica/acnamesp.h>
122 #include <contrib/dev/acpica/acevents.h>
123 #include <contrib/dev/acpica/acdebug.h>
124 #include <contrib/dev/acpica/acresrc.h>
125 #include <contrib/dev/acpica/acdisasm.h>
128 #include <contrib/dev/acpica/acparser.h>
132 #define _COMPONENT ACPI_CA_DEBUGGER
133 ACPI_MODULE_NAME ("dbcmds")
135 /* Local prototypes */
138 AcpiDbIntegrityWalk (
139 ACPI_HANDLE ObjHandle,
145 AcpiDbWalkAndMatchName (
146 ACPI_HANDLE ObjHandle,
152 AcpiDbWalkForReferences (
153 ACPI_HANDLE ObjHandle,
159 AcpiDbWalkForSpecificObjects (
160 ACPI_HANDLE ObjHandle,
165 static ACPI_NAMESPACE_NODE *
166 AcpiDbConvertToNode (
170 AcpiDmCompareAmlResources (
172 ACPI_RSDESC_SIZE Aml1BufferLength,
174 ACPI_RSDESC_SIZE Aml2BufferLength);
177 AcpiDmTestResourceConversion (
178 ACPI_NAMESPACE_NODE *Node,
183 * Arguments for the Objects command
184 * These object types map directly to the ACPI_TYPES
186 static ARGUMENT_INFO AcpiDbObjectTypes [] =
210 {NULL} /* Must be null terminated */
214 /*******************************************************************************
216 * FUNCTION: AcpiDbConvertToNode
218 * PARAMETERS: InString - String to convert
220 * RETURN: Pointer to a NS node
222 * DESCRIPTION: Convert a string to a valid NS pointer. Handles numeric or
225 ******************************************************************************/
227 static ACPI_NAMESPACE_NODE *
228 AcpiDbConvertToNode (
231 ACPI_NAMESPACE_NODE *Node;
234 if ((*InString >= 0x30) && (*InString <= 0x39))
236 /* Numeric argument, convert */
238 Node = ACPI_TO_POINTER (ACPI_STRTOUL (InString, NULL, 16));
239 if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE)))
241 AcpiOsPrintf ("Address %p is invalid in this address space\n",
246 /* Make sure pointer is valid NS node */
248 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
250 AcpiOsPrintf ("Address %p is not a valid NS node [%s]\n",
251 Node, AcpiUtGetDescriptorName (Node));
258 /* The parameter is a name string that must be resolved to a
261 Node = AcpiDbLocalNsLookup (InString);
264 Node = AcpiGbl_RootNode;
272 /*******************************************************************************
274 * FUNCTION: AcpiDbSleep
276 * PARAMETERS: ObjectArg - Desired sleep state (0-5)
280 * DESCRIPTION: Simulate a sleep/wake sequence
282 ******************************************************************************/
292 SleepState = (UINT8) ACPI_STRTOUL (ObjectArg, NULL, 0);
294 AcpiOsPrintf ("**** Prepare to sleep ****\n");
295 Status = AcpiEnterSleepStatePrep (SleepState);
296 if (ACPI_FAILURE (Status))
301 AcpiOsPrintf ("**** Going to sleep ****\n");
302 Status = AcpiEnterSleepState (SleepState);
303 if (ACPI_FAILURE (Status))
308 AcpiOsPrintf ("**** returning from sleep ****\n");
309 Status = AcpiLeaveSleepState (SleepState);
315 /*******************************************************************************
317 * FUNCTION: AcpiDbWalkForReferences
319 * PARAMETERS: Callback from WalkNamespace
323 * DESCRIPTION: Check if this namespace object refers to the target object
324 * that is passed in as the context value.
326 * Note: Currently doesn't check subobjects within the Node's object
328 ******************************************************************************/
331 AcpiDbWalkForReferences (
332 ACPI_HANDLE ObjHandle,
337 ACPI_OPERAND_OBJECT *ObjDesc = (ACPI_OPERAND_OBJECT *) Context;
338 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
341 /* Check for match against the namespace node itself */
343 if (Node == (void *) ObjDesc)
345 AcpiOsPrintf ("Object is a Node [%4.4s]\n",
346 AcpiUtGetNodeName (Node));
349 /* Check for match against the object attached to the node */
351 if (AcpiNsGetAttachedObject (Node) == ObjDesc)
353 AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n",
354 Node, AcpiUtGetNodeName (Node));
361 /*******************************************************************************
363 * FUNCTION: AcpiDbFindReferences
365 * PARAMETERS: ObjectArg - String with hex value of the object
369 * DESCRIPTION: Search namespace for all references to the input object
371 ******************************************************************************/
374 AcpiDbFindReferences (
377 ACPI_OPERAND_OBJECT *ObjDesc;
380 /* Convert string to object pointer */
382 ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16));
384 /* Search all nodes in namespace */
386 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
387 AcpiDbWalkForReferences, (void *) ObjDesc, NULL);
391 /*******************************************************************************
393 * FUNCTION: AcpiDbDisplayLocks
399 * DESCRIPTION: Display information about internal mutexes.
401 ******************************************************************************/
410 for (i = 0; i < ACPI_MAX_MUTEX; i++)
412 AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i),
413 AcpiGbl_MutexInfo[i].ThreadId == ACPI_MUTEX_NOT_ACQUIRED
414 ? "Locked" : "Unlocked");
419 /*******************************************************************************
421 * FUNCTION: AcpiDbDisplayTableInfo
423 * PARAMETERS: TableArg - String with name of table to be displayed
427 * DESCRIPTION: Display information about loaded tables. Current
428 * implementation displays all loaded tables.
430 ******************************************************************************/
433 AcpiDbDisplayTableInfo (
437 ACPI_TABLE_DESC *TableDesc;
441 * Walk the root table list
443 for (i = 0; i < AcpiGbl_RootTableList.Count; i++)
445 TableDesc = &AcpiGbl_RootTableList.Tables[i];
446 AcpiOsPrintf ( "%4.4s at %p length %.5X",
447 TableDesc->Signature.Ascii, TableDesc->Pointer,
448 (UINT32) TableDesc->Length);
450 if (TableDesc->Pointer && (i != ACPI_TABLE_INDEX_FACS))
452 AcpiOsPrintf (" OemId=\"%6s\" OemTableId=\"%8s\" OemRevision=%8.8X",
453 TableDesc->Pointer->OemId,
454 TableDesc->Pointer->OemTableId,
455 TableDesc->Pointer->OemRevision);
462 /*******************************************************************************
464 * FUNCTION: AcpiDbUnloadAcpiTable
466 * PARAMETERS: TableArg - Name of the table to be unloaded
467 * InstanceArg - Which instance of the table to unload (if
468 * there are multiple tables of the same type)
472 * DESCRIPTION: Unload an ACPI table.
473 * Instance is not implemented
475 ******************************************************************************/
478 AcpiDbUnloadAcpiTable (
482 /* TBD: Need to reimplement for new data structures */
489 /* Search all tables for the target type */
491 for (i = 0; i < (ACPI_TABLE_ID_MAX+1); i++)
493 if (!ACPI_STRNCMP (TableArg, AcpiGbl_TableData[i].Signature,
494 AcpiGbl_TableData[i].SigLength))
496 /* Found the table, unload it */
498 Status = AcpiUnloadTable (i);
499 if (ACPI_SUCCESS (Status))
501 AcpiOsPrintf ("[%s] unloaded and uninstalled\n", TableArg);
505 AcpiOsPrintf ("%s, while unloading [%s]\n",
506 AcpiFormatException (Status), TableArg);
513 AcpiOsPrintf ("Unknown table type [%s]\n", TableArg);
518 /*******************************************************************************
520 * FUNCTION: AcpiDbSetMethodBreakpoint
522 * PARAMETERS: Location - AML offset of breakpoint
523 * WalkState - Current walk info
524 * Op - Current Op (from parse walk)
528 * DESCRIPTION: Set a breakpoint in a control method at the specified
531 ******************************************************************************/
534 AcpiDbSetMethodBreakpoint (
536 ACPI_WALK_STATE *WalkState,
537 ACPI_PARSE_OBJECT *Op)
544 AcpiOsPrintf ("There is no method currently executing\n");
548 /* Get and verify the breakpoint address */
550 Address = ACPI_STRTOUL (Location, NULL, 16);
551 if (Address <= Op->Common.AmlOffset)
553 AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n",
554 Address, Op->Common.AmlOffset);
557 /* Save breakpoint in current walk */
559 WalkState->UserBreakpoint = Address;
560 AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address);
564 /*******************************************************************************
566 * FUNCTION: AcpiDbSetMethodCallBreakpoint
568 * PARAMETERS: Op - Current Op (from parse walk)
572 * DESCRIPTION: Set a breakpoint in a control method at the specified
575 ******************************************************************************/
578 AcpiDbSetMethodCallBreakpoint (
579 ACPI_PARSE_OBJECT *Op)
585 AcpiOsPrintf ("There is no method currently executing\n");
589 AcpiGbl_StepToNextCall = TRUE;
593 /*******************************************************************************
595 * FUNCTION: AcpiDbDisassembleAml
597 * PARAMETERS: Statements - Number of statements to disassemble
598 * Op - Current Op (from parse walk)
602 * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
603 * of statements specified.
605 ******************************************************************************/
608 AcpiDbDisassembleAml (
610 ACPI_PARSE_OBJECT *Op)
612 UINT32 NumStatements = 8;
617 AcpiOsPrintf ("There is no method currently executing\n");
623 NumStatements = ACPI_STRTOUL (Statements, NULL, 0);
626 #ifdef ACPI_DISASSEMBLER
627 AcpiDmDisassemble (NULL, Op, NumStatements);
632 /*******************************************************************************
634 * FUNCTION: AcpiDbDisassembleMethod
636 * PARAMETERS: Name - Name of control method
640 * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
641 * of statements specified.
643 ******************************************************************************/
646 AcpiDbDisassembleMethod (
650 ACPI_PARSE_OBJECT *Op;
651 ACPI_WALK_STATE *WalkState;
652 ACPI_OPERAND_OBJECT *ObjDesc;
653 ACPI_NAMESPACE_NODE *Method;
656 Method = AcpiDbConvertToNode (Name);
659 return (AE_BAD_PARAMETER);
662 ObjDesc = Method->Object;
664 Op = AcpiPsCreateScopeOp ();
667 return (AE_NO_MEMORY);
670 /* Create and initialize a new walk state */
672 WalkState = AcpiDsCreateWalkState (0, Op, NULL, NULL);
675 return (AE_NO_MEMORY);
678 Status = AcpiDsInitAmlWalk (WalkState, Op, NULL,
679 ObjDesc->Method.AmlStart,
680 ObjDesc->Method.AmlLength, NULL, ACPI_IMODE_LOAD_PASS1);
681 if (ACPI_FAILURE (Status))
688 WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE;
689 WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE;
690 Status = AcpiPsParseAml (WalkState);
692 #ifdef ACPI_DISASSEMBLER
693 AcpiDmDisassemble (NULL, Op, 0);
695 AcpiPsDeleteParseTree (Op);
700 /*******************************************************************************
702 * FUNCTION: AcpiDbDumpNamespace
704 * PARAMETERS: StartArg - Node to begin namespace dump
705 * DepthArg - Maximum tree depth to be dumped
709 * DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed
710 * with type and other information.
712 ******************************************************************************/
715 AcpiDbDumpNamespace (
719 ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode;
720 UINT32 MaxDepth = ACPI_UINT32_MAX;
723 /* No argument given, just start at the root and dump entire namespace */
727 SubtreeEntry = AcpiDbConvertToNode (StartArg);
733 /* Now we can check for the depth argument */
737 MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
741 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
742 AcpiOsPrintf ("ACPI Namespace (from %4.4s (%p) subtree):\n",
743 ((ACPI_NAMESPACE_NODE *) SubtreeEntry)->Name.Ascii, SubtreeEntry);
745 /* Display the subtree */
747 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
748 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth,
749 ACPI_OWNER_ID_MAX, SubtreeEntry);
750 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
754 /*******************************************************************************
756 * FUNCTION: AcpiDbDumpNamespaceByOwner
758 * PARAMETERS: OwnerArg - Owner ID whose nodes will be displayed
759 * DepthArg - Maximum tree depth to be dumped
763 * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId.
765 ******************************************************************************/
768 AcpiDbDumpNamespaceByOwner (
772 ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode;
773 UINT32 MaxDepth = ACPI_UINT32_MAX;
774 ACPI_OWNER_ID OwnerId;
777 OwnerId = (ACPI_OWNER_ID) ACPI_STRTOUL (OwnerArg, NULL, 0);
779 /* Now we can check for the depth argument */
783 MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
786 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
787 AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId);
789 /* Display the subtree */
791 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
792 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId,
794 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
798 /*******************************************************************************
800 * FUNCTION: AcpiDbSendNotify
802 * PARAMETERS: Name - Name of ACPI object to send the notify to
803 * Value - Value of the notify to send.
807 * DESCRIPTION: Send an ACPI notification. The value specified is sent to the
808 * named object as an ACPI notify.
810 ******************************************************************************/
817 ACPI_NAMESPACE_NODE *Node;
821 /* Translate name to an Named object */
823 Node = AcpiDbConvertToNode (Name);
829 /* Decode Named object type */
833 case ACPI_TYPE_DEVICE:
834 case ACPI_TYPE_THERMAL:
836 /* Send the notify */
838 Status = AcpiEvQueueNotifyRequest (Node, Value);
839 if (ACPI_FAILURE (Status))
841 AcpiOsPrintf ("Could not queue notify\n");
846 AcpiOsPrintf ("Named object is not a device or a thermal object\n");
852 /*******************************************************************************
854 * FUNCTION: AcpiDbSetMethodData
856 * PARAMETERS: TypeArg - L for local, A for argument
857 * IndexArg - which one
858 * ValueArg - Value to set.
862 * DESCRIPTION: Set a local or argument for the running control method.
863 * NOTE: only object supported is Number.
865 ******************************************************************************/
868 AcpiDbSetMethodData (
876 ACPI_WALK_STATE *WalkState;
877 ACPI_OPERAND_OBJECT *ObjDesc;
879 ACPI_NAMESPACE_NODE *Node;
882 /* Validate TypeArg */
884 AcpiUtStrupr (TypeArg);
890 AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg);
894 Value = ACPI_STRTOUL (ValueArg, NULL, 16);
898 Node = AcpiDbConvertToNode (IndexArg);
899 if (Node->Type != ACPI_TYPE_INTEGER)
901 AcpiOsPrintf ("Can only set Integer nodes\n");
904 ObjDesc = Node->Object;
905 ObjDesc->Integer.Value = Value;
909 /* Get the index and value */
911 Index = ACPI_STRTOUL (IndexArg, NULL, 16);
913 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
916 AcpiOsPrintf ("There is no method currently executing\n");
920 /* Create and initialize the new object */
922 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
925 AcpiOsPrintf ("Could not create an internal object\n");
929 ObjDesc->Integer.Value = Value;
931 /* Store the new object into the target */
937 /* Set a method argument */
939 if (Index > ACPI_METHOD_MAX_ARG)
941 AcpiOsPrintf ("Arg%d - Invalid argument name\n", Index);
945 Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Index, ObjDesc,
947 if (ACPI_FAILURE (Status))
952 ObjDesc = WalkState->Arguments[Index].Object;
954 AcpiOsPrintf ("Arg%d: ", Index);
955 AcpiDmDisplayInternalObject (ObjDesc, WalkState);
960 /* Set a method local */
962 if (Index > ACPI_METHOD_MAX_LOCAL)
964 AcpiOsPrintf ("Local%d - Invalid local variable name\n", Index);
968 Status = AcpiDsStoreObjectToLocal (AML_LOCAL_OP, Index, ObjDesc,
970 if (ACPI_FAILURE (Status))
975 ObjDesc = WalkState->LocalVariables[Index].Object;
977 AcpiOsPrintf ("Local%d: ", Index);
978 AcpiDmDisplayInternalObject (ObjDesc, WalkState);
986 AcpiUtRemoveReference (ObjDesc);
990 /*******************************************************************************
992 * FUNCTION: AcpiDbWalkForSpecificObjects
994 * PARAMETERS: Callback from WalkNamespace
998 * DESCRIPTION: Display short info about objects in the namespace
1000 ******************************************************************************/
1003 AcpiDbWalkForSpecificObjects (
1004 ACPI_HANDLE ObjHandle,
1005 UINT32 NestingLevel,
1009 ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context;
1016 /* Get and display the full pathname to this object */
1018 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1019 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
1020 if (ACPI_FAILURE (Status))
1022 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
1026 AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);
1027 ACPI_FREE (Buffer.Pointer);
1029 /* Dump short info about the object */
1031 (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, Info, NULL);
1036 /*******************************************************************************
1038 * FUNCTION: AcpiDbDisplayObjects
1040 * PARAMETERS: ObjTypeArg - Type of object to display
1041 * DisplayCountArg - Max depth to display
1045 * DESCRIPTION: Display objects in the namespace of the requested type
1047 ******************************************************************************/
1050 AcpiDbDisplayObjects (
1052 char *DisplayCountArg)
1054 ACPI_WALK_INFO Info;
1055 ACPI_OBJECT_TYPE Type;
1058 /* Get the object type */
1060 Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes);
1061 if (Type == ACPI_TYPE_NOT_FOUND)
1063 AcpiOsPrintf ("Invalid or unsupported argument\n");
1067 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
1069 "Objects of type [%s] defined in the current ACPI Namespace:\n",
1070 AcpiUtGetTypeName (Type));
1072 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
1075 Info.OwnerId = ACPI_OWNER_ID_MAX;
1076 Info.DebugLevel = ACPI_UINT32_MAX;
1077 Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
1079 /* Walk the namespace from the root */
1081 (void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
1082 AcpiDbWalkForSpecificObjects, (void *) &Info, NULL);
1085 "\nFound %u objects of type [%s] in the current ACPI Namespace\n",
1086 Info.Count, AcpiUtGetTypeName (Type));
1088 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1093 /*******************************************************************************
1095 * FUNCTION: AcpiDbWalkAndMatchName
1097 * PARAMETERS: Callback from WalkNamespace
1101 * DESCRIPTION: Find a particular name/names within the namespace. Wildcards
1102 * are supported -- '?' matches any character.
1104 ******************************************************************************/
1107 AcpiDbWalkAndMatchName (
1108 ACPI_HANDLE ObjHandle,
1109 UINT32 NestingLevel,
1114 char *RequestedName = (char *) Context;
1117 ACPI_WALK_INFO Info;
1120 /* Check for a name match */
1122 for (i = 0; i < 4; i++)
1124 /* Wildcard support */
1126 if ((RequestedName[i] != '?') &&
1127 (RequestedName[i] != ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii[i]))
1129 /* No match, just exit */
1135 /* Get the full pathname to this object */
1137 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1138 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
1139 if (ACPI_FAILURE (Status))
1141 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
1145 Info.OwnerId = ACPI_OWNER_ID_MAX;
1146 Info.DebugLevel = ACPI_UINT32_MAX;
1147 Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
1149 AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);
1150 (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, &Info, NULL);
1151 ACPI_FREE (Buffer.Pointer);
1158 /*******************************************************************************
1160 * FUNCTION: AcpiDbFindNameInNamespace
1162 * PARAMETERS: NameArg - The 4-character ACPI name to find.
1163 * wildcards are supported.
1167 * DESCRIPTION: Search the namespace for a given name (with wildcards)
1169 ******************************************************************************/
1172 AcpiDbFindNameInNamespace (
1176 if (ACPI_STRLEN (NameArg) > 4)
1178 AcpiOsPrintf ("Name must be no longer than 4 characters\n");
1182 /* Walk the namespace from the root */
1184 AcpiUtStrupr (NameArg);
1185 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
1186 AcpiDbWalkAndMatchName, NameArg, NULL);
1188 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1193 /*******************************************************************************
1195 * FUNCTION: AcpiDbSetScope
1197 * PARAMETERS: Name - New scope path
1201 * DESCRIPTION: Set the "current scope" as maintained by this utility.
1202 * The scope is used as a prefix to ACPI paths.
1204 ******************************************************************************/
1211 ACPI_NAMESPACE_NODE *Node;
1214 if (!Name || Name[0] == 0)
1216 AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf);
1220 AcpiDbPrepNamestring (Name);
1222 if (Name[0] == '\\')
1224 /* Validate new scope from the root */
1226 Status = AcpiNsGetNode (AcpiGbl_RootNode, Name, ACPI_NS_NO_UPSEARCH,
1228 if (ACPI_FAILURE (Status))
1233 ACPI_STRCPY (AcpiGbl_DbScopeBuf, Name);
1234 ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
1238 /* Validate new scope relative to old scope */
1240 Status = AcpiNsGetNode (AcpiGbl_DbScopeNode, Name, ACPI_NS_NO_UPSEARCH,
1242 if (ACPI_FAILURE (Status))
1247 ACPI_STRCAT (AcpiGbl_DbScopeBuf, Name);
1248 ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
1251 AcpiGbl_DbScopeNode = Node;
1252 AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf);
1257 AcpiOsPrintf ("Could not attach scope: %s, %s\n",
1258 Name, AcpiFormatException (Status));
1262 /*******************************************************************************
1264 * FUNCTION: AcpiDmCompareAmlResources
1266 * PARAMETERS: Aml1Buffer - Contains first resource list
1267 * Aml1BufferLength - Length of first resource list
1268 * Aml2Buffer - Contains second resource list
1269 * Aml2BufferLength - Length of second resource list
1273 * DESCRIPTION: Compare two AML resource lists, descriptor by descriptor (in
1274 * order to isolate a miscompare to an individual resource)
1276 ******************************************************************************/
1279 AcpiDmCompareAmlResources (
1281 ACPI_RSDESC_SIZE Aml1BufferLength,
1283 ACPI_RSDESC_SIZE Aml2BufferLength)
1287 ACPI_RSDESC_SIZE Aml1Length;
1288 ACPI_RSDESC_SIZE Aml2Length;
1289 ACPI_RSDESC_SIZE Offset = 0;
1294 /* Compare overall buffer sizes (may be different due to size rounding) */
1296 if (Aml1BufferLength != Aml2BufferLength)
1299 "**** Buffer length mismatch in converted AML: original %X new %X ****\n",
1300 Aml1BufferLength, Aml2BufferLength);
1306 /* Walk the descriptor lists, comparing each descriptor */
1308 while (Aml1 < (Aml1Buffer + Aml1BufferLength))
1310 /* Get the lengths of each descriptor */
1312 Aml1Length = AcpiUtGetDescriptorLength (Aml1);
1313 Aml2Length = AcpiUtGetDescriptorLength (Aml2);
1314 ResourceType = AcpiUtGetResourceType (Aml1);
1316 /* Check for descriptor length match */
1318 if (Aml1Length != Aml2Length)
1321 "**** Length mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X L1 %X L2 %X ****\n",
1322 Count, ResourceType, Offset, Aml1Length, Aml2Length);
1325 /* Check for descriptor byte match */
1327 else if (ACPI_MEMCMP (Aml1, Aml2, Aml1Length))
1330 "**** Data mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X ****\n",
1331 Count, ResourceType, Offset);
1334 /* Exit on EndTag descriptor */
1336 if (ResourceType == ACPI_RESOURCE_NAME_END_TAG)
1341 /* Point to next descriptor in each buffer */
1344 Offset += Aml1Length;
1351 /*******************************************************************************
1353 * FUNCTION: AcpiDmTestResourceConversion
1355 * PARAMETERS: Node - Parent device node
1356 * Name - resource method name (_CRS)
1360 * DESCRIPTION: Compare the original AML with a conversion of the AML to
1361 * internal resource list, then back to AML.
1363 ******************************************************************************/
1366 AcpiDmTestResourceConversion (
1367 ACPI_NAMESPACE_NODE *Node,
1371 ACPI_BUFFER ReturnObj;
1372 ACPI_BUFFER ResourceObj;
1374 ACPI_OBJECT *OriginalAml;
1377 AcpiOsPrintf ("Resource Conversion Comparison:\n");
1379 NewAml.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1380 ReturnObj.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1381 ResourceObj.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1383 /* Get the original _CRS AML resource template */
1385 Status = AcpiEvaluateObject (Node, Name, NULL, &ReturnObj);
1386 if (ACPI_FAILURE (Status))
1388 AcpiOsPrintf ("Could not obtain %s: %s\n",
1389 Name, AcpiFormatException (Status));
1393 /* Get the AML resource template, converted to internal resource structs */
1395 Status = AcpiGetCurrentResources (Node, &ResourceObj);
1396 if (ACPI_FAILURE (Status))
1398 AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
1399 AcpiFormatException (Status));
1403 /* Convert internal resource list to external AML resource template */
1405 Status = AcpiRsCreateAmlResources (ResourceObj.Pointer, &NewAml);
1406 if (ACPI_FAILURE (Status))
1408 AcpiOsPrintf ("AcpiRsCreateAmlResources failed: %s\n",
1409 AcpiFormatException (Status));
1413 /* Compare original AML to the newly created AML resource list */
1415 OriginalAml = ReturnObj.Pointer;
1417 AcpiDmCompareAmlResources (
1418 OriginalAml->Buffer.Pointer, OriginalAml->Buffer.Length,
1419 NewAml.Pointer, NewAml.Length);
1421 /* Cleanup and exit */
1423 ACPI_FREE (NewAml.Pointer);
1425 ACPI_FREE (ResourceObj.Pointer);
1427 ACPI_FREE (ReturnObj.Pointer);
1432 /*******************************************************************************
1434 * FUNCTION: AcpiDbDisplayResources
1436 * PARAMETERS: ObjectArg - String with hex value of the object
1440 * DESCRIPTION: Display the resource objects associated with a device.
1442 ******************************************************************************/
1445 AcpiDbDisplayResources (
1448 ACPI_NAMESPACE_NODE *Node;
1450 ACPI_BUFFER ReturnObj;
1453 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
1454 AcpiDbgLevel |= ACPI_LV_RESOURCES;
1456 /* Convert string to object pointer */
1458 Node = AcpiDbConvertToNode (ObjectArg);
1464 /* Prepare for a return object of arbitrary size */
1466 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1467 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1471 AcpiOsPrintf ("Evaluating _PRT\n");
1473 /* Check if _PRT exists */
1475 Status = AcpiEvaluateObject (Node, METHOD_NAME__PRT, NULL, &ReturnObj);
1476 if (ACPI_FAILURE (Status))
1478 AcpiOsPrintf ("Could not obtain _PRT: %s\n",
1479 AcpiFormatException (Status));
1483 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1484 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1486 Status = AcpiGetIrqRoutingTable (Node, &ReturnObj);
1487 if (ACPI_FAILURE (Status))
1489 AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n",
1490 AcpiFormatException (Status));
1494 AcpiRsDumpIrqList (ACPI_CAST_PTR (UINT8, AcpiGbl_DbBuffer));
1500 AcpiOsPrintf ("Evaluating _CRS\n");
1502 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1503 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1505 /* Check if _CRS exists */
1507 Status = AcpiEvaluateObject (Node, METHOD_NAME__CRS, NULL, &ReturnObj);
1508 if (ACPI_FAILURE (Status))
1510 AcpiOsPrintf ("Could not obtain _CRS: %s\n",
1511 AcpiFormatException (Status));
1515 /* Get the _CRS resource list */
1517 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1518 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1520 Status = AcpiGetCurrentResources (Node, &ReturnObj);
1521 if (ACPI_FAILURE (Status))
1523 AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
1524 AcpiFormatException (Status));
1528 /* Dump the _CRS resource list */
1530 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE,
1531 ReturnObj.Pointer));
1534 * Perform comparison of original AML to newly created AML. This tests both
1535 * the AML->Resource conversion and the Resource->Aml conversion.
1537 Status = AcpiDmTestResourceConversion (Node, METHOD_NAME__CRS);
1539 /* Execute _SRS with the resource list */
1541 Status = AcpiSetCurrentResources (Node, &ReturnObj);
1542 if (ACPI_FAILURE (Status))
1544 AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n",
1545 AcpiFormatException (Status));
1553 AcpiOsPrintf ("Evaluating _PRS\n");
1555 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1556 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1558 /* Check if _PRS exists */
1560 Status = AcpiEvaluateObject (Node, METHOD_NAME__PRS, NULL, &ReturnObj);
1561 if (ACPI_FAILURE (Status))
1563 AcpiOsPrintf ("Could not obtain _PRS: %s\n",
1564 AcpiFormatException (Status));
1568 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1569 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1571 Status = AcpiGetPossibleResources (Node, &ReturnObj);
1572 if (ACPI_FAILURE (Status))
1574 AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n",
1575 AcpiFormatException (Status));
1579 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer));
1583 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1588 /*******************************************************************************
1590 * FUNCTION: AcpiDbIntegrityWalk
1592 * PARAMETERS: Callback from WalkNamespace
1596 * DESCRIPTION: Examine one NS node for valid values.
1598 ******************************************************************************/
1601 AcpiDbIntegrityWalk (
1602 ACPI_HANDLE ObjHandle,
1603 UINT32 NestingLevel,
1607 ACPI_INTEGRITY_INFO *Info = (ACPI_INTEGRITY_INFO *) Context;
1608 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
1609 ACPI_OPERAND_OBJECT *Object;
1613 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
1615 AcpiOsPrintf ("Invalid Descriptor Type for Node %p [%s]\n",
1616 Node, AcpiUtGetDescriptorName (Node));
1619 if (Node->Type > ACPI_TYPE_LOCAL_MAX)
1621 AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n",
1625 if (!AcpiUtValidAcpiName (Node->Name.Integer))
1627 AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node);
1630 Object = AcpiNsGetAttachedObject (Node);
1634 if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
1636 AcpiOsPrintf ("Invalid Descriptor Type for Object %p [%s]\n",
1637 Object, AcpiUtGetDescriptorName (Object));
1645 /*******************************************************************************
1647 * FUNCTION: AcpiDbCheckIntegrity
1653 * DESCRIPTION: Check entire namespace for data structure integrity
1655 ******************************************************************************/
1658 AcpiDbCheckIntegrity (
1661 ACPI_INTEGRITY_INFO Info = {0,0};
1663 /* Search all nodes in namespace */
1665 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
1666 AcpiDbIntegrityWalk, (void *) &Info, NULL);
1668 AcpiOsPrintf ("Verified %d namespace nodes with %d Objects\n",
1669 Info.Nodes, Info.Objects);
1673 /*******************************************************************************
1675 * FUNCTION: AcpiDbGenerateGpe
1677 * PARAMETERS: GpeArg - Raw GPE number, ascii string
1678 * BlockArg - GPE block number, ascii string
1679 * 0 or 1 for FADT GPE blocks
1683 * DESCRIPTION: Generate a GPE
1685 ******************************************************************************/
1694 ACPI_GPE_EVENT_INFO *GpeEventInfo;
1697 GpeNumber = ACPI_STRTOUL (GpeArg, NULL, 0);
1698 BlockNumber = ACPI_STRTOUL (BlockArg, NULL, 0);
1701 GpeEventInfo = AcpiEvGetGpeEventInfo (ACPI_TO_POINTER (BlockNumber),
1705 AcpiOsPrintf ("Invalid GPE\n");
1709 (void) AcpiEvGpeDispatch (GpeEventInfo, GpeNumber);
1713 /*******************************************************************************
1715 * FUNCTION: AcpiDbBusWalk
1717 * PARAMETERS: Callback from WalkNamespace
1721 * DESCRIPTION: Display info about device objects that have a corresponding
1724 ******************************************************************************/
1728 ACPI_HANDLE ObjHandle,
1729 UINT32 NestingLevel,
1733 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
1738 ACPI_COMPATIBLE_ID_LIST *Cid;
1739 ACPI_NAMESPACE_NODE *TempNode;
1742 /* Exit if there is no _PRT under this device */
1744 Status = AcpiGetHandle (Node, METHOD_NAME__PRT,
1745 ACPI_CAST_PTR (ACPI_HANDLE, &TempNode));
1746 if (ACPI_FAILURE (Status))
1751 /* Get the full path to this device object */
1753 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1754 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
1755 if (ACPI_FAILURE (Status))
1757 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
1761 /* Display the full path */
1763 AcpiOsPrintf ("%-32s", (char *) Buffer.Pointer);
1764 ACPI_FREE (Buffer.Pointer);
1768 AcpiOsPrintf ("_PRT=%p", TempNode);
1770 /* Get the _ADR value */
1772 Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, Node, &ADR);
1773 if (ACPI_FAILURE (Status))
1775 AcpiOsPrintf (" No _ADR ");
1779 AcpiOsPrintf (" _ADR=%8.8X", (UINT32) ADR);
1782 /* Get the _HID if present */
1784 Status = AcpiUtExecute_HID (Node, &Id);
1785 if (ACPI_SUCCESS (Status))
1787 AcpiOsPrintf (" _HID=%s", Id.Value);
1794 /* Get the _UID if present */
1796 Status = AcpiUtExecute_UID (Node, &Id);
1797 if (ACPI_SUCCESS (Status))
1799 AcpiOsPrintf (" _UID=%s", Id.Value);
1802 /* Get the _CID if present */
1804 Status = AcpiUtExecute_CID (Node, &Cid);
1805 if (ACPI_SUCCESS (Status))
1807 AcpiOsPrintf (" _CID=%s", Cid->Id[0].Value);
1811 AcpiOsPrintf ("\n");
1816 /*******************************************************************************
1818 * FUNCTION: AcpiDbGetBusInfo
1824 * DESCRIPTION: Display info about system busses.
1826 ******************************************************************************/
1832 /* Search all nodes in namespace */
1834 (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
1835 AcpiDbBusWalk, NULL, NULL);
1838 #endif /* ACPI_DEBUGGER */