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 .macro addruart, rx 25 .endm 26 27 .macro senduart, rd, rx 28 mcr p14, 0, \rd, c1, c0, 0 29 .endm 30 31 .macro busyuart, rd, rx 321001: 33 mrc p14, 0, \rx, c0, c0, 0 34 tst \rx, #2 35 beq 1001b 36 37 .endm 38 39 .macro waituart, rd, rx 40 mov \rd, #0x2000000 411001: 42 subs \rd, \rd, #1 43 bmi 1002f 44 mrc p14, 0, \rx, c0, c0, 0 45 tst \rx, #2 46 bne 1001b 471002: 48 .endm 49#else 50#include <asm/arch/debug-macro.S> 51#endif 52 53/* 54 * Useful debugging routines 55 */ 56ENTRY(printhex8) 57 mov r1, #8 58 b printhex 59 60ENTRY(printhex4) 61 mov r1, #4 62 b printhex 63 64ENTRY(printhex2) 65 mov r1, #2 66printhex: adr r2, hexbuf 67 add r3, r2, r1 68 mov r1, #0 69 strb r1, [r3] 701: and r1, r0, #15 71 mov r0, r0, lsr #4 72 cmp r1, #10 73 addlt r1, r1, #'0' 74 addge r1, r1, #'a' - 10 75 strb r1, [r3, #-1]! 76 teq r3, r2 77 bne 1b 78 mov r0, r2 79 b printascii 80 81 .ltorg 82 83ENTRY(printascii) 84 addruart r3 85 b 2f 861: waituart r2, r3 87 senduart r1, r3 88 busyuart r2, r3 89 teq r1, #'\n' 90 moveq r1, #'\r' 91 beq 1b 922: teq r0, #0 93 ldrneb r1, [r0], #1 94 teqne r1, #0 95 bne 1b 96 mov pc, lr 97 98ENTRY(printch) 99 addruart r3 100 mov r1, r0 101 mov r0, #0 102 b 1b 103 104hexbuf: .space 16 105