Home | History | Annotate | Line # | Download | only in executer
exdebug.c revision 1.1.1.6
      1      1.1    jruoho /******************************************************************************
      2      1.1    jruoho  *
      3      1.1    jruoho  * Module Name: exdebug - Support for stores to the AML Debug Object
      4      1.1    jruoho  *
      5      1.1    jruoho  *****************************************************************************/
      6      1.1    jruoho 
      7  1.1.1.2    jruoho /*
      8  1.1.1.5  christos  * Copyright (C) 2000 - 2015, Intel Corp.
      9      1.1    jruoho  * All rights reserved.
     10      1.1    jruoho  *
     11  1.1.1.2    jruoho  * Redistribution and use in source and binary forms, with or without
     12  1.1.1.2    jruoho  * modification, are permitted provided that the following conditions
     13  1.1.1.2    jruoho  * are met:
     14  1.1.1.2    jruoho  * 1. Redistributions of source code must retain the above copyright
     15  1.1.1.2    jruoho  *    notice, this list of conditions, and the following disclaimer,
     16  1.1.1.2    jruoho  *    without modification.
     17  1.1.1.2    jruoho  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
     18  1.1.1.2    jruoho  *    substantially similar to the "NO WARRANTY" disclaimer below
     19  1.1.1.2    jruoho  *    ("Disclaimer") and any redistribution must be conditioned upon
     20  1.1.1.2    jruoho  *    including a substantially similar Disclaimer requirement for further
     21  1.1.1.2    jruoho  *    binary redistribution.
     22  1.1.1.2    jruoho  * 3. Neither the names of the above-listed copyright holders nor the names
     23  1.1.1.2    jruoho  *    of any contributors may be used to endorse or promote products derived
     24  1.1.1.2    jruoho  *    from this software without specific prior written permission.
     25  1.1.1.2    jruoho  *
     26  1.1.1.2    jruoho  * Alternatively, this software may be distributed under the terms of the
     27  1.1.1.2    jruoho  * GNU General Public License ("GPL") version 2 as published by the Free
     28  1.1.1.2    jruoho  * Software Foundation.
     29  1.1.1.2    jruoho  *
     30  1.1.1.2    jruoho  * NO WARRANTY
     31  1.1.1.2    jruoho  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     32  1.1.1.2    jruoho  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     33  1.1.1.2    jruoho  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
     34  1.1.1.2    jruoho  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     35  1.1.1.2    jruoho  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     36  1.1.1.2    jruoho  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     37  1.1.1.2    jruoho  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     38  1.1.1.2    jruoho  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     39  1.1.1.2    jruoho  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
     40  1.1.1.2    jruoho  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     41  1.1.1.2    jruoho  * POSSIBILITY OF SUCH DAMAGES.
     42  1.1.1.2    jruoho  */
     43      1.1    jruoho 
     44      1.1    jruoho #include "acpi.h"
     45      1.1    jruoho #include "accommon.h"
     46  1.1.1.6  christos #include "acnamesp.h"
     47      1.1    jruoho #include "acinterp.h"
     48  1.1.1.6  christos #include "acparser.h"
     49      1.1    jruoho 
     50      1.1    jruoho 
     51      1.1    jruoho #define _COMPONENT          ACPI_EXECUTER
     52      1.1    jruoho         ACPI_MODULE_NAME    ("exdebug")
     53      1.1    jruoho 
     54      1.1    jruoho 
     55  1.1.1.6  christos static ACPI_OPERAND_OBJECT  *AcpiGbl_TraceMethodObject = NULL;
     56  1.1.1.6  christos 
     57  1.1.1.6  christos /* Local prototypes */
     58  1.1.1.6  christos 
     59  1.1.1.6  christos #ifdef ACPI_DEBUG_OUTPUT
     60  1.1.1.6  christos static const char *
     61  1.1.1.6  christos AcpiExGetTraceEventName (
     62  1.1.1.6  christos     ACPI_TRACE_EVENT_TYPE   Type);
     63  1.1.1.6  christos #endif
     64  1.1.1.6  christos 
     65  1.1.1.6  christos 
     66      1.1    jruoho #ifndef ACPI_NO_ERROR_MESSAGES
     67      1.1    jruoho /*******************************************************************************
     68      1.1    jruoho  *
     69      1.1    jruoho  * FUNCTION:    AcpiExDoDebugObject
     70      1.1    jruoho  *
     71      1.1    jruoho  * PARAMETERS:  SourceDesc          - Object to be output to "Debug Object"
     72      1.1    jruoho  *              Level               - Indentation level (used for packages)
     73      1.1    jruoho  *              Index               - Current package element, zero if not pkg
     74      1.1    jruoho  *
     75      1.1    jruoho  * RETURN:      None
     76      1.1    jruoho  *
     77      1.1    jruoho  * DESCRIPTION: Handles stores to the AML Debug Object. For example:
     78      1.1    jruoho  *              Store(INT1, Debug)
     79      1.1    jruoho  *
     80      1.1    jruoho  * This function is not compiled if ACPI_NO_ERROR_MESSAGES is set.
     81      1.1    jruoho  *
     82      1.1    jruoho  * This function is only enabled if AcpiGbl_EnableAmlDebugObject is set, or
     83      1.1    jruoho  * if ACPI_LV_DEBUG_OBJECT is set in the AcpiDbgLevel. Thus, in the normal
     84      1.1    jruoho  * operational case, stores to the debug object are ignored but can be easily
     85      1.1    jruoho  * enabled if necessary.
     86      1.1    jruoho  *
     87      1.1    jruoho  ******************************************************************************/
     88      1.1    jruoho 
     89      1.1    jruoho void
     90      1.1    jruoho AcpiExDoDebugObject (
     91      1.1    jruoho     ACPI_OPERAND_OBJECT     *SourceDesc,
     92      1.1    jruoho     UINT32                  Level,
     93      1.1    jruoho     UINT32                  Index)
     94      1.1    jruoho {
     95      1.1    jruoho     UINT32                  i;
     96  1.1.1.4  christos     UINT32                  Timer;
     97  1.1.1.6  christos     ACPI_OPERAND_OBJECT     *ObjectDesc;
     98  1.1.1.6  christos     UINT32                  Value;
     99      1.1    jruoho 
    100      1.1    jruoho 
    101      1.1    jruoho     ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc);
    102      1.1    jruoho 
    103      1.1    jruoho 
    104      1.1    jruoho     /* Output must be enabled via the DebugObject global or the DbgLevel */
    105      1.1    jruoho 
    106      1.1    jruoho     if (!AcpiGbl_EnableAmlDebugObject &&
    107      1.1    jruoho         !(AcpiDbgLevel & ACPI_LV_DEBUG_OBJECT))
    108      1.1    jruoho     {
    109      1.1    jruoho         return_VOID;
    110      1.1    jruoho     }
    111      1.1    jruoho 
    112      1.1    jruoho     /*
    113  1.1.1.4  christos      * We will emit the current timer value (in microseconds) with each
    114  1.1.1.4  christos      * debug output. Only need the lower 26 bits. This allows for 67
    115  1.1.1.4  christos      * million microseconds or 67 seconds before rollover.
    116  1.1.1.4  christos      */
    117  1.1.1.4  christos     Timer = ((UINT32) AcpiOsGetTimer () / 10); /* (100 nanoseconds to microseconds) */
    118  1.1.1.4  christos     Timer &= 0x03FFFFFF;
    119  1.1.1.4  christos 
    120  1.1.1.4  christos     /*
    121      1.1    jruoho      * Print line header as long as we are not in the middle of an
    122      1.1    jruoho      * object display
    123      1.1    jruoho      */
    124      1.1    jruoho     if (!((Level > 0) && Index == 0))
    125      1.1    jruoho     {
    126  1.1.1.4  christos         AcpiOsPrintf ("[ACPI Debug %.8u] %*s", Timer, Level, " ");
    127      1.1    jruoho     }
    128      1.1    jruoho 
    129      1.1    jruoho     /* Display the index for package output only */
    130      1.1    jruoho 
    131      1.1    jruoho     if (Index > 0)
    132      1.1    jruoho     {
    133      1.1    jruoho        AcpiOsPrintf ("(%.2u) ", Index-1);
    134      1.1    jruoho     }
    135      1.1    jruoho 
    136      1.1    jruoho     if (!SourceDesc)
    137      1.1    jruoho     {
    138      1.1    jruoho         AcpiOsPrintf ("[Null Object]\n");
    139      1.1    jruoho         return_VOID;
    140      1.1    jruoho     }
    141      1.1    jruoho 
    142      1.1    jruoho     if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND)
    143      1.1    jruoho     {
    144      1.1    jruoho         AcpiOsPrintf ("%s ", AcpiUtGetObjectTypeName (SourceDesc));
    145      1.1    jruoho 
    146      1.1    jruoho         if (!AcpiUtValidInternalObject (SourceDesc))
    147      1.1    jruoho         {
    148      1.1    jruoho            AcpiOsPrintf ("%p, Invalid Internal Object!\n", SourceDesc);
    149      1.1    jruoho            return_VOID;
    150      1.1    jruoho         }
    151      1.1    jruoho     }
    152      1.1    jruoho     else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED)
    153      1.1    jruoho     {
    154      1.1    jruoho         AcpiOsPrintf ("%s: %p\n",
    155      1.1    jruoho             AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type),
    156      1.1    jruoho             SourceDesc);
    157      1.1    jruoho         return_VOID;
    158      1.1    jruoho     }
    159      1.1    jruoho     else
    160      1.1    jruoho     {
    161      1.1    jruoho         return_VOID;
    162      1.1    jruoho     }
    163      1.1    jruoho 
    164      1.1    jruoho     /* SourceDesc is of type ACPI_DESC_TYPE_OPERAND */
    165      1.1    jruoho 
    166      1.1    jruoho     switch (SourceDesc->Common.Type)
    167      1.1    jruoho     {
    168      1.1    jruoho     case ACPI_TYPE_INTEGER:
    169      1.1    jruoho 
    170      1.1    jruoho         /* Output correct integer width */
    171      1.1    jruoho 
    172      1.1    jruoho         if (AcpiGbl_IntegerByteWidth == 4)
    173      1.1    jruoho         {
    174      1.1    jruoho             AcpiOsPrintf ("0x%8.8X\n",
    175      1.1    jruoho                 (UINT32) SourceDesc->Integer.Value);
    176      1.1    jruoho         }
    177      1.1    jruoho         else
    178      1.1    jruoho         {
    179      1.1    jruoho             AcpiOsPrintf ("0x%8.8X%8.8X\n",
    180      1.1    jruoho                 ACPI_FORMAT_UINT64 (SourceDesc->Integer.Value));
    181      1.1    jruoho         }
    182      1.1    jruoho         break;
    183      1.1    jruoho 
    184      1.1    jruoho     case ACPI_TYPE_BUFFER:
    185      1.1    jruoho 
    186      1.1    jruoho         AcpiOsPrintf ("[0x%.2X]\n", (UINT32) SourceDesc->Buffer.Length);
    187  1.1.1.3  christos         AcpiUtDumpBuffer (SourceDesc->Buffer.Pointer,
    188      1.1    jruoho             (SourceDesc->Buffer.Length < 256) ?
    189  1.1.1.3  christos                 SourceDesc->Buffer.Length : 256, DB_BYTE_DISPLAY, 0);
    190      1.1    jruoho         break;
    191      1.1    jruoho 
    192      1.1    jruoho     case ACPI_TYPE_STRING:
    193      1.1    jruoho 
    194      1.1    jruoho         AcpiOsPrintf ("[0x%.2X] \"%s\"\n",
    195      1.1    jruoho             SourceDesc->String.Length, SourceDesc->String.Pointer);
    196      1.1    jruoho         break;
    197      1.1    jruoho 
    198      1.1    jruoho     case ACPI_TYPE_PACKAGE:
    199      1.1    jruoho 
    200      1.1    jruoho         AcpiOsPrintf ("[Contains 0x%.2X Elements]\n",
    201      1.1    jruoho             SourceDesc->Package.Count);
    202      1.1    jruoho 
    203      1.1    jruoho         /* Output the entire contents of the package */
    204      1.1    jruoho 
    205      1.1    jruoho         for (i = 0; i < SourceDesc->Package.Count; i++)
    206      1.1    jruoho         {
    207      1.1    jruoho             AcpiExDoDebugObject (SourceDesc->Package.Elements[i],
    208      1.1    jruoho                 Level+4, i+1);
    209      1.1    jruoho         }
    210      1.1    jruoho         break;
    211      1.1    jruoho 
    212      1.1    jruoho     case ACPI_TYPE_LOCAL_REFERENCE:
    213      1.1    jruoho 
    214      1.1    jruoho         AcpiOsPrintf ("[%s] ", AcpiUtGetReferenceName (SourceDesc));
    215      1.1    jruoho 
    216      1.1    jruoho         /* Decode the reference */
    217      1.1    jruoho 
    218      1.1    jruoho         switch (SourceDesc->Reference.Class)
    219      1.1    jruoho         {
    220      1.1    jruoho         case ACPI_REFCLASS_INDEX:
    221      1.1    jruoho 
    222      1.1    jruoho             AcpiOsPrintf ("0x%X\n", SourceDesc->Reference.Value);
    223      1.1    jruoho             break;
    224      1.1    jruoho 
    225      1.1    jruoho         case ACPI_REFCLASS_TABLE:
    226      1.1    jruoho 
    227      1.1    jruoho             /* Case for DdbHandle */
    228      1.1    jruoho 
    229      1.1    jruoho             AcpiOsPrintf ("Table Index 0x%X\n", SourceDesc->Reference.Value);
    230  1.1.1.3  christos             return_VOID;
    231      1.1    jruoho 
    232      1.1    jruoho         default:
    233  1.1.1.3  christos 
    234      1.1    jruoho             break;
    235      1.1    jruoho         }
    236      1.1    jruoho 
    237      1.1    jruoho         AcpiOsPrintf ("  ");
    238      1.1    jruoho 
    239      1.1    jruoho         /* Check for valid node first, then valid object */
    240      1.1    jruoho 
    241      1.1    jruoho         if (SourceDesc->Reference.Node)
    242      1.1    jruoho         {
    243      1.1    jruoho             if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Node) !=
    244      1.1    jruoho                     ACPI_DESC_TYPE_NAMED)
    245      1.1    jruoho             {
    246      1.1    jruoho                 AcpiOsPrintf (" %p - Not a valid namespace node\n",
    247      1.1    jruoho                     SourceDesc->Reference.Node);
    248      1.1    jruoho             }
    249      1.1    jruoho             else
    250      1.1    jruoho             {
    251      1.1    jruoho                 AcpiOsPrintf ("Node %p [%4.4s] ", SourceDesc->Reference.Node,
    252      1.1    jruoho                     (SourceDesc->Reference.Node)->Name.Ascii);
    253      1.1    jruoho 
    254      1.1    jruoho                 switch ((SourceDesc->Reference.Node)->Type)
    255      1.1    jruoho                 {
    256      1.1    jruoho                 /* These types have no attached object */
    257      1.1    jruoho 
    258      1.1    jruoho                 case ACPI_TYPE_DEVICE:
    259      1.1    jruoho                     AcpiOsPrintf ("Device\n");
    260      1.1    jruoho                     break;
    261      1.1    jruoho 
    262      1.1    jruoho                 case ACPI_TYPE_THERMAL:
    263      1.1    jruoho                     AcpiOsPrintf ("Thermal Zone\n");
    264      1.1    jruoho                     break;
    265      1.1    jruoho 
    266      1.1    jruoho                 default:
    267  1.1.1.3  christos 
    268      1.1    jruoho                     AcpiExDoDebugObject ((SourceDesc->Reference.Node)->Object,
    269      1.1    jruoho                         Level+4, 0);
    270      1.1    jruoho                     break;
    271      1.1    jruoho                 }
    272      1.1    jruoho             }
    273      1.1    jruoho         }
    274      1.1    jruoho         else if (SourceDesc->Reference.Object)
    275      1.1    jruoho         {
    276      1.1    jruoho             if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc->Reference.Object) ==
    277      1.1    jruoho                     ACPI_DESC_TYPE_NAMED)
    278      1.1    jruoho             {
    279      1.1    jruoho                 AcpiExDoDebugObject (((ACPI_NAMESPACE_NODE *)
    280      1.1    jruoho                     SourceDesc->Reference.Object)->Object,
    281      1.1    jruoho                     Level+4, 0);
    282      1.1    jruoho             }
    283      1.1    jruoho             else
    284      1.1    jruoho             {
    285  1.1.1.6  christos                 ObjectDesc = SourceDesc->Reference.Object;
    286  1.1.1.6  christos                 Value = SourceDesc->Reference.Value;
    287  1.1.1.6  christos 
    288  1.1.1.6  christos                 switch (ObjectDesc->Common.Type)
    289  1.1.1.6  christos                 {
    290  1.1.1.6  christos                 case ACPI_TYPE_BUFFER:
    291  1.1.1.6  christos 
    292  1.1.1.6  christos                     AcpiOsPrintf ("Buffer[%u] = 0x%2.2X\n",
    293  1.1.1.6  christos                         Value, *SourceDesc->Reference.IndexPointer);
    294  1.1.1.6  christos                     break;
    295  1.1.1.6  christos 
    296  1.1.1.6  christos                 case ACPI_TYPE_STRING:
    297  1.1.1.6  christos 
    298  1.1.1.6  christos                     AcpiOsPrintf ("String[%u] = \"%c\" (0x%2.2X)\n",
    299  1.1.1.6  christos                         Value, *SourceDesc->Reference.IndexPointer,
    300  1.1.1.6  christos                         *SourceDesc->Reference.IndexPointer);
    301  1.1.1.6  christos                     break;
    302  1.1.1.6  christos 
    303  1.1.1.6  christos                 case ACPI_TYPE_PACKAGE:
    304  1.1.1.6  christos 
    305  1.1.1.6  christos                     AcpiOsPrintf ("Package[%u] = ", Value);
    306  1.1.1.6  christos                     AcpiExDoDebugObject (*SourceDesc->Reference.Where,
    307  1.1.1.6  christos                         Level+4, 0);
    308  1.1.1.6  christos                     break;
    309  1.1.1.6  christos 
    310  1.1.1.6  christos                 default:
    311  1.1.1.6  christos 
    312  1.1.1.6  christos                     AcpiOsPrintf ("Unknown Reference object type %X\n",
    313  1.1.1.6  christos                         ObjectDesc->Common.Type);
    314  1.1.1.6  christos                     break;
    315  1.1.1.6  christos                 }
    316      1.1    jruoho             }
    317      1.1    jruoho         }
    318      1.1    jruoho         break;
    319      1.1    jruoho 
    320      1.1    jruoho     default:
    321      1.1    jruoho 
    322      1.1    jruoho         AcpiOsPrintf ("%p\n", SourceDesc);
    323      1.1    jruoho         break;
    324      1.1    jruoho     }
    325      1.1    jruoho 
    326      1.1    jruoho     ACPI_DEBUG_PRINT_RAW ((ACPI_DB_EXEC, "\n"));
    327      1.1    jruoho     return_VOID;
    328      1.1    jruoho }
    329      1.1    jruoho #endif
    330  1.1.1.6  christos 
    331  1.1.1.6  christos 
    332  1.1.1.6  christos /*******************************************************************************
    333  1.1.1.6  christos  *
    334  1.1.1.6  christos  * FUNCTION:    AcpiExInterpreterTraceEnabled
    335  1.1.1.6  christos  *
    336  1.1.1.6  christos  * PARAMETERS:  Name                - Whether method name should be matched,
    337  1.1.1.6  christos  *                                    this should be checked before starting
    338  1.1.1.6  christos  *                                    the tracer
    339  1.1.1.6  christos  *
    340  1.1.1.6  christos  * RETURN:      TRUE if interpreter trace is enabled.
    341  1.1.1.6  christos  *
    342  1.1.1.6  christos  * DESCRIPTION: Check whether interpreter trace is enabled
    343  1.1.1.6  christos  *
    344  1.1.1.6  christos  ******************************************************************************/
    345  1.1.1.6  christos 
    346  1.1.1.6  christos static BOOLEAN
    347  1.1.1.6  christos AcpiExInterpreterTraceEnabled (
    348  1.1.1.6  christos     char                    *Name)
    349  1.1.1.6  christos {
    350  1.1.1.6  christos 
    351  1.1.1.6  christos     /* Check if tracing is enabled */
    352  1.1.1.6  christos 
    353  1.1.1.6  christos     if (!(AcpiGbl_TraceFlags & ACPI_TRACE_ENABLED))
    354  1.1.1.6  christos     {
    355  1.1.1.6  christos         return (FALSE);
    356  1.1.1.6  christos     }
    357  1.1.1.6  christos 
    358  1.1.1.6  christos     /*
    359  1.1.1.6  christos      * Check if tracing is filtered:
    360  1.1.1.6  christos      *
    361  1.1.1.6  christos      * 1. If the tracer is started, AcpiGbl_TraceMethodObject should have
    362  1.1.1.6  christos      *    been filled by the trace starter
    363  1.1.1.6  christos      * 2. If the tracer is not started, AcpiGbl_TraceMethodName should be
    364  1.1.1.6  christos      *    matched if it is specified
    365  1.1.1.6  christos      * 3. If the tracer is oneshot style, AcpiGbl_TraceMethodName should
    366  1.1.1.6  christos      *    not be cleared by the trace stopper during the first match
    367  1.1.1.6  christos      */
    368  1.1.1.6  christos     if (AcpiGbl_TraceMethodObject)
    369  1.1.1.6  christos     {
    370  1.1.1.6  christos         return (TRUE);
    371  1.1.1.6  christos     }
    372  1.1.1.6  christos     if (Name &&
    373  1.1.1.6  christos         (AcpiGbl_TraceMethodName &&
    374  1.1.1.6  christos          strcmp (AcpiGbl_TraceMethodName, Name)))
    375  1.1.1.6  christos     {
    376  1.1.1.6  christos         return (FALSE);
    377  1.1.1.6  christos     }
    378  1.1.1.6  christos     if ((AcpiGbl_TraceFlags & ACPI_TRACE_ONESHOT) &&
    379  1.1.1.6  christos         !AcpiGbl_TraceMethodName)
    380  1.1.1.6  christos     {
    381  1.1.1.6  christos         return (FALSE);
    382  1.1.1.6  christos     }
    383  1.1.1.6  christos 
    384  1.1.1.6  christos     return (TRUE);
    385  1.1.1.6  christos }
    386  1.1.1.6  christos 
    387  1.1.1.6  christos 
    388  1.1.1.6  christos /*******************************************************************************
    389  1.1.1.6  christos  *
    390  1.1.1.6  christos  * FUNCTION:    AcpiExGetTraceEventName
    391  1.1.1.6  christos  *
    392  1.1.1.6  christos  * PARAMETERS:  Type            - Trace event type
    393  1.1.1.6  christos  *
    394  1.1.1.6  christos  * RETURN:      Trace event name.
    395  1.1.1.6  christos  *
    396  1.1.1.6  christos  * DESCRIPTION: Used to obtain the full trace event name.
    397  1.1.1.6  christos  *
    398  1.1.1.6  christos  ******************************************************************************/
    399  1.1.1.6  christos 
    400  1.1.1.6  christos #ifdef ACPI_DEBUG_OUTPUT
    401  1.1.1.6  christos 
    402  1.1.1.6  christos static const char *
    403  1.1.1.6  christos AcpiExGetTraceEventName (
    404  1.1.1.6  christos     ACPI_TRACE_EVENT_TYPE   Type)
    405  1.1.1.6  christos {
    406  1.1.1.6  christos     switch (Type)
    407  1.1.1.6  christos     {
    408  1.1.1.6  christos     case ACPI_TRACE_AML_METHOD:
    409  1.1.1.6  christos 
    410  1.1.1.6  christos         return "Method";
    411  1.1.1.6  christos 
    412  1.1.1.6  christos     case ACPI_TRACE_AML_OPCODE:
    413  1.1.1.6  christos 
    414  1.1.1.6  christos         return "Opcode";
    415  1.1.1.6  christos 
    416  1.1.1.6  christos     case ACPI_TRACE_AML_REGION:
    417  1.1.1.6  christos 
    418  1.1.1.6  christos         return "Region";
    419  1.1.1.6  christos 
    420  1.1.1.6  christos     default:
    421  1.1.1.6  christos 
    422  1.1.1.6  christos         return "";
    423  1.1.1.6  christos     }
    424  1.1.1.6  christos }
    425  1.1.1.6  christos 
    426  1.1.1.6  christos #endif
    427  1.1.1.6  christos 
    428  1.1.1.6  christos 
    429  1.1.1.6  christos /*******************************************************************************
    430  1.1.1.6  christos  *
    431  1.1.1.6  christos  * FUNCTION:    AcpiExTracePoint
    432  1.1.1.6  christos  *
    433  1.1.1.6  christos  * PARAMETERS:  Type                - Trace event type
    434  1.1.1.6  christos  *              Begin               - TRUE if before execution
    435  1.1.1.6  christos  *              Aml                 - Executed AML address
    436  1.1.1.6  christos  *              Pathname            - Object path
    437  1.1.1.6  christos  *
    438  1.1.1.6  christos  * RETURN:      None
    439  1.1.1.6  christos  *
    440  1.1.1.6  christos  * DESCRIPTION: Internal interpreter execution trace.
    441  1.1.1.6  christos  *
    442  1.1.1.6  christos  ******************************************************************************/
    443  1.1.1.6  christos 
    444  1.1.1.6  christos void
    445  1.1.1.6  christos AcpiExTracePoint (
    446  1.1.1.6  christos     ACPI_TRACE_EVENT_TYPE   Type,
    447  1.1.1.6  christos     BOOLEAN                 Begin,
    448  1.1.1.6  christos     UINT8                   *Aml,
    449  1.1.1.6  christos     char                    *Pathname)
    450  1.1.1.6  christos {
    451  1.1.1.6  christos 
    452  1.1.1.6  christos     ACPI_FUNCTION_NAME (ExTracePoint);
    453  1.1.1.6  christos 
    454  1.1.1.6  christos 
    455  1.1.1.6  christos     if (Pathname)
    456  1.1.1.6  christos     {
    457  1.1.1.6  christos         ACPI_DEBUG_PRINT ((ACPI_DB_TRACE_POINT,
    458  1.1.1.6  christos                 "%s %s [0x%p:%s] execution.\n",
    459  1.1.1.6  christos                 AcpiExGetTraceEventName (Type), Begin ? "Begin" : "End",
    460  1.1.1.6  christos                 Aml, Pathname));
    461  1.1.1.6  christos     }
    462  1.1.1.6  christos     else
    463  1.1.1.6  christos     {
    464  1.1.1.6  christos         ACPI_DEBUG_PRINT ((ACPI_DB_TRACE_POINT,
    465  1.1.1.6  christos                 "%s %s [0x%p] execution.\n",
    466  1.1.1.6  christos                 AcpiExGetTraceEventName (Type), Begin ? "Begin" : "End",
    467  1.1.1.6  christos                 Aml));
    468  1.1.1.6  christos     }
    469  1.1.1.6  christos }
    470  1.1.1.6  christos 
    471  1.1.1.6  christos 
    472  1.1.1.6  christos /*******************************************************************************
    473  1.1.1.6  christos  *
    474  1.1.1.6  christos  * FUNCTION:    AcpiExStartTraceMethod
    475  1.1.1.6  christos  *
    476  1.1.1.6  christos  * PARAMETERS:  MethodNode          - Node of the method
    477  1.1.1.6  christos  *              ObjDesc             - The method object
    478  1.1.1.6  christos  *              WalkState           - current state, NULL if not yet executing
    479  1.1.1.6  christos  *                                    a method.
    480  1.1.1.6  christos  *
    481  1.1.1.6  christos  * RETURN:      None
    482  1.1.1.6  christos  *
    483  1.1.1.6  christos  * DESCRIPTION: Start control method execution trace
    484  1.1.1.6  christos  *
    485  1.1.1.6  christos  ******************************************************************************/
    486  1.1.1.6  christos 
    487  1.1.1.6  christos void
    488  1.1.1.6  christos AcpiExStartTraceMethod (
    489  1.1.1.6  christos     ACPI_NAMESPACE_NODE     *MethodNode,
    490  1.1.1.6  christos     ACPI_OPERAND_OBJECT     *ObjDesc,
    491  1.1.1.6  christos     ACPI_WALK_STATE         *WalkState)
    492  1.1.1.6  christos {
    493  1.1.1.6  christos     ACPI_STATUS             Status;
    494  1.1.1.6  christos     char                    *Pathname = NULL;
    495  1.1.1.6  christos     BOOLEAN                 Enabled = FALSE;
    496  1.1.1.6  christos 
    497  1.1.1.6  christos 
    498  1.1.1.6  christos     ACPI_FUNCTION_NAME (ExStartTraceMethod);
    499  1.1.1.6  christos 
    500  1.1.1.6  christos 
    501  1.1.1.6  christos     if (MethodNode)
    502  1.1.1.6  christos     {
    503  1.1.1.6  christos         Pathname = AcpiNsGetNormalizedPathname (MethodNode, TRUE);
    504  1.1.1.6  christos     }
    505  1.1.1.6  christos 
    506  1.1.1.6  christos     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
    507  1.1.1.6  christos     if (ACPI_FAILURE (Status))
    508  1.1.1.6  christos     {
    509  1.1.1.6  christos         goto Exit;
    510  1.1.1.6  christos     }
    511  1.1.1.6  christos 
    512  1.1.1.6  christos     Enabled = AcpiExInterpreterTraceEnabled (Pathname);
    513  1.1.1.6  christos     if (Enabled && !AcpiGbl_TraceMethodObject)
    514  1.1.1.6  christos     {
    515  1.1.1.6  christos         AcpiGbl_TraceMethodObject = ObjDesc;
    516  1.1.1.6  christos         AcpiGbl_OriginalDbgLevel = AcpiDbgLevel;
    517  1.1.1.6  christos         AcpiGbl_OriginalDbgLayer = AcpiDbgLayer;
    518  1.1.1.6  christos         AcpiDbgLevel = ACPI_TRACE_LEVEL_ALL;
    519  1.1.1.6  christos         AcpiDbgLayer = ACPI_TRACE_LAYER_ALL;
    520  1.1.1.6  christos 
    521  1.1.1.6  christos         if (AcpiGbl_TraceDbgLevel)
    522  1.1.1.6  christos         {
    523  1.1.1.6  christos             AcpiDbgLevel = AcpiGbl_TraceDbgLevel;
    524  1.1.1.6  christos         }
    525  1.1.1.6  christos         if (AcpiGbl_TraceDbgLayer)
    526  1.1.1.6  christos         {
    527  1.1.1.6  christos             AcpiDbgLayer = AcpiGbl_TraceDbgLayer;
    528  1.1.1.6  christos         }
    529  1.1.1.6  christos     }
    530  1.1.1.6  christos     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
    531  1.1.1.6  christos 
    532  1.1.1.6  christos Exit:
    533  1.1.1.6  christos     if (Enabled)
    534  1.1.1.6  christos     {
    535  1.1.1.6  christos         ACPI_TRACE_POINT (ACPI_TRACE_AML_METHOD, TRUE,
    536  1.1.1.6  christos                 ObjDesc ? ObjDesc->Method.AmlStart : NULL, Pathname);
    537  1.1.1.6  christos     }
    538  1.1.1.6  christos     if (Pathname)
    539  1.1.1.6  christos     {
    540  1.1.1.6  christos         ACPI_FREE (Pathname);
    541  1.1.1.6  christos     }
    542  1.1.1.6  christos }
    543  1.1.1.6  christos 
    544  1.1.1.6  christos 
    545  1.1.1.6  christos /*******************************************************************************
    546  1.1.1.6  christos  *
    547  1.1.1.6  christos  * FUNCTION:    AcpiExStopTraceMethod
    548  1.1.1.6  christos  *
    549  1.1.1.6  christos  * PARAMETERS:  MethodNode          - Node of the method
    550  1.1.1.6  christos  *              ObjDesc             - The method object
    551  1.1.1.6  christos  *              WalkState           - current state, NULL if not yet executing
    552  1.1.1.6  christos  *                                    a method.
    553  1.1.1.6  christos  *
    554  1.1.1.6  christos  * RETURN:      None
    555  1.1.1.6  christos  *
    556  1.1.1.6  christos  * DESCRIPTION: Stop control method execution trace
    557  1.1.1.6  christos  *
    558  1.1.1.6  christos  ******************************************************************************/
    559  1.1.1.6  christos 
    560  1.1.1.6  christos void
    561  1.1.1.6  christos AcpiExStopTraceMethod (
    562  1.1.1.6  christos     ACPI_NAMESPACE_NODE     *MethodNode,
    563  1.1.1.6  christos     ACPI_OPERAND_OBJECT     *ObjDesc,
    564  1.1.1.6  christos     ACPI_WALK_STATE         *WalkState)
    565  1.1.1.6  christos {
    566  1.1.1.6  christos     ACPI_STATUS             Status;
    567  1.1.1.6  christos     char                    *Pathname = NULL;
    568  1.1.1.6  christos     BOOLEAN                 Enabled;
    569  1.1.1.6  christos 
    570  1.1.1.6  christos 
    571  1.1.1.6  christos     ACPI_FUNCTION_NAME (ExStopTraceMethod);
    572  1.1.1.6  christos 
    573  1.1.1.6  christos 
    574  1.1.1.6  christos     if (MethodNode)
    575  1.1.1.6  christos     {
    576  1.1.1.6  christos         Pathname = AcpiNsGetNormalizedPathname (MethodNode, TRUE);
    577  1.1.1.6  christos     }
    578  1.1.1.6  christos 
    579  1.1.1.6  christos     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
    580  1.1.1.6  christos     if (ACPI_FAILURE (Status))
    581  1.1.1.6  christos     {
    582  1.1.1.6  christos         goto ExitPath;
    583  1.1.1.6  christos     }
    584  1.1.1.6  christos 
    585  1.1.1.6  christos     Enabled = AcpiExInterpreterTraceEnabled (NULL);
    586  1.1.1.6  christos 
    587  1.1.1.6  christos     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
    588  1.1.1.6  christos 
    589  1.1.1.6  christos     if (Enabled)
    590  1.1.1.6  christos     {
    591  1.1.1.6  christos         ACPI_TRACE_POINT (ACPI_TRACE_AML_METHOD, FALSE,
    592  1.1.1.6  christos                 ObjDesc ? ObjDesc->Method.AmlStart : NULL, Pathname);
    593  1.1.1.6  christos     }
    594  1.1.1.6  christos 
    595  1.1.1.6  christos     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
    596  1.1.1.6  christos     if (ACPI_FAILURE (Status))
    597  1.1.1.6  christos     {
    598  1.1.1.6  christos         goto ExitPath;
    599  1.1.1.6  christos     }
    600  1.1.1.6  christos 
    601  1.1.1.6  christos     /* Check whether the tracer should be stopped */
    602  1.1.1.6  christos 
    603  1.1.1.6  christos     if (AcpiGbl_TraceMethodObject == ObjDesc)
    604  1.1.1.6  christos     {
    605  1.1.1.6  christos         /* Disable further tracing if type is one-shot */
    606  1.1.1.6  christos 
    607  1.1.1.6  christos         if (AcpiGbl_TraceFlags & ACPI_TRACE_ONESHOT)
    608  1.1.1.6  christos         {
    609  1.1.1.6  christos             AcpiGbl_TraceMethodName = NULL;
    610  1.1.1.6  christos         }
    611  1.1.1.6  christos 
    612  1.1.1.6  christos         AcpiDbgLevel = AcpiGbl_OriginalDbgLevel;
    613  1.1.1.6  christos         AcpiDbgLayer = AcpiGbl_OriginalDbgLayer;
    614  1.1.1.6  christos         AcpiGbl_TraceMethodObject = NULL;
    615  1.1.1.6  christos     }
    616  1.1.1.6  christos 
    617  1.1.1.6  christos     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
    618  1.1.1.6  christos 
    619  1.1.1.6  christos ExitPath:
    620  1.1.1.6  christos     if (Pathname)
    621  1.1.1.6  christos     {
    622  1.1.1.6  christos         ACPI_FREE (Pathname);
    623  1.1.1.6  christos     }
    624  1.1.1.6  christos }
    625  1.1.1.6  christos 
    626  1.1.1.6  christos 
    627  1.1.1.6  christos /*******************************************************************************
    628  1.1.1.6  christos  *
    629  1.1.1.6  christos  * FUNCTION:    AcpiExStartTraceOpcode
    630  1.1.1.6  christos  *
    631  1.1.1.6  christos  * PARAMETERS:  Op                  - The parser opcode object
    632  1.1.1.6  christos  *              WalkState           - current state, NULL if not yet executing
    633  1.1.1.6  christos  *                                    a method.
    634  1.1.1.6  christos  *
    635  1.1.1.6  christos  * RETURN:      None
    636  1.1.1.6  christos  *
    637  1.1.1.6  christos  * DESCRIPTION: Start opcode execution trace
    638  1.1.1.6  christos  *
    639  1.1.1.6  christos  ******************************************************************************/
    640  1.1.1.6  christos 
    641  1.1.1.6  christos void
    642  1.1.1.6  christos AcpiExStartTraceOpcode (
    643  1.1.1.6  christos     ACPI_PARSE_OBJECT       *Op,
    644  1.1.1.6  christos     ACPI_WALK_STATE         *WalkState)
    645  1.1.1.6  christos {
    646  1.1.1.6  christos 
    647  1.1.1.6  christos     ACPI_FUNCTION_NAME (ExStartTraceOpcode);
    648  1.1.1.6  christos 
    649  1.1.1.6  christos 
    650  1.1.1.6  christos     if (AcpiExInterpreterTraceEnabled (NULL) &&
    651  1.1.1.6  christos         (AcpiGbl_TraceFlags & ACPI_TRACE_OPCODE))
    652  1.1.1.6  christos     {
    653  1.1.1.6  christos         ACPI_TRACE_POINT (ACPI_TRACE_AML_OPCODE, TRUE,
    654  1.1.1.6  christos                 Op->Common.Aml, Op->Common.AmlOpName);
    655  1.1.1.6  christos     }
    656  1.1.1.6  christos }
    657  1.1.1.6  christos 
    658  1.1.1.6  christos 
    659  1.1.1.6  christos /*******************************************************************************
    660  1.1.1.6  christos  *
    661  1.1.1.6  christos  * FUNCTION:    AcpiExStopTraceOpcode
    662  1.1.1.6  christos  *
    663  1.1.1.6  christos  * PARAMETERS:  Op                  - The parser opcode object
    664  1.1.1.6  christos  *              WalkState           - current state, NULL if not yet executing
    665  1.1.1.6  christos  *                                    a method.
    666  1.1.1.6  christos  *
    667  1.1.1.6  christos  * RETURN:      None
    668  1.1.1.6  christos  *
    669  1.1.1.6  christos  * DESCRIPTION: Stop opcode execution trace
    670  1.1.1.6  christos  *
    671  1.1.1.6  christos  ******************************************************************************/
    672  1.1.1.6  christos 
    673  1.1.1.6  christos void
    674  1.1.1.6  christos AcpiExStopTraceOpcode (
    675  1.1.1.6  christos     ACPI_PARSE_OBJECT       *Op,
    676  1.1.1.6  christos     ACPI_WALK_STATE         *WalkState)
    677  1.1.1.6  christos {
    678  1.1.1.6  christos 
    679  1.1.1.6  christos     ACPI_FUNCTION_NAME (ExStopTraceOpcode);
    680  1.1.1.6  christos 
    681  1.1.1.6  christos 
    682  1.1.1.6  christos     if (AcpiExInterpreterTraceEnabled (NULL) &&
    683  1.1.1.6  christos         (AcpiGbl_TraceFlags & ACPI_TRACE_OPCODE))
    684  1.1.1.6  christos     {
    685  1.1.1.6  christos         ACPI_TRACE_POINT (ACPI_TRACE_AML_OPCODE, FALSE,
    686  1.1.1.6  christos                 Op->Common.Aml, Op->Common.AmlOpName);
    687  1.1.1.6  christos     }
    688  1.1.1.6  christos }
    689