blob: a0f07521ca8a2dd1b5a3ffc375b6eaadc9f51131 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <linux/linkage.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
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
Tony Lindgren7d95ded2006-09-20 13:03:34 +010024
Jeremy Kerr0ea12932010-07-06 18:30:06 +080025 .macro addruart, rp, rv
Tony Lindgren7d95ded2006-09-20 13:03:34 +010026 .endm
27
Jeremy Kerr1ea64612010-07-21 10:40:50 +020028#if defined(CONFIG_CPU_V6)
29
Tony Lindgren7d95ded2006-09-20 13:03:34 +010030 .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
Tony Lindgren200b7a82010-01-19 16:40:07 +010052#elif defined(CONFIG_CPU_V7)
53
Tony Lindgren200b7a82010-01-19 16:40:07 +010054 .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
Jean-Christop PLAGNIOL-VILLARDc633c3c2009-02-25 04:20:40 +010069#elif defined(CONFIG_CPU_XSCALE)
70
Jean-Christop PLAGNIOL-VILLARDc633c3c2009-02-25 04:20:40 +010071 .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
Tony Lindgren7d95ded2006-09-20 13:03:34 +010093#else
94
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 .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
Tony Lindgren7d95ded2006-09-20 13:03:34 +0100117
118#endif /* CONFIG_CPU_V6 */
119
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120#else
Russell Kinga09e64f2008-08-05 16:14:15 +0100121#include <mach/debug-macro.S>
Tony Lindgren7d95ded2006-09-20 13:03:34 +0100122#endif /* CONFIG_DEBUG_ICEDCC */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123
Jeremy Kerr0ea12932010-07-06 18:30:06 +0800124#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
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140/*
141 * Useful debugging routines
142 */
143ENTRY(printhex8)
144 mov r1, #8
145 b printhex
Catalin Marinas93ed3972008-08-28 11:22:32 +0100146ENDPROC(printhex8)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147
148ENTRY(printhex4)
149 mov r1, #4
150 b printhex
Catalin Marinas93ed3972008-08-28 11:22:32 +0100151ENDPROC(printhex4)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152
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
Catalin Marinas93ed3972008-08-28 11:22:32 +0100169ENDPROC(printhex2)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170
171 .ltorg
172
173ENTRY(printascii)
Jeremy Kerr0ea12932010-07-06 18:30:06 +0800174 addruart_current r3, r1, r2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175 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
Catalin Marinas93ed3972008-08-28 11:22:32 +0100187ENDPROC(printascii)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188
189ENTRY(printch)
Jeremy Kerr0ea12932010-07-06 18:30:06 +0800190 addruart_current r3, r1, r2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 mov r1, r0
192 mov r0, #0
193 b 1b
Catalin Marinas93ed3972008-08-28 11:22:32 +0100194ENDPROC(printch)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195
196hexbuf: .space 16