Merge git://git.denx.de/u-boot-fsl-qoriq
[oweals/u-boot.git] / arch / arm / lib / debug.S
1 /*
2  *  linux/arch/arm/kernel/debug.S
3  *
4  *  Copyright (C) 1994-1999 Russell King
5  *
6  * SPDX-License-Identifier:     GPL-2.0+
7  *
8  *  32-bit debugging code
9  */
10 #include <linux/linkage.h>
11 #include <asm/assembler.h>
12
13                 .text
14
15 /*
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
21 #if !defined(CONFIG_DEBUG_SEMIHOSTING)
22 #include CONFIG_DEBUG_LL_INCLUDE
23 #endif
24
25 #ifdef CONFIG_MMU
26                 .macro  addruart_current, rx, tmp1, tmp2
27                 addruart        \tmp1, \tmp2, \rx
28                 mrc             p15, 0, \rx, c1, c0
29                 tst             \rx, #1
30                 moveq           \rx, \tmp1
31                 movne           \rx, \tmp2
32                 .endm
33
34 #else /* !CONFIG_MMU */
35                 .macro  addruart_current, rx, tmp1, tmp2
36                 addruart        \rx, \tmp1, \tmp2
37                 .endm
38
39 #endif /* CONFIG_MMU */
40
41 /*
42  * Useful debugging routines
43  */
44 ENTRY(printhex8)
45                 mov     r1, #8
46                 b       printhex
47 ENDPROC(printhex8)
48
49 ENTRY(printhex4)
50                 mov     r1, #4
51                 b       printhex
52 ENDPROC(printhex4)
53
54 ENTRY(printhex2)
55                 mov     r1, #2
56 printhex:       adr     r2, hexbuf
57                 add     r3, r2, r1
58                 mov     r1, #0
59                 strb    r1, [r3]
60 1:              and     r1, r0, #15
61                 mov     r0, r0, lsr #4
62                 cmp     r1, #10
63                 addlt   r1, r1, #'0'
64                 addge   r1, r1, #'a' - 10
65                 strb    r1, [r3, #-1]!
66                 teq     r3, r2
67                 bne     1b
68                 mov     r0, r2
69                 b       printascii
70 ENDPROC(printhex2)
71
72 hexbuf:         .space 16
73
74                 .ltorg
75
76 #ifndef CONFIG_DEBUG_SEMIHOSTING
77
78 ENTRY(printascii)
79                 addruart_current r3, r1, r2
80                 b       2f
81 1:              waituart r2, r3
82                 senduart r1, r3
83                 busyuart r2, r3
84                 teq     r1, #'\n'
85                 moveq   r1, #'\r'
86                 beq     1b
87 2:              teq     r0, #0
88                 ldrneb  r1, [r0], #1
89                 teqne   r1, #0
90                 bne     1b
91                 mov     pc, lr
92 ENDPROC(printascii)
93
94 ENTRY(printch)
95                 addruart_current r3, r1, r2
96                 mov     r1, r0
97                 mov     r0, #0
98                 b       1b
99 ENDPROC(printch)
100
101 #ifdef CONFIG_MMU
102 ENTRY(debug_ll_addr)
103                 addruart r2, r3, ip
104                 str     r2, [r0]
105                 str     r3, [r1]
106                 mov     pc, lr
107 ENDPROC(debug_ll_addr)
108 #endif
109
110 #else
111
112 ENTRY(printascii)
113                 mov     r1, r0
114                 mov     r0, #0x04               @ SYS_WRITE0
115         ARM(    svc     #0x123456       )
116         THUMB(  svc     #0xab           )
117                 mov     pc, lr
118 ENDPROC(printascii)
119
120 ENTRY(printch)
121                 adr     r1, hexbuf
122                 strb    r0, [r1]
123                 mov     r0, #0x03               @ SYS_WRITEC
124         ARM(    svc     #0x123456       )
125         THUMB(  svc     #0xab           )
126                 mov     pc, lr
127 ENDPROC(printch)
128
129 ENTRY(debug_ll_addr)
130                 mov     r2, #0
131                 str     r2, [r0]
132                 str     r2, [r1]
133                 mov     pc, lr
134 ENDPROC(debug_ll_addr)
135
136 #endif