exdebug.c revision 1.7 1 1.1 jruoho /******************************************************************************
2 1.1 jruoho *
3 1.1 jruoho * Module Name: exdebug - Support for stores to the AML Debug Object
4 1.1 jruoho *
5 1.1 jruoho *****************************************************************************/
6 1.1 jruoho
7 1.3 jruoho /*
8 1.6 christos * Copyright (C) 2000 - 2015, Intel Corp.
9 1.1 jruoho * All rights reserved.
10 1.1 jruoho *
11 1.3 jruoho * Redistribution and use in source and binary forms, with or without
12 1.3 jruoho * modification, are permitted provided that the following conditions
13 1.3 jruoho * are met:
14 1.3 jruoho * 1. Redistributions of source code must retain the above copyright
15 1.3 jruoho * notice, this list of conditions, and the following disclaimer,
16 1.3 jruoho * without modification.
17 1.3 jruoho * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 1.3 jruoho * substantially similar to the "NO WARRANTY" disclaimer below
19 1.3 jruoho * ("Disclaimer") and any redistribution must be conditioned upon
20 1.3 jruoho * including a substantially similar Disclaimer requirement for further
21 1.3 jruoho * binary redistribution.
22 1.3 jruoho * 3. Neither the names of the above-listed copyright holders nor the names
23 1.3 jruoho * of any contributors may be used to endorse or promote products derived
24 1.3 jruoho * from this software without specific prior written permission.
25 1.3 jruoho *
26 1.3 jruoho * Alternatively, this software may be distributed under the terms of the
27 1.3 jruoho * GNU General Public License ("GPL") version 2 as published by the Free
28 1.3 jruoho * Software Foundation.
29 1.3 jruoho *
30 1.3 jruoho * NO WARRANTY
31 1.3 jruoho * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 1.3 jruoho * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 1.3 jruoho * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 1.3 jruoho * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 1.3 jruoho * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 1.3 jruoho * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 1.3 jruoho * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 1.3 jruoho * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 1.3 jruoho * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 1.3 jruoho * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 1.3 jruoho * POSSIBILITY OF SUCH DAMAGES.
42 1.3 jruoho */
43 1.1 jruoho
44 1.1 jruoho #include "acpi.h"
45 1.1 jruoho #include "accommon.h"
46 1.7 christos #include "acnamesp.h"
47 1.1 jruoho #include "acinterp.h"
48 1.7 christos #include "acparser.h"
49 1.1 jruoho
50 1.1 jruoho
51 1.1 jruoho #define _COMPONENT ACPI_EXECUTER
52 1.1 jruoho ACPI_MODULE_NAME ("exdebug")
53 1.1 jruoho
54 1.1 jruoho
55 1.7 christos static ACPI_OPERAND_OBJECT *AcpiGbl_TraceMethodObject = NULL;
56 1.7 christos
57 1.7 christos /* Local prototypes */
58 1.7 christos
59 1.7 christos #ifdef ACPI_DEBUG_OUTPUT
60 1.7 christos static const char *
61 1.7 christos AcpiExGetTraceEventName (
62 1.7 christos ACPI_TRACE_EVENT_TYPE Type);
63 1.7 christos #endif
64 1.7 christos
65 1.7 christos
66 1.1 jruoho #ifndef ACPI_NO_ERROR_MESSAGES
67 1.1 jruoho /*******************************************************************************
68 1.1 jruoho *
69 1.1 jruoho * FUNCTION: AcpiExDoDebugObject
70 1.1 jruoho *
71 1.1 jruoho * PARAMETERS: SourceDesc - Object to be output to "Debug Object"
72 1.1 jruoho * Level - Indentation level (used for packages)
73 1.1 jruoho * Index - Current package element, zero if not pkg
74 1.1 jruoho *
75 1.1 jruoho * RETURN: None
76 1.1 jruoho *
77 1.1 jruoho * DESCRIPTION: Handles stores to the AML Debug Object. For example:
78 1.1 jruoho * Store(INT1, Debug)
79 1.1 jruoho *
80 1.1 jruoho * This function is not compiled if ACPI_NO_ERROR_MESSAGES is set.
81 1.1 jruoho *
82 1.2 jruoho * This function is only enabled if AcpiGbl_EnableAmlDebugObject is set.
83 1.2 jruoho * Thus, in the normal operational case, stores to the debug object are
84 1.2 jruoho * ignored but can be easily enabled if necessary.
85 1.1 jruoho *
86 1.1 jruoho ******************************************************************************/
87 1.1 jruoho
88 1.1 jruoho void
89 1.1 jruoho AcpiExDoDebugObject (
90 1.1 jruoho ACPI_OPERAND_OBJECT *SourceDesc,
91 1.1 jruoho UINT32 Level,
92 1.1 jruoho UINT32 Index)
93 1.1 jruoho {
94 1.1 jruoho UINT32 i;
95 1.5 christos UINT32 Timer;
96 1.7 christos ACPI_OPERAND_OBJECT *ObjectDesc;
97 1.7 christos UINT32 Value;
98 1.1 jruoho
99 1.1 jruoho
100 1.1 jruoho ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc);
101 1.1 jruoho
102 1.1 jruoho
103 1.2 jruoho /* Output must be enabled via the DebugObject global */
104 1.1 jruoho
105 1.2 jruoho if (!AcpiGbl_EnableAmlDebugObject)
106 1.1 jruoho {
107 1.1 jruoho return_VOID;
108 1.1 jruoho }
109 1.1 jruoho
110 1.1 jruoho /*
111 1.5 christos * We will emit the current timer value (in microseconds) with each
112 1.5 christos * debug output. Only need the lower 26 bits. This allows for 67
113 1.5 christos * million microseconds or 67 seconds before rollover.
114 1.5 christos */
115 1.5 christos Timer = ((UINT32) AcpiOsGetTimer () / 10); /* (100 nanoseconds to microseconds) */
116 1.5 christos Timer &= 0x03FFFFFF;
117 1.5 christos
118 1.5 christos /*
119 1.1 jruoho * Print line header as long as we are not in the middle of an
120 1.1 jruoho * object display
121 1.1 jruoho */
122 1.1 jruoho if (!((Level > 0) && Index == 0))
123 1.1 jruoho {
124 1.5 christos AcpiOsPrintf ("[ACPI Debug %.8u] %*s", Timer, Level, " ");
125 1.1 jruoho }
126 1.1 jruoho
127 1.1 jruoho /* Display the index for package output only */
128 1.1 jruoho
129 1.1 jruoho if (Index > 0)
130 1.1 jruoho {
131 1.1 jruoho AcpiOsPrintf ("(%.2u) ", Index-1);
132 1.1 jruoho }
133 1.1 jruoho
134 1.1 jruoho if (!SourceDesc)
135 1.1 jruoho {
136 1.1 jruoho AcpiOsPrintf ("[Null Object]\n");
137 1.1 jruoho return_VOID;
138 1.1 jruoho }
139 1.1 jruoho
140 1.1 jruoho if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND)
141 1.1 jruoho {
142 1.1 jruoho AcpiOsPrintf ("%s ", AcpiUtGetObjectTypeName (SourceDesc));
143 1.1 jruoho
144 1.1 jruoho if (!AcpiUtValidInternalObject (SourceDesc))
145 1.1 jruoho {
146 1.1 jruoho AcpiOsPrintf ("%p, Invalid Internal Object!\n", SourceDesc);
147 1.1 jruoho return_VOID;
148 1.1 jruoho }
149 1.1 jruoho }
150 1.1 jruoho else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED)
151 1.1 jruoho {
152 1.1 jruoho AcpiOsPrintf ("%s: %p\n",
153 1.1 jruoho AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type),
154 1.1 jruoho SourceDesc);
155 1.1 jruoho return_VOID;
156 1.1 jruoho }
157 1.1 jruoho else
158 1.1 jruoho {
159 1.1 jruoho return_VOID;
160 1.1 jruoho }
161 1.1 jruoho
162 1.1 jruoho /* SourceDesc is of type ACPI_DESC_TYPE_OPERAND */
163 1.1 jruoho
164 1.1 jruoho switch (SourceDesc->Common.Type)
165 1.1 jruoho {
166 1.1 jruoho case ACPI_TYPE_INTEGER:
167 1.1 jruoho
168 1.1 jruoho /* Output correct integer width */
169 1.1 jruoho
170 1.1 jruoho if (AcpiGbl_IntegerByteWidth == 4)
171 1.1 jruoho {
172 1.1 jruoho AcpiOsPrintf ("0x%8.8X\n",
173 1.1 jruoho (UINT32) SourceDesc->Integer.Value);
174 1.1 jruoho }
175 1.1 jruoho else
176 1.1 jruoho {
177 1.1 jruoho AcpiOsPrintf ("0x%8.8X%8.8X\n",
178 1.1 jruoho ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value));
179 1.1 jruoho }
180 1.1 jruoho break;
181 1.1 jruoho
182 1.1 jruoho case ACPI_TYPE_BUFFER:
183 1.1 jruoho
184 1.1 jruoho AcpiOsPrintf ("[0x%.2X]\n", (UINT32) SourceDesc->Buffer.Length);
185 1.4 christos AcpiUtDumpBuffer (SourceDesc->Buffer.Pointer,
186 1.1 jruoho (SourceDesc->Buffer.Length < 256) ?
187 1.4 christos SourceDesc->Buffer.Length : 256, DB_BYTE_DISPLAY, 0);
188 1.1 jruoho break;
189 1.1 jruoho
190 1.1 jruoho case ACPI_TYPE_STRING:
191 1.1 jruoho
192 1.1 jruoho AcpiOsPrintf ("[0x%.2X] \"%s\"\n",
193 1.1 jruoho SourceDesc->String.Length, SourceDesc->String.Pointer);
194 1.1 jruoho break;
195 1.1 jruoho
196 1.1 jruoho case ACPI_TYPE_PACKAGE:
197 1.1 jruoho
198 1.1 jruoho AcpiOsPrintf ("[Contains 0x%.2X Elements]\n",
199 1.1 jruoho SourceDesc->Package.Count);
200 1.1 jruoho
201 1.1 jruoho /* Output the entire contents of the package */
202 1.1 jruoho
203 1.1 jruoho for (i = 0; i < SourceDesc->Package.Count; i++)
204 1.1 jruoho {
205 1.1 jruoho AcpiExDoDebugObject (SourceDesc->Package.Elements[i],
206 1.1 jruoho Level+4, i+1);
207 1.1 jruoho }
208 1.1 jruoho break;
209 1.1 jruoho
210 1.1 jruoho case ACPI_TYPE_LOCAL_REFERENCE:
211 1.1 jruoho
212 1.1 jruoho AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (SourceDesc));
213 1.1 jruoho
214 1.1 jruoho /* Decode the reference */
215 1.1 jruoho
216 1.1 jruoho switch (SourceDesc->Reference.Class)
217 1.1 jruoho {
218 1.1 jruoho case ACPI_REFCLASS_INDEX:
219 1.1 jruoho
220 1.1 jruoho AcpiOsPrintf ("0x%X\n", SourceDesc->Reference.Value);
221 1.1 jruoho break;
222 1.1 jruoho
223 1.1 jruoho case ACPI_REFCLASS_TABLE:
224 1.1 jruoho
225 1.1 jruoho /* Case for DdbHandle */
226 1.1 jruoho
227 1.1 jruoho AcpiOsPrintf ("Table Index 0x%X\n", SourceDesc->Reference.Value);
228 1.4 christos return_VOID;
229 1.1 jruoho
230 1.1 jruoho default:
231 1.4 christos
232 1.1 jruoho break;
233 1.1 jruoho }
234 1.1 jruoho
235 1.1 jruoho AcpiOsPrintf (" ");
236 1.1 jruoho
237 1.1 jruoho /* Check for valid node first, then valid object */
238 1.1 jruoho
239 1.1 jruoho if (SourceDesc->Reference.Node)
240 1.1 jruoho {
241 1.1 jruoho if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Node) !=
242 1.1 jruoho ACPI_DESC_TYPE_NAMED)
243 1.1 jruoho {
244 1.1 jruoho AcpiOsPrintf (" %p - Not a valid namespace node\n",
245 1.1 jruoho SourceDesc->Reference.Node);
246 1.1 jruoho }
247 1.1 jruoho else
248 1.1 jruoho {
249 1.1 jruoho AcpiOsPrintf ("Node %p [%4.4s] ", SourceDesc->Reference.Node,
250 1.1 jruoho (SourceDesc->Reference.Node)->Name.Ascii);
251 1.1 jruoho
252 1.1 jruoho switch ((SourceDesc->Reference.Node)->Type)
253 1.1 jruoho {
254 1.1 jruoho /* These types have no attached object */
255 1.1 jruoho
256 1.1 jruoho case ACPI_TYPE_DEVICE:
257 1.1 jruoho AcpiOsPrintf ("Device\n");
258 1.1 jruoho break;
259 1.1 jruoho
260 1.1 jruoho case ACPI_TYPE_THERMAL:
261 1.1 jruoho AcpiOsPrintf ("Thermal Zone\n");
262 1.1 jruoho break;
263 1.1 jruoho
264 1.1 jruoho default:
265 1.4 christos
266 1.1 jruoho AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object,
267 1.1 jruoho Level+4, 0);
268 1.1 jruoho break;
269 1.1 jruoho }
270 1.1 jruoho }
271 1.1 jruoho }
272 1.1 jruoho else if (SourceDesc->Reference.Object)
273 1.1 jruoho {
274 1.1 jruoho if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) ==
275 1.1 jruoho ACPI_DESC_TYPE_NAMED)
276 1.1 jruoho {
277 1.1 jruoho AcpiExDoDebugObject (((ACPI_NAMESPACE_NODE *)
278 1.1 jruoho SourceDesc->Reference.Object)->Object,
279 1.1 jruoho Level+4, 0);
280 1.1 jruoho }
281 1.1 jruoho else
282 1.1 jruoho {
283 1.7 christos ObjectDesc = SourceDesc->Reference.Object;
284 1.7 christos Value = SourceDesc->Reference.Value;
285 1.7 christos
286 1.7 christos switch (ObjectDesc->Common.Type)
287 1.7 christos {
288 1.7 christos case ACPI_TYPE_BUFFER:
289 1.7 christos
290 1.7 christos AcpiOsPrintf ("Buffer[%u] = 0x%2.2X\n",
291 1.7 christos Value, *SourceDesc->Reference.IndexPointer);
292 1.7 christos break;
293 1.7 christos
294 1.7 christos case ACPI_TYPE_STRING:
295 1.7 christos
296 1.7 christos AcpiOsPrintf ("String[%u] = \"%c\" (0x%2.2X)\n",
297 1.7 christos Value, *SourceDesc->Reference.IndexPointer,
298 1.7 christos *SourceDesc->Reference.IndexPointer);
299 1.7 christos break;
300 1.7 christos
301 1.7 christos case ACPI_TYPE_PACKAGE:
302 1.7 christos
303 1.7 christos AcpiOsPrintf ("Package[%u] = ", Value);
304 1.7 christos AcpiExDoDebugObject (*SourceDesc->Reference.Where,
305 1.7 christos Level+4, 0);
306 1.7 christos break;
307 1.7 christos
308 1.7 christos default:
309 1.7 christos
310 1.7 christos AcpiOsPrintf ("Unknown Reference object type %X\n",
311 1.7 christos ObjectDesc->Common.Type);
312 1.7 christos break;
313 1.7 christos }
314 1.1 jruoho }
315 1.1 jruoho }
316 1.1 jruoho break;
317 1.1 jruoho
318 1.1 jruoho default:
319 1.1 jruoho
320 1.1 jruoho AcpiOsPrintf ("%p\n", SourceDesc);
321 1.1 jruoho break;
322 1.1 jruoho }
323 1.1 jruoho
324 1.1 jruoho ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n"));
325 1.1 jruoho return_VOID;
326 1.1 jruoho }
327 1.1 jruoho #endif
328 1.7 christos
329 1.7 christos
330 1.7 christos /*******************************************************************************
331 1.7 christos *
332 1.7 christos * FUNCTION: AcpiExInterpreterTraceEnabled
333 1.7 christos *
334 1.7 christos * PARAMETERS: Name - Whether method name should be matched,
335 1.7 christos * this should be checked before starting
336 1.7 christos * the tracer
337 1.7 christos *
338 1.7 christos * RETURN: TRUE if interpreter trace is enabled.
339 1.7 christos *
340 1.7 christos * DESCRIPTION: Check whether interpreter trace is enabled
341 1.7 christos *
342 1.7 christos ******************************************************************************/
343 1.7 christos
344 1.7 christos static BOOLEAN
345 1.7 christos AcpiExInterpreterTraceEnabled (
346 1.7 christos char *Name)
347 1.7 christos {
348 1.7 christos
349 1.7 christos /* Check if tracing is enabled */
350 1.7 christos
351 1.7 christos if (!(AcpiGbl_TraceFlags & ACPI_TRACE_ENABLED))
352 1.7 christos {
353 1.7 christos return (FALSE);
354 1.7 christos }
355 1.7 christos
356 1.7 christos /*
357 1.7 christos * Check if tracing is filtered:
358 1.7 christos *
359 1.7 christos * 1. If the tracer is started, AcpiGbl_TraceMethodObject should have
360 1.7 christos * been filled by the trace starter
361 1.7 christos * 2. If the tracer is not started, AcpiGbl_TraceMethodName should be
362 1.7 christos * matched if it is specified
363 1.7 christos * 3. If the tracer is oneshot style, AcpiGbl_TraceMethodName should
364 1.7 christos * not be cleared by the trace stopper during the first match
365 1.7 christos */
366 1.7 christos if (AcpiGbl_TraceMethodObject)
367 1.7 christos {
368 1.7 christos return (TRUE);
369 1.7 christos }
370 1.7 christos if (Name &&
371 1.7 christos (AcpiGbl_TraceMethodName &&
372 1.7 christos strcmp (AcpiGbl_TraceMethodName, Name)))
373 1.7 christos {
374 1.7 christos return (FALSE);
375 1.7 christos }
376 1.7 christos if ((AcpiGbl_TraceFlags & ACPI_TRACE_ONESHOT) &&
377 1.7 christos !AcpiGbl_TraceMethodName)
378 1.7 christos {
379 1.7 christos return (FALSE);
380 1.7 christos }
381 1.7 christos
382 1.7 christos return (TRUE);
383 1.7 christos }
384 1.7 christos
385 1.7 christos
386 1.7 christos /*******************************************************************************
387 1.7 christos *
388 1.7 christos * FUNCTION: AcpiExGetTraceEventName
389 1.7 christos *
390 1.7 christos * PARAMETERS: Type - Trace event type
391 1.7 christos *
392 1.7 christos * RETURN: Trace event name.
393 1.7 christos *
394 1.7 christos * DESCRIPTION: Used to obtain the full trace event name.
395 1.7 christos *
396 1.7 christos ******************************************************************************/
397 1.7 christos
398 1.7 christos #ifdef ACPI_DEBUG_OUTPUT
399 1.7 christos
400 1.7 christos static const char *
401 1.7 christos AcpiExGetTraceEventName (
402 1.7 christos ACPI_TRACE_EVENT_TYPE Type)
403 1.7 christos {
404 1.7 christos switch (Type)
405 1.7 christos {
406 1.7 christos case ACPI_TRACE_AML_METHOD:
407 1.7 christos
408 1.7 christos return "Method";
409 1.7 christos
410 1.7 christos case ACPI_TRACE_AML_OPCODE:
411 1.7 christos
412 1.7 christos return "Opcode";
413 1.7 christos
414 1.7 christos case ACPI_TRACE_AML_REGION:
415 1.7 christos
416 1.7 christos return "Region";
417 1.7 christos
418 1.7 christos default:
419 1.7 christos
420 1.7 christos return "";
421 1.7 christos }
422 1.7 christos }
423 1.7 christos
424 1.7 christos #endif
425 1.7 christos
426 1.7 christos
427 1.7 christos /*******************************************************************************
428 1.7 christos *
429 1.7 christos * FUNCTION: AcpiExTracePoint
430 1.7 christos *
431 1.7 christos * PARAMETERS: Type - Trace event type
432 1.7 christos * Begin - TRUE if before execution
433 1.7 christos * Aml - Executed AML address
434 1.7 christos * Pathname - Object path
435 1.7 christos *
436 1.7 christos * RETURN: None
437 1.7 christos *
438 1.7 christos * DESCRIPTION: Internal interpreter execution trace.
439 1.7 christos *
440 1.7 christos ******************************************************************************/
441 1.7 christos
442 1.7 christos void
443 1.7 christos AcpiExTracePoint (
444 1.7 christos ACPI_TRACE_EVENT_TYPE Type,
445 1.7 christos BOOLEAN Begin,
446 1.7 christos UINT8 *Aml,
447 1.7 christos char *Pathname)
448 1.7 christos {
449 1.7 christos
450 1.7 christos ACPI_FUNCTION_NAME (ExTracePoint);
451 1.7 christos
452 1.7 christos
453 1.7 christos if (Pathname)
454 1.7 christos {
455 1.7 christos ACPI_DEBUG_PRINT ((ACPI_DB_TRACE_POINT,
456 1.7 christos "%s %s [0x%p:%s] execution.\n",
457 1.7 christos AcpiExGetTraceEventName (Type), Begin ? "Begin" : "End",
458 1.7 christos Aml, Pathname));
459 1.7 christos }
460 1.7 christos else
461 1.7 christos {
462 1.7 christos ACPI_DEBUG_PRINT ((ACPI_DB_TRACE_POINT,
463 1.7 christos "%s %s [0x%p] execution.\n",
464 1.7 christos AcpiExGetTraceEventName (Type), Begin ? "Begin" : "End",
465 1.7 christos Aml));
466 1.7 christos }
467 1.7 christos }
468 1.7 christos
469 1.7 christos
470 1.7 christos /*******************************************************************************
471 1.7 christos *
472 1.7 christos * FUNCTION: AcpiExStartTraceMethod
473 1.7 christos *
474 1.7 christos * PARAMETERS: MethodNode - Node of the method
475 1.7 christos * ObjDesc - The method object
476 1.7 christos * WalkState - current state, NULL if not yet executing
477 1.7 christos * a method.
478 1.7 christos *
479 1.7 christos * RETURN: None
480 1.7 christos *
481 1.7 christos * DESCRIPTION: Start control method execution trace
482 1.7 christos *
483 1.7 christos ******************************************************************************/
484 1.7 christos
485 1.7 christos void
486 1.7 christos AcpiExStartTraceMethod (
487 1.7 christos ACPI_NAMESPACE_NODE *MethodNode,
488 1.7 christos ACPI_OPERAND_OBJECT *ObjDesc,
489 1.7 christos ACPI_WALK_STATE *WalkState)
490 1.7 christos {
491 1.7 christos ACPI_STATUS Status;
492 1.7 christos char *Pathname = NULL;
493 1.7 christos BOOLEAN Enabled = FALSE;
494 1.7 christos
495 1.7 christos
496 1.7 christos ACPI_FUNCTION_NAME (ExStartTraceMethod);
497 1.7 christos
498 1.7 christos
499 1.7 christos if (MethodNode)
500 1.7 christos {
501 1.7 christos Pathname = AcpiNsGetNormalizedPathname (MethodNode, TRUE);
502 1.7 christos }
503 1.7 christos
504 1.7 christos Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
505 1.7 christos if (ACPI_FAILURE (Status))
506 1.7 christos {
507 1.7 christos goto Exit;
508 1.7 christos }
509 1.7 christos
510 1.7 christos Enabled = AcpiExInterpreterTraceEnabled (Pathname);
511 1.7 christos if (Enabled && !AcpiGbl_TraceMethodObject)
512 1.7 christos {
513 1.7 christos AcpiGbl_TraceMethodObject = ObjDesc;
514 1.7 christos AcpiGbl_OriginalDbgLevel = AcpiDbgLevel;
515 1.7 christos AcpiGbl_OriginalDbgLayer = AcpiDbgLayer;
516 1.7 christos AcpiDbgLevel = ACPI_TRACE_LEVEL_ALL;
517 1.7 christos AcpiDbgLayer = ACPI_TRACE_LAYER_ALL;
518 1.7 christos
519 1.7 christos if (AcpiGbl_TraceDbgLevel)
520 1.7 christos {
521 1.7 christos AcpiDbgLevel = AcpiGbl_TraceDbgLevel;
522 1.7 christos }
523 1.7 christos if (AcpiGbl_TraceDbgLayer)
524 1.7 christos {
525 1.7 christos AcpiDbgLayer = AcpiGbl_TraceDbgLayer;
526 1.7 christos }
527 1.7 christos }
528 1.7 christos (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
529 1.7 christos
530 1.7 christos Exit:
531 1.7 christos if (Enabled)
532 1.7 christos {
533 1.7 christos ACPI_TRACE_POINT (ACPI_TRACE_AML_METHOD, TRUE,
534 1.7 christos ObjDesc ? ObjDesc->Method.AmlStart : NULL, Pathname);
535 1.7 christos }
536 1.7 christos if (Pathname)
537 1.7 christos {
538 1.7 christos ACPI_FREE (Pathname);
539 1.7 christos }
540 1.7 christos }
541 1.7 christos
542 1.7 christos
543 1.7 christos /*******************************************************************************
544 1.7 christos *
545 1.7 christos * FUNCTION: AcpiExStopTraceMethod
546 1.7 christos *
547 1.7 christos * PARAMETERS: MethodNode - Node of the method
548 1.7 christos * ObjDesc - The method object
549 1.7 christos * WalkState - current state, NULL if not yet executing
550 1.7 christos * a method.
551 1.7 christos *
552 1.7 christos * RETURN: None
553 1.7 christos *
554 1.7 christos * DESCRIPTION: Stop control method execution trace
555 1.7 christos *
556 1.7 christos ******************************************************************************/
557 1.7 christos
558 1.7 christos void
559 1.7 christos AcpiExStopTraceMethod (
560 1.7 christos ACPI_NAMESPACE_NODE *MethodNode,
561 1.7 christos ACPI_OPERAND_OBJECT *ObjDesc,
562 1.7 christos ACPI_WALK_STATE *WalkState)
563 1.7 christos {
564 1.7 christos ACPI_STATUS Status;
565 1.7 christos char *Pathname = NULL;
566 1.7 christos BOOLEAN Enabled;
567 1.7 christos
568 1.7 christos
569 1.7 christos ACPI_FUNCTION_NAME (ExStopTraceMethod);
570 1.7 christos
571 1.7 christos
572 1.7 christos if (MethodNode)
573 1.7 christos {
574 1.7 christos Pathname = AcpiNsGetNormalizedPathname (MethodNode, TRUE);
575 1.7 christos }
576 1.7 christos
577 1.7 christos Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
578 1.7 christos if (ACPI_FAILURE (Status))
579 1.7 christos {
580 1.7 christos goto ExitPath;
581 1.7 christos }
582 1.7 christos
583 1.7 christos Enabled = AcpiExInterpreterTraceEnabled (NULL);
584 1.7 christos
585 1.7 christos (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
586 1.7 christos
587 1.7 christos if (Enabled)
588 1.7 christos {
589 1.7 christos ACPI_TRACE_POINT (ACPI_TRACE_AML_METHOD, FALSE,
590 1.7 christos ObjDesc ? ObjDesc->Method.AmlStart : NULL, Pathname);
591 1.7 christos }
592 1.7 christos
593 1.7 christos Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
594 1.7 christos if (ACPI_FAILURE (Status))
595 1.7 christos {
596 1.7 christos goto ExitPath;
597 1.7 christos }
598 1.7 christos
599 1.7 christos /* Check whether the tracer should be stopped */
600 1.7 christos
601 1.7 christos if (AcpiGbl_TraceMethodObject == ObjDesc)
602 1.7 christos {
603 1.7 christos /* Disable further tracing if type is one-shot */
604 1.7 christos
605 1.7 christos if (AcpiGbl_TraceFlags & ACPI_TRACE_ONESHOT)
606 1.7 christos {
607 1.7 christos AcpiGbl_TraceMethodName = NULL;
608 1.7 christos }
609 1.7 christos
610 1.7 christos AcpiDbgLevel = AcpiGbl_OriginalDbgLevel;
611 1.7 christos AcpiDbgLayer = AcpiGbl_OriginalDbgLayer;
612 1.7 christos AcpiGbl_TraceMethodObject = NULL;
613 1.7 christos }
614 1.7 christos
615 1.7 christos (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
616 1.7 christos
617 1.7 christos ExitPath:
618 1.7 christos if (Pathname)
619 1.7 christos {
620 1.7 christos ACPI_FREE (Pathname);
621 1.7 christos }
622 1.7 christos }
623 1.7 christos
624 1.7 christos
625 1.7 christos /*******************************************************************************
626 1.7 christos *
627 1.7 christos * FUNCTION: AcpiExStartTraceOpcode
628 1.7 christos *
629 1.7 christos * PARAMETERS: Op - The parser opcode object
630 1.7 christos * WalkState - current state, NULL if not yet executing
631 1.7 christos * a method.
632 1.7 christos *
633 1.7 christos * RETURN: None
634 1.7 christos *
635 1.7 christos * DESCRIPTION: Start opcode execution trace
636 1.7 christos *
637 1.7 christos ******************************************************************************/
638 1.7 christos
639 1.7 christos void
640 1.7 christos AcpiExStartTraceOpcode (
641 1.7 christos ACPI_PARSE_OBJECT *Op,
642 1.7 christos ACPI_WALK_STATE *WalkState)
643 1.7 christos {
644 1.7 christos
645 1.7 christos ACPI_FUNCTION_NAME (ExStartTraceOpcode);
646 1.7 christos
647 1.7 christos
648 1.7 christos if (AcpiExInterpreterTraceEnabled (NULL) &&
649 1.7 christos (AcpiGbl_TraceFlags & ACPI_TRACE_OPCODE))
650 1.7 christos {
651 1.7 christos ACPI_TRACE_POINT (ACPI_TRACE_AML_OPCODE, TRUE,
652 1.7 christos Op->Common.Aml, Op->Common.AmlOpName);
653 1.7 christos }
654 1.7 christos }
655 1.7 christos
656 1.7 christos
657 1.7 christos /*******************************************************************************
658 1.7 christos *
659 1.7 christos * FUNCTION: AcpiExStopTraceOpcode
660 1.7 christos *
661 1.7 christos * PARAMETERS: Op - The parser opcode object
662 1.7 christos * WalkState - current state, NULL if not yet executing
663 1.7 christos * a method.
664 1.7 christos *
665 1.7 christos * RETURN: None
666 1.7 christos *
667 1.7 christos * DESCRIPTION: Stop opcode execution trace
668 1.7 christos *
669 1.7 christos ******************************************************************************/
670 1.7 christos
671 1.7 christos void
672 1.7 christos AcpiExStopTraceOpcode (
673 1.7 christos ACPI_PARSE_OBJECT *Op,
674 1.7 christos ACPI_WALK_STATE *WalkState)
675 1.7 christos {
676 1.7 christos
677 1.7 christos ACPI_FUNCTION_NAME (ExStopTraceOpcode);
678 1.7 christos
679 1.7 christos
680 1.7 christos if (AcpiExInterpreterTraceEnabled (NULL) &&
681 1.7 christos (AcpiGbl_TraceFlags & ACPI_TRACE_OPCODE))
682 1.7 christos {
683 1.7 christos ACPI_TRACE_POINT (ACPI_TRACE_AML_OPCODE, FALSE,
684 1.7 christos Op->Common.Aml, Op->Common.AmlOpName);
685 1.7 christos }
686 1.7 christos }
687