xref: /haiku/src/add-ons/kernel/bus_managers/acpi/acpica/components/executer/extrace.c (revision 6dde014f768e0ee49bae871ed857cf433837b9ff)
14dffc0abSAugustin Cavalier /******************************************************************************
24dffc0abSAugustin Cavalier  *
34dffc0abSAugustin Cavalier  * Module Name: extrace - Support for interpreter execution tracing
44dffc0abSAugustin Cavalier  *
54dffc0abSAugustin Cavalier  *****************************************************************************/
64dffc0abSAugustin Cavalier 
74dffc0abSAugustin Cavalier /******************************************************************************
84dffc0abSAugustin Cavalier  *
94dffc0abSAugustin Cavalier  * 1. Copyright Notice
104dffc0abSAugustin Cavalier  *
11*6dde014fSPulkoMandy  * Some or all of this work - Copyright (c) 1999 - 2024, Intel Corp.
124dffc0abSAugustin Cavalier  * All rights reserved.
134dffc0abSAugustin Cavalier  *
144dffc0abSAugustin Cavalier  * 2. License
154dffc0abSAugustin Cavalier  *
164dffc0abSAugustin Cavalier  * 2.1. This is your license from Intel Corp. under its intellectual property
174dffc0abSAugustin Cavalier  * rights. You may have additional license terms from the party that provided
184dffc0abSAugustin Cavalier  * you this software, covering your right to use that party's intellectual
194dffc0abSAugustin Cavalier  * property rights.
204dffc0abSAugustin Cavalier  *
214dffc0abSAugustin Cavalier  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
224dffc0abSAugustin Cavalier  * copy of the source code appearing in this file ("Covered Code") an
234dffc0abSAugustin Cavalier  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
244dffc0abSAugustin Cavalier  * base code distributed originally by Intel ("Original Intel Code") to copy,
254dffc0abSAugustin Cavalier  * make derivatives, distribute, use and display any portion of the Covered
264dffc0abSAugustin Cavalier  * Code in any form, with the right to sublicense such rights; and
274dffc0abSAugustin Cavalier  *
284dffc0abSAugustin Cavalier  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
294dffc0abSAugustin Cavalier  * license (with the right to sublicense), under only those claims of Intel
304dffc0abSAugustin Cavalier  * patents that are infringed by the Original Intel Code, to make, use, sell,
314dffc0abSAugustin Cavalier  * offer to sell, and import the Covered Code and derivative works thereof
324dffc0abSAugustin Cavalier  * solely to the minimum extent necessary to exercise the above copyright
334dffc0abSAugustin Cavalier  * license, and in no event shall the patent license extend to any additions
344dffc0abSAugustin Cavalier  * to or modifications of the Original Intel Code. No other license or right
354dffc0abSAugustin Cavalier  * is granted directly or by implication, estoppel or otherwise;
364dffc0abSAugustin Cavalier  *
374dffc0abSAugustin Cavalier  * The above copyright and patent license is granted only if the following
384dffc0abSAugustin Cavalier  * conditions are met:
394dffc0abSAugustin Cavalier  *
404dffc0abSAugustin Cavalier  * 3. Conditions
414dffc0abSAugustin Cavalier  *
424dffc0abSAugustin Cavalier  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
434dffc0abSAugustin Cavalier  * Redistribution of source code of any substantial portion of the Covered
444dffc0abSAugustin Cavalier  * Code or modification with rights to further distribute source must include
454dffc0abSAugustin Cavalier  * the above Copyright Notice, the above License, this list of Conditions,
464dffc0abSAugustin Cavalier  * and the following Disclaimer and Export Compliance provision. In addition,
474dffc0abSAugustin Cavalier  * Licensee must cause all Covered Code to which Licensee contributes to
484dffc0abSAugustin Cavalier  * contain a file documenting the changes Licensee made to create that Covered
494dffc0abSAugustin Cavalier  * Code and the date of any change. Licensee must include in that file the
504dffc0abSAugustin Cavalier  * documentation of any changes made by any predecessor Licensee. Licensee
514dffc0abSAugustin Cavalier  * must include a prominent statement that the modification is derived,
524dffc0abSAugustin Cavalier  * directly or indirectly, from Original Intel Code.
534dffc0abSAugustin Cavalier  *
544dffc0abSAugustin Cavalier  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
554dffc0abSAugustin Cavalier  * Redistribution of source code of any substantial portion of the Covered
564dffc0abSAugustin Cavalier  * Code or modification without rights to further distribute source must
574dffc0abSAugustin Cavalier  * include the following Disclaimer and Export Compliance provision in the
584dffc0abSAugustin Cavalier  * documentation and/or other materials provided with distribution. In
594dffc0abSAugustin Cavalier  * addition, Licensee may not authorize further sublicense of source of any
604dffc0abSAugustin Cavalier  * portion of the Covered Code, and must include terms to the effect that the
614dffc0abSAugustin Cavalier  * license from Licensee to its licensee is limited to the intellectual
624dffc0abSAugustin Cavalier  * property embodied in the software Licensee provides to its licensee, and
634dffc0abSAugustin Cavalier  * not to intellectual property embodied in modifications its licensee may
644dffc0abSAugustin Cavalier  * make.
654dffc0abSAugustin Cavalier  *
664dffc0abSAugustin Cavalier  * 3.3. Redistribution of Executable. Redistribution in executable form of any
674dffc0abSAugustin Cavalier  * substantial portion of the Covered Code or modification must reproduce the
684dffc0abSAugustin Cavalier  * above Copyright Notice, and the following Disclaimer and Export Compliance
694dffc0abSAugustin Cavalier  * provision in the documentation and/or other materials provided with the
704dffc0abSAugustin Cavalier  * distribution.
714dffc0abSAugustin Cavalier  *
724dffc0abSAugustin Cavalier  * 3.4. Intel retains all right, title, and interest in and to the Original
734dffc0abSAugustin Cavalier  * Intel Code.
744dffc0abSAugustin Cavalier  *
754dffc0abSAugustin Cavalier  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
764dffc0abSAugustin Cavalier  * Intel shall be used in advertising or otherwise to promote the sale, use or
774dffc0abSAugustin Cavalier  * other dealings in products derived from or relating to the Covered Code
784dffc0abSAugustin Cavalier  * without prior written authorization from Intel.
794dffc0abSAugustin Cavalier  *
804dffc0abSAugustin Cavalier  * 4. Disclaimer and Export Compliance
814dffc0abSAugustin Cavalier  *
824dffc0abSAugustin Cavalier  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
834dffc0abSAugustin Cavalier  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
844dffc0abSAugustin Cavalier  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
854dffc0abSAugustin Cavalier  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
864dffc0abSAugustin Cavalier  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
874dffc0abSAugustin Cavalier  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
884dffc0abSAugustin Cavalier  * PARTICULAR PURPOSE.
894dffc0abSAugustin Cavalier  *
904dffc0abSAugustin Cavalier  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
914dffc0abSAugustin Cavalier  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
924dffc0abSAugustin Cavalier  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
934dffc0abSAugustin Cavalier  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
944dffc0abSAugustin Cavalier  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
954dffc0abSAugustin Cavalier  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
964dffc0abSAugustin Cavalier  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
974dffc0abSAugustin Cavalier  * LIMITED REMEDY.
984dffc0abSAugustin Cavalier  *
994dffc0abSAugustin Cavalier  * 4.3. Licensee shall not export, either directly or indirectly, any of this
1004dffc0abSAugustin Cavalier  * software or system incorporating such software without first obtaining any
1014dffc0abSAugustin Cavalier  * required license or other approval from the U. S. Department of Commerce or
1024dffc0abSAugustin Cavalier  * any other agency or department of the United States Government. In the
1034dffc0abSAugustin Cavalier  * event Licensee exports any such software from the United States or
1044dffc0abSAugustin Cavalier  * re-exports any such software from a foreign destination, Licensee shall
1054dffc0abSAugustin Cavalier  * ensure that the distribution and export/re-export of the software is in
1064dffc0abSAugustin Cavalier  * compliance with all laws, regulations, orders, or other restrictions of the
1074dffc0abSAugustin Cavalier  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1084dffc0abSAugustin Cavalier  * any of its subsidiaries will export/re-export any technical data, process,
1094dffc0abSAugustin Cavalier  * software, or service, directly or indirectly, to any country for which the
1104dffc0abSAugustin Cavalier  * United States government or any agency thereof requires an export license,
1114dffc0abSAugustin Cavalier  * other governmental approval, or letter of assurance, without first obtaining
1124dffc0abSAugustin Cavalier  * such license, approval or letter.
1134dffc0abSAugustin Cavalier  *
114ff2e2f81SFredrik Holmqvist  *****************************************************************************
115ff2e2f81SFredrik Holmqvist  *
116ff2e2f81SFredrik Holmqvist  * Alternatively, you may choose to be licensed under the terms of the
117ff2e2f81SFredrik Holmqvist  * following license:
118ff2e2f81SFredrik Holmqvist  *
119ff2e2f81SFredrik Holmqvist  * Redistribution and use in source and binary forms, with or without
120ff2e2f81SFredrik Holmqvist  * modification, are permitted provided that the following conditions
121ff2e2f81SFredrik Holmqvist  * are met:
122ff2e2f81SFredrik Holmqvist  * 1. Redistributions of source code must retain the above copyright
123ff2e2f81SFredrik Holmqvist  *    notice, this list of conditions, and the following disclaimer,
124ff2e2f81SFredrik Holmqvist  *    without modification.
125ff2e2f81SFredrik Holmqvist  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126ff2e2f81SFredrik Holmqvist  *    substantially similar to the "NO WARRANTY" disclaimer below
127ff2e2f81SFredrik Holmqvist  *    ("Disclaimer") and any redistribution must be conditioned upon
128ff2e2f81SFredrik Holmqvist  *    including a substantially similar Disclaimer requirement for further
129ff2e2f81SFredrik Holmqvist  *    binary redistribution.
130ff2e2f81SFredrik Holmqvist  * 3. Neither the names of the above-listed copyright holders nor the names
131ff2e2f81SFredrik Holmqvist  *    of any contributors may be used to endorse or promote products derived
132ff2e2f81SFredrik Holmqvist  *    from this software without specific prior written permission.
133ff2e2f81SFredrik Holmqvist  *
134ff2e2f81SFredrik Holmqvist  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
135ff2e2f81SFredrik Holmqvist  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
136ff2e2f81SFredrik Holmqvist  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
137ff2e2f81SFredrik Holmqvist  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
138ff2e2f81SFredrik Holmqvist  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
139ff2e2f81SFredrik Holmqvist  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
140ff2e2f81SFredrik Holmqvist  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
141ff2e2f81SFredrik Holmqvist  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
142ff2e2f81SFredrik Holmqvist  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
143ff2e2f81SFredrik Holmqvist  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
144ff2e2f81SFredrik Holmqvist  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
145ff2e2f81SFredrik Holmqvist  *
146ff2e2f81SFredrik Holmqvist  * Alternatively, you may choose to be licensed under the terms of the
147ff2e2f81SFredrik Holmqvist  * GNU General Public License ("GPL") version 2 as published by the Free
148ff2e2f81SFredrik Holmqvist  * Software Foundation.
149ff2e2f81SFredrik Holmqvist  *
1504dffc0abSAugustin Cavalier  *****************************************************************************/
1514dffc0abSAugustin Cavalier 
1524dffc0abSAugustin Cavalier #include "acpi.h"
1534dffc0abSAugustin Cavalier #include "accommon.h"
1544dffc0abSAugustin Cavalier #include "acnamesp.h"
1554dffc0abSAugustin Cavalier #include "acinterp.h"
1564dffc0abSAugustin Cavalier 
1574dffc0abSAugustin Cavalier 
1584dffc0abSAugustin Cavalier #define _COMPONENT          ACPI_EXECUTER
1594dffc0abSAugustin Cavalier         ACPI_MODULE_NAME    ("extrace")
1604dffc0abSAugustin Cavalier 
1614dffc0abSAugustin Cavalier 
1624dffc0abSAugustin Cavalier static ACPI_OPERAND_OBJECT  *AcpiGbl_TraceMethodObject = NULL;
1634dffc0abSAugustin Cavalier 
1644dffc0abSAugustin Cavalier /* Local prototypes */
1654dffc0abSAugustin Cavalier 
1664dffc0abSAugustin Cavalier #ifdef ACPI_DEBUG_OUTPUT
1674dffc0abSAugustin Cavalier static const char *
1684dffc0abSAugustin Cavalier AcpiExGetTraceEventName (
1694dffc0abSAugustin Cavalier     ACPI_TRACE_EVENT_TYPE   Type);
1704dffc0abSAugustin Cavalier #endif
1714dffc0abSAugustin Cavalier 
1724dffc0abSAugustin Cavalier 
1734dffc0abSAugustin Cavalier /*******************************************************************************
1744dffc0abSAugustin Cavalier  *
1754dffc0abSAugustin Cavalier  * FUNCTION:    AcpiExInterpreterTraceEnabled
1764dffc0abSAugustin Cavalier  *
1774dffc0abSAugustin Cavalier  * PARAMETERS:  Name                - Whether method name should be matched,
1784dffc0abSAugustin Cavalier  *                                    this should be checked before starting
1794dffc0abSAugustin Cavalier  *                                    the tracer
1804dffc0abSAugustin Cavalier  *
1814dffc0abSAugustin Cavalier  * RETURN:      TRUE if interpreter trace is enabled.
1824dffc0abSAugustin Cavalier  *
1834dffc0abSAugustin Cavalier  * DESCRIPTION: Check whether interpreter trace is enabled
1844dffc0abSAugustin Cavalier  *
1854dffc0abSAugustin Cavalier  ******************************************************************************/
1864dffc0abSAugustin Cavalier 
1874dffc0abSAugustin Cavalier static BOOLEAN
AcpiExInterpreterTraceEnabled(char * Name)1884dffc0abSAugustin Cavalier AcpiExInterpreterTraceEnabled (
1894dffc0abSAugustin Cavalier     char                    *Name)
1904dffc0abSAugustin Cavalier {
1914dffc0abSAugustin Cavalier 
1924dffc0abSAugustin Cavalier     /* Check if tracing is enabled */
1934dffc0abSAugustin Cavalier 
1944dffc0abSAugustin Cavalier     if (!(AcpiGbl_TraceFlags & ACPI_TRACE_ENABLED))
1954dffc0abSAugustin Cavalier     {
1964dffc0abSAugustin Cavalier         return (FALSE);
1974dffc0abSAugustin Cavalier     }
1984dffc0abSAugustin Cavalier 
1994dffc0abSAugustin Cavalier     /*
2004dffc0abSAugustin Cavalier      * Check if tracing is filtered:
2014dffc0abSAugustin Cavalier      *
2024dffc0abSAugustin Cavalier      * 1. If the tracer is started, AcpiGbl_TraceMethodObject should have
2034dffc0abSAugustin Cavalier      *    been filled by the trace starter
2044dffc0abSAugustin Cavalier      * 2. If the tracer is not started, AcpiGbl_TraceMethodName should be
2054dffc0abSAugustin Cavalier      *    matched if it is specified
2064dffc0abSAugustin Cavalier      * 3. If the tracer is oneshot style, AcpiGbl_TraceMethodName should
2074dffc0abSAugustin Cavalier      *    not be cleared by the trace stopper during the first match
2084dffc0abSAugustin Cavalier      */
2094dffc0abSAugustin Cavalier     if (AcpiGbl_TraceMethodObject)
2104dffc0abSAugustin Cavalier     {
2114dffc0abSAugustin Cavalier         return (TRUE);
2124dffc0abSAugustin Cavalier     }
2134dffc0abSAugustin Cavalier 
2144dffc0abSAugustin Cavalier     if (Name &&
2154dffc0abSAugustin Cavalier         (AcpiGbl_TraceMethodName &&
2164dffc0abSAugustin Cavalier          strcmp (AcpiGbl_TraceMethodName, Name)))
2174dffc0abSAugustin Cavalier     {
2184dffc0abSAugustin Cavalier         return (FALSE);
2194dffc0abSAugustin Cavalier     }
2204dffc0abSAugustin Cavalier 
2214dffc0abSAugustin Cavalier     if ((AcpiGbl_TraceFlags & ACPI_TRACE_ONESHOT) &&
2224dffc0abSAugustin Cavalier         !AcpiGbl_TraceMethodName)
2234dffc0abSAugustin Cavalier     {
2244dffc0abSAugustin Cavalier         return (FALSE);
2254dffc0abSAugustin Cavalier     }
2264dffc0abSAugustin Cavalier 
2274dffc0abSAugustin Cavalier     return (TRUE);
2284dffc0abSAugustin Cavalier }
2294dffc0abSAugustin Cavalier 
2304dffc0abSAugustin Cavalier 
2314dffc0abSAugustin Cavalier /*******************************************************************************
2324dffc0abSAugustin Cavalier  *
2334dffc0abSAugustin Cavalier  * FUNCTION:    AcpiExGetTraceEventName
2344dffc0abSAugustin Cavalier  *
2354dffc0abSAugustin Cavalier  * PARAMETERS:  Type            - Trace event type
2364dffc0abSAugustin Cavalier  *
2374dffc0abSAugustin Cavalier  * RETURN:      Trace event name.
2384dffc0abSAugustin Cavalier  *
2394dffc0abSAugustin Cavalier  * DESCRIPTION: Used to obtain the full trace event name.
2404dffc0abSAugustin Cavalier  *
2414dffc0abSAugustin Cavalier  ******************************************************************************/
2424dffc0abSAugustin Cavalier 
2434dffc0abSAugustin Cavalier #ifdef ACPI_DEBUG_OUTPUT
2444dffc0abSAugustin Cavalier 
2454dffc0abSAugustin Cavalier static const char *
AcpiExGetTraceEventName(ACPI_TRACE_EVENT_TYPE Type)2464dffc0abSAugustin Cavalier AcpiExGetTraceEventName (
2474dffc0abSAugustin Cavalier     ACPI_TRACE_EVENT_TYPE   Type)
2484dffc0abSAugustin Cavalier {
2494dffc0abSAugustin Cavalier 
2504dffc0abSAugustin Cavalier     switch (Type)
2514dffc0abSAugustin Cavalier     {
2524dffc0abSAugustin Cavalier     case ACPI_TRACE_AML_METHOD:
2534dffc0abSAugustin Cavalier 
2544dffc0abSAugustin Cavalier         return "Method";
2554dffc0abSAugustin Cavalier 
2564dffc0abSAugustin Cavalier     case ACPI_TRACE_AML_OPCODE:
2574dffc0abSAugustin Cavalier 
2584dffc0abSAugustin Cavalier         return "Opcode";
2594dffc0abSAugustin Cavalier 
2604dffc0abSAugustin Cavalier     case ACPI_TRACE_AML_REGION:
2614dffc0abSAugustin Cavalier 
2624dffc0abSAugustin Cavalier         return "Region";
2634dffc0abSAugustin Cavalier 
2644dffc0abSAugustin Cavalier     default:
2654dffc0abSAugustin Cavalier 
2664dffc0abSAugustin Cavalier         return "";
2674dffc0abSAugustin Cavalier     }
2684dffc0abSAugustin Cavalier }
2694dffc0abSAugustin Cavalier 
2704dffc0abSAugustin Cavalier #endif
2714dffc0abSAugustin Cavalier 
2724dffc0abSAugustin Cavalier 
2734dffc0abSAugustin Cavalier /*******************************************************************************
2744dffc0abSAugustin Cavalier  *
2754dffc0abSAugustin Cavalier  * FUNCTION:    AcpiExTracePoint
2764dffc0abSAugustin Cavalier  *
2774dffc0abSAugustin Cavalier  * PARAMETERS:  Type                - Trace event type
2784dffc0abSAugustin Cavalier  *              Begin               - TRUE if before execution
2794dffc0abSAugustin Cavalier  *              Aml                 - Executed AML address
2804dffc0abSAugustin Cavalier  *              Pathname            - Object path
2814dffc0abSAugustin Cavalier  *
2824dffc0abSAugustin Cavalier  * RETURN:      None
2834dffc0abSAugustin Cavalier  *
2844dffc0abSAugustin Cavalier  * DESCRIPTION: Internal interpreter execution trace.
2854dffc0abSAugustin Cavalier  *
2864dffc0abSAugustin Cavalier  ******************************************************************************/
2874dffc0abSAugustin Cavalier 
2884dffc0abSAugustin Cavalier void
AcpiExTracePoint(ACPI_TRACE_EVENT_TYPE Type,BOOLEAN Begin,UINT8 * Aml,char * Pathname)2894dffc0abSAugustin Cavalier AcpiExTracePoint (
2904dffc0abSAugustin Cavalier     ACPI_TRACE_EVENT_TYPE   Type,
2914dffc0abSAugustin Cavalier     BOOLEAN                 Begin,
2924dffc0abSAugustin Cavalier     UINT8                   *Aml,
2934dffc0abSAugustin Cavalier     char                    *Pathname)
2944dffc0abSAugustin Cavalier {
2954dffc0abSAugustin Cavalier 
2964dffc0abSAugustin Cavalier     ACPI_FUNCTION_NAME (ExTracePoint);
2974dffc0abSAugustin Cavalier 
2984dffc0abSAugustin Cavalier 
2994dffc0abSAugustin Cavalier     if (Pathname)
3004dffc0abSAugustin Cavalier     {
3014dffc0abSAugustin Cavalier         ACPI_DEBUG_PRINT ((ACPI_DB_TRACE_POINT,
3024dffc0abSAugustin Cavalier             "%s %s [0x%p:%s] execution.\n",
3034dffc0abSAugustin Cavalier             AcpiExGetTraceEventName (Type), Begin ? "Begin" : "End",
3044dffc0abSAugustin Cavalier             Aml, Pathname));
3054dffc0abSAugustin Cavalier     }
3064dffc0abSAugustin Cavalier     else
3074dffc0abSAugustin Cavalier     {
3084dffc0abSAugustin Cavalier         ACPI_DEBUG_PRINT ((ACPI_DB_TRACE_POINT,
3094dffc0abSAugustin Cavalier             "%s %s [0x%p] execution.\n",
3104dffc0abSAugustin Cavalier             AcpiExGetTraceEventName (Type), Begin ? "Begin" : "End",
3114dffc0abSAugustin Cavalier             Aml));
3124dffc0abSAugustin Cavalier     }
3134dffc0abSAugustin Cavalier }
3144dffc0abSAugustin Cavalier 
3154dffc0abSAugustin Cavalier 
3164dffc0abSAugustin Cavalier /*******************************************************************************
3174dffc0abSAugustin Cavalier  *
3184dffc0abSAugustin Cavalier  * FUNCTION:    AcpiExStartTraceMethod
3194dffc0abSAugustin Cavalier  *
3204dffc0abSAugustin Cavalier  * PARAMETERS:  MethodNode          - Node of the method
3214dffc0abSAugustin Cavalier  *              ObjDesc             - The method object
3224dffc0abSAugustin Cavalier  *              WalkState           - current state, NULL if not yet executing
3234dffc0abSAugustin Cavalier  *                                    a method.
3244dffc0abSAugustin Cavalier  *
3254dffc0abSAugustin Cavalier  * RETURN:      None
3264dffc0abSAugustin Cavalier  *
3274dffc0abSAugustin Cavalier  * DESCRIPTION: Start control method execution trace
3284dffc0abSAugustin Cavalier  *
3294dffc0abSAugustin Cavalier  ******************************************************************************/
3304dffc0abSAugustin Cavalier 
3314dffc0abSAugustin Cavalier void
AcpiExStartTraceMethod(ACPI_NAMESPACE_NODE * MethodNode,ACPI_OPERAND_OBJECT * ObjDesc,ACPI_WALK_STATE * WalkState)3324dffc0abSAugustin Cavalier AcpiExStartTraceMethod (
3334dffc0abSAugustin Cavalier     ACPI_NAMESPACE_NODE     *MethodNode,
3344dffc0abSAugustin Cavalier     ACPI_OPERAND_OBJECT     *ObjDesc,
3354dffc0abSAugustin Cavalier     ACPI_WALK_STATE         *WalkState)
3364dffc0abSAugustin Cavalier {
3374dffc0abSAugustin Cavalier     char                    *Pathname = NULL;
3384dffc0abSAugustin Cavalier     BOOLEAN                 Enabled = FALSE;
3394dffc0abSAugustin Cavalier 
3404dffc0abSAugustin Cavalier 
3414dffc0abSAugustin Cavalier     ACPI_FUNCTION_NAME (ExStartTraceMethod);
3424dffc0abSAugustin Cavalier 
3434dffc0abSAugustin Cavalier 
3444dffc0abSAugustin Cavalier     if (MethodNode)
3454dffc0abSAugustin Cavalier     {
3464dffc0abSAugustin Cavalier         Pathname = AcpiNsGetNormalizedPathname (MethodNode, TRUE);
3474dffc0abSAugustin Cavalier     }
3484dffc0abSAugustin Cavalier 
3494dffc0abSAugustin Cavalier     Enabled = AcpiExInterpreterTraceEnabled (Pathname);
3504dffc0abSAugustin Cavalier     if (Enabled && !AcpiGbl_TraceMethodObject)
3514dffc0abSAugustin Cavalier     {
3524dffc0abSAugustin Cavalier         AcpiGbl_TraceMethodObject = ObjDesc;
3534dffc0abSAugustin Cavalier         AcpiGbl_OriginalDbgLevel = AcpiDbgLevel;
3544dffc0abSAugustin Cavalier         AcpiGbl_OriginalDbgLayer = AcpiDbgLayer;
3554dffc0abSAugustin Cavalier         AcpiDbgLevel = ACPI_TRACE_LEVEL_ALL;
3564dffc0abSAugustin Cavalier         AcpiDbgLayer = ACPI_TRACE_LAYER_ALL;
3574dffc0abSAugustin Cavalier 
3584dffc0abSAugustin Cavalier         if (AcpiGbl_TraceDbgLevel)
3594dffc0abSAugustin Cavalier         {
3604dffc0abSAugustin Cavalier             AcpiDbgLevel = AcpiGbl_TraceDbgLevel;
3614dffc0abSAugustin Cavalier         }
3624dffc0abSAugustin Cavalier 
3634dffc0abSAugustin Cavalier         if (AcpiGbl_TraceDbgLayer)
3644dffc0abSAugustin Cavalier         {
3654dffc0abSAugustin Cavalier             AcpiDbgLayer = AcpiGbl_TraceDbgLayer;
3664dffc0abSAugustin Cavalier         }
3674dffc0abSAugustin Cavalier     }
3684dffc0abSAugustin Cavalier 
3694dffc0abSAugustin Cavalier     if (Enabled)
3704dffc0abSAugustin Cavalier     {
3714dffc0abSAugustin Cavalier         ACPI_TRACE_POINT (ACPI_TRACE_AML_METHOD, TRUE,
3724dffc0abSAugustin Cavalier             ObjDesc ? ObjDesc->Method.AmlStart : NULL, Pathname);
3734dffc0abSAugustin Cavalier     }
3744dffc0abSAugustin Cavalier 
3754dffc0abSAugustin Cavalier     if (Pathname)
3764dffc0abSAugustin Cavalier     {
3774dffc0abSAugustin Cavalier         ACPI_FREE (Pathname);
3784dffc0abSAugustin Cavalier     }
3794dffc0abSAugustin Cavalier }
3804dffc0abSAugustin Cavalier 
3814dffc0abSAugustin Cavalier 
3824dffc0abSAugustin Cavalier /*******************************************************************************
3834dffc0abSAugustin Cavalier  *
3844dffc0abSAugustin Cavalier  * FUNCTION:    AcpiExStopTraceMethod
3854dffc0abSAugustin Cavalier  *
3864dffc0abSAugustin Cavalier  * PARAMETERS:  MethodNode          - Node of the method
3874dffc0abSAugustin Cavalier  *              ObjDesc             - The method object
3884dffc0abSAugustin Cavalier  *              WalkState           - current state, NULL if not yet executing
3894dffc0abSAugustin Cavalier  *                                    a method.
3904dffc0abSAugustin Cavalier  *
3914dffc0abSAugustin Cavalier  * RETURN:      None
3924dffc0abSAugustin Cavalier  *
3934dffc0abSAugustin Cavalier  * DESCRIPTION: Stop control method execution trace
3944dffc0abSAugustin Cavalier  *
3954dffc0abSAugustin Cavalier  ******************************************************************************/
3964dffc0abSAugustin Cavalier 
3974dffc0abSAugustin Cavalier void
AcpiExStopTraceMethod(ACPI_NAMESPACE_NODE * MethodNode,ACPI_OPERAND_OBJECT * ObjDesc,ACPI_WALK_STATE * WalkState)3984dffc0abSAugustin Cavalier AcpiExStopTraceMethod (
3994dffc0abSAugustin Cavalier     ACPI_NAMESPACE_NODE     *MethodNode,
4004dffc0abSAugustin Cavalier     ACPI_OPERAND_OBJECT     *ObjDesc,
4014dffc0abSAugustin Cavalier     ACPI_WALK_STATE         *WalkState)
4024dffc0abSAugustin Cavalier {
4034dffc0abSAugustin Cavalier     char                    *Pathname = NULL;
4044dffc0abSAugustin Cavalier     BOOLEAN                 Enabled;
4054dffc0abSAugustin Cavalier 
4064dffc0abSAugustin Cavalier 
4074dffc0abSAugustin Cavalier     ACPI_FUNCTION_NAME (ExStopTraceMethod);
4084dffc0abSAugustin Cavalier 
4094dffc0abSAugustin Cavalier 
4104dffc0abSAugustin Cavalier     if (MethodNode)
4114dffc0abSAugustin Cavalier     {
4124dffc0abSAugustin Cavalier         Pathname = AcpiNsGetNormalizedPathname (MethodNode, TRUE);
4134dffc0abSAugustin Cavalier     }
4144dffc0abSAugustin Cavalier 
4154dffc0abSAugustin Cavalier     Enabled = AcpiExInterpreterTraceEnabled (NULL);
4164dffc0abSAugustin Cavalier 
4174dffc0abSAugustin Cavalier     if (Enabled)
4184dffc0abSAugustin Cavalier     {
4194dffc0abSAugustin Cavalier         ACPI_TRACE_POINT (ACPI_TRACE_AML_METHOD, FALSE,
4204dffc0abSAugustin Cavalier             ObjDesc ? ObjDesc->Method.AmlStart : NULL, Pathname);
4214dffc0abSAugustin Cavalier     }
4224dffc0abSAugustin Cavalier 
4234dffc0abSAugustin Cavalier     /* Check whether the tracer should be stopped */
4244dffc0abSAugustin Cavalier 
4254dffc0abSAugustin Cavalier     if (AcpiGbl_TraceMethodObject == ObjDesc)
4264dffc0abSAugustin Cavalier     {
4274dffc0abSAugustin Cavalier         /* Disable further tracing if type is one-shot */
4284dffc0abSAugustin Cavalier 
4294dffc0abSAugustin Cavalier         if (AcpiGbl_TraceFlags & ACPI_TRACE_ONESHOT)
4304dffc0abSAugustin Cavalier         {
4314dffc0abSAugustin Cavalier             AcpiGbl_TraceMethodName = NULL;
4324dffc0abSAugustin Cavalier         }
4334dffc0abSAugustin Cavalier 
4344dffc0abSAugustin Cavalier         AcpiDbgLevel = AcpiGbl_OriginalDbgLevel;
4354dffc0abSAugustin Cavalier         AcpiDbgLayer = AcpiGbl_OriginalDbgLayer;
4364dffc0abSAugustin Cavalier         AcpiGbl_TraceMethodObject = NULL;
4374dffc0abSAugustin Cavalier     }
4384dffc0abSAugustin Cavalier 
4394dffc0abSAugustin Cavalier     if (Pathname)
4404dffc0abSAugustin Cavalier     {
4414dffc0abSAugustin Cavalier         ACPI_FREE (Pathname);
4424dffc0abSAugustin Cavalier     }
4434dffc0abSAugustin Cavalier }
4444dffc0abSAugustin Cavalier 
4454dffc0abSAugustin Cavalier 
4464dffc0abSAugustin Cavalier /*******************************************************************************
4474dffc0abSAugustin Cavalier  *
4484dffc0abSAugustin Cavalier  * FUNCTION:    AcpiExStartTraceOpcode
4494dffc0abSAugustin Cavalier  *
4504dffc0abSAugustin Cavalier  * PARAMETERS:  Op                  - The parser opcode object
4514dffc0abSAugustin Cavalier  *              WalkState           - current state, NULL if not yet executing
4524dffc0abSAugustin Cavalier  *                                    a method.
4534dffc0abSAugustin Cavalier  *
4544dffc0abSAugustin Cavalier  * RETURN:      None
4554dffc0abSAugustin Cavalier  *
4564dffc0abSAugustin Cavalier  * DESCRIPTION: Start opcode execution trace
4574dffc0abSAugustin Cavalier  *
4584dffc0abSAugustin Cavalier  ******************************************************************************/
4594dffc0abSAugustin Cavalier 
4604dffc0abSAugustin Cavalier void
AcpiExStartTraceOpcode(ACPI_PARSE_OBJECT * Op,ACPI_WALK_STATE * WalkState)4614dffc0abSAugustin Cavalier AcpiExStartTraceOpcode (
4624dffc0abSAugustin Cavalier     ACPI_PARSE_OBJECT       *Op,
4634dffc0abSAugustin Cavalier     ACPI_WALK_STATE         *WalkState)
4644dffc0abSAugustin Cavalier {
4654dffc0abSAugustin Cavalier 
4664dffc0abSAugustin Cavalier     ACPI_FUNCTION_NAME (ExStartTraceOpcode);
4674dffc0abSAugustin Cavalier 
4684dffc0abSAugustin Cavalier 
4694dffc0abSAugustin Cavalier     if (AcpiExInterpreterTraceEnabled (NULL) &&
4704dffc0abSAugustin Cavalier         (AcpiGbl_TraceFlags & ACPI_TRACE_OPCODE))
4714dffc0abSAugustin Cavalier     {
4724dffc0abSAugustin Cavalier         ACPI_TRACE_POINT (ACPI_TRACE_AML_OPCODE, TRUE,
4734dffc0abSAugustin Cavalier             Op->Common.Aml, Op->Common.AmlOpName);
4744dffc0abSAugustin Cavalier     }
4754dffc0abSAugustin Cavalier }
4764dffc0abSAugustin Cavalier 
4774dffc0abSAugustin Cavalier 
4784dffc0abSAugustin Cavalier /*******************************************************************************
4794dffc0abSAugustin Cavalier  *
4804dffc0abSAugustin Cavalier  * FUNCTION:    AcpiExStopTraceOpcode
4814dffc0abSAugustin Cavalier  *
4824dffc0abSAugustin Cavalier  * PARAMETERS:  Op                  - The parser opcode object
4834dffc0abSAugustin Cavalier  *              WalkState           - current state, NULL if not yet executing
4844dffc0abSAugustin Cavalier  *                                    a method.
4854dffc0abSAugustin Cavalier  *
4864dffc0abSAugustin Cavalier  * RETURN:      None
4874dffc0abSAugustin Cavalier  *
4884dffc0abSAugustin Cavalier  * DESCRIPTION: Stop opcode execution trace
4894dffc0abSAugustin Cavalier  *
4904dffc0abSAugustin Cavalier  ******************************************************************************/
4914dffc0abSAugustin Cavalier 
4924dffc0abSAugustin Cavalier void
AcpiExStopTraceOpcode(ACPI_PARSE_OBJECT * Op,ACPI_WALK_STATE * WalkState)4934dffc0abSAugustin Cavalier AcpiExStopTraceOpcode (
4944dffc0abSAugustin Cavalier     ACPI_PARSE_OBJECT       *Op,
4954dffc0abSAugustin Cavalier     ACPI_WALK_STATE         *WalkState)
4964dffc0abSAugustin Cavalier {
4974dffc0abSAugustin Cavalier 
4984dffc0abSAugustin Cavalier     ACPI_FUNCTION_NAME (ExStopTraceOpcode);
4994dffc0abSAugustin Cavalier 
5004dffc0abSAugustin Cavalier 
5014dffc0abSAugustin Cavalier     if (AcpiExInterpreterTraceEnabled (NULL) &&
5024dffc0abSAugustin Cavalier         (AcpiGbl_TraceFlags & ACPI_TRACE_OPCODE))
5034dffc0abSAugustin Cavalier     {
5044dffc0abSAugustin Cavalier         ACPI_TRACE_POINT (ACPI_TRACE_AML_OPCODE, FALSE,
5054dffc0abSAugustin Cavalier             Op->Common.Aml, Op->Common.AmlOpName);
5064dffc0abSAugustin Cavalier     }
5074dffc0abSAugustin Cavalier }
508