1*3446Smrj /******************************************************************************
2*3446Smrj  *
3*3446Smrj  * Module Name: utdebug - Debug print routines
4*3446Smrj  *              $Revision: 1.132 $
5*3446Smrj  *
6*3446Smrj  *****************************************************************************/
7*3446Smrj 
8*3446Smrj /******************************************************************************
9*3446Smrj  *
10*3446Smrj  * 1. Copyright Notice
11*3446Smrj  *
12*3446Smrj  * Some or all of this work - Copyright (c) 1999 - 2006, Intel Corp.
13*3446Smrj  * All rights reserved.
14*3446Smrj  *
15*3446Smrj  * 2. License
16*3446Smrj  *
17*3446Smrj  * 2.1. This is your license from Intel Corp. under its intellectual property
18*3446Smrj  * rights.  You may have additional license terms from the party that provided
19*3446Smrj  * you this software, covering your right to use that party's intellectual
20*3446Smrj  * property rights.
21*3446Smrj  *
22*3446Smrj  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
23*3446Smrj  * copy of the source code appearing in this file ("Covered Code") an
24*3446Smrj  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
25*3446Smrj  * base code distributed originally by Intel ("Original Intel Code") to copy,
26*3446Smrj  * make derivatives, distribute, use and display any portion of the Covered
27*3446Smrj  * Code in any form, with the right to sublicense such rights; and
28*3446Smrj  *
29*3446Smrj  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
30*3446Smrj  * license (with the right to sublicense), under only those claims of Intel
31*3446Smrj  * patents that are infringed by the Original Intel Code, to make, use, sell,
32*3446Smrj  * offer to sell, and import the Covered Code and derivative works thereof
33*3446Smrj  * solely to the minimum extent necessary to exercise the above copyright
34*3446Smrj  * license, and in no event shall the patent license extend to any additions
35*3446Smrj  * to or modifications of the Original Intel Code.  No other license or right
36*3446Smrj  * is granted directly or by implication, estoppel or otherwise;
37*3446Smrj  *
38*3446Smrj  * The above copyright and patent license is granted only if the following
39*3446Smrj  * conditions are met:
40*3446Smrj  *
41*3446Smrj  * 3. Conditions
42*3446Smrj  *
43*3446Smrj  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
44*3446Smrj  * Redistribution of source code of any substantial portion of the Covered
45*3446Smrj  * Code or modification with rights to further distribute source must include
46*3446Smrj  * the above Copyright Notice, the above License, this list of Conditions,
47*3446Smrj  * and the following Disclaimer and Export Compliance provision.  In addition,
48*3446Smrj  * Licensee must cause all Covered Code to which Licensee contributes to
49*3446Smrj  * contain a file documenting the changes Licensee made to create that Covered
50*3446Smrj  * Code and the date of any change.  Licensee must include in that file the
51*3446Smrj  * documentation of any changes made by any predecessor Licensee.  Licensee
52*3446Smrj  * must include a prominent statement that the modification is derived,
53*3446Smrj  * directly or indirectly, from Original Intel Code.
54*3446Smrj  *
55*3446Smrj  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
56*3446Smrj  * Redistribution of source code of any substantial portion of the Covered
57*3446Smrj  * Code or modification without rights to further distribute source must
58*3446Smrj  * include the following Disclaimer and Export Compliance provision in the
59*3446Smrj  * documentation and/or other materials provided with distribution.  In
60*3446Smrj  * addition, Licensee may not authorize further sublicense of source of any
61*3446Smrj  * portion of the Covered Code, and must include terms to the effect that the
62*3446Smrj  * license from Licensee to its licensee is limited to the intellectual
63*3446Smrj  * property embodied in the software Licensee provides to its licensee, and
64*3446Smrj  * not to intellectual property embodied in modifications its licensee may
65*3446Smrj  * make.
66*3446Smrj  *
67*3446Smrj  * 3.3. Redistribution of Executable. Redistribution in executable form of any
68*3446Smrj  * substantial portion of the Covered Code or modification must reproduce the
69*3446Smrj  * above Copyright Notice, and the following Disclaimer and Export Compliance
70*3446Smrj  * provision in the documentation and/or other materials provided with the
71*3446Smrj  * distribution.
72*3446Smrj  *
73*3446Smrj  * 3.4. Intel retains all right, title, and interest in and to the Original
74*3446Smrj  * Intel Code.
75*3446Smrj  *
76*3446Smrj  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
77*3446Smrj  * Intel shall be used in advertising or otherwise to promote the sale, use or
78*3446Smrj  * other dealings in products derived from or relating to the Covered Code
79*3446Smrj  * without prior written authorization from Intel.
80*3446Smrj  *
81*3446Smrj  * 4. Disclaimer and Export Compliance
82*3446Smrj  *
83*3446Smrj  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
84*3446Smrj  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
85*3446Smrj  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
86*3446Smrj  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
87*3446Smrj  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
88*3446Smrj  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
89*3446Smrj  * PARTICULAR PURPOSE.
90*3446Smrj  *
91*3446Smrj  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
92*3446Smrj  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
93*3446Smrj  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
94*3446Smrj  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
95*3446Smrj  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
96*3446Smrj  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
97*3446Smrj  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
98*3446Smrj  * LIMITED REMEDY.
99*3446Smrj  *
100*3446Smrj  * 4.3. Licensee shall not export, either directly or indirectly, any of this
101*3446Smrj  * software or system incorporating such software without first obtaining any
102*3446Smrj  * required license or other approval from the U. S. Department of Commerce or
103*3446Smrj  * any other agency or department of the United States Government.  In the
104*3446Smrj  * event Licensee exports any such software from the United States or
105*3446Smrj  * re-exports any such software from a foreign destination, Licensee shall
106*3446Smrj  * ensure that the distribution and export/re-export of the software is in
107*3446Smrj  * compliance with all laws, regulations, orders, or other restrictions of the
108*3446Smrj  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
109*3446Smrj  * any of its subsidiaries will export/re-export any technical data, process,
110*3446Smrj  * software, or service, directly or indirectly, to any country for which the
111*3446Smrj  * United States government or any agency thereof requires an export license,
112*3446Smrj  * other governmental approval, or letter of assurance, without first obtaining
113*3446Smrj  * such license, approval or letter.
114*3446Smrj  *
115*3446Smrj  *****************************************************************************/
116*3446Smrj 
117*3446Smrj #define __UTDEBUG_C__
118*3446Smrj 
119*3446Smrj #include "acpi.h"
120*3446Smrj 
121*3446Smrj #define _COMPONENT          ACPI_UTILITIES
122*3446Smrj         ACPI_MODULE_NAME    ("utdebug")
123*3446Smrj 
124*3446Smrj 
125*3446Smrj #ifdef ACPI_DEBUG_OUTPUT
126*3446Smrj 
127*3446Smrj static UINT32   AcpiGbl_PrevThreadId = 0xFFFFFFFF;
128*3446Smrj static char     *AcpiGbl_FnEntryStr = "----Entry";
129*3446Smrj static char     *AcpiGbl_FnExitStr  = "----Exit-";
130*3446Smrj 
131*3446Smrj /* Local prototypes */
132*3446Smrj 
133*3446Smrj static const char *
134*3446Smrj AcpiUtTrimFunctionName (
135*3446Smrj     const char              *FunctionName);
136*3446Smrj 
137*3446Smrj 
138*3446Smrj /*******************************************************************************
139*3446Smrj  *
140*3446Smrj  * FUNCTION:    AcpiUtInitStackPtrTrace
141*3446Smrj  *
142*3446Smrj  * PARAMETERS:  None
143*3446Smrj  *
144*3446Smrj  * RETURN:      None
145*3446Smrj  *
146*3446Smrj  * DESCRIPTION: Save the current CPU stack pointer at subsystem startup
147*3446Smrj  *
148*3446Smrj  ******************************************************************************/
149*3446Smrj 
150*3446Smrj void
151*3446Smrj AcpiUtInitStackPtrTrace (
152*3446Smrj     void)
153*3446Smrj {
154*3446Smrj     UINT32                  CurrentSp;
155*3446Smrj 
156*3446Smrj 
157*3446Smrj     AcpiGbl_EntryStackPointer = ACPI_PTR_DIFF (&CurrentSp, NULL);
158*3446Smrj }
159*3446Smrj 
160*3446Smrj 
161*3446Smrj /*******************************************************************************
162*3446Smrj  *
163*3446Smrj  * FUNCTION:    AcpiUtTrackStackPtr
164*3446Smrj  *
165*3446Smrj  * PARAMETERS:  None
166*3446Smrj  *
167*3446Smrj  * RETURN:      None
168*3446Smrj  *
169*3446Smrj  * DESCRIPTION: Save the current CPU stack pointer
170*3446Smrj  *
171*3446Smrj  ******************************************************************************/
172*3446Smrj 
173*3446Smrj void
174*3446Smrj AcpiUtTrackStackPtr (
175*3446Smrj     void)
176*3446Smrj {
177*3446Smrj     ACPI_SIZE               CurrentSp;
178*3446Smrj 
179*3446Smrj 
180*3446Smrj     CurrentSp = ACPI_PTR_DIFF (&CurrentSp, NULL);
181*3446Smrj 
182*3446Smrj     if (CurrentSp < AcpiGbl_LowestStackPointer)
183*3446Smrj     {
184*3446Smrj         AcpiGbl_LowestStackPointer = CurrentSp;
185*3446Smrj     }
186*3446Smrj 
187*3446Smrj     if (AcpiGbl_NestingLevel > AcpiGbl_DeepestNesting)
188*3446Smrj     {
189*3446Smrj         AcpiGbl_DeepestNesting = AcpiGbl_NestingLevel;
190*3446Smrj     }
191*3446Smrj }
192*3446Smrj 
193*3446Smrj 
194*3446Smrj /*******************************************************************************
195*3446Smrj  *
196*3446Smrj  * FUNCTION:    AcpiUtTrimFunctionName
197*3446Smrj  *
198*3446Smrj  * PARAMETERS:  FunctionName        - Ascii string containing a procedure name
199*3446Smrj  *
200*3446Smrj  * RETURN:      Updated pointer to the function name
201*3446Smrj  *
202*3446Smrj  * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present.
203*3446Smrj  *              This allows compiler macros such as __FUNCTION__ to be used
204*3446Smrj  *              with no change to the debug output.
205*3446Smrj  *
206*3446Smrj  ******************************************************************************/
207*3446Smrj 
208*3446Smrj static const char *
209*3446Smrj AcpiUtTrimFunctionName (
210*3446Smrj     const char              *FunctionName)
211*3446Smrj {
212*3446Smrj 
213*3446Smrj     /* All Function names are longer than 4 chars, check is safe */
214*3446Smrj 
215*3446Smrj     if (*(ACPI_CAST_PTR (UINT32, FunctionName)) == ACPI_PREFIX_MIXED)
216*3446Smrj     {
217*3446Smrj         /* This is the case where the original source has not been modified */
218*3446Smrj 
219*3446Smrj         return (FunctionName + 4);
220*3446Smrj     }
221*3446Smrj 
222*3446Smrj     if (*(ACPI_CAST_PTR (UINT32, FunctionName)) == ACPI_PREFIX_LOWER)
223*3446Smrj     {
224*3446Smrj         /* This is the case where the source has been 'linuxized' */
225*3446Smrj 
226*3446Smrj         return (FunctionName + 5);
227*3446Smrj     }
228*3446Smrj 
229*3446Smrj     return (FunctionName);
230*3446Smrj }
231*3446Smrj 
232*3446Smrj 
233*3446Smrj /*******************************************************************************
234*3446Smrj  *
235*3446Smrj  * FUNCTION:    AcpiUtDebugPrint
236*3446Smrj  *
237*3446Smrj  * PARAMETERS:  RequestedDebugLevel - Requested debug print level
238*3446Smrj  *              LineNumber          - Caller's line number (for error output)
239*3446Smrj  *              FunctionName        - Caller's procedure name
240*3446Smrj  *              ModuleName          - Caller's module name
241*3446Smrj  *              ComponentId         - Caller's component ID
242*3446Smrj  *              Format              - Printf format field
243*3446Smrj  *              ...                 - Optional printf arguments
244*3446Smrj  *
245*3446Smrj  * RETURN:      None
246*3446Smrj  *
247*3446Smrj  * DESCRIPTION: Print error message with prefix consisting of the module name,
248*3446Smrj  *              line number, and component ID.
249*3446Smrj  *
250*3446Smrj  ******************************************************************************/
251*3446Smrj 
252*3446Smrj void  ACPI_INTERNAL_VAR_XFACE
253*3446Smrj AcpiUtDebugPrint (
254*3446Smrj     UINT32                  RequestedDebugLevel,
255*3446Smrj     UINT32                  LineNumber,
256*3446Smrj     const char              *FunctionName,
257*3446Smrj     char                    *ModuleName,
258*3446Smrj     UINT32                  ComponentId,
259*3446Smrj     char                    *Format,
260*3446Smrj     ...)
261*3446Smrj {
262*3446Smrj     ACPI_THREAD_ID          ThreadId;
263*3446Smrj     va_list                 args;
264*3446Smrj 
265*3446Smrj 
266*3446Smrj     /*
267*3446Smrj      * Stay silent if the debug level or component ID is disabled
268*3446Smrj      */
269*3446Smrj     if (!(RequestedDebugLevel & AcpiDbgLevel) ||
270*3446Smrj         !(ComponentId & AcpiDbgLayer))
271*3446Smrj     {
272*3446Smrj         return;
273*3446Smrj     }
274*3446Smrj 
275*3446Smrj     /*
276*3446Smrj      * Thread tracking and context switch notification
277*3446Smrj      */
278*3446Smrj     ThreadId = AcpiOsGetThreadId ();
279*3446Smrj     if (ThreadId != AcpiGbl_PrevThreadId)
280*3446Smrj     {
281*3446Smrj         if (ACPI_LV_THREADS & AcpiDbgLevel)
282*3446Smrj         {
283*3446Smrj             AcpiOsPrintf (
284*3446Smrj                 "\n**** Context Switch from TID %X to TID %X ****\n\n",
285*3446Smrj                 AcpiGbl_PrevThreadId, ThreadId);
286*3446Smrj         }
287*3446Smrj 
288*3446Smrj         AcpiGbl_PrevThreadId = ThreadId;
289*3446Smrj     }
290*3446Smrj 
291*3446Smrj     /*
292*3446Smrj      * Display the module name, current line number, thread ID (if requested),
293*3446Smrj      * current procedure nesting level, and the current procedure name
294*3446Smrj      */
295*3446Smrj     AcpiOsPrintf ("%8s-%04ld ", ModuleName, LineNumber);
296*3446Smrj 
297*3446Smrj     if (ACPI_LV_THREADS & AcpiDbgLevel)
298*3446Smrj     {
299*3446Smrj         AcpiOsPrintf ("[%04lX] ", ThreadId);
300*3446Smrj     }
301*3446Smrj 
302*3446Smrj     AcpiOsPrintf ("[%02ld] %-22.22s: ",
303*3446Smrj         AcpiGbl_NestingLevel, AcpiUtTrimFunctionName (FunctionName));
304*3446Smrj 
305*3446Smrj     va_start (args, Format);
306*3446Smrj     AcpiOsVprintf (Format, args);
307*3446Smrj }
308*3446Smrj 
309*3446Smrj ACPI_EXPORT_SYMBOL (AcpiUtDebugPrint)
310*3446Smrj 
311*3446Smrj 
312*3446Smrj /*******************************************************************************
313*3446Smrj  *
314*3446Smrj  * FUNCTION:    AcpiUtDebugPrintRaw
315*3446Smrj  *
316*3446Smrj  * PARAMETERS:  RequestedDebugLevel - Requested debug print level
317*3446Smrj  *              LineNumber          - Caller's line number
318*3446Smrj  *              FunctionName        - Caller's procedure name
319*3446Smrj  *              ModuleName          - Caller's module name
320*3446Smrj  *              ComponentId         - Caller's component ID
321*3446Smrj  *              Format              - Printf format field
322*3446Smrj  *              ...                 - Optional printf arguments
323*3446Smrj  *
324*3446Smrj  * RETURN:      None
325*3446Smrj  *
326*3446Smrj  * DESCRIPTION: Print message with no headers.  Has same interface as
327*3446Smrj  *              DebugPrint so that the same macros can be used.
328*3446Smrj  *
329*3446Smrj  ******************************************************************************/
330*3446Smrj 
331*3446Smrj void  ACPI_INTERNAL_VAR_XFACE
332*3446Smrj AcpiUtDebugPrintRaw (
333*3446Smrj     UINT32                  RequestedDebugLevel,
334*3446Smrj     UINT32                  LineNumber,
335*3446Smrj     const char              *FunctionName,
336*3446Smrj     char                    *ModuleName,
337*3446Smrj     UINT32                  ComponentId,
338*3446Smrj     char                    *Format,
339*3446Smrj     ...)
340*3446Smrj {
341*3446Smrj     va_list                 args;
342*3446Smrj 
343*3446Smrj 
344*3446Smrj     if (!(RequestedDebugLevel & AcpiDbgLevel) ||
345*3446Smrj         !(ComponentId & AcpiDbgLayer))
346*3446Smrj     {
347*3446Smrj         return;
348*3446Smrj     }
349*3446Smrj 
350*3446Smrj     va_start (args, Format);
351*3446Smrj     AcpiOsVprintf (Format, args);
352*3446Smrj }
353*3446Smrj 
354*3446Smrj ACPI_EXPORT_SYMBOL (AcpiUtDebugPrintRaw)
355*3446Smrj 
356*3446Smrj 
357*3446Smrj /*******************************************************************************
358*3446Smrj  *
359*3446Smrj  * FUNCTION:    AcpiUtTrace
360*3446Smrj  *
361*3446Smrj  * PARAMETERS:  LineNumber          - Caller's line number
362*3446Smrj  *              FunctionName        - Caller's procedure name
363*3446Smrj  *              ModuleName          - Caller's module name
364*3446Smrj  *              ComponentId         - Caller's component ID
365*3446Smrj  *
366*3446Smrj  * RETURN:      None
367*3446Smrj  *
368*3446Smrj  * DESCRIPTION: Function entry trace.  Prints only if TRACE_FUNCTIONS bit is
369*3446Smrj  *              set in DebugLevel
370*3446Smrj  *
371*3446Smrj  ******************************************************************************/
372*3446Smrj 
373*3446Smrj void
374*3446Smrj AcpiUtTrace (
375*3446Smrj     UINT32                  LineNumber,
376*3446Smrj     const char              *FunctionName,
377*3446Smrj     char                    *ModuleName,
378*3446Smrj     UINT32                  ComponentId)
379*3446Smrj {
380*3446Smrj 
381*3446Smrj     AcpiGbl_NestingLevel++;
382*3446Smrj     AcpiUtTrackStackPtr ();
383*3446Smrj 
384*3446Smrj     AcpiUtDebugPrint (ACPI_LV_FUNCTIONS,
385*3446Smrj         LineNumber, FunctionName, ModuleName, ComponentId,
386*3446Smrj         "%s\n", AcpiGbl_FnEntryStr);
387*3446Smrj }
388*3446Smrj 
389*3446Smrj ACPI_EXPORT_SYMBOL (AcpiUtTrace)
390*3446Smrj 
391*3446Smrj 
392*3446Smrj /*******************************************************************************
393*3446Smrj  *
394*3446Smrj  * FUNCTION:    AcpiUtTracePtr
395*3446Smrj  *
396*3446Smrj  * PARAMETERS:  LineNumber          - Caller's line number
397*3446Smrj  *              FunctionName        - Caller's procedure name
398*3446Smrj  *              ModuleName          - Caller's module name
399*3446Smrj  *              ComponentId         - Caller's component ID
400*3446Smrj  *              Pointer             - Pointer to display
401*3446Smrj  *
402*3446Smrj  * RETURN:      None
403*3446Smrj  *
404*3446Smrj  * DESCRIPTION: Function entry trace.  Prints only if TRACE_FUNCTIONS bit is
405*3446Smrj  *              set in DebugLevel
406*3446Smrj  *
407*3446Smrj  ******************************************************************************/
408*3446Smrj 
409*3446Smrj void
410*3446Smrj AcpiUtTracePtr (
411*3446Smrj     UINT32                  LineNumber,
412*3446Smrj     const char              *FunctionName,
413*3446Smrj     char                    *ModuleName,
414*3446Smrj     UINT32                  ComponentId,
415*3446Smrj     void                    *Pointer)
416*3446Smrj {
417*3446Smrj     AcpiGbl_NestingLevel++;
418*3446Smrj     AcpiUtTrackStackPtr ();
419*3446Smrj 
420*3446Smrj     AcpiUtDebugPrint (ACPI_LV_FUNCTIONS,
421*3446Smrj         LineNumber, FunctionName, ModuleName, ComponentId,
422*3446Smrj         "%s %p\n", AcpiGbl_FnEntryStr, Pointer);
423*3446Smrj }
424*3446Smrj 
425*3446Smrj 
426*3446Smrj /*******************************************************************************
427*3446Smrj  *
428*3446Smrj  * FUNCTION:    AcpiUtTraceStr
429*3446Smrj  *
430*3446Smrj  * PARAMETERS:  LineNumber          - Caller's line number
431*3446Smrj  *              FunctionName        - Caller's procedure name
432*3446Smrj  *              ModuleName          - Caller's module name
433*3446Smrj  *              ComponentId         - Caller's component ID
434*3446Smrj  *              String              - Additional string to display
435*3446Smrj  *
436*3446Smrj  * RETURN:      None
437*3446Smrj  *
438*3446Smrj  * DESCRIPTION: Function entry trace.  Prints only if TRACE_FUNCTIONS bit is
439*3446Smrj  *              set in DebugLevel
440*3446Smrj  *
441*3446Smrj  ******************************************************************************/
442*3446Smrj 
443*3446Smrj void
444*3446Smrj AcpiUtTraceStr (
445*3446Smrj     UINT32                  LineNumber,
446*3446Smrj     const char              *FunctionName,
447*3446Smrj     char                    *ModuleName,
448*3446Smrj     UINT32                  ComponentId,
449*3446Smrj     char                    *String)
450*3446Smrj {
451*3446Smrj 
452*3446Smrj     AcpiGbl_NestingLevel++;
453*3446Smrj     AcpiUtTrackStackPtr ();
454*3446Smrj 
455*3446Smrj     AcpiUtDebugPrint (ACPI_LV_FUNCTIONS,
456*3446Smrj         LineNumber, FunctionName, ModuleName, ComponentId,
457*3446Smrj         "%s %s\n", AcpiGbl_FnEntryStr, String);
458*3446Smrj }
459*3446Smrj 
460*3446Smrj 
461*3446Smrj /*******************************************************************************
462*3446Smrj  *
463*3446Smrj  * FUNCTION:    AcpiUtTraceU32
464*3446Smrj  *
465*3446Smrj  * PARAMETERS:  LineNumber          - Caller's line number
466*3446Smrj  *              FunctionName        - Caller's procedure name
467*3446Smrj  *              ModuleName          - Caller's module name
468*3446Smrj  *              ComponentId         - Caller's component ID
469*3446Smrj  *              Integer             - Integer to display
470*3446Smrj  *
471*3446Smrj  * RETURN:      None
472*3446Smrj  *
473*3446Smrj  * DESCRIPTION: Function entry trace.  Prints only if TRACE_FUNCTIONS bit is
474*3446Smrj  *              set in DebugLevel
475*3446Smrj  *
476*3446Smrj  ******************************************************************************/
477*3446Smrj 
478*3446Smrj void
479*3446Smrj AcpiUtTraceU32 (
480*3446Smrj     UINT32                  LineNumber,
481*3446Smrj     const char              *FunctionName,
482*3446Smrj     char                    *ModuleName,
483*3446Smrj     UINT32                  ComponentId,
484*3446Smrj     UINT32                  Integer)
485*3446Smrj {
486*3446Smrj 
487*3446Smrj     AcpiGbl_NestingLevel++;
488*3446Smrj     AcpiUtTrackStackPtr ();
489*3446Smrj 
490*3446Smrj     AcpiUtDebugPrint (ACPI_LV_FUNCTIONS,
491*3446Smrj         LineNumber, FunctionName, ModuleName, ComponentId,
492*3446Smrj         "%s %08X\n", AcpiGbl_FnEntryStr, Integer);
493*3446Smrj }
494*3446Smrj 
495*3446Smrj 
496*3446Smrj /*******************************************************************************
497*3446Smrj  *
498*3446Smrj  * FUNCTION:    AcpiUtExit
499*3446Smrj  *
500*3446Smrj  * PARAMETERS:  LineNumber          - Caller's line number
501*3446Smrj  *              FunctionName        - Caller's procedure name
502*3446Smrj  *              ModuleName          - Caller's module name
503*3446Smrj  *              ComponentId         - Caller's component ID
504*3446Smrj  *
505*3446Smrj  * RETURN:      None
506*3446Smrj  *
507*3446Smrj  * DESCRIPTION: Function exit trace.  Prints only if TRACE_FUNCTIONS bit is
508*3446Smrj  *              set in DebugLevel
509*3446Smrj  *
510*3446Smrj  ******************************************************************************/
511*3446Smrj 
512*3446Smrj void
513*3446Smrj AcpiUtExit (
514*3446Smrj     UINT32                  LineNumber,
515*3446Smrj     const char              *FunctionName,
516*3446Smrj     char                    *ModuleName,
517*3446Smrj     UINT32                  ComponentId)
518*3446Smrj {
519*3446Smrj 
520*3446Smrj     AcpiUtDebugPrint (ACPI_LV_FUNCTIONS,
521*3446Smrj         LineNumber, FunctionName, ModuleName, ComponentId,
522*3446Smrj         "%s\n", AcpiGbl_FnExitStr);
523*3446Smrj 
524*3446Smrj     AcpiGbl_NestingLevel--;
525*3446Smrj }
526*3446Smrj 
527*3446Smrj ACPI_EXPORT_SYMBOL (AcpiUtExit)
528*3446Smrj 
529*3446Smrj 
530*3446Smrj /*******************************************************************************
531*3446Smrj  *
532*3446Smrj  * FUNCTION:    AcpiUtStatusExit
533*3446Smrj  *
534*3446Smrj  * PARAMETERS:  LineNumber          - Caller's line number
535*3446Smrj  *              FunctionName        - Caller's procedure name
536*3446Smrj  *              ModuleName          - Caller's module name
537*3446Smrj  *              ComponentId         - Caller's component ID
538*3446Smrj  *              Status              - Exit status code
539*3446Smrj  *
540*3446Smrj  * RETURN:      None
541*3446Smrj  *
542*3446Smrj  * DESCRIPTION: Function exit trace.  Prints only if TRACE_FUNCTIONS bit is
543*3446Smrj  *              set in DebugLevel.  Prints exit status also.
544*3446Smrj  *
545*3446Smrj  ******************************************************************************/
546*3446Smrj 
547*3446Smrj void
548*3446Smrj AcpiUtStatusExit (
549*3446Smrj     UINT32                  LineNumber,
550*3446Smrj     const char              *FunctionName,
551*3446Smrj     char                    *ModuleName,
552*3446Smrj     UINT32                  ComponentId,
553*3446Smrj     ACPI_STATUS             Status)
554*3446Smrj {
555*3446Smrj 
556*3446Smrj     if (ACPI_SUCCESS (Status))
557*3446Smrj     {
558*3446Smrj         AcpiUtDebugPrint (ACPI_LV_FUNCTIONS,
559*3446Smrj             LineNumber, FunctionName, ModuleName, ComponentId,
560*3446Smrj             "%s %s\n", AcpiGbl_FnExitStr,
561*3446Smrj             AcpiFormatException (Status));
562*3446Smrj     }
563*3446Smrj     else
564*3446Smrj     {
565*3446Smrj         AcpiUtDebugPrint (ACPI_LV_FUNCTIONS,
566*3446Smrj             LineNumber, FunctionName, ModuleName, ComponentId,
567*3446Smrj             "%s ****Exception****: %s\n", AcpiGbl_FnExitStr,
568*3446Smrj             AcpiFormatException (Status));
569*3446Smrj     }
570*3446Smrj 
571*3446Smrj     AcpiGbl_NestingLevel--;
572*3446Smrj }
573*3446Smrj 
574*3446Smrj ACPI_EXPORT_SYMBOL (AcpiUtStatusExit)
575*3446Smrj 
576*3446Smrj 
577*3446Smrj /*******************************************************************************
578*3446Smrj  *
579*3446Smrj  * FUNCTION:    AcpiUtValueExit
580*3446Smrj  *
581*3446Smrj  * PARAMETERS:  LineNumber          - Caller's line number
582*3446Smrj  *              FunctionName        - Caller's procedure name
583*3446Smrj  *              ModuleName          - Caller's module name
584*3446Smrj  *              ComponentId         - Caller's component ID
585*3446Smrj  *              Value               - Value to be printed with exit msg
586*3446Smrj  *
587*3446Smrj  * RETURN:      None
588*3446Smrj  *
589*3446Smrj  * DESCRIPTION: Function exit trace.  Prints only if TRACE_FUNCTIONS bit is
590*3446Smrj  *              set in DebugLevel.  Prints exit value also.
591*3446Smrj  *
592*3446Smrj  ******************************************************************************/
593*3446Smrj 
594*3446Smrj void
595*3446Smrj AcpiUtValueExit (
596*3446Smrj     UINT32                  LineNumber,
597*3446Smrj     const char              *FunctionName,
598*3446Smrj     char                    *ModuleName,
599*3446Smrj     UINT32                  ComponentId,
600*3446Smrj     ACPI_INTEGER            Value)
601*3446Smrj {
602*3446Smrj 
603*3446Smrj     AcpiUtDebugPrint (ACPI_LV_FUNCTIONS,
604*3446Smrj         LineNumber, FunctionName, ModuleName, ComponentId,
605*3446Smrj         "%s %8.8X%8.8X\n", AcpiGbl_FnExitStr,
606*3446Smrj         ACPI_FORMAT_UINT64 (Value));
607*3446Smrj 
608*3446Smrj     AcpiGbl_NestingLevel--;
609*3446Smrj }
610*3446Smrj 
611*3446Smrj ACPI_EXPORT_SYMBOL (AcpiUtValueExit)
612*3446Smrj 
613*3446Smrj 
614*3446Smrj /*******************************************************************************
615*3446Smrj  *
616*3446Smrj  * FUNCTION:    AcpiUtPtrExit
617*3446Smrj  *
618*3446Smrj  * PARAMETERS:  LineNumber          - Caller's line number
619*3446Smrj  *              FunctionName        - Caller's procedure name
620*3446Smrj  *              ModuleName          - Caller's module name
621*3446Smrj  *              ComponentId         - Caller's component ID
622*3446Smrj  *              Ptr                 - Pointer to display
623*3446Smrj  *
624*3446Smrj  * RETURN:      None
625*3446Smrj  *
626*3446Smrj  * DESCRIPTION: Function exit trace.  Prints only if TRACE_FUNCTIONS bit is
627*3446Smrj  *              set in DebugLevel.  Prints exit value also.
628*3446Smrj  *
629*3446Smrj  ******************************************************************************/
630*3446Smrj 
631*3446Smrj void
632*3446Smrj AcpiUtPtrExit (
633*3446Smrj     UINT32                  LineNumber,
634*3446Smrj     const char              *FunctionName,
635*3446Smrj     char                    *ModuleName,
636*3446Smrj     UINT32                  ComponentId,
637*3446Smrj     UINT8                   *Ptr)
638*3446Smrj {
639*3446Smrj 
640*3446Smrj     AcpiUtDebugPrint (ACPI_LV_FUNCTIONS,
641*3446Smrj         LineNumber, FunctionName, ModuleName, ComponentId,
642*3446Smrj         "%s %p\n", AcpiGbl_FnExitStr, Ptr);
643*3446Smrj 
644*3446Smrj     AcpiGbl_NestingLevel--;
645*3446Smrj }
646*3446Smrj 
647*3446Smrj #endif
648*3446Smrj 
649*3446Smrj 
650*3446Smrj /*******************************************************************************
651*3446Smrj  *
652*3446Smrj  * FUNCTION:    AcpiUtDumpBuffer
653*3446Smrj  *
654*3446Smrj  * PARAMETERS:  Buffer              - Buffer to dump
655*3446Smrj  *              Count               - Amount to dump, in bytes
656*3446Smrj  *              Display             - BYTE, WORD, DWORD, or QWORD display
657*3446Smrj  *              ComponentID         - Caller's component ID
658*3446Smrj  *
659*3446Smrj  * RETURN:      None
660*3446Smrj  *
661*3446Smrj  * DESCRIPTION: Generic dump buffer in both hex and ascii.
662*3446Smrj  *
663*3446Smrj  ******************************************************************************/
664*3446Smrj 
665*3446Smrj void
666*3446Smrj AcpiUtDumpBuffer2 (
667*3446Smrj     UINT8                   *Buffer,
668*3446Smrj     UINT32                  Count,
669*3446Smrj     UINT32                  Display)
670*3446Smrj {
671*3446Smrj     ACPI_NATIVE_UINT        i = 0;
672*3446Smrj     ACPI_NATIVE_UINT        j;
673*3446Smrj     UINT32                  Temp32;
674*3446Smrj     UINT8                   BufChar;
675*3446Smrj 
676*3446Smrj 
677*3446Smrj     if ((Count < 4) || (Count & 0x01))
678*3446Smrj     {
679*3446Smrj         Display = DB_BYTE_DISPLAY;
680*3446Smrj     }
681*3446Smrj 
682*3446Smrj     /* Nasty little dump buffer routine! */
683*3446Smrj 
684*3446Smrj     while (i < Count)
685*3446Smrj     {
686*3446Smrj         /* Print current offset */
687*3446Smrj 
688*3446Smrj         AcpiOsPrintf ("%6.4X: ", (UINT32) i);
689*3446Smrj 
690*3446Smrj         /* Print 16 hex chars */
691*3446Smrj 
692*3446Smrj         for (j = 0; j < 16;)
693*3446Smrj         {
694*3446Smrj             if (i + j >= Count)
695*3446Smrj             {
696*3446Smrj                 /* Dump fill spaces */
697*3446Smrj 
698*3446Smrj                 AcpiOsPrintf ("%*s", ((Display * 2) + 1), " ");
699*3446Smrj                 j += (ACPI_NATIVE_UINT) Display;
700*3446Smrj                 continue;
701*3446Smrj             }
702*3446Smrj 
703*3446Smrj             switch (Display)
704*3446Smrj             {
705*3446Smrj             case DB_BYTE_DISPLAY:
706*3446Smrj             default:    /* Default is BYTE display */
707*3446Smrj 
708*3446Smrj                 AcpiOsPrintf ("%02X ", Buffer[i + j]);
709*3446Smrj                 break;
710*3446Smrj 
711*3446Smrj 
712*3446Smrj             case DB_WORD_DISPLAY:
713*3446Smrj 
714*3446Smrj                 ACPI_MOVE_16_TO_32 (&Temp32, &Buffer[i + j]);
715*3446Smrj                 AcpiOsPrintf ("%04X ", Temp32);
716*3446Smrj                 break;
717*3446Smrj 
718*3446Smrj 
719*3446Smrj             case DB_DWORD_DISPLAY:
720*3446Smrj 
721*3446Smrj                 ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[i + j]);
722*3446Smrj                 AcpiOsPrintf ("%08X ", Temp32);
723*3446Smrj                 break;
724*3446Smrj 
725*3446Smrj 
726*3446Smrj             case DB_QWORD_DISPLAY:
727*3446Smrj 
728*3446Smrj                 ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[i + j]);
729*3446Smrj                 AcpiOsPrintf ("%08X", Temp32);
730*3446Smrj 
731*3446Smrj                 ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[i + j + 4]);
732*3446Smrj                 AcpiOsPrintf ("%08X ", Temp32);
733*3446Smrj                 break;
734*3446Smrj             }
735*3446Smrj 
736*3446Smrj             j += (ACPI_NATIVE_UINT) Display;
737*3446Smrj         }
738*3446Smrj 
739*3446Smrj         /*
740*3446Smrj          * Print the ASCII equivalent characters but watch out for the bad
741*3446Smrj          * unprintable ones (printable chars are 0x20 through 0x7E)
742*3446Smrj          */
743*3446Smrj         AcpiOsPrintf (" ");
744*3446Smrj         for (j = 0; j < 16; j++)
745*3446Smrj         {
746*3446Smrj             if (i + j >= Count)
747*3446Smrj             {
748*3446Smrj                 AcpiOsPrintf ("\n");
749*3446Smrj                 return;
750*3446Smrj             }
751*3446Smrj 
752*3446Smrj             BufChar = Buffer[i + j];
753*3446Smrj             if (ACPI_IS_PRINT (BufChar))
754*3446Smrj             {
755*3446Smrj                 AcpiOsPrintf ("%c", BufChar);
756*3446Smrj             }
757*3446Smrj             else
758*3446Smrj             {
759*3446Smrj                 AcpiOsPrintf (".");
760*3446Smrj             }
761*3446Smrj         }
762*3446Smrj 
763*3446Smrj         /* Done with that line. */
764*3446Smrj 
765*3446Smrj         AcpiOsPrintf ("\n");
766*3446Smrj         i += 16;
767*3446Smrj     }
768*3446Smrj 
769*3446Smrj     return;
770*3446Smrj }
771*3446Smrj 
772*3446Smrj 
773*3446Smrj /*******************************************************************************
774*3446Smrj  *
775*3446Smrj  * FUNCTION:    AcpiUtDumpBuffer
776*3446Smrj  *
777*3446Smrj  * PARAMETERS:  Buffer              - Buffer to dump
778*3446Smrj  *              Count               - Amount to dump, in bytes
779*3446Smrj  *              Display             - BYTE, WORD, DWORD, or QWORD display
780*3446Smrj  *              ComponentID         - Caller's component ID
781*3446Smrj  *
782*3446Smrj  * RETURN:      None
783*3446Smrj  *
784*3446Smrj  * DESCRIPTION: Generic dump buffer in both hex and ascii.
785*3446Smrj  *
786*3446Smrj  ******************************************************************************/
787*3446Smrj 
788*3446Smrj void
789*3446Smrj AcpiUtDumpBuffer (
790*3446Smrj     UINT8                   *Buffer,
791*3446Smrj     UINT32                  Count,
792*3446Smrj     UINT32                  Display,
793*3446Smrj     UINT32                  ComponentId)
794*3446Smrj {
795*3446Smrj 
796*3446Smrj     /* Only dump the buffer if tracing is enabled */
797*3446Smrj 
798*3446Smrj     if (!((ACPI_LV_TABLES & AcpiDbgLevel) &&
799*3446Smrj         (ComponentId & AcpiDbgLayer)))
800*3446Smrj     {
801*3446Smrj         return;
802*3446Smrj     }
803*3446Smrj 
804*3446Smrj     AcpiUtDumpBuffer2 (Buffer, Count, Display);
805*3446Smrj }
806*3446Smrj 
807*3446Smrj 
808