1ae115bc7Smrj /******************************************************************************
2ae115bc7Smrj *
3*385cc6b4SJerry Jelinek * Module Name: utdebug - Debug print/trace routines
4ae115bc7Smrj *
5ae115bc7Smrj *****************************************************************************/
6ae115bc7Smrj
726f3cdf0SGordon Ross /*
8*385cc6b4SJerry Jelinek * Copyright (C) 2000 - 2016, Intel Corp.
9ae115bc7Smrj * All rights reserved.
10ae115bc7Smrj *
1126f3cdf0SGordon Ross * Redistribution and use in source and binary forms, with or without
1226f3cdf0SGordon Ross * modification, are permitted provided that the following conditions
1326f3cdf0SGordon Ross * are met:
1426f3cdf0SGordon Ross * 1. Redistributions of source code must retain the above copyright
1526f3cdf0SGordon Ross * notice, this list of conditions, and the following disclaimer,
1626f3cdf0SGordon Ross * without modification.
1726f3cdf0SGordon Ross * 2. Redistributions in binary form must reproduce at minimum a disclaimer
1826f3cdf0SGordon Ross * substantially similar to the "NO WARRANTY" disclaimer below
1926f3cdf0SGordon Ross * ("Disclaimer") and any redistribution must be conditioned upon
2026f3cdf0SGordon Ross * including a substantially similar Disclaimer requirement for further
2126f3cdf0SGordon Ross * binary redistribution.
2226f3cdf0SGordon Ross * 3. Neither the names of the above-listed copyright holders nor the names
2326f3cdf0SGordon Ross * of any contributors may be used to endorse or promote products derived
2426f3cdf0SGordon Ross * from this software without specific prior written permission.
25ae115bc7Smrj *
2626f3cdf0SGordon Ross * Alternatively, this software may be distributed under the terms of the
2726f3cdf0SGordon Ross * GNU General Public License ("GPL") version 2 as published by the Free
2826f3cdf0SGordon Ross * Software Foundation.
29ae115bc7Smrj *
3026f3cdf0SGordon Ross * NO WARRANTY
3126f3cdf0SGordon Ross * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
3226f3cdf0SGordon Ross * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
3326f3cdf0SGordon Ross * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
3426f3cdf0SGordon Ross * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
3526f3cdf0SGordon Ross * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3626f3cdf0SGordon Ross * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3726f3cdf0SGordon Ross * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3826f3cdf0SGordon Ross * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
3926f3cdf0SGordon Ross * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
4026f3cdf0SGordon Ross * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
4126f3cdf0SGordon Ross * POSSIBILITY OF SUCH DAMAGES.
4226f3cdf0SGordon Ross */
43ae115bc7Smrj
44*385cc6b4SJerry Jelinek #define EXPORT_ACPI_INTERFACES
45ae115bc7Smrj
46ae115bc7Smrj #include "acpi.h"
47aa2aa9a6SDana Myers #include "accommon.h"
48*385cc6b4SJerry Jelinek #include "acinterp.h"
49ae115bc7Smrj
50ae115bc7Smrj #define _COMPONENT ACPI_UTILITIES
51ae115bc7Smrj ACPI_MODULE_NAME ("utdebug")
52ae115bc7Smrj
53ae115bc7Smrj
54ae115bc7Smrj #ifdef ACPI_DEBUG_OUTPUT
55ae115bc7Smrj
56*385cc6b4SJerry Jelinek static ACPI_THREAD_ID AcpiGbl_PreviousThreadId = (ACPI_THREAD_ID) 0xFFFFFFFF;
57*385cc6b4SJerry Jelinek static const char *AcpiGbl_FunctionEntryPrefix = "----Entry";
58*385cc6b4SJerry Jelinek static const char *AcpiGbl_FunctionExitPrefix = "----Exit-";
59ae115bc7Smrj
60ae115bc7Smrj
61ae115bc7Smrj /*******************************************************************************
62ae115bc7Smrj *
63ae115bc7Smrj * FUNCTION: AcpiUtInitStackPtrTrace
64ae115bc7Smrj *
65ae115bc7Smrj * PARAMETERS: None
66ae115bc7Smrj *
67ae115bc7Smrj * RETURN: None
68ae115bc7Smrj *
69ae115bc7Smrj * DESCRIPTION: Save the current CPU stack pointer at subsystem startup
70ae115bc7Smrj *
71ae115bc7Smrj ******************************************************************************/
72ae115bc7Smrj
73ae115bc7Smrj void
AcpiUtInitStackPtrTrace(void)74ae115bc7Smrj AcpiUtInitStackPtrTrace (
75ae115bc7Smrj void)
76ae115bc7Smrj {
77db2bae30SDana Myers ACPI_SIZE CurrentSp;
78ae115bc7Smrj
79ae115bc7Smrj
80db2bae30SDana Myers AcpiGbl_EntryStackPointer = &CurrentSp;
81ae115bc7Smrj }
82ae115bc7Smrj
83ae115bc7Smrj
84ae115bc7Smrj /*******************************************************************************
85ae115bc7Smrj *
86ae115bc7Smrj * FUNCTION: AcpiUtTrackStackPtr
87ae115bc7Smrj *
88ae115bc7Smrj * PARAMETERS: None
89ae115bc7Smrj *
90ae115bc7Smrj * RETURN: None
91ae115bc7Smrj *
92ae115bc7Smrj * DESCRIPTION: Save the current CPU stack pointer
93ae115bc7Smrj *
94ae115bc7Smrj ******************************************************************************/
95ae115bc7Smrj
96ae115bc7Smrj void
AcpiUtTrackStackPtr(void)97ae115bc7Smrj AcpiUtTrackStackPtr (
98ae115bc7Smrj void)
99ae115bc7Smrj {
100ae115bc7Smrj ACPI_SIZE CurrentSp;
101ae115bc7Smrj
102ae115bc7Smrj
103db2bae30SDana Myers if (&CurrentSp < AcpiGbl_LowestStackPointer)
104ae115bc7Smrj {
105db2bae30SDana Myers AcpiGbl_LowestStackPointer = &CurrentSp;
106ae115bc7Smrj }
107ae115bc7Smrj
108ae115bc7Smrj if (AcpiGbl_NestingLevel > AcpiGbl_DeepestNesting)
109ae115bc7Smrj {
110ae115bc7Smrj AcpiGbl_DeepestNesting = AcpiGbl_NestingLevel;
111ae115bc7Smrj }
112ae115bc7Smrj }
113ae115bc7Smrj
114ae115bc7Smrj
115ae115bc7Smrj /*******************************************************************************
116ae115bc7Smrj *
117ae115bc7Smrj * FUNCTION: AcpiUtTrimFunctionName
118ae115bc7Smrj *
119ae115bc7Smrj * PARAMETERS: FunctionName - Ascii string containing a procedure name
120ae115bc7Smrj *
121ae115bc7Smrj * RETURN: Updated pointer to the function name
122ae115bc7Smrj *
123ae115bc7Smrj * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present.
124ae115bc7Smrj * This allows compiler macros such as __FUNCTION__ to be used
125ae115bc7Smrj * with no change to the debug output.
126ae115bc7Smrj *
127ae115bc7Smrj ******************************************************************************/
128ae115bc7Smrj
129ae115bc7Smrj static const char *
AcpiUtTrimFunctionName(const char * FunctionName)130ae115bc7Smrj AcpiUtTrimFunctionName (
131ae115bc7Smrj const char *FunctionName)
132ae115bc7Smrj {
133ae115bc7Smrj
134ae115bc7Smrj /* All Function names are longer than 4 chars, check is safe */
135ae115bc7Smrj
136ae115bc7Smrj if (*(ACPI_CAST_PTR (UINT32, FunctionName)) == ACPI_PREFIX_MIXED)
137ae115bc7Smrj {
138ae115bc7Smrj /* This is the case where the original source has not been modified */
139ae115bc7Smrj
140ae115bc7Smrj return (FunctionName + 4);
141ae115bc7Smrj }
142ae115bc7Smrj
143ae115bc7Smrj if (*(ACPI_CAST_PTR (UINT32, FunctionName)) == ACPI_PREFIX_LOWER)
144ae115bc7Smrj {
145ae115bc7Smrj /* This is the case where the source has been 'linuxized' */
146ae115bc7Smrj
147ae115bc7Smrj return (FunctionName + 5);
148ae115bc7Smrj }
149ae115bc7Smrj
150ae115bc7Smrj return (FunctionName);
151ae115bc7Smrj }
152ae115bc7Smrj
153ae115bc7Smrj
154ae115bc7Smrj /*******************************************************************************
155ae115bc7Smrj *
156aa2aa9a6SDana Myers * FUNCTION: AcpiDebugPrint
157ae115bc7Smrj *
158ae115bc7Smrj * PARAMETERS: RequestedDebugLevel - Requested debug print level
159ae115bc7Smrj * LineNumber - Caller's line number (for error output)
160ae115bc7Smrj * FunctionName - Caller's procedure name
161ae115bc7Smrj * ModuleName - Caller's module name
162ae115bc7Smrj * ComponentId - Caller's component ID
163ae115bc7Smrj * Format - Printf format field
164ae115bc7Smrj * ... - Optional printf arguments
165ae115bc7Smrj *
166ae115bc7Smrj * RETURN: None
167ae115bc7Smrj *
168ae115bc7Smrj * DESCRIPTION: Print error message with prefix consisting of the module name,
169ae115bc7Smrj * line number, and component ID.
170ae115bc7Smrj *
171ae115bc7Smrj ******************************************************************************/
172ae115bc7Smrj
173ae115bc7Smrj void ACPI_INTERNAL_VAR_XFACE
AcpiDebugPrint(UINT32 RequestedDebugLevel,UINT32 LineNumber,const char * FunctionName,const char * ModuleName,UINT32 ComponentId,const char * Format,...)174aa2aa9a6SDana Myers AcpiDebugPrint (
175ae115bc7Smrj UINT32 RequestedDebugLevel,
176ae115bc7Smrj UINT32 LineNumber,
177ae115bc7Smrj const char *FunctionName,
178db2bae30SDana Myers const char *ModuleName,
179ae115bc7Smrj UINT32 ComponentId,
180db2bae30SDana Myers const char *Format,
181ae115bc7Smrj ...)
182ae115bc7Smrj {
183ae115bc7Smrj ACPI_THREAD_ID ThreadId;
184ae115bc7Smrj va_list args;
185ae115bc7Smrj
186ae115bc7Smrj
187*385cc6b4SJerry Jelinek /* Check if debug output enabled */
188*385cc6b4SJerry Jelinek
189*385cc6b4SJerry Jelinek if (!ACPI_IS_DEBUG_ENABLED (RequestedDebugLevel, ComponentId))
190ae115bc7Smrj {
191ae115bc7Smrj return;
192ae115bc7Smrj }
193ae115bc7Smrj
194ae115bc7Smrj /*
195ae115bc7Smrj * Thread tracking and context switch notification
196ae115bc7Smrj */
197ae115bc7Smrj ThreadId = AcpiOsGetThreadId ();
198*385cc6b4SJerry Jelinek if (ThreadId != AcpiGbl_PreviousThreadId)
199ae115bc7Smrj {
200ae115bc7Smrj if (ACPI_LV_THREADS & AcpiDbgLevel)
201ae115bc7Smrj {
202ae115bc7Smrj AcpiOsPrintf (
20326f3cdf0SGordon Ross "\n**** Context Switch from TID %u to TID %u ****\n\n",
204*385cc6b4SJerry Jelinek (UINT32) AcpiGbl_PreviousThreadId, (UINT32) ThreadId);
205ae115bc7Smrj }
206ae115bc7Smrj
207*385cc6b4SJerry Jelinek AcpiGbl_PreviousThreadId = ThreadId;
208*385cc6b4SJerry Jelinek AcpiGbl_NestingLevel = 0;
209ae115bc7Smrj }
210ae115bc7Smrj
211ae115bc7Smrj /*
212ae115bc7Smrj * Display the module name, current line number, thread ID (if requested),
213ae115bc7Smrj * current procedure nesting level, and the current procedure name
214ae115bc7Smrj */
215*385cc6b4SJerry Jelinek AcpiOsPrintf ("%9s-%04ld ", ModuleName, LineNumber);
216ae115bc7Smrj
217*385cc6b4SJerry Jelinek #ifdef ACPI_APPLICATION
218*385cc6b4SJerry Jelinek /*
219*385cc6b4SJerry Jelinek * For AcpiExec/iASL only, emit the thread ID and nesting level.
220*385cc6b4SJerry Jelinek * Note: nesting level is really only useful during a single-thread
221*385cc6b4SJerry Jelinek * execution. Otherwise, multiple threads will keep resetting the
222*385cc6b4SJerry Jelinek * level.
223*385cc6b4SJerry Jelinek */
224ae115bc7Smrj if (ACPI_LV_THREADS & AcpiDbgLevel)
225ae115bc7Smrj {
22626f3cdf0SGordon Ross AcpiOsPrintf ("[%u] ", (UINT32) ThreadId);
227ae115bc7Smrj }
228ae115bc7Smrj
229*385cc6b4SJerry Jelinek AcpiOsPrintf ("[%02ld] ", AcpiGbl_NestingLevel);
230*385cc6b4SJerry Jelinek #endif
231*385cc6b4SJerry Jelinek
232*385cc6b4SJerry Jelinek AcpiOsPrintf ("%-22.22s: ", AcpiUtTrimFunctionName (FunctionName));
233ae115bc7Smrj
234ae115bc7Smrj va_start (args, Format);
235ae115bc7Smrj AcpiOsVprintf (Format, args);
236db2bae30SDana Myers va_end (args);
237ae115bc7Smrj }
238ae115bc7Smrj
ACPI_EXPORT_SYMBOL(AcpiDebugPrint)239aa2aa9a6SDana Myers ACPI_EXPORT_SYMBOL (AcpiDebugPrint)
240ae115bc7Smrj
241ae115bc7Smrj
242ae115bc7Smrj /*******************************************************************************
243ae115bc7Smrj *
244aa2aa9a6SDana Myers * FUNCTION: AcpiDebugPrintRaw
245ae115bc7Smrj *
246ae115bc7Smrj * PARAMETERS: RequestedDebugLevel - Requested debug print level
247ae115bc7Smrj * LineNumber - Caller's line number
248ae115bc7Smrj * FunctionName - Caller's procedure name
249ae115bc7Smrj * ModuleName - Caller's module name
250ae115bc7Smrj * ComponentId - Caller's component ID
251ae115bc7Smrj * Format - Printf format field
252ae115bc7Smrj * ... - Optional printf arguments
253ae115bc7Smrj *
254ae115bc7Smrj * RETURN: None
255ae115bc7Smrj *
256ae115bc7Smrj * DESCRIPTION: Print message with no headers. Has same interface as
257ae115bc7Smrj * DebugPrint so that the same macros can be used.
258ae115bc7Smrj *
259ae115bc7Smrj ******************************************************************************/
260ae115bc7Smrj
261ae115bc7Smrj void ACPI_INTERNAL_VAR_XFACE
262aa2aa9a6SDana Myers AcpiDebugPrintRaw (
263ae115bc7Smrj UINT32 RequestedDebugLevel,
264ae115bc7Smrj UINT32 LineNumber,
265ae115bc7Smrj const char *FunctionName,
266db2bae30SDana Myers const char *ModuleName,
267ae115bc7Smrj UINT32 ComponentId,
268db2bae30SDana Myers const char *Format,
269ae115bc7Smrj ...)
270ae115bc7Smrj {
271ae115bc7Smrj va_list args;
272ae115bc7Smrj
273ae115bc7Smrj
274*385cc6b4SJerry Jelinek /* Check if debug output enabled */
275*385cc6b4SJerry Jelinek
276*385cc6b4SJerry Jelinek if (!ACPI_IS_DEBUG_ENABLED (RequestedDebugLevel, ComponentId))
277ae115bc7Smrj {
278ae115bc7Smrj return;
279ae115bc7Smrj }
280ae115bc7Smrj
281ae115bc7Smrj va_start (args, Format);
282ae115bc7Smrj AcpiOsVprintf (Format, args);
283db2bae30SDana Myers va_end (args);
284ae115bc7Smrj }
285ae115bc7Smrj
ACPI_EXPORT_SYMBOL(AcpiDebugPrintRaw)286aa2aa9a6SDana Myers ACPI_EXPORT_SYMBOL (AcpiDebugPrintRaw)
287ae115bc7Smrj
288ae115bc7Smrj
289ae115bc7Smrj /*******************************************************************************
290ae115bc7Smrj *
291ae115bc7Smrj * FUNCTION: AcpiUtTrace
292ae115bc7Smrj *
293ae115bc7Smrj * PARAMETERS: LineNumber - Caller's line number
294ae115bc7Smrj * FunctionName - Caller's procedure name
295ae115bc7Smrj * ModuleName - Caller's module name
296ae115bc7Smrj * ComponentId - Caller's component ID
297ae115bc7Smrj *
298ae115bc7Smrj * RETURN: None
299ae115bc7Smrj *
300ae115bc7Smrj * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
301ae115bc7Smrj * set in DebugLevel
302ae115bc7Smrj *
303ae115bc7Smrj ******************************************************************************/
304ae115bc7Smrj
305ae115bc7Smrj void
306ae115bc7Smrj AcpiUtTrace (
307ae115bc7Smrj UINT32 LineNumber,
308ae115bc7Smrj const char *FunctionName,
309db2bae30SDana Myers const char *ModuleName,
310ae115bc7Smrj UINT32 ComponentId)
311ae115bc7Smrj {
312ae115bc7Smrj
313ae115bc7Smrj AcpiGbl_NestingLevel++;
314ae115bc7Smrj AcpiUtTrackStackPtr ();
315ae115bc7Smrj
316*385cc6b4SJerry Jelinek /* Check if enabled up-front for performance */
317*385cc6b4SJerry Jelinek
318*385cc6b4SJerry Jelinek if (ACPI_IS_DEBUG_ENABLED (ACPI_LV_FUNCTIONS, ComponentId))
319*385cc6b4SJerry Jelinek {
320aa2aa9a6SDana Myers AcpiDebugPrint (ACPI_LV_FUNCTIONS,
321ae115bc7Smrj LineNumber, FunctionName, ModuleName, ComponentId,
322*385cc6b4SJerry Jelinek "%s\n", AcpiGbl_FunctionEntryPrefix);
323*385cc6b4SJerry Jelinek }
324ae115bc7Smrj }
325ae115bc7Smrj
ACPI_EXPORT_SYMBOL(AcpiUtTrace)326ae115bc7Smrj ACPI_EXPORT_SYMBOL (AcpiUtTrace)
327ae115bc7Smrj
328ae115bc7Smrj
329ae115bc7Smrj /*******************************************************************************
330ae115bc7Smrj *
331ae115bc7Smrj * FUNCTION: AcpiUtTracePtr
332ae115bc7Smrj *
333ae115bc7Smrj * PARAMETERS: LineNumber - Caller's line number
334ae115bc7Smrj * FunctionName - Caller's procedure name
335ae115bc7Smrj * ModuleName - Caller's module name
336ae115bc7Smrj * ComponentId - Caller's component ID
337ae115bc7Smrj * Pointer - Pointer to display
338ae115bc7Smrj *
339ae115bc7Smrj * RETURN: None
340ae115bc7Smrj *
341ae115bc7Smrj * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
342ae115bc7Smrj * set in DebugLevel
343ae115bc7Smrj *
344ae115bc7Smrj ******************************************************************************/
345ae115bc7Smrj
346ae115bc7Smrj void
347ae115bc7Smrj AcpiUtTracePtr (
348ae115bc7Smrj UINT32 LineNumber,
349ae115bc7Smrj const char *FunctionName,
350db2bae30SDana Myers const char *ModuleName,
351ae115bc7Smrj UINT32 ComponentId,
352*385cc6b4SJerry Jelinek const void *Pointer)
353ae115bc7Smrj {
354*385cc6b4SJerry Jelinek
355ae115bc7Smrj AcpiGbl_NestingLevel++;
356ae115bc7Smrj AcpiUtTrackStackPtr ();
357ae115bc7Smrj
358*385cc6b4SJerry Jelinek /* Check if enabled up-front for performance */
359*385cc6b4SJerry Jelinek
360*385cc6b4SJerry Jelinek if (ACPI_IS_DEBUG_ENABLED (ACPI_LV_FUNCTIONS, ComponentId))
361*385cc6b4SJerry Jelinek {
362aa2aa9a6SDana Myers AcpiDebugPrint (ACPI_LV_FUNCTIONS,
363ae115bc7Smrj LineNumber, FunctionName, ModuleName, ComponentId,
364*385cc6b4SJerry Jelinek "%s %p\n", AcpiGbl_FunctionEntryPrefix, Pointer);
365*385cc6b4SJerry Jelinek }
366ae115bc7Smrj }
367ae115bc7Smrj
368ae115bc7Smrj
369ae115bc7Smrj /*******************************************************************************
370ae115bc7Smrj *
371ae115bc7Smrj * FUNCTION: AcpiUtTraceStr
372ae115bc7Smrj *
373ae115bc7Smrj * PARAMETERS: LineNumber - Caller's line number
374ae115bc7Smrj * FunctionName - Caller's procedure name
375ae115bc7Smrj * ModuleName - Caller's module name
376ae115bc7Smrj * ComponentId - Caller's component ID
377ae115bc7Smrj * String - Additional string to display
378ae115bc7Smrj *
379ae115bc7Smrj * RETURN: None
380ae115bc7Smrj *
381ae115bc7Smrj * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
382ae115bc7Smrj * set in DebugLevel
383ae115bc7Smrj *
384ae115bc7Smrj ******************************************************************************/
385ae115bc7Smrj
386ae115bc7Smrj void
AcpiUtTraceStr(UINT32 LineNumber,const char * FunctionName,const char * ModuleName,UINT32 ComponentId,const char * String)387ae115bc7Smrj AcpiUtTraceStr (
388ae115bc7Smrj UINT32 LineNumber,
389ae115bc7Smrj const char *FunctionName,
390db2bae30SDana Myers const char *ModuleName,
391ae115bc7Smrj UINT32 ComponentId,
392*385cc6b4SJerry Jelinek const char *String)
393ae115bc7Smrj {
394ae115bc7Smrj
395ae115bc7Smrj AcpiGbl_NestingLevel++;
396ae115bc7Smrj AcpiUtTrackStackPtr ();
397ae115bc7Smrj
398*385cc6b4SJerry Jelinek /* Check if enabled up-front for performance */
399*385cc6b4SJerry Jelinek
400*385cc6b4SJerry Jelinek if (ACPI_IS_DEBUG_ENABLED (ACPI_LV_FUNCTIONS, ComponentId))
401*385cc6b4SJerry Jelinek {
402aa2aa9a6SDana Myers AcpiDebugPrint (ACPI_LV_FUNCTIONS,
403ae115bc7Smrj LineNumber, FunctionName, ModuleName, ComponentId,
404*385cc6b4SJerry Jelinek "%s %s\n", AcpiGbl_FunctionEntryPrefix, String);
405*385cc6b4SJerry Jelinek }
406ae115bc7Smrj }
407ae115bc7Smrj
408ae115bc7Smrj
409ae115bc7Smrj /*******************************************************************************
410ae115bc7Smrj *
411ae115bc7Smrj * FUNCTION: AcpiUtTraceU32
412ae115bc7Smrj *
413ae115bc7Smrj * PARAMETERS: LineNumber - Caller's line number
414ae115bc7Smrj * FunctionName - Caller's procedure name
415ae115bc7Smrj * ModuleName - Caller's module name
416ae115bc7Smrj * ComponentId - Caller's component ID
417ae115bc7Smrj * Integer - Integer to display
418ae115bc7Smrj *
419ae115bc7Smrj * RETURN: None
420ae115bc7Smrj *
421ae115bc7Smrj * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
422ae115bc7Smrj * set in DebugLevel
423ae115bc7Smrj *
424ae115bc7Smrj ******************************************************************************/
425ae115bc7Smrj
426ae115bc7Smrj void
AcpiUtTraceU32(UINT32 LineNumber,const char * FunctionName,const char * ModuleName,UINT32 ComponentId,UINT32 Integer)427ae115bc7Smrj AcpiUtTraceU32 (
428ae115bc7Smrj UINT32 LineNumber,
429ae115bc7Smrj const char *FunctionName,
430db2bae30SDana Myers const char *ModuleName,
431ae115bc7Smrj UINT32 ComponentId,
432ae115bc7Smrj UINT32 Integer)
433ae115bc7Smrj {
434ae115bc7Smrj
435ae115bc7Smrj AcpiGbl_NestingLevel++;
436ae115bc7Smrj AcpiUtTrackStackPtr ();
437ae115bc7Smrj
438*385cc6b4SJerry Jelinek /* Check if enabled up-front for performance */
439*385cc6b4SJerry Jelinek
440*385cc6b4SJerry Jelinek if (ACPI_IS_DEBUG_ENABLED (ACPI_LV_FUNCTIONS, ComponentId))
441*385cc6b4SJerry Jelinek {
442aa2aa9a6SDana Myers AcpiDebugPrint (ACPI_LV_FUNCTIONS,
443ae115bc7Smrj LineNumber, FunctionName, ModuleName, ComponentId,
444*385cc6b4SJerry Jelinek "%s %08X\n", AcpiGbl_FunctionEntryPrefix, Integer);
445*385cc6b4SJerry Jelinek }
446ae115bc7Smrj }
447ae115bc7Smrj
448ae115bc7Smrj
449ae115bc7Smrj /*******************************************************************************
450ae115bc7Smrj *
451ae115bc7Smrj * FUNCTION: AcpiUtExit
452ae115bc7Smrj *
453ae115bc7Smrj * PARAMETERS: LineNumber - Caller's line number
454ae115bc7Smrj * FunctionName - Caller's procedure name
455ae115bc7Smrj * ModuleName - Caller's module name
456ae115bc7Smrj * ComponentId - Caller's component ID
457ae115bc7Smrj *
458ae115bc7Smrj * RETURN: None
459ae115bc7Smrj *
460ae115bc7Smrj * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
461ae115bc7Smrj * set in DebugLevel
462ae115bc7Smrj *
463ae115bc7Smrj ******************************************************************************/
464ae115bc7Smrj
465ae115bc7Smrj void
AcpiUtExit(UINT32 LineNumber,const char * FunctionName,const char * ModuleName,UINT32 ComponentId)466ae115bc7Smrj AcpiUtExit (
467ae115bc7Smrj UINT32 LineNumber,
468ae115bc7Smrj const char *FunctionName,
469db2bae30SDana Myers const char *ModuleName,
470ae115bc7Smrj UINT32 ComponentId)
471ae115bc7Smrj {
472ae115bc7Smrj
473*385cc6b4SJerry Jelinek /* Check if enabled up-front for performance */
474*385cc6b4SJerry Jelinek
475*385cc6b4SJerry Jelinek if (ACPI_IS_DEBUG_ENABLED (ACPI_LV_FUNCTIONS, ComponentId))
476*385cc6b4SJerry Jelinek {
477aa2aa9a6SDana Myers AcpiDebugPrint (ACPI_LV_FUNCTIONS,
478ae115bc7Smrj LineNumber, FunctionName, ModuleName, ComponentId,
479*385cc6b4SJerry Jelinek "%s\n", AcpiGbl_FunctionExitPrefix);
480*385cc6b4SJerry Jelinek }
481ae115bc7Smrj
482*385cc6b4SJerry Jelinek if (AcpiGbl_NestingLevel)
483*385cc6b4SJerry Jelinek {
484ae115bc7Smrj AcpiGbl_NestingLevel--;
485ae115bc7Smrj }
486*385cc6b4SJerry Jelinek }
487ae115bc7Smrj
ACPI_EXPORT_SYMBOL(AcpiUtExit)488ae115bc7Smrj ACPI_EXPORT_SYMBOL (AcpiUtExit)
489ae115bc7Smrj
490ae115bc7Smrj
491ae115bc7Smrj /*******************************************************************************
492ae115bc7Smrj *
493ae115bc7Smrj * FUNCTION: AcpiUtStatusExit
494ae115bc7Smrj *
495ae115bc7Smrj * PARAMETERS: LineNumber - Caller's line number
496ae115bc7Smrj * FunctionName - Caller's procedure name
497ae115bc7Smrj * ModuleName - Caller's module name
498ae115bc7Smrj * ComponentId - Caller's component ID
499ae115bc7Smrj * Status - Exit status code
500ae115bc7Smrj *
501ae115bc7Smrj * RETURN: None
502ae115bc7Smrj *
503ae115bc7Smrj * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
504ae115bc7Smrj * set in DebugLevel. Prints exit status also.
505ae115bc7Smrj *
506ae115bc7Smrj ******************************************************************************/
507ae115bc7Smrj
508ae115bc7Smrj void
509ae115bc7Smrj AcpiUtStatusExit (
510ae115bc7Smrj UINT32 LineNumber,
511ae115bc7Smrj const char *FunctionName,
512db2bae30SDana Myers const char *ModuleName,
513ae115bc7Smrj UINT32 ComponentId,
514ae115bc7Smrj ACPI_STATUS Status)
515ae115bc7Smrj {
516ae115bc7Smrj
517*385cc6b4SJerry Jelinek /* Check if enabled up-front for performance */
518*385cc6b4SJerry Jelinek
519*385cc6b4SJerry Jelinek if (ACPI_IS_DEBUG_ENABLED (ACPI_LV_FUNCTIONS, ComponentId))
520*385cc6b4SJerry Jelinek {
521ae115bc7Smrj if (ACPI_SUCCESS (Status))
522ae115bc7Smrj {
523aa2aa9a6SDana Myers AcpiDebugPrint (ACPI_LV_FUNCTIONS,
524ae115bc7Smrj LineNumber, FunctionName, ModuleName, ComponentId,
525*385cc6b4SJerry Jelinek "%s %s\n", AcpiGbl_FunctionExitPrefix,
526ae115bc7Smrj AcpiFormatException (Status));
527ae115bc7Smrj }
528ae115bc7Smrj else
529ae115bc7Smrj {
530aa2aa9a6SDana Myers AcpiDebugPrint (ACPI_LV_FUNCTIONS,
531ae115bc7Smrj LineNumber, FunctionName, ModuleName, ComponentId,
532*385cc6b4SJerry Jelinek "%s ****Exception****: %s\n", AcpiGbl_FunctionExitPrefix,
533ae115bc7Smrj AcpiFormatException (Status));
534ae115bc7Smrj }
535*385cc6b4SJerry Jelinek }
536ae115bc7Smrj
537*385cc6b4SJerry Jelinek if (AcpiGbl_NestingLevel)
538*385cc6b4SJerry Jelinek {
539ae115bc7Smrj AcpiGbl_NestingLevel--;
540ae115bc7Smrj }
541*385cc6b4SJerry Jelinek }
542ae115bc7Smrj
ACPI_EXPORT_SYMBOL(AcpiUtStatusExit)543ae115bc7Smrj ACPI_EXPORT_SYMBOL (AcpiUtStatusExit)
544ae115bc7Smrj
545ae115bc7Smrj
546ae115bc7Smrj /*******************************************************************************
547ae115bc7Smrj *
548ae115bc7Smrj * FUNCTION: AcpiUtValueExit
549ae115bc7Smrj *
550ae115bc7Smrj * PARAMETERS: LineNumber - Caller's line number
551ae115bc7Smrj * FunctionName - Caller's procedure name
552ae115bc7Smrj * ModuleName - Caller's module name
553ae115bc7Smrj * ComponentId - Caller's component ID
554ae115bc7Smrj * Value - Value to be printed with exit msg
555ae115bc7Smrj *
556ae115bc7Smrj * RETURN: None
557ae115bc7Smrj *
558ae115bc7Smrj * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
559ae115bc7Smrj * set in DebugLevel. Prints exit value also.
560ae115bc7Smrj *
561ae115bc7Smrj ******************************************************************************/
562ae115bc7Smrj
563ae115bc7Smrj void
564ae115bc7Smrj AcpiUtValueExit (
565ae115bc7Smrj UINT32 LineNumber,
566ae115bc7Smrj const char *FunctionName,
567db2bae30SDana Myers const char *ModuleName,
568ae115bc7Smrj UINT32 ComponentId,
56926f3cdf0SGordon Ross UINT64 Value)
570ae115bc7Smrj {
571ae115bc7Smrj
572*385cc6b4SJerry Jelinek /* Check if enabled up-front for performance */
573*385cc6b4SJerry Jelinek
574*385cc6b4SJerry Jelinek if (ACPI_IS_DEBUG_ENABLED (ACPI_LV_FUNCTIONS, ComponentId))
575*385cc6b4SJerry Jelinek {
576aa2aa9a6SDana Myers AcpiDebugPrint (ACPI_LV_FUNCTIONS,
577ae115bc7Smrj LineNumber, FunctionName, ModuleName, ComponentId,
578*385cc6b4SJerry Jelinek "%s %8.8X%8.8X\n", AcpiGbl_FunctionExitPrefix,
579ae115bc7Smrj ACPI_FORMAT_UINT64 (Value));
580*385cc6b4SJerry Jelinek }
581ae115bc7Smrj
582*385cc6b4SJerry Jelinek if (AcpiGbl_NestingLevel)
583*385cc6b4SJerry Jelinek {
584ae115bc7Smrj AcpiGbl_NestingLevel--;
585ae115bc7Smrj }
586*385cc6b4SJerry Jelinek }
587ae115bc7Smrj
ACPI_EXPORT_SYMBOL(AcpiUtValueExit)588ae115bc7Smrj ACPI_EXPORT_SYMBOL (AcpiUtValueExit)
589ae115bc7Smrj
590ae115bc7Smrj
591ae115bc7Smrj /*******************************************************************************
592ae115bc7Smrj *
593ae115bc7Smrj * FUNCTION: AcpiUtPtrExit
594ae115bc7Smrj *
595ae115bc7Smrj * PARAMETERS: LineNumber - Caller's line number
596ae115bc7Smrj * FunctionName - Caller's procedure name
597ae115bc7Smrj * ModuleName - Caller's module name
598ae115bc7Smrj * ComponentId - Caller's component ID
599ae115bc7Smrj * Ptr - Pointer to display
600ae115bc7Smrj *
601ae115bc7Smrj * RETURN: None
602ae115bc7Smrj *
603ae115bc7Smrj * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
604ae115bc7Smrj * set in DebugLevel. Prints exit value also.
605ae115bc7Smrj *
606ae115bc7Smrj ******************************************************************************/
607ae115bc7Smrj
608ae115bc7Smrj void
609ae115bc7Smrj AcpiUtPtrExit (
610ae115bc7Smrj UINT32 LineNumber,
611ae115bc7Smrj const char *FunctionName,
612db2bae30SDana Myers const char *ModuleName,
613ae115bc7Smrj UINT32 ComponentId,
614ae115bc7Smrj UINT8 *Ptr)
615ae115bc7Smrj {
616ae115bc7Smrj
617*385cc6b4SJerry Jelinek /* Check if enabled up-front for performance */
618*385cc6b4SJerry Jelinek
619*385cc6b4SJerry Jelinek if (ACPI_IS_DEBUG_ENABLED (ACPI_LV_FUNCTIONS, ComponentId))
620*385cc6b4SJerry Jelinek {
621aa2aa9a6SDana Myers AcpiDebugPrint (ACPI_LV_FUNCTIONS,
622ae115bc7Smrj LineNumber, FunctionName, ModuleName, ComponentId,
623*385cc6b4SJerry Jelinek "%s %p\n", AcpiGbl_FunctionExitPrefix, Ptr);
624*385cc6b4SJerry Jelinek }
625ae115bc7Smrj
626*385cc6b4SJerry Jelinek if (AcpiGbl_NestingLevel)
627*385cc6b4SJerry Jelinek {
628ae115bc7Smrj AcpiGbl_NestingLevel--;
629ae115bc7Smrj }
630*385cc6b4SJerry Jelinek }
631*385cc6b4SJerry Jelinek
632*385cc6b4SJerry Jelinek
633*385cc6b4SJerry Jelinek /*******************************************************************************
634*385cc6b4SJerry Jelinek *
635*385cc6b4SJerry Jelinek * FUNCTION: AcpiUtStrExit
636*385cc6b4SJerry Jelinek *
637*385cc6b4SJerry Jelinek * PARAMETERS: LineNumber - Caller's line number
638*385cc6b4SJerry Jelinek * FunctionName - Caller's procedure name
639*385cc6b4SJerry Jelinek * ModuleName - Caller's module name
640*385cc6b4SJerry Jelinek * ComponentId - Caller's component ID
641*385cc6b4SJerry Jelinek * String - String to display
642*385cc6b4SJerry Jelinek *
643*385cc6b4SJerry Jelinek * RETURN: None
644*385cc6b4SJerry Jelinek *
645*385cc6b4SJerry Jelinek * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
646*385cc6b4SJerry Jelinek * set in DebugLevel. Prints exit value also.
647*385cc6b4SJerry Jelinek *
648*385cc6b4SJerry Jelinek ******************************************************************************/
649*385cc6b4SJerry Jelinek
650*385cc6b4SJerry Jelinek void
AcpiUtStrExit(UINT32 LineNumber,const char * FunctionName,const char * ModuleName,UINT32 ComponentId,const char * String)651*385cc6b4SJerry Jelinek AcpiUtStrExit (
652*385cc6b4SJerry Jelinek UINT32 LineNumber,
653*385cc6b4SJerry Jelinek const char *FunctionName,
654*385cc6b4SJerry Jelinek const char *ModuleName,
655*385cc6b4SJerry Jelinek UINT32 ComponentId,
656*385cc6b4SJerry Jelinek const char *String)
657*385cc6b4SJerry Jelinek {
658*385cc6b4SJerry Jelinek
659*385cc6b4SJerry Jelinek /* Check if enabled up-front for performance */
660*385cc6b4SJerry Jelinek
661*385cc6b4SJerry Jelinek if (ACPI_IS_DEBUG_ENABLED (ACPI_LV_FUNCTIONS, ComponentId))
662*385cc6b4SJerry Jelinek {
663*385cc6b4SJerry Jelinek AcpiDebugPrint (ACPI_LV_FUNCTIONS,
664*385cc6b4SJerry Jelinek LineNumber, FunctionName, ModuleName, ComponentId,
665*385cc6b4SJerry Jelinek "%s %s\n", AcpiGbl_FunctionExitPrefix, String);
666*385cc6b4SJerry Jelinek }
667*385cc6b4SJerry Jelinek
668*385cc6b4SJerry Jelinek if (AcpiGbl_NestingLevel)
669*385cc6b4SJerry Jelinek {
670*385cc6b4SJerry Jelinek AcpiGbl_NestingLevel--;
671*385cc6b4SJerry Jelinek }
672*385cc6b4SJerry Jelinek }
673*385cc6b4SJerry Jelinek
674*385cc6b4SJerry Jelinek
675*385cc6b4SJerry Jelinek /*******************************************************************************
676*385cc6b4SJerry Jelinek *
677*385cc6b4SJerry Jelinek * FUNCTION: AcpiTracePoint
678*385cc6b4SJerry Jelinek *
679*385cc6b4SJerry Jelinek * PARAMETERS: Type - Trace event type
680*385cc6b4SJerry Jelinek * Begin - TRUE if before execution
681*385cc6b4SJerry Jelinek * Aml - Executed AML address
682*385cc6b4SJerry Jelinek * Pathname - Object path
683*385cc6b4SJerry Jelinek * Pointer - Pointer to the related object
684*385cc6b4SJerry Jelinek *
685*385cc6b4SJerry Jelinek * RETURN: None
686*385cc6b4SJerry Jelinek *
687*385cc6b4SJerry Jelinek * DESCRIPTION: Interpreter execution trace.
688*385cc6b4SJerry Jelinek *
689*385cc6b4SJerry Jelinek ******************************************************************************/
690*385cc6b4SJerry Jelinek
691*385cc6b4SJerry Jelinek void
AcpiTracePoint(ACPI_TRACE_EVENT_TYPE Type,BOOLEAN Begin,UINT8 * Aml,char * Pathname)692*385cc6b4SJerry Jelinek AcpiTracePoint (
693*385cc6b4SJerry Jelinek ACPI_TRACE_EVENT_TYPE Type,
694*385cc6b4SJerry Jelinek BOOLEAN Begin,
695*385cc6b4SJerry Jelinek UINT8 *Aml,
696*385cc6b4SJerry Jelinek char *Pathname)
697*385cc6b4SJerry Jelinek {
698*385cc6b4SJerry Jelinek
699*385cc6b4SJerry Jelinek ACPI_FUNCTION_ENTRY ();
700*385cc6b4SJerry Jelinek
701*385cc6b4SJerry Jelinek AcpiExTracePoint (Type, Begin, Aml, Pathname);
702*385cc6b4SJerry Jelinek
703*385cc6b4SJerry Jelinek #ifdef ACPI_USE_SYSTEM_TRACER
704*385cc6b4SJerry Jelinek AcpiOsTracePoint (Type, Begin, Aml, Pathname);
705*385cc6b4SJerry Jelinek #endif
706*385cc6b4SJerry Jelinek }
707*385cc6b4SJerry Jelinek
ACPI_EXPORT_SYMBOL(AcpiTracePoint)708*385cc6b4SJerry Jelinek ACPI_EXPORT_SYMBOL (AcpiTracePoint)
709ae115bc7Smrj
710ae115bc7Smrj #endif
711ae115bc7Smrj
712ae115bc7Smrj
713*385cc6b4SJerry Jelinek #ifdef ACPI_APPLICATION
714ae115bc7Smrj /*******************************************************************************
715ae115bc7Smrj *
716*385cc6b4SJerry Jelinek * FUNCTION: AcpiLogError
717ae115bc7Smrj *
718*385cc6b4SJerry Jelinek * PARAMETERS: Format - Printf format field
719*385cc6b4SJerry Jelinek * ... - Optional printf arguments
720ae115bc7Smrj *
721ae115bc7Smrj * RETURN: None
722ae115bc7Smrj *
723*385cc6b4SJerry Jelinek * DESCRIPTION: Print error message to the console, used by applications.
724ae115bc7Smrj *
725ae115bc7Smrj ******************************************************************************/
726ae115bc7Smrj
727*385cc6b4SJerry Jelinek void ACPI_INTERNAL_VAR_XFACE
728*385cc6b4SJerry Jelinek AcpiLogError (
729*385cc6b4SJerry Jelinek const char *Format,
730*385cc6b4SJerry Jelinek ...)
731ae115bc7Smrj {
732*385cc6b4SJerry Jelinek va_list Args;
733ae115bc7Smrj
734*385cc6b4SJerry Jelinek va_start (Args, Format);
735*385cc6b4SJerry Jelinek (void) AcpiUtFileVprintf (ACPI_FILE_ERR, Format, Args);
736*385cc6b4SJerry Jelinek va_end (Args);
737db2bae30SDana Myers }
738db2bae30SDana Myers
739*385cc6b4SJerry Jelinek ACPI_EXPORT_SYMBOL (AcpiLogError)
740*385cc6b4SJerry Jelinek #endif
741