Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[pandora-kernel.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 #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
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_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
62 1001:
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
70 1001:
71                 subs    \rd, \rd, #1
72                 bmi     1002f
73                 mrc     p14, 0, \rx, c14, c0, 0
74                 tst     \rx, #0x10000000
75                 bne     1001b
76 1002:
77                 .endm
78
79 #else
80
81                 .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
89 1001:
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
98 1001:
99                 subs    \rd, \rd, #1
100                 bmi     1002f
101                 mrc     p14, 0, \rx, c0, c0, 0
102                 tst     \rx, #2
103                 bne     1001b
104 1002:
105                 .endm
106
107 #endif  /* CONFIG_CPU_V6 */
108
109 #else
110 #include <mach/debug-macro.S>
111 #endif  /* CONFIG_DEBUG_ICEDCC */
112
113 /*
114  * Useful debugging routines
115  */
116 ENTRY(printhex8)
117                 mov     r1, #8
118                 b       printhex
119 ENDPROC(printhex8)
120
121 ENTRY(printhex4)
122                 mov     r1, #4
123                 b       printhex
124 ENDPROC(printhex4)
125
126 ENTRY(printhex2)
127                 mov     r1, #2
128 printhex:       adr     r2, hexbuf
129                 add     r3, r2, r1
130                 mov     r1, #0
131                 strb    r1, [r3]
132 1:              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
142 ENDPROC(printhex2)
143
144                 .ltorg
145
146 ENTRY(printascii)
147                 addruart r3
148                 b       2f
149 1:              waituart r2, r3
150                 senduart r1, r3
151                 busyuart r2, r3
152                 teq     r1, #'\n'
153                 moveq   r1, #'\r'
154                 beq     1b
155 2:              teq     r0, #0
156                 ldrneb  r1, [r0], #1
157                 teqne   r1, #0
158                 bne     1b
159                 mov     pc, lr
160 ENDPROC(printascii)
161
162 ENTRY(printch)
163                 addruart r3
164                 mov     r1, r0
165                 mov     r0, #0
166                 b       1b
167 ENDPROC(printch)
168
169 hexbuf:         .space 16