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