blob: 7eba2b6cc69f951ffeb54013e1108ed08346ac77 [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>
12
13 .macro outword, rd
14#ifndef __ARMEB__
15 strb \rd, [r0]
16 mov \rd, \rd, lsr #8
17 strb \rd, [r0]
18 mov \rd, \rd, lsr #8
19 strb \rd, [r0]
20 mov \rd, \rd, lsr #8
21 strb \rd, [r0]
22#else
23 mov lr, \rd, lsr #24
24 strb lr, [r0]
25 mov lr, \rd, lsr #16
26 strb lr, [r0]
27 mov lr, \rd, lsr #8
28 strb lr, [r0]
29 strb \rd, [r0]
30#endif
31 .endm
32
Nicolas Pitrea9c48142005-11-11 21:51:48 +000033.Loutsb_align: rsb ip, ip, #4
Linus Torvalds1da177e2005-04-16 15:20:36 -070034 cmp ip, r2
35 movgt ip, r2
36 cmp ip, #2
37 ldrb r3, [r1], #1
38 strb r3, [r0]
39 ldrgeb r3, [r1], #1
40 strgeb r3, [r0]
41 ldrgtb r3, [r1], #1
42 strgtb r3, [r0]
43 subs r2, r2, ip
Nicolas Pitrea9c48142005-11-11 21:51:48 +000044 bne .Loutsb_aligned
Linus Torvalds1da177e2005-04-16 15:20:36 -070045
46ENTRY(__raw_writesb)
47 teq r2, #0 @ do we have to check for the zero len?
48 moveq pc, lr
49 ands ip, r1, #3
Nicolas Pitrea9c48142005-11-11 21:51:48 +000050 bne .Loutsb_align
Linus Torvalds1da177e2005-04-16 15:20:36 -070051
Nicolas Pitrea9c48142005-11-11 21:51:48 +000052.Loutsb_aligned:
53 stmfd sp!, {r4, r5, lr}
Linus Torvalds1da177e2005-04-16 15:20:36 -070054
55 subs r2, r2, #16
Nicolas Pitrea9c48142005-11-11 21:51:48 +000056 bmi .Loutsb_no_16
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
Nicolas Pitrea9c48142005-11-11 21:51:48 +000058.Loutsb_16_lp: ldmia r1!, {r3, r4, r5, ip}
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 outword r3
60 outword r4
61 outword r5
62 outword ip
63 subs r2, r2, #16
Nicolas Pitrea9c48142005-11-11 21:51:48 +000064 bpl .Loutsb_16_lp
Linus Torvalds1da177e2005-04-16 15:20:36 -070065
66 tst r2, #15
Russell King1b93a712006-06-25 11:23:45 +010067 ldmeqfd sp!, {r4, r5, pc}
Linus Torvalds1da177e2005-04-16 15:20:36 -070068
Nicolas Pitrea9c48142005-11-11 21:51:48 +000069.Loutsb_no_16: tst r2, #8
70 beq .Loutsb_no_8
Linus Torvalds1da177e2005-04-16 15:20:36 -070071
72 ldmia r1!, {r3, r4}
73 outword r3
74 outword r4
75
Nicolas Pitrea9c48142005-11-11 21:51:48 +000076.Loutsb_no_8: tst r2, #4
77 beq .Loutsb_no_4
Linus Torvalds1da177e2005-04-16 15:20:36 -070078
79 ldr r3, [r1], #4
80 outword r3
81
Nicolas Pitrea9c48142005-11-11 21:51:48 +000082.Loutsb_no_4: ands r2, r2, #3
Russell King1b93a712006-06-25 11:23:45 +010083 ldmeqfd sp!, {r4, r5, pc}
Linus Torvalds1da177e2005-04-16 15:20:36 -070084
85 cmp r2, #2
86 ldrb r3, [r1], #1
87 strb r3, [r0]
88 ldrgeb r3, [r1], #1
89 strgeb r3, [r0]
90 ldrgtb r3, [r1]
91 strgtb r3, [r0]
92
Russell King1b93a712006-06-25 11:23:45 +010093 ldmfd sp!, {r4, r5, pc}