| Robin Getz | 669b792 | 2007-06-21 16:34:08 +0800 | [diff] [blame] | 1 | /* | 
| Robin Getz | 96f1050 | 2009-09-24 14:11:24 +0000 | [diff] [blame] | 2 |  * header file for hardware trace functions | 
| Robin Getz | 669b792 | 2007-06-21 16:34:08 +0800 | [diff] [blame] | 3 |  * | 
| Robin Getz | 96f1050 | 2009-09-24 14:11:24 +0000 | [diff] [blame] | 4 |  * Copyright 2007-2008 Analog Devices Inc. | 
 | 5 |  * | 
 | 6 |  * Licensed under the GPL-2 or later. | 
| Robin Getz | 669b792 | 2007-06-21 16:34:08 +0800 | [diff] [blame] | 7 |  */ | 
 | 8 |  | 
 | 9 | #ifndef _BLACKFIN_TRACE_ | 
 | 10 | #define _BLACKFIN_TRACE_ | 
 | 11 |  | 
| Robin Getz | 518039b | 2007-07-25 11:03:28 +0800 | [diff] [blame] | 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 |  | 
| Robin Getz | 669b792 | 2007-06-21 16:34:08 +0800 | [diff] [blame] | 23 | #ifndef __ASSEMBLY__ | 
| Robin Getz | 518039b | 2007-07-25 11:03:28 +0800 | [diff] [blame] | 24 | extern unsigned long trace_buff_offset; | 
 | 25 | extern unsigned long software_trace_buff[]; | 
| Robin Getz | d28cff4 | 2010-03-11 19:26:38 +0000 | [diff] [blame] | 26 | #if defined(CONFIG_DEBUG_VERBOSE) | 
| Robin Getz | 2a12c46 | 2010-03-11 16:24:18 +0000 | [diff] [blame] | 27 | extern void decode_address(char *buf, unsigned long address); | 
| Robin Getz | 9a95e2f | 2010-03-15 17:42:07 +0000 | [diff] [blame] | 28 | extern bool get_instruction(unsigned int *val, unsigned short *address); | 
| Robin Getz | d28cff4 | 2010-03-11 19:26:38 +0000 | [diff] [blame] | 29 | #else | 
| Robin Getz | 9a95e2f | 2010-03-15 17:42:07 +0000 | [diff] [blame] | 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; } | 
| Robin Getz | d28cff4 | 2010-03-11 19:26:38 +0000 | [diff] [blame] | 32 | #endif | 
| Robin Getz | 518039b | 2007-07-25 11:03:28 +0800 | [diff] [blame] | 33 |  | 
| Robin Getz | 669b792 | 2007-06-21 16:34:08 +0800 | [diff] [blame] | 34 | /* Trace Macros for C files */ | 
 | 35 |  | 
| Robin Getz | 518039b | 2007-07-25 11:03:28 +0800 | [diff] [blame] | 36 | #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON | 
 | 37 |  | 
| Graf Yang | 46fe23a | 2009-09-28 09:23:05 +0000 | [diff] [blame] | 38 | #define trace_buffer_init() bfin_write_TBUFCTL(BFIN_TRACE_INIT) | 
 | 39 |  | 
| Robin Getz | 669b792 | 2007-06-21 16:34:08 +0800 | [diff] [blame] | 40 | #define trace_buffer_save(x) \ | 
| Robin Getz | 518039b | 2007-07-25 11:03:28 +0800 | [diff] [blame] | 41 | 	do { \ | 
 | 42 | 		(x) = bfin_read_TBUFCTL(); \ | 
 | 43 | 		bfin_write_TBUFCTL((x) & ~TBUFEN); \ | 
 | 44 | 	} while (0) | 
| Robin Getz | 669b792 | 2007-06-21 16:34:08 +0800 | [diff] [blame] | 45 |  | 
 | 46 | #define trace_buffer_restore(x) \ | 
| Robin Getz | 518039b | 2007-07-25 11:03:28 +0800 | [diff] [blame] | 47 | 	do { \ | 
 | 48 | 		bfin_write_TBUFCTL((x));        \ | 
 | 49 | 	} while (0) | 
 | 50 | #else /* DEBUG_BFIN_HWTRACE_ON */ | 
 | 51 |  | 
 | 52 | #define trace_buffer_save(x) | 
 | 53 | #define trace_buffer_restore(x) | 
 | 54 | #endif /* CONFIG_DEBUG_BFIN_HWTRACE_ON */ | 
| Robin Getz | 669b792 | 2007-06-21 16:34:08 +0800 | [diff] [blame] | 55 |  | 
 | 56 | #else | 
 | 57 | /* Trace Macros for Assembly files */ | 
 | 58 |  | 
