aboutsummaryrefslogtreecommitdiffstats
path: root/include/asm-blackfin/trace.h
blob: 6313aace9d5915991aa55c438fa45914a561e809 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
 * Common header file for blackfin family of processors.
 *
 */

#ifndef _BLACKFIN_TRACE_
#define _BLACKFIN_TRACE_

/* Normally, we use ON, but you can't turn on software expansion until
 * interrupts subsystem is ready
 */

#define BFIN_TRACE_INIT ((CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION << 4) | 0x03)
#ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
#define BFIN_TRACE_ON   (BFIN_TRACE_INIT | (CONFIG_DEBUG_BFIN_HWTRACE_EXPAND << 2))
#else
#define BFIN_TRACE_ON   (BFIN_TRACE_INIT)
#endif

#ifndef __ASSEMBLY__
extern unsigned long trace_buff_offset;
extern unsigned long software_trace_buff[];

/* Trace Macros for C files */

#ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON

#define trace_buffer_save(x) \
	do { \
		(x) = bfin_read_TBUFCTL(); \
		bfin_write_TBUFCTL((x) & ~TBUFEN); \
	} while (0)

#define trace_buffer_restore(x) \
	do { \
		bfin_write_TBUFCTL((x));        \
	} while (0)
#else /* DEBUG_BFIN_HWTRACE_ON */

#define trace_buffer_save(x)
#define trace_buffer_restore(x)
#endif /* CONFIG_DEBUG_BFIN_HWTRACE_ON */

#else
/* Trace Macros for Assembly files */

#ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON

#define TRACE_BUFFER_START(preg, dreg) trace_buffer_start(preg, dreg)
#define TRACE_BUFFER_STOP(preg, dreg)  trace_buffer_stop(preg, dreg)

#define trace_buffer_stop(preg, dreg)	\
	preg.L = LO(TBUFCTL);		\
	preg.H = HI(TBUFCTL);		\
	dreg = 0x1;			\
	[preg] = dreg;

#define trace_buffer_start(preg, dreg)	\
	preg.L = LO(TBUFCTL);		\
	preg.H = HI(TBUFCTL);		\
	dreg = BFIN_TRACE_ON;		\
	[preg] = dreg;

#define trace_buffer_init(preg, dreg) \
	preg.L = LO(TBUFCTL);         \
	preg.H = HI(TBUFCTL);         \
	dreg = BFIN_TRACE_INIT;       \
	[preg] = dreg;

#else /* CONFIG_DEBUG_BFIN_HWTRACE_ON */

#define trace_buffer_stop(preg, dreg)
#define trace_buffer_start(preg, dreg)
#define trace_buffer_init(preg, dreg)

#endif /* CONFIG_DEBUG_BFIN_HWTRACE_ON */

#ifdef CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE
# define DEBUG_START_HWTRACE(preg, dreg) trace_buffer_start(preg, dreg)
# define DEBUG_STOP_HWTRACE(preg, dreg) trace_buffer_stop(preg, dreg)

#else
# define DEBUG_START_HWTRACE(preg, dreg)
# define DEBUG_STOP_HWTRACE(preg, dreg)
#endif

#endif /* __ASSEMBLY__ */

#endif				/* _BLACKFIN_TRACE_ */