1 /*******************************************************************************
3 * Module Name: dbcmds - debug commands and output routines
6 ******************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2005, 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 [] =
204 {NULL} /* Must be null terminated */
208 /*******************************************************************************
210 * FUNCTION: AcpiDbConvertToNode
212 * PARAMETERS: InString - String to convert
214 * RETURN: Pointer to a NS node
216 * DESCRIPTION: Convert a string to a valid NS pointer. Handles numeric or
219 ******************************************************************************/
221 static ACPI_NAMESPACE_NODE *
222 AcpiDbConvertToNode (
225 ACPI_NAMESPACE_NODE *Node;
228 if ((*InString >= 0x30) && (*InString <= 0x39))
230 /* Numeric argument, convert */
232 Node = ACPI_TO_POINTER (ACPI_STRTOUL (InString, NULL, 16));
233 if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE)))
235 AcpiOsPrintf ("Address %p is invalid in this address space\n",
240 /* Make sure pointer is valid NS node */
242 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
244 AcpiOsPrintf ("Address %p is not a valid NS node [%s]\n",
245 Node, AcpiUtGetDescriptorName (Node));
252 /* The parameter is a name string that must be resolved to a
255 Node = AcpiDbLocalNsLookup (InString);
258 Node = AcpiGbl_RootNode;
266 /*******************************************************************************
268 * FUNCTION: AcpiDbSleep
270 * PARAMETERS: ObjectArg - Desired sleep state (0-5)
274 * DESCRIPTION: Simulate a sleep/wake sequence
276 ******************************************************************************/
282 #if ACPI_MACHINE_WIDTH == 16
289 SleepState = (UINT8) ACPI_STRTOUL (ObjectArg, NULL, 0);
291 AcpiOsPrintf ("**** Prepare to sleep ****\n");
292 Status = AcpiEnterSleepStatePrep (SleepState);
293 if (ACPI_FAILURE (Status))
298 AcpiOsPrintf ("**** Going to sleep ****\n");
299 Status = AcpiEnterSleepState (SleepState);
300 if (ACPI_FAILURE (Status))
305 AcpiOsPrintf ("**** returning from sleep ****\n");
306 Status = AcpiLeaveSleepState (SleepState);
313 /*******************************************************************************
315 * FUNCTION: AcpiDbWalkForReferences
317 * PARAMETERS: Callback from WalkNamespace
321 * DESCRIPTION: Check if this namespace object refers to the target object
322 * that is passed in as the context value.
324 * Note: Currently doesn't check subobjects within the Node's object
326 ******************************************************************************/
329 AcpiDbWalkForReferences (
330 ACPI_HANDLE ObjHandle,
335 ACPI_OPERAND_OBJECT *ObjDesc = (ACPI_OPERAND_OBJECT *) Context;
336 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
339 /* Check for match against the namespace node itself */
341 if (Node == (void *) ObjDesc)
343 AcpiOsPrintf ("Object is a Node [%4.4s]\n",
344 AcpiUtGetNodeName (Node));
347 /* Check for match against the object attached to the node */
349 if (AcpiNsGetAttachedObject (Node) == ObjDesc)
351 AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n",
352 Node, AcpiUtGetNodeName (Node));
359 /*******************************************************************************
361 * FUNCTION: AcpiDbFindReferences
363 * PARAMETERS: ObjectArg - String with hex value of the object
367 * DESCRIPTION: Search namespace for all references to the input object
369 ******************************************************************************/
372 AcpiDbFindReferences (
375 ACPI_OPERAND_OBJECT *ObjDesc;
378 /* Convert string to object pointer */
380 ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16));
382 /* Search all nodes in namespace */
384 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
385 AcpiDbWalkForReferences, (void *) ObjDesc, NULL);
389 /*******************************************************************************
391 * FUNCTION: AcpiDbDisplayLocks
397 * DESCRIPTION: Display information about internal mutexes.
399 ******************************************************************************/
408 for (i = 0; i < MAX_MUTEX; i++)
410 AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i),
411 AcpiGbl_MutexInfo[i].ThreadId == ACPI_MUTEX_NOT_ACQUIRED
412 ? "Locked" : "Unlocked");
417 /*******************************************************************************
419 * FUNCTION: AcpiDbDisplayTableInfo
421 * PARAMETERS: TableArg - String with name of table to be displayed
425 * DESCRIPTION: Display information about loaded tables. Current
426 * implementation displays all loaded tables.
428 ******************************************************************************/
431 AcpiDbDisplayTableInfo (
435 ACPI_TABLE_DESC *TableDesc;
438 for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++)
440 TableDesc = AcpiGbl_TableLists[i].Next;
443 AcpiOsPrintf ( "%s at %p length %.5X",
444 AcpiGbl_TableData[i].Name, TableDesc->Pointer,
445 (UINT32) TableDesc->Length);
447 if (i != ACPI_TABLE_FACS)
449 AcpiOsPrintf (" OemID=%6s TableId=%8s OemRevision=%8.8X",
450 TableDesc->Pointer->OemId,
451 TableDesc->Pointer->OemTableId,
452 TableDesc->Pointer->OemRevision);
456 TableDesc = TableDesc->Next;
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 (
486 /* Search all tables for the target type */
488 for (i = 0; i < NUM_ACPI_TABLE_TYPES; i++)
490 if (!ACPI_STRNCMP (TableArg, AcpiGbl_TableData[i].Signature,
491 AcpiGbl_TableData[i].SigLength))
493 /* Found the table, unload it */
495 Status = AcpiUnloadTable (i);
496 if (ACPI_SUCCESS (Status))
498 AcpiOsPrintf ("[%s] unloaded and uninstalled\n", TableArg);
502 AcpiOsPrintf ("%s, while unloading [%s]\n",
503 AcpiFormatException (Status), TableArg);
510 AcpiOsPrintf ("Unknown table type [%s]\n", TableArg);
514 /*******************************************************************************
516 * FUNCTION: AcpiDbSetMethodBreakpoint
518 * PARAMETERS: Location - AML offset of breakpoint
519 * WalkState - Current walk info
520 * Op - Current Op (from parse walk)
524 * DESCRIPTION: Set a breakpoint in a control method at the specified
527 ******************************************************************************/
530 AcpiDbSetMethodBreakpoint (
532 ACPI_WALK_STATE *WalkState,
533 ACPI_PARSE_OBJECT *Op)
540 AcpiOsPrintf ("There is no method currently executing\n");
544 /* Get and verify the breakpoint address */
546 Address = ACPI_STRTOUL (Location, NULL, 16);
547 if (Address <= Op->Common.AmlOffset)
549 AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n",
550 Address, Op->Common.AmlOffset);
553 /* Save breakpoint in current walk */
555 WalkState->UserBreakpoint = Address;
556 AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address);
560 /*******************************************************************************
562 * FUNCTION: AcpiDbSetMethodCallBreakpoint
564 * PARAMETERS: Op - Current Op (from parse walk)
568 * DESCRIPTION: Set a breakpoint in a control method at the specified
571 ******************************************************************************/
574 AcpiDbSetMethodCallBreakpoint (
575 ACPI_PARSE_OBJECT *Op)
581 AcpiOsPrintf ("There is no method currently executing\n");
585 AcpiGbl_StepToNextCall = TRUE;
589 /*******************************************************************************
591 * FUNCTION: AcpiDbDisassembleAml
593 * PARAMETERS: Statements - Number of statements to disassemble
594 * Op - Current Op (from parse walk)
598 * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
599 * of statements specified.
601 ******************************************************************************/
604 AcpiDbDisassembleAml (
606 ACPI_PARSE_OBJECT *Op)
608 UINT32 NumStatements = 8;
613 AcpiOsPrintf ("There is no method currently executing\n");
619 NumStatements = ACPI_STRTOUL (Statements, NULL, 0);
622 #ifdef ACPI_DISASSEMBLER
623 AcpiDmDisassemble (NULL, Op, NumStatements);
628 /*******************************************************************************
630 * FUNCTION: AcpiDbDisassembleMethod
632 * PARAMETERS: Name - Name of control method
636 * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
637 * of statements specified.
639 ******************************************************************************/
642 AcpiDbDisassembleMethod (
646 ACPI_PARSE_OBJECT *Op;
647 ACPI_WALK_STATE *WalkState;
648 ACPI_OPERAND_OBJECT *ObjDesc;
649 ACPI_NAMESPACE_NODE *Method;
652 Method = AcpiDbConvertToNode (Name);
655 return (AE_BAD_PARAMETER);
658 ObjDesc = Method->Object;
660 Op = AcpiPsCreateScopeOp ();
663 return (AE_NO_MEMORY);
666 /* Create and initialize a new walk state */
668 WalkState = AcpiDsCreateWalkState (0, Op, NULL, NULL);
671 return (AE_NO_MEMORY);
674 Status = AcpiDsInitAmlWalk (WalkState, Op, NULL,
675 ObjDesc->Method.AmlStart,
676 ObjDesc->Method.AmlLength, NULL, 1);
677 if (ACPI_FAILURE (Status))
684 WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE;
685 WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE;
686 Status = AcpiPsParseAml (WalkState);
688 #ifdef ACPI_DISASSEMBLER
689 AcpiDmDisassemble (NULL, Op, 0);
691 AcpiPsDeleteParseTree (Op);
696 /*******************************************************************************
698 * FUNCTION: AcpiDbDumpNamespace
700 * PARAMETERS: StartArg - Node to begin namespace dump
701 * DepthArg - Maximum tree depth to be dumped
705 * DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed
706 * with type and other information.
708 ******************************************************************************/
711 AcpiDbDumpNamespace (
715 ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode;
716 UINT32 MaxDepth = ACPI_UINT32_MAX;
719 /* No argument given, just start at the root and dump entire namespace */
723 SubtreeEntry = AcpiDbConvertToNode (StartArg);
729 /* Now we can check for the depth argument */
733 MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
737 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
738 AcpiOsPrintf ("ACPI Namespace (from %4.4s (%p) subtree):\n",
739 ((ACPI_NAMESPACE_NODE *) SubtreeEntry)->Name.Ascii, SubtreeEntry);
741 /* Display the subtree */
743 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
744 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth,
745 ACPI_OWNER_ID_MAX, SubtreeEntry);
746 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
750 /*******************************************************************************
752 * FUNCTION: AcpiDbDumpNamespaceByOwner
754 * PARAMETERS: OwnerArg - Owner ID whose nodes will be displayed
755 * DepthArg - Maximum tree depth to be dumped
759 * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId.
761 ******************************************************************************/
764 AcpiDbDumpNamespaceByOwner (
768 ACPI_HANDLE SubtreeEntry = AcpiGbl_RootNode;
769 UINT32 MaxDepth = ACPI_UINT32_MAX;
770 ACPI_OWNER_ID OwnerId;
773 OwnerId = (ACPI_OWNER_ID) ACPI_STRTOUL (OwnerArg, NULL, 0);
775 /* Now we can check for the depth argument */
779 MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
782 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
783 AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId);
785 /* Display the subtree */
787 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
788 AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId,
790 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
794 /*******************************************************************************
796 * FUNCTION: AcpiDbSendNotify
798 * PARAMETERS: Name - Name of ACPI object to send the notify to
799 * Value - Value of the notify to send.
803 * DESCRIPTION: Send an ACPI notification. The value specified is sent to the
804 * named object as an ACPI notify.
806 ******************************************************************************/
813 ACPI_NAMESPACE_NODE *Node;
817 /* Translate name to an Named object */
819 Node = AcpiDbConvertToNode (Name);
825 /* Decode Named object type */
829 case ACPI_TYPE_DEVICE:
830 case ACPI_TYPE_THERMAL:
832 /* Send the notify */
834 Status = AcpiEvQueueNotifyRequest (Node, Value);
835 if (ACPI_FAILURE (Status))
837 AcpiOsPrintf ("Could not queue notify\n");
842 AcpiOsPrintf ("Named object is not a device or a thermal object\n");
848 /*******************************************************************************
850 * FUNCTION: AcpiDbSetMethodData
852 * PARAMETERS: TypeArg - L for local, A for argument
853 * IndexArg - which one
854 * ValueArg - Value to set.
858 * DESCRIPTION: Set a local or argument for the running control method.
859 * NOTE: only object supported is Number.
861 ******************************************************************************/
864 AcpiDbSetMethodData (
872 ACPI_WALK_STATE *WalkState;
873 ACPI_OPERAND_OBJECT *ObjDesc;
875 ACPI_NAMESPACE_NODE *Node;
878 /* Validate TypeArg */
880 AcpiUtStrupr (TypeArg);
886 AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg);
890 Value = ACPI_STRTOUL (ValueArg, NULL, 16);
894 Node = AcpiDbConvertToNode (IndexArg);
895 if (Node->Type != ACPI_TYPE_INTEGER)
897 AcpiOsPrintf ("Can only set Integer nodes\n");
900 ObjDesc = Node->Object;
901 ObjDesc->Integer.Value = Value;
905 /* Get the index and value */
907 Index = ACPI_STRTOUL (IndexArg, NULL, 16);
909 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
912 AcpiOsPrintf ("There is no method currently executing\n");
916 /* Create and initialize the new object */
918 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
921 AcpiOsPrintf ("Could not create an internal object\n");
925 ObjDesc->Integer.Value = Value;
927 /* Store the new object into the target */
933 /* Set a method argument */
935 if (Index > ACPI_METHOD_MAX_ARG)
937 AcpiOsPrintf ("Arg%d - Invalid argument name\n", Index);
941 Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Index, ObjDesc,
943 if (ACPI_FAILURE (Status))
948 ObjDesc = WalkState->Arguments[Index].Object;
950 AcpiOsPrintf ("Arg%d: ", Index);
951 AcpiDmDisplayInternalObject (ObjDesc, WalkState);
956 /* Set a method local */
958 if (Index > ACPI_METHOD_MAX_LOCAL)
960 AcpiOsPrintf ("Local%d - Invalid local variable name\n", Index);
964 Status = AcpiDsStoreObjectToLocal (AML_LOCAL_OP, Index, ObjDesc,
966 if (ACPI_FAILURE (Status))
971 ObjDesc = WalkState->LocalVariables[Index].Object;
973 AcpiOsPrintf ("Local%d: ", Index);
974 AcpiDmDisplayInternalObject (ObjDesc, WalkState);
983 /*******************************************************************************
985 * FUNCTION: AcpiDbWalkForSpecificObjects
987 * PARAMETERS: Callback from WalkNamespace
991 * DESCRIPTION: Display short info about objects in the namespace
993 ******************************************************************************/
996 AcpiDbWalkForSpecificObjects (
997 ACPI_HANDLE ObjHandle,
1002 ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context;
1009 /* Get and display the full pathname to this object */
1011 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1012 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
1013 if (ACPI_FAILURE (Status))
1015 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
1019 AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);
1020 ACPI_MEM_FREE (Buffer.Pointer);
1022 /* Dump short info about the object */
1024 (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, Info, NULL);
1029 /*******************************************************************************
1031 * FUNCTION: AcpiDbDisplayObjects
1033 * PARAMETERS: ObjTypeArg - Type of object to display
1034 * DisplayCountArg - Max depth to display
1038 * DESCRIPTION: Display objects in the namespace of the requested type
1040 ******************************************************************************/
1043 AcpiDbDisplayObjects (
1045 char *DisplayCountArg)
1047 ACPI_WALK_INFO Info;
1048 ACPI_OBJECT_TYPE Type;
1051 /* Get the object type */
1053 Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes);
1054 if (Type == ACPI_TYPE_NOT_FOUND)
1056 AcpiOsPrintf ("Invalid or unsupported argument\n");
1060 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
1062 "Objects of type [%s] defined in the current ACPI Namespace:\n",
1063 AcpiUtGetTypeName (Type));
1065 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
1068 Info.OwnerId = ACPI_OWNER_ID_MAX;
1069 Info.DebugLevel = ACPI_UINT32_MAX;
1070 Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
1072 /* Walk the namespace from the root */
1074 (void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
1075 AcpiDbWalkForSpecificObjects, (void *) &Info, NULL);
1078 "\nFound %u objects of type [%s] in the current ACPI Namespace\n",
1079 Info.Count, AcpiUtGetTypeName (Type));
1081 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1086 /*******************************************************************************
1088 * FUNCTION: AcpiDbWalkAndMatchName
1090 * PARAMETERS: Callback from WalkNamespace
1094 * DESCRIPTION: Find a particular name/names within the namespace. Wildcards
1095 * are supported -- '?' matches any character.
1097 ******************************************************************************/
1100 AcpiDbWalkAndMatchName (
1101 ACPI_HANDLE ObjHandle,
1102 UINT32 NestingLevel,
1107 char *RequestedName = (char *) Context;
1110 ACPI_WALK_INFO Info;
1113 /* Check for a name match */
1115 for (i = 0; i < 4; i++)
1117 /* Wildcard support */
1119 if ((RequestedName[i] != '?') &&
1120 (RequestedName[i] != ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii[i]))
1122 /* No match, just exit */
1128 /* Get the full pathname to this object */
1130 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1131 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
1132 if (ACPI_FAILURE (Status))
1134 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
1138 Info.OwnerId = ACPI_OWNER_ID_MAX;
1139 Info.DebugLevel = ACPI_UINT32_MAX;
1140 Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
1142 AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);
1143 (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, &Info, NULL);
1144 ACPI_MEM_FREE (Buffer.Pointer);
1151 /*******************************************************************************
1153 * FUNCTION: AcpiDbFindNameInNamespace
1155 * PARAMETERS: NameArg - The 4-character ACPI name to find.
1156 * wildcards are supported.
1160 * DESCRIPTION: Search the namespace for a given name (with wildcards)
1162 ******************************************************************************/
1165 AcpiDbFindNameInNamespace (
1169 if (ACPI_STRLEN (NameArg) > 4)
1171 AcpiOsPrintf ("Name must be no longer than 4 characters\n");
1175 /* Walk the namespace from the root */
1177 AcpiUtStrupr (NameArg);
1178 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
1179 AcpiDbWalkAndMatchName, NameArg, NULL);
1181 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1186 /*******************************************************************************
1188 * FUNCTION: AcpiDbSetScope
1190 * PARAMETERS: Name - New scope path
1194 * DESCRIPTION: Set the "current scope" as maintained by this utility.
1195 * The scope is used as a prefix to ACPI paths.
1197 ******************************************************************************/
1204 ACPI_NAMESPACE_NODE *Node;
1207 if (!Name || Name[0] == 0)
1209 AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf);
1213 AcpiDbPrepNamestring (Name);
1215 if (Name[0] == '\\')
1217 /* Validate new scope from the root */
1219 Status = AcpiNsGetNodeByPath (Name, AcpiGbl_RootNode,
1220 ACPI_NS_NO_UPSEARCH, &Node);
1221 if (ACPI_FAILURE (Status))
1226 ACPI_STRCPY (AcpiGbl_DbScopeBuf, Name);
1227 ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
1231 /* Validate new scope relative to old scope */
1233 Status = AcpiNsGetNodeByPath (Name, AcpiGbl_DbScopeNode,
1234 ACPI_NS_NO_UPSEARCH, &Node);
1235 if (ACPI_FAILURE (Status))
1240 ACPI_STRCAT (AcpiGbl_DbScopeBuf, Name);
1241 ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
1244 AcpiGbl_DbScopeNode = Node;
1245 AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf);
1250 AcpiOsPrintf ("Could not attach scope: %s, %s\n",
1251 Name, AcpiFormatException (Status));
1255 /*******************************************************************************
1257 * FUNCTION: AcpiDmCompareAmlResources
1259 * PARAMETERS: Aml1Buffer - Contains first resource list
1260 * Aml1BufferLength - Length of first resource list
1261 * Aml2Buffer - Contains second resource list
1262 * Aml2BufferLength - Length of second resource list
1266 * DESCRIPTION: Compare two AML resource lists, descriptor by descriptor (in
1267 * order to isolate a miscompare to an individual resource)
1269 ******************************************************************************/
1272 AcpiDmCompareAmlResources (
1274 ACPI_RSDESC_SIZE Aml1BufferLength,
1276 ACPI_RSDESC_SIZE Aml2BufferLength)
1280 ACPI_RSDESC_SIZE Aml1Length;
1281 ACPI_RSDESC_SIZE Aml2Length;
1282 ACPI_RSDESC_SIZE Offset = 0;
1287 /* Compare overall buffer sizes (may be different due to size rounding) */
1289 if (Aml1BufferLength != Aml2BufferLength)
1292 "**** Buffer length mismatch in converted AML: original %X new %X ****\n",
1293 Aml1BufferLength, Aml2BufferLength);
1299 /* Walk the descriptor lists, comparing each descriptor */
1301 while (Aml1 < (Aml1Buffer + Aml1BufferLength))
1303 /* Get the lengths of each descriptor */
1305 Aml1Length = AcpiUtGetDescriptorLength (Aml1);
1306 Aml2Length = AcpiUtGetDescriptorLength (Aml2);
1307 ResourceType = AcpiUtGetResourceType (Aml1);
1309 /* Check for descriptor length match */
1311 if (Aml1Length != Aml2Length)
1314 "**** Length mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X L1 %X L2 %X ****\n",
1315 Count, ResourceType, Offset, Aml1Length, Aml2Length);
1319 /* Check for descriptor byte match */
1321 if (ACPI_MEMCMP (Aml1, Aml2, Aml1Length))
1324 "**** Data mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X ****\n",
1325 Count, ResourceType, Offset);
1328 /* Exit on EndTag descriptor */
1330 if (ResourceType == ACPI_RESOURCE_NAME_END_TAG)
1335 /* Point to next descriptor in each buffer */
1338 Offset += Aml1Length;
1345 /*******************************************************************************
1347 * FUNCTION: AcpiDmTestResourceConversion
1349 * PARAMETERS: Node - Parent device node
1350 * Name - resource method name (_CRS)
1354 * DESCRIPTION: Compare the original AML with a conversion of the AML to
1355 * internal resource list, then back to AML.
1357 ******************************************************************************/
1360 AcpiDmTestResourceConversion (
1361 ACPI_NAMESPACE_NODE *Node,
1365 ACPI_BUFFER ReturnObj;
1366 ACPI_BUFFER ResourceObj;
1368 ACPI_OBJECT *OriginalAml;
1371 AcpiOsPrintf ("Resource Conversion Comparison:\n");
1373 NewAml.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1374 ReturnObj.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1375 ResourceObj.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1377 /* Get the original _CRS AML resource template */
1379 Status = AcpiEvaluateObject (Node, Name, NULL, &ReturnObj);
1380 if (ACPI_FAILURE (Status))
1382 AcpiOsPrintf ("Could not obtain %s: %s\n",
1383 Name, AcpiFormatException (Status));
1387 /* Get the AML resource template, converted to internal resource structs */
1389 Status = AcpiGetCurrentResources (Node, &ResourceObj);
1390 if (ACPI_FAILURE (Status))
1392 AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
1393 AcpiFormatException (Status));
1397 /* Convert internal resource list to external AML resource template */
1399 Status = AcpiRsCreateAmlResources (ResourceObj.Pointer, &NewAml);
1400 if (ACPI_FAILURE (Status))
1402 AcpiOsPrintf ("AcpiRsCreateAmlResources failed: %s\n",
1403 AcpiFormatException (Status));
1407 /* Compare original AML to the newly created AML resource list */
1409 OriginalAml = ReturnObj.Pointer;
1411 AcpiDmCompareAmlResources (
1412 OriginalAml->Buffer.Pointer, OriginalAml->Buffer.Length,
1413 NewAml.Pointer, NewAml.Length);
1415 /* Cleanup and exit */
1417 ACPI_MEM_FREE (NewAml.Pointer);
1419 ACPI_MEM_FREE (ResourceObj.Pointer);
1421 ACPI_MEM_FREE (ReturnObj.Pointer);
1426 /*******************************************************************************
1428 * FUNCTION: AcpiDbDisplayResources
1430 * PARAMETERS: ObjectArg - String with hex value of the object
1434 * DESCRIPTION: Display the resource objects associated with a device.
1436 ******************************************************************************/
1439 AcpiDbDisplayResources (
1442 #if ACPI_MACHINE_WIDTH != 16
1444 ACPI_NAMESPACE_NODE *Node;
1446 ACPI_BUFFER ReturnObj;
1449 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
1450 AcpiDbgLevel |= ACPI_LV_RESOURCES;
1452 /* Convert string to object pointer */
1454 Node = AcpiDbConvertToNode (ObjectArg);
1460 /* Prepare for a return object of arbitrary size */
1462 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1463 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1467 AcpiOsPrintf ("Evaluating _PRT\n");
1469 /* Check if _PRT exists */
1471 Status = AcpiEvaluateObject (Node, METHOD_NAME__PRT, NULL, &ReturnObj);
1472 if (ACPI_FAILURE (Status))
1474 AcpiOsPrintf ("Could not obtain _PRT: %s\n",
1475 AcpiFormatException (Status));
1479 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1480 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1482 Status = AcpiGetIrqRoutingTable (Node, &ReturnObj);
1483 if (ACPI_FAILURE (Status))
1485 AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n",
1486 AcpiFormatException (Status));
1490 AcpiRsDumpIrqList ((UINT8 *) AcpiGbl_DbBuffer);
1496 AcpiOsPrintf ("Evaluating _CRS\n");
1498 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1499 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1501 /* Check if _CRS exists */
1503 Status = AcpiEvaluateObject (Node, METHOD_NAME__CRS, NULL, &ReturnObj);
1504 if (ACPI_FAILURE (Status))
1506 AcpiOsPrintf ("Could not obtain _CRS: %s\n",
1507 AcpiFormatException (Status));
1511 /* Get the _CRS resource list */
1513 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1514 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1516 Status = AcpiGetCurrentResources (Node, &ReturnObj);
1517 if (ACPI_FAILURE (Status))
1519 AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
1520 AcpiFormatException (Status));
1524 /* Dump the _CRS resource list */
1526 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE,
1527 ReturnObj.Pointer));
1530 * Perform comparison of original AML to newly created AML. This tests both
1531 * the AML->Resource conversion and the Resource->Aml conversion.
1533 Status = AcpiDmTestResourceConversion (Node, METHOD_NAME__CRS);
1535 /* Execute _SRS with the resource list */
1537 Status = AcpiSetCurrentResources (Node, &ReturnObj);
1538 if (ACPI_FAILURE (Status))
1540 AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n",
1541 AcpiFormatException (Status));
1549 AcpiOsPrintf ("Evaluating _PRS\n");
1551 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1552 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1554 /* Check if _PRS exists */
1556 Status = AcpiEvaluateObject (Node, METHOD_NAME__PRS, NULL, &ReturnObj);
1557 if (ACPI_FAILURE (Status))
1559 AcpiOsPrintf ("Could not obtain _PRS: %s\n",
1560 AcpiFormatException (Status));
1564 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1565 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1567 Status = AcpiGetPossibleResources (Node, &ReturnObj);
1568 if (ACPI_FAILURE (Status))
1570 AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n",
1571 AcpiFormatException (Status));
1575 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer));
1579 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1585 /*******************************************************************************
1587 * FUNCTION: AcpiDbIntegrityWalk
1589 * PARAMETERS: Callback from WalkNamespace
1593 * DESCRIPTION: Examine one NS node for valid values.
1595 ******************************************************************************/
1598 AcpiDbIntegrityWalk (
1599 ACPI_HANDLE ObjHandle,
1600 UINT32 NestingLevel,
1604 ACPI_INTEGRITY_INFO *Info = (ACPI_INTEGRITY_INFO *) Context;
1605 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
1606 ACPI_OPERAND_OBJECT *Object;
1610 if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
1612 AcpiOsPrintf ("Invalid Descriptor Type for Node %p [%s]\n",
1613 Node, AcpiUtGetDescriptorName (Node));
1616 if (Node->Type > ACPI_TYPE_LOCAL_MAX)
1618 AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n",
1622 if (!AcpiUtValidAcpiName (Node->Name.Integer))
1624 AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node);
1627 Object = AcpiNsGetAttachedObject (Node);
1631 if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
1633 AcpiOsPrintf ("Invalid Descriptor Type for Object %p [%s]\n",
1634 Object, AcpiUtGetDescriptorName (Object));
1642 /*******************************************************************************
1644 * FUNCTION: AcpiDbCheckIntegrity
1650 * DESCRIPTION: Check entire namespace for data structure integrity
1652 ******************************************************************************/
1655 AcpiDbCheckIntegrity (
1658 ACPI_INTEGRITY_INFO Info = {0,0};
1660 /* Search all nodes in namespace */
1662 (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
1663 AcpiDbIntegrityWalk, (void *) &Info, NULL);
1665 AcpiOsPrintf ("Verified %d namespace nodes with %d Objects\n",
1666 Info.Nodes, Info.Objects);
1670 /*******************************************************************************
1672 * FUNCTION: AcpiDbGenerateGpe
1674 * PARAMETERS: GpeArg - Raw GPE number, ascii string
1675 * BlockArg - GPE block number, ascii string
1676 * 0 or 1 for FADT GPE blocks
1680 * DESCRIPTION: Generate a GPE
1682 ******************************************************************************/
1691 ACPI_GPE_EVENT_INFO *GpeEventInfo;
1694 GpeNumber = ACPI_STRTOUL (GpeArg, NULL, 0);
1695 BlockNumber = ACPI_STRTOUL (BlockArg, NULL, 0);
1698 GpeEventInfo = AcpiEvGetGpeEventInfo (ACPI_TO_POINTER (BlockNumber),
1702 AcpiOsPrintf ("Invalid GPE\n");
1706 (void) AcpiEvGpeDispatch (GpeEventInfo, GpeNumber);
1710 /*******************************************************************************
1712 * FUNCTION: AcpiDbBusWalk
1714 * PARAMETERS: Callback from WalkNamespace
1718 * DESCRIPTION: Display info about device objects that have a corresponding
1721 ******************************************************************************/
1725 ACPI_HANDLE ObjHandle,
1726 UINT32 NestingLevel,
1730 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
1735 ACPI_COMPATIBLE_ID_LIST *Cid;
1736 ACPI_NAMESPACE_NODE *TempNode;
1739 /* Exit if there is no _PRT under this device */
1741 Status = AcpiGetHandle (Node, METHOD_NAME__PRT, (ACPI_HANDLE *) (uintptr_t) &TempNode);
1742 if (ACPI_FAILURE (Status))
1747 /* Get the full path to this device object */
1749 Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1750 Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
1751 if (ACPI_FAILURE (Status))
1753 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
1757 /* Display the full path */
1759 AcpiOsPrintf ("%-32s", (char *) Buffer.Pointer);
1760 ACPI_MEM_FREE (Buffer.Pointer);
1764 AcpiOsPrintf ("_PRT=%p", TempNode);
1766 /* Get the _ADR value */
1768 Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, Node, &ADR);
1769 if (ACPI_FAILURE (Status))
1771 AcpiOsPrintf (" No _ADR ");
1775 AcpiOsPrintf (" _ADR=%8.8X", (UINT32) ADR);
1778 /* Get the _HID if present */
1780 Status = AcpiUtExecute_HID (Node, &Id);
1781 if (ACPI_SUCCESS (Status))
1783 AcpiOsPrintf (" _HID=%s", Id.Value);
1790 /* Get the _UID if present */
1792 Status = AcpiUtExecute_UID (Node, &Id);
1793 if (ACPI_SUCCESS (Status))
1795 AcpiOsPrintf (" _UID=%s", Id.Value);
1798 /* Get the _CID if present */
1800 Status = AcpiUtExecute_CID (Node, &Cid);
1801 if (ACPI_SUCCESS (Status))
1803 AcpiOsPrintf (" _CID=%s", Cid->Id[0].Value);
1804 ACPI_MEM_FREE (Cid);
1807 AcpiOsPrintf ("\n");
1812 /*******************************************************************************
1814 * FUNCTION: AcpiDbGetBusInfo
1820 * DESCRIPTION: Display info about system busses.
1822 ******************************************************************************/
1828 /* Search all nodes in namespace */
1830 (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
1831 AcpiDbBusWalk, NULL, NULL);
1834 #endif /* ACPI_DEBUGGER */