aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/lib
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /arch/s390/lib
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'arch/s390/lib')
-rw-r--r--arch/s390/lib/Makefile9
-rw-r--r--arch/s390/lib/delay.c51
-rw-r--r--arch/s390/lib/string.c381
-rw-r--r--arch/s390/lib/uaccess.S210
-rw-r--r--arch/s390/lib/uaccess64.S206
5 files changed, 857 insertions, 0 deletions
diff --git a/arch/s390/lib/Makefile b/arch/s390/lib/Makefile
new file mode 100644
index 000000000000..a8758b1d20a9
--- /dev/null
+++ b/arch/s390/lib/Makefile
@@ -0,0 +1,9 @@
1#
2# Makefile for s390-specific library files..
3#
4
5EXTRA_AFLAGS := -traditional
6
7lib-y += delay.o string.o
8lib-$(CONFIG_ARCH_S390_31) += uaccess.o
9lib-$(CONFIG_ARCH_S390X) += uaccess64.o
diff --git a/arch/s390/lib/delay.c b/arch/s390/lib/delay.c
new file mode 100644
index 000000000000..e96c35bddac7
--- /dev/null
+++ b/arch/s390/lib/delay.c
@@ -0,0 +1,51 @@
1/*
2 * arch/s390/kernel/delay.c
3 * Precise Delay Loops for S390
4 *
5 * S390 version
6 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
7 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com),
8 *
9 * Derived from "arch/i386/lib/delay.c"
10 * Copyright (C) 1993 Linus Torvalds
11 * Copyright (C) 1997 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
12 */
13
14#include <linux/config.h>
15#include <linux/sched.h>
16#include <linux/delay.h>
17
18#ifdef CONFIG_SMP
19#include <asm/smp.h>
20#endif
21
22void __delay(unsigned long loops)
23{
24 /*
25 * To end the bloody studid and useless discussion about the
26 * BogoMips number I took the liberty to define the __delay
27 * function in a way that that resulting BogoMips number will
28 * yield the megahertz number of the cpu. The important function
29 * is udelay and that is done using the tod clock. -- martin.
30 */
31 __asm__ __volatile__(
32 "0: brct %0,0b"
33 : /* no outputs */ : "r" (loops/2) );
34}
35
36/*
37 * Waits for 'usecs' microseconds using the tod clock, giving up the time slice
38 * of the virtual PU inbetween to avoid congestion.
39 */
40void __udelay(unsigned long usecs)
41{
42 uint64_t start_cc, end_cc;
43
44 if (usecs == 0)
45 return;
46 asm volatile ("STCK %0" : "=m" (start_cc));
47 do {
48 cpu_relax();
49 asm volatile ("STCK %0" : "=m" (end_cc));
50 } while (((end_cc - start_cc)/4096) < usecs);
51}
diff --git a/arch/s390/lib/string.c b/arch/s390/lib/string.c
new file mode 100644
index 000000000000..8240cc77e06e
--- /dev/null
+++ b/arch/s390/lib/string.c
@@ -0,0 +1,381 @@
1/*
2 * arch/s390/lib/string.c
3 * Optimized string functions
4 *
5 * S390 version
6 * Copyright (C) 2004 IBM Deutschland Entwicklung GmbH, IBM Corporation
7 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
8 */
9
10#define IN_ARCH_STRING_C 1
11
12#include <linux/types.h>
13#include <linux/module.h>
14
15/*
16 * Helper functions to find the end of a string
17 */
18static inline char *__strend(const char *s)
19{
20 register unsigned long r0 asm("0") = 0;
21
22 asm volatile ("0: srst %0,%1\n"
23 " jo 0b"
24 : "+d" (r0), "+a" (s) : : "cc" );
25 return (char *) r0;
26}
27
28static inline char *__strnend(const char *s, size_t n)
29{
30 register unsigned long r0 asm("0") = 0;
31 const char *p = s + n;
32
33 asm volatile ("0: srst %0,%1\n"
34 " jo 0b"
35 : "+d" (p), "+a" (s) : "d" (r0) : "cc" );
36 return (char *) p;
37}
38
39/**
40 * strlen - Find the length of a string
41 * @s: The string to be sized
42 *
43 * returns the length of @s
44 */
45size_t strlen(const char *s)
46{
47 return __strend(s) - s;
48}
49EXPORT_SYMBOL(strlen);
50
51/**
52 * strnlen - Find the length of a length-limited string
53 * @s: The string to be sized
54 * @n: The maximum number of bytes to search
55 *
56 * returns the minimum of the length of @s and @n
57 */
58size_t strnlen(const char * s, size_t n)
59{
60 return __strnend(s, n) - s;
61}
62EXPORT_SYMBOL(strnlen);
63
64/**
65 * strcpy - Copy a %NUL terminated string
66 * @dest: Where to copy the string to
67 * @src: Where to copy the string from
68 *
69 * returns a pointer to @dest
70 */
71char *strcpy(char *dest, const char *src)
72{
73 register int r0 asm("0") = 0;
74 char *ret = dest;
75
76 asm volatile ("0: mvst %0,%1\n"
77 " jo 0b"
78 : "+&a" (dest), "+&a" (src) : "d" (r0)
79 : "cc", "memory" );
80 return ret;
81}
82EXPORT_SYMBOL(strcpy);
83
84/**
85 * strlcpy - Copy a %NUL terminated string into a sized buffer
86 * @dest: Where to copy the string to
87 * @src: Where to copy the string from
88 * @size: size of destination buffer
89 *
90 * Compatible with *BSD: the result is always a valid
91 * NUL-terminated string that fits in the buffer (unless,
92 * of course, the buffer size is zero). It does not pad
93 * out the result like strncpy() does.
94 */
95size_t strlcpy(char *dest, const char *src, size_t size)
96{
97 size_t ret = __strend(src) - src;
98
99 if (size) {
100 size_t len = (ret >= size) ? size-1 : ret;
101 dest[len] = '\0';
102 __builtin_memcpy(dest, src, len);
103 }
104 return ret;
105}
106EXPORT_SYMBOL(strlcpy);
107
108/**
109 * strncpy - Copy a length-limited, %NUL-terminated string
110 * @dest: Where to copy the string to
111 * @src: Where to copy the string from
112 * @n: The maximum number of bytes to copy
113 *
114 * The result is not %NUL-terminated if the source exceeds
115 * @n bytes.
116 */
117char *strncpy(char *dest, const char *src, size_t n)
118{
119 size_t len = __strnend(src, n) - src;
120 __builtin_memset(dest + len, 0, n - len);
121 __builtin_memcpy(dest, src, len);
122 return dest;
123}
124EXPORT_SYMBOL(strncpy);
125
126/**
127 * strcat - Append one %NUL-terminated string to another
128 * @dest: The string to be appended to
129 * @src: The string to append to it
130 *
131 * returns a pointer to @dest
132 */
133char *strcat(char *dest, const char *src)
134{
135 register int r0 asm("0") = 0;
136 unsigned long dummy;
137 char *ret = dest;
138
139 asm volatile ("0: srst %0,%1\n"
140 " jo 0b\n"
141 "1: mvst %0,%2\n"
142 " jo 1b"
143 : "=&a" (dummy), "+a" (dest), "+a" (src)
144 : "d" (r0), "0" (0UL) : "cc", "memory" );
145 return ret;
146}
147EXPORT_SYMBOL(strcat);
148
149/**
150 * strlcat - Append a length-limited, %NUL-terminated string to another
151 * @dest: The string to be appended to
152 * @src: The string to append to it
153 * @n: The size of the destination buffer.
154 */
155size_t strlcat(char *dest, const char *src, size_t n)
156{
157 size_t dsize = __strend(dest) - dest;
158 size_t len = __strend(src) - src;
159 size_t res = dsize + len;
160
161 if (dsize < n) {
162 dest += dsize;
163 n -= dsize;
164 if (len >= n)
165 len = n - 1;
166 dest[len] = '\0';
167 __builtin_memcpy(dest, src, len);
168 }
169 return res;
170}
171EXPORT_SYMBOL(strlcat);
172
173/**
174 * strncat - Append a length-limited, %NUL-terminated string to another
175 * @dest: The string to be appended to
176 * @src: The string to append to it
177 * @n: The maximum numbers of bytes to copy
178 *
179 * returns a pointer to @dest
180 *
181 * Note that in contrast to strncpy, strncat ensures the result is
182 * terminated.
183 */
184char *strncat(char *dest, const char *src, size_t n)
185{
186 size_t len = __strnend(src, n) - src;
187 char *p = __strend(dest);
188
189 p[len] = '\0';
190 __builtin_memcpy(p, src, len);
191 return dest;
192}
193EXPORT_SYMBOL(strncat);
194
195/**
196 * strcmp - Compare two strings
197 * @cs: One string
198 * @ct: Another string
199 *
200 * returns 0 if @cs and @ct are equal,
201 * < 0 if @cs is less than @ct
202 * > 0 if @cs is greater than @ct
203 */
204int strcmp(const char *cs, const char *ct)
205{
206 register int r0 asm("0") = 0;
207 int ret = 0;
208
209 asm volatile ("0: clst %2,%3\n"
210 " jo 0b\n"
211 " je 1f\n"
212 " ic %0,0(%2)\n"
213 " ic %1,0(%3)\n"
214 " sr %0,%1\n"
215 "1:"
216 : "+d" (ret), "+d" (r0), "+a" (cs), "+a" (ct)
217 : : "cc" );
218 return ret;
219}
220EXPORT_SYMBOL(strcmp);
221
222/**
223 * strrchr - Find the last occurrence of a character in a string
224 * @s: The string to be searched
225 * @c: The character to search for
226 */
227char * strrchr(const char * s, int c)
228{
229 size_t len = __strend(s) - s;
230
231 if (len)
232 do {
233 if (s[len] == (char) c)
234 return (char *) s + len;
235 } while (--len > 0);
236 return 0;
237}
238EXPORT_SYMBOL(strrchr);
239
240/**
241 * strstr - Find the first substring in a %NUL terminated string
242 * @s1: The string to be searched
243 * @s2: The string to search for
244 */
245char * strstr(const char * s1,const char * s2)
246{
247 int l1, l2;
248
249 l2 = __strend(s2) - s2;
250 if (!l2)
251 return (char *) s1;
252 l1 = __strend(s1) - s1;
253 while (l1-- >= l2) {
254 register unsigned long r2 asm("2") = (unsigned long) s1;
255 register unsigned long r3 asm("3") = (unsigned long) l2;
256 register unsigned long r4 asm("4") = (unsigned long) s2;
257 register unsigned long r5 asm("5") = (unsigned long) l2;
258 int cc;
259
260 asm volatile ("0: clcle %1,%3,0\n"
261 " jo 0b\n"
262 " ipm %0\n"
263 " srl %0,28"
264 : "=&d" (cc), "+a" (r2), "+a" (r3),
265 "+a" (r4), "+a" (r5) : : "cc" );
266 if (!cc)
267 return (char *) s1;
268 s1++;
269 }
270 return 0;
271}
272EXPORT_SYMBOL(strstr);
273
274/**
275 * memchr - Find a character in an area of memory.
276 * @s: The memory area
277 * @c: The byte to search for
278 * @n: The size of the area.
279 *
280 * returns the address of the first occurrence of @c, or %NULL
281 * if @c is not found
282 */
283void *memchr(const void *s, int c, size_t n)
284{
285 register int r0 asm("0") = (char) c;
286 const void *ret = s + n;
287
288 asm volatile ("0: srst %0,%1\n"
289 " jo 0b\n"
290 " jl 1f\n"
291 " la %0,0\n"
292 "1:"
293 : "+a" (ret), "+&a" (s) : "d" (r0) : "cc" );
294 return (void *) ret;
295}
296EXPORT_SYMBOL(memchr);
297
298/**
299 * memcmp - Compare two areas of memory
300 * @cs: One area of memory
301 * @ct: Another area of memory
302 * @count: The size of the area.
303 */
304int memcmp(const void *cs, const void *ct, size_t n)
305{
306 register unsigned long r2 asm("2") = (unsigned long) cs;
307 register unsigned long r3 asm("3") = (unsigned long) n;
308 register unsigned long r4 asm("4") = (unsigned long) ct;
309 register unsigned long r5 asm("5") = (unsigned long) n;
310 int ret;
311
312 asm volatile ("0: clcle %1,%3,0\n"
313 " jo 0b\n"
314 " ipm %0\n"
315 " srl %0,28"
316 : "=&d" (ret), "+a" (r2), "+a" (r3), "+a" (r4), "+a" (r5)
317 : : "cc" );
318 if (ret)
319 ret = *(char *) r2 - *(char *) r4;
320 return ret;
321}
322EXPORT_SYMBOL(memcmp);
323
324/**
325 * memscan - Find a character in an area of memory.
326 * @s: The memory area
327 * @c: The byte to search for
328 * @n: The size of the area.
329 *
330 * returns the address of the first occurrence of @c, or 1 byte past
331 * the area if @c is not found
332 */
333void *memscan(void *s, int c, size_t n)
334{
335 register int r0 asm("0") = (char) c;
336 const void *ret = s + n;
337
338 asm volatile ("0: srst %0,%1\n"
339 " jo 0b\n"
340 : "+a" (ret), "+&a" (s) : "d" (r0) : "cc" );
341 return (void *) ret;
342}
343EXPORT_SYMBOL(memscan);
344
345/**
346 * memcpy - Copy one area of memory to another
347 * @dest: Where to copy to
348 * @src: Where to copy from
349 * @n: The size of the area.
350 *
351 * returns a pointer to @dest
352 */
353void *memcpy(void *dest, const void *src, size_t n)
354{
355 return __builtin_memcpy(dest, src, n);
356}
357EXPORT_SYMBOL(memcpy);
358
359/**
360 * memset - Fill a region of memory with the given value
361 * @s: Pointer to the start of the area.
362 * @c: The byte to fill the area with
363 * @n: The size of the area.
364 *
365 * returns a pointer to @s
366 */
367void *memset(void *s, int c, size_t n)
368{
369 char *xs;
370
371 if (c == 0)
372 return __builtin_memset(s, 0, n);
373
374 xs = (char *) s;
375 if (n > 0)
376 do {
377 *xs++ = c;
378 } while (--n > 0);
379 return s;
380}
381EXPORT_SYMBOL(memset);
diff --git a/arch/s390/lib/uaccess.S b/arch/s390/lib/uaccess.S
new file mode 100644
index 000000000000..e8029ef42ef2
--- /dev/null
+++ b/arch/s390/lib/uaccess.S
@@ -0,0 +1,210 @@
1/*
2 * arch/s390/lib/uaccess.S
3 * __copy_{from|to}_user functions.
4 *
5 * s390
6 * Copyright (C) 2000,2002 IBM Deutschland Entwicklung GmbH, IBM Corporation
7 * Authors(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
8 *
9 * These functions have standard call interface
10 */
11
12#include <linux/errno.h>
13#include <asm/lowcore.h>
14#include <asm/offsets.h>
15
16 .text
17 .align 4
18 .globl __copy_from_user_asm
19 # %r2 = to, %r3 = n, %r4 = from
20__copy_from_user_asm:
21 slr %r0,%r0
220: mvcp 0(%r3,%r2),0(%r4),%r0
23 jnz 1f
24 slr %r2,%r2
25 br %r14
261: la %r2,256(%r2)
27 la %r4,256(%r4)
28 ahi %r3,-256
292: mvcp 0(%r3,%r2),0(%r4),%r0
30 jnz 1b
313: slr %r2,%r2
32 br %r14
334: lhi %r0,-4096
34 lr %r5,%r4
35 slr %r5,%r0
36 nr %r5,%r0 # %r5 = (%r4 + 4096) & -4096
37 slr %r5,%r4 # %r5 = #bytes to next user page boundary
38 clr %r3,%r5 # copy crosses next page boundary ?
39 jnh 6f # no, the current page faulted
40 # move with the reduced length which is < 256
415: mvcp 0(%r5,%r2),0(%r4),%r0
42 slr %r3,%r5
436: lr %r2,%r3
44 br %r14
45 .section __ex_table,"a"
46 .long 0b,4b
47 .long 2b,4b
48 .long 5b,6b
49 .previous
50
51 .align 4
52 .text
53 .globl __copy_to_user_asm
54 # %r2 = from, %r3 = n, %r4 = to
55__copy_to_user_asm:
56 slr %r0,%r0
570: mvcs 0(%r3,%r4),0(%r2),%r0
58 jnz 1f
59 slr %r2,%r2
60 br %r14
611: la %r2,256(%r2)
62 la %r4,256(%r4)
63 ahi %r3,-256
642: mvcs 0(%r3,%r4),0(%r2),%r0
65 jnz 1b
663: slr %r2,%r2
67 br %r14
684: lhi %r0,-4096
69 lr %r5,%r4
70 slr %r5,%r0
71 nr %r5,%r0 # %r5 = (%r4 + 4096) & -4096
72 slr %r5,%r4 # %r5 = #bytes to next user page boundary
73 clr %r3,%r5 # copy crosses next page boundary ?
74 jnh 6f # no, the current page faulted
75 # move with the reduced length which is < 256
765: mvcs 0(%r5,%r4),0(%r2),%r0
77 slr %r3,%r5
786: lr %r2,%r3
79 br %r14
80 .section __ex_table,"a"
81 .long 0b,4b
82 .long 2b,4b
83 .long 5b,6b
84 .previous
85
86 .align 4
87 .text
88 .globl __copy_in_user_asm
89 # %r2 = from, %r3 = n, %r4 = to
90__copy_in_user_asm:
91 sacf 256
92 bras 1,1f
93 mvc 0(1,%r4),0(%r2)
940: mvc 0(256,%r4),0(%r2)
95 la %r2,256(%r2)
96 la %r4,256(%r4)
971: ahi %r3,-256
98 jnm 0b
992: ex %r3,0(%r1)
100 sacf 0
101 slr %r2,%r2
102 br 14
1033: mvc 0(1,%r4),0(%r2)
104 la %r2,1(%r2)
105 la %r4,1(%r4)
106 ahi %r3,-1
107 jnm 3b
1084: lr %r2,%r3
109 sacf 0
110 br %r14
111 .section __ex_table,"a"
112 .long 0b,3b
113 .long 2b,3b
114 .long 3b,4b
115 .previous
116
117 .align 4
118 .text
119 .globl __clear_user_asm
120 # %r2 = to, %r3 = n
121__clear_user_asm:
122 bras %r5,0f
123 .long empty_zero_page
1240: l %r5,0(%r5)
125 slr %r0,%r0
1261: mvcs 0(%r3,%r2),0(%r5),%r0
127 jnz 2f
128 slr %r2,%r2
129 br %r14
1302: la %r2,256(%r2)
131 ahi %r3,-256
1323: mvcs 0(%r3,%r2),0(%r5),%r0
133 jnz 2b
1344: slr %r2,%r2
135 br %r14
1365: lhi %r0,-4096
137 lr %r4,%r2
138 slr %r4,%r0
139 nr %r4,%r0 # %r4 = (%r2 + 4096) & -4096
140 slr %r4,%r2 # %r4 = #bytes to next user page boundary
141 clr %r3,%r4 # clear crosses next page boundary ?
142 jnh 7f # no, the current page faulted
143 # clear with the reduced length which is < 256
1446: mvcs 0(%r4,%r2),0(%r5),%r0
145 slr %r3,%r4
1467: lr %r2,%r3
147 br %r14
148 .section __ex_table,"a"
149 .long 1b,5b
150 .long 3b,5b
151 .long 6b,7b
152 .previous
153
154 .align 4
155 .text
156 .globl __strncpy_from_user_asm
157 # %r2 = count, %r3 = dst, %r4 = src
158__strncpy_from_user_asm:
159 lhi %r0,0
160 lr %r1,%r4
161 la %r4,0(%r4) # clear high order bit from %r4
162 la %r2,0(%r2,%r4) # %r2 points to first byte after string
163 sacf 256
1640: srst %r2,%r1
165 jo 0b
166 sacf 0
167 lr %r1,%r2
168 jh 1f # \0 found in string ?
169 ahi %r1,1 # include \0 in copy
1701: slr %r1,%r4 # %r1 = copy length (without \0)
171 slr %r2,%r4 # %r2 = return length (including \0)
1722: mvcp 0(%r1,%r3),0(%r4),%r0
173 jnz 3f
174 br %r14
1753: la %r3,256(%r3)
176 la %r4,256(%r4)
177 ahi %r1,-256
178 mvcp 0(%r1,%r3),0(%r4),%r0
179 jnz 3b
180 br %r14
1814: sacf 0
182 lhi %r2,-EFAULT
183 br %r14
184 .section __ex_table,"a"
185 .long 0b,4b
186 .previous
187
188 .align 4
189 .text
190 .globl __strnlen_user_asm
191 # %r2 = count, %r3 = src
192__strnlen_user_asm:
193 lhi %r0,0
194 lr %r1,%r3
195 la %r3,0(%r3) # clear high order bit from %r4
196 la %r2,0(%r2,%r3) # %r2 points to first byte after string
197 sacf 256
1980: srst %r2,%r1
199 jo 0b
200 sacf 0
201 jh 1f # \0 found in string ?
202 ahi %r2,1 # strnlen_user result includes the \0
2031: slr %r2,%r3
204 br %r14
2052: sacf 0
206 lhi %r2,-EFAULT
207 br %r14
208 .section __ex_table,"a"
209 .long 0b,2b
210 .previous
diff --git a/arch/s390/lib/uaccess64.S b/arch/s390/lib/uaccess64.S
new file mode 100644
index 000000000000..0ca56972f4f0
--- /dev/null
+++ b/arch/s390/lib/uaccess64.S
@@ -0,0 +1,206 @@
1/*
2 * arch/s390x/lib/uaccess.S
3 * __copy_{from|to}_user functions.
4 *
5 * s390
6 * Copyright (C) 2000,2002 IBM Deutschland Entwicklung GmbH, IBM Corporation
7 * Authors(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
8 *
9 * These functions have standard call interface
10 */
11
12#include <linux/errno.h>
13#include <asm/lowcore.h>
14#include <asm/offsets.h>
15
16 .text
17 .align 4
18 .globl __copy_from_user_asm
19 # %r2 = to, %r3 = n, %r4 = from
20__copy_from_user_asm:
21 slgr %r0,%r0
220: mvcp 0(%r3,%r2),0(%r4),%r0
23 jnz 1f
24 slgr %r2,%r2
25 br %r14
261: la %r2,256(%r2)
27 la %r4,256(%r4)
28 aghi %r3,-256
292: mvcp 0(%r3,%r2),0(%r4),%r0
30 jnz 1b
313: slgr %r2,%r2
32 br %r14
334: lghi %r0,-4096
34 lgr %r5,%r4
35 slgr %r5,%r0
36 ngr %r5,%r0 # %r5 = (%r4 + 4096) & -4096
37 slgr %r5,%r4 # %r5 = #bytes to next user page boundary
38 clgr %r3,%r5 # copy crosses next page boundary ?
39 jnh 6f # no, the current page faulted
40 # move with the reduced length which is < 256
415: mvcp 0(%r5,%r2),0(%r4),%r0
42 slgr %r3,%r5
436: lgr %r2,%r3
44 br %r14
45 .section __ex_table,"a"
46 .quad 0b,4b
47 .quad 2b,4b
48 .quad 5b,6b
49 .previous
50
51 .align 4
52 .text
53 .globl __copy_to_user_asm
54 # %r2 = from, %r3 = n, %r4 = to
55__copy_to_user_asm:
56 slgr %r0,%r0
570: mvcs 0(%r3,%r4),0(%r2),%r0
58 jnz 1f
59 slgr %r2,%r2
60 br %r14
611: la %r2,256(%r2)
62 la %r4,256(%r4)
63 aghi %r3,-256
642: mvcs 0(%r3,%r4),0(%r2),%r0
65 jnz 1b
663: slgr %r2,%r2
67 br %r14
684: lghi %r0,-4096
69 lgr %r5,%r4
70 slgr %r5,%r0
71 ngr %r5,%r0 # %r5 = (%r4 + 4096) & -4096
72 slgr %r5,%r4 # %r5 = #bytes to next user page boundary
73 clgr %r3,%r5 # copy crosses next page boundary ?
74 jnh 6f # no, the current page faulted
75 # move with the reduced length which is < 256
765: mvcs 0(%r5,%r4),0(%r2),%r0
77 slgr %r3,%r5
786: lgr %r2,%r3
79 br %r14
80 .section __ex_table,"a"
81 .quad 0b,4b
82 .quad 2b,4b
83 .quad 5b,6b
84 .previous
85
86 .align 4
87 .text
88 .globl __copy_in_user_asm
89 # %r2 = from, %r3 = n, %r4 = to
90__copy_in_user_asm:
91 sacf 256
92 bras 1,1f
93 mvc 0(1,%r4),0(%r2)
940: mvc 0(256,%r4),0(%r2)
95 la %r2,256(%r2)
96 la %r4,256(%r4)
971: aghi %r3,-256
98 jnm 0b
992: ex %r3,0(%r1)
100 sacf 0
101 slgr %r2,%r2
102 br 14
1033: mvc 0(1,%r4),0(%r2)
104 la %r2,1(%r2)
105 la %r4,1(%r4)
106 aghi %r3,-1
107 jnm 3b
1084: lgr %r2,%r3
109 sacf 0
110 br %r14
111 .section __ex_table,"a"
112 .quad 0b,3b
113 .quad 2b,3b
114 .quad 3b,4b
115 .previous
116
117 .align 4
118 .text
119 .globl __clear_user_asm
120 # %r2 = to, %r3 = n
121__clear_user_asm:
122 slgr %r0,%r0
123 larl %r5,empty_zero_page
1241: mvcs 0(%r3,%r2),0(%r5),%r0
125 jnz 2f
126 slgr %r2,%r2
127 br %r14
1282: la %r2,256(%r2)
129 aghi %r3,-256
1303: mvcs 0(%r3,%r2),0(%r5),%r0
131 jnz 2b
1324: slgr %r2,%r2
133 br %r14
1345: lghi %r0,-4096
135 lgr %r4,%r2
136 slgr %r4,%r0
137 ngr %r4,%r0 # %r4 = (%r2 + 4096) & -4096
138 slgr %r4,%r2 # %r4 = #bytes to next user page boundary
139 clgr %r3,%r4 # clear crosses next page boundary ?
140 jnh 7f # no, the current page faulted
141 # clear with the reduced length which is < 256
1426: mvcs 0(%r4,%r2),0(%r5),%r0
143 slgr %r3,%r4
1447: lgr %r2,%r3
145 br %r14
146 .section __ex_table,"a"
147 .quad 1b,5b
148 .quad 3b,5b
149 .quad 6b,7b
150 .previous
151
152 .align 4
153 .text
154 .globl __strncpy_from_user_asm
155 # %r2 = count, %r3 = dst, %r4 = src
156__strncpy_from_user_asm:
157 lghi %r0,0
158 lgr %r1,%r4
159 la %r2,0(%r2,%r4) # %r2 points to first byte after string
160 sacf 256
1610: srst %r2,%r1
162 jo 0b
163 sacf 0
164 lgr %r1,%r2
165 jh 1f # \0 found in string ?
166 aghi %r1,1 # include \0 in copy
1671: slgr %r1,%r4 # %r1 = copy length (without \0)
168 slgr %r2,%r4 # %r2 = return length (including \0)
1692: mvcp 0(%r1,%r3),0(%r4),%r0
170 jnz 3f
171 br %r14
1723: la %r3,256(%r3)
173 la %r4,256(%r4)
174 aghi %r1,-256
175 mvcp 0(%r1,%r3),0(%r4),%r0
176 jnz 3b
177 br %r14
1784: sacf 0
179 lghi %r2,-EFAULT
180 br %r14
181 .section __ex_table,"a"
182 .quad 0b,4b
183 .previous
184
185 .align 4
186 .text
187 .globl __strnlen_user_asm
188 # %r2 = count, %r3 = src
189__strnlen_user_asm:
190 lghi %r0,0
191 lgr %r1,%r3
192 la %r2,0(%r2,%r3) # %r2 points to first byte after string
193 sacf 256
1940: srst %r2,%r1
195 jo 0b
196 sacf 0
197 jh 1f # \0 found in string ?
198 aghi %r2,1 # strnlen_user result includes the \0
1991: slgr %r2,%r3
200 br %r14
2012: sacf 0
202 lghi %r2,-EFAULT
203 br %r14
204 .section __ex_table,"a"
205 .quad 0b,2b
206 .previous