blob: b121b6053cce4e74a1b650c6bc83665920225ede [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
27 .macro addruart, rx
28 .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
Jean-Christop PLAGNIOL-VILLARDc633c3c2009-02-25 04:20:40 +010052#elif defined(CONFIG_CPU_XSCALE)
53
54 .macro addruart, rx
55 .endm
56
57 .macro senduart, rd, rx
58 mcr p14, 0, \rd, c8, c0, 0
59 .endm
60
61 .macro busyuart, rd, rx
621001:
63 mrc p14, 0, \rx, c14, c0, 0
64 tst \rx, #0x10000000
65 beq 1001b
66 .endm
67
68 .macro waituart, rd, rx
69 mov \rd, #0x10000000
701001:
71 subs \rd, \rd, #1
72 bmi 1002f
73 mrc p14, 0, \rx, c14, c0, 0
74 tst \rx, #0x10000000
75 bne 1001b
761002:
77 .endm
78
Tony Lindgren7d95ded2006-09-20 13:03:34 +010079#else
80
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 .macro addruart, rx
82 .endm
83
84 .macro senduart, rd, rx
85 mcr p14, 0, \rd, c1, c0, 0
86 .endm
87
88 .macro busyuart, rd, rx
891001:
90 mrc p14, 0, \rx, c0, c0, 0
91 tst \rx, #2
92 beq 1001b
93
94 .endm
95
96 .macro waituart, rd, rx
97 mov \rd, #0x2000000
981001:
99 subs \rd, \rd, #1
100 bmi 1002f
101 mrc p14, 0, \rx, c0, c0, 0
102 tst \rx, #2
103 bne 1001b
1041002:
105 .endm
Tony Lindgren7d95ded2006-09-20 13:03:34 +0100106
107#endif /* CONFIG_CPU_V6 */
108
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109#else
Russell Kinga09e64f2008-08-05 16:14:15 +0100110#include <mach/debug-macro.S>
Tony Lindgren7d95ded2006-09-20 13:03:34 +0100111#endif /* CONFIG_DEBUG_ICEDCC */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700112
113/*
114 * Useful debugging routines
115 */
116ENTRY(printhex8)
117 mov r1, #8
118 b printhex
Catalin Marinas93ed3972008-08-28 11:22:32 +0100119ENDPROC(printhex8)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120
121ENTRY(printhex4)
122 mov r1, #4
123 b printhex
Catalin Marinas93ed3972008-08-28 11:22:32 +0100124ENDPROC(printhex4)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125
126ENTRY(printhex2)
127 mov r1, #2
128printhex: adr r2, hexbuf
129 add r3, r2, r1
130 mov r1, #0
131 strb r1, [r3]
1321: 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
Catalin Marinas93ed3972008-08-28 11:22:32 +0100142ENDPROC(printhex2)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143
144 .ltorg
145
146ENTRY(printascii)
147 addruart r3
148 b 2f
1491: waituart r2, r3
150 senduart r1, r3
151 busyuart r2, r3
152 teq r1, #'\n'
153 moveq r1, #'\r'
154 beq 1b
1552: teq r0, #0
156 ldrneb r1, [r0], #1
157 teqne r1, #0
158 bne 1b
159 mov pc, lr
Catalin Marinas93ed3972008-08-28 11:22:32 +0100160ENDPROC(printascii)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161
162ENTRY(printch)
163 addruart r3
164 mov r1, r0
165 mov r0, #0
166 b 1b
Catalin Marinas93ed3972008-08-28 11:22:32 +0100167ENDPROC(printch)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168
169hexbuf: .space 16