xref: /onnv-gate/usr/src/uts/intel/io/acpica/debugger/dbxface.c (revision 3446:5903aece022d)
1*3446Smrj /*******************************************************************************
2*3446Smrj  *
3*3446Smrj  * Module Name: dbxface - AML Debugger external interfaces
4*3446Smrj  *              $Revision: 1.77 $
5*3446Smrj  *
6*3446Smrj  ******************************************************************************/
7*3446Smrj 
8*3446Smrj /******************************************************************************
9*3446Smrj  *
10*3446Smrj  * 1. Copyright Notice
11*3446Smrj  *
12*3446Smrj  * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp.
13*3446Smrj  * All rights reserved.
14*3446Smrj  *
15*3446Smrj  * 2. License
16*3446Smrj  *
17*3446Smrj  * 2.1. This is your license from Intel Corp. under its intellectual property
18*3446Smrj  * rights.  You may have additional license terms from the party that provided
19*3446Smrj  * you this software, covering your right to use that party's intellectual
20*3446Smrj  * property rights.
21*3446Smrj  *
22*3446Smrj  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23*3446Smrj  * copy of the source code appearing in this file ("Covered Code") an
24*3446Smrj  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25*3446Smrj  * base code distributed originally by Intel ("Original Intel Code") to copy,
26*3446Smrj  * make derivatives, distribute, use and display any portion of the Covered
27*3446Smrj  * Code in any form, with the right to sublicense such rights; and
28*3446Smrj  *
29*3446Smrj  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30*3446Smrj  * license (with the right to sublicense), under only those claims of Intel
31*3446Smrj  * patents that are infringed by the Original Intel Code, to make, use, sell,
32*3446Smrj  * offer to sell, and import the Covered Code and derivative works thereof
33*3446Smrj  * solely to the minimum extent necessary to exercise the above copyright
34*3446Smrj  * license, and in no event shall the patent license extend to any additions
35*3446Smrj  * to or modifications of the Original Intel Code.  No other license or right
36*3446Smrj  * is granted directly or by implication, estoppel or otherwise;
37*3446Smrj  *
38*3446Smrj  * The above copyright and patent license is granted only if the following
39*3446Smrj  * conditions are met:
40*3446Smrj  *
41*3446Smrj  * 3. Conditions
42*3446Smrj  *
43*3446Smrj  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44*3446Smrj  * Redistribution of source code of any substantial portion of the Covered
45*3446Smrj  * Code or modification with rights to further distribute source must include
46*3446Smrj  * the above Copyright Notice, the above License, this list of Conditions,
47*3446Smrj  * and the following Disclaimer and Export Compliance provision.  In addition,
48*3446Smrj  * Licensee must cause all Covered Code to which Licensee contributes to
49*3446Smrj  * contain a file documenting the changes Licensee made to create that Covered
50*3446Smrj  * Code and the date of any change.  Licensee must include in that file the
51*3446Smrj  * documentation of any changes made by any predecessor Licensee.  Licensee
52*3446Smrj  * must include a prominent statement that the modification is derived,
53*3446Smrj  * directly or indirectly, from Original Intel Code.
54*3446Smrj  *
55*3446Smrj  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56*3446Smrj  * Redistribution of source code of any substantial portion of the Covered
57*3446Smrj  * Code or modification without rights to further distribute source must
58*3446Smrj  * include the following Disclaimer and Export Compliance provision in the
59*3446Smrj  * documentation and/or other materials provided with distribution.  In
60*3446Smrj  * addition, Licensee may not authorize further sublicense of source of any
61*3446Smrj  * portion of the Covered Code, and must include terms to the effect that the
62*3446Smrj  * license from Licensee to its licensee is limited to the intellectual
63*3446Smrj  * property embodied in the software Licensee provides to its licensee, and
64*3446Smrj  * not to intellectual property embodied in modifications its licensee may
65*3446Smrj  * make.
66*3446Smrj  *
67*3446Smrj  * 3.3. Redistribution of Executable. Redistribution in executable form of any
68*3446Smrj  * substantial portion of the Covered Code or modification must reproduce the
69*3446Smrj  * above Copyright Notice, and the following Disclaimer and Export Compliance
70*3446Smrj  * provision in the documentation and/or other materials provided with the
71*3446Smrj  * distribution.
72*3446Smrj  *
73*3446Smrj  * 3.4. Intel retains all right, title, and interest in and to the Original
74*3446Smrj  * Intel Code.
75*3446Smrj  *
76*3446Smrj  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77*3446Smrj  * Intel shall be used in advertising or otherwise to promote the sale, use or
78*3446Smrj  * other dealings in products derived from or relating to the Covered Code
79*3446Smrj  * without prior written authorization from Intel.
80*3446Smrj  *
81*3446Smrj  * 4. Disclaimer and Export Compliance
82*3446Smrj  *
83*3446Smrj  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84*3446Smrj  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85*3446Smrj  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86*3446Smrj  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87*3446Smrj  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88*3446Smrj  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89*3446Smrj  * PARTICULAR PURPOSE.
90*3446Smrj  *
91*3446Smrj  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92*3446Smrj  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93*3446Smrj  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94*3446Smrj  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95*3446Smrj  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96*3446Smrj  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97*3446Smrj  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98*3446Smrj  * LIMITED REMEDY.
99*3446Smrj  *
100*3446Smrj  * 4.3. Licensee shall not export, either directly or indirectly, any of this
101*3446Smrj  * software or system incorporating such software without first obtaining any
102*3446Smrj  * required license or other approval from the U. S. Department of Commerce or
103*3446Smrj  * any other agency or department of the United States Government.  In the
104*3446Smrj  * event Licensee exports any such software from the United States or
105*3446Smrj  * re-exports any such software from a foreign destination, Licensee shall
106*3446Smrj  * ensure that the distribution and export/re-export of the software is in
107*3446Smrj  * compliance with all laws, regulations, orders, or other restrictions of the
108*3446Smrj  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109*3446Smrj  * any of its subsidiaries will export/re-export any technical data, process,
110*3446Smrj  * software, or service, directly or indirectly, to any country for which the
111*3446Smrj  * United States government or any agency thereof requires an export license,
112*3446Smrj  * other governmental approval, or letter of assurance, without first obtaining
113*3446Smrj  * such license, approval or letter.
114*3446Smrj  *
115*3446Smrj  *****************************************************************************/
116*3446Smrj 
117*3446Smrj 
118*3446Smrj #include "acpi.h"
119*3446Smrj #include "amlcode.h"
120*3446Smrj #include "acdebug.h"
121*3446Smrj #include "acdisasm.h"
122*3446Smrj 
123*3446Smrj 
124*3446Smrj #ifdef ACPI_DEBUGGER
125*3446Smrj 
126*3446Smrj #define _COMPONENT          ACPI_CA_DEBUGGER
127*3446Smrj         ACPI_MODULE_NAME    ("dbxface")
128*3446Smrj 
129*3446Smrj 
130*3446Smrj /* Local prototypes */
131*3446Smrj 
132*3446Smrj static ACPI_STATUS
133*3446Smrj AcpiDbStartCommand (
134*3446Smrj     ACPI_WALK_STATE         *WalkState,
135*3446Smrj     ACPI_PARSE_OBJECT       *Op);
136*3446Smrj 
137*3446Smrj #ifdef ACPI_OBSOLETE_FUNCTIONS
138*3446Smrj void
139*3446Smrj AcpiDbMethodEnd (
140*3446Smrj     ACPI_WALK_STATE         *WalkState);
141*3446Smrj #endif
142*3446Smrj 
143*3446Smrj 
144*3446Smrj /*******************************************************************************
145*3446Smrj  *
146*3446Smrj  * FUNCTION:    AcpiDbStartCommand
147*3446Smrj  *
148*3446Smrj  * PARAMETERS:  WalkState       - Current walk
149*3446Smrj  *              Op              - Current executing Op, from AML interpreter
150*3446Smrj  *
151*3446Smrj  * RETURN:      Status
152*3446Smrj  *
153*3446Smrj  * DESCRIPTION: Enter debugger command loop
154*3446Smrj  *
155*3446Smrj  ******************************************************************************/
156*3446Smrj 
157*3446Smrj static ACPI_STATUS
158*3446Smrj AcpiDbStartCommand (
159*3446Smrj     ACPI_WALK_STATE         *WalkState,
160*3446Smrj     ACPI_PARSE_OBJECT       *Op)
161*3446Smrj {
162*3446Smrj     ACPI_STATUS             Status;
163*3446Smrj 
164*3446Smrj 
165*3446Smrj     /* TBD: [Investigate] are there namespace locking issues here? */
166*3446Smrj 
167*3446Smrj     /* AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE); */
168*3446Smrj 
169*3446Smrj     /* Go into the command loop and await next user command */
170*3446Smrj 
171*3446Smrj 
172*3446Smrj     AcpiGbl_MethodExecuting = TRUE;
173*3446Smrj     Status = AE_CTRL_TRUE;
174*3446Smrj     while (Status == AE_CTRL_TRUE)
175*3446Smrj     {
176*3446Smrj         if (AcpiGbl_DebuggerConfiguration == DEBUGGER_MULTI_THREADED)
177*3446Smrj         {
178*3446Smrj             /* Handshake with the front-end that gets user command lines */
179*3446Smrj 
180*3446Smrj             Status = AcpiUtReleaseMutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
181*3446Smrj             if (ACPI_FAILURE (Status))
182*3446Smrj             {
183*3446Smrj                 return (Status);
184*3446Smrj             }
185*3446Smrj             Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY);
186*3446Smrj             if (ACPI_FAILURE (Status))
187*3446Smrj             {
188*3446Smrj                 return (Status);
189*3446Smrj             }
190*3446Smrj         }
191*3446Smrj         else
192*3446Smrj         {
193*3446Smrj             /* Single threaded, we must get a command line ourselves */
194*3446Smrj 
195*3446Smrj             /* Force output to console until a command is entered */
196*3446Smrj 
197*3446Smrj             AcpiDbSetOutputDestination (ACPI_DB_CONSOLE_OUTPUT);
198*3446Smrj 
199*3446Smrj             /* Different prompt if method is executing */
200*3446Smrj 
201*3446Smrj             if (!AcpiGbl_MethodExecuting)
202*3446Smrj             {
203*3446Smrj                 AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_COMMAND_PROMPT);
204*3446Smrj             }
205*3446Smrj             else
206*3446Smrj             {
207*3446Smrj                 AcpiOsPrintf ("%1c ", ACPI_DEBUGGER_EXECUTE_PROMPT);
208*3446Smrj             }
209*3446Smrj 
210*3446Smrj             /* Get the user input line */
211*3446Smrj 
212*3446Smrj             (void) AcpiOsGetLine (AcpiGbl_DbLineBuf);
213*3446Smrj         }
214*3446Smrj 
215*3446Smrj         Status = AcpiDbCommandDispatch (AcpiGbl_DbLineBuf, WalkState, Op);
216*3446Smrj     }
217*3446Smrj 
218*3446Smrj     /* AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE); */
219*3446Smrj 
220*3446Smrj     return (Status);
221*3446Smrj }
222*3446Smrj 
223*3446Smrj 
224*3446Smrj /*******************************************************************************
225*3446Smrj  *
226*3446Smrj  * FUNCTION:    AcpiDbSingleStep
227*3446Smrj  *
228*3446Smrj  * PARAMETERS:  WalkState       - Current walk
229*3446Smrj  *              Op              - Current executing op (from aml interpreter)
230*3446Smrj  *              OpcodeClass     - Class of the current AML Opcode
231*3446Smrj  *
232*3446Smrj  * RETURN:      Status
233*3446Smrj  *
234*3446Smrj  * DESCRIPTION: Called just before execution of an AML opcode.
235*3446Smrj  *
236*3446Smrj  ******************************************************************************/
237*3446Smrj 
238*3446Smrj ACPI_STATUS
239*3446Smrj AcpiDbSingleStep (
240*3446Smrj     ACPI_WALK_STATE         *WalkState,
241*3446Smrj     ACPI_PARSE_OBJECT       *Op,
242*3446Smrj     UINT32                  OpcodeClass)
243*3446Smrj {
244*3446Smrj     ACPI_PARSE_OBJECT       *Next;
245*3446Smrj     ACPI_STATUS             Status = AE_OK;
246*3446Smrj     UINT32                  OriginalDebugLevel;
247*3446Smrj     ACPI_PARSE_OBJECT       *DisplayOp;
248*3446Smrj     ACPI_PARSE_OBJECT       *ParentOp;
249*3446Smrj 
250*3446Smrj 
251*3446Smrj     ACPI_FUNCTION_ENTRY ();
252*3446Smrj 
253*3446Smrj 
254*3446Smrj     /* Check the abort flag */
255*3446Smrj 
256*3446Smrj     if (AcpiGbl_AbortMethod)
257*3446Smrj     {
258*3446Smrj         AcpiGbl_AbortMethod = FALSE;
259*3446Smrj         return (AE_ABORT_METHOD);
260*3446Smrj     }
261*3446Smrj 
262*3446Smrj     /* Check for single-step breakpoint */
263*3446Smrj 
264*3446Smrj     if (WalkState->MethodBreakpoint &&
265*3446Smrj        (WalkState->MethodBreakpoint <= Op->Common.AmlOffset))
266*3446Smrj     {
267*3446Smrj         /* Check if the breakpoint has been reached or passed */
268*3446Smrj         /* Hit the breakpoint, resume single step, reset breakpoint */
269*3446Smrj 
270*3446Smrj         AcpiOsPrintf ("***Break*** at AML offset %X\n", Op->Common.AmlOffset);
271*3446Smrj         AcpiGbl_CmSingleStep = TRUE;
272*3446Smrj         AcpiGbl_StepToNextCall = FALSE;
273*3446Smrj         WalkState->MethodBreakpoint = 0;
274*3446Smrj     }
275*3446Smrj 
276*3446Smrj     /* Check for user breakpoint (Must be on exact Aml offset) */
277*3446Smrj 
278*3446Smrj     else if (WalkState->UserBreakpoint &&
279*3446Smrj             (WalkState->UserBreakpoint == Op->Common.AmlOffset))
280*3446Smrj     {
281*3446Smrj         AcpiOsPrintf ("***UserBreakpoint*** at AML offset %X\n",
282*3446Smrj             Op->Common.AmlOffset);
283*3446Smrj         AcpiGbl_CmSingleStep = TRUE;
284*3446Smrj         AcpiGbl_StepToNextCall = FALSE;
285*3446Smrj         WalkState->MethodBreakpoint = 0;
286*3446Smrj     }
287*3446Smrj 
288*3446Smrj     /*
289*3446Smrj      * Check if this is an opcode that we are interested in --
290*3446Smrj      * namely, opcodes that have arguments
291*3446Smrj      */
292*3446Smrj     if (Op->Common.AmlOpcode == AML_INT_NAMEDFIELD_OP)
293*3446Smrj     {
294*3446Smrj         return (AE_OK);
295*3446Smrj     }
296*3446Smrj 
297*3446Smrj     switch (OpcodeClass)
298*3446Smrj     {
299*3446Smrj     case AML_CLASS_UNKNOWN:
300*3446Smrj     case AML_CLASS_ARGUMENT:    /* constants, literals, etc.  do nothing */
301*3446Smrj         return (AE_OK);
302*3446Smrj 
303*3446Smrj     default:
304*3446Smrj         /* All other opcodes -- continue */
305*3446Smrj         break;
306*3446Smrj     }
307*3446Smrj 
308*3446Smrj     /*
309*3446Smrj      * Under certain debug conditions, display this opcode and its operands
310*3446Smrj      */
311*3446Smrj     if ((AcpiGbl_DbOutputToFile)            ||
312*3446Smrj         (AcpiGbl_CmSingleStep)              ||
313*3446Smrj         (AcpiDbgLevel & ACPI_LV_PARSE))
314*3446Smrj     {
315*3446Smrj         if ((AcpiGbl_DbOutputToFile)        ||
316*3446Smrj             (AcpiDbgLevel & ACPI_LV_PARSE))
317*3446Smrj         {
318*3446Smrj             AcpiOsPrintf ("\n[AmlDebug] Next AML Opcode to execute:\n");
319*3446Smrj         }
320*3446Smrj 
321*3446Smrj         /*
322*3446Smrj          * Display this op (and only this op - zero out the NEXT field
323*3446Smrj          * temporarily, and disable parser trace output for the duration of
324*3446Smrj          * the display because we don't want the extraneous debug output)
325*3446Smrj          */
326*3446Smrj         OriginalDebugLevel = AcpiDbgLevel;
327*3446Smrj         AcpiDbgLevel &= ~(ACPI_LV_PARSE | ACPI_LV_FUNCTIONS);
328*3446Smrj         Next = Op->Common.Next;
329*3446Smrj         Op->Common.Next = NULL;
330*3446Smrj 
331*3446Smrj 
332*3446Smrj         DisplayOp = Op;
333*3446Smrj         ParentOp = Op->Common.Parent;
334*3446Smrj         if (ParentOp)
335*3446Smrj         {
336*3446Smrj             if ((WalkState->ControlState) &&
337*3446Smrj                 (WalkState->ControlState->Common.State ==
338*3446Smrj                     ACPI_CONTROL_PREDICATE_EXECUTING))
339*3446Smrj             {
340*3446Smrj                 /*
341*3446Smrj                  * We are executing the predicate of an IF or WHILE statement
342*3446Smrj                  * Search upwards for the containing IF or WHILE so that the
343*3446Smrj                  * entire predicate can be displayed.
344*3446Smrj                  */
345*3446Smrj                 while (ParentOp)
346*3446Smrj                 {
347*3446Smrj                     if ((ParentOp->Common.AmlOpcode == AML_IF_OP) ||
348*3446Smrj                         (ParentOp->Common.AmlOpcode == AML_WHILE_OP))
349*3446Smrj                     {
350*3446Smrj                         DisplayOp = ParentOp;
351*3446Smrj                         break;
352*3446Smrj                     }
353*3446Smrj                     ParentOp = ParentOp->Common.Parent;
354*3446Smrj                 }
355*3446Smrj             }
356*3446Smrj             else
357*3446Smrj             {
358*3446Smrj                 while (ParentOp)
359*3446Smrj                 {
360*3446Smrj                     if ((ParentOp->Common.AmlOpcode == AML_IF_OP)     ||
361*3446Smrj                         (ParentOp->Common.AmlOpcode == AML_ELSE_OP)   ||
362*3446Smrj                         (ParentOp->Common.AmlOpcode == AML_SCOPE_OP)  ||
363*3446Smrj                         (ParentOp->Common.AmlOpcode == AML_METHOD_OP) ||
364*3446Smrj                         (ParentOp->Common.AmlOpcode == AML_WHILE_OP))
365*3446Smrj                     {
366*3446Smrj                         break;
367*3446Smrj                     }
368*3446Smrj                     DisplayOp = ParentOp;
369*3446Smrj                     ParentOp = ParentOp->Common.Parent;
370*3446Smrj                 }
371*3446Smrj             }
372*3446Smrj         }
373*3446Smrj 
374*3446Smrj         /* Now we can display it */
375*3446Smrj 
376*3446Smrj         AcpiDmDisassemble (WalkState, DisplayOp, ACPI_UINT32_MAX);
377*3446Smrj 
378*3446Smrj         if ((Op->Common.AmlOpcode == AML_IF_OP) ||
379*3446Smrj             (Op->Common.AmlOpcode == AML_WHILE_OP))
380*3446Smrj         {
381*3446Smrj             if (WalkState->ControlState->Common.Value)
382*3446Smrj             {
383*3446Smrj                 AcpiOsPrintf ("Predicate = [True], IF block was executed\n");
384*3446Smrj             }
385*3446Smrj             else
386*3446Smrj             {
387*3446Smrj                 AcpiOsPrintf ("Predicate = [False], Skipping IF block\n");
388*3446Smrj             }
389*3446Smrj         }
390*3446Smrj         else if (Op->Common.AmlOpcode == AML_ELSE_OP)
391*3446Smrj         {
392*3446Smrj             AcpiOsPrintf ("Predicate = [False], ELSE block was executed\n");
393*3446Smrj         }
394*3446Smrj 
395*3446Smrj         /* Restore everything */
396*3446Smrj 
397*3446Smrj         Op->Common.Next = Next;
398*3446Smrj         AcpiOsPrintf ("\n");
399*3446Smrj         if ((AcpiGbl_DbOutputToFile)        ||
400*3446Smrj             (AcpiDbgLevel & ACPI_LV_PARSE))
401*3446Smrj         {
402*3446Smrj             AcpiOsPrintf ("\n");
403*3446Smrj         }
404*3446Smrj         AcpiDbgLevel = OriginalDebugLevel;
405*3446Smrj     }
406*3446Smrj 
407*3446Smrj     /* If we are not single stepping, just continue executing the method */
408*3446Smrj 
409*3446Smrj     if (!AcpiGbl_CmSingleStep)
410*3446Smrj     {
411*3446Smrj         return (AE_OK);
412*3446Smrj     }
413*3446Smrj 
414*3446Smrj     /*
415*3446Smrj      * If we are executing a step-to-call command,
416*3446Smrj      * Check if this is a method call.
417*3446Smrj      */
418*3446Smrj     if (AcpiGbl_StepToNextCall)
419*3446Smrj     {
420*3446Smrj         if (Op->Common.AmlOpcode != AML_INT_METHODCALL_OP)
421*3446Smrj         {
422*3446Smrj             /* Not a method call, just keep executing */
423*3446Smrj 
424*3446Smrj             return (AE_OK);
425*3446Smrj         }
426*3446Smrj 
427*3446Smrj         /* Found a method call, stop executing */
428*3446Smrj 
429*3446Smrj         AcpiGbl_StepToNextCall = FALSE;
430*3446Smrj     }
431*3446Smrj 
432*3446Smrj     /*
433*3446Smrj      * If the next opcode is a method call, we will "step over" it
434*3446Smrj      * by default.
435*3446Smrj      */
436*3446Smrj     if (Op->Common.AmlOpcode == AML_INT_METHODCALL_OP)
437*3446Smrj     {
438*3446Smrj         /* Force no more single stepping while executing called method */
439*3446Smrj 
440*3446Smrj         AcpiGbl_CmSingleStep = FALSE;
441*3446Smrj 
442*3446Smrj         /*
443*3446Smrj          * Set the breakpoint on/before the call, it will stop execution
444*3446Smrj          * as soon as we return
445*3446Smrj          */
446*3446Smrj         WalkState->MethodBreakpoint = 1;  /* Must be non-zero! */
447*3446Smrj     }
448*3446Smrj 
449*3446Smrj 
450*3446Smrj     Status = AcpiDbStartCommand (WalkState, Op);
451*3446Smrj 
452*3446Smrj     /* User commands complete, continue execution of the interrupted method */
453*3446Smrj 
454*3446Smrj     return (Status);
455*3446Smrj }
456*3446Smrj 
457*3446Smrj 
458*3446Smrj /*******************************************************************************
459*3446Smrj  *
460*3446Smrj  * FUNCTION:    AcpiDbInitialize
461*3446Smrj  *
462*3446Smrj  * PARAMETERS:  None
463*3446Smrj  *
464*3446Smrj  * RETURN:      Status
465*3446Smrj  *
466*3446Smrj  * DESCRIPTION: Init and start debugger
467*3446Smrj  *
468*3446Smrj  ******************************************************************************/
469*3446Smrj 
470*3446Smrj ACPI_STATUS
471*3446Smrj AcpiDbInitialize (
472*3446Smrj     void)
473*3446Smrj {
474*3446Smrj     ACPI_STATUS             Status;
475*3446Smrj 
476*3446Smrj 
477*3446Smrj     /* Init globals */
478*3446Smrj 
479*3446Smrj     AcpiGbl_DbBuffer            = NULL;
480*3446Smrj     AcpiGbl_DbFilename          = NULL;
481*3446Smrj     AcpiGbl_DbOutputToFile      = FALSE;
482*3446Smrj 
483*3446Smrj     AcpiGbl_DbDebugLevel        = ACPI_LV_VERBOSITY2;
484*3446Smrj     AcpiGbl_DbConsoleDebugLevel = ACPI_NORMAL_DEFAULT | ACPI_LV_TABLES;
485*3446Smrj     AcpiGbl_DbOutputFlags       = ACPI_DB_CONSOLE_OUTPUT;
486*3446Smrj 
487*3446Smrj     AcpiGbl_DbOpt_tables        = FALSE;
488*3446Smrj     AcpiGbl_DbOpt_disasm        = FALSE;
489*3446Smrj     AcpiGbl_DbOpt_stats         = FALSE;
490*3446Smrj     AcpiGbl_DbOpt_verbose       = TRUE;
491*3446Smrj     AcpiGbl_DbOpt_ini_methods   = TRUE;
492*3446Smrj 
493*3446Smrj     AcpiGbl_DbBuffer = AcpiOsAllocate (ACPI_DEBUG_BUFFER_SIZE);
494*3446Smrj     if (!AcpiGbl_DbBuffer)
495*3446Smrj     {
496*3446Smrj         return (AE_NO_MEMORY);
497*3446Smrj     }
498*3446Smrj     ACPI_MEMSET (AcpiGbl_DbBuffer, 0, ACPI_DEBUG_BUFFER_SIZE);
499*3446Smrj 
500*3446Smrj     /* Initial scope is the root */
501*3446Smrj 
502*3446Smrj     AcpiGbl_DbScopeBuf [0] = '\\';
503*3446Smrj     AcpiGbl_DbScopeBuf [1] =  0;
504*3446Smrj     AcpiGbl_DbScopeNode = AcpiGbl_RootNode;
505*3446Smrj 
506*3446Smrj     /*
507*3446Smrj      * If configured for multi-thread support, the debug executor runs in
508*3446Smrj      * a separate thread so that the front end can be in another address
509*3446Smrj      * space, environment, or even another machine.
510*3446Smrj      */
511*3446Smrj     if (AcpiGbl_DebuggerConfiguration & DEBUGGER_MULTI_THREADED)
512*3446Smrj     {
513*3446Smrj         /* These were created with one unit, grab it */
514*3446Smrj 
515*3446Smrj         Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_COMPLETE);
516*3446Smrj         if (ACPI_FAILURE (Status))
517*3446Smrj         {
518*3446Smrj             AcpiOsPrintf ("Could not get debugger mutex\n");
519*3446Smrj             return (Status);
520*3446Smrj         }
521*3446Smrj 
522*3446Smrj         Status = AcpiUtAcquireMutex (ACPI_MTX_DEBUG_CMD_READY);
523*3446Smrj         if (ACPI_FAILURE (Status))
524*3446Smrj         {
525*3446Smrj             AcpiOsPrintf ("Could not get debugger mutex\n");
526*3446Smrj             return (Status);
527*3446Smrj         }
528*3446Smrj 
529*3446Smrj         /* Create the debug execution thread to execute commands */
530*3446Smrj 
531*3446Smrj         Status = AcpiOsExecute (OSL_DEBUGGER_THREAD, AcpiDbExecuteThread, NULL);
532*3446Smrj         if (ACPI_FAILURE (Status))
533*3446Smrj         {
534*3446Smrj             AcpiOsPrintf ("Could not start debugger thread\n");
535*3446Smrj             return (Status);
536*3446Smrj         }
537*3446Smrj     }
538*3446Smrj 
539*3446Smrj     if (!AcpiGbl_DbOpt_verbose)
540*3446Smrj     {
541*3446Smrj         AcpiGbl_DbOpt_disasm = TRUE;
542*3446Smrj         AcpiGbl_DbOpt_stats = FALSE;
543*3446Smrj     }
544*3446Smrj 
545*3446Smrj     return (AE_OK);
546*3446Smrj }
547*3446Smrj 
548*3446Smrj 
549*3446Smrj /*******************************************************************************
550*3446Smrj  *
551*3446Smrj  * FUNCTION:    AcpiDbTerminate
552*3446Smrj  *
553*3446Smrj  * PARAMETERS:  None
554*3446Smrj  *
555*3446Smrj  * RETURN:      None
556*3446Smrj  *
557*3446Smrj  * DESCRIPTION: Stop debugger
558*3446Smrj  *
559*3446Smrj  ******************************************************************************/
560*3446Smrj 
561*3446Smrj void
562*3446Smrj AcpiDbTerminate (
563*3446Smrj     void)
564*3446Smrj {
565*3446Smrj 
566*3446Smrj     if (AcpiGbl_DbTablePtr)
567*3446Smrj     {
568*3446Smrj         AcpiOsFree (AcpiGbl_DbTablePtr);
569*3446Smrj     }
570*3446Smrj     if (AcpiGbl_DbBuffer)
571*3446Smrj     {
572*3446Smrj         AcpiOsFree (AcpiGbl_DbBuffer);
573*3446Smrj     }
574*3446Smrj }
575*3446Smrj 
576*3446Smrj 
577*3446Smrj #ifdef ACPI_OBSOLETE_FUNCTIONS
578*3446Smrj /*******************************************************************************
579*3446Smrj  *
580*3446Smrj  * FUNCTION:    AcpiDbMethodEnd
581*3446Smrj  *
582*3446Smrj  * PARAMETERS:  WalkState       - Current walk
583*3446Smrj  *
584*3446Smrj  * RETURN:      Status
585*3446Smrj  *
586*3446Smrj  * DESCRIPTION: Called at method termination
587*3446Smrj  *
588*3446Smrj  ******************************************************************************/
589*3446Smrj 
590*3446Smrj void
591*3446Smrj AcpiDbMethodEnd (
592*3446Smrj     ACPI_WALK_STATE         *WalkState)
593*3446Smrj {
594*3446Smrj 
595*3446Smrj     if (!AcpiGbl_CmSingleStep)
596*3446Smrj     {
597*3446Smrj         return;
598*3446Smrj     }
599*3446Smrj 
600*3446Smrj     AcpiOsPrintf ("<Method Terminating>\n");
601*3446Smrj 
602*3446Smrj     AcpiDbStartCommand (WalkState, NULL);
603*3446Smrj }
604*3446Smrj #endif
605*3446Smrj 
606*3446Smrj #endif /* ACPI_DEBUGGER */
607