blob: af4beb4d9d269125ebc2e400a060ffc354511ab9 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Masahiro Yamada59cbe792014-09-01 11:06:32 +09002/*
3 * linux/arch/arm/kernel/debug.S
4 *
5 * Copyright (C) 1994-1999 Russell King
6 *
Masahiro Yamada59cbe792014-09-01 11:06:32 +09007 * 32-bit debugging code
8 */
9#include <linux/linkage.h>
10#include <asm/assembler.h>
11
12 .text
13
14/*
15 * Some debugging routines (useful if you've got MM problems and
16 * printk isn't working). For DEBUGGING ONLY!!! Do not leave
17 * references to these in a production kernel!
18 */
19
20#if !defined(CONFIG_DEBUG_SEMIHOSTING)
21#include CONFIG_DEBUG_LL_INCLUDE
22#endif
23
Masahiro Yamada59cbe792014-09-01 11:06:32 +090024 .macro addruart_current, rx, tmp1, tmp2
Masahiro Yamada4cb23ab2014-09-01 11:06:35 +090025 addruart \rx, \tmp1, \tmp2
Masahiro Yamada59cbe792014-09-01 11:06:32 +090026 .endm
27
Masahiro Yamada59cbe792014-09-01 11:06:32 +090028/*
29 * Useful debugging routines
30 */
31ENTRY(printhex8)
32 mov r1, #8
33 b printhex
34ENDPROC(printhex8)
35
36ENTRY(printhex4)
37 mov r1, #4
38 b printhex
39ENDPROC(printhex4)
40
41ENTRY(printhex2)
42 mov r1, #2
43printhex: adr r2, hexbuf
44 add r3, r2, r1
45 mov r1, #0
46 strb r1, [r3]
471: and r1, r0, #15
48 mov r0, r0, lsr #4
49 cmp r1, #10
50 addlt r1, r1, #'0'
51 addge r1, r1, #'a' - 10
52 strb r1, [r3, #-1]!
53 teq r3, r2
54 bne 1b
55 mov r0, r2
56 b printascii
57ENDPROC(printhex2)
58
59hexbuf: .space 16
60
61 .ltorg
62
63#ifndef CONFIG_DEBUG_SEMIHOSTING
64
65ENTRY(printascii)
66 addruart_current r3, r1, r2
67 b 2f
681: waituart r2, r3
69 senduart r1, r3
70 busyuart r2, r3
71 teq r1, #'\n'
72 moveq r1, #'\r'
73 beq 1b
742: teq r0, #0
75 ldrneb r1, [r0], #1
76 teqne r1, #0
77 bne 1b
78 mov pc, lr
79ENDPROC(printascii)
80
81ENTRY(printch)
82 addruart_current r3, r1, r2
83 mov r1, r0
84 mov r0, #0
85 b 1b
86ENDPROC(printch)
87
Masahiro Yamada59cbe792014-09-01 11:06:32 +090088#else
89
90ENTRY(printascii)
91 mov r1, r0
92 mov r0, #0x04 @ SYS_WRITE0
93 ARM( svc #0x123456 )
94 THUMB( svc #0xab )
95 mov pc, lr
96ENDPROC(printascii)
97
98ENTRY(printch)
99 adr r1, hexbuf
100 strb r0, [r1]
101 mov r0, #0x03 @ SYS_WRITEC
102 ARM( svc #0x123456 )
103 THUMB( svc #0xab )
104 mov pc, lr
105ENDPROC(printch)
106
107ENTRY(debug_ll_addr)
108 mov r2, #0
109 str r2, [r0]
110 str r2, [r1]
111 mov pc, lr
112ENDPROC(debug_ll_addr)
113
114#endif