| Robin Getz | 518039b | 2007-07-25 11:03:28 +0800 | [diff] [blame] | 59 | #ifdef CONFIG_DEBUG_BFIN_HWTRACE_ON | 
 | 60 |  | 
| Robin Getz | 669b792 | 2007-06-21 16:34:08 +0800 | [diff] [blame] | 61 | #define trace_buffer_stop(preg, dreg)	\ | 
 | 62 | 	preg.L = LO(TBUFCTL);		\ | 
 | 63 | 	preg.H = HI(TBUFCTL);		\ | 
 | 64 | 	dreg = 0x1;			\ | 
 | 65 | 	[preg] = dreg; | 
 | 66 |  | 
| Robin Getz | 518039b | 2007-07-25 11:03:28 +0800 | [diff] [blame] | 67 | #define trace_buffer_init(preg, dreg) \ | 
 | 68 | 	preg.L = LO(TBUFCTL);         \ | 
 | 69 | 	preg.H = HI(TBUFCTL);         \ | 
 | 70 | 	dreg = BFIN_TRACE_INIT;       \ | 
 | 71 | 	[preg] = dreg; | 
 | 72 |  | 
| Mike Frysinger | 80f31c8 | 2008-02-02 15:47:24 +0800 | [diff] [blame] | 73 | #define trace_buffer_save(preg, dreg) \ | 
 | 74 | 	preg.L = LO(TBUFCTL); \ | 
 | 75 | 	preg.H = HI(TBUFCTL); \ | 
 | 76 | 	dreg = [preg]; \ | 
| Bernd Schmidt | 2a0c4fd | 2008-04-23 07:17:34 +0800 | [diff] [blame] | 77 | 	[--sp] = dreg; \ | 
| Mike Frysinger | 80f31c8 | 2008-02-02 15:47:24 +0800 | [diff] [blame] | 78 | 	dreg = 0x1; \ | 
 | 79 | 	[preg] = dreg; | 
 | 80 |  | 
 | 81 | #define trace_buffer_restore(preg, dreg) \ | 
 | 82 | 	preg.L = LO(TBUFCTL); \ | 
 | 83 | 	preg.H = HI(TBUFCTL); \ | 
| Bernd Schmidt | 2a0c4fd | 2008-04-23 07:17:34 +0800 | [diff] [blame] | 84 | 	dreg = [sp++]; \ | 
| Mike Frysinger | 80f31c8 | 2008-02-02 15:47:24 +0800 | [diff] [blame] | 85 | 	[preg] = dreg; | 
 | 86 |  | 
| Robin Getz | 518039b | 2007-07-25 11:03:28 +0800 | [diff] [blame] | 87 | #else /* CONFIG_DEBUG_BFIN_HWTRACE_ON */ | 
 | 88 |  | 
 | 89 | #define trace_buffer_stop(preg, dreg) | 
| Robin Getz | 518039b | 2007-07-25 11:03:28 +0800 | [diff] [blame] | 90 | #define trace_buffer_init(preg, dreg) | 
| Mike Frysinger | 80f31c8 | 2008-02-02 15:47:24 +0800 | [diff] [blame] | 91 | #define trace_buffer_save(preg, dreg) | 
 | 92 | #define trace_buffer_restore(preg, dreg) | 
| Robin Getz | 518039b | 2007-07-25 11:03:28 +0800 | [diff] [blame] | 93 |  | 
 | 94 | #endif /* CONFIG_DEBUG_BFIN_HWTRACE_ON */ | 
 | 95 |  | 
| Robin Getz | 669b792 | 2007-06-21 16:34:08 +0800 | [diff] [blame] | 96 | #ifdef CONFIG_DEBUG_BFIN_NO_KERN_HWTRACE | 
| Mike Frysinger | 80f31c8 | 2008-02-02 15:47:24 +0800 | [diff] [blame] | 97 | # define DEBUG_HWTRACE_SAVE(preg, dreg)    trace_buffer_save(preg, dreg) | 
 | 98 | # define DEBUG_HWTRACE_RESTORE(preg, dreg) trace_buffer_restore(preg, dreg) | 
| Robin Getz | 669b792 | 2007-06-21 16:34:08 +0800 | [diff] [blame] | 99 | #else | 
| Mike Frysinger | 80f31c8 | 2008-02-02 15:47:24 +0800 | [diff] [blame] | 100 | # define DEBUG_HWTRACE_SAVE(preg, dreg) | 
 | 101 | # define DEBUG_HWTRACE_RESTORE(preg, dreg) | 
| Robin Getz | 669b792 | 2007-06-21 16:34:08 +0800 | [diff] [blame] | 102 | #endif | 
 | 103 |  | 
 | 104 | #endif /* __ASSEMBLY__ */ | 
 | 105 |  | 
 | 106 | #endif				/* _BLACKFIN_TRACE_ */ |