00001
00011 #ifndef _TRACE_H_
00012 #define _TRACE_H_
00013
00014 #include "rwnx_config.h"
00015 #include "co_int.h"
00016 #include "co_bool.h"
00017
00018 #if NX_TRACE
00019
00062 void trace_init(bool force, bool loop);
00063
00079 void trace(uint32_t id, uint16_t nb_param, uint16_t *param, bool trace_buf);
00080
00090 void trace_set_filter(unsigned int compo_id, unsigned int level);
00091
00182 #define TRACE(a,...) { \
00183 uint16_t __p[] = { __VA_ARGS__ }; \
00184 trace((TRACE_FILE_ID << 16) + __LINE__ , sizeof(__p)/sizeof(__p[0]), __p, false); \
00185 }
00186
00243 #define TRACE_BUF(format, size, buf) { \
00244 uint16_t __p[] = {(uint16_t)(size), (uint16_t)((uint32_t)buf), \
00245 (uint16_t)(((uint32_t)buf) >> 16)}; \
00246 uint16_t __size = 1 + (size + 1 + ((uint32_t)buf & 0x1)) / 2; \
00247 trace((TRACE_FILE_ID << 16) + __LINE__, __size, __p, true); \
00248 }
00249
00258 #define TR_32(a) (uint16_t)((uint32_t)(a) >> 16), (uint16_t)((uint32_t)(a))
00259
00268 #define TR_64(a) TR_32(((uint64_t)(a) >> 32)), TR_32(a)
00269
00278 #define TR_PTR(p) TR_32(p)
00279
00288 #define TR_MAC(m) ((uint16_t *)(m))[0], ((uint16_t *)(m))[1], ((uint16_t *)(m))[2]
00289
00298 #define TR_IP4(m) TR_32(*((uint32_t *)m))
00299
00308 #define TR_IP6(m) ((uint16_t *)(m))[0], ((uint16_t *)(m))[1], ((uint16_t *)(m))[2] \
00309 ((uint16_t *)(m))[3], ((uint16_t *)(m))[4], ((uint16_t *)(m))[5] \
00310 ((uint16_t *)(m))[6], ((uint16_t *)(m))[7]
00311
00313 #ifdef CFG_RWTL
00314 #define _PTR_ALIGN(p) ((uint16_t *) p)
00315
00324 #define TR_STR_8(s) (0x0800) , \
00325 (_PTR_ALIGN(s)[0] & 0xFF) + ((_PTR_ALIGN(s)[1] & 0xFF) << 8), \
00326 (_PTR_ALIGN(s)[2] & 0xFF) + ((_PTR_ALIGN(s)[3] & 0xFF) << 8), \
00327 (_PTR_ALIGN(s)[4] & 0xFF) + ((_PTR_ALIGN(s)[5] & 0xFF) << 8), \
00328 (_PTR_ALIGN(s)[6] & 0xFF) + ((_PTR_ALIGN(s)[7] & 0xFF) << 8)
00329
00330
00331 #else
00332 #define _PTR_ALIGN(p) ((uint16_t *)((uint32_t)p & ~0x1))
00333
00342 #define TR_STR_8(s) (0x0800 + (uint16_t)((uint32_t)(s) & 0x1)) , \
00343 _PTR_ALIGN(s)[0], _PTR_ALIGN(s)[1], \
00344 _PTR_ALIGN(s)[2], _PTR_ALIGN(s)[3]
00345
00346 #endif
00347
00358 #define TRACE_FILT(compo, lvl, ...) \
00359 if (trace_compo_level[TRACE_COMPO_##compo] & CO_BIT(TRACE_LVL_##lvl)) { \
00360 TRACE(__VA_ARGS__) }
00361
00371 #define TRACE_BUF_FILT(compo, lvl, ...) \
00372 if (trace_compo_level[TRACE_COMPO_##compo] & CO_BIT(TRACE_LVL_##lvl)) { \
00373 TRACE_BUF(__VA_ARGS__) }
00374
00375
00376 #else
00377
00378 #define TRACE(...)
00379 #define TRACE_BUF(...)
00380 #define TRACE_FILT(...)
00381 #define TRACE_BUF_FILT(...)
00382 static inline void trace_init(bool force, bool loop) {}
00383
00384 #endif
00385
00386 #include "trace_compo.h"
00387
00388 #endif
00389