1/* SPDX-License-Identifier: GPL-2.0 */
2#include <linux/linkage.h>
3#include <asm/assembler.h>
4
5#ifndef CONFIG_DEBUG_SEMIHOSTING
6
7#include CONFIG_DEBUG_LL_INCLUDE
8
9ENTRY(putc)
10	addruart r1, r2, r3
11#ifdef CONFIG_DEBUG_UART_FLOW_CONTROL
12	waituartcts r3, r1
13#endif
14	waituarttxrdy r3, r1
15	senduart r0, r1
16	busyuart r3, r1
17	mov	 pc, lr
18ENDPROC(putc)
19
20#else
21
22ENTRY(putc)
23	adr	r1, 1f
24	ldmia	r1, {r2, r3}
25	add	r2, r2, r1
26	ldr	r1, [r2, r3]
27	strb	r0, [r1]
28	mov	r0, #0x03		@ SYS_WRITEC
29   ARM(	svc	#0x123456	)
30#ifdef CONFIG_CPU_V7M
31 THUMB(	bkpt	#0xab		)
32#else
33 THUMB(	svc	#0xab		)
34#endif
35	mov	pc, lr
36	.align	2
371:	.word	_GLOBAL_OFFSET_TABLE_ - .
38	.word	semi_writec_buf(GOT)
39ENDPROC(putc)
40
41	.bss
42	.global	semi_writec_buf
43	.type   semi_writec_buf, %object
44semi_writec_buf:
45	.space	4
46	.size	semi_writec_buf, 4
47
48#endif
49