dbcmds.c revision 71867
167754Smsmith/*******************************************************************************
267754Smsmith *
367754Smsmith * Module Name: dbcmds - debug commands and output routines
471867Smsmith *              $Revision: 45 $
567754Smsmith *
667754Smsmith ******************************************************************************/
767754Smsmith
867754Smsmith/******************************************************************************
967754Smsmith *
1067754Smsmith * 1. Copyright Notice
1167754Smsmith *
1271867Smsmith * Some or all of this work - Copyright (c) 1999, 2000, 2001, 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 "acparser.h"
12067754Smsmith#include "acdispat.h"
12167754Smsmith#include "amlcode.h"
12267754Smsmith#include "acnamesp.h"
12367754Smsmith#include "acparser.h"
12467754Smsmith#include "acevents.h"
12567754Smsmith#include "acinterp.h"
12667754Smsmith#include "acdebug.h"
12767754Smsmith#include "actables.h"
12867754Smsmith
12967754Smsmith#ifdef ENABLE_DEBUGGER
13067754Smsmith
13167754Smsmith#define _COMPONENT          DEBUGGER
13267754Smsmith        MODULE_NAME         ("dbcmds")
13367754Smsmith
13467754Smsmith
13567754Smsmith/*
13667754Smsmith * Arguments for the Objects command
13767754Smsmith * These object types map directly to the ACPI_TYPES
13867754Smsmith */
13967754Smsmith
14067754SmsmithARGUMENT_INFO               AcpiDbObjectTypes [] =
14167754Smsmith{
14267754Smsmith    {"ANY"},
14367754Smsmith    {"NUMBERS"},
14467754Smsmith    {"STRINGS"},
14567754Smsmith    {"BUFFERS"},
14667754Smsmith    {"PACKAGES"},
14767754Smsmith    {"FIELDS"},
14867754Smsmith    {"DEVICES"},
14967754Smsmith    {"EVENTS"},
15067754Smsmith    {"METHODS"},
15167754Smsmith    {"MUTEXES"},
15267754Smsmith    {"REGIONS"},
15367754Smsmith    {"POWERRESOURCES"},
15467754Smsmith    {"PROCESSORS"},
15567754Smsmith    {"THERMALZONES"},
15667754Smsmith    {"BUFFERFIELDS"},
15767754Smsmith    {"DDBHANDLES"},
15867754Smsmith    {NULL}           /* Must be null terminated */
15967754Smsmith};
16067754Smsmith
16167754Smsmith
16267754Smsmith/*******************************************************************************
16367754Smsmith *
16467754Smsmith * FUNCTION:    AcpiDbWalkForReferences
16567754Smsmith *
16667754Smsmith * PARAMETERS:  Callback from WalkNamespace
16767754Smsmith *
16867754Smsmith * RETURN:      Status
16967754Smsmith *
17067754Smsmith * DESCRIPTION: Check if this namespace object refers to the target object
17167754Smsmith *              that is passed in as the context value.
17267754Smsmith *
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    {
19067754Smsmith        AcpiOsPrintf ("Object is a Node [%4.4s]\n", &Node->Name);
19167754Smsmith    }
19267754Smsmith
19367754Smsmith    /* Check for match against the object attached to the node */
19467754Smsmith
19567754Smsmith    if (Node->Object == ObjDesc)
19667754Smsmith    {
19767754Smsmith        AcpiOsPrintf ("Reference at Node->Object %p [%4.4s]\n", Node, &Node->Name);
19867754Smsmith    }
19967754Smsmith
20067754Smsmith    /* Check first child for a match */
20167754Smsmith    /* TBD: [Investigate] probably now obsolete with new datastructure */
20267754Smsmith
20367754Smsmith    if (Node->Child == (void *) ObjDesc)
20467754Smsmith    {
20567754Smsmith        AcpiOsPrintf ("Reference at Node->Child %p [%4.4s]\n", Node, &Node->Name);
20667754Smsmith    }
20767754Smsmith
20867754Smsmith    return (AE_OK);
20967754Smsmith}
21067754Smsmith
21167754Smsmith
21267754Smsmith/*******************************************************************************
21367754Smsmith *
21467754Smsmith * FUNCTION:    AcpiDbFindReferences
21567754Smsmith *
21667754Smsmith * PARAMETERS:  ObjectArg       - String with hex value of the object
21767754Smsmith *
21867754Smsmith * RETURN:      None
21967754Smsmith *
22067754Smsmith * DESCRIPTION: Search namespace for all references to the input object
22167754Smsmith *
22267754Smsmith ******************************************************************************/
22367754Smsmith
22467754Smsmithvoid
22567754SmsmithAcpiDbFindReferences (
22667754Smsmith    NATIVE_CHAR             *ObjectArg)
22767754Smsmith{
22867754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
22967754Smsmith
23067754Smsmith
23167754Smsmith    /* Convert string to object pointer */
23267754Smsmith
23367754Smsmith    ObjDesc = (ACPI_OPERAND_OBJECT  *) STRTOUL (ObjectArg, NULL, 16);
23467754Smsmith
23567754Smsmith    /* Search all nodes in namespace */
23667754Smsmith
23767754Smsmith    AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
23867754Smsmith                    AcpiDbWalkForReferences, (void *) ObjDesc, NULL);
23967754Smsmith}
24067754Smsmith
24167754Smsmith
24267754Smsmith/*******************************************************************************
24367754Smsmith *
24467754Smsmith * FUNCTION:    AcpiDbDisplayTableInfo
24567754Smsmith *
24667754Smsmith * PARAMETERS:  TableArg        - String with name of table to be displayed
24767754Smsmith *
24867754Smsmith * RETURN:      None
24967754Smsmith *
25067754Smsmith * DESCRIPTION: Display information about loaded tables.  Current
25167754Smsmith *              implementation displays all loaded tables.
25267754Smsmith *
25367754Smsmith ******************************************************************************/
25467754Smsmith
25567754Smsmithvoid
25667754SmsmithAcpiDbDisplayTableInfo (
25767754Smsmith    NATIVE_CHAR             *TableArg)
25867754Smsmith{
25967754Smsmith    UINT32                  i;
26067754Smsmith
26167754Smsmith
26267754Smsmith    for (i = 0; i < NUM_ACPI_TABLES; i++)
26367754Smsmith    {
26467754Smsmith        if (AcpiGbl_AcpiTables[i].Pointer)
26567754Smsmith        {
26669746Smsmith            AcpiOsPrintf ("%s at %p length %X\n", AcpiGbl_AcpiTableData[i].Name,
26767754Smsmith                        AcpiGbl_AcpiTables[i].Pointer, AcpiGbl_AcpiTables[i].Length);
26867754Smsmith        }
26967754Smsmith    }
27067754Smsmith}
27167754Smsmith
27267754Smsmith
27367754Smsmith/*******************************************************************************
27467754Smsmith *
27567754Smsmith * FUNCTION:    AcpiDbUnloadAcpiTable
27667754Smsmith *
27767754Smsmith * PARAMETERS:  TableArg        - Name of the table to be unloaded
27867754Smsmith *              InstanceArg     - Which instance of the table to unload (if
27967754Smsmith *                                there are multiple tables of the same type)
28067754Smsmith *
28167754Smsmith * RETURN:      Nonde
28267754Smsmith *
28367754Smsmith * DESCRIPTION: Unload an ACPI table.
28467754Smsmith *              Instance is not implemented
28567754Smsmith *
28667754Smsmith ******************************************************************************/
28767754Smsmith
28867754Smsmithvoid
28967754SmsmithAcpiDbUnloadAcpiTable (
29067754Smsmith    NATIVE_CHAR             *TableArg,
29167754Smsmith    NATIVE_CHAR             *InstanceArg)
29267754Smsmith{
29367754Smsmith    UINT32                  i;
29467754Smsmith    ACPI_STATUS             Status;
29567754Smsmith
29667754Smsmith
29767754Smsmith    /* Search all tables for the target type */
29867754Smsmith
29967754Smsmith    for (i = 0; i < NUM_ACPI_TABLES; i++)
30067754Smsmith    {
30167754Smsmith        if (!STRNCMP (TableArg, AcpiGbl_AcpiTableData[i].Signature, AcpiGbl_AcpiTableData[i].SigLength))
30267754Smsmith        {
30367754Smsmith            /* Found the table, unload it */
30467754Smsmith
30567754Smsmith            Status = AcpiUnloadTable (i);
30667754Smsmith            if (ACPI_SUCCESS (Status))
30767754Smsmith            {
30867754Smsmith                AcpiOsPrintf ("[%s] unloaded and uninstalled\n", TableArg);
30967754Smsmith            }
31067754Smsmith            else
31167754Smsmith            {
31267754Smsmith                AcpiOsPrintf ("%s, while unloading [%s]\n", AcpiCmFormatException (Status), TableArg);
31367754Smsmith            }
31467754Smsmith
31567754Smsmith            return;
31667754Smsmith        }
31767754Smsmith    }
31867754Smsmith
31967754Smsmith    AcpiOsPrintf ("Unknown table type [%s]\n", TableArg);
32067754Smsmith}
32167754Smsmith
32267754Smsmith
32367754Smsmith/*******************************************************************************
32467754Smsmith *
32567754Smsmith * FUNCTION:    AcpiDbSetMethodBreakpoint
32667754Smsmith *
32767754Smsmith * PARAMETERS:  Location            - AML offset of breakpoint
32867754Smsmith *              WalkState           - Current walk info
32967754Smsmith *              Op                  - Current Op (from parse walk)
33067754Smsmith *
33167754Smsmith * RETURN:      None
33267754Smsmith *
33367754Smsmith * DESCRIPTION: Set a breakpoint in a control method at the specified
33467754Smsmith *              AML offset
33567754Smsmith *
33667754Smsmith ******************************************************************************/
33767754Smsmith
33867754Smsmithvoid
33967754SmsmithAcpiDbSetMethodBreakpoint (
34067754Smsmith    NATIVE_CHAR             *Location,
34167754Smsmith    ACPI_WALK_STATE         *WalkState,
34267754Smsmith    ACPI_PARSE_OBJECT       *Op)
34367754Smsmith{
34467754Smsmith    UINT32                  Address;
34567754Smsmith
34667754Smsmith
34767754Smsmith    if (!Op)
34867754Smsmith    {
34967754Smsmith        AcpiOsPrintf ("There is no method currently executing\n");
35067754Smsmith        return;
35167754Smsmith    }
35267754Smsmith
35367754Smsmith    /* Get and verify the breakpoint address */
35467754Smsmith
35567754Smsmith    Address = STRTOUL (Location, NULL, 16);
35667754Smsmith    if (Address <= Op->AmlOffset)
35767754Smsmith    {
35869746Smsmith        AcpiOsPrintf ("Breakpoint %X is beyond current address %X\n", Address, Op->AmlOffset);
35967754Smsmith    }
36067754Smsmith
36167754Smsmith    /* Save breakpoint in current walk */
36267754Smsmith
36367754Smsmith    WalkState->MethodBreakpoint = Address;
36469746Smsmith    AcpiOsPrintf ("Breakpoint set at AML offset %X\n", Address);
36567754Smsmith}
36667754Smsmith
36767754Smsmith
36867754Smsmith/*******************************************************************************
36967754Smsmith *
37067754Smsmith * FUNCTION:    AcpiDbSetMethodCallBreakpoint
37167754Smsmith *
37267754Smsmith * PARAMETERS:  Op                  - Current Op (from parse walk)
37367754Smsmith *
37467754Smsmith * RETURN:      None
37567754Smsmith *
37667754Smsmith * DESCRIPTION: Set a breakpoint in a control method at the specified
37767754Smsmith *              AML offset
37867754Smsmith *
37967754Smsmith ******************************************************************************/
38067754Smsmith
38167754Smsmithvoid
38267754SmsmithAcpiDbSetMethodCallBreakpoint (
38367754Smsmith    ACPI_PARSE_OBJECT       *Op)
38467754Smsmith{
38567754Smsmith
38667754Smsmith
38767754Smsmith    if (!Op)
38867754Smsmith    {
38967754Smsmith        AcpiOsPrintf ("There is no method currently executing\n");
39067754Smsmith        return;
39167754Smsmith    }
39267754Smsmith
39367754Smsmith
39467754Smsmith    AcpiGbl_StepToNextCall = TRUE;
39567754Smsmith}
39667754Smsmith
39767754Smsmith
39867754Smsmith/*******************************************************************************
39967754Smsmith *
40067754Smsmith * FUNCTION:    AcpiDbDisassembleAml
40167754Smsmith *
40267754Smsmith * PARAMETERS:  Statements          - Number of statements to disassemble
40367754Smsmith *              Op                  - Current Op (from parse walk)
40467754Smsmith *
40567754Smsmith * RETURN:      None
40667754Smsmith *
40767754Smsmith * DESCRIPTION: Display disassembled AML (ASL) starting from Op for the number
40867754Smsmith *              of statements specified.
40967754Smsmith *
41067754Smsmith ******************************************************************************/
41167754Smsmith
41267754Smsmithvoid
41367754SmsmithAcpiDbDisassembleAml (
41467754Smsmith    NATIVE_CHAR             *Statements,
41567754Smsmith    ACPI_PARSE_OBJECT       *Op)
41667754Smsmith{
41767754Smsmith    UINT32                  NumStatements = 8;
41867754Smsmith
41967754Smsmith
42067754Smsmith    if (!Op)
42167754Smsmith    {
42267754Smsmith        AcpiOsPrintf ("There is no method currently executing\n");
42367754Smsmith        return;
42467754Smsmith    }
42567754Smsmith
42667754Smsmith    if (Statements)
42767754Smsmith    {
42867754Smsmith        NumStatements = STRTOUL (Statements, NULL, 0);
42967754Smsmith    }
43067754Smsmith
43167754Smsmith
43267754Smsmith    AcpiDbDisplayOp (NULL, Op, NumStatements);
43367754Smsmith}
43467754Smsmith
43567754Smsmith
43667754Smsmith/*******************************************************************************
43767754Smsmith *
43867754Smsmith * FUNCTION:    AcpiDbDumpNamespace
43967754Smsmith *
44067754Smsmith * PARAMETERS:  StartArg        - Node to begin namespace dump
44167754Smsmith *              DepthArg        - Maximum tree depth to be dumped
44267754Smsmith *
44367754Smsmith * RETURN:      None
44467754Smsmith *
44567754Smsmith * DESCRIPTION: Dump entire namespace or a subtree.  Each node is displayed
44667754Smsmith *              with type and other information.
44767754Smsmith *
44867754Smsmith ******************************************************************************/
44967754Smsmith
45067754Smsmithvoid
45167754SmsmithAcpiDbDumpNamespace (
45267754Smsmith    NATIVE_CHAR             *StartArg,
45367754Smsmith    NATIVE_CHAR             *DepthArg)
45467754Smsmith{
45567754Smsmith    ACPI_HANDLE             SubtreeEntry = AcpiGbl_RootNode;
45667754Smsmith    UINT32                  MaxDepth = ACPI_UINT32_MAX;
45767754Smsmith
45867754Smsmith
45967754Smsmith    /* No argument given, just start at the root and dump entire namespace */
46067754Smsmith
46167754Smsmith    if (StartArg)
46267754Smsmith    {
46367754Smsmith        /* Check if numeric argument, must be a Node */
46467754Smsmith
46567754Smsmith        if ((StartArg[0] >= 0x30) && (StartArg[0] <= 0x39))
46667754Smsmith        {
46767754Smsmith            SubtreeEntry = (ACPI_HANDLE) STRTOUL (StartArg, NULL, 16);
46867754Smsmith            if (!AcpiOsReadable (SubtreeEntry, sizeof (ACPI_NAMESPACE_NODE)))
46967754Smsmith            {
47067754Smsmith                AcpiOsPrintf ("Address %p is invalid in this address space\n", SubtreeEntry);
47167754Smsmith                return;
47267754Smsmith            }
47367754Smsmith
47467754Smsmith            if (!VALID_DESCRIPTOR_TYPE ((SubtreeEntry), ACPI_DESC_TYPE_NAMED))
47567754Smsmith            {
47667754Smsmith                AcpiOsPrintf ("Address %p is not a valid Named object\n", SubtreeEntry);
47767754Smsmith                return;
47867754Smsmith            }
47967754Smsmith        }
48067754Smsmith
48167754Smsmith        /* Alpha argument */
48267754Smsmith
48367754Smsmith        else
48467754Smsmith        {
48567754Smsmith            /* The parameter is a name string that must be resolved to a Named obj*/
48667754Smsmith
48767754Smsmith            SubtreeEntry = AcpiDbLocalNsLookup (StartArg);
48867754Smsmith            if (!SubtreeEntry)
48967754Smsmith            {
49067754Smsmith                SubtreeEntry = AcpiGbl_RootNode;
49167754Smsmith            }
49267754Smsmith        }
49367754Smsmith
49467754Smsmith        /* Now we can check for the depth argument */
49567754Smsmith
49667754Smsmith        if (DepthArg)
49767754Smsmith        {
49867754Smsmith            MaxDepth = STRTOUL (DepthArg, NULL, 0);
49967754Smsmith        }
50067754Smsmith    }
50167754Smsmith
50267754Smsmith
50367754Smsmith    AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT);
50467754Smsmith    AcpiOsPrintf ("ACPI Namespace (from %p subtree):\n", SubtreeEntry);
50567754Smsmith
50667754Smsmith    /* Display the subtree */
50767754Smsmith
50867754Smsmith    AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT);
50967754Smsmith    AcpiNsDumpObjects (ACPI_TYPE_ANY, MaxDepth, ACPI_UINT32_MAX, SubtreeEntry);
51067754Smsmith    AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT);
51167754Smsmith}
51267754Smsmith
51367754Smsmith
51467754Smsmith/*******************************************************************************
51567754Smsmith *
51667754Smsmith * FUNCTION:    AcpiDbDumpNamespaceByOwner
51767754Smsmith *
51867754Smsmith * PARAMETERS:  OwnerArg        - Owner ID whose nodes will be displayed
51967754Smsmith *              DepthArg        - Maximum tree depth to be dumped
52067754Smsmith *
52167754Smsmith * RETURN:      None
52267754Smsmith *
52367754Smsmith * DESCRIPTION: Dump elements of the namespace that are owned by the OwnerId.
52467754Smsmith *
52567754Smsmith ******************************************************************************/
52667754Smsmith
52767754Smsmithvoid
52867754SmsmithAcpiDbDumpNamespaceByOwner (
52967754Smsmith    NATIVE_CHAR             *OwnerArg,
53067754Smsmith    NATIVE_CHAR             *DepthArg)
53167754Smsmith{
53267754Smsmith    ACPI_HANDLE             SubtreeEntry = AcpiGbl_RootNode;
53367754Smsmith    UINT32                  MaxDepth = ACPI_UINT32_MAX;
53467754Smsmith    UINT16                  OwnerId;
53567754Smsmith
53667754Smsmith
53767754Smsmith    OwnerId = (UINT16) STRTOUL (OwnerArg, NULL, 0);
53867754Smsmith
53967754Smsmith
54067754Smsmith    /* Now we can check for the depth argument */
54167754Smsmith
54267754Smsmith    if (DepthArg)
54367754Smsmith    {
54467754Smsmith        MaxDepth = STRTOUL (DepthArg, NULL, 0);
54567754Smsmith    }
54667754Smsmith
54767754Smsmith
54867754Smsmith    AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT);
54969746Smsmith    AcpiOsPrintf ("ACPI Namespace by owner %X:\n", OwnerId);
55067754Smsmith
55167754Smsmith    /* Display the subtree */
55267754Smsmith
55367754Smsmith    AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT);
55467754Smsmith    AcpiNsDumpObjects (ACPI_TYPE_ANY, MaxDepth, OwnerId, SubtreeEntry);
55567754Smsmith    AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT);
55667754Smsmith}
55767754Smsmith
55867754Smsmith
55967754Smsmith/*******************************************************************************
56067754Smsmith *
56167754Smsmith * FUNCTION:    AcpiDbSendNotify
56267754Smsmith *
56367754Smsmith * PARAMETERS:  Name            - Name of ACPI object to send the notify to
56467754Smsmith *              Value           - Value of the notify to send.
56567754Smsmith *
56667754Smsmith * RETURN:      None
56767754Smsmith *
56867754Smsmith * DESCRIPTION: Send an ACPI notification.  The value specified is sent to the
56967754Smsmith *              named object as an ACPI notify.
57067754Smsmith *
57167754Smsmith ******************************************************************************/
57267754Smsmith
57367754Smsmithvoid
57467754SmsmithAcpiDbSendNotify (
57567754Smsmith    NATIVE_CHAR             *Name,
57667754Smsmith    UINT32                  Value)
57767754Smsmith{
57867754Smsmith    ACPI_NAMESPACE_NODE     *Node;
57967754Smsmith
58067754Smsmith
58167754Smsmith    /* Translate name to an Named object */
58267754Smsmith
58367754Smsmith    Node = AcpiDbLocalNsLookup (Name);
58467754Smsmith    if (!Node)
58567754Smsmith    {
58667754Smsmith        return;
58767754Smsmith    }
58867754Smsmith
58967754Smsmith    /* Decode Named object type */
59067754Smsmith
59167754Smsmith    switch (Node->Type)
59267754Smsmith    {
59367754Smsmith    case ACPI_TYPE_DEVICE:
59467754Smsmith    case ACPI_TYPE_THERMAL:
59567754Smsmith
59667754Smsmith         /* Send the notify */
59767754Smsmith
59867754Smsmith        AcpiEvNotifyDispatch (Node, Value);
59967754Smsmith        break;
60067754Smsmith
60167754Smsmith    default:
60267754Smsmith        AcpiOsPrintf ("Named object is not a device or a thermal object\n");
60367754Smsmith        break;
60467754Smsmith    }
60567754Smsmith
60667754Smsmith}
60767754Smsmith
60867754Smsmith
60967754Smsmith/*******************************************************************************
61067754Smsmith *
61167754Smsmith * FUNCTION:    AcpiDbSetMethodData
61267754Smsmith *
61367754Smsmith * PARAMETERS:  TypeArg         - L for local, A for argument
61467754Smsmith *              IndexArg        - which one
61567754Smsmith *              ValueArg        - Value to set.
61667754Smsmith *
61767754Smsmith * RETURN:      None
61867754Smsmith *
61967754Smsmith * DESCRIPTION: Set a local or argument for the running control method.
62067754Smsmith *              NOTE: only object supported is Number.
62167754Smsmith *
62267754Smsmith ******************************************************************************/
62367754Smsmith
62467754Smsmithvoid
62567754SmsmithAcpiDbSetMethodData (
62667754Smsmith    NATIVE_CHAR             *TypeArg,
62767754Smsmith    NATIVE_CHAR             *IndexArg,
62867754Smsmith    NATIVE_CHAR             *ValueArg)
62967754Smsmith{
63067754Smsmith    NATIVE_CHAR             Type;
63167754Smsmith    UINT32                  Index;
63267754Smsmith    UINT32                  Value;
63367754Smsmith    ACPI_WALK_STATE         *WalkState;
63467754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
63567754Smsmith
63667754Smsmith
63767754Smsmith    /* Validate TypeArg */
63867754Smsmith
63967754Smsmith    STRUPR (TypeArg);
64067754Smsmith    Type = TypeArg[0];
64167754Smsmith    if ((Type != 'L') &&
64267754Smsmith        (Type != 'A'))
64367754Smsmith    {
64467754Smsmith        AcpiOsPrintf ("Invalid SET operand: %s\n", TypeArg);
64567754Smsmith        return;
64667754Smsmith    }
64767754Smsmith
64867754Smsmith    /* Get the index and value */
64967754Smsmith
65067754Smsmith    Index = STRTOUL (IndexArg, NULL, 16);
65167754Smsmith    Value = STRTOUL (ValueArg, NULL, 16);
65267754Smsmith
65367754Smsmith    WalkState = AcpiDsGetCurrentWalkState (AcpiGbl_CurrentWalkList);
65467754Smsmith    if (!WalkState)
65567754Smsmith    {
65667754Smsmith        AcpiOsPrintf ("There is no method currently executing\n");
65767754Smsmith        return;
65867754Smsmith    }
65967754Smsmith
66067754Smsmith
66167754Smsmith    /* Create and initialize the new object */
66267754Smsmith
66371867Smsmith    ObjDesc = AcpiCmCreateInternalObject (ACPI_TYPE_INTEGER);
66467754Smsmith    if (!ObjDesc)
66567754Smsmith    {
66667754Smsmith        AcpiOsPrintf ("Could not create an internal object\n");
66767754Smsmith        return;
66867754Smsmith    }
66967754Smsmith
67071867Smsmith    ObjDesc->Integer.Value = Value;
67167754Smsmith
67267754Smsmith
67367754Smsmith    /* Store the new object into the target */
67467754Smsmith
67567754Smsmith    switch (Type)
67667754Smsmith    {
67767754Smsmith    case 'A':
67867754Smsmith
67967754Smsmith        /* Set a method argument */
68067754Smsmith
68167754Smsmith        if (Index > MTH_NUM_ARGS)
68267754Smsmith        {
68367754Smsmith            AcpiOsPrintf ("Arg%d - Invalid argument name\n", Index);
68467754Smsmith            return;
68567754Smsmith        }
68667754Smsmith
68767754Smsmith        AcpiDsMethodDataSetValue (MTH_TYPE_ARG, Index, ObjDesc, WalkState);
68867754Smsmith        ObjDesc = WalkState->Arguments[Index].Object;
68967754Smsmith
69067754Smsmith        AcpiOsPrintf ("Arg%d: ", Index);
69167754Smsmith        AcpiDbDisplayInternalObject (ObjDesc, WalkState);
69267754Smsmith        break;
69367754Smsmith
69467754Smsmith    case 'L':
69567754Smsmith
69667754Smsmith        /* Set a method local */
69767754Smsmith
69867754Smsmith        if (Index > MTH_NUM_LOCALS)
69967754Smsmith        {
70067754Smsmith            AcpiOsPrintf ("Local%d - Invalid local variable name\n", Index);
70167754Smsmith            return;
70267754Smsmith        }
70367754Smsmith
70467754Smsmith        AcpiDsMethodDataSetValue (MTH_TYPE_LOCAL, Index, ObjDesc, WalkState);
70567754Smsmith        ObjDesc = WalkState->LocalVariables[Index].Object;
70667754Smsmith
70767754Smsmith        AcpiOsPrintf ("Local%d: ", Index);
70867754Smsmith        AcpiDbDisplayInternalObject (ObjDesc, WalkState);
70967754Smsmith        break;
71067754Smsmith
71167754Smsmith    default:
71267754Smsmith        break;
71367754Smsmith    }
71467754Smsmith}
71567754Smsmith
71667754Smsmith
71767754Smsmith/*******************************************************************************
71867754Smsmith *
71967754Smsmith * FUNCTION:    AcpiDbWalkForSpecificObjects
72067754Smsmith *
72167754Smsmith * PARAMETERS:  Callback from WalkNamespace
72267754Smsmith *
72367754Smsmith * RETURN:      Status
72467754Smsmith *
72567754Smsmith * DESCRIPTION: Display short info about objects in the namespace
72667754Smsmith *
72767754Smsmith ******************************************************************************/
72867754Smsmith
72967754SmsmithACPI_STATUS
73067754SmsmithAcpiDbWalkForSpecificObjects (
73167754Smsmith    ACPI_HANDLE             ObjHandle,
73267754Smsmith    UINT32                  NestingLevel,
73367754Smsmith    void                    *Context,
73467754Smsmith    void                    **ReturnValue)
73567754Smsmith{
73667754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
73767754Smsmith    ACPI_STATUS             Status;
73867754Smsmith    UINT32                  BufSize;
73971867Smsmith    NATIVE_CHAR             Buffer[64];
74067754Smsmith
74167754Smsmith
74267754Smsmith    ObjDesc = ((ACPI_NAMESPACE_NODE *)ObjHandle)->Object;
74371867Smsmith    BufSize = sizeof (Buffer) / sizeof (*Buffer);
74467754Smsmith
74567754Smsmith    /* Get and display the full pathname to this object */
74667754Smsmith
74771867Smsmith    Status = AcpiNsHandleToPathname (ObjHandle, &BufSize, Buffer);
74867754Smsmith
74967754Smsmith    if (ACPI_FAILURE (Status))
75067754Smsmith    {
75167754Smsmith        AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
75267754Smsmith        return (AE_OK);
75367754Smsmith    }
75467754Smsmith
75571867Smsmith    AcpiOsPrintf ("%32s", Buffer);
75667754Smsmith
75767754Smsmith
75867754Smsmith    /* Display short information about the object */
75967754Smsmith
76067754Smsmith    if (ObjDesc)
76167754Smsmith    {
76267754Smsmith        switch (ObjDesc->Common.Type)
76367754Smsmith        {
76467754Smsmith        case ACPI_TYPE_METHOD:
76569746Smsmith            AcpiOsPrintf ("  #Args %d  Concurrency %X", ObjDesc->Method.ParamCount, ObjDesc->Method.Concurrency);
76667754Smsmith            break;
76767754Smsmith
76871867Smsmith        case ACPI_TYPE_INTEGER:
76971867Smsmith            AcpiOsPrintf ("  Value %X", ObjDesc->Integer.Value);
77067754Smsmith            break;
77167754Smsmith
77267754Smsmith        case ACPI_TYPE_STRING:
77367754Smsmith            AcpiOsPrintf ("  \"%s\"", ObjDesc->String.Pointer);
77467754Smsmith            break;
77567754Smsmith
77667754Smsmith        case ACPI_TYPE_REGION:
77769746Smsmith            AcpiOsPrintf ("  SpaceId %X Address %X Length %X", ObjDesc->Region.SpaceId, ObjDesc->Region.Address, ObjDesc->Region.Length);
77867754Smsmith            break;
77967754Smsmith
78067754Smsmith        case ACPI_TYPE_PACKAGE:
78169746Smsmith            AcpiOsPrintf ("  #Elements %X", ObjDesc->Package.Count);
78267754Smsmith            break;
78367754Smsmith
78467754Smsmith        case ACPI_TYPE_BUFFER:
78569746Smsmith            AcpiOsPrintf ("  Length %X", ObjDesc->Buffer.Length);
78667754Smsmith            break;
78767754Smsmith        }
78867754Smsmith    }
78967754Smsmith
79067754Smsmith    AcpiOsPrintf ("\n");
79167754Smsmith    return (AE_OK);
79267754Smsmith}
79367754Smsmith
79467754Smsmith
79567754Smsmith/*******************************************************************************
79667754Smsmith *
79767754Smsmith * FUNCTION:    AcpiDbDisplayObjects
79867754Smsmith *
79967754Smsmith * PARAMETERS:  ObjTypeArg          - Type of object to display
80067754Smsmith *              DisplayCountArg     - Max depth to display
80167754Smsmith *
80267754Smsmith * RETURN:      None
80367754Smsmith *
80467754Smsmith * DESCRIPTION: Display objects in the namespace of the requested type
80567754Smsmith *
80667754Smsmith ******************************************************************************/
80767754Smsmith
80867754SmsmithACPI_STATUS
80967754SmsmithAcpiDbDisplayObjects (
81067754Smsmith    NATIVE_CHAR             *ObjTypeArg,
81167754Smsmith    NATIVE_CHAR             *DisplayCountArg)
81267754Smsmith{
81367754Smsmith    UINT32                  DisplayCount;
81467754Smsmith    OBJECT_TYPE_INTERNAL    Type;
81567754Smsmith
81667754Smsmith
81767754Smsmith    /* Get the object type */
81867754Smsmith
81967754Smsmith    STRUPR (ObjTypeArg);
82067754Smsmith    Type = AcpiDbMatchArgument (ObjTypeArg, AcpiDbObjectTypes);
82167754Smsmith    if (Type == ACPI_TYPE_NOT_FOUND)
82267754Smsmith    {
82367754Smsmith        AcpiOsPrintf ("Invalid or unsupported argument\n");
82467754Smsmith        return (AE_OK);
82567754Smsmith    }
82667754Smsmith
82767754Smsmith    /* Get the display depth */
82867754Smsmith
82967754Smsmith    if (DisplayCountArg)
83067754Smsmith    {
83167754Smsmith        DisplayCount = STRTOUL (DisplayCountArg, NULL, 0);
83267754Smsmith    }
83367754Smsmith
83467754Smsmith    else
83567754Smsmith    {
83667754Smsmith        DisplayCount = ACPI_UINT32_MAX;
83767754Smsmith    }
83867754Smsmith
83967754Smsmith    AcpiDbSetOutputDestination (DB_DUPLICATE_OUTPUT);
84067754Smsmith    AcpiOsPrintf ("Objects of type [%s] defined in the current ACPI Namespace: \n", AcpiCmGetTypeName (Type));
84167754Smsmith
84267754Smsmith    AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT);
84367754Smsmith
84467754Smsmith    /* Walk the namespace from the root */
84567754Smsmith
84667754Smsmith    AcpiWalkNamespace (Type, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
84767754Smsmith                        AcpiDbWalkForSpecificObjects, (void *) &Type, NULL);
84867754Smsmith
84967754Smsmith    AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT);
85067754Smsmith    return (AE_OK);
85167754Smsmith}
85267754Smsmith
85367754Smsmith
85467754Smsmith/*******************************************************************************
85567754Smsmith *
85667754Smsmith * FUNCTION:    AcpiDbWalkAndMatchName
85767754Smsmith *
85867754Smsmith * PARAMETERS:  Callback from WalkNamespace
85967754Smsmith *
86067754Smsmith * RETURN:      Status
86167754Smsmith *
86267754Smsmith * DESCRIPTION: Find a particular name/names within the namespace.  Wildcards
86367754Smsmith *              are supported -- '?' matches any character.
86467754Smsmith *
86567754Smsmith ******************************************************************************/
86667754Smsmith
86767754SmsmithACPI_STATUS
86867754SmsmithAcpiDbWalkAndMatchName (
86967754Smsmith    ACPI_HANDLE             ObjHandle,
87067754Smsmith    UINT32                  NestingLevel,
87167754Smsmith    void                    *Context,
87267754Smsmith    void                    **ReturnValue)
87367754Smsmith{
87467754Smsmith    ACPI_OPERAND_OBJECT     *ObjDesc;
87567754Smsmith    ACPI_STATUS             Status;
87667754Smsmith    NATIVE_CHAR             *RequestedName = (NATIVE_CHAR *) Context;
87767754Smsmith    UINT32                  i;
87867754Smsmith    UINT32                  BufSize;
87967754Smsmith    NATIVE_CHAR             Buffer[96];
88067754Smsmith
88167754Smsmith
88267754Smsmith    ObjDesc = ((ACPI_NAMESPACE_NODE *)ObjHandle)->Object;
88367754Smsmith
88467754Smsmith
88567754Smsmith    /* Check for a name match */
88667754Smsmith
88767754Smsmith    for (i = 0; i < 4; i++)
88867754Smsmith    {
88967754Smsmith        /* Wildcard support */
89067754Smsmith
89167754Smsmith        if ((RequestedName[i] != '?') &&
89267754Smsmith            (RequestedName[i] != ((NATIVE_CHAR *) (&((ACPI_NAMESPACE_NODE *) ObjHandle)->Name))[i]))
89367754Smsmith        {
89467754Smsmith            /* No match, just exit */
89567754Smsmith
89667754Smsmith            return (AE_OK);
89767754Smsmith        }
89867754Smsmith    }
89967754Smsmith
90067754Smsmith
90167754Smsmith    /* Get the full pathname to this object */
90267754Smsmith
90371867Smsmith    BufSize = sizeof (Buffer) / sizeof (*Buffer);
90467754Smsmith
90567754Smsmith    Status = AcpiNsHandleToPathname (ObjHandle, &BufSize, Buffer);
90667754Smsmith    if (ACPI_FAILURE (Status))
90767754Smsmith    {
90867754Smsmith        AcpiOsPrintf ("Could Not get pathname for object %p\n", ObjHandle);
90967754Smsmith    }
91067754Smsmith
91167754Smsmith    else
91267754Smsmith    {
91369746Smsmith        AcpiOsPrintf ("%32s (%p) - %s\n", Buffer, ObjHandle,
91467754Smsmith            AcpiCmGetTypeName (((ACPI_NAMESPACE_NODE *) ObjHandle)->Type));
91567754Smsmith    }
91667754Smsmith
91767754Smsmith    return (AE_OK);
91867754Smsmith}
91967754Smsmith
92067754Smsmith
92167754Smsmith/*******************************************************************************
92267754Smsmith *
92367754Smsmith * FUNCTION:    AcpiDbFindNameInNamespace
92467754Smsmith *
92567754Smsmith * PARAMETERS:  NameArg         - The 4-character ACPI name to find.
92667754Smsmith *                                wildcards are supported.
92767754Smsmith *
92867754Smsmith * RETURN:      None
92967754Smsmith *
93067754Smsmith * DESCRIPTION: Search the namespace for a given name (with wildcards)
93167754Smsmith *
93267754Smsmith ******************************************************************************/
93367754Smsmith
93467754SmsmithACPI_STATUS
93567754SmsmithAcpiDbFindNameInNamespace (
93667754Smsmith    NATIVE_CHAR             *NameArg)
93767754Smsmith{
93867754Smsmith
93967754Smsmith    if (STRLEN (NameArg) > 4)
94067754Smsmith    {
94167754Smsmith        AcpiOsPrintf ("Name must be no longer than 4 characters\n");
94267754Smsmith        return (AE_OK);
94367754Smsmith    }
94467754Smsmith
94567754Smsmith    /* Walk the namespace from the root */
94667754Smsmith
94767754Smsmith    AcpiWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT, ACPI_UINT32_MAX,
94867754Smsmith                        AcpiDbWalkAndMatchName, NameArg, NULL);
94967754Smsmith
95067754Smsmith    AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT);
95167754Smsmith    return (AE_OK);
95267754Smsmith}
95367754Smsmith
95467754Smsmith
95567754Smsmith/*******************************************************************************
95667754Smsmith *
95767754Smsmith * FUNCTION:    AcpiDbSetScope
95867754Smsmith *
95967754Smsmith * PARAMETERS:  Name                - New scope path
96067754Smsmith *
96167754Smsmith * RETURN:      Status
96267754Smsmith *
96367754Smsmith * DESCRIPTION: Set the "current scope" as maintained by this utility.
96467754Smsmith *              The scope is used as a prefix to ACPI paths.
96567754Smsmith *
96667754Smsmith ******************************************************************************/
96767754Smsmith
96867754Smsmithvoid
96967754SmsmithAcpiDbSetScope (
97067754Smsmith    NATIVE_CHAR             *Name)
97167754Smsmith{
97267754Smsmith
97367754Smsmith    if (!Name || Name[0] == 0)
97467754Smsmith    {
97567754Smsmith        AcpiOsPrintf ("Current scope: %s\n", ScopeBuf);
97667754Smsmith        return;
97767754Smsmith    }
97867754Smsmith
97967754Smsmith    AcpiDbPrepNamestring (Name);
98067754Smsmith
98167754Smsmith    /* TBD: [Future] Validate scope here */
98267754Smsmith
98367754Smsmith    if (Name[0] == '\\')
98467754Smsmith    {
98567754Smsmith        STRCPY (ScopeBuf, Name);
98667754Smsmith        STRCAT (ScopeBuf, "\\");
98767754Smsmith    }
98867754Smsmith
98967754Smsmith    else
99067754Smsmith    {
99167754Smsmith        STRCAT (ScopeBuf, Name);
99267754Smsmith        STRCAT (ScopeBuf, "\\");
99367754Smsmith    }
99467754Smsmith
99567754Smsmith    AcpiOsPrintf ("New scope: %s\n", ScopeBuf);
99667754Smsmith}
99767754Smsmith
99867754Smsmith#endif /* ENABLE_DEBUGGER */
999