import of upstream 2.4.34.4 from kernel.org
[linux-2.4.git] / arch / arm / kernel / debug-armo.S
1 /*
2  *  linux/arch/arm/kernel/debug-armo.S
3  *
4  *  Copyright (C) 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  *  26-bit debugging code
11  */
12 #include <linux/linkage.h>
13
14                 .macro  addruart,rx
15                 mov     \rx, #0x03000000
16                 orr     \rx, \rx, #0x00010000
17                 orr     \rx, \rx, #0x00000fe0
18                 .endm
19
20                 .macro  senduart,rd,rx
21                 strb    \rd, [\rx]
22                 .endm
23
24                 .macro  busyuart,rd,rx
25 1002:           ldrb    \rd, [\rx, #0x14]
26                 and     \rd, \rd, #0x60
27                 teq     \rd, #0x60
28                 bne     1002b
29                 .endm
30
31                 .macro  waituart,rd,rx
32 1001:           ldrb    \rd, [\rx, #0x18]
33                 tst     \rd, #0x10
34                 beq     1001b
35                 .endm
36
37                 .text
38 /*
39  * Useful debugging routines
40  */
41 ENTRY(printhex8)
42                 mov     r1, #8
43                 b       printhex
44
45 ENTRY(printhex4)
46                 mov     r1, #4
47                 b       printhex
48
49 ENTRY(printhex2)
50                 mov     r1, #2
51 printhex:       ldr     r2, =hexbuf
52                 add     r3, r2, r1
53                 mov     r1, #0
54                 strb    r1, [r3]
55 1:              and     r1, r0, #15
56                 mov     r0, r0, lsr #4
57                 cmp     r1, #10
58                 addlt   r1, r1, #'0'
59                 addge   r1, r1, #'a' - 10
60                 strb    r1, [r3, #-1]!
61                 teq     r3, r2
62                 bne     1b
63                 mov     r0, r2
64                 b       printascii
65
66                 .ltorg
67
68 ENTRY(printascii)
69                 addruart r3
70                 b       2f
71 1:              waituart r2, r3
72                 senduart r1, r3
73                 busyuart r2, r3
74                 teq     r1, #'\n'
75                 moveq   r1, #'\r'
76                 beq     1b
77 2:              teq     r0, #0
78                 ldrneb  r1, [r0], #1
79                 teqne   r1, #0
80                 bne     1b
81                 mov     pc, lr
82
83 ENTRY(printch)
84                 addruart r3
85                 mov     r1, r0
86                 mov     r0, #0
87                 b       1b
88
89                 .bss
90 hexbuf:         .space 16