xref: /onnv-gate/usr/src/uts/intel/io/acpica/debugger/dbcmds.c (revision 3446:5903aece022d)
1 /*******************************************************************************
2  *
3  * Module Name: dbcmds - debug commands and output routines
4  *              $Revision: 1.145 $
5  *
6  ******************************************************************************/
7 
8 /******************************************************************************
9  *
10  * 1. Copyright Notice
11  *
12  * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp.
13  * All rights reserved.
14  *
15  * 2. License
16  *
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.
21  *
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
28  *
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;
37  *
38  * The above copyright and patent license is granted only if the following
39  * conditions are met:
40  *
41  * 3. Conditions
42  *
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.
54  *
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.
66  *
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.
72  *
73  * 3.4. Intel retains all right, title, and interest in and to the Original
74  * Intel Code.
75  *
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.
80  *
81  * 4. Disclaimer and Export Compliance
82  *
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.
90  *
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.
99  *
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.
114  *
115  *****************************************************************************/
116 
117 
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"
126 
127 
128 #include "acparser.h"
129 
130 #ifdef ACPI_DEBUGGER
131 
132 #define _COMPONENT          ACPI_CA_DEBUGGER
133         ACPI_MODULE_NAME    ("dbcmds")
134 
135 /* Local prototypes */
136 
137 static ACPI_STATUS
138 AcpiDbIntegrityWalk (
139     ACPI_HANDLE             ObjHandle,
140     UINT32                  NestingLevel,
141     void                    *Context,
142     void                    **ReturnValue);
143 
144 static ACPI_STATUS
145 AcpiDbWalkAndMatchName (
146     ACPI_HANDLE             ObjHandle,
147     UINT32                  NestingLevel,
148     void                    *Context,
149     void                    **ReturnValue);
150 
151 static ACPI_STATUS
152 AcpiDbWalkForReferences (
153     ACPI_HANDLE             ObjHandle,
154     UINT32                  NestingLevel,
155     void                    *Context,
156     void                    **ReturnValue);
157 
158 static ACPI_STATUS
159 AcpiDbWalkForSpecificObjects (
160     ACPI_HANDLE             ObjHandle,
161     UINT32                  NestingLevel,
162     void                    *Context,
163     void                    **ReturnValue);
164 
165 static ACPI_NAMESPACE_NODE *
166 AcpiDbConvertToNode (
167     char                    *InString);
168 
169 static void
170 AcpiDmCompareAmlResources (
171     UINT8                   *Aml1Buffer,
172     ACPI_RSDESC_SIZE        Aml1BufferLength,
173     UINT8                   *Aml2Buffer,
174     ACPI_RSDESC_SIZE        Aml2BufferLength);
175 
176 static ACPI_STATUS
177 AcpiDmTestResourceConversion (
178     ACPI_NAMESPACE_NODE     *Node,
179     char                    *Name);
180 
181 
182 /*
183  * Arguments for the Objects command
184  * These object types map directly to the ACPI_TYPES
185  */
186 static ARGUMENT_INFO        AcpiDbObjectTypes [] =
187 {
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 */
211 };
212 
213 
214 /*******************************************************************************
215  *
216  * FUNCTION:    AcpiDbConvertToNode
217  *
218  * PARAMETERS:  InString        - String to convert
219  *
220  * RETURN:      Pointer to a NS node
221  *
222  * DESCRIPTION: Convert a string to a valid NS pointer.  Handles numeric or
223  *              alpha strings.
224  *
225  ******************************************************************************/
226 
227 static ACPI_NAMESPACE_NODE *
228 AcpiDbConvertToNode (
229     char                    *InString)
230 {
231     ACPI_NAMESPACE_NODE     *Node;
232 
233 
234     if ((*InString >= 0x30) && (*InString <= 0x39))
235     {
236         /* Numeric argument, convert */
237 
238         Node = ACPI_TO_POINTER (ACPI_STRTOUL (InString, NULL, 16));
239         if (!AcpiOsReadable (Node, sizeof (ACPI_NAMESPACE_NODE)))
240         {
241             AcpiOsPrintf ("Address %p is invalid in this address space\n",
242                 Node);
243             return (NULL);
244         }
245 
246         /* Make sure pointer is valid NS node */
247 
248         if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
249         {
250             AcpiOsPrintf ("Address %p is not a valid NS node [%s]\n",
251                     Node, AcpiUtGetDescriptorName (Node));
252             return (NULL);
253         }
254     }
255     else
256     {
257         /* Alpha argument */
258         /* The parameter is a name string that must be resolved to a
259          * Named obj
260          */
261         Node = AcpiDbLocalNsLookup (InString);
262         if (!Node)
263         {
264             Node = AcpiGbl_RootNode;
265         }
266     }
267 
268     return (Node);
269 }
270 
271 
272 /*******************************************************************************
273  *
274  * FUNCTION:    AcpiDbSleep
275  *
276  * PARAMETERS:  ObjectArg       - Desired sleep state (0-5)
277  *
278  * RETURN:      Status
279  *
280  * DESCRIPTION: Simulate a sleep/wake sequence
281  *
282  ******************************************************************************/
283 
284 ACPI_STATUS
285 AcpiDbSleep (
286     char                    *ObjectArg)
287 {
288 #if ACPI_MACHINE_WIDTH == 16
289     return (AE_OK);
290 #else
291     ACPI_STATUS             Status;
292     UINT8                   SleepState;
293 
294 
295     SleepState = (UINT8) ACPI_STRTOUL (ObjectArg, NULL, 0);
296 
297     AcpiOsPrintf ("**** Prepare to sleep ****\n");
298     Status = AcpiEnterSleepStatePrep (SleepState);
299     if (ACPI_FAILURE (Status))
300     {
301         return (Status);
302     }
303 
304     AcpiOsPrintf ("**** Going to sleep ****\n");
305     Status = AcpiEnterSleepState (SleepState);
306     if (ACPI_FAILURE (Status))
307     {
308         return (Status);
309     }
310 
311     AcpiOsPrintf ("**** returning from sleep ****\n");
312     Status = AcpiLeaveSleepState (SleepState);
313 
314     return (Status);
315 #endif
316 }
317 
318 
319 /*******************************************************************************
320  *
321  * FUNCTION:    AcpiDbWalkForReferences
322  *
323  * PARAMETERS:  Callback from WalkNamespace
324  *
325  * RETURN:      Status
326  *
327  * DESCRIPTION: Check if this namespace object refers to the target object
328  *              that is passed in as the context value.
329  *
330  * Note: Currently doesn't check subobjects within the Node's object
331  *
332  ******************************************************************************/
333 
334 static ACPI_STATUS
335 AcpiDbWalkForReferences (
336     ACPI_HANDLE             ObjHandle,
337     UINT32                  NestingLevel,
338     void                    *Context,
339     void                    **ReturnValue)
340 {
341     ACPI_OPERAND_OBJECT     *ObjDesc = (ACPI_OPERAND_OBJECT  *) Context;
342     ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
343 
344 
345     /* Check for match against the namespace node itself */
346 
347     if (Node == (void *) ObjDesc)
348     {
349         AcpiOsPrintf ("Object is a Node [%4.4s]\n",
350             AcpiUtGetNodeName (Node));
351     }
352 
353     /* Check for match against the object attached to the node */
354 
355     if (AcpiNsGetAttachedObject (Node) == ObjDesc)
356     {
357         AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n",
358             Node, AcpiUtGetNodeName (Node));
359     }
360 
361     return (AE_OK);
362 }
363 
364 
365 /*******************************************************************************
366  *
367  * FUNCTION:    AcpiDbFindReferences
368  *
369  * PARAMETERS:  ObjectArg       - String with hex value of the object
370  *
371  * RETURN:      None
372  *
373  * DESCRIPTION: Search namespace for all references to the input object
374  *
375  ******************************************************************************/
376 
377 void
378 AcpiDbFindReferences (
379     char                    *ObjectArg)
380 {
381     ACPI_OPERAND_OBJECT     *ObjDesc;
382 
383 
384     /* Convert string to object pointer */
385 
386     ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16));
387 
388     /* Search all nodes in namespace */
389 
390     (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
391                     AcpiDbWalkForReferences, (void *) ObjDesc, NULL);
392 }
393 
394 
395 /*******************************************************************************
396  *
397  * FUNCTION:    AcpiDbDisplayLocks
398  *
399  * PARAMETERS:  None
400  *
401  * RETURN:      None
402  *
403  * DESCRIPTION: Display information about internal mutexes.
404  *
405  ******************************************************************************/
406 
407 void
408 AcpiDbDisplayLocks (
409     void)
410 {
411     UINT32                  i;
412 
413 
414     for (i = 0; i < ACPI_MAX_MUTEX; i++)
415     {
416         AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i),
417             AcpiGbl_MutexInfo[i].ThreadId == ACPI_MUTEX_NOT_ACQUIRED
418                 ? "Locked" : "Unlocked");
419     }
420 }
421 
422 
423 /*******************************************************************************
424  *
425  * FUNCTION:    AcpiDbDisplayTableInfo
426  *
427  * PARAMETERS:  TableArg        - String with name of table to be displayed
428  *
429  * RETURN:      None
430  *
431  * DESCRIPTION: Display information about loaded tables.  Current
432  *              implementation displays all loaded tables.
433  *
434  ******************************************************************************/
435 
436 void
437 AcpiDbDisplayTableInfo (
438     char                    *TableArg)
439 {
440     UINT32                  i;
441     ACPI_TABLE_DESC         *TableDesc;
442 
443 
444     for (i = 0; i < (ACPI_TABLE_ID_MAX+1); i++)
445     {
446         TableDesc = AcpiGbl_TableLists[i].Next;
447         while (TableDesc)
448         {
449             AcpiOsPrintf ( "%s at %p length %.5X",
450                     AcpiGbl_TableData[i].Name, TableDesc->Pointer,
451                     (UINT32) TableDesc->Length);
452 
453             if (i != ACPI_TABLE_ID_FACS)
454             {
455                 AcpiOsPrintf (" OemID=%6s TableId=%8s OemRevision=%8.8X",
456                         TableDesc->Pointer->OemId,
457                         TableDesc->Pointer->OemTableId,
458                         TableDesc->Pointer->OemRevision);
459             }
460             AcpiOsPrintf ("\n");
461 
462             TableDesc = TableDesc->Next;
463         }
464     }
465 }
466 
467 
468 /*******************************************************************************
469  *
470  * FUNCTION:    AcpiDbUnloadAcpiTable
471  *
472  * PARAMETERS:  TableArg        - Name of the table to be unloaded
473  *              InstanceArg     - Which instance of the table to unload (if
474  *                                there are multiple tables of the same type)
475  *
476  * RETURN:      Nonde
477  *
478  * DESCRIPTION: Unload an ACPI table.
479  *              Instance is not implemented
480  *
481  ******************************************************************************/
482 
483 void
484 AcpiDbUnloadAcpiTable (
485     char                    *TableArg,
486     char                    *InstanceArg)
487 {
488     UINT32                  i;
489     ACPI_STATUS             Status;
490 
491 
492     /* Search all tables for the target type */
493 
494     for (i = 0; i < (ACPI_TABLE_ID_MAX+1); i++)
495     {
496         if (!ACPI_STRNCMP (TableArg, AcpiGbl_TableData[i].Signature,
497                 AcpiGbl_TableData[i].SigLength))
498         {
499             /* Found the table, unload it */
500 
501             Status = AcpiUnloadTable (i);
502             if (ACPI_SUCCESS (Status))
503             {
504                 AcpiOsPrintf ("[%s] unloaded and uninstalled\n", TableArg);
505             }
506             else
507             {
508                 AcpiOsPrintf ("%s, while unloading [%s]\n",
509                     AcpiFormatException (Status), TableArg);
510             }
511 
512             return;
513         }
514     }
515 
516     AcpiOsPrintf ("Unknown table type [%s]\n", TableArg);
517 }
518 
519 
520 /*******************************************************************************
521  *
522  * FUNCTION:    AcpiDbSetMethodBreakpoint
523  *
524  * PARAMETERS:  Location            - AML offset of breakpoint
525  *              WalkState           - Current walk info
526  *              Op                  - Current Op (from parse walk)
527  *
528  * RETURN:      None
529  *
530  * DESCRIPTION: Set a breakpoint in a control method at the specified
531  *              AML offset
532  *
533  ******************************************************************************/
534 
535 void
536 AcpiDbSetMethodBreakpoint (
537     char                    *Location,
538     ACPI_WALK_STATE         *WalkState,
539     ACPI_PARSE_OBJECT       *Op)
540 {
541     UINT32                  Address;
542 
543 
544     if (!Op)
545     {
546         AcpiOsPrintf ("There is no method currently executing\n");
547         return;
548     }
549 
550     /* Get and verify the breakpoint address */
551 
552     Address = ACPI_STRTOUL (Location, NULL, 16);
553     if (Address <= Op->Common.AmlOffset)
554     {
555         AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n",
556             Address, Op->Common.AmlOffset);
557     }
558 
559     /* Save breakpoint in current walk */
560 
561     WalkState->UserBreakpoint = Address;
562     AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address);
563 }
564 
565 
566 /*******************************************************************************
567  *
568  * FUNCTION:    AcpiDbSetMethodCallBreakpoint
569  *
570  * PARAMETERS:  Op                  - Current Op (from parse walk)
571  *
572  * RETURN:      None
573  *
574  * DESCRIPTION: Set a breakpoint in a control method at the specified
575  *              AML offset
576  *
577  ******************************************************************************/
578 
579 void
580 AcpiDbSetMethodCallBreakpoint (
581     ACPI_PARSE_OBJECT       *Op)
582 {
583 
584 
585     if (!Op)
586     {
587         AcpiOsPrintf ("There is no method currently executing\n");
588         return;
589     }
590 
591     AcpiGbl_StepToNextCall = TRUE;
592 }
593 
594 
595 /*******************************************************************************
596  *
597  * FUNCTION:    AcpiDbDisassembleAml
598  *
599  * PARAMETERS:  Statements          - Number of statements to disassemble
600  *              Op                  - Current Op (from parse walk)
601  *
602  * RETURN:      None
603  *
604  * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
605  *              of statements specified.
606  *
607  ******************************************************************************/
608 
609 void
610 AcpiDbDisassembleAml (
611     char                    *Statements,
612     ACPI_PARSE_OBJECT       *Op)
613 {
614     UINT32                  NumStatements = 8;
615 
616 
617     if (!Op)
618     {
619         AcpiOsPrintf ("There is no method currently executing\n");
620         return;
621     }
622 
623     if (Statements)
624     {
625         NumStatements = ACPI_STRTOUL (Statements, NULL, 0);
626     }
627 
628     AcpiDmDisassemble (NULL, Op, NumStatements);
629 }
630 
631 
632 /*******************************************************************************
633  *
634  * FUNCTION:    AcpiDbDisassembleMethod
635  *
636  * PARAMETERS:  Name            - Name of control method
637  *
638  * RETURN:      None
639  *
640  * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
641  *              of statements specified.
642  *
643  ******************************************************************************/
644 
645 ACPI_STATUS
646 AcpiDbDisassembleMethod (
647     char                    *Name)
648 {
649     ACPI_STATUS             Status;
650     ACPI_PARSE_OBJECT       *Op;
651     ACPI_WALK_STATE         *WalkState;
652     ACPI_OPERAND_OBJECT     *ObjDesc;
653     ACPI_NAMESPACE_NODE     *Method;
654 
655 
656     Method = AcpiDbConvertToNode (Name);
657     if (!Method)
658     {
659         return (AE_BAD_PARAMETER);
660     }
661 
662     ObjDesc = Method->Object;
663 
664     Op = AcpiPsCreateScopeOp ();
665     if (!Op)
666     {
667         return (AE_NO_MEMORY);
668     }
669 
670     /* Create and initialize a new walk state */
671 
672     WalkState = AcpiDsCreateWalkState (0, Op, NULL, NULL);
673     if (!WalkState)
674     {
675         return (AE_NO_MEMORY);
676     }
677 
678     Status = AcpiDsInitAmlWalk (WalkState, Op, NULL,
679                     ObjDesc->Method.AmlStart,
680                     ObjDesc->Method.AmlLength, NULL, 1);
681     if (ACPI_FAILURE (Status))
682     {
683         return (Status);
684     }
685 
686     /* Parse the AML */
687 
688     WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE;
689     WalkState->ParseFlags |= ACPI_PARSE_DISASSEMBLE;
690     Status = AcpiPsParseAml (WalkState);
691 
692     AcpiDmDisassemble (NULL, Op, 0);
693     AcpiPsDeleteParseTree (Op);
694     return (AE_OK);
695 }
696 
697 
698 /*******************************************************************************
699  *
700  * FUNCTION:    AcpiDbDumpNamespace
701  *
702  * PARAMETERS:  StartArg        - Node to begin namespace dump
703  *              DepthArg        - Maximum tree depth to be dumped
704  *
705  * RETURN:      None
706  *
707  * DESCRIPTION: Dump entire namespace or a subtree.  Each node is displayed
708  *              with type and other information.
709  *
710  ******************************************************************************/
711 
712 void
713 AcpiDbDumpNamespace (
714     char                    *StartArg,
715     char                    *DepthArg)
716 {
717     ACPI_HANDLE             SubtreeEntry = AcpiGbl_RootNode;
718     UINT32                  MaxDepth = ACPI_UINT32_MAX;
719 
720 
721     /* No argument given, just start at the root and dump entire namespace */
722 
723     if (StartArg)
724     {
725         SubtreeEntry = AcpiDbConvertToNode (StartArg);
726         if (!SubtreeEntry)
727         {
728             return;
729         }
730 
731         /* Now we can check for the depth argument */
732 
733         if (DepthArg)
734         {
735             MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
736         }
737     }
738 
739     AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
740     AcpiOsPrintf ("ACPI Namespace (from %4.4s (%p) subtree):\n",
741         ((ACPI_NAMESPACE_NODE *) SubtreeEntry)->Name.Ascii, SubtreeEntry);
742 
743     /* Display the subtree */
744 
745     AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
746     AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth,
747         ACPI_OWNER_ID_MAX, SubtreeEntry);
748     AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
749 }
750 
751 
752 /*******************************************************************************
753  *
754  * FUNCTION:    AcpiDbDumpNamespaceByOwner
755  *
756  * PARAMETERS:  OwnerArg        - Owner ID whose nodes will be displayed
757  *              DepthArg        - Maximum tree depth to be dumped
758  *
759  * RETURN:      None
760  *
761  * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId.
762  *
763  ******************************************************************************/
764 
765 void
766 AcpiDbDumpNamespaceByOwner (
767     char                    *OwnerArg,
768     char                    *DepthArg)
769 {
770     ACPI_HANDLE             SubtreeEntry = AcpiGbl_RootNode;
771     UINT32                  MaxDepth = ACPI_UINT32_MAX;
772     ACPI_OWNER_ID           OwnerId;
773 
774 
775     OwnerId = (ACPI_OWNER_ID) ACPI_STRTOUL (OwnerArg, NULL, 0);
776 
777     /* Now we can check for the depth argument */
778 
779     if (DepthArg)
780     {
781         MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
782     }
783 
784     AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
785     AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId);
786 
787     /* Display the subtree */
788 
789     AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
790     AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId,
791         SubtreeEntry);
792     AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
793 }
794 
795 
796 /*******************************************************************************
797  *
798  * FUNCTION:    AcpiDbSendNotify
799  *
800  * PARAMETERS:  Name            - Name of ACPI object to send the notify to
801  *              Value           - Value of the notify to send.
802  *
803  * RETURN:      None
804  *
805  * DESCRIPTION: Send an ACPI notification.  The value specified is sent to the
806  *              named object as an ACPI notify.
807  *
808  ******************************************************************************/
809 
810 void
811 AcpiDbSendNotify (
812     char                    *Name,
813     UINT32                  Value)
814 {
815     ACPI_NAMESPACE_NODE     *Node;
816     ACPI_STATUS             Status;
817 
818 
819     /* Translate name to an Named object */
820 
821     Node = AcpiDbConvertToNode (Name);
822     if (!Node)
823     {
824         return;
825     }
826 
827     /* Decode Named object type */
828 
829     switch (Node->Type)
830     {
831     case ACPI_TYPE_DEVICE:
832     case ACPI_TYPE_THERMAL:
833 
834          /* Send the notify */
835 
836         Status = AcpiEvQueueNotifyRequest (Node, Value);
837         if (ACPI_FAILURE (Status))
838         {
839             AcpiOsPrintf ("Could not queue notify\n");
840         }
841         break;
842 
843     default:
844         AcpiOsPrintf ("Named object is not a device or a thermal object\n");
845         break;
846     }
847 }
848 
849 
850 /*******************************************************************************
851  *
852  * FUNCTION:    AcpiDbSetMethodData
853  *
854  * PARAMETERS:  TypeArg         - L for local, A for argument
855  *              IndexArg        - which one
856  *              ValueArg        - Value to set.
857  *
858  * RETURN:      None
859  *
860  * DESCRIPTION: Set a local or argument for the running control method.
861  *              NOTE: only object supported is Number.
862  *
863  ******************************************************************************/
864 
865 void
866 AcpiDbSetMethodData (
867     char                    *TypeArg,
868     char                    *IndexArg,
869     char                    *ValueArg)
870 {
871     char                    Type;
872     UINT32                  Index;
873     UINT32                  Value;
874     ACPI_WALK_STATE         *WalkState;
875     ACPI_OPERAND_OBJECT     *ObjDesc;
876     ACPI_STATUS             Status;
877     ACPI_NAMESPACE_NODE     *Node;
878 
879 
880     /* Validate TypeArg */
881 
882     AcpiUtStrupr (TypeArg);
883     Type = TypeArg[0];
884     if ((Type != 'L') &&
885         (Type != 'A') &&
886         (Type != 'N'))
887     {
888         AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg);
889         return;
890     }
891 
892     Value = ACPI_STRTOUL (ValueArg, NULL, 16);
893 
894     if (Type == 'N')
895     {
896         Node = AcpiDbConvertToNode (IndexArg);
897         if (Node->Type != ACPI_TYPE_INTEGER)
898         {
899             AcpiOsPrintf ("Can only set Integer nodes\n");
900             return;
901         }
902         ObjDesc = Node->Object;
903         ObjDesc->Integer.Value = Value;
904         return;
905     }
906 
907     /* Get the index and value */
908 
909     Index = ACPI_STRTOUL (IndexArg, NULL, 16);
910 
911     WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
912     if (!WalkState)
913     {
914         AcpiOsPrintf ("There is no method currently executing\n");
915         return;
916     }
917 
918     /* Create and initialize the new object */
919 
920     ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
921     if (!ObjDesc)
922     {
923         AcpiOsPrintf ("Could not create an internal object\n");
924         return;
925     }
926 
927     ObjDesc->Integer.Value = Value;
928 
929     /* Store the new object into the target */
930 
931     switch (Type)
932     {
933     case 'A':
934 
935         /* Set a method argument */
936 
937         if (Index > ACPI_METHOD_MAX_ARG)
938         {
939             AcpiOsPrintf ("Arg%d - Invalid argument name\n", Index);
940             goto Cleanup;
941         }
942 
943         Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Index, ObjDesc,
944                     WalkState);
945         if (ACPI_FAILURE (Status))
946         {
947             goto Cleanup;
948         }
949 
950         ObjDesc = WalkState->Arguments[Index].Object;
951 
952         AcpiOsPrintf ("Arg%d: ", Index);
953         AcpiDmDisplayInternalObject (ObjDesc, WalkState);
954         break;
955 
956     case 'L':
957 
958         /* Set a method local */
959 
960         if (Index > ACPI_METHOD_MAX_LOCAL)
961         {
962             AcpiOsPrintf ("Local%d - Invalid local variable name\n", Index);
963             goto Cleanup;
964         }
965 
966         Status = AcpiDsStoreObjectToLocal (AML_LOCAL_OP, Index, ObjDesc,
967                     WalkState);
968         if (ACPI_FAILURE (Status))
969         {
970             goto Cleanup;
971         }
972 
973         ObjDesc = WalkState->LocalVariables[Index].Object;
974 
975         AcpiOsPrintf ("Local%d: ", Index);
976         AcpiDmDisplayInternalObject (ObjDesc, WalkState);
977         break;
978 
979     default:
980         break;
981     }
982 
983 Cleanup:
984     AcpiUtRemoveReference (ObjDesc);
985 }
986 
987 
988 /*******************************************************************************
989  *
990  * FUNCTION:    AcpiDbWalkForSpecificObjects
991  *
992  * PARAMETERS:  Callback from WalkNamespace
993  *
994  * RETURN:      Status
995  *
996  * DESCRIPTION: Display short info about objects in the namespace
997  *
998  ******************************************************************************/
999 
1000 static ACPI_STATUS
1001 AcpiDbWalkForSpecificObjects (
1002     ACPI_HANDLE             ObjHandle,
1003     UINT32                  NestingLevel,
1004     void                    *Context,
1005     void                    **ReturnValue)
1006 {
1007     ACPI_WALK_INFO          *Info = (ACPI_WALK_INFO *) Context;
1008     ACPI_BUFFER             Buffer;
1009     ACPI_STATUS             Status;
1010 
1011 
1012     Info->Count++;
1013 
1014     /* Get and display the full pathname to this object */
1015 
1016     Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1017     Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
1018     if (ACPI_FAILURE (Status))
1019     {
1020         AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
1021         return (AE_OK);
1022     }
1023 
1024     AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);
1025     ACPI_FREE (Buffer.Pointer);
1026 
1027     /* Dump short info about the object */
1028 
1029     (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, Info, NULL);
1030     return (AE_OK);
1031 }
1032 
1033 
1034 /*******************************************************************************
1035  *
1036  * FUNCTION:    AcpiDbDisplayObjects
1037  *
1038  * PARAMETERS:  ObjTypeArg          - Type of object to display
1039  *              DisplayCountArg     - Max depth to display
1040  *
1041  * RETURN:      None
1042  *
1043  * DESCRIPTION: Display objects in the namespace of the requested type
1044  *
1045  ******************************************************************************/
1046 
1047 ACPI_STATUS
1048 AcpiDbDisplayObjects (
1049     char                    *ObjTypeArg,
1050     char                    *DisplayCountArg)
1051 {
1052     ACPI_WALK_INFO          Info;
1053     ACPI_OBJECT_TYPE        Type;
1054 
1055 
1056     /* Get the object type */
1057 
1058     Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes);
1059     if (Type == ACPI_TYPE_NOT_FOUND)
1060     {
1061         AcpiOsPrintf ("Invalid or unsupported argument\n");
1062         return (AE_OK);
1063     }
1064 
1065     AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
1066     AcpiOsPrintf (
1067         "Objects of type [%s] defined in the current ACPI Namespace:\n",
1068         AcpiUtGetTypeName (Type));
1069 
1070     AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
1071 
1072     Info.Count = 0;
1073     Info.OwnerId = ACPI_OWNER_ID_MAX;
1074     Info.DebugLevel = ACPI_UINT32_MAX;
1075     Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
1076 
1077     /* Walk the namespace from the root */
1078 
1079     (void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
1080                 AcpiDbWalkForSpecificObjects, (void *) &Info, NULL);
1081 
1082     AcpiOsPrintf (
1083         "\nFound %u objects of type [%s] in the current ACPI Namespace\n",
1084         Info.Count, AcpiUtGetTypeName (Type));
1085 
1086     AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1087     return (AE_OK);
1088 }
1089 
1090 
1091 /*******************************************************************************
1092  *
1093  * FUNCTION:    AcpiDbWalkAndMatchName
1094  *
1095  * PARAMETERS:  Callback from WalkNamespace
1096  *
1097  * RETURN:      Status
1098  *
1099  * DESCRIPTION: Find a particular name/names within the namespace.  Wildcards
1100  *              are supported -- '?' matches any character.
1101  *
1102  ******************************************************************************/
1103 
1104 static ACPI_STATUS
1105 AcpiDbWalkAndMatchName (
1106     ACPI_HANDLE             ObjHandle,
1107     UINT32                  NestingLevel,
1108     void                    *Context,
1109     void                    **ReturnValue)
1110 {
1111     ACPI_STATUS             Status;
1112     char                    *RequestedName = (char *) Context;
1113     UINT32                  i;
1114     ACPI_BUFFER             Buffer;
1115     ACPI_WALK_INFO          Info;
1116 
1117 
1118     /* Check for a name match */
1119 
1120     for (i = 0; i < 4; i++)
1121     {
1122         /* Wildcard support */
1123 
1124         if ((RequestedName[i] != '?') &&
1125             (RequestedName[i] != ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii[i]))
1126         {
1127             /* No match, just exit */
1128 
1129             return (AE_OK);
1130         }
1131     }
1132 
1133     /* Get the full pathname to this object */
1134 
1135     Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1136     Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
1137     if (ACPI_FAILURE (Status))
1138     {
1139         AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
1140     }
1141     else
1142     {
1143         Info.OwnerId = ACPI_OWNER_ID_MAX;
1144         Info.DebugLevel = ACPI_UINT32_MAX;
1145         Info.DisplayType = ACPI_DISPLAY_SUMMARY | ACPI_DISPLAY_SHORT;
1146 
1147         AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);
1148         (void) AcpiNsDumpOneObject (ObjHandle, NestingLevel, &Info, NULL);
1149         ACPI_FREE (Buffer.Pointer);
1150     }
1151 
1152     return (AE_OK);
1153 }
1154 
1155 
1156 /*******************************************************************************
1157  *
1158  * FUNCTION:    AcpiDbFindNameInNamespace
1159  *
1160  * PARAMETERS:  NameArg         - The 4-character ACPI name to find.
1161  *                                wildcards are supported.
1162  *
1163  * RETURN:      None
1164  *
1165  * DESCRIPTION: Search the namespace for a given name (with wildcards)
1166  *
1167  ******************************************************************************/
1168 
1169 ACPI_STATUS
1170 AcpiDbFindNameInNamespace (
1171     char                    *NameArg)
1172 {
1173 
1174     if (ACPI_STRLEN (NameArg) > 4)
1175     {
1176         AcpiOsPrintf ("Name must be no longer than 4 characters\n");
1177         return (AE_OK);
1178     }
1179 
1180     /* Walk the namespace from the root */
1181 
1182     AcpiUtStrupr (NameArg);
1183     (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
1184                         AcpiDbWalkAndMatchName, NameArg, NULL);
1185 
1186     AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1187     return (AE_OK);
1188 }
1189 
1190 
1191 /*******************************************************************************
1192  *
1193  * FUNCTION:    AcpiDbSetScope
1194  *
1195  * PARAMETERS:  Name                - New scope path
1196  *
1197  * RETURN:      Status
1198  *
1199  * DESCRIPTION: Set the "current scope" as maintained by this utility.
1200  *              The scope is used as a prefix to ACPI paths.
1201  *
1202  ******************************************************************************/
1203 
1204 void
1205 AcpiDbSetScope (
1206     char                    *Name)
1207 {
1208     ACPI_STATUS             Status;
1209     ACPI_NAMESPACE_NODE     *Node;
1210 
1211 
1212     if (!Name || Name[0] == 0)
1213     {
1214         AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf);
1215         return;
1216     }
1217 
1218     AcpiDbPrepNamestring (Name);
1219 
1220     if (Name[0] == '\\')
1221     {
1222         /* Validate new scope from the root */
1223 
1224         Status = AcpiNsGetNode (AcpiGbl_RootNode, Name, ACPI_NS_NO_UPSEARCH,
1225                     &Node);
1226         if (ACPI_FAILURE (Status))
1227         {
1228             goto ErrorExit;
1229         }
1230 
1231         ACPI_STRCPY (AcpiGbl_DbScopeBuf, Name);
1232         ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
1233     }
1234     else
1235     {
1236         /* Validate new scope relative to old scope */
1237 
1238         Status = AcpiNsGetNode (AcpiGbl_DbScopeNode, Name, ACPI_NS_NO_UPSEARCH,
1239                     &Node);
1240         if (ACPI_FAILURE (Status))
1241         {
1242             goto ErrorExit;
1243         }
1244 
1245         ACPI_STRCAT (AcpiGbl_DbScopeBuf, Name);
1246         ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
1247     }
1248 
1249     AcpiGbl_DbScopeNode = Node;
1250     AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf);
1251     return;
1252 
1253 ErrorExit:
1254 
1255     AcpiOsPrintf ("Could not attach scope: %s, %s\n",
1256         Name, AcpiFormatException (Status));
1257 }
1258 
1259 
1260 /*******************************************************************************
1261  *
1262  * FUNCTION:    AcpiDmCompareAmlResources
1263  *
1264  * PARAMETERS:  Aml1Buffer          - Contains first resource list
1265  *              Aml1BufferLength    - Length of first resource list
1266  *              Aml2Buffer          - Contains second resource list
1267  *              Aml2BufferLength    - Length of second resource list
1268  *
1269  * RETURN:      None
1270  *
1271  * DESCRIPTION: Compare two AML resource lists, descriptor by descriptor (in
1272  *              order to isolate a miscompare to an individual resource)
1273  *
1274  ******************************************************************************/
1275 
1276 static void
1277 AcpiDmCompareAmlResources (
1278     UINT8                   *Aml1Buffer,
1279     ACPI_RSDESC_SIZE        Aml1BufferLength,
1280     UINT8                   *Aml2Buffer,
1281     ACPI_RSDESC_SIZE        Aml2BufferLength)
1282 {
1283     UINT8                   *Aml1;
1284     UINT8                   *Aml2;
1285     ACPI_RSDESC_SIZE        Aml1Length;
1286     ACPI_RSDESC_SIZE        Aml2Length;
1287     ACPI_RSDESC_SIZE        Offset = 0;
1288     UINT8                   ResourceType;
1289     UINT32                  Count = 0;
1290 
1291 
1292     /* Compare overall buffer sizes (may be different due to size rounding) */
1293 
1294     if (Aml1BufferLength != Aml2BufferLength)
1295     {
1296         AcpiOsPrintf (
1297             "**** Buffer length mismatch in converted AML: original %X new %X ****\n",
1298             Aml1BufferLength, Aml2BufferLength);
1299     }
1300 
1301     Aml1 = Aml1Buffer;
1302     Aml2 = Aml2Buffer;
1303 
1304     /* Walk the descriptor lists, comparing each descriptor */
1305 
1306     while (Aml1 < (Aml1Buffer + Aml1BufferLength))
1307     {
1308         /* Get the lengths of each descriptor */
1309 
1310         Aml1Length = AcpiUtGetDescriptorLength (Aml1);
1311         Aml2Length = AcpiUtGetDescriptorLength (Aml2);
1312         ResourceType = AcpiUtGetResourceType (Aml1);
1313 
1314         /* Check for descriptor length match */
1315 
1316         if (Aml1Length != Aml2Length)
1317         {
1318             AcpiOsPrintf (
1319                 "**** Length mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X L1 %X L2 %X ****\n",
1320                 Count, ResourceType, Offset, Aml1Length, Aml2Length);
1321         }
1322 
1323         /* Check for descriptor byte match */
1324 
1325         else if (ACPI_MEMCMP (Aml1, Aml2, Aml1Length))
1326         {
1327             AcpiOsPrintf (
1328                 "**** Data mismatch in descriptor [%.2X] type %2.2X, Offset %8.8X ****\n",
1329                 Count, ResourceType, Offset);
1330         }
1331 
1332         /* Exit on EndTag descriptor */
1333 
1334         if (ResourceType == ACPI_RESOURCE_NAME_END_TAG)
1335         {
1336             return;
1337         }
1338 
1339         /* Point to next descriptor in each buffer */
1340 
1341         Count++;
1342         Offset += Aml1Length;
1343         Aml1 += Aml1Length;
1344         Aml2 += Aml2Length;
1345     }
1346 }
1347 
1348 
1349 /*******************************************************************************
1350  *
1351  * FUNCTION:    AcpiDmTestResourceConversion
1352  *
1353  * PARAMETERS:  Node            - Parent device node
1354  *              Name            - resource method name (_CRS)
1355  *
1356  * RETURN:      Status
1357  *
1358  * DESCRIPTION: Compare the original AML with a conversion of the AML to
1359  *              internal resource list, then back to AML.
1360  *
1361  ******************************************************************************/
1362 
1363 static ACPI_STATUS
1364 AcpiDmTestResourceConversion (
1365     ACPI_NAMESPACE_NODE     *Node,
1366     char                    *Name)
1367 {
1368     ACPI_STATUS             Status;
1369     ACPI_BUFFER             ReturnObj;
1370     ACPI_BUFFER             ResourceObj;
1371     ACPI_BUFFER             NewAml;
1372     ACPI_OBJECT             *OriginalAml;
1373 
1374 
1375     AcpiOsPrintf ("Resource Conversion Comparison:\n");
1376 
1377     NewAml.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1378     ReturnObj.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1379     ResourceObj.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1380 
1381     /* Get the original _CRS AML resource template */
1382 
1383     Status = AcpiEvaluateObject (Node, Name, NULL, &ReturnObj);
1384     if (ACPI_FAILURE (Status))
1385     {
1386         AcpiOsPrintf ("Could not obtain %s: %s\n",
1387             Name, AcpiFormatException (Status));
1388         return (Status);
1389     }
1390 
1391     /* Get the AML resource template, converted to internal resource structs */
1392 
1393     Status = AcpiGetCurrentResources (Node, &ResourceObj);
1394     if (ACPI_FAILURE (Status))
1395     {
1396         AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
1397             AcpiFormatException (Status));
1398         goto Exit1;
1399     }
1400 
1401     /* Convert internal resource list to external AML resource template */
1402 
1403     Status = AcpiRsCreateAmlResources (ResourceObj.Pointer, &NewAml);
1404     if (ACPI_FAILURE (Status))
1405     {
1406         AcpiOsPrintf ("AcpiRsCreateAmlResources failed: %s\n",
1407             AcpiFormatException (Status));
1408         goto Exit2;
1409     }
1410 
1411     /* Compare original AML to the newly created AML resource list */
1412 
1413     OriginalAml = ReturnObj.Pointer;
1414 
1415     AcpiDmCompareAmlResources (
1416         OriginalAml->Buffer.Pointer, OriginalAml->Buffer.Length,
1417         NewAml.Pointer, NewAml.Length);
1418 
1419     /* Cleanup and exit */
1420 
1421     ACPI_FREE (NewAml.Pointer);
1422 Exit2:
1423     ACPI_FREE (ResourceObj.Pointer);
1424 Exit1:
1425     ACPI_FREE (ReturnObj.Pointer);
1426     return (Status);
1427 }
1428 
1429 
1430 /*******************************************************************************
1431  *
1432  * FUNCTION:    AcpiDbDisplayResources
1433  *
1434  * PARAMETERS:  ObjectArg       - String with hex value of the object
1435  *
1436  * RETURN:      None
1437  *
1438  * DESCRIPTION: Display the resource objects associated with a device.
1439  *
1440  ******************************************************************************/
1441 
1442 void
1443 AcpiDbDisplayResources (
1444     char                    *ObjectArg)
1445 {
1446 #if ACPI_MACHINE_WIDTH != 16
1447 
1448     ACPI_NAMESPACE_NODE     *Node;
1449     ACPI_STATUS             Status;
1450     ACPI_BUFFER             ReturnObj;
1451 
1452 
1453     AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
1454     AcpiDbgLevel |= ACPI_LV_RESOURCES;
1455 
1456     /* Convert string to object pointer */
1457 
1458     Node = AcpiDbConvertToNode (ObjectArg);
1459     if (!Node)
1460     {
1461         return;
1462     }
1463 
1464     /* Prepare for a return object of arbitrary size */
1465 
1466     ReturnObj.Pointer = AcpiGbl_DbBuffer;
1467     ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
1468 
1469     /* _PRT */
1470 
1471     AcpiOsPrintf ("Evaluating _PRT\n");
1472 
1473     /* Check if _PRT exists */
1474 
1475     Status = AcpiEvaluateObject (Node, METHOD_NAME__PRT, NULL, &ReturnObj);
1476     if (ACPI_FAILURE (Status))
1477     {
1478         AcpiOsPrintf ("Could not obtain _PRT: %s\n",
1479             AcpiFormatException (Status));
1480         goto GetCrs;
1481     }
1482 
1483     ReturnObj.Pointer = AcpiGbl_DbBuffer;
1484     ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
1485 
1486     Status = AcpiGetIrqRoutingTable (Node, &ReturnObj);
1487     if (ACPI_FAILURE (Status))
1488     {
1489         AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n",
1490             AcpiFormatException (Status));
1491         goto GetCrs;
1492     }
1493 
1494     AcpiRsDumpIrqList (ACPI_CAST_PTR (UINT8, AcpiGbl_DbBuffer));
1495 
1496 
1497     /* _CRS */
1498 
1499 GetCrs:
1500     AcpiOsPrintf ("Evaluating _CRS\n");
1501 
1502     ReturnObj.Pointer = AcpiGbl_DbBuffer;
1503     ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
1504 
1505     /* Check if _CRS exists */
1506 
1507     Status = AcpiEvaluateObject (Node, METHOD_NAME__CRS, NULL, &ReturnObj);
1508     if (ACPI_FAILURE (Status))
1509     {
1510         AcpiOsPrintf ("Could not obtain _CRS: %s\n",
1511             AcpiFormatException (Status));
1512         goto GetPrs;
1513     }
1514 
1515     /* Get the _CRS resource list */
1516 
1517     ReturnObj.Pointer = AcpiGbl_DbBuffer;
1518     ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
1519 
1520     Status = AcpiGetCurrentResources (Node, &ReturnObj);
1521     if (ACPI_FAILURE (Status))
1522     {
1523         AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n",
1524             AcpiFormatException (Status));
1525         goto GetPrs;
1526     }
1527 
1528     /* Dump the _CRS resource list */
1529 
1530     AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE,
1531         ReturnObj.Pointer));
1532 
1533     /*
1534      * Perform comparison of original AML to newly created AML. This tests both
1535      * the AML->Resource conversion and the Resource->Aml conversion.
1536      */
1537     Status = AcpiDmTestResourceConversion (Node, METHOD_NAME__CRS);
1538 
1539     /* Execute _SRS with the resource list */
1540 
1541     Status = AcpiSetCurrentResources (Node, &ReturnObj);
1542     if (ACPI_FAILURE (Status))
1543     {
1544         AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n",
1545             AcpiFormatException (Status));
1546         goto GetPrs;
1547     }
1548 
1549 
1550     /* _PRS */
1551 
1552 GetPrs:
1553     AcpiOsPrintf ("Evaluating _PRS\n");
1554 
1555     ReturnObj.Pointer = AcpiGbl_DbBuffer;
1556     ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
1557 
1558     /* Check if _PRS exists */
1559 
1560     Status = AcpiEvaluateObject (Node, METHOD_NAME__PRS, NULL, &ReturnObj);
1561     if (ACPI_FAILURE (Status))
1562     {
1563         AcpiOsPrintf ("Could not obtain _PRS: %s\n",
1564             AcpiFormatException (Status));
1565         goto Cleanup;
1566     }
1567 
1568     ReturnObj.Pointer = AcpiGbl_DbBuffer;
1569     ReturnObj.Length  = ACPI_DEBUG_BUFFER_SIZE;
1570 
1571     Status = AcpiGetPossibleResources (Node, &ReturnObj);
1572     if (ACPI_FAILURE (Status))
1573     {
1574         AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n",
1575             AcpiFormatException (Status));
1576         goto Cleanup;
1577     }
1578 
1579     AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer));
1580 
1581 Cleanup:
1582 
1583     AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1584     return;
1585 #endif
1586 }
1587 
1588 
1589 /*******************************************************************************
1590  *
1591  * FUNCTION:    AcpiDbIntegrityWalk
1592  *
1593  * PARAMETERS:  Callback from WalkNamespace
1594  *
1595  * RETURN:      Status
1596  *
1597  * DESCRIPTION: Examine one NS node for valid values.
1598  *
1599  ******************************************************************************/
1600 
1601 static ACPI_STATUS
1602 AcpiDbIntegrityWalk (
1603     ACPI_HANDLE             ObjHandle,
1604     UINT32                  NestingLevel,
1605     void                    *Context,
1606     void                    **ReturnValue)
1607 {
1608     ACPI_INTEGRITY_INFO     *Info = (ACPI_INTEGRITY_INFO *) Context;
1609     ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
1610     ACPI_OPERAND_OBJECT     *Object;
1611 
1612 
1613     Info->Nodes++;
1614     if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
1615     {
1616         AcpiOsPrintf ("Invalid Descriptor Type for Node %p [%s]\n",
1617             Node, AcpiUtGetDescriptorName (Node));
1618     }
1619 
1620     if (Node->Type > ACPI_TYPE_LOCAL_MAX)
1621     {
1622         AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n",
1623             Node, Node->Type);
1624     }
1625 
1626     if (!AcpiUtValidAcpiName (Node->Name.Integer))
1627     {
1628         AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node);
1629     }
1630 
1631     Object = AcpiNsGetAttachedObject (Node);
1632     if (Object)
1633     {
1634         Info->Objects++;
1635         if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
1636         {
1637             AcpiOsPrintf ("Invalid Descriptor Type for Object %p [%s]\n",
1638                 Object, AcpiUtGetDescriptorName (Object));
1639         }
1640     }
1641 
1642     return (AE_OK);
1643 }
1644 
1645 
1646 /*******************************************************************************
1647  *
1648  * FUNCTION:    AcpiDbCheckIntegrity
1649  *
1650  * PARAMETERS:  None
1651  *
1652  * RETURN:      None
1653  *
1654  * DESCRIPTION: Check entire namespace for data structure integrity
1655  *
1656  ******************************************************************************/
1657 
1658 void
1659 AcpiDbCheckIntegrity (
1660     void)
1661 {
1662     ACPI_INTEGRITY_INFO     Info = {0,0};
1663 
1664     /* Search all nodes in namespace */
1665 
1666     (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
1667                     AcpiDbIntegrityWalk, (void *) &Info, NULL);
1668 
1669     AcpiOsPrintf ("Verified %d namespace nodes with %d Objects\n",
1670         Info.Nodes, Info.Objects);
1671 }
1672 
1673 
1674 /*******************************************************************************
1675  *
1676  * FUNCTION:    AcpiDbGenerateGpe
1677  *
1678  * PARAMETERS:  GpeArg          - Raw GPE number, ascii string
1679  *              BlockArg        - GPE block number, ascii string
1680  *                                0 or 1 for FADT GPE blocks
1681  *
1682  * RETURN:      None
1683  *
1684  * DESCRIPTION: Generate a GPE
1685  *
1686  ******************************************************************************/
1687 
1688 void
1689 AcpiDbGenerateGpe (
1690     char                    *GpeArg,
1691     char                    *BlockArg)
1692 {
1693     UINT32                  BlockNumber;
1694     UINT32                  GpeNumber;
1695     ACPI_GPE_EVENT_INFO     *GpeEventInfo;
1696 
1697 
1698     GpeNumber   = ACPI_STRTOUL (GpeArg, NULL, 0);
1699     BlockNumber = ACPI_STRTOUL (BlockArg, NULL, 0);
1700 
1701 
1702     GpeEventInfo = AcpiEvGetGpeEventInfo (ACPI_TO_POINTER (BlockNumber),
1703         GpeNumber);
1704     if (!GpeEventInfo)
1705     {
1706         AcpiOsPrintf ("Invalid GPE\n");
1707         return;
1708     }
1709 
1710     (void) AcpiEvGpeDispatch (GpeEventInfo, GpeNumber);
1711 }
1712 
1713 
1714 /*******************************************************************************
1715  *
1716  * FUNCTION:    AcpiDbBusWalk
1717  *
1718  * PARAMETERS:  Callback from WalkNamespace
1719  *
1720  * RETURN:      Status
1721  *
1722  * DESCRIPTION: Display info about device objects that have a corresponding
1723  *              _PRT method.
1724  *
1725  ******************************************************************************/
1726 
1727 static ACPI_STATUS
1728 AcpiDbBusWalk (
1729     ACPI_HANDLE             ObjHandle,
1730     UINT32                  NestingLevel,
1731     void                    *Context,
1732     void                    **ReturnValue)
1733 {
1734     ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
1735     ACPI_STATUS             Status;
1736     ACPI_BUFFER             Buffer;
1737     ACPI_INTEGER            ADR;
1738     ACPI_DEVICE_ID          Id;
1739     ACPI_COMPATIBLE_ID_LIST *Cid;
1740     ACPI_NAMESPACE_NODE     *TempNode;
1741 
1742 
1743     /* Exit if there is no _PRT under this device */
1744 
1745     Status = AcpiGetHandle (Node, METHOD_NAME__PRT,
1746                 ACPI_CAST_PTR (ACPI_HANDLE, &TempNode));
1747     if (ACPI_FAILURE (Status))
1748     {
1749         return (AE_OK);
1750     }
1751 
1752     /* Get the full path to this device object */
1753 
1754     Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
1755     Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
1756     if (ACPI_FAILURE (Status))
1757     {
1758         AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
1759         return (AE_OK);
1760     }
1761 
1762     /* Display the full path */
1763 
1764     AcpiOsPrintf ("%-32s", (char *) Buffer.Pointer);
1765     ACPI_FREE (Buffer.Pointer);
1766 
1767     /* _PRT info */
1768 
1769     AcpiOsPrintf ("_PRT=%p", TempNode);
1770 
1771     /* Get the _ADR value */
1772 
1773     Status = AcpiUtEvaluateNumericObject (METHOD_NAME__ADR, Node, &ADR);
1774     if (ACPI_FAILURE (Status))
1775     {
1776         AcpiOsPrintf (" No _ADR      ");
1777     }
1778     else
1779     {
1780         AcpiOsPrintf (" _ADR=%8.8X", (UINT32) ADR);
1781     }
1782 
1783     /* Get the _HID if present */
1784 
1785     Status = AcpiUtExecute_HID (Node, &Id);
1786     if (ACPI_SUCCESS (Status))
1787     {
1788         AcpiOsPrintf (" _HID=%s", Id.Value);
1789     }
1790     else
1791     {
1792         AcpiOsPrintf ("             ");
1793     }
1794 
1795     /* Get the _UID if present */
1796 
1797     Status = AcpiUtExecute_UID (Node, &Id);
1798     if (ACPI_SUCCESS (Status))
1799     {
1800         AcpiOsPrintf (" _UID=%s", Id.Value);
1801     }
1802 
1803     /* Get the _CID if present */
1804 
1805     Status = AcpiUtExecute_CID (Node, &Cid);
1806     if (ACPI_SUCCESS (Status))
1807     {
1808         AcpiOsPrintf (" _CID=%s", Cid->Id[0].Value);
1809         ACPI_FREE (Cid);
1810     }
1811 
1812     AcpiOsPrintf ("\n");
1813     return (AE_OK);
1814 }
1815 
1816 
1817 /*******************************************************************************
1818  *
1819  * FUNCTION:    AcpiDbGetBusInfo
1820  *
1821  * PARAMETERS:  None
1822  *
1823  * RETURN:      None
1824  *
1825  * DESCRIPTION: Display info about system busses.
1826  *
1827  ******************************************************************************/
1828 
1829 void
1830 AcpiDbGetBusInfo (
1831     void)
1832 {
1833     /* Search all nodes in namespace */
1834 
1835     (void) AcpiWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
1836                     AcpiDbBusWalk, NULL, NULL);
1837 }
1838 
1839 #endif /* ACPI_DEBUGGER */
1840