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