blob: 501cdbfc902c3b7968caa450b887ac496abd5ed7 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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 */
Linus Torvalds1da177e2005-04-16 15:20:36 -070012#include <linux/linkage.h>
Rob Herring6f6f6a72012-03-10 10:30:31 -060013#include <asm/assembler.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014
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
Tony Lindgren7d95ded2006-09-20 13:03:34 +010025
Nicolas Pitre639da5e2011-08-31 22:55:46 -040026 .macro addruart, rp, rv, tmp
Tony Lindgren7d95ded2006-09-20 13:03:34 +010027 .endm
28
Stephen Boyddfad5492011-03-23 22:46:15 +010029#if defined(CONFIG_CPU_V6) || defined(CONFIG_CPU_V6K) || defined(CONFIG_CPU_V7)
Jeremy Kerr1ea64612010-07-21 10:40:50 +020030
Tony Lindgren7d95ded2006-09-20 13:03:34 +010031 .macro senduart, rd, rx
32 mcr p14, 0, \rd, c0, c5, 0
33 .endm
34
35 .macro busyuart, rd, rx
361001:
37 mrc p14, 0, \rx, c0, c1, 0
38 tst \rx, #0x20000000
39 beq 1001b
40 .endm
41
42 .macro waituart, rd, rx
43 mov \rd, #0x2000000
441001:
45 subs \rd, \rd, #1
46 bmi 1002f
47 mrc p14, 0, \rx, c0, c1, 0
48 tst \rx, #0x20000000
49 bne 1001b
501002:
51 .endm
52
Jean-Christop PLAGNIOL-VILLARDc633c3c2009-02-25 04:20:40 +010053#elif defined(CONFIG_CPU_XSCALE)
54
Jean-Christop PLAGNIOL-VILLARDc633c3c2009-02-25 04:20:40 +010055 .macro senduart, rd, rx
56 mcr p14, 0, \rd, c8, c0, 0
57 .endm
58
59 .macro busyuart, rd, rx
601001:
61 mrc p14, 0, \rx, c14, c0, 0
62 tst \rx, #0x10000000
63 beq 1001b
64 .endm
65
66 .macro waituart, rd, rx
67 mov \rd, #0x10000000
681001:
69 subs \rd, \rd, #1
70 bmi 1002f
71 mrc p14, 0, \rx, c14, c0, 0
72 tst \rx, #0x10000000
73 bne 1001b
741002:
75 .endm
76
Tony Lindgren7d95ded2006-09-20 13:03:34 +010077#else
78
Linus Torvalds1da177e2005-04-16 15:20:36 -070079 .macro senduart, rd, rx
80 mcr p14, 0, \rd, c1, c0, 0
81 .endm
82
83 .macro busyuart, rd, rx
841001:
85 mrc p14, 0, \rx, c0, c0, 0
86 tst \rx, #2
87 beq 1001b
88
89 .endm
90
91 .macro waituart, rd, rx
92 mov \rd, #0x2000000
931001:
94 subs \rd, \rd, #1
95 bmi 1002f
96 mrc p14, 0, \rx, c0, c0, 0
97 tst \rx, #2
98 bne 1001b
991002:
100 .endm
Tony Lindgren7d95ded2006-09-20 13:03:34 +0100101
102#endif /* CONFIG_CPU_V6 */
103
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104#else
Russell Kinga09e64f2008-08-05 16:14:15 +0100105#include <mach/debug-macro.S>
Tony Lindgren7d95ded2006-09-20 13:03:34 +0100106#endif /* CONFIG_DEBUG_ICEDCC */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107
Jeremy Kerr0ea12932010-07-06 18:30:06 +0800108#ifdef CONFIG_MMU
109 .macro addruart_current, rx, tmp1, tmp2
Nicolas Pitre639da5e2011-08-31 22:55:46 -0400110 addruart \tmp1, \tmp2, \rx
Jeremy Kerr0ea12932010-07-06 18:30:06 +0800111 mrc p15, 0, \rx, c1, c0
112 tst \rx, #1
113 moveq \rx, \tmp1
114 movne \rx, \tmp2
115 .endm
116
117#else /* !CONFIG_MMU */
118 .macro addruart_current, rx, tmp1, tmp2
119 addruart \rx, \tmp1
120 .endm
121
122#endif /* CONFIG_MMU */
123
Linus Torvalds1da177e2005-04-16 15:20:36 -0700124/*
125 * Useful debugging routines
126 */
127ENTRY(printhex8)
128 mov r1, #8
129 b printhex
Catalin Marinas93ed3972008-08-28 11:22:32 +0100130ENDPROC(printhex8)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131
132ENTRY(printhex4)
133 mov r1, #4
134 b printhex
Catalin Marinas93ed3972008-08-28 11:22:32 +0100135ENDPROC(printhex4)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136
137ENTRY(printhex2)
138 mov r1, #2
139printhex: adr r2, hexbuf
140 add r3, r2, r1
141 mov r1, #0
142 strb r1, [r3]
1431: and r1, r0, #15
144 mov r0, r0, lsr #4
145 cmp r1, #10
146 addlt r1, r1, #'0'
147 addge r1, r1, #'a' - 10
148 strb r1, [r3, #-1]!
149 teq r3, r2
150 bne 1b
151 mov r0, r2
152 b printascii
Catalin Marinas93ed3972008-08-28 11:22:32 +0100153ENDPROC(printhex2)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700154
Afzal Mohammedb55fa182011-10-20 19:32:07 +0100155hexbuf: .space 16
156
Linus Torvalds1da177e2005-04-16 15:20:36 -0700157 .ltorg
158
159ENTRY(printascii)
Jeremy Kerr0ea12932010-07-06 18:30:06 +0800160 addruart_current r3, r1, r2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 b 2f
1621: waituart r2, r3
163 senduart r1, r3
164 busyuart r2, r3
165 teq r1, #'\n'
166 moveq r1, #'\r'
167 beq 1b
1682: teq r0, #0
169 ldrneb r1, [r0], #1
170 teqne r1, #0
171 bne 1b
172 mov pc, lr
Catalin Marinas93ed3972008-08-28 11:22:32 +0100173ENDPROC(printascii)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700174
175ENTRY(printch)
Jeremy Kerr0ea12932010-07-06 18:30:06 +0800176 addruart_current r3, r1, r2
Linus Torvalds1da177e2005-04-16 15:20:36 -0700177 mov r1, r0
178 mov r0, #0
179 b 1b
Catalin Marinas93ed3972008-08-28 11:22:32 +0100180ENDPROC(printch)