blob: c31b2f3153f171fd09602aed2ea9cb8c97797f4d [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/arch/arm/lib/io-readsb.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
Nicolas Pitrea9c48142005-11-11 21:51:48 +000013.Linsb_align: rsb ip, ip, #4
Linus Torvalds1da177e2005-04-16 15:20:36 -070014 cmp ip, r2
15 movgt ip, r2
16 cmp ip, #2
17 ldrb r3, [r0]
18 strb r3, [r1], #1
19 ldrgeb r3, [r0]
20 strgeb r3, [r1], #1
21 ldrgtb r3, [r0]
22 strgtb r3, [r1], #1
23 subs r2, r2, ip
Nicolas Pitrea9c48142005-11-11 21:51:48 +000024 bne .Linsb_aligned
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
26ENTRY(__raw_readsb)
27 teq r2, #0 @ do we have to check for the zero len?
Russell King6ebbf2c2014-06-30 16:29:12 +010028 reteq lr
Linus Torvalds1da177e2005-04-16 15:20:36 -070029 ands ip, r1, #3
Nicolas Pitrea9c48142005-11-11 21:51:48 +000030 bne .Linsb_align
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
Nicolas Pitrea9c48142005-11-11 21:51:48 +000032.Linsb_aligned: stmfd sp!, {r4 - r6, lr}
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
34 subs r2, r2, #16
Nicolas Pitrea9c48142005-11-11 21:51:48 +000035 bmi .Linsb_no_16
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
Nicolas Pitrea9c48142005-11-11 21:51:48 +000037.Linsb_16_lp: ldrb r3, [r0]
Linus Torvalds1da177e2005-04-16 15:20:36 -070038 ldrb r4, [r0]
39 ldrb r5, [r0]
40 mov r3, r3, put_byte_0
41 ldrb r6, [r0]
42 orr r3, r3, r4, put_byte_1
43 ldrb r4, [r0]
44 orr r3, r3, r5, put_byte_2
45 ldrb r5, [r0]
46 orr r3, r3, r6, put_byte_3
47 ldrb r6, [r0]
48 mov r4, r4, put_byte_0
49 ldrb ip, [r0]
50 orr r4, r4, r5, put_byte_1
51 ldrb r5, [r0]
52 orr r4, r4, r6, put_byte_2
53 ldrb r6, [r0]
54 orr r4, r4, ip, put_byte_3
55 ldrb ip, [r0]
56 mov r5, r5, put_byte_0
57 ldrb lr, [r0]
58 orr r5, r5, r6, put_byte_1
59 ldrb r6, [r0]
60 orr r5, r5, ip, put_byte_2
61 ldrb ip, [r0]
62 orr r5, r5, lr, put_byte_3
63 ldrb lr, [r0]
64 mov r6, r6, put_byte_0
65 orr r6, r6, ip, put_byte_1
66 ldrb ip, [r0]
67 orr r6, r6, lr, put_byte_2
68 orr r6, r6, ip, put_byte_3
69 stmia r1!, {r3 - r6}
70
71 subs r2, r2, #16
Nicolas Pitrea9c48142005-11-11 21:51:48 +000072 bpl .Linsb_16_lp
Linus Torvalds1da177e2005-04-16 15:20:36 -070073
74 tst r2, #15
Russell King1b93a712006-06-25 11:23:45 +010075 ldmeqfd sp!, {r4 - r6, pc}
Linus Torvalds1da177e2005-04-16 15:20:36 -070076
Nicolas Pitrea9c48142005-11-11 21:51:48 +000077.Linsb_no_16: tst r2, #8
78 beq .Linsb_no_8
Linus Torvalds1da177e2005-04-16 15:20:36 -070079
80 ldrb r3, [r0]
81 ldrb r4, [r0]
82 ldrb r5, [r0]
83 mov r3, r3, put_byte_0
84 ldrb r6, [r0]
85 orr r3, r3, r4, put_byte_1
86 ldrb r4, [r0]
87 orr r3, r3, r5, put_byte_2
88 ldrb r5, [r0]
89 orr r3, r3, r6, put_byte_3
90 ldrb r6, [r0]
91 mov r4, r4, put_byte_0
92 ldrb ip, [r0]
93 orr r4, r4, r5, put_byte_1
94 orr r4, r4, r6, put_byte_2
95 orr r4, r4, ip, put_byte_3
96 stmia r1!, {r3, r4}
97
Nicolas Pitrea9c48142005-11-11 21:51:48 +000098.Linsb_no_8: tst r2, #4
99 beq .Linsb_no_4
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100
101 ldrb r3, [r0]
102 ldrb r4, [r0]
103 ldrb r5, [r0]
104 ldrb r6, [r0]
105 mov r3, r3, put_byte_0
106 orr r3, r3, r4, put_byte_1
107 orr r3, r3, r5, put_byte_2
108 orr r3, r3, r6, put_byte_3
109 str r3, [r1], #4
110
Nicolas Pitrea9c48142005-11-11 21:51:48 +0000111.Linsb_no_4: ands r2, r2, #3
Russell King1b93a712006-06-25 11:23:45 +0100112 ldmeqfd sp!, {r4 - r6, pc}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113
114 cmp r2, #2
115 ldrb r3, [r0]
116 strb r3, [r1], #1
117 ldrgeb r3, [r0]
118 strgeb r3, [r1], #1
119 ldrgtb r3, [r0]
120 strgtb r3, [r1]
121
Russell King1b93a712006-06-25 11:23:45 +0100122 ldmfd sp!, {r4 - r6, pc}
Catalin Marinas93ed3972008-08-28 11:22:32 +0100123ENDPROC(__raw_readsb)