xref: /openbmc/linux/arch/arm/lib/io-writesw-armv4.S (revision d9e32672)
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 *  linux/arch/arm/lib/io-writesw-armv4.S
4 *
5 *  Copyright (C) 1995-2000 Russell King
6 */
7#include <linux/linkage.h>
8#include <asm/assembler.h>
9
10		.macro	outword, rd
11#ifndef __ARMEB__
12		strh	\rd, [r0]
13		mov	\rd, \rd, lsr #16
14		strh	\rd, [r0]
15#else
16		mov	lr, \rd, lsr #16
17		strh	lr, [r0]
18		strh	\rd, [r0]
19#endif
20		.endm
21
22.Loutsw_align:	movs	ip, r1, lsl #31
23		bne	.Loutsw_noalign
24
25		ldrh	r3, [r1], #2
26		sub	r2, r2, #1
27		strh	r3, [r0]
28
29ENTRY(__raw_writesw)
30		teq	r2, #0
31		reteq	lr
32		ands	r3, r1, #3
33		bne	.Loutsw_align
34
35		stmfd	sp!, {r4, r5, lr}
36
37		subs	r2, r2, #8
38		bmi	.Lno_outsw_8
39
40.Loutsw_8_lp:	ldmia	r1!, {r3, r4, r5, ip}
41		subs	r2, r2, #8
42		outword	r3
43		outword	r4
44		outword	r5
45		outword	ip
46		bpl	.Loutsw_8_lp
47
48.Lno_outsw_8:	tst	r2, #4
49		beq	.Lno_outsw_4
50
51		ldmia	r1!, {r3, ip}
52		outword	r3
53		outword	ip
54
55.Lno_outsw_4:	movs	r2, r2, lsl #31
56		bcc	.Lno_outsw_2
57
58		ldr	r3, [r1], #4
59		outword	r3
60
61.Lno_outsw_2:	ldrhne	r3, [r1]
62		strhne	r3, [r0]
63
64		ldmfd	sp!, {r4, r5, pc}
65
66#ifdef __ARMEB__
67#define pull_hbyte0	lsl #8
68#define push_hbyte1	lsr #24
69#else
70#define pull_hbyte0	lsr #24
71#define push_hbyte1	lsl #8
72#endif
73
74.Loutsw_noalign:
75 ARM(		ldr	r3, [r1, -r3]!	)
76 THUMB(		rsb	r3, r3, #0	)
77 THUMB(		ldr	r3, [r1, r3]	)
78 THUMB(		sub	r1, r3		)
79		subcs	r2, r2, #1
80		bcs	2f
81		subs	r2, r2, #2
82		bmi	3f
83
841:		mov	ip, r3, lsr #8
85		strh	ip, [r0]
862:		mov	ip, r3, pull_hbyte0
87		ldr	r3, [r1, #4]!
88		subs	r2, r2, #2
89		orr	ip, ip, r3, push_hbyte1
90		strh	ip, [r0]
91		bpl	1b
92
93		tst	r2, #1
943:		movne	ip, r3, lsr #8
95		strhne	ip, [r0]
96		ret	lr
97ENDPROC(__raw_writesw)
98