1 /*
2  * Copyright (c) 2018 Oticon A/S
3  *
4  * SPDX-License-Identifier: Apache-2.0
5  */
6 
7 #ifndef SUBSYS_DEBUG_TRACING_CTF_TOP_H
8 #define SUBSYS_DEBUG_TRACING_CTF_TOP_H
9 
10 #include <stddef.h>
11 #include <string.h>
12 #include <ctf_map.h>
13 #include <zephyr/tracing/tracing_format.h>
14 #include <zephyr/net/net_ip.h>
15 
16 /* Limit strings to 20 bytes to optimize bandwidth */
17 #define CTF_MAX_STRING_LEN 20
18 
19 /* Increase the string length to be able to store IPv4/6 address */
20 #if defined(CONFIG_NET_IPV6)
21 #define CTF_NET_MAX_STRING_LEN INET6_ADDRSTRLEN
22 #else
23 #define CTF_NET_MAX_STRING_LEN CTF_MAX_STRING_LEN
24 #endif
25 
26 /*
27  * Obtain a field's size at compile-time.
28  */
29 #define CTF_INTERNAL_FIELD_SIZE(x) + sizeof(x)
30 
31 /*
32  * Append a field to current event-packet.
33  */
34 #define CTF_INTERNAL_FIELD_APPEND(x)                                           \
35 	{                                                                      \
36 		memcpy(epacket_cursor, &(x), sizeof(x));                       \
37 		epacket_cursor += sizeof(x);                                   \
38 	}
39 
40 /*
41  * Gather fields to a contiguous event-packet, then atomically emit.
42  */
43 #define CTF_GATHER_FIELDS(...)                                                  \
44 	{                                                                       \
45 		uint8_t epacket[0 MAP(CTF_INTERNAL_FIELD_SIZE, ##__VA_ARGS__)]; \
46 		uint8_t *epacket_cursor = &epacket[0];                          \
47 										\
48 		MAP(CTF_INTERNAL_FIELD_APPEND, ##__VA_ARGS__)                   \
49 		tracing_format_raw_data(epacket, sizeof(epacket));              \
50 	}
51 
52 #ifdef CONFIG_TRACING_CTF_TIMESTAMP
53 #define CTF_EVENT(...)                                                         \
54 	{                                                                      \
55 		const uint32_t tstamp = k_cyc_to_ns_floor64(k_cycle_get_32()); \
56 									       \
57 		CTF_GATHER_FIELDS(tstamp, __VA_ARGS__)                         \
58 	}
59 #else
60 #define CTF_EVENT(...)                                                         \
61 	{                                                                      \
62 		CTF_GATHER_FIELDS(__VA_ARGS__)                                 \
63 	}
64 #endif
65 
66 /* Anonymous compound literal with 1 member. Legal since C99.
67  * This permits us to take the address of literals, like so:
68  *  &CTF_LITERAL(int, 1234)
69  *
70  * This may be required if a ctf_bottom layer uses memcpy.
71  *
72  * NOTE string literals already support address-of and sizeof,
73  * so string literals should not be wrapped with CTF_LITERAL.
74  */
75 #define CTF_LITERAL(type, value) ((type) { (type)(value) })
76 
77 typedef enum {
78 	CTF_EVENT_THREAD_SWITCHED_OUT = 0x10,
79 	CTF_EVENT_THREAD_SWITCHED_IN = 0x11,
80 	CTF_EVENT_THREAD_PRIORITY_SET = 0x12,
81 	CTF_EVENT_THREAD_CREATE = 0x13,
82 	CTF_EVENT_THREAD_ABORT = 0x14,
83 	CTF_EVENT_THREAD_SUSPEND = 0x15,
84 	CTF_EVENT_THREAD_RESUME = 0x16,
85 	CTF_EVENT_THREAD_READY = 0x17,
86 	CTF_EVENT_THREAD_PENDING = 0x18,
87 	CTF_EVENT_THREAD_INFO = 0x19,
88 	CTF_EVENT_THREAD_NAME_SET = 0x1A,
89 	CTF_EVENT_ISR_ENTER = 0x1B,
90 	CTF_EVENT_ISR_EXIT = 0x1C,
91 	CTF_EVENT_ISR_EXIT_TO_SCHEDULER = 0x1D,
92 	CTF_EVENT_IDLE = 0x1E,
93 	CTF_EVENT_ID_START_CALL = 0x1F,
94 	CTF_EVENT_ID_END_CALL = 0x20,
95 	CTF_EVENT_SEMAPHORE_INIT = 0x21,
96 	CTF_EVENT_SEMAPHORE_GIVE_ENTER = 0x22,
97 	CTF_EVENT_SEMAPHORE_GIVE_EXIT = 0x23,
98 	CTF_EVENT_SEMAPHORE_TAKE_ENTER = 0x24,
99 	CTF_EVENT_SEMAPHORE_TAKE_BLOCKING = 0x25,
100 	CTF_EVENT_SEMAPHORE_TAKE_EXIT = 0x26,
101 	CTF_EVENT_SEMAPHORE_RESET = 0x27,
102 	CTF_EVENT_MUTEX_INIT = 0x28,
103 	CTF_EVENT_MUTEX_LOCK_ENTER = 0x29,
104 	CTF_EVENT_MUTEX_LOCK_BLOCKING = 0x2A,
105 	CTF_EVENT_MUTEX_LOCK_EXIT = 0x2B,
106 	CTF_EVENT_MUTEX_UNLOCK_ENTER = 0x2C,
107 	CTF_EVENT_MUTEX_UNLOCK_EXIT = 0x2D,
108 	CTF_EVENT_TIMER_INIT = 0x2E,
109 	CTF_EVENT_TIMER_START = 0x2F,
110 	CTF_EVENT_TIMER_STOP = 0x30,
111 	CTF_EVENT_TIMER_STATUS_SYNC_ENTER = 0x31,
112 	CTF_EVENT_TIMER_STATUS_SYNC_BLOCKING = 0x32,
113 	CTF_EVENT_TIMER_STATUS_SYNC_EXIT = 0x33,
114 	CTF_EVENT_THREAD_USER_MODE_ENTER = 0x34,
115 	CTF_EVENT_THREAD_WAKEUP = 0x35,
116 	CTF_EVENT_SOCKET_INIT = 0x36,
117 	CTF_EVENT_SOCKET_CLOSE_ENTER = 0x37,
118 	CTF_EVENT_SOCKET_CLOSE_EXIT = 0x38,
119 	CTF_EVENT_SOCKET_SHUTDOWN_ENTER = 0x39,
120 	CTF_EVENT_SOCKET_SHUTDOWN_EXIT = 0x3A,
121 	CTF_EVENT_SOCKET_BIND_ENTER = 0x3B,
122 	CTF_EVENT_SOCKET_BIND_EXIT = 0x3C,
123 	CTF_EVENT_SOCKET_CONNECT_ENTER = 0x3D,
124 	CTF_EVENT_SOCKET_CONNECT_EXIT = 0x3E,
125 	CTF_EVENT_SOCKET_LISTEN_ENTER = 0x3F,
126 	CTF_EVENT_SOCKET_LISTEN_EXIT = 0x40,
127 	CTF_EVENT_SOCKET_ACCEPT_ENTER = 0x41,
128 	CTF_EVENT_SOCKET_ACCEPT_EXIT = 0x42,
129 	CTF_EVENT_SOCKET_SENDTO_ENTER = 0x43,
130 	CTF_EVENT_SOCKET_SENDTO_EXIT = 0x44,
131 	CTF_EVENT_SOCKET_SENDMSG_ENTER = 0x45,
132 	CTF_EVENT_SOCKET_SENDMSG_EXIT = 0x46,
133 	CTF_EVENT_SOCKET_RECVFROM_ENTER = 0x47,
134 	CTF_EVENT_SOCKET_RECVFROM_EXIT = 0x48,
135 	CTF_EVENT_SOCKET_RECVMSG_ENTER = 0x49,
136 	CTF_EVENT_SOCKET_RECVMSG_EXIT = 0x4A,
137 	CTF_EVENT_SOCKET_FCNTL_ENTER = 0x4B,
138 	CTF_EVENT_SOCKET_FCNTL_EXIT = 0x4C,
139 	CTF_EVENT_SOCKET_IOCTL_ENTER = 0x4D,
140 	CTF_EVENT_SOCKET_IOCTL_EXIT = 0x4E,
141 	CTF_EVENT_SOCKET_POLL_ENTER = 0x4F,
142 	CTF_EVENT_SOCKET_POLL_VALUE = 0x50,
143 	CTF_EVENT_SOCKET_POLL_EXIT = 0x51,
144 	CTF_EVENT_SOCKET_GETSOCKOPT_ENTER = 0x52,
145 	CTF_EVENT_SOCKET_GETSOCKOPT_EXIT = 0x53,
146 	CTF_EVENT_SOCKET_SETSOCKOPT_ENTER = 0x54,
147 	CTF_EVENT_SOCKET_SETSOCKOPT_EXIT = 0x55,
148 	CTF_EVENT_SOCKET_GETPEERNAME_ENTER = 0x56,
149 	CTF_EVENT_SOCKET_GETPEERNAME_EXIT = 0x57,
150 	CTF_EVENT_SOCKET_GETSOCKNAME_ENTER = 0x58,
151 	CTF_EVENT_SOCKET_GETSOCKNAME_EXIT = 0x59,
152 	CTF_EVENT_SOCKET_SOCKETPAIR_ENTER = 0x5A,
153 	CTF_EVENT_SOCKET_SOCKETPAIR_EXIT = 0x5B,
154 	CTF_EVENT_NET_RECV_DATA_ENTER = 0x5C,
155 	CTF_EVENT_NET_RECV_DATA_EXIT = 0x5D,
156 	CTF_EVENT_NET_SEND_DATA_ENTER = 0x5E,
157 	CTF_EVENT_NET_SEND_DATA_EXIT = 0x5F,
158 	CTF_EVENT_NET_RX_TIME = 0x60,
159 	CTF_EVENT_NET_TX_TIME = 0x61,
160 	CTF_EVENT_NAMED_EVENT = 0x62,
161 	CTF_EVENT_GPIO_PIN_CONFIGURE_INTERRUPT_ENTER = 0x63,
162 	CTF_EVENT_GPIO_PIN_CONFIGURE_INTERRUPT_EXIT = 0x64,
163 	CTF_EVENT_GPIO_PIN_CONFIGURE_ENTER = 0x65,
164 	CTF_EVENT_GPIO_PIN_CONFIGURE_EXIT = 0x66,
165 	CTF_EVENT_GPIO_PORT_GET_DIRECTION_ENTER = 0x67,
166 	CTF_EVENT_GPIO_PORT_GET_DIRECTION_EXIT = 0x68,
167 	CTF_EVENT_GPIO_PIN_GET_CONFIG_ENTER = 0x69,
168 	CTF_EVENT_GPIO_PIN_GET_CONFIG_EXIT = 0x6A,
169 	CTF_EVENT_GPIO_PORT_GET_RAW_ENTER = 0x6B,
170 	CTF_EVENT_GPIO_PORT_GET_RAW_EXIT = 0x6C,
171 	CTF_EVENT_GPIO_PORT_SET_MASKED_RAW_ENTER = 0x6D,
172 	CTF_EVENT_GPIO_PORT_SET_MASKED_RAW_EXIT = 0x6E,
173 	CTF_EVENT_GPIO_PORT_SET_BITS_RAW_ENTER = 0x6F,
174 	CTF_EVENT_GPIO_PORT_SET_BITS_RAW_EXIT = 0x70,
175 	CTF_EVENT_GPIO_PORT_CLEAR_BITS_RAW_ENTER = 0x71,
176 	CTF_EVENT_GPIO_PORT_CLEAR_BITS_RAW_EXIT = 0x72,
177 	CTF_EVENT_GPIO_PORT_TOGGLE_BITS_ENTER = 0x73,
178 	CTF_EVENT_GPIO_PORT_TOGGLE_BITS_EXIT = 0x74,
179 	CTF_EVENT_GPIO_INIT_CALLBACK_ENTER = 0x75,
180 	CTF_EVENT_GPIO_INIT_CALLBACK_EXIT = 0x76,
181 	CTF_EVENT_GPIO_ADD_CALLBACK_ENTER = 0x77,
182 	CTF_EVENT_GPIO_ADD_CALLBACK_EXIT = 0x78,
183 	CTF_EVENT_GPIO_REMOVE_CALLBACK_ENTER = 0x79,
184 	CTF_EVENT_GPIO_REMOVE_CALLBACK_EXIT = 0x7A,
185 	CTF_EVENT_GPIO_GET_PENDING_INT_ENTER = 0x7B,
186 	CTF_EVENT_GPIO_GET_PENDING_INT_EXIT = 0x7C,
187 	CTF_EVENT_GPIO_FIRE_CALLBACKS_ENTER = 0x7D,
188 	CTF_EVENT_GPIO_FIRE_CALLBACK = 0x7E,
189 } ctf_event_t;
190 
191 typedef struct {
192 	char buf[CTF_MAX_STRING_LEN];
193 } ctf_bounded_string_t;
194 
ctf_top_thread_switched_out(uint32_t thread_id,ctf_bounded_string_t name)195 static inline void ctf_top_thread_switched_out(uint32_t thread_id,
196 					       ctf_bounded_string_t name)
197 {
198 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_SWITCHED_OUT),
199 		  thread_id, name);
200 }
201 
ctf_top_thread_switched_in(uint32_t thread_id,ctf_bounded_string_t name)202 static inline void ctf_top_thread_switched_in(uint32_t thread_id,
203 					      ctf_bounded_string_t name)
204 {
205 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_SWITCHED_IN), thread_id,
206 		  name);
207 }
208 
ctf_top_thread_priority_set(uint32_t thread_id,int8_t prio,ctf_bounded_string_t name)209 static inline void ctf_top_thread_priority_set(uint32_t thread_id, int8_t prio,
210 					       ctf_bounded_string_t name)
211 {
212 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_PRIORITY_SET),
213 		  thread_id, name, prio);
214 }
215 
ctf_top_thread_create(uint32_t thread_id,int8_t prio,ctf_bounded_string_t name)216 static inline void ctf_top_thread_create(uint32_t thread_id, int8_t prio,
217 					 ctf_bounded_string_t name)
218 {
219 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_CREATE), thread_id,
220 		  name);
221 }
222 
ctf_top_thread_abort(uint32_t thread_id,ctf_bounded_string_t name)223 static inline void ctf_top_thread_abort(uint32_t thread_id,
224 					ctf_bounded_string_t name)
225 {
226 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_ABORT), thread_id,
227 		  name);
228 }
229 
ctf_top_thread_suspend(uint32_t thread_id,ctf_bounded_string_t name)230 static inline void ctf_top_thread_suspend(uint32_t thread_id,
231 					  ctf_bounded_string_t name)
232 {
233 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_SUSPEND), thread_id,
234 		  name);
235 }
236 
ctf_top_thread_resume(uint32_t thread_id,ctf_bounded_string_t name)237 static inline void ctf_top_thread_resume(uint32_t thread_id,
238 					 ctf_bounded_string_t name)
239 {
240 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_RESUME), thread_id,
241 		  name);
242 }
243 
ctf_top_thread_ready(uint32_t thread_id,ctf_bounded_string_t name)244 static inline void ctf_top_thread_ready(uint32_t thread_id,
245 					ctf_bounded_string_t name)
246 {
247 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_READY), thread_id,
248 		  name);
249 }
250 
ctf_top_thread_pend(uint32_t thread_id,ctf_bounded_string_t name)251 static inline void ctf_top_thread_pend(uint32_t thread_id,
252 				       ctf_bounded_string_t name)
253 {
254 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_PENDING), thread_id,
255 		  name);
256 }
257 
ctf_top_thread_info(uint32_t thread_id,ctf_bounded_string_t name,uint32_t stack_base,uint32_t stack_size)258 static inline void ctf_top_thread_info(uint32_t thread_id,
259 				       ctf_bounded_string_t name,
260 				       uint32_t stack_base, uint32_t stack_size)
261 {
262 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_INFO), thread_id, name,
263 		  stack_base, stack_size);
264 }
265 
ctf_top_thread_name_set(uint32_t thread_id,ctf_bounded_string_t name)266 static inline void ctf_top_thread_name_set(uint32_t thread_id,
267 					   ctf_bounded_string_t name)
268 {
269 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_NAME_SET), thread_id,
270 		  name);
271 }
272 
273 
ctf_top_thread_user_mode_enter(uint32_t thread_id,ctf_bounded_string_t name)274 static inline void ctf_top_thread_user_mode_enter(uint32_t thread_id, ctf_bounded_string_t name)
275 {
276 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_USER_MODE_ENTER),
277 		  thread_id, name);
278 }
279 
ctf_top_thread_wakeup(uint32_t thread_id,ctf_bounded_string_t name)280 static inline void ctf_top_thread_wakeup(uint32_t thread_id, ctf_bounded_string_t name)
281 {
282 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_THREAD_WAKEUP),
283 		  thread_id, name);
284 }
285 
ctf_top_isr_enter(void)286 static inline void ctf_top_isr_enter(void)
287 {
288 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_ISR_ENTER));
289 }
290 
ctf_top_isr_exit(void)291 static inline void ctf_top_isr_exit(void)
292 {
293 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_ISR_EXIT));
294 }
295 
ctf_top_isr_exit_to_scheduler(void)296 static inline void ctf_top_isr_exit_to_scheduler(void)
297 {
298 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_ISR_EXIT_TO_SCHEDULER));
299 }
300 
ctf_top_idle(void)301 static inline void ctf_top_idle(void)
302 {
303 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_IDLE));
304 }
305 
ctf_top_void(uint32_t id)306 static inline void ctf_top_void(uint32_t id)
307 {
308 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_ID_START_CALL), id);
309 }
310 
ctf_top_end_call(uint32_t id)311 static inline void ctf_top_end_call(uint32_t id)
312 {
313 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_ID_END_CALL), id);
314 }
315 
316 /* Semaphore */
ctf_top_semaphore_init(uint32_t sem_id,int32_t ret)317 static inline void ctf_top_semaphore_init(uint32_t sem_id,
318 					  int32_t ret)
319 {
320 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SEMAPHORE_INIT), sem_id, ret);
321 }
322 
ctf_top_semaphore_reset(uint32_t sem_id)323 static inline void ctf_top_semaphore_reset(uint32_t sem_id)
324 {
325 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SEMAPHORE_RESET), sem_id);
326 }
327 
ctf_top_semaphore_take_enter(uint32_t sem_id,uint32_t timeout)328 static inline void ctf_top_semaphore_take_enter(uint32_t sem_id,
329 						uint32_t timeout)
330 {
331 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SEMAPHORE_TAKE_ENTER), sem_id,
332 		  timeout);
333 }
334 
ctf_top_semaphore_take_blocking(uint32_t sem_id,uint32_t timeout)335 static inline void ctf_top_semaphore_take_blocking(uint32_t sem_id,
336 						   uint32_t timeout)
337 {
338 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SEMAPHORE_TAKE_BLOCKING),
339 		  sem_id, timeout);
340 }
341 
ctf_top_semaphore_take_exit(uint32_t sem_id,uint32_t timeout,int32_t ret)342 static inline void ctf_top_semaphore_take_exit(uint32_t sem_id,
343 					       uint32_t timeout, int32_t ret)
344 {
345 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SEMAPHORE_TAKE_EXIT), sem_id,
346 		  timeout, ret);
347 }
348 
ctf_top_semaphore_give_enter(uint32_t sem_id)349 static inline void ctf_top_semaphore_give_enter(uint32_t sem_id)
350 {
351 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SEMAPHORE_GIVE_ENTER), sem_id);
352 }
353 
ctf_top_semaphore_give_exit(uint32_t sem_id)354 static inline void ctf_top_semaphore_give_exit(uint32_t sem_id)
355 {
356 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SEMAPHORE_GIVE_EXIT), sem_id);
357 }
358 
359 /* Mutex */
ctf_top_mutex_init(uint32_t mutex_id,int32_t ret)360 static inline void ctf_top_mutex_init(uint32_t mutex_id, int32_t ret)
361 {
362 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_MUTEX_INIT), mutex_id, ret);
363 }
364 
ctf_top_mutex_lock_enter(uint32_t mutex_id,uint32_t timeout)365 static inline void ctf_top_mutex_lock_enter(uint32_t mutex_id, uint32_t timeout)
366 {
367 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_MUTEX_LOCK_ENTER), mutex_id,
368 		  timeout);
369 }
370 
ctf_top_mutex_lock_blocking(uint32_t mutex_id,uint32_t timeout)371 static inline void ctf_top_mutex_lock_blocking(uint32_t mutex_id,
372 					       uint32_t timeout)
373 {
374 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_MUTEX_LOCK_BLOCKING), mutex_id,
375 		  timeout);
376 }
377 
ctf_top_mutex_lock_exit(uint32_t mutex_id,uint32_t timeout,int32_t ret)378 static inline void ctf_top_mutex_lock_exit(uint32_t mutex_id, uint32_t timeout,
379 					   int32_t ret)
380 {
381 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_MUTEX_LOCK_EXIT), mutex_id,
382 		  timeout, ret);
383 }
384 
ctf_top_mutex_unlock_enter(uint32_t mutex_id)385 static inline void ctf_top_mutex_unlock_enter(uint32_t mutex_id)
386 {
387 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_MUTEX_UNLOCK_ENTER), mutex_id);
388 }
389 
ctf_top_mutex_unlock_exit(uint32_t mutex_id,int32_t ret)390 static inline void ctf_top_mutex_unlock_exit(uint32_t mutex_id, int32_t ret)
391 {
392 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_MUTEX_UNLOCK_EXIT), mutex_id);
393 }
394 
395 /* Timer */
ctf_top_timer_init(uint32_t timer)396 static inline void ctf_top_timer_init(uint32_t timer)
397 {
398 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_TIMER_INIT), timer);
399 }
400 
ctf_top_timer_start(uint32_t timer,uint32_t duration,uint32_t period)401 static inline void ctf_top_timer_start(uint32_t timer, uint32_t duration, uint32_t period)
402 {
403 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_TIMER_START), timer, duration, period);
404 }
405 
ctf_top_timer_stop(uint32_t timer)406 static inline void ctf_top_timer_stop(uint32_t timer)
407 {
408 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_TIMER_STOP), timer);
409 }
410 
ctf_top_timer_status_sync_enter(uint32_t timer)411 static inline void ctf_top_timer_status_sync_enter(uint32_t timer)
412 {
413 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_TIMER_STATUS_SYNC_ENTER), timer);
414 }
415 
ctf_top_timer_status_sync_blocking(uint32_t timer,uint32_t timeout)416 static inline void ctf_top_timer_status_sync_blocking(uint32_t timer, uint32_t timeout)
417 {
418 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_TIMER_STATUS_SYNC_BLOCKING), timer, timeout);
419 }
420 
ctf_top_timer_status_sync_exit(uint32_t timer,uint32_t result)421 static inline void ctf_top_timer_status_sync_exit(uint32_t timer, uint32_t result)
422 {
423 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_TIMER_STATUS_SYNC_EXIT), timer, result);
424 }
425 
426 /* Network socket */
427 typedef struct {
428 	char buf[CTF_NET_MAX_STRING_LEN];
429 } ctf_net_bounded_string_t;
430 
ctf_top_socket_init(int32_t sock,uint32_t family,uint32_t type,uint32_t proto)431 static inline void ctf_top_socket_init(int32_t sock, uint32_t family,
432 				       uint32_t type, uint32_t proto)
433 {
434 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_INIT), sock, family, type, proto);
435 }
436 
ctf_top_socket_close_enter(int32_t sock)437 static inline void ctf_top_socket_close_enter(int32_t sock)
438 {
439 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_CLOSE_ENTER), sock);
440 }
441 
ctf_top_socket_close_exit(int32_t sock,int32_t ret)442 static inline void ctf_top_socket_close_exit(int32_t sock, int32_t ret)
443 {
444 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_CLOSE_EXIT), sock, ret);
445 }
446 
ctf_top_socket_shutdown_enter(int32_t sock,int32_t how)447 static inline void ctf_top_socket_shutdown_enter(int32_t sock, int32_t how)
448 {
449 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_SHUTDOWN_ENTER), sock, how);
450 }
451 
ctf_top_socket_shutdown_exit(int32_t sock,int32_t ret)452 static inline void ctf_top_socket_shutdown_exit(int32_t sock, int32_t ret)
453 {
454 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_SHUTDOWN_EXIT), sock, ret);
455 }
456 
ctf_top_socket_bind_enter(int32_t sock,ctf_net_bounded_string_t addr,uint32_t addrlen,uint16_t port)457 static inline void ctf_top_socket_bind_enter(int32_t sock, ctf_net_bounded_string_t addr,
458 					     uint32_t addrlen, uint16_t port)
459 {
460 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_BIND_ENTER), sock, addr, addrlen, port);
461 }
462 
ctf_top_socket_bind_exit(int32_t sock,int32_t ret)463 static inline void ctf_top_socket_bind_exit(int32_t sock, int32_t ret)
464 {
465 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_BIND_EXIT), sock, ret);
466 }
467 
ctf_top_socket_connect_enter(int32_t sock,ctf_net_bounded_string_t addr,uint32_t addrlen)468 static inline void ctf_top_socket_connect_enter(int32_t sock,
469 						ctf_net_bounded_string_t addr,
470 						uint32_t addrlen)
471 {
472 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_CONNECT_ENTER), sock, addr, addrlen);
473 }
474 
ctf_top_socket_connect_exit(int32_t sock,int32_t ret)475 static inline void ctf_top_socket_connect_exit(int32_t sock, int32_t ret)
476 {
477 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_CONNECT_EXIT), sock, ret);
478 }
479 
ctf_top_socket_listen_enter(int32_t sock,uint32_t backlog)480 static inline void ctf_top_socket_listen_enter(int32_t sock, uint32_t backlog)
481 {
482 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_LISTEN_ENTER), sock, backlog);
483 }
484 
ctf_top_socket_listen_exit(int32_t sock,int32_t ret)485 static inline void ctf_top_socket_listen_exit(int32_t sock, int32_t ret)
486 {
487 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_LISTEN_EXIT), sock, ret);
488 }
489 
ctf_top_socket_accept_enter(int32_t sock)490 static inline void ctf_top_socket_accept_enter(int32_t sock)
491 {
492 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_ACCEPT_ENTER), sock);
493 }
494 
ctf_top_socket_accept_exit(int32_t sock,ctf_net_bounded_string_t addr,uint32_t addrlen,uint16_t port,int32_t ret)495 static inline void ctf_top_socket_accept_exit(int32_t sock, ctf_net_bounded_string_t addr,
496 					      uint32_t addrlen, uint16_t port, int32_t ret)
497 {
498 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_ACCEPT_EXIT), sock, addr, addrlen,
499 		  port, ret);
500 }
501 
ctf_top_socket_sendto_enter(int32_t sock,uint32_t len,uint32_t flags,ctf_net_bounded_string_t addr,uint32_t addrlen)502 static inline void ctf_top_socket_sendto_enter(int32_t sock, uint32_t len, uint32_t flags,
503 					       ctf_net_bounded_string_t addr, uint32_t addrlen)
504 {
505 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_SENDTO_ENTER), sock, len, flags,
506 		  addr, addrlen);
507 }
508 
ctf_top_socket_sendto_exit(int32_t sock,int32_t ret)509 static inline void ctf_top_socket_sendto_exit(int32_t sock, int32_t ret)
510 {
511 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_SENDTO_EXIT), sock, ret);
512 }
513 
ctf_top_socket_sendmsg_enter(int32_t sock,uint32_t flags,uint32_t msg,ctf_net_bounded_string_t addr,uint32_t len)514 static inline void ctf_top_socket_sendmsg_enter(int32_t sock, uint32_t flags, uint32_t msg,
515 						ctf_net_bounded_string_t addr, uint32_t len)
516 {
517 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_SENDMSG_ENTER), sock, flags, msg,
518 		  addr, len);
519 }
520 
ctf_top_socket_sendmsg_exit(int32_t sock,int32_t ret)521 static inline void ctf_top_socket_sendmsg_exit(int32_t sock, int32_t ret)
522 {
523 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_SENDMSG_EXIT), sock, ret);
524 }
525 
ctf_top_socket_recvfrom_enter(int32_t sock,uint32_t max_len,uint32_t flags,uint32_t addr,uint32_t addrlen)526 static inline void ctf_top_socket_recvfrom_enter(int32_t sock, uint32_t max_len, uint32_t flags,
527 						 uint32_t addr, uint32_t addrlen)
528 {
529 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_RECVFROM_ENTER), sock, max_len, flags,
530 		  addr, addrlen);
531 }
532 
ctf_top_socket_recvfrom_exit(int32_t sock,ctf_net_bounded_string_t addr,uint32_t addrlen,int32_t ret)533 static inline void ctf_top_socket_recvfrom_exit(int32_t sock, ctf_net_bounded_string_t addr,
534 						uint32_t addrlen, int32_t ret)
535 {
536 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_RECVFROM_EXIT), sock, addr, addrlen, ret);
537 }
538 
ctf_top_socket_recvmsg_enter(int32_t sock,uint32_t msg,uint32_t max_len,uint32_t flags)539 static inline void ctf_top_socket_recvmsg_enter(int32_t sock, uint32_t msg, uint32_t max_len,
540 						uint32_t flags)
541 {
542 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_RECVMSG_ENTER), sock, msg, max_len, flags);
543 }
544 
ctf_top_socket_recvmsg_exit(int32_t sock,uint32_t len,ctf_net_bounded_string_t addr,int32_t ret)545 static inline void ctf_top_socket_recvmsg_exit(int32_t sock, uint32_t len,
546 					       ctf_net_bounded_string_t addr, int32_t ret)
547 {
548 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_RECVMSG_EXIT), sock, len, addr, ret);
549 }
550 
ctf_top_socket_fcntl_enter(int32_t sock,uint32_t cmd,uint32_t flags)551 static inline void ctf_top_socket_fcntl_enter(int32_t sock, uint32_t cmd, uint32_t flags)
552 {
553 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_FCNTL_ENTER), sock, cmd, flags);
554 }
555 
ctf_top_socket_fcntl_exit(int32_t sock,int32_t ret)556 static inline void ctf_top_socket_fcntl_exit(int32_t sock, int32_t ret)
557 {
558 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_FCNTL_EXIT), sock, ret);
559 }
560 
ctf_top_socket_ioctl_enter(int32_t sock,uint32_t req)561 static inline void ctf_top_socket_ioctl_enter(int32_t sock, uint32_t req)
562 {
563 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_IOCTL_ENTER), sock, req);
564 }
565 
ctf_top_socket_ioctl_exit(int32_t sock,int32_t ret)566 static inline void ctf_top_socket_ioctl_exit(int32_t sock, int32_t ret)
567 {
568 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_IOCTL_EXIT), sock, ret);
569 }
570 
ctf_top_socket_poll_enter(uint32_t fds,uint32_t nfds,int32_t timeout)571 static inline void ctf_top_socket_poll_enter(uint32_t fds, uint32_t nfds, int32_t timeout)
572 {
573 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_POLL_ENTER), fds, nfds, timeout);
574 }
575 
ctf_top_socket_poll_value(int32_t fd,uint16_t flag)576 static inline void ctf_top_socket_poll_value(int32_t fd, uint16_t flag)
577 {
578 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_POLL_VALUE), fd, flag);
579 }
580 
ctf_top_socket_poll_exit(uint32_t fds,int nfds,int ret)581 static inline void ctf_top_socket_poll_exit(uint32_t fds, int nfds, int ret)
582 {
583 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_POLL_EXIT), fds, nfds, ret);
584 }
585 
ctf_top_socket_getsockopt_enter(int32_t sock,uint32_t level,uint32_t optname)586 static inline void ctf_top_socket_getsockopt_enter(int32_t sock, uint32_t level, uint32_t optname)
587 {
588 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_GETSOCKOPT_ENTER), sock, level, optname);
589 }
590 
ctf_top_socket_getsockopt_exit(int32_t sock,uint32_t level,uint32_t optname,uint32_t optval,uint32_t optlen,int32_t ret)591 static inline void ctf_top_socket_getsockopt_exit(int32_t sock, uint32_t level, uint32_t optname,
592 						  uint32_t optval, uint32_t optlen, int32_t ret)
593 {
594 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_GETSOCKOPT_EXIT),
595 		  sock, level, optname, optval, optlen, ret);
596 }
597 
ctf_top_socket_setsockopt_enter(int32_t sock,uint32_t level,uint32_t optname,uint32_t optval,uint32_t optlen)598 static inline void ctf_top_socket_setsockopt_enter(int32_t sock, uint32_t level, uint32_t optname,
599 						   uint32_t optval, uint32_t optlen)
600 {
601 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_SETSOCKOPT_ENTER), sock, level,
602 		  optname, optval, optlen);
603 }
604 
ctf_top_socket_setsockopt_exit(int32_t sock,int32_t ret)605 static inline void ctf_top_socket_setsockopt_exit(int32_t sock, int32_t ret)
606 {
607 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_SETSOCKOPT_EXIT), sock, ret);
608 }
609 
ctf_top_socket_getpeername_enter(int32_t sock)610 static inline void ctf_top_socket_getpeername_enter(int32_t sock)
611 {
612 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_GETPEERNAME_ENTER), sock);
613 }
614 
ctf_top_socket_getpeername_exit(int32_t sock,ctf_net_bounded_string_t addr,uint32_t addrlen,int32_t ret)615 static inline void ctf_top_socket_getpeername_exit(int32_t sock, ctf_net_bounded_string_t addr,
616 						   uint32_t addrlen, int32_t ret)
617 {
618 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_GETPEERNAME_EXIT),
619 		  sock, addr, addrlen, ret);
620 }
621 
ctf_top_socket_getsockname_enter(int32_t sock)622 static inline void ctf_top_socket_getsockname_enter(int32_t sock)
623 {
624 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_GETSOCKNAME_ENTER), sock);
625 }
626 
ctf_top_socket_getsockname_exit(int32_t sock,ctf_net_bounded_string_t addr,uint32_t addrlen,int32_t ret)627 static inline void ctf_top_socket_getsockname_exit(int32_t sock, ctf_net_bounded_string_t addr,
628 						   uint32_t addrlen, int32_t ret)
629 {
630 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_GETSOCKNAME_EXIT),
631 		  sock, addr, addrlen, ret);
632 }
633 
ctf_top_socket_socketpair_enter(uint32_t family,uint32_t type,uint32_t proto,uint32_t sv)634 static inline void ctf_top_socket_socketpair_enter(uint32_t family, uint32_t type,
635 						   uint32_t proto, uint32_t sv)
636 {
637 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_SOCKETPAIR_ENTER), family, type,
638 		  proto, sv);
639 }
640 
ctf_top_socket_socketpair_exit(int32_t sock_A,int32_t sock_B,int32_t ret)641 static inline void ctf_top_socket_socketpair_exit(int32_t sock_A, int32_t sock_B, int32_t ret)
642 {
643 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_SOCKET_SOCKETPAIR_EXIT), sock_A, sock_B, ret);
644 }
645 
ctf_top_net_recv_data_enter(int32_t if_index,uint32_t iface,uint32_t pkt,uint32_t len)646 static inline void ctf_top_net_recv_data_enter(int32_t if_index, uint32_t iface, uint32_t pkt,
647 					       uint32_t len)
648 {
649 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_NET_RECV_DATA_ENTER),
650 		  if_index, iface, pkt, len);
651 }
652 
ctf_top_net_recv_data_exit(int32_t if_index,uint32_t iface,uint32_t pkt,int32_t ret)653 static inline void ctf_top_net_recv_data_exit(int32_t if_index, uint32_t iface, uint32_t pkt,
654 					      int32_t ret)
655 {
656 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_NET_RECV_DATA_EXIT),
657 		  if_index, iface, pkt, ret);
658 }
659 
ctf_top_net_send_data_enter(int32_t if_index,uint32_t iface,uint32_t pkt,uint32_t len)660 static inline void ctf_top_net_send_data_enter(int32_t if_index, uint32_t iface, uint32_t pkt,
661 					       uint32_t len)
662 {
663 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_NET_SEND_DATA_ENTER),
664 		  if_index, iface, pkt, len);
665 }
666 
ctf_top_net_send_data_exit(int32_t if_index,uint32_t iface,uint32_t pkt,int32_t ret)667 static inline void ctf_top_net_send_data_exit(int32_t if_index, uint32_t iface, uint32_t pkt,
668 					      int32_t ret)
669 {
670 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_NET_SEND_DATA_EXIT),
671 		  if_index, iface, pkt, ret);
672 }
673 
ctf_top_net_rx_time(int32_t if_index,uint32_t iface,uint32_t pkt,uint32_t priority,uint32_t tc,uint32_t duration)674 static inline void ctf_top_net_rx_time(int32_t if_index, uint32_t iface, uint32_t pkt,
675 				       uint32_t priority, uint32_t tc, uint32_t duration)
676 {
677 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_NET_RX_TIME),
678 		  if_index, iface, pkt, priority, tc, duration);
679 }
680 
ctf_top_net_tx_time(int32_t if_index,uint32_t iface,uint32_t pkt,uint32_t priority,uint32_t tc,uint32_t duration)681 static inline void ctf_top_net_tx_time(int32_t if_index, uint32_t iface, uint32_t pkt,
682 				       uint32_t priority, uint32_t tc, uint32_t duration)
683 {
684 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_NET_TX_TIME),
685 		  if_index, iface, pkt, priority, tc, duration);
686 }
687 
ctf_named_event(ctf_bounded_string_t name,uint32_t arg0,uint32_t arg1)688 static inline void ctf_named_event(ctf_bounded_string_t name, uint32_t arg0,
689 				   uint32_t arg1)
690 {
691 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_NAMED_EVENT), name,
692 		  arg0, arg1);
693 }
694 
695 /* GPIO */
ctf_top_gpio_pin_interrupt_configure_enter(uint32_t port,uint32_t pin,uint32_t flags)696 static inline void ctf_top_gpio_pin_interrupt_configure_enter(uint32_t port, uint32_t pin,
697 							      uint32_t flags)
698 {
699 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_PIN_CONFIGURE_INTERRUPT_ENTER), port, pin,
700 		  flags);
701 }
702 
ctf_top_gpio_pin_interrupt_configure_exit(uint32_t port,uint32_t pin,int32_t ret)703 static inline void ctf_top_gpio_pin_interrupt_configure_exit(uint32_t port, uint32_t pin,
704 							     int32_t ret)
705 {
706 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_PIN_CONFIGURE_INTERRUPT_EXIT), port, pin,
707 		  ret);
708 }
709 
ctf_top_gpio_pin_configure_enter(uint32_t port,uint32_t pin,uint32_t flags)710 static inline void ctf_top_gpio_pin_configure_enter(uint32_t port, uint32_t pin, uint32_t flags)
711 {
712 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_PIN_CONFIGURE_ENTER), port, pin, flags);
713 }
714 
ctf_top_gpio_pin_configure_exit(uint32_t port,uint32_t pin,int32_t ret)715 static inline void ctf_top_gpio_pin_configure_exit(uint32_t port, uint32_t pin, int32_t ret)
716 {
717 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_PIN_CONFIGURE_EXIT), port, pin, ret);
718 }
719 
ctf_top_gpio_port_get_direction_enter(uint32_t port,uint32_t map,uint32_t inputs,uint32_t outputs)720 static inline void ctf_top_gpio_port_get_direction_enter(uint32_t port, uint32_t map,
721 							 uint32_t inputs, uint32_t outputs)
722 {
723 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_PORT_GET_DIRECTION_ENTER), port, map, inputs,
724 		  outputs);
725 }
726 
ctf_top_gpio_port_get_direction_exit(uint32_t port,int32_t ret)727 static inline void ctf_top_gpio_port_get_direction_exit(uint32_t port, int32_t ret)
728 {
729 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_PORT_GET_DIRECTION_EXIT), port, ret);
730 }
731 
ctf_top_gpio_pin_get_config_enter(uint32_t port,uint32_t pin,uint32_t flags)732 static inline void ctf_top_gpio_pin_get_config_enter(uint32_t port, uint32_t pin, uint32_t flags)
733 {
734 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_PIN_GET_CONFIG_ENTER), port, pin, flags);
735 }
736 
ctf_top_gpio_pin_get_config_exit(uint32_t port,uint32_t pin,int32_t ret)737 static inline void ctf_top_gpio_pin_get_config_exit(uint32_t port, uint32_t pin, int32_t ret)
738 {
739 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_PIN_GET_CONFIG_EXIT), port, pin, ret);
740 }
741 
ctf_top_gpio_port_get_raw_enter(uint32_t port,uint32_t value)742 static inline void ctf_top_gpio_port_get_raw_enter(uint32_t port, uint32_t value)
743 {
744 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_PORT_GET_RAW_ENTER), port, value);
745 }
746 
ctf_top_gpio_port_get_raw_exit(uint32_t port,int32_t ret)747 static inline void ctf_top_gpio_port_get_raw_exit(uint32_t port, int32_t ret)
748 {
749 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_PORT_GET_RAW_EXIT), port, ret);
750 }
751 
ctf_top_gpio_port_set_masked_raw_enter(uint32_t port,uint32_t mask,uint32_t value)752 static inline void ctf_top_gpio_port_set_masked_raw_enter(uint32_t port, uint32_t mask,
753 							  uint32_t value)
754 {
755 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_PORT_SET_MASKED_RAW_ENTER), port, mask,
756 		  value);
757 }
758 
ctf_top_gpio_port_set_masked_raw_exit(uint32_t port,int32_t ret)759 static inline void ctf_top_gpio_port_set_masked_raw_exit(uint32_t port, int32_t ret)
760 {
761 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_PORT_SET_MASKED_RAW_EXIT), port, ret);
762 }
763 
ctf_top_gpio_port_set_bits_raw_enter(uint32_t port,uint32_t pins)764 static inline void ctf_top_gpio_port_set_bits_raw_enter(uint32_t port, uint32_t pins)
765 {
766 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_PORT_SET_BITS_RAW_ENTER), port, pins);
767 }
768 
ctf_top_gpio_port_set_bits_raw_exit(uint32_t port,int32_t ret)769 static inline void ctf_top_gpio_port_set_bits_raw_exit(uint32_t port, int32_t ret)
770 {
771 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_PORT_SET_BITS_RAW_EXIT), port, ret);
772 }
773 
ctf_top_gpio_port_clear_bits_raw_enter(uint32_t port,uint32_t pins)774 static inline void ctf_top_gpio_port_clear_bits_raw_enter(uint32_t port, uint32_t pins)
775 {
776 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_PORT_CLEAR_BITS_RAW_ENTER), port, pins);
777 }
778 
ctf_top_gpio_port_clear_bits_raw_exit(uint32_t port,int32_t ret)779 static inline void ctf_top_gpio_port_clear_bits_raw_exit(uint32_t port, int32_t ret)
780 {
781 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_PORT_CLEAR_BITS_RAW_EXIT), port, ret);
782 }
783 
ctf_top_gpio_port_toggle_bits_enter(uint32_t port,uint32_t pins)784 static inline void ctf_top_gpio_port_toggle_bits_enter(uint32_t port, uint32_t pins)
785 {
786 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_PORT_TOGGLE_BITS_ENTER), port, pins);
787 }
788 
ctf_top_gpio_port_toggle_bits_exit(uint32_t port,int32_t ret)789 static inline void ctf_top_gpio_port_toggle_bits_exit(uint32_t port, int32_t ret)
790 {
791 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_PORT_TOGGLE_BITS_EXIT), port, ret);
792 }
793 
ctf_top_gpio_init_callback_enter(uint32_t callback,uint32_t handler,uint32_t pin_mask)794 static inline void ctf_top_gpio_init_callback_enter(uint32_t callback, uint32_t handler,
795 						    uint32_t pin_mask)
796 {
797 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_INIT_CALLBACK_ENTER), callback, handler,
798 		  pin_mask);
799 }
800 
ctf_top_gpio_init_callback_exit(uint32_t callback)801 static inline void ctf_top_gpio_init_callback_exit(uint32_t callback)
802 {
803 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_INIT_CALLBACK_EXIT), callback);
804 }
805 
ctf_top_gpio_add_callback_enter(uint32_t port,uint32_t callback)806 static inline void ctf_top_gpio_add_callback_enter(uint32_t port, uint32_t callback)
807 {
808 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_ADD_CALLBACK_ENTER), port, callback);
809 }
810 
ctf_top_gpio_add_callback_exit(uint32_t port,int32_t ret)811 static inline void ctf_top_gpio_add_callback_exit(uint32_t port, int32_t ret)
812 {
813 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_ADD_CALLBACK_EXIT), port, ret);
814 }
815 
ctf_top_gpio_remove_callback_enter(uint32_t port,uint32_t callback)816 static inline void ctf_top_gpio_remove_callback_enter(uint32_t port, uint32_t callback)
817 {
818 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_REMOVE_CALLBACK_ENTER), port, callback);
819 }
820 
ctf_top_gpio_remove_callback_exit(uint32_t port,int32_t ret)821 static inline void ctf_top_gpio_remove_callback_exit(uint32_t port, int32_t ret)
822 {
823 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_REMOVE_CALLBACK_EXIT), port, ret);
824 }
825 
ctf_top_gpio_get_pending_int_enter(uint32_t dev)826 static inline void ctf_top_gpio_get_pending_int_enter(uint32_t dev)
827 {
828 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_GET_PENDING_INT_ENTER), dev);
829 }
830 
ctf_top_gpio_get_pending_int_exit(uint32_t dev,int32_t ret)831 static inline void ctf_top_gpio_get_pending_int_exit(uint32_t dev, int32_t ret)
832 {
833 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_GET_PENDING_INT_EXIT), dev, ret);
834 }
835 
ctf_top_gpio_fire_callbacks_enter(uint32_t list,uint32_t port,uint32_t pins)836 static inline void ctf_top_gpio_fire_callbacks_enter(uint32_t list, uint32_t port, uint32_t pins)
837 {
838 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_FIRE_CALLBACKS_ENTER), list, port, pins);
839 }
840 
ctf_top_gpio_fire_callback(uint32_t port,uint32_t cb)841 static inline void ctf_top_gpio_fire_callback(uint32_t port, uint32_t cb)
842 {
843 	CTF_EVENT(CTF_LITERAL(uint8_t, CTF_EVENT_GPIO_FIRE_CALLBACK), port, cb);
844 }
845 
846 #endif /* SUBSYS_DEBUG_TRACING_CTF_TOP_H */
847