Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * linux/arch/arm/kernel/debug.S |
| 3 | * |
| 4 | * Copyright (C) 1994-1999 Russell King |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License version 2 as |
| 8 | * published by the Free Software Foundation. |
| 9 | * |
| 10 | * 32-bit debugging code |
| 11 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <linux/linkage.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | |
| 14 | .text |
| 15 | |
| 16 | /* |
| 17 | * Some debugging routines (useful if you've got MM problems and |
| 18 | * printk isn't working). For DEBUGGING ONLY!!! Do not leave |
| 19 | * references to these in a production kernel! |
| 20 | */ |
| 21 | |
| 22 | #if defined(CONFIG_DEBUG_ICEDCC) |
| 23 | @@ debug using ARM EmbeddedICE DCC channel |
Tony Lindgren | 7d95ded | 2006-09-20 13:03:34 +0100 | [diff] [blame] | 24 | |
Jeremy Kerr | 0ea1293 | 2010-07-06 18:30:06 +0800 | [diff] [blame^] | 25 | .macro addruart, rp, rv |
Tony Lindgren | 7d95ded | 2006-09-20 13:03:34 +0100 | [diff] [blame] | 26 | .endm |
| 27 | |
Jeremy Kerr | 1ea6461 | 2010-07-21 10:40:50 +0200 | [diff] [blame] | 28 | #if defined(CONFIG_CPU_V6) |
| 29 | |
Tony Lindgren | 7d95ded | 2006-09-20 13:03:34 +0100 | [diff] [blame] | 30 | .macro senduart, rd, rx |
| 31 | mcr p14, 0, \rd, c0, c5, 0 |
| 32 | .endm |
| 33 | |
| 34 | .macro busyuart, rd, rx |
| 35 | 1001: |
| 36 | mrc p14, 0, \rx, c0, c1, 0 |
| 37 | tst \rx, #0x20000000 |
| 38 | beq 1001b |
| 39 | .endm |
| 40 | |
| 41 | .macro waituart, rd, rx |
| 42 | mov \rd, #0x2000000 |
| 43 | 1001: |
| 44 | subs \rd, \rd, #1 |
| 45 | bmi 1002f |
| 46 | mrc p14, 0, \rx, c0, c1, 0 |
| 47 | tst \rx, #0x20000000 |
| 48 | bne 1001b |
| 49 | 1002: |
| 50 | .endm |
| 51 | |
Tony Lindgren | 200b7a8 | 2010-01-19 16:40:07 +0100 | [diff] [blame] | 52 | #elif defined(CONFIG_CPU_V7) |
| 53 | |
Tony Lindgren | 200b7a8 | 2010-01-19 16:40:07 +0100 | [diff] [blame] | 54 | .macro senduart, rd, rx |
| 55 | mcr p14, 0, \rd, c0, c5, 0 |
| 56 | .endm |
| 57 | |
| 58 | .macro busyuart, rd, rx |
| 59 | busy: mrc p14, 0, pc, c0, c1, 0 |
| 60 | bcs busy |
| 61 | .endm |
| 62 | |
| 63 | .macro waituart, rd, rx |
| 64 | wait: mrc p14, 0, pc, c0, c1, 0 |
| 65 | bcs wait |
| 66 | |
| 67 | .endm |
| 68 | |
Jean-Christop PLAGNIOL-VILLARD | c633c3c | 2009-02-25 04:20:40 +0100 | [diff] [blame] | 69 | #elif defined(CONFIG_CPU_XSCALE) |
| 70 | |
Jean-Christop PLAGNIOL-VILLARD | c633c3c | 2009-02-25 04:20:40 +0100 | [diff] [blame] | 71 | .macro senduart, rd, rx |
| 72 | mcr p14, 0, \rd, c8, c0, 0 |
| 73 | .endm |
| 74 | |
| 75 | .macro busyuart, rd, rx |
| 76 | 1001: |
| 77 | mrc p14, 0, \rx, c14, c0, 0 |
| 78 | tst \rx, #0x10000000 |
| 79 | beq 1001b |
| 80 | .endm |
| 81 | |
| 82 | .macro waituart, rd, rx |
| 83 | mov \rd, #0x10000000 |
| 84 | 1001: |
| 85 | subs \rd, \rd, #1 |
| 86 | bmi 1002f |
| 87 | mrc p14, 0, \rx, c14, c0, 0 |
| 88 | tst \rx, #0x10000000 |
| 89 | bne 1001b |
| 90 | 1002: |
| 91 | .endm |
| 92 | |
Tony Lindgren | 7d95ded | 2006-09-20 13:03:34 +0100 | [diff] [blame] | 93 | #else |
| 94 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | .macro senduart, rd, rx |
| 96 | mcr p14, 0, \rd, c1, c0, 0 |
| 97 | .endm |
| 98 | |
| 99 | .macro busyuart, rd, rx |
| 100 | 1001: |
| 101 | mrc p14, 0, \rx, c0, c0, 0 |
| 102 | tst \rx, #2 |
| 103 | beq 1001b |
| 104 | |
| 105 | .endm |
| 106 | |
| 107 | .macro waituart, rd, rx |
| 108 | mov \rd, #0x2000000 |
| 109 | 1001: |
| 110 | subs \rd, \rd, #1 |
| 111 | bmi 1002f |
| 112 | mrc p14, 0, \rx, c0, c0, 0 |
| 113 | tst \rx, #2 |
| 114 | bne 1001b |
| 115 | 1002: |
| 116 | .endm |
Tony Lindgren | 7d95ded | 2006-09-20 13:03:34 +0100 | [diff] [blame] | 117 | |
| 118 | #endif /* CONFIG_CPU_V6 */ |
| 119 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 120 | #else |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 121 | #include <mach/debug-macro.S> |
Tony Lindgren | 7d95ded | 2006-09-20 13:03:34 +0100 | [diff] [blame] | 122 | #endif /* CONFIG_DEBUG_ICEDCC */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | |
Jeremy Kerr | 0ea1293 | 2010-07-06 18:30:06 +0800 | [diff] [blame^] | 124 | #ifdef CONFIG_MMU |
| 125 | .macro addruart_current, rx, tmp1, tmp2 |
| 126 | addruart \tmp1, \tmp2 |
| 127 | mrc p15, 0, \rx, c1, c0 |
| 128 | tst \rx, #1 |
| 129 | moveq \rx, \tmp1 |
| 130 | movne \rx, \tmp2 |
| 131 | .endm |
| 132 | |
| 133 | #else /* !CONFIG_MMU */ |
| 134 | .macro addruart_current, rx, tmp1, tmp2 |
| 135 | addruart \rx, \tmp1 |
| 136 | .endm |
| 137 | |
| 138 | #endif /* CONFIG_MMU */ |
| 139 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | /* |
| 141 | * Useful debugging routines |
| 142 | */ |
| 143 | ENTRY(printhex8) |
| 144 | mov r1, #8 |
| 145 | b printhex |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 146 | ENDPROC(printhex8) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 147 | |
| 148 | ENTRY(printhex4) |
| 149 | mov r1, #4 |
| 150 | b printhex |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 151 | ENDPROC(printhex4) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 152 | |
| 153 | ENTRY(printhex2) |
| 154 | mov r1, #2 |
| 155 | printhex: adr r2, hexbuf |
| 156 | add r3, r2, r1 |
| 157 | mov r1, #0 |
| 158 | strb r1, [r3] |
| 159 | 1: and r1, r0, #15 |
| 160 | mov r0, r0, lsr #4 |
| 161 | cmp r1, #10 |
| 162 | addlt r1, r1, #'0' |
| 163 | addge r1, r1, #'a' - 10 |
| 164 | strb r1, [r3, #-1]! |
| 165 | teq r3, r2 |
| 166 | bne 1b |
| 167 | mov r0, r2 |
| 168 | b printascii |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 169 | ENDPROC(printhex2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 170 | |
| 171 | .ltorg |
| 172 | |
| 173 | ENTRY(printascii) |
Jeremy Kerr | 0ea1293 | 2010-07-06 18:30:06 +0800 | [diff] [blame^] | 174 | addruart_current r3, r1, r2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | b 2f |
| 176 | 1: waituart r2, r3 |
| 177 | senduart r1, r3 |
| 178 | busyuart r2, r3 |
| 179 | teq r1, #'\n' |
| 180 | moveq r1, #'\r' |
| 181 | beq 1b |
| 182 | 2: teq r0, #0 |
| 183 | ldrneb r1, [r0], #1 |
| 184 | teqne r1, #0 |
| 185 | bne 1b |
| 186 | mov pc, lr |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 187 | ENDPROC(printascii) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | |
| 189 | ENTRY(printch) |
Jeremy Kerr | 0ea1293 | 2010-07-06 18:30:06 +0800 | [diff] [blame^] | 190 | addruart_current r3, r1, r2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | mov r1, r0 |
| 192 | mov r0, #0 |
| 193 | b 1b |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 194 | ENDPROC(printch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 195 | |
| 196 | hexbuf: .space 16 |