Import acpica-unix-20061109 from Intel.
[dragonfly.git] / sys / contrib / dev / acpica-unix-20061109 / debugger / dbcmds.c
blob6c23876d99c8b6c87b9ab25ecbeb394f75855a47
1 /*******************************************************************************
3 * Module Name: dbcmds - debug commands and output routines
4 * $Revision: 1.148 $
6 ******************************************************************************/
8 /******************************************************************************
10 * 1. Copyright Notice
12 * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp.
13 * All rights reserved.
15 * 2. License
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
20 * property rights.
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
39 * conditions are met:
41 * 3. Conditions
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
65 * make.
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
71 * distribution.
73 * 3.4. Intel retains all right, title, and interest in and to the Original
74 * Intel Code.
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
89 * PARTICULAR PURPOSE.
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
98 * LIMITED REMEDY.
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 "acpi.h"
119 #include "acdispat.h"
120 #include "amlcode.h"
121 #include "acnamesp.h"
122 #include "acevents.h"
123 #include "acdebug.h"
124 #include "acresrc.h"
125 #include "acdisasm.h"
128 #include "acparser.h"
130 #ifdef ACPI_DEBUGGER
132 #define _COMPONENT ACPI_CA_DEBUGGER
133 ACPI_MODULE_NAME ("dbcmds")
135 /* Local prototypes */
137 static ACPI_STATUS
138 AcpiDbIntegrityWalk (
139 ACPI_HANDLE ObjHandle,
140 UINT32 NestingLevel,
141 void *Context,
142 void **ReturnValue);
144 static ACPI_STATUS
145 AcpiDbWalkAndMatchName (
146 ACPI_HANDLE ObjHandle,
147 UINT32 NestingLevel,
148 void *Context,
149 void **ReturnValue);
151 static ACPI_STATUS
152 AcpiDbWalkForReferences (
153 ACPI_HANDLE ObjHandle,
154 UINT32 NestingLevel,
155 void *Context,
156 void **ReturnValue);
158 static ACPI_STATUS
159 AcpiDbWalkForSpecificObjects (
160 ACPI_HANDLE ObjHandle,
161 UINT32 NestingLevel,
162 void *Context,
163 void **ReturnValue);
165 static ACPI_NAMESPACE_NODE *
166 AcpiDbConvertToNode (
167 char *InString);
169 static void
170 AcpiDmCompareAmlResources (
171 UINT8 *Aml1Buffer,
172 ACPI_RSDESC_SIZE Aml1BufferLength,
173 UINT8 *Aml2Buffer,
174 ACPI_RSDESC_SIZE Aml2BufferLength);
176 static ACPI_STATUS
177 AcpiDmTestResourceConversion (
178 ACPI_NAMESPACE_NODE *Node,
179 char *Name);
183 * Arguments for the Objects command
184 * These object types map directly to the ACPI_TYPES
186 static ARGUMENT_INFO AcpiDbObjectTypes [] =
188 {"ANY"},
189 {"INTEGERS"},
190 {"STRINGS"},
191 {"BUFFERS"},
192 {"PACKAGES"},
193 {"FIELDS"},
194 {"DEVICES"},
195 {"EVENTS"},
196 {"METHODS"},
197 {"MUTEXES"},
198 {"REGIONS"},
199 {"POWERRESOURCES"},
200 {"PROCESSORS"},
201 {"THERMALZONES"},
202 {"BUFFERFIELDS"},
203 {"DDBHANDLES"},
204 {"DEBUG"},
205 {"REGIONFIELDS"},
206 {"BANKFIELDS"},
207 {"INDEXFIELDS"},
208 {"REFERENCES"},
209 {"ALIAS"},
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
223 * alpha strings.
225 ******************************************************************************/
227 static ACPI_NAMESPACE_NODE *
228 AcpiDbConvertToNode (
229 char *InString)
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",
242 Node);
243 return (NULL);
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));
252 return (NULL);
255 else
257 /* Alpha argument */
258 /* The parameter is a name string that must be resolved to a
259 * Named obj
261 Node = AcpiDbLocalNsLookup (InString);
262 if (!Node)
264 Node = AcpiGbl_RootNode;
268 return (Node);
272 /*******************************************************************************
274 * FUNCTION: AcpiDbSleep
276 * PARAMETERS: ObjectArg - Desired sleep state (0-5)
278 * RETURN: Status
280 * DESCRIPTION: Simulate a sleep/wake sequence
282 ******************************************************************************/
284 ACPI_STATUS
285 AcpiDbSleep (
286 char *ObjectArg)
288 #if ACPI_MACHINE_WIDTH == 16
289 return (AE_OK);
290 #else
291 ACPI_STATUS Status;
292 UINT8 SleepState;
295 SleepState = (UINT8) ACPI_STRTOUL (ObjectArg, NULL, 0);
297 AcpiOsPrintf ("**** Prepare to sleep ****\n");
298 Status = AcpiEnterSleepStatePrep (SleepState);
299 if (ACPI_FAILURE (Status))
301 return (Status);
304 AcpiOsPrintf ("**** Going to sleep ****\n");
305 Status = AcpiEnterSleepState (SleepState);
306 if (ACPI_FAILURE (Status))
308 return (Status);
311 AcpiOsPrintf ("**** returning from sleep ****\n");
312 Status = AcpiLeaveSleepState (SleepState);
314 return (Status);
315 #endif
319 /*******************************************************************************
321 * FUNCTION: AcpiDbWalkForReferences
323 * PARAMETERS: Callback from WalkNamespace
325 * RETURN: Status
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 ******************************************************************************/
334 static ACPI_STATUS
335 AcpiDbWalkForReferences (
336 ACPI_HANDLE ObjHandle,
337 UINT32 NestingLevel,
338 void *Context,
339 void **ReturnValue)
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));
361 return (AE_OK);
365 /*******************************************************************************
367 * FUNCTION: AcpiDbFindReferences
369 * PARAMETERS: ObjectArg - String with hex value of the object
371 * RETURN: None
373 * DESCRIPTION: Search namespace for all references to the input object
375 ******************************************************************************/
377 void
378 AcpiDbFindReferences (
379 char *ObjectArg)
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
399 * PARAMETERS: None
401 * RETURN: None
403 * DESCRIPTION: Display information about internal mutexes.
405 ******************************************************************************/
407 void
408 AcpiDbDisplayLocks (
409 void)
411 UINT32 i;
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
429 * RETURN: None
431 * DESCRIPTION: Display information about loaded tables. Current
432 * implementation displays all loaded tables.
434 ******************************************************************************/
436 void
437 AcpiDbDisplayTableInfo (
438 char *TableArg)
440 ACPI_NATIVE_UINT i;
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);
461 AcpiOsPrintf ("\n");
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)
474 * RETURN: Nonde
476 * DESCRIPTION: Unload an ACPI table.
477 * Instance is not implemented
479 ******************************************************************************/
481 void
482 AcpiDbUnloadAcpiTable (
483 char *TableArg,
484 char *InstanceArg)
486 /* TBD: Need to reimplement for new data structures */
488 #if 0
489 UINT32 i;
490 ACPI_STATUS Status;
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);
507 else
509 AcpiOsPrintf ("%s, while unloading [%s]\n",
510 AcpiFormatException (Status), TableArg);
513 return;
517 AcpiOsPrintf ("Unknown table type [%s]\n", TableArg);
518 #endif
522 /*******************************************************************************
524 * FUNCTION: AcpiDbSetMethodBreakpoint
526 * PARAMETERS: Location - AML offset of breakpoint
527 * WalkState - Current walk info
528 * Op - Current Op (from parse walk)
530 * RETURN: None
532 * DESCRIPTION: Set a breakpoint in a control method at the specified
533 * AML offset
535 ******************************************************************************/
537 void
538 AcpiDbSetMethodBreakpoint (
539 char *Location,
540 ACPI_WALK_STATE *WalkState,
541 ACPI_PARSE_OBJECT *Op)
543 UINT32 Address;
546 if (!Op)
548 AcpiOsPrintf ("There is no method currently executing\n");
549 return;
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)
574 * RETURN: None
576 * DESCRIPTION: Set a breakpoint in a control method at the specified
577 * AML offset
579 ******************************************************************************/
581 void
582 AcpiDbSetMethodCallBreakpoint (
583 ACPI_PARSE_OBJECT *Op)
587 if (!Op)
589 AcpiOsPrintf ("There is no method currently executing\n");
590 return;
593 AcpiGbl_StepToNextCall = TRUE;
597 /*******************************************************************************
599 * FUNCTION: AcpiDbDisassembleAml
601 * PARAMETERS: Statements - Number of statements to disassemble
602 * Op - Current Op (from parse walk)
604 * RETURN: None
606 * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
607 * of statements specified.
609 ******************************************************************************/
611 void
612 AcpiDbDisassembleAml (
613 char *Statements,
614 ACPI_PARSE_OBJECT *Op)
616 UINT32 NumStatements = 8;
619 if (!Op)
621 AcpiOsPrintf ("There is no method currently executing\n");
622 return;
625 if (Statements)
627 NumStatements = ACPI_STRTOUL (Statements, NULL, 0);
630 AcpiDmDisassemble (NULL, Op, NumStatements);
634 /*******************************************************************************
636 * FUNCTION: AcpiDbDisassembleMethod
638 * PARAMETERS: Name - Name of control method
640 * RETURN: None
642 * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
643 * of statements specified.
645 ******************************************************************************/
647 ACPI_STATUS
648 AcpiDbDisassembleMethod (
649 char *Name)
651 ACPI_STATUS Status;
652 ACPI_PARSE_OBJECT *Op;
653 ACPI_WALK_STATE *WalkState;
654 ACPI_OPERAND_OBJECT *ObjDesc;
655 ACPI_NAMESPACE_NODE *Method;
658 Method = AcpiDbConvertToNode (Name);
659 if (!Method)
661 return (AE_BAD_PARAMETER);
664 ObjDesc = Method->Object;
666 Op = AcpiPsCreateScopeOp ();
667 if (!Op)
669 return (AE_NO_MEMORY);
672 /* Create and initialize a new walk state */
674 WalkState = AcpiDsCreateWalkState (0, Op, NULL, NULL);
675 if (!WalkState)
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))
685 return (Status);
688 /* Parse the AML */
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);
696 return (AE_OK);
700 /*******************************************************************************
702 * FUNCTION: AcpiDbDumpNamespace
704 * PARAMETERS: StartArg - Node to begin namespace dump
705 * DepthArg - Maximum tree depth to be dumped
707 * RETURN: None
709 * DESCRIPTION: Dump entire namespace or a subtree. Each node is displayed
710 * with type and other information.
712 ******************************************************************************/
714 void
715 AcpiDbDumpNamespace (
716 char *StartArg,
717 char *DepthArg)
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 */
725 if (StartArg)
727 SubtreeEntry = AcpiDbConvertToNode (StartArg);
728 if (!SubtreeEntry)
730 return;
733 /* Now we can check for the depth argument */
735 if (DepthArg)
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
761 * RETURN: None
763 * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId.
765 ******************************************************************************/
767 void
768 AcpiDbDumpNamespaceByOwner (
769 char *OwnerArg,
770 char *DepthArg)
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 */
781 if (DepthArg)
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,
793 SubtreeEntry);
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.
805 * RETURN: None
807 * DESCRIPTION: Send an ACPI notification. The value specified is sent to the
808 * named object as an ACPI notify.
810 ******************************************************************************/
812 void
813 AcpiDbSendNotify (
814 char *Name,
815 UINT32 Value)
817 ACPI_NAMESPACE_NODE *Node;
818 ACPI_STATUS Status;
821 /* Translate name to an Named object */
823 Node = AcpiDbConvertToNode (Name);
824 if (!Node)
826 return;
829 /* Decode Named object type */
831 switch (Node->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");
843 break;
845 default:
846 AcpiOsPrintf ("Named object is not a device or a thermal object\n");
847 break;
852 /*******************************************************************************
854 * FUNCTION: AcpiDbSetMethodData
856 * PARAMETERS: TypeArg - L for local, A for argument
857 * IndexArg - which one
858 * ValueArg - Value to set.
860 * RETURN: None
862 * DESCRIPTION: Set a local or argument for the running control method.
863 * NOTE: only object supported is Number.
865 ******************************************************************************/
867 void
868 AcpiDbSetMethodData (
869 char *TypeArg,
870 char *IndexArg,
871 char *ValueArg)
873 char Type;
874 UINT32 Index;
875 UINT32 Value;
876 ACPI_WALK_STATE *WalkState;
877 ACPI_OPERAND_OBJECT *ObjDesc;
878 ACPI_STATUS Status;
879 ACPI_NAMESPACE_NODE *Node;
882 /* Validate TypeArg */
884 AcpiUtStrupr (TypeArg);
885 Type = TypeArg[0];
886 if ((Type != 'L') &&
887 (Type != 'A') &&
888 (Type != 'N'))
890 AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg);
891 return;
894 Value = ACPI_STRTOUL (ValueArg, NULL, 16);
896 if (Type == 'N')
898 Node = AcpiDbConvertToNode (IndexArg);
899 if (Node->Type != ACPI_TYPE_INTEGER)
901 AcpiOsPrintf ("Can only set Integer nodes\n");
902 return;
904 ObjDesc = Node->Object;
905 ObjDesc->Integer.Value = Value;
906 return;
909 /* Get the index and value */
911 Index = ACPI_STRTOUL (IndexArg, NULL, 16);
913 WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
914 if (!WalkState)
916 AcpiOsPrintf ("There is no method currently executing\n");
917 return;
920 /* Create and initialize the new object */
922 ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
923 if (!ObjDesc)
925 AcpiOsPrintf ("Could not create an internal object\n");
926 return;
929 ObjDesc->Integer.Value = Value;
931 /* Store the new object into the target */
933 switch (Type)
935 case 'A':
937 /* Set a method argument */
939 if (Index > ACPI_METHOD_MAX_ARG)
941 AcpiOsPrintf ("Arg%d - Invalid argument name\n", Index);
942 goto Cleanup;
945 Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Index, ObjDesc,
946 WalkState);
947 if (ACPI_FAILURE (Status))
949 goto Cleanup;
952 ObjDesc = WalkState->Arguments[Index].Object;
954 AcpiOsPrintf ("Arg%d: ", Index);
955 AcpiDmDisplayInternalObject (ObjDesc, WalkState);
956 break;
958 case 'L':
960 /* Set a method local */
962 if (Index > ACPI_METHOD_MAX_LOCAL)
964 AcpiOsPrintf ("Local%d - Invalid local variable name\n", Index);
965 goto Cleanup;
968 Status = AcpiDsStoreObjectToLocal (AML_LOCAL_OP, Index, ObjDesc,
969 WalkState);
970 if (ACPI_FAILURE (Status))
972 goto Cleanup;
975 ObjDesc = WalkState->LocalVariables[Index].Object;
977 AcpiOsPrintf ("Local%d: ", Index);
978 AcpiDmDisplayInternalObject (ObjDesc, WalkState);
979 break;
981 default:
982 break;
985 Cleanup:
986 AcpiUtRemoveReference (ObjDesc);
990 /*******************************************************************************
992 * FUNCTION: AcpiDbWalkForSpecificObjects
994 * PARAMETERS: Callback from WalkNamespace
996 * RETURN: Status
998 * DESCRIPTION: Display short info about objects in the namespace
1000 ******************************************************************************/
1002 static ACPI_STATUS
1003 AcpiDbWalkForSpecificObjects (
1004 ACPI_HANDLE ObjHandle,
1005 UINT32 NestingLevel,
1006 void *Context,
1007 void **ReturnValue)
1009 ACPI_WALK_INFO *Info = (ACPI_WALK_INFO *) Context;
1010 ACPI_BUFFER Buffer;
1011 ACPI_STATUS Status;
1014 Info->Count++;
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);
1023 return (AE_OK);
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);
1032 return (AE_OK);
1036 /*******************************************************************************
1038 * FUNCTION: AcpiDbDisplayObjects
1040 * PARAMETERS: ObjTypeArg - Type of object to display
1041 * DisplayCountArg - Max depth to display
1043 * RETURN: None
1045 * DESCRIPTION: Display objects in the namespace of the requested type
1047 ******************************************************************************/
1049 ACPI_STATUS
1050 AcpiDbDisplayObjects (
1051 char *ObjTypeArg,
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");
1064 return (AE_OK);
1067 AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
1068 AcpiOsPrintf (
1069 "Objects of type [%s] defined in the current ACPI Namespace:\n",
1070 AcpiUtGetTypeName (Type));
1072 AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
1074 Info.Count = 0;
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);
1084 AcpiOsPrintf (
1085 "\nFound %u objects of type [%s] in the current ACPI Namespace\n",
1086 Info.Count, AcpiUtGetTypeName (Type));
1088 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1089 return (AE_OK);
1093 /*******************************************************************************
1095 * FUNCTION: AcpiDbWalkAndMatchName
1097 * PARAMETERS: Callback from WalkNamespace
1099 * RETURN: Status
1101 * DESCRIPTION: Find a particular name/names within the namespace. Wildcards
1102 * are supported -- '?' matches any character.
1104 ******************************************************************************/
1106 static ACPI_STATUS
1107 AcpiDbWalkAndMatchName (
1108 ACPI_HANDLE ObjHandle,
1109 UINT32 NestingLevel,
1110 void *Context,
1111 void **ReturnValue)
1113 ACPI_STATUS Status;
1114 char *RequestedName = (char *) Context;
1115 UINT32 i;
1116 ACPI_BUFFER Buffer;
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 */
1131 return (AE_OK);
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);
1143 else
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);
1154 return (AE_OK);
1158 /*******************************************************************************
1160 * FUNCTION: AcpiDbFindNameInNamespace
1162 * PARAMETERS: NameArg - The 4-character ACPI name to find.
1163 * wildcards are supported.
1165 * RETURN: None
1167 * DESCRIPTION: Search the namespace for a given name (with wildcards)
1169 ******************************************************************************/
1171 ACPI_STATUS
1172 AcpiDbFindNameInNamespace (
1173 char *NameArg)
1176 if (ACPI_STRLEN (NameArg) > 4)
1178 AcpiOsPrintf ("Name must be no longer than 4 characters\n");
1179 return (AE_OK);
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);
1189 return (AE_OK);
1193 /*******************************************************************************
1195 * FUNCTION: AcpiDbSetScope
1197 * PARAMETERS: Name - New scope path
1199 * RETURN: Status
1201 * DESCRIPTION: Set the "current scope" as maintained by this utility.
1202 * The scope is used as a prefix to ACPI paths.
1204 ******************************************************************************/
1206 void
1207 AcpiDbSetScope (
1208 char *Name)
1210 ACPI_STATUS Status;
1211 ACPI_NAMESPACE_NODE *Node;
1214 if (!Name || Name[0] == 0)
1216 AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf);
1217 return;
1220 AcpiDbPrepNamestring (Name);
1222 if (Name[0] == '\\')
1224 /* Validate new scope from the root */
1226 Status = AcpiNsGetNode (AcpiGbl_RootNode, Name, ACPI_NS_NO_UPSEARCH,
1227 &Node);
1228 if (ACPI_FAILURE (Status))
1230 goto ErrorExit;
1233 ACPI_STRCPY (AcpiGbl_DbScopeBuf, Name);
1234 ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
1236 else
1238 /* Validate new scope relative to old scope */
1240 Status = AcpiNsGetNode (AcpiGbl_DbScopeNode, Name, ACPI_NS_NO_UPSEARCH,
1241 &Node);
1242 if (ACPI_FAILURE (Status))
1244 goto ErrorExit;
1247 ACPI_STRCAT (AcpiGbl_DbScopeBuf, Name);
1248 ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
1251 AcpiGbl_DbScopeNode = Node;
1252 AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf);
1253 return;
1255 ErrorExit:
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
1271 * RETURN: None
1273 * DESCRIPTION: Compare two AML resource lists, descriptor by descriptor (in
1274 * order to isolate a miscompare to an individual resource)
1276 ******************************************************************************/
1278 static void
1279 AcpiDmCompareAmlResources (
1280 UINT8 *Aml1Buffer,
1281 ACPI_RSDESC_SIZE Aml1BufferLength,
1282 UINT8 *Aml2Buffer,
1283 ACPI_RSDESC_SIZE Aml2BufferLength)
1285 UINT8 *Aml1;
1286 UINT8 *Aml2;
1287 ACPI_RSDESC_SIZE Aml1Length;
1288 ACPI_RSDESC_SIZE Aml2Length;
1289 ACPI_RSDESC_SIZE Offset = 0;
1290 UINT8 ResourceType;
1291 UINT32 Count = 0;
1294 /* Compare overall buffer sizes (may be different due to size rounding) */
1296 if (Aml1BufferLength != Aml2BufferLength)
1298 AcpiOsPrintf (
1299 "**** Buffer length mismatch in converted AML: original %X new %X ****\n",
1300 Aml1BufferLength, Aml2BufferLength);
1303 Aml1 = Aml1Buffer;
1304 Aml2 = Aml2Buffer;
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)
1320 AcpiOsPrintf (
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))
1329 AcpiOsPrintf (
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)
1338 return;
1341 /* Point to next descriptor in each buffer */
1343 Count++;
1344 Offset += Aml1Length;
1345 Aml1 += Aml1Length;
1346 Aml2 += Aml2Length;
1351 /*******************************************************************************
1353 * FUNCTION: AcpiDmTestResourceConversion
1355 * PARAMETERS: Node - Parent device node
1356 * Name - resource method name (_CRS)
1358 * RETURN: Status
1360 * DESCRIPTION: Compare the original AML with a conversion of the AML to
1361 * internal resource list, then back to AML.
1363 ******************************************************************************/
1365 static ACPI_STATUS
1366 AcpiDmTestResourceConversion (
1367 ACPI_NAMESPACE_NODE *Node,
1368 char *Name)
1370 ACPI_STATUS Status;
1371 ACPI_BUFFER ReturnObj;
1372 ACPI_BUFFER ResourceObj;
1373 ACPI_BUFFER NewAml;
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));
1390 return (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));
1400 goto Exit1;
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));
1410 goto Exit2;
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);
1424 Exit2:
1425 ACPI_FREE (ResourceObj.Pointer);
1426 Exit1:
1427 ACPI_FREE (ReturnObj.Pointer);
1428 return (Status);
1432 /*******************************************************************************
1434 * FUNCTION: AcpiDbDisplayResources
1436 * PARAMETERS: ObjectArg - String with hex value of the object
1438 * RETURN: None
1440 * DESCRIPTION: Display the resource objects associated with a device.
1442 ******************************************************************************/
1444 void
1445 AcpiDbDisplayResources (
1446 char *ObjectArg)
1448 #if ACPI_MACHINE_WIDTH != 16
1450 ACPI_NAMESPACE_NODE *Node;
1451 ACPI_STATUS Status;
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);
1461 if (!Node)
1463 return;
1466 /* Prepare for a return object of arbitrary size */
1468 ReturnObj.Pointer = AcpiGbl_DbBuffer;
1469 ReturnObj.Length = ACPI_DEBUG_BUFFER_SIZE;
1471 /* _PRT */
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));
1482 goto GetCrs;
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));
1493 goto GetCrs;
1496 AcpiRsDumpIrqList (ACPI_CAST_PTR (UINT8, AcpiGbl_DbBuffer));
1499 /* _CRS */
1501 GetCrs:
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));
1514 goto GetPrs;
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));
1527 goto GetPrs;
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));
1548 goto GetPrs;
1552 /* _PRS */
1554 GetPrs:
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));
1567 goto Cleanup;
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));
1578 goto Cleanup;
1581 AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer));
1583 Cleanup:
1585 AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1586 return;
1587 #endif
1591 /*******************************************************************************
1593 * FUNCTION: AcpiDbIntegrityWalk
1595 * PARAMETERS: Callback from WalkNamespace
1597 * RETURN: Status
1599 * DESCRIPTION: Examine one NS node for valid values.
1601 ******************************************************************************/
1603 static ACPI_STATUS
1604 AcpiDbIntegrityWalk (
1605 ACPI_HANDLE ObjHandle,
1606 UINT32 NestingLevel,
1607 void *Context,
1608 void **ReturnValue)
1610 ACPI_INTEGRITY_INFO *Info = (ACPI_INTEGRITY_INFO *) Context;
1611 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
1612 ACPI_OPERAND_OBJECT *Object;
1615 Info->Nodes++;
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",
1625 Node, Node->Type);
1628 if (!AcpiUtValidAcpiName (Node->Name.Integer))
1630 AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node);
1633 Object = AcpiNsGetAttachedObject (Node);
1634 if (Object)
1636 Info->Objects++;
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));
1644 return (AE_OK);
1648 /*******************************************************************************
1650 * FUNCTION: AcpiDbCheckIntegrity
1652 * PARAMETERS: None
1654 * RETURN: None
1656 * DESCRIPTION: Check entire namespace for data structure integrity
1658 ******************************************************************************/
1660 void
1661 AcpiDbCheckIntegrity (
1662 void)
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
1684 * RETURN: None
1686 * DESCRIPTION: Generate a GPE
1688 ******************************************************************************/
1690 void
1691 AcpiDbGenerateGpe (
1692 char *GpeArg,
1693 char *BlockArg)
1695 UINT32 BlockNumber;
1696 UINT32 GpeNumber;
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),
1705 GpeNumber);
1706 if (!GpeEventInfo)
1708 AcpiOsPrintf ("Invalid GPE\n");
1709 return;
1712 (void) AcpiEvGpeDispatch (GpeEventInfo, GpeNumber);
1716 /*******************************************************************************
1718 * FUNCTION: AcpiDbBusWalk
1720 * PARAMETERS: Callback from WalkNamespace
1722 * RETURN: Status
1724 * DESCRIPTION: Display info about device objects that have a corresponding
1725 * _PRT method.
1727 ******************************************************************************/
1729 static ACPI_STATUS
1730 AcpiDbBusWalk (
1731 ACPI_HANDLE ObjHandle,
1732 UINT32 NestingLevel,
1733 void *Context,
1734 void **ReturnValue)
1736 ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
1737 ACPI_STATUS Status;
1738 ACPI_BUFFER Buffer;
1739 ACPI_INTEGER ADR;
1740 ACPI_DEVICE_ID Id;
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))
1751 return (AE_OK);
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);
1761 return (AE_OK);
1764 /* Display the full path */
1766 AcpiOsPrintf ("%-32s", (char *) Buffer.Pointer);
1767 ACPI_FREE (Buffer.Pointer);
1769 /* _PRT info */
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 ");
1780 else
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);
1792 else
1794 AcpiOsPrintf (" ");
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);
1811 ACPI_FREE (Cid);
1814 AcpiOsPrintf ("\n");
1815 return (AE_OK);
1819 /*******************************************************************************
1821 * FUNCTION: AcpiDbGetBusInfo
1823 * PARAMETERS: None
1825 * RETURN: None
1827 * DESCRIPTION: Display info about system busses.
1829 ******************************************************************************/
1831 void
1832 AcpiDbGetBusInfo (
1833 void)
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 */