blob: a38b4879441d1715b42c4e7994f9f4d8e67b7fe4 [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
25#if defined(CONFIG_CPU_V6)
26
Tony Lindgren4e6d4882010-02-01 23:26:53 +010027 .macro addruart, rx, tmp
Tony Lindgren7d95ded2006-09-20 13:03:34 +010028 .endm
29
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
Tony Lindgren200b7a82010-01-19 16:40:07 +010052#elif defined(CONFIG_CPU_V7)
53
Tony Lindgren4e6d4882010-02-01 23:26:53 +010054 .macro addruart, rx, tmp
Tony Lindgren200b7a82010-01-19 16:40:07 +010055 .endm
56
57 .macro senduart, rd, rx
58 mcr p14, 0, \rd, c0, c5, 0
59 .endm
60
61 .macro busyuart, rd, rx
62busy: mrc p14, 0, pc, c0, c1, 0
63 bcs busy
64 .endm
65
66 .macro waituart, rd, rx
67wait: mrc p14, 0, pc, c0, c1, 0
68 bcs wait
69
70 .endm
71
Jean-Christop PLAGNIOL-VILLARDc633c3c2009-02-25 04:20:40 +010072#elif defined(CONFIG_CPU_XSCALE)
73
Tony Lindgren4e6d4882010-02-01 23:26:53 +010074 .macro addruart, rx, tmp
Jean-Christop PLAGNIOL-VILLARDc633c3c2009-02-25 04:20:40 +010075 .endm
76
77 .macro senduart, rd, rx
78 mcr p14, 0, \rd, c8, c0, 0
79 .endm
80
81 .macro busyuart, rd, rx
821001:
83 mrc p14, 0, \rx, c14, c0, 0
84 tst \rx, #0x10000000
85 beq 1001b
86 .endm
87
88 .macro waituart, rd, rx
89 mov \rd, #0x10000000
901001:
91 subs \rd, \rd, #1
92 bmi 1002f
93 mrc p14, 0, \rx, c14, c0, 0
94 tst \rx, #0x10000000
95 bne 1001b
961002:
97 .endm
98
Tony Lindgren7d95ded2006-09-20 13:03:34 +010099#else
100
Tony Lindgren4e6d4882010-02-01 23:26:53 +0100101 .macro addruart, rx, tmp
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 .endm
103
104 .macro senduart, rd, rx
105 mcr p14, 0, \rd, c1, c0, 0
106 .endm
107
108 .macro busyuart, rd, rx
1091001:
110 mrc p14, 0, \rx, c0, c0, 0
111 tst \rx, #2
112 beq 1001b
113
114 .endm
115
116 .macro waituart, rd, rx
117 mov \rd, #0x2000000
1181001:
119 subs \rd, \rd, #1
120 bmi 1002f
121 mrc p14, 0, \rx, c0, c0, 0
122 tst \rx, #2
123 bne 1001b
1241002:
125 .endm
Tony Lindgren7d95ded2006-09-20 13:03:34 +0100126
127#endif /* CONFIG_CPU_V6 */
128
Linus Torvalds1da177e2005-04-16 15:20:36 -0700129#else
Russell Kinga09e64f2008-08-05 16:14:15 +0100130#include <mach/debug-macro.S>
Tony Lindgren7d95ded2006-09-20 13:03:34 +0100131#endif /* CONFIG_DEBUG_ICEDCC */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132
133/*
134 * Useful debugging routines
135 */
136ENTRY(printhex8)
137 mov r1, #8
138 b printhex
Catalin Marinas93ed3972008-08-28 11:22:32 +0100139ENDPROC(printhex8)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140
141ENTRY(printhex4)
142 mov r1, #4
143 b printhex
Catalin Marinas93ed3972008-08-28 11:22:32 +0100144ENDPROC(printhex4)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145
146ENTRY(printhex2)
147 mov r1, #2
148printhex: adr r2, hexbuf
149 add r3, r2, r1
150 mov r1, #0
151 strb r1, [r3]
1521: and r1, r0, #15
153 mov r0, r0, lsr #4
154 cmp r1, #10
155 addlt r1, r1, #'0'
156 addge r1, r1, #'a' - 10
157 strb r1, [r3, #-1]!
158 teq r3, r2
159 bne 1b
160 mov r0, r2
161 b printascii
Catalin Marinas93ed3972008-08-28 11:22:32 +0100162ENDPROC(printhex2)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163
164 .ltorg
165
166ENTRY(printascii)
Tony Lindgren4e6d4882010-02-01 23:26:53 +0100167 addruart r3, r1
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 b 2f
1691: waituart r2, r3
170 senduart r1, r3
171 busyuart r2, r3
172 teq r1, #'\n'
173 moveq r1, #'\r'
174 beq 1b
1752: teq r0, #0
176 ldrneb r1, [r0], #1
177 teqne r1, #0
178 bne 1b
179 mov pc, lr
Catalin Marinas93ed3972008-08-28 11:22:32 +0100180ENDPROC(printascii)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700181
182ENTRY(printch)
Tony Lindgren4e6d4882010-02-01 23:26:53 +0100183 addruart r3, r1
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 mov r1, r0
185 mov r0, #0
186 b 1b
Catalin Marinas93ed3972008-08-28 11:22:32 +0100187ENDPROC(printch)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188
189hexbuf: .space 16