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#else 53 54 .macro addruart, rx 55 .endm 56 57 .macro senduart, rd, rx 58 mcr p14, 0, \rd, c1, c0, 0 59 .endm 60 61 .macro busyuart, rd, rx 621001: 63 mrc p14, 0, \rx, c0, c0, 0 64 tst \rx, #2 65 beq 1001b 66 67 .endm 68 69 .macro waituart, rd, rx 70 mov \rd, #0x2000000 711001: 72 subs \rd, \rd, #1 73 bmi 1002f 74 mrc p14, 0, \rx, c0, c0, 0 75 tst \rx, #2 76 bne 1001b 771002: 78 .endm 79 80#endif /* CONFIG_CPU_V6 */ 81 82#else 83#include <mach/debug-macro.S> 84#endif /* CONFIG_DEBUG_ICEDCC */ 85 86/* 87 * Useful debugging routines 88 */ 89ENTRY(printhex8) 90 mov r1, #8 91 b printhex 92ENDPROC(printhex8) 93 94ENTRY(printhex4) 95 mov r1, #4 96 b printhex 97ENDPROC(printhex4) 98 99ENTRY(printhex2) 100 mov r1, #2 101printhex: adr r2, hexbuf 102 add r3, r2, r1 103 mov r1, #0 104 strb r1, [r3] 1051: and r1, r0, #15 106 mov r0, r0, lsr #4 107 cmp r1, #10 108 addlt r1, r1, #'0' 109 addge r1, r1, #'a' - 10 110 strb r1, [r3, #-1]! 111 teq r3, r2 112 bne 1b 113 mov r0, r2 114 b printascii 115ENDPROC(printhex2) 116 117 .ltorg 118 119ENTRY(printascii) 120 addruart r3 121 b 2f 1221: waituart r2, r3 123 senduart r1, r3 124 busyuart r2, r3 125 teq r1, #'\n' 126 moveq r1, #'\r' 127 beq 1b 1282: teq r0, #0 129 ldrneb r1, [r0], #1 130 teqne r1, #0 131 bne 1b 132 mov pc, lr 133ENDPROC(printascii) 134 135ENTRY(printch) 136 addruart r3 137 mov r1, r0 138 mov r0, #0 139 b 1b 140ENDPROC(printch) 141 142hexbuf: .space 16 143