dbcmds.c revision 114237
167754Smsmith/*******************************************************************************
267754Smsmith *
367754Smsmith * Module Name: dbcmds - debug commands and output routines
4114237Snjl *              $Revision: 97 $
567754Smsmith *
667754Smsmith ******************************************************************************/
767754Smsmith
867754Smsmith/******************************************************************************
967754Smsmith *
1067754Smsmith * 1. Copyright Notice
1167754Smsmith *
12114237Snjl * Some or all of this work - Copyright (c) 1999 - 2003, Intel Corp.
1370243Smsmith * All rights reserved.
1467754Smsmith *
1567754Smsmith * 2. License
1667754Smsmith *
1767754Smsmith * 2.1. This is your license from Intel Corp. under its intellectual property
1867754Smsmith * rights.  You may have additional license terms from the party that provided
1967754Smsmith * you this software, covering your right to use that party's intellectual
2067754Smsmith * property rights.
2167754Smsmith *
2267754Smsmith * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
2367754Smsmith * copy of the source code appearing in this file ("Covered Code") an
2467754Smsmith * irrevocable, perpetual, worldwide license under Intel's copyrights in the
2567754Smsmith * base code distributed originally by Intel ("Original Intel Code") to copy,
2667754Smsmith * make derivatives, distribute, use and display any portion of the Covered
2767754Smsmith * Code in any form, with the right to sublicense such rights; and
2867754Smsmith *
2967754Smsmith * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
3067754Smsmith * license (with the right to sublicense), under only those claims of Intel
3167754Smsmith * patents that are infringed by the Original Intel Code, to make, use, sell,
3267754Smsmith * offer to sell, and import the Covered Code and derivative works thereof
3367754Smsmith * solely to the minimum extent necessary to exercise the above copyright
3467754Smsmith * license, and in no event shall the patent license extend to any additions
3567754Smsmith * to or modifications of the Original Intel Code.  No other license or right
3667754Smsmith * is granted directly or by implication, estoppel or otherwise;
3767754Smsmith *
3867754Smsmith * The above copyright and patent license is granted only if the following
3967754Smsmith * conditions are met:
4067754Smsmith *
4167754Smsmith * 3. Conditions
4267754Smsmith *
4367754Smsmith * 3.1. Redistribution of Source with Rights to Further Distribute Source.
4467754Smsmith * Redistribution of source code of any substantial portion of the Covered
4567754Smsmith * Code or modification with rights to further distribute source must include
4667754Smsmith * the above Copyright Notice, the above License, this list of Conditions,
4767754Smsmith * and the following Disclaimer and Export Compliance provision.  In addition,
4867754Smsmith * Licensee must cause all Covered Code to which Licensee contributes to
4967754Smsmith * contain a file documenting the changes Licensee made to create that Covered
5067754Smsmith * Code and the date of any change.  Licensee must include in that file the
5167754Smsmith * documentation of any changes made by any predecessor Licensee.  Licensee
5267754Smsmith * must include a prominent statement that the modification is derived,
5367754Smsmith * directly or indirectly, from Original Intel Code.
5467754Smsmith *
5567754Smsmith * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
5667754Smsmith * Redistribution of source code of any substantial portion of the Covered
5767754Smsmith * Code or modification without rights to further distribute source must
5867754Smsmith * include the following Disclaimer and Export Compliance provision in the
5967754Smsmith * documentation and/or other materials provided with distribution.  In
6067754Smsmith * addition, Licensee may not authorize further sublicense of source of any
6167754Smsmith * portion of the Covered Code, and must include terms to the effect that the
6267754Smsmith * license from Licensee to its licensee is limited to the intellectual
6367754Smsmith * property embodied in the software Licensee provides to its licensee, and
6467754Smsmith * not to intellectual property embodied in modifications its licensee may
6567754Smsmith * make.
6667754Smsmith *
6767754Smsmith * 3.3. Redistribution of Executable. Redistribution in executable form of any
6867754Smsmith * substantial portion of the Covered Code or modification must reproduce the
6967754Smsmith * above Copyright Notice, and the following Disclaimer and Export Compliance
7067754Smsmith * provision in the documentation and/or other materials provided with the
7167754Smsmith * distribution.
7267754Smsmith *
7367754Smsmith * 3.4. Intel retains all right, title, and interest in and to the Original
7467754Smsmith * Intel Code.
7567754Smsmith *
7667754Smsmith * 3.5. Neither the name Intel nor any other trademark owned or controlled by
7767754Smsmith * Intel shall be used in advertising or otherwise to promote the sale, use or
7867754Smsmith * other dealings in products derived from or relating to the Covered Code
7967754Smsmith * without prior written authorization from Intel.
8067754Smsmith *
8167754Smsmith * 4. Disclaimer and Export Compliance
8267754Smsmith *
8367754Smsmith * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
8467754Smsmith * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
8567754Smsmith * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
8667754Smsmith * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
8767754Smsmith * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
8867754Smsmith * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
8967754Smsmith * PARTICULAR PURPOSE.
9067754Smsmith *
9167754Smsmith * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
9267754Smsmith * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
9367754Smsmith * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
9467754Smsmith * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
9567754Smsmith * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
9667754Smsmith * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
9767754Smsmith * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
9867754Smsmith * LIMITED REMEDY.
9967754Smsmith *
10067754Smsmith * 4.3. Licensee shall not export, either directly or indirectly, any of this
10167754Smsmith * software or system incorporating such software without first obtaining any
10267754Smsmith * required license or other approval from the U. S. Department of Commerce or
10367754Smsmith * any other agency or department of the United States Government.  In the
10467754Smsmith * event Licensee exports any such software from the United States or
10567754Smsmith * re-exports any such software from a foreign destination, Licensee shall
10667754Smsmith * ensure that the distribution and export/re-export of the software is in
10767754Smsmith * compliance with all laws, regulations, orders, or other restrictions of the
10867754Smsmith * U.S. Export Administration Regulations. Licensee agrees that neither it nor
10967754Smsmith * any of its subsidiaries will export/re-export any technical data, process,
11067754Smsmith * software, or service, directly or indirectly, to any country for which the
11167754Smsmith * United States government or any agency thereof requires an export license,
11267754Smsmith * other governmental approval, or letter of assurance, without first obtaining
11367754Smsmith * such license, approval or letter.
11467754Smsmith *
11567754Smsmith *****************************************************************************/
11667754Smsmith
11767754Smsmith
11867754Smsmith#include "acpi.h"
11967754Smsmith#include "acdispat.h"
12067754Smsmith#include "amlcode.h"
12167754Smsmith#include "acnamesp.h"
12267754Smsmith#include "acevents.h"
12367754Smsmith#include "acdebug.h"
12477424Smsmith#include "acresrc.h"
125100966Siwasaki#include "acdisasm.h"
12667754Smsmith
127102550Siwasaki#ifdef ACPI_DEBUGGER
12867754Smsmith
129102550Siwasaki#define _COMPONENT          ACPI_CA_DEBUGGER
13091116Smsmith        ACPI_MODULE_NAME    ("dbcmds")
13167754Smsmith
13267754Smsmith
13367754Smsmith/*
13467754Smsmith * Arguments for the Objects command
13567754Smsmith * These object types map directly to the ACPI_TYPES
13667754Smsmith */
13767754Smsmith
13899679Siwasakistatic ARGUMENT_INFO        AcpiDbObjectTypes [] =
13967754Smsmith{
14067754Smsmith    {"ANY"},
14167754Smsmith    {"NUMBERS"},
14267754Smsmith    {"STRINGS"},
14367754Smsmith    {"BUFFERS"},
14467754Smsmith    {"PACKAGES"},
14567754Smsmith    {"FIELDS"},
14667754Smsmith    {"DEVICES"},
14767754Smsmith    {"EVENTS"},
14867754Smsmith    {"METHODS"},
14967754Smsmith    {"MUTEXES"},
15067754Smsmith    {"REGIONS"},
15167754Smsmith    {"POWERRESOURCES"},
15267754Smsmith    {"PROCESSORS"},
15367754Smsmith    {"THERMALZONES"},
15467754Smsmith    {"BUFFERFIELDS"},
15567754Smsmith    {"DDBHANDLES"},
15667754Smsmith    {NULL}           /* Must be null terminated */
15767754Smsmith};
15867754Smsmith
15967754Smsmith
16067754Smsmith/*******************************************************************************
16167754Smsmith *
16267754Smsmith * FUNCTION:    AcpiDbWalkForReferences
16367754Smsmith *
16467754Smsmith * PARAMETERS:  Callback from WalkNamespace
16567754Smsmith *
16667754Smsmith * RETURN:      Status
16767754Smsmith *
16867754Smsmith * DESCRIPTION: Check if this namespace object refers to the target object
16967754Smsmith *              that is passed in as the context value.
17067754Smsmith *
17191116Smsmith * Note: Currently doesn't check subobjects within the Node's object
17291116Smsmith *
17367754Smsmith ******************************************************************************/
17467754Smsmith
17567754SmsmithACPI_STATUS
17667754SmsmithAcpiDbWalkForReferences (
17767754Smsmith    ACPI_HANDLE             ObjHandle,
17867754Smsmith    UINT32                  NestingLevel,
17967754Smsmith    void                    *Context,
18067754Smsmith    void                    **ReturnValue)
18167754Smsmith{
18267754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc = (ACPI_OPERAND_OBJECT  *) Context;
18367754Smsmith    ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
18467754Smsmith
18567754Smsmith
18667754Smsmith    /* Check for match against the namespace node itself */
18767754Smsmith
18867754Smsmith    if (Node == (void *) ObjDesc)
18967754Smsmith    {
19099679Siwasaki        AcpiOsPrintf ("Object is a Node [%4.4s]\n", Node->Name.Ascii);
19167754Smsmith    }
19267754Smsmith
19367754Smsmith    /* Check for match against the object attached to the node */
19467754Smsmith
19587031Smsmith    if (AcpiNsGetAttachedObject (Node) == ObjDesc)
19667754Smsmith    {
19799679Siwasaki        AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n", Node, Node->Name.Ascii);
19867754Smsmith    }
19967754Smsmith
20067754Smsmith    return (AE_OK);
20167754Smsmith}
20267754Smsmith
20367754Smsmith
20467754Smsmith/*******************************************************************************
20567754Smsmith *
20667754Smsmith * FUNCTION:    AcpiDbFindReferences
20767754Smsmith *
20867754Smsmith * PARAMETERS:  ObjectArg       - String with hex value of the object
20967754Smsmith *
21067754Smsmith * RETURN:      None
21167754Smsmith *
21267754Smsmith * DESCRIPTION: Search namespace for all references to the input object
21367754Smsmith *
21467754Smsmith ******************************************************************************/
21567754Smsmith
21667754Smsmithvoid
21767754SmsmithAcpiDbFindReferences (
218114237Snjl    char                    *ObjectArg)
21967754Smsmith{
22067754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
22167754Smsmith
22267754Smsmith
22367754Smsmith    /* Convert string to object pointer */
22467754Smsmith
22591116Smsmith    ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16));
22667754Smsmith
22767754Smsmith    /* Search all nodes in namespace */
22867754Smsmith
22999679Siwasaki    (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
23067754Smsmith                    AcpiDbWalkForReferences, (void *) ObjDesc, NULL);
23167754Smsmith}
23267754Smsmith
23367754Smsmith
23467754Smsmith/*******************************************************************************
23567754Smsmith *
23677424Smsmith * FUNCTION:    AcpiDbDisplayLocks
23777424Smsmith *
23877424Smsmith * PARAMETERS:  None
23977424Smsmith *
24077424Smsmith * RETURN:      None
24177424Smsmith *
24277424Smsmith * DESCRIPTION: Display information about internal mutexes.
24377424Smsmith *
24477424Smsmith ******************************************************************************/
24577424Smsmith
24677424Smsmithvoid
24777424SmsmithAcpiDbDisplayLocks (void)
24877424Smsmith{
24977424Smsmith    UINT32                  i;
25077424Smsmith
25177424Smsmith
25277424Smsmith    for (i = 0; i < MAX_MTX; i++)
25377424Smsmith    {
25477424Smsmith        AcpiOsPrintf ("%26s : %s\n", AcpiUtGetMutexName (i),
25577424Smsmith                    AcpiGbl_AcpiMutexInfo[i].OwnerId == ACPI_MUTEX_NOT_ACQUIRED
25677424Smsmith                        ? "Locked" : "Unlocked");
25777424Smsmith    }
25877424Smsmith}
25977424Smsmith
26077424Smsmith
26177424Smsmith/*******************************************************************************
26277424Smsmith *
26367754Smsmith * FUNCTION:    AcpiDbDisplayTableInfo
26467754Smsmith *
26567754Smsmith * PARAMETERS:  TableArg        - String with name of table to be displayed
26667754Smsmith *
26767754Smsmith * RETURN:      None
26867754Smsmith *
26967754Smsmith * DESCRIPTION: Display information about loaded tables.  Current
27067754Smsmith *              implementation displays all loaded tables.
27167754Smsmith *
27267754Smsmith ******************************************************************************/
27367754Smsmith
27467754Smsmithvoid
27567754SmsmithAcpiDbDisplayTableInfo (
276114237Snjl    char                    *TableArg)
27767754Smsmith{
27867754Smsmith    UINT32                  i;
27967754Smsmith
28067754Smsmith
28167754Smsmith    for (i = 0; i < NUM_ACPI_TABLES; i++)
28267754Smsmith    {
28367754Smsmith        if (AcpiGbl_AcpiTables[i].Pointer)
28467754Smsmith        {
28569746Smsmith            AcpiOsPrintf ("%s at %p length %X\n", AcpiGbl_AcpiTableData[i].Name,
286114237Snjl                        AcpiGbl_AcpiTables[i].Pointer,
287104470Siwasaki                        (UINT32) AcpiGbl_AcpiTables[i].Length);
28867754Smsmith        }
28967754Smsmith    }
29067754Smsmith}
29167754Smsmith
29267754Smsmith
29367754Smsmith/*******************************************************************************
29467754Smsmith *
29567754Smsmith * FUNCTION:    AcpiDbUnloadAcpiTable
29667754Smsmith *
29767754Smsmith * PARAMETERS:  TableArg        - Name of the table to be unloaded
29867754Smsmith *              InstanceArg     - Which instance of the table to unload (if
29967754Smsmith *                                there are multiple tables of the same type)
30067754Smsmith *
30167754Smsmith * RETURN:      Nonde
30267754Smsmith *
30367754Smsmith * DESCRIPTION: Unload an ACPI table.
30467754Smsmith *              Instance is not implemented
30567754Smsmith *
30667754Smsmith ******************************************************************************/
30767754Smsmith
30867754Smsmithvoid
30967754SmsmithAcpiDbUnloadAcpiTable (
310114237Snjl    char                    *TableArg,
311114237Snjl    char                    *InstanceArg)
31267754Smsmith{
31367754Smsmith    UINT32                  i;
31467754Smsmith    ACPI_STATUS             Status;
31567754Smsmith
31667754Smsmith
31767754Smsmith    /* Search all tables for the target type */
31867754Smsmith
31967754Smsmith    for (i = 0; i < NUM_ACPI_TABLES; i++)
32067754Smsmith    {
32191116Smsmith        if (!ACPI_STRNCMP (TableArg, AcpiGbl_AcpiTableData[i].Signature,
32280062Smsmith                AcpiGbl_AcpiTableData[i].SigLength))
32367754Smsmith        {
32467754Smsmith            /* Found the table, unload it */
32567754Smsmith
32667754Smsmith            Status = AcpiUnloadTable (i);
32767754Smsmith            if (ACPI_SUCCESS (Status))
32867754Smsmith            {
32967754Smsmith                AcpiOsPrintf ("[%s] unloaded and uninstalled\n", TableArg);
33067754Smsmith            }
33167754Smsmith            else
33267754Smsmith            {
33383174Smsmith                AcpiOsPrintf ("%s, while unloading [%s]\n",
33480062Smsmith                    AcpiFormatException (Status), TableArg);
33567754Smsmith            }
33667754Smsmith
33767754Smsmith            return;
33867754Smsmith        }
33967754Smsmith    }
34067754Smsmith
34167754Smsmith    AcpiOsPrintf ("Unknown table type [%s]\n", TableArg);
34267754Smsmith}
34367754Smsmith
34467754Smsmith
34567754Smsmith/*******************************************************************************
34667754Smsmith *
34767754Smsmith * FUNCTION:    AcpiDbSetMethodBreakpoint
34867754Smsmith *
34967754Smsmith * PARAMETERS:  Location            - AML offset of breakpoint
35067754Smsmith *              WalkState           - Current walk info
35167754Smsmith *              Op                  - Current Op (from parse walk)
35267754Smsmith *
35367754Smsmith * RETURN:      None
35467754Smsmith *
35567754Smsmith * DESCRIPTION: Set a breakpoint in a control method at the specified
35667754Smsmith *              AML offset
35767754Smsmith *
35867754Smsmith ******************************************************************************/
35967754Smsmith
36067754Smsmithvoid
36167754SmsmithAcpiDbSetMethodBreakpoint (
362114237Snjl    char                    *Location,
36367754Smsmith    ACPI_WALK_STATE         *WalkState,
36467754Smsmith    ACPI_PARSE_OBJECT       *Op)
36567754Smsmith{
36667754Smsmith    UINT32                  Address;
36767754Smsmith
36867754Smsmith
36967754Smsmith    if (!Op)
37067754Smsmith    {
37167754Smsmith        AcpiOsPrintf ("There is no method currently executing\n");
37267754Smsmith        return;
37367754Smsmith    }
37467754Smsmith
37567754Smsmith    /* Get and verify the breakpoint address */
37667754Smsmith
37791116Smsmith    Address = ACPI_STRTOUL (Location, NULL, 16);
37899679Siwasaki    if (Address <= Op->Common.AmlOffset)
37967754Smsmith    {
38099679Siwasaki        AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n", Address, Op->Common.AmlOffset);
38167754Smsmith    }
38267754Smsmith
38367754Smsmith    /* Save breakpoint in current walk */
38467754Smsmith
38591116Smsmith    WalkState->UserBreakpoint = Address;
38669746Smsmith    AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address);
38767754Smsmith}
38867754Smsmith
38967754Smsmith
39067754Smsmith/*******************************************************************************
39167754Smsmith *
39267754Smsmith * FUNCTION:    AcpiDbSetMethodCallBreakpoint
39367754Smsmith *
39467754Smsmith * PARAMETERS:  Op                  - Current Op (from parse walk)
39567754Smsmith *
39667754Smsmith * RETURN:      None
39767754Smsmith *
39867754Smsmith * DESCRIPTION: Set a breakpoint in a control method at the specified
39967754Smsmith *              AML offset
40067754Smsmith *
40167754Smsmith ******************************************************************************/
40267754Smsmith
40367754Smsmithvoid
40467754SmsmithAcpiDbSetMethodCallBreakpoint (
40567754Smsmith    ACPI_PARSE_OBJECT       *Op)
40667754Smsmith{
40767754Smsmith
40867754Smsmith
40967754Smsmith    if (!Op)
41067754Smsmith    {
41167754Smsmith        AcpiOsPrintf ("There is no method currently executing\n");
41267754Smsmith        return;
41367754Smsmith    }
41467754Smsmith
41567754Smsmith    AcpiGbl_StepToNextCall = TRUE;
41667754Smsmith}
41767754Smsmith
41867754Smsmith
41967754Smsmith/*******************************************************************************
42067754Smsmith *
42167754Smsmith * FUNCTION:    AcpiDbDisassembleAml
42267754Smsmith *
42367754Smsmith * PARAMETERS:  Statements          - Number of statements to disassemble
42467754Smsmith *              Op                  - Current Op (from parse walk)
42567754Smsmith *
42667754Smsmith * RETURN:      None
42767754Smsmith *
42867754Smsmith * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
42967754Smsmith *              of statements specified.
43067754Smsmith *
43167754Smsmith ******************************************************************************/
43267754Smsmith
43367754Smsmithvoid
43467754SmsmithAcpiDbDisassembleAml (
435114237Snjl    char                    *Statements,
43667754Smsmith    ACPI_PARSE_OBJECT       *Op)
43767754Smsmith{
43867754Smsmith    UINT32                  NumStatements = 8;
43967754Smsmith
44067754Smsmith
44167754Smsmith    if (!Op)
44267754Smsmith    {
44367754Smsmith        AcpiOsPrintf ("There is no method currently executing\n");
44467754Smsmith        return;
44567754Smsmith    }
44667754Smsmith
44767754Smsmith    if (Statements)
44867754Smsmith    {
44991116Smsmith        NumStatements = ACPI_STRTOUL (Statements, NULL, 0);
45067754Smsmith    }
45167754Smsmith
452100966Siwasaki    AcpiDmDisassemble (NULL, Op, NumStatements);
45367754Smsmith}
45467754Smsmith
45567754Smsmith
45667754Smsmith/*******************************************************************************
45767754Smsmith *
45867754Smsmith * FUNCTION:    AcpiDbDumpNamespace
45967754Smsmith *
46067754Smsmith * PARAMETERS:  StartArg        - Node to begin namespace dump
46167754Smsmith *              DepthArg        - Maximum tree depth to be dumped
46267754Smsmith *
46367754Smsmith * RETURN:      None
46467754Smsmith *
46567754Smsmith * DESCRIPTION: Dump entire namespace or a subtree.  Each node is displayed
46667754Smsmith *              with type and other information.
46767754Smsmith *
46867754Smsmith ******************************************************************************/
46967754Smsmith
47067754Smsmithvoid
47167754SmsmithAcpiDbDumpNamespace (
472114237Snjl    char                    *StartArg,
473114237Snjl    char                    *DepthArg)
47467754Smsmith{
47567754Smsmith    ACPI_HANDLE             SubtreeEntry = AcpiGbl_RootNode;
47667754Smsmith    UINT32                  MaxDepth = ACPI_UINT32_MAX;
47767754Smsmith
47867754Smsmith
47967754Smsmith    /* No argument given, just start at the root and dump entire namespace */
48067754Smsmith
48167754Smsmith    if (StartArg)
48267754Smsmith    {
48367754Smsmith        /* Check if numeric argument, must be a Node */
48467754Smsmith
48567754Smsmith        if ((StartArg[0] >= 0x30) && (StartArg[0] <= 0x39))
48667754Smsmith        {
48791116Smsmith            SubtreeEntry = ACPI_TO_POINTER (ACPI_STRTOUL (StartArg, NULL, 16));
48867754Smsmith            if (!AcpiOsReadable (SubtreeEntry, sizeof (ACPI_NAMESPACE_NODE)))
48967754Smsmith            {
49067754Smsmith                AcpiOsPrintf ("Address %p is invalid in this address space\n", SubtreeEntry);
49167754Smsmith                return;
49267754Smsmith            }
49367754Smsmith
49491116Smsmith            if (ACPI_GET_DESCRIPTOR_TYPE (SubtreeEntry) != ACPI_DESC_TYPE_NAMED)
49567754Smsmith            {
49667754Smsmith                AcpiOsPrintf ("Address %p is not a valid Named object\n", SubtreeEntry);
49767754Smsmith                return;
49867754Smsmith            }
49967754Smsmith        }
50067754Smsmith
50167754Smsmith        /* Alpha argument */
50267754Smsmith
50367754Smsmith        else
50467754Smsmith        {
50567754Smsmith            /* The parameter is a name string that must be resolved to a Named obj*/
50667754Smsmith
50767754Smsmith            SubtreeEntry = AcpiDbLocalNsLookup (StartArg);
50867754Smsmith            if (!SubtreeEntry)
50967754Smsmith            {
51067754Smsmith                SubtreeEntry = AcpiGbl_RootNode;
51167754Smsmith            }
51267754Smsmith        }
51367754Smsmith
51467754Smsmith        /* Now we can check for the depth argument */
51567754Smsmith
51667754Smsmith        if (DepthArg)
51767754Smsmith        {
51891116Smsmith            MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
51967754Smsmith        }
52067754Smsmith    }
52167754Smsmith
52291116Smsmith    AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
52367754Smsmith    AcpiOsPrintf ("ACPI Namespace (from %p subtree):\n", SubtreeEntry);
52467754Smsmith
52567754Smsmith    /* Display the subtree */
52667754Smsmith
52791116Smsmith    AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
52885756Smsmith    AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, ACPI_UINT32_MAX, SubtreeEntry);
52991116Smsmith    AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
53067754Smsmith}
53167754Smsmith
53267754Smsmith
53367754Smsmith/*******************************************************************************
53467754Smsmith *
53567754Smsmith * FUNCTION:    AcpiDbDumpNamespaceByOwner
53667754Smsmith *
53767754Smsmith * PARAMETERS:  OwnerArg        - Owner ID whose nodes will be displayed
53867754Smsmith *              DepthArg        - Maximum tree depth to be dumped
53967754Smsmith *
54067754Smsmith * RETURN:      None
54167754Smsmith *
54267754Smsmith * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId.
54367754Smsmith *
54467754Smsmith ******************************************************************************/
54567754Smsmith
54667754Smsmithvoid
54767754SmsmithAcpiDbDumpNamespaceByOwner (
548114237Snjl    char                    *OwnerArg,
549114237Snjl    char                    *DepthArg)
55067754Smsmith{
55167754Smsmith    ACPI_HANDLE             SubtreeEntry = AcpiGbl_RootNode;
55267754Smsmith    UINT32                  MaxDepth = ACPI_UINT32_MAX;
55367754Smsmith    UINT16                  OwnerId;
55467754Smsmith
55567754Smsmith
55691116Smsmith    OwnerId = (UINT16) ACPI_STRTOUL (OwnerArg, NULL, 0);
55767754Smsmith
55867754Smsmith    /* Now we can check for the depth argument */
55967754Smsmith
56067754Smsmith    if (DepthArg)
56167754Smsmith    {
56291116Smsmith        MaxDepth = ACPI_STRTOUL (DepthArg, NULL, 0);
56367754Smsmith    }
56467754Smsmith
56591116Smsmith    AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
56669746Smsmith    AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId);
56767754Smsmith
56867754Smsmith    /* Display the subtree */
56967754Smsmith
57091116Smsmith    AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
57185756Smsmith    AcpiNsDumpObjects (ACPI_TYPE_ANY, ACPI_DISPLAY_SUMMARY, MaxDepth, OwnerId, SubtreeEntry);
57291116Smsmith    AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
57367754Smsmith}
57467754Smsmith
57567754Smsmith
57667754Smsmith/*******************************************************************************
57767754Smsmith *
57867754Smsmith * FUNCTION:    AcpiDbSendNotify
57967754Smsmith *
58067754Smsmith * PARAMETERS:  Name            - Name of ACPI object to send the notify to
58167754Smsmith *              Value           - Value of the notify to send.
58267754Smsmith *
58367754Smsmith * RETURN:      None
58467754Smsmith *
58567754Smsmith * DESCRIPTION: Send an ACPI notification.  The value specified is sent to the
58667754Smsmith *              named object as an ACPI notify.
58767754Smsmith *
58867754Smsmith ******************************************************************************/
58967754Smsmith
59067754Smsmithvoid
59167754SmsmithAcpiDbSendNotify (
592114237Snjl    char                    *Name,
59367754Smsmith    UINT32                  Value)
59467754Smsmith{
59567754Smsmith    ACPI_NAMESPACE_NODE     *Node;
59699679Siwasaki    ACPI_STATUS             Status;
59767754Smsmith
59867754Smsmith
59967754Smsmith    /* Translate name to an Named object */
60067754Smsmith
60167754Smsmith    Node = AcpiDbLocalNsLookup (Name);
60267754Smsmith    if (!Node)
60367754Smsmith    {
60467754Smsmith        return;
60567754Smsmith    }
60667754Smsmith
60767754Smsmith    /* Decode Named object type */
60867754Smsmith
60967754Smsmith    switch (Node->Type)
61067754Smsmith    {
61167754Smsmith    case ACPI_TYPE_DEVICE:
61267754Smsmith    case ACPI_TYPE_THERMAL:
61367754Smsmith
61467754Smsmith         /* Send the notify */
61567754Smsmith
61699679Siwasaki        Status = AcpiEvQueueNotifyRequest (Node, Value);
61799679Siwasaki        if (ACPI_FAILURE (Status))
61899679Siwasaki        {
61999679Siwasaki            AcpiOsPrintf ("Could not queue notify\n");
62099679Siwasaki        }
62167754Smsmith        break;
62267754Smsmith
62367754Smsmith    default:
62467754Smsmith        AcpiOsPrintf ("Named object is not a device or a thermal object\n");
62567754Smsmith        break;
62667754Smsmith    }
62767754Smsmith
62867754Smsmith}
62967754Smsmith
63067754Smsmith
63167754Smsmith/*******************************************************************************
63267754Smsmith *
63367754Smsmith * FUNCTION:    AcpiDbSetMethodData
63467754Smsmith *
63567754Smsmith * PARAMETERS:  TypeArg         - L for local, A for argument
63667754Smsmith *              IndexArg        - which one
63767754Smsmith *              ValueArg        - Value to set.
63867754Smsmith *
63967754Smsmith * RETURN:      None
64067754Smsmith *
64167754Smsmith * DESCRIPTION: Set a local or argument for the running control method.
64267754Smsmith *              NOTE: only object supported is Number.
64367754Smsmith *
64467754Smsmith ******************************************************************************/
64567754Smsmith
64667754Smsmithvoid
64767754SmsmithAcpiDbSetMethodData (
648114237Snjl    char                    *TypeArg,
649114237Snjl    char                    *IndexArg,
650114237Snjl    char                    *ValueArg)
65167754Smsmith{
652114237Snjl    char                    Type;
65367754Smsmith    UINT32                  Index;
65467754Smsmith    UINT32                  Value;
65567754Smsmith    ACPI_WALK_STATE         *WalkState;
65667754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
65799679Siwasaki    ACPI_STATUS             Status;
65867754Smsmith
65967754Smsmith
66067754Smsmith    /* Validate TypeArg */
66167754Smsmith
66291116Smsmith    ACPI_STRUPR (TypeArg);
66367754Smsmith    Type = TypeArg[0];
66467754Smsmith    if ((Type != 'L') &&
66567754Smsmith        (Type != 'A'))
66667754Smsmith    {
66767754Smsmith        AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg);
66867754Smsmith        return;
66967754Smsmith    }
67067754Smsmith
67167754Smsmith    /* Get the index and value */
67267754Smsmith
67391116Smsmith    Index = ACPI_STRTOUL (IndexArg, NULL, 16);
67491116Smsmith    Value = ACPI_STRTOUL (ValueArg, NULL, 16);
67567754Smsmith
67667754Smsmith    WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
67767754Smsmith    if (!WalkState)
67867754Smsmith    {
67967754Smsmith        AcpiOsPrintf ("There is no method currently executing\n");
68067754Smsmith        return;
68167754Smsmith    }
68267754Smsmith
68367754Smsmith
68467754Smsmith    /* Create and initialize the new object */
68567754Smsmith
68677424Smsmith    ObjDesc = AcpiUtCreateInternalObject (ACPI_TYPE_INTEGER);
68767754Smsmith    if (!ObjDesc)
68867754Smsmith    {
68967754Smsmith        AcpiOsPrintf ("Could not create an internal object\n");
69067754Smsmith        return;
69167754Smsmith    }
69267754Smsmith
69371867Smsmith    ObjDesc->Integer.Value = Value;
69467754Smsmith
69567754Smsmith
69667754Smsmith    /* Store the new object into the target */
69767754Smsmith
69867754Smsmith    switch (Type)
69967754Smsmith    {
70067754Smsmith    case 'A':
70167754Smsmith
70267754Smsmith        /* Set a method argument */
70367754Smsmith
704114237Snjl        if (Index > ACPI_METHOD_MAX_ARG)
70567754Smsmith        {
70667754Smsmith            AcpiOsPrintf ("Arg%d - Invalid argument name\n", Index);
70767754Smsmith            return;
70867754Smsmith        }
70967754Smsmith
71099679Siwasaki        Status = AcpiDsStoreObjectToLocal (AML_ARG_OP, Index, ObjDesc, WalkState);
71199679Siwasaki        if (ACPI_FAILURE (Status))
71299679Siwasaki        {
71399679Siwasaki            return;
71499679Siwasaki        }
71599679Siwasaki
71667754Smsmith        ObjDesc = WalkState->Arguments[Index].Object;
71767754Smsmith
71867754Smsmith        AcpiOsPrintf ("Arg%d: ", Index);
71967754Smsmith        AcpiDbDisplayInternalObject (ObjDesc, WalkState);
72067754Smsmith        break;
72167754Smsmith
72267754Smsmith    case 'L':
72367754Smsmith
72467754Smsmith        /* Set a method local */
72567754Smsmith
726114237Snjl        if (Index > ACPI_METHOD_MAX_LOCAL)
72767754Smsmith        {
72867754Smsmith            AcpiOsPrintf ("Local%d - Invalid local variable name\n", Index);
72967754Smsmith            return;
73067754Smsmith        }
73167754Smsmith
73299679Siwasaki        Status = AcpiDsStoreObjectToLocal (AML_LOCAL_OP, Index, ObjDesc, WalkState);
73399679Siwasaki        if (ACPI_FAILURE (Status))
73499679Siwasaki        {
73599679Siwasaki            return;
73699679Siwasaki        }
73799679Siwasaki
73867754Smsmith        ObjDesc = WalkState->LocalVariables[Index].Object;
73967754Smsmith
74067754Smsmith        AcpiOsPrintf ("Local%d: ", Index);
74167754Smsmith        AcpiDbDisplayInternalObject (ObjDesc, WalkState);
74267754Smsmith        break;
74367754Smsmith
74467754Smsmith    default:
74567754Smsmith        break;
74667754Smsmith    }
74767754Smsmith}
74867754Smsmith
74967754Smsmith
75067754Smsmith/*******************************************************************************
75167754Smsmith *
75267754Smsmith * FUNCTION:    AcpiDbWalkForSpecificObjects
75367754Smsmith *
75467754Smsmith * PARAMETERS:  Callback from WalkNamespace
75567754Smsmith *
75667754Smsmith * RETURN:      Status
75767754Smsmith *
75867754Smsmith * DESCRIPTION: Display short info about objects in the namespace
75967754Smsmith *
76067754Smsmith ******************************************************************************/
76167754Smsmith
76267754SmsmithACPI_STATUS
76367754SmsmithAcpiDbWalkForSpecificObjects (
76467754Smsmith    ACPI_HANDLE             ObjHandle,
76567754Smsmith    UINT32                  NestingLevel,
76667754Smsmith    void                    *Context,
76767754Smsmith    void                    **ReturnValue)
76867754Smsmith{
76967754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
77067754Smsmith    ACPI_STATUS             Status;
77191116Smsmith    ACPI_BUFFER             Buffer;
77267754Smsmith
77367754Smsmith
77487031Smsmith    ObjDesc = AcpiNsGetAttachedObject ((ACPI_NAMESPACE_NODE *) ObjHandle);
77567754Smsmith
77667754Smsmith    /* Get and display the full pathname to this object */
77767754Smsmith
77891116Smsmith    Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
77991116Smsmith    Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
78067754Smsmith    if (ACPI_FAILURE (Status))
78167754Smsmith    {
78267754Smsmith        AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
78367754Smsmith        return (AE_OK);
78467754Smsmith    }
78567754Smsmith
786104470Siwasaki    AcpiOsPrintf ("%32s", (char *) Buffer.Pointer);
78791116Smsmith    ACPI_MEM_FREE (Buffer.Pointer);
78867754Smsmith
78967754Smsmith
79067754Smsmith    /* Display short information about the object */
79167754Smsmith
79267754Smsmith    if (ObjDesc)
79367754Smsmith    {
79499679Siwasaki        switch (ACPI_GET_OBJECT_TYPE (ObjDesc))
79567754Smsmith        {
79667754Smsmith        case ACPI_TYPE_METHOD:
797114237Snjl            AcpiOsPrintf ("  #Args %d  Concurrency %X",
798104470Siwasaki                    ObjDesc->Method.ParamCount, ObjDesc->Method.Concurrency);
79967754Smsmith            break;
80067754Smsmith
80171867Smsmith        case ACPI_TYPE_INTEGER:
802114237Snjl            AcpiOsPrintf ("  Value %8.8X%8.8X",
803104470Siwasaki                    ACPI_HIDWORD (ObjDesc->Integer.Value),
804104470Siwasaki                    ACPI_LODWORD (ObjDesc->Integer.Value));
80567754Smsmith            break;
80667754Smsmith
80767754Smsmith        case ACPI_TYPE_STRING:
80867754Smsmith            AcpiOsPrintf ("  \"%s\"", ObjDesc->String.Pointer);
80967754Smsmith            break;
81067754Smsmith
81167754Smsmith        case ACPI_TYPE_REGION:
812114237Snjl            AcpiOsPrintf ("  SpaceId %X Length %X Address %8.8X%8.8X",
813104470Siwasaki                    ObjDesc->Region.SpaceId,
814104470Siwasaki                    ObjDesc->Region.Length,
815104470Siwasaki                    ACPI_HIDWORD (ObjDesc->Region.Address),
816104470Siwasaki                    ACPI_LODWORD (ObjDesc->Region.Address));
81767754Smsmith            break;
81867754Smsmith
81967754Smsmith        case ACPI_TYPE_PACKAGE:
82069746Smsmith            AcpiOsPrintf ("  #Elements %X", ObjDesc->Package.Count);
82167754Smsmith            break;
82267754Smsmith
82367754Smsmith        case ACPI_TYPE_BUFFER:
82469746Smsmith            AcpiOsPrintf ("  Length %X", ObjDesc->Buffer.Length);
82567754Smsmith            break;
82699679Siwasaki
82799679Siwasaki        default:
82899679Siwasaki            /* Ignore other object types */
82999679Siwasaki            break;
83067754Smsmith        }
83167754Smsmith    }
83267754Smsmith
83367754Smsmith    AcpiOsPrintf ("\n");
83467754Smsmith    return (AE_OK);
83567754Smsmith}
83667754Smsmith
83767754Smsmith
83867754Smsmith/*******************************************************************************
83967754Smsmith *
84067754Smsmith * FUNCTION:    AcpiDbDisplayObjects
84167754Smsmith *
84267754Smsmith * PARAMETERS:  ObjTypeArg          - Type of object to display
84367754Smsmith *              DisplayCountArg     - Max depth to display
84467754Smsmith *
84567754Smsmith * RETURN:      None
84667754Smsmith *
84767754Smsmith * DESCRIPTION: Display objects in the namespace of the requested type
84867754Smsmith *
84967754Smsmith ******************************************************************************/
85067754Smsmith
85167754SmsmithACPI_STATUS
85267754SmsmithAcpiDbDisplayObjects (
853114237Snjl    char                    *ObjTypeArg,
854114237Snjl    char                    *DisplayCountArg)
85567754Smsmith{
85691116Smsmith    ACPI_OBJECT_TYPE        Type;
85767754Smsmith
85867754Smsmith
85967754Smsmith    /* Get the object type */
86067754Smsmith
86167754Smsmith    Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes);
86267754Smsmith    if (Type == ACPI_TYPE_NOT_FOUND)
86367754Smsmith    {
86467754Smsmith        AcpiOsPrintf ("Invalid or unsupported argument\n");
86567754Smsmith        return (AE_OK);
86667754Smsmith    }
86767754Smsmith
86891116Smsmith    AcpiDbSetOutputDestination (ACPI_DB_DUPLICATE_OUTPUT);
869102550Siwasaki    AcpiOsPrintf ("Objects of type [%s] defined in the current ACPI Namespace: \n",
87099679Siwasaki        AcpiUtGetTypeName (Type));
87167754Smsmith
87291116Smsmith    AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
87367754Smsmith
87467754Smsmith    /* Walk the namespace from the root */
87567754Smsmith
87699679Siwasaki    (void) AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
87767754Smsmith                        AcpiDbWalkForSpecificObjects, (void *) &Type, NULL);
87867754Smsmith
87991116Smsmith    AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
88067754Smsmith    return (AE_OK);
88167754Smsmith}
88267754Smsmith
88367754Smsmith
88467754Smsmith/*******************************************************************************
88567754Smsmith *
88667754Smsmith * FUNCTION:    AcpiDbWalkAndMatchName
88767754Smsmith *
88867754Smsmith * PARAMETERS:  Callback from WalkNamespace
88967754Smsmith *
89067754Smsmith * RETURN:      Status
89167754Smsmith *
89267754Smsmith * DESCRIPTION: Find a particular name/names within the namespace.  Wildcards
89367754Smsmith *              are supported -- '?' matches any character.
89467754Smsmith *
89567754Smsmith ******************************************************************************/
89667754Smsmith
89767754SmsmithACPI_STATUS
89867754SmsmithAcpiDbWalkAndMatchName (
89967754Smsmith    ACPI_HANDLE             ObjHandle,
90067754Smsmith    UINT32                  NestingLevel,
90167754Smsmith    void                    *Context,
90267754Smsmith    void                    **ReturnValue)
90367754Smsmith{
90467754Smsmith    ACPI_STATUS             Status;
905114237Snjl    char                    *RequestedName = (char *) Context;
90667754Smsmith    UINT32                  i;
90791116Smsmith    ACPI_BUFFER             Buffer;
90867754Smsmith
90967754Smsmith
91067754Smsmith    /* Check for a name match */
91167754Smsmith
91267754Smsmith    for (i = 0; i < 4; i++)
91367754Smsmith    {
91467754Smsmith        /* Wildcard support */
91567754Smsmith
91667754Smsmith        if ((RequestedName[i] != '?') &&
91799679Siwasaki            (RequestedName[i] != ((ACPI_NAMESPACE_NODE *) ObjHandle)->Name.Ascii[i]))
91867754Smsmith        {
91967754Smsmith            /* No match, just exit */
92067754Smsmith
92167754Smsmith            return (AE_OK);
92267754Smsmith        }
92367754Smsmith    }
92467754Smsmith
92567754Smsmith
92667754Smsmith    /* Get the full pathname to this object */
92767754Smsmith
92891116Smsmith    Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
92991116Smsmith    Status = AcpiNsHandleToPathname (ObjHandle, &Buffer);
93067754Smsmith    if (ACPI_FAILURE (Status))
93167754Smsmith    {
93267754Smsmith        AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
93367754Smsmith    }
93467754Smsmith    else
93567754Smsmith    {
936104470Siwasaki        AcpiOsPrintf ("%32s (%p) - %s\n", (char *) Buffer.Pointer, ObjHandle,
93777424Smsmith            AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) ObjHandle)->Type));
93891116Smsmith        ACPI_MEM_FREE (Buffer.Pointer);
93967754Smsmith    }
94067754Smsmith
94167754Smsmith    return (AE_OK);
94267754Smsmith}
94367754Smsmith
94467754Smsmith
94567754Smsmith/*******************************************************************************
94667754Smsmith *
94767754Smsmith * FUNCTION:    AcpiDbFindNameInNamespace
94867754Smsmith *
94967754Smsmith * PARAMETERS:  NameArg         - The 4-character ACPI name to find.
95067754Smsmith *                                wildcards are supported.
95167754Smsmith *
95267754Smsmith * RETURN:      None
95367754Smsmith *
95467754Smsmith * DESCRIPTION: Search the namespace for a given name (with wildcards)
95567754Smsmith *
95667754Smsmith ******************************************************************************/
95767754Smsmith
95867754SmsmithACPI_STATUS
95967754SmsmithAcpiDbFindNameInNamespace (
960114237Snjl    char                    *NameArg)
96167754Smsmith{
96267754Smsmith
96391116Smsmith    if (ACPI_STRLEN (NameArg) > 4)
96467754Smsmith    {
96567754Smsmith        AcpiOsPrintf ("Name must be no longer than 4 characters\n");
96667754Smsmith        return (AE_OK);
96767754Smsmith    }
96867754Smsmith
96967754Smsmith    /* Walk the namespace from the root */
97067754Smsmith
97199679Siwasaki    (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
97267754Smsmith                        AcpiDbWalkAndMatchName, NameArg, NULL);
97367754Smsmith
97491116Smsmith    AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
97567754Smsmith    return (AE_OK);
97667754Smsmith}
97767754Smsmith
97867754Smsmith
97967754Smsmith/*******************************************************************************
98067754Smsmith *
98167754Smsmith * FUNCTION:    AcpiDbSetScope
98267754Smsmith *
98367754Smsmith * PARAMETERS:  Name                - New scope path
98467754Smsmith *
98567754Smsmith * RETURN:      Status
98667754Smsmith *
98767754Smsmith * DESCRIPTION: Set the "current scope" as maintained by this utility.
98867754Smsmith *              The scope is used as a prefix to ACPI paths.
98967754Smsmith *
99067754Smsmith ******************************************************************************/
99167754Smsmith
99267754Smsmithvoid
99367754SmsmithAcpiDbSetScope (
994114237Snjl    char                    *Name)
99567754Smsmith{
99691116Smsmith    ACPI_STATUS             Status;
99791116Smsmith    ACPI_NAMESPACE_NODE     *Node;
99867754Smsmith
99991116Smsmith
100067754Smsmith    if (!Name || Name[0] == 0)
100167754Smsmith    {
100283174Smsmith        AcpiOsPrintf ("Current scope: %s\n", AcpiGbl_DbScopeBuf);
100367754Smsmith        return;
100467754Smsmith    }
100567754Smsmith
100667754Smsmith    AcpiDbPrepNamestring (Name);
100767754Smsmith
100867754Smsmith
100967754Smsmith    if (Name[0] == '\\')
101067754Smsmith    {
101191116Smsmith        /* Validate new scope from the root */
101291116Smsmith
101391116Smsmith        Status = AcpiNsGetNodeByPath (Name, AcpiGbl_RootNode, ACPI_NS_NO_UPSEARCH, &Node);
101491116Smsmith        if (ACPI_FAILURE (Status))
101591116Smsmith        {
101691116Smsmith            goto ErrorExit;
101791116Smsmith        }
101891116Smsmith
101991116Smsmith        ACPI_STRCPY (AcpiGbl_DbScopeBuf, Name);
102091116Smsmith        ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
102167754Smsmith    }
102267754Smsmith    else
102367754Smsmith    {
102491116Smsmith        /* Validate new scope relative to old scope */
102591116Smsmith
102691116Smsmith        Status = AcpiNsGetNodeByPath (Name, AcpiGbl_DbScopeNode, ACPI_NS_NO_UPSEARCH, &Node);
102791116Smsmith        if (ACPI_FAILURE (Status))
102891116Smsmith        {
102991116Smsmith            goto ErrorExit;
103091116Smsmith        }
103191116Smsmith
103291116Smsmith        ACPI_STRCAT (AcpiGbl_DbScopeBuf, Name);
103391116Smsmith        ACPI_STRCAT (AcpiGbl_DbScopeBuf, "\\");
103467754Smsmith    }
103567754Smsmith
103691116Smsmith    AcpiGbl_DbScopeNode = Node;
103783174Smsmith    AcpiOsPrintf ("New scope: %s\n", AcpiGbl_DbScopeBuf);
103891116Smsmith    return;
103991116Smsmith
104091116Smsmith
104191116SmsmithErrorExit:
104291116Smsmith
104391116Smsmith    AcpiOsPrintf ("Could not attach scope: %s, %s\n", Name, AcpiFormatException (Status));
104467754Smsmith}
104567754Smsmith
104673561Smsmith
104773561Smsmith/*******************************************************************************
104873561Smsmith *
104973561Smsmith * FUNCTION:    AcpiDbDisplayResources
105073561Smsmith *
105173561Smsmith * PARAMETERS:  ObjectArg       - String with hex value of the object
105273561Smsmith *
105373561Smsmith * RETURN:      None
105473561Smsmith *
1055107325Siwasaki * DESCRIPTION: Display the resource objects associated with a device.
105673561Smsmith *
105773561Smsmith ******************************************************************************/
105873561Smsmith
105973561Smsmithvoid
106073561SmsmithAcpiDbDisplayResources (
1061114237Snjl    char                    *ObjectArg)
106273561Smsmith{
106399679Siwasaki#if ACPI_MACHINE_WIDTH != 16
106499679Siwasaki
106573561Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
106673561Smsmith    ACPI_STATUS             Status;
106773561Smsmith    ACPI_BUFFER             ReturnObj;
106873561Smsmith
106973561Smsmith
107091116Smsmith    AcpiDbSetOutputDestination (ACPI_DB_REDIRECTABLE_OUTPUT);
107191116Smsmith    AcpiDbgLevel |= ACPI_LV_RESOURCES;
107273561Smsmith
107373561Smsmith    /* Convert string to object pointer */
107473561Smsmith
107591116Smsmith    ObjDesc = ACPI_TO_POINTER (ACPI_STRTOUL (ObjectArg, NULL, 16));
107673561Smsmith
107773561Smsmith    /* Prepare for a return object of arbitrary size */
107873561Smsmith
107983174Smsmith    ReturnObj.Pointer           = AcpiGbl_DbBuffer;
108083174Smsmith    ReturnObj.Length            = ACPI_DEBUG_BUFFER_SIZE;
108173561Smsmith
108277424Smsmith    /* _PRT */
108377424Smsmith
108477424Smsmith    AcpiOsPrintf ("Evaluating _PRT\n");
108577424Smsmith
108673561Smsmith    Status = AcpiEvaluateObject (ObjDesc, "_PRT", NULL, &ReturnObj);
108773561Smsmith    if (ACPI_FAILURE (Status))
108873561Smsmith    {
108980062Smsmith        AcpiOsPrintf ("Could not obtain _PRT: %s\n", AcpiFormatException (Status));
109083174Smsmith        goto GetCrs;
109173561Smsmith    }
109273561Smsmith
109383174Smsmith    ReturnObj.Pointer           = AcpiGbl_DbBuffer;
109483174Smsmith    ReturnObj.Length            = ACPI_DEBUG_BUFFER_SIZE;
109573561Smsmith
109673561Smsmith    Status = AcpiGetIrqRoutingTable (ObjDesc, &ReturnObj);
109773561Smsmith    if (ACPI_FAILURE (Status))
109873561Smsmith    {
109980062Smsmith        AcpiOsPrintf ("GetIrqRoutingTable failed: %s\n", AcpiFormatException (Status));
110077424Smsmith    }
110177424Smsmith
110283174Smsmith    else
110383174Smsmith    {
110483174Smsmith        AcpiRsDumpIrqList ((UINT8 *) AcpiGbl_DbBuffer);
110583174Smsmith    }
110677424Smsmith
110777424Smsmith
110877424Smsmith    /* _CRS */
110983174Smsmith
111083174SmsmithGetCrs:
111177424Smsmith    AcpiOsPrintf ("Evaluating _CRS\n");
111277424Smsmith
111383174Smsmith    ReturnObj.Pointer           = AcpiGbl_DbBuffer;
111483174Smsmith    ReturnObj.Length            = ACPI_DEBUG_BUFFER_SIZE;
111577424Smsmith
111677424Smsmith    Status = AcpiEvaluateObject (ObjDesc, "_CRS", NULL, &ReturnObj);
111777424Smsmith    if (ACPI_FAILURE (Status))
111877424Smsmith    {
111980062Smsmith        AcpiOsPrintf ("Could not obtain _CRS: %s\n", AcpiFormatException (Status));
112083174Smsmith        goto GetPrs;
112177424Smsmith    }
112277424Smsmith
112383174Smsmith    ReturnObj.Pointer           = AcpiGbl_DbBuffer;
112483174Smsmith    ReturnObj.Length            = ACPI_DEBUG_BUFFER_SIZE;
112577424Smsmith
112677424Smsmith    Status = AcpiGetCurrentResources (ObjDesc, &ReturnObj);
112777424Smsmith    if (ACPI_FAILURE (Status))
112877424Smsmith    {
112980062Smsmith        AcpiOsPrintf ("AcpiGetCurrentResources failed: %s\n", AcpiFormatException (Status));
113091116Smsmith        goto GetPrs;
113177424Smsmith    }
113277424Smsmith
113383174Smsmith    else
113483174Smsmith    {
113599679Siwasaki        AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer));
113683174Smsmith    }
113777424Smsmith
113891116Smsmith    Status = AcpiSetCurrentResources (ObjDesc, &ReturnObj);
113991116Smsmith    if (ACPI_FAILURE (Status))
114091116Smsmith    {
114191116Smsmith        AcpiOsPrintf ("AcpiSetCurrentResources failed: %s\n", AcpiFormatException (Status));
114291116Smsmith        goto GetPrs;
114391116Smsmith    }
114483174Smsmith
114591116Smsmith
114677424Smsmith    /* _PRS */
114783174Smsmith
114883174SmsmithGetPrs:
114977424Smsmith    AcpiOsPrintf ("Evaluating _PRS\n");
115077424Smsmith
115183174Smsmith    ReturnObj.Pointer           = AcpiGbl_DbBuffer;
115283174Smsmith    ReturnObj.Length            = ACPI_DEBUG_BUFFER_SIZE;
115377424Smsmith
115477424Smsmith    Status = AcpiEvaluateObject (ObjDesc, "_PRS", NULL, &ReturnObj);
115577424Smsmith    if (ACPI_FAILURE (Status))
115677424Smsmith    {
115780062Smsmith        AcpiOsPrintf ("Could not obtain _PRS: %s\n", AcpiFormatException (Status));
115873561Smsmith        goto Cleanup;
115973561Smsmith    }
116073561Smsmith
116183174Smsmith    ReturnObj.Pointer           = AcpiGbl_DbBuffer;
116283174Smsmith    ReturnObj.Length            = ACPI_DEBUG_BUFFER_SIZE;
116377424Smsmith
116477424Smsmith    Status = AcpiGetPossibleResources (ObjDesc, &ReturnObj);
116577424Smsmith    if (ACPI_FAILURE (Status))
116673561Smsmith    {
116780062Smsmith        AcpiOsPrintf ("AcpiGetPossibleResources failed: %s\n", AcpiFormatException (Status));
116873561Smsmith    }
116973561Smsmith
117083174Smsmith    else
117183174Smsmith    {
117299679Siwasaki        AcpiRsDumpResourceList (ACPI_CAST_PTR (ACPI_RESOURCE, AcpiGbl_DbBuffer));
117383174Smsmith    }
117477424Smsmith
117577424Smsmith
117673561SmsmithCleanup:
117773561Smsmith
117891116Smsmith    AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
117973561Smsmith    return;
118077424Smsmith#endif
118173561Smsmith
118273561Smsmith}
118373561Smsmith
118473561Smsmith
118599679Siwasaki/*******************************************************************************
118699679Siwasaki *
118799679Siwasaki * FUNCTION:    AcpiDbIntegrityWalk
118899679Siwasaki *
118999679Siwasaki * PARAMETERS:  Callback from WalkNamespace
119099679Siwasaki *
119199679Siwasaki * RETURN:      Status
119299679Siwasaki *
119399679Siwasaki * DESCRIPTION: Examine one NS node for valid values.
119499679Siwasaki *
119599679Siwasaki ******************************************************************************/
119699679Siwasaki
119799679SiwasakiACPI_STATUS
119899679SiwasakiAcpiDbIntegrityWalk (
119999679Siwasaki    ACPI_HANDLE             ObjHandle,
120099679Siwasaki    UINT32                  NestingLevel,
120199679Siwasaki    void                    *Context,
120299679Siwasaki    void                    **ReturnValue)
120399679Siwasaki{
120499679Siwasaki    ACPI_INTEGRITY_INFO     *Info = (ACPI_INTEGRITY_INFO *) Context;
120599679Siwasaki    ACPI_NAMESPACE_NODE     *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
120699679Siwasaki    ACPI_OPERAND_OBJECT     *Object;
120799679Siwasaki
120899679Siwasaki
120999679Siwasaki    Info->Nodes++;
121099679Siwasaki    if (ACPI_GET_DESCRIPTOR_TYPE (Node) != ACPI_DESC_TYPE_NAMED)
121199679Siwasaki    {
121299679Siwasaki        AcpiOsPrintf ("Invalid Descriptor Type for Node %p, Type = %X\n",
121399679Siwasaki            Node, ACPI_GET_DESCRIPTOR_TYPE (Node));
121499679Siwasaki    }
121599679Siwasaki
1216107325Siwasaki    if (Node->Type > ACPI_TYPE_LOCAL_MAX)
121799679Siwasaki    {
121899679Siwasaki        AcpiOsPrintf ("Invalid Object Type for Node %p, Type = %X\n",
121999679Siwasaki            Node, Node->Type);
122099679Siwasaki    }
122199679Siwasaki
122299679Siwasaki    if (!AcpiUtValidAcpiName (Node->Name.Integer))
122399679Siwasaki    {
122499679Siwasaki        AcpiOsPrintf ("Invalid AcpiName for Node %p\n", Node);
122599679Siwasaki    }
122699679Siwasaki
122799679Siwasaki    Object = AcpiNsGetAttachedObject (Node);
122899679Siwasaki    if (Object)
122999679Siwasaki    {
123099679Siwasaki        Info->Objects++;
123199679Siwasaki        if (ACPI_GET_DESCRIPTOR_TYPE (Object) != ACPI_DESC_TYPE_OPERAND)
123299679Siwasaki        {
123399679Siwasaki            AcpiOsPrintf ("Invalid Descriptor Type for Object %p, Type = %X\n",
123499679Siwasaki                Object, ACPI_GET_DESCRIPTOR_TYPE (Object));
123599679Siwasaki        }
123699679Siwasaki    }
123799679Siwasaki
123899679Siwasaki
123999679Siwasaki    return (AE_OK);
124099679Siwasaki}
124199679Siwasaki
124299679Siwasaki
124399679Siwasaki/*******************************************************************************
124499679Siwasaki *
124599679Siwasaki * FUNCTION:    AcpiDbCheckIntegrity
124699679Siwasaki *
124799679Siwasaki * PARAMETERS:  None
124899679Siwasaki *
124999679Siwasaki * RETURN:      None
125099679Siwasaki *
125199679Siwasaki * DESCRIPTION: Check entire namespace for data structure integrity
125299679Siwasaki *
125399679Siwasaki ******************************************************************************/
125499679Siwasaki
125599679Siwasakivoid
125699679SiwasakiAcpiDbCheckIntegrity (void)
125799679Siwasaki{
125899679Siwasaki    ACPI_INTEGRITY_INFO     Info = {0,0};
125999679Siwasaki
126099679Siwasaki    /* Search all nodes in namespace */
126199679Siwasaki
126299679Siwasaki    (void) AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
126399679Siwasaki                    AcpiDbIntegrityWalk, (void *) &Info, NULL);
126499679Siwasaki
126599679Siwasaki    AcpiOsPrintf ("Verified %d namespace nodes with %d Objects\n", Info.Nodes, Info.Objects);
126699679Siwasaki
126799679Siwasaki}
126899679Siwasaki
1269114237Snjl
1270114237Snjl/*******************************************************************************
1271114237Snjl *
1272114237Snjl * FUNCTION:    AcpiDbGenerateGpe
1273114237Snjl *
1274114237Snjl * PARAMETERS:  None
1275114237Snjl *
1276114237Snjl * RETURN:      None
1277114237Snjl *
1278114237Snjl * DESCRIPTION: Generate a GPE
1279114237Snjl *
1280114237Snjl ******************************************************************************/
1281114237Snjl
1282114237Snjlvoid
1283114237SnjlAcpiDbGenerateGpe (
1284114237Snjl    char                    *GpeArg,
1285114237Snjl    char                    *BlockArg)
1286114237Snjl{
1287114237Snjl    UINT32                  BlockNumber;
1288114237Snjl    UINT32                  GpeNumber;
1289114237Snjl    ACPI_GPE_EVENT_INFO     *GpeEventInfo;
1290114237Snjl
1291114237Snjl
1292114237Snjl    GpeNumber   = ACPI_STRTOUL (GpeArg, NULL, 10);
1293114237Snjl    BlockNumber = ACPI_STRTOUL (BlockArg, NULL, 10);
1294114237Snjl
1295114237Snjl
1296114237Snjl    GpeEventInfo = AcpiEvGetGpeEventInfo (GpeNumber);
1297114237Snjl    if (!GpeEventInfo)
1298114237Snjl    {
1299114237Snjl        AcpiOsPrintf ("Invalid GPE\n");
1300114237Snjl        return;
1301114237Snjl    }
1302114237Snjl
1303114237Snjl    AcpiEvGpeDispatch (GpeEventInfo);
1304114237Snjl
1305114237Snjl}
1306114237Snjl
1307102550Siwasaki#endif /* ACPI_DEBUGGER */
1308