Home | History | Annotate | Line # | Download | only in debugger
dbxface.c revision 1.1.1.12.2.1
      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.12.2.1  christos  * Copyright (C) 2000 - 2019, 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.1.10  christos #include "acinterp.h"
     49  1.1.1.12.2.1  christos #include "acparser.h"
     50           1.1    jruoho 
     51           1.1    jruoho 
     52           1.1    jruoho #define _COMPONENT          ACPI_CA_DEBUGGER
     53           1.1    jruoho         ACPI_MODULE_NAME    ("dbxface")
     54           1.1    jruoho 
     55           1.1    jruoho 
     56           1.1    jruoho /* Local prototypes */
     57           1.1    jruoho 
     58           1.1    jruoho static ACPI_STATUS
     59           1.1    jruoho AcpiDbStartCommand (
     60           1.1    jruoho     ACPI_WALK_STATE         *WalkState,
     61           1.1    jruoho     ACPI_PARSE_OBJECT       *Op);
     62           1.1    jruoho 
     63           1.1    jruoho #ifdef ACPI_OBSOLETE_FUNCTIONS
     64           1.1    jruoho void
     65           1.1    jruoho AcpiDbMethodEnd (
     66           1.1    jruoho     ACPI_WALK_STATE         *WalkState);
     67           1.1    jruoho #endif
     68           1.1    jruoho 
     69  1.1.1.12.2.1  christos #ifdef ACPI_DISASSEMBLER
     70  1.1.1.12.2.1  christos static ACPI_PARSE_OBJECT *
     71  1.1.1.12.2.1  christos AcpiDbGetDisplayOp (
     72  1.1.1.12.2.1  christos     ACPI_WALK_STATE         *WalkState,
     73  1.1.1.12.2.1  christos     ACPI_PARSE_OBJECT       *Op);
     74  1.1.1.12.2.1  christos #endif
     75           1.1    jruoho 
     76           1.1    jruoho /*******************************************************************************
     77           1.1    jruoho  *
     78           1.1    jruoho  * FUNCTION:    AcpiDbStartCommand
     79           1.1    jruoho  *
     80           1.1    jruoho  * PARAMETERS:  WalkState       - Current walk
     81           1.1    jruoho  *              Op              - Current executing Op, from AML interpreter
     82           1.1    jruoho  *
     83           1.1    jruoho  * RETURN:      Status
     84           1.1    jruoho  *
     85           1.1    jruoho  * DESCRIPTION: Enter debugger command loop
     86           1.1    jruoho  *
     87           1.1    jruoho  ******************************************************************************/
     88           1.1    jruoho 
     89           1.1    jruoho static ACPI_STATUS
     90           1.1    jruoho AcpiDbStartCommand (
     91           1.1    jruoho     ACPI_WALK_STATE         *WalkState,
     92           1.1    jruoho     ACPI_PARSE_OBJECT       *Op)
     93           1.1    jruoho {
     94           1.1    jruoho     ACPI_STATUS             Status;
     95           1.1    jruoho 
     96           1.1    jruoho 
     97           1.1    jruoho     /* TBD: [Investigate] are there namespace locking issues here? */
     98           1.1    jruoho 
     99           1.1    jruoho     /* AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); */
    100           1.1    jruoho 
    101           1.1    jruoho     /* Go into the command loop and await next user command */
    102           1.1    jruoho 
    103           1.1    jruoho 
    104           1.1    jruoho     AcpiGbl_MethodExecuting = TRUE;
    105           1.1    jruoho     Status = AE_CTRL_TRUE;
    106       1.1.1.9  christos 
    107           1.1    jruoho     while (Status == AE_CTRL_TRUE)
    108           1.1    jruoho     {
    109       1.1.1.9  christos         /* Notify the completion of the command */
    110           1.1    jruoho 
    111       1.1.1.9  christos         Status = AcpiOsNotifyCommandComplete ();
    112       1.1.1.9  christos         if (ACPI_FAILURE (Status))
    113           1.1    jruoho         {
    114       1.1.1.9  christos             goto ErrorExit;
    115       1.1.1.9  christos         }
    116           1.1    jruoho 
    117       1.1.1.9  christos         /* Wait the readiness of the command */
    118           1.1    jruoho 
    119       1.1.1.9  christos         Status = AcpiOsWaitCommandReady ();
    120       1.1.1.9  christos         if (ACPI_FAILURE (Status))
    121       1.1.1.9  christos         {
    122       1.1.1.9  christos             goto ErrorExit;
    123           1.1    jruoho         }
    124           1.1    jruoho 
    125           1.1    jruoho         Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, WalkState, Op);
    126           1.1    jruoho     }
    127           1.1    jruoho 
    128           1.1    jruoho     /* AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); */
    129           1.1    jruoho 
    130       1.1.1.9  christos ErrorExit:
    131       1.1.1.9  christos     if (ACPI_FAILURE (Status) && Status != AE_CTRL_TERMINATE)
    132       1.1.1.9  christos     {
    133       1.1.1.9  christos         ACPI_EXCEPTION ((AE_INFO, Status,
    134       1.1.1.9  christos             "While parsing/handling command line"));
    135       1.1.1.9  christos     }
    136           1.1    jruoho     return (Status);
    137           1.1    jruoho }
    138           1.1    jruoho 
    139           1.1    jruoho 
    140           1.1    jruoho /*******************************************************************************
    141           1.1    jruoho  *
    142       1.1.1.8  christos  * FUNCTION:    AcpiDbSignalBreakPoint
    143       1.1.1.8  christos  *
    144       1.1.1.8  christos  * PARAMETERS:  WalkState       - Current walk
    145       1.1.1.8  christos  *
    146       1.1.1.8  christos  * RETURN:      Status
    147       1.1.1.8  christos  *
    148      1.1.1.10  christos  * DESCRIPTION: Called for AML_BREAKPOINT_OP
    149       1.1.1.8  christos  *
    150       1.1.1.8  christos  ******************************************************************************/
    151       1.1.1.8  christos 
    152       1.1.1.8  christos void
    153       1.1.1.8  christos AcpiDbSignalBreakPoint (
    154       1.1.1.8  christos     ACPI_WALK_STATE         *WalkState)
    155       1.1.1.8  christos {
    156       1.1.1.8  christos 
    157       1.1.1.8  christos #ifndef ACPI_APPLICATION
    158       1.1.1.8  christos     if (AcpiGbl_DbThreadId != AcpiOsGetThreadId ())
    159       1.1.1.8  christos     {
    160       1.1.1.8  christos         return;
    161       1.1.1.8  christos     }
    162       1.1.1.8  christos #endif
    163       1.1.1.8  christos 
    164       1.1.1.8  christos     /*
    165       1.1.1.8  christos      * Set the single-step flag. This will cause the debugger (if present)
    166       1.1.1.8  christos      * to break to the console within the AML debugger at the start of the
    167       1.1.1.8  christos      * next AML instruction.
    168       1.1.1.8  christos      */
    169       1.1.1.8  christos     AcpiGbl_CmSingleStep = TRUE;
    170       1.1.1.8  christos     AcpiOsPrintf ("**break** Executed AML BreakPoint opcode\n");
    171       1.1.1.8  christos }
    172       1.1.1.8  christos 
    173       1.1.1.8  christos 
    174  1.1.1.12.2.1  christos #ifdef ACPI_DISASSEMBLER
    175  1.1.1.12.2.1  christos /*******************************************************************************
    176  1.1.1.12.2.1  christos  *
    177  1.1.1.12.2.1  christos  * FUNCTION:    AcpiDbGetDisplayOp
    178  1.1.1.12.2.1  christos  *
    179  1.1.1.12.2.1  christos  * PARAMETERS:  WalkState       - Current walk
    180  1.1.1.12.2.1  christos  *              Op              - Current executing op (from aml interpreter)
    181  1.1.1.12.2.1  christos  *
    182  1.1.1.12.2.1  christos  * RETURN:      Opcode to display
    183  1.1.1.12.2.1  christos  *
    184  1.1.1.12.2.1  christos  * DESCRIPTION: Find the opcode to display during single stepping
    185  1.1.1.12.2.1  christos  *
    186  1.1.1.12.2.1  christos  ******************************************************************************/
    187  1.1.1.12.2.1  christos 
    188  1.1.1.12.2.1  christos static ACPI_PARSE_OBJECT *
    189  1.1.1.12.2.1  christos AcpiDbGetDisplayOp (
    190  1.1.1.12.2.1  christos     ACPI_WALK_STATE         *WalkState,
    191  1.1.1.12.2.1  christos     ACPI_PARSE_OBJECT       *Op)
    192  1.1.1.12.2.1  christos {
    193  1.1.1.12.2.1  christos     ACPI_PARSE_OBJECT       *DisplayOp;
    194  1.1.1.12.2.1  christos     ACPI_PARSE_OBJECT       *ParentOp;
    195  1.1.1.12.2.1  christos 
    196  1.1.1.12.2.1  christos     DisplayOp = Op;
    197  1.1.1.12.2.1  christos     ParentOp = Op->Common.Parent;
    198  1.1.1.12.2.1  christos     if (ParentOp)
    199  1.1.1.12.2.1  christos     {
    200  1.1.1.12.2.1  christos         if ((WalkState->ControlState) &&
    201  1.1.1.12.2.1  christos             (WalkState->ControlState->Common.State ==
    202  1.1.1.12.2.1  christos                 ACPI_CONTROL_PREDICATE_EXECUTING))
    203  1.1.1.12.2.1  christos         {
    204  1.1.1.12.2.1  christos             /*
    205  1.1.1.12.2.1  christos              * We are executing the predicate of an IF or WHILE statement
    206  1.1.1.12.2.1  christos              * Search upwards for the containing IF or WHILE so that the
    207  1.1.1.12.2.1  christos              * entire predicate can be displayed.
    208  1.1.1.12.2.1  christos              */
    209  1.1.1.12.2.1  christos             while (ParentOp)
    210  1.1.1.12.2.1  christos             {
    211  1.1.1.12.2.1  christos                 if ((ParentOp->Common.AmlOpcode == AML_IF_OP) ||
    212  1.1.1.12.2.1  christos                     (ParentOp->Common.AmlOpcode == AML_WHILE_OP))
    213  1.1.1.12.2.1  christos                 {
    214  1.1.1.12.2.1  christos                     DisplayOp = ParentOp;
    215  1.1.1.12.2.1  christos                     break;
    216  1.1.1.12.2.1  christos                 }
    217  1.1.1.12.2.1  christos                 ParentOp = ParentOp->Common.Parent;
    218  1.1.1.12.2.1  christos             }
    219  1.1.1.12.2.1  christos         }
    220  1.1.1.12.2.1  christos         else
    221  1.1.1.12.2.1  christos         {
    222  1.1.1.12.2.1  christos             while (ParentOp)
    223  1.1.1.12.2.1  christos             {
    224  1.1.1.12.2.1  christos                 if ((ParentOp->Common.AmlOpcode == AML_IF_OP)     ||
    225  1.1.1.12.2.1  christos                     (ParentOp->Common.AmlOpcode == AML_ELSE_OP)   ||
    226  1.1.1.12.2.1  christos                     (ParentOp->Common.AmlOpcode == AML_SCOPE_OP)  ||
    227  1.1.1.12.2.1  christos                     (ParentOp->Common.AmlOpcode == AML_METHOD_OP) ||
    228  1.1.1.12.2.1  christos                     (ParentOp->Common.AmlOpcode == AML_WHILE_OP))
    229  1.1.1.12.2.1  christos                 {
    230  1.1.1.12.2.1  christos                     break;
    231  1.1.1.12.2.1  christos                 }
    232  1.1.1.12.2.1  christos                 DisplayOp = ParentOp;
    233  1.1.1.12.2.1  christos                 ParentOp = ParentOp->Common.Parent;
    234  1.1.1.12.2.1  christos             }
    235  1.1.1.12.2.1  christos         }
    236  1.1.1.12.2.1  christos     }
    237  1.1.1.12.2.1  christos     return DisplayOp;
    238  1.1.1.12.2.1  christos }
    239  1.1.1.12.2.1  christos #endif
    240  1.1.1.12.2.1  christos 
    241  1.1.1.12.2.1  christos 
    242       1.1.1.8  christos /*******************************************************************************
    243       1.1.1.8  christos  *
    244           1.1    jruoho  * FUNCTION:    AcpiDbSingleStep
    245           1.1    jruoho  *
    246           1.1    jruoho  * PARAMETERS:  WalkState       - Current walk
    247           1.1    jruoho  *              Op              - Current executing op (from aml interpreter)
    248           1.1    jruoho  *              OpcodeClass     - Class of the current AML Opcode
    249           1.1    jruoho  *
    250           1.1    jruoho  * RETURN:      Status
    251           1.1    jruoho  *
    252           1.1    jruoho  * DESCRIPTION: Called just before execution of an AML opcode.
    253           1.1    jruoho  *
    254           1.1    jruoho  ******************************************************************************/
    255           1.1    jruoho 
    256           1.1    jruoho ACPI_STATUS
    257           1.1    jruoho AcpiDbSingleStep (
    258           1.1    jruoho     ACPI_WALK_STATE         *WalkState,
    259           1.1    jruoho     ACPI_PARSE_OBJECT       *Op,
    260           1.1    jruoho     UINT32                  OpcodeClass)
    261           1.1    jruoho {
    262           1.1    jruoho     ACPI_PARSE_OBJECT       *Next;
    263           1.1    jruoho     ACPI_STATUS             Status = AE_OK;
    264           1.1    jruoho     UINT32                  OriginalDebugLevel;
    265       1.1.1.7  christos     UINT32                  AmlOffset;
    266           1.1    jruoho 
    267           1.1    jruoho 
    268           1.1    jruoho     ACPI_FUNCTION_ENTRY ();
    269           1.1    jruoho 
    270           1.1    jruoho 
    271       1.1.1.8  christos #ifndef ACPI_APPLICATION
    272       1.1.1.8  christos     if (AcpiGbl_DbThreadId != AcpiOsGetThreadId ())
    273       1.1.1.8  christos     {
    274       1.1.1.8  christos         return (AE_OK);
    275       1.1.1.8  christos     }
    276       1.1.1.8  christos #endif
    277       1.1.1.8  christos 
    278           1.1    jruoho     /* Check the abort flag */
    279           1.1    jruoho 
    280           1.1    jruoho     if (AcpiGbl_AbortMethod)
    281           1.1    jruoho     {
    282           1.1    jruoho         AcpiGbl_AbortMethod = FALSE;
    283           1.1    jruoho         return (AE_ABORT_METHOD);
    284           1.1    jruoho     }
    285           1.1    jruoho 
    286       1.1.1.7  christos     AmlOffset = (UINT32) ACPI_PTR_DIFF (Op->Common.Aml,
    287       1.1.1.8  christos         WalkState->ParserState.AmlStart);
    288       1.1.1.7  christos 
    289           1.1    jruoho     /* Check for single-step breakpoint */
    290           1.1    jruoho 
    291           1.1    jruoho     if (WalkState->MethodBreakpoint &&
    292       1.1.1.7  christos        (WalkState->MethodBreakpoint <= AmlOffset))
    293           1.1    jruoho     {
    294           1.1    jruoho         /* Check if the breakpoint has been reached or passed */
    295           1.1    jruoho         /* Hit the breakpoint, resume single step, reset breakpoint */
    296           1.1    jruoho 
    297       1.1.1.7  christos         AcpiOsPrintf ("***Break*** at AML offset %X\n", AmlOffset);
    298           1.1    jruoho         AcpiGbl_CmSingleStep = TRUE;
    299           1.1    jruoho         AcpiGbl_StepToNextCall = FALSE;
    300           1.1    jruoho         WalkState->MethodBreakpoint = 0;
    301           1.1    jruoho     }
    302           1.1    jruoho 
    303           1.1    jruoho     /* Check for user breakpoint (Must be on exact Aml offset) */
    304           1.1    jruoho 
    305           1.1    jruoho     else if (WalkState->UserBreakpoint &&
    306       1.1.1.7  christos             (WalkState->UserBreakpoint == AmlOffset))
    307           1.1    jruoho     {
    308           1.1    jruoho         AcpiOsPrintf ("***UserBreakpoint*** at AML offset %X\n",
    309       1.1.1.7  christos             AmlOffset);
    310           1.1    jruoho         AcpiGbl_CmSingleStep = TRUE;
    311           1.1    jruoho         AcpiGbl_StepToNextCall = FALSE;
    312           1.1    jruoho         WalkState->MethodBreakpoint = 0;
    313           1.1    jruoho     }
    314           1.1    jruoho 
    315           1.1    jruoho     /*
    316           1.1    jruoho      * Check if this is an opcode that we are interested in --
    317           1.1    jruoho      * namely, opcodes that have arguments
    318           1.1    jruoho      */
    319           1.1    jruoho     if (Op->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
    320           1.1    jruoho     {
    321           1.1    jruoho         return (AE_OK);
    322           1.1    jruoho     }
    323           1.1    jruoho 
    324           1.1    jruoho     switch (OpcodeClass)
    325           1.1    jruoho     {
    326           1.1    jruoho     case AML_CLASS_UNKNOWN:
    327       1.1.1.4  christos     case AML_CLASS_ARGUMENT:    /* constants, literals, etc. do nothing */
    328       1.1.1.4  christos 
    329           1.1    jruoho         return (AE_OK);
    330           1.1    jruoho 
    331           1.1    jruoho     default:
    332       1.1.1.4  christos 
    333           1.1    jruoho         /* All other opcodes -- continue */
    334           1.1    jruoho         break;
    335           1.1    jruoho     }
    336           1.1    jruoho 
    337           1.1    jruoho     /*
    338           1.1    jruoho      * Under certain debug conditions, display this opcode and its operands
    339           1.1    jruoho      */
    340           1.1    jruoho     if ((AcpiGbl_DbOutputToFile)            ||
    341           1.1    jruoho         (AcpiGbl_CmSingleStep)              ||
    342           1.1    jruoho         (AcpiDbgLevel & ACPI_LV_PARSE))
    343           1.1    jruoho     {
    344           1.1    jruoho         if ((AcpiGbl_DbOutputToFile)        ||
    345           1.1    jruoho             (AcpiDbgLevel & ACPI_LV_PARSE))
    346           1.1    jruoho         {
    347      1.1.1.11  christos             AcpiOsPrintf ("\nAML Debug: Next AML Opcode to execute:\n");
    348           1.1    jruoho         }
    349           1.1    jruoho 
    350           1.1    jruoho         /*
    351           1.1    jruoho          * Display this op (and only this op - zero out the NEXT field
    352           1.1    jruoho          * temporarily, and disable parser trace output for the duration of
    353           1.1    jruoho          * the display because we don't want the extraneous debug output)
    354           1.1    jruoho          */
    355           1.1    jruoho         OriginalDebugLevel = AcpiDbgLevel;
    356           1.1    jruoho         AcpiDbgLevel &= ~(ACPI_LV_PARSE | ACPI_LV_FUNCTIONS);
    357           1.1    jruoho         Next = Op->Common.Next;
    358           1.1    jruoho         Op->Common.Next = NULL;
    359           1.1    jruoho 
    360  1.1.1.12.2.1  christos         /* Now we can disassemble and display it */
    361           1.1    jruoho 
    362       1.1.1.7  christos #ifdef ACPI_DISASSEMBLER
    363  1.1.1.12.2.1  christos         AcpiDmDisassemble (WalkState, AcpiDbGetDisplayOp (WalkState, Op),
    364  1.1.1.12.2.1  christos             ACPI_UINT32_MAX);
    365  1.1.1.12.2.1  christos #else
    366  1.1.1.12.2.1  christos         /*
    367  1.1.1.12.2.1  christos          * The AML Disassembler is not configured - at least we can
    368  1.1.1.12.2.1  christos          * display the opcode value and name
    369  1.1.1.12.2.1  christos          */
    370  1.1.1.12.2.1  christos         AcpiOsPrintf ("AML Opcode: %4.4X  %s\n", Op->Common.AmlOpcode,
    371  1.1.1.12.2.1  christos             AcpiPsGetOpcodeName (Op->Common.AmlOpcode));
    372       1.1.1.7  christos #endif
    373           1.1    jruoho 
    374           1.1    jruoho         if ((Op->Common.AmlOpcode == AML_IF_OP) ||
    375           1.1    jruoho             (Op->Common.AmlOpcode == AML_WHILE_OP))
    376           1.1    jruoho         {
    377           1.1    jruoho             if (WalkState->ControlState->Common.Value)
    378           1.1    jruoho             {
    379           1.1    jruoho                 AcpiOsPrintf ("Predicate = [True], IF block was executed\n");
    380           1.1    jruoho             }
    381           1.1    jruoho             else
    382           1.1    jruoho             {
    383           1.1    jruoho                 AcpiOsPrintf ("Predicate = [False], Skipping IF block\n");
    384           1.1    jruoho             }
    385           1.1    jruoho         }
    386           1.1    jruoho         else if (Op->Common.AmlOpcode == AML_ELSE_OP)
    387           1.1    jruoho         {
    388           1.1    jruoho             AcpiOsPrintf ("Predicate = [False], ELSE block was executed\n");
    389           1.1    jruoho         }
    390           1.1    jruoho 
    391           1.1    jruoho         /* Restore everything */
    392           1.1    jruoho 
    393           1.1    jruoho         Op->Common.Next = Next;
    394           1.1    jruoho         AcpiOsPrintf ("\n");
    395           1.1    jruoho         if ((AcpiGbl_DbOutputToFile)        ||
    396           1.1    jruoho             (AcpiDbgLevel & ACPI_LV_PARSE))
    397           1.1    jruoho         {
    398           1.1    jruoho             AcpiOsPrintf ("\n");
    399           1.1    jruoho         }
    400           1.1    jruoho         AcpiDbgLevel = OriginalDebugLevel;
    401           1.1    jruoho     }
    402           1.1    jruoho 
    403           1.1    jruoho     /* If we are not single stepping, just continue executing the method */
    404           1.1    jruoho 
    405           1.1    jruoho     if (!AcpiGbl_CmSingleStep)
    406           1.1    jruoho     {
    407           1.1    jruoho         return (AE_OK);
    408           1.1    jruoho     }
    409           1.1    jruoho 
    410           1.1    jruoho     /*
    411           1.1    jruoho      * If we are executing a step-to-call command,
    412           1.1    jruoho      * Check if this is a method call.
    413           1.1    jruoho      */
    414           1.1    jruoho     if (AcpiGbl_StepToNextCall)
    415           1.1    jruoho     {
    416           1.1    jruoho         if (Op->Common.AmlOpcode != AML_INT_METHODCALL_OP)
    417           1.1    jruoho         {
    418           1.1    jruoho             /* Not a method call, just keep executing */
    419           1.1    jruoho 
    420           1.1    jruoho             return (AE_OK);
    421           1.1    jruoho         }
    422           1.1    jruoho 
    423           1.1    jruoho         /* Found a method call, stop executing */
    424           1.1    jruoho 
    425           1.1    jruoho         AcpiGbl_StepToNextCall = FALSE;
    426           1.1    jruoho     }
    427           1.1    jruoho 
    428           1.1    jruoho     /*
    429           1.1    jruoho      * If the next opcode is a method call, we will "step over" it
    430           1.1    jruoho      * by default.
    431           1.1    jruoho      */
    432           1.1    jruoho     if (Op->Common.AmlOpcode == AML_INT_METHODCALL_OP)
    433           1.1    jruoho     {
    434           1.1    jruoho         /* Force no more single stepping while executing called method */
    435           1.1    jruoho 
    436           1.1    jruoho         AcpiGbl_CmSingleStep = FALSE;
    437           1.1    jruoho 
    438           1.1    jruoho         /*
    439           1.1    jruoho          * Set the breakpoint on/before the call, it will stop execution
    440           1.1    jruoho          * as soon as we return
    441           1.1    jruoho          */
    442           1.1    jruoho         WalkState->MethodBreakpoint = 1;  /* Must be non-zero! */
    443           1.1    jruoho     }
    444           1.1    jruoho 
    445           1.1    jruoho 
    446      1.1.1.10  christos     AcpiExExitInterpreter ();
    447           1.1    jruoho     Status = AcpiDbStartCommand (WalkState, Op);
    448      1.1.1.10  christos     AcpiExEnterInterpreter ();
    449           1.1    jruoho 
    450           1.1    jruoho     /* User commands complete, continue execution of the interrupted method */
    451           1.1    jruoho 
    452           1.1    jruoho     return (Status);
    453           1.1    jruoho }
    454           1.1    jruoho 
    455           1.1    jruoho 
    456           1.1    jruoho /*******************************************************************************
    457           1.1    jruoho  *
    458       1.1.1.8  christos  * FUNCTION:    AcpiInitializeDebugger
    459           1.1    jruoho  *
    460           1.1    jruoho  * PARAMETERS:  None
    461           1.1    jruoho  *
    462           1.1    jruoho  * RETURN:      Status
    463           1.1    jruoho  *
    464           1.1    jruoho  * DESCRIPTION: Init and start debugger
    465           1.1    jruoho  *
    466           1.1    jruoho  ******************************************************************************/
    467           1.1    jruoho 
    468           1.1    jruoho ACPI_STATUS
    469       1.1.1.8  christos AcpiInitializeDebugger (
    470           1.1    jruoho     void)
    471           1.1    jruoho {
    472           1.1    jruoho     ACPI_STATUS             Status;
    473           1.1    jruoho 
    474           1.1    jruoho 
    475       1.1.1.8  christos     ACPI_FUNCTION_TRACE (AcpiInitializeDebugger);
    476       1.1.1.4  christos 
    477       1.1.1.4  christos 
    478           1.1    jruoho     /* Init globals */
    479           1.1    jruoho 
    480           1.1    jruoho     AcpiGbl_DbBuffer            = NULL;
    481           1.1    jruoho     AcpiGbl_DbFilename          = NULL;
    482           1.1    jruoho     AcpiGbl_DbOutputToFile      = FALSE;
    483           1.1    jruoho 
    484           1.1    jruoho     AcpiGbl_DbDebugLevel        = ACPI_LV_VERBOSITY2;
    485           1.1    jruoho     AcpiGbl_DbConsoleDebugLevel = ACPI_NORMAL_DEFAULT | ACPI_LV_TABLES;
    486           1.1    jruoho     AcpiGbl_DbOutputFlags       = ACPI_DB_CONSOLE_OUTPUT;
    487           1.1    jruoho 
    488       1.1.1.6  christos     AcpiGbl_DbOpt_NoIniMethods  = FALSE;
    489           1.1    jruoho 
    490           1.1    jruoho     AcpiGbl_DbBuffer = AcpiOsAllocate (ACPI_DEBUG_BUFFER_SIZE);
    491           1.1    jruoho     if (!AcpiGbl_DbBuffer)
    492           1.1    jruoho     {
    493       1.1.1.4  christos         return_ACPI_STATUS (AE_NO_MEMORY);
    494           1.1    jruoho     }
    495       1.1.1.7  christos     memset (AcpiGbl_DbBuffer, 0, ACPI_DEBUG_BUFFER_SIZE);
    496           1.1    jruoho 
    497           1.1    jruoho     /* Initial scope is the root */
    498           1.1    jruoho 
    499       1.1.1.4  christos     AcpiGbl_DbScopeBuf [0] = AML_ROOT_PREFIX;
    500           1.1    jruoho     AcpiGbl_DbScopeBuf [1] =  0;
    501           1.1    jruoho     AcpiGbl_DbScopeNode = AcpiGbl_RootNode;
    502           1.1    jruoho 
    503       1.1.1.8  christos     /* Initialize user commands loop */
    504       1.1.1.8  christos 
    505       1.1.1.8  christos     AcpiGbl_DbTerminateLoop = FALSE;
    506       1.1.1.8  christos 
    507           1.1    jruoho     /*
    508           1.1    jruoho      * If configured for multi-thread support, the debug executor runs in
    509           1.1    jruoho      * a separate thread so that the front end can be in another address
    510           1.1    jruoho      * space, environment, or even another machine.
    511           1.1    jruoho      */
    512           1.1    jruoho     if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED)
    513           1.1    jruoho     {
    514           1.1    jruoho         /* These were created with one unit, grab it */
    515           1.1    jruoho 
    516       1.1.1.9  christos         Status = AcpiOsInitializeDebugger ();
    517           1.1    jruoho         if (ACPI_FAILURE (Status))
    518           1.1    jruoho         {
    519           1.1    jruoho             AcpiOsPrintf ("Could not get debugger mutex\n");
    520       1.1.1.4  christos             return_ACPI_STATUS (Status);
    521           1.1    jruoho         }
    522           1.1    jruoho 
    523           1.1    jruoho         /* Create the debug execution thread to execute commands */
    524           1.1    jruoho 
    525       1.1.1.8  christos         AcpiGbl_DbThreadsTerminated = FALSE;
    526       1.1.1.8  christos         Status = AcpiOsExecute (OSL_DEBUGGER_MAIN_THREAD,
    527       1.1.1.8  christos             AcpiDbExecuteThread, NULL);
    528           1.1    jruoho         if (ACPI_FAILURE (Status))
    529           1.1    jruoho         {
    530       1.1.1.8  christos             ACPI_EXCEPTION ((AE_INFO, Status,
    531       1.1.1.8  christos                 "Could not start debugger thread"));
    532       1.1.1.8  christos             AcpiGbl_DbThreadsTerminated = TRUE;
    533       1.1.1.4  christos             return_ACPI_STATUS (Status);
    534           1.1    jruoho         }
    535           1.1    jruoho     }
    536       1.1.1.8  christos     else
    537           1.1    jruoho     {
    538       1.1.1.8  christos         AcpiGbl_DbThreadId = AcpiOsGetThreadId ();
    539           1.1    jruoho     }
    540           1.1    jruoho 
    541       1.1.1.4  christos     return_ACPI_STATUS (AE_OK);
    542           1.1    jruoho }
    543           1.1    jruoho 
    544       1.1.1.8  christos ACPI_EXPORT_SYMBOL (AcpiInitializeDebugger)
    545       1.1.1.8  christos 
    546           1.1    jruoho 
    547           1.1    jruoho /*******************************************************************************
    548           1.1    jruoho  *
    549       1.1.1.8  christos  * FUNCTION:    AcpiTerminateDebugger
    550           1.1    jruoho  *
    551           1.1    jruoho  * PARAMETERS:  None
    552           1.1    jruoho  *
    553           1.1    jruoho  * RETURN:      None
    554           1.1    jruoho  *
    555           1.1    jruoho  * DESCRIPTION: Stop debugger
    556           1.1    jruoho  *
    557           1.1    jruoho  ******************************************************************************/
    558           1.1    jruoho 
    559           1.1    jruoho void
    560       1.1.1.8  christos AcpiTerminateDebugger (
    561           1.1    jruoho     void)
    562           1.1    jruoho {
    563           1.1    jruoho 
    564       1.1.1.8  christos     /* Terminate the AML Debugger */
    565       1.1.1.8  christos 
    566       1.1.1.8  christos     AcpiGbl_DbTerminateLoop = TRUE;
    567       1.1.1.8  christos 
    568       1.1.1.8  christos     if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED)
    569       1.1.1.8  christos     {
    570       1.1.1.8  christos         /* Wait the AML Debugger threads */
    571       1.1.1.8  christos 
    572       1.1.1.8  christos         while (!AcpiGbl_DbThreadsTerminated)
    573       1.1.1.8  christos         {
    574       1.1.1.8  christos             AcpiOsSleep (100);
    575       1.1.1.8  christos         }
    576       1.1.1.9  christos 
    577       1.1.1.9  christos         AcpiOsTerminateDebugger ();
    578       1.1.1.8  christos     }
    579       1.1.1.8  christos 
    580           1.1    jruoho     if (AcpiGbl_DbBuffer)
    581           1.1    jruoho     {
    582           1.1    jruoho         AcpiOsFree (AcpiGbl_DbBuffer);
    583       1.1.1.4  christos         AcpiGbl_DbBuffer = NULL;
    584           1.1    jruoho     }
    585       1.1.1.4  christos 
    586       1.1.1.4  christos     /* Ensure that debug output is now disabled */
    587       1.1.1.4  christos 
    588       1.1.1.4  christos     AcpiGbl_DbOutputFlags = ACPI_DB_DISABLE_OUTPUT;
    589           1.1    jruoho }
    590           1.1    jruoho 
    591       1.1.1.8  christos ACPI_EXPORT_SYMBOL (AcpiTerminateDebugger)
    592       1.1.1.8  christos 
    593           1.1    jruoho 
    594           1.1    jruoho /*******************************************************************************
    595           1.1    jruoho  *
    596       1.1.1.8  christos  * FUNCTION:    AcpiSetDebuggerThreadId
    597           1.1    jruoho  *
    598       1.1.1.8  christos  * PARAMETERS:  ThreadId        - Debugger thread ID
    599           1.1    jruoho  *
    600       1.1.1.8  christos  * RETURN:      None
    601           1.1    jruoho  *
    602       1.1.1.8  christos  * DESCRIPTION: Set debugger thread ID
    603           1.1    jruoho  *
    604           1.1    jruoho  ******************************************************************************/
    605           1.1    jruoho 
    606           1.1    jruoho void
    607       1.1.1.8  christos AcpiSetDebuggerThreadId (
    608       1.1.1.8  christos     ACPI_THREAD_ID          ThreadId)
    609           1.1    jruoho {
    610       1.1.1.8  christos     AcpiGbl_DbThreadId = ThreadId;
    611           1.1    jruoho }
    612           1.1    jruoho 
    613       1.1.1.8  christos ACPI_EXPORT_SYMBOL (AcpiSetDebuggerThreadId)
    614