diff options
Diffstat (limited to 'arch/score/lib')
-rw-r--r-- | arch/score/lib/Makefile | 8 | ||||
-rw-r--r-- | arch/score/lib/ashldi3.c | 46 | ||||
-rw-r--r-- | arch/score/lib/ashrdi3.c | 48 | ||||
-rw-r--r-- | arch/score/lib/checksum.S | 255 | ||||
-rw-r--r-- | arch/score/lib/checksum_copy.c | 52 | ||||
-rw-r--r-- | arch/score/lib/cmpdi2.c | 44 | ||||
-rw-r--r-- | arch/score/lib/libgcc.h | 37 | ||||
-rw-r--r-- | arch/score/lib/lshrdi3.c | 47 | ||||
-rw-r--r-- | arch/score/lib/string.S | 196 | ||||
-rw-r--r-- | arch/score/lib/ucmpdi2.c | 38 |
10 files changed, 771 insertions, 0 deletions
diff --git a/arch/score/lib/Makefile b/arch/score/lib/Makefile new file mode 100644 index 000000000000..553e30e81faf --- /dev/null +++ b/arch/score/lib/Makefile | |||
@@ -0,0 +1,8 @@ | |||
1 | # | ||
2 | # Makefile for SCORE-specific library files.. | ||
3 | # | ||
4 | |||
5 | lib-y += string.o checksum.o checksum_copy.o | ||
6 | |||
7 | # libgcc-style stuff needed in the kernel | ||
8 | obj-y += ashldi3.o ashrdi3.o cmpdi2.o lshrdi3.o ucmpdi2.o | ||
diff --git a/arch/score/lib/ashldi3.c b/arch/score/lib/ashldi3.c new file mode 100644 index 000000000000..15691a910431 --- /dev/null +++ b/arch/score/lib/ashldi3.c | |||
@@ -0,0 +1,46 @@ | |||
1 | /* | ||
2 | * arch/score/lib/ashldi3.c | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, see the file COPYING, or write | ||
16 | * to the Free Software Foundation, Inc., | ||
17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | */ | ||
19 | |||
20 | #include <linux/module.h> | ||
21 | #include "libgcc.h" | ||
22 | |||
23 | long long __ashldi3(long long u, word_type b) | ||
24 | { | ||
25 | DWunion uu, w; | ||
26 | word_type bm; | ||
27 | |||
28 | if (b == 0) | ||
29 | return u; | ||
30 | |||
31 | uu.ll = u; | ||
32 | bm = 32 - b; | ||
33 | |||
34 | if (bm <= 0) { | ||
35 | w.s.low = 0; | ||
36 | w.s.high = (unsigned int) uu.s.low << -bm; | ||
37 | } else { | ||
38 | const unsigned int carries = (unsigned int) uu.s.low >> bm; | ||
39 | |||
40 | w.s.low = (unsigned int) uu.s.low << b; | ||
41 | w.s.high = ((unsigned int) uu.s.high << b) | carries; | ||
42 | } | ||
43 | |||
44 | return w.ll; | ||
45 | } | ||
46 | EXPORT_SYMBOL(__ashldi3); | ||
diff --git a/arch/score/lib/ashrdi3.c b/arch/score/lib/ashrdi3.c new file mode 100644 index 000000000000..d9814a5d8d30 --- /dev/null +++ b/arch/score/lib/ashrdi3.c | |||
@@ -0,0 +1,48 @@ | |||
1 | /* | ||
2 | * arch/score/lib/ashrdi3.c | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, see the file COPYING, or write | ||
16 | * to the Free Software Foundation, Inc., | ||
17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | */ | ||
19 | |||
20 | #include <linux/module.h> | ||
21 | #include "libgcc.h" | ||
22 | |||
23 | long long __ashrdi3(long long u, word_type b) | ||
24 | { | ||
25 | DWunion uu, w; | ||
26 | word_type bm; | ||
27 | |||
28 | if (b == 0) | ||
29 | return u; | ||
30 | |||
31 | uu.ll = u; | ||
32 | bm = 32 - b; | ||
33 | |||
34 | if (bm <= 0) { | ||
35 | /* w.s.high = 1..1 or 0..0 */ | ||
36 | w.s.high = | ||
37 | uu.s.high >> 31; | ||
38 | w.s.low = uu.s.high >> -bm; | ||
39 | } else { | ||
40 | const unsigned int carries = (unsigned int) uu.s.high << bm; | ||
41 | |||
42 | w.s.high = uu.s.high >> b; | ||
43 | w.s.low = ((unsigned int) uu.s.low >> b) | carries; | ||
44 | } | ||
45 | |||
46 | return w.ll; | ||
47 | } | ||
48 | EXPORT_SYMBOL(__ashrdi3); | ||
diff --git a/arch/score/lib/checksum.S b/arch/score/lib/checksum.S new file mode 100644 index 000000000000..706157edc7d5 --- /dev/null +++ b/arch/score/lib/checksum.S | |||
@@ -0,0 +1,255 @@ | |||
1 | /* | ||
2 | * arch/score/lib/csum_partial.S | ||
3 | * | ||
4 | * Score Processor version. | ||
5 | * | ||
6 | * Copyright (C) 2009 Sunplus Core Technology Co., Ltd. | ||
7 | * Lennox Wu <lennox.wu@sunplusct.com> | ||
8 | * Chen Liqin <liqin.chen@sunplusct.com> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, see the file COPYING, or write | ||
22 | * to the Free Software Foundation, Inc., | ||
23 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
24 | */ | ||
25 | #include <linux/linkage.h> | ||
26 | |||
27 | #define ADDC(sum,reg) \ | ||
28 | add sum, sum, reg; \ | ||
29 | cmp.c reg, sum; \ | ||
30 | bleu 9f; \ | ||
31 | addi sum, 0x1; \ | ||
32 | 9: | ||
33 | |||
34 | #define CSUM_BIGCHUNK(src, offset, sum) \ | ||
35 | lw r8, [src, offset + 0x00]; \ | ||
36 | lw r9, [src, offset + 0x04]; \ | ||
37 | lw r10, [src, offset + 0x08]; \ | ||
38 | lw r11, [src, offset + 0x0c]; \ | ||
39 | ADDC(sum, r8); \ | ||
40 | ADDC(sum, r9); \ | ||
41 | ADDC(sum, r10); \ | ||
42 | ADDC(sum, r11); \ | ||
43 | lw r8, [src, offset + 0x10]; \ | ||
44 | lw r9, [src, offset + 0x14]; \ | ||
45 | lw r10, [src, offset + 0x18]; \ | ||
46 | lw r11, [src, offset + 0x1c]; \ | ||
47 | ADDC(sum, r8); \ | ||
48 | ADDC(sum, r9); \ | ||
49 | ADDC(sum, r10); \ | ||
50 | ADDC(sum, r11); \ | ||
51 | |||
52 | #define src r4 | ||
53 | #define dest r5 | ||
54 | #define sum r27 | ||
55 | |||
56 | .text | ||
57 | /* unknown src alignment and < 8 bytes to go */ | ||
58 | small_csumcpy: | ||
59 | mv r5, r10 | ||
60 | ldi r9, 0x0 | ||
61 | cmpi.c r25, 0x1 | ||
62 | beq pass_small_set_t7 /*already set, jump to pass_small_set_t7*/ | ||
63 | andri.c r25,r4 , 0x1 /*Is src 2 bytes aligned?*/ | ||
64 | |||
65 | pass_small_set_t7: | ||
66 | beq aligned | ||
67 | cmpi.c r5, 0x0 | ||
68 | beq fold | ||
69 | lbu r9, [src] | ||
70 | slli r9,r9, 0x8 /*Little endian*/ | ||
71 | ADDC(sum, r9) | ||
72 | addi src, 0x1 | ||
73 | subi.c r5, 0x1 | ||
74 | |||
75 | /*len still a full word */ | ||
76 | aligned: | ||
77 | andri.c r8, r5, 0x4 /*Len >= 4?*/ | ||
78 | beq len_less_4bytes | ||
79 | |||
80 | /* Still a full word (4byte) to go,and the src is word aligned.*/ | ||
81 | andri.c r8, src, 0x3 /*src is 4bytes aligned, so use LW!!*/ | ||
82 | beq four_byte_aligned | ||
83 | lhu r9, [src] | ||
84 | addi src, 2 | ||
85 | ADDC(sum, r9) | ||
86 | lhu r9, [src] | ||
87 | addi src, 2 | ||
88 | ADDC(sum, r9) | ||
89 | b len_less_4bytes | ||
90 | |||
91 | four_byte_aligned: /* Len >=4 and four byte aligned */ | ||
92 | lw r9, [src] | ||
93 | addi src, 4 | ||
94 | ADDC(sum, r9) | ||
95 | |||
96 | len_less_4bytes: /* 2 byte aligned aligned and length<4B */ | ||
97 | andri.c r8, r5, 0x2 | ||
98 | beq len_less_2bytes | ||
99 | lhu r9, [src] | ||
100 | addi src, 0x2 /* src+=2 */ | ||
101 | ADDC(sum, r9) | ||
102 | |||
103 | len_less_2bytes: /* len = 1 */ | ||
104 | andri.c r8, r5, 0x1 | ||
105 | beq fold /* less than 2 and not equal 1--> len=0 -> fold */ | ||
106 | lbu r9, [src] | ||
107 | |||
108 | fold_ADDC: | ||
109 | ADDC(sum, r9) | ||
110 | fold: | ||
111 | /* fold checksum */ | ||
112 | slli r26, sum, 16 | ||
113 | add sum, sum, r26 | ||
114 | cmp.c r26, sum | ||
115 | srli sum, sum, 16 | ||
116 | bleu 1f /* if r26<=sum */ | ||
117 | addi sum, 0x1 /* r26>sum */ | ||
118 | 1: | ||
119 | /* odd buffer alignment? r25 was set in csum_partial */ | ||
120 | cmpi.c r25, 0x0 | ||
121 | beq 1f | ||
122 | slli r26, sum, 8 | ||
123 | srli sum, sum, 8 | ||
124 | or sum, sum, r26 | ||
125 | andi sum, 0xffff | ||
126 | 1: | ||
127 | .set optimize | ||
128 | /* Add the passed partial csum. */ | ||
129 | ADDC(sum, r6) | ||
130 | mv r4, sum | ||
131 | br r3 | ||
132 | .set volatile | ||
133 | |||
134 | .align 5 | ||
135 | ENTRY(csum_partial) | ||
136 | ldi sum, 0 | ||
137 | ldi r25, 0 | ||
138 | mv r10, r5 | ||
139 | cmpi.c r5, 0x8 | ||
140 | blt small_csumcpy /* < 8(singed) bytes to copy */ | ||
141 | cmpi.c r5, 0x0 | ||
142 | beq out | ||
143 | andri.c r25, src, 0x1 /* odd buffer? */ | ||
144 | |||
145 | beq word_align | ||
146 | hword_align: /* 1 byte */ | ||
147 | lbu r8, [src] | ||
148 | subi r5, 0x1 | ||
149 | slli r8, r8, 8 | ||
150 | ADDC(sum, r8) | ||
151 | addi src, 0x1 | ||
152 | |||
153 | word_align: /* 2 bytes */ | ||
154 | andri.c r8, src, 0x2 /* 4bytes(dword)_aligned? */ | ||
155 | beq dword_align /* not, maybe dword_align */ | ||
156 | lhu r8, [src] | ||
157 | subi r5, 0x2 | ||
158 | ADDC(sum, r8) | ||
159 | addi src, 0x2 | ||
160 | |||
161 | dword_align: /* 4bytes */ | ||
162 | mv r26, r5 /* maybe useless when len >=56 */ | ||
163 | ldi r8, 56 | ||
164 | cmp.c r8, r5 | ||
165 | bgtu do_end_words /* if a1(len)<t0(56) ,unsigned */ | ||
166 | andri.c r26, src, 0x4 | ||
167 | beq qword_align | ||
168 | lw r8, [src] | ||
169 | subi r5, 0x4 | ||
170 | ADDC(sum, r8) | ||
171 | addi src, 0x4 | ||
172 | |||
173 | qword_align: /* 8 bytes */ | ||
174 | andri.c r26, src, 0x8 | ||
175 | beq oword_align | ||
176 | lw r8, [src, 0x0] | ||
177 | lw r9, [src, 0x4] | ||
178 | subi r5, 0x8 /* len-=0x8 */ | ||
179 | ADDC(sum, r8) | ||
180 | ADDC(sum, r9) | ||
181 | addi src, 0x8 | ||
182 | |||
183 | oword_align: /* 16bytes */ | ||
184 | andri.c r26, src, 0x10 | ||
185 | beq begin_movement | ||
186 | lw r10, [src, 0x08] | ||
187 | lw r11, [src, 0x0c] | ||
188 | lw r8, [src, 0x00] | ||
189 | lw r9, [src, 0x04] | ||
190 | ADDC(sum, r10) | ||
191 | ADDC(sum, r11) | ||
192 | ADDC(sum, r8) | ||
193 | ADDC(sum, r9) | ||
194 | subi r5, 0x10 | ||
195 | addi src, 0x10 | ||
196 | |||
197 | begin_movement: | ||
198 | srli.c r26, r5, 0x7 /* len>=128? */ | ||
199 | beq 1f /* len<128 */ | ||
200 | |||
201 | /* r26 is the result that computed in oword_align */ | ||
202 | move_128bytes: | ||
203 | CSUM_BIGCHUNK(src, 0x00, sum) | ||
204 | CSUM_BIGCHUNK(src, 0x20, sum) | ||
205 | CSUM_BIGCHUNK(src, 0x40, sum) | ||
206 | CSUM_BIGCHUNK(src, 0x60, sum) | ||
207 | subi.c r26, 0x01 /* r26 equals len/128 */ | ||
208 | addi src, 0x80 | ||
209 | bne move_128bytes | ||
210 | |||
211 | 1: /* len<128,we process 64byte here */ | ||
212 | andri.c r10, r5, 0x40 | ||
213 | beq 1f | ||
214 | |||
215 | move_64bytes: | ||
216 | CSUM_BIGCHUNK(src, 0x00, sum) | ||
217 | CSUM_BIGCHUNK(src, 0x20, sum) | ||
218 | addi src, 0x40 | ||
219 | |||
220 | 1: /* len<64 */ | ||
221 | andri r26, r5, 0x1c /* 0x1c=28 */ | ||
222 | andri.c r10, r5, 0x20 | ||
223 | beq do_end_words /* decided by andri */ | ||
224 | |||
225 | move_32bytes: | ||
226 | CSUM_BIGCHUNK(src, 0x00, sum) | ||
227 | andri r26, r5, 0x1c | ||
228 | addri src, src, 0x20 | ||
229 | |||
230 | do_end_words: /* len<32 */ | ||
231 | /* r26 was set already in dword_align */ | ||
232 | cmpi.c r26, 0x0 | ||
233 | beq maybe_end_cruft /* len<28 or len<56 */ | ||
234 | srli r26, r26, 0x2 | ||
235 | |||
236 | end_words: | ||
237 | lw r8, [src] | ||
238 | subi.c r26, 0x1 /* unit is 4 byte */ | ||
239 | ADDC(sum, r8) | ||
240 | addi src, 0x4 | ||
241 | cmpi.c r26, 0x0 | ||
242 | bne end_words /* r26!=0 */ | ||
243 | |||
244 | maybe_end_cruft: /* len<4 */ | ||
245 | andri r10, r5, 0x3 | ||
246 | |||
247 | small_memcpy: | ||
248 | mv r5, r10 | ||
249 | j small_csumcpy | ||
250 | |||
251 | out: | ||
252 | mv r4, sum | ||
253 | br r3 | ||
254 | |||
255 | END(csum_partial) | ||
diff --git a/arch/score/lib/checksum_copy.c b/arch/score/lib/checksum_copy.c new file mode 100644 index 000000000000..04565dd3ded8 --- /dev/null +++ b/arch/score/lib/checksum_copy.c | |||
@@ -0,0 +1,52 @@ | |||
1 | /* | ||
2 | * arch/score/lib/csum_partial_copy.c | ||
3 | * | ||
4 | * Score Processor version. | ||
5 | * | ||
6 | * Copyright (C) 2009 Sunplus Core Technology Co., Ltd. | ||
7 | * Lennox Wu <lennox.wu@sunplusct.com> | ||
8 | * Chen Liqin <liqin.chen@sunplusct.com> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, see the file COPYING, or write | ||
22 | * to the Free Software Foundation, Inc., | ||
23 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
24 | */ | ||
25 | |||
26 | #include <net/checksum.h> | ||
27 | |||
28 | #include <asm/uaccess.h> | ||
29 | |||
30 | unsigned int csum_partial_copy(const char *src, char *dst, | ||
31 | int len, unsigned int sum) | ||
32 | { | ||
33 | sum = csum_partial(src, len, sum); | ||
34 | memcpy(dst, src, len); | ||
35 | |||
36 | return sum; | ||
37 | } | ||
38 | |||
39 | unsigned int csum_partial_copy_from_user(const char *src, char *dst, | ||
40 | int len, unsigned int sum, | ||
41 | int *err_ptr) | ||
42 | { | ||
43 | int missing; | ||
44 | |||
45 | missing = copy_from_user(dst, src, len); | ||
46 | if (missing) { | ||
47 | memset(dst + len - missing, 0, missing); | ||
48 | *err_ptr = -EFAULT; | ||
49 | } | ||
50 | |||
51 | return csum_partial(dst, len, sum); | ||
52 | } | ||
diff --git a/arch/score/lib/cmpdi2.c b/arch/score/lib/cmpdi2.c new file mode 100644 index 000000000000..1ed5290c66ed --- /dev/null +++ b/arch/score/lib/cmpdi2.c | |||
@@ -0,0 +1,44 @@ | |||
1 | /* | ||
2 | * arch/score/lib/cmpdi2.c | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, see the file COPYING, or write | ||
16 | * to the Free Software Foundation, Inc., | ||
17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | */ | ||
19 | |||
20 | #include <linux/module.h> | ||
21 | #include "libgcc.h" | ||
22 | |||
23 | word_type __cmpdi2(long long a, long long b) | ||
24 | { | ||
25 | const DWunion au = { | ||
26 | .ll = a | ||
27 | }; | ||
28 | const DWunion bu = { | ||
29 | .ll = b | ||
30 | }; | ||
31 | |||
32 | if (au.s.high < bu.s.high) | ||
33 | return 0; | ||
34 | else if (au.s.high > bu.s.high) | ||
35 | return 2; | ||
36 | |||
37 | if ((unsigned int) au.s.low < (unsigned int) bu.s.low) | ||
38 | return 0; | ||
39 | else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) | ||
40 | return 2; | ||
41 | |||
42 | return 1; | ||
43 | } | ||
44 | EXPORT_SYMBOL(__cmpdi2); | ||
diff --git a/arch/score/lib/libgcc.h b/arch/score/lib/libgcc.h new file mode 100644 index 000000000000..0f12543d9f31 --- /dev/null +++ b/arch/score/lib/libgcc.h | |||
@@ -0,0 +1,37 @@ | |||
1 | /* | ||
2 | * arch/score/lib/libgcc.h | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, see the file COPYING, or write | ||
16 | * to the Free Software Foundation, Inc., | ||
17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | */ | ||
19 | |||
20 | |||
21 | #ifndef __ASM_LIBGCC_H | ||
22 | #define __ASM_LIBGCC_H | ||
23 | |||
24 | #include <asm/byteorder.h> | ||
25 | |||
26 | typedef int word_type __attribute__((mode(__word__))); | ||
27 | |||
28 | struct DWstruct { | ||
29 | int low, high; | ||
30 | }; | ||
31 | |||
32 | typedef union { | ||
33 | struct DWstruct s; | ||
34 | long long ll; | ||
35 | } DWunion; | ||
36 | |||
37 | #endif /* __ASM_LIBGCC_H */ | ||
diff --git a/arch/score/lib/lshrdi3.c b/arch/score/lib/lshrdi3.c new file mode 100644 index 000000000000..ce21175fd791 --- /dev/null +++ b/arch/score/lib/lshrdi3.c | |||
@@ -0,0 +1,47 @@ | |||
1 | /* | ||
2 | * arch/score/lib/lshrdi3.c | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, see the file COPYING, or write | ||
16 | * to the Free Software Foundation, Inc., | ||
17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | */ | ||
19 | |||
20 | |||
21 | #include <linux/module.h> | ||
22 | #include "libgcc.h" | ||
23 | |||
24 | long long __lshrdi3(long long u, word_type b) | ||
25 | { | ||
26 | DWunion uu, w; | ||
27 | word_type bm; | ||
28 | |||
29 | if (b == 0) | ||
30 | return u; | ||
31 | |||
32 | uu.ll = u; | ||
33 | bm = 32 - b; | ||
34 | |||
35 | if (bm <= 0) { | ||
36 | w.s.high = 0; | ||
37 | w.s.low = (unsigned int) uu.s.high >> -bm; | ||
38 | } else { | ||
39 | const unsigned int carries = (unsigned int) uu.s.high << bm; | ||
40 | |||
41 | w.s.high = (unsigned int) uu.s.high >> b; | ||
42 | w.s.low = ((unsigned int) uu.s.low >> b) | carries; | ||
43 | } | ||
44 | |||
45 | return w.ll; | ||
46 | } | ||
47 | EXPORT_SYMBOL(__lshrdi3); | ||
diff --git a/arch/score/lib/string.S b/arch/score/lib/string.S new file mode 100644 index 000000000000..943d0911ea89 --- /dev/null +++ b/arch/score/lib/string.S | |||
@@ -0,0 +1,196 @@ | |||
1 | /* | ||
2 | * arch/score/lib/string.S | ||
3 | * | ||
4 | * Score Processor version. | ||
5 | * | ||
6 | * Copyright (C) 2009 Sunplus Core Technology Co., Ltd. | ||
7 | * Chen Liqin <liqin.chen@sunplusct.com> | ||
8 | * Lennox Wu <lennox.wu@sunplusct.com> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * GNU General Public License for more details. | ||
19 | * | ||
20 | * You should have received a copy of the GNU General Public License | ||
21 | * along with this program; if not, see the file COPYING, or write | ||
22 | * to the Free Software Foundation, Inc., | ||
23 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
24 | */ | ||
25 | |||
26 | #include <linux/linkage.h> | ||
27 | #include <asm-generic/errno.h> | ||
28 | |||
29 | .text | ||
30 | .align 2 | ||
31 | ENTRY(__strncpy_from_user) | ||
32 | cmpi.c r6, 0 | ||
33 | mv r9, r6 | ||
34 | ble .L2 | ||
35 | 0: lbu r7, [r5] | ||
36 | ldi r8, 0 | ||
37 | 1: sb r7, [r4] | ||
38 | 2: lb r6, [r5] | ||
39 | cmp.c r6, r8 | ||
40 | beq .L2 | ||
41 | |||
42 | .L5: | ||
43 | addi r8, 1 | ||
44 | cmp.c r8, r9 | ||
45 | beq .L7 | ||
46 | 3: lbu r6, [r5, 1]+ | ||
47 | 4: sb r6, [r4, 1]+ | ||
48 | 5: lb r7, [r5] | ||
49 | cmpi.c r7, 0 | ||
50 | bne .L5 | ||
51 | .L7: | ||
52 | mv r4, r8 | ||
53 | br r3 | ||
54 | .L2: | ||
55 | ldi r8, 0 | ||
56 | mv r4, r8 | ||
57 | br r3 | ||
58 | .section .fixup, "ax" | ||
59 | 99: | ||
60 | ldi r4, -EFAULT | ||
61 | br r3 | ||
62 | .previous | ||
63 | .section __ex_table, "a" | ||
64 | .align 2 | ||
65 | .word 0b ,99b | ||
66 | .word 1b ,99b | ||
67 | .word 2b ,99b | ||
68 | .word 3b ,99b | ||
69 | .word 4b ,99b | ||
70 | .word 5b ,99b | ||
71 | .previous | ||
72 | |||
73 | .align 2 | ||
74 | ENTRY(__strnlen_user) | ||
75 | cmpi.c r5, 0 | ||
76 | ble .L11 | ||
77 | 0: lb r6, [r4] | ||
78 | ldi r7, 0 | ||
79 | cmp.c r6, r7 | ||
80 | beq .L11 | ||
81 | .L15: | ||
82 | addi r7, 1 | ||
83 | cmp.c r7, r5 | ||
84 | beq .L23 | ||
85 | 1: lb r6, [r4,1]+ | ||
86 | cmpi.c r6, 0 | ||
87 | bne .L15 | ||
88 | .L23: | ||
89 | addri r4, r7, 1 | ||
90 | br r3 | ||
91 | |||
92 | .L11: | ||
93 | ldi r4, 1 | ||
94 | br r3 | ||
95 | .section .fixup, "ax" | ||
96 | 99: | ||
97 | ldi r4, 0 | ||
98 | br r3 | ||
99 | |||
100 | .section __ex_table,"a" | ||
101 | .align 2 | ||
102 | .word 0b, 99b | ||
103 | .word 1b, 99b | ||
104 | .previous | ||
105 | |||
106 | .align 2 | ||
107 | ENTRY(__strlen_user) | ||
108 | 0: lb r6, [r4] | ||
109 | mv r7, r4 | ||
110 | extsb r6, r6 | ||
111 | cmpi.c r6, 0 | ||
112 | mv r4, r6 | ||
113 | beq .L27 | ||
114 | .L28: | ||
115 | 1: lb r6, [r7, 1]+ | ||
116 | addi r6, 1 | ||
117 | cmpi.c r6, 0 | ||
118 | bne .L28 | ||
119 | .L27: | ||
120 | br r3 | ||
121 | .section .fixup, "ax" | ||
122 | ldi r4, 0x0 | ||
123 | br r3 | ||
124 | 99: | ||
125 | ldi r4, 0 | ||
126 | br r3 | ||
127 | .previous | ||
128 | .section __ex_table, "a" | ||
129 | .align 2 | ||
130 | .word 0b ,99b | ||
131 | .word 1b ,99b | ||
132 | .previous | ||
133 | |||
134 | .align 2 | ||
135 | ENTRY(__copy_tofrom_user) | ||
136 | cmpi.c r6, 0 | ||
137 | mv r10,r6 | ||
138 | beq .L32 | ||
139 | ldi r9, 0 | ||
140 | .L34: | ||
141 | add r6, r5, r9 | ||
142 | 0: lbu r8, [r6] | ||
143 | add r7, r4, r9 | ||
144 | 1: sb r8, [r7] | ||
145 | addi r9, 1 | ||
146 | cmp.c r9, r10 | ||
147 | bne .L34 | ||
148 | .L32: | ||
149 | ldi r4, 0 | ||
150 | br r3 | ||
151 | .section .fixup, "ax" | ||
152 | 99: | ||
153 | sub r4, r10, r9 | ||
154 | br r3 | ||
155 | .previous | ||
156 | .section __ex_table, "a" | ||
157 | .align 2 | ||
158 | .word 0b, 99b | ||
159 | .word 1b, 99b | ||
160 | .previous | ||
161 | |||
162 | .align 2 | ||
163 | ENTRY(__clear_user) | ||
164 | cmpi.c r5, 0 | ||
165 | beq .L38 | ||
166 | ldi r6, 0 | ||
167 | mv r7, r6 | ||
168 | .L40: | ||
169 | addi r6, 1 | ||
170 | 0: sb r7, [r4]+, 1 | ||
171 | cmp.c r6, r5 | ||
172 | bne .L40 | ||
173 | .L38: | ||
174 | ldi r4, 0 | ||
175 | br r3 | ||
176 | |||
177 | .section .fixup, "ax" | ||
178 | br r3 | ||
179 | .previous | ||
180 | .section __ex_table, "a" | ||
181 | .align 2 | ||
182 | 99: | ||
183 | .word 0b, 99b | ||
184 | .previous | ||
185 | |||
186 | .align 2 | ||
187 | ENTRY(__put_user_unknown) | ||
188 | .set volatile | ||
189 | ldi r4, -EFAULT | ||
190 | br r3 | ||
191 | |||
192 | .align 2 | ||
193 | ENTRY(__get_user_unknown) | ||
194 | ldi r5, 0 | ||
195 | ldi r4, -EFAULT | ||
196 | br r3 | ||
diff --git a/arch/score/lib/ucmpdi2.c b/arch/score/lib/ucmpdi2.c new file mode 100644 index 000000000000..b15241e0b079 --- /dev/null +++ b/arch/score/lib/ucmpdi2.c | |||
@@ -0,0 +1,38 @@ | |||
1 | /* | ||
2 | * arch/score/lib/ucmpdi2.c | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, see the file COPYING, or write | ||
16 | * to the Free Software Foundation, Inc., | ||
17 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
18 | */ | ||
19 | |||
20 | #include <linux/module.h> | ||
21 | #include "libgcc.h" | ||
22 | |||
23 | word_type __ucmpdi2(unsigned long long a, unsigned long long b) | ||
24 | { | ||
25 | const DWunion au = {.ll = a}; | ||
26 | const DWunion bu = {.ll = b}; | ||
27 | |||
28 | if ((unsigned int) au.s.high < (unsigned int) bu.s.high) | ||
29 | return 0; | ||
30 | else if ((unsigned int) au.s.high > (unsigned int) bu.s.high) | ||
31 | return 2; | ||
32 | if ((unsigned int) au.s.low < (unsigned int) bu.s.low) | ||
33 | return 0; | ||
34 | else if ((unsigned int) au.s.low > (unsigned int) bu.s.low) | ||
35 | return 2; | ||
36 | return 1; | ||
37 | } | ||
38 | EXPORT_SYMBOL(__ucmpdi2); | ||