blob: ddee7c09c8276077d9397f1fc3539afc2d29f58c [file] [log] [blame]
Masahiro Yamada1cfe9fa2014-09-01 11:06:32 +09001/*
2 * linux/arch/arm/kernel/debug.S
3 *
4 * Copyright (C) 1994-1999 Russell King
5 *
Masahiro Yamada93456512014-09-01 11:06:33 +09006 * SPDX-License-Identifier: GPL-2.0+
Masahiro Yamada1cfe9fa2014-09-01 11:06:32 +09007 *
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
37 .endm
38
39#endif /* CONFIG_MMU */
40
41/*
42 * Useful debugging routines
43 */
44ENTRY(printhex8)
45 mov r1, #8
46 b printhex
47ENDPROC(printhex8)
48
49ENTRY(printhex4)
50 mov r1, #4
51 b printhex
52ENDPROC(printhex4)
53
54ENTRY(printhex2)
55 mov r1, #2
56printhex: adr r2, hexbuf
57 add r3, r2, r1
58 mov r1, #0
59 strb r1, [r3]
601: 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
70ENDPROC(printhex2)
71
72hexbuf: .space 16
73
74 .ltorg
75
76#ifndef CONFIG_DEBUG_SEMIHOSTING
77
78ENTRY(printascii)
79 addruart_current r3, r1, r2
80 b 2f
811: waituart r2, r3
82 senduart r1, r3
83 busyuart r2, r3
84 teq r1, #'\n'
85 moveq r1, #'\r'
86 beq 1b
872: teq r0, #0
88 ldrneb r1, [r0], #1
89 teqne r1, #0
90 bne 1b
91 mov pc, lr
92ENDPROC(printascii)
93
94ENTRY(printch)
95 addruart_current r3, r1, r2
96 mov r1, r0
97 mov r0, #0
98 b 1b
99ENDPROC(printch)
100
101#ifdef CONFIG_MMU
102ENTRY(debug_ll_addr)
103 addruart r2, r3, ip
104 str r2, [r0]
105 str r3, [r1]
106 mov pc, lr
107ENDPROC(debug_ll_addr)
108#endif
109
110#else
111
112ENTRY(printascii)
113 mov r1, r0
114 mov r0, #0x04 @ SYS_WRITE0
115 ARM( svc #0x123456 )
116 THUMB( svc #0xab )
117 mov pc, lr
118ENDPROC(printascii)
119
120ENTRY(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
127ENDPROC(printch)
128
129ENTRY(debug_ll_addr)
130 mov r2, #0
131 str r2, [r0]
132 str r2, [r1]
133 mov pc, lr
134ENDPROC(debug_ll_addr)
135
136#endif