dbcmds.c revision 91116
1/*******************************************************************************
2 *
3 * Module Name: dbcmds - debug commands and output routines
4 *              $Revision: 79 $
5 *
6 ******************************************************************************/
7
8/******************************************************************************
9 *
10 * 1. Copyright Notice
11 *
12 * Some or all of this work - Copyright (c) 1999 - 2002, 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 "acparser.h"
120#include "acdispat.h"
121#include "amlcode.h"
122#include "acnamesp.h"
123#include "acparser.h"
124#include "acevents.h"
125#include "acinterp.h"
126#include "acdebug.h"
127#include "actables.h"
128#include "acresrc.h"
129
130#ifdef ENABLE_DEBUGGER
131
132#define _COMPONENT          ACPI_DEBUGGER
133        ACPI_MODULE_NAME    ("dbcmds")
134
135
136/*
137 * Arguments for the Objects command
138 * These object types map directly to the ACPI_TYPES
139 */
140
141ARGUMENT_INFO         AcpiDbObjectTypes [] =
142{
143    {"ANY"},
144    {"NUMBERS"},
145    {"STRINGS"},
146    {"BUFFERS"},
147    {"PACKAGES"},
148    {"FIELDS"},
149    {"DEVICES"},
150    {"EVENTS"},
151    {"METHODS"},
152    {"MUTEXES"},
153    {"REGIONS"},
154    {"POWERRESOURCES"},
155    {"PROCESSORS"},
156    {"THERMALZONES"},
157    {"BUFFERFIELDS"},
158    {"DDBHANDLES"},
159    {NULL}           /* Must be null terminated */
160};
161
162
163/*******************************************************************************
164 *
165 * FUNCTION:    AcpiDbWalkForReferences
166 *
167 * PARAMETERS:  Callback from WalkNamespace
168 *
169 * RETURN:      Status
170 *
171 * DESCRIPTION: Check if this namespace object refers to the target object
172 *              that is passed in as the context value.
173 *
174 * Note: Currently doesn't check subobjects within the Node's object
175 *
176 ******************************************************************************/
177
178ACPI_STATUS
179AcpiDbWalkForReferences (
180    ACPI_HANDLE             ObjHandle,
181    UINT32                  NestingLevel,
182    void                    *Context,
183    void                    **ReturnValue)
184{
185    ACPI_OPERAND_OBJECT     *ObjDesc = (ACPI_OPERAND_OBJECT  *) Context;
186    ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
187
188
189    /* Check for match against the namespace node itself */
190
191    if (Node == (void *) ObjDesc)
192    {
193        AcpiOsPrintf ("Object is a Node [%4.4s]\n", &Node->Name);
194    }
195
196    /* Check for match against the object attached to the node */
197
198    if (AcpiNsGetAttachedObject (Node) == ObjDesc)
199    {
200        AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n", Node, &Node->Name);
201    }
202
203    return (AE_OK);
204}
205
206
207/*******************************************************************************
208 *
209 * FUNCTION:    AcpiDbFindReferences
210 *
211 * PARAMETERS:  ObjectArg       - String with hex value of the object
212 *
213 * RETURN:      None
214 *
215 * DESCRIPTION: Search namespace for all references to the input object
216 *
217 ******************************************************************************/
218
219void
220AcpiDbFindReferences (
221    NATIVE_CHAR             *ObjectArg)
222{
223    ACPI_OPERAND_OBJECT     *ObjDesc;
224
225
226    /* Convert string to object pointer */
227
228    ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16));
229
230    /* Search all nodes in namespace */
231
232    AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
233                    AcpiDbWalkForReferences, (void *) ObjDesc, NULL);
234}
235
236
237/*******************************************************************************
238 *
239 * FUNCTION:    AcpiDbDisplayLocks
240 *
241 * PARAMETERS:  None
242 *
243 * RETURN:      None
244 *
245 * DESCRIPTION: Display information about internal mutexes.
246 *
247 ******************************************************************************/
248
249void
250AcpiDbDisplayLocks (void)
251{
252    UINT32                  i;
253
254
255    for (i = 0; i < MAX_MTX; i++)
256    {
257        AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i),
258                    AcpiGbl_AcpiMutexInfo[i].OwnerId == ACPI_MUTEX_NOT_ACQUIRED
259                        ? "Locked" : "Unlocked");
260    }
261}
262
263
264/*******************************************************************************
265 *
266 * FUNCTION:    AcpiDbDisplayTableInfo
267 *
268 * PARAMETERS:  TableArg        - String with name of table to be displayed
269 *
270 * RETURN:      None
271 *
272 * DESCRIPTION: Display information about loaded tables.  Current
273 *              implementation displays all loaded tables.
274 *
275 ******************************************************************************/
276
277void
278AcpiDbDisplayTableInfo (
279    NATIVE_CHAR             *TableArg)
280{
281    UINT32                  i;
282
283
284    for (i = 0; i < NUM_ACPI_TABLES; i++)
285    {
286        if (AcpiGbl_AcpiTables[i].Pointer)
287        {
288            AcpiOsPrintf ("%s at %p length %X\n", AcpiGbl_AcpiTableData[i].Name,
289                        AcpiGbl_AcpiTables[i].Pointer, AcpiGbl_AcpiTables[i].Length);
290        }
291    }
292}
293
294
295/*******************************************************************************
296 *
297 * FUNCTION:    AcpiDbUnloadAcpiTable
298 *
299 * PARAMETERS:  TableArg        - Name of the table to be unloaded
300 *              InstanceArg     - Which instance of the table to unload (if
301 *                                there are multiple tables of the same type)
302 *
303 * RETURN:      Nonde
304 *
305 * DESCRIPTION: Unload an ACPI table.
306 *              Instance is not implemented
307 *
308 ******************************************************************************/
309
310void
311AcpiDbUnloadAcpiTable (
312    NATIVE_CHAR             *TableArg,
313    NATIVE_CHAR             *InstanceArg)
314{
315    UINT32                  i;
316    ACPI_STATUS             Status;
317
318
319    /* Search all tables for the target type */
320
321    for (i = 0; i < NUM_ACPI_TABLES; i++)
322    {
323        if (!ACPI_STRNCMP (TableArg, AcpiGbl_AcpiTableData[i].Signature,
324                AcpiGbl_AcpiTableData[i].SigLength))
325        {
326            /* Found the table, unload it */
327
328            Status = AcpiUnloadTable (i);
329            if (ACPI_SUCCESS (Status))
330            {
331                AcpiOsPrintf ("[%s] unloaded and uninstalled\n", TableArg);
332            }
333            else
334            {
335                AcpiOsPrintf ("%s, while unloading [%s]\n",
336                    AcpiFormatException (Status), TableArg);
337            }
338
339            return;
340        }
341    }
342
343    AcpiOsPrintf ("Unknown table type [%s]\n", TableArg);
344}
345
346
347/*******************************************************************************
348 *
349 * FUNCTION:    AcpiDbSetMethodBreakpoint
350 *
351 * PARAMETERS:  Location            - AML offset of breakpoint
352 *              WalkState           - Current walk info
353 *              Op                  - Current Op (from parse walk)
354 *
355 * RETURN:      None
356 *
357 * DESCRIPTION: Set a breakpoint in a control method at the specified
358 *              AML offset
359 *
360 ******************************************************************************/
361
362void
363AcpiDbSetMethodBreakpoint (
364    NATIVE_CHAR             *Location,
365    ACPI_WALK_STATE         *WalkState,
366    ACPI_PARSE_OBJECT       *Op)
367{
368    UINT32                  Address;
369
370
371    if (!Op)
372    {
373        AcpiOsPrintf ("There is no method currently executing\n");
374        return;
375    }
376
377    /* Get and verify the breakpoint address */
378
379    Address = ACPI_STRTOUL (Location, NULL, 16);
380    if (Address <= Op->AmlOffset)
381    {
382        AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n", Address, Op->AmlOffset);
383    }
384
385    /* Save breakpoint in current walk */
386
387    WalkState->UserBreakpoint = Address;
388    AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address);
389}
390
391
392/*******************************************************************************
393 *
394 * FUNCTION:    AcpiDbSetMethodCallBreakpoint
395 *
396 * PARAMETERS:  Op                  - Current Op (from parse walk)
397 *
398 * RETURN:      None
399 *
400 * DESCRIPTION: Set a breakpoint in a control method at the specified
401 *              AML offset
402 *
403 ******************************************************************************/
404
405void
406AcpiDbSetMethodCallBreakpoint (
407    ACPI_PARSE_OBJECT       *Op)
408{
409
410
411    if (!Op)
412    {
413        AcpiOsPrintf ("There is no method currently executing\n");
414        return;
415    }
416
417
418    AcpiGbl_StepToNextCall = TRUE;
419}
420
421
422/*******************************************************************************
423 *
424 * FUNCTION:    AcpiDbDisassembleAml
425 *
426 * PARAMETERS:  Statements          - Number of statements to disassemble
427 *              Op                  - Current Op (from parse walk)
428 *
429 * RETURN:      None
430 *
431 * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
432 *              of statements specified.
433 *
434 ******************************************************************************/
435
436void
437AcpiDbDisassembleAml (
438    NATIVE_CHAR             *Statements,
439    ACPI_PARSE_OBJECT       *Op)
440{
441    UINT32                  NumStatements = 8;
442
443
444    if (!Op)
445    {
446        AcpiOsPrintf ("There is no method currently executing\n");
447        return;
448    }
449
450    if (Statements)
451    {
452        NumStatements = ACPI_STRTOUL (Statements, NULL, 0);
453    }
454
455    AcpiDbDisplayOp (NULL, Op, NumStatements);
456}
457
458
459/*******************************************************************************
460 *
461 * FUNCTION:    AcpiDbDumpNamespace
462 *
463 * PARAMETERS:  StartArg        - Node to begin namespace dump
464 *              DepthArg        - Maximum tree depth to be dumped
465 *
466 * RETURN:      None
467 *
468 * DESCRIPTION: Dump entire namespace or a subtree.  Each node is displayed
469 *              with type and other information.
470 *
471 ******************************************************************************/
472
473void
474AcpiDbDumpNamespace (
475    NATIVE_CHAR             *StartArg,
476    NATIVE_CHAR             *DepthArg)
477{
478    ACPI_HANDLE             SubtreeEntry = AcpiGbl_RootNode;
479    UINT32                  MaxDepth = ACPI_UINT32_MAX;
480
481
482    /* No argument given, just start at the root and dump entire namespace */
483
484    if (StartArg)
485    {
486        /* Check if numeric argument, must be a Node */
487
488        if ((StartArg[0] >= 0x30) && (StartArg[0] <= 0x39))
489        {
490            SubtreeEntry = ACPI_TO_POINTER (ACPI_STRTOUL (StartArg, NULL, 16));
491            if (!AcpiOsReadable (SubtreeEntry, sizeof (ACPI_NAMESPACE_NODE)))
492            {
493                AcpiOsPrintf ("Address %p is invalid in this address space\n", SubtreeEntry);
494                return;
495            }
496
497            if (ACPI_GET_DESCRIPTOR_TYPE (SubtreeEntry) != ACPI_DESC_TYPE_NAMED)
498            {
499                AcpiOsPrintf ("Address %p is not a valid Named object\n", SubtreeEntry);
500                return;
501            }
502        }
503
504        /* Alpha argument */
505
506        else
507        {
508            /* The parameter is a name string that must be resolved to a Named obj*/
509
510            SubtreeEntry = AcpiDbLocalNsLookup (StartArg);
511            if (!SubtreeEntry)
512            {
513                SubtreeEntry = AcpiGbl_RootNode;
514            }
515        }
516
517        /* Now we can check for the depth argument */
518
519        if (DepthArg)
520        {
521            MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
522        }
523    }
524
525    AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
526    AcpiOsPrintf ("ACPI Namespace (from %p subtree):\n", SubtreeEntry);
527
528    /* Display the subtree */
529
530    AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
531    AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, ACPI_UINT32_MAX, SubtreeEntry);
532    AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
533}
534
535
536/*******************************************************************************
537 *
538 * FUNCTION:    AcpiDbDumpNamespaceByOwner
539 *
540 * PARAMETERS:  OwnerArg        - Owner ID whose nodes will be displayed
541 *              DepthArg        - Maximum tree depth to be dumped
542 *
543 * RETURN:      None
544 *
545 * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId.
546 *
547 ******************************************************************************/
548
549void
550AcpiDbDumpNamespaceByOwner (
551    NATIVE_CHAR             *OwnerArg,
552    NATIVE_CHAR             *DepthArg)
553{
554    ACPI_HANDLE             SubtreeEntry = AcpiGbl_RootNode;
555    UINT32                  MaxDepth = ACPI_UINT32_MAX;
556    UINT16                  OwnerId;
557
558
559    OwnerId = (UINT16) ACPI_STRTOUL (OwnerArg, NULL, 0);
560
561    /* Now we can check for the depth argument */
562
563    if (DepthArg)
564    {
565        MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
566    }
567
568    AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
569    AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId);
570
571    /* Display the subtree */
572
573    AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
574    AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId, SubtreeEntry);
575    AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
576}
577
578
579/*******************************************************************************
580 *
581 * FUNCTION:    AcpiDbSendNotify
582 *
583 * PARAMETERS:  Name            - Name of ACPI object to send the notify to
584 *              Value           - Value of the notify to send.
585 *
586 * RETURN:      None
587 *
588 * DESCRIPTION: Send an ACPI notification.  The value specified is sent to the
589 *              named object as an ACPI notify.
590 *
591 ******************************************************************************/
592
593void
594AcpiDbSendNotify (
595    NATIVE_CHAR             *Name,
596    UINT32                  Value)
597{
598    ACPI_NAMESPACE_NODE     *Node;
599
600
601    /* Translate name to an Named object */
602
603    Node = AcpiDbLocalNsLookup (Name);
604    if (!Node)
605    {
606        return;
607    }
608
609    /* Decode Named object type */
610
611    switch (Node->Type)
612    {
613    case ACPI_TYPE_DEVICE:
614    case ACPI_TYPE_THERMAL:
615
616         /* Send the notify */
617
618        AcpiEvQueueNotifyRequest (Node, Value);
619        break;
620
621    default:
622        AcpiOsPrintf ("Named object is not a device or a thermal object\n");
623        break;
624    }
625
626}
627
628
629/*******************************************************************************
630 *
631 * FUNCTION:    AcpiDbSetMethodData
632 *
633 * PARAMETERS:  TypeArg         - L for local, A for argument
634 *              IndexArg        - which one
635 *              ValueArg        - Value to set.
636 *
637 * RETURN:      None
638 *
639 * DESCRIPTION: Set a local or argument for the running control method.
640 *              NOTE: only object supported is Number.
641 *
642 ******************************************************************************/
643
644void
645AcpiDbSetMethodData (
646    NATIVE_CHAR             *TypeArg,
647    NATIVE_CHAR             *IndexArg,
648    NATIVE_CHAR             *ValueArg)
649{
650    NATIVE_CHAR             Type;
651    UINT32                  Index;
652    UINT32                  Value;
653    ACPI_WALK_STATE         *WalkState;
654    ACPI_OPERAND_OBJECT     *ObjDesc;
655
656
657    /* Validate TypeArg */
658
659    ACPI_STRUPR (TypeArg);
660    Type = TypeArg[0];
661    if ((Type != 'L') &&
662        (Type != 'A'))
663    {
664        AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg);
665        return;
666    }
667
668    /* Get the index and value */
669
670    Index = ACPI_STRTOUL (IndexArg, NULL, 16);
671    Value = ACPI_STRTOUL (ValueArg, NULL, 16);
672
673    WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
674    if (!WalkState)
675    {
676        AcpiOsPrintf ("There is no method currently executing\n");
677        return;
678    }
679
680
681    /* Create and initialize the new object */
682
683    ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
684    if (!ObjDesc)
685    {
686        AcpiOsPrintf ("Could not create an internal object\n");
687        return;
688    }
689
690    ObjDesc->Integer.Value = Value;
691
692
693    /* Store the new object into the target */
694
695    switch (Type)
696    {
697    case 'A':
698
699        /* Set a method argument */
700
701        if (Index > MTH_NUM_ARGS)
702        {
703            AcpiOsPrintf ("Arg%d - Invalid argument name\n", Index);
704            return;
705        }
706
707        AcpiDsStoreObjectToLocal (AML_ARG_OP, Index, ObjDesc, WalkState);
708        ObjDesc = WalkState->Arguments[Index].Object;
709
710        AcpiOsPrintf ("Arg%d: ", Index);
711        AcpiDbDisplayInternalObject (ObjDesc, WalkState);
712        break;
713
714    case 'L':
715
716        /* Set a method local */
717
718        if (Index > MTH_NUM_LOCALS)
719        {
720            AcpiOsPrintf ("Local%d - Invalid local variable name\n", Index);
721            return;
722        }
723
724        AcpiDsStoreObjectToLocal (AML_LOCAL_OP, Index, ObjDesc, WalkState);
725        ObjDesc = WalkState->LocalVariables[Index].Object;
726
727        AcpiOsPrintf ("Local%d: ", Index);
728        AcpiDbDisplayInternalObject (ObjDesc, WalkState);
729        break;
730
731    default:
732        break;
733    }
734}
735
736
737/*******************************************************************************
738 *
739 * FUNCTION:    AcpiDbWalkForSpecificObjects
740 *
741 * PARAMETERS:  Callback from WalkNamespace
742 *
743 * RETURN:      Status
744 *
745 * DESCRIPTION: Display short info about objects in the namespace
746 *
747 ******************************************************************************/
748
749ACPI_STATUS
750AcpiDbWalkForSpecificObjects (
751    ACPI_HANDLE             ObjHandle,
752    UINT32                  NestingLevel,
753    void                    *Context,
754    void                    **ReturnValue)
755{
756    ACPI_OPERAND_OBJECT     *ObjDesc;
757    ACPI_STATUS             Status;
758    ACPI_BUFFER             Buffer;
759
760
761    ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjHandle);
762
763    /* Get and display the full pathname to this object */
764
765    Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
766    Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
767    if (ACPI_FAILURE (Status))
768    {
769        AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
770        return (AE_OK);
771    }
772
773    AcpiOsPrintf ("%32s", Buffer.Pointer);
774    ACPI_MEM_FREE (Buffer.Pointer);
775
776
777    /* Display short information about the object */
778
779    if (ObjDesc)
780    {
781        switch (ObjDesc->Common.Type)
782        {
783        case ACPI_TYPE_METHOD:
784            AcpiOsPrintf ("  #Args %d  Concurrency %X", ObjDesc->Method.ParamCount, ObjDesc->Method.Concurrency);
785            break;
786
787        case ACPI_TYPE_INTEGER:
788            AcpiOsPrintf ("  Value %X", ObjDesc->Integer.Value);
789            break;
790
791        case ACPI_TYPE_STRING:
792            AcpiOsPrintf ("  \"%s\"", ObjDesc->String.Pointer);
793            break;
794
795        case ACPI_TYPE_REGION:
796            AcpiOsPrintf ("  SpaceId %X Address %X Length %X", ObjDesc->Region.SpaceId, ObjDesc->Region.Address, ObjDesc->Region.Length);
797            break;
798
799        case ACPI_TYPE_PACKAGE:
800            AcpiOsPrintf ("  #Elements %X", ObjDesc->Package.Count);
801            break;
802
803        case ACPI_TYPE_BUFFER:
804            AcpiOsPrintf ("  Length %X", ObjDesc->Buffer.Length);
805            break;
806        }
807    }
808
809    AcpiOsPrintf ("\n");
810    return (AE_OK);
811}
812
813
814/*******************************************************************************
815 *
816 * FUNCTION:    AcpiDbDisplayObjects
817 *
818 * PARAMETERS:  ObjTypeArg          - Type of object to display
819 *              DisplayCountArg     - Max depth to display
820 *
821 * RETURN:      None
822 *
823 * DESCRIPTION: Display objects in the namespace of the requested type
824 *
825 ******************************************************************************/
826
827ACPI_STATUS
828AcpiDbDisplayObjects (
829    NATIVE_CHAR             *ObjTypeArg,
830    NATIVE_CHAR             *DisplayCountArg)
831{
832    ACPI_OBJECT_TYPE        Type;
833
834
835    /* Get the object type */
836
837    Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes);
838    if (Type == ACPI_TYPE_NOT_FOUND)
839    {
840        AcpiOsPrintf ("Invalid or unsupported argument\n");
841        return (AE_OK);
842    }
843
844    AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
845    AcpiOsPrintf ("Objects of type [%s] defined in the current ACPI Namespace: \n", AcpiUtGetTypeName (Type));
846
847    AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
848
849    /* Walk the namespace from the root */
850
851    AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
852                        AcpiDbWalkForSpecificObjects, (void *) &Type, NULL);
853
854    AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
855    return (AE_OK);
856}
857
858
859/*******************************************************************************
860 *
861 * FUNCTION:    AcpiDbWalkAndMatchName
862 *
863 * PARAMETERS:  Callback from WalkNamespace
864 *
865 * RETURN:      Status
866 *
867 * DESCRIPTION: Find a particular name/names within the namespace.  Wildcards
868 *              are supported -- '?' matches any character.
869 *
870 ******************************************************************************/
871
872ACPI_STATUS
873AcpiDbWalkAndMatchName (
874    ACPI_HANDLE             ObjHandle,
875    UINT32                  NestingLevel,
876    void                    *Context,
877    void                    **ReturnValue)
878{
879    ACPI_STATUS             Status;
880    NATIVE_CHAR             *RequestedName = (NATIVE_CHAR *) Context;
881    UINT32                  i;
882    ACPI_BUFFER             Buffer;
883
884
885    /* Check for a name match */
886
887    for (i = 0; i < 4; i++)
888    {
889        /* Wildcard support */
890
891        if ((RequestedName[i] != '?') &&
892            (RequestedName[i] != ((NATIVE_CHAR *) (&((ACPI_NAMESPACE_NODE *) ObjHandle)->Name))[i]))
893        {
894            /* No match, just exit */
895
896            return (AE_OK);
897        }
898    }
899
900
901    /* Get the full pathname to this object */
902
903    Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
904    Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
905    if (ACPI_FAILURE (Status))
906    {
907        AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
908    }
909    else
910    {
911        AcpiOsPrintf ("%32s (%p) - %s\n", Buffer.Pointer, ObjHandle,
912            AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) ObjHandle)->Type));
913        ACPI_MEM_FREE (Buffer.Pointer);
914    }
915
916    return (AE_OK);
917}
918
919
920/*******************************************************************************
921 *
922 * FUNCTION:    AcpiDbFindNameInNamespace
923 *
924 * PARAMETERS:  NameArg         - The 4-character ACPI name to find.
925 *                                wildcards are supported.
926 *
927 * RETURN:      None
928 *
929 * DESCRIPTION: Search the namespace for a given name (with wildcards)
930 *
931 ******************************************************************************/
932
933ACPI_STATUS
934AcpiDbFindNameInNamespace (
935    NATIVE_CHAR             *NameArg)
936{
937
938    if (ACPI_STRLEN (NameArg) > 4)
939    {
940        AcpiOsPrintf ("Name must be no longer than 4 characters\n");
941        return (AE_OK);
942    }
943
944    /* Walk the namespace from the root */
945
946    AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
947                        AcpiDbWalkAndMatchName, NameArg, NULL);
948
949    AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
950    return (AE_OK);
951}
952
953
954/*******************************************************************************
955 *
956 * FUNCTION:    AcpiDbSetScope
957 *
958 * PARAMETERS:  Name                - New scope path
959 *
960 * RETURN:      Status
961 *
962 * DESCRIPTION: Set the "current scope" as maintained by this utility.
963 *              The scope is used as a prefix to ACPI paths.
964 *
965 ******************************************************************************/
966
967void
968AcpiDbSetScope (
969    NATIVE_CHAR             *Name)
970{
971    ACPI_STATUS             Status;
972    ACPI_NAMESPACE_NODE     *Node;
973
974
975    if (!Name || Name[0] == 0)
976    {
977        AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf);
978        return;
979    }
980
981    AcpiDbPrepNamestring (Name);
982
983
984    if (Name[0] == '\\')
985    {
986        /* Validate new scope from the root */
987
988        Status = AcpiNsGetNodeByPath (Name, AcpiGbl_RootNode, ACPI_NS_NO_UPSEARCH, &Node);
989        if (ACPI_FAILURE (Status))
990        {
991            goto ErrorExit;
992        }
993
994        ACPI_STRCPY (AcpiGbl_DbScopeBuf, Name);
995        ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
996    }
997    else
998    {
999        /* Validate new scope relative to old scope */
1000
1001        Status = AcpiNsGetNodeByPath (Name, AcpiGbl_DbScopeNode, ACPI_NS_NO_UPSEARCH, &Node);
1002        if (ACPI_FAILURE (Status))
1003        {
1004            goto ErrorExit;
1005        }
1006
1007        ACPI_STRCAT (AcpiGbl_DbScopeBuf, Name);
1008        ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
1009    }
1010
1011    AcpiGbl_DbScopeNode = Node;
1012    AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf);
1013    return;
1014
1015
1016ErrorExit:
1017
1018    AcpiOsPrintf ("Could not attach scope: %s, %s\n", Name, AcpiFormatException (Status));
1019}
1020
1021
1022/*******************************************************************************
1023 *
1024 * FUNCTION:    AcpiDbDisplayResources
1025 *
1026 * PARAMETERS:  ObjectArg       - String with hex value of the object
1027 *
1028 * RETURN:      None
1029 *
1030 * DESCRIPTION:
1031 *
1032 ******************************************************************************/
1033
1034void
1035AcpiDbDisplayResources (
1036    NATIVE_CHAR             *ObjectArg)
1037{
1038#ifndef _IA16
1039    ACPI_OPERAND_OBJECT     *ObjDesc;
1040    ACPI_STATUS             Status;
1041    ACPI_BUFFER             ReturnObj;
1042
1043
1044    AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
1045    AcpiDbgLevel |= ACPI_LV_RESOURCES;
1046
1047    /* Convert string to object pointer */
1048
1049    ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16));
1050
1051    /* Prepare for a return object of arbitrary size */
1052
1053    ReturnObj.Pointer           = AcpiGbl_DbBuffer;
1054    ReturnObj.Length            = ACPI_DEBUG_BUFFER_SIZE;
1055
1056    /* _PRT */
1057
1058    AcpiOsPrintf ("Evaluating _PRT\n");
1059
1060    Status = AcpiEvaluateObject (ObjDesc, "_PRT", NULL, &ReturnObj);
1061    if (ACPI_FAILURE (Status))
1062    {
1063        AcpiOsPrintf ("Could not obtain _PRT: %s\n", AcpiFormatException (Status));
1064        goto GetCrs;
1065    }
1066
1067    ReturnObj.Pointer           = AcpiGbl_DbBuffer;
1068    ReturnObj.Length            = ACPI_DEBUG_BUFFER_SIZE;
1069
1070    Status = AcpiGetIrqRoutingTable (ObjDesc, &ReturnObj);
1071    if (ACPI_FAILURE (Status))
1072    {
1073        AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n", AcpiFormatException (Status));
1074    }
1075
1076    else
1077    {
1078        AcpiRsDumpIrqList ((UINT8 *) AcpiGbl_DbBuffer);
1079    }
1080
1081
1082    /* _CRS */
1083
1084GetCrs:
1085    AcpiOsPrintf ("Evaluating _CRS\n");
1086
1087    ReturnObj.Pointer           = AcpiGbl_DbBuffer;
1088    ReturnObj.Length            = ACPI_DEBUG_BUFFER_SIZE;
1089
1090    Status = AcpiEvaluateObject (ObjDesc, "_CRS", NULL, &ReturnObj);
1091    if (ACPI_FAILURE (Status))
1092    {
1093        AcpiOsPrintf ("Could not obtain _CRS: %s\n", AcpiFormatException (Status));
1094        goto GetPrs;
1095    }
1096
1097    ReturnObj.Pointer           = AcpiGbl_DbBuffer;
1098    ReturnObj.Length            = ACPI_DEBUG_BUFFER_SIZE;
1099
1100    Status = AcpiGetCurrentResources (ObjDesc, &ReturnObj);
1101    if (ACPI_FAILURE (Status))
1102    {
1103        AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", AcpiFormatException (Status));
1104        goto GetPrs;
1105    }
1106
1107    else
1108    {
1109        AcpiRsDumpResourceList ((ACPI_RESOURCE *) AcpiGbl_DbBuffer);
1110    }
1111
1112    Status = AcpiSetCurrentResources (ObjDesc, &ReturnObj);
1113    if (ACPI_FAILURE (Status))
1114    {
1115        AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n", AcpiFormatException (Status));
1116        goto GetPrs;
1117    }
1118
1119
1120    /* _PRS */
1121
1122GetPrs:
1123    AcpiOsPrintf ("Evaluating _PRS\n");
1124
1125    ReturnObj.Pointer           = AcpiGbl_DbBuffer;
1126    ReturnObj.Length            = ACPI_DEBUG_BUFFER_SIZE;
1127
1128    Status = AcpiEvaluateObject (ObjDesc, "_PRS", NULL, &ReturnObj);
1129    if (ACPI_FAILURE (Status))
1130    {
1131        AcpiOsPrintf ("Could not obtain _PRS: %s\n", AcpiFormatException (Status));
1132        goto Cleanup;
1133    }
1134
1135    ReturnObj.Pointer           = AcpiGbl_DbBuffer;
1136    ReturnObj.Length            = ACPI_DEBUG_BUFFER_SIZE;
1137
1138    Status = AcpiGetPossibleResources (ObjDesc, &ReturnObj);
1139    if (ACPI_FAILURE (Status))
1140    {
1141        AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n", AcpiFormatException (Status));
1142    }
1143
1144    else
1145    {
1146        AcpiRsDumpResourceList ((ACPI_RESOURCE *) AcpiGbl_DbBuffer);
1147    }
1148
1149
1150Cleanup:
1151
1152    AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1153    return;
1154#endif
1155
1156}
1157
1158
1159#endif /* ENABLE_DEBUGGER */
1160