xref: /onnv-gate/usr/src/uts/intel/io/acpica/debugger/dbxface.c (revision 9980:13d7f3eec672)
13446Smrj /*******************************************************************************
23446Smrj  *
33446Smrj  * Module Name: dbxface - AML Debugger external interfaces
43446Smrj  *
53446Smrj  ******************************************************************************/
63446Smrj 
73446Smrj /******************************************************************************
83446Smrj  *
93446Smrj  * 1. Copyright Notice
103446Smrj  *
11*9980SDana.Myers@Sun.COM  * Some or all of this work - Copyright (c) 1999 - 2009, Intel Corp.
123446Smrj  * All rights reserved.
133446Smrj  *
143446Smrj  * 2. License
153446Smrj  *
163446Smrj  * 2.1. This is your license from Intel Corp. under its intellectual property
173446Smrj  * rights.  You may have additional license terms from the party that provided
183446Smrj  * you this software, covering your right to use that party's intellectual
193446Smrj  * property rights.
203446Smrj  *
213446Smrj  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
223446Smrj  * copy of the source code appearing in this file ("Covered Code") an
233446Smrj  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
243446Smrj  * base code distributed originally by Intel ("Original Intel Code") to copy,
253446Smrj  * make derivatives, distribute, use and display any portion of the Covered
263446Smrj  * Code in any form, with the right to sublicense such rights; and
273446Smrj  *
283446Smrj  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
293446Smrj  * license (with the right to sublicense), under only those claims of Intel
303446Smrj  * patents that are infringed by the Original Intel Code, to make, use, sell,
313446Smrj  * offer to sell, and import the Covered Code and derivative works thereof
323446Smrj  * solely to the minimum extent necessary to exercise the above copyright
333446Smrj  * license, and in no event shall the patent license extend to any additions
343446Smrj  * to or modifications of the Original Intel Code.  No other license or right
353446Smrj  * is granted directly or by implication, estoppel or otherwise;
363446Smrj  *
373446Smrj  * The above copyright and patent license is granted only if the following
383446Smrj  * conditions are met:
393446Smrj  *
403446Smrj  * 3. Conditions
413446Smrj  *
423446Smrj  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
433446Smrj  * Redistribution of source code of any substantial portion of the Covered
443446Smrj  * Code or modification with rights to further distribute source must include
453446Smrj  * the above Copyright Notice, the above License, this list of Conditions,
463446Smrj  * and the following Disclaimer and Export Compliance provision.  In addition,
473446Smrj  * Licensee must cause all Covered Code to which Licensee contributes to
483446Smrj  * contain a file documenting the changes Licensee made to create that Covered
493446Smrj  * Code and the date of any change.  Licensee must include in that file the
503446Smrj  * documentation of any changes made by any predecessor Licensee.  Licensee
513446Smrj  * must include a prominent statement that the modification is derived,
523446Smrj  * directly or indirectly, from Original Intel Code.
533446Smrj  *
543446Smrj  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
553446Smrj  * Redistribution of source code of any substantial portion of the Covered
563446Smrj  * Code or modification without rights to further distribute source must
573446Smrj  * include the following Disclaimer and Export Compliance provision in the
583446Smrj  * documentation and/or other materials provided with distribution.  In
593446Smrj  * addition, Licensee may not authorize further sublicense of source of any
603446Smrj  * portion of the Covered Code, and must include terms to the effect that the
613446Smrj  * license from Licensee to its licensee is limited to the intellectual
623446Smrj  * property embodied in the software Licensee provides to its licensee, and
633446Smrj  * not to intellectual property embodied in modifications its licensee may
643446Smrj  * make.
653446Smrj  *
663446Smrj  * 3.3. Redistribution of Executable. Redistribution in executable form of any
673446Smrj  * substantial portion of the Covered Code or modification must reproduce the
683446Smrj  * above Copyright Notice, and the following Disclaimer and Export Compliance
693446Smrj  * provision in the documentation and/or other materials provided with the
703446Smrj  * distribution.
713446Smrj  *
723446Smrj  * 3.4. Intel retains all right, title, and interest in and to the Original
733446Smrj  * Intel Code.
743446Smrj  *
753446Smrj  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
763446Smrj  * Intel shall be used in advertising or otherwise to promote the sale, use or
773446Smrj  * other dealings in products derived from or relating to the Covered Code
783446Smrj  * without prior written authorization from Intel.
793446Smrj  *
803446Smrj  * 4. Disclaimer and Export Compliance
813446Smrj  *
823446Smrj  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
833446Smrj  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
843446Smrj  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
853446Smrj  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
863446Smrj  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
873446Smrj  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
883446Smrj  * PARTICULAR PURPOSE.
893446Smrj  *
903446Smrj  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
913446Smrj  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
923446Smrj  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
933446Smrj  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
943446Smrj  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
953446Smrj  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
963446Smrj  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
973446Smrj  * LIMITED REMEDY.
983446Smrj  *
993446Smrj  * 4.3. Licensee shall not export, either directly or indirectly, any of this
1003446Smrj  * software or system incorporating such software without first obtaining any
1013446Smrj  * required license or other approval from the U. S. Department of Commerce or
1023446Smrj  * any other agency or department of the United States Government.  In the
1033446Smrj  * event Licensee exports any such software from the United States or
1043446Smrj  * re-exports any such software from a foreign destination, Licensee shall
1053446Smrj  * ensure that the distribution and export/re-export of the software is in
1063446Smrj  * compliance with all laws, regulations, orders, or other restrictions of the
1073446Smrj  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1083446Smrj  * any of its subsidiaries will export/re-export any technical data, process,
1093446Smrj  * software, or service, directly or indirectly, to any country for which the
1103446Smrj  * United States government or any agency thereof requires an export license,
1113446Smrj  * other governmental approval, or letter of assurance, without first obtaining
1123446Smrj  * such license, approval or letter.
1133446Smrj  *
1143446Smrj  *****************************************************************************/
1153446Smrj 
1163446Smrj 
1173446Smrj #include "acpi.h"
118*9980SDana.Myers@Sun.COM #include "accommon.h"
1193446Smrj #include "amlcode.h"
1203446Smrj #include "acdebug.h"
1213446Smrj #include "acdisasm.h"
1223446Smrj 
1233446Smrj 
1243446Smrj #ifdef ACPI_DEBUGGER
1253446Smrj 
1263446Smrj #define _COMPONENT          ACPI_CA_DEBUGGER
1273446Smrj         ACPI_MODULE_NAME    ("dbxface")
1283446Smrj 
1293446Smrj 
1303446Smrj /* Local prototypes */
1313446Smrj 
1323446Smrj static ACPI_STATUS
1333446Smrj AcpiDbStartCommand (
1343446Smrj     ACPI_WALK_STATE         *WalkState,
1353446Smrj     ACPI_PARSE_OBJECT       *Op);
1363446Smrj 
1373446Smrj #ifdef ACPI_OBSOLETE_FUNCTIONS
1383446Smrj void
1393446Smrj AcpiDbMethodEnd (
1403446Smrj     ACPI_WALK_STATE         *WalkState);
1413446Smrj #endif
1423446Smrj 
1433446Smrj 
1443446Smrj /*******************************************************************************
1453446Smrj  *
1463446Smrj  * FUNCTION:    AcpiDbStartCommand
1473446Smrj  *
1483446Smrj  * PARAMETERS:  WalkState       - Current walk
1493446Smrj  *              Op              - Current executing Op, from AML interpreter
1503446Smrj  *
1513446Smrj  * RETURN:      Status
1523446Smrj  *
1533446Smrj  * DESCRIPTION: Enter debugger command loop
1543446Smrj  *
1553446Smrj  ******************************************************************************/
1563446Smrj 
1573446Smrj static ACPI_STATUS
AcpiDbStartCommand(ACPI_WALK_STATE * WalkState,ACPI_PARSE_OBJECT * Op)1583446Smrj AcpiDbStartCommand (
1593446Smrj     ACPI_WALK_STATE         *WalkState,
1603446Smrj     ACPI_PARSE_OBJECT       *Op)
1613446Smrj {
1623446Smrj     ACPI_STATUS             Status;
1633446Smrj 
1643446Smrj 
1653446Smrj     /* TBD: [Investigate] are there namespace locking issues here? */
1663446Smrj 
1673446Smrj     /* AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); */
1683446Smrj 
1693446Smrj     /* Go into the command loop and await next user command */
1703446Smrj 
1713446Smrj 
1723446Smrj     AcpiGbl_MethodExecuting = TRUE;
1733446Smrj     Status = AE_CTRL_TRUE;
1743446Smrj     while (Status == AE_CTRL_TRUE)
1753446Smrj     {
1763446Smrj         if (AcpiGbl_DebuggerConfiguration == DEBUGGER_MULTI_THREADED)
1773446Smrj         {
1783446Smrj             /* Handshake with the front-end that gets user command lines */
1793446Smrj 
1803446Smrj             Status = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
1813446Smrj             if (ACPI_FAILURE (Status))
1823446Smrj             {
1833446Smrj                 return (Status);
1843446Smrj             }
1853446Smrj             Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY);
1863446Smrj             if (ACPI_FAILURE (Status))
1873446Smrj             {
1883446Smrj                 return (Status);
1893446Smrj             }
1903446Smrj         }
1913446Smrj         else
1923446Smrj         {
1933446Smrj             /* Single threaded, we must get a command line ourselves */
1943446Smrj 
1953446Smrj             /* Force output to console until a command is entered */
1963446Smrj 
1973446Smrj             AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
1983446Smrj 
1993446Smrj             /* Different prompt if method is executing */
2003446Smrj 
2013446Smrj             if (!AcpiGbl_MethodExecuting)
2023446Smrj             {
2033446Smrj                 AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT);
2043446Smrj             }
2053446Smrj             else
2063446Smrj             {
2073446Smrj                 AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT);
2083446Smrj             }
2093446Smrj 
2103446Smrj             /* Get the user input line */
2113446Smrj 
2123446Smrj             (void) AcpiOsGetLine (AcpiGbl_DbLineBuf);
2133446Smrj         }
2143446Smrj 
2153446Smrj         Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, WalkState, Op);
2163446Smrj     }
2173446Smrj 
2183446Smrj     /* AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); */
2193446Smrj 
2203446Smrj     return (Status);
2213446Smrj }
2223446Smrj 
2233446Smrj 
2243446Smrj /*******************************************************************************
2253446Smrj  *
2263446Smrj  * FUNCTION:    AcpiDbSingleStep
2273446Smrj  *
2283446Smrj  * PARAMETERS:  WalkState       - Current walk
2293446Smrj  *              Op              - Current executing op (from aml interpreter)
2303446Smrj  *              OpcodeClass     - Class of the current AML Opcode
2313446Smrj  *
2323446Smrj  * RETURN:      Status
2333446Smrj  *
2343446Smrj  * DESCRIPTION: Called just before execution of an AML opcode.
2353446Smrj  *
2363446Smrj  ******************************************************************************/
2373446Smrj 
2383446Smrj ACPI_STATUS
AcpiDbSingleStep(ACPI_WALK_STATE * WalkState,ACPI_PARSE_OBJECT * Op,UINT32 OpcodeClass)2393446Smrj AcpiDbSingleStep (
2403446Smrj     ACPI_WALK_STATE         *WalkState,
2413446Smrj     ACPI_PARSE_OBJECT       *Op,
2423446Smrj     UINT32                  OpcodeClass)
2433446Smrj {
2443446Smrj     ACPI_PARSE_OBJECT       *Next;
2453446Smrj     ACPI_STATUS             Status = AE_OK;
2463446Smrj     UINT32                  OriginalDebugLevel;
2473446Smrj     ACPI_PARSE_OBJECT       *DisplayOp;
2483446Smrj     ACPI_PARSE_OBJECT       *ParentOp;
2493446Smrj 
2503446Smrj 
2513446Smrj     ACPI_FUNCTION_ENTRY ();
2523446Smrj 
2533446Smrj 
2543446Smrj     /* Check the abort flag */
2553446Smrj 
2563446Smrj     if (AcpiGbl_AbortMethod)
2573446Smrj     {
2583446Smrj         AcpiGbl_AbortMethod = FALSE;
2593446Smrj         return (AE_ABORT_METHOD);
2603446Smrj     }
2613446Smrj 
2623446Smrj     /* Check for single-step breakpoint */
2633446Smrj 
2643446Smrj     if (WalkState->MethodBreakpoint &&
2653446Smrj        (WalkState->MethodBreakpoint <= Op->Common.AmlOffset))
2663446Smrj     {
2673446Smrj         /* Check if the breakpoint has been reached or passed */
2683446Smrj         /* Hit the breakpoint, resume single step, reset breakpoint */
2693446Smrj 
2703446Smrj         AcpiOsPrintf ("***Break*** at AML offset %X\n", Op->Common.AmlOffset);
2713446Smrj         AcpiGbl_CmSingleStep = TRUE;
2723446Smrj         AcpiGbl_StepToNextCall = FALSE;
2733446Smrj         WalkState->MethodBreakpoint = 0;
2743446Smrj     }
2753446Smrj 
2763446Smrj     /* Check for user breakpoint (Must be on exact Aml offset) */
2773446Smrj 
2783446Smrj     else if (WalkState->UserBreakpoint &&
2793446Smrj             (WalkState->UserBreakpoint == Op->Common.AmlOffset))
2803446Smrj     {
2813446Smrj         AcpiOsPrintf ("***UserBreakpoint*** at AML offset %X\n",
2823446Smrj             Op->Common.AmlOffset);
2833446Smrj         AcpiGbl_CmSingleStep = TRUE;
2843446Smrj         AcpiGbl_StepToNextCall = FALSE;
2853446Smrj         WalkState->MethodBreakpoint = 0;
2863446Smrj     }
2873446Smrj 
2883446Smrj     /*
2893446Smrj      * Check if this is an opcode that we are interested in --
2903446Smrj      * namely, opcodes that have arguments
2913446Smrj      */
2923446Smrj     if (Op->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
2933446Smrj     {
2943446Smrj         return (AE_OK);
2953446Smrj     }
2963446Smrj 
2973446Smrj     switch (OpcodeClass)
2983446Smrj     {
2993446Smrj     case AML_CLASS_UNKNOWN:
3003446Smrj     case AML_CLASS_ARGUMENT:    /* constants, literals, etc.  do nothing */
3013446Smrj         return (AE_OK);
3023446Smrj 
3033446Smrj     default:
3043446Smrj         /* All other opcodes -- continue */
3053446Smrj         break;
3063446Smrj     }
3073446Smrj 
3083446Smrj     /*
3093446Smrj      * Under certain debug conditions, display this opcode and its operands
3103446Smrj      */
3113446Smrj     if ((AcpiGbl_DbOutputToFile)            ||
3123446Smrj         (AcpiGbl_CmSingleStep)              ||
3133446Smrj         (AcpiDbgLevel & ACPI_LV_PARSE))
3143446Smrj     {
3153446Smrj         if ((AcpiGbl_DbOutputToFile)        ||
3163446Smrj             (AcpiDbgLevel & ACPI_LV_PARSE))
3173446Smrj         {
3183446Smrj             AcpiOsPrintf ("\n[AmlDebug] Next AML Opcode to execute:\n");
3193446Smrj         }
3203446Smrj 
3213446Smrj         /*
3223446Smrj          * Display this op (and only this op - zero out the NEXT field
3233446Smrj          * temporarily, and disable parser trace output for the duration of
3243446Smrj          * the display because we don't want the extraneous debug output)
3253446Smrj          */
3263446Smrj         OriginalDebugLevel = AcpiDbgLevel;
3273446Smrj         AcpiDbgLevel &= ~(ACPI_LV_PARSE | ACPI_LV_FUNCTIONS);
3283446Smrj         Next = Op->Common.Next;
3293446Smrj         Op->Common.Next = NULL;
3303446Smrj 
3313446Smrj 
3323446Smrj         DisplayOp = Op;
3333446Smrj         ParentOp = Op->Common.Parent;
3343446Smrj         if (ParentOp)
3353446Smrj         {
3363446Smrj             if ((WalkState->ControlState) &&
3373446Smrj                 (WalkState->ControlState->Common.State ==
3383446Smrj                     ACPI_CONTROL_PREDICATE_EXECUTING))
3393446Smrj             {
3403446Smrj                 /*
3413446Smrj                  * We are executing the predicate of an IF or WHILE statement
3423446Smrj                  * Search upwards for the containing IF or WHILE so that the
3433446Smrj                  * entire predicate can be displayed.
3443446Smrj                  */
3453446Smrj                 while (ParentOp)
3463446Smrj                 {
3473446Smrj                     if ((ParentOp->Common.AmlOpcode == AML_IF_OP) ||
3483446Smrj                         (ParentOp->Common.AmlOpcode == AML_WHILE_OP))
3493446Smrj                     {
3503446Smrj                         DisplayOp = ParentOp;
3513446Smrj                         break;
3523446Smrj                     }
3533446Smrj                     ParentOp = ParentOp->Common.Parent;
3543446Smrj                 }
3553446Smrj             }
3563446Smrj             else
3573446Smrj             {
3583446Smrj                 while (ParentOp)
3593446Smrj                 {
3603446Smrj                     if ((ParentOp->Common.AmlOpcode == AML_IF_OP)     ||
3613446Smrj                         (ParentOp->Common.AmlOpcode == AML_ELSE_OP)   ||
3623446Smrj                         (ParentOp->Common.AmlOpcode == AML_SCOPE_OP)  ||
3633446Smrj                         (ParentOp->Common.AmlOpcode == AML_METHOD_OP) ||
3643446Smrj                         (ParentOp->Common.AmlOpcode == AML_WHILE_OP))
3653446Smrj                     {
3663446Smrj                         break;
3673446Smrj                     }
3683446Smrj                     DisplayOp = ParentOp;
3693446Smrj                     ParentOp = ParentOp->Common.Parent;
3703446Smrj                 }
3713446Smrj             }
3723446Smrj         }
3733446Smrj 
3743446Smrj         /* Now we can display it */
3753446Smrj 
3763446Smrj         AcpiDmDisassemble (WalkState, DisplayOp, ACPI_UINT32_MAX);
3773446Smrj 
3783446Smrj         if ((Op->Common.AmlOpcode == AML_IF_OP) ||
3793446Smrj             (Op->Common.AmlOpcode == AML_WHILE_OP))
3803446Smrj         {
3813446Smrj             if (WalkState->ControlState->Common.Value)
3823446Smrj             {
3833446Smrj                 AcpiOsPrintf ("Predicate = [True], IF block was executed\n");
3843446Smrj             }
3853446Smrj             else
3863446Smrj             {
3873446Smrj                 AcpiOsPrintf ("Predicate = [False], Skipping IF block\n");
3883446Smrj             }
3893446Smrj         }
3903446Smrj         else if (Op->Common.AmlOpcode == AML_ELSE_OP)
3913446Smrj         {
3923446Smrj             AcpiOsPrintf ("Predicate = [False], ELSE block was executed\n");
3933446Smrj         }
3943446Smrj 
3953446Smrj         /* Restore everything */
3963446Smrj 
3973446Smrj         Op->Common.Next = Next;
3983446Smrj         AcpiOsPrintf ("\n");
3993446Smrj         if ((AcpiGbl_DbOutputToFile)        ||
4003446Smrj             (AcpiDbgLevel & ACPI_LV_PARSE))
4013446Smrj         {
4023446Smrj             AcpiOsPrintf ("\n");
4033446Smrj         }
4043446Smrj         AcpiDbgLevel = OriginalDebugLevel;
4053446Smrj     }
4063446Smrj 
4073446Smrj     /* If we are not single stepping, just continue executing the method */
4083446Smrj 
4093446Smrj     if (!AcpiGbl_CmSingleStep)
4103446Smrj     {
4113446Smrj         return (AE_OK);
4123446Smrj     }
4133446Smrj 
4143446Smrj     /*
4153446Smrj      * If we are executing a step-to-call command,
4163446Smrj      * Check if this is a method call.
4173446Smrj      */
4183446Smrj     if (AcpiGbl_StepToNextCall)
4193446Smrj     {
4203446Smrj         if (Op->Common.AmlOpcode != AML_INT_METHODCALL_OP)
4213446Smrj         {
4223446Smrj             /* Not a method call, just keep executing */
4233446Smrj 
4243446Smrj             return (AE_OK);
4253446Smrj         }
4263446Smrj 
4273446Smrj         /* Found a method call, stop executing */
4283446Smrj 
4293446Smrj         AcpiGbl_StepToNextCall = FALSE;
4303446Smrj     }
4313446Smrj 
4323446Smrj     /*
4333446Smrj      * If the next opcode is a method call, we will "step over" it
4343446Smrj      * by default.
4353446Smrj      */
4363446Smrj     if (Op->Common.AmlOpcode == AML_INT_METHODCALL_OP)
4373446Smrj     {
4383446Smrj         /* Force no more single stepping while executing called method */
4393446Smrj 
4403446Smrj         AcpiGbl_CmSingleStep = FALSE;
4413446Smrj 
4423446Smrj         /*
4433446Smrj          * Set the breakpoint on/before the call, it will stop execution
4443446Smrj          * as soon as we return
4453446Smrj          */
4463446Smrj         WalkState->MethodBreakpoint = 1;  /* Must be non-zero! */
4473446Smrj     }
4483446Smrj 
4493446Smrj 
4503446Smrj     Status = AcpiDbStartCommand (WalkState, Op);
4513446Smrj 
4523446Smrj     /* User commands complete, continue execution of the interrupted method */
4533446Smrj 
4543446Smrj     return (Status);
4553446Smrj }
4563446Smrj 
4573446Smrj 
4583446Smrj /*******************************************************************************
4593446Smrj  *
4603446Smrj  * FUNCTION:    AcpiDbInitialize
4613446Smrj  *
4623446Smrj  * PARAMETERS:  None
4633446Smrj  *
4643446Smrj  * RETURN:      Status
4653446Smrj  *
4663446Smrj  * DESCRIPTION: Init and start debugger
4673446Smrj  *
4683446Smrj  ******************************************************************************/
4693446Smrj 
4703446Smrj ACPI_STATUS
AcpiDbInitialize(void)4713446Smrj AcpiDbInitialize (
4723446Smrj     void)
4733446Smrj {
4743446Smrj     ACPI_STATUS             Status;
4753446Smrj 
4763446Smrj 
4773446Smrj     /* Init globals */
4783446Smrj 
4793446Smrj     AcpiGbl_DbBuffer            = NULL;
4803446Smrj     AcpiGbl_DbFilename          = NULL;
4813446Smrj     AcpiGbl_DbOutputToFile      = FALSE;
4823446Smrj 
4833446Smrj     AcpiGbl_DbDebugLevel        = ACPI_LV_VERBOSITY2;
4843446Smrj     AcpiGbl_DbConsoleDebugLevel = ACPI_NORMAL_DEFAULT | ACPI_LV_TABLES;
4853446Smrj     AcpiGbl_DbOutputFlags       = ACPI_DB_CONSOLE_OUTPUT;
4863446Smrj 
4873446Smrj     AcpiGbl_DbOpt_tables        = FALSE;
4883446Smrj     AcpiGbl_DbOpt_disasm        = FALSE;
4893446Smrj     AcpiGbl_DbOpt_stats         = FALSE;
4903446Smrj     AcpiGbl_DbOpt_verbose       = TRUE;
4913446Smrj     AcpiGbl_DbOpt_ini_methods   = TRUE;
4923446Smrj 
4933446Smrj     AcpiGbl_DbBuffer = AcpiOsAllocate (ACPI_DEBUG_BUFFER_SIZE);
4943446Smrj     if (!AcpiGbl_DbBuffer)
4953446Smrj     {
4963446Smrj         return (AE_NO_MEMORY);
4973446Smrj     }
4983446Smrj     ACPI_MEMSET (AcpiGbl_DbBuffer, 0, ACPI_DEBUG_BUFFER_SIZE);
4993446Smrj 
5003446Smrj     /* Initial scope is the root */
5013446Smrj 
5023446Smrj     AcpiGbl_DbScopeBuf [0] = '\\';
5033446Smrj     AcpiGbl_DbScopeBuf [1] =  0;
5043446Smrj     AcpiGbl_DbScopeNode = AcpiGbl_RootNode;
5053446Smrj 
5063446Smrj     /*
5073446Smrj      * If configured for multi-thread support, the debug executor runs in
5083446Smrj      * a separate thread so that the front end can be in another address
5093446Smrj      * space, environment, or even another machine.
5103446Smrj      */
5113446Smrj     if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED)
5123446Smrj     {
5133446Smrj         /* These were created with one unit, grab it */
5143446Smrj 
5153446Smrj         Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
5163446Smrj         if (ACPI_FAILURE (Status))
5173446Smrj         {
5183446Smrj             AcpiOsPrintf ("Could not get debugger mutex\n");
5193446Smrj             return (Status);
5203446Smrj         }
5213446Smrj 
5223446Smrj         Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY);
5233446Smrj         if (ACPI_FAILURE (Status))
5243446Smrj         {
5253446Smrj             AcpiOsPrintf ("Could not get debugger mutex\n");
5263446Smrj             return (Status);
5273446Smrj         }
5283446Smrj 
5293446Smrj         /* Create the debug execution thread to execute commands */
5303446Smrj 
5313446Smrj         Status = AcpiOsExecute (OSL_DEBUGGER_THREAD, AcpiDbExecuteThread, NULL);
5323446Smrj         if (ACPI_FAILURE (Status))
5333446Smrj         {
5343446Smrj             AcpiOsPrintf ("Could not start debugger thread\n");
5353446Smrj             return (Status);
5363446Smrj         }
5373446Smrj     }
5383446Smrj 
5393446Smrj     if (!AcpiGbl_DbOpt_verbose)
5403446Smrj     {
5413446Smrj         AcpiGbl_DbOpt_disasm = TRUE;
5423446Smrj         AcpiGbl_DbOpt_stats = FALSE;
5433446Smrj     }
5443446Smrj 
5453446Smrj     return (AE_OK);
5463446Smrj }
5473446Smrj 
5483446Smrj 
5493446Smrj /*******************************************************************************
5503446Smrj  *
5513446Smrj  * FUNCTION:    AcpiDbTerminate
5523446Smrj  *
5533446Smrj  * PARAMETERS:  None
5543446Smrj  *
5553446Smrj  * RETURN:      None
5563446Smrj  *
5573446Smrj  * DESCRIPTION: Stop debugger
5583446Smrj  *
5593446Smrj  ******************************************************************************/
5603446Smrj 
5613446Smrj void
AcpiDbTerminate(void)5623446Smrj AcpiDbTerminate (
5633446Smrj     void)
5643446Smrj {
5653446Smrj 
5663446Smrj     if (AcpiGbl_DbBuffer)
5673446Smrj     {
5683446Smrj         AcpiOsFree (AcpiGbl_DbBuffer);
5693446Smrj     }
5703446Smrj }
5713446Smrj 
5723446Smrj 
5733446Smrj #ifdef ACPI_OBSOLETE_FUNCTIONS
5743446Smrj /*******************************************************************************
5753446Smrj  *
5763446Smrj  * FUNCTION:    AcpiDbMethodEnd
5773446Smrj  *
5783446Smrj  * PARAMETERS:  WalkState       - Current walk
5793446Smrj  *
5803446Smrj  * RETURN:      Status
5813446Smrj  *
5823446Smrj  * DESCRIPTION: Called at method termination
5833446Smrj  *
5843446Smrj  ******************************************************************************/
5853446Smrj 
5863446Smrj void
AcpiDbMethodEnd(ACPI_WALK_STATE * WalkState)5873446Smrj AcpiDbMethodEnd (
5883446Smrj     ACPI_WALK_STATE         *WalkState)
5893446Smrj {
5903446Smrj 
5913446Smrj     if (!AcpiGbl_CmSingleStep)
5923446Smrj     {
5933446Smrj         return;
5943446Smrj     }
5953446Smrj 
5963446Smrj     AcpiOsPrintf ("<Method Terminating>\n");
5973446Smrj 
5983446Smrj     AcpiDbStartCommand (WalkState, NULL);
5993446Smrj }
6003446Smrj #endif
6013446Smrj 
6023446Smrj #endif /* ACPI_DEBUGGER */
603