xref: /openbmc/linux/arch/arm/lib/io-readsw-armv3.S (revision bc5aa3a0)
1/*
2 *  linux/arch/arm/lib/io-readsw-armv3.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
13.Linsw_bad_alignment:
14		adr	r0, .Linsw_bad_align_msg
15		mov	r2, lr
16		b	panic
17.Linsw_bad_align_msg:
18		.asciz	"insw: bad buffer alignment (0x%p, lr=0x%08lX)\n"
19		.align
20
21.Linsw_align:	tst	r1, #1
22		bne	.Linsw_bad_alignment
23
24		ldr	r3, [r0]
25		strb	r3, [r1], #1
26		mov	r3, r3, lsr #8
27		strb	r3, [r1], #1
28
29		subs	r2, r2, #1
30		reteq	lr
31
32ENTRY(__raw_readsw)
33		teq	r2, #0		@ do we have to check for the zero len?
34		reteq	lr
35		tst	r1, #3
36		bne	.Linsw_align
37
38.Linsw_aligned:	mov	ip, #0xff
39		orr	ip, ip, ip, lsl #8
40		stmfd	sp!, {r4, r5, r6, lr}
41
42		subs	r2, r2, #8
43		bmi	.Lno_insw_8
44
45.Linsw_8_lp:	ldr	r3, [r0]
46		and	r3, r3, ip
47		ldr	r4, [r0]
48		orr	r3, r3, r4, lsl #16
49
50		ldr	r4, [r0]
51		and	r4, r4, ip
52		ldr	r5, [r0]
53		orr	r4, r4, r5, lsl #16
54
55		ldr	r5, [r0]
56		and	r5, r5, ip
57		ldr	r6, [r0]
58		orr	r5, r5, r6, lsl #16
59
60		ldr	r6, [r0]
61		and	r6, r6, ip
62		ldr	lr, [r0]
63		orr	r6, r6, lr, lsl #16
64
65		stmia	r1!, {r3 - r6}
66
67		subs	r2, r2, #8
68		bpl	.Linsw_8_lp
69
70		tst	r2, #7
71		ldmeqfd	sp!, {r4, r5, r6, pc}
72
73.Lno_insw_8:	tst	r2, #4
74		beq	.Lno_insw_4
75
76		ldr	r3, [r0]
77		and	r3, r3, ip
78		ldr	r4, [r0]
79		orr	r3, r3, r4, lsl #16
80
81		ldr	r4, [r0]
82		and	r4, r4, ip
83		ldr	r5, [r0]
84		orr	r4, r4, r5, lsl #16
85
86		stmia	r1!, {r3, r4}
87
88.Lno_insw_4:	tst	r2, #2
89		beq	.Lno_insw_2
90
91		ldr	r3, [r0]
92		and	r3, r3, ip
93		ldr	r4, [r0]
94		orr	r3, r3, r4, lsl #16
95
96		str	r3, [r1], #4
97
98.Lno_insw_2:	tst	r2, #1
99		ldrne	r3, [r0]
100		strneb	r3, [r1], #1
101		movne	r3, r3, lsr #8
102		strneb	r3, [r1]
103
104		ldmfd	sp!, {r4, r5, r6, pc}
105
106
107