m68knommu: move ColdFire pit.c to its own coldfire directory
[wrt350n-kernel.git] / arch / arm / kernel / debug.S
blob5617566477b493d5cc6034a8518b8f6e696195f3
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>
14                 .text
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  */
22 #if defined(CONFIG_DEBUG_ICEDCC)
23                 @@ debug using ARM EmbeddedICE DCC channel
25 #if defined(CONFIG_CPU_V6)
27                 .macro  addruart, rx
28                 .endm
30                 .macro  senduart, rd, rx
31                 mcr     p14, 0, \rd, c0, c5, 0
32                 .endm
34                 .macro  busyuart, rd, rx
35 1001:
36                 mrc     p14, 0, \rx, c0, c1, 0
37                 tst     \rx, #0x20000000
38                 beq     1001b
39                 .endm
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
52 #else
54                 .macro  addruart, rx
55                 .endm
57                 .macro  senduart, rd, rx
58                 mcr     p14, 0, \rd, c1, c0, 0
59                 .endm
61                 .macro  busyuart, rd, rx
62 1001:
63                 mrc     p14, 0, \rx, c0, c0, 0
64                 tst     \rx, #2
65                 beq     1001b
67                 .endm
69                 .macro  waituart, rd, rx
70                 mov     \rd, #0x2000000
71 1001:
72                 subs    \rd, \rd, #1
73                 bmi     1002f
74                 mrc     p14, 0, \rx, c0, c0, 0
75                 tst     \rx, #2
76                 bne     1001b
77 1002:
78                 .endm
80 #endif  /* CONFIG_CPU_V6 */
82 #else
83 #include <asm/arch/debug-macro.S>
84 #endif  /* CONFIG_DEBUG_ICEDCC */
87  * Useful debugging routines
88  */
89 ENTRY(printhex8)
90                 mov     r1, #8
91                 b       printhex
93 ENTRY(printhex4)
94                 mov     r1, #4
95                 b       printhex
97 ENTRY(printhex2)
98                 mov     r1, #2
99 printhex:       adr     r2, hexbuf
100                 add     r3, r2, r1
101                 mov     r1, #0
102                 strb    r1, [r3]
103 1:              and     r1, r0, #15
104                 mov     r0, r0, lsr #4
105                 cmp     r1, #10
106                 addlt   r1, r1, #'0'
107                 addge   r1, r1, #'a' - 10
108                 strb    r1, [r3, #-1]!
109                 teq     r3, r2
110                 bne     1b
111                 mov     r0, r2
112                 b       printascii
114                 .ltorg
116 ENTRY(printascii)
117                 addruart r3
118                 b       2f
119 1:              waituart r2, r3
120                 senduart r1, r3
121                 busyuart r2, r3
122                 teq     r1, #'\n'
123                 moveq   r1, #'\r'
124                 beq     1b
125 2:              teq     r0, #0
126                 ldrneb  r1, [r0], #1
127                 teqne   r1, #0
128                 bne     1b
129                 mov     pc, lr
131 ENTRY(printch)
132                 addruart r3
133                 mov     r1, r0
134                 mov     r0, #0
135                 b       1b
137 hexbuf:         .space 16