]> nv-tegra.nvidia Code Review - linux-3.10.git/blob - arch/arm/kernel/debug.S
a0f07521ca8a2dd1b5a3ffc375b6eaadc9f51131
[linux-3.10.git] / arch / arm / kernel / debug.S
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  */
12 #include <linux/linkage.h>
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
24
25                 .macro  addruart, rp, rv
26                 .endm
27
28 #if defined(CONFIG_CPU_V6)
29
30                 .macro  senduart, rd, rx
31                 mcr     p14, 0, \rd, c0, c5, 0
32                 .endm
33
34                 .macro  busyuart, rd, rx
35 1001:
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
43 1001:
44                 subs    \rd, \rd, #1
45                 bmi     1002f
46                 mrc     p14, 0, \rx, c0, c1, 0
47                 tst     \rx, #0x20000000
48                 bne     1001b
49 1002:
50                 .endm
51
52 #elif defined(CONFIG_CPU_V7)
53
54                 .macro  senduart, rd, rx
55                 mcr     p14, 0, \rd, c0, c5, 0
56                 .endm
57
58                 .macro  busyuart, rd, rx
59 busy:           mrc     p14, 0, pc, c0, c1, 0
60                 bcs     busy
61                 .endm
62
63                 .macro  waituart, rd, rx
64 wait:           mrc     p14, 0, pc, c0, c1, 0
65                 bcs     wait
66
67                 .endm
68
69 #elif defined(CONFIG_CPU_XSCALE)
70
71                 .macro  senduart, rd, rx
72                 mcr     p14, 0, \rd, c8, c0, 0
73                 .endm
74
75                 .macro  busyuart, rd, rx
76 1001:
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
84 1001:
85                 subs    \rd, \rd, #1
86                 bmi     1002f
87                 mrc     p14, 0, \rx, c14, c0, 0
88                 tst     \rx, #0x10000000
89                 bne     1001b
90 1002:
91                 .endm
92
93 #else
94
95                 .macro  senduart, rd, rx
96                 mcr     p14, 0, \rd, c1, c0, 0
97                 .endm
98
99                 .macro  busyuart, rd, rx
100 1001:
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
109 1001:
110                 subs    \rd, \rd, #1
111                 bmi     1002f
112                 mrc     p14, 0, \rx, c0, c0, 0
113                 tst     \rx, #2
114                 bne     1001b
115 1002:
116                 .endm
117
118 #endif  /* CONFIG_CPU_V6 */
119
120 #else
121 #include <mach/debug-macro.S>
122 #endif  /* CONFIG_DEBUG_ICEDCC */
123
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
140 /*
141  * Useful debugging routines
142  */
143 ENTRY(printhex8)
144                 mov     r1, #8
145                 b       printhex
146 ENDPROC(printhex8)
147
148 ENTRY(printhex4)
149                 mov     r1, #4
150                 b       printhex
151 ENDPROC(printhex4)
152
153 ENTRY(printhex2)
154                 mov     r1, #2
155 printhex:       adr     r2, hexbuf
156                 add     r3, r2, r1
157                 mov     r1, #0
158                 strb    r1, [r3]
159 1:              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
169 ENDPROC(printhex2)
170
171                 .ltorg
172
173 ENTRY(printascii)
174                 addruart_current r3, r1, r2
175                 b       2f
176 1:              waituart r2, r3
177                 senduart r1, r3
178                 busyuart r2, r3
179                 teq     r1, #'\n'
180                 moveq   r1, #'\r'
181                 beq     1b
182 2:              teq     r0, #0
183                 ldrneb  r1, [r0], #1
184                 teqne   r1, #0
185                 bne     1b
186                 mov     pc, lr
187 ENDPROC(printascii)
188
189 ENTRY(printch)
190                 addruart_current r3, r1, r2
191                 mov     r1, r0
192                 mov     r0, #0
193                 b       1b
194 ENDPROC(printch)
195
196 hexbuf:         .space 16