1/*
2 * linux/arch/unicore32/kernel/debug.S
3 *
4 * Code specific to PKUnity SoC and UniCore ISA
5 *
6 * Copyright (C) 2001-2010 GUAN Xue-tao
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 *  32-bit debugging code
13 */
14#include <linux/linkage.h>
15#include <asm/assembler.h>
16
17		.text
18
19/*
20 * Some debugging routines (useful if you've got MM problems and
21 * printk isn't working).  For DEBUGGING ONLY!!!  Do not leave
22 * references to these in a production kernel!
23 */
24#include "debug-macro.S"
25
26/*
27 * Useful debugging routines
28 */
29ENTRY(printhex8)
30		mov	r1, #8
31		b	printhex
32ENDPROC(printhex8)
33
34ENTRY(printhex4)
35		mov	r1, #4
36		b	printhex
37ENDPROC(printhex4)
38
39ENTRY(printhex2)
40		mov	r1, #2
41printhex:	adr	r2, hexbuf
42		add	r3, r2, r1
43		mov	r1, #0
44		stb	r1, [r3]
451:		and	r1, r0, #15
46		mov	r0, r0 >> #4
47		csub.a	r1, #10
48		beg	2f
49		add	r1, r1, #'0' - 'a' + 10
502:		add	r1, r1, #'a' - 10
51		stb.w	r1, [r3+], #-1
52		cxor.a	r3, r2
53		bne	1b
54		mov	r0, r2
55		b	printascii
56ENDPROC(printhex2)
57
58		.ltorg
59
60ENTRY(printascii)
61		addruart r3
62		b	2f
631:		waituart r2, r3
64		senduart r1, r3
65		busyuart r2, r3
66		cxor.a	r1, #'\n'
67		cmoveq	r1, #'\r'
68		beq	1b
692:		cxor.a	r0, #0
70		beq	3f
71		ldb.w	r1, [r0]+, #1
72		cxor.a	r1, #0
73		bne	1b
743:		mov	pc, lr
75ENDPROC(printascii)
76
77ENTRY(printch)
78		addruart r3
79		mov	r1, r0
80		mov	r0, #0
81		b	1b
82ENDPROC(printch)
83
84hexbuf:		.space 16
85
86