Home | History | Annotate | Line # | Download | only in debugger
dbxface.c revision 1.1.1.8
      1      1.1    jruoho /*******************************************************************************
      2      1.1    jruoho  *
      3      1.1    jruoho  * Module Name: dbxface - AML Debugger external interfaces
      4      1.1    jruoho  *
      5      1.1    jruoho  ******************************************************************************/
      6      1.1    jruoho 
      7  1.1.1.2    jruoho /*
      8  1.1.1.8  christos  * Copyright (C) 2000 - 2016, Intel Corp.
      9      1.1    jruoho  * All rights reserved.
     10      1.1    jruoho  *
     11  1.1.1.2    jruoho  * Redistribution and use in source and binary forms, with or without
     12  1.1.1.2    jruoho  * modification, are permitted provided that the following conditions
     13  1.1.1.2    jruoho  * are met:
     14  1.1.1.2    jruoho  * 1. Redistributions of source code must retain the above copyright
     15  1.1.1.2    jruoho  *    notice, this list of conditions, and the following disclaimer,
     16  1.1.1.2    jruoho  *    without modification.
     17  1.1.1.2    jruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18  1.1.1.2    jruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
     19  1.1.1.2    jruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
     20  1.1.1.2    jruoho  *    including a substantially similar Disclaimer requirement for further
     21  1.1.1.2    jruoho  *    binary redistribution.
     22  1.1.1.2    jruoho  * 3. Neither the names of the above-listed copyright holders nor the names
     23  1.1.1.2    jruoho  *    of any contributors may be used to endorse or promote products derived
     24  1.1.1.2    jruoho  *    from this software without specific prior written permission.
     25  1.1.1.2    jruoho  *
     26  1.1.1.2    jruoho  * Alternatively, this software may be distributed under the terms of the
     27  1.1.1.2    jruoho  * GNU General Public License ("GPL") version 2 as published by the Free
     28  1.1.1.2    jruoho  * Software Foundation.
     29  1.1.1.2    jruoho  *
     30  1.1.1.2    jruoho  * NO WARRANTY
     31  1.1.1.2    jruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32  1.1.1.2    jruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  1.1.1.2    jruoho  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34  1.1.1.2    jruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35  1.1.1.2    jruoho  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36  1.1.1.2    jruoho  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37  1.1.1.2    jruoho  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38  1.1.1.2    jruoho  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39  1.1.1.2    jruoho  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40  1.1.1.2    jruoho  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41  1.1.1.2    jruoho  * POSSIBILITY OF SUCH DAMAGES.
     42  1.1.1.2    jruoho  */
     43      1.1    jruoho 
     44      1.1    jruoho #include "acpi.h"
     45      1.1    jruoho #include "accommon.h"
     46      1.1    jruoho #include "amlcode.h"
     47      1.1    jruoho #include "acdebug.h"
     48      1.1    jruoho 
     49      1.1    jruoho 
     50      1.1    jruoho #define _COMPONENT          ACPI_CA_DEBUGGER
     51      1.1    jruoho         ACPI_MODULE_NAME    ("dbxface")
     52      1.1    jruoho 
     53      1.1    jruoho 
     54      1.1    jruoho /* Local prototypes */
     55      1.1    jruoho 
     56      1.1    jruoho static ACPI_STATUS
     57      1.1    jruoho AcpiDbStartCommand (
     58      1.1    jruoho     ACPI_WALK_STATE         *WalkState,
     59      1.1    jruoho     ACPI_PARSE_OBJECT       *Op);
     60      1.1    jruoho 
     61      1.1    jruoho #ifdef ACPI_OBSOLETE_FUNCTIONS
     62      1.1    jruoho void
     63      1.1    jruoho AcpiDbMethodEnd (
     64      1.1    jruoho     ACPI_WALK_STATE         *WalkState);
     65      1.1    jruoho #endif
     66      1.1    jruoho 
     67      1.1    jruoho 
     68      1.1    jruoho /*******************************************************************************
     69      1.1    jruoho  *
     70      1.1    jruoho  * FUNCTION:    AcpiDbStartCommand
     71      1.1    jruoho  *
     72      1.1    jruoho  * PARAMETERS:  WalkState       - Current walk
     73      1.1    jruoho  *              Op              - Current executing Op, from AML interpreter
     74      1.1    jruoho  *
     75      1.1    jruoho  * RETURN:      Status
     76      1.1    jruoho  *
     77      1.1    jruoho  * DESCRIPTION: Enter debugger command loop
     78      1.1    jruoho  *
     79      1.1    jruoho  ******************************************************************************/
     80      1.1    jruoho 
     81      1.1    jruoho static ACPI_STATUS
     82      1.1    jruoho AcpiDbStartCommand (
     83      1.1    jruoho     ACPI_WALK_STATE         *WalkState,
     84      1.1    jruoho     ACPI_PARSE_OBJECT       *Op)
     85      1.1    jruoho {
     86      1.1    jruoho     ACPI_STATUS             Status;
     87      1.1    jruoho 
     88      1.1    jruoho 
     89      1.1    jruoho     /* TBD: [Investigate] are there namespace locking issues here? */
     90      1.1    jruoho 
     91      1.1    jruoho     /* AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); */
     92      1.1    jruoho 
     93      1.1    jruoho     /* Go into the command loop and await next user command */
     94      1.1    jruoho 
     95      1.1    jruoho 
     96      1.1    jruoho     AcpiGbl_MethodExecuting = TRUE;
     97      1.1    jruoho     Status = AE_CTRL_TRUE;
     98      1.1    jruoho     while (Status == AE_CTRL_TRUE)
     99      1.1    jruoho     {
    100      1.1    jruoho         if (AcpiGbl_DebuggerConfiguration == DEBUGGER_MULTI_THREADED)
    101      1.1    jruoho         {
    102      1.1    jruoho             /* Handshake with the front-end that gets user command lines */
    103      1.1    jruoho 
    104  1.1.1.8  christos             AcpiOsReleaseMutex (AcpiGbl_DbCommandComplete);
    105  1.1.1.8  christos 
    106  1.1.1.8  christos             Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandReady,
    107  1.1.1.8  christos                 ACPI_WAIT_FOREVER);
    108      1.1    jruoho             if (ACPI_FAILURE (Status))
    109      1.1    jruoho             {
    110      1.1    jruoho                 return (Status);
    111      1.1    jruoho             }
    112      1.1    jruoho         }
    113      1.1    jruoho         else
    114      1.1    jruoho         {
    115      1.1    jruoho             /* Single threaded, we must get a command line ourselves */
    116      1.1    jruoho 
    117      1.1    jruoho             /* Force output to console until a command is entered */
    118      1.1    jruoho 
    119      1.1    jruoho             AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
    120      1.1    jruoho 
    121      1.1    jruoho             /* Different prompt if method is executing */
    122      1.1    jruoho 
    123      1.1    jruoho             if (!AcpiGbl_MethodExecuting)
    124      1.1    jruoho             {
    125      1.1    jruoho                 AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT);
    126      1.1    jruoho             }
    127      1.1    jruoho             else
    128      1.1    jruoho             {
    129      1.1    jruoho                 AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT);
    130      1.1    jruoho             }
    131      1.1    jruoho 
    132      1.1    jruoho             /* Get the user input line */
    133      1.1    jruoho 
    134  1.1.1.3    jruoho             Status = AcpiOsGetLine (AcpiGbl_DbLineBuf,
    135  1.1.1.3    jruoho                 ACPI_DB_LINE_BUFFER_SIZE, NULL);
    136  1.1.1.3    jruoho             if (ACPI_FAILURE (Status))
    137  1.1.1.3    jruoho             {
    138  1.1.1.8  christos                 ACPI_EXCEPTION ((AE_INFO, Status,
    139  1.1.1.8  christos                     "While parsing command line"));
    140  1.1.1.3    jruoho                 return (Status);
    141  1.1.1.3    jruoho             }
    142      1.1    jruoho         }
    143      1.1    jruoho 
    144      1.1    jruoho         Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, WalkState, Op);
    145      1.1    jruoho     }
    146      1.1    jruoho 
    147      1.1    jruoho     /* AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); */
    148      1.1    jruoho 
    149      1.1    jruoho     return (Status);
    150      1.1    jruoho }
    151      1.1    jruoho 
    152      1.1    jruoho 
    153      1.1    jruoho /*******************************************************************************
    154      1.1    jruoho  *
    155  1.1.1.8  christos  * FUNCTION:    AcpiDbSignalBreakPoint
    156  1.1.1.8  christos  *
    157  1.1.1.8  christos  * PARAMETERS:  WalkState       - Current walk
    158  1.1.1.8  christos  *
    159  1.1.1.8  christos  * RETURN:      Status
    160  1.1.1.8  christos  *
    161  1.1.1.8  christos  * DESCRIPTION: Called for AML_BREAK_POINT_OP
    162  1.1.1.8  christos  *
    163  1.1.1.8  christos  ******************************************************************************/
    164  1.1.1.8  christos 
    165  1.1.1.8  christos void
    166  1.1.1.8  christos AcpiDbSignalBreakPoint (
    167  1.1.1.8  christos     ACPI_WALK_STATE         *WalkState)
    168  1.1.1.8  christos {
    169  1.1.1.8  christos 
    170  1.1.1.8  christos #ifndef ACPI_APPLICATION
    171  1.1.1.8  christos     if (AcpiGbl_DbThreadId != AcpiOsGetThreadId ())
    172  1.1.1.8  christos     {
    173  1.1.1.8  christos         return;
    174  1.1.1.8  christos     }
    175  1.1.1.8  christos #endif
    176  1.1.1.8  christos 
    177  1.1.1.8  christos     /*
    178  1.1.1.8  christos      * Set the single-step flag. This will cause the debugger (if present)
    179  1.1.1.8  christos      * to break to the console within the AML debugger at the start of the
    180  1.1.1.8  christos      * next AML instruction.
    181  1.1.1.8  christos      */
    182  1.1.1.8  christos     AcpiGbl_CmSingleStep = TRUE;
    183  1.1.1.8  christos     AcpiOsPrintf ("**break** Executed AML BreakPoint opcode\n");
    184  1.1.1.8  christos }
    185  1.1.1.8  christos 
    186  1.1.1.8  christos 
    187  1.1.1.8  christos /*******************************************************************************
    188  1.1.1.8  christos  *
    189      1.1    jruoho  * FUNCTION:    AcpiDbSingleStep
    190      1.1    jruoho  *
    191      1.1    jruoho  * PARAMETERS:  WalkState       - Current walk
    192      1.1    jruoho  *              Op              - Current executing op (from aml interpreter)
    193      1.1    jruoho  *              OpcodeClass     - Class of the current AML Opcode
    194      1.1    jruoho  *
    195      1.1    jruoho  * RETURN:      Status
    196      1.1    jruoho  *
    197      1.1    jruoho  * DESCRIPTION: Called just before execution of an AML opcode.
    198      1.1    jruoho  *
    199      1.1    jruoho  ******************************************************************************/
    200      1.1    jruoho 
    201      1.1    jruoho ACPI_STATUS
    202      1.1    jruoho AcpiDbSingleStep (
    203      1.1    jruoho     ACPI_WALK_STATE         *WalkState,
    204      1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
    205      1.1    jruoho     UINT32                  OpcodeClass)
    206      1.1    jruoho {
    207      1.1    jruoho     ACPI_PARSE_OBJECT       *Next;
    208      1.1    jruoho     ACPI_STATUS             Status = AE_OK;
    209      1.1    jruoho     UINT32                  OriginalDebugLevel;
    210      1.1    jruoho     ACPI_PARSE_OBJECT       *DisplayOp;
    211      1.1    jruoho     ACPI_PARSE_OBJECT       *ParentOp;
    212  1.1.1.7  christos     UINT32                  AmlOffset;
    213      1.1    jruoho 
    214      1.1    jruoho 
    215      1.1    jruoho     ACPI_FUNCTION_ENTRY ();
    216      1.1    jruoho 
    217      1.1    jruoho 
    218  1.1.1.8  christos #ifndef ACPI_APPLICATION
    219  1.1.1.8  christos     if (AcpiGbl_DbThreadId != AcpiOsGetThreadId ())
    220  1.1.1.8  christos     {
    221  1.1.1.8  christos         return (AE_OK);
    222  1.1.1.8  christos     }
    223  1.1.1.8  christos #endif
    224  1.1.1.8  christos 
    225      1.1    jruoho     /* Check the abort flag */
    226      1.1    jruoho 
    227      1.1    jruoho     if (AcpiGbl_AbortMethod)
    228      1.1    jruoho     {
    229      1.1    jruoho         AcpiGbl_AbortMethod = FALSE;
    230      1.1    jruoho         return (AE_ABORT_METHOD);
    231      1.1    jruoho     }
    232      1.1    jruoho 
    233  1.1.1.7  christos     AmlOffset = (UINT32) ACPI_PTR_DIFF (Op->Common.Aml,
    234  1.1.1.8  christos         WalkState->ParserState.AmlStart);
    235  1.1.1.7  christos 
    236      1.1    jruoho     /* Check for single-step breakpoint */
    237      1.1    jruoho 
    238      1.1    jruoho     if (WalkState->MethodBreakpoint &&
    239  1.1.1.7  christos        (WalkState->MethodBreakpoint <= AmlOffset))
    240      1.1    jruoho     {
    241      1.1    jruoho         /* Check if the breakpoint has been reached or passed */
    242      1.1    jruoho         /* Hit the breakpoint, resume single step, reset breakpoint */
    243      1.1    jruoho 
    244  1.1.1.7  christos         AcpiOsPrintf ("***Break*** at AML offset %X\n", AmlOffset);
    245      1.1    jruoho         AcpiGbl_CmSingleStep = TRUE;
    246      1.1    jruoho         AcpiGbl_StepToNextCall = FALSE;
    247      1.1    jruoho         WalkState->MethodBreakpoint = 0;
    248      1.1    jruoho     }
    249      1.1    jruoho 
    250      1.1    jruoho     /* Check for user breakpoint (Must be on exact Aml offset) */
    251      1.1    jruoho 
    252      1.1    jruoho     else if (WalkState->UserBreakpoint &&
    253  1.1.1.7  christos             (WalkState->UserBreakpoint == AmlOffset))
    254      1.1    jruoho     {
    255      1.1    jruoho         AcpiOsPrintf ("***UserBreakpoint*** at AML offset %X\n",
    256  1.1.1.7  christos             AmlOffset);
    257      1.1    jruoho         AcpiGbl_CmSingleStep = TRUE;
    258      1.1    jruoho         AcpiGbl_StepToNextCall = FALSE;
    259      1.1    jruoho         WalkState->MethodBreakpoint = 0;
    260      1.1    jruoho     }
    261      1.1    jruoho 
    262      1.1    jruoho     /*
    263      1.1    jruoho      * Check if this is an opcode that we are interested in --
    264      1.1    jruoho      * namely, opcodes that have arguments
    265      1.1    jruoho      */
    266      1.1    jruoho     if (Op->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
    267      1.1    jruoho     {
    268      1.1    jruoho         return (AE_OK);
    269      1.1    jruoho     }
    270      1.1    jruoho 
    271      1.1    jruoho     switch (OpcodeClass)
    272      1.1    jruoho     {
    273      1.1    jruoho     case AML_CLASS_UNKNOWN:
    274  1.1.1.4  christos     case AML_CLASS_ARGUMENT:    /* constants, literals, etc. do nothing */
    275  1.1.1.4  christos 
    276      1.1    jruoho         return (AE_OK);
    277      1.1    jruoho 
    278      1.1    jruoho     default:
    279  1.1.1.4  christos 
    280      1.1    jruoho         /* All other opcodes -- continue */
    281      1.1    jruoho         break;
    282      1.1    jruoho     }
    283      1.1    jruoho 
    284      1.1    jruoho     /*
    285      1.1    jruoho      * Under certain debug conditions, display this opcode and its operands
    286      1.1    jruoho      */
    287      1.1    jruoho     if ((AcpiGbl_DbOutputToFile)            ||
    288      1.1    jruoho         (AcpiGbl_CmSingleStep)              ||
    289      1.1    jruoho         (AcpiDbgLevel & ACPI_LV_PARSE))
    290      1.1    jruoho     {
    291      1.1    jruoho         if ((AcpiGbl_DbOutputToFile)        ||
    292      1.1    jruoho             (AcpiDbgLevel & ACPI_LV_PARSE))
    293      1.1    jruoho         {
    294      1.1    jruoho             AcpiOsPrintf ("\n[AmlDebug] Next AML Opcode to execute:\n");
    295      1.1    jruoho         }
    296      1.1    jruoho 
    297      1.1    jruoho         /*
    298      1.1    jruoho          * Display this op (and only this op - zero out the NEXT field
    299      1.1    jruoho          * temporarily, and disable parser trace output for the duration of
    300      1.1    jruoho          * the display because we don't want the extraneous debug output)
    301      1.1    jruoho          */
    302      1.1    jruoho         OriginalDebugLevel = AcpiDbgLevel;
    303      1.1    jruoho         AcpiDbgLevel &= ~(ACPI_LV_PARSE | ACPI_LV_FUNCTIONS);
    304      1.1    jruoho         Next = Op->Common.Next;
    305      1.1    jruoho         Op->Common.Next = NULL;
    306      1.1    jruoho 
    307      1.1    jruoho 
    308      1.1    jruoho         DisplayOp = Op;
    309      1.1    jruoho         ParentOp = Op->Common.Parent;
    310      1.1    jruoho         if (ParentOp)
    311      1.1    jruoho         {
    312      1.1    jruoho             if ((WalkState->ControlState) &&
    313      1.1    jruoho                 (WalkState->ControlState->Common.State ==
    314      1.1    jruoho                     ACPI_CONTROL_PREDICATE_EXECUTING))
    315      1.1    jruoho             {
    316      1.1    jruoho                 /*
    317      1.1    jruoho                  * We are executing the predicate of an IF or WHILE statement
    318      1.1    jruoho                  * Search upwards for the containing IF or WHILE so that the
    319      1.1    jruoho                  * entire predicate can be displayed.
    320      1.1    jruoho                  */
    321      1.1    jruoho                 while (ParentOp)
    322      1.1    jruoho                 {
    323      1.1    jruoho                     if ((ParentOp->Common.AmlOpcode == AML_IF_OP) ||
    324      1.1    jruoho                         (ParentOp->Common.AmlOpcode == AML_WHILE_OP))
    325      1.1    jruoho                     {
    326      1.1    jruoho                         DisplayOp = ParentOp;
    327      1.1    jruoho                         break;
    328      1.1    jruoho                     }
    329      1.1    jruoho                     ParentOp = ParentOp->Common.Parent;
    330      1.1    jruoho                 }
    331      1.1    jruoho             }
    332      1.1    jruoho             else
    333      1.1    jruoho             {
    334      1.1    jruoho                 while (ParentOp)
    335      1.1    jruoho                 {
    336      1.1    jruoho                     if ((ParentOp->Common.AmlOpcode == AML_IF_OP)     ||
    337      1.1    jruoho                         (ParentOp->Common.AmlOpcode == AML_ELSE_OP)   ||
    338      1.1    jruoho                         (ParentOp->Common.AmlOpcode == AML_SCOPE_OP)  ||
    339      1.1    jruoho                         (ParentOp->Common.AmlOpcode == AML_METHOD_OP) ||
    340      1.1    jruoho                         (ParentOp->Common.AmlOpcode == AML_WHILE_OP))
    341      1.1    jruoho                     {
    342      1.1    jruoho                         break;
    343      1.1    jruoho                     }
    344      1.1    jruoho                     DisplayOp = ParentOp;
    345      1.1    jruoho                     ParentOp = ParentOp->Common.Parent;
    346      1.1    jruoho                 }
    347      1.1    jruoho             }
    348      1.1    jruoho         }
    349      1.1    jruoho 
    350      1.1    jruoho         /* Now we can display it */
    351      1.1    jruoho 
    352  1.1.1.7  christos #ifdef ACPI_DISASSEMBLER
    353      1.1    jruoho         AcpiDmDisassemble (WalkState, DisplayOp, ACPI_UINT32_MAX);
    354  1.1.1.7  christos #endif
    355      1.1    jruoho 
    356      1.1    jruoho         if ((Op->Common.AmlOpcode == AML_IF_OP) ||
    357      1.1    jruoho             (Op->Common.AmlOpcode == AML_WHILE_OP))
    358      1.1    jruoho         {
    359      1.1    jruoho             if (WalkState->ControlState->Common.Value)
    360      1.1    jruoho             {
    361      1.1    jruoho                 AcpiOsPrintf ("Predicate = [True], IF block was executed\n");
    362      1.1    jruoho             }
    363      1.1    jruoho             else
    364      1.1    jruoho             {
    365      1.1    jruoho                 AcpiOsPrintf ("Predicate = [False], Skipping IF block\n");
    366      1.1    jruoho             }
    367      1.1    jruoho         }
    368      1.1    jruoho         else if (Op->Common.AmlOpcode == AML_ELSE_OP)
    369      1.1    jruoho         {
    370      1.1    jruoho             AcpiOsPrintf ("Predicate = [False], ELSE block was executed\n");
    371      1.1    jruoho         }
    372      1.1    jruoho 
    373      1.1    jruoho         /* Restore everything */
    374      1.1    jruoho 
    375      1.1    jruoho         Op->Common.Next = Next;
    376      1.1    jruoho         AcpiOsPrintf ("\n");
    377      1.1    jruoho         if ((AcpiGbl_DbOutputToFile)        ||
    378      1.1    jruoho             (AcpiDbgLevel & ACPI_LV_PARSE))
    379      1.1    jruoho         {
    380      1.1    jruoho             AcpiOsPrintf ("\n");
    381      1.1    jruoho         }
    382      1.1    jruoho         AcpiDbgLevel = OriginalDebugLevel;
    383      1.1    jruoho     }
    384      1.1    jruoho 
    385      1.1    jruoho     /* If we are not single stepping, just continue executing the method */
    386      1.1    jruoho 
    387      1.1    jruoho     if (!AcpiGbl_CmSingleStep)
    388      1.1    jruoho     {
    389      1.1    jruoho         return (AE_OK);
    390      1.1    jruoho     }
    391      1.1    jruoho 
    392      1.1    jruoho     /*
    393      1.1    jruoho      * If we are executing a step-to-call command,
    394      1.1    jruoho      * Check if this is a method call.
    395      1.1    jruoho      */
    396      1.1    jruoho     if (AcpiGbl_StepToNextCall)
    397      1.1    jruoho     {
    398      1.1    jruoho         if (Op->Common.AmlOpcode != AML_INT_METHODCALL_OP)
    399      1.1    jruoho         {
    400      1.1    jruoho             /* Not a method call, just keep executing */
    401      1.1    jruoho 
    402      1.1    jruoho             return (AE_OK);
    403      1.1    jruoho         }
    404      1.1    jruoho 
    405      1.1    jruoho         /* Found a method call, stop executing */
    406      1.1    jruoho 
    407      1.1    jruoho         AcpiGbl_StepToNextCall = FALSE;
    408      1.1    jruoho     }
    409      1.1    jruoho 
    410      1.1    jruoho     /*
    411      1.1    jruoho      * If the next opcode is a method call, we will "step over" it
    412      1.1    jruoho      * by default.
    413      1.1    jruoho      */
    414      1.1    jruoho     if (Op->Common.AmlOpcode == AML_INT_METHODCALL_OP)
    415      1.1    jruoho     {
    416      1.1    jruoho         /* Force no more single stepping while executing called method */
    417      1.1    jruoho 
    418      1.1    jruoho         AcpiGbl_CmSingleStep = FALSE;
    419      1.1    jruoho 
    420      1.1    jruoho         /*
    421      1.1    jruoho          * Set the breakpoint on/before the call, it will stop execution
    422      1.1    jruoho          * as soon as we return
    423      1.1    jruoho          */
    424      1.1    jruoho         WalkState->MethodBreakpoint = 1;  /* Must be non-zero! */
    425      1.1    jruoho     }
    426      1.1    jruoho 
    427      1.1    jruoho 
    428      1.1    jruoho     Status = AcpiDbStartCommand (WalkState, Op);
    429      1.1    jruoho 
    430      1.1    jruoho     /* User commands complete, continue execution of the interrupted method */
    431      1.1    jruoho 
    432      1.1    jruoho     return (Status);
    433      1.1    jruoho }
    434      1.1    jruoho 
    435      1.1    jruoho 
    436      1.1    jruoho /*******************************************************************************
    437      1.1    jruoho  *
    438  1.1.1.8  christos  * FUNCTION:    AcpiInitializeDebugger
    439      1.1    jruoho  *
    440      1.1    jruoho  * PARAMETERS:  None
    441      1.1    jruoho  *
    442      1.1    jruoho  * RETURN:      Status
    443      1.1    jruoho  *
    444      1.1    jruoho  * DESCRIPTION: Init and start debugger
    445      1.1    jruoho  *
    446      1.1    jruoho  ******************************************************************************/
    447      1.1    jruoho 
    448      1.1    jruoho ACPI_STATUS
    449  1.1.1.8  christos AcpiInitializeDebugger (
    450      1.1    jruoho     void)
    451      1.1    jruoho {
    452      1.1    jruoho     ACPI_STATUS             Status;
    453      1.1    jruoho 
    454      1.1    jruoho 
    455  1.1.1.8  christos     ACPI_FUNCTION_TRACE (AcpiInitializeDebugger);
    456  1.1.1.4  christos 
    457  1.1.1.4  christos 
    458      1.1    jruoho     /* Init globals */
    459      1.1    jruoho 
    460      1.1    jruoho     AcpiGbl_DbBuffer            = NULL;
    461      1.1    jruoho     AcpiGbl_DbFilename          = NULL;
    462      1.1    jruoho     AcpiGbl_DbOutputToFile      = FALSE;
    463      1.1    jruoho 
    464      1.1    jruoho     AcpiGbl_DbDebugLevel        = ACPI_LV_VERBOSITY2;
    465      1.1    jruoho     AcpiGbl_DbConsoleDebugLevel = ACPI_NORMAL_DEFAULT | ACPI_LV_TABLES;
    466      1.1    jruoho     AcpiGbl_DbOutputFlags       = ACPI_DB_CONSOLE_OUTPUT;
    467      1.1    jruoho 
    468  1.1.1.6  christos     AcpiGbl_DbOpt_NoIniMethods  = FALSE;
    469      1.1    jruoho 
    470      1.1    jruoho     AcpiGbl_DbBuffer = AcpiOsAllocate (ACPI_DEBUG_BUFFER_SIZE);
    471      1.1    jruoho     if (!AcpiGbl_DbBuffer)
    472      1.1    jruoho     {
    473  1.1.1.4  christos         return_ACPI_STATUS (AE_NO_MEMORY);
    474      1.1    jruoho     }
    475  1.1.1.7  christos     memset (AcpiGbl_DbBuffer, 0, ACPI_DEBUG_BUFFER_SIZE);
    476      1.1    jruoho 
    477      1.1    jruoho     /* Initial scope is the root */
    478      1.1    jruoho 
    479  1.1.1.4  christos     AcpiGbl_DbScopeBuf [0] = AML_ROOT_PREFIX;
    480      1.1    jruoho     AcpiGbl_DbScopeBuf [1] =  0;
    481      1.1    jruoho     AcpiGbl_DbScopeNode = AcpiGbl_RootNode;
    482      1.1    jruoho 
    483  1.1.1.8  christos     /* Initialize user commands loop */
    484  1.1.1.8  christos 
    485  1.1.1.8  christos     AcpiGbl_DbTerminateLoop = FALSE;
    486  1.1.1.8  christos 
    487      1.1    jruoho     /*
    488      1.1    jruoho      * If configured for multi-thread support, the debug executor runs in
    489      1.1    jruoho      * a separate thread so that the front end can be in another address
    490      1.1    jruoho      * space, environment, or even another machine.
    491      1.1    jruoho      */
    492      1.1    jruoho     if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED)
    493      1.1    jruoho     {
    494      1.1    jruoho         /* These were created with one unit, grab it */
    495      1.1    jruoho 
    496  1.1.1.8  christos         Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandComplete,
    497  1.1.1.8  christos             ACPI_WAIT_FOREVER);
    498      1.1    jruoho         if (ACPI_FAILURE (Status))
    499      1.1    jruoho         {
    500      1.1    jruoho             AcpiOsPrintf ("Could not get debugger mutex\n");
    501  1.1.1.4  christos             return_ACPI_STATUS (Status);
    502      1.1    jruoho         }
    503      1.1    jruoho 
    504  1.1.1.8  christos         Status = AcpiOsAcquireMutex (AcpiGbl_DbCommandReady,
    505  1.1.1.8  christos             ACPI_WAIT_FOREVER);
    506      1.1    jruoho         if (ACPI_FAILURE (Status))
    507      1.1    jruoho         {
    508      1.1    jruoho             AcpiOsPrintf ("Could not get debugger mutex\n");
    509  1.1.1.4  christos             return_ACPI_STATUS (Status);
    510      1.1    jruoho         }
    511      1.1    jruoho 
    512      1.1    jruoho         /* Create the debug execution thread to execute commands */
    513      1.1    jruoho 
    514  1.1.1.8  christos         AcpiGbl_DbThreadsTerminated = FALSE;
    515  1.1.1.8  christos         Status = AcpiOsExecute (OSL_DEBUGGER_MAIN_THREAD,
    516  1.1.1.8  christos             AcpiDbExecuteThread, NULL);
    517      1.1    jruoho         if (ACPI_FAILURE (Status))
    518      1.1    jruoho         {
    519  1.1.1.8  christos             ACPI_EXCEPTION ((AE_INFO, Status,
    520  1.1.1.8  christos                 "Could not start debugger thread"));
    521  1.1.1.8  christos             AcpiGbl_DbThreadsTerminated = TRUE;
    522  1.1.1.4  christos             return_ACPI_STATUS (Status);
    523      1.1    jruoho         }
    524      1.1    jruoho     }
    525  1.1.1.8  christos     else
    526      1.1    jruoho     {
    527  1.1.1.8  christos         AcpiGbl_DbThreadId = AcpiOsGetThreadId ();
    528      1.1    jruoho     }
    529      1.1    jruoho 
    530  1.1.1.4  christos     return_ACPI_STATUS (AE_OK);
    531      1.1    jruoho }
    532      1.1    jruoho 
    533  1.1.1.8  christos ACPI_EXPORT_SYMBOL (AcpiInitializeDebugger)
    534  1.1.1.8  christos 
    535      1.1    jruoho 
    536      1.1    jruoho /*******************************************************************************
    537      1.1    jruoho  *
    538  1.1.1.8  christos  * FUNCTION:    AcpiTerminateDebugger
    539      1.1    jruoho  *
    540      1.1    jruoho  * PARAMETERS:  None
    541      1.1    jruoho  *
    542      1.1    jruoho  * RETURN:      None
    543      1.1    jruoho  *
    544      1.1    jruoho  * DESCRIPTION: Stop debugger
    545      1.1    jruoho  *
    546      1.1    jruoho  ******************************************************************************/
    547      1.1    jruoho 
    548      1.1    jruoho void
    549  1.1.1.8  christos AcpiTerminateDebugger (
    550      1.1    jruoho     void)
    551      1.1    jruoho {
    552      1.1    jruoho 
    553  1.1.1.8  christos     /* Terminate the AML Debugger */
    554  1.1.1.8  christos 
    555  1.1.1.8  christos     AcpiGbl_DbTerminateLoop = TRUE;
    556  1.1.1.8  christos 
    557  1.1.1.8  christos     if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED)
    558  1.1.1.8  christos     {
    559  1.1.1.8  christos         AcpiOsReleaseMutex (AcpiGbl_DbCommandReady);
    560  1.1.1.8  christos 
    561  1.1.1.8  christos         /* Wait the AML Debugger threads */
    562  1.1.1.8  christos 
    563  1.1.1.8  christos         while (!AcpiGbl_DbThreadsTerminated)
    564  1.1.1.8  christos         {
    565  1.1.1.8  christos             AcpiOsSleep (100);
    566  1.1.1.8  christos         }
    567  1.1.1.8  christos     }
    568  1.1.1.8  christos 
    569      1.1    jruoho     if (AcpiGbl_DbBuffer)
    570      1.1    jruoho     {
    571      1.1    jruoho         AcpiOsFree (AcpiGbl_DbBuffer);
    572  1.1.1.4  christos         AcpiGbl_DbBuffer = NULL;
    573      1.1    jruoho     }
    574  1.1.1.4  christos 
    575  1.1.1.4  christos     /* Ensure that debug output is now disabled */
    576  1.1.1.4  christos 
    577  1.1.1.4  christos     AcpiGbl_DbOutputFlags = ACPI_DB_DISABLE_OUTPUT;
    578      1.1    jruoho }
    579      1.1    jruoho 
    580  1.1.1.8  christos ACPI_EXPORT_SYMBOL (AcpiTerminateDebugger)
    581  1.1.1.8  christos 
    582      1.1    jruoho 
    583      1.1    jruoho /*******************************************************************************
    584      1.1    jruoho  *
    585  1.1.1.8  christos  * FUNCTION:    AcpiSetDebuggerThreadId
    586      1.1    jruoho  *
    587  1.1.1.8  christos  * PARAMETERS:  ThreadId        - Debugger thread ID
    588      1.1    jruoho  *
    589  1.1.1.8  christos  * RETURN:      None
    590      1.1    jruoho  *
    591  1.1.1.8  christos  * DESCRIPTION: Set debugger thread ID
    592      1.1    jruoho  *
    593      1.1    jruoho  ******************************************************************************/
    594      1.1    jruoho 
    595      1.1    jruoho void
    596  1.1.1.8  christos AcpiSetDebuggerThreadId (
    597  1.1.1.8  christos     ACPI_THREAD_ID          ThreadId)
    598      1.1    jruoho {
    599  1.1.1.8  christos     AcpiGbl_DbThreadId = ThreadId;
    600      1.1    jruoho }
    601      1.1    jruoho 
    602  1.1.1.8  christos ACPI_EXPORT_SYMBOL (AcpiSetDebuggerThreadId)
    603