Merge git://oss.sgi.com:8090/oss/git/xfs-2.6
[sfrench/cifs-2.6.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/config.h>
13 #include <linux/linkage.h>
14
15                 .text
16
17 /*
18  * Some debugging routines (useful if you've got MM problems and
19  * printk isn't working).  For DEBUGGING ONLY!!!  Do not leave
20  * references to these in a production kernel!
21  */
22
23 #if defined(CONFIG_DEBUG_ICEDCC)
24                 @@ debug using ARM EmbeddedICE DCC channel
25                 .macro  addruart, rx
26                 .endm
27
28                 .macro  senduart, rd, rx
29                 mcr     p14, 0, \rd, c1, c0, 0
30                 .endm
31
32                 .macro  busyuart, rd, rx
33 1001:
34                 mrc     p14, 0, \rx, c0, c0, 0
35                 tst     \rx, #2
36                 beq     1001b
37
38                 .endm
39
40                 .macro  waituart, rd, rx
41                 mov     \rd, #0x2000000
42 1001:
43                 subs    \rd, \rd, #1
44                 bmi     1002f
45                 mrc     p14, 0, \rx, c0, c0, 0
46                 tst     \rx, #2
47                 bne     1001b
48 1002:
49                 .endm
50 #else
51 #include <asm/arch/debug-macro.S>
52 #endif
53
54 /*
55  * Useful debugging routines
56  */
57 ENTRY(printhex8)
58                 mov     r1, #8
59                 b       printhex
60
61 ENTRY(printhex4)
62                 mov     r1, #4
63                 b       printhex
64
65 ENTRY(printhex2)
66                 mov     r1, #2
67 printhex:       adr     r2, hexbuf
68                 add     r3, r2, r1
69                 mov     r1, #0
70                 strb    r1, [r3]
71 1:              and     r1, r0, #15
72                 mov     r0, r0, lsr #4
73                 cmp     r1, #10
74                 addlt   r1, r1, #'0'
75                 addge   r1, r1, #'a' - 10
76                 strb    r1, [r3, #-1]!
77                 teq     r3, r2
78                 bne     1b
79                 mov     r0, r2
80                 b       printascii
81
82                 .ltorg
83
84 ENTRY(printascii)
85                 addruart r3
86                 b       2f
87 1:              waituart r2, r3
88                 senduart r1, r3
89                 busyuart r2, r3
90                 teq     r1, #'\n'
91                 moveq   r1, #'\r'
92                 beq     1b
93 2:              teq     r0, #0
94                 ldrneb  r1, [r0], #1
95                 teqne   r1, #0
96                 bne     1b
97                 mov     pc, lr
98
99 ENTRY(printch)
100                 addruart r3
101                 mov     r1, r0
102                 mov     r0, #0
103                 b       1b
104
105 hexbuf:         .space 16