blob: fa36335944159050eceedba7fcb1505c42e79f15 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
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>
Al Viro4dd18372016-01-13 13:46:22 -050012#include <asm/export.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
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
Nicolas Pitrea9c48142005-11-11 21:51:48 +000034.Loutsb_align: rsb ip, ip, #4
Linus Torvalds1da177e2005-04-16 15:20:36 -070035 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
Nicolas Pitrea9c48142005-11-11 21:51:48 +000045 bne .Loutsb_aligned
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
47ENTRY(__raw_writesb)
48 teq r2, #0 @ do we have to check for the zero len?
Russell King6ebbf2c2014-06-30 16:29:12 +010049 reteq lr
Linus Torvalds1da177e2005-04-16 15:20:36 -070050 ands ip, r1, #3
Nicolas Pitrea9c48142005-11-11 21:51:48 +000051 bne .Loutsb_align
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
Nicolas Pitrea9c48142005-11-11 21:51:48 +000053.Loutsb_aligned:
54 stmfd sp!, {r4, r5, lr}
Linus Torvalds1da177e2005-04-16 15:20:36 -070055
56 subs r2, r2, #16
Nicolas Pitrea9c48142005-11-11 21:51:48 +000057 bmi .Loutsb_no_16
Linus Torvalds1da177e2005-04-16 15:20:36 -070058
Nicolas Pitrea9c48142005-11-11 21:51:48 +000059.Loutsb_16_lp: ldmia r1!, {r3, r4, r5, ip}
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 outword r3
61 outword r4
62 outword r5
63 outword ip
64 subs r2, r2, #16
Nicolas Pitrea9c48142005-11-11 21:51:48 +000065 bpl .Loutsb_16_lp
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
67 tst r2, #15
Russell King1b93a712006-06-25 11:23:45 +010068 ldmeqfd sp!, {r4, r5, pc}
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
Nicolas Pitrea9c48142005-11-11 21:51:48 +000070.Loutsb_no_16: tst r2, #8
71 beq .Loutsb_no_8
Linus Torvalds1da177e2005-04-16 15:20:36 -070072
73 ldmia r1!, {r3, r4}
74 outword r3
75 outword r4
76
Nicolas Pitrea9c48142005-11-11 21:51:48 +000077.Loutsb_no_8: tst r2, #4
78 beq .Loutsb_no_4
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
80 ldr r3, [r1], #4
81 outword r3
82
Nicolas Pitrea9c48142005-11-11 21:51:48 +000083.Loutsb_no_4: ands r2, r2, #3
Russell King1b93a712006-06-25 11:23:45 +010084 ldmeqfd sp!, {r4, r5, pc}
Linus Torvalds1da177e2005-04-16 15:20:36 -070085
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
Russell King1b93a712006-06-25 11:23:45 +010094 ldmfd sp!, {r4, r5, pc}
Catalin Marinas93ed3972008-08-28 11:22:32 +010095ENDPROC(__raw_writesb)
Al Viro4dd18372016-01-13 13:46:22 -050096EXPORT_SYMBOL(__raw_writesb)