blob: 204e2160cfccbdd5fa88a00285086d73a522ebcb [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
Nicolas Pitre639da5e2011-08-31 22:55:46 -040025 .macro addruart, rp, rv, tmp
Tony Lindgren7d95ded2006-09-20 13:03:34 +010026 .endm
27
Stephen Boyddfad5492011-03-23 22:46:15 +010028#if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_V6K) || defined(CONFIG_CPU_V7)
Jeremy Kerr1ea64612010-07-21 10:40:50 +020029
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
Jean-Christop PLAGNIOL-VILLARDc633c3c2009-02-25 04:20:40 +010052#elif defined(CONFIG_CPU_XSCALE)
53
Jean-Christop PLAGNIOL-VILLARDc633c3c2009-02-25 04:20:40 +010054 .macro senduart, rd, rx
55 mcr p14, 0, \rd, c8, c0, 0
56 .endm
57
58 .macro busyuart, rd, rx
591001:
60 mrc p14, 0, \rx, c14, c0, 0
61 tst \rx, #0x10000000
62 beq 1001b
63 .endm
64
65 .macro waituart, rd, rx
66 mov \rd, #0x10000000
671001:
68 subs \rd, \rd, #1
69 bmi 1002f
70 mrc p14, 0, \rx, c14, c0, 0
71 tst \rx, #0x10000000
72 bne 1001b
731002:
74 .endm
75
Tony Lindgren7d95ded2006-09-20 13:03:34 +010076#else
77
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 .macro senduart, rd, rx
79 mcr p14, 0, \rd, c1, c0, 0
80 .endm
81
82 .macro busyuart, rd, rx
831001:
84 mrc p14, 0, \rx, c0, c0, 0
85 tst \rx, #2
86 beq 1001b
87
88 .endm
89
90 .macro waituart, rd, rx
91 mov \rd, #0x2000000
921001:
93 subs \rd, \rd, #1
94 bmi 1002f
95 mrc p14, 0, \rx, c0, c0, 0
96 tst \rx, #2
97 bne 1001b
981002:
99 .endm
Tony Lindgren7d95ded2006-09-20 13:03:34 +0100100
101#endif /* CONFIG_CPU_V6 */
102
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103#else
Russell Kinga09e64f2008-08-05 16:14:15 +0100104#include <mach/debug-macro.S>
Tony Lindgren7d95ded2006-09-20 13:03:34 +0100105#endif /* CONFIG_DEBUG_ICEDCC */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106
Jeremy Kerr0ea12932010-07-06 18:30:06 +0800107#ifdef CONFIG_MMU
108 .macro addruart_current, rx, tmp1, tmp2
Nicolas Pitre639da5e2011-08-31 22:55:46 -0400109 addruart \tmp1, \tmp2, \rx
Jeremy Kerr0ea12932010-07-06 18:30:06 +0800110 mrc p15, 0, \rx, c1, c0
111 tst \rx, #1
112 moveq \rx, \tmp1
113 movne \rx, \tmp2
114 .endm
115
116#else /* !CONFIG_MMU */
117 .macro addruart_current, rx, tmp1, tmp2
118 addruart \rx, \tmp1
119 .endm
120
121#endif /* CONFIG_MMU */
122
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123/*
124 * Useful debugging routines
125 */
126ENTRY(printhex8)
127 mov r1, #8
128 b printhex
Catalin Marinas93ed3972008-08-28 11:22:32 +0100129ENDPROC(printhex8)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130
131ENTRY(printhex4)
132 mov r1, #4
133 b printhex
Catalin Marinas93ed3972008-08-28 11:22:32 +0100134ENDPROC(printhex4)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700135
136ENTRY(printhex2)
137 mov r1, #2
138printhex: adr r2, hexbuf
139 add r3, r2, r1
140 mov r1, #0
141 strb r1, [r3]
1421: and r1, r0, #15
143 mov r0, r0, lsr #4
144 cmp r1, #10
145 addlt r1, r1, #'0'
146 addge r1, r1, #'a' - 10
147 strb r1, [r3, #-1]!
148 teq r3, r2
149 bne 1b
150 mov r0, r2
151 b printascii
Catalin Marinas93ed3972008-08-28 11:22:32 +0100152ENDPROC(printhex2)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153
Afzal Mohammedb55fa182011-10-20 19:32:07 +0100154hexbuf: .space 16
155
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156 .ltorg
157
158ENTRY(printascii)
Jeremy Kerr0ea12932010-07-06 18:30:06 +0800159 addruart_current r3, r1, r2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 b 2f
1611: waituart r2, r3
162 senduart r1, r3
163 busyuart r2, r3
164 teq r1, #'\n'
165 moveq r1, #'\r'
166 beq 1b
1672: teq r0, #0
168 ldrneb r1, [r0], #1
169 teqne r1, #0
170 bne 1b
171 mov pc, lr
Catalin Marinas93ed3972008-08-28 11:22:32 +0100172ENDPROC(printascii)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173
174ENTRY(printch)
Jeremy Kerr0ea12932010-07-06 18:30:06 +0800175 addruart_current r3, r1, r2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176 mov r1, r0
177 mov r0, #0
178 b 1b
Catalin Marinas93ed3972008-08-28 11:22:32 +0100179ENDPROC(printch)