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 #include "tx_trace.h"
30 #include "tx_thread.h"
31 
32 
33 /**************************************************************************/
34 /*                                                                        */
35 /*  FUNCTION                                               RELEASE        */
36 /*                                                                        */
37 /*    _tx_trace_interrupt_control                         PORTABLE C      */
38 /*                                                           6.1          */
39 /*  AUTHOR                                                                */
40 /*                                                                        */
41 /*    William E. Lamie, Microsoft Corporation                             */
42 /*                                                                        */
43 /*  DESCRIPTION                                                           */
44 /*                                                                        */
45 /*    This function provides a shell for the tx_interrupt_control         */
46 /*    function so that a trace event can be logged for its use.           */
47 /*                                                                        */
48 /*  INPUT                                                                 */
49 /*                                                                        */
50 /*    new_posture                           New interrupt posture         */
51 /*                                                                        */
52 /*  OUTPUT                                                                */
53 /*                                                                        */
54 /*    Previous Interrupt Posture                                          */
55 /*                                                                        */
56 /*  CALLS                                                                 */
57 /*                                                                        */
58 /*    _tx_thread_interrupt_control          Interrupt control service     */
59 /*                                                                        */
60 /*  CALLED BY                                                             */
61 /*                                                                        */
62 /*    Application Code                                                    */
63 /*                                                                        */
64 /*  RELEASE HISTORY                                                       */
65 /*                                                                        */
66 /*    DATE              NAME                      DESCRIPTION             */
67 /*                                                                        */
68 /*  05-19-2020     William E. Lamie         Initial Version 6.0           */
69 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
70 /*                                            resulting in version 6.1    */
71 /*                                                                        */
72 /**************************************************************************/
_tx_trace_interrupt_control(UINT new_posture)73 UINT  _tx_trace_interrupt_control(UINT new_posture)
74 {
75 
76 #ifdef TX_ENABLE_EVENT_TRACE
77 
78 TX_INTERRUPT_SAVE_AREA
79 UINT    saved_posture;
80 
81     /* Disable interrupts.  */
82     TX_DISABLE
83 
84     /* Insert this event into the trace buffer.  */
85     TX_TRACE_IN_LINE_INSERT(TX_TRACE_INTERRUPT_CONTROL, TX_ULONG_TO_POINTER_CONVERT(new_posture), TX_POINTER_TO_ULONG_CONVERT(&saved_posture), 0, 0, TX_TRACE_INTERRUPT_CONTROL_EVENT)
86 
87     /* Restore interrupts.  */
88     TX_RESTORE
89 
90     /* Perform the interrupt service.  */
91     saved_posture =  _tx_thread_interrupt_control(new_posture);
92 
93     /* Return saved posture.  */
94     return(saved_posture);
95 #else
96 
97 UINT    saved_posture;
98 
99     /* Perform the interrupt service.  */
100     saved_posture =  _tx_thread_interrupt_control(new_posture);
101 
102     /* Return saved posture.  */
103     return(saved_posture);
104 #endif
105 }
106 
107