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