|
31 | 31 | * Ranjani Sridharan <ranjani.sridharan@linux.intel.com> |
32 | 32 | */ |
33 | 33 |
|
| 34 | +#include <sof/preproc.h> |
34 | 35 | #include <stdint.h> |
35 | 36 | #include <stdio.h> |
36 | 37 | #include <string.h> |
@@ -142,134 +143,84 @@ static char *get_trace_class(uint32_t trace_class) |
142 | 143 | return "value"; |
143 | 144 | } |
144 | 145 |
|
145 | | -/* print trace event */ |
146 | | -void _trace_event0(uint32_t event) |
147 | | -{ |
148 | | - char a, b, c; |
149 | | - char *trace_class = NULL; |
150 | | - |
151 | | - if (test_bench_trace > 0) { |
152 | | - a = event & 0xff; |
153 | | - b = (event >> 8) & 0xff; |
154 | | - c = (event >> 16) & 0xff; |
| 146 | +#define META_SEQ_STEP_param_procD(i, _) META_CONCAT(param, i) %d |
155 | 147 |
|
156 | | - /* look up subsystem from trace class table */ |
157 | | - trace_class = strdup(get_trace_class(event >> 24)); |
158 | | - |
159 | | - /* print trace event stderr*/ |
160 | | - if (strcmp(trace_class, "value") == 0) |
161 | | - fprintf(stderr, "Trace value %d\n", event); |
162 | | - else |
163 | | - fprintf(stderr, "Trace %s %c%c%c\n", trace_class, |
164 | | - c, b, a); |
165 | | - } |
166 | | - |
167 | | - free(trace_class); |
168 | | -} |
169 | | - |
170 | | -void _trace_event_mbox_atomic0(uint32_t event) |
171 | | -{ |
172 | | - _trace_event0(event); |
173 | | -} |
| 148 | +#define HOST_TRACE_EVENT_NTH(postfix, vararg_count)\ |
| 149 | + META_FUNC_WITH_VARARGS(_trace_event, postfix, void,\ |
| 150 | + META_CONCAT(, uint32_t event),\ |
| 151 | + vararg_count, META_SEQ_STEP_param_uint32_t) |
174 | 152 |
|
175 | 153 | /* print trace event */ |
176 | | -void _trace_event1(uint32_t event, uint32_t param) |
177 | | -{ |
178 | | - char a, b, c; |
179 | | - char *trace_class = NULL; |
180 | | - |
181 | | - if (test_bench_trace > 0) { |
182 | | - a = event & 0xff; |
183 | | - b = (event >> 8) & 0xff; |
184 | | - c = (event >> 16) & 0xff; |
185 | | - |
186 | | - /* look up subsystem from trace class table */ |
187 | | - trace_class = strdup(get_trace_class(event >> 24)); |
188 | | - |
189 | | - /* print trace event stderr*/ |
190 | | - if (strcmp(trace_class, "value") == 0) |
191 | | - fprintf(stderr, "Trace value %d, param1 %d\n", event, |
192 | | - param); |
193 | | - else |
194 | | - fprintf(stderr, "Trace %s %c%c%c\n", trace_class, |
195 | | - c, b, a); |
196 | | - } |
197 | | - |
198 | | - free(trace_class); |
| 154 | +#define HOST_TRACE_EVENT_NTH_IMPL(arg_count)\ |
| 155 | +HOST_TRACE_EVENT_NTH(, arg_count)\ |
| 156 | +{\ |
| 157 | + char a, b, c;\ |
| 158 | + \ |
| 159 | + if (test_bench_trace > 0) {\ |
| 160 | + /* look up subsystem from trace class table */\ |
| 161 | + char *trace_class = strdup(get_trace_class(event >> 24));\ |
| 162 | + \ |
| 163 | + a = event & 0xff;\ |
| 164 | + b = (event >> 8) & 0xff;\ |
| 165 | + c = (event >> 16) & 0xff;\ |
| 166 | + \ |
| 167 | + /* print trace event stderr*/\ |
| 168 | + if (!strcmp(trace_class, "value"))\ |
| 169 | + fprintf(stderr,\ |
| 170 | + "Trace value %d, "META_QUOTE(\ |
| 171 | + META_SEQ_FROM_0_TO(\ |
| 172 | + arg_count, META_SEQ_STEP_param_procD\ |
| 173 | + ))"\n"\ |
| 174 | + , event META_SEQ_FROM_0_TO(arg_count, META_SEQ_STEP_param));\ |
| 175 | + else\ |
| 176 | + fprintf(stderr,\ |
| 177 | + "Trace %s %c%c%c\n"\ |
| 178 | + , trace_class, c, b, a);\ |
| 179 | + if (trace_class)\ |
| 180 | + free(trace_class);\ |
| 181 | + }\ |
| 182 | +}\ |
| 183 | +HOST_TRACE_EVENT_NTH(_mbox_atomic, arg_count)\ |
| 184 | +{\ |
| 185 | + META_CONCAT(_trace_event, arg_count)\ |
| 186 | + (event META_SEQ_FROM_0_TO(arg_count,META_SEQ_STEP_param));\ |
199 | 187 | } |
200 | 188 |
|
201 | | -void _trace_event_mbox_atomic1(uint32_t event, uint32_t param) |
202 | | -{ |
203 | | - _trace_event1(event, param); |
204 | | -} |
205 | | - |
206 | | -/* print trace event */ |
207 | | -void _trace_event2(uint32_t event, uint32_t param1, uint32_t param2) |
208 | | -{ |
209 | | - char a, b, c; |
210 | | - char *trace_class = NULL; |
211 | | - |
212 | | - if (test_bench_trace > 0) { |
213 | | - a = event & 0xff; |
214 | | - b = (event >> 8) & 0xff; |
215 | | - c = (event >> 16) & 0xff; |
216 | | - |
217 | | - /* look up subsystem from trace class table */ |
218 | | - trace_class = strdup(get_trace_class(event >> 24)); |
219 | | - |
220 | | - /* print trace event stderr*/ |
221 | | - if (strcmp(trace_class, "value") == 0) |
222 | | - fprintf(stderr, |
223 | | - "Trace value %d, param1 %d param2 %d\n", |
224 | | - event, param1, param2); |
225 | | - else |
226 | | - fprintf(stderr, "Trace %s %c%c%c\n", trace_class, |
227 | | - c, b, a); |
228 | | - } |
229 | | - |
230 | | - free(trace_class); |
231 | | -} |
232 | | - |
233 | | -void _trace_event_mbox_atomic2(uint32_t event, uint32_t param1, |
234 | | - uint32_t param2) |
235 | | -{ |
236 | | - _trace_event2(event, param1, param2); |
237 | | -} |
238 | | - |
239 | | -/* print trace event */ |
240 | | -void _trace_event3(uint32_t event, uint32_t param1, uint32_t param2, |
241 | | - uint32_t param3) |
242 | | -{ |
243 | | - char a, b, c; |
244 | | - char *trace_class = NULL; |
| 189 | +/* Implementation of |
| 190 | + * void _trace_event0( uint32_t log_entry, uint32_t params...) {...} |
| 191 | + * void _trace_event_mbox_atomic0(uint32_t log_entry, uint32_t params...) {...} |
| 192 | + */ |
| 193 | +HOST_TRACE_EVENT_NTH_IMPL(0); |
245 | 194 |
|
246 | | - if (test_bench_trace > 0) { |
247 | | - a = event & 0xff; |
248 | | - b = (event >> 8) & 0xff; |
249 | | - c = (event >> 16) & 0xff; |
| 195 | +/* Implementation of |
| 196 | + * void _trace_event1( uint32_t log_entry, uint32_t params...) {...} |
| 197 | + * void _trace_event_mbox_atomic1(uint32_t log_entry, uint32_t params...) {...} |
| 198 | + */ |
| 199 | +HOST_TRACE_EVENT_NTH_IMPL(1); |
250 | 200 |
|
251 | | - /* look up subsystem from trace class table */ |
252 | | - trace_class = strdup(get_trace_class(event >> 24)); |
| 201 | +/* Implementation of |
| 202 | + * void _trace_event2( uint32_t log_entry, uint32_t params...) {...} |
| 203 | + * void _trace_event_mbox_atomic2(uint32_t log_entry, uint32_t params...) {...} |
| 204 | + */ |
| 205 | +HOST_TRACE_EVENT_NTH_IMPL(2); |
253 | 206 |
|
254 | | - /* print trace event stderr*/ |
255 | | - if (strcmp(trace_class, "value") == 0) |
256 | | - fprintf |
257 | | - (stderr, |
258 | | - "Trace value %d, param1 %d param2 %d param3 %d\n", |
259 | | - event, param1, param2, param3); |
260 | | - else |
261 | | - fprintf(stderr, "Trace %s %c%c%c\n", trace_class, |
262 | | - c, b, a); |
263 | | - } |
| 207 | +/* Implementation of |
| 208 | + * void _trace_event3( uint32_t log_entry, uint32_t params...) {...} |
| 209 | + * void _trace_event_mbox_atomic3(uint32_t log_entry, uint32_t params...) {...} |
| 210 | + */ |
| 211 | +HOST_TRACE_EVENT_NTH_IMPL(3); |
264 | 212 |
|
265 | | - free(trace_class); |
266 | | -} |
| 213 | +/* Implementation of |
| 214 | + * void _trace_event4( uint32_t log_entry, uint32_t params...) {...} |
| 215 | + * void _trace_event_mbox_atomic4(uint32_t log_entry, uint32_t params...) {...} |
| 216 | + */ |
| 217 | +HOST_TRACE_EVENT_NTH_IMPL(4); |
267 | 218 |
|
268 | | -void _trace_event_mbox_atomic3(uint32_t event, uint32_t param1, |
269 | | - uint32_t param2, uint32_t param3) |
270 | | -{ |
271 | | - _trace_event3(event, param1, param2, param3); |
272 | | -} |
| 219 | +/* Implementation of |
| 220 | + * void _trace_event5( uint32_t log_entry, uint32_t params...) {...} |
| 221 | + * void _trace_event_mbox_atomic5(uint32_t log_entry, uint32_t params...) {...} |
| 222 | + */ |
| 223 | +HOST_TRACE_EVENT_NTH_IMPL(5); |
273 | 224 |
|
274 | 225 | /* enable trace in testbench */ |
275 | 226 | void tb_enable_trace(bool enable) |
|
0 commit comments