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