]> bbs.cooldavid.org Git - net-next-2.6.git/blame - arch/arm/kernel/debug.S
arm: return both physical and virtual addresses from addruart
[net-next-2.6.git] / arch / arm / kernel / debug.S
CommitLineData
1da177e4
LT
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 */
1da177e4 12#include <linux/linkage.h>
1da177e4
LT
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
7d95ded9 24
0ea12930 25 .macro addruart, rp, rv
7d95ded9
TL
26 .endm
27
1ea64615
JK
28#if defined(CONFIG_CPU_V6)
29
7d95ded9
TL
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
200b7a8d
TL
52#elif defined(CONFIG_CPU_V7)
53
200b7a8d
TL
54 .macro senduart, rd, rx
55 mcr p14, 0, \rd, c0, c5, 0
56 .endm
57
58 .macro busyuart, rd, rx
59busy: mrc p14, 0, pc, c0, c1, 0
60 bcs busy
61 .endm
62
63 .macro waituart, rd, rx
64wait: mrc p14, 0, pc, c0, c1, 0
65 bcs wait
66
67 .endm
68
c633c3cf
JCPV
69#elif defined(CONFIG_CPU_XSCALE)
70
c633c3cf
JCPV
71 .macro senduart, rd, rx
72 mcr p14, 0, \rd, c8, c0, 0
73 .endm
74
75 .macro busyuart, rd, rx
761001:
77 mrc p14, 0, \rx, c14, c0, 0
78 tst \rx, #0x10000000
79 beq 1001b
80 .endm
81
82 .macro waituart, rd, rx
83 mov \rd, #0x10000000
841001:
85 subs \rd, \rd, #1
86 bmi 1002f
87 mrc p14, 0, \rx, c14, c0, 0
88 tst \rx, #0x10000000
89 bne 1001b
901002:
91 .endm
92
7d95ded9
TL
93#else
94
1da177e4
LT
95 .macro senduart, rd, rx
96 mcr p14, 0, \rd, c1, c0, 0
97 .endm
98
99 .macro busyuart, rd, rx
1001001:
101 mrc p14, 0, \rx, c0, c0, 0
102 tst \rx, #2
103 beq 1001b
104
105 .endm
106
107 .macro waituart, rd, rx
108 mov \rd, #0x2000000
1091001:
110 subs \rd, \rd, #1
111 bmi 1002f
112 mrc p14, 0, \rx, c0, c0, 0
113 tst \rx, #2
114 bne 1001b
1151002:
116 .endm
7d95ded9
TL
117
118#endif /* CONFIG_CPU_V6 */
119
1da177e4 120#else
a09e64fb 121#include <mach/debug-macro.S>
7d95ded9 122#endif /* CONFIG_DEBUG_ICEDCC */
1da177e4 123
0ea12930
JK
124#ifdef CONFIG_MMU
125 .macro addruart_current, rx, tmp1, tmp2
126 addruart \tmp1, \tmp2
127 mrc p15, 0, \rx, c1, c0
128 tst \rx, #1
129 moveq \rx, \tmp1
130 movne \rx, \tmp2
131 .endm
132
133#else /* !CONFIG_MMU */
134 .macro addruart_current, rx, tmp1, tmp2
135 addruart \rx, \tmp1
136 .endm
137
138#endif /* CONFIG_MMU */
139
1da177e4
LT
140/*
141 * Useful debugging routines
142 */
143ENTRY(printhex8)
144 mov r1, #8
145 b printhex
93ed3970 146ENDPROC(printhex8)
1da177e4
LT
147
148ENTRY(printhex4)
149 mov r1, #4
150 b printhex
93ed3970 151ENDPROC(printhex4)
1da177e4
LT
152
153ENTRY(printhex2)
154 mov r1, #2
155printhex: adr r2, hexbuf
156 add r3, r2, r1
157 mov r1, #0
158 strb r1, [r3]
1591: and r1, r0, #15
160 mov r0, r0, lsr #4
161 cmp r1, #10
162 addlt r1, r1, #'0'
163 addge r1, r1, #'a' - 10
164 strb r1, [r3, #-1]!
165 teq r3, r2
166 bne 1b
167 mov r0, r2
168 b printascii
93ed3970 169ENDPROC(printhex2)
1da177e4
LT
170
171 .ltorg
172
173ENTRY(printascii)
0ea12930 174 addruart_current r3, r1, r2
1da177e4
LT
175 b 2f
1761: waituart r2, r3
177 senduart r1, r3
178 busyuart r2, r3
179 teq r1, #'\n'
180 moveq r1, #'\r'
181 beq 1b
1822: teq r0, #0
183 ldrneb r1, [r0], #1
184 teqne r1, #0
185 bne 1b
186 mov pc, lr
93ed3970 187ENDPROC(printascii)
1da177e4
LT
188
189ENTRY(printch)
0ea12930 190 addruart_current r3, r1, r2
1da177e4
LT
191 mov r1, r0
192 mov r0, #0
193 b 1b
93ed3970 194ENDPROC(printch)
1da177e4
LT
195
196hexbuf: .space 16