#ifndef __RTL_TRACE_H__
#define __RTL_TRACE_H__

/* #undef to leave no trace */
/* #define CONFIG_RTL_TRACER */

/* event ids */
enum {  RTL_TRACE_STOP_INTERRUPTS = 1, RTL_TRACE_ALLOW_INTERRUPTS = 2,
       	RTL_TRACE_SAVE_INTERRUPTS = 4, RTL_TRACE_RESTORE_INTERRUPTS = 8,
       	RTL_TRACE_NO_INTERRUPTS = 16,
	RTL_TRACE_SMP_INTERCEPT = 32, RTL_TRACE_SMP_INTERCEPT_EXIT = 64,
	RTL_TRACE_USER = 128, RTL_TRACE_SPIN_LOCK = 256, RTL_TRACE_SPIN_UNLOCK = 512, RTL_TRACE_INTERCEPT = 1024, RTL_TRACE_INTERCEPT_EXIT = 2048,
	RTL_TRACE_USER2 = 4096};

#define RTL_TRACE_ALL 0xffffffff


#ifdef CONFIG_RTL_TRACER
extern void (*rtl_trace)(int event_id, long event_data, long eip);

#define rtl_trace2(event_id, event_data) \
do { \
	long eip; \
	__asm__("1: mov $1b, %%eax" : "=a" (eip) : ); \
	rtl_trace(event_id, event_data, eip); \
} while (0)

#define rtl_trace2a(event_id, event_data) \
do { \
	long eip; \
	__asm__("mov $1f, %%eax" : "=a" (eip) : ); \
	rtl_trace(event_id, event_data, eip); \
	__asm__("1:" : : ); \
} while (0)

#else

#define rtl_trace(event_id, event_data, eip)
#define rtl_trace2(event_id, event_data)
#define rtl_trace2a(event_id, event_data)
#endif

#endif
