Merge with Linux 2.3.40.
[linux-2.6/linux-mips.git] / arch / arm / kernel / debug-armv.S
blob5802dac708eff349c7bd57ddd87ce884adeb52d7
1 /*
2  * linux/arch/arm/kernel/debug-armv.S
3  *
4  * Copyright (C) 1994-1999 Russell King
5  *
6  * 32-bit debugging code
7  */
8 #include <linux/config.h>
9 #include <linux/linkage.h>
10 #include <asm/hardware.h>
11 #include <asm/dec21285.h>
13                 .text
16  * Some debugging routines (useful if you've got MM problems and
17  * printk isn't working).  For DEBUGGING ONLY!!!  Do not leave
18  * references to these in a production kernel!
19  */
20 #if defined(CONFIG_ARCH_RPC)
21                 .macro  addruart,rx
22                 mov     \rx, #0xe0000000
23                 orr     \rx, \rx, #0x00010000
24                 orr     \rx, \rx, #0x00000fe0
25                 .endm
27                 .macro  senduart,rd,rx
28                 strb    \rd, [\rx]
29                 .endm
31                 .macro  busyuart,rd,rx
32 1002:           ldrb    \rd, [\rx, #0x14]
33                 and     \rd, \rd, #0x60
34                 teq     \rd, #0x60
35                 bne     1002b
36                 .endm
38                 .macro  waituart,rd,rx
39 1001:           ldrb    \rd, [\rx, #0x18]
40                 tst     \rd, #0x10
41                 beq     1001b
42                 .endm
44 #elif defined(CONFIG_ARCH_EBSA110)
45                 .macro  addruart,rx
46                 mov     \rx, #0xf0000000
47                 orr     \rx, \rx, #0x00000be0
48                 .endm
50                 .macro  senduart,rd,rx
51                 strb    \rd, [\rx]
52                 .endm
54                 .macro  busyuart,rd,rx
55 1002:           ldrb    \rd, [\rx, #0x14]
56                 and     \rd, \rd, #0x60
57                 teq     \rd, #0x60
58                 bne     1002b
59                 .endm
61                 .macro  waituart,rd,rx
62 1001:           ldrb    \rd, [\rx, #0x18]
63                 tst     \rd, #0x10
64                 beq     1001b
65                 .endm
67 #elif defined(CONFIG_HOST_FOOTBRIDGE) || defined(CONFIG_ADDIN_FOOTBRIDGE)
68 #ifndef CONFIG_DEBUG_DC21285_PORT
69         /* For NetWinder debugging */
70                 .macro  addruart,rx
71                 mov     \rx, #0xff000000
72                 orr     \rx, \rx, #0x000003f8
73                 .endm
75                 .macro  senduart,rd,rx
76                 strb    \rd, [\rx]
77                 .endm
79                 .macro  busyuart,rd,rx
80 1002:           ldrb    \rd, [\rx, #0x5]
81                 and     \rd, \rd, #0x60
82                 teq     \rd, #0x60
83                 bne     1002b
84                 .endm
86                 .macro  waituart,rd,rx
87 1001:           ldrb    \rd, [\rx, #0x6]
88                 tst     \rd, #0x10
89                 beq     1001b
90                 .endm
91 #else
92         /* For EBSA285 debugging */
93                 .equ    dc21285_high, ARMCSR_BASE & 0xff000000
94                 .equ    dc21285_low,  ARMCSR_BASE & 0x00ffffff
96                 .macro  addruart,rx
97                 mov     \rx, #dc21285_high
98                 .if     dc21285_low
99                 orr     \rx, \rx, #dc21285_low
100                 .endif
101                 .endm
103                 .macro  senduart,rd,rx
104                 str     \rd, [\rx, #0x160]      @ UARTDR
105                 .endm
107                 .macro  busyuart,rd,rx
108 1001:           ldr     \rd, [\rx, #0x178]      @ UARTFLG
109                 tst     \rd, #1 << 3
110                 bne     1001b
111                 .endm
113                 .macro  waituart,rd,rx
114                 .endm
115 #endif
116 #elif defined(CONFIG_ARCH_NEXUSPCI)
117                 .macro  addruart,rx
118                 ldr     \rx, =0xfff00000
119                 .endm
121                 .macro  senduart,rd,rx
122                 str     \rd, [\rx, #0xc]
123                 .endm
125                 .macro  busyuart,rd,rx
126 1001:           ldr     \rd, [\rx, #0x4]
127                 tst     \rd, #1 << 0
128                 bne     1001b
129                 .endm
131                 .macro  waituart,rd,rx
132                 .endm
134 #elif defined(CONFIG_ARCH_SA1100)
135                 .macro  addruart,rx
136                 mov     \rx, #0xf8000000
137                 add     \rx, \rx, #0x00050000   @ Ser3
138                 @add    \rx, \rx, #0x00010000   @ Ser1
139                 .endm
141                 .macro  senduart,rd,rx
142                 str     \rd, [\rx, #0x14]       @ UTDR
143                 .endm
145                 .macro  waituart,rd,rx
146 1001:           ldr     \rd, [\rx, #0x20]       @ UTSR1
147                 tst     \rd, #1 << 2            @ UTSR1_TNF
148                 beq     1001b
149                 .endm
151                 .macro  busyuart,rd,rx
152 1001:           ldr     \rd, [\rx, #0x20]       @ UTSR1
153                 tst     \rd, #1 << 0            @ UTSR1_TBY
154                 bne     1001b
155                 .endm
157 #else
158 #error Unknown architecture
159 #endif
162  * Useful debugging routines
163  */
164 ENTRY(printhex8)
165                 mov     r1, #8
166                 b       printhex
168 ENTRY(printhex4)
169                 mov     r1, #4
170                 b       printhex
172 ENTRY(printhex2)
173                 mov     r1, #2
174 printhex:       ldr     r2, =hexbuf
175                 add     r3, r2, r1
176                 mov     r1, #0
177                 strb    r1, [r3]
178 1:              and     r1, r0, #15
179                 mov     r0, r0, lsr #4
180                 cmp     r1, #10
181                 addlt   r1, r1, #'0'
182                 addge   r1, r1, #'a' - 10
183                 strb    r1, [r3, #-1]!
184                 teq     r3, r2
185                 bne     1b
186                 mov     r0, r2
187                 b       printascii
189                 .ltorg
191 ENTRY(printascii)
192                 addruart r3
193                 b       2f
194 1:              waituart r2, r3
195                 senduart r1, r3
196                 busyuart r2, r3
197                 teq     r1, #'\n'
198                 moveq   r1, #'\r'
199                 beq     1b
200 2:              teq     r0, #0
201                 ldrneb  r1, [r0], #1
202                 teqne   r1, #0
203                 bne     1b
204                 mov     pc, lr
206 ENTRY(printch)
207                 addruart r3
208                 mov     r1, r0
209                 mov     r0, #0
210                 b       1b
212                 .bss
213 hexbuf:         .space 16