1 /*
2  * Copyright (c) 2020 Lexmark International, Inc.
3  * Copyright (c) 2022 Qualcomm Innovation Center, Inc.
4  *
5  * SPDX-License-Identifier: Apache-2.0
6  */
7 
8 #include <tracing_user.h>
9 #include <zephyr/kernel.h>
10 #include <zephyr/init.h>
11 
sys_trace_thread_create_user(struct k_thread * thread)12 void __weak sys_trace_thread_create_user(struct k_thread *thread) {}
sys_trace_thread_abort_user(struct k_thread * thread)13 void __weak sys_trace_thread_abort_user(struct k_thread *thread) {}
sys_trace_thread_suspend_user(struct k_thread * thread)14 void __weak sys_trace_thread_suspend_user(struct k_thread *thread) {}
sys_trace_thread_resume_user(struct k_thread * thread)15 void __weak sys_trace_thread_resume_user(struct k_thread *thread) {}
sys_trace_thread_name_set_user(struct k_thread * thread)16 void __weak sys_trace_thread_name_set_user(struct k_thread *thread) {}
sys_trace_thread_switched_in_user(void)17 void __weak sys_trace_thread_switched_in_user(void) {}
sys_trace_thread_switched_out_user(void)18 void __weak sys_trace_thread_switched_out_user(void) {}
sys_trace_thread_info_user(struct k_thread * thread)19 void __weak sys_trace_thread_info_user(struct k_thread *thread) {}
sys_trace_thread_sched_ready_user(struct k_thread * thread)20 void __weak sys_trace_thread_sched_ready_user(struct k_thread *thread) {}
sys_trace_thread_pend_user(struct k_thread * thread)21 void __weak sys_trace_thread_pend_user(struct k_thread *thread) {}
sys_trace_thread_priority_set_user(struct k_thread * thread,int prio)22 void __weak sys_trace_thread_priority_set_user(struct k_thread *thread, int prio) {}
sys_trace_isr_enter_user(void)23 void __weak sys_trace_isr_enter_user(void) {}
sys_trace_isr_exit_user(void)24 void __weak sys_trace_isr_exit_user(void) {}
sys_trace_idle_user(void)25 void __weak sys_trace_idle_user(void) {}
sys_trace_sys_init_enter_user(const struct init_entry * entry,int level)26 void __weak sys_trace_sys_init_enter_user(const struct init_entry *entry, int level) {}
sys_trace_sys_init_exit_user(const struct init_entry * entry,int level,int result)27 void __weak sys_trace_sys_init_exit_user(const struct init_entry *entry, int level, int result) {}
sys_trace_gpio_pin_interrupt_configure_enter_user(const struct device * port,gpio_pin_t pin,gpio_flags_t flags)28 void __weak sys_trace_gpio_pin_interrupt_configure_enter_user(const struct device *port,
29 							      gpio_pin_t pin, gpio_flags_t flags) {}
sys_trace_gpio_pin_interrupt_configure_exit_user(const struct device * port,gpio_pin_t pin,int ret)30 void __weak sys_trace_gpio_pin_interrupt_configure_exit_user(const struct device *port,
31 							     gpio_pin_t pin, int ret) {}
sys_trace_gpio_pin_configure_enter_user(const struct device * port,gpio_pin_t pin,gpio_flags_t flags)32 void __weak sys_trace_gpio_pin_configure_enter_user(const struct device *port, gpio_pin_t pin,
33 						    gpio_flags_t flags) {}
sys_trace_gpio_pin_configure_exit_user(const struct device * port,gpio_pin_t pin,int ret)34 void __weak sys_trace_gpio_pin_configure_exit_user(const struct device *port, gpio_pin_t pin,
35 						   int ret) {}
sys_trace_gpio_port_get_direction_enter_user(const struct device * port,gpio_port_pins_t map,gpio_port_pins_t inputs,gpio_port_pins_t outputs)36 void __weak sys_trace_gpio_port_get_direction_enter_user(const struct device *port,
37 							 gpio_port_pins_t map,
38 							 gpio_port_pins_t inputs,
39 							 gpio_port_pins_t outputs) {}
sys_trace_gpio_port_get_direction_exit_user(const struct device * port,int ret)40 void __weak sys_trace_gpio_port_get_direction_exit_user(const struct device *port, int ret) {}
sys_trace_gpio_pin_get_config_enter_user(const struct device * port,gpio_pin_t pin,int ret)41 void __weak sys_trace_gpio_pin_get_config_enter_user(const struct device *port, gpio_pin_t pin,
42 						     int ret) {}
sys_trace_gpio_pin_get_config_exit_user(const struct device * port,gpio_pin_t pin,int ret)43 void __weak sys_trace_gpio_pin_get_config_exit_user(const struct device *port, gpio_pin_t pin,
44 						    int ret) {}
sys_trace_gpio_port_get_raw_enter_user(const struct device * port,gpio_port_value_t * value)45 void __weak sys_trace_gpio_port_get_raw_enter_user(const struct device *port,
46 						   gpio_port_value_t *value) {}
sys_trace_gpio_port_get_raw_exit_user(const struct device * port,int ret)47 void __weak sys_trace_gpio_port_get_raw_exit_user(const struct device *port, int ret) {}
sys_trace_gpio_port_set_masked_raw_enter_user(const struct device * port,gpio_port_pins_t mask,gpio_port_value_t value)48 void __weak sys_trace_gpio_port_set_masked_raw_enter_user(const struct device *port,
49 							  gpio_port_pins_t mask,
50 							  gpio_port_value_t value) {}
sys_trace_gpio_port_set_masked_raw_exit_user(const struct device * port,int ret)51 void __weak sys_trace_gpio_port_set_masked_raw_exit_user(const struct device *port, int ret) {}
sys_trace_gpio_port_set_bits_raw_enter_user(const struct device * port,gpio_port_pins_t pins)52 void __weak sys_trace_gpio_port_set_bits_raw_enter_user(const struct device *port,
53 							gpio_port_pins_t pins) {}
sys_trace_gpio_port_set_bits_raw_exit_user(const struct device * port,int ret)54 void __weak sys_trace_gpio_port_set_bits_raw_exit_user(const struct device *port, int ret) {}
sys_trace_gpio_port_clear_bits_raw_enter_user(const struct device * port,gpio_port_pins_t pins)55 void __weak sys_trace_gpio_port_clear_bits_raw_enter_user(const struct device *port,
56 							  gpio_port_pins_t pins) {}
sys_trace_gpio_port_clear_bits_raw_exit_user(const struct device * port,int ret)57 void __weak sys_trace_gpio_port_clear_bits_raw_exit_user(const struct device *port, int ret) {}
sys_trace_gpio_port_toggle_bits_enter_user(const struct device * port,gpio_port_pins_t pins)58 void __weak sys_trace_gpio_port_toggle_bits_enter_user(const struct device *port,
59 						       gpio_port_pins_t pins) {}
sys_trace_gpio_port_toggle_bits_exit_user(const struct device * port,int ret)60 void __weak sys_trace_gpio_port_toggle_bits_exit_user(const struct device *port, int ret) {}
sys_trace_gpio_init_callback_enter_user(struct gpio_callback * callback,gpio_callback_handler_t handler,gpio_port_pins_t pin_mask)61 void __weak sys_trace_gpio_init_callback_enter_user(struct gpio_callback *callback,
62 						    gpio_callback_handler_t handler,
63 						    gpio_port_pins_t pin_mask) {}
sys_trace_gpio_init_callback_exit_user(struct gpio_callback * callback)64 void __weak sys_trace_gpio_init_callback_exit_user(struct gpio_callback *callback) {}
sys_trace_gpio_add_callback_enter_user(const struct device * port,struct gpio_callback * callback)65 void __weak sys_trace_gpio_add_callback_enter_user(const struct device *port,
66 						   struct gpio_callback *callback) {}
sys_trace_gpio_add_callback_exit_user(const struct device * port,int ret)67 void __weak sys_trace_gpio_add_callback_exit_user(const struct device *port, int ret) {}
sys_trace_gpio_remove_callback_enter_user(const struct device * port,struct gpio_callback * callback)68 void __weak sys_trace_gpio_remove_callback_enter_user(const struct device *port,
69 						      struct gpio_callback *callback) {}
sys_trace_gpio_remove_callback_exit_user(const struct device * port,int ret)70 void __weak sys_trace_gpio_remove_callback_exit_user(const struct device *port, int ret) {}
sys_trace_gpio_get_pending_int_enter_user(const struct device * dev)71 void __weak sys_trace_gpio_get_pending_int_enter_user(const struct device *dev) {}
sys_trace_gpio_get_pending_int_exit_user(const struct device * dev,int ret)72 void __weak sys_trace_gpio_get_pending_int_exit_user(const struct device *dev, int ret) {}
sys_trace_gpio_fire_callbacks_enter_user(sys_slist_t * list,const struct device * port,gpio_pin_t pins)73 void __weak sys_trace_gpio_fire_callbacks_enter_user(sys_slist_t *list, const struct device *port,
74 						     gpio_pin_t pins) {}
sys_trace_gpio_fire_callback_user(const struct device * port,struct gpio_callback * callback)75 void __weak sys_trace_gpio_fire_callback_user(const struct device *port,
76 					      struct gpio_callback *callback) {}
77 
sys_trace_thread_create(struct k_thread * thread)78 void sys_trace_thread_create(struct k_thread *thread)
79 {
80 	sys_trace_thread_create_user(thread);
81 }
82 
sys_trace_thread_abort(struct k_thread * thread)83 void sys_trace_thread_abort(struct k_thread *thread)
84 {
85 	sys_trace_thread_abort_user(thread);
86 }
87 
sys_trace_thread_suspend(struct k_thread * thread)88 void sys_trace_thread_suspend(struct k_thread *thread)
89 {
90 	sys_trace_thread_suspend_user(thread);
91 }
92 
sys_trace_thread_resume(struct k_thread * thread)93 void sys_trace_thread_resume(struct k_thread *thread)
94 {
95 	sys_trace_thread_resume_user(thread);
96 }
97 
sys_trace_thread_name_set(struct k_thread * thread)98 void sys_trace_thread_name_set(struct k_thread *thread)
99 {
100 	sys_trace_thread_name_set_user(thread);
101 }
102 
sys_trace_k_thread_switched_in(void)103 void sys_trace_k_thread_switched_in(void)
104 {
105 	sys_trace_thread_switched_in_user();
106 }
107 
sys_trace_k_thread_switched_out(void)108 void sys_trace_k_thread_switched_out(void)
109 {
110 	sys_trace_thread_switched_out_user();
111 }
112 
sys_trace_thread_info(struct k_thread * thread)113 void sys_trace_thread_info(struct k_thread *thread)
114 {
115 	sys_trace_thread_info_user(thread);
116 }
117 
sys_trace_thread_sched_priority_set(struct k_thread * thread,int prio)118 void sys_trace_thread_sched_priority_set(struct k_thread *thread, int prio)
119 {
120 	sys_trace_thread_priority_set_user(thread, prio);
121 }
122 
sys_trace_thread_sched_ready(struct k_thread * thread)123 void sys_trace_thread_sched_ready(struct k_thread *thread)
124 {
125 	sys_trace_thread_sched_ready_user(thread);
126 }
127 
sys_trace_thread_pend(struct k_thread * thread)128 void sys_trace_thread_pend(struct k_thread *thread)
129 {
130 	sys_trace_thread_pend_user(thread);
131 }
132 
sys_trace_isr_enter(void)133 void sys_trace_isr_enter(void)
134 {
135 	sys_trace_isr_enter_user();
136 }
137 
sys_trace_isr_exit(void)138 void sys_trace_isr_exit(void)
139 {
140 	sys_trace_isr_exit_user();
141 }
142 
sys_trace_idle(void)143 void sys_trace_idle(void)
144 {
145 	sys_trace_idle_user();
146 }
147 
sys_trace_sys_init_enter(const struct init_entry * entry,int level)148 void sys_trace_sys_init_enter(const struct init_entry *entry, int level)
149 {
150 	sys_trace_sys_init_enter_user(entry, level);
151 }
152 
sys_trace_sys_init_exit(const struct init_entry * entry,int level,int result)153 void sys_trace_sys_init_exit(const struct init_entry *entry, int level, int result)
154 {
155 	sys_trace_sys_init_exit_user(entry, level, result);
156 }
157 
sys_trace_gpio_pin_interrupt_configure_enter(const struct device * port,gpio_pin_t pin,gpio_flags_t flags)158 void sys_trace_gpio_pin_interrupt_configure_enter(const struct device *port, gpio_pin_t pin,
159 						  gpio_flags_t flags)
160 {
161 	sys_trace_gpio_pin_interrupt_configure_enter_user(port, pin, flags);
162 }
163 
sys_trace_gpio_pin_interrupt_configure_exit(const struct device * port,gpio_pin_t pin,int ret)164 void sys_trace_gpio_pin_interrupt_configure_exit(const struct device *port, gpio_pin_t pin,
165 						  int ret)
166 {
167 	sys_trace_gpio_pin_interrupt_configure_exit_user(port, pin, ret);
168 }
169 
sys_trace_gpio_pin_configure_enter(const struct device * port,gpio_pin_t pin,gpio_flags_t flags)170 void sys_trace_gpio_pin_configure_enter(const struct device *port, gpio_pin_t pin,
171 					gpio_flags_t flags)
172 {
173 	sys_trace_gpio_pin_configure_enter_user(port, pin, flags);
174 }
175 
sys_trace_gpio_pin_configure_exit(const struct device * port,gpio_pin_t pin,int ret)176 void sys_trace_gpio_pin_configure_exit(const struct device *port, gpio_pin_t pin, int ret)
177 {
178 	sys_trace_gpio_pin_configure_exit_user(port, pin, ret);
179 }
180 
sys_trace_gpio_port_get_direction_enter(const struct device * port,gpio_port_pins_t map,gpio_port_pins_t inputs,gpio_port_pins_t outputs)181 void sys_trace_gpio_port_get_direction_enter(const struct device *port, gpio_port_pins_t map,
182 					     gpio_port_pins_t inputs, gpio_port_pins_t outputs)
183 {
184 	sys_trace_gpio_port_get_direction_enter_user(port, map, inputs, outputs);
185 }
186 
sys_trace_gpio_port_get_direction_exit(const struct device * port,int ret)187 void sys_trace_gpio_port_get_direction_exit(const struct device *port, int ret)
188 {
189 	sys_trace_gpio_port_get_direction_exit_user(port, ret);
190 }
191 
sys_trace_gpio_pin_get_config_enter(const struct device * port,gpio_pin_t pin,int ret)192 void sys_trace_gpio_pin_get_config_enter(const struct device *port, gpio_pin_t pin, int ret)
193 {
194 	sys_trace_gpio_pin_get_config_enter_user(port, pin, ret);
195 }
196 
sys_trace_gpio_pin_get_config_exit(const struct device * port,gpio_pin_t pin,int ret)197 void sys_trace_gpio_pin_get_config_exit(const struct device *port, gpio_pin_t pin, int ret)
198 {
199 	sys_trace_gpio_pin_get_config_exit_user(port, pin, ret);
200 }
201 
sys_trace_gpio_port_get_raw_enter(const struct device * port,gpio_port_value_t * value)202 void sys_trace_gpio_port_get_raw_enter(const struct device *port, gpio_port_value_t *value)
203 {
204 	sys_trace_gpio_port_get_raw_enter_user(port, value);
205 }
206 
sys_trace_gpio_port_get_raw_exit(const struct device * port,int ret)207 void sys_trace_gpio_port_get_raw_exit(const struct device *port, int ret)
208 {
209 	sys_trace_gpio_port_get_raw_exit_user(port, ret);
210 }
211 
sys_trace_gpio_port_set_masked_raw_enter(const struct device * port,gpio_port_pins_t mask,gpio_port_value_t value)212 void sys_trace_gpio_port_set_masked_raw_enter(const struct device *port, gpio_port_pins_t mask,
213 					      gpio_port_value_t value)
214 {
215 	sys_trace_gpio_port_set_masked_raw_enter_user(port, mask, value);
216 }
217 
sys_trace_gpio_port_set_masked_raw_exit(const struct device * port,int ret)218 void sys_trace_gpio_port_set_masked_raw_exit(const struct device *port, int ret)
219 {
220 	sys_trace_gpio_port_set_masked_raw_exit_user(port, ret);
221 }
222 
sys_trace_gpio_port_set_bits_raw_enter(const struct device * port,gpio_port_pins_t pins)223 void sys_trace_gpio_port_set_bits_raw_enter(const struct device *port, gpio_port_pins_t pins)
224 {
225 	sys_trace_gpio_port_set_bits_raw_enter_user(port, pins);
226 }
227 
sys_trace_gpio_port_set_bits_raw_exit(const struct device * port,int ret)228 void sys_trace_gpio_port_set_bits_raw_exit(const struct device *port, int ret)
229 {
230 	sys_trace_gpio_port_set_bits_raw_exit_user(port, ret);
231 }
232 
sys_trace_gpio_port_clear_bits_raw_enter(const struct device * port,gpio_port_pins_t pins)233 void sys_trace_gpio_port_clear_bits_raw_enter(const struct device *port, gpio_port_pins_t pins)
234 {
235 	sys_trace_gpio_port_clear_bits_raw_enter_user(port, pins);
236 }
237 
sys_trace_gpio_port_clear_bits_raw_exit(const struct device * port,int ret)238 void sys_trace_gpio_port_clear_bits_raw_exit(const struct device *port, int ret)
239 {
240 	sys_trace_gpio_port_clear_bits_raw_exit_user(port, ret);
241 }
242 
sys_trace_gpio_port_toggle_bits_enter(const struct device * port,gpio_port_pins_t pins)243 void sys_trace_gpio_port_toggle_bits_enter(const struct device *port, gpio_port_pins_t pins)
244 {
245 	sys_trace_gpio_port_toggle_bits_enter_user(port, pins);
246 }
247 
sys_trace_gpio_port_toggle_bits_exit(const struct device * port,int ret)248 void sys_trace_gpio_port_toggle_bits_exit(const struct device *port, int ret)
249 {
250 	sys_trace_gpio_port_toggle_bits_exit_user(port, ret);
251 }
252 
sys_trace_gpio_init_callback_enter(struct gpio_callback * callback,gpio_callback_handler_t handler,gpio_port_pins_t pin_mask)253 void sys_trace_gpio_init_callback_enter(struct gpio_callback *callback,
254 					gpio_callback_handler_t handler, gpio_port_pins_t pin_mask)
255 {
256 	sys_trace_gpio_init_callback_enter_user(callback, handler, pin_mask);
257 }
258 
sys_trace_gpio_init_callback_exit(struct gpio_callback * callback)259 void sys_trace_gpio_init_callback_exit(struct gpio_callback *callback)
260 {
261 	sys_trace_gpio_init_callback_exit_user(callback);
262 }
263 
sys_trace_gpio_add_callback_enter(const struct device * port,struct gpio_callback * callback)264 void sys_trace_gpio_add_callback_enter(const struct device *port, struct gpio_callback *callback)
265 {
266 	sys_trace_gpio_add_callback_enter_user(port, callback);
267 }
268 
sys_trace_gpio_add_callback_exit(const struct device * port,int ret)269 void sys_trace_gpio_add_callback_exit(const struct device *port, int ret)
270 {
271 	sys_trace_gpio_add_callback_exit_user(port, ret);
272 }
273 
sys_trace_gpio_remove_callback_enter(const struct device * port,struct gpio_callback * callback)274 void sys_trace_gpio_remove_callback_enter(const struct device *port,
275 						struct gpio_callback *callback)
276 {
277 	sys_trace_gpio_remove_callback_enter_user(port, callback);
278 }
279 
sys_trace_gpio_remove_callback_exit(const struct device * port,int ret)280 void sys_trace_gpio_remove_callback_exit(const struct device *port, int ret)
281 {
282 	sys_trace_gpio_remove_callback_exit_user(port, ret);
283 }
284 
sys_trace_gpio_get_pending_int_enter(const struct device * dev)285 void sys_trace_gpio_get_pending_int_enter(const struct device *dev)
286 {
287 	sys_trace_gpio_get_pending_int_enter_user(dev);
288 }
289 
sys_trace_gpio_get_pending_int_exit(const struct device * dev,int ret)290 void sys_trace_gpio_get_pending_int_exit(const struct device *dev, int ret)
291 {
292 	sys_trace_gpio_get_pending_int_exit_user(dev, ret);
293 }
294 
sys_trace_gpio_fire_callbacks_enter(sys_slist_t * list,const struct device * port,gpio_pin_t pins)295 void sys_trace_gpio_fire_callbacks_enter(sys_slist_t *list, const struct device *port,
296 					 gpio_pin_t pins)
297 {
298 	sys_trace_gpio_fire_callbacks_enter_user(list, port, pins);
299 }
300 
sys_trace_gpio_fire_callback(const struct device * port,struct gpio_callback * callback)301 void sys_trace_gpio_fire_callback(const struct device *port, struct gpio_callback *callback)
302 {
303 	sys_trace_gpio_fire_callback_user(port, callback);
304 }
305