2 * header file for hardware trace functions
4 * Copyright 2007-2008 Analog Devices Inc.
6 * Licensed under the GPL-2 or later.
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))
20 #define BFIN_TRACE_ON (BFIN_TRACE_INIT)
24 extern unsigned long trace_buff_offset
;
25 extern unsigned long software_trace_buff
[];
26 #if defined(CONFIG_DEBUG_VERBOSE)
27 extern void decode_address(char *buf
, unsigned long address
);
28 extern bool get_instruction(unsigned int *val
, unsigned short *address
);
30 static inline void decode_address(char *buf
, unsigned long address
) { }
31 static inline bool get_instruction(unsigned int *val
, unsigned short *address
) { return false; }
34 /* Trace Macros for C files */
36 #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON
38 #define trace_buffer_init() bfin_write_TBUFCTL(BFIN_TRACE_INIT)
40 #define trace_buffer_save(x) \
42 (x) = bfin_read_TBUFCTL(); \
43 bfin_write_TBUFCTL((x) & ~TBUFEN); \
46 #define trace_buffer_restore(x) \
48 bfin_write_TBUFCTL((x)); \
50 #else /* DEBUG_BFIN_HWTRACE_ON */
52 #define trace_buffer_save(x)
53 #define trace_buffer_restore(x)
54 #endif /* CONFIG_DEBUG_BFIN_HWTRACE_ON */
57 /* Trace Macros for Assembly files */
59 #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON
61 #define trace_buffer_stop(preg, dreg) \
62 preg.L = LO(TBUFCTL); \
63 preg.H = HI(TBUFCTL); \
67 #define trace_buffer_init(preg, dreg) \
68 preg.L = LO(TBUFCTL); \
69 preg.H = HI(TBUFCTL); \
70 dreg = BFIN_TRACE_INIT; \
73 #define trace_buffer_save(preg, dreg) \
74 preg.L = LO(TBUFCTL); \
75 preg.H = HI(TBUFCTL); \
81 #define trace_buffer_restore(preg, dreg) \
82 preg.L = LO(TBUFCTL); \
83 preg.H = HI(TBUFCTL); \
87 #else /* CONFIG_DEBUG_BFIN_HWTRACE_ON */
89 #define trace_buffer_stop(preg, dreg)
90 #define trace_buffer_init(preg, dreg)
91 #define trace_buffer_save(preg, dreg)
92 #define trace_buffer_restore(preg, dreg)
94 #endif /* CONFIG_DEBUG_BFIN_HWTRACE_ON */
96 #ifdef CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE
97 # define DEBUG_HWTRACE_SAVE(preg, dreg) trace_buffer_save(preg, dreg)
98 # define DEBUG_HWTRACE_RESTORE(preg, dreg) trace_buffer_restore(preg, dreg)
100 # define DEBUG_HWTRACE_SAVE(preg, dreg)
101 # define DEBUG_HWTRACE_RESTORE(preg, dreg)
104 #endif /* __ASSEMBLY__ */
106 #endif /* _BLACKFIN_TRACE_ */