1 /***************************************************************************
2  * Copyright (c) 2024 Microsoft Corporation
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the MIT License which is available at
6  * https://opensource.org/licenses/MIT.
7  *
8  * SPDX-License-Identifier: MIT
9  **************************************************************************/
10 
11 
12 /**************************************************************************/
13 /**************************************************************************/
14 /**                                                                       */
15 /** ThreadX Component                                                     */
16 /**                                                                       */
17 /**   Trace                                                               */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 #define TX_SOURCE_CODE
23 
24 
25 /* Include necessary system files.  */
26 
27 #include "tx_api.h"
28 #ifdef TX_ENABLE_EVENT_TRACE
29 #include "tx_thread.h"
30 #endif
31 #include "tx_trace.h"
32 
33 
34 /**************************************************************************/
35 /*                                                                        */
36 /*  FUNCTION                                               RELEASE        */
37 /*                                                                        */
38 /*    _tx_trace_isr_exit_insert                           PORTABLE C      */
39 /*                                                           6.1          */
40 /*  AUTHOR                                                                */
41 /*                                                                        */
42 /*    William E. Lamie, Microsoft Corporation                             */
43 /*                                                                        */
44 /*  DESCRIPTION                                                           */
45 /*                                                                        */
46 /*    This function provides inserts an ISR exit event into the trace     */
47 /*    buffer.                                                             */
48 /*                                                                        */
49 /*  INPUT                                                                 */
50 /*                                                                        */
51 /*    isr_id                                User defined ISR ID           */
52 /*                                                                        */
53 /*  OUTPUT                                                                */
54 /*                                                                        */
55 /*    None                                                                */
56 /*                                                                        */
57 /*  CALLS                                                                 */
58 /*                                                                        */
59 /*    None                                                                */
60 /*                                                                        */
61 /*  CALLED BY                                                             */
62 /*                                                                        */
63 /*    Application Code                                                    */
64 /*                                                                        */
65 /*  RELEASE HISTORY                                                       */
66 /*                                                                        */
67 /*    DATE              NAME                      DESCRIPTION             */
68 /*                                                                        */
69 /*  05-19-2020     William E. Lamie         Initial Version 6.0           */
70 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
71 /*                                            resulting in version 6.1    */
72 /*                                                                        */
73 /**************************************************************************/
_tx_trace_isr_exit_insert(ULONG isr_id)74 VOID  _tx_trace_isr_exit_insert(ULONG isr_id)
75 {
76 
77 TX_INTERRUPT_SAVE_AREA
78 
79 
80 #ifdef TX_ENABLE_EVENT_TRACE
81 
82 UINT            stack_address;
83 ULONG           system_state;
84 UINT            preempt_disable;
85 
86 
87     /* Disable interrupts.  */
88     TX_DISABLE
89 
90     /* Insert this event into the trace buffer.  */
91     system_state =  TX_THREAD_GET_SYSTEM_STATE();
92     preempt_disable =  _tx_thread_preempt_disable;
93     TX_TRACE_IN_LINE_INSERT(TX_TRACE_ISR_EXIT, &stack_address, isr_id, system_state, preempt_disable, TX_TRACE_INTERNAL_EVENTS)
94 
95     /* Restore interrupts.  */
96     TX_RESTORE
97 #else
98 
99     /* Access input arguments just for the sake of lint, MISRA, etc.  */
100     if (isr_id != ((ULONG) 0))
101     {
102 
103         /* NOP code.  */
104         TX_DISABLE
105         TX_RESTORE
106     }
107 #endif
108 }
109 
110