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