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 /** USBX Component */
17 /** */
18 /** Trace */
19 /** */
20 /**************************************************************************/
21 /**************************************************************************/
22
23 #ifndef UX_SOURCE_CODE
24 #define UX_SOURCE_CODE
25 #endif
26
27
28 /* Include necessary system files. */
29
30 #include "ux_api.h"
31
32
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _ux_trace_event_insert PORTABLE C */
38 /* 6.1.9 */
39 /* AUTHOR */
40 /* */
41 /* Chaoqiong Xiao, Microsoft Corporation */
42 /* */
43 /* DESCRIPTION */
44 /* */
45 /* This function inserts a USBX event into the current trace buffer. */
46 /* */
47 /* INPUT */
48 /* */
49 /* event_id User Event ID */
50 /* info_field_1 First information field */
51 /* info_field_2 First information field */
52 /* info_field_3 First information field */
53 /* info_field_4 First information field */
54 /* current_event Current event pointer for */
55 /* post event update */
56 /* current_timestamp Timestamp for post event */
57 /* update */
58 /* */
59 /* OUTPUT */
60 /* */
61 /* None */
62 /* */
63 /* CALLS */
64 /* */
65 /* None */
66 /* */
67 /* CALLED BY */
68 /* */
69 /* Internal USBX Functions */
70 /* */
71 /* RELEASE HISTORY */
72 /* */
73 /* DATE NAME DESCRIPTION */
74 /* */
75 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
76 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
77 /* used UX prefix to refer to */
78 /* TX symbols instead of using */
79 /* them directly, */
80 /* resulting in version 6.1 */
81 /* 10-15-2021 Chaoqiong Xiao Modified comment(s), */
82 /* improved traceX support, */
83 /* resulting in version 6.1.9 */
84 /* */
85 /**************************************************************************/
86 #ifdef UX_ENABLE_EVENT_TRACE
_ux_trace_event_insert(ULONG event_id,ULONG info_field_1,ULONG info_field_2,ULONG info_field_3,ULONG info_field_4,ULONG filter,TX_TRACE_BUFFER_ENTRY ** current_event,ULONG * current_timestamp)87 VOID _ux_trace_event_insert(ULONG event_id, ULONG info_field_1, ULONG info_field_2, ULONG info_field_3, ULONG info_field_4,
88 ULONG filter, TX_TRACE_BUFFER_ENTRY **current_event, ULONG *current_timestamp)
89 {
90
91 UX_INTERRUPT_SAVE_AREA
92
93 TX_TRACE_BUFFER_ENTRY *event;
94 ULONG timestamp;
95
96
97 /* Disable interrupts. */
98 UX_DISABLE
99
100 /* Pickup the current event. */
101 event = _tx_trace_buffer_current_ptr;
102
103 /* Insert this event into the trace buffer. */
104 TX_TRACE_IN_LINE_INSERT(event_id, info_field_1, info_field_2, info_field_3, info_field_4, filter)
105
106 /* Initialize the timestamp to 0. */
107 timestamp = 0;
108
109 /* Determine if the event was inserted. */
110 if (event)
111 {
112
113 /* Was the event inserted? */
114 if (event -> tx_trace_buffer_entry_event_id == event_id)
115 {
116
117 /* Yes, the event was inserted in the event trace so pickup the timestamp. */
118 timestamp = event -> tx_trace_buffer_entry_time_stamp;
119 }
120 else
121 {
122
123 /* Event was not inserted, simply set the event pointer to NULL. */
124 event = UX_NULL;
125 }
126 }
127
128 /* Now determine if the caller requested the current event. */
129 if (current_event)
130 {
131
132 /* Yes, return the event pointer of potential subsequent update. */
133 *current_event = event;
134 }
135
136 /* Now determine if the current timestamp was requested. */
137 if (current_timestamp)
138 {
139
140 /* Yes, return the current timestamp. */
141 *current_timestamp = timestamp;
142 }
143
144 /* Restore interrupts. */
145 UX_RESTORE
146 }
147 #endif
148
149