mm-only debug patch...
[mmotm.git] / arch / blackfin / include / asm / trace.h
blob609ad3c841891c0bb59cb9784edf113da932ed39
1 /*
2 * header file for hardware trace functions
4 * Copyright 2007-2008 Analog Devices Inc.
6 * Licensed under the GPL-2 or later.
7 */
9 #ifndef _BLACKFIN_TRACE_
10 #define _BLACKFIN_TRACE_
12 /* Normally, we use ON, but you can't turn on software expansion until
13 * interrupts subsystem is ready
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
23 #ifndef __ASSEMBLY__
24 extern unsigned long trace_buff_offset;
25 extern unsigned long software_trace_buff[];
27 /* Trace Macros for C files */
29 #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON
31 #define trace_buffer_save(x) \
32 do { \
33 (x) = bfin_read_TBUFCTL(); \
34 bfin_write_TBUFCTL((x) & ~TBUFEN); \
35 } while (0)
37 #define trace_buffer_restore(x) \
38 do { \
39 bfin_write_TBUFCTL((x)); \
40 } while (0)
41 #else /* DEBUG_BFIN_HWTRACE_ON */
43 #define trace_buffer_save(x)
44 #define trace_buffer_restore(x)
45 #endif /* CONFIG_DEBUG_BFIN_HWTRACE_ON */
47 #else
48 /* Trace Macros for Assembly files */
50 #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON
52 #define trace_buffer_stop(preg, dreg) \
53 preg.L = LO(TBUFCTL); \
54 preg.H = HI(TBUFCTL); \
55 dreg = 0x1; \
56 [preg] = dreg;
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;
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;
72 #define trace_buffer_restore(preg, dreg) \
73 preg.L = LO(TBUFCTL); \
74 preg.H = HI(TBUFCTL); \
75 dreg = [sp++]; \
76 [preg] = dreg;
78 #else /* CONFIG_DEBUG_BFIN_HWTRACE_ON */
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)
85 #endif /* CONFIG_DEBUG_BFIN_HWTRACE_ON */
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
95 #endif /* __ASSEMBLY__ */
97 #endif /* _BLACKFIN_TRACE_ */