xref: /minix3/minix/drivers/power/acpi/utilities/utdebug.c (revision 29492bb71c7148a089a5afafa0c99409161218df)
1433d6423SLionel Sambuc /******************************************************************************
2433d6423SLionel Sambuc  *
3*29492bb7SDavid van Moolenbroek  * Module Name: utdebug - Debug print/trace routines
4433d6423SLionel Sambuc  *
5433d6423SLionel Sambuc  *****************************************************************************/
6433d6423SLionel Sambuc 
7*29492bb7SDavid van Moolenbroek /*
8*29492bb7SDavid van Moolenbroek  * Copyright (C) 2000 - 2014, Intel Corp.
9433d6423SLionel Sambuc  * All rights reserved.
10433d6423SLionel Sambuc  *
11*29492bb7SDavid van Moolenbroek  * Redistribution and use in source and binary forms, with or without
12*29492bb7SDavid van Moolenbroek  * modification, are permitted provided that the following conditions
13*29492bb7SDavid van Moolenbroek  * are met:
14*29492bb7SDavid van Moolenbroek  * 1. Redistributions of source code must retain the above copyright
15*29492bb7SDavid van Moolenbroek  *    notice, this list of conditions, and the following disclaimer,
16*29492bb7SDavid van Moolenbroek  *    without modification.
17*29492bb7SDavid van Moolenbroek  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18*29492bb7SDavid van Moolenbroek  *    substantially similar to the "NO WARRANTY" disclaimer below
19*29492bb7SDavid van Moolenbroek  *    ("Disclaimer") and any redistribution must be conditioned upon
20*29492bb7SDavid van Moolenbroek  *    including a substantially similar Disclaimer requirement for further
21*29492bb7SDavid van Moolenbroek  *    binary redistribution.
22*29492bb7SDavid van Moolenbroek  * 3. Neither the names of the above-listed copyright holders nor the names
23*29492bb7SDavid van Moolenbroek  *    of any contributors may be used to endorse or promote products derived
24*29492bb7SDavid van Moolenbroek  *    from this software without specific prior written permission.
25433d6423SLionel Sambuc  *
26*29492bb7SDavid van Moolenbroek  * Alternatively, this software may be distributed under the terms of the
27*29492bb7SDavid van Moolenbroek  * GNU General Public License ("GPL") version 2 as published by the Free
28*29492bb7SDavid van Moolenbroek  * Software Foundation.
29433d6423SLionel Sambuc  *
30*29492bb7SDavid van Moolenbroek  * NO WARRANTY
31*29492bb7SDavid van Moolenbroek  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32*29492bb7SDavid van Moolenbroek  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33*29492bb7SDavid van Moolenbroek  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34*29492bb7SDavid van Moolenbroek  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35*29492bb7SDavid van Moolenbroek  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36*29492bb7SDavid van Moolenbroek  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37*29492bb7SDavid van Moolenbroek  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38*29492bb7SDavid van Moolenbroek  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39*29492bb7SDavid van Moolenbroek  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40*29492bb7SDavid van Moolenbroek  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41*29492bb7SDavid van Moolenbroek  * POSSIBILITY OF SUCH DAMAGES.
42*29492bb7SDavid van Moolenbroek  */
43433d6423SLionel Sambuc 
44*29492bb7SDavid van Moolenbroek #define EXPORT_ACPI_INTERFACES
45433d6423SLionel Sambuc 
46433d6423SLionel Sambuc #include "acpi.h"
47433d6423SLionel Sambuc #include "accommon.h"
48433d6423SLionel Sambuc 
49433d6423SLionel Sambuc #define _COMPONENT          ACPI_UTILITIES
50433d6423SLionel Sambuc         ACPI_MODULE_NAME    ("utdebug")
51433d6423SLionel Sambuc 
52433d6423SLionel Sambuc 
53433d6423SLionel Sambuc #ifdef ACPI_DEBUG_OUTPUT
54433d6423SLionel Sambuc 
55433d6423SLionel Sambuc static ACPI_THREAD_ID       AcpiGbl_PrevThreadId = (ACPI_THREAD_ID) 0xFFFFFFFF;
56433d6423SLionel Sambuc static char                 *AcpiGbl_FnEntryStr = "----Entry";
57433d6423SLionel Sambuc static char                 *AcpiGbl_FnExitStr  = "----Exit-";
58433d6423SLionel Sambuc 
59433d6423SLionel Sambuc /* Local prototypes */
60433d6423SLionel Sambuc 
61433d6423SLionel Sambuc static const char *
62433d6423SLionel Sambuc AcpiUtTrimFunctionName (
63433d6423SLionel Sambuc     const char              *FunctionName);
64433d6423SLionel Sambuc 
65433d6423SLionel Sambuc 
66433d6423SLionel Sambuc /*******************************************************************************
67433d6423SLionel Sambuc  *
68433d6423SLionel Sambuc  * FUNCTION:    AcpiUtInitStackPtrTrace
69433d6423SLionel Sambuc  *
70433d6423SLionel Sambuc  * PARAMETERS:  None
71433d6423SLionel Sambuc  *
72433d6423SLionel Sambuc  * RETURN:      None
73433d6423SLionel Sambuc  *
74433d6423SLionel Sambuc  * DESCRIPTION: Save the current CPU stack pointer at subsystem startup
75433d6423SLionel Sambuc  *
76433d6423SLionel Sambuc  ******************************************************************************/
77433d6423SLionel Sambuc 
78433d6423SLionel Sambuc void
AcpiUtInitStackPtrTrace(void)79433d6423SLionel Sambuc AcpiUtInitStackPtrTrace (
80433d6423SLionel Sambuc     void)
81433d6423SLionel Sambuc {
82433d6423SLionel Sambuc     ACPI_SIZE               CurrentSp;
83433d6423SLionel Sambuc 
84433d6423SLionel Sambuc 
85433d6423SLionel Sambuc     AcpiGbl_EntryStackPointer = &CurrentSp;
86433d6423SLionel Sambuc }
87433d6423SLionel Sambuc 
88433d6423SLionel Sambuc 
89433d6423SLionel Sambuc /*******************************************************************************
90433d6423SLionel Sambuc  *
91433d6423SLionel Sambuc  * FUNCTION:    AcpiUtTrackStackPtr
92433d6423SLionel Sambuc  *
93433d6423SLionel Sambuc  * PARAMETERS:  None
94433d6423SLionel Sambuc  *
95433d6423SLionel Sambuc  * RETURN:      None
96433d6423SLionel Sambuc  *
97433d6423SLionel Sambuc  * DESCRIPTION: Save the current CPU stack pointer
98433d6423SLionel Sambuc  *
99433d6423SLionel Sambuc  ******************************************************************************/
100433d6423SLionel Sambuc 
101433d6423SLionel Sambuc void
AcpiUtTrackStackPtr(void)102433d6423SLionel Sambuc AcpiUtTrackStackPtr (
103433d6423SLionel Sambuc     void)
104433d6423SLionel Sambuc {
105433d6423SLionel Sambuc     ACPI_SIZE               CurrentSp;
106433d6423SLionel Sambuc 
107433d6423SLionel Sambuc 
108433d6423SLionel Sambuc     if (&CurrentSp < AcpiGbl_LowestStackPointer)
109433d6423SLionel Sambuc     {
110433d6423SLionel Sambuc         AcpiGbl_LowestStackPointer = &CurrentSp;
111433d6423SLionel Sambuc     }
112433d6423SLionel Sambuc 
113433d6423SLionel Sambuc     if (AcpiGbl_NestingLevel > AcpiGbl_DeepestNesting)
114433d6423SLionel Sambuc     {
115433d6423SLionel Sambuc         AcpiGbl_DeepestNesting = AcpiGbl_NestingLevel;
116433d6423SLionel Sambuc     }
117433d6423SLionel Sambuc }
118433d6423SLionel Sambuc 
119433d6423SLionel Sambuc 
120433d6423SLionel Sambuc /*******************************************************************************
121433d6423SLionel Sambuc  *
122433d6423SLionel Sambuc  * FUNCTION:    AcpiUtTrimFunctionName
123433d6423SLionel Sambuc  *
124433d6423SLionel Sambuc  * PARAMETERS:  FunctionName        - Ascii string containing a procedure name
125433d6423SLionel Sambuc  *
126433d6423SLionel Sambuc  * RETURN:      Updated pointer to the function name
127433d6423SLionel Sambuc  *
128433d6423SLionel Sambuc  * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present.
129433d6423SLionel Sambuc  *              This allows compiler macros such as __FUNCTION__ to be used
130433d6423SLionel Sambuc  *              with no change to the debug output.
131433d6423SLionel Sambuc  *
132433d6423SLionel Sambuc  ******************************************************************************/
133433d6423SLionel Sambuc 
134433d6423SLionel Sambuc static const char *
AcpiUtTrimFunctionName(const char * FunctionName)135433d6423SLionel Sambuc AcpiUtTrimFunctionName (
136433d6423SLionel Sambuc     const char              *FunctionName)
137433d6423SLionel Sambuc {
138433d6423SLionel Sambuc 
139433d6423SLionel Sambuc     /* All Function names are longer than 4 chars, check is safe */
140433d6423SLionel Sambuc 
141433d6423SLionel Sambuc     if (*(ACPI_CAST_PTR (UINT32, FunctionName)) == ACPI_PREFIX_MIXED)
142433d6423SLionel Sambuc     {
143433d6423SLionel Sambuc         /* This is the case where the original source has not been modified */
144433d6423SLionel Sambuc 
145433d6423SLionel Sambuc         return (FunctionName + 4);
146433d6423SLionel Sambuc     }
147433d6423SLionel Sambuc 
148433d6423SLionel Sambuc     if (*(ACPI_CAST_PTR (UINT32, FunctionName)) == ACPI_PREFIX_LOWER)
149433d6423SLionel Sambuc     {
150433d6423SLionel Sambuc         /* This is the case where the source has been 'linuxized' */
151433d6423SLionel Sambuc 
152433d6423SLionel Sambuc         return (FunctionName + 5);
153433d6423SLionel Sambuc     }
154433d6423SLionel Sambuc 
155433d6423SLionel Sambuc     return (FunctionName);
156433d6423SLionel Sambuc }
157433d6423SLionel Sambuc 
158433d6423SLionel Sambuc 
159433d6423SLionel Sambuc /*******************************************************************************
160433d6423SLionel Sambuc  *
161433d6423SLionel Sambuc  * FUNCTION:    AcpiDebugPrint
162433d6423SLionel Sambuc  *
163433d6423SLionel Sambuc  * PARAMETERS:  RequestedDebugLevel - Requested debug print level
164433d6423SLionel Sambuc  *              LineNumber          - Caller's line number (for error output)
165433d6423SLionel Sambuc  *              FunctionName        - Caller's procedure name
166433d6423SLionel Sambuc  *              ModuleName          - Caller's module name
167433d6423SLionel Sambuc  *              ComponentId         - Caller's component ID
168433d6423SLionel Sambuc  *              Format              - Printf format field
169433d6423SLionel Sambuc  *              ...                 - Optional printf arguments
170433d6423SLionel Sambuc  *
171433d6423SLionel Sambuc  * RETURN:      None
172433d6423SLionel Sambuc  *
173433d6423SLionel Sambuc  * DESCRIPTION: Print error message with prefix consisting of the module name,
174433d6423SLionel Sambuc  *              line number, and component ID.
175433d6423SLionel Sambuc  *
176433d6423SLionel Sambuc  ******************************************************************************/
177433d6423SLionel Sambuc 
178433d6423SLionel Sambuc void  ACPI_INTERNAL_VAR_XFACE
AcpiDebugPrint(UINT32 RequestedDebugLevel,UINT32 LineNumber,const char * FunctionName,const char * ModuleName,UINT32 ComponentId,const char * Format,...)179433d6423SLionel Sambuc AcpiDebugPrint (
180433d6423SLionel Sambuc     UINT32                  RequestedDebugLevel,
181433d6423SLionel Sambuc     UINT32                  LineNumber,
182433d6423SLionel Sambuc     const char              *FunctionName,
183433d6423SLionel Sambuc     const char              *ModuleName,
184433d6423SLionel Sambuc     UINT32                  ComponentId,
185433d6423SLionel Sambuc     const char              *Format,
186433d6423SLionel Sambuc     ...)
187433d6423SLionel Sambuc {
188433d6423SLionel Sambuc     ACPI_THREAD_ID          ThreadId;
189433d6423SLionel Sambuc     va_list                 args;
190433d6423SLionel Sambuc 
191433d6423SLionel Sambuc 
192*29492bb7SDavid van Moolenbroek     /* Check if debug output enabled */
193*29492bb7SDavid van Moolenbroek 
194*29492bb7SDavid van Moolenbroek     if (!ACPI_IS_DEBUG_ENABLED (RequestedDebugLevel, ComponentId))
195433d6423SLionel Sambuc     {
196433d6423SLionel Sambuc         return;
197433d6423SLionel Sambuc     }
198433d6423SLionel Sambuc 
199433d6423SLionel Sambuc     /*
200433d6423SLionel Sambuc      * Thread tracking and context switch notification
201433d6423SLionel Sambuc      */
202433d6423SLionel Sambuc     ThreadId = AcpiOsGetThreadId ();
203433d6423SLionel Sambuc     if (ThreadId != AcpiGbl_PrevThreadId)
204433d6423SLionel Sambuc     {
205433d6423SLionel Sambuc         if (ACPI_LV_THREADS & AcpiDbgLevel)
206433d6423SLionel Sambuc         {
207433d6423SLionel Sambuc             AcpiOsPrintf (
208*29492bb7SDavid van Moolenbroek                 "\n**** Context Switch from TID %u to TID %u ****\n\n",
209*29492bb7SDavid van Moolenbroek                 (UINT32) AcpiGbl_PrevThreadId, (UINT32) ThreadId);
210433d6423SLionel Sambuc         }
211433d6423SLionel Sambuc 
212433d6423SLionel Sambuc         AcpiGbl_PrevThreadId = ThreadId;
213*29492bb7SDavid van Moolenbroek         AcpiGbl_NestingLevel = 0;
214433d6423SLionel Sambuc     }
215433d6423SLionel Sambuc 
216433d6423SLionel Sambuc     /*
217433d6423SLionel Sambuc      * Display the module name, current line number, thread ID (if requested),
218433d6423SLionel Sambuc      * current procedure nesting level, and the current procedure name
219433d6423SLionel Sambuc      */
220*29492bb7SDavid van Moolenbroek     AcpiOsPrintf ("%9s-%04ld ", ModuleName, LineNumber);
221433d6423SLionel Sambuc 
222*29492bb7SDavid van Moolenbroek #ifdef ACPI_APPLICATION
223*29492bb7SDavid van Moolenbroek     /*
224*29492bb7SDavid van Moolenbroek      * For AcpiExec/iASL only, emit the thread ID and nesting level.
225*29492bb7SDavid van Moolenbroek      * Note: nesting level is really only useful during a single-thread
226*29492bb7SDavid van Moolenbroek      * execution. Otherwise, multiple threads will keep resetting the
227*29492bb7SDavid van Moolenbroek      * level.
228*29492bb7SDavid van Moolenbroek      */
229433d6423SLionel Sambuc     if (ACPI_LV_THREADS & AcpiDbgLevel)
230433d6423SLionel Sambuc     {
231*29492bb7SDavid van Moolenbroek         AcpiOsPrintf ("[%u] ", (UINT32) ThreadId);
232433d6423SLionel Sambuc     }
233433d6423SLionel Sambuc 
234*29492bb7SDavid van Moolenbroek     AcpiOsPrintf ("[%02ld] ", AcpiGbl_NestingLevel);
235*29492bb7SDavid van Moolenbroek #endif
236*29492bb7SDavid van Moolenbroek 
237*29492bb7SDavid van Moolenbroek     AcpiOsPrintf ("%-22.22s: ", AcpiUtTrimFunctionName (FunctionName));
238433d6423SLionel Sambuc 
239433d6423SLionel Sambuc     va_start (args, Format);
240433d6423SLionel Sambuc     AcpiOsVprintf (Format, args);
241433d6423SLionel Sambuc     va_end (args);
242433d6423SLionel Sambuc }
243433d6423SLionel Sambuc 
ACPI_EXPORT_SYMBOL(AcpiDebugPrint)244433d6423SLionel Sambuc ACPI_EXPORT_SYMBOL (AcpiDebugPrint)
245433d6423SLionel Sambuc 
246433d6423SLionel Sambuc 
247433d6423SLionel Sambuc /*******************************************************************************
248433d6423SLionel Sambuc  *
249433d6423SLionel Sambuc  * FUNCTION:    AcpiDebugPrintRaw
250433d6423SLionel Sambuc  *
251433d6423SLionel Sambuc  * PARAMETERS:  RequestedDebugLevel - Requested debug print level
252433d6423SLionel Sambuc  *              LineNumber          - Caller's line number
253433d6423SLionel Sambuc  *              FunctionName        - Caller's procedure name
254433d6423SLionel Sambuc  *              ModuleName          - Caller's module name
255433d6423SLionel Sambuc  *              ComponentId         - Caller's component ID
256433d6423SLionel Sambuc  *              Format              - Printf format field
257433d6423SLionel Sambuc  *              ...                 - Optional printf arguments
258433d6423SLionel Sambuc  *
259433d6423SLionel Sambuc  * RETURN:      None
260433d6423SLionel Sambuc  *
261433d6423SLionel Sambuc  * DESCRIPTION: Print message with no headers. Has same interface as
262433d6423SLionel Sambuc  *              DebugPrint so that the same macros can be used.
263433d6423SLionel Sambuc  *
264433d6423SLionel Sambuc  ******************************************************************************/
265433d6423SLionel Sambuc 
266433d6423SLionel Sambuc void  ACPI_INTERNAL_VAR_XFACE
267433d6423SLionel Sambuc AcpiDebugPrintRaw (
268433d6423SLionel Sambuc     UINT32                  RequestedDebugLevel,
269433d6423SLionel Sambuc     UINT32                  LineNumber,
270433d6423SLionel Sambuc     const char              *FunctionName,
271433d6423SLionel Sambuc     const char              *ModuleName,
272433d6423SLionel Sambuc     UINT32                  ComponentId,
273433d6423SLionel Sambuc     const char              *Format,
274433d6423SLionel Sambuc     ...)
275433d6423SLionel Sambuc {
276433d6423SLionel Sambuc     va_list                 args;
277433d6423SLionel Sambuc 
278433d6423SLionel Sambuc 
279*29492bb7SDavid van Moolenbroek     /* Check if debug output enabled */
280*29492bb7SDavid van Moolenbroek 
281*29492bb7SDavid van Moolenbroek     if (!ACPI_IS_DEBUG_ENABLED (RequestedDebugLevel, ComponentId))
282433d6423SLionel Sambuc     {
283433d6423SLionel Sambuc         return;
284433d6423SLionel Sambuc     }
285433d6423SLionel Sambuc 
286433d6423SLionel Sambuc     va_start (args, Format);
287433d6423SLionel Sambuc     AcpiOsVprintf (Format, args);
288433d6423SLionel Sambuc     va_end (args);
289433d6423SLionel Sambuc }
290433d6423SLionel Sambuc 
ACPI_EXPORT_SYMBOL(AcpiDebugPrintRaw)291433d6423SLionel Sambuc ACPI_EXPORT_SYMBOL (AcpiDebugPrintRaw)
292433d6423SLionel Sambuc 
293433d6423SLionel Sambuc 
294433d6423SLionel Sambuc /*******************************************************************************
295433d6423SLionel Sambuc  *
296433d6423SLionel Sambuc  * FUNCTION:    AcpiUtTrace
297433d6423SLionel Sambuc  *
298433d6423SLionel Sambuc  * PARAMETERS:  LineNumber          - Caller's line number
299433d6423SLionel Sambuc  *              FunctionName        - Caller's procedure name
300433d6423SLionel Sambuc  *              ModuleName          - Caller's module name
301433d6423SLionel Sambuc  *              ComponentId         - Caller's component ID
302433d6423SLionel Sambuc  *
303433d6423SLionel Sambuc  * RETURN:      None
304433d6423SLionel Sambuc  *
305433d6423SLionel Sambuc  * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
306433d6423SLionel Sambuc  *              set in DebugLevel
307433d6423SLionel Sambuc  *
308433d6423SLionel Sambuc  ******************************************************************************/
309433d6423SLionel Sambuc 
310433d6423SLionel Sambuc void
311433d6423SLionel Sambuc AcpiUtTrace (
312433d6423SLionel Sambuc     UINT32                  LineNumber,
313433d6423SLionel Sambuc     const char              *FunctionName,
314433d6423SLionel Sambuc     const char              *ModuleName,
315433d6423SLionel Sambuc     UINT32                  ComponentId)
316433d6423SLionel Sambuc {
317433d6423SLionel Sambuc 
318433d6423SLionel Sambuc     AcpiGbl_NestingLevel++;
319433d6423SLionel Sambuc     AcpiUtTrackStackPtr ();
320433d6423SLionel Sambuc 
321*29492bb7SDavid van Moolenbroek     /* Check if enabled up-front for performance */
322*29492bb7SDavid van Moolenbroek 
323*29492bb7SDavid van Moolenbroek     if (ACPI_IS_DEBUG_ENABLED (ACPI_LV_FUNCTIONS, ComponentId))
324*29492bb7SDavid van Moolenbroek     {
325433d6423SLionel Sambuc         AcpiDebugPrint (ACPI_LV_FUNCTIONS,
326433d6423SLionel Sambuc             LineNumber, FunctionName, ModuleName, ComponentId,
327433d6423SLionel Sambuc             "%s\n", AcpiGbl_FnEntryStr);
328433d6423SLionel Sambuc     }
329*29492bb7SDavid van Moolenbroek }
330433d6423SLionel Sambuc 
ACPI_EXPORT_SYMBOL(AcpiUtTrace)331433d6423SLionel Sambuc ACPI_EXPORT_SYMBOL (AcpiUtTrace)
332433d6423SLionel Sambuc 
333433d6423SLionel Sambuc 
334433d6423SLionel Sambuc /*******************************************************************************
335433d6423SLionel Sambuc  *
336433d6423SLionel Sambuc  * FUNCTION:    AcpiUtTracePtr
337433d6423SLionel Sambuc  *
338433d6423SLionel Sambuc  * PARAMETERS:  LineNumber          - Caller's line number
339433d6423SLionel Sambuc  *              FunctionName        - Caller's procedure name
340433d6423SLionel Sambuc  *              ModuleName          - Caller's module name
341433d6423SLionel Sambuc  *              ComponentId         - Caller's component ID
342433d6423SLionel Sambuc  *              Pointer             - Pointer to display
343433d6423SLionel Sambuc  *
344433d6423SLionel Sambuc  * RETURN:      None
345433d6423SLionel Sambuc  *
346433d6423SLionel Sambuc  * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
347433d6423SLionel Sambuc  *              set in DebugLevel
348433d6423SLionel Sambuc  *
349433d6423SLionel Sambuc  ******************************************************************************/
350433d6423SLionel Sambuc 
351433d6423SLionel Sambuc void
352433d6423SLionel Sambuc AcpiUtTracePtr (
353433d6423SLionel Sambuc     UINT32                  LineNumber,
354433d6423SLionel Sambuc     const char              *FunctionName,
355433d6423SLionel Sambuc     const char              *ModuleName,
356433d6423SLionel Sambuc     UINT32                  ComponentId,
357433d6423SLionel Sambuc     void                    *Pointer)
358433d6423SLionel Sambuc {
359*29492bb7SDavid van Moolenbroek 
360433d6423SLionel Sambuc     AcpiGbl_NestingLevel++;
361433d6423SLionel Sambuc     AcpiUtTrackStackPtr ();
362433d6423SLionel Sambuc 
363*29492bb7SDavid van Moolenbroek     /* Check if enabled up-front for performance */
364*29492bb7SDavid van Moolenbroek 
365*29492bb7SDavid van Moolenbroek     if (ACPI_IS_DEBUG_ENABLED (ACPI_LV_FUNCTIONS, ComponentId))
366*29492bb7SDavid van Moolenbroek     {
367433d6423SLionel Sambuc         AcpiDebugPrint (ACPI_LV_FUNCTIONS,
368433d6423SLionel Sambuc             LineNumber, FunctionName, ModuleName, ComponentId,
369433d6423SLionel Sambuc             "%s %p\n", AcpiGbl_FnEntryStr, Pointer);
370433d6423SLionel Sambuc     }
371*29492bb7SDavid van Moolenbroek }
372433d6423SLionel Sambuc 
373433d6423SLionel Sambuc 
374433d6423SLionel Sambuc /*******************************************************************************
375433d6423SLionel Sambuc  *
376433d6423SLionel Sambuc  * FUNCTION:    AcpiUtTraceStr
377433d6423SLionel Sambuc  *
378433d6423SLionel Sambuc  * PARAMETERS:  LineNumber          - Caller's line number
379433d6423SLionel Sambuc  *              FunctionName        - Caller's procedure name
380433d6423SLionel Sambuc  *              ModuleName          - Caller's module name
381433d6423SLionel Sambuc  *              ComponentId         - Caller's component ID
382433d6423SLionel Sambuc  *              String              - Additional string to display
383433d6423SLionel Sambuc  *
384433d6423SLionel Sambuc  * RETURN:      None
385433d6423SLionel Sambuc  *
386433d6423SLionel Sambuc  * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
387433d6423SLionel Sambuc  *              set in DebugLevel
388433d6423SLionel Sambuc  *
389433d6423SLionel Sambuc  ******************************************************************************/
390433d6423SLionel Sambuc 
391433d6423SLionel Sambuc void
AcpiUtTraceStr(UINT32 LineNumber,const char * FunctionName,const char * ModuleName,UINT32 ComponentId,char * String)392433d6423SLionel Sambuc AcpiUtTraceStr (
393433d6423SLionel Sambuc     UINT32                  LineNumber,
394433d6423SLionel Sambuc     const char              *FunctionName,
395433d6423SLionel Sambuc     const char              *ModuleName,
396433d6423SLionel Sambuc     UINT32                  ComponentId,
397433d6423SLionel Sambuc     char                    *String)
398433d6423SLionel Sambuc {
399433d6423SLionel Sambuc 
400433d6423SLionel Sambuc     AcpiGbl_NestingLevel++;
401433d6423SLionel Sambuc     AcpiUtTrackStackPtr ();
402433d6423SLionel Sambuc 
403*29492bb7SDavid van Moolenbroek     /* Check if enabled up-front for performance */
404*29492bb7SDavid van Moolenbroek 
405*29492bb7SDavid van Moolenbroek     if (ACPI_IS_DEBUG_ENABLED (ACPI_LV_FUNCTIONS, ComponentId))
406*29492bb7SDavid van Moolenbroek     {
407433d6423SLionel Sambuc         AcpiDebugPrint (ACPI_LV_FUNCTIONS,
408433d6423SLionel Sambuc             LineNumber, FunctionName, ModuleName, ComponentId,
409433d6423SLionel Sambuc             "%s %s\n", AcpiGbl_FnEntryStr, String);
410433d6423SLionel Sambuc     }
411*29492bb7SDavid van Moolenbroek }
412433d6423SLionel Sambuc 
413433d6423SLionel Sambuc 
414433d6423SLionel Sambuc /*******************************************************************************
415433d6423SLionel Sambuc  *
416433d6423SLionel Sambuc  * FUNCTION:    AcpiUtTraceU32
417433d6423SLionel Sambuc  *
418433d6423SLionel Sambuc  * PARAMETERS:  LineNumber          - Caller's line number
419433d6423SLionel Sambuc  *              FunctionName        - Caller's procedure name
420433d6423SLionel Sambuc  *              ModuleName          - Caller's module name
421433d6423SLionel Sambuc  *              ComponentId         - Caller's component ID
422433d6423SLionel Sambuc  *              Integer             - Integer to display
423433d6423SLionel Sambuc  *
424433d6423SLionel Sambuc  * RETURN:      None
425433d6423SLionel Sambuc  *
426433d6423SLionel Sambuc  * DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
427433d6423SLionel Sambuc  *              set in DebugLevel
428433d6423SLionel Sambuc  *
429433d6423SLionel Sambuc  ******************************************************************************/
430433d6423SLionel Sambuc 
431433d6423SLionel Sambuc void
AcpiUtTraceU32(UINT32 LineNumber,const char * FunctionName,const char * ModuleName,UINT32 ComponentId,UINT32 Integer)432433d6423SLionel Sambuc AcpiUtTraceU32 (
433433d6423SLionel Sambuc     UINT32                  LineNumber,
434433d6423SLionel Sambuc     const char              *FunctionName,
435433d6423SLionel Sambuc     const char              *ModuleName,
436433d6423SLionel Sambuc     UINT32                  ComponentId,
437433d6423SLionel Sambuc     UINT32                  Integer)
438433d6423SLionel Sambuc {
439433d6423SLionel Sambuc 
440433d6423SLionel Sambuc     AcpiGbl_NestingLevel++;
441433d6423SLionel Sambuc     AcpiUtTrackStackPtr ();
442433d6423SLionel Sambuc 
443*29492bb7SDavid van Moolenbroek     /* Check if enabled up-front for performance */
444*29492bb7SDavid van Moolenbroek 
445*29492bb7SDavid van Moolenbroek     if (ACPI_IS_DEBUG_ENABLED (ACPI_LV_FUNCTIONS, ComponentId))
446*29492bb7SDavid van Moolenbroek     {
447433d6423SLionel Sambuc         AcpiDebugPrint (ACPI_LV_FUNCTIONS,
448433d6423SLionel Sambuc             LineNumber, FunctionName, ModuleName, ComponentId,
449433d6423SLionel Sambuc             "%s %08X\n", AcpiGbl_FnEntryStr, Integer);
450433d6423SLionel Sambuc     }
451*29492bb7SDavid van Moolenbroek }
452433d6423SLionel Sambuc 
453433d6423SLionel Sambuc 
454433d6423SLionel Sambuc /*******************************************************************************
455433d6423SLionel Sambuc  *
456433d6423SLionel Sambuc  * FUNCTION:    AcpiUtExit
457433d6423SLionel Sambuc  *
458433d6423SLionel Sambuc  * PARAMETERS:  LineNumber          - Caller's line number
459433d6423SLionel Sambuc  *              FunctionName        - Caller's procedure name
460433d6423SLionel Sambuc  *              ModuleName          - Caller's module name
461433d6423SLionel Sambuc  *              ComponentId         - Caller's component ID
462433d6423SLionel Sambuc  *
463433d6423SLionel Sambuc  * RETURN:      None
464433d6423SLionel Sambuc  *
465433d6423SLionel Sambuc  * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
466433d6423SLionel Sambuc  *              set in DebugLevel
467433d6423SLionel Sambuc  *
468433d6423SLionel Sambuc  ******************************************************************************/
469433d6423SLionel Sambuc 
470433d6423SLionel Sambuc void
AcpiUtExit(UINT32 LineNumber,const char * FunctionName,const char * ModuleName,UINT32 ComponentId)471433d6423SLionel Sambuc AcpiUtExit (
472433d6423SLionel Sambuc     UINT32                  LineNumber,
473433d6423SLionel Sambuc     const char              *FunctionName,
474433d6423SLionel Sambuc     const char              *ModuleName,
475433d6423SLionel Sambuc     UINT32                  ComponentId)
476433d6423SLionel Sambuc {
477433d6423SLionel Sambuc 
478*29492bb7SDavid van Moolenbroek     /* Check if enabled up-front for performance */
479*29492bb7SDavid van Moolenbroek 
480*29492bb7SDavid van Moolenbroek     if (ACPI_IS_DEBUG_ENABLED (ACPI_LV_FUNCTIONS, ComponentId))
481*29492bb7SDavid van Moolenbroek     {
482433d6423SLionel Sambuc         AcpiDebugPrint (ACPI_LV_FUNCTIONS,
483433d6423SLionel Sambuc             LineNumber, FunctionName, ModuleName, ComponentId,
484433d6423SLionel Sambuc             "%s\n", AcpiGbl_FnExitStr);
485*29492bb7SDavid van Moolenbroek     }
486433d6423SLionel Sambuc 
487*29492bb7SDavid van Moolenbroek     if (AcpiGbl_NestingLevel)
488*29492bb7SDavid van Moolenbroek     {
489433d6423SLionel Sambuc         AcpiGbl_NestingLevel--;
490433d6423SLionel Sambuc     }
491*29492bb7SDavid van Moolenbroek }
492433d6423SLionel Sambuc 
ACPI_EXPORT_SYMBOL(AcpiUtExit)493433d6423SLionel Sambuc ACPI_EXPORT_SYMBOL (AcpiUtExit)
494433d6423SLionel Sambuc 
495433d6423SLionel Sambuc 
496433d6423SLionel Sambuc /*******************************************************************************
497433d6423SLionel Sambuc  *
498433d6423SLionel Sambuc  * FUNCTION:    AcpiUtStatusExit
499433d6423SLionel Sambuc  *
500433d6423SLionel Sambuc  * PARAMETERS:  LineNumber          - Caller's line number
501433d6423SLionel Sambuc  *              FunctionName        - Caller's procedure name
502433d6423SLionel Sambuc  *              ModuleName          - Caller's module name
503433d6423SLionel Sambuc  *              ComponentId         - Caller's component ID
504433d6423SLionel Sambuc  *              Status              - Exit status code
505433d6423SLionel Sambuc  *
506433d6423SLionel Sambuc  * RETURN:      None
507433d6423SLionel Sambuc  *
508433d6423SLionel Sambuc  * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
509433d6423SLionel Sambuc  *              set in DebugLevel. Prints exit status also.
510433d6423SLionel Sambuc  *
511433d6423SLionel Sambuc  ******************************************************************************/
512433d6423SLionel Sambuc 
513433d6423SLionel Sambuc void
514433d6423SLionel Sambuc AcpiUtStatusExit (
515433d6423SLionel Sambuc     UINT32                  LineNumber,
516433d6423SLionel Sambuc     const char              *FunctionName,
517433d6423SLionel Sambuc     const char              *ModuleName,
518433d6423SLionel Sambuc     UINT32                  ComponentId,
519433d6423SLionel Sambuc     ACPI_STATUS             Status)
520433d6423SLionel Sambuc {
521433d6423SLionel Sambuc 
522*29492bb7SDavid van Moolenbroek     /* Check if enabled up-front for performance */
523*29492bb7SDavid van Moolenbroek 
524*29492bb7SDavid van Moolenbroek     if (ACPI_IS_DEBUG_ENABLED (ACPI_LV_FUNCTIONS, ComponentId))
525*29492bb7SDavid van Moolenbroek     {
526433d6423SLionel Sambuc         if (ACPI_SUCCESS (Status))
527433d6423SLionel Sambuc         {
528433d6423SLionel Sambuc             AcpiDebugPrint (ACPI_LV_FUNCTIONS,
529433d6423SLionel Sambuc                 LineNumber, FunctionName, ModuleName, ComponentId,
530433d6423SLionel Sambuc                 "%s %s\n", AcpiGbl_FnExitStr,
531433d6423SLionel Sambuc                 AcpiFormatException (Status));
532433d6423SLionel Sambuc         }
533433d6423SLionel Sambuc         else
534433d6423SLionel Sambuc         {
535433d6423SLionel Sambuc             AcpiDebugPrint (ACPI_LV_FUNCTIONS,
536433d6423SLionel Sambuc                 LineNumber, FunctionName, ModuleName, ComponentId,
537433d6423SLionel Sambuc                 "%s ****Exception****: %s\n", AcpiGbl_FnExitStr,
538433d6423SLionel Sambuc                 AcpiFormatException (Status));
539433d6423SLionel Sambuc         }
540*29492bb7SDavid van Moolenbroek     }
541433d6423SLionel Sambuc 
542*29492bb7SDavid van Moolenbroek     if (AcpiGbl_NestingLevel)
543*29492bb7SDavid van Moolenbroek     {
544433d6423SLionel Sambuc         AcpiGbl_NestingLevel--;
545433d6423SLionel Sambuc     }
546*29492bb7SDavid van Moolenbroek }
547433d6423SLionel Sambuc 
ACPI_EXPORT_SYMBOL(AcpiUtStatusExit)548433d6423SLionel Sambuc ACPI_EXPORT_SYMBOL (AcpiUtStatusExit)
549433d6423SLionel Sambuc 
550433d6423SLionel Sambuc 
551433d6423SLionel Sambuc /*******************************************************************************
552433d6423SLionel Sambuc  *
553433d6423SLionel Sambuc  * FUNCTION:    AcpiUtValueExit
554433d6423SLionel Sambuc  *
555433d6423SLionel Sambuc  * PARAMETERS:  LineNumber          - Caller's line number
556433d6423SLionel Sambuc  *              FunctionName        - Caller's procedure name
557433d6423SLionel Sambuc  *              ModuleName          - Caller's module name
558433d6423SLionel Sambuc  *              ComponentId         - Caller's component ID
559433d6423SLionel Sambuc  *              Value               - Value to be printed with exit msg
560433d6423SLionel Sambuc  *
561433d6423SLionel Sambuc  * RETURN:      None
562433d6423SLionel Sambuc  *
563433d6423SLionel Sambuc  * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
564433d6423SLionel Sambuc  *              set in DebugLevel. Prints exit value also.
565433d6423SLionel Sambuc  *
566433d6423SLionel Sambuc  ******************************************************************************/
567433d6423SLionel Sambuc 
568433d6423SLionel Sambuc void
569433d6423SLionel Sambuc AcpiUtValueExit (
570433d6423SLionel Sambuc     UINT32                  LineNumber,
571433d6423SLionel Sambuc     const char              *FunctionName,
572433d6423SLionel Sambuc     const char              *ModuleName,
573433d6423SLionel Sambuc     UINT32                  ComponentId,
574433d6423SLionel Sambuc     UINT64                  Value)
575433d6423SLionel Sambuc {
576433d6423SLionel Sambuc 
577*29492bb7SDavid van Moolenbroek     /* Check if enabled up-front for performance */
578*29492bb7SDavid van Moolenbroek 
579*29492bb7SDavid van Moolenbroek     if (ACPI_IS_DEBUG_ENABLED (ACPI_LV_FUNCTIONS, ComponentId))
580*29492bb7SDavid van Moolenbroek     {
581433d6423SLionel Sambuc         AcpiDebugPrint (ACPI_LV_FUNCTIONS,
582433d6423SLionel Sambuc             LineNumber, FunctionName, ModuleName, ComponentId,
583433d6423SLionel Sambuc             "%s %8.8X%8.8X\n", AcpiGbl_FnExitStr,
584433d6423SLionel Sambuc             ACPI_FORMAT_UINT64 (Value));
585*29492bb7SDavid van Moolenbroek     }
586433d6423SLionel Sambuc 
587*29492bb7SDavid van Moolenbroek     if (AcpiGbl_NestingLevel)
588*29492bb7SDavid van Moolenbroek     {
589433d6423SLionel Sambuc         AcpiGbl_NestingLevel--;
590433d6423SLionel Sambuc     }
591*29492bb7SDavid van Moolenbroek }
592433d6423SLionel Sambuc 
ACPI_EXPORT_SYMBOL(AcpiUtValueExit)593433d6423SLionel Sambuc ACPI_EXPORT_SYMBOL (AcpiUtValueExit)
594433d6423SLionel Sambuc 
595433d6423SLionel Sambuc 
596433d6423SLionel Sambuc /*******************************************************************************
597433d6423SLionel Sambuc  *
598433d6423SLionel Sambuc  * FUNCTION:    AcpiUtPtrExit
599433d6423SLionel Sambuc  *
600433d6423SLionel Sambuc  * PARAMETERS:  LineNumber          - Caller's line number
601433d6423SLionel Sambuc  *              FunctionName        - Caller's procedure name
602433d6423SLionel Sambuc  *              ModuleName          - Caller's module name
603433d6423SLionel Sambuc  *              ComponentId         - Caller's component ID
604433d6423SLionel Sambuc  *              Ptr                 - Pointer to display
605433d6423SLionel Sambuc  *
606433d6423SLionel Sambuc  * RETURN:      None
607433d6423SLionel Sambuc  *
608433d6423SLionel Sambuc  * DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
609433d6423SLionel Sambuc  *              set in DebugLevel. Prints exit value also.
610433d6423SLionel Sambuc  *
611433d6423SLionel Sambuc  ******************************************************************************/
612433d6423SLionel Sambuc 
613433d6423SLionel Sambuc void
614433d6423SLionel Sambuc AcpiUtPtrExit (
615433d6423SLionel Sambuc     UINT32                  LineNumber,
616433d6423SLionel Sambuc     const char              *FunctionName,
617433d6423SLionel Sambuc     const char              *ModuleName,
618433d6423SLionel Sambuc     UINT32                  ComponentId,
619433d6423SLionel Sambuc     UINT8                   *Ptr)
620433d6423SLionel Sambuc {
621433d6423SLionel Sambuc 
622*29492bb7SDavid van Moolenbroek     /* Check if enabled up-front for performance */
623*29492bb7SDavid van Moolenbroek 
624*29492bb7SDavid van Moolenbroek     if (ACPI_IS_DEBUG_ENABLED (ACPI_LV_FUNCTIONS, ComponentId))
625*29492bb7SDavid van Moolenbroek     {
626433d6423SLionel Sambuc         AcpiDebugPrint (ACPI_LV_FUNCTIONS,
627433d6423SLionel Sambuc             LineNumber, FunctionName, ModuleName, ComponentId,
628433d6423SLionel Sambuc             "%s %p\n", AcpiGbl_FnExitStr, Ptr);
629*29492bb7SDavid van Moolenbroek     }
630433d6423SLionel Sambuc 
631*29492bb7SDavid van Moolenbroek     if (AcpiGbl_NestingLevel)
632*29492bb7SDavid van Moolenbroek     {
633433d6423SLionel Sambuc         AcpiGbl_NestingLevel--;
634433d6423SLionel Sambuc     }
635*29492bb7SDavid van Moolenbroek }
636433d6423SLionel Sambuc 
637433d6423SLionel Sambuc #endif
638433d6423SLionel Sambuc 
639433d6423SLionel Sambuc 
640*29492bb7SDavid van Moolenbroek #ifdef ACPI_APPLICATION
641433d6423SLionel Sambuc /*******************************************************************************
642433d6423SLionel Sambuc  *
643*29492bb7SDavid van Moolenbroek  * FUNCTION:    AcpiLogError
644433d6423SLionel Sambuc  *
645*29492bb7SDavid van Moolenbroek  * PARAMETERS:  Format              - Printf format field
646*29492bb7SDavid van Moolenbroek  *              ...                 - Optional printf arguments
647433d6423SLionel Sambuc  *
648433d6423SLionel Sambuc  * RETURN:      None
649433d6423SLionel Sambuc  *
650*29492bb7SDavid van Moolenbroek  * DESCRIPTION: Print error message to the console, used by applications.
651433d6423SLionel Sambuc  *
652433d6423SLionel Sambuc  ******************************************************************************/
653433d6423SLionel Sambuc 
654*29492bb7SDavid van Moolenbroek void  ACPI_INTERNAL_VAR_XFACE
AcpiLogError(const char * Format,...)655*29492bb7SDavid van Moolenbroek AcpiLogError (
656*29492bb7SDavid van Moolenbroek     const char              *Format,
657*29492bb7SDavid van Moolenbroek     ...)
658433d6423SLionel Sambuc {
659*29492bb7SDavid van Moolenbroek     va_list                 Args;
660433d6423SLionel Sambuc 
661*29492bb7SDavid van Moolenbroek     va_start (Args, Format);
662*29492bb7SDavid van Moolenbroek     (void) AcpiUtFileVprintf (ACPI_FILE_ERR, Format, Args);
663*29492bb7SDavid van Moolenbroek     va_end (Args);
664433d6423SLionel Sambuc }
665433d6423SLionel Sambuc 
666*29492bb7SDavid van Moolenbroek ACPI_EXPORT_SYMBOL (AcpiLogError)
667*29492bb7SDavid van Moolenbroek #endif
668