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