xref: /freebsd/sys/contrib/dev/acpica/components/executer/extrace.c (revision 95c8b4d74bced30f26d19f1d6fcd6310fe99486f)
1f8146b88SJung-uk Kim /******************************************************************************
2f8146b88SJung-uk Kim  *
3f8146b88SJung-uk Kim  * Module Name: extrace - Support for interpreter execution tracing
4f8146b88SJung-uk Kim  *
5f8146b88SJung-uk Kim  *****************************************************************************/
6f8146b88SJung-uk Kim 
70d84335fSJung-uk Kim /******************************************************************************
80d84335fSJung-uk Kim  *
90d84335fSJung-uk Kim  * 1. Copyright Notice
100d84335fSJung-uk Kim  *
1158308fadSJung-uk Kim  * Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
12f8146b88SJung-uk Kim  * All rights reserved.
13f8146b88SJung-uk Kim  *
140d84335fSJung-uk Kim  * 2. License
150d84335fSJung-uk Kim  *
160d84335fSJung-uk Kim  * 2.1. This is your license from Intel Corp. under its intellectual property
170d84335fSJung-uk Kim  * rights. You may have additional license terms from the party that provided
180d84335fSJung-uk Kim  * you this software, covering your right to use that party's intellectual
190d84335fSJung-uk Kim  * property rights.
200d84335fSJung-uk Kim  *
210d84335fSJung-uk Kim  * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
220d84335fSJung-uk Kim  * copy of the source code appearing in this file ("Covered Code") an
230d84335fSJung-uk Kim  * irrevocable, perpetual, worldwide license under Intel's copyrights in the
240d84335fSJung-uk Kim  * base code distributed originally by Intel ("Original Intel Code") to copy,
250d84335fSJung-uk Kim  * make derivatives, distribute, use and display any portion of the Covered
260d84335fSJung-uk Kim  * Code in any form, with the right to sublicense such rights; and
270d84335fSJung-uk Kim  *
280d84335fSJung-uk Kim  * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
290d84335fSJung-uk Kim  * license (with the right to sublicense), under only those claims of Intel
300d84335fSJung-uk Kim  * patents that are infringed by the Original Intel Code, to make, use, sell,
310d84335fSJung-uk Kim  * offer to sell, and import the Covered Code and derivative works thereof
320d84335fSJung-uk Kim  * solely to the minimum extent necessary to exercise the above copyright
330d84335fSJung-uk Kim  * license, and in no event shall the patent license extend to any additions
340d84335fSJung-uk Kim  * to or modifications of the Original Intel Code. No other license or right
350d84335fSJung-uk Kim  * is granted directly or by implication, estoppel or otherwise;
360d84335fSJung-uk Kim  *
370d84335fSJung-uk Kim  * The above copyright and patent license is granted only if the following
380d84335fSJung-uk Kim  * conditions are met:
390d84335fSJung-uk Kim  *
400d84335fSJung-uk Kim  * 3. Conditions
410d84335fSJung-uk Kim  *
420d84335fSJung-uk Kim  * 3.1. Redistribution of Source with Rights to Further Distribute Source.
430d84335fSJung-uk Kim  * Redistribution of source code of any substantial portion of the Covered
440d84335fSJung-uk Kim  * Code or modification with rights to further distribute source must include
450d84335fSJung-uk Kim  * the above Copyright Notice, the above License, this list of Conditions,
460d84335fSJung-uk Kim  * and the following Disclaimer and Export Compliance provision. In addition,
470d84335fSJung-uk Kim  * Licensee must cause all Covered Code to which Licensee contributes to
480d84335fSJung-uk Kim  * contain a file documenting the changes Licensee made to create that Covered
490d84335fSJung-uk Kim  * Code and the date of any change. Licensee must include in that file the
500d84335fSJung-uk Kim  * documentation of any changes made by any predecessor Licensee. Licensee
510d84335fSJung-uk Kim  * must include a prominent statement that the modification is derived,
520d84335fSJung-uk Kim  * directly or indirectly, from Original Intel Code.
530d84335fSJung-uk Kim  *
540d84335fSJung-uk Kim  * 3.2. Redistribution of Source with no Rights to Further Distribute Source.
550d84335fSJung-uk Kim  * Redistribution of source code of any substantial portion of the Covered
560d84335fSJung-uk Kim  * Code or modification without rights to further distribute source must
570d84335fSJung-uk Kim  * include the following Disclaimer and Export Compliance provision in the
580d84335fSJung-uk Kim  * documentation and/or other materials provided with distribution. In
590d84335fSJung-uk Kim  * addition, Licensee may not authorize further sublicense of source of any
600d84335fSJung-uk Kim  * portion of the Covered Code, and must include terms to the effect that the
610d84335fSJung-uk Kim  * license from Licensee to its licensee is limited to the intellectual
620d84335fSJung-uk Kim  * property embodied in the software Licensee provides to its licensee, and
630d84335fSJung-uk Kim  * not to intellectual property embodied in modifications its licensee may
640d84335fSJung-uk Kim  * make.
650d84335fSJung-uk Kim  *
660d84335fSJung-uk Kim  * 3.3. Redistribution of Executable. Redistribution in executable form of any
670d84335fSJung-uk Kim  * substantial portion of the Covered Code or modification must reproduce the
680d84335fSJung-uk Kim  * above Copyright Notice, and the following Disclaimer and Export Compliance
690d84335fSJung-uk Kim  * provision in the documentation and/or other materials provided with the
700d84335fSJung-uk Kim  * distribution.
710d84335fSJung-uk Kim  *
720d84335fSJung-uk Kim  * 3.4. Intel retains all right, title, and interest in and to the Original
730d84335fSJung-uk Kim  * Intel Code.
740d84335fSJung-uk Kim  *
750d84335fSJung-uk Kim  * 3.5. Neither the name Intel nor any other trademark owned or controlled by
760d84335fSJung-uk Kim  * Intel shall be used in advertising or otherwise to promote the sale, use or
770d84335fSJung-uk Kim  * other dealings in products derived from or relating to the Covered Code
780d84335fSJung-uk Kim  * without prior written authorization from Intel.
790d84335fSJung-uk Kim  *
800d84335fSJung-uk Kim  * 4. Disclaimer and Export Compliance
810d84335fSJung-uk Kim  *
820d84335fSJung-uk Kim  * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
830d84335fSJung-uk Kim  * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
840d84335fSJung-uk Kim  * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
850d84335fSJung-uk Kim  * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
860d84335fSJung-uk Kim  * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
870d84335fSJung-uk Kim  * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
880d84335fSJung-uk Kim  * PARTICULAR PURPOSE.
890d84335fSJung-uk Kim  *
900d84335fSJung-uk Kim  * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
910d84335fSJung-uk Kim  * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
920d84335fSJung-uk Kim  * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
930d84335fSJung-uk Kim  * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
940d84335fSJung-uk Kim  * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
950d84335fSJung-uk Kim  * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
960d84335fSJung-uk Kim  * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
970d84335fSJung-uk Kim  * LIMITED REMEDY.
980d84335fSJung-uk Kim  *
990d84335fSJung-uk Kim  * 4.3. Licensee shall not export, either directly or indirectly, any of this
1000d84335fSJung-uk Kim  * software or system incorporating such software without first obtaining any
1010d84335fSJung-uk Kim  * required license or other approval from the U. S. Department of Commerce or
1020d84335fSJung-uk Kim  * any other agency or department of the United States Government. In the
1030d84335fSJung-uk Kim  * event Licensee exports any such software from the United States or
1040d84335fSJung-uk Kim  * re-exports any such software from a foreign destination, Licensee shall
1050d84335fSJung-uk Kim  * ensure that the distribution and export/re-export of the software is in
1060d84335fSJung-uk Kim  * compliance with all laws, regulations, orders, or other restrictions of the
1070d84335fSJung-uk Kim  * U.S. Export Administration Regulations. Licensee agrees that neither it nor
1080d84335fSJung-uk Kim  * any of its subsidiaries will export/re-export any technical data, process,
1090d84335fSJung-uk Kim  * software, or service, directly or indirectly, to any country for which the
1100d84335fSJung-uk Kim  * United States government or any agency thereof requires an export license,
1110d84335fSJung-uk Kim  * other governmental approval, or letter of assurance, without first obtaining
1120d84335fSJung-uk Kim  * such license, approval or letter.
1130d84335fSJung-uk Kim  *
1140d84335fSJung-uk Kim  *****************************************************************************
1150d84335fSJung-uk Kim  *
1160d84335fSJung-uk Kim  * Alternatively, you may choose to be licensed under the terms of the
1170d84335fSJung-uk Kim  * following license:
1180d84335fSJung-uk Kim  *
119f8146b88SJung-uk Kim  * Redistribution and use in source and binary forms, with or without
120f8146b88SJung-uk Kim  * modification, are permitted provided that the following conditions
121f8146b88SJung-uk Kim  * are met:
122f8146b88SJung-uk Kim  * 1. Redistributions of source code must retain the above copyright
123f8146b88SJung-uk Kim  *    notice, this list of conditions, and the following disclaimer,
124f8146b88SJung-uk Kim  *    without modification.
125f8146b88SJung-uk Kim  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
126f8146b88SJung-uk Kim  *    substantially similar to the "NO WARRANTY" disclaimer below
127f8146b88SJung-uk Kim  *    ("Disclaimer") and any redistribution must be conditioned upon
128f8146b88SJung-uk Kim  *    including a substantially similar Disclaimer requirement for further
129f8146b88SJung-uk Kim  *    binary redistribution.
130f8146b88SJung-uk Kim  * 3. Neither the names of the above-listed copyright holders nor the names
131f8146b88SJung-uk Kim  *    of any contributors may be used to endorse or promote products derived
132f8146b88SJung-uk Kim  *    from this software without specific prior written permission.
133f8146b88SJung-uk Kim  *
1340d84335fSJung-uk Kim  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
1350d84335fSJung-uk Kim  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
1360d84335fSJung-uk Kim  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
1370d84335fSJung-uk Kim  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
1380d84335fSJung-uk Kim  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
1390d84335fSJung-uk Kim  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
1400d84335fSJung-uk Kim  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
1410d84335fSJung-uk Kim  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
1420d84335fSJung-uk Kim  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1430d84335fSJung-uk Kim  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
1440d84335fSJung-uk Kim  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1450d84335fSJung-uk Kim  *
1460d84335fSJung-uk Kim  * Alternatively, you may choose to be licensed under the terms of the
147f8146b88SJung-uk Kim  * GNU General Public License ("GPL") version 2 as published by the Free
148f8146b88SJung-uk Kim  * Software Foundation.
149f8146b88SJung-uk Kim  *
1500d84335fSJung-uk Kim  *****************************************************************************/
151f8146b88SJung-uk Kim 
152f8146b88SJung-uk Kim #include <contrib/dev/acpica/include/acpi.h>
153f8146b88SJung-uk Kim #include <contrib/dev/acpica/include/accommon.h>
154f8146b88SJung-uk Kim #include <contrib/dev/acpica/include/acnamesp.h>
155f8146b88SJung-uk Kim #include <contrib/dev/acpica/include/acinterp.h>
156f8146b88SJung-uk Kim 
157f8146b88SJung-uk Kim 
158f8146b88SJung-uk Kim #define _COMPONENT          ACPI_EXECUTER
159f8146b88SJung-uk Kim         ACPI_MODULE_NAME    ("extrace")
160f8146b88SJung-uk Kim 
161f8146b88SJung-uk Kim 
162f8146b88SJung-uk Kim static ACPI_OPERAND_OBJECT  *AcpiGbl_TraceMethodObject = NULL;
163f8146b88SJung-uk Kim 
164f8146b88SJung-uk Kim /* Local prototypes */
165f8146b88SJung-uk Kim 
166f8146b88SJung-uk Kim #ifdef ACPI_DEBUG_OUTPUT
167f8146b88SJung-uk Kim static const char *
168f8146b88SJung-uk Kim AcpiExGetTraceEventName (
169f8146b88SJung-uk Kim     ACPI_TRACE_EVENT_TYPE   Type);
170f8146b88SJung-uk Kim #endif
171f8146b88SJung-uk Kim 
172f8146b88SJung-uk Kim 
173f8146b88SJung-uk Kim /*******************************************************************************
174f8146b88SJung-uk Kim  *
175f8146b88SJung-uk Kim  * FUNCTION:    AcpiExInterpreterTraceEnabled
176f8146b88SJung-uk Kim  *
177f8146b88SJung-uk Kim  * PARAMETERS:  Name                - Whether method name should be matched,
178f8146b88SJung-uk Kim  *                                    this should be checked before starting
179f8146b88SJung-uk Kim  *                                    the tracer
180f8146b88SJung-uk Kim  *
181f8146b88SJung-uk Kim  * RETURN:      TRUE if interpreter trace is enabled.
182f8146b88SJung-uk Kim  *
183f8146b88SJung-uk Kim  * DESCRIPTION: Check whether interpreter trace is enabled
184f8146b88SJung-uk Kim  *
185f8146b88SJung-uk Kim  ******************************************************************************/
186f8146b88SJung-uk Kim 
187f8146b88SJung-uk Kim static BOOLEAN
AcpiExInterpreterTraceEnabled(char * Name)188f8146b88SJung-uk Kim AcpiExInterpreterTraceEnabled (
189f8146b88SJung-uk Kim     char                    *Name)
190f8146b88SJung-uk Kim {
191f8146b88SJung-uk Kim 
192f8146b88SJung-uk Kim     /* Check if tracing is enabled */
193f8146b88SJung-uk Kim 
194f8146b88SJung-uk Kim     if (!(AcpiGbl_TraceFlags & ACPI_TRACE_ENABLED))
195f8146b88SJung-uk Kim     {
196f8146b88SJung-uk Kim         return (FALSE);
197f8146b88SJung-uk Kim     }
198f8146b88SJung-uk Kim 
199f8146b88SJung-uk Kim     /*
200f8146b88SJung-uk Kim      * Check if tracing is filtered:
201f8146b88SJung-uk Kim      *
202f8146b88SJung-uk Kim      * 1. If the tracer is started, AcpiGbl_TraceMethodObject should have
203f8146b88SJung-uk Kim      *    been filled by the trace starter
204f8146b88SJung-uk Kim      * 2. If the tracer is not started, AcpiGbl_TraceMethodName should be
205f8146b88SJung-uk Kim      *    matched if it is specified
206f8146b88SJung-uk Kim      * 3. If the tracer is oneshot style, AcpiGbl_TraceMethodName should
207f8146b88SJung-uk Kim      *    not be cleared by the trace stopper during the first match
208f8146b88SJung-uk Kim      */
209f8146b88SJung-uk Kim     if (AcpiGbl_TraceMethodObject)
210f8146b88SJung-uk Kim     {
211f8146b88SJung-uk Kim         return (TRUE);
212f8146b88SJung-uk Kim     }
213f8146b88SJung-uk Kim 
214f8146b88SJung-uk Kim     if (Name &&
215f8146b88SJung-uk Kim         (AcpiGbl_TraceMethodName &&
216f8146b88SJung-uk Kim          strcmp (AcpiGbl_TraceMethodName, Name)))
217f8146b88SJung-uk Kim     {
218f8146b88SJung-uk Kim         return (FALSE);
219f8146b88SJung-uk Kim     }
220f8146b88SJung-uk Kim 
221f8146b88SJung-uk Kim     if ((AcpiGbl_TraceFlags & ACPI_TRACE_ONESHOT) &&
222f8146b88SJung-uk Kim         !AcpiGbl_TraceMethodName)
223f8146b88SJung-uk Kim     {
224f8146b88SJung-uk Kim         return (FALSE);
225f8146b88SJung-uk Kim     }
226f8146b88SJung-uk Kim 
227f8146b88SJung-uk Kim     return (TRUE);
228f8146b88SJung-uk Kim }
229f8146b88SJung-uk Kim 
230f8146b88SJung-uk Kim 
231f8146b88SJung-uk Kim /*******************************************************************************
232f8146b88SJung-uk Kim  *
233f8146b88SJung-uk Kim  * FUNCTION:    AcpiExGetTraceEventName
234f8146b88SJung-uk Kim  *
235f8146b88SJung-uk Kim  * PARAMETERS:  Type            - Trace event type
236f8146b88SJung-uk Kim  *
237f8146b88SJung-uk Kim  * RETURN:      Trace event name.
238f8146b88SJung-uk Kim  *
239f8146b88SJung-uk Kim  * DESCRIPTION: Used to obtain the full trace event name.
240f8146b88SJung-uk Kim  *
241f8146b88SJung-uk Kim  ******************************************************************************/
242f8146b88SJung-uk Kim 
243f8146b88SJung-uk Kim #ifdef ACPI_DEBUG_OUTPUT
244f8146b88SJung-uk Kim 
245f8146b88SJung-uk Kim static const char *
AcpiExGetTraceEventName(ACPI_TRACE_EVENT_TYPE Type)246f8146b88SJung-uk Kim AcpiExGetTraceEventName (
247f8146b88SJung-uk Kim     ACPI_TRACE_EVENT_TYPE   Type)
248f8146b88SJung-uk Kim {
249f8146b88SJung-uk Kim 
250f8146b88SJung-uk Kim     switch (Type)
251f8146b88SJung-uk Kim     {
252f8146b88SJung-uk Kim     case ACPI_TRACE_AML_METHOD:
253f8146b88SJung-uk Kim 
254f8146b88SJung-uk Kim         return "Method";
255f8146b88SJung-uk Kim 
256f8146b88SJung-uk Kim     case ACPI_TRACE_AML_OPCODE:
257f8146b88SJung-uk Kim 
258f8146b88SJung-uk Kim         return "Opcode";
259f8146b88SJung-uk Kim 
260f8146b88SJung-uk Kim     case ACPI_TRACE_AML_REGION:
261f8146b88SJung-uk Kim 
262f8146b88SJung-uk Kim         return "Region";
263f8146b88SJung-uk Kim 
264f8146b88SJung-uk Kim     default:
265f8146b88SJung-uk Kim 
266f8146b88SJung-uk Kim         return "";
267f8146b88SJung-uk Kim     }
268f8146b88SJung-uk Kim }
269f8146b88SJung-uk Kim 
270f8146b88SJung-uk Kim #endif
271f8146b88SJung-uk Kim 
272b5daf675SJung-uk Kim /*******************************************************************************
273b5daf675SJung-uk Kim  *
274b5daf675SJung-uk Kim  * FUNCTION:    AcpiExTraceArgs
275b5daf675SJung-uk Kim  *
276b5daf675SJung-uk Kim  * PARAMETERS:  Params            - AML method arguments
277b5daf675SJung-uk Kim  *              Count             - numer of method arguments
278b5daf675SJung-uk Kim  *
279b5daf675SJung-uk Kim  * RETURN:      None
280b5daf675SJung-uk Kim  *
281b5daf675SJung-uk Kim  * DESCRIPTION: Trace any arguments
282b5daf675SJung-uk Kim  *
283b5daf675SJung-uk Kim  ******************************************************************************/
284b5daf675SJung-uk Kim 
285b5daf675SJung-uk Kim void
AcpiExTraceArgs(ACPI_OPERAND_OBJECT ** Params,UINT32 Count)286b5daf675SJung-uk Kim AcpiExTraceArgs(ACPI_OPERAND_OBJECT **Params, UINT32 Count)
287b5daf675SJung-uk Kim {
288b5daf675SJung-uk Kim     UINT32 i;
289b5daf675SJung-uk Kim 
290b5daf675SJung-uk Kim     ACPI_FUNCTION_NAME(ExTraceArgs);
291b5daf675SJung-uk Kim 
292b5daf675SJung-uk Kim     for (i = 0; i < Count; i++)
293b5daf675SJung-uk Kim     {
294b5daf675SJung-uk Kim         ACPI_OPERAND_OBJECT *obj_desc = Params[i];
295b5daf675SJung-uk Kim 
296b5daf675SJung-uk Kim         if (!i)
297b5daf675SJung-uk Kim         {
298b5daf675SJung-uk Kim             ACPI_DEBUG_PRINT((ACPI_DB_TRACE_POINT, " "));
299b5daf675SJung-uk Kim         }
300b5daf675SJung-uk Kim 
301b5daf675SJung-uk Kim         switch (obj_desc->Common.Type)
302b5daf675SJung-uk Kim         {
303b5daf675SJung-uk Kim         case ACPI_TYPE_INTEGER:
304*95c8b4d7SJohn Baldwin             ACPI_DEBUG_PRINT_RAW((ACPI_DB_TRACE_POINT, "%jx", (uintmax_t)obj_desc->Integer.Value));
305b5daf675SJung-uk Kim             break;
306b5daf675SJung-uk Kim 
307b5daf675SJung-uk Kim         case ACPI_TYPE_STRING:
308b5daf675SJung-uk Kim             if (!obj_desc->String.Length)
309b5daf675SJung-uk Kim             {
310b5daf675SJung-uk Kim                 ACPI_DEBUG_PRINT_RAW((ACPI_DB_TRACE_POINT, "NULL"));
311b5daf675SJung-uk Kim                 break;
312b5daf675SJung-uk Kim             }
313b5daf675SJung-uk Kim             if (ACPI_IS_DEBUG_ENABLED(ACPI_LV_TRACE_POINT, _COMPONENT))
314b5daf675SJung-uk Kim             {
315b5daf675SJung-uk Kim                 AcpiUtPrintString(obj_desc->String.Pointer, ACPI_UINT8_MAX);
316b5daf675SJung-uk Kim             }
317b5daf675SJung-uk Kim             break;
318b5daf675SJung-uk Kim 
319b5daf675SJung-uk Kim         default:
320b5daf675SJung-uk Kim             ACPI_DEBUG_PRINT_RAW((ACPI_DB_TRACE_POINT, "Unknown"));
321b5daf675SJung-uk Kim             break;
322b5daf675SJung-uk Kim         }
323b5daf675SJung-uk Kim 
324b5daf675SJung-uk Kim         if ((i + 1) == Count)
325b5daf675SJung-uk Kim         {
326b5daf675SJung-uk Kim             ACPI_DEBUG_PRINT_RAW((ACPI_DB_TRACE_POINT, "\n"));
327b5daf675SJung-uk Kim         }
328b5daf675SJung-uk Kim         else
329b5daf675SJung-uk Kim         {
330b5daf675SJung-uk Kim             ACPI_DEBUG_PRINT_RAW((ACPI_DB_TRACE_POINT, ", "));
331b5daf675SJung-uk Kim         }
332b5daf675SJung-uk Kim     }
333b5daf675SJung-uk Kim }
334f8146b88SJung-uk Kim 
335f8146b88SJung-uk Kim /*******************************************************************************
336f8146b88SJung-uk Kim  *
337f8146b88SJung-uk Kim  * FUNCTION:    AcpiExTracePoint
338f8146b88SJung-uk Kim  *
339f8146b88SJung-uk Kim  * PARAMETERS:  Type                - Trace event type
340f8146b88SJung-uk Kim  *              Begin               - TRUE if before execution
341f8146b88SJung-uk Kim  *              Aml                 - Executed AML address
342f8146b88SJung-uk Kim  *              Pathname            - Object path
343f8146b88SJung-uk Kim  *
344f8146b88SJung-uk Kim  * RETURN:      None
345f8146b88SJung-uk Kim  *
346f8146b88SJung-uk Kim  * DESCRIPTION: Internal interpreter execution trace.
347f8146b88SJung-uk Kim  *
348f8146b88SJung-uk Kim  ******************************************************************************/
349f8146b88SJung-uk Kim 
350f8146b88SJung-uk Kim void
AcpiExTracePoint(ACPI_TRACE_EVENT_TYPE Type,BOOLEAN Begin,UINT8 * Aml,char * Pathname)351f8146b88SJung-uk Kim AcpiExTracePoint (
352f8146b88SJung-uk Kim     ACPI_TRACE_EVENT_TYPE   Type,
353f8146b88SJung-uk Kim     BOOLEAN                 Begin,
354f8146b88SJung-uk Kim     UINT8                   *Aml,
355f8146b88SJung-uk Kim     char                    *Pathname)
356f8146b88SJung-uk Kim {
357f8146b88SJung-uk Kim 
358f8146b88SJung-uk Kim     ACPI_FUNCTION_NAME (ExTracePoint);
359f8146b88SJung-uk Kim 
360f8146b88SJung-uk Kim 
361f8146b88SJung-uk Kim     if (Pathname)
362f8146b88SJung-uk Kim     {
363f8146b88SJung-uk Kim         ACPI_DEBUG_PRINT ((ACPI_DB_TRACE_POINT,
364b5daf675SJung-uk Kim             "%s %s [%s] execution.\n",
365f8146b88SJung-uk Kim             AcpiExGetTraceEventName (Type), Begin ? "Begin" : "End",
366b5daf675SJung-uk Kim             Pathname));
367f8146b88SJung-uk Kim     }
368f8146b88SJung-uk Kim     else
369f8146b88SJung-uk Kim     {
370f8146b88SJung-uk Kim         ACPI_DEBUG_PRINT ((ACPI_DB_TRACE_POINT,
371f8146b88SJung-uk Kim             "%s %s [0x%p] execution.\n",
372f8146b88SJung-uk Kim             AcpiExGetTraceEventName (Type), Begin ? "Begin" : "End",
373f8146b88SJung-uk Kim             Aml));
374f8146b88SJung-uk Kim     }
375f8146b88SJung-uk Kim }
376f8146b88SJung-uk Kim 
377f8146b88SJung-uk Kim 
378f8146b88SJung-uk Kim /*******************************************************************************
379f8146b88SJung-uk Kim  *
380f8146b88SJung-uk Kim  * FUNCTION:    AcpiExStartTraceMethod
381f8146b88SJung-uk Kim  *
382f8146b88SJung-uk Kim  * PARAMETERS:  MethodNode          - Node of the method
383f8146b88SJung-uk Kim  *              ObjDesc             - The method object
384f8146b88SJung-uk Kim  *              WalkState           - current state, NULL if not yet executing
385f8146b88SJung-uk Kim  *                                    a method.
386f8146b88SJung-uk Kim  *
387f8146b88SJung-uk Kim  * RETURN:      None
388f8146b88SJung-uk Kim  *
389f8146b88SJung-uk Kim  * DESCRIPTION: Start control method execution trace
390f8146b88SJung-uk Kim  *
391f8146b88SJung-uk Kim  ******************************************************************************/
392f8146b88SJung-uk Kim 
393f8146b88SJung-uk Kim void
AcpiExStartTraceMethod(ACPI_NAMESPACE_NODE * MethodNode,ACPI_OPERAND_OBJECT * ObjDesc,ACPI_WALK_STATE * WalkState)394f8146b88SJung-uk Kim AcpiExStartTraceMethod (
395f8146b88SJung-uk Kim     ACPI_NAMESPACE_NODE     *MethodNode,
396f8146b88SJung-uk Kim     ACPI_OPERAND_OBJECT     *ObjDesc,
397f8146b88SJung-uk Kim     ACPI_WALK_STATE         *WalkState)
398f8146b88SJung-uk Kim {
399f8146b88SJung-uk Kim     char                    *Pathname = NULL;
400f8146b88SJung-uk Kim     BOOLEAN                 Enabled = FALSE;
401f8146b88SJung-uk Kim 
402f8146b88SJung-uk Kim 
403f8146b88SJung-uk Kim     ACPI_FUNCTION_NAME (ExStartTraceMethod);
404f8146b88SJung-uk Kim 
405f8146b88SJung-uk Kim 
406f8146b88SJung-uk Kim     if (MethodNode)
407f8146b88SJung-uk Kim     {
408f8146b88SJung-uk Kim         Pathname = AcpiNsGetNormalizedPathname (MethodNode, TRUE);
409f8146b88SJung-uk Kim     }
410f8146b88SJung-uk Kim 
411f8146b88SJung-uk Kim     Enabled = AcpiExInterpreterTraceEnabled (Pathname);
412f8146b88SJung-uk Kim     if (Enabled && !AcpiGbl_TraceMethodObject)
413f8146b88SJung-uk Kim     {
414f8146b88SJung-uk Kim         AcpiGbl_TraceMethodObject = ObjDesc;
415f8146b88SJung-uk Kim         AcpiGbl_OriginalDbgLevel = AcpiDbgLevel;
416f8146b88SJung-uk Kim         AcpiGbl_OriginalDbgLayer = AcpiDbgLayer;
417f8146b88SJung-uk Kim         AcpiDbgLevel = ACPI_TRACE_LEVEL_ALL;
418f8146b88SJung-uk Kim         AcpiDbgLayer = ACPI_TRACE_LAYER_ALL;
419f8146b88SJung-uk Kim 
420f8146b88SJung-uk Kim         if (AcpiGbl_TraceDbgLevel)
421f8146b88SJung-uk Kim         {
422f8146b88SJung-uk Kim             AcpiDbgLevel = AcpiGbl_TraceDbgLevel;
423f8146b88SJung-uk Kim         }
424f8146b88SJung-uk Kim 
425f8146b88SJung-uk Kim         if (AcpiGbl_TraceDbgLayer)
426f8146b88SJung-uk Kim         {
427f8146b88SJung-uk Kim             AcpiDbgLayer = AcpiGbl_TraceDbgLayer;
428f8146b88SJung-uk Kim         }
429f8146b88SJung-uk Kim     }
430f8146b88SJung-uk Kim 
431f8146b88SJung-uk Kim     if (Enabled)
432f8146b88SJung-uk Kim     {
433f8146b88SJung-uk Kim         ACPI_TRACE_POINT (ACPI_TRACE_AML_METHOD, TRUE,
434f8146b88SJung-uk Kim             ObjDesc ? ObjDesc->Method.AmlStart : NULL, Pathname);
435f8146b88SJung-uk Kim     }
436f8146b88SJung-uk Kim 
437f8146b88SJung-uk Kim     if (Pathname)
438f8146b88SJung-uk Kim     {
439f8146b88SJung-uk Kim         ACPI_FREE (Pathname);
440f8146b88SJung-uk Kim     }
441f8146b88SJung-uk Kim }
442f8146b88SJung-uk Kim 
443f8146b88SJung-uk Kim 
444f8146b88SJung-uk Kim /*******************************************************************************
445f8146b88SJung-uk Kim  *
446f8146b88SJung-uk Kim  * FUNCTION:    AcpiExStopTraceMethod
447f8146b88SJung-uk Kim  *
448f8146b88SJung-uk Kim  * PARAMETERS:  MethodNode          - Node of the method
449f8146b88SJung-uk Kim  *              ObjDesc             - The method object
450f8146b88SJung-uk Kim  *              WalkState           - current state, NULL if not yet executing
451f8146b88SJung-uk Kim  *                                    a method.
452f8146b88SJung-uk Kim  *
453f8146b88SJung-uk Kim  * RETURN:      None
454f8146b88SJung-uk Kim  *
455f8146b88SJung-uk Kim  * DESCRIPTION: Stop control method execution trace
456f8146b88SJung-uk Kim  *
457f8146b88SJung-uk Kim  ******************************************************************************/
458f8146b88SJung-uk Kim 
459f8146b88SJung-uk Kim void
AcpiExStopTraceMethod(ACPI_NAMESPACE_NODE * MethodNode,ACPI_OPERAND_OBJECT * ObjDesc,ACPI_WALK_STATE * WalkState)460f8146b88SJung-uk Kim AcpiExStopTraceMethod (
461f8146b88SJung-uk Kim     ACPI_NAMESPACE_NODE     *MethodNode,
462f8146b88SJung-uk Kim     ACPI_OPERAND_OBJECT     *ObjDesc,
463f8146b88SJung-uk Kim     ACPI_WALK_STATE         *WalkState)
464f8146b88SJung-uk Kim {
465f8146b88SJung-uk Kim     char                    *Pathname = NULL;
466f8146b88SJung-uk Kim     BOOLEAN                 Enabled;
467f8146b88SJung-uk Kim 
468f8146b88SJung-uk Kim 
469f8146b88SJung-uk Kim     ACPI_FUNCTION_NAME (ExStopTraceMethod);
470f8146b88SJung-uk Kim 
471f8146b88SJung-uk Kim 
472f8146b88SJung-uk Kim     if (MethodNode)
473f8146b88SJung-uk Kim     {
474f8146b88SJung-uk Kim         Pathname = AcpiNsGetNormalizedPathname (MethodNode, TRUE);
475f8146b88SJung-uk Kim     }
476f8146b88SJung-uk Kim 
477f8146b88SJung-uk Kim     Enabled = AcpiExInterpreterTraceEnabled (NULL);
478f8146b88SJung-uk Kim 
479f8146b88SJung-uk Kim     if (Enabled)
480f8146b88SJung-uk Kim     {
481f8146b88SJung-uk Kim         ACPI_TRACE_POINT (ACPI_TRACE_AML_METHOD, FALSE,
482f8146b88SJung-uk Kim             ObjDesc ? ObjDesc->Method.AmlStart : NULL, Pathname);
483f8146b88SJung-uk Kim     }
484f8146b88SJung-uk Kim 
485f8146b88SJung-uk Kim     /* Check whether the tracer should be stopped */
486f8146b88SJung-uk Kim 
487f8146b88SJung-uk Kim     if (AcpiGbl_TraceMethodObject == ObjDesc)
488f8146b88SJung-uk Kim     {
489f8146b88SJung-uk Kim         /* Disable further tracing if type is one-shot */
490f8146b88SJung-uk Kim 
491f8146b88SJung-uk Kim         if (AcpiGbl_TraceFlags & ACPI_TRACE_ONESHOT)
492f8146b88SJung-uk Kim         {
493f8146b88SJung-uk Kim             AcpiGbl_TraceMethodName = NULL;
494f8146b88SJung-uk Kim         }
495f8146b88SJung-uk Kim 
496f8146b88SJung-uk Kim         AcpiDbgLevel = AcpiGbl_OriginalDbgLevel;
497f8146b88SJung-uk Kim         AcpiDbgLayer = AcpiGbl_OriginalDbgLayer;
498f8146b88SJung-uk Kim         AcpiGbl_TraceMethodObject = NULL;
499f8146b88SJung-uk Kim     }
500f8146b88SJung-uk Kim 
501f8146b88SJung-uk Kim     if (Pathname)
502f8146b88SJung-uk Kim     {
503f8146b88SJung-uk Kim         ACPI_FREE (Pathname);
504f8146b88SJung-uk Kim     }
505f8146b88SJung-uk Kim }
506f8146b88SJung-uk Kim 
507f8146b88SJung-uk Kim 
508f8146b88SJung-uk Kim /*******************************************************************************
509f8146b88SJung-uk Kim  *
510f8146b88SJung-uk Kim  * FUNCTION:    AcpiExStartTraceOpcode
511f8146b88SJung-uk Kim  *
512f8146b88SJung-uk Kim  * PARAMETERS:  Op                  - The parser opcode object
513f8146b88SJung-uk Kim  *              WalkState           - current state, NULL if not yet executing
514f8146b88SJung-uk Kim  *                                    a method.
515f8146b88SJung-uk Kim  *
516f8146b88SJung-uk Kim  * RETURN:      None
517f8146b88SJung-uk Kim  *
518f8146b88SJung-uk Kim  * DESCRIPTION: Start opcode execution trace
519f8146b88SJung-uk Kim  *
520f8146b88SJung-uk Kim  ******************************************************************************/
521f8146b88SJung-uk Kim 
522f8146b88SJung-uk Kim void
AcpiExStartTraceOpcode(ACPI_PARSE_OBJECT * Op,ACPI_WALK_STATE * WalkState)523f8146b88SJung-uk Kim AcpiExStartTraceOpcode (
524f8146b88SJung-uk Kim     ACPI_PARSE_OBJECT       *Op,
525f8146b88SJung-uk Kim     ACPI_WALK_STATE         *WalkState)
526f8146b88SJung-uk Kim {
527f8146b88SJung-uk Kim 
528f8146b88SJung-uk Kim     ACPI_FUNCTION_NAME (ExStartTraceOpcode);
529f8146b88SJung-uk Kim 
530f8146b88SJung-uk Kim 
531f8146b88SJung-uk Kim     if (AcpiExInterpreterTraceEnabled (NULL) &&
532f8146b88SJung-uk Kim         (AcpiGbl_TraceFlags & ACPI_TRACE_OPCODE))
533f8146b88SJung-uk Kim     {
534f8146b88SJung-uk Kim         ACPI_TRACE_POINT (ACPI_TRACE_AML_OPCODE, TRUE,
535f8146b88SJung-uk Kim             Op->Common.Aml, Op->Common.AmlOpName);
536f8146b88SJung-uk Kim     }
537f8146b88SJung-uk Kim }
538f8146b88SJung-uk Kim 
539f8146b88SJung-uk Kim 
540f8146b88SJung-uk Kim /*******************************************************************************
541f8146b88SJung-uk Kim  *
542f8146b88SJung-uk Kim  * FUNCTION:    AcpiExStopTraceOpcode
543f8146b88SJung-uk Kim  *
544f8146b88SJung-uk Kim  * PARAMETERS:  Op                  - The parser opcode object
545f8146b88SJung-uk Kim  *              WalkState           - current state, NULL if not yet executing
546f8146b88SJung-uk Kim  *                                    a method.
547f8146b88SJung-uk Kim  *
548f8146b88SJung-uk Kim  * RETURN:      None
549f8146b88SJung-uk Kim  *
550f8146b88SJung-uk Kim  * DESCRIPTION: Stop opcode execution trace
551f8146b88SJung-uk Kim  *
552f8146b88SJung-uk Kim  ******************************************************************************/
553f8146b88SJung-uk Kim 
554f8146b88SJung-uk Kim void
AcpiExStopTraceOpcode(ACPI_PARSE_OBJECT * Op,ACPI_WALK_STATE * WalkState)555f8146b88SJung-uk Kim AcpiExStopTraceOpcode (
556f8146b88SJung-uk Kim     ACPI_PARSE_OBJECT       *Op,
557f8146b88SJung-uk Kim     ACPI_WALK_STATE         *WalkState)
558f8146b88SJung-uk Kim {
559f8146b88SJung-uk Kim 
560f8146b88SJung-uk Kim     ACPI_FUNCTION_NAME (ExStopTraceOpcode);
561f8146b88SJung-uk Kim 
562f8146b88SJung-uk Kim 
563f8146b88SJung-uk Kim     if (AcpiExInterpreterTraceEnabled (NULL) &&
564f8146b88SJung-uk Kim         (AcpiGbl_TraceFlags & ACPI_TRACE_OPCODE))
565f8146b88SJung-uk Kim     {
566f8146b88SJung-uk Kim         ACPI_TRACE_POINT (ACPI_TRACE_AML_OPCODE, FALSE,
567f8146b88SJung-uk Kim             Op->Common.Aml, Op->Common.AmlOpName);
568f8146b88SJung-uk Kim     }
569f8146b88SJung-uk Kim }
570