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