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 */ 12#include <linux/linkage.h> 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 24 25#if defined(CONFIG_CPU_V6) 26 27 .macro addruart, rx 28 .endm 29 30 .macro senduart, rd, rx 31 mcr p14, 0, \rd, c0, c5, 0 32 .endm 33 34 .macro busyuart, rd, rx 351001: 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 431001: 44 subs \rd, \rd, #1 45 bmi 1002f 46 mrc p14, 0, \rx, c0, c1, 0 47 tst \rx, #0x20000000 48 bne 1001b 491002: 50 .endm 51 52#elif defined(CONFIG_CPU_V7) 53 54 .macro addruart, rx 55 .endm 56 57 .macro senduart, rd, rx 58 mcr p14, 0, \rd, c0, c5, 0 59 .endm 60 61 .macro busyuart, rd, rx 62busy: mrc p14, 0, pc, c0, c1, 0 63 bcs busy 64 .endm 65 66 .macro waituart, rd, rx 67wait: mrc p14, 0, pc, c0, c1, 0 68 bcs wait 69 70 .endm 71 72#elif defined(CONFIG_CPU_XSCALE) 73 74 .macro addruart, rx 75 .endm 76 77 .macro senduart, rd, rx 78 mcr p14, 0, \rd, c8, c0, 0 79 .endm 80 81 .macro busyuart, rd, rx 821001: 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 901001: 91 subs \rd, \rd, #1 92 bmi 1002f 93 mrc p14, 0, \rx, c14, c0, 0 94 tst \rx, #0x10000000 95 bne 1001b 961002: 97 .endm 98 99#else 100 101 .macro addruart, rx 102 .endm 103 104 .macro senduart, rd, rx 105 mcr p14, 0, \rd, c1, c0, 0 106 .endm 107 108 .macro busyuart, rd, rx 1091001: 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 1181001: 119 subs \rd, \rd, #1 120 bmi 1002f 121 mrc p14, 0, \rx, c0, c0, 0 122 tst \rx, #2 123 bne 1001b 1241002: 125 .endm 126 127#endif /* CONFIG_CPU_V6 */ 128 129#else 130#include <mach/debug-macro.S> 131#endif /* CONFIG_DEBUG_ICEDCC */ 132 133/* 134 * Useful debugging routines 135 */ 136ENTRY(printhex8) 137 mov r1, #8 138 b printhex 139ENDPROC(printhex8) 140 141ENTRY(printhex4) 142 mov r1, #4 143 b printhex 144ENDPROC(printhex4) 145 146ENTRY(printhex2) 147 mov r1, #2 148printhex: adr r2, hexbuf 149 add r3, r2, r1 150 mov r1, #0 151 strb r1, [r3] 1521: 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 162ENDPROC(printhex2) 163 164 .ltorg 165 166ENTRY(printascii) 167 addruart r3 168 b 2f 1691: waituart r2, r3 170 senduart r1, r3 171 busyuart r2, r3 172 teq r1, #'\n' 173 moveq r1, #'\r' 174 beq 1b 1752: teq r0, #0 176 ldrneb r1, [r0], #1 177 teqne r1, #0 178 bne 1b 179 mov pc, lr 180ENDPROC(printascii) 181 182ENTRY(printch) 183 addruart r3 184 mov r1, r0 185 mov r0, #0 186 b 1b 187ENDPROC(printch) 188 189hexbuf: .space 16 190