microblaze: Print early printk information to log buffer
[linux-2.6-block.git] / arch / microblaze / lib / uaccess_old.S
CommitLineData
0d6de953
MS
1/*
2 * Copyright (C) 2009 Michal Simek <monstr@monstr.eu>
3 * Copyright (C) 2009 PetaLogix
4 * Copyright (C) 2007 LynuxWorks, Inc.
5 *
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file "COPYING" in the main directory of this archive
8 * for more details.
9 */
10
11#include <linux/errno.h>
12#include <linux/linkage.h>
13
14/*
15 * int __strncpy_user(char *to, char *from, int len);
16 *
17 * Returns:
18 * -EFAULT for an exception
19 * len if we hit the buffer limit
20 * bytes copied
21 */
22
23 .text
24.globl __strncpy_user;
13851966 25.type __strncpy_user, @function
0d6de953
MS
26.align 4;
27__strncpy_user:
28
29 /*
30 * r5 - to
31 * r6 - from
32 * r7 - len
33 * r3 - temp count
34 * r4 - temp val
35 */
36 addik r3,r7,0 /* temp_count = len */
37 beqi r3,3f
381:
39 lbu r4,r6,r0
40 sb r4,r5,r0
41
42 addik r3,r3,-1
43 beqi r3,2f /* break on len */
44
45 addik r5,r5,1
46 bneid r4,1b
47 addik r6,r6,1 /* delay slot */
48 addik r3,r3,1 /* undo "temp_count--" */
492:
50 rsubk r3,r3,r7 /* temp_count = len - temp_count */
513:
52 rtsd r15,8
53 nop
13851966 54 .size __strncpy_user, . - __strncpy_user
0d6de953
MS
55
56
57 .section .fixup, "ax"
58 .align 2
594:
60 brid 3b
61 addik r3,r0, -EFAULT
62
63 .section __ex_table, "a"
64 .word 1b,4b
65
66/*
67 * int __strnlen_user(char __user *str, int maxlen);
68 *
69 * Returns:
70 * 0 on error
71 * maxlen + 1 if no NUL byte found within maxlen bytes
72 * size of the string (including NUL byte)
73 */
74
75 .text
76.globl __strnlen_user;
13851966 77.type __strnlen_user, @function
0d6de953
MS
78.align 4;
79__strnlen_user:
80 addik r3,r6,0
81 beqi r3,3f
821:
83 lbu r4,r5,r0
84 beqid r4,2f /* break on NUL */
85 addik r3,r3,-1 /* delay slot */
86
87 bneid r3,1b
88 addik r5,r5,1 /* delay slot */
89
90 addik r3,r3,-1 /* for break on len */
912:
92 rsubk r3,r3,r6
933:
94 rtsd r15,8
95 nop
13851966 96 .size __strnlen_user, . - __strnlen_user
0d6de953
MS
97
98
99 .section .fixup,"ax"
1004:
101 brid 3b
102 addk r3,r0,r0
103
104 .section __ex_table,"a"
105 .word 1b,4b
106
107/*
108 * int __copy_tofrom_user(char *to, char *from, int len)
109 * Return:
110 * 0 on success
111 * number of not copied bytes on error
112 */
113 .text
114.globl __copy_tofrom_user;
13851966 115.type __copy_tofrom_user, @function
0d6de953
MS
116.align 4;
117__copy_tofrom_user:
118 /*
119 * r5 - to
120 * r6 - from
121 * r7, r3 - count
122 * r4 - tempval
123 */
124 addik r3,r7,0
125 beqi r3,3f
1261:
127 lbu r4,r6,r0
128 addik r6,r6,1
1292:
130 sb r4,r5,r0
131 addik r3,r3,-1
132 bneid r3,1b
133 addik r5,r5,1 /* delay slot */
1343:
135 rtsd r15,8
136 nop
13851966 137 .size __copy_tofrom_user, . - __copy_tofrom_user
0d6de953
MS
138
139
140 .section __ex_table,"a"
141 .word 1b,3b,2b,3b