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