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