1 /*
2  * Trace Recorder for Tracealyzer v4.6.6
3  * Copyright 2021 Percepio AB
4  * www.percepio.com
5  *
6  * SPDX-License-Identifier: Apache-2.0
7  *
8  * This file defines the CTI wrappers which the ThreadX recorder kernel port
9  * uses to trace the outcome of events.
10  */
11 
12 #include <stdio.h>
13 #include <stdarg.h>
14 #include "tx_api.h"
15 #include "tx_trace.h"
16 #include "tx_semaphore.h"
17 #include "trcKernelPort.h"
18 
19 /* External declarations */
20 extern UINT _txe_block_allocate_orig(TX_BLOCK_POOL *pool_ptr, VOID **block_ptr, ULONG wait_option);
21 extern UINT _txe_block_pool_create_orig(TX_BLOCK_POOL *pool_ptr, CHAR *name_ptr, ULONG block_size, VOID *pool_start, ULONG pool_size, UINT pool_control_block_size);
22 extern UINT _txe_block_pool_delete_orig(TX_BLOCK_POOL *pool_ptr);
23 extern UINT _txe_block_pool_info_get_orig(TX_BLOCK_POOL *pool_ptr, CHAR **name, ULONG *available_blocks, ULONG *total_blocks, TX_THREAD **first_suspended, ULONG *suspended_count, TX_BLOCK_POOL **next_pool);
24 extern UINT _tx_block_pool_performance_info_get_orig(TX_BLOCK_POOL *pool_ptr, ULONG *allocates, ULONG *releases, ULONG *suspensions, ULONG *timeouts);
25 extern UINT _tx_block_pool_performance_system_info_get_oirg(ULONG *allocates, ULONG *releases, ULONG *suspensions, ULONG *timeouts);
26 extern UINT _txe_block_pool_prioritize_orig(TX_BLOCK_POOL *pool_ptr);
27 extern UINT _txe_block_release_orig(VOID *block_ptr);
28 
29 extern UINT _txe_byte_allocate_orig(TX_BYTE_POOL *pool_ptr, VOID **memory_ptr, ULONG memory_size,  ULONG wait_option);
30 extern UINT _txe_byte_pool_create_orig(TX_BYTE_POOL *pool_ptr, CHAR *name_ptr, VOID *pool_start, ULONG pool_size, UINT pool_control_block_size);
31 extern UINT _txe_byte_pool_delete_orig(TX_BYTE_POOL *pool_ptr);
32 extern UINT _txe_byte_pool_info_get_orig(TX_BYTE_POOL *pool_ptr, CHAR **name, ULONG *available_bytes, ULONG *fragments, TX_THREAD **first_suspended, ULONG *suspended_count, TX_BYTE_POOL **next_pool);
33 extern UINT _tx_byte_pool_performance_info_get_orig(TX_BYTE_POOL *pool_ptr, ULONG *allocates, ULONG *releases, ULONG *fragments_searched, ULONG *merges, ULONG *splits, ULONG *suspensions, ULONG *timeouts);
34 extern UINT _tx_byte_pool_performance_system_info_get_orig(ULONG *allocates, ULONG *releases, ULONG *fragments_searched, ULONG *merges,	ULONG *splits, ULONG *suspensions,ULONG *timeouts);
35 extern UINT _txe_byte_pool_prioritize_orig(TX_BYTE_POOL *pool_ptr);
36 extern UINT _txe_byte_release_orig(VOID *memory_ptr);
37 
38 extern UINT _txe_event_flags_create_orig(TX_EVENT_FLAGS_GROUP *group_ptr, CHAR *name_ptr, UINT event_control_block_size);
39 extern UINT _txe_event_flags_delete_orig(TX_EVENT_FLAGS_GROUP *group_ptr);
40 extern UINT _txe_event_flags_get_orig(TX_EVENT_FLAGS_GROUP *group_ptr, ULONG requested_flags, UINT get_option, ULONG *actual_flags_ptr, ULONG wait_option);
41 extern UINT _txe_event_flags_info_get_orig(TX_EVENT_FLAGS_GROUP *group_ptr, CHAR **name, ULONG *current_flags, TX_THREAD **first_suspended, ULONG *suspended_count, TX_EVENT_FLAGS_GROUP **next_group);
42 extern UINT _tx_event_flags_performance_info_get_orig(TX_EVENT_FLAGS_GROUP *group_ptr, ULONG *sets, ULONG *gets, ULONG *suspensions, ULONG *timeouts);
43 extern UINT _tx_event_flags_performance_system_info_get_orig(ULONG *sets, ULONG *gets, ULONG *suspensions, ULONG *timeouts);
44 extern UINT _txe_event_flags_set_orig(TX_EVENT_FLAGS_GROUP *group_ptr, ULONG flags_to_set, UINT set_option);
45 extern UINT _txe_event_flags_set_notify_orig(TX_EVENT_FLAGS_GROUP *group_ptr, VOID (*events_set_notify)(TX_EVENT_FLAGS_GROUP *notify_group_ptr));
46 
47 extern UINT _txe_mutex_create_orig(TX_MUTEX *mutex_ptr, CHAR *name_ptr, UINT inherit, UINT mutex_control_block_size);
48 extern UINT _txe_mutex_delete_orig(TX_MUTEX *mutex_ptr);
49 extern UINT _txe_mutex_get_orig(TX_MUTEX *mutex_ptr, ULONG wait_option);
50 extern UINT _txe_mutex_info_get_orig(TX_MUTEX *mutex_ptr, CHAR **name, ULONG *count, TX_THREAD **owner, TX_THREAD **first_suspended, ULONG *suspended_count, TX_MUTEX **next_mutex);
51 extern UINT _tx_mutex_performance_info_get_orig(TX_MUTEX *mutex_ptr, ULONG *puts, ULONG *gets, ULONG *suspensions, ULONG *timeouts, ULONG *inversions, ULONG *inheritances);
52 extern UINT _tx_mutex_performance_system_info_get_oirg(ULONG *puts, ULONG *gets, ULONG *suspensions, ULONG *timeouts, ULONG *inversions, ULONG *inheritances);
53 extern UINT _txe_mutex_prioritize_orig(TX_MUTEX *mutex_ptr);
54 extern UINT _txe_mutex_put_orig(TX_MUTEX *mutex_ptr);
55 
56 extern UINT _txe_queue_create_orig(TX_QUEUE *queue_ptr, CHAR *name_ptr, UINT message_size, VOID *queue_start, ULONG queue_size, UINT queue_control_block_size);
57 extern UINT _txe_queue_delete_orig(TX_QUEUE *queue_ptr);
58 extern UINT _txe_queue_flush_orig(TX_QUEUE *queue_ptr);
59 extern UINT _txe_queue_front_send_orig(TX_QUEUE *queue_ptr, VOID *source_ptr, ULONG wait_option);
60 extern UINT _txe_queue_info_get_orig(TX_QUEUE *queue_ptr, CHAR **name, ULONG *enqueued, ULONG *available_storage, TX_THREAD **first_suspended, ULONG *suspended_count, TX_QUEUE **next_queue);
61 extern UINT _tx_queue_performance_info_get_orig(TX_QUEUE *queue_ptr, ULONG *messages_sent, ULONG *messages_received, ULONG *empty_suspensions, ULONG *full_suspensions, ULONG *full_errors, ULONG *timeouts);
62 extern UINT _tx_queue_performance_system_info_get_orig(ULONG *messages_sent, ULONG *messages_received, ULONG *empty_suspensions, ULONG *full_suspensions, ULONG *full_errors, ULONG *timeouts);
63 extern UINT _txe_queue_prioritize_orig(TX_QUEUE *queue_ptr);
64 extern UINT _txe_queue_receive_orig(TX_QUEUE *queue_ptr, VOID *destination_ptr, ULONG wait_option);
65 extern UINT _txe_queue_send_notify_orig(TX_QUEUE *queue_ptr, VOID (*queue_send_notify)(TX_QUEUE *notify_queue_ptr));
66 extern UINT _txe_queue_send_orig(TX_QUEUE *queue_ptr, VOID *source_ptr, ULONG wait_option);
67 
68 extern UINT _txe_semaphore_ceiling_put_orig(TX_SEMAPHORE *semaphore_ptr, ULONG ceiling);
69 extern UINT _txe_semaphore_create_orig(TX_SEMAPHORE *semaphore_ptr, CHAR *name_ptr, ULONG initial_count, UINT semaphore_control_block_size);
70 extern UINT _txe_semaphore_delete_orig(TX_SEMAPHORE *semaphore_ptr);
71 extern UINT _txe_semaphore_get_orig(TX_SEMAPHORE *semaphore_ptr, ULONG wait_option);
72 extern UINT _txe_semaphore_info_get_orig(TX_SEMAPHORE *semaphore_ptr, CHAR **name, ULONG *current_value, TX_THREAD **first_suspended, ULONG *suspended_count, TX_SEMAPHORE **next_semaphore);
73 extern UINT _tx_semaphore_performance_info_get_orig(TX_SEMAPHORE *semaphore_ptr, ULONG *puts, ULONG *gets, ULONG *suspensions, ULONG *timeouts);
74 extern UINT _tx_semaphore_performance_system_info_get_oirg(ULONG *puts, ULONG *gets, ULONG *suspensions, ULONG *timeouts);
75 extern UINT _txe_semaphore_prioritize_orig(TX_SEMAPHORE *semaphore_ptr);
76 extern UINT _txe_semaphore_put_notify_orig(TX_SEMAPHORE *semaphore_ptr, VOID (*semaphore_put_notify)(TX_SEMAPHORE *notify_semaphore_ptr));
77 extern UINT _txe_semaphore_put_orig(TX_SEMAPHORE *semaphore_ptr);
78 
79 extern UINT _txe_thread_create_orig(TX_THREAD *thread_ptr, CHAR *name_ptr, VOID (*entry_function)(ULONG id), ULONG entry_input, VOID *stack_start, ULONG stack_size, UINT priority, UINT preempt_threshold, ULONG time_slice, UINT auto_start, UINT thread_control_block_size);
80 extern UINT _txe_thread_delete_orig(TX_THREAD *thread_ptr);
81 extern UINT _txe_thread_entry_exit_notify_orig(TX_THREAD *thread_ptr, VOID (*thread_entry_exit_notify)(TX_THREAD *notify_thread_ptr, UINT type));
82 extern UINT _txe_thread_info_get_orig(TX_THREAD *thread_ptr, CHAR **name, UINT *state, ULONG *run_count, UINT *priority, UINT *preemption_threshold, ULONG *time_slice, TX_THREAD **next_thread, TX_THREAD **next_suspended_thread);
83 extern UINT _tx_thread_performance_info_get_orig(TX_THREAD *thread_ptr, ULONG *resumptions, ULONG *suspensions, ULONG *solicited_preemptions, ULONG *interrupt_preemptions, ULONG *priority_inversions, ULONG *time_slices, ULONG *relinquishes, ULONG *timeouts, ULONG *wait_aborts, TX_THREAD **last_preempted_by);
84 extern UINT _tx_thread_performance_system_info_get_oirg(ULONG *resumptions, ULONG *suspensions, ULONG *solicited_preemptions, ULONG *interrupt_preemptions, ULONG *priority_inversions, ULONG *time_slices, ULONG *relinquishes, ULONG *timeouts, ULONG *wait_aborts, ULONG *non_idle_returns, ULONG *idle_returns);
85 extern UINT _txe_thread_preemption_change_orig(TX_THREAD *thread_ptr, UINT new_threshold, UINT *old_threshold);
86 extern UINT _txe_thread_priority_change_orig(TX_THREAD *thread_ptr, UINT new_priority, UINT *old_priority);
87 extern UINT _txe_thread_reset_orig(TX_THREAD *thread_ptr);
88 extern UINT _txe_thread_resume_orig(TX_THREAD *thread_ptr);
89 extern UINT _tx_thread_sleep_orig(ULONG timer_ticks);
90 extern UINT _tx_thread_stack_error_notify_orig(VOID (*stack_error_handler)(TX_THREAD *thread_ptr));
91 extern UINT _txe_thread_suspend_orig(TX_THREAD *thread_ptr);
92 extern UINT _txe_thread_terminate_orig(TX_THREAD *thread_ptr);
93 extern VOID _tx_thread_time_slice_orig(VOID);
94 extern UINT _txe_thread_time_slice_change_orig(TX_THREAD *thread_ptr, ULONG new_time_slice, ULONG *old_time_slice);
95 extern UINT _txe_thread_wait_abort_orig(TX_THREAD  *thread_ptr);
96 
97 extern ULONG _tx_time_get_orig(VOID);
98 extern VOID _tx_time_set_orig(ULONG new_time);
99 extern UINT _txe_timer_activate_orig(TX_TIMER *timer_ptr);
100 extern UINT _txe_timer_change_orig(TX_TIMER *timer_ptr, ULONG initial_ticks, ULONG reschedule_ticks);
101 extern UINT _txe_timer_create_orig(TX_TIMER *timer_ptr, CHAR *name_ptr, VOID (*expiration_function)(ULONG id), ULONG expiration_input, ULONG initial_ticks, ULONG reschedule_ticks, UINT auto_activate, UINT timer_control_block_size);
102 extern UINT _txe_timer_deactivate_orig(TX_TIMER *timer_ptr);
103 extern UINT _txe_timer_delete_orig(TX_TIMER *timer_ptr);
104 extern UINT _txe_timer_info_get_orig(TX_TIMER *timer_ptr, CHAR **name, UINT *active, ULONG *remaining_ticks, ULONG *reschedule_ticks, TX_TIMER **next_timer);
105 extern UINT _tx_timer_performance_info_get_orig(TX_TIMER *timer_ptr, ULONG *activates, ULONG *reactivates, ULONG *deactivates, ULONG *expirations, ULONG *expiration_adjusts);
106 
107 extern traceResult xTraceISREnd_orig(TraceBaseType_t uxIsTaskSwitchRequired);
108 
109 extern traceResult xTraceEventBeginRawOffline_orig(uint32_t uiSize, TraceEventHandle_t* pxEventHandle);
110 extern traceResult xTraceEventEndOffline_orig(TraceEventHandle_t xEventHandle);
111 
112 
_txe_block_allocate(TX_BLOCK_POOL * pool_ptr,VOID ** block_ptr,ULONG wait_option)113 UINT _txe_block_allocate(TX_BLOCK_POOL *pool_ptr, VOID **block_ptr, ULONG wait_option)
114 {
115 	UINT ret = _txe_block_allocate_orig(pool_ptr, block_ptr, wait_option);
116 
117 	if (ret == TX_SUCCESS)
118 	{
119 		TraceEventHandle_t xTraceHandle;
120 
121 		if (xTraceEventBegin(PSF_EVENT_BLOCK_ALLOCATE_SUCCESS, sizeof(void*) + sizeof(ULONG) + sizeof(UINT) + sizeof(UINT),
122 			&xTraceHandle) == TRC_SUCCESS) {
123 			xTraceEventAddPointer(xTraceHandle, (void*)pool_ptr);
124 			xTraceEventAddUnsignedBaseType(xTraceHandle, wait_option);
125 			xTraceEventAdd32(xTraceHandle, ret);
126 			xTraceEventAdd32(xTraceHandle, pool_ptr->tx_block_pool_available);
127 			xTraceEventEnd(xTraceHandle);
128 		}
129 	}
130 	else if (ret == TX_NO_MEMORY)
131 	{
132 		TraceEventHandle_t xTraceHandle;
133 
134 		if (xTraceEventBegin(PSF_EVENT_BLOCK_ALLOCATE_TIMEOUT, sizeof(void*) + sizeof(ULONG) + sizeof(UINT) + sizeof(UINT),
135 			&xTraceHandle) == TRC_SUCCESS) {
136 			xTraceEventAddPointer(xTraceHandle, (void*)pool_ptr);
137 			xTraceEventAddUnsignedBaseType(xTraceHandle, wait_option);
138 			xTraceEventAdd32(xTraceHandle, ret);
139 			xTraceEventAdd32(xTraceHandle, pool_ptr->tx_block_pool_available);
140 			xTraceEventEnd(xTraceHandle);
141 		}
142 	}
143 	else
144 	{
145 		TraceEventHandle_t xTraceHandle;
146 
147 		if (xTraceEventBegin(PSF_EVENT_BLOCK_ALLOCATE_FAILED, sizeof(void*) + sizeof(ULONG) + sizeof(UINT),
148 			&xTraceHandle) == TRC_SUCCESS) {
149 			xTraceEventAddPointer(xTraceHandle, (void*)pool_ptr);
150 			xTraceEventAddUnsignedBaseType(xTraceHandle, wait_option);
151 			xTraceEventAdd32(xTraceHandle, ret);
152 			xTraceEventEnd(xTraceHandle);
153 		}
154 	}
155 
156 	return ret;
157 }
158 
_txe_block_pool_create(TX_BLOCK_POOL * pool_ptr,CHAR * name_ptr,ULONG block_size,VOID * pool_start,ULONG pool_size,UINT pool_control_block_size)159 UINT _txe_block_pool_create(TX_BLOCK_POOL *pool_ptr, CHAR *name_ptr, ULONG block_size, VOID *pool_start, ULONG pool_size, UINT pool_control_block_size)
160 {
161 	UINT ret = _txe_block_pool_create_orig(pool_ptr, name_ptr, block_size, pool_start, pool_size, pool_control_block_size);
162 
163 	if (ret != TX_SUCCESS)
164 	{
165 		TraceEventHandle_t xTraceHandle;
166 
167 		if (xTraceEventBegin(PSF_EVENT_BLOCK_POOL_CREATE_FAILED, sizeof(void*) + sizeof(ULONG) + sizeof(VOID*) + sizeof(ULONG) + sizeof(UINT),
168 			&xTraceHandle) == TRC_SUCCESS) {
169 			xTraceEventAddPointer(xTraceHandle, (void*)pool_ptr);
170 			xTraceEventAddUnsignedBaseType(xTraceHandle, block_size);
171 			xTraceEventAddPointer(xTraceHandle, (void*)pool_ptr);
172 			xTraceEventAddUnsignedBaseType(xTraceHandle, pool_size);
173 			xTraceEventAdd32(xTraceHandle, ret);
174 			xTraceEventEnd(xTraceHandle);
175 		}
176 	}
177 
178 	return ret;
179 }
180 
_txe_block_pool_delete(TX_BLOCK_POOL * pool_ptr)181 UINT _txe_block_pool_delete(TX_BLOCK_POOL *pool_ptr)
182 {
183 	UINT ret = _txe_block_pool_delete_orig(pool_ptr);
184 
185 	if (ret != TX_SUCCESS)
186 	{
187 		TraceEventHandle_t xTraceHandle;
188 
189 		if (xTraceEventBegin(PSF_EVENT_BLOCK_POOL_DELETE_FAILED, sizeof(void*) + sizeof(UINT),
190 			&xTraceHandle) == TRC_SUCCESS) {
191 			xTraceEventAddPointer(xTraceHandle, (void*)pool_ptr);
192 			xTraceEventAdd32(xTraceHandle, ret);
193 			xTraceEventEnd(xTraceHandle);
194 		}
195 	}
196 
197 	return ret;
198 }
199 
_txe_block_pool_info_get(TX_BLOCK_POOL * pool_ptr,CHAR ** name,ULONG * available_blocks,ULONG * total_blocks,TX_THREAD ** first_suspended,ULONG * suspended_count,TX_BLOCK_POOL ** next_pool)200 UINT _txe_block_pool_info_get(TX_BLOCK_POOL *pool_ptr, CHAR **name, ULONG *available_blocks, ULONG *total_blocks, TX_THREAD **first_suspended, ULONG *suspended_count, TX_BLOCK_POOL **next_pool)
201 {
202 	UINT ret = _txe_block_pool_info_get_orig(pool_ptr, name, available_blocks, total_blocks, first_suspended, suspended_count, next_pool);
203 
204 	if (ret != TX_SUCCESS)
205 	{
206 		TraceEventHandle_t xTraceHandle;
207 
208 		if (xTraceEventBegin(PSF_EVENT_BLOCK_POOL_INFO_GET_FAILED, sizeof(void*) + sizeof(UINT),
209 			&xTraceHandle) == TRC_SUCCESS) {
210 			xTraceEventAddPointer(xTraceHandle, (void*)pool_ptr);
211 			xTraceEventAdd32(xTraceHandle, ret);
212 			xTraceEventEnd(xTraceHandle);
213 		}
214 	}
215 
216 	return ret;
217 }
218 
_tx_block_pool_performance_info_get(TX_BLOCK_POOL * pool_ptr,ULONG * allocates,ULONG * releases,ULONG * suspensions,ULONG * timeouts)219 UINT  _tx_block_pool_performance_info_get(TX_BLOCK_POOL *pool_ptr, ULONG *allocates, ULONG *releases, ULONG *suspensions, ULONG *timeouts)
220 {
221 	UINT ret = _tx_block_pool_performance_info_get_orig(pool_ptr, allocates, releases, suspensions, timeouts);
222 
223 	if (ret != TX_SUCCESS)
224 	{
225 		TraceEventHandle_t xTraceHandle;
226 
227 		if (xTraceEventBegin(PSF_EVENT_BLOCK_POOL_PERFORMANCE_INFO_GET_FAILED, sizeof(void*) + sizeof(UINT),
228 			&xTraceHandle) == TRC_SUCCESS) {
229 			xTraceEventAddPointer(xTraceHandle, (void*)pool_ptr);
230 			xTraceEventAdd32(xTraceHandle, ret);
231 			xTraceEventEnd(xTraceHandle);
232 		}
233 	}
234 
235 	return ret;
236 }
237 
_tx_block_pool_performance_system_info_get(ULONG * allocates,ULONG * releases,ULONG * suspensions,ULONG * timeouts)238 UINT  _tx_block_pool_performance_system_info_get(ULONG *allocates, ULONG *releases, ULONG *suspensions, ULONG *timeouts)
239 {
240 	UINT ret = _tx_block_pool_performance_system_info_get_oirg(allocates, releases, suspensions, timeouts);
241 
242 	if (ret == TX_SUCCESS)
243 	{
244 		TraceEventHandle_t xTraceHandle;
245 
246 		if (xTraceEventBegin(PSF_EVENT_BLOCK_POOL__PERFORMANCE_SYSTEM_INFO_GET_SUCCESS, 0,
247 			&xTraceHandle) == TRC_SUCCESS) {
248 			xTraceEventEnd(xTraceHandle);
249 		}
250 	}
251 	else
252 	{
253 		TraceEventHandle_t xTraceHandle;
254 
255 		if (xTraceEventBegin(PSF_EVENT_BLOCK_POOL__PERFORMANCE_SYSTEM_INFO_GET_FAILED, 0,
256 			&xTraceHandle) == TRC_SUCCESS) {
257 			xTraceEventEnd(xTraceHandle);
258 		}
259 	}
260 	return ret;
261 }
262 
_txe_block_pool_prioritize(TX_BLOCK_POOL * pool_ptr)263 UINT _txe_block_pool_prioritize(TX_BLOCK_POOL *pool_ptr)
264 {
265 	UINT ret = _txe_block_pool_prioritize_orig(pool_ptr);
266 
267 	if (ret != TX_SUCCESS)
268 	{
269 		TraceEventHandle_t xTraceHandle;
270 
271 		if (xTraceEventBegin(PSF_EVENT_BLOCK_POOL_PRIORITIZE_FAILED, sizeof(void*) + sizeof(UINT),
272 			&xTraceHandle) == TRC_SUCCESS) {
273 			xTraceEventAddPointer(xTraceHandle, (void*)pool_ptr);
274 			xTraceEventAdd32(xTraceHandle, ret);
275 			xTraceEventEnd(xTraceHandle);
276 		}
277 	}
278 
279 	return ret;
280 }
281 
_txe_block_release(VOID * block_ptr)282 UINT _txe_block_release(VOID *block_ptr)
283 {
284 	UINT ret = _txe_block_release_orig(block_ptr);
285 
286 	if (ret != TX_SUCCESS)
287 	{
288 		TraceEventHandle_t xTraceHandle;
289 
290 		if (xTraceEventBegin(PSF_EVENT_BLOCK_POOL_RELEASE_FAILED, sizeof(void*) + sizeof(UINT),
291 			&xTraceHandle) == TRC_SUCCESS) {
292 			xTraceEventAddPointer(xTraceHandle, (void*)block_ptr);
293 			xTraceEventAdd32(xTraceHandle, ret);
294 			xTraceEventEnd(xTraceHandle);
295 		}
296 	}
297 
298 	return ret;
299 }
300 
_txe_byte_allocate(TX_BYTE_POOL * pool_ptr,VOID ** memory_ptr,ULONG memory_size,ULONG wait_option)301 UINT _txe_byte_allocate(TX_BYTE_POOL *pool_ptr, VOID **memory_ptr, ULONG memory_size,  ULONG wait_option)
302 {
303 	TraceEventHandle_t xTraceHandle;
304 
305 	if (xTraceEventBegin(PSF_EVENT_BYTE_ALLOCATE_BLOCKED, sizeof(void*) + sizeof(void*) + sizeof(ULONG) + sizeof(ULONG),
306 		&xTraceHandle) == TRC_SUCCESS) {
307 		xTraceEventAddPointer(xTraceHandle, (void*)pool_ptr);
308 		xTraceEventAddPointer(xTraceHandle, (void*)memory_ptr);
309 		xTraceEventAddUnsignedBaseType(xTraceHandle, memory_size);
310 		xTraceEventAddUnsignedBaseType(xTraceHandle, wait_option);
311 		xTraceEventEnd(xTraceHandle);
312 	}
313 
314 	UINT ret = _txe_byte_allocate_orig(pool_ptr, memory_ptr, memory_size, wait_option);
315 
316 	if (ret == TX_SUCCESS)
317 	{
318 		if (xTraceEventBegin(PSF_EVENT_BYTE_ALLOCATE_SUCCESS, sizeof(void*) + sizeof(void*) + sizeof(void*),
319 			&xTraceHandle) == TRC_SUCCESS) {
320 			xTraceEventAddPointer(xTraceHandle, (void*)pool_ptr);
321 			xTraceEventAddPointer(xTraceHandle, (void*)memory_ptr);
322 			xTraceEventAddPointer(xTraceHandle, (void*)*memory_ptr);
323 			xTraceEventEnd(xTraceHandle);
324 		}
325 	}
326 	else if (ret == TX_NO_MEMORY)
327 	{
328 		if (xTraceEventBegin(PSF_EVENT_BYTE_ALLOCATE_TIMEOUT, sizeof(void*) + sizeof(void*) + sizeof(void*),
329 			&xTraceHandle) == TRC_SUCCESS) {
330 			xTraceEventAddPointer(xTraceHandle, (void*)pool_ptr);
331 			xTraceEventAddPointer(xTraceHandle, (void*)memory_ptr);
332 			xTraceEventAddPointer(xTraceHandle, (void*)memory_ptr);
333 			xTraceEventEnd(xTraceHandle);
334 		}
335 	}
336 	else
337 	{
338 		if (xTraceEventBegin(PSF_EVENT_BYTE_ALLOCATE_FAILED, sizeof(void*) + sizeof(void*) + sizeof(ULONG) + sizeof(ULONG) + sizeof(void*),
339 			&xTraceHandle) == TRC_SUCCESS) {
340 			xTraceEventAddPointer(xTraceHandle, (void*)pool_ptr);
341 			xTraceEventAddPointer(xTraceHandle, (void*)memory_ptr);
342 			xTraceEventAddUnsignedBaseType(xTraceHandle, memory_size);
343 			xTraceEventAdd32(xTraceHandle, wait_option);
344 			xTraceEventAddPointer(xTraceHandle, (void*)memory_ptr);
345 			xTraceEventEnd(xTraceHandle);
346 		}
347 	}
348 
349 	return ret;
350 }
351 
_txe_byte_pool_create(TX_BYTE_POOL * pool_ptr,CHAR * name_ptr,VOID * pool_start,ULONG pool_size,UINT pool_control_block_size)352 UINT _txe_byte_pool_create(TX_BYTE_POOL *pool_ptr, CHAR *name_ptr, VOID *pool_start, ULONG pool_size, UINT pool_control_block_size)
353 {
354 	UINT ret = _txe_byte_pool_create_orig(pool_ptr, name_ptr, pool_start, pool_size, pool_control_block_size);
355 
356 	if (ret != TX_SUCCESS)
357 	{
358 		TraceEventHandle_t xTraceHandle;
359 
360 		if (xTraceEventBegin(PSF_EVENT_BYTE_POOL_CREATE_FAILED, sizeof(void*) + sizeof(void*) + sizeof(ULONG) + sizeof(UINT),
361 			&xTraceHandle) == TRC_SUCCESS) {
362 			xTraceEventAddPointer(xTraceHandle, (void*)pool_ptr);
363 			xTraceEventAddPointer(xTraceHandle, (void*)pool_start);
364 			xTraceEventAddUnsignedBaseType(xTraceHandle, pool_size);
365 			xTraceEventAdd32(xTraceHandle, ret);
366 			xTraceEventEnd(xTraceHandle);
367 		}
368 	}
369 
370 	return ret;
371 }
372 
_txe_byte_pool_delete(TX_BYTE_POOL * pool_ptr)373 UINT _txe_byte_pool_delete(TX_BYTE_POOL *pool_ptr)
374 {
375 	UINT ret = _txe_byte_pool_delete_orig(pool_ptr);
376 
377 	if (ret != TX_SUCCESS)
378 	{
379 		TraceEventHandle_t xTraceHandle;
380 
381 		if (xTraceEventBegin(PSF_EVENT_BYTE_POOL_DELETE_FAILED, sizeof(void*) + sizeof(UINT),
382 			&xTraceHandle) == TRC_SUCCESS) {
383 			xTraceEventAddPointer(xTraceHandle, (void*)pool_ptr);
384 			xTraceEventAdd32(xTraceHandle, ret);
385 			xTraceEventEnd(xTraceHandle);
386 		}
387 	}
388 
389 	return ret;
390 }
391 
_txe_byte_pool_info_get(TX_BYTE_POOL * pool_ptr,CHAR ** name,ULONG * available_bytes,ULONG * fragments,TX_THREAD ** first_suspended,ULONG * suspended_count,TX_BYTE_POOL ** next_pool)392 UINT _txe_byte_pool_info_get(TX_BYTE_POOL *pool_ptr, CHAR **name, ULONG *available_bytes, ULONG *fragments, TX_THREAD **first_suspended, ULONG *suspended_count, TX_BYTE_POOL **next_pool)
393 {
394 	UINT ret = _txe_byte_pool_info_get_orig(pool_ptr, name, available_bytes, fragments, first_suspended, suspended_count, next_pool);
395 
396 	if (ret != TX_SUCCESS)
397 	{
398 		TraceEventHandle_t xTraceHandle;
399 
400 		if (xTraceEventBegin(PSF_EVENT_BYTE_POOL_INFO_GET_FAILED, sizeof(void*) + sizeof(UINT),
401 			&xTraceHandle) == TRC_SUCCESS) {
402 			xTraceEventAddPointer(xTraceHandle, (void*)pool_ptr);
403 			xTraceEventAdd32(xTraceHandle, ret);
404 			xTraceEventEnd(xTraceHandle);
405 		}
406 	}
407 
408 	return ret;
409 }
410 
_tx_byte_pool_performance_info_get(TX_BYTE_POOL * pool_ptr,ULONG * allocates,ULONG * releases,ULONG * fragments_searched,ULONG * merges,ULONG * splits,ULONG * suspensions,ULONG * timeouts)411 UINT _tx_byte_pool_performance_info_get(TX_BYTE_POOL *pool_ptr,
412 	    ULONG *allocates,
413 	    ULONG *releases,
414 	    ULONG *fragments_searched,
415 	    ULONG *merges,
416 	    ULONG *splits,
417 	    ULONG *suspensions,
418 	    ULONG *timeouts)
419 {
420 	UINT ret = _tx_byte_pool_performance_info_get_orig(pool_ptr, allocates, releases, fragments_searched, merges,
421 			splits, suspensions, timeouts);
422 
423 	if (ret != TX_SUCCESS)
424 	{
425 		TraceEventHandle_t xTraceHandle;
426 
427 		if (xTraceEventBegin(PSF_EVENT_BYTE_POOL_PERFORMANCE_INFO_GET_FAILED, sizeof(void*) + sizeof(UINT),
428 			&xTraceHandle) == TRC_SUCCESS) {
429 			xTraceEventAddPointer(xTraceHandle, (void*)pool_ptr);
430 			xTraceEventAdd32(xTraceHandle, ret);
431 			xTraceEventEnd(xTraceHandle);
432 		}
433 	}
434 
435 	return ret;
436 }
437 
_tx_byte_pool_performance_system_info_get(ULONG * allocates,ULONG * releases,ULONG * fragments_searched,ULONG * merges,ULONG * splits,ULONG * suspensions,ULONG * timeouts)438 UINT  _tx_byte_pool_performance_system_info_get(ULONG *allocates,
439 		ULONG *releases,
440 		ULONG *fragments_searched,
441 		ULONG *merges,
442 		ULONG *splits,
443 		ULONG *suspensions,
444 		ULONG *timeouts)
445 {
446 	UINT ret = _tx_byte_pool_performance_system_info_get_orig(allocates, releases, fragments_searched,
447 			merges, splits, suspensions, timeouts);
448 
449 	if(ret == TX_SUCCESS)
450 	{
451 		TraceEventHandle_t xTraceHandle;
452 
453 		if (xTraceEventBegin(PSF_EVENT_BYTE_POOL__PERFORMANCE_SYSTEM_INFO_GET_SUCCESS, 0,
454 			&xTraceHandle) == TRC_SUCCESS) {
455 			xTraceEventEnd(xTraceHandle);
456 		}
457 	}
458 	else
459 	{
460 		TraceEventHandle_t xTraceHandle;
461 
462 		if (xTraceEventBegin(PSF_EVENT_BYTE_POOL__PERFORMANCE_SYSTEM_INFO_GET_FAILED, 0,
463 			&xTraceHandle) == TRC_SUCCESS) {
464 			xTraceEventEnd(xTraceHandle);
465 		}
466 	}
467 
468 	return ret;
469 }
470 
_txe_byte_pool_prioritize(TX_BYTE_POOL * pool_ptr)471 UINT _txe_byte_pool_prioritize(TX_BYTE_POOL *pool_ptr)
472 {
473 	UINT ret = _txe_byte_pool_prioritize_orig(pool_ptr);
474 
475 	if (ret != TX_SUCCESS)
476 	{
477 		TraceEventHandle_t xTraceHandle;
478 
479 		if (xTraceEventBegin(PSF_EVENT_BYTE_POOL_PRIORITIZE_FAILED, sizeof(void*) + sizeof(UINT),
480 			&xTraceHandle) == TRC_SUCCESS) {
481 			xTraceEventAddPointer(xTraceHandle, (void*)pool_ptr);
482 			xTraceEventAdd32(xTraceHandle, ret);
483 			xTraceEventEnd(xTraceHandle);
484 		}
485 	}
486 
487 	return ret;
488 }
489 
_txe_byte_release(VOID * memory_ptr)490 UINT _txe_byte_release(VOID *memory_ptr)
491 {
492 	UINT ret = _txe_byte_release_orig(memory_ptr);
493 
494 	if (ret != TX_SUCCESS)
495 	{
496 		TraceEventHandle_t xTraceHandle;
497 
498 		if (xTraceEventBegin(PSF_EVENT_BYTE_POOL_RELEASE_FAILED, sizeof(void*) + sizeof(UINT),
499 			&xTraceHandle) == TRC_SUCCESS) {
500 			xTraceEventAddPointer(xTraceHandle, (void*)memory_ptr);
501 			xTraceEventAdd32(xTraceHandle, ret);
502 			xTraceEventEnd(xTraceHandle);
503 		}
504 	}
505 
506 	return ret;
507 }
508 
509 
_txe_event_flags_create(TX_EVENT_FLAGS_GROUP * group_ptr,CHAR * name_ptr,UINT event_control_block_size)510 UINT _txe_event_flags_create(TX_EVENT_FLAGS_GROUP *group_ptr, CHAR *name_ptr, UINT event_control_block_size)
511 {
512 	UINT ret = _txe_event_flags_create_orig(group_ptr, name_ptr, event_control_block_size);
513 
514 	if (ret != TX_SUCCESS)
515 	{
516 		TraceEventHandle_t xTraceHandle;
517 
518 		if (xTraceEventBegin(PSF_EVENT_FLAGS_CREATE_FAILED, sizeof(void*) + sizeof(UINT),
519 			&xTraceHandle) == TRC_SUCCESS) {
520 			xTraceEventAddPointer(xTraceHandle, (void*)group_ptr);
521 			xTraceEventAdd32(xTraceHandle, ret);
522 			xTraceEventEnd(xTraceHandle);
523 		}
524 	}
525 
526 	return ret;
527 }
528 
529 
_txe_event_flags_delete(TX_EVENT_FLAGS_GROUP * group_ptr)530 UINT _txe_event_flags_delete(TX_EVENT_FLAGS_GROUP *group_ptr)
531 {
532 	UINT ret = _txe_event_flags_delete_orig(group_ptr);
533 
534 	if (ret != TX_SUCCESS)
535 	{
536 		TraceEventHandle_t xTraceHandle;
537 
538 		if (xTraceEventBegin(PSF_EVENT_FLAGS_DELETE_FAILED, sizeof(void*) + sizeof(UINT),
539 			&xTraceHandle) == TRC_SUCCESS) {
540 			xTraceEventAddPointer(xTraceHandle, (void*)group_ptr);
541 			xTraceEventAdd32(xTraceHandle, ret);
542 			xTraceEventEnd(xTraceHandle);
543 		}
544 	}
545 
546 	return ret;
547 }
548 
549 
_txe_event_flags_get(TX_EVENT_FLAGS_GROUP * group_ptr,ULONG requested_flags,UINT get_option,ULONG * actual_flags_ptr,ULONG wait_option)550 UINT _txe_event_flags_get(TX_EVENT_FLAGS_GROUP *group_ptr, ULONG requested_flags, UINT get_option, ULONG *actual_flags_ptr, ULONG wait_option)
551 {
552 	UINT ret = _txe_event_flags_get_orig(group_ptr, requested_flags, get_option, actual_flags_ptr, wait_option);
553 
554 	if (ret == TX_SUCCESS)
555 	{
556 		TraceEventHandle_t xTraceHandle;
557 
558 		if (xTraceEventBegin(PSF_EVENT_FLAGS_GET_SUCCESS, sizeof(void*) + sizeof(ULONG) + sizeof(UINT),
559 			&xTraceHandle) == TRC_SUCCESS) {
560 			xTraceEventAddPointer(xTraceHandle, (void*)group_ptr);
561 			xTraceEventAddUnsignedBaseType(xTraceHandle, requested_flags);
562 			xTraceEventAdd32(xTraceHandle, get_option);
563 			xTraceEventEnd(xTraceHandle);
564 		}
565 	}
566 	else if (ret == TX_NO_EVENTS)
567 	{
568 		TraceEventHandle_t xTraceHandle;
569 
570 		if (xTraceEventBegin(PSF_EVENT_FLAGS_GET_TIMEOUT, sizeof(void*) + sizeof(ULONG) + sizeof(UINT) + sizeof(UINT),
571 			&xTraceHandle) == TRC_SUCCESS) {
572 			xTraceEventAddPointer(xTraceHandle, (void*)group_ptr);
573 			xTraceEventAddUnsignedBaseType(xTraceHandle, requested_flags);
574 			xTraceEventAdd32(xTraceHandle, get_option);
575 			xTraceEventAdd32(xTraceHandle, ret);
576 			xTraceEventEnd(xTraceHandle);
577 		}
578 	}
579 	else
580 	{
581 		TraceEventHandle_t xTraceHandle;
582 
583 		if (xTraceEventBegin(PSF_EVENT_FLAGS_GET_FAILED, sizeof(void*) + sizeof(ULONG) + sizeof(UINT) + sizeof(UINT),
584 			&xTraceHandle) == TRC_SUCCESS) {
585 			xTraceEventAddPointer(xTraceHandle, (void*)group_ptr);
586 			xTraceEventAddUnsignedBaseType(xTraceHandle, requested_flags);
587 			xTraceEventAdd32(xTraceHandle, get_option);
588 			xTraceEventAdd32(xTraceHandle, ret);
589 			xTraceEventEnd(xTraceHandle);
590 		}
591 	}
592 
593 	return ret;
594 }
595 
596 
_txe_event_flags_info_get(TX_EVENT_FLAGS_GROUP * group_ptr,CHAR ** name,ULONG * current_flags,TX_THREAD ** first_suspended,ULONG * suspended_count,TX_EVENT_FLAGS_GROUP ** next_group)597 UINT _txe_event_flags_info_get(TX_EVENT_FLAGS_GROUP *group_ptr, CHAR **name, ULONG *current_flags, TX_THREAD **first_suspended, ULONG *suspended_count, TX_EVENT_FLAGS_GROUP **next_group)
598 {
599 	UINT ret = _txe_event_flags_info_get_orig(group_ptr, name, current_flags, first_suspended, suspended_count, next_group);
600 
601 	if (ret != TX_SUCCESS)
602 	{
603 		TraceEventHandle_t xTraceHandle;
604 
605 		if (xTraceEventBegin(PSF_EVENT_FLAGS_INFO_GET_FAILED, sizeof(void*) + sizeof(UINT),
606 			&xTraceHandle) == TRC_SUCCESS) {
607 			xTraceEventAddPointer(xTraceHandle, (void*)group_ptr);
608 			xTraceEventAdd32(xTraceHandle, ret);
609 			xTraceEventEnd(xTraceHandle);
610 		}
611 	}
612 
613 	return ret;
614 }
615 
616 
_tx_event_flags_performance_info_get(TX_EVENT_FLAGS_GROUP * group_ptr,ULONG * sets,ULONG * gets,ULONG * suspensions,ULONG * timeouts)617 UINT _tx_event_flags_performance_info_get(TX_EVENT_FLAGS_GROUP *group_ptr, ULONG *sets, ULONG *gets, ULONG *suspensions, ULONG *timeouts)
618 {
619 	UINT ret = _tx_event_flags_performance_info_get_orig(group_ptr, sets, gets, suspensions, timeouts);
620 
621 	if (ret != TX_SUCCESS)
622 	{
623 		TraceEventHandle_t xTraceHandle;
624 
625 		if (xTraceEventBegin(PSF_EVENT_FLAGS_PERFORMANCE_INFO_GET_FAILED, sizeof(void*) + sizeof(UINT),
626 			&xTraceHandle) == TRC_SUCCESS) {
627 			xTraceEventAddPointer(xTraceHandle, (void*)group_ptr);
628 			xTraceEventAdd32(xTraceHandle, ret);
629 			xTraceEventEnd(xTraceHandle);
630 		}
631 	}
632 
633 	return ret;
634 }
635 
_tx_event_flags_performance_system_info_get(ULONG * sets,ULONG * gets,ULONG * suspensions,ULONG * timeouts)636 UINT  _tx_event_flags_performance_system_info_get(ULONG *sets, ULONG *gets, ULONG *suspensions, ULONG *timeouts)
637 {
638 	UINT ret = _tx_event_flags_performance_system_info_get_orig(sets, gets, suspensions, timeouts);
639 
640 	if(ret == TX_SUCCESS)
641 	{
642 		TraceEventHandle_t xTraceHandle;
643 
644 		if (xTraceEventBegin(PSF_EVENT_FLAGS__PERFORMANCE_SYSTEM_INFO_GET_SUCCESS, 0,
645 			&xTraceHandle) == TRC_SUCCESS) {
646 			xTraceEventEnd(xTraceHandle);
647 		}
648 	}
649 	else
650 	{
651 		TraceEventHandle_t xTraceHandle;
652 
653 		if (xTraceEventBegin(PSF_EVENT_FLAGS__PERFORMANCE_SYSTEM_INFO_GET_FAILED, 0,
654 			&xTraceHandle) == TRC_SUCCESS) {
655 			xTraceEventEnd(xTraceHandle);
656 		}
657 	}
658 
659 	return ret;
660 }
661 
662 
_txe_event_flags_set(TX_EVENT_FLAGS_GROUP * group_ptr,ULONG flags_to_set,UINT set_option)663 UINT _txe_event_flags_set(TX_EVENT_FLAGS_GROUP *group_ptr, ULONG flags_to_set, UINT set_option)
664 {
665 	UINT ret = _txe_event_flags_set_orig(group_ptr, flags_to_set, set_option);
666 
667 	if (ret != TX_SUCCESS)
668 	{
669 		TraceEventHandle_t xTraceHandle;
670 
671 		if (xTraceEventBegin(PSF_EVENT_FLAGS_SET_FAILED, sizeof(void*) + sizeof(ULONG) + sizeof(UINT) + sizeof(UINT),
672 			&xTraceHandle) == TRC_SUCCESS) {
673 			xTraceEventAddPointer(xTraceHandle, (void*)group_ptr);
674 			xTraceEventAddUnsignedBaseType(xTraceHandle, flags_to_set);
675 			xTraceEventAdd32(xTraceHandle, set_option);
676 			xTraceEventAdd32(xTraceHandle, ret);
677 			xTraceEventEnd(xTraceHandle);
678 		}
679 	}
680 
681 	return ret;
682 }
683 
684 
_txe_event_flags_set_notify(TX_EVENT_FLAGS_GROUP * group_ptr,VOID (* events_set_notify)(TX_EVENT_FLAGS_GROUP * notify_group_ptr))685 UINT _txe_event_flags_set_notify(TX_EVENT_FLAGS_GROUP *group_ptr, VOID (*events_set_notify)(TX_EVENT_FLAGS_GROUP *notify_group_ptr))
686 {
687 	UINT ret = _txe_event_flags_set_notify_orig(group_ptr, events_set_notify);
688 
689 	if (ret != TX_SUCCESS)
690 	{
691 		TraceEventHandle_t xTraceHandle;
692 
693 		if (xTraceEventBegin(PSF_EVENT_FLAGS_SET_NOTIFY_FAILED, sizeof(void*) + sizeof(UINT),
694 			&xTraceHandle) == TRC_SUCCESS) {
695 			xTraceEventAddPointer(xTraceHandle, (void*)group_ptr);
696 			xTraceEventAdd32(xTraceHandle, ret);
697 			xTraceEventEnd(xTraceHandle);
698 		}
699 	}
700 
701 	return ret;
702 }
703 
704 
_txe_mutex_create(TX_MUTEX * mutex_ptr,CHAR * name_ptr,UINT inherit,UINT mutex_control_block_size)705 UINT _txe_mutex_create(TX_MUTEX *mutex_ptr, CHAR *name_ptr, UINT inherit, UINT mutex_control_block_size)
706 {
707 	UINT ret = _txe_mutex_create_orig(mutex_ptr, name_ptr, inherit, mutex_control_block_size);
708 
709 	if (ret != TX_SUCCESS)
710 	{
711 		TraceEventHandle_t xTraceHandle;
712 
713 		if (xTraceEventBegin(PSF_EVENT_MUTEX_CREATE_FAILED, sizeof(void*) + sizeof(UINT) + sizeof(UINT),
714 			&xTraceHandle) == TRC_SUCCESS) {
715 			xTraceEventAddPointer(xTraceHandle, (void*)mutex_ptr);
716 			xTraceEventAdd32(xTraceHandle, inherit);
717 			xTraceEventAdd32(xTraceHandle, ret);
718 			xTraceEventEnd(xTraceHandle);
719 		}
720 	}
721 
722 	return ret;
723 }
724 
_txe_mutex_delete(TX_MUTEX * mutex_ptr)725 UINT _txe_mutex_delete(TX_MUTEX *mutex_ptr)
726 {
727 	UINT ret = _txe_mutex_delete_orig(mutex_ptr);
728 
729 	if (ret != TX_SUCCESS)
730 	{
731 		TraceEventHandle_t xTraceHandle;
732 
733 		if (xTraceEventBegin(PSF_EVENT_MUTEX_DELETE_FAILED, sizeof(void*) + sizeof(UINT),
734 			&xTraceHandle) == TRC_SUCCESS) {
735 			xTraceEventAddPointer(xTraceHandle, (void*)mutex_ptr);
736 			xTraceEventAdd32(xTraceHandle, ret);
737 			xTraceEventEnd(xTraceHandle);
738 		}
739 	}
740 
741 	return ret;
742 }
743 
_txe_mutex_get(TX_MUTEX * mutex_ptr,ULONG wait_option)744 UINT _txe_mutex_get(TX_MUTEX *mutex_ptr, ULONG wait_option)
745 {
746 	TraceEventHandle_t xTraceHandle;
747 
748 	if (xTraceEventBegin(PSF_EVENT_MUTEX_GET_BLOCKED, sizeof(void*) + sizeof(ULONG),
749 		&xTraceHandle) == TRC_SUCCESS) {
750 		xTraceEventAddPointer(xTraceHandle, (void*)mutex_ptr);
751 		xTraceEventAddUnsignedBaseType(xTraceHandle, wait_option);
752 		xTraceEventEnd(xTraceHandle);
753 	}
754 
755 	UINT ret = _txe_mutex_get_orig(mutex_ptr, wait_option);
756 
757 	if (ret == TX_SUCCESS)
758 	{
759 		if (xTraceEventBegin(PSF_EVENT_MUTEX_GET_SUCCESS, sizeof(void*) + sizeof(ULONG),
760 			&xTraceHandle) == TRC_SUCCESS) {
761 			xTraceEventAddPointer(xTraceHandle, (void*)mutex_ptr);
762 			xTraceEventAddUnsignedBaseType(xTraceHandle, wait_option);
763 			xTraceEventEnd(xTraceHandle);
764 		}
765 	}
766 	else if (ret == TX_NOT_AVAILABLE || ret == TX_WAIT_ABORTED)
767 	{
768 		if (xTraceEventBegin(PSF_EVENT_MUTEX_GET_TIMEOUT, sizeof(void*) + sizeof(ULONG) + sizeof(UINT),
769 			&xTraceHandle) == TRC_SUCCESS) {
770 			xTraceEventAddPointer(xTraceHandle, (void*)mutex_ptr);
771 			xTraceEventAddUnsignedBaseType(xTraceHandle, wait_option);
772 			xTraceEventAdd32(xTraceHandle, ret);
773 			xTraceEventEnd(xTraceHandle);
774 		}
775 	}
776 	else
777 	{
778 		if (xTraceEventBegin(PSF_EVENT_MUTEX_GET_FAILED, sizeof(void*) + sizeof(ULONG) + sizeof(UINT),
779 			&xTraceHandle) == TRC_SUCCESS) {
780 			xTraceEventAddPointer(xTraceHandle, (void*)mutex_ptr);
781 			xTraceEventAddUnsignedBaseType(xTraceHandle, wait_option);
782 			xTraceEventAdd32(xTraceHandle, ret);
783 			xTraceEventEnd(xTraceHandle);
784 		}
785 	}
786 
787 	return ret;
788 }
789 
_txe_mutex_info_get(TX_MUTEX * mutex_ptr,CHAR ** name,ULONG * count,TX_THREAD ** owner,TX_THREAD ** first_suspended,ULONG * suspended_count,TX_MUTEX ** next_mutex)790 UINT _txe_mutex_info_get(TX_MUTEX *mutex_ptr, CHAR **name, ULONG *count,
791 		TX_THREAD **owner, TX_THREAD **first_suspended, ULONG *suspended_count, TX_MUTEX **next_mutex)
792 {
793 	UINT ret = _txe_mutex_info_get_orig(mutex_ptr, name, count, owner,
794 			first_suspended, suspended_count, next_mutex);
795 
796 	if (ret != TX_SUCCESS)
797 	{
798 		TraceEventHandle_t xTraceHandle;
799 
800 		if (xTraceEventBegin(PSF_EVENT_MUTEX_INFO_GET_FAILED, sizeof(void*) + sizeof(UINT),
801 			&xTraceHandle) == TRC_SUCCESS) {
802 			xTraceEventAddPointer(xTraceHandle, (void*)mutex_ptr);
803 			xTraceEventAdd32(xTraceHandle, ret);
804 			xTraceEventEnd(xTraceHandle);
805 		}
806 	}
807 
808 	return ret;
809 }
810 
_tx_mutex_performance_info_get(TX_MUTEX * mutex_ptr,ULONG * puts,ULONG * gets,ULONG * suspensions,ULONG * timeouts,ULONG * inversions,ULONG * inheritances)811 UINT _tx_mutex_performance_info_get(TX_MUTEX *mutex_ptr, ULONG *puts, ULONG *gets, ULONG *suspensions, ULONG *timeouts, ULONG *inversions, ULONG *inheritances)
812 {
813 	UINT ret = _tx_mutex_performance_info_get_orig(mutex_ptr, puts, gets, suspensions, timeouts, inversions, inheritances);
814 
815 	if (ret != TX_SUCCESS)
816 	{
817 		TraceEventHandle_t xTraceHandle;
818 
819 		if (xTraceEventBegin(PSF_EVENT_MUTEX_PERFORMANCE_INFO_GET_FAILED, sizeof(void*) + sizeof(UINT),
820 			&xTraceHandle) == TRC_SUCCESS) {
821 			xTraceEventAddPointer(xTraceHandle, (void*)mutex_ptr);
822 			xTraceEventAdd32(xTraceHandle, ret);
823 			xTraceEventEnd(xTraceHandle);
824 		}
825 	}
826 
827 	return ret;
828 }
829 
_tx_mutex_performance_system_info_get(ULONG * puts,ULONG * gets,ULONG * suspensions,ULONG * timeouts,ULONG * inversions,ULONG * inheritances)830 UINT  _tx_mutex_performance_system_info_get(ULONG *puts, ULONG *gets, ULONG *suspensions,
831                                 ULONG *timeouts, ULONG *inversions, ULONG *inheritances)
832 {
833 	UINT ret = _tx_mutex_performance_system_info_get_oirg(puts, gets, suspensions, timeouts, inversions, inheritances);
834 
835 	if(ret == TX_SUCCESS)
836 	{
837 		TraceEventHandle_t xTraceHandle;
838 
839 		if (xTraceEventBegin(PSF_EVENT_MUTEX_PERFORMANCE_SYSTEM_INFO_GET_SUCCESS, 0,
840 			&xTraceHandle) == TRC_SUCCESS) {
841 			xTraceEventEnd(xTraceHandle);
842 		}
843 	}
844 	else
845 	{
846 		TraceEventHandle_t xTraceHandle;
847 
848 		if (xTraceEventBegin(PSF_EVENT_BLOCK_POOL__PERFORMANCE_SYSTEM_INFO_GET_FAILED, 0,
849 			&xTraceHandle) == TRC_SUCCESS) {
850 			xTraceEventEnd(xTraceHandle);
851 		}
852 	}
853 
854 	return ret;
855 }
856 
_txe_mutex_prioritize(TX_MUTEX * mutex_ptr)857 UINT _txe_mutex_prioritize(TX_MUTEX *mutex_ptr)
858 {
859 	UINT ret = _txe_mutex_prioritize_orig(mutex_ptr);
860 
861 	if (ret != TX_SUCCESS)
862 	{
863 		TraceEventHandle_t xTraceHandle;
864 
865 		if (xTraceEventBegin(PSF_EVENT_MUTEX_PRIORITIZE_FAILED, sizeof(void*) + sizeof(UINT),
866 			&xTraceHandle) == TRC_SUCCESS) {
867 			xTraceEventAddPointer(xTraceHandle, (void*)mutex_ptr);
868 			xTraceEventAdd32(xTraceHandle, ret);
869 			xTraceEventEnd(xTraceHandle);
870 		}
871 	}
872 
873 	return ret;
874 }
875 
_txe_mutex_put(TX_MUTEX * mutex_ptr)876 UINT _txe_mutex_put(TX_MUTEX *mutex_ptr)
877 {
878 	UINT ret = _txe_mutex_put_orig(mutex_ptr);
879 
880 	if (ret != TX_SUCCESS)
881 	{
882 		TraceEventHandle_t xTraceHandle;
883 
884 		if (xTraceEventBegin(PSF_EVENT_MUTEX_PUT_FAILED, sizeof(void*) + sizeof(UINT),
885 			&xTraceHandle) == TRC_SUCCESS) {
886 			xTraceEventAddPointer(xTraceHandle, (void*)mutex_ptr);
887 			xTraceEventAdd32(xTraceHandle, ret);
888 			xTraceEventEnd(xTraceHandle);
889 		}
890 	}
891 
892 	return ret;
893 }
894 
895 
_txe_queue_create(TX_QUEUE * queue_ptr,CHAR * name_ptr,UINT message_size,VOID * queue_start,ULONG queue_size,UINT queue_control_block_size)896 UINT _txe_queue_create(TX_QUEUE *queue_ptr, CHAR *name_ptr, UINT message_size,
897                         VOID *queue_start, ULONG queue_size, UINT queue_control_block_size)
898 {
899 	TraceEventHandle_t xTraceHandle;
900 
901 	UINT ret = _txe_queue_create_orig(queue_ptr, name_ptr, message_size, queue_start, queue_size, queue_control_block_size);
902 
903 	if (ret != TX_SUCCESS)
904 	{
905 		if (xTraceEventBegin(PSF_EVENT_QUEUE_CREATE_FAILED, sizeof(void*) + sizeof(UINT) + sizeof(void*) + sizeof(ULONG) + sizeof(UINT),
906 			&xTraceHandle) == TRC_SUCCESS) {
907 			xTraceEventAddPointer(xTraceHandle, (void*)queue_ptr);
908 			xTraceEventAdd32(xTraceHandle, message_size);
909 			xTraceEventAddPointer(xTraceHandle, (void*)queue_start);
910 			xTraceEventAddUnsignedBaseType(xTraceHandle, queue_size);
911 			xTraceEventAdd32(xTraceHandle, ret);
912 			xTraceEventEnd(xTraceHandle);
913 		}
914 	}
915 
916 	return ret;
917 }
918 
_txe_queue_delete(TX_QUEUE * queue_ptr)919 UINT _txe_queue_delete(TX_QUEUE *queue_ptr)
920 {
921 	UINT ret = _txe_queue_delete_orig(queue_ptr);
922 
923 	if (ret != TX_SUCCESS)
924 	{
925 		TraceEventHandle_t xTraceHandle;
926 
927 		if (xTraceEventBegin(PSF_EVENT_QUEUE_DELETE_FAILED, sizeof(void*) + sizeof(UINT),
928 			&xTraceHandle) == TRC_SUCCESS) {
929 			xTraceEventAddPointer(xTraceHandle, (void*)queue_ptr);
930 			xTraceEventAdd32(xTraceHandle, ret);
931 			xTraceEventEnd(xTraceHandle);
932 		}
933 	}
934 
935 	return ret;
936 }
937 
938 
_txe_queue_flush(TX_QUEUE * queue_ptr)939 UINT _txe_queue_flush(TX_QUEUE *queue_ptr)
940 {
941 	UINT ret = _txe_queue_flush_orig(queue_ptr);
942 
943 	if (ret != TX_SUCCESS)
944 	{
945 		TraceEventHandle_t xTraceHandle;
946 
947 		if (xTraceEventBegin(PSF_EVENT_QUEUE_FLUSH_FAILED, sizeof(void*) + sizeof(UINT),
948 			&xTraceHandle) == TRC_SUCCESS) {
949 			xTraceEventAddPointer(xTraceHandle, (void*)queue_ptr);
950 			xTraceEventAdd32(xTraceHandle, ret);
951 			xTraceEventEnd(xTraceHandle);
952 		}
953 	}
954 
955 	return ret;
956 }
957 
_txe_queue_front_send(TX_QUEUE * queue_ptr,VOID * source_ptr,ULONG wait_option)958 UINT _txe_queue_front_send(TX_QUEUE *queue_ptr, VOID *source_ptr, ULONG wait_option)
959 {
960 	TraceEventHandle_t xTraceHandle;
961 
962 	if (xTraceEventBegin(PSF_EVENT_QUEUE_FRONT_SEND_BLOCKED, sizeof(void*) + sizeof(void*) + sizeof(ULONG),
963 		&xTraceHandle) == TRC_SUCCESS) {
964 		xTraceEventAddPointer(xTraceHandle, (void*)queue_ptr);
965 		xTraceEventAddPointer(xTraceHandle, (void*)source_ptr);
966 		xTraceEventAddUnsignedBaseType(xTraceHandle, wait_option);
967 		xTraceEventEnd(xTraceHandle);
968 	}
969 
970 	UINT ret = _txe_queue_front_send_orig(queue_ptr, source_ptr, wait_option);
971 
972 	if (ret == TX_SUCCESS)
973 	{
974 		if (xTraceEventBegin(PSF_EVENT_QUEUE_FRONT_SEND_SUCCESS, sizeof(void*) + sizeof(void*) + sizeof(ULONG),
975 			&xTraceHandle) == TRC_SUCCESS) {
976 			xTraceEventAddPointer(xTraceHandle, (void*)queue_ptr);
977 			xTraceEventAddPointer(xTraceHandle, (void*)source_ptr);
978 			xTraceEventAddUnsignedBaseType(xTraceHandle, wait_option);
979 			xTraceEventEnd(xTraceHandle);
980 		}
981 	}
982 	else if (ret == TX_QUEUE_FULL)
983 	{
984 		if (xTraceEventBegin(PSF_EVENT_QUEUE_FRONT_SEND_TIMEOUT, sizeof(void*) + sizeof(void*) + sizeof(ULONG) + sizeof(UINT),
985 			&xTraceHandle) == TRC_SUCCESS) {
986 			xTraceEventAddPointer(xTraceHandle, (void*)queue_ptr);
987 			xTraceEventAddPointer(xTraceHandle, (void*)source_ptr);
988 			xTraceEventAddUnsignedBaseType(xTraceHandle, wait_option);
989 			xTraceEventAdd32(xTraceHandle, ret);
990 			xTraceEventEnd(xTraceHandle);
991 		}
992 	}
993 	else
994 	{
995 		if (xTraceEventBegin(PSF_EVENT_QUEUE_FRONT_SEND_FAILED, sizeof(void*) + sizeof(void*) + sizeof(ULONG) + sizeof(UINT),
996 			&xTraceHandle) == TRC_SUCCESS) {
997 			xTraceEventAddPointer(xTraceHandle, (void*)queue_ptr);
998 			xTraceEventAddPointer(xTraceHandle, (void*)source_ptr);
999 			xTraceEventAddUnsignedBaseType(xTraceHandle, wait_option);
1000 			xTraceEventAdd32(xTraceHandle, ret);
1001 			xTraceEventEnd(xTraceHandle);
1002 		}
1003 	}
1004 
1005 	return ret;
1006 }
1007 
_txe_queue_info_get(TX_QUEUE * queue_ptr,CHAR ** name,ULONG * enqueued,ULONG * available_storage,TX_THREAD ** first_suspended,ULONG * suspended_count,TX_QUEUE ** next_queue)1008 UINT _txe_queue_info_get(TX_QUEUE *queue_ptr, CHAR **name, ULONG *enqueued, ULONG *available_storage, TX_THREAD **first_suspended, ULONG *suspended_count, TX_QUEUE **next_queue)
1009 {
1010 	UINT ret = _txe_queue_info_get_orig(queue_ptr, name, enqueued, available_storage, first_suspended, suspended_count, next_queue);
1011 
1012 	if (ret != TX_SUCCESS)
1013 	{
1014 		TraceEventHandle_t xTraceHandle;
1015 
1016 		if (xTraceEventBegin(PSF_EVENT_QUEUE_INFO_GET_FAILED, sizeof(void*) + sizeof(UINT),
1017 			&xTraceHandle) == TRC_SUCCESS) {
1018 			xTraceEventAddPointer(xTraceHandle, (void*)queue_ptr);
1019 			xTraceEventAdd32(xTraceHandle, ret);
1020 			xTraceEventEnd(xTraceHandle);
1021 		}
1022 	}
1023 
1024 	return ret;
1025 }
1026 
_tx_queue_performance_info_get(TX_QUEUE * queue_ptr,ULONG * messages_sent,ULONG * messages_received,ULONG * empty_suspensions,ULONG * full_suspensions,ULONG * full_errors,ULONG * timeouts)1027 UINT  _tx_queue_performance_info_get(TX_QUEUE *queue_ptr, ULONG *messages_sent, ULONG *messages_received,
1028                     ULONG *empty_suspensions, ULONG *full_suspensions, ULONG *full_errors, ULONG *timeouts)
1029 {
1030 	UINT ret = _tx_queue_performance_info_get_orig(queue_ptr, messages_sent, messages_received, empty_suspensions, full_suspensions, full_errors, timeouts);
1031 
1032 	if (ret != TX_SUCCESS)
1033 	{
1034 		TraceEventHandle_t xTraceHandle;
1035 
1036 		if (xTraceEventBegin(PSF_EVENT_QUEUE_PERFORMANCE_INFO_GET_FAILED, sizeof(void*) + sizeof(UINT),
1037 			&xTraceHandle) == TRC_SUCCESS) {
1038 			xTraceEventAddPointer(xTraceHandle, (void*)queue_ptr);
1039 			xTraceEventAdd32(xTraceHandle, ret);
1040 			xTraceEventEnd(xTraceHandle);
1041 		}
1042 	}
1043 
1044 	return ret;
1045 }
1046 
_tx_queue_performance_system_info_get(ULONG * messages_sent,ULONG * messages_received,ULONG * empty_suspensions,ULONG * full_suspensions,ULONG * full_errors,ULONG * timeouts)1047 UINT  _tx_queue_performance_system_info_get(ULONG *messages_sent, ULONG *messages_received,
1048                     ULONG *empty_suspensions, ULONG *full_suspensions, ULONG *full_errors, ULONG *timeouts)
1049 {
1050 	UINT ret = _tx_queue_performance_system_info_get_orig(messages_sent, messages_received, empty_suspensions, full_suspensions, full_errors, timeouts);
1051 
1052 	if(ret == TX_SUCCESS)
1053 	{
1054 		TraceEventHandle_t xTraceHandle;
1055 
1056 		if (xTraceEventBegin(PSF_EVENT_QUEUE_PERFORMANCE_SYSTEM_INFO_GET_SUCCESS, 0,
1057 			&xTraceHandle) == TRC_SUCCESS) {
1058 			xTraceEventEnd(xTraceHandle);
1059 		}
1060 	}
1061 	else
1062 	{
1063 		TraceEventHandle_t xTraceHandle;
1064 
1065 		if (xTraceEventBegin(PSF_EVENT_QUEUE_PERFORMANCE_SYSTEM_INFO_GET_FAILED, 0,
1066 			&xTraceHandle) == TRC_SUCCESS) {
1067 			xTraceEventEnd(xTraceHandle);
1068 		}
1069 	}
1070 
1071 	return ret;
1072 }
1073 
_txe_queue_prioritize(TX_QUEUE * queue_ptr)1074 UINT _txe_queue_prioritize(TX_QUEUE *queue_ptr)
1075 {
1076 	UINT ret = _txe_queue_prioritize_orig(queue_ptr);
1077 
1078 	if (ret != TX_SUCCESS)
1079 	{
1080 		TraceEventHandle_t xTraceHandle;
1081 
1082 		if (xTraceEventBegin(PSF_EVENT_QUEUE_PRIORITIZE_FAILED, sizeof(void*) + sizeof(UINT),
1083 			&xTraceHandle) == TRC_SUCCESS) {
1084 			xTraceEventAddPointer(xTraceHandle, (void*)queue_ptr);
1085 			xTraceEventAdd32(xTraceHandle, ret);
1086 			xTraceEventEnd(xTraceHandle);
1087 		}
1088 	}
1089 
1090 	return ret;
1091 }
1092 
_txe_queue_receive(TX_QUEUE * queue_ptr,VOID * destination_ptr,ULONG wait_option)1093 UINT _txe_queue_receive(TX_QUEUE *queue_ptr, VOID *destination_ptr, ULONG wait_option)
1094 {
1095 	TraceEventHandle_t xTraceHandle;
1096 
1097 	if (xTraceEventBegin(PSF_EVENT_QUEUE_RECEIVE_BLOCKED, sizeof(void*) + sizeof(void*) + sizeof(ULONG),
1098 		&xTraceHandle) == TRC_SUCCESS) {
1099 		xTraceEventAddPointer(xTraceHandle, (void*)queue_ptr);
1100 		xTraceEventAddPointer(xTraceHandle, (void*)destination_ptr);
1101 		xTraceEventAddUnsignedBaseType(xTraceHandle, wait_option);
1102 		xTraceEventEnd(xTraceHandle);
1103 	}
1104 
1105 	UINT ret = _txe_queue_receive_orig(queue_ptr, destination_ptr, wait_option);
1106 
1107 	if (ret == TX_SUCCESS)
1108 	{
1109 		if (xTraceEventBegin(PSF_EVENT_QUEUE_RECEIVE_SUCCESS, sizeof(void*) + sizeof(void*) + sizeof(ULONG),
1110 			&xTraceHandle) == TRC_SUCCESS) {
1111 			xTraceEventAddPointer(xTraceHandle, (void*)queue_ptr);
1112 			xTraceEventAddPointer(xTraceHandle, (void*)destination_ptr);
1113 			xTraceEventAddUnsignedBaseType(xTraceHandle, wait_option);
1114 			xTraceEventEnd(xTraceHandle);
1115 		}
1116 	}
1117 	else if (ret == TX_QUEUE_EMPTY)
1118 	{
1119 		if (xTraceEventBegin(PSF_EVENT_QUEUE_RECEIVE_TIMEOUT, sizeof(void*) + sizeof(void*) + sizeof(ULONG) + sizeof(UINT),
1120 			&xTraceHandle) == TRC_SUCCESS) {
1121 			xTraceEventAddPointer(xTraceHandle, (void*)queue_ptr);
1122 			xTraceEventAddPointer(xTraceHandle, (void*)destination_ptr);
1123 			xTraceEventAddUnsignedBaseType(xTraceHandle, wait_option);
1124 			xTraceEventAdd32(xTraceHandle, ret);
1125 			xTraceEventEnd(xTraceHandle);
1126 		}
1127 	}
1128 	else
1129 	{
1130 		if (xTraceEventBegin(PSF_EVENT_QUEUE_RECEIVE_FAILED, sizeof(void*) + sizeof(void*) + sizeof(ULONG) + sizeof(UINT),
1131 			&xTraceHandle) == TRC_SUCCESS) {
1132 			xTraceEventAddPointer(xTraceHandle, (void*)queue_ptr);
1133 			xTraceEventAddPointer(xTraceHandle, (void*)destination_ptr);
1134 			xTraceEventAddUnsignedBaseType(xTraceHandle, wait_option);
1135 			xTraceEventAdd32(xTraceHandle, ret);
1136 			xTraceEventEnd(xTraceHandle);
1137 		}
1138 	}
1139 
1140 	return ret;
1141 }
1142 
_txe_queue_send_notify(TX_QUEUE * queue_ptr,VOID (* queue_send_notify)(TX_QUEUE * notify_queue_ptr))1143 UINT _txe_queue_send_notify(TX_QUEUE *queue_ptr, VOID (*queue_send_notify)(TX_QUEUE *notify_queue_ptr))
1144 {
1145 	UINT ret = _txe_queue_send_notify_orig(queue_ptr, queue_send_notify);
1146 
1147 	if (ret != TX_SUCCESS)
1148 	{
1149 		TraceEventHandle_t xTraceHandle;
1150 
1151 		if (xTraceEventBegin(PSF_EVENT_QUEUE_SEND_NOTIFY_FAILED, sizeof(void*) + sizeof(UINT),
1152 			&xTraceHandle) == TRC_SUCCESS) {
1153 			xTraceEventAddPointer(xTraceHandle, (void*)queue_ptr);
1154 			xTraceEventAdd32(xTraceHandle, ret);
1155 			xTraceEventEnd(xTraceHandle);
1156 		}
1157 	}
1158 
1159 	return ret;
1160 }
1161 
_txe_queue_send(TX_QUEUE * queue_ptr,VOID * source_ptr,ULONG wait_option)1162 UINT _txe_queue_send(TX_QUEUE *queue_ptr, VOID *source_ptr, ULONG wait_option)
1163 {
1164 	TraceEventHandle_t xTraceHandle;
1165 
1166 	if (xTraceEventBegin(PSF_EVENT_QUEUE_SEND_BLOCKED, sizeof(void*) + sizeof(void*) + sizeof(ULONG),
1167 		&xTraceHandle) == TRC_SUCCESS) {
1168 		xTraceEventAddPointer(xTraceHandle, (void*)queue_ptr);
1169 		xTraceEventAddPointer(xTraceHandle, (void*)source_ptr);
1170 		xTraceEventAddUnsignedBaseType(xTraceHandle, wait_option);
1171 		xTraceEventEnd(xTraceHandle);
1172 	}
1173 
1174 	UINT ret = _txe_queue_send_orig(queue_ptr, source_ptr, wait_option);
1175 
1176 	if (ret == TX_SUCCESS)
1177 	{
1178 		if (xTraceEventBegin(PSF_EVENT_QUEUE_SEND_SUCCESS, sizeof(void*) + sizeof(void*) + sizeof(ULONG),
1179 			&xTraceHandle) == TRC_SUCCESS) {
1180 			xTraceEventAddPointer(xTraceHandle, (void*)queue_ptr);
1181 			xTraceEventAddPointer(xTraceHandle, (void*)source_ptr);
1182 			xTraceEventAddUnsignedBaseType(xTraceHandle, wait_option);
1183 			xTraceEventEnd(xTraceHandle);
1184 		}
1185 	}
1186 	else if (ret == TX_QUEUE_FULL)
1187 	{
1188 		if (xTraceEventBegin(PSF_EVENT_QUEUE_SEND_TIMEOUT, sizeof(void*) + sizeof(void*) + sizeof(ULONG) + sizeof(UINT),
1189 			&xTraceHandle) == TRC_SUCCESS) {
1190 			xTraceEventAddPointer(xTraceHandle, (void*)queue_ptr);
1191 			xTraceEventAddPointer(xTraceHandle, (void*)source_ptr);
1192 			xTraceEventAddUnsignedBaseType(xTraceHandle, wait_option);
1193 			xTraceEventAdd32(xTraceHandle, ret);
1194 			xTraceEventEnd(xTraceHandle);
1195 		}
1196 	}
1197 	else
1198 	{
1199 		if (xTraceEventBegin(PSF_EVENT_QUEUE_SEND_FAILED, sizeof(void*) + sizeof(void*) + sizeof(ULONG) + sizeof(UINT),
1200 			&xTraceHandle) == TRC_SUCCESS) {
1201 			xTraceEventAddPointer(xTraceHandle, (void*)queue_ptr);
1202 			xTraceEventAddPointer(xTraceHandle, (void*)source_ptr);
1203 			xTraceEventAddUnsignedBaseType(xTraceHandle, wait_option);
1204 			xTraceEventAdd32(xTraceHandle, ret);
1205 			xTraceEventEnd(xTraceHandle);
1206 		}
1207 	}
1208 
1209 	return ret;
1210 }
1211 
_txe_semaphore_ceiling_put(TX_SEMAPHORE * semaphore_ptr,ULONG ceiling)1212 UINT _txe_semaphore_ceiling_put(TX_SEMAPHORE *semaphore_ptr, ULONG ceiling)
1213 {
1214 	TraceEventHandle_t xTraceHandle;
1215 
1216 	if (xTraceEventBegin(PSF_EVENT_SEMAPHORE_CEILING_PUT_BLOCKED, sizeof(void*) + sizeof(ULONG),
1217 		&xTraceHandle) == TRC_SUCCESS) {
1218 		xTraceEventAddPointer(xTraceHandle, (void*)semaphore_ptr);
1219 		xTraceEventAddUnsignedBaseType(xTraceHandle, ceiling);
1220 		xTraceEventEnd(xTraceHandle);
1221 	}
1222 
1223 	UINT ret = _txe_semaphore_ceiling_put_orig(semaphore_ptr, ceiling);
1224 
1225 	if (ret == TX_SUCCESS)
1226 	{
1227 		if (xTraceEventBegin(PSF_EVENT_SEMAPHORE_CEILING_PUT_SUCCESS, sizeof(void*) + sizeof(ULONG),
1228 			&xTraceHandle) == TRC_SUCCESS) {
1229 			xTraceEventAddPointer(xTraceHandle, (void*)semaphore_ptr);
1230 			xTraceEventAddUnsignedBaseType(xTraceHandle, ceiling);
1231 			xTraceEventEnd(xTraceHandle);
1232 		}
1233 	}
1234 	else
1235 	{
1236 		if (xTraceEventBegin(PSF_EVENT_SEMAPHORE_CEILING_PUT_FAILED, sizeof(void*) + sizeof(ULONG) + sizeof(UINT),
1237 			&xTraceHandle) == TRC_SUCCESS) {
1238 			xTraceEventAddPointer(xTraceHandle, (void*)semaphore_ptr);
1239 			xTraceEventAddUnsignedBaseType(xTraceHandle, ceiling);
1240 			xTraceEventAdd32(xTraceHandle, ret);
1241 			xTraceEventEnd(xTraceHandle);
1242 		}
1243 	}
1244 
1245 	return ret;
1246 }
1247 
_txe_semaphore_create(TX_SEMAPHORE * semaphore_ptr,CHAR * name_ptr,ULONG initial_count,UINT semaphore_control_block_size)1248 UINT _txe_semaphore_create(TX_SEMAPHORE *semaphore_ptr, CHAR *name_ptr, ULONG initial_count, UINT semaphore_control_block_size)
1249 {
1250 	UINT ret = _txe_semaphore_create_orig(semaphore_ptr, name_ptr, initial_count, semaphore_control_block_size);
1251 
1252 	if (ret != TX_SUCCESS)
1253 	{
1254 		TraceEventHandle_t xTraceHandle;
1255 
1256 		if (xTraceEventBegin(PSF_EVENT_SEMAPHORE_CREATE_FAILED, sizeof(void*) + sizeof(ULONG) + sizeof(UINT),
1257 			&xTraceHandle) == TRC_SUCCESS) {
1258 			xTraceEventAddPointer(xTraceHandle, (void*)semaphore_ptr);
1259 			xTraceEventAddUnsignedBaseType(xTraceHandle, initial_count);
1260 			xTraceEventAdd32(xTraceHandle, ret);
1261 			xTraceEventEnd(xTraceHandle);
1262 		}
1263 	}
1264 
1265 	return ret;
1266 }
1267 
_txe_semaphore_delete(TX_SEMAPHORE * semaphore_ptr)1268 UINT _txe_semaphore_delete(TX_SEMAPHORE *semaphore_ptr)
1269 {
1270 	UINT ret = _txe_semaphore_delete_orig(semaphore_ptr);
1271 
1272 	if (ret != TX_SUCCESS)
1273 	{
1274 		TraceEventHandle_t xTraceHandle;
1275 
1276 		if (xTraceEventBegin(PSF_EVENT_SEMAPHORE_DELETE_FAILED, sizeof(void*) + sizeof(UINT),
1277 			&xTraceHandle) == TRC_SUCCESS) {
1278 			xTraceEventAddPointer(xTraceHandle, (void*)semaphore_ptr);
1279 			xTraceEventAdd32(xTraceHandle, ret);
1280 			xTraceEventEnd(xTraceHandle);
1281 		}
1282 	}
1283 
1284 	return ret;
1285 }
1286 
_txe_semaphore_get(TX_SEMAPHORE * semaphore_ptr,ULONG wait_option)1287 UINT _txe_semaphore_get(TX_SEMAPHORE *semaphore_ptr, ULONG wait_option)
1288 {
1289 	TraceEventHandle_t xTraceHandle;
1290 
1291 	if (xTraceEventBegin(PSF_EVENT_SEMAPHORE_GET_BLOCKED, sizeof(void*) + sizeof(ULONG),
1292 		&xTraceHandle) == TRC_SUCCESS) {
1293 		xTraceEventAddPointer(xTraceHandle, (void*)semaphore_ptr);
1294 		xTraceEventAddUnsignedBaseType(xTraceHandle, wait_option);
1295 		xTraceEventEnd(xTraceHandle);
1296 	}
1297 
1298 	UINT ret = _txe_semaphore_get_orig(semaphore_ptr, wait_option);
1299 
1300 	if (ret == TX_SUCCESS)
1301 	{
1302 		if (xTraceEventBegin(PSF_EVENT_SEMAPHORE_GET_SUCCESS, sizeof(void*) + sizeof(ULONG),
1303 			&xTraceHandle) == TRC_SUCCESS) {
1304 			xTraceEventAddPointer(xTraceHandle, (void*)semaphore_ptr);
1305 			xTraceEventAddUnsignedBaseType(xTraceHandle, wait_option);
1306 			xTraceEventEnd(xTraceHandle);
1307 		}
1308 	}
1309 	else if (ret == TX_NO_INSTANCE)
1310 	{
1311 		if (xTraceEventBegin(PSF_EVENT_SEMAPHORE_GET_TIMEOUT, sizeof(void*) + sizeof(ULONG) + sizeof(UINT),
1312 			&xTraceHandle) == TRC_SUCCESS) {
1313 			xTraceEventAddPointer(xTraceHandle, (void*)semaphore_ptr);
1314 			xTraceEventAddUnsignedBaseType(xTraceHandle, wait_option);
1315 			xTraceEventAdd32(xTraceHandle, ret);
1316 			xTraceEventEnd(xTraceHandle);
1317 		}
1318 	}
1319 	else
1320 	{
1321 		if (xTraceEventBegin(PSF_EVENT_SEMAPHORE_GET_FAILED, sizeof(void*) + sizeof(ULONG) + sizeof(UINT),
1322 			&xTraceHandle) == TRC_SUCCESS) {
1323 			xTraceEventAddPointer(xTraceHandle, (void*)semaphore_ptr);
1324 			xTraceEventAddUnsignedBaseType(xTraceHandle, wait_option);
1325 			xTraceEventAdd32(xTraceHandle, ret);
1326 			xTraceEventEnd(xTraceHandle);
1327 		}
1328 	}
1329 
1330 	return ret;
1331 }
1332 
_txe_semaphore_info_get(TX_SEMAPHORE * semaphore_ptr,CHAR ** name,ULONG * current_value,TX_THREAD ** first_suspended,ULONG * suspended_count,TX_SEMAPHORE ** next_semaphore)1333 UINT _txe_semaphore_info_get(TX_SEMAPHORE *semaphore_ptr, CHAR **name, ULONG *current_value, TX_THREAD **first_suspended, ULONG *suspended_count, TX_SEMAPHORE **next_semaphore)
1334 {
1335 	UINT ret = _txe_semaphore_info_get_orig(semaphore_ptr, name, current_value, first_suspended, suspended_count, next_semaphore);
1336 
1337 	if (ret != TX_SUCCESS)
1338 	{
1339 		TraceEventHandle_t xTraceHandle;
1340 
1341 		if (xTraceEventBegin(PSF_EVENT_SEMAPHORE_INFO_GET_FAILED, sizeof(void*) + sizeof(UINT),
1342 			&xTraceHandle) == TRC_SUCCESS) {
1343 			xTraceEventAddPointer(xTraceHandle, (void*)semaphore_ptr);
1344 			xTraceEventAdd32(xTraceHandle, ret);
1345 			xTraceEventEnd(xTraceHandle);
1346 		}
1347 	}
1348 
1349 	return ret;
1350 }
1351 
_tx_semaphore_performance_info_get(TX_SEMAPHORE * semaphore_ptr,ULONG * puts,ULONG * gets,ULONG * suspensions,ULONG * timeouts)1352 UINT _tx_semaphore_performance_info_get(TX_SEMAPHORE *semaphore_ptr, ULONG *puts, ULONG *gets, ULONG *suspensions, ULONG *timeouts)
1353 {
1354 	UINT ret = _tx_semaphore_performance_info_get_orig(semaphore_ptr, puts, gets, suspensions, timeouts);
1355 
1356 	if (ret != TX_SUCCESS)
1357 	{
1358 		TraceEventHandle_t xTraceHandle;
1359 
1360 		if (xTraceEventBegin(PSF_EVENT_SEMAPHORE_PERFORMANCE_INFO_GET_FAILED, sizeof(void*) + sizeof(UINT),
1361 			&xTraceHandle) == TRC_SUCCESS) {
1362 			xTraceEventAddPointer(xTraceHandle, (void*)semaphore_ptr);
1363 			xTraceEventAdd32(xTraceHandle, ret);
1364 			xTraceEventEnd(xTraceHandle);
1365 		}
1366 	}
1367 
1368 	return ret;
1369 }
1370 
_tx_semaphore_performance_system_info_get(ULONG * puts,ULONG * gets,ULONG * suspensions,ULONG * timeouts)1371 UINT  _tx_semaphore_performance_system_info_get(ULONG *puts, ULONG *gets, ULONG *suspensions, ULONG *timeouts)
1372 {
1373 	UINT ret = _tx_semaphore_performance_system_info_get_oirg(puts, gets, suspensions, timeouts);
1374 
1375 	if(ret == TX_SUCCESS)
1376 	{
1377 		TraceEventHandle_t xTraceHandle;
1378 
1379 		if (xTraceEventBegin(PSF_EVENT_SEMAPHORE__PERFORMANCE_SYSTEM_INFO_GET_SUCCESS, 0,
1380 			&xTraceHandle) == TRC_SUCCESS) {
1381 			xTraceEventEnd(xTraceHandle);
1382 		}
1383 	}
1384 	else
1385 	{
1386 		TraceEventHandle_t xTraceHandle;
1387 
1388 		if (xTraceEventBegin(PSF_EVENT_SEMAPHORE__PERFORMANCE_SYSTEM_INFO_GET_FAILED, 0,
1389 			&xTraceHandle) == TRC_SUCCESS) {
1390 			xTraceEventEnd(xTraceHandle);
1391 		}
1392 	}
1393 
1394 	return ret;
1395 }
1396 
1397 
_txe_semaphore_prioritize(TX_SEMAPHORE * semaphore_ptr)1398 UINT _txe_semaphore_prioritize(TX_SEMAPHORE *semaphore_ptr)
1399 {
1400 	UINT ret = _txe_semaphore_prioritize_orig(semaphore_ptr);
1401 
1402 	if (ret != TX_SUCCESS)
1403 	{
1404 		TraceEventHandle_t xTraceHandle;
1405 
1406 		if (xTraceEventBegin(PSF_EVENT_SEMAPHORE_PRIORITIZE_FAILED, sizeof(void*) + sizeof(UINT),
1407 			&xTraceHandle) == TRC_SUCCESS) {
1408 			xTraceEventAddPointer(xTraceHandle, (void*)semaphore_ptr);
1409 			xTraceEventAdd32(xTraceHandle, ret);
1410 			xTraceEventEnd(xTraceHandle);
1411 		}
1412 	}
1413 
1414 	return ret;
1415 }
1416 
_txe_semaphore_put_notify(TX_SEMAPHORE * semaphore_ptr,VOID (* semaphore_put_notify)(TX_SEMAPHORE * notify_semaphore_ptr))1417 UINT _txe_semaphore_put_notify(TX_SEMAPHORE *semaphore_ptr, VOID (*semaphore_put_notify)(TX_SEMAPHORE *notify_semaphore_ptr))
1418 {
1419 	UINT ret = _txe_semaphore_put_notify_orig(semaphore_ptr, semaphore_put_notify);
1420 
1421 	if (ret != TX_SUCCESS)
1422 	{
1423 		TraceEventHandle_t xTraceHandle;
1424 
1425 		if (xTraceEventBegin(PSF_EVENT_SEMAPHORE_PUT_NOTIFY_FAILED, sizeof(void*) + sizeof(UINT),
1426 			&xTraceHandle) == TRC_SUCCESS) {
1427 			xTraceEventAddPointer(xTraceHandle, (void*)semaphore_ptr);
1428 			xTraceEventAdd32(xTraceHandle, ret);
1429 			xTraceEventEnd(xTraceHandle);
1430 		}
1431 	}
1432 
1433 	return ret;
1434 }
1435 
_txe_semaphore_put(TX_SEMAPHORE * semaphore_ptr)1436 UINT _txe_semaphore_put(TX_SEMAPHORE *semaphore_ptr)
1437 {
1438 	UINT ret = _txe_semaphore_put_orig(semaphore_ptr);
1439 
1440 	if (ret != TX_SUCCESS)
1441 	{
1442 		TraceEventHandle_t xTraceHandle;
1443 
1444 		if (xTraceEventBegin(PSF_EVENT_SEMAPHORE_PUT_FAILED, sizeof(void*) + sizeof(UINT),
1445 			&xTraceHandle) == TRC_SUCCESS) {
1446 			xTraceEventAddPointer(xTraceHandle, (void*)semaphore_ptr);
1447 			xTraceEventAdd32(xTraceHandle, ret);
1448 			xTraceEventEnd(xTraceHandle);
1449 		}
1450 	}
1451 
1452 	return ret;
1453 }
1454 
1455 
_txe_thread_create(TX_THREAD * thread_ptr,CHAR * name_ptr,VOID (* entry_function)(ULONG id),ULONG entry_input,VOID * stack_start,ULONG stack_size,UINT priority,UINT preempt_threshold,ULONG time_slice,UINT auto_start,UINT thread_control_block_size)1456 UINT _txe_thread_create(TX_THREAD *thread_ptr, CHAR *name_ptr, VOID (*entry_function)(ULONG id), ULONG entry_input,
1457         VOID *stack_start, ULONG stack_size, UINT priority, UINT preempt_threshold,
1458         ULONG time_slice, UINT auto_start, UINT thread_control_block_size)
1459 {
1460 	UINT ret = _txe_thread_create_orig(thread_ptr, name_ptr, entry_function, entry_input, stack_start,
1461 			stack_size, priority, preempt_threshold, time_slice, auto_start, thread_control_block_size);
1462 
1463 	if (ret != TX_SUCCESS)
1464 	{
1465 		TraceEventHandle_t xTraceHandle;
1466 
1467 		if (xTraceEventBegin(PSF_EVENT_THREAD_CREATE_FAILED, sizeof(void*) + sizeof(UINT),
1468 			&xTraceHandle) == TRC_SUCCESS) {
1469 			xTraceEventAddPointer(xTraceHandle, (void*)thread_ptr);
1470 			xTraceEventAdd32(xTraceHandle, ret);
1471 			xTraceEventEnd(xTraceHandle);
1472 		}
1473 	}
1474 
1475 	return ret;
1476 }
1477 
_txe_thread_delete(TX_THREAD * thread_ptr)1478 UINT _txe_thread_delete(TX_THREAD *thread_ptr)
1479 {
1480 	UINT ret = _txe_thread_delete_orig(thread_ptr);
1481 
1482 	if (ret != TX_SUCCESS)
1483 	{
1484 		TraceEventHandle_t xTraceHandle;
1485 
1486 		if (xTraceEventBegin(PSF_EVENT_THREAD_DELETE_FAILED, sizeof(void*) + sizeof(UINT),
1487 			&xTraceHandle) == TRC_SUCCESS) {
1488 			xTraceEventAddPointer(xTraceHandle, (void*)thread_ptr);
1489 			xTraceEventAdd32(xTraceHandle, ret);
1490 			xTraceEventEnd(xTraceHandle);
1491 		}
1492 	}
1493 
1494 	return ret;
1495 }
1496 
_txe_thread_entry_exit_notify(TX_THREAD * thread_ptr,VOID (* thread_entry_exit_notify)(TX_THREAD * notify_thread_ptr,UINT type))1497 UINT _txe_thread_entry_exit_notify(TX_THREAD *thread_ptr, VOID (*thread_entry_exit_notify)(TX_THREAD *notify_thread_ptr, UINT type))
1498 {
1499 	UINT ret = _txe_thread_entry_exit_notify_orig(thread_ptr, thread_entry_exit_notify);
1500 
1501 	if (ret != TX_SUCCESS)
1502 	{
1503 		TraceEventHandle_t xTraceHandle;
1504 
1505 		if (xTraceEventBegin(PSF_EVENT_THREAD_ENTRY_EXIT_NOTIFY_FAILED, sizeof(void*) + sizeof(UINT),
1506 			&xTraceHandle) == TRC_SUCCESS) {
1507 			xTraceEventAddPointer(xTraceHandle, (void*)thread_ptr);
1508 			xTraceEventAdd32(xTraceHandle, ret);
1509 			xTraceEventEnd(xTraceHandle);
1510 		}
1511 	}
1512 
1513 	return ret;
1514 }
1515 
_txe_thread_info_get(TX_THREAD * thread_ptr,CHAR ** name,UINT * state,ULONG * run_count,UINT * priority,UINT * preemption_threshold,ULONG * time_slice,TX_THREAD ** next_thread,TX_THREAD ** next_suspended_thread)1516 UINT _txe_thread_info_get(TX_THREAD *thread_ptr, CHAR **name, UINT *state, ULONG *run_count, UINT *priority, UINT *preemption_threshold, ULONG *time_slice, TX_THREAD **next_thread, TX_THREAD **next_suspended_thread)
1517 {
1518 	UINT ret = _txe_thread_info_get_orig(thread_ptr, name, state, run_count, priority, preemption_threshold, time_slice, next_thread, next_suspended_thread);
1519 
1520 	if (ret != TX_SUCCESS)
1521 	{
1522 		TraceEventHandle_t xTraceHandle;
1523 
1524 		if (xTraceEventBegin(PSF_EVENT_THREAD_INFO_GET_FAILED, sizeof(void*) + sizeof(UINT),
1525 			&xTraceHandle) == TRC_SUCCESS) {
1526 			xTraceEventAddPointer(xTraceHandle, (void*)thread_ptr);
1527 			xTraceEventAdd32(xTraceHandle, ret);
1528 			xTraceEventEnd(xTraceHandle);
1529 		}
1530 	}
1531 
1532 	return ret;
1533 }
1534 
_tx_thread_performance_info_get(TX_THREAD * thread_ptr,ULONG * resumptions,ULONG * suspensions,ULONG * solicited_preemptions,ULONG * interrupt_preemptions,ULONG * priority_inversions,ULONG * time_slices,ULONG * relinquishes,ULONG * timeouts,ULONG * wait_aborts,TX_THREAD ** last_preempted_by)1535 UINT _tx_thread_performance_info_get(TX_THREAD *thread_ptr, ULONG *resumptions, ULONG *suspensions,
1536                 ULONG *solicited_preemptions, ULONG *interrupt_preemptions, ULONG *priority_inversions,
1537                 ULONG *time_slices, ULONG *relinquishes, ULONG *timeouts, ULONG *wait_aborts, TX_THREAD **last_preempted_by)
1538 {
1539 	UINT ret = _tx_thread_performance_info_get_orig(thread_ptr, resumptions, suspensions, solicited_preemptions, interrupt_preemptions, priority_inversions, time_slices, relinquishes, timeouts, wait_aborts, last_preempted_by);
1540 
1541 	if (ret != TX_SUCCESS)
1542 	{
1543 		TraceEventHandle_t xTraceHandle;
1544 
1545 		if (xTraceEventBegin(PSF_EVENT_THREAD_PERFORMANCE_INFO_GET_FAILED, sizeof(void*) + sizeof(UINT),
1546 			&xTraceHandle) == TRC_SUCCESS) {
1547 			xTraceEventAddPointer(xTraceHandle, (void*)thread_ptr);
1548 			xTraceEventAdd32(xTraceHandle, ret);
1549 			xTraceEventEnd(xTraceHandle);
1550 		}
1551 	}
1552 
1553 	return ret;
1554 }
1555 
_tx_thread_performance_system_info_get(ULONG * resumptions,ULONG * suspensions,ULONG * solicited_preemptions,ULONG * interrupt_preemptions,ULONG * priority_inversions,ULONG * time_slices,ULONG * relinquishes,ULONG * timeouts,ULONG * wait_aborts,ULONG * non_idle_returns,ULONG * idle_returns)1556 UINT  _tx_thread_performance_system_info_get(ULONG *resumptions, ULONG *suspensions,
1557                 ULONG *solicited_preemptions, ULONG *interrupt_preemptions, ULONG *priority_inversions,
1558                 ULONG *time_slices, ULONG *relinquishes, ULONG *timeouts, ULONG *wait_aborts,
1559                 ULONG *non_idle_returns, ULONG *idle_returns)
1560 {
1561 	UINT ret = _tx_thread_performance_system_info_get_oirg(resumptions, suspensions, solicited_preemptions, interrupt_preemptions, priority_inversions, time_slices, relinquishes, timeouts, wait_aborts, non_idle_returns, idle_returns);
1562 
1563 	if(ret == TX_SUCCESS)
1564 	{
1565 		TraceEventHandle_t xTraceHandle;
1566 
1567 		if (xTraceEventBegin(PSF_EVENT_THREAD_PERFORMANCE_SYSTEM_INFO_GET_SUCCESS, 0,
1568 			&xTraceHandle) == TRC_SUCCESS) {
1569 			xTraceEventEnd(xTraceHandle);
1570 		}
1571 	}
1572 	else
1573 	{
1574 		TraceEventHandle_t xTraceHandle;
1575 
1576 		if (xTraceEventBegin(PSF_EVENT_THREAD_PERFORMANCE_SYSTEM_INFO_GET_FAILED, 0,
1577 			&xTraceHandle) == TRC_SUCCESS) {
1578 			xTraceEventEnd(xTraceHandle);
1579 		}
1580 	}
1581 
1582 	return ret;
1583 }
1584 
_txe_thread_preemption_change(TX_THREAD * thread_ptr,UINT new_threshold,UINT * old_threshold)1585 UINT _txe_thread_preemption_change(TX_THREAD *thread_ptr, UINT new_threshold, UINT *old_threshold)
1586 {
1587 	UINT ret = _txe_thread_preemption_change_orig(thread_ptr, new_threshold, old_threshold);
1588 
1589 	if (ret != TX_SUCCESS)
1590 	{
1591 		TraceEventHandle_t xTraceHandle;
1592 
1593 		if (xTraceEventBegin(PSF_EVENT_THREAD_PREEMPTION_CHANGE_FAILED, sizeof(void*) + sizeof(UINT) + sizeof(UINT),
1594 			&xTraceHandle) == TRC_SUCCESS) {
1595 			xTraceEventAddPointer(xTraceHandle, (void*)thread_ptr);
1596 			xTraceEventAdd32(xTraceHandle, new_threshold);
1597 			xTraceEventAdd32(xTraceHandle, ret);
1598 			xTraceEventEnd(xTraceHandle);
1599 		}
1600 	}
1601 
1602 	return ret;
1603 }
1604 
_txe_thread_priority_change(TX_THREAD * thread_ptr,UINT new_priority,UINT * old_priority)1605 UINT _txe_thread_priority_change(TX_THREAD *thread_ptr, UINT new_priority, UINT *old_priority)
1606 {
1607 	UINT ret = _txe_thread_priority_change_orig(thread_ptr, new_priority, old_priority);
1608 
1609 	if (ret != TX_SUCCESS)
1610 	{
1611 		TraceEventHandle_t xTraceHandle;
1612 
1613 		if (xTraceEventBegin(PSF_EVENT_THREAD_PRIORITY_CHANGE_FAILED, sizeof(void*) + sizeof(UINT) + sizeof(UINT),
1614 			&xTraceHandle) == TRC_SUCCESS) {
1615 			xTraceEventAddPointer(xTraceHandle, (void*)thread_ptr);
1616 			xTraceEventAdd32(xTraceHandle, new_priority);
1617 			xTraceEventAdd32(xTraceHandle, ret);
1618 			xTraceEventEnd(xTraceHandle);
1619 		}
1620 	}
1621 
1622 	return ret;
1623 }
1624 
_txe_thread_reset(TX_THREAD * thread_ptr)1625 UINT _txe_thread_reset(TX_THREAD *thread_ptr)
1626 {
1627 	UINT ret = _txe_thread_reset_orig(thread_ptr);
1628 
1629 	if (ret != TX_SUCCESS)
1630 	{
1631 		TraceEventHandle_t xTraceHandle;
1632 
1633 		if (xTraceEventBegin(PSF_EVENT_THREAD_RESET_FAILED, sizeof(void*) + sizeof(UINT),
1634 			&xTraceHandle) == TRC_SUCCESS) {
1635 			xTraceEventAddPointer(xTraceHandle, (void*)thread_ptr);
1636 			xTraceEventAdd32(xTraceHandle, ret);
1637 			xTraceEventEnd(xTraceHandle);
1638 		}
1639 	}
1640 
1641 	return ret;
1642 }
1643 
_txe_thread_resume(TX_THREAD * thread_ptr)1644 UINT _txe_thread_resume(TX_THREAD *thread_ptr)
1645 {
1646 	UINT ret = _txe_thread_resume_orig(thread_ptr);
1647 
1648 	if (ret != TX_SUCCESS)
1649 	{
1650 		TraceEventHandle_t xTraceHandle;
1651 
1652 		if (xTraceEventBegin(PSF_EVENT_THREAD_RESUME_FAILED, sizeof(void*) + sizeof(UINT),
1653 			&xTraceHandle) == TRC_SUCCESS) {
1654 			xTraceEventAddPointer(xTraceHandle, (void*)thread_ptr);
1655 			xTraceEventAdd32(xTraceHandle, ret);
1656 			xTraceEventEnd(xTraceHandle);
1657 		}
1658 	}
1659 
1660 	return ret;
1661 }
1662 
_tx_thread_sleep(ULONG timer_ticks)1663 UINT _tx_thread_sleep(ULONG timer_ticks)
1664 {
1665 	TraceEventHandle_t xTraceHandle;
1666 
1667 	if (xTraceEventBegin(PSF_EVENT_THREAD_SLEEP_BLOCKED, sizeof(UINT),
1668 		&xTraceHandle) == TRC_SUCCESS) {
1669 		xTraceEventAddUnsignedBaseType(xTraceHandle, timer_ticks);
1670 		xTraceEventEnd(xTraceHandle);
1671 	}
1672 
1673 	UINT ret = _tx_thread_sleep_orig(timer_ticks);
1674 
1675 	if (ret == TX_SUCCESS) {
1676 		if (xTraceEventBegin(PSF_EVENT_THREAD_SLEEP_SUCCESS, sizeof(UINT), &xTraceHandle) == TRC_SUCCESS) {
1677 			xTraceEventAddUnsignedBaseType(xTraceHandle, timer_ticks);
1678 			xTraceEventEnd(xTraceHandle);
1679 		}
1680 	}
1681 	else
1682 	{
1683 		if (xTraceEventBegin(PSF_EVENT_THREAD_SLEEP_FAILED, sizeof(UINT) + sizeof(ULONG),
1684 			&xTraceHandle) == TRC_SUCCESS) {
1685 			xTraceEventAddUnsignedBaseType(xTraceHandle, timer_ticks);
1686 			xTraceEventAdd32(xTraceHandle, ret);
1687 			xTraceEventEnd(xTraceHandle);
1688 		}
1689 	}
1690 
1691 	return ret;
1692 }
1693 
_tx_thread_stack_error_notify(VOID (* stack_error_handler)(TX_THREAD * thread_ptr))1694 UINT _tx_thread_stack_error_notify(VOID (*stack_error_handler)(TX_THREAD *thread_ptr))
1695 {
1696 	TraceEventHandle_t xTraceHandle;
1697 
1698 	UINT ret = _tx_thread_stack_error_notify_orig(stack_error_handler);
1699 
1700 	if (xTraceEventBegin(TX_TRACE_THREAD_STACK_ERROR_NOTIFY, sizeof(UINT),
1701 		&xTraceHandle) == TRC_SUCCESS) {
1702 		xTraceEventAdd32(xTraceHandle, ret);
1703 		xTraceEventEnd(xTraceHandle);
1704 	}
1705 
1706 	return ret;
1707 }
1708 
_txe_thread_suspend(TX_THREAD * thread_ptr)1709 UINT _txe_thread_suspend(TX_THREAD *thread_ptr)
1710 {
1711 	UINT ret = _txe_thread_suspend_orig(thread_ptr);
1712 
1713 	if (ret != TX_SUCCESS)
1714 	{
1715 		TraceEventHandle_t xTraceHandle;
1716 
1717 		if (xTraceEventBegin(PSF_EVENT_THREAD_SUSPEND_FAILED, sizeof(void*) + sizeof(UINT),
1718 			&xTraceHandle) == TRC_SUCCESS) {
1719 			xTraceEventAddPointer(xTraceHandle, (void*)thread_ptr);
1720 			xTraceEventAdd32(xTraceHandle, ret);
1721 			xTraceEventEnd(xTraceHandle);
1722 		}
1723 	}
1724 
1725 	return ret;
1726 }
1727 
_txe_thread_terminate(TX_THREAD * thread_ptr)1728 UINT _txe_thread_terminate(TX_THREAD *thread_ptr)
1729 {
1730 	UINT ret = _txe_thread_terminate_orig(thread_ptr);
1731 
1732 	if (ret != TX_SUCCESS)
1733 	{
1734 		TraceEventHandle_t xTraceHandle;
1735 
1736 		if (xTraceEventBegin(PSF_EVENT_THREAD_TERMINATE_FAILED, sizeof(void*) + sizeof(UINT),
1737 			&xTraceHandle) == TRC_SUCCESS) {
1738 			xTraceEventAddPointer(xTraceHandle, (void*)thread_ptr);
1739 			xTraceEventAdd32(xTraceHandle, ret);
1740 			xTraceEventEnd(xTraceHandle);
1741 		}
1742 	}
1743 
1744 	return ret;
1745 }
1746 
_tx_thread_time_slice(VOID)1747 VOID _tx_thread_time_slice(VOID)
1748 {
1749 	_tx_thread_time_slice_orig();
1750 }
1751 
_txe_thread_time_slice_change(TX_THREAD * thread_ptr,ULONG new_time_slice,ULONG * old_time_slice)1752 UINT _txe_thread_time_slice_change(TX_THREAD *thread_ptr, ULONG new_time_slice, ULONG *old_time_slice)
1753 {
1754 	UINT ret = _txe_thread_time_slice_change_orig(thread_ptr, new_time_slice, old_time_slice);
1755 
1756 	if (ret != TX_SUCCESS)
1757 	{
1758 		TraceEventHandle_t xTraceHandle;
1759 
1760 		if (xTraceEventBegin(PSF_EVENT_THREAD_TIME_SLICE_CHANGE_FAILED, sizeof(void*) + sizeof(ULONG) + sizeof(UINT),
1761 			&xTraceHandle) == TRC_SUCCESS) {
1762 			xTraceEventAddPointer(xTraceHandle, (void*)thread_ptr);
1763 			xTraceEventAddUnsignedBaseType(xTraceHandle, new_time_slice);
1764 			xTraceEventAdd32(xTraceHandle, ret);
1765 			xTraceEventEnd(xTraceHandle);
1766 		}
1767 	}
1768 
1769 	return ret;
1770 }
1771 
_txe_thread_wait_abort(TX_THREAD * thread_ptr)1772 UINT _txe_thread_wait_abort(TX_THREAD  *thread_ptr)
1773 {
1774 	UINT ret = _txe_thread_wait_abort_orig(thread_ptr);
1775 
1776 	if (ret != TX_SUCCESS)
1777 	{
1778 		TraceEventHandle_t xTraceHandle;
1779 
1780 		if (xTraceEventBegin(PSF_EVENT_THREAD_WAIT_ABORT_FAILED, sizeof(void*) + sizeof(UINT),
1781 			&xTraceHandle) == TRC_SUCCESS) {
1782 			xTraceEventAddPointer(xTraceHandle, (void*)thread_ptr);
1783 			xTraceEventAdd32(xTraceHandle, ret);
1784 			xTraceEventEnd(xTraceHandle);
1785 		}
1786 	}
1787 
1788 	return ret;
1789 }
1790 
_tx_time_get(VOID)1791 ULONG _tx_time_get(VOID)
1792 {
1793 	TraceEventHandle_t xTraceHandle;
1794 
1795 	ULONG ret = _tx_time_get_orig();
1796 
1797 	if (xTraceEventBegin(PSF_EVENT_TIME_GET_SUCCESS, sizeof(ULONG),
1798 		&xTraceHandle) == TRC_SUCCESS) {
1799 		xTraceEventAddUnsignedBaseType(xTraceHandle, ret);
1800 		xTraceEventEnd(xTraceHandle);
1801 	}
1802 
1803 	return ret;
1804 }
1805 
_tx_time_set(ULONG new_time)1806 VOID _tx_time_set(ULONG new_time)
1807 {
1808 	_tx_time_set_orig(new_time);
1809 }
1810 
_txe_timer_activate(TX_TIMER * timer_ptr)1811 UINT _txe_timer_activate(TX_TIMER *timer_ptr)
1812 {
1813 	UINT ret = _txe_timer_activate_orig(timer_ptr);
1814 
1815 	if (ret != TX_SUCCESS)
1816 	{
1817 		TraceEventHandle_t xTraceHandle;
1818 
1819 		if (xTraceEventBegin(PSF_EVENT_TIMER_ACTIVATE_FAILED, sizeof(void*) + sizeof(UINT),
1820 			&xTraceHandle) == TRC_SUCCESS) {
1821 			xTraceEventAddPointer(xTraceHandle, (void*)timer_ptr);
1822 			xTraceEventAdd32(xTraceHandle, ret);
1823 			xTraceEventEnd(xTraceHandle);
1824 		}
1825 	}
1826 
1827 	return ret;
1828 }
1829 
_txe_timer_change(TX_TIMER * timer_ptr,ULONG initial_ticks,ULONG reschedule_ticks)1830 UINT _txe_timer_change(TX_TIMER *timer_ptr, ULONG initial_ticks, ULONG reschedule_ticks)
1831 {
1832 	UINT ret = _txe_timer_change_orig(timer_ptr, initial_ticks, reschedule_ticks);
1833 
1834 	if (ret != TX_SUCCESS)
1835 	{
1836 		TraceEventHandle_t xTraceHandle;
1837 
1838 		if (xTraceEventBegin(PSF_EVENT_TIMER_CHANGE_FAILED, sizeof(void*) + sizeof(ULONG) + sizeof(ULONG) + sizeof(UINT),
1839 			&xTraceHandle) == TRC_SUCCESS) {
1840 			xTraceEventAddPointer(xTraceHandle, (void*)timer_ptr);
1841 			xTraceEventAddUnsignedBaseType(xTraceHandle, initial_ticks);
1842 			xTraceEventAddUnsignedBaseType(xTraceHandle, reschedule_ticks);
1843 			xTraceEventAdd32(xTraceHandle, ret);
1844 			xTraceEventEnd(xTraceHandle);
1845 		}
1846 	}
1847 
1848 	return ret;
1849 }
1850 
_txe_timer_create(TX_TIMER * timer_ptr,CHAR * name_ptr,VOID (* expiration_function)(ULONG id),ULONG expiration_input,ULONG initial_ticks,ULONG reschedule_ticks,UINT auto_activate,UINT timer_control_block_size)1851 UINT _txe_timer_create(TX_TIMER *timer_ptr, CHAR *name_ptr,
1852             VOID (*expiration_function)(ULONG id), ULONG expiration_input,
1853             ULONG initial_ticks, ULONG reschedule_ticks, UINT auto_activate, UINT timer_control_block_size)
1854 {
1855 	UINT ret = _txe_timer_create_orig(timer_ptr, name_ptr, expiration_function, expiration_input, initial_ticks,
1856 			reschedule_ticks, auto_activate, timer_control_block_size);
1857 
1858 	if (ret != TX_SUCCESS)
1859 	{
1860 		TraceEventHandle_t xTraceHandle;
1861 
1862 		if (xTraceEventBegin(PSF_EVENT_TIMER_CREATE_FAILED, sizeof(void*) + sizeof(ULONG) + sizeof(ULONG) + sizeof(ULONG) + sizeof(UINT),
1863 			&xTraceHandle) == TRC_SUCCESS) {
1864 			xTraceEventAddPointer(xTraceHandle, (void*)timer_ptr);
1865 			xTraceEventAddUnsignedBaseType(xTraceHandle, initial_ticks);
1866 			xTraceEventAddUnsignedBaseType(xTraceHandle, reschedule_ticks);
1867 			xTraceEventAddUnsignedBaseType(xTraceHandle, auto_activate);
1868 			xTraceEventAdd32(xTraceHandle, ret);
1869 			xTraceEventEnd(xTraceHandle);
1870 		}
1871 	}
1872 
1873 	return ret;
1874 }
1875 
_txe_timer_deactivate(TX_TIMER * timer_ptr)1876 UINT _txe_timer_deactivate(TX_TIMER *timer_ptr)
1877 {
1878 	UINT ret = _txe_timer_deactivate_orig(timer_ptr);
1879 
1880 	if (ret != TX_SUCCESS)
1881 	{
1882 		TraceEventHandle_t xTraceHandle;
1883 
1884 		if (xTraceEventBegin(PSF_EVENT_TIMER_DEACTIVATE_FAILED, sizeof(void*) + sizeof(UINT),
1885 			&xTraceHandle) == TRC_SUCCESS) {
1886 			xTraceEventAddPointer(xTraceHandle, (void*)timer_ptr);
1887 			xTraceEventAdd32(xTraceHandle, ret);
1888 			xTraceEventEnd(xTraceHandle);
1889 		}
1890 	}
1891 
1892 	return ret;
1893 }
1894 
_txe_timer_delete(TX_TIMER * timer_ptr)1895 UINT _txe_timer_delete(TX_TIMER *timer_ptr)
1896 {
1897 	UINT ret = _txe_timer_delete_orig(timer_ptr);
1898 
1899 	if (ret != TX_SUCCESS)
1900 	{
1901 		TraceEventHandle_t xTraceHandle;
1902 
1903 		if (xTraceEventBegin(PSF_EVENT_TIMER_DELETE_FAILED, sizeof(void*) + sizeof(UINT),
1904 			&xTraceHandle) == TRC_SUCCESS) {
1905 			xTraceEventAddPointer(xTraceHandle, (void*)timer_ptr);
1906 			xTraceEventAdd32(xTraceHandle, ret);
1907 			xTraceEventEnd(xTraceHandle);
1908 		}
1909 	}
1910 
1911 	return ret;
1912 }
1913 
_txe_timer_info_get(TX_TIMER * timer_ptr,CHAR ** name,UINT * active,ULONG * remaining_ticks,ULONG * reschedule_ticks,TX_TIMER ** next_timer)1914 UINT _txe_timer_info_get(TX_TIMER *timer_ptr, CHAR **name, UINT *active, ULONG *remaining_ticks, ULONG *reschedule_ticks, TX_TIMER **next_timer)
1915 {
1916 	UINT ret = _txe_timer_info_get_orig(timer_ptr, name, active, remaining_ticks, reschedule_ticks, next_timer);
1917 
1918 	if (ret != TX_SUCCESS)
1919 	{
1920 		TraceEventHandle_t xTraceHandle;
1921 
1922 		if (xTraceEventBegin(PSF_EVENT_TIMER_INFO_GET_FAILED, sizeof(void*) + sizeof(UINT),
1923 			&xTraceHandle) == TRC_SUCCESS) {
1924 			xTraceEventAddPointer(xTraceHandle, (void*)timer_ptr);
1925 			xTraceEventAdd32(xTraceHandle, ret);
1926 			xTraceEventEnd(xTraceHandle);
1927 		}
1928 	}
1929 
1930 	return ret;
1931 }
1932 
_tx_timer_performance_info_get(TX_TIMER * timer_ptr,ULONG * activates,ULONG * reactivates,ULONG * deactivates,ULONG * expirations,ULONG * expiration_adjusts)1933 UINT _tx_timer_performance_info_get(TX_TIMER *timer_ptr, ULONG *activates, ULONG *reactivates, ULONG *deactivates, ULONG *expirations, ULONG *expiration_adjusts)
1934 {
1935 	UINT ret = _tx_timer_performance_info_get_orig(timer_ptr, activates, reactivates, deactivates, expirations, expiration_adjusts);
1936 
1937 	if (ret != TX_SUCCESS)
1938 	{
1939 		TraceEventHandle_t xTraceHandle;
1940 
1941 		if (xTraceEventBegin(PSF_EVENT_TIMER_PERFORMANCE_INFO_GET_FAILED, sizeof(void*) + sizeof(UINT),
1942 			&xTraceHandle) == TRC_SUCCESS) {
1943 			xTraceEventAddPointer(xTraceHandle, (void*)timer_ptr);
1944 			xTraceEventAdd32(xTraceHandle, ret);
1945 			xTraceEventEnd(xTraceHandle);
1946 		}
1947 	}
1948 
1949 	return ret;
1950 }
1951 
xTraceISREnd(TraceBaseType_t uxIsTaskSwitchRequired)1952 traceResult xTraceISREnd(TraceBaseType_t uxIsTaskSwitchRequired)
1953 {
1954 	traceResult xResult;
1955 
1956 	xResult = xTraceISREnd_orig(uxIsTaskSwitchRequired);
1957 
1958 	/* Force a thread switch outcome result when exiting an ISR. Without this
1959 	 * we would get incorrect switching if the ISR exits to the thread that
1960 	 * it entered from.
1961 	 */
1962 	xTraceResetCurrentThread();
1963 
1964 	return xResult;
1965 }
1966 
TRACE_ALLOC_CRITICAL_SECTION()1967 static TRACE_ALLOC_CRITICAL_SECTION()
1968 
1969 traceResult xTraceEventBeginRawOffline(uint32_t uiSize, TraceEventHandle_t* pxEventHandle)
1970 {
1971 	traceResult xResult;
1972 
1973 	/* We must use a critical section here or there is a chance that an interrupt
1974 	 * could fire in the time between checking for a thread switch and the event
1975 	 * being sent.
1976 	 */
1977 	TRACE_ENTER_CRITICAL_SECTION();
1978 
1979 	/* Perform a thread switch check before each event to see if ThreadX has switched to a new
1980 	 * thread without informing us.
1981 	 */
1982 	xTraceCheckThreadSwitch();
1983 
1984 	xResult = xTraceEventBeginRawOffline_orig(uiSize, pxEventHandle);
1985 
1986 	if (xResult == TRC_FAIL) {
1987 		/* Exit wrapped critical section */
1988 		TRACE_EXIT_CRITICAL_SECTION();
1989 	}
1990 
1991 	return xResult;
1992 }
1993 
xTraceEventEndOffline(TraceEventHandle_t xEventHandle)1994 traceResult xTraceEventEndOffline(TraceEventHandle_t xEventHandle)
1995 {
1996 	traceResult xResult;
1997 
1998 	xResult = xTraceEventEndOffline_orig(xEventHandle);
1999 
2000 	/* Exit wrapped critical section */
2001 	TRACE_EXIT_CRITICAL_SECTION();
2002 
2003 	return xResult;
2004 }
2005