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