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 | */ |
| 12 | #include <linux/config.h> |
| 13 | #include <linux/linkage.h> |
| 14 | #include <asm/hardware.h> |
| 15 | |
| 16 | .text |
| 17 | |
| 18 | /* |
| 19 | * Some debugging routines (useful if you've got MM problems and |
| 20 | * printk isn't working). For DEBUGGING ONLY!!! Do not leave |
| 21 | * references to these in a production kernel! |
| 22 | */ |
| 23 | |
| 24 | #if defined(CONFIG_DEBUG_ICEDCC) |
| 25 | @@ debug using ARM EmbeddedICE DCC channel |
| 26 | .macro addruart, rx |
| 27 | .endm |
| 28 | |
| 29 | .macro senduart, rd, rx |
| 30 | mcr p14, 0, \rd, c1, c0, 0 |
| 31 | .endm |
| 32 | |
| 33 | .macro busyuart, rd, rx |
| 34 | 1001: |
| 35 | mrc p14, 0, \rx, c0, c0, 0 |
| 36 | tst \rx, #2 |
| 37 | beq 1001b |
| 38 | |
| 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, c0, 0 |
| 47 | tst \rx, #2 |
| 48 | bne 1001b |
| 49 | 1002: |
| 50 | .endm |
| 51 | #else |
| 52 | #include <asm/arch/debug-macro.S> |
| 53 | #endif |
| 54 | |
| 55 | /* |
| 56 | * Useful debugging routines |
| 57 | */ |
| 58 | ENTRY(printhex8) |
| 59 | mov r1, #8 |
| 60 | b printhex |
| 61 | |
| 62 | ENTRY(printhex4) |
| 63 | mov r1, #4 |
| 64 | b printhex |
| 65 | |
| 66 | ENTRY(printhex2) |
| 67 | mov r1, #2 |
| 68 | printhex: adr r2, hexbuf |
| 69 | add r3, r2, r1 |
| 70 | mov r1, #0 |
| 71 | strb r1, [r3] |
| 72 | 1: and r1, r0, #15 |
| 73 | mov r0, r0, lsr #4 |
| 74 | cmp r1, #10 |
| 75 | addlt r1, r1, #'0' |
| 76 | addge r1, r1, #'a' - 10 |
| 77 | strb r1, [r3, #-1]! |
| 78 | teq r3, r2 |
| 79 | bne 1b |
| 80 | mov r0, r2 |
| 81 | b printascii |
| 82 | |
| 83 | .ltorg |
| 84 | |
| 85 | ENTRY(printascii) |
| 86 | addruart r3 |
| 87 | b 2f |
| 88 | 1: waituart r2, r3 |
| 89 | senduart r1, r3 |
| 90 | busyuart r2, r3 |
| 91 | teq r1, #'\n' |
| 92 | moveq r1, #'\r' |
| 93 | beq 1b |
| 94 | 2: teq r0, #0 |
| 95 | ldrneb r1, [r0], #1 |
| 96 | teqne r1, #0 |
| 97 | bne 1b |
| 98 | mov pc, lr |
| 99 | |
| 100 | ENTRY(printch) |
| 101 | addruart r3 |
| 102 | mov r1, r0 |
| 103 | mov r0, #0 |
| 104 | b 1b |
| 105 | |
| 106 | hexbuf: .space 16 |