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 *****************************************************************************/
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")
137 * Arguments for the Objects command
138 * These object types map directly to the ACPI_TYPES
141 static ARGUMENT_INFO AcpiDbObjectTypes
[] =
159 {NULL
} /* Must be null terminated */
163 /*******************************************************************************
165 * FUNCTION: AcpiDbSleep
167 * PARAMETERS: ObjectArg - Desired sleep state (0-5)
171 * DESCRIPTION: Simulate a sleep/wake sequence
173 ******************************************************************************/
179 #if ACPI_MACHINE_WIDTH == 16
186 SleepState
= (UINT8
) ACPI_STRTOUL (ObjectArg
, NULL
, 0);
188 AcpiOsPrintf ("**** Prepare to sleep ****\n");
189 Status
= AcpiEnterSleepStatePrep (SleepState
);
190 if (ACPI_FAILURE (Status
))
195 AcpiOsPrintf ("**** Going to sleep ****\n");
196 Status
= AcpiEnterSleepState (SleepState
);
197 if (ACPI_FAILURE (Status
))
202 AcpiOsPrintf ("**** returning from sleep ****\n");
203 Status
= AcpiLeaveSleepState (SleepState
);
210 /*******************************************************************************
212 * FUNCTION: AcpiDbWalkForReferences
214 * PARAMETERS: Callback from WalkNamespace
218 * DESCRIPTION: Check if this namespace object refers to the target object
219 * that is passed in as the context value.
221 * Note: Currently doesn't check subobjects within the Node's object
223 ******************************************************************************/
226 AcpiDbWalkForReferences (
227 ACPI_HANDLE ObjHandle
,
232 ACPI_OPERAND_OBJECT
*ObjDesc
= (ACPI_OPERAND_OBJECT
*) Context
;
233 ACPI_NAMESPACE_NODE
*Node
= (ACPI_NAMESPACE_NODE
*) ObjHandle
;
236 /* Check for match against the namespace node itself */
238 if (Node
== (void *) ObjDesc
)
240 AcpiOsPrintf ("Object is a Node [%4.4s]\n",
241 AcpiUtGetNodeName (Node
));
244 /* Check for match against the object attached to the node */
246 if (AcpiNsGetAttachedObject (Node
) == ObjDesc
)
248 AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n",
249 Node
, AcpiUtGetNodeName (Node
));
256 /*******************************************************************************
258 * FUNCTION: AcpiDbFindReferences
260 * PARAMETERS: ObjectArg - String with hex value of the object
264 * DESCRIPTION: Search namespace for all references to the input object
266 ******************************************************************************/
269 AcpiDbFindReferences (
272 ACPI_OPERAND_OBJECT
*ObjDesc
;
275 /* Convert string to object pointer */
277 ObjDesc
= ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg
, NULL
, 16));
279 /* Search all nodes in namespace */
281 (void) AcpiWalkNamespace (ACPI_TYPE_ANY
, ACPI_ROOT_OBJECT
, ACPI_UINT32_MAX
,
282 AcpiDbWalkForReferences
, (void *) ObjDesc
, NULL
);
286 /*******************************************************************************
288 * FUNCTION: AcpiDbDisplayLocks
294 * DESCRIPTION: Display information about internal mutexes.
296 ******************************************************************************/
299 AcpiDbDisplayLocks (void)
304 for (i
= 0; i
< MAX_MUTEX
; i
++)
306 AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i
),
307 AcpiGbl_MutexInfo
[i
].OwnerId
== ACPI_MUTEX_NOT_ACQUIRED
308 ? "Locked" : "Unlocked");
313 /*******************************************************************************
315 * FUNCTION: AcpiDbDisplayTableInfo
317 * PARAMETERS: TableArg - String with name of table to be displayed
321 * DESCRIPTION: Display information about loaded tables. Current
322 * implementation displays all loaded tables.
324 ******************************************************************************/
327 AcpiDbDisplayTableInfo (
331 ACPI_TABLE_DESC
*TableDesc
;
334 for (i
= 0; i
< NUM_ACPI_TABLE_TYPES
; i
++)
336 TableDesc
= AcpiGbl_TableLists
[i
].Next
;
339 AcpiOsPrintf ( "%s at %p length %.5X",
340 AcpiGbl_TableData
[i
].Name
, TableDesc
->Pointer
,
341 (UINT32
) TableDesc
->Length
);
343 if (i
!= ACPI_TABLE_FACS
)
345 AcpiOsPrintf (" OemID=%6s TableId=%8s OemRevision=%8.8X",
346 TableDesc
->Pointer
->OemId
,
347 TableDesc
->Pointer
->OemTableId
,
348 TableDesc
->Pointer
->OemRevision
);
352 TableDesc
= TableDesc
->Next
;
358 /*******************************************************************************
360 * FUNCTION: AcpiDbUnloadAcpiTable
362 * PARAMETERS: TableArg - Name of the table to be unloaded
363 * InstanceArg - Which instance of the table to unload (if
364 * there are multiple tables of the same type)
368 * DESCRIPTION: Unload an ACPI table.
369 * Instance is not implemented
371 ******************************************************************************/
374 AcpiDbUnloadAcpiTable (
382 /* Search all tables for the target type */
384 for (i
= 0; i
< NUM_ACPI_TABLE_TYPES
; i
++)
386 if (!ACPI_STRNCMP (TableArg
, AcpiGbl_TableData
[i
].Signature
,
387 AcpiGbl_TableData
[i
].SigLength
))
389 /* Found the table, unload it */
391 Status
= AcpiUnloadTable (i
);
392 if (ACPI_SUCCESS (Status
))
394 AcpiOsPrintf ("[%s] unloaded and uninstalled\n", TableArg
);
398 AcpiOsPrintf ("%s, while unloading [%s]\n",
399 AcpiFormatException (Status
), TableArg
);
406 AcpiOsPrintf ("Unknown table type [%s]\n", TableArg
);
410 /*******************************************************************************
412 * FUNCTION: AcpiDbSetMethodBreakpoint
414 * PARAMETERS: Location - AML offset of breakpoint
415 * WalkState - Current walk info
416 * Op - Current Op (from parse walk)
420 * DESCRIPTION: Set a breakpoint in a control method at the specified
423 ******************************************************************************/
426 AcpiDbSetMethodBreakpoint (
428 ACPI_WALK_STATE
*WalkState
,
429 ACPI_PARSE_OBJECT
*Op
)
436 AcpiOsPrintf ("There is no method currently executing\n");
440 /* Get and verify the breakpoint address */
442 Address
= ACPI_STRTOUL (Location
, NULL
, 16);
443 if (Address
<= Op
->Common
.AmlOffset
)
445 AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n", Address
, Op
->Common
.AmlOffset
);
448 /* Save breakpoint in current walk */
450 WalkState
->UserBreakpoint
= Address
;
451 AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address
);
455 /*******************************************************************************
457 * FUNCTION: AcpiDbSetMethodCallBreakpoint
459 * PARAMETERS: Op - Current Op (from parse walk)
463 * DESCRIPTION: Set a breakpoint in a control method at the specified
466 ******************************************************************************/
469 AcpiDbSetMethodCallBreakpoint (
470 ACPI_PARSE_OBJECT
*Op
)
476 AcpiOsPrintf ("There is no method currently executing\n");
480 AcpiGbl_StepToNextCall
= TRUE
;
484 /*******************************************************************************
486 * FUNCTION: AcpiDbDisassembleAml
488 * PARAMETERS: Statements - Number of statements to disassemble
489 * Op - Current Op (from parse walk)
493 * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
494 * of statements specified.
496 ******************************************************************************/
499 AcpiDbDisassembleAml (
501 ACPI_PARSE_OBJECT
*Op
)
503 UINT32 NumStatements
= 8;
508 AcpiOsPrintf ("There is no method currently executing\n");
514 NumStatements
= ACPI_STRTOUL (Statements
, NULL
, 0);
517 AcpiDmDisassemble (NULL
, Op
, NumStatements
);
521 /*******************************************************************************
523 * FUNCTION: AcpiDbDisassembleMethod
525 * PARAMETERS: Method - Name of control method
529 * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
530 * of statements specified.
532 ******************************************************************************/
535 AcpiDbDisassembleMethod (
539 ACPI_PARSE_OBJECT
*Op
;
540 ACPI_WALK_STATE
*WalkState
;
541 ACPI_OPERAND_OBJECT
*ObjDesc
;
542 ACPI_NAMESPACE_NODE
*Method
;
545 Method
= ACPI_CAST_PTR (ACPI_NAMESPACE_NODE
, ACPI_STRTOUL (Name
, NULL
, 16));
548 return (AE_BAD_PARAMETER
);
551 ObjDesc
= Method
->Object
;
553 Op
= AcpiPsCreateScopeOp ();
556 return (AE_NO_MEMORY
);
559 /* Create and initialize a new walk state */
561 WalkState
= AcpiDsCreateWalkState (0, Op
, NULL
, NULL
);
564 return (AE_NO_MEMORY
);
567 Status
= AcpiDsInitAmlWalk (WalkState
, Op
, NULL
,
568 ObjDesc
->Method
.AmlStart
,
569 ObjDesc
->Method
.AmlLength
, NULL
, 1);
570 if (ACPI_FAILURE (Status
))
577 WalkState
->ParseFlags
&= ~ACPI_PARSE_DELETE_TREE
;
578 Status
= AcpiPsParseAml (WalkState
);
580 AcpiDmDisassemble (NULL
, Op
, 0);
581 AcpiPsDeleteParseTree (Op
);
586 /*******************************************************************************
588 * FUNCTION: AcpiDbDumpNamespace
590 * PARAMETERS: StartArg - Node to begin namespace dump
591 * DepthArg - Maximum tree depth to be dumped
595 * DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed
596 * with type and other information.
598 ******************************************************************************/
601 AcpiDbDumpNamespace (
605 ACPI_HANDLE SubtreeEntry
= AcpiGbl_RootNode
;
606 UINT32 MaxDepth
= ACPI_UINT32_MAX
;
609 /* No argument given, just start at the root and dump entire namespace */
613 /* Check if numeric argument, must be a Node */
615 if ((StartArg
[0] >= 0x30) && (StartArg
[0] <= 0x39))
617 SubtreeEntry
= ACPI_TO_POINTER (ACPI_STRTOUL (StartArg
, NULL
, 16));
618 if (!AcpiOsReadable (SubtreeEntry
, sizeof (ACPI_NAMESPACE_NODE
)))
620 AcpiOsPrintf ("Address %p is invalid in this address space\n", SubtreeEntry
);
624 if (ACPI_GET_DESCRIPTOR_TYPE (SubtreeEntry
) != ACPI_DESC_TYPE_NAMED
)
626 AcpiOsPrintf ("Address %p is not a valid NS node [%s]\n",
627 SubtreeEntry
, AcpiUtGetDescriptorName (SubtreeEntry
));
634 /* The parameter is a name string that must be resolved to a Named obj*/
636 SubtreeEntry
= AcpiDbLocalNsLookup (StartArg
);
639 SubtreeEntry
= AcpiGbl_RootNode
;
643 /* Now we can check for the depth argument */
647 MaxDepth
= ACPI_STRTOUL (DepthArg
, NULL
, 0);
651 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT
);
652 AcpiOsPrintf ("ACPI Namespace (from %p subtree):\n", SubtreeEntry
);
654 /* Display the subtree */
656 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT
);
657 AcpiNsDumpObjects (ACPI_TYPE_ANY
, ACPI_DISPLAY_SUMMARY
, MaxDepth
, ACPI_UINT32_MAX
, SubtreeEntry
);
658 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT
);
662 /*******************************************************************************
664 * FUNCTION: AcpiDbDumpNamespaceByOwner
666 * PARAMETERS: OwnerArg - Owner ID whose nodes will be displayed
667 * DepthArg - Maximum tree depth to be dumped
671 * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId.
673 ******************************************************************************/
676 AcpiDbDumpNamespaceByOwner (
680 ACPI_HANDLE SubtreeEntry
= AcpiGbl_RootNode
;
681 UINT32 MaxDepth
= ACPI_UINT32_MAX
;
685 OwnerId
= (UINT16
) ACPI_STRTOUL (OwnerArg
, NULL
, 0);
687 /* Now we can check for the depth argument */
691 MaxDepth
= ACPI_STRTOUL (DepthArg
, NULL
, 0);
694 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT
);
695 AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId
);
697 /* Display the subtree */
699 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT
);
700 AcpiNsDumpObjects (ACPI_TYPE_ANY
, ACPI_DISPLAY_SUMMARY
, MaxDepth
, OwnerId
, SubtreeEntry
);
701 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT
);
705 /*******************************************************************************
707 * FUNCTION: AcpiDbSendNotify
709 * PARAMETERS: Name - Name of ACPI object to send the notify to
710 * Value - Value of the notify to send.
714 * DESCRIPTION: Send an ACPI notification. The value specified is sent to the
715 * named object as an ACPI notify.
717 ******************************************************************************/
724 ACPI_NAMESPACE_NODE
*Node
;
728 /* Translate name to an Named object */
730 Node
= AcpiDbLocalNsLookup (Name
);
736 /* Decode Named object type */
740 case ACPI_TYPE_DEVICE
:
741 case ACPI_TYPE_THERMAL
:
743 /* Send the notify */
745 Status
= AcpiEvQueueNotifyRequest (Node
, Value
);
746 if (ACPI_FAILURE (Status
))
748 AcpiOsPrintf ("Could not queue notify\n");
753 AcpiOsPrintf ("Named object is not a device or a thermal object\n");
759 /*******************************************************************************
761 * FUNCTION: AcpiDbSetMethodData
763 * PARAMETERS: TypeArg - L for local, A for argument
764 * IndexArg - which one
765 * ValueArg - Value to set.
769 * DESCRIPTION: Set a local or argument for the running control method.
770 * NOTE: only object supported is Number.
772 ******************************************************************************/
775 AcpiDbSetMethodData (
783 ACPI_WALK_STATE
*WalkState
;
784 ACPI_OPERAND_OBJECT
*ObjDesc
;
788 /* Validate TypeArg */
790 ACPI_STRUPR (TypeArg
);
795 AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg
);
799 /* Get the index and value */
801 Index
= ACPI_STRTOUL (IndexArg
, NULL
, 16);
802 Value
= ACPI_STRTOUL (ValueArg
, NULL
, 16);
804 WalkState
= AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList
);
807 AcpiOsPrintf ("There is no method currently executing\n");
811 /* Create and initialize the new object */
813 ObjDesc
= AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER
);
816 AcpiOsPrintf ("Could not create an internal object\n");
820 ObjDesc
->Integer
.Value
= Value
;
822 /* Store the new object into the target */
828 /* Set a method argument */
830 if (Index
> ACPI_METHOD_MAX_ARG
)
832 AcpiOsPrintf ("Arg%d - Invalid argument name\n", Index
);
836 Status
= AcpiDsStoreObjectToLocal (AML_ARG_OP
, Index
, ObjDesc
, WalkState
);
837 if (ACPI_FAILURE (Status
))
842 ObjDesc
= WalkState
->Arguments
[Index
].Object
;
844 AcpiOsPrintf ("Arg%d: ", Index
);
845 AcpiDmDisplayInternalObject (ObjDesc
, WalkState
);
850 /* Set a method local */
852 if (Index
> ACPI_METHOD_MAX_LOCAL
)
854 AcpiOsPrintf ("Local%d - Invalid local variable name\n", Index
);
858 Status
= AcpiDsStoreObjectToLocal (AML_LOCAL_OP
, Index
, ObjDesc
, WalkState
);
859 if (ACPI_FAILURE (Status
))
864 ObjDesc
= WalkState
->LocalVariables
[Index
].Object
;
866 AcpiOsPrintf ("Local%d: ", Index
);
867 AcpiDmDisplayInternalObject (ObjDesc
, WalkState
);
876 /*******************************************************************************
878 * FUNCTION: AcpiDbWalkForSpecificObjects
880 * PARAMETERS: Callback from WalkNamespace
884 * DESCRIPTION: Display short info about objects in the namespace
886 ******************************************************************************/
889 AcpiDbWalkForSpecificObjects (
890 ACPI_HANDLE ObjHandle
,
895 ACPI_OPERAND_OBJECT
*ObjDesc
;
900 ObjDesc
= AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE
*) ObjHandle
);
902 /* Get and display the full pathname to this object */
904 Buffer
.Length
= ACPI_ALLOCATE_LOCAL_BUFFER
;
905 Status
= AcpiNsHandleToPathname (ObjHandle
, &Buffer
);
906 if (ACPI_FAILURE (Status
))
908 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle
);
912 AcpiOsPrintf ("%32s", (char *) Buffer
.Pointer
);
913 ACPI_MEM_FREE (Buffer
.Pointer
);
915 /* Display short information about the object */
919 AcpiOsPrintf (" %p/%p", ObjHandle
, ObjDesc
);
921 switch (ACPI_GET_OBJECT_TYPE (ObjDesc
))
923 case ACPI_TYPE_METHOD
:
924 AcpiOsPrintf (" #Args %d Concurrency %X",
925 ObjDesc
->Method
.ParamCount
, ObjDesc
->Method
.Concurrency
);
928 case ACPI_TYPE_INTEGER
:
929 AcpiOsPrintf (" Value %8.8X%8.8X",
930 ACPI_FORMAT_UINT64 (ObjDesc
->Integer
.Value
));
933 case ACPI_TYPE_STRING
:
934 AcpiOsPrintf (" \"%s\"", ObjDesc
->String
.Pointer
);
937 case ACPI_TYPE_REGION
:
938 AcpiOsPrintf (" SpaceId %X Length %X Address %8.8X%8.8X",
939 ObjDesc
->Region
.SpaceId
,
940 ObjDesc
->Region
.Length
,
941 ACPI_FORMAT_UINT64 (ObjDesc
->Region
.Address
));
944 case ACPI_TYPE_PACKAGE
:
945 AcpiOsPrintf (" #Elements %X", ObjDesc
->Package
.Count
);
948 case ACPI_TYPE_BUFFER
:
949 AcpiOsPrintf (" Length %X", ObjDesc
->Buffer
.Length
);
953 /* Ignore other object types */
963 /*******************************************************************************
965 * FUNCTION: AcpiDbDisplayObjects
967 * PARAMETERS: ObjTypeArg - Type of object to display
968 * DisplayCountArg - Max depth to display
972 * DESCRIPTION: Display objects in the namespace of the requested type
974 ******************************************************************************/
977 AcpiDbDisplayObjects (
979 char *DisplayCountArg
)
981 ACPI_OBJECT_TYPE Type
;
984 /* Get the object type */
986 Type
= AcpiDbMatchArgument (ObjTypeArg
, AcpiDbObjectTypes
);
987 if (Type
== ACPI_TYPE_NOT_FOUND
)
989 AcpiOsPrintf ("Invalid or unsupported argument\n");
993 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT
);
994 AcpiOsPrintf ("Objects of type [%s] defined in the current ACPI Namespace: \n",
995 AcpiUtGetTypeName (Type
));
997 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT
);
999 /* Walk the namespace from the root */
1001 (void) AcpiWalkNamespace (Type
, ACPI_ROOT_OBJECT
, ACPI_UINT32_MAX
,
1002 AcpiDbWalkForSpecificObjects
, (void *) &Type
, NULL
);
1004 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT
);
1009 /*******************************************************************************
1011 * FUNCTION: AcpiDbWalkAndMatchName
1013 * PARAMETERS: Callback from WalkNamespace
1017 * DESCRIPTION: Find a particular name/names within the namespace. Wildcards
1018 * are supported -- '?' matches any character.
1020 ******************************************************************************/
1023 AcpiDbWalkAndMatchName (
1024 ACPI_HANDLE ObjHandle
,
1025 UINT32 NestingLevel
,
1030 char *RequestedName
= (char *) Context
;
1035 /* Check for a name match */
1037 for (i
= 0; i
< 4; i
++)
1039 /* Wildcard support */
1041 if ((RequestedName
[i
] != '?') &&
1042 (RequestedName
[i
] != ((ACPI_NAMESPACE_NODE
*) ObjHandle
)->Name
.Ascii
[i
]))
1044 /* No match, just exit */
1050 /* Get the full pathname to this object */
1052 Buffer
.Length
= ACPI_ALLOCATE_LOCAL_BUFFER
;
1053 Status
= AcpiNsHandleToPathname (ObjHandle
, &Buffer
);
1054 if (ACPI_FAILURE (Status
))
1056 AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle
);
1060 AcpiOsPrintf ("%32s (%p) - %s\n", (char *) Buffer
.Pointer
, ObjHandle
,
1061 AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE
*) ObjHandle
)->Type
));
1062 ACPI_MEM_FREE (Buffer
.Pointer
);
1069 /*******************************************************************************
1071 * FUNCTION: AcpiDbFindNameInNamespace
1073 * PARAMETERS: NameArg - The 4-character ACPI name to find.
1074 * wildcards are supported.
1078 * DESCRIPTION: Search the namespace for a given name (with wildcards)
1080 ******************************************************************************/
1083 AcpiDbFindNameInNamespace (
1087 if (ACPI_STRLEN (NameArg
) > 4)
1089 AcpiOsPrintf ("Name must be no longer than 4 characters\n");
1093 /* Walk the namespace from the root */
1095 (void) AcpiWalkNamespace (ACPI_TYPE_ANY
, ACPI_ROOT_OBJECT
, ACPI_UINT32_MAX
,
1096 AcpiDbWalkAndMatchName
, NameArg
, NULL
);
1098 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT
);
1103 /*******************************************************************************
1105 * FUNCTION: AcpiDbSetScope
1107 * PARAMETERS: Name - New scope path
1111 * DESCRIPTION: Set the "current scope" as maintained by this utility.
1112 * The scope is used as a prefix to ACPI paths.
1114 ******************************************************************************/
1121 ACPI_NAMESPACE_NODE
*Node
;
1124 if (!Name
|| Name
[0] == 0)
1126 AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf
);
1130 AcpiDbPrepNamestring (Name
);
1132 if (Name
[0] == '\\')
1134 /* Validate new scope from the root */
1136 Status
= AcpiNsGetNodeByPath (Name
, AcpiGbl_RootNode
, ACPI_NS_NO_UPSEARCH
, &Node
);
1137 if (ACPI_FAILURE (Status
))
1142 ACPI_STRCPY (AcpiGbl_DbScopeBuf
, Name
);
1143 ACPI_STRCAT (AcpiGbl_DbScopeBuf
, "\\");
1147 /* Validate new scope relative to old scope */
1149 Status
= AcpiNsGetNodeByPath (Name
, AcpiGbl_DbScopeNode
, ACPI_NS_NO_UPSEARCH
, &Node
);
1150 if (ACPI_FAILURE (Status
))
1155 ACPI_STRCAT (AcpiGbl_DbScopeBuf
, Name
);
1156 ACPI_STRCAT (AcpiGbl_DbScopeBuf
, "\\");
1159 AcpiGbl_DbScopeNode
= Node
;
1160 AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf
);
1165 AcpiOsPrintf ("Could not attach scope: %s, %s\n", Name
, AcpiFormatException (Status
));
1169 /*******************************************************************************
1171 * FUNCTION: AcpiDbDisplayResources
1173 * PARAMETERS: ObjectArg - String with hex value of the object
1177 * DESCRIPTION: Display the resource objects associated with a device.
1179 ******************************************************************************/
1182 AcpiDbDisplayResources (
1185 #if ACPI_MACHINE_WIDTH != 16
1187 ACPI_OPERAND_OBJECT
*ObjDesc
;
1189 ACPI_BUFFER ReturnObj
;
1192 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT
);
1193 AcpiDbgLevel
|= ACPI_LV_RESOURCES
;
1195 /* Convert string to object pointer */
1197 ObjDesc
= ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg
, NULL
, 16));
1199 /* Prepare for a return object of arbitrary size */
1201 ReturnObj
.Pointer
= AcpiGbl_DbBuffer
;
1202 ReturnObj
.Length
= ACPI_DEBUG_BUFFER_SIZE
;
1206 AcpiOsPrintf ("Evaluating _PRT\n");
1208 Status
= AcpiEvaluateObject (ObjDesc
, "_PRT", NULL
, &ReturnObj
);
1209 if (ACPI_FAILURE (Status
))
1211 AcpiOsPrintf ("Could not obtain _PRT: %s\n", AcpiFormatException (Status
));
1215 ReturnObj
.Pointer
= AcpiGbl_DbBuffer
;
1216 ReturnObj
.Length
= ACPI_DEBUG_BUFFER_SIZE
;
1218 Status
= AcpiGetIrqRoutingTable (ObjDesc
, &ReturnObj
);
1219 if (ACPI_FAILURE (Status
))
1221 AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n", AcpiFormatException (Status
));
1225 AcpiRsDumpIrqList ((UINT8
*) AcpiGbl_DbBuffer
);
1232 AcpiOsPrintf ("Evaluating _CRS\n");
1234 ReturnObj
.Pointer
= AcpiGbl_DbBuffer
;
1235 ReturnObj
.Length
= ACPI_DEBUG_BUFFER_SIZE
;
1237 Status
= AcpiEvaluateObject (ObjDesc
, "_CRS", NULL
, &ReturnObj
);
1238 if (ACPI_FAILURE (Status
))
1240 AcpiOsPrintf ("Could not obtain _CRS: %s\n", AcpiFormatException (Status
));
1244 ReturnObj
.Pointer
= AcpiGbl_DbBuffer
;
1245 ReturnObj
.Length
= ACPI_DEBUG_BUFFER_SIZE
;
1247 Status
= AcpiGetCurrentResources (ObjDesc
, &ReturnObj
);
1248 if (ACPI_FAILURE (Status
))
1250 AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", AcpiFormatException (Status
));
1255 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE
, AcpiGbl_DbBuffer
));
1258 Status
= AcpiSetCurrentResources (ObjDesc
, &ReturnObj
);
1259 if (ACPI_FAILURE (Status
))
1261 AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n", AcpiFormatException (Status
));
1269 AcpiOsPrintf ("Evaluating _PRS\n");
1271 ReturnObj
.Pointer
= AcpiGbl_DbBuffer
;
1272 ReturnObj
.Length
= ACPI_DEBUG_BUFFER_SIZE
;
1274 Status
= AcpiEvaluateObject (ObjDesc
, "_PRS", NULL
, &ReturnObj
);
1275 if (ACPI_FAILURE (Status
))
1277 AcpiOsPrintf ("Could not obtain _PRS: %s\n", AcpiFormatException (Status
));
1281 ReturnObj
.Pointer
= AcpiGbl_DbBuffer
;
1282 ReturnObj
.Length
= ACPI_DEBUG_BUFFER_SIZE
;
1284 Status
= AcpiGetPossibleResources (ObjDesc
, &ReturnObj
);
1285 if (ACPI_FAILURE (Status
))
1287 AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n", AcpiFormatException (Status
));
1291 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE
, AcpiGbl_DbBuffer
));
1296 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT
);
1302 /*******************************************************************************
1304 * FUNCTION: AcpiDbIntegrityWalk
1306 * PARAMETERS: Callback from WalkNamespace
1310 * DESCRIPTION: Examine one NS node for valid values.
1312 ******************************************************************************/
1315 AcpiDbIntegrityWalk (
1316 ACPI_HANDLE ObjHandle
,
1317 UINT32 NestingLevel
,
1321 ACPI_INTEGRITY_INFO
*Info
= (ACPI_INTEGRITY_INFO
*) Context
;
1322 ACPI_NAMESPACE_NODE
*Node
= (ACPI_NAMESPACE_NODE
*) ObjHandle
;
1323 ACPI_OPERAND_OBJECT
*Object
;
1327 if (ACPI_GET_DESCRIPTOR_TYPE (Node
) != ACPI_DESC_TYPE_NAMED
)
1329 AcpiOsPrintf ("Invalid Descriptor Type for Node %p [%s]\n",
1330 Node
, AcpiUtGetDescriptorName (Node
));
1333 if (Node
->Type
> ACPI_TYPE_LOCAL_MAX
)
1335 AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n",
1339 if (!AcpiUtValidAcpiName (Node
->Name
.Integer
))
1341 AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node
);
1344 Object
= AcpiNsGetAttachedObject (Node
);
1348 if (ACPI_GET_DESCRIPTOR_TYPE (Object
) != ACPI_DESC_TYPE_OPERAND
)
1350 AcpiOsPrintf ("Invalid Descriptor Type for Object %p [%s]\n",
1351 Object
, AcpiUtGetDescriptorName (Object
));
1359 /*******************************************************************************
1361 * FUNCTION: AcpiDbCheckIntegrity
1367 * DESCRIPTION: Check entire namespace for data structure integrity
1369 ******************************************************************************/
1372 AcpiDbCheckIntegrity (void)
1374 ACPI_INTEGRITY_INFO Info
= {0,0};
1376 /* Search all nodes in namespace */
1378 (void) AcpiWalkNamespace (ACPI_TYPE_ANY
, ACPI_ROOT_OBJECT
, ACPI_UINT32_MAX
,
1379 AcpiDbIntegrityWalk
, (void *) &Info
, NULL
);
1381 AcpiOsPrintf ("Verified %d namespace nodes with %d Objects\n", Info
.Nodes
, Info
.Objects
);
1385 /*******************************************************************************
1387 * FUNCTION: AcpiDbGenerateGpe
1393 * DESCRIPTION: Generate a GPE
1395 ******************************************************************************/
1404 ACPI_GPE_EVENT_INFO
*GpeEventInfo
;
1407 GpeNumber
= ACPI_STRTOUL (GpeArg
, NULL
, 0);
1408 BlockNumber
= ACPI_STRTOUL (BlockArg
, NULL
, 0);
1411 GpeEventInfo
= AcpiEvGetGpeEventInfo (ACPI_TO_POINTER (BlockNumber
), GpeNumber
);
1414 AcpiOsPrintf ("Invalid GPE\n");
1418 (void) AcpiEvGpeDispatch (GpeEventInfo
, GpeNumber
);
1421 #endif /* ACPI_DEBUGGER */