Merge branch 'mini2440-dev-unlikely' into mini2440-dev
[linux-2.6/mini2440.git] / arch / arm / kernel / debug.S
blobb121b6053cce4e74a1b650c6bc83665920225ede
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>
14                 .text
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  */
22 #if defined(CONFIG_DEBUG_ICEDCC)
23                 @@ debug using ARM EmbeddedICE DCC channel
25 #if defined(CONFIG_CPU_V6)
27                 .macro  addruart, rx
28                 .endm
30                 .macro  senduart, rd, rx
31                 mcr     p14, 0, \rd, c0, c5, 0
32                 .endm
34                 .macro  busyuart, rd, rx
35 1001:
36                 mrc     p14, 0, \rx, c0, c1, 0
37                 tst     \rx, #0x20000000
38                 beq     1001b
39                 .endm
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
52 #elif defined(CONFIG_CPU_XSCALE)
54                 .macro  addruart, rx
55                 .endm
57                 .macro  senduart, rd, rx
58                 mcr     p14, 0, \rd, c8, c0, 0
59                 .endm
61                 .macro  busyuart, rd, rx
62 1001:
63                 mrc     p14, 0, \rx, c14, c0, 0
64                 tst     \rx, #0x10000000
65                 beq     1001b
66                 .endm
68                 .macro  waituart, rd, rx
69                 mov     \rd, #0x10000000
70 1001:
71                 subs    \rd, \rd, #1
72                 bmi     1002f
73                 mrc     p14, 0, \rx, c14, c0, 0
74                 tst     \rx, #0x10000000
75                 bne     1001b
76 1002:
77                 .endm
79 #else
81                 .macro  addruart, rx
82                 .endm
84                 .macro  senduart, rd, rx
85                 mcr     p14, 0, \rd, c1, c0, 0
86                 .endm
88                 .macro  busyuart, rd, rx
89 1001:
90                 mrc     p14, 0, \rx, c0, c0, 0
91                 tst     \rx, #2
92                 beq     1001b
94                 .endm
96                 .macro  waituart, rd, rx
97                 mov     \rd, #0x2000000
98 1001:
99                 subs    \rd, \rd, #1
100                 bmi     1002f
101                 mrc     p14, 0, \rx, c0, c0, 0
102                 tst     \rx, #2
103                 bne     1001b
104 1002:
105                 .endm
107 #endif  /* CONFIG_CPU_V6 */
109 #else
110 #include <mach/debug-macro.S>
111 #endif  /* CONFIG_DEBUG_ICEDCC */
114  * Useful debugging routines
115  */
116 ENTRY(printhex8)
117                 mov     r1, #8
118                 b       printhex
119 ENDPROC(printhex8)
121 ENTRY(printhex4)
122                 mov     r1, #4
123                 b       printhex
124 ENDPROC(printhex4)
126 ENTRY(printhex2)
127                 mov     r1, #2
128 printhex:       adr     r2, hexbuf
129                 add     r3, r2, r1
130                 mov     r1, #0
131                 strb    r1, [r3]
132 1:              and     r1, r0, #15
133                 mov     r0, r0, lsr #4
134                 cmp     r1, #10
135                 addlt   r1, r1, #'0'
136                 addge   r1, r1, #'a' - 10
137                 strb    r1, [r3, #-1]!
138                 teq     r3, r2
139                 bne     1b
140                 mov     r0, r2
141                 b       printascii
142 ENDPROC(printhex2)
144                 .ltorg
146 ENTRY(printascii)
147                 addruart r3
148                 b       2f
149 1:              waituart r2, r3
150                 senduart r1, r3
151                 busyuart r2, r3
152                 teq     r1, #'\n'
153                 moveq   r1, #'\r'
154                 beq     1b
155 2:              teq     r0, #0
156                 ldrneb  r1, [r0], #1
157                 teqne   r1, #0
158                 bne     1b
159                 mov     pc, lr
160 ENDPROC(printascii)
162 ENTRY(printch)
163                 addruart r3
164                 mov     r1, r0
165                 mov     r0, #0
166                 b       1b
167 ENDPROC(printch)
169 hexbuf:         .space 16