Blame view

arch/blackfin/include/asm/trace.h 2.67 KB
669b792c7   Robin Getz   Blackfin arch: Cl...
1
  /*
96f1050d3   Robin Getz   Blackfin: mass cl...
2
   * header file for hardware trace functions
669b792c7   Robin Getz   Blackfin arch: Cl...
3
   *
96f1050d3   Robin Getz   Blackfin: mass cl...
4
5
6
   * Copyright 2007-2008 Analog Devices Inc.
   *
   * Licensed under the GPL-2 or later.
669b792c7   Robin Getz   Blackfin arch: Cl...
7
8
9
10
   */
  
  #ifndef _BLACKFIN_TRACE_
  #define _BLACKFIN_TRACE_
518039bc2   Robin Getz   Blackfin arch: Ad...
11
12
13
14
15
16
17
18
19
20
  /* 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
669b792c7   Robin Getz   Blackfin arch: Cl...
21
  #ifndef __ASSEMBLY__
518039bc2   Robin Getz   Blackfin arch: Ad...
22
23
  extern unsigned long trace_buff_offset;
  extern unsigned long software_trace_buff[];
d28cff4b6   Robin Getz   Blackfin: remove ...
24
  #if defined(CONFIG_DEBUG_VERBOSE)
2a12c4632   Robin Getz   Blackfin: split k...
25
  extern void decode_address(char *buf, unsigned long address);
9a95e2f10   Robin Getz   Blackfin: make ha...
26
  extern bool get_instruction(unsigned int *val, unsigned short *address);
d28cff4b6   Robin Getz   Blackfin: remove ...
27
  #else
9a95e2f10   Robin Getz   Blackfin: make ha...
28
29
  static inline void decode_address(char *buf, unsigned long address) { }
  static inline bool get_instruction(unsigned int *val, unsigned short *address) { return false; }
d28cff4b6   Robin Getz   Blackfin: remove ...
30
  #endif
518039bc2   Robin Getz   Blackfin arch: Ad...
31

669b792c7   Robin Getz   Blackfin arch: Cl...
32
  /* Trace Macros for C files */
518039bc2   Robin Getz   Blackfin arch: Ad...
33
  #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON
46fe23ac3   Graf Yang   Blackfin: add C d...
34
  #define trace_buffer_init() bfin_write_TBUFCTL(BFIN_TRACE_INIT)
669b792c7   Robin Getz   Blackfin arch: Cl...
35
  #define trace_buffer_save(x) \
518039bc2   Robin Getz   Blackfin arch: Ad...
36
37
38
39
  	do { \
  		(x) = bfin_read_TBUFCTL(); \
  		bfin_write_TBUFCTL((x) & ~TBUFEN); \
  	} while (0)
669b792c7   Robin Getz   Blackfin arch: Cl...
40
41
  
  #define trace_buffer_restore(x) \
518039bc2   Robin Getz   Blackfin arch: Ad...
42
43
44
45
46
47
48
49
  	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 */
669b792c7   Robin Getz   Blackfin arch: Cl...
50
51
52
  
  #else
  /* Trace Macros for Assembly files */
518039bc2   Robin Getz   Blackfin arch: Ad...
53
  #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON
669b792c7   Robin Getz   Blackfin arch: Cl...
54
55
56
57
58
  #define trace_buffer_stop(preg, dreg)	\
  	preg.L = LO(TBUFCTL);		\
  	preg.H = HI(TBUFCTL);		\
  	dreg = 0x1;			\
  	[preg] = dreg;
518039bc2   Robin Getz   Blackfin arch: Ad...
59
60
61
62
  #define trace_buffer_init(preg, dreg) \
  	preg.L = LO(TBUFCTL);         \
  	preg.H = HI(TBUFCTL);         \
  	dreg = BFIN_TRACE_INIT;       \
669b792c7   Robin Getz   Blackfin arch: Cl...
63
  	[preg] = dreg;
80f31c8a0   Mike Frysinger   [Blackfin] arch: ...
64
65
66
67
  #define trace_buffer_save(preg, dreg) \
  	preg.L = LO(TBUFCTL); \
  	preg.H = HI(TBUFCTL); \
  	dreg = [preg]; \
2a0c4fdb6   Bernd Schmidt   [Blackfin] arch: ...
68
  	[--sp] = dreg; \
80f31c8a0   Mike Frysinger   [Blackfin] arch: ...
69
70
71
72
73
74
  	dreg = 0x1; \
  	[preg] = dreg;
  
  #define trace_buffer_restore(preg, dreg) \
  	preg.L = LO(TBUFCTL); \
  	preg.H = HI(TBUFCTL); \
2a0c4fdb6   Bernd Schmidt   [Blackfin] arch: ...
75
  	dreg = [sp++]; \
80f31c8a0   Mike Frysinger   [Blackfin] arch: ...
76
  	[preg] = dreg;
518039bc2   Robin Getz   Blackfin arch: Ad...
77
78
79
  #else /* CONFIG_DEBUG_BFIN_HWTRACE_ON */
  
  #define trace_buffer_stop(preg, dreg)
518039bc2   Robin Getz   Blackfin arch: Ad...
80
  #define trace_buffer_init(preg, dreg)
80f31c8a0   Mike Frysinger   [Blackfin] arch: ...
81
82
  #define trace_buffer_save(preg, dreg)
  #define trace_buffer_restore(preg, dreg)
518039bc2   Robin Getz   Blackfin arch: Ad...
83
84
  
  #endif /* CONFIG_DEBUG_BFIN_HWTRACE_ON */
669b792c7   Robin Getz   Blackfin arch: Cl...
85
  #ifdef CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE
80f31c8a0   Mike Frysinger   [Blackfin] arch: ...
86
87
  # define DEBUG_HWTRACE_SAVE(preg, dreg)    trace_buffer_save(preg, dreg)
  # define DEBUG_HWTRACE_RESTORE(preg, dreg) trace_buffer_restore(preg, dreg)
669b792c7   Robin Getz   Blackfin arch: Cl...
88
  #else
80f31c8a0   Mike Frysinger   [Blackfin] arch: ...
89
90
  # define DEBUG_HWTRACE_SAVE(preg, dreg)
  # define DEBUG_HWTRACE_RESTORE(preg, dreg)
669b792c7   Robin Getz   Blackfin arch: Cl...
91
92
93
94
95
  #endif
  
  #endif /* __ASSEMBLY__ */
  
  #endif				/* _BLACKFIN_TRACE_ */