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