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