utdebug.c revision 83174
11541Srgrimes/******************************************************************************
21541Srgrimes *
31541Srgrimes * Module Name: utdebug - Debug print routines
41541Srgrimes *              $Revision: 87 $
51541Srgrimes *
61541Srgrimes *****************************************************************************/
71541Srgrimes
81541Srgrimes/******************************************************************************
91541Srgrimes *
101541Srgrimes * 1. Copyright Notice
111541Srgrimes *
121541Srgrimes * Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
131541Srgrimes * All rights reserved.
141541Srgrimes *
151541Srgrimes * 2. License
161541Srgrimes *
171541Srgrimes * 2.1. This is your license from Intel Corp. under its intellectual property
181541Srgrimes * rights.  You may have additional license terms from the party that provided
191541Srgrimes * you this software, covering your right to use that party's intellectual
201541Srgrimes * property rights.
211541Srgrimes *
221541Srgrimes * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
231541Srgrimes * copy of the source code appearing in this file ("Covered Code") an
241541Srgrimes * irrevocable, perpetual, worldwide license under Intel's copyrights in the
251541Srgrimes * base code distributed originally by Intel ("Original Intel Code") to copy,
261541Srgrimes * make derivatives, distribute, use and display any portion of the Covered
271541Srgrimes * Code in any form, with the right to sublicense such rights; and
281541Srgrimes *
291541Srgrimes * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
301541Srgrimes * license (with the right to sublicense), under only those claims of Intel
311541Srgrimes * patents that are infringed by the Original Intel Code, to make, use, sell,
321541Srgrimes * offer to sell, and import the Covered Code and derivative works thereof
3310939Swollman * solely to the minimum extent necessary to exercise the above copyright
3413351Sguido * license, and in no event shall the patent license extend to any additions
351541Srgrimes * to or modifications of the Original Intel Code.  No other license or right
361541Srgrimes * is granted directly or by implication, estoppel or otherwise;
371541Srgrimes *
381549Srgrimes * The above copyright and patent license is granted only if the following
391541Srgrimes * conditions are met:
401541Srgrimes *
411541Srgrimes * 3. Conditions
421541Srgrimes *
431541Srgrimes * 3.1. Redistribution of Source with Rights to Further Distribute Source.
447280Swollman * Redistribution of source code of any substantial portion of the Covered
4512704Sphk * Code or modification with rights to further distribute source must include
4612704Sphk * the above Copyright Notice, the above License, this list of Conditions,
471541Srgrimes * and the following Disclaimer and Export Compliance provision.  In addition,
481541Srgrimes * Licensee must cause all Covered Code to which Licensee contributes to
491541Srgrimes * contain a file documenting the changes Licensee made to create that Covered
501541Srgrimes * Code and the date of any change.  Licensee must include in that file the
511541Srgrimes * documentation of any changes made by any predecessor Licensee.  Licensee
521541Srgrimes * must include a prominent statement that the modification is derived,
531541Srgrimes * directly or indirectly, from Original Intel Code.
541541Srgrimes *
551541Srgrimes * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
566363Sphk * Redistribution of source code of any substantial portion of the Covered
576363Sphk * Code or modification without rights to further distribute source must
581541Srgrimes * include the following Disclaimer and Export Compliance provision in the
597280Swollman * documentation and/or other materials provided with distribution.  In
607280Swollman * addition, Licensee may not authorize further sublicense of source of any
617280Swollman * portion of the Covered Code, and must include terms to the effect that the
627280Swollman * license from Licensee to its licensee is limited to the intellectual
637280Swollman * property embodied in the software Licensee provides to its licensee, and
647280Swollman * not to intellectual property embodied in modifications its licensee may
657280Swollman * make.
667280Swollman *
677280Swollman * 3.3. Redistribution of Executable. Redistribution in executable form of any
687280Swollman * substantial portion of the Covered Code or modification must reproduce the
697280Swollman * above Copyright Notice, and the following Disclaimer and Export Compliance
7012296Sphk * provision in the documentation and/or other materials provided with the
7112296Sphk * distribution.
7212296Sphk *
7312296Sphk * 3.4. Intel retains all right, title, and interest in and to the Original
741541Srgrimes * Intel Code.
7512704Sphk *
7612704Sphk * 3.5. Neither the name Intel nor any other trademark owned or controlled by
7712704Sphk * Intel shall be used in advertising or otherwise to promote the sale, use or
781541Srgrimes * other dealings in products derived from or relating to the Covered Code
791541Srgrimes * without prior written authorization from Intel.
801541Srgrimes *
811541Srgrimes * 4. Disclaimer and Export Compliance
821541Srgrimes *
831541Srgrimes * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
841549Srgrimes * HERE.  ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
851541Srgrimes * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT,  ASSISTANCE,
861541Srgrimes * INSTALLATION, TRAINING OR OTHER SERVICES.  INTEL WILL NOT PROVIDE ANY
871541Srgrimes * UPDATES, ENHANCEMENTS OR EXTENSIONS.  INTEL SPECIFICALLY DISCLAIMS ANY
881541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
891541Srgrimes * PARTICULAR PURPOSE.
901541Srgrimes *
911541Srgrimes * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
921541Srgrimes * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
931541Srgrimes * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
941541Srgrimes * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
951541Srgrimes * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
961541Srgrimes * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES.  THESE LIMITATIONS
971541Srgrimes * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
981541Srgrimes * LIMITED REMEDY.
991541Srgrimes *
1001541Srgrimes * 4.3. Licensee shall not export, either directly or indirectly, any of this
1011541Srgrimes * software or system incorporating such software without first obtaining any
1021541Srgrimes * required license or other approval from the U. S. Department of Commerce or
1031541Srgrimes * any other agency or department of the United States Government.  In the
1041541Srgrimes * event Licensee exports any such software from the United States or
1051541Srgrimes * re-exports any such software from a foreign destination, Licensee shall
1061541Srgrimes * ensure that the distribution and export/re-export of the software is in
1071541Srgrimes * compliance with all laws, regulations, orders, or other restrictions of the
1081549Srgrimes * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1091541Srgrimes * any of its subsidiaries will export/re-export any technical data, process,
1101541Srgrimes * software, or service, directly or indirectly, to any country for which the
1111541Srgrimes * United States government or any agency thereof requires an export license,
1121541Srgrimes * other governmental approval, or letter of assurance, without first obtaining
1131541Srgrimes * such license, approval or letter.
1141541Srgrimes *
1151541Srgrimes *****************************************************************************/
1161541Srgrimes
1171541Srgrimes#define __UTDEBUG_C__
1181541Srgrimes
1191541Srgrimes#include "acpi.h"
1201541Srgrimes
1211541Srgrimes#define _COMPONENT          ACPI_UTILITIES
1221541Srgrimes        MODULE_NAME         ("utdebug")
1231541Srgrimes
1241541Srgrimes
1251541SrgrimesUINT32          AcpiGbl_PrevThreadId = 0xFFFFFFFF;
1261541Srgrimeschar            *AcpiGbl_FnEntryStr = "----Entry";
1271541Srgrimeschar            *AcpiGbl_FnExitStr  = "----Exit-";
12812296Sphk
1291541Srgrimes
1301541Srgrimes
1311541Srgrimes#ifdef ACPI_DEBUG
1321541Srgrimes
1331541Srgrimes
1341541Srgrimes/*****************************************************************************
1351541Srgrimes *
1364127Swollman * FUNCTION:    AcpiUtInitStackPtrTrace
1371541Srgrimes *
1381541Srgrimes * PARAMETERS:  None
1391541Srgrimes *
1401541Srgrimes * RETURN:      None
1411541Srgrimes *
1421541Srgrimes * DESCRIPTION: Save the current stack pointer
14312704Sphk *
1441541Srgrimes ****************************************************************************/
1451541Srgrimes
1461541Srgrimesvoid
1471541SrgrimesAcpiUtInitStackPtrTrace (
1481541Srgrimes    void)
1491541Srgrimes{
1501549Srgrimes    UINT32              CurrentSp;
1511541Srgrimes
1521541Srgrimes
15310939Swollman    AcpiGbl_EntryStackPointer =  (UINT32) &CurrentSp;
1541541Srgrimes}
1551541Srgrimes
1561541Srgrimes
1571541Srgrimes/*****************************************************************************
1581541Srgrimes *
1591541Srgrimes * FUNCTION:    AcpiUtTrackStackPtr
1601541Srgrimes *
1611541Srgrimes * PARAMETERS:  None
1621541Srgrimes *
1631541Srgrimes * RETURN:      None
1641541Srgrimes *
1657280Swollman * DESCRIPTION: Save the current stack pointer
1661541Srgrimes *
1671541Srgrimes ****************************************************************************/
1681541Srgrimes
1691541Srgrimesvoid
1701541SrgrimesAcpiUtTrackStackPtr (
1711541Srgrimes    void)
1721541Srgrimes{
1731541Srgrimes    UINT32              CurrentSp;
1741541Srgrimes
1751541Srgrimes    CurrentSp = (UINT32) &CurrentSp;
1761541Srgrimes
1771541Srgrimes    if (CurrentSp < AcpiGbl_LowestStackPointer)
1781541Srgrimes    {
1798071Swollman        AcpiGbl_LowestStackPointer = CurrentSp;
1808071Swollman    }
1818071Swollman
1828071Swollman    if (AcpiGbl_NestingLevel > AcpiGbl_DeepestNesting)
1838071Swollman    {
1848071Swollman        AcpiGbl_DeepestNesting = AcpiGbl_NestingLevel;
1858071Swollman
1868876Srgrimes        if (AcpiGbl_DeepestNesting == 34)
1878071Swollman        {
1888071Swollman            AcpiOsPrintf ("hit deepest nesting\n");
1898071Swollman        }
1909563Swollman    }
1918071Swollman}
1921541Srgrimes
1931541Srgrimes
1941541Srgrimes/*****************************************************************************
1951541Srgrimes *
1961541Srgrimes * FUNCTION:    AcpiUtDebugPrint
1971541Srgrimes *
1981541Srgrimes * PARAMETERS:  DebugLevel          - Requested debug print level
1991541Srgrimes *              ProcName            - Caller's procedure name
2001541Srgrimes *              ModuleName          - Caller's module name (for error output)
2011541Srgrimes *              LineNumber          - Caller's line number (for error output)
2021541Srgrimes *              ComponentId         - Caller's component ID (for error output)
2031541Srgrimes *
2041541Srgrimes *              Format              - Printf format field
2051541Srgrimes *              ...                 - Optional printf arguments
2061541Srgrimes *
2071541Srgrimes * RETURN:      None
2081541Srgrimes *
2091541Srgrimes * DESCRIPTION: Print error message with prefix consisting of the module name,
2103311Sphk *              line number, and component ID.
2113311Sphk *
2121541Srgrimes ****************************************************************************/
2131541Srgrimes
2141541Srgrimesvoid
2151541SrgrimesAcpiUtDebugPrint (
2161541Srgrimes    UINT32                  RequestedDebugLevel,
2171541Srgrimes    UINT32                  LineNumber,
2183311Sphk    ACPI_DEBUG_PRINT_INFO   *DbgInfo,
2193311Sphk    char                    *Format,
2201541Srgrimes    ...)
2211541Srgrimes{
2221541Srgrimes    UINT32                  ThreadId;
2231541Srgrimes    va_list                 args;
2241541Srgrimes
2251541Srgrimes
2261541Srgrimes    /*
2271541Srgrimes     * Stay silent if the debug level or component ID is disabled
2281541Srgrimes     */
2291541Srgrimes    if (!(RequestedDebugLevel & AcpiDbgLevel) ||
2301541Srgrimes        !(DbgInfo->ComponentId & AcpiDbgLayer))
2311541Srgrimes    {
2321541Srgrimes        return;
2331541Srgrimes    }
2341541Srgrimes
2351541Srgrimes
2368090Spst    /*
2371541Srgrimes     * Thread tracking and context switch notification
2381541Srgrimes     */
2391541Srgrimes    ThreadId = AcpiOsGetThreadId ();
2401541Srgrimes
2411541Srgrimes    if (ThreadId != AcpiGbl_PrevThreadId)
2421541Srgrimes    {
2431541Srgrimes        if (ACPI_LV_THREADS & AcpiDbgLevel)
2441541Srgrimes        {
2451541Srgrimes            AcpiOsPrintf ("\n**** Context Switch from TID %X to TID %X ****\n\n",
2461541Srgrimes                AcpiGbl_PrevThreadId, ThreadId);
2471541Srgrimes        }
2481541Srgrimes
2491541Srgrimes        AcpiGbl_PrevThreadId = ThreadId;
2501541Srgrimes    }
2511541Srgrimes
2521541Srgrimes    /*
2531541Srgrimes     * Display the module name, current line number, thread ID (if requested),
2541541Srgrimes     * current procedure nesting level, and the current procedure name
2551541Srgrimes     */
2561541Srgrimes    AcpiOsPrintf ("%8s-%04d ", DbgInfo->ModuleName, LineNumber);
2571541Srgrimes
2581541Srgrimes    if (ACPI_LV_THREADS & AcpiDbgLevel)
2591541Srgrimes    {
2601541Srgrimes        AcpiOsPrintf ("[%04X] ", ThreadId, AcpiGbl_NestingLevel, DbgInfo->ProcName);
2611541Srgrimes    }
2621541Srgrimes
2631541Srgrimes    AcpiOsPrintf ("[%02d] %-22.22s: ", AcpiGbl_NestingLevel, DbgInfo->ProcName);
2641541Srgrimes
2651541Srgrimes
2661541Srgrimes    va_start (args, Format);
2671541Srgrimes    AcpiOsVprintf (Format, args);
2681541Srgrimes}
2691541Srgrimes
2701541Srgrimes
2711541Srgrimes/*****************************************************************************
2721541Srgrimes *
2731541Srgrimes * FUNCTION:    AcpiUtDebugPrintRaw
2741541Srgrimes *
2751541Srgrimes * PARAMETERS:  RequestedDebugLevel - Requested debug print level
2761541Srgrimes *              LineNumber          - Caller's line number
2771541Srgrimes *              DbgInfo             - Contains:
2781541Srgrimes *                  ProcName            - Caller's procedure name
2791541Srgrimes *                  ModuleName          - Caller's module name
2801541Srgrimes *                  ComponentId         - Caller's component ID
2811541Srgrimes *              Format              - Printf format field
2821541Srgrimes *              ...                 - Optional printf arguments
2831541Srgrimes *
2841541Srgrimes * RETURN:      None
2851541Srgrimes *
2861541Srgrimes * DESCRIPTION: Print message with no headers.  Has same interface as
2871541Srgrimes *              DebugPrint so that the same macros can be used.
2881541Srgrimes *
2891541Srgrimes ****************************************************************************/
2901541Srgrimes
2911541Srgrimesvoid
2921541SrgrimesAcpiUtDebugPrintRaw (
2931541Srgrimes    UINT32                  RequestedDebugLevel,
2941541Srgrimes    UINT32                  LineNumber,
2951541Srgrimes    ACPI_DEBUG_PRINT_INFO   *DbgInfo,
2961541Srgrimes    char                    *Format,
2971541Srgrimes    ...)
2981541Srgrimes{
2991541Srgrimes    va_list                 args;
3001541Srgrimes
3011541Srgrimes
3021541Srgrimes    if (!(RequestedDebugLevel & AcpiDbgLevel) ||
3031541Srgrimes        !(DbgInfo->ComponentId & AcpiDbgLayer))
3041541Srgrimes    {
3051541Srgrimes        return;
3061541Srgrimes    }
3071541Srgrimes
3081541Srgrimes    va_start (args, Format);
3091541Srgrimes
3101541Srgrimes    AcpiOsVprintf (Format, args);
3111541Srgrimes}
3121541Srgrimes
3131541Srgrimes
3141541Srgrimes/*****************************************************************************
3151541Srgrimes *
3161541Srgrimes * FUNCTION:    AcpiUtTrace
3171541Srgrimes *
3181541Srgrimes * PARAMETERS:  LineNumber          - Caller's line number
3191541Srgrimes *              DbgInfo             - Contains:
3201541Srgrimes *                  ProcName            - Caller's procedure name
3211541Srgrimes *                  ModuleName          - Caller's module name
3221541Srgrimes *                  ComponentId         - Caller's component ID
3231541Srgrimes *
3241541Srgrimes * RETURN:      None
3251541Srgrimes *
3261541Srgrimes * DESCRIPTION: Function entry trace.  Prints only if TRACE_FUNCTIONS bit is
3271541Srgrimes *              set in DebugLevel
3281541Srgrimes *
3291541Srgrimes ****************************************************************************/
3301541Srgrimes
3311541Srgrimesvoid
3321541SrgrimesAcpiUtTrace (
3331541Srgrimes    UINT32                  LineNumber,
3341541Srgrimes    ACPI_DEBUG_PRINT_INFO   *DbgInfo)
3351541Srgrimes{
3361541Srgrimes
3371541Srgrimes    AcpiGbl_NestingLevel++;
3381541Srgrimes    AcpiUtTrackStackPtr ();
3391541Srgrimes
3401541Srgrimes    AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo,
3411541Srgrimes            "%s\n", AcpiGbl_FnEntryStr);
3421541Srgrimes}
3431541Srgrimes
3447280Swollman
3457280Swollman/*****************************************************************************
3467280Swollman *
3477280Swollman * FUNCTION:    AcpiUtTracePtr
3481541Srgrimes *
3491541Srgrimes * PARAMETERS:  LineNumber          - Caller's line number
3501541Srgrimes *              DbgInfo             - Contains:
3511541Srgrimes *                  ProcName            - Caller's procedure name
3521541Srgrimes *                  ModuleName          - Caller's module name
3531541Srgrimes *                  ComponentId         - Caller's component ID
3541541Srgrimes *              Pointer             - Pointer to display
3551541Srgrimes *
3561541Srgrimes * RETURN:      None
3571541Srgrimes *
3581541Srgrimes * DESCRIPTION: Function entry trace.  Prints only if TRACE_FUNCTIONS bit is
3591541Srgrimes *              set in DebugLevel
3601541Srgrimes *
3611541Srgrimes ****************************************************************************/
3621541Srgrimes
3631541Srgrimesvoid
3641541SrgrimesAcpiUtTracePtr (
3651541Srgrimes    UINT32                  LineNumber,
3661541Srgrimes    ACPI_DEBUG_PRINT_INFO   *DbgInfo,
3671541Srgrimes    void                    *Pointer)
3681541Srgrimes{
3691541Srgrimes    AcpiGbl_NestingLevel++;
3701541Srgrimes    AcpiUtTrackStackPtr ();
3717280Swollman
3727280Swollman    AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo,
3737280Swollman            "%s %p\n", AcpiGbl_FnEntryStr, Pointer);
3747280Swollman}
3757280Swollman
3767280Swollman
3777280Swollman/*****************************************************************************
3787280Swollman *
3797280Swollman * FUNCTION:    AcpiUtTraceStr
3807280Swollman *
3817280Swollman * PARAMETERS:  LineNumber          - Caller's line number
3827280Swollman *              DbgInfo             - Contains:
3837280Swollman *                  ProcName            - Caller's procedure name
3847280Swollman *                  ModuleName          - Caller's module name
3857280Swollman *                  ComponentId         - Caller's component ID
3867280Swollman *              String              - Additional string to display
3877280Swollman *
3888876Srgrimes * RETURN:      None
3897280Swollman *
3907280Swollman * DESCRIPTION: Function entry trace.  Prints only if TRACE_FUNCTIONS bit is
3917280Swollman *              set in DebugLevel
3927280Swollman *
3937280Swollman ****************************************************************************/
3947280Swollman
3957280Swollmanvoid
3967280SwollmanAcpiUtTraceStr (
3977280Swollman    UINT32                  LineNumber,
3987280Swollman    ACPI_DEBUG_PRINT_INFO   *DbgInfo,
3997280Swollman    NATIVE_CHAR             *String)
4007280Swollman{
4017280Swollman
4027280Swollman    AcpiGbl_NestingLevel++;
4038876Srgrimes    AcpiUtTrackStackPtr ();
4047280Swollman
4057280Swollman    AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo,
4067280Swollman            "%s %s\n", AcpiGbl_FnEntryStr, String);
4077280Swollman}
4087280Swollman
4097280Swollman
4107280Swollman/*****************************************************************************
4117280Swollman *
4127280Swollman * FUNCTION:    AcpiUtTraceU32
4137280Swollman *
4148876Srgrimes * PARAMETERS:  LineNumber          - Caller's line number
4151541Srgrimes *              DbgInfo             - Contains:
4161541Srgrimes *                  ProcName            - Caller's procedure name
4171541Srgrimes *                  ModuleName          - Caller's module name
4181541Srgrimes *                  ComponentId         - Caller's component ID
4191541Srgrimes *              Integer             - Integer to display
4201541Srgrimes *
4211541Srgrimes * RETURN:      None
4221541Srgrimes *
4231541Srgrimes * DESCRIPTION: Function entry trace.  Prints only if TRACE_FUNCTIONS bit is
4241541Srgrimes *              set in DebugLevel
4251541Srgrimes *
4261541Srgrimes ****************************************************************************/
4271541Srgrimes
4281541Srgrimesvoid
42912296SphkAcpiUtTraceU32 (
4301541Srgrimes    UINT32                  LineNumber,
4311541Srgrimes    ACPI_DEBUG_PRINT_INFO   *DbgInfo,
4321541Srgrimes    UINT32                  Integer)
4331541Srgrimes{
4341541Srgrimes
4351541Srgrimes    AcpiGbl_NestingLevel++;
4361541Srgrimes    AcpiUtTrackStackPtr ();
4371541Srgrimes
4381541Srgrimes    AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo,
4391541Srgrimes            "%s %08X\n", AcpiGbl_FnEntryStr, Integer);
4401541Srgrimes}
4411541Srgrimes
4421541Srgrimes
4431541Srgrimes/*****************************************************************************
4441541Srgrimes *
4451541Srgrimes * FUNCTION:    AcpiUtExit
4461541Srgrimes *
4471541Srgrimes * PARAMETERS:  LineNumber          - Caller's line number
44812296Sphk *              DbgInfo             - Contains:
4491541Srgrimes *                  ProcName            - Caller's procedure name
4501541Srgrimes *                  ModuleName          - Caller's module name
4511541Srgrimes *                  ComponentId         - Caller's component ID
4521541Srgrimes *
4531541Srgrimes * RETURN:      None
4541541Srgrimes *
4551541Srgrimes * DESCRIPTION: Function exit trace.  Prints only if TRACE_FUNCTIONS bit is
4561541Srgrimes *              set in DebugLevel
4572112Swollman *
4587280Swollman ****************************************************************************/
4591541Srgrimes
4601541Srgrimesvoid
4611541SrgrimesAcpiUtExit (
4621541Srgrimes    UINT32                  LineNumber,
4631541Srgrimes    ACPI_DEBUG_PRINT_INFO   *DbgInfo)
4641541Srgrimes{
4651541Srgrimes
4661541Srgrimes    AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo,
4671541Srgrimes            "%s\n", AcpiGbl_FnExitStr);
4681541Srgrimes
4691541Srgrimes    AcpiGbl_NestingLevel--;
4701541Srgrimes}
4711541Srgrimes
4721541Srgrimes
4731541Srgrimes/*****************************************************************************
4741541Srgrimes *
4751541Srgrimes * FUNCTION:    AcpiUtStatusExit
4761541Srgrimes *
4771541Srgrimes * PARAMETERS:  LineNumber          - Caller's line number
4781541Srgrimes *              DbgInfo             - Contains:
4791541Srgrimes *                  ProcName            - Caller's procedure name
4801541Srgrimes *                  ModuleName          - Caller's module name
4811541Srgrimes *                  ComponentId         - Caller's component ID
4821541Srgrimes *              Status              - Exit status code
4831541Srgrimes *
4841541Srgrimes * RETURN:      None
4851541Srgrimes *
4861541Srgrimes * DESCRIPTION: Function exit trace.  Prints only if TRACE_FUNCTIONS bit is
4871541Srgrimes *              set in DebugLevel.  Prints exit status also.
4881541Srgrimes *
4891541Srgrimes ****************************************************************************/
4901541Srgrimes
4911541Srgrimesvoid
4921541SrgrimesAcpiUtStatusExit (
4931541Srgrimes    UINT32                  LineNumber,
4941541Srgrimes    ACPI_DEBUG_PRINT_INFO   *DbgInfo,
4951541Srgrimes    ACPI_STATUS             Status)
4961541Srgrimes{
4971541Srgrimes
4981541Srgrimes    if (ACPI_SUCCESS (Status))
4991541Srgrimes    {
5001541Srgrimes        AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo,
5011541Srgrimes                "%s %s\n", AcpiGbl_FnExitStr,
5021541Srgrimes                AcpiFormatException (Status));
5031541Srgrimes    }
5041541Srgrimes    else
5051541Srgrimes    {
5061541Srgrimes        AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo,
5071541Srgrimes                "%s ****Exception****: %s\n", AcpiGbl_FnExitStr,
5081541Srgrimes                AcpiFormatException (Status));
5091541Srgrimes    }
5101541Srgrimes
5111541Srgrimes    AcpiGbl_NestingLevel--;
5121541Srgrimes}
5131541Srgrimes
5141541Srgrimes
5151541Srgrimes/*****************************************************************************
5161541Srgrimes *
5177280Swollman * FUNCTION:    AcpiUtValueExit
5187280Swollman *
5191541Srgrimes * PARAMETERS:  LineNumber          - Caller's line number
5201541Srgrimes *              DbgInfo             - Contains:
5211541Srgrimes *                  ProcName            - Caller's procedure name
5221541Srgrimes *                  ModuleName          - Caller's module name
5231541Srgrimes *                  ComponentId         - Caller's component ID
5241541Srgrimes *              Value               - Value to be printed with exit msg
5251541Srgrimes *
5267280Swollman * RETURN:      None
5277280Swollman *
5288876Srgrimes * DESCRIPTION: Function exit trace.  Prints only if TRACE_FUNCTIONS bit is
5297280Swollman *              set in DebugLevel.  Prints exit value also.
5307280Swollman *
5317280Swollman ****************************************************************************/
5327280Swollman
5337280Swollmanvoid
5347280SwollmanAcpiUtValueExit (
5358876Srgrimes    UINT32                  LineNumber,
5368876Srgrimes    ACPI_DEBUG_PRINT_INFO   *DbgInfo,
5377280Swollman    ACPI_INTEGER            Value)
5387280Swollman{
5397280Swollman
5407280Swollman    AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo,
5418876Srgrimes            "%s %08X\n", AcpiGbl_FnExitStr, Value);
5427280Swollman
5437280Swollman    AcpiGbl_NestingLevel--;
5447280Swollman}
5457280Swollman
5467280Swollman
5477280Swollman/*****************************************************************************
5487280Swollman *
5497280Swollman * FUNCTION:    AcpiUtPtrExit
5501541Srgrimes *
5511541Srgrimes * PARAMETERS:  LineNumber          - Caller's line number
5521541Srgrimes *              DbgInfo             - Contains:
5531541Srgrimes *                  ProcName            - Caller's procedure name
5541541Srgrimes *                  ModuleName          - Caller's module name
5551541Srgrimes *                  ComponentId         - Caller's component ID
5561541Srgrimes *              Value               - Value to be printed with exit msg
5571541Srgrimes *
5581541Srgrimes * RETURN:      None
5591541Srgrimes *
5601549Srgrimes * DESCRIPTION: Function exit trace.  Prints only if TRACE_FUNCTIONS bit is
5611541Srgrimes *              set in DebugLevel.  Prints exit value also.
5621541Srgrimes *
5631541Srgrimes ****************************************************************************/
5641541Srgrimes
5651541Srgrimesvoid
5661541SrgrimesAcpiUtPtrExit (
5671541Srgrimes    UINT32                  LineNumber,
5681541Srgrimes    ACPI_DEBUG_PRINT_INFO   *DbgInfo,
5691541Srgrimes    UINT8                   *Ptr)
5701541Srgrimes{
5711541Srgrimes
5721541Srgrimes    AcpiUtDebugPrint (ACPI_LV_FUNCTIONS, LineNumber, DbgInfo,
5731541Srgrimes            "%s %p\n", AcpiGbl_FnExitStr, Ptr);
5741541Srgrimes
5751541Srgrimes    AcpiGbl_NestingLevel--;
5761541Srgrimes}
5771541Srgrimes
5781541Srgrimes#endif
5791541Srgrimes
5801541Srgrimes
5811541Srgrimes
5821541Srgrimes
5831541Srgrimes/*****************************************************************************
5841541Srgrimes *
5851541Srgrimes * FUNCTION:    AcpiUtDumpBuffer
58613351Sguido *
58713351Sguido * PARAMETERS:  Buffer              - Buffer to dump
58813351Sguido *              Count               - Amount to dump, in bytes
58913351Sguido *              Display             - BYTE, WORD, DWORD, or QWORD display
59013351Sguido *              ComponentID         - Caller's component ID
59113351Sguido *
59213351Sguido * RETURN:      None
5931541Srgrimes *
5941541Srgrimes * DESCRIPTION: Generic dump buffer in both hex and ascii.
5951541Srgrimes *
5961541Srgrimes ****************************************************************************/
5971541Srgrimes
5981541Srgrimesvoid
5991541SrgrimesAcpiUtDumpBuffer (
6001541Srgrimes    UINT8                   *Buffer,
6011541Srgrimes    UINT32                  Count,
6021541Srgrimes    UINT32                  Display,
6031541Srgrimes    UINT32                  ComponentId)
6041541Srgrimes{
6051541Srgrimes    UINT32                  i = 0;
6061541Srgrimes    UINT32                  j;
6071541Srgrimes    UINT32                  Temp32;
6081541Srgrimes    UINT8                   BufChar;
6091541Srgrimes
6101541Srgrimes
6111541Srgrimes    /* Only dump the buffer if tracing is enabled */
6121541Srgrimes
6131541Srgrimes    if (!((ACPI_LV_TABLES & AcpiDbgLevel) &&
6141541Srgrimes        (ComponentId & AcpiDbgLayer)))
6151541Srgrimes    {
6161541Srgrimes        return;
6171541Srgrimes    }
6181541Srgrimes
6191541Srgrimes
6201541Srgrimes    /*
6211541Srgrimes     * Nasty little dump buffer routine!
6221541Srgrimes     */
6231541Srgrimes    while (i < Count)
6241541Srgrimes    {
6251541Srgrimes        /* Print current offset */
6261541Srgrimes
6271541Srgrimes        AcpiOsPrintf ("%05X    ", i);
6281541Srgrimes
6291541Srgrimes
6301541Srgrimes        /* Print 16 hex chars */
6311541Srgrimes
6321541Srgrimes        for (j = 0; j < 16;)
6331541Srgrimes        {
6341541Srgrimes            if (i + j >= Count)
6351541Srgrimes            {
6361541Srgrimes                AcpiOsPrintf ("\n");
6371541Srgrimes                return;
6381541Srgrimes            }
6391541Srgrimes
6401541Srgrimes            /* Make sure that the INT8 doesn't get sign-extended! */
6417280Swollman
6427280Swollman            switch (Display)
6437280Swollman            {
6441541Srgrimes            /* Default is BYTE display */
6451541Srgrimes
6461541Srgrimes            default:
6471541Srgrimes
6481541Srgrimes                AcpiOsPrintf ("%02X ",
6491541Srgrimes                        *((UINT8 *) &Buffer[i + j]));
6501541Srgrimes                j += 1;
6511541Srgrimes                break;
6527280Swollman
6537280Swollman
6541541Srgrimes            case DB_WORD_DISPLAY:
6551541Srgrimes
6561541Srgrimes                MOVE_UNALIGNED16_TO_32 (&Temp32,
6571541Srgrimes                                        &Buffer[i + j]);
6581541Srgrimes                AcpiOsPrintf ("%04X ", Temp32);
6591541Srgrimes                j += 2;
6601541Srgrimes                break;
6611541Srgrimes
6621541Srgrimes
6631541Srgrimes            case DB_DWORD_DISPLAY:
6641541Srgrimes
6651541Srgrimes                MOVE_UNALIGNED32_TO_32 (&Temp32,
6661541Srgrimes                                        &Buffer[i + j]);
6671541Srgrimes                AcpiOsPrintf ("%08X ", Temp32);
6681541Srgrimes                j += 4;
6691541Srgrimes                break;
6701549Srgrimes
6711541Srgrimes
6721541Srgrimes            case DB_QWORD_DISPLAY:
6731541Srgrimes
6741541Srgrimes                MOVE_UNALIGNED32_TO_32 (&Temp32,
6751541Srgrimes                                        &Buffer[i + j]);
6761541Srgrimes                AcpiOsPrintf ("%08X", Temp32);
6771541Srgrimes
6781541Srgrimes                MOVE_UNALIGNED32_TO_32 (&Temp32,
6791541Srgrimes                                        &Buffer[i + j + 4]);
6801541Srgrimes                AcpiOsPrintf ("%08X ", Temp32);
6811541Srgrimes                j += 8;
6821541Srgrimes                break;
6831541Srgrimes            }
6841541Srgrimes        }
6851541Srgrimes
6867280Swollman
6877280Swollman        /*
6887280Swollman         * Print the ASCII equivalent characters
6891541Srgrimes         * But watch out for the bad unprintable ones...
6901541Srgrimes         */
6911541Srgrimes
6921541Srgrimes        for (j = 0; j < 16; j++)
6931541Srgrimes        {
6941541Srgrimes            if (i + j >= Count)
6951541Srgrimes            {
6961541Srgrimes                AcpiOsPrintf ("\n");
6971541Srgrimes                return;
6981541Srgrimes            }
6991541Srgrimes
7001541Srgrimes            BufChar = Buffer[i + j];
7011541Srgrimes            if ((BufChar > 0x1F && BufChar < 0x2E) ||
702                (BufChar > 0x2F && BufChar < 0x61) ||
703                (BufChar > 0x60 && BufChar < 0x7F))
704            {
705                AcpiOsPrintf ("%c", BufChar);
706            }
707            else
708            {
709                AcpiOsPrintf (".");
710            }
711        }
712
713        /* Done with that line. */
714
715        AcpiOsPrintf ("\n");
716        i += 16;
717    }
718
719    return;
720}
721
722