xref: /openbmc/linux/arch/arm/lib/io-writesb.S (revision 6dfcd296)
1/*
2 *  linux/arch/arm/lib/io-writesb.S
3 *
4 *  Copyright (C) 1995-2000 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#include <linux/linkage.h>
11#include <asm/assembler.h>
12#include <asm/export.h>
13
14		.macro	outword, rd
15#ifndef __ARMEB__
16		strb	\rd, [r0]
17		mov	\rd, \rd, lsr #8
18		strb	\rd, [r0]
19		mov	\rd, \rd, lsr #8
20		strb	\rd, [r0]
21		mov	\rd, \rd, lsr #8
22		strb	\rd, [r0]
23#else
24		mov	lr, \rd, lsr #24
25		strb	lr, [r0]
26		mov	lr, \rd, lsr #16
27		strb	lr, [r0]
28		mov	lr, \rd, lsr #8
29		strb	lr, [r0]
30		strb	\rd, [r0]
31#endif
32		.endm
33
34.Loutsb_align:	rsb	ip, ip, #4
35		cmp	ip, r2
36		movgt	ip, r2
37		cmp	ip, #2
38		ldrb	r3, [r1], #1
39		strb	r3, [r0]
40		ldrgeb	r3, [r1], #1
41		strgeb	r3, [r0]
42		ldrgtb	r3, [r1], #1
43		strgtb	r3, [r0]
44		subs	r2, r2, ip
45		bne	.Loutsb_aligned
46
47ENTRY(__raw_writesb)
48		teq	r2, #0		@ do we have to check for the zero len?
49		reteq	lr
50		ands	ip, r1, #3
51		bne	.Loutsb_align
52
53.Loutsb_aligned:
54		stmfd	sp!, {r4, r5, lr}
55
56		subs	r2, r2, #16
57		bmi	.Loutsb_no_16
58
59.Loutsb_16_lp:	ldmia	r1!, {r3, r4, r5, ip}
60		outword	r3
61		outword	r4
62		outword	r5
63		outword	ip
64		subs	r2, r2, #16
65		bpl	.Loutsb_16_lp
66
67		tst	r2, #15
68		ldmeqfd	sp!, {r4, r5, pc}
69
70.Loutsb_no_16:	tst	r2, #8
71		beq	.Loutsb_no_8
72
73		ldmia	r1!, {r3, r4}
74		outword	r3
75		outword	r4
76
77.Loutsb_no_8:	tst	r2, #4
78		beq	.Loutsb_no_4
79
80		ldr	r3, [r1], #4
81		outword	r3
82
83.Loutsb_no_4:	ands	r2, r2, #3
84		ldmeqfd	sp!, {r4, r5, pc}
85
86		cmp	r2, #2
87		ldrb	r3, [r1], #1
88		strb	r3, [r0]
89		ldrgeb	r3, [r1], #1
90		strgeb	r3, [r0]
91		ldrgtb	r3, [r1]
92		strgtb	r3, [r0]
93
94		ldmfd	sp!, {r4, r5, pc}
95ENDPROC(__raw_writesb)
96EXPORT_SYMBOL(__raw_writesb)
97