Merge branch 'x86-cpu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6.git] / arch / blackfin / include / asm / trace.h
1 /*
2  * header file for hardware trace functions
3  *
4  * Copyright 2007-2008 Analog Devices Inc.
5  *
6  * Licensed under the GPL-2 or later.
7  */
8
9 #ifndef _BLACKFIN_TRACE_
10 #define _BLACKFIN_TRACE_
11
12 /* Normally, we use ON, but you can't turn on software expansion until
13  * interrupts subsystem is ready
14  */
15
16 #define BFIN_TRACE_INIT ((CONFIG_DEBUG_BFIN_HWTRACE_COMPRESSION << 4) | 0x03)
17 #ifdef CONFIG_DEBUG_BFIN_HWTRACE_EXPAND
18 #define BFIN_TRACE_ON   (BFIN_TRACE_INIT | (CONFIG_DEBUG_BFIN_HWTRACE_EXPAND << 2))
19 #else
20 #define BFIN_TRACE_ON   (BFIN_TRACE_INIT)
21 #endif
22
23 #ifndef __ASSEMBLY__
24 extern unsigned long trace_buff_offset;
25 extern unsigned long software_trace_buff[];
26
27 /* Trace Macros for C files */
28
29 #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON
30
31 #define trace_buffer_save(x) \
32         do { \
33                 (x) = bfin_read_TBUFCTL(); \
34                 bfin_write_TBUFCTL((x) & ~TBUFEN); \
35         } while (0)
36
37 #define trace_buffer_restore(x) \
38         do { \
39                 bfin_write_TBUFCTL((x));        \
40         } while (0)
41 #else /* DEBUG_BFIN_HWTRACE_ON */
42
43 #define trace_buffer_save(x)
44 #define trace_buffer_restore(x)
45 #endif /* CONFIG_DEBUG_BFIN_HWTRACE_ON */
46
47 #else
48 /* Trace Macros for Assembly files */
49
50 #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON
51
52 #define trace_buffer_stop(preg, dreg)   \
53         preg.L = LO(TBUFCTL);           \
54         preg.H = HI(TBUFCTL);           \
55         dreg = 0x1;                     \
56         [preg] = dreg;
57
58 #define trace_buffer_init(preg, dreg) \
59         preg.L = LO(TBUFCTL);         \
60         preg.H = HI(TBUFCTL);         \
61         dreg = BFIN_TRACE_INIT;       \
62         [preg] = dreg;
63
64 #define trace_buffer_save(preg, dreg) \
65         preg.L = LO(TBUFCTL); \
66         preg.H = HI(TBUFCTL); \
67         dreg = [preg]; \
68         [--sp] = dreg; \
69         dreg = 0x1; \
70         [preg] = dreg;
71
72 #define trace_buffer_restore(preg, dreg) \
73         preg.L = LO(TBUFCTL); \
74         preg.H = HI(TBUFCTL); \
75         dreg = [sp++]; \
76         [preg] = dreg;
77
78 #else /* CONFIG_DEBUG_BFIN_HWTRACE_ON */
79
80 #define trace_buffer_stop(preg, dreg)
81 #define trace_buffer_init(preg, dreg)
82 #define trace_buffer_save(preg, dreg)
83 #define trace_buffer_restore(preg, dreg)
84
85 #endif /* CONFIG_DEBUG_BFIN_HWTRACE_ON */
86
87 #ifdef CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE
88 # define DEBUG_HWTRACE_SAVE(preg, dreg)    trace_buffer_save(preg, dreg)
89 # define DEBUG_HWTRACE_RESTORE(preg, dreg) trace_buffer_restore(preg, dreg)
90 #else
91 # define DEBUG_HWTRACE_SAVE(preg, dreg)
92 # define DEBUG_HWTRACE_RESTORE(preg, dreg)
93 #endif
94
95 #endif /* __ASSEMBLY__ */
96
97 #endif                          /* _BLACKFIN_TRACE_ */