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 | |
| 25 | #if defined(CONFIG_CPU_V6) |
| 26 | |
Tony Lindgren | 4e6d488 | 2010-02-01 23:26:53 +0100 | [diff] [blame] | 27 | .macro addruart, rx, tmp |
Tony Lindgren | 7d95ded | 2006-09-20 13:03:34 +0100 | [diff] [blame] | 28 | .endm |
| 29 | |
| 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 | 4e6d488 | 2010-02-01 23:26:53 +0100 | [diff] [blame] | 54 | .macro addruart, rx, tmp |
Tony Lindgren | 200b7a8 | 2010-01-19 16:40:07 +0100 | [diff] [blame] | 55 | .endm |
| 56 | |
| 57 | .macro senduart, rd, rx |
| 58 | mcr p14, 0, \rd, c0, c5, 0 |
| 59 | .endm |
| 60 | |
| 61 | .macro busyuart, rd, rx |
| 62 | busy: mrc p14, 0, pc, c0, c1, 0 |
| 63 | bcs busy |
| 64 | .endm |
| 65 | |
| 66 | .macro waituart, rd, rx |
| 67 | wait: mrc p14, 0, pc, c0, c1, 0 |
| 68 | bcs wait |
| 69 | |
| 70 | .endm |
| 71 | |
Jean-Christop PLAGNIOL-VILLARD | c633c3c | 2009-02-25 04:20:40 +0100 | [diff] [blame] | 72 | #elif defined(CONFIG_CPU_XSCALE) |
| 73 | |
Tony Lindgren | 4e6d488 | 2010-02-01 23:26:53 +0100 | [diff] [blame] | 74 | .macro addruart, rx, tmp |
Jean-Christop PLAGNIOL-VILLARD | c633c3c | 2009-02-25 04:20:40 +0100 | [diff] [blame] | 75 | .endm |
| 76 | |
| 77 | .macro senduart, rd, rx |
| 78 | mcr p14, 0, \rd, c8, c0, 0 |
| 79 | .endm |
| 80 | |
| 81 | .macro busyuart, rd, rx |
| 82 | 1001: |
| 83 | mrc p14, 0, \rx, c14, c0, 0 |
| 84 | tst \rx, #0x10000000 |
| 85 | beq 1001b |
| 86 | .endm |
| 87 | |
| 88 | .macro waituart, rd, rx |
| 89 | mov \rd, #0x10000000 |
| 90 | 1001: |
| 91 | subs \rd, \rd, #1 |
| 92 | bmi 1002f |
| 93 | mrc p14, 0, \rx, c14, c0, 0 |
| 94 | tst \rx, #0x10000000 |
| 95 | bne 1001b |
| 96 | 1002: |
| 97 | .endm |
| 98 | |
Tony Lindgren | 7d95ded | 2006-09-20 13:03:34 +0100 | [diff] [blame] | 99 | #else |
| 100 | |
Tony Lindgren | 4e6d488 | 2010-02-01 23:26:53 +0100 | [diff] [blame] | 101 | .macro addruart, rx, tmp |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 102 | .endm |
| 103 | |
| 104 | .macro senduart, rd, rx |
| 105 | mcr p14, 0, \rd, c1, c0, 0 |
| 106 | .endm |
| 107 | |
| 108 | .macro busyuart, rd, rx |
| 109 | 1001: |
| 110 | mrc p14, 0, \rx, c0, c0, 0 |
| 111 | tst \rx, #2 |
| 112 | beq 1001b |
| 113 | |
| 114 | .endm |
| 115 | |
| 116 | .macro waituart, rd, rx |
| 117 | mov \rd, #0x2000000 |
| 118 | 1001: |
| 119 | subs \rd, \rd, #1 |
| 120 | bmi 1002f |
| 121 | mrc p14, 0, \rx, c0, c0, 0 |
| 122 | tst \rx, #2 |
| 123 | bne 1001b |
| 124 | 1002: |
| 125 | .endm |
Tony Lindgren | 7d95ded | 2006-09-20 13:03:34 +0100 | [diff] [blame] | 126 | |
| 127 | #endif /* CONFIG_CPU_V6 */ |
| 128 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | #else |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 130 | #include <mach/debug-macro.S> |
Tony Lindgren | 7d95ded | 2006-09-20 13:03:34 +0100 | [diff] [blame] | 131 | #endif /* CONFIG_DEBUG_ICEDCC */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | |
| 133 | /* |
| 134 | * Useful debugging routines |
| 135 | */ |
| 136 | ENTRY(printhex8) |
| 137 | mov r1, #8 |
| 138 | b printhex |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 139 | ENDPROC(printhex8) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | |
| 141 | ENTRY(printhex4) |
| 142 | mov r1, #4 |
| 143 | b printhex |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 144 | ENDPROC(printhex4) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | |
| 146 | ENTRY(printhex2) |
| 147 | mov r1, #2 |
| 148 | printhex: adr r2, hexbuf |
| 149 | add r3, r2, r1 |
| 150 | mov r1, #0 |
| 151 | strb r1, [r3] |
| 152 | 1: and r1, r0, #15 |
| 153 | mov r0, r0, lsr #4 |
| 154 | cmp r1, #10 |
| 155 | addlt r1, r1, #'0' |
| 156 | addge r1, r1, #'a' - 10 |
| 157 | strb r1, [r3, #-1]! |
| 158 | teq r3, r2 |
| 159 | bne 1b |
| 160 | mov r0, r2 |
| 161 | b printascii |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 162 | ENDPROC(printhex2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | |
| 164 | .ltorg |
| 165 | |
| 166 | ENTRY(printascii) |
Tony Lindgren | 4e6d488 | 2010-02-01 23:26:53 +0100 | [diff] [blame] | 167 | addruart r3, r1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | b 2f |
| 169 | 1: waituart r2, r3 |
| 170 | senduart r1, r3 |
| 171 | busyuart r2, r3 |
| 172 | teq r1, #'\n' |
| 173 | moveq r1, #'\r' |
| 174 | beq 1b |
| 175 | 2: teq r0, #0 |
| 176 | ldrneb r1, [r0], #1 |
| 177 | teqne r1, #0 |
| 178 | bne 1b |
| 179 | mov pc, lr |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 180 | ENDPROC(printascii) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | |
| 182 | ENTRY(printch) |
Tony Lindgren | 4e6d488 | 2010-02-01 23:26:53 +0100 | [diff] [blame] | 183 | addruart r3, r1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | mov r1, r0 |
| 185 | mov r0, #0 |
| 186 | b 1b |
Catalin Marinas | 93ed397 | 2008-08-28 11:22:32 +0100 | [diff] [blame] | 187 | ENDPROC(printch) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 | |
| 189 | hexbuf: .space 16 |