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
31
32 /**************************************************************************/
33 /* */
34 /* FUNCTION RELEASE */
35 /* */
36 /* _tx_trace_user_event_insert PORTABLE C */
37 /* 6.1 */
38 /* AUTHOR */
39 /* */
40 /* William E. Lamie, Microsoft Corporation */
41 /* */
42 /* DESCRIPTION */
43 /* */
44 /* This function inserts a user-defined event into the trace buffer. */
45 /* */
46 /* INPUT */
47 /* */
48 /* event_id User Event ID */
49 /* info_field_1 First information field */
50 /* info_field_2 First information field */
51 /* info_field_3 First information field */
52 /* info_field_4 First information field */
53 /* */
54 /* OUTPUT */
55 /* */
56 /* Completion Status */
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_user_event_insert(ULONG event_id,ULONG info_field_1,ULONG info_field_2,ULONG info_field_3,ULONG info_field_4)75 UINT _tx_trace_user_event_insert(ULONG event_id, ULONG info_field_1, ULONG info_field_2, ULONG info_field_3, ULONG info_field_4)
76 {
77
78 #ifdef TX_ENABLE_EVENT_TRACE
79
80 TX_INTERRUPT_SAVE_AREA
81
82 UINT status;
83
84
85 /* Disable interrupts. */
86 TX_DISABLE
87
88 /* Determine if trace is disabled. */
89 if (_tx_trace_buffer_current_ptr == TX_NULL)
90 {
91
92 /* Yes, trace is already disabled. */
93 status = TX_NOT_DONE;
94 }
95 else
96 {
97
98 /* Insert this event into the trace buffer. */
99 #ifdef TX_MISRA_ENABLE
100 TX_TRACE_IN_LINE_INSERT(event_id, TX_ULONG_TO_POINTER_CONVERT(info_field_1), info_field_2, info_field_3, info_field_4, ((ULONG) TX_TRACE_USER_EVENTS))
101 #else
102 TX_TRACE_IN_LINE_INSERT(event_id, info_field_1, info_field_2, info_field_3, info_field_4, TX_TRACE_USER_EVENTS)
103 #endif
104
105 /* Return successful status. */
106 status = TX_SUCCESS;
107 }
108
109 /* Restore interrupts. */
110 TX_RESTORE
111
112 /* Return completion status. */
113 return(status);
114
115 #else
116
117 UINT status;
118
119
120 /* Access input arguments just for the sake of lint, MISRA, etc. */
121 if (event_id != ((ULONG) 0))
122 {
123
124 /* Trace not enabled, return an error. */
125 status = TX_FEATURE_NOT_ENABLED;
126 }
127 else if (info_field_1 != ((ULONG) 0))
128 {
129
130 /* Trace not enabled, return an error. */
131 status = TX_FEATURE_NOT_ENABLED;
132 }
133 else if (info_field_2 != ((ULONG) 0))
134 {
135
136 /* Trace not enabled, return an error. */
137 status = TX_FEATURE_NOT_ENABLED;
138 }
139 else if (info_field_3 != ((ULONG) 0))
140 {
141
142 /* Trace not enabled, return an error. */
143 status = TX_FEATURE_NOT_ENABLED;
144 }
145 else if (info_field_4 != ((ULONG) 0))
146 {
147
148 /* Trace not enabled, return an error. */
149 status = TX_FEATURE_NOT_ENABLED;
150 }
151 else
152 {
153
154 /* Trace not enabled, return an error. */
155 status = TX_FEATURE_NOT_ENABLED;
156 }
157
158 /* Return completion status. */
159 return(status);
160 #endif
161 }
162
163