1 /*
2  * Copyright (c) 2018 Oticon A/S
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef _TRACE_CTF_H
8 #define _TRACE_CTF_H
9 
10 #include <zephyr/kernel.h>
11 #include <zephyr/kernel_structs.h>
12 #include <zephyr/init.h>
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 
19 #define sys_port_trace_k_thread_foreach_enter()
20 #define sys_port_trace_k_thread_foreach_exit()
21 #define sys_port_trace_k_thread_foreach_unlocked_enter()
22 #define sys_port_trace_k_thread_foreach_unlocked_exit()
23 
24 #define sys_port_trace_k_thread_create(new_thread)                             \
25 	sys_trace_k_thread_create(new_thread, stack_size, prio)
26 
27 #define sys_port_trace_k_thread_user_mode_enter()                              \
28 	sys_trace_k_thread_user_mode_enter()
29 
30 #define sys_port_trace_k_thread_heap_assign(thread, heap)
31 #define sys_port_trace_k_thread_join_enter(thread, timeout)
32 #define sys_port_trace_k_thread_join_blocking(thread, timeout)
33 #define sys_port_trace_k_thread_join_exit(thread, timeout, ret)
34 #define sys_port_trace_k_thread_sleep_enter(timeout)
35 #define sys_port_trace_k_thread_sleep_exit(timeout, ret)
36 #define sys_port_trace_k_thread_msleep_enter(ms)
37 #define sys_port_trace_k_thread_msleep_exit(ms, ret)
38 #define sys_port_trace_k_thread_usleep_enter(us)
39 #define sys_port_trace_k_thread_usleep_exit(us, ret)
40 #define sys_port_trace_k_thread_busy_wait_enter(usec_to_wait)
41 #define sys_port_trace_k_thread_busy_wait_exit(usec_to_wait)
42 #define sys_port_trace_k_thread_yield()
43 #define sys_port_trace_k_thread_wakeup(thread) sys_trace_k_thread_wakeup(thread)
44 #define sys_port_trace_k_thread_start(thread) sys_trace_k_thread_start(thread)
45 #define sys_port_trace_k_thread_abort(thread) sys_trace_k_thread_abort(thread)
46 #define sys_port_trace_k_thread_suspend_enter(thread)                          \
47 	sys_trace_k_thread_suspend(thread)
48 #define sys_port_trace_k_thread_suspend_exit(thread)
49 #define sys_port_trace_k_thread_resume_enter(thread)                           \
50 	sys_trace_k_thread_resume(thread)
51 
52 #define sys_port_trace_k_thread_sched_lock()
53 
54 #define sys_port_trace_k_thread_sched_unlock()
55 
56 #define sys_port_trace_k_thread_name_set(thread, ret)                          \
57 	sys_trace_k_thread_name_set(thread, ret)
58 
59 #define sys_port_trace_k_thread_switched_out() sys_trace_k_thread_switched_out()
60 
61 #define sys_port_trace_k_thread_switched_in() sys_trace_k_thread_switched_in()
62 
63 #define sys_port_trace_k_thread_info(thread) sys_trace_k_thread_info(thread)
64 
65 #define sys_port_trace_k_thread_sched_wakeup(thread)
66 #define sys_port_trace_k_thread_sched_abort(thread)
67 #define sys_port_trace_k_thread_sched_priority_set(thread, prio)
68 #define sys_port_trace_k_thread_sched_ready(thread)
69 
70 #define sys_port_trace_k_thread_sched_pend(thread)
71 
72 #define sys_port_trace_k_thread_sched_resume(thread)
73 
74 #define sys_port_trace_k_thread_sched_suspend(thread)
75 
76 #define sys_port_trace_k_work_init(work)
77 #define sys_port_trace_k_work_submit_to_queue_enter(queue, work)
78 #define sys_port_trace_k_work_submit_to_queue_exit(queue, work, ret)
79 #define sys_port_trace_k_work_submit_enter(work)
80 #define sys_port_trace_k_work_submit_exit(work, ret)
81 #define sys_port_trace_k_work_flush_enter(work)
82 #define sys_port_trace_k_work_flush_blocking(work, timeout)
83 #define sys_port_trace_k_work_flush_exit(work, ret)
84 #define sys_port_trace_k_work_cancel_enter(work)
85 #define sys_port_trace_k_work_cancel_exit(work, ret)
86 #define sys_port_trace_k_work_cancel_sync_enter(work, sync)
87 #define sys_port_trace_k_work_cancel_sync_blocking(work, sync)
88 #define sys_port_trace_k_work_cancel_sync_exit(work, sync, ret)
89 
90 #define sys_port_trace_k_work_queue_init(queue)
91 #define sys_port_trace_k_work_queue_start_enter(queue)
92 #define sys_port_trace_k_work_queue_start_exit(queue)
93 #define sys_port_trace_k_work_queue_stop_enter(queue, timeout)
94 #define sys_port_trace_k_work_queue_stop_blocking(queue, timeout)
95 #define sys_port_trace_k_work_queue_stop_exit(queue, timeout, ret)
96 #define sys_port_trace_k_work_queue_drain_enter(queue)
97 #define sys_port_trace_k_work_queue_drain_exit(queue, ret)
98 #define sys_port_trace_k_work_queue_unplug_enter(queue)
99 #define sys_port_trace_k_work_queue_unplug_exit(queue, ret)
100 
101 #define sys_port_trace_k_work_delayable_init(dwork)
102 #define sys_port_trace_k_work_schedule_for_queue_enter(queue, dwork, delay)
103 #define sys_port_trace_k_work_schedule_for_queue_exit(queue, dwork, delay,     \
104 						      ret)
105 #define sys_port_trace_k_work_schedule_enter(dwork, delay)
106 #define sys_port_trace_k_work_schedule_exit(dwork, delay, ret)
107 #define sys_port_trace_k_work_reschedule_for_queue_enter(queue, dwork, delay)
108 #define sys_port_trace_k_work_reschedule_for_queue_exit(queue, dwork, delay,   \
109 							ret)
110 #define sys_port_trace_k_work_reschedule_enter(dwork, delay)
111 #define sys_port_trace_k_work_reschedule_exit(dwork, delay, ret)
112 #define sys_port_trace_k_work_flush_delayable_enter(dwork, sync)
113 #define sys_port_trace_k_work_flush_delayable_exit(dwork, sync, ret)
114 #define sys_port_trace_k_work_cancel_delayable_enter(dwork)
115 #define sys_port_trace_k_work_cancel_delayable_exit(dwork, ret)
116 #define sys_port_trace_k_work_cancel_delayable_sync_enter(dwork, sync)
117 #define sys_port_trace_k_work_cancel_delayable_sync_exit(dwork, sync, ret)
118 
119 #define sys_port_trace_k_work_poll_init_enter(work)
120 #define sys_port_trace_k_work_poll_init_exit(work)
121 #define sys_port_trace_k_work_poll_submit_to_queue_enter(work_q, work,         \
122 							 timeout)
123 #define sys_port_trace_k_work_poll_submit_to_queue_blocking(work_q, work,      \
124 							    timeout)
125 #define sys_port_trace_k_work_poll_submit_to_queue_exit(work_q, work, timeout, \
126 							ret)
127 #define sys_port_trace_k_work_poll_submit_enter(work, timeout)
128 #define sys_port_trace_k_work_poll_submit_exit(work, timeout, ret)
129 #define sys_port_trace_k_work_poll_cancel_enter(work)
130 #define sys_port_trace_k_work_poll_cancel_exit(work, ret)
131 
132 #define sys_port_trace_k_poll_api_event_init(event)
133 #define sys_port_trace_k_poll_api_poll_enter(events)
134 #define sys_port_trace_k_poll_api_poll_exit(events, ret)
135 #define sys_port_trace_k_poll_api_signal_init(signal)
136 #define sys_port_trace_k_poll_api_signal_reset(signal)
137 #define sys_port_trace_k_poll_api_signal_check(signal)
138 #define sys_port_trace_k_poll_api_signal_raise(signal, ret)
139 
140 #define sys_port_trace_k_sem_init(sem, ret)                                    \
141 	sys_trace_k_sem_init(sem, ret)
142 
143 #define sys_port_trace_k_sem_give_enter(sem) sys_trace_k_sem_give_enter(sem)
144 #define sys_port_trace_k_sem_give_exit(sem) sys_trace_k_sem_give_exit(sem)
145 #define sys_port_trace_k_sem_take_enter(sem, timeout)                          \
146 	sys_trace_k_sem_take_enter(sem, timeout)
147 #define sys_port_trace_k_sem_take_blocking(sem, timeout)                       \
148 	sys_trace_k_sem_take_blocking(sem, timeout)
149 #define sys_port_trace_k_sem_take_exit(sem, timeout, ret)                      \
150 	sys_trace_k_sem_take_exit(sem, timeout, ret)
151 #define sys_port_trace_k_sem_reset(sem) sys_trace_k_sem_reset(sem)
152 
153 #define sys_port_trace_k_mutex_init(mutex, ret)                                \
154 	sys_trace_k_mutex_init(mutex, ret)
155 #define sys_port_trace_k_mutex_lock_enter(mutex, timeout)                      \
156 	sys_trace_k_mutex_lock_enter(mutex, timeout)
157 #define sys_port_trace_k_mutex_lock_blocking(mutex, timeout)                   \
158 	sys_trace_k_mutex_lock_blocking(mutex, timeout)
159 #define sys_port_trace_k_mutex_lock_exit(mutex, timeout, ret)                  \
160 	sys_trace_k_mutex_lock_exit(mutex, timeout, ret)
161 #define sys_port_trace_k_mutex_unlock_enter(mutex)                             \
162 	sys_trace_k_mutex_unlock_enter(mutex)
163 #define sys_port_trace_k_mutex_unlock_exit(mutex, ret)                         \
164 	sys_trace_k_mutex_unlock_exit(mutex, ret)
165 
166 /* Timer */
167 #define sys_port_trace_k_timer_init(timer)					\
168 	sys_trace_k_timer_init(timer)
169 #define sys_port_trace_k_timer_start(timer, duration, period)			\
170 	sys_trace_k_timer_start(timer, duration, period)
171 #define sys_port_trace_k_timer_stop(timer)					\
172 	sys_trace_k_timer_stop(timer)
173 #define sys_port_trace_k_timer_status_sync_enter(timer)				\
174 	sys_trace_k_timer_status_sync_enter(timer)
175 #define sys_port_trace_k_timer_status_sync_blocking(timer, timeout)		\
176 	sys_trace_k_timer_status_sync_blocking(timer, timeout)
177 #define sys_port_trace_k_timer_status_sync_exit(timer, result)			\
178 	sys_trace_k_timer_status_sync_exit(timer, result)
179 
180 #define sys_port_trace_k_condvar_init(condvar, ret)
181 #define sys_port_trace_k_condvar_signal_enter(condvar)
182 #define sys_port_trace_k_condvar_signal_blocking(condvar, timeout)
183 #define sys_port_trace_k_condvar_signal_exit(condvar, ret)
184 #define sys_port_trace_k_condvar_broadcast_enter(condvar)
185 #define sys_port_trace_k_condvar_broadcast_exit(condvar, ret)
186 #define sys_port_trace_k_condvar_wait_enter(condvar)
187 #define sys_port_trace_k_condvar_wait_exit(condvar, ret)
188 
189 #define sys_port_trace_k_queue_init(queue)
190 #define sys_port_trace_k_queue_cancel_wait(queue)
191 #define sys_port_trace_k_queue_queue_insert_enter(queue, alloc)
192 #define sys_port_trace_k_queue_queue_insert_blocking(queue, alloc, timeout)
193 #define sys_port_trace_k_queue_queue_insert_exit(queue, alloc, ret)
194 #define sys_port_trace_k_queue_append_enter(queue)
195 #define sys_port_trace_k_queue_append_exit(queue)
196 #define sys_port_trace_k_queue_alloc_append_enter(queue)
197 #define sys_port_trace_k_queue_alloc_append_exit(queue, ret)
198 #define sys_port_trace_k_queue_prepend_enter(queue)
199 #define sys_port_trace_k_queue_prepend_exit(queue)
200 #define sys_port_trace_k_queue_alloc_prepend_enter(queue)
201 #define sys_port_trace_k_queue_alloc_prepend_exit(queue, ret)
202 #define sys_port_trace_k_queue_insert_enter(queue)
203 #define sys_port_trace_k_queue_insert_blocking(queue, timeout)
204 #define sys_port_trace_k_queue_insert_exit(queue)
205 #define sys_port_trace_k_queue_append_list_enter(queue)
206 #define sys_port_trace_k_queue_append_list_exit(queue, ret)
207 #define sys_port_trace_k_queue_merge_slist_enter(queue)
208 #define sys_port_trace_k_queue_merge_slist_exit(queue, ret)
209 #define sys_port_trace_k_queue_get_enter(queue, timeout)
210 #define sys_port_trace_k_queue_get_blocking(queue, timeout)
211 #define sys_port_trace_k_queue_get_exit(queue, timeout, ret)
212 #define sys_port_trace_k_queue_remove_enter(queue)
213 #define sys_port_trace_k_queue_remove_exit(queue, ret)
214 #define sys_port_trace_k_queue_unique_append_enter(queue)
215 #define sys_port_trace_k_queue_unique_append_exit(queue, ret)
216 #define sys_port_trace_k_queue_peek_head(queue, ret)
217 #define sys_port_trace_k_queue_peek_tail(queue, ret)
218 
219 #define sys_port_trace_k_fifo_init_enter(fifo)
220 #define sys_port_trace_k_fifo_init_exit(fifo)
221 #define sys_port_trace_k_fifo_cancel_wait_enter(fifo)
222 #define sys_port_trace_k_fifo_cancel_wait_exit(fifo)
223 #define sys_port_trace_k_fifo_put_enter(fifo, data)
224 #define sys_port_trace_k_fifo_put_exit(fifo, data)
225 #define sys_port_trace_k_fifo_alloc_put_enter(fifo, data)
226 #define sys_port_trace_k_fifo_alloc_put_exit(fifo, data, ret)
227 #define sys_port_trace_k_fifo_put_list_enter(fifo, head, tail)
228 #define sys_port_trace_k_fifo_put_list_exit(fifo, head, tail)
229 #define sys_port_trace_k_fifo_put_slist_enter(fifo, list)
230 #define sys_port_trace_k_fifo_put_slist_exit(fifo, list)
231 #define sys_port_trace_k_fifo_get_enter(fifo, timeout)
232 #define sys_port_trace_k_fifo_get_exit(fifo, timeout, ret)
233 #define sys_port_trace_k_fifo_peek_head_enter(fifo)
234 #define sys_port_trace_k_fifo_peek_head_exit(fifo, ret)
235 #define sys_port_trace_k_fifo_peek_tail_enter(fifo)
236 #define sys_port_trace_k_fifo_peek_tail_exit(fifo, ret)
237 
238 #define sys_port_trace_k_lifo_init_enter(lifo)
239 #define sys_port_trace_k_lifo_init_exit(lifo)
240 #define sys_port_trace_k_lifo_put_enter(lifo, data)
241 #define sys_port_trace_k_lifo_put_exit(lifo, data)
242 #define sys_port_trace_k_lifo_alloc_put_enter(lifo, data)
243 #define sys_port_trace_k_lifo_alloc_put_exit(lifo, data, ret)
244 #define sys_port_trace_k_lifo_get_enter(lifo, timeout)
245 #define sys_port_trace_k_lifo_get_exit(lifo, timeout, ret)
246 
247 #define sys_port_trace_k_stack_init(stack)
248 #define sys_port_trace_k_stack_alloc_init_enter(stack)
249 #define sys_port_trace_k_stack_alloc_init_exit(stack, ret)
250 #define sys_port_trace_k_stack_cleanup_enter(stack)
251 #define sys_port_trace_k_stack_cleanup_exit(stack, ret)
252 #define sys_port_trace_k_stack_push_enter(stack)
253 #define sys_port_trace_k_stack_push_exit(stack, ret)
254 #define sys_port_trace_k_stack_pop_enter(stack, timeout)
255 #define sys_port_trace_k_stack_pop_blocking(stack, timeout)
256 #define sys_port_trace_k_stack_pop_exit(stack, timeout, ret)
257 
258 #define sys_port_trace_k_msgq_init(msgq)
259 #define sys_port_trace_k_msgq_alloc_init_enter(msgq)
260 #define sys_port_trace_k_msgq_alloc_init_exit(msgq, ret)
261 #define sys_port_trace_k_msgq_cleanup_enter(msgq)
262 #define sys_port_trace_k_msgq_cleanup_exit(msgq, ret)
263 #define sys_port_trace_k_msgq_put_enter(msgq, timeout)
264 #define sys_port_trace_k_msgq_put_blocking(msgq, timeout)
265 #define sys_port_trace_k_msgq_put_exit(msgq, timeout, ret)
266 #define sys_port_trace_k_msgq_get_enter(msgq, timeout)
267 #define sys_port_trace_k_msgq_get_blocking(msgq, timeout)
268 #define sys_port_trace_k_msgq_get_exit(msgq, timeout, ret)
269 #define sys_port_trace_k_msgq_peek(msgq, ret)
270 #define sys_port_trace_k_msgq_purge(msgq)
271 
272 #define sys_port_trace_k_mbox_init(mbox)
273 #define sys_port_trace_k_mbox_message_put_enter(mbox, timeout)
274 #define sys_port_trace_k_mbox_message_put_blocking(mbox, timeout)
275 #define sys_port_trace_k_mbox_message_put_exit(mbox, timeout, ret)
276 #define sys_port_trace_k_mbox_put_enter(mbox, timeout)
277 #define sys_port_trace_k_mbox_put_exit(mbox, timeout, ret)
278 #define sys_port_trace_k_mbox_async_put_enter(mbox, sem)
279 #define sys_port_trace_k_mbox_async_put_exit(mbox, sem)
280 #define sys_port_trace_k_mbox_get_enter(mbox, timeout)
281 #define sys_port_trace_k_mbox_get_blocking(mbox, timeout)
282 #define sys_port_trace_k_mbox_get_exit(mbox, timeout, ret)
283 #define sys_port_trace_k_mbox_data_get(rx_msg)
284 
285 #define sys_port_trace_k_pipe_init(pipe)
286 #define sys_port_trace_k_pipe_cleanup_enter(pipe)
287 #define sys_port_trace_k_pipe_cleanup_exit(pipe, ret)
288 #define sys_port_trace_k_pipe_alloc_init_enter(pipe)
289 #define sys_port_trace_k_pipe_alloc_init_exit(pipe, ret)
290 #define sys_port_trace_k_pipe_flush_enter(pipe)
291 #define sys_port_trace_k_pipe_flush_exit(pipe)
292 #define sys_port_trace_k_pipe_buffer_flush_enter(pipe)
293 #define sys_port_trace_k_pipe_buffer_flush_exit(pipe)
294 #define sys_port_trace_k_pipe_put_enter(pipe, timeout)
295 #define sys_port_trace_k_pipe_put_blocking(pipe, timeout)
296 #define sys_port_trace_k_pipe_put_exit(pipe, timeout, ret)
297 #define sys_port_trace_k_pipe_get_enter(pipe, timeout)
298 #define sys_port_trace_k_pipe_get_blocking(pipe, timeout)
299 #define sys_port_trace_k_pipe_get_exit(pipe, timeout, ret)
300 
301 #define sys_port_trace_k_heap_init(heap)
302 #define sys_port_trace_k_heap_aligned_alloc_enter(heap, timeout)
303 #define sys_port_trace_k_heap_aligned_alloc_blocking(heap, timeout)
304 #define sys_port_trace_k_heap_aligned_alloc_exit(heap, timeout, ret)
305 #define sys_port_trace_k_heap_alloc_enter(heap, timeout)
306 #define sys_port_trace_k_heap_alloc_exit(heap, timeout, ret)
307 #define sys_port_trace_k_heap_calloc_enter(heap, timeout)
308 #define sys_port_trace_k_heap_calloc_exit(heap, timeout, ret)
309 #define sys_port_trace_k_heap_free(heap)
310 #define sys_port_trace_k_heap_realloc_enter(h, ptr, bytes, timeout)
311 #define sys_port_trace_k_heap_realloc_exit(h, ptr, bytes, timeout, ret)
312 #define sys_port_trace_k_heap_sys_k_aligned_alloc_enter(heap)
313 #define sys_port_trace_k_heap_sys_k_aligned_alloc_exit(heap, ret)
314 #define sys_port_trace_k_heap_sys_k_malloc_enter(heap)
315 #define sys_port_trace_k_heap_sys_k_malloc_exit(heap, ret)
316 #define sys_port_trace_k_heap_sys_k_free_enter(heap, heap_ref)
317 #define sys_port_trace_k_heap_sys_k_free_exit(heap, heap_ref)
318 #define sys_port_trace_k_heap_sys_k_calloc_enter(heap)
319 #define sys_port_trace_k_heap_sys_k_calloc_exit(heap, ret)
320 #define sys_port_trace_k_heap_sys_k_realloc_enter(heap, ptr)
321 #define sys_port_trace_k_heap_sys_k_realloc_exit(heap, ptr, ret)
322 
323 #define sys_port_trace_k_mem_slab_init(slab, rc)
324 #define sys_port_trace_k_mem_slab_alloc_enter(slab, timeout)
325 #define sys_port_trace_k_mem_slab_alloc_blocking(slab, timeout)
326 #define sys_port_trace_k_mem_slab_alloc_exit(slab, timeout, ret)
327 #define sys_port_trace_k_mem_slab_free_enter(slab)
328 #define sys_port_trace_k_mem_slab_free_exit(slab)
329 
330 #define sys_port_trace_k_event_init(event)
331 #define sys_port_trace_k_event_post_enter(event, events, events_mask)
332 #define sys_port_trace_k_event_post_exit(event, events, events_mask)
333 #define sys_port_trace_k_event_wait_enter(event, events, options, timeout)
334 #define sys_port_trace_k_event_wait_blocking(event, events, options, timeout)
335 #define sys_port_trace_k_event_wait_exit(event, events, ret)
336 
337 #define sys_port_trace_k_thread_abort_exit(thread)
338 #define sys_port_trace_k_thread_abort_enter(thread)
339 #define sys_port_trace_k_thread_resume_exit(thread)
340 
341 
342 #define sys_port_trace_pm_system_suspend_enter(ticks)
343 #define sys_port_trace_pm_system_suspend_exit(ticks, state)
344 
345 #define sys_port_trace_pm_device_runtime_get_enter(dev)
346 #define sys_port_trace_pm_device_runtime_get_exit(dev, ret)
347 #define sys_port_trace_pm_device_runtime_put_enter(dev)
348 #define sys_port_trace_pm_device_runtime_put_exit(dev, ret)
349 #define sys_port_trace_pm_device_runtime_put_async_enter(dev, delay)
350 #define sys_port_trace_pm_device_runtime_put_async_exit(dev, delay, ret)
351 #define sys_port_trace_pm_device_runtime_enable_enter(dev)
352 #define sys_port_trace_pm_device_runtime_enable_exit(dev, ret)
353 #define sys_port_trace_pm_device_runtime_disable_enter(dev)
354 #define sys_port_trace_pm_device_runtime_disable_exit(dev, ret)
355 
356 #define sys_trace_sys_init_enter(...)
357 #define sys_trace_sys_init_exit(...)
358 
359 void sys_trace_idle(void);
360 void sys_trace_isr_enter(void);
361 void sys_trace_isr_exit(void);
362 
363 void sys_trace_k_thread_abort_exit(struct k_thread *thread);
364 void sys_trace_k_thread_abort_enter(struct k_thread *thread);
365 void sys_trace_k_thread_resume_exit(struct k_thread *thread);
366 void sys_trace_k_thread_sched_abort(struct k_thread *thread);
367 void sys_trace_k_thread_sched_ready(struct k_thread *thread);
368 
369 void sys_trace_k_thread_sched_resume(struct k_thread *thread);
370 void sys_trace_k_thread_sched_suspend(struct k_thread *thread);
371 
372 void sys_trace_k_thread_foreach_enter(k_thread_user_cb_t user_cb,
373 				      void *user_data);
374 void sys_trace_k_thread_foreach_exit(k_thread_user_cb_t user_cb,
375 				     void *user_data);
376 void sys_trace_k_thread_foreach_unlocked_enter(k_thread_user_cb_t user_cb,
377 					       void *user_data);
378 void sys_trace_k_thread_foreach_unlocked_exit(k_thread_user_cb_t user_cb,
379 					      void *user_data);
380 void sys_trace_k_thread_create(struct k_thread *new_thread, size_t stack_size,
381 			       int prio);
382 void sys_trace_k_thread_user_mode_enter(void);
383 void sys_trace_k_thread_heap_assign(struct k_thread *thread,
384 				    struct k_heap *heap);
385 void sys_trace_k_thread_join_blocking(struct k_thread *thread,
386 				      k_timeout_t timeout);
387 void sys_trace_k_thread_join_exit(struct k_thread *thread, k_timeout_t timeout,
388 				  int ret);
389 void sys_trace_k_thread_sleep_enter(k_timeout_t timeout);
390 void sys_trace_k_thread_sleep_exit(k_timeout_t timeout, int ret);
391 void sys_trace_k_thread_msleep_enter(int32_t ms);
392 void sys_trace_k_thread_msleep_exit(int32_t ms, int ret);
393 void sys_trace_k_thread_usleep_enter(int32_t us);
394 void sys_trace_k_thread_usleep_exit(int32_t us, int ret);
395 void sys_trace_k_thread_busy_wait_enter(uint32_t usec_to_wait);
396 void sys_trace_k_thread_busy_wait_exit(uint32_t usec_to_wait);
397 void sys_trace_k_thread_yield(void);
398 void sys_trace_k_thread_wakeup(struct k_thread *thread);
399 void sys_trace_k_thread_abort(struct k_thread *thread);
400 void sys_trace_k_thread_start(struct k_thread *thread);
401 void sys_trace_k_thread_priority_set(struct k_thread *thread);
402 void sys_trace_k_thread_suspend(struct k_thread *thread);
403 void sys_trace_k_thread_resume(struct k_thread *thread);
404 void sys_trace_k_thread_sched_lock(void);
405 void sys_trace_k_thread_sched_unlock(void);
406 void sys_trace_k_thread_name_set(struct k_thread *thread, int ret);
407 void sys_trace_k_thread_switched_out(void);
408 void sys_trace_k_thread_switched_in(void);
409 void sys_trace_k_thread_ready(struct k_thread *thread);
410 void sys_trace_k_thread_pend(struct k_thread *thread);
411 void sys_trace_k_thread_info(struct k_thread *thread);
412 
413 /* Semaphore */
414 
415 void sys_trace_k_sem_init(struct k_sem *sem, int ret);
416 void sys_trace_k_sem_give_enter(struct k_sem *sem);
417 
418 void sys_trace_k_sem_give_exit(struct k_sem *sem);
419 
420 void sys_trace_k_sem_take_enter(struct k_sem *sem, k_timeout_t timeout);
421 void sys_trace_k_sem_take_blocking(struct k_sem *sem, k_timeout_t timeout);
422 void sys_trace_k_sem_take_exit(struct k_sem *sem, k_timeout_t timeout, int ret);
423 void sys_trace_k_sem_reset(struct k_sem *sem);
424 
425 /* Mutex */
426 void sys_trace_k_mutex_init(struct k_mutex *mutex, int ret);
427 void sys_trace_k_mutex_lock_enter(struct k_mutex *mutex, k_timeout_t timeout);
428 void sys_trace_k_mutex_lock_blocking(struct k_mutex *mutex,
429 				     k_timeout_t timeout);
430 void sys_trace_k_mutex_lock_exit(struct k_mutex *mutex, k_timeout_t timeout,
431 				 int ret);
432 void sys_trace_k_mutex_unlock_enter(struct k_mutex *mutex);
433 void sys_trace_k_mutex_unlock_exit(struct k_mutex *mutex, int ret);
434 
435 /* Timer */
436 void sys_trace_k_timer_init(struct k_timer *timer);
437 
438 void sys_trace_k_timer_start(struct k_timer *timer, k_timeout_t duration,
439 			     k_timeout_t period);
440 void sys_trace_k_timer_stop(struct k_timer *timer);
441 void sys_trace_k_timer_status_sync_blocking(struct k_timer *timer, k_timeout_t timeout);
442 void sys_trace_k_timer_status_sync_enter(struct k_timer *timer);
443 void sys_trace_k_timer_status_sync_exit(struct k_timer *timer, uint32_t result);
444 
445 void sys_trace_k_event_init(struct k_event *event);
446 
447 
448 #define sys_port_trace_socket_init(sock, family, type, proto)	\
449 	sys_trace_socket_init(sock, family, type, proto)
450 #define sys_port_trace_socket_close_enter(sock) \
451 	sys_trace_socket_close_enter(sock)
452 #define sys_port_trace_socket_close_exit(sock, ret) \
453 	sys_trace_socket_close_exit(sock, ret)
454 #define sys_port_trace_socket_shutdown_enter(sock, how) \
455 	sys_trace_socket_shutdown_enter(sock, how)
456 #define sys_port_trace_socket_shutdown_exit(sock, ret) \
457 	sys_trace_socket_shutdown_exit(sock, ret)
458 #define sys_port_trace_socket_bind_enter(sock, addr, addrlen) \
459 	sys_trace_socket_bind_enter(sock, addr, addrlen)
460 #define sys_port_trace_socket_bind_exit(sock, ret) \
461 	sys_trace_socket_bind_exit(sock, ret)
462 #define sys_port_trace_socket_connect_enter(sock, addr, addrlen) \
463 	sys_trace_socket_connect_enter(sock, addr, addrlen)
464 #define sys_port_trace_socket_connect_exit(sock, ret) \
465 	sys_trace_socket_connect_exit(sock, ret)
466 #define sys_port_trace_socket_listen_enter(sock, backlog) \
467 	sys_trace_socket_listen_enter(sock, backlog)
468 #define sys_port_trace_socket_listen_exit(sock, ret) \
469 	sys_trace_socket_listen_exit(sock, ret)
470 #define sys_port_trace_socket_accept_enter(sock) \
471 	sys_trace_socket_accept_enter(sock)
472 #define sys_port_trace_socket_accept_exit(sock, addr, addrlen, ret) \
473 	sys_trace_socket_accept_exit(sock, addr, addrlen, ret)
474 #define sys_port_trace_socket_sendto_enter(sock, len, flags, dest_addr, addrlen) \
475 	sys_trace_socket_sendto_enter(sock, len, flags, dest_addr, addrlen)
476 #define sys_port_trace_socket_sendto_exit(sock, ret) \
477 	sys_trace_socket_sendto_exit(sock, ret)
478 #define sys_port_trace_socket_sendmsg_enter(sock, msg, flags) \
479 	sys_trace_socket_sendmsg_enter(sock, msg, flags)
480 #define sys_port_trace_socket_sendmsg_exit(sock, ret) \
481 	sys_trace_socket_sendmsg_exit(sock, ret)
482 #define sys_port_trace_socket_recvfrom_enter(sock, max_len, flags, addr, addrlen) \
483 	sys_trace_socket_recvfrom_enter(sock, max_len, flags, addr, addrlen)
484 #define sys_port_trace_socket_recvfrom_exit(sock, src_addr, addrlen, ret) \
485 	sys_trace_socket_recvfrom_exit(sock, src_addr, addrlen, ret)
486 #define sys_port_trace_socket_recvmsg_enter(sock, msg, flags) \
487 	sys_trace_socket_recvmsg_enter(sock, msg, flags)
488 #define sys_port_trace_socket_recvmsg_exit(sock, msg, ret) \
489 	sys_trace_socket_recvmsg_exit(sock, msg, ret)
490 #define sys_port_trace_socket_fcntl_enter(sock, cmd, flags) \
491 	sys_trace_socket_fcntl_enter(sock, cmd, flags)
492 #define sys_port_trace_socket_fcntl_exit(sock, ret) \
493 	sys_trace_socket_fcntl_exit(sock, ret)
494 #define sys_port_trace_socket_ioctl_enter(sock, req) \
495 	sys_trace_socket_ioctl_enter(sock, req)
496 #define sys_port_trace_socket_ioctl_exit(sock, ret) \
497 	sys_trace_socket_ioctl_exit(sock, ret)
498 #define sys_port_trace_socket_poll_enter(fds, nfds, timeout) \
499 	sys_trace_socket_poll_enter(fds, nfds, timeout)
500 #define sys_port_trace_socket_poll_exit(fds, nfds, ret) \
501 	sys_trace_socket_poll_exit(fds, nfds, ret)
502 #define sys_port_trace_socket_getsockopt_enter(sock, level, optname) \
503 	sys_trace_socket_getsockopt_enter(sock, level, optname)
504 #define sys_port_trace_socket_getsockopt_exit(sock, level, optname, optval, optlen, ret) \
505 	sys_trace_socket_getsockopt_exit(sock, level, optname, optval, optlen, ret)
506 #define sys_port_trace_socket_setsockopt_enter(sock, level, optname, optval, optlen) \
507 	sys_trace_socket_setsockopt_enter(sock, level, optname, optval, optlen)
508 #define sys_port_trace_socket_setsockopt_exit(sock, ret) \
509 	sys_trace_socket_setsockopt_exit(sock, ret)
510 #define sys_port_trace_socket_getpeername_enter(sock) \
511 	sys_trace_socket_getpeername_enter(sock)
512 #define sys_port_trace_socket_getpeername_exit(sock, addr, addrlen, ret) \
513 	sys_trace_socket_getpeername_exit(sock, addr, addrlen, ret)
514 #define sys_port_trace_socket_getsockname_enter(sock) \
515 	sys_trace_socket_getsockname_enter(sock)
516 #define sys_port_trace_socket_getsockname_exit(sock, addr, addrlen, ret) \
517 	sys_trace_socket_getsockname_exit(sock, addr, addrlen, ret)
518 #define sys_port_trace_socket_socketpair_enter(family, type, proto, sv)	\
519 	sys_trace_socket_socketpair_enter(family, type, proto, sv)
520 #define sys_port_trace_socket_socketpair_exit(sockA, sockB, ret) \
521 	sys_trace_socket_socketpair_exit(sockA, sockB, ret)
522 
523 /* Do not try to include network headers as it just leads to inclusion
524  * nightmare, just declare couple of structs that are needed.
525  */
526 struct sockaddr;
527 struct msghdr;
528 struct zvfs_pollfd;
529 
530 void sys_trace_socket_init(int sock, int family, int type, int proto);
531 void sys_trace_socket_close_enter(int sock);
532 void sys_trace_socket_close_exit(int sock, int ret);
533 void sys_trace_socket_shutdown_enter(int sock, int how);
534 void sys_trace_socket_shutdown_exit(int sock, int ret);
535 void sys_trace_socket_bind_enter(int sock, const struct sockaddr *addr, size_t addrlen);
536 void sys_trace_socket_bind_exit(int sock, int ret);
537 void sys_trace_socket_connect_enter(int sock, const struct sockaddr *addr, size_t addrlen);
538 void sys_trace_socket_connect_exit(int sock, int ret);
539 void sys_trace_socket_listen_enter(int sock, int backlog);
540 void sys_trace_socket_listen_exit(int sock, int ret);
541 void sys_trace_socket_accept_enter(int sock);
542 void sys_trace_socket_accept_exit(int sock, const struct sockaddr *addr, const size_t *addrlen,
543 				  int ret);
544 void sys_trace_socket_sendto_enter(int sock, int len, int flags, const struct sockaddr *dest_addr,
545 				   size_t addrlen);
546 void sys_trace_socket_sendto_exit(int sock, int ret);
547 void sys_trace_socket_sendmsg_enter(int sock, const struct msghdr *msg, int flags);
548 void sys_trace_socket_sendmsg_exit(int sock, int ret);
549 void sys_trace_socket_recvfrom_enter(int sock, int max_len, int flags, struct sockaddr *addr,
550 				     size_t *addrlen);
551 void sys_trace_socket_recvfrom_exit(int sock, const struct sockaddr *src_addr,
552 				    const size_t *addrlen, int ret);
553 void sys_trace_socket_recvmsg_enter(int sock, const struct msghdr *msg, int flags);
554 void sys_trace_socket_recvmsg_exit(int sock, const struct msghdr *msg, int ret);
555 void sys_trace_socket_fcntl_enter(int sock, int cmd, int flags);
556 void sys_trace_socket_fcntl_exit(int sock, int ret);
557 void sys_trace_socket_ioctl_enter(int sock, int req);
558 void sys_trace_socket_ioctl_exit(int sock, int ret);
559 void sys_trace_socket_poll_enter(const struct zvfs_pollfd *fds, int nfds, int timeout);
560 void sys_trace_socket_poll_exit(const struct zvfs_pollfd *fds, int nfds, int ret);
561 void sys_trace_socket_getsockopt_enter(int sock, int level, int optname);
562 void sys_trace_socket_getsockopt_exit(int sock, int level, int optname, void *optval,
563 				      size_t optlen, int ret);
564 void sys_trace_socket_setsockopt_enter(int sock, int level, int optname, const void *optval,
565 				       size_t optlen);
566 void sys_trace_socket_setsockopt_exit(int sock, int ret);
567 void sys_trace_socket_getpeername_enter(int sock);
568 void sys_trace_socket_getpeername_exit(int sock,  struct sockaddr *addr, const size_t *addrlen,
569 				       int ret);
570 void sys_trace_socket_getsockname_enter(int sock);
571 void sys_trace_socket_getsockname_exit(int sock, const struct sockaddr *addr, const size_t *addrlen,
572 				       int ret);
573 void sys_trace_socket_socketpair_enter(int family, int type, int proto, int *sv);
574 void sys_trace_socket_socketpair_exit(int sock_A, int sock_B, int ret);
575 
576 #define sys_port_trace_net_recv_data_enter(iface, pkt)          \
577 	sys_trace_net_recv_data_enter(iface, pkt)
578 #define sys_port_trace_net_recv_data_exit(iface, pkt, ret)	\
579 	sys_trace_net_recv_data_exit(iface, pkt, ret)
580 #define sys_port_trace_net_send_data_enter(pkt)			\
581 	sys_trace_net_send_data_enter(pkt)
582 #define sys_port_trace_net_send_data_exit(pkt, ret)		\
583 	sys_trace_net_send_data_exit(pkt, ret)
584 #define sys_port_trace_net_rx_time(pkt, end_time)		\
585 	sys_trace_net_rx_time(pkt, end_time)
586 #define sys_port_trace_net_tx_time(pkt, end_time)		\
587 	sys_trace_net_tx_time(pkt, end_time)
588 
589 struct net_if;
590 struct net_pkt;
591 
592 void sys_trace_net_recv_data_enter(struct net_if *iface, struct net_pkt *pkt);
593 void sys_trace_net_recv_data_exit(struct net_if *iface, struct net_pkt *pkt, int ret);
594 void sys_trace_net_send_data_enter(struct net_pkt *pkt);
595 void sys_trace_net_send_data_exit(struct net_pkt *pkt, int ret);
596 void sys_trace_net_rx_time(struct net_pkt *pkt, uint32_t end_time);
597 void sys_trace_net_tx_time(struct net_pkt *pkt, uint32_t end_time);
598 
599 void sys_trace_named_event(const char *name, uint32_t arg0, uint32_t arg1);
600 
601 /* GPIO */
602 struct gpio_callback;
603 typedef uint8_t gpio_pin_t;
604 typedef uint32_t gpio_port_pins_t;
605 typedef uint32_t gpio_flags_t;
606 typedef uint32_t gpio_port_value_t;
607 typedef void (*gpio_callback_handler_t)(const struct device *port, struct gpio_callback *cb,
608 					gpio_port_pins_t pins);
609 
610 void sys_trace_gpio_pin_interrupt_configure_enter(const struct device *port, gpio_pin_t pin,
611 						  gpio_flags_t flags);
612 void sys_trace_gpio_pin_interrupt_configure_exit(const struct device *port, gpio_pin_t pin,
613 						 int ret);
614 void sys_trace_gpio_pin_configure_enter(const struct device *port, gpio_pin_t pin,
615 					gpio_flags_t flags);
616 void sys_trace_gpio_pin_configure_exit(const struct device *port, gpio_pin_t pin, int ret);
617 void sys_trace_gpio_port_get_direction_enter(const struct device *port, gpio_port_pins_t map,
618 					     gpio_port_pins_t *inputs, gpio_port_pins_t *outputs);
619 void sys_trace_gpio_port_get_direction_exit(const struct device *port, int ret);
620 void sys_trace_gpio_pin_get_config_enter(const struct device *port, gpio_pin_t pin,
621 					 gpio_flags_t flags);
622 void sys_trace_gpio_pin_get_config_exit(const struct device *port, gpio_pin_t pin, int ret);
623 void sys_trace_gpio_port_get_raw_enter(const struct device *port, gpio_port_value_t *value);
624 void sys_trace_gpio_port_get_raw_exit(const struct device *port, int ret);
625 void sys_trace_gpio_port_set_masked_raw_enter(const struct device *port, gpio_port_pins_t mask,
626 					      gpio_port_value_t value);
627 void sys_trace_gpio_port_set_masked_raw_exit(const struct device *port, int ret);
628 void sys_trace_gpio_port_set_bits_raw_enter(const struct device *port, gpio_port_pins_t pins);
629 void sys_trace_gpio_port_set_bits_raw_exit(const struct device *port, int ret);
630 void sys_trace_gpio_port_clear_bits_raw_enter(const struct device *port, gpio_port_pins_t pins);
631 void sys_trace_gpio_port_clear_bits_raw_exit(const struct device *port, int ret);
632 void sys_trace_gpio_port_toggle_bits_enter(const struct device *port, gpio_port_pins_t pins);
633 void sys_trace_gpio_port_toggle_bits_exit(const struct device *port, int ret);
634 void sys_trace_gpio_init_callback_enter(struct gpio_callback *callback,
635 					gpio_callback_handler_t handler, gpio_port_pins_t pin_mask);
636 void sys_trace_gpio_init_callback_exit(struct gpio_callback *callback);
637 void sys_trace_gpio_add_callback_enter(const struct device *port, struct gpio_callback *callback);
638 void sys_trace_gpio_add_callback_exit(const struct device *port, int ret);
639 void sys_trace_gpio_remove_callback_enter(const struct device *port,
640 					  struct gpio_callback *callback);
641 void sys_trace_gpio_remove_callback_exit(const struct device *port, int ret);
642 void sys_trace_gpio_get_pending_int_enter(const struct device *dev);
643 void sys_trace_gpio_get_pending_int_exit(const struct device *dev, int ret);
644 void sys_trace_gpio_fire_callbacks_enter(sys_slist_t *list, const struct device *port,
645 					 gpio_port_pins_t pins);
646 void sys_trace_gpio_fire_callback(const struct device *port, struct gpio_callback *callback);
647 
648 #define sys_port_trace_gpio_pin_interrupt_configure_enter(port, pin, flags)                        \
649 	sys_trace_gpio_pin_interrupt_configure_enter(port, pin, flags)
650 #define sys_port_trace_gpio_pin_interrupt_configure_exit(port, pin, ret)                           \
651 	sys_trace_gpio_pin_interrupt_configure_exit(port, pin, ret)
652 #define sys_port_trace_gpio_pin_configure_enter(port, pin, flags)                                  \
653 	sys_trace_gpio_pin_configure_enter(port, pin, flags)
654 #define sys_port_trace_gpio_pin_configure_exit(port, pin, ret)                                     \
655 	sys_trace_gpio_pin_configure_exit(port, pin, ret)
656 #define sys_port_trace_gpio_port_get_direction_enter(port, map, inputs, outputs)                   \
657 	sys_trace_gpio_port_get_direction_enter(port, map, inputs, outputs)
658 #define sys_port_trace_gpio_port_get_direction_exit(port, ret)                                     \
659 	sys_trace_gpio_port_get_direction_exit(port, ret)
660 #define sys_port_trace_gpio_pin_get_config_enter(port, pin, flags)                                 \
661 	sys_trace_gpio_pin_get_config_enter(port, pin, flags)
662 #define sys_port_trace_gpio_pin_get_config_exit(port, pin, ret)                                    \
663 	sys_trace_gpio_pin_get_config_exit(port, pin, ret)
664 #define sys_port_trace_gpio_port_get_raw_enter(port, value)                                        \
665 	sys_trace_gpio_port_get_raw_enter(port, value)
666 #define sys_port_trace_gpio_port_get_raw_exit(port, ret) sys_trace_gpio_port_get_raw_exit(port, ret)
667 #define sys_port_trace_gpio_port_set_masked_raw_enter(port, mask, value)                           \
668 	sys_trace_gpio_port_set_masked_raw_enter(port, mask, value)
669 #define sys_port_trace_gpio_port_set_masked_raw_exit(port, ret)                                    \
670 	sys_trace_gpio_port_set_masked_raw_exit(port, ret)
671 #define sys_port_trace_gpio_port_set_bits_raw_enter(port, pins)                                    \
672 	sys_trace_gpio_port_set_bits_raw_enter(port, pins)
673 #define sys_port_trace_gpio_port_set_bits_raw_exit(port, ret)                                      \
674 	sys_trace_gpio_port_set_bits_raw_exit(port, ret)
675 #define sys_port_trace_gpio_port_clear_bits_raw_enter(port, pins)                                  \
676 	sys_trace_gpio_port_clear_bits_raw_enter(port, pins)
677 #define sys_port_trace_gpio_port_clear_bits_raw_exit(port, ret)                                    \
678 	sys_trace_gpio_port_clear_bits_raw_exit(port, ret)
679 #define sys_port_trace_gpio_port_toggle_bits_enter(port, pins)                                     \
680 	sys_trace_gpio_port_toggle_bits_enter(port, pins)
681 #define sys_port_trace_gpio_port_toggle_bits_exit(port, ret)                                       \
682 	sys_trace_gpio_port_toggle_bits_exit(port, ret)
683 #define sys_port_trace_gpio_init_callback_enter(callback, handler, pin_mask)                       \
684 	sys_trace_gpio_init_callback_enter(callback, handler, pin_mask)
685 #define sys_port_trace_gpio_init_callback_exit(callback) sys_trace_gpio_init_callback_exit(callback)
686 #define sys_port_trace_gpio_add_callback_enter(port, callback)                                     \
687 	sys_trace_gpio_add_callback_enter(port, callback)
688 #define sys_port_trace_gpio_add_callback_exit(port, ret) sys_trace_gpio_add_callback_exit(port, ret)
689 #define sys_port_trace_gpio_remove_callback_enter(port, callback)                                  \
690 	sys_trace_gpio_remove_callback_enter(port, callback)
691 #define sys_port_trace_gpio_remove_callback_exit(port, ret)                                        \
692 	sys_trace_gpio_remove_callback_exit(port, ret)
693 #define sys_port_trace_gpio_get_pending_int_enter(dev) sys_trace_gpio_get_pending_int_enter(dev)
694 #define sys_port_trace_gpio_get_pending_int_exit(dev, ret)                                         \
695 	sys_trace_gpio_get_pending_int_exit(dev, ret)
696 #define sys_port_trace_gpio_fire_callbacks_enter(list, port, pins)                                 \
697 	sys_trace_gpio_fire_callbacks_enter(list, port, pins)
698 #define sys_port_trace_gpio_fire_callback(port, cb) sys_trace_gpio_fire_callback(port, cb)
699 
700 #ifdef __cplusplus
701 }
702 #endif
703 
704 #endif /* _TRACE_CTF_H */
705