13446Smrj /******************************************************************************
23446Smrj  *
33446Smrj  * Module Name: utdebug - Debug print routines
4*7851SDana.Myers@Sun.COM  *              $Revision: 1.137 $
53446Smrj  *
63446Smrj  *****************************************************************************/
73446Smrj 
83446Smrj /******************************************************************************
93446Smrj  *
103446Smrj  * 1. Copyright Notice
113446Smrj  *
12*7851SDana.Myers@Sun.COM  * Some or all of this work - Copyright (c) 1999 - 2008, Intel Corp.
133446Smrj  * All rights reserved.
143446Smrj  *
153446Smrj  * 2. License
163446Smrj  *
173446Smrj  * 2.1. This is your license from Intel Corp. under its intellectual property
183446Smrj  * rights.  You may have additional license terms from the party that provided
193446Smrj  * you this software, covering your right to use that party's intellectual
203446Smrj  * property rights.
213446Smrj  *
223446Smrj  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
233446Smrj  * copy of the source code appearing in this file ("Covered Code") an
243446Smrj  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
253446Smrj  * base code distributed originally by Intel ("Original Intel Code") to copy,
263446Smrj  * make derivatives, distribute, use and display any portion of the Covered
273446Smrj  * Code in any form, with the right to sublicense such rights; and
283446Smrj  *
293446Smrj  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
303446Smrj  * license (with the right to sublicense), under only those claims of Intel
313446Smrj  * patents that are infringed by the Original Intel Code, to make, use, sell,
323446Smrj  * offer to sell, and import the Covered Code and derivative works thereof
333446Smrj  * solely to the minimum extent necessary to exercise the above copyright
343446Smrj  * license, and in no event shall the patent license extend to any additions
353446Smrj  * to or modifications of the Original Intel Code.  No other license or right
363446Smrj  * is granted directly or by implication, estoppel or otherwise;
373446Smrj  *
383446Smrj  * The above copyright and patent license is granted only if the following
393446Smrj  * conditions are met:
403446Smrj  *
413446Smrj  * 3. Conditions
423446Smrj  *
433446Smrj  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
443446Smrj  * Redistribution of source code of any substantial portion of the Covered
453446Smrj  * Code or modification with rights to further distribute source must include
463446Smrj  * the above Copyright Notice, the above License, this list of Conditions,
473446Smrj  * and the following Disclaimer and Export Compliance provision.  In addition,
483446Smrj  * Licensee must cause all Covered Code to which Licensee contributes to
493446Smrj  * contain a file documenting the changes Licensee made to create that Covered
503446Smrj  * Code and the date of any change.  Licensee must include in that file the
513446Smrj  * documentation of any changes made by any predecessor Licensee.  Licensee
523446Smrj  * must include a prominent statement that the modification is derived,
533446Smrj  * directly or indirectly, from Original Intel Code.
543446Smrj  *
553446Smrj  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
563446Smrj  * Redistribution of source code of any substantial portion of the Covered
573446Smrj  * Code or modification without rights to further distribute source must
583446Smrj  * include the following Disclaimer and Export Compliance provision in the
593446Smrj  * documentation and/or other materials provided with distribution.  In
603446Smrj  * addition, Licensee may not authorize further sublicense of source of any
613446Smrj  * portion of the Covered Code, and must include terms to the effect that the
623446Smrj  * license from Licensee to its licensee is limited to the intellectual
633446Smrj  * property embodied in the software Licensee provides to its licensee, and
643446Smrj  * not to intellectual property embodied in modifications its licensee may
653446Smrj  * make.
663446Smrj  *
673446Smrj  * 3.3. Redistribution of Executable. Redistribution in executable form of any
683446Smrj  * substantial portion of the Covered Code or modification must reproduce the
693446Smrj  * above Copyright Notice, and the following Disclaimer and Export Compliance
703446Smrj  * provision in the documentation and/or other materials provided with the
713446Smrj  * distribution.
723446Smrj  *
733446Smrj  * 3.4. Intel retains all right, title, and interest in and to the Original
743446Smrj  * Intel Code.
753446Smrj  *
763446Smrj  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
773446Smrj  * Intel shall be used in advertising or otherwise to promote the sale, use or
783446Smrj  * other dealings in products derived from or relating to the Covered Code
793446Smrj  * without prior written authorization from Intel.
803446Smrj  *
813446Smrj  * 4. Disclaimer and Export Compliance
823446Smrj  *
833446Smrj  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
843446Smrj  * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
853446Smrj  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
863446Smrj  * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
873446Smrj  * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
883446Smrj  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
893446Smrj  * PARTICULAR PURPOSE.
903446Smrj  *
913446Smrj  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
923446Smrj  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
933446Smrj  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
943446Smrj  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
953446Smrj  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
963446Smrj  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
973446Smrj  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
983446Smrj  * LIMITED REMEDY.
993446Smrj  *
1003446Smrj  * 4.3. Licensee shall not export, either directly or indirectly, any of this
1013446Smrj  * software or system incorporating such software without first obtaining any
1023446Smrj  * required license or other approval from the U. S. Department of Commerce or
1033446Smrj  * any other agency or department of the United States Government.  In the
1043446Smrj  * event Licensee exports any such software from the United States or
1053446Smrj  * re-exports any such software from a foreign destination, Licensee shall
1063446Smrj  * ensure that the distribution and export/re-export of the software is in
1073446Smrj  * compliance with all laws, regulations, orders, or other restrictions of the
1083446Smrj  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1093446Smrj  * any of its subsidiaries will export/re-export any technical data, process,
1103446Smrj  * software, or service, directly or indirectly, to any country for which the
1113446Smrj  * United States government or any agency thereof requires an export license,
1123446Smrj  * other governmental approval, or letter of assurance, without first obtaining
1133446Smrj  * such license, approval or letter.
1143446Smrj  *
1153446Smrj  *****************************************************************************/
1163446Smrj 
1173446Smrj #define __UTDEBUG_C__
1183446Smrj 
1193446Smrj #include "acpi.h"
1203446Smrj 
1213446Smrj #define _COMPONENT          ACPI_UTILITIES
1223446Smrj         ACPI_MODULE_NAME    ("utdebug")
1233446Smrj 
1243446Smrj 
1253446Smrj #ifdef ACPI_DEBUG_OUTPUT
1263446Smrj 
127*7851SDana.Myers@Sun.COM static ACPI_THREAD_ID       AcpiGbl_PrevThreadId = 0xFFFFFFFF;
128*7851SDana.Myers@Sun.COM static char                 *AcpiGbl_FnEntryStr = "----Entry";
129*7851SDana.Myers@Sun.COM static char                 *AcpiGbl_FnExitStr  = "----Exit-";
1303446Smrj 
1313446Smrj /* Local prototypes */
1323446Smrj 
1333446Smrj static const char *
1343446Smrj AcpiUtTrimFunctionName (
1353446Smrj     const char              *FunctionName);
1363446Smrj 
1373446Smrj 
1383446Smrj /*******************************************************************************
1393446Smrj  *
1403446Smrj  * FUNCTION:    AcpiUtInitStackPtrTrace
1413446Smrj  *
1423446Smrj  * PARAMETERS:  None
1433446Smrj  *
1443446Smrj  * RETURN:      None
1453446Smrj  *
1463446Smrj  * DESCRIPTION: Save the current CPU stack pointer at subsystem startup
1473446Smrj  *
1483446Smrj  ******************************************************************************/
1493446Smrj 
1503446Smrj void
1513446Smrj AcpiUtInitStackPtrTrace (
1523446Smrj     void)
1533446Smrj {
154*7851SDana.Myers@Sun.COM     ACPI_SIZE               CurrentSp;
1553446Smrj 
1563446Smrj 
157*7851SDana.Myers@Sun.COM     AcpiGbl_EntryStackPointer = &CurrentSp;
1583446Smrj }
1593446Smrj 
1603446Smrj 
1613446Smrj /*******************************************************************************
1623446Smrj  *
1633446Smrj  * FUNCTION:    AcpiUtTrackStackPtr
1643446Smrj  *
1653446Smrj  * PARAMETERS:  None
1663446Smrj  *
1673446Smrj  * RETURN:      None
1683446Smrj  *
1693446Smrj  * DESCRIPTION: Save the current CPU stack pointer
1703446Smrj  *
1713446Smrj  ******************************************************************************/
1723446Smrj 
1733446Smrj void
1743446Smrj AcpiUtTrackStackPtr (
1753446Smrj     void)
1763446Smrj {
1773446Smrj     ACPI_SIZE               CurrentSp;
1783446Smrj 
1793446Smrj 
180*7851SDana.Myers@Sun.COM     if (&CurrentSp < AcpiGbl_LowestStackPointer)
1813446Smrj     {
182*7851SDana.Myers@Sun.COM         AcpiGbl_LowestStackPointer = &CurrentSp;
1833446Smrj     }
1843446Smrj 
1853446Smrj     if (AcpiGbl_NestingLevel > AcpiGbl_DeepestNesting)
1863446Smrj     {
1873446Smrj         AcpiGbl_DeepestNesting = AcpiGbl_NestingLevel;
1883446Smrj     }
1893446Smrj }
1903446Smrj 
1913446Smrj 
1923446Smrj /*******************************************************************************
1933446Smrj  *
1943446Smrj  * FUNCTION:    AcpiUtTrimFunctionName
1953446Smrj  *
1963446Smrj  * PARAMETERS:  FunctionName        - Ascii string containing a procedure name
1973446Smrj  *
1983446Smrj  * RETURN:      Updated pointer to the function name
1993446Smrj  *
2003446Smrj  * DESCRIPTION: Remove the "Acpi" prefix from the function name, if present.
2013446Smrj  *              This allows compiler macros such as __FUNCTION__ to be used
2023446Smrj  *              with no change to the debug output.
2033446Smrj  *
2043446Smrj  ******************************************************************************/
2053446Smrj 
2063446Smrj static const char *
2073446Smrj AcpiUtTrimFunctionName (
2083446Smrj     const char              *FunctionName)
2093446Smrj {
2103446Smrj 
2113446Smrj     /* All Function names are longer than 4 chars, check is safe */
2123446Smrj 
2133446Smrj     if (*(ACPI_CAST_PTR (UINT32, FunctionName)) == ACPI_PREFIX_MIXED)
2143446Smrj     {
2153446Smrj         /* This is the case where the original source has not been modified */
2163446Smrj 
2173446Smrj         return (FunctionName + 4);
2183446Smrj     }
2193446Smrj 
2203446Smrj     if (*(ACPI_CAST_PTR (UINT32, FunctionName)) == ACPI_PREFIX_LOWER)
2213446Smrj     {
2223446Smrj         /* This is the case where the source has been 'linuxized' */
2233446Smrj 
2243446Smrj         return (FunctionName + 5);
2253446Smrj     }
2263446Smrj 
2273446Smrj     return (FunctionName);
2283446Smrj }
2293446Smrj 
2303446Smrj 
2313446Smrj /*******************************************************************************
2323446Smrj  *
2333446Smrj  * FUNCTION:    AcpiUtDebugPrint
2343446Smrj  *
2353446Smrj  * PARAMETERS:  RequestedDebugLevel - Requested debug print level
2363446Smrj  *              LineNumber          - Caller's line number (for error output)
2373446Smrj  *              FunctionName        - Caller's procedure name
2383446Smrj  *              ModuleName          - Caller's module name
2393446Smrj  *              ComponentId         - Caller's component ID
2403446Smrj  *              Format              - Printf format field
2413446Smrj  *              ...                 - Optional printf arguments
2423446Smrj  *
2433446Smrj  * RETURN:      None
2443446Smrj  *
2453446Smrj  * DESCRIPTION: Print error message with prefix consisting of the module name,
2463446Smrj  *              line number, and component ID.
2473446Smrj  *
2483446Smrj  ******************************************************************************/
2493446Smrj 
2503446Smrj void  ACPI_INTERNAL_VAR_XFACE
2513446Smrj AcpiUtDebugPrint (
2523446Smrj     UINT32                  RequestedDebugLevel,
2533446Smrj     UINT32                  LineNumber,
2543446Smrj     const char              *FunctionName,
255*7851SDana.Myers@Sun.COM     const char              *ModuleName,
2563446Smrj     UINT32                  ComponentId,
257*7851SDana.Myers@Sun.COM     const char              *Format,
2583446Smrj     ...)
2593446Smrj {
2603446Smrj     ACPI_THREAD_ID          ThreadId;
2613446Smrj     va_list                 args;
2623446Smrj 
2633446Smrj 
2643446Smrj     /*
2653446Smrj      * Stay silent if the debug level or component ID is disabled
2663446Smrj      */
2673446Smrj     if (!(RequestedDebugLevel & AcpiDbgLevel) ||
2683446Smrj         !(ComponentId & AcpiDbgLayer))
2693446Smrj     {
2703446Smrj         return;
2713446Smrj     }
2723446Smrj 
2733446Smrj     /*
2743446Smrj      * Thread tracking and context switch notification
2753446Smrj      */
2763446Smrj     ThreadId = AcpiOsGetThreadId ();
2773446Smrj     if (ThreadId != AcpiGbl_PrevThreadId)
2783446Smrj     {
2793446Smrj         if (ACPI_LV_THREADS & AcpiDbgLevel)
2803446Smrj         {
2813446Smrj             AcpiOsPrintf (
2823446Smrj                 "\n**** Context Switch from TID %X to TID %X ****\n\n",
2833446Smrj                 AcpiGbl_PrevThreadId, ThreadId);
2843446Smrj         }
2853446Smrj 
2863446Smrj         AcpiGbl_PrevThreadId = ThreadId;
2873446Smrj     }
2883446Smrj 
2893446Smrj     /*
2903446Smrj      * Display the module name, current line number, thread ID (if requested),
2913446Smrj      * current procedure nesting level, and the current procedure name
2923446Smrj      */
2933446Smrj     AcpiOsPrintf ("%8s-%04ld ", ModuleName, LineNumber);
2943446Smrj 
2953446Smrj     if (ACPI_LV_THREADS & AcpiDbgLevel)
2963446Smrj     {
2973446Smrj         AcpiOsPrintf ("[%04lX] ", ThreadId);
2983446Smrj     }
2993446Smrj 
3003446Smrj     AcpiOsPrintf ("[%02ld] %-22.22s: ",
3013446Smrj         AcpiGbl_NestingLevel, AcpiUtTrimFunctionName (FunctionName));
3023446Smrj 
3033446Smrj     va_start (args, Format);
3043446Smrj     AcpiOsVprintf (Format, args);
305*7851SDana.Myers@Sun.COM     va_end (args);
3063446Smrj }
3073446Smrj 
3083446Smrj ACPI_EXPORT_SYMBOL (AcpiUtDebugPrint)
3093446Smrj 
3103446Smrj 
3113446Smrj /*******************************************************************************
3123446Smrj  *
3133446Smrj  * FUNCTION:    AcpiUtDebugPrintRaw
3143446Smrj  *
3153446Smrj  * PARAMETERS:  RequestedDebugLevel - Requested debug print level
3163446Smrj  *              LineNumber          - Caller's line number
3173446Smrj  *              FunctionName        - Caller's procedure name
3183446Smrj  *              ModuleName          - Caller's module name
3193446Smrj  *              ComponentId         - Caller's component ID
3203446Smrj  *              Format              - Printf format field
3213446Smrj  *              ...                 - Optional printf arguments
3223446Smrj  *
3233446Smrj  * RETURN:      None
3243446Smrj  *
3253446Smrj  * DESCRIPTION: Print message with no headers.  Has same interface as
3263446Smrj  *              DebugPrint so that the same macros can be used.
3273446Smrj  *
3283446Smrj  ******************************************************************************/
3293446Smrj 
3303446Smrj void  ACPI_INTERNAL_VAR_XFACE
3313446Smrj AcpiUtDebugPrintRaw (
3323446Smrj     UINT32                  RequestedDebugLevel,
3333446Smrj     UINT32                  LineNumber,
3343446Smrj     const char              *FunctionName,
335*7851SDana.Myers@Sun.COM     const char              *ModuleName,
3363446Smrj     UINT32                  ComponentId,
337*7851SDana.Myers@Sun.COM     const char              *Format,
3383446Smrj     ...)
3393446Smrj {
3403446Smrj     va_list                 args;
3413446Smrj 
3423446Smrj 
3433446Smrj     if (!(RequestedDebugLevel & AcpiDbgLevel) ||
3443446Smrj         !(ComponentId & AcpiDbgLayer))
3453446Smrj     {
3463446Smrj         return;
3473446Smrj     }
3483446Smrj 
3493446Smrj     va_start (args, Format);
3503446Smrj     AcpiOsVprintf (Format, args);
351*7851SDana.Myers@Sun.COM     va_end (args);
3523446Smrj }
3533446Smrj 
3543446Smrj ACPI_EXPORT_SYMBOL (AcpiUtDebugPrintRaw)
3553446Smrj 
3563446Smrj 
3573446Smrj /*******************************************************************************
3583446Smrj  *
3593446Smrj  * FUNCTION:    AcpiUtTrace
3603446Smrj  *
3613446Smrj  * PARAMETERS:  LineNumber          - Caller's line number
3623446Smrj  *              FunctionName        - Caller's procedure name
3633446Smrj  *              ModuleName          - Caller's module name
3643446Smrj  *              ComponentId         - Caller's component ID
3653446Smrj  *
3663446Smrj  * RETURN:      None
3673446Smrj  *
3683446Smrj  * DESCRIPTION: Function entry trace.  Prints only if TRACE_FUNCTIONS bit is
3693446Smrj  *              set in DebugLevel
3703446Smrj  *
3713446Smrj  ******************************************************************************/
3723446Smrj 
3733446Smrj void
3743446Smrj AcpiUtTrace (
3753446Smrj     UINT32                  LineNumber,
3763446Smrj     const char              *FunctionName,
377*7851SDana.Myers@Sun.COM     const char              *ModuleName,
3783446Smrj     UINT32                  ComponentId)
3793446Smrj {
3803446Smrj 
3813446Smrj     AcpiGbl_NestingLevel++;
3823446Smrj     AcpiUtTrackStackPtr ();
3833446Smrj 
3843446Smrj     AcpiUtDebugPrint (ACPI_LV_FUNCTIONS,
3853446Smrj         LineNumber, FunctionName, ModuleName, ComponentId,
3863446Smrj         "%s\n", AcpiGbl_FnEntryStr);
3873446Smrj }
3883446Smrj 
3893446Smrj ACPI_EXPORT_SYMBOL (AcpiUtTrace)
3903446Smrj 
3913446Smrj 
3923446Smrj /*******************************************************************************
3933446Smrj  *
3943446Smrj  * FUNCTION:    AcpiUtTracePtr
3953446Smrj  *
3963446Smrj  * PARAMETERS:  LineNumber          - Caller's line number
3973446Smrj  *              FunctionName        - Caller's procedure name
3983446Smrj  *              ModuleName          - Caller's module name
3993446Smrj  *              ComponentId         - Caller's component ID
4003446Smrj  *              Pointer             - Pointer to display
4013446Smrj  *
4023446Smrj  * RETURN:      None
4033446Smrj  *
4043446Smrj  * DESCRIPTION: Function entry trace.  Prints only if TRACE_FUNCTIONS bit is
4053446Smrj  *              set in DebugLevel
4063446Smrj  *
4073446Smrj  ******************************************************************************/
4083446Smrj 
4093446Smrj void
4103446Smrj AcpiUtTracePtr (
4113446Smrj     UINT32                  LineNumber,
4123446Smrj     const char              *FunctionName,
413*7851SDana.Myers@Sun.COM     const char              *ModuleName,
4143446Smrj     UINT32                  ComponentId,
4153446Smrj     void                    *Pointer)
4163446Smrj {
4173446Smrj     AcpiGbl_NestingLevel++;
4183446Smrj     AcpiUtTrackStackPtr ();
4193446Smrj 
4203446Smrj     AcpiUtDebugPrint (ACPI_LV_FUNCTIONS,
4213446Smrj         LineNumber, FunctionName, ModuleName, ComponentId,
4223446Smrj         "%s %p\n", AcpiGbl_FnEntryStr, Pointer);
4233446Smrj }
4243446Smrj 
4253446Smrj 
4263446Smrj /*******************************************************************************
4273446Smrj  *
4283446Smrj  * FUNCTION:    AcpiUtTraceStr
4293446Smrj  *
4303446Smrj  * PARAMETERS:  LineNumber          - Caller's line number
4313446Smrj  *              FunctionName        - Caller's procedure name
4323446Smrj  *              ModuleName          - Caller's module name
4333446Smrj  *              ComponentId         - Caller's component ID
4343446Smrj  *              String              - Additional string to display
4353446Smrj  *
4363446Smrj  * RETURN:      None
4373446Smrj  *
4383446Smrj  * DESCRIPTION: Function entry trace.  Prints only if TRACE_FUNCTIONS bit is
4393446Smrj  *              set in DebugLevel
4403446Smrj  *
4413446Smrj  ******************************************************************************/
4423446Smrj 
4433446Smrj void
4443446Smrj AcpiUtTraceStr (
4453446Smrj     UINT32                  LineNumber,
4463446Smrj     const char              *FunctionName,
447*7851SDana.Myers@Sun.COM     const char              *ModuleName,
4483446Smrj     UINT32                  ComponentId,
4493446Smrj     char                    *String)
4503446Smrj {
4513446Smrj 
4523446Smrj     AcpiGbl_NestingLevel++;
4533446Smrj     AcpiUtTrackStackPtr ();
4543446Smrj 
4553446Smrj     AcpiUtDebugPrint (ACPI_LV_FUNCTIONS,
4563446Smrj         LineNumber, FunctionName, ModuleName, ComponentId,
4573446Smrj         "%s %s\n", AcpiGbl_FnEntryStr, String);
4583446Smrj }
4593446Smrj 
4603446Smrj 
4613446Smrj /*******************************************************************************
4623446Smrj  *
4633446Smrj  * FUNCTION:    AcpiUtTraceU32
4643446Smrj  *
4653446Smrj  * PARAMETERS:  LineNumber          - Caller's line number
4663446Smrj  *              FunctionName        - Caller's procedure name
4673446Smrj  *              ModuleName          - Caller's module name
4683446Smrj  *              ComponentId         - Caller's component ID
4693446Smrj  *              Integer             - Integer to display
4703446Smrj  *
4713446Smrj  * RETURN:      None
4723446Smrj  *
4733446Smrj  * DESCRIPTION: Function entry trace.  Prints only if TRACE_FUNCTIONS bit is
4743446Smrj  *              set in DebugLevel
4753446Smrj  *
4763446Smrj  ******************************************************************************/
4773446Smrj 
4783446Smrj void
4793446Smrj AcpiUtTraceU32 (
4803446Smrj     UINT32                  LineNumber,
4813446Smrj     const char              *FunctionName,
482*7851SDana.Myers@Sun.COM     const char              *ModuleName,
4833446Smrj     UINT32                  ComponentId,
4843446Smrj     UINT32                  Integer)
4853446Smrj {
4863446Smrj 
4873446Smrj     AcpiGbl_NestingLevel++;
4883446Smrj     AcpiUtTrackStackPtr ();
4893446Smrj 
4903446Smrj     AcpiUtDebugPrint (ACPI_LV_FUNCTIONS,
4913446Smrj         LineNumber, FunctionName, ModuleName, ComponentId,
4923446Smrj         "%s %08X\n", AcpiGbl_FnEntryStr, Integer);
4933446Smrj }
4943446Smrj 
4953446Smrj 
4963446Smrj /*******************************************************************************
4973446Smrj  *
4983446Smrj  * FUNCTION:    AcpiUtExit
4993446Smrj  *
5003446Smrj  * PARAMETERS:  LineNumber          - Caller's line number
5013446Smrj  *              FunctionName        - Caller's procedure name
5023446Smrj  *              ModuleName          - Caller's module name
5033446Smrj  *              ComponentId         - Caller's component ID
5043446Smrj  *
5053446Smrj  * RETURN:      None
5063446Smrj  *
5073446Smrj  * DESCRIPTION: Function exit trace.  Prints only if TRACE_FUNCTIONS bit is
5083446Smrj  *              set in DebugLevel
5093446Smrj  *
5103446Smrj  ******************************************************************************/
5113446Smrj 
5123446Smrj void
5133446Smrj AcpiUtExit (
5143446Smrj     UINT32                  LineNumber,
5153446Smrj     const char              *FunctionName,
516*7851SDana.Myers@Sun.COM     const char              *ModuleName,
5173446Smrj     UINT32                  ComponentId)
5183446Smrj {
5193446Smrj 
5203446Smrj     AcpiUtDebugPrint (ACPI_LV_FUNCTIONS,
5213446Smrj         LineNumber, FunctionName, ModuleName, ComponentId,
5223446Smrj         "%s\n", AcpiGbl_FnExitStr);
5233446Smrj 
5243446Smrj     AcpiGbl_NestingLevel--;
5253446Smrj }
5263446Smrj 
5273446Smrj ACPI_EXPORT_SYMBOL (AcpiUtExit)
5283446Smrj 
5293446Smrj 
5303446Smrj /*******************************************************************************
5313446Smrj  *
5323446Smrj  * FUNCTION:    AcpiUtStatusExit
5333446Smrj  *
5343446Smrj  * PARAMETERS:  LineNumber          - Caller's line number
5353446Smrj  *              FunctionName        - Caller's procedure name
5363446Smrj  *              ModuleName          - Caller's module name
5373446Smrj  *              ComponentId         - Caller's component ID
5383446Smrj  *              Status              - Exit status code
5393446Smrj  *
5403446Smrj  * RETURN:      None
5413446Smrj  *
5423446Smrj  * DESCRIPTION: Function exit trace.  Prints only if TRACE_FUNCTIONS bit is
5433446Smrj  *              set in DebugLevel.  Prints exit status also.
5443446Smrj  *
5453446Smrj  ******************************************************************************/
5463446Smrj 
5473446Smrj void
5483446Smrj AcpiUtStatusExit (
5493446Smrj     UINT32                  LineNumber,
5503446Smrj     const char              *FunctionName,
551*7851SDana.Myers@Sun.COM     const char              *ModuleName,
5523446Smrj     UINT32                  ComponentId,
5533446Smrj     ACPI_STATUS             Status)
5543446Smrj {
5553446Smrj 
5563446Smrj     if (ACPI_SUCCESS (Status))
5573446Smrj     {
5583446Smrj         AcpiUtDebugPrint (ACPI_LV_FUNCTIONS,
5593446Smrj             LineNumber, FunctionName, ModuleName, ComponentId,
5603446Smrj             "%s %s\n", AcpiGbl_FnExitStr,
5613446Smrj             AcpiFormatException (Status));
5623446Smrj     }
5633446Smrj     else
5643446Smrj     {
5653446Smrj         AcpiUtDebugPrint (ACPI_LV_FUNCTIONS,
5663446Smrj             LineNumber, FunctionName, ModuleName, ComponentId,
5673446Smrj             "%s ****Exception****: %s\n", AcpiGbl_FnExitStr,
5683446Smrj             AcpiFormatException (Status));
5693446Smrj     }
5703446Smrj 
5713446Smrj     AcpiGbl_NestingLevel--;
5723446Smrj }
5733446Smrj 
5743446Smrj ACPI_EXPORT_SYMBOL (AcpiUtStatusExit)
5753446Smrj 
5763446Smrj 
5773446Smrj /*******************************************************************************
5783446Smrj  *
5793446Smrj  * FUNCTION:    AcpiUtValueExit
5803446Smrj  *
5813446Smrj  * PARAMETERS:  LineNumber          - Caller's line number
5823446Smrj  *              FunctionName        - Caller's procedure name
5833446Smrj  *              ModuleName          - Caller's module name
5843446Smrj  *              ComponentId         - Caller's component ID
5853446Smrj  *              Value               - Value to be printed with exit msg
5863446Smrj  *
5873446Smrj  * RETURN:      None
5883446Smrj  *
5893446Smrj  * DESCRIPTION: Function exit trace.  Prints only if TRACE_FUNCTIONS bit is
5903446Smrj  *              set in DebugLevel.  Prints exit value also.
5913446Smrj  *
5923446Smrj  ******************************************************************************/
5933446Smrj 
5943446Smrj void
5953446Smrj AcpiUtValueExit (
5963446Smrj     UINT32                  LineNumber,
5973446Smrj     const char              *FunctionName,
598*7851SDana.Myers@Sun.COM     const char              *ModuleName,
5993446Smrj     UINT32                  ComponentId,
6003446Smrj     ACPI_INTEGER            Value)
6013446Smrj {
6023446Smrj 
6033446Smrj     AcpiUtDebugPrint (ACPI_LV_FUNCTIONS,
6043446Smrj         LineNumber, FunctionName, ModuleName, ComponentId,
6053446Smrj         "%s %8.8X%8.8X\n", AcpiGbl_FnExitStr,
6063446Smrj         ACPI_FORMAT_UINT64 (Value));
6073446Smrj 
6083446Smrj     AcpiGbl_NestingLevel--;
6093446Smrj }
6103446Smrj 
6113446Smrj ACPI_EXPORT_SYMBOL (AcpiUtValueExit)
6123446Smrj 
6133446Smrj 
6143446Smrj /*******************************************************************************
6153446Smrj  *
6163446Smrj  * FUNCTION:    AcpiUtPtrExit
6173446Smrj  *
6183446Smrj  * PARAMETERS:  LineNumber          - Caller's line number
6193446Smrj  *              FunctionName        - Caller's procedure name
6203446Smrj  *              ModuleName          - Caller's module name
6213446Smrj  *              ComponentId         - Caller's component ID
6223446Smrj  *              Ptr                 - Pointer to display
6233446Smrj  *
6243446Smrj  * RETURN:      None
6253446Smrj  *
6263446Smrj  * DESCRIPTION: Function exit trace.  Prints only if TRACE_FUNCTIONS bit is
6273446Smrj  *              set in DebugLevel.  Prints exit value also.
6283446Smrj  *
6293446Smrj  ******************************************************************************/
6303446Smrj 
6313446Smrj void
6323446Smrj AcpiUtPtrExit (
6333446Smrj     UINT32                  LineNumber,
6343446Smrj     const char              *FunctionName,
635*7851SDana.Myers@Sun.COM     const char              *ModuleName,
6363446Smrj     UINT32                  ComponentId,
6373446Smrj     UINT8                   *Ptr)
6383446Smrj {
6393446Smrj 
6403446Smrj     AcpiUtDebugPrint (ACPI_LV_FUNCTIONS,
6413446Smrj         LineNumber, FunctionName, ModuleName, ComponentId,
6423446Smrj         "%s %p\n", AcpiGbl_FnExitStr, Ptr);
6433446Smrj 
6443446Smrj     AcpiGbl_NestingLevel--;
6453446Smrj }
6463446Smrj 
6473446Smrj #endif
6483446Smrj 
6493446Smrj 
6503446Smrj /*******************************************************************************
6513446Smrj  *
6523446Smrj  * FUNCTION:    AcpiUtDumpBuffer
6533446Smrj  *
6543446Smrj  * PARAMETERS:  Buffer              - Buffer to dump
6553446Smrj  *              Count               - Amount to dump, in bytes
6563446Smrj  *              Display             - BYTE, WORD, DWORD, or QWORD display
6573446Smrj  *              ComponentID         - Caller's component ID
6583446Smrj  *
6593446Smrj  * RETURN:      None
6603446Smrj  *
6613446Smrj  * DESCRIPTION: Generic dump buffer in both hex and ascii.
6623446Smrj  *
6633446Smrj  ******************************************************************************/
6643446Smrj 
6653446Smrj void
6663446Smrj AcpiUtDumpBuffer2 (
6673446Smrj     UINT8                   *Buffer,
6683446Smrj     UINT32                  Count,
6693446Smrj     UINT32                  Display)
6703446Smrj {
671*7851SDana.Myers@Sun.COM     UINT32                  i = 0;
672*7851SDana.Myers@Sun.COM     UINT32                  j;
6733446Smrj     UINT32                  Temp32;
6743446Smrj     UINT8                   BufChar;
6753446Smrj 
6763446Smrj 
677*7851SDana.Myers@Sun.COM     if (!Buffer)
678*7851SDana.Myers@Sun.COM     {
679*7851SDana.Myers@Sun.COM         AcpiOsPrintf ("Null Buffer Pointer in DumpBuffer!\n");
680*7851SDana.Myers@Sun.COM         return;
681*7851SDana.Myers@Sun.COM     }
682*7851SDana.Myers@Sun.COM 
6833446Smrj     if ((Count < 4) || (Count & 0x01))
6843446Smrj     {
6853446Smrj         Display = DB_BYTE_DISPLAY;
6863446Smrj     }
6873446Smrj 
6883446Smrj     /* Nasty little dump buffer routine! */
6893446Smrj 
6903446Smrj     while (i < Count)
6913446Smrj     {
6923446Smrj         /* Print current offset */
6933446Smrj 
694*7851SDana.Myers@Sun.COM         AcpiOsPrintf ("%6.4X: ", i);
6953446Smrj 
6963446Smrj         /* Print 16 hex chars */
6973446Smrj 
6983446Smrj         for (j = 0; j < 16;)
6993446Smrj         {
7003446Smrj             if (i + j >= Count)
7013446Smrj             {
7023446Smrj                 /* Dump fill spaces */
7033446Smrj 
7043446Smrj                 AcpiOsPrintf ("%*s", ((Display * 2) + 1), " ");
705*7851SDana.Myers@Sun.COM                 j += Display;
7063446Smrj                 continue;
7073446Smrj             }
7083446Smrj 
7093446Smrj             switch (Display)
7103446Smrj             {
7113446Smrj             case DB_BYTE_DISPLAY:
7123446Smrj             default:    /* Default is BYTE display */
7133446Smrj 
714*7851SDana.Myers@Sun.COM                 AcpiOsPrintf ("%02X ", Buffer[(ACPI_SIZE) i + j]);
7153446Smrj                 break;
7163446Smrj 
7173446Smrj 
7183446Smrj             case DB_WORD_DISPLAY:
7193446Smrj 
720*7851SDana.Myers@Sun.COM                 ACPI_MOVE_16_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
7213446Smrj                 AcpiOsPrintf ("%04X ", Temp32);
7223446Smrj                 break;
7233446Smrj 
7243446Smrj 
7253446Smrj             case DB_DWORD_DISPLAY:
7263446Smrj 
727*7851SDana.Myers@Sun.COM                 ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
7283446Smrj                 AcpiOsPrintf ("%08X ", Temp32);
7293446Smrj                 break;
7303446Smrj 
7313446Smrj 
7323446Smrj             case DB_QWORD_DISPLAY:
7333446Smrj 
734*7851SDana.Myers@Sun.COM                 ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j]);
7353446Smrj                 AcpiOsPrintf ("%08X", Temp32);
7363446Smrj 
737*7851SDana.Myers@Sun.COM                 ACPI_MOVE_32_TO_32 (&Temp32, &Buffer[(ACPI_SIZE) i + j + 4]);
7383446Smrj                 AcpiOsPrintf ("%08X ", Temp32);
7393446Smrj                 break;
7403446Smrj             }
7413446Smrj 
742*7851SDana.Myers@Sun.COM             j += Display;
7433446Smrj         }
7443446Smrj 
7453446Smrj         /*
7463446Smrj          * Print the ASCII equivalent characters but watch out for the bad
7473446Smrj          * unprintable ones (printable chars are 0x20 through 0x7E)
7483446Smrj          */
7493446Smrj         AcpiOsPrintf (" ");
7503446Smrj         for (j = 0; j < 16; j++)
7513446Smrj         {
7523446Smrj             if (i + j >= Count)
7533446Smrj             {
7543446Smrj                 AcpiOsPrintf ("\n");
7553446Smrj                 return;
7563446Smrj             }
7573446Smrj 
758*7851SDana.Myers@Sun.COM             BufChar = Buffer[(ACPI_SIZE) i + j];
7593446Smrj             if (ACPI_IS_PRINT (BufChar))
7603446Smrj             {
7613446Smrj                 AcpiOsPrintf ("%c", BufChar);
7623446Smrj             }
7633446Smrj             else
7643446Smrj             {
7653446Smrj                 AcpiOsPrintf (".");
7663446Smrj             }
7673446Smrj         }
7683446Smrj 
7693446Smrj         /* Done with that line. */
7703446Smrj 
7713446Smrj         AcpiOsPrintf ("\n");
7723446Smrj         i += 16;
7733446Smrj     }
7743446Smrj 
7753446Smrj     return;
7763446Smrj }
7773446Smrj 
7783446Smrj 
7793446Smrj /*******************************************************************************
7803446Smrj  *
7813446Smrj  * FUNCTION:    AcpiUtDumpBuffer
7823446Smrj  *
7833446Smrj  * PARAMETERS:  Buffer              - Buffer to dump
7843446Smrj  *              Count               - Amount to dump, in bytes
7853446Smrj  *              Display             - BYTE, WORD, DWORD, or QWORD display
7863446Smrj  *              ComponentID         - Caller's component ID
7873446Smrj  *
7883446Smrj  * RETURN:      None
7893446Smrj  *
7903446Smrj  * DESCRIPTION: Generic dump buffer in both hex and ascii.
7913446Smrj  *
7923446Smrj  ******************************************************************************/
7933446Smrj 
7943446Smrj void
7953446Smrj AcpiUtDumpBuffer (
7963446Smrj     UINT8                   *Buffer,
7973446Smrj     UINT32                  Count,
7983446Smrj     UINT32                  Display,
7993446Smrj     UINT32                  ComponentId)
8003446Smrj {
8013446Smrj 
8023446Smrj     /* Only dump the buffer if tracing is enabled */
8033446Smrj 
8043446Smrj     if (!((ACPI_LV_TABLES & AcpiDbgLevel) &&
8053446Smrj         (ComponentId & AcpiDbgLayer)))
8063446Smrj     {
8073446Smrj         return;
8083446Smrj     }
8093446Smrj 
8103446Smrj     AcpiUtDumpBuffer2 (Buffer, Count, Display);
8113446Smrj }
8123446Smrj 
8133446Smrj 
814