@@ -144,6 +144,75 @@ void trace_init(struct sof *sof);
144144
145145#if TRACE
146146
147+ /*
148+ * trace_event macro definition
149+ *
150+ * trace_event() macro is used for logging events that occur at runtime.
151+ * It comes in 2 main flavours, atomic and non-atomic. Depending of definitions
152+ * above, it might also propagate log messages to mbox if desired.
153+ *
154+ * First argument is always class of event being logged, as defined above.
155+ * Second argument is string literal in printf format, followed by up to 3
156+ * parameters (uint32_t), that are used to expand into string fromat when
157+ * parsing log data.
158+ *
159+ * All compile-time accessible data (verbosity, class, source file name, line
160+ * index and string literal) are linked into .static_log_entries section
161+ * of binary and then extracted by rimage, so they do not contribute to loadable
162+ * image size. This way more elaborate log messages are possible and encouraged,
163+ * for better debugging experience, without worrying about runtime performance.
164+ */
165+ #if TRACEM
166+ /* send all trace to mbox and local trace buffer */
167+ #define trace_event (__c , __e , ...) \
168+ _log_message(_mbox,, LOG_LEVEL_VERBOSE, __c, __e, ##__VA_ARGS__)
169+ #define trace_event_atomic (__c , __e , ...) \
170+ _log_message(_mbox, _atomic, LOG_LEVEL_VERBOSE, __c, __e, ##__VA_ARGS__)
171+ #else
172+ /* send trace events only to the local trace buffer */
173+ #define trace_event (__c , __e , ...) \
174+ _log_message(,, LOG_LEVEL_VERBOSE, __c, __e, ##__VA_ARGS__)
175+ #define trace_event_atomic (__c , __e , ...) \
176+ _log_message(, _atomic, LOG_LEVEL_VERBOSE, __c, __e, ##__VA_ARGS__)
177+ #endif
178+ #define trace_value (x ) trace_event(0, "value %u", x)
179+ #define trace_value_atomic (x ) trace_event_atomic(0, "value %u", x)
180+
181+ #define trace_point (x ) platform_trace_point(x)
182+
183+ /* verbose tracing */
184+ #if TRACEV
185+ #define tracev_event (__c , __e , ...) trace_event(__c, __e, ##__VA_ARGS__)
186+ #define tracev_value (x ) trace_value(x)
187+ #define tracev_event_atomic (__c , __e , ...) \
188+ trace_event_atomic(__c, __e, ##__VA_ARGS__)
189+ #define tracev_value_atomic (x ) trace_value_atomic(x)
190+ #else
191+ #define tracev_event (__c , __e , ...)
192+ #define tracev_event_atomic (__c , __e , ...)
193+
194+ #define tracev_value (x )
195+ #define tracev_value_atomic (x )
196+ #endif
197+
198+ /* error tracing */
199+ #if TRACEE
200+ #define trace_error (__c , __e , ...) \
201+ _log_message(,, LOG_LEVEL_CRITICAL, __c, __e, ##__VA_ARGS__)
202+ #define trace_error_atomic (__c , __e , ...) \
203+ _log_message(, _atomic, LOG_LEVEL_CRITICAL, __c, __e, ##__VA_ARGS__)
204+ /* write back error value to mbox */
205+ #define trace_error_value (x ) \
206+ trace_error(0, "value %u", x)
207+ #define trace_error_value_atomic (x ) \
208+ trace_error_atomic(0, "value %u", x)
209+ #else
210+ #define trace_error (__c , __e , ...)
211+ #define trace_error_atomic (__c , __e , ...)
212+ #define trace_error_value (x )
213+ #define trace_error_value_atomic (x )
214+ #endif
215+
147216typedef void (* log_func )();
148217
149218/*
@@ -203,64 +272,27 @@ typedef void(*log_func)();
203272 __log_message(_trace_event##mbox##atomic, level, \
204273 comp_id, format, ##__VA_ARGS__)
205274
206- /* send all trace to mbox and local trace buffer */
207- #if TRACEM
208- #define trace_event (__c , __e , ...) \
209- _log_message(_mbox,, LOG_LEVEL_VERBOSE, __c, __e, ##__VA_ARGS__)
210- #define trace_event_atomic (__c , __e , ...) \
211- _log_message(_mbox, _atomic, LOG_LEVEL_VERBOSE, __c, __e, ##__VA_ARGS__)
212- /* send trace events only to the local trace buffer */
213- #else
214- #define trace_event (__c , __e , ...) \
215- _log_message(,, LOG_LEVEL_VERBOSE, __c, __e, ##__VA_ARGS__)
216- #define trace_event_atomic (__c , __e , ...) \
217- _log_message(, _atomic, LOG_LEVEL_VERBOSE, __c, __e, ##__VA_ARGS__)
218- #endif
219- #define trace_value (x ) trace_event(0, "value %d", x)
220- #define trace_value_atomic (x ) trace_event_atomic(0, "value %d", x)
221275
222- #define trace_point (x ) platform_trace_point(x)
223-
224- /* verbose tracing */
225- #if TRACEV
226- #define tracev_event (__c , __e , ...) trace_event(__c, __e, ##__VA_ARGS__)
227- #define tracev_value (x ) trace_value(x)
228- #define tracev_event_atomic (__c , __e , ...) \
229- trace_event_atomic(__c, __e, ##__VA_ARGS__)
230- #define tracev_value_atomic (x ) trace_value_atomic(x)
231276#else
232- #define tracev_event (__c , __e , ...)
233- #define tracev_value (x )
234- #define tracev_event_atomic (__c , __e , ...)
235- #define tracev_value_atomic (x )
236- #endif
237277
238- /* error tracing */
239- #if TRACEE
240- #define trace_error (__c , __e , ...) \
241- _log_message(,, LOG_LEVEL_CRITICAL, __c, __e, ##__VA_ARGS__)
242- #define trace_error_atomic (__c , __e , ...) \
243- _log_message(, _atomic, LOG_LEVEL_CRITICAL, __c, __e, ##__VA_ARGS__)
244- /* write back error value to mbox */
245- #define trace_error_value (x ) \
246- trace_error(0, "value %d", x)
247- #define trace_error_value_atomic (x ) \
248- trace_error_atomic(0, "value %d", x)
249- #else
278+ #define trace_event (__c , __e , ...)
279+ #define trace_event_atomic (__c , __e , ...)
280+
250281#define trace_error (__c , __e , ...)
251282#define trace_error_atomic (__c , __e , ...)
283+
252284#define trace_error_value (x )
253285#define trace_error_value_atomic (x )
254- #endif
255286
256- #else
257-
258- #define trace_event (x , e , ...)
259- #define trace_error (c , e , ...)
260287#define trace_value (x )
288+ #define trace_value_atomic (x )
289+
261290#define trace_point (x )
291+
262292#define tracev_event (__c , __e , ...)
293+ #define tracev_event_atomic (__c , __e , ...)
263294#define tracev_value (x )
295+ #define tracev_value_atomic (x )
264296
265297#endif
266298
0 commit comments