1 /*******************************************************************************
3 * Module Name: dbcmds - debug commands and output routines
6 ******************************************************************************/
8 /******************************************************************************
12 * Some or all of this work - Copyright (c) 1999 - 2006, 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 *****************************************************************************/
119 #include "acdispat.h"
121 #include "acnamesp.h"
122 #include "acevents.h"
125 #include "acdisasm.h"
128 #include "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 ******************************************************************************/
288 #if ACPI_MACHINE_WIDTH == 16
295 SleepState
= (UINT8
) ACPI_STRTOUL (ObjectArg
, NULL
, 0);
297 AcpiOsPrintf ("**** Prepare to sleep ****\n");
298 Status
= AcpiEnterSleepStatePrep (SleepState
);
299 if (ACPI_FAILURE (Status
))
304 AcpiOsPrintf ("**** Going to sleep ****\n");
305 Status
= AcpiEnterSleepState (SleepState
);
306 if (ACPI_FAILURE (Status
))
311 AcpiOsPrintf ("**** returning from sleep ****\n");
312 Status
= AcpiLeaveSleepState (SleepState
);
319 /*******************************************************************************
321 * FUNCTION: AcpiDbWalkForReferences
323 * PARAMETERS: Callback from WalkNamespace
327 * DESCRIPTION: Check if this namespace object refers to the target object
328 * that is passed in as the context value.
330 * Note: Currently doesn't check subobjects within the Node's object
332 ******************************************************************************/
335 AcpiDbWalkForReferences (
336 ACPI_HANDLE ObjHandle
,
341 ACPI_OPERAND_OBJECT
*ObjDesc
= (ACPI_OPERAND_OBJECT
*) Context
;
342 ACPI_NAMESPACE_NODE
*Node
= (ACPI_NAMESPACE_NODE
*) ObjHandle
;
345 /* Check for match against the namespace node itself */
347 if (Node
== (void *) ObjDesc
)
349 AcpiOsPrintf ("Object is a Node [%4.4s]\n",
350 AcpiUtGetNodeName (Node
));
353 /* Check for match against the object attached to the node */
355 if (AcpiNsGetAttachedObject (Node
) == ObjDesc
)
357 AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n",
358 Node
, AcpiUtGetNodeName (Node
));
365 /*******************************************************************************
367 * FUNCTION: AcpiDbFindReferences
369 * PARAMETERS: ObjectArg - String with hex value of the object
373 * DESCRIPTION: Search namespace for all references to the input object
375 ******************************************************************************/
378 AcpiDbFindReferences (
381 ACPI_OPERAND_OBJECT
*ObjDesc
;
384 /* Convert string to object pointer */
386 ObjDesc
= ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg
, NULL
, 16));
388 /* Search all nodes in namespace */
390 (void) AcpiWalkNamespace (ACPI_TYPE_ANY
, ACPI_ROOT_OBJECT
, ACPI_UINT32_MAX
,
391 AcpiDbWalkForReferences
, (void *) ObjDesc
, NULL
);
395 /*******************************************************************************
397 * FUNCTION: AcpiDbDisplayLocks
403 * DESCRIPTION: Display information about internal mutexes.
405 ******************************************************************************/
414 for (i
= 0; i
< ACPI_MAX_MUTEX
; i
++)
416 AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i
),
417 AcpiGbl_MutexInfo
[i
].ThreadId
== ACPI_MUTEX_NOT_ACQUIRED
418 ? "Locked" : "Unlocked");
423 /*******************************************************************************
425 * FUNCTION: AcpiDbDisplayTableInfo
427 * PARAMETERS: TableArg - String with name of table to be displayed
431 * DESCRIPTION: Display information about loaded tables. Current
432 * implementation displays all loaded tables.
434 ******************************************************************************/
437 AcpiDbDisplayTableInfo (
441 ACPI_TABLE_DESC
*TableDesc
;
445 * Walk the root table list
447 for (i
= 0; i
< AcpiGbl_RootTableList
.Count
; i
++)
449 TableDesc
= &AcpiGbl_RootTableList
.Tables
[i
];
450 AcpiOsPrintf ( "%4.4s at %p length %.5X",
451 TableDesc
->Signature
.Ascii
, TableDesc
->Pointer
,
452 (UINT32
) TableDesc
->Length
);
454 if (TableDesc
->Pointer
&& (i
!= ACPI_TABLE_INDEX_FACS
))
456 AcpiOsPrintf (" OemId=\"%6s\" OemTableId=\"%8s\" OemRevision=%8.8X",
457 TableDesc
->Pointer
->OemId
,
458 TableDesc
->Pointer
->OemTableId
,
459 TableDesc
->Pointer
->OemRevision
);
466 /*******************************************************************************
468 * FUNCTION: AcpiDbUnloadAcpiTable
470 * PARAMETERS: TableArg - Name of the table to be unloaded
471 * InstanceArg - Which instance of the table to unload (if
472 * there are multiple tables of the same type)
476 * DESCRIPTION: Unload an ACPI table.
477 * Instance is not implemented
479 ******************************************************************************/
482 AcpiDbUnloadAcpiTable (
486 /* TBD: Need to reimplement for new data structures */
493 /* Search all tables for the target type */
495 for (i
= 0; i
< (ACPI_TABLE_ID_MAX
+1); i
++)
497 if (!ACPI_STRNCMP (TableArg
, AcpiGbl_TableData
[i
].Signature
,
498 AcpiGbl_TableData
[i
].SigLength
))
500 /* Found the table, unload it */
502 Status
= AcpiUnloadTable (i
);
503 if (ACPI_SUCCESS (Status
))
505 AcpiOsPrintf ("[%s] unloaded and uninstalled\n", TableArg
);
509 AcpiOsPrintf ("%s, while unloading [%s]\n",
510 AcpiFormatException (Status
), TableArg
);
517 AcpiOsPrintf ("Unknown table type [%s]\n", TableArg
);
522 /*******************************************************************************
524 * FUNCTION: AcpiDbSetMethodBreakpoint
526 * PARAMETERS: Location - AML offset of breakpoint
527 * WalkState - Current walk info
528 * Op - Current Op (from parse walk)
532 * DESCRIPTION: Set a breakpoint in a control method at the specified
535 ******************************************************************************/
538 AcpiDbSetMethodBreakpoint (
540 ACPI_WALK_STATE
*WalkState
,
541 ACPI_PARSE_OBJECT
*Op
)
548 AcpiOsPrintf ("There is no method currently executing\n");
552 /* Get and verify the breakpoint address */
554 Address
= ACPI_STRTOUL (Location
, NULL
, 16);
555 if (Address
<= Op
->Common
.AmlOffset
)
557 AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n",
558 Address
, Op
->Common
.AmlOffset
);
561 /* Save breakpoint in current walk */
563 WalkState
->UserBreakpoint
= Address
;
564 AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address
);
568 /*******************************************************************************
570 * FUNCTION: AcpiDbSetMethodCallBreakpoint
572 * PARAMETERS: Op - Current Op (from parse walk)
576 * DESCRIPTION: Set a breakpoint in a control method at the specified
579 ******************************************************************************/
582 AcpiDbSetMethodCallBreakpoint (
583 ACPI_PARSE_OBJECT
*Op
)
589 AcpiOsPrintf ("There is no method currently executing\n");
593 AcpiGbl_StepToNextCall
= TRUE
;
597 /*******************************************************************************
599 * FUNCTION: AcpiDbDisassembleAml
601 * PARAMETERS: Statements - Number of statements to disassemble
602 * Op - Current Op (from parse walk)
606 * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
607 * of statements specified.
609 ******************************************************************************/
612 AcpiDbDisassembleAml (
614 ACPI_PARSE_OBJECT
*Op
)
616 UINT32 NumStatements
= 8;
621 AcpiOsPrintf ("There is no method currently executing\n");
627 NumStatements
= ACPI_STRTOUL (Statements
, NULL
, 0);
630 AcpiDmDisassemble (NULL
, Op
, NumStatements
);
634 /*******************************************************************************
636 * FUNCTION: AcpiDbDisassembleMethod
638 * PARAMETERS: Name - Name of control method
642 * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
643 * of statements specified.
645 ******************************************************************************/
648 AcpiDbDisassembleMethod (
652 ACPI_PARSE_OBJECT
*Op
;
653 ACPI_WALK_STATE
*WalkState
;
654 ACPI_OPERAND_OBJECT
*ObjDesc
;
655 ACPI_NAMESPACE_NODE
*Method
;
658 Method
= AcpiDbConvertToNode (Name
);
661 return (AE_BAD_PARAMETER
);
664 ObjDesc
= Method
->Object
;
666 Op
= AcpiPsCreateScopeOp ();
669 return (AE_NO_MEMORY
);
672 /* Create and initialize a new walk state */
674 WalkState
= AcpiDsCreateWalkState (0, Op
, NULL
, NULL
);
677 return (AE_NO_MEMORY
);
680 Status
= AcpiDsInitAmlWalk (WalkState
, Op
, NULL
,
681 ObjDesc
->Method
.AmlStart
,
682 ObjDesc
->Method
.AmlLength
, NULL
, ACPI_IMODE_LOAD_PASS1
);
683 if (ACPI_FAILURE (Status
))
690 WalkState
->ParseFlags
&= ~ACPI_PARSE_DELETE_TREE
;
691 WalkState
->ParseFlags
|= ACPI_PARSE_DISASSEMBLE
;
692 Status
= AcpiPsParseAml (WalkState
);
694 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 #if ACPI_MACHINE_WIDTH != 16
1450 ACPI_NAMESPACE_NODE
*Node
;
1452 ACPI_BUFFER ReturnObj
;
1455 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT
);
1456 AcpiDbgLevel
|= ACPI_LV_RESOURCES
;
1458 /* Convert string to object pointer */
1460 Node
= AcpiDbConvertToNode (ObjectArg
);
1466 /* Prepare for a return object of arbitrary size */
1468 ReturnObj
.Pointer
= AcpiGbl_DbBuffer
;
1469 ReturnObj
.Length
= ACPI_DEBUG_BUFFER_SIZE
;
1473 AcpiOsPrintf ("Evaluating _PRT\n");
1475 /* Check if _PRT exists */
1477 Status
= AcpiEvaluateObject (Node
, METHOD_NAME__PRT
, NULL
, &ReturnObj
);
1478 if (ACPI_FAILURE (Status
))
1480 AcpiOsPrintf ("Could not obtain _PRT: %s\n",
1481 AcpiFormatException (Status
));
1485 ReturnObj
.Pointer
= AcpiGbl_DbBuffer
;
1486 ReturnObj
.Length
= ACPI_DEBUG_BUFFER_SIZE
;
1488 Status
= AcpiGetIrqRoutingTable (Node
, &ReturnObj
);
1489 if (ACPI_FAILURE (Status
))
1491 AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n",
1492 AcpiFormatException (Status
));
1496 AcpiRsDumpIrqList (ACPI_CAST_PTR (UINT8
, AcpiGbl_DbBuffer
));
1502 AcpiOsPrintf ("Evaluating _CRS\n");
1504 ReturnObj
.Pointer
= AcpiGbl_DbBuffer
;
1505 ReturnObj
.Length
= ACPI_DEBUG_BUFFER_SIZE
;
1507 /* Check if _CRS exists */
1509 Status
= AcpiEvaluateObject (Node
, METHOD_NAME__CRS
, NULL
, &ReturnObj
);
1510 if (ACPI_FAILURE (Status
))
1512 AcpiOsPrintf ("Could not obtain _CRS: %s\n",
1513 AcpiFormatException (Status
));
1517 /* Get the _CRS resource list */
1519 ReturnObj
.Pointer
= AcpiGbl_DbBuffer
;
1520 ReturnObj
.Length
= ACPI_DEBUG_BUFFER_SIZE
;
1522 Status
= AcpiGetCurrentResources (Node
, &ReturnObj
);
1523 if (ACPI_FAILURE (Status
))
1525 AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
1526 AcpiFormatException (Status
));
1530 /* Dump the _CRS resource list */
1532 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE
,
1533 ReturnObj
.Pointer
));
1536 * Perform comparison of original AML to newly created AML. This tests both
1537 * the AML->Resource conversion and the Resource->Aml conversion.
1539 Status
= AcpiDmTestResourceConversion (Node
, METHOD_NAME__CRS
);
1541 /* Execute _SRS with the resource list */
1543 Status
= AcpiSetCurrentResources (Node
, &ReturnObj
);
1544 if (ACPI_FAILURE (Status
))
1546 AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n",
1547 AcpiFormatException (Status
));
1555 AcpiOsPrintf ("Evaluating _PRS\n");
1557 ReturnObj
.Pointer
= AcpiGbl_DbBuffer
;
1558 ReturnObj
.Length
= ACPI_DEBUG_BUFFER_SIZE
;
1560 /* Check if _PRS exists */
1562 Status
= AcpiEvaluateObject (Node
, METHOD_NAME__PRS
, NULL
, &ReturnObj
);
1563 if (ACPI_FAILURE (Status
))
1565 AcpiOsPrintf ("Could not obtain _PRS: %s\n",
1566 AcpiFormatException (Status
));
1570 ReturnObj
.Pointer
= AcpiGbl_DbBuffer
;
1571 ReturnObj
.Length
= ACPI_DEBUG_BUFFER_SIZE
;
1573 Status
= AcpiGetPossibleResources (Node
, &ReturnObj
);
1574 if (ACPI_FAILURE (Status
))
1576 AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n",
1577 AcpiFormatException (Status
));
1581 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE
, AcpiGbl_DbBuffer
));
1585 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT
);
1591 /*******************************************************************************
1593 * FUNCTION: AcpiDbIntegrityWalk
1595 * PARAMETERS: Callback from WalkNamespace
1599 * DESCRIPTION: Examine one NS node for valid values.
1601 ******************************************************************************/
1604 AcpiDbIntegrityWalk (
1605 ACPI_HANDLE ObjHandle
,
1606 UINT32 NestingLevel
,
1610 ACPI_INTEGRITY_INFO
*Info
= (ACPI_INTEGRITY_INFO
*) Context
;
1611 ACPI_NAMESPACE_NODE
*Node
= (ACPI_NAMESPACE_NODE
*) ObjHandle
;
1612 ACPI_OPERAND_OBJECT
*Object
;
1616 if (ACPI_GET_DESCRIPTOR_TYPE (Node
) != ACPI_DESC_TYPE_NAMED
)
1618 AcpiOsPrintf ("Invalid Descriptor Type for Node %p [%s]\n",
1619 Node
, AcpiUtGetDescriptorName (Node
));
1622 if (Node
->Type
> ACPI_TYPE_LOCAL_MAX
)
1624 AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n",
1628 if (!AcpiUtValidAcpiName (Node
->Name
.Integer
))
1630 AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node
);
1633 Object
= AcpiNsGetAttachedObject (Node
);
1637 if (ACPI_GET_DESCRIPTOR_TYPE (Object
) != ACPI_DESC_TYPE_OPERAND
)
1639 AcpiOsPrintf ("Invalid Descriptor Type for Object %p [%s]\n",
1640 Object
, AcpiUtGetDescriptorName (Object
));
1648 /*******************************************************************************
1650 * FUNCTION: AcpiDbCheckIntegrity
1656 * DESCRIPTION: Check entire namespace for data structure integrity
1658 ******************************************************************************/
1661 AcpiDbCheckIntegrity (
1664 ACPI_INTEGRITY_INFO Info
= {0,0};
1666 /* Search all nodes in namespace */
1668 (void) AcpiWalkNamespace (ACPI_TYPE_ANY
, ACPI_ROOT_OBJECT
, ACPI_UINT32_MAX
,
1669 AcpiDbIntegrityWalk
, (void *) &Info
, NULL
);
1671 AcpiOsPrintf ("Verified %d namespace nodes with %d Objects\n",
1672 Info
.Nodes
, Info
.Objects
);
1676 /*******************************************************************************
1678 * FUNCTION: AcpiDbGenerateGpe
1680 * PARAMETERS: GpeArg - Raw GPE number, ascii string
1681 * BlockArg - GPE block number, ascii string
1682 * 0 or 1 for FADT GPE blocks
1686 * DESCRIPTION: Generate a GPE
1688 ******************************************************************************/
1697 ACPI_GPE_EVENT_INFO
*GpeEventInfo
;
1700 GpeNumber
= ACPI_STRTOUL (GpeArg
, NULL
, 0);
1701 BlockNumber
= ACPI_STRTOUL (BlockArg
, NULL
, 0);
1704 GpeEventInfo
= AcpiEvGetGpeEventInfo (ACPI_TO_POINTER (BlockNumber
),
1708 AcpiOsPrintf ("Invalid GPE\n");
1712 (void) AcpiEvGpeDispatch (GpeEventInfo
, GpeNumber
);
1716 /*******************************************************************************
1718 * FUNCTION: AcpiDbBusWalk
1720 * PARAMETERS: Callback from WalkNamespace
1724 * DESCRIPTION: Display info about device objects that have a corresponding
1727 ******************************************************************************/
1731 ACPI_HANDLE ObjHandle
,
1732 UINT32 NestingLevel
,
1736 ACPI_NAMESPACE_NODE
*Node
= (ACPI_NAMESPACE_NODE
*) ObjHandle
;
1741 ACPI_COMPATIBLE_ID_LIST
*Cid
;
1742 ACPI_NAMESPACE_NODE
*TempNode
;
1745 /* Exit if there is no _PRT under this device */
1747 Status
= AcpiGetHandle (Node
, METHOD_NAME__PRT
,
1748 ACPI_CAST_PTR (ACPI_HANDLE
, &TempNode
));
1749 if (ACPI_FAILURE (Status
))
1754 /* Get the full path to this device object */
1756 Buffer
.Length
= ACPI_ALLOCATE_LOCAL_BUFFER
;
1757 Status
= AcpiNsHandleToPathname (ObjHandle
, &Buffer
);
1758 if (ACPI_FAILURE (Status
))
1760 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle
);
1764 /* Display the full path */
1766 AcpiOsPrintf ("%-32s", (char *) Buffer
.Pointer
);
1767 ACPI_FREE (Buffer
.Pointer
);
1771 AcpiOsPrintf ("_PRT=%p", TempNode
);
1773 /* Get the _ADR value */
1775 Status
= AcpiUtEvaluateNumericObject (METHOD_NAME__ADR
, Node
, &ADR
);
1776 if (ACPI_FAILURE (Status
))
1778 AcpiOsPrintf (" No _ADR ");
1782 AcpiOsPrintf (" _ADR=%8.8X", (UINT32
) ADR
);
1785 /* Get the _HID if present */
1787 Status
= AcpiUtExecute_HID (Node
, &Id
);
1788 if (ACPI_SUCCESS (Status
))
1790 AcpiOsPrintf (" _HID=%s", Id
.Value
);
1797 /* Get the _UID if present */
1799 Status
= AcpiUtExecute_UID (Node
, &Id
);
1800 if (ACPI_SUCCESS (Status
))
1802 AcpiOsPrintf (" _UID=%s", Id
.Value
);
1805 /* Get the _CID if present */
1807 Status
= AcpiUtExecute_CID (Node
, &Cid
);
1808 if (ACPI_SUCCESS (Status
))
1810 AcpiOsPrintf (" _CID=%s", Cid
->Id
[0].Value
);
1814 AcpiOsPrintf ("\n");
1819 /*******************************************************************************
1821 * FUNCTION: AcpiDbGetBusInfo
1827 * DESCRIPTION: Display info about system busses.
1829 ******************************************************************************/
1835 /* Search all nodes in namespace */
1837 (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE
, ACPI_ROOT_OBJECT
, ACPI_UINT32_MAX
,
1838 AcpiDbBusWalk
, NULL
, NULL
);
1841 #endif /* ACPI_DEBUGGER */