Blame view
arch/microblaze/lib/uaccess_old.S
4.79 KB
0d6de9532 microblaze_mmu_v2... |
1 2 3 4 5 6 7 8 9 10 11 12 |
/* * Copyright (C) 2009 Michal Simek <monstr@monstr.eu> * Copyright (C) 2009 PetaLogix * Copyright (C) 2007 LynuxWorks, Inc. * * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. */ #include <linux/errno.h> #include <linux/linkage.h> |
ebe211254 microblaze: Add l... |
13 |
#include <asm/page.h> |
0d6de9532 microblaze_mmu_v2... |
14 15 16 17 18 19 20 21 22 23 24 25 |
/* * int __strncpy_user(char *to, char *from, int len); * * Returns: * -EFAULT for an exception * len if we hit the buffer limit * bytes copied */ .text .globl __strncpy_user; |
13851966d microblaze: Add .... |
26 |
.type __strncpy_user, @function |
0d6de9532 microblaze_mmu_v2... |
27 28 29 30 31 32 33 34 35 36 |
.align 4; __strncpy_user: /* * r5 - to * r6 - from * r7 - len * r3 - temp count * r4 - temp val */ |
cb5edfe3e microblaze: Use d... |
37 |
beqid r7,3f |
0d6de9532 microblaze_mmu_v2... |
38 |
addik r3,r7,0 /* temp_count = len */ |
0d6de9532 microblaze_mmu_v2... |
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
1: lbu r4,r6,r0 sb r4,r5,r0 addik r3,r3,-1 beqi r3,2f /* break on len */ addik r5,r5,1 bneid r4,1b addik r6,r6,1 /* delay slot */ addik r3,r3,1 /* undo "temp_count--" */ 2: rsubk r3,r3,r7 /* temp_count = len - temp_count */ 3: rtsd r15,8 nop |
13851966d microblaze: Add .... |
55 |
.size __strncpy_user, . - __strncpy_user |
0d6de9532 microblaze_mmu_v2... |
56 |
|
0d6de9532 microblaze_mmu_v2... |
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
.section .fixup, "ax" .align 2 4: brid 3b addik r3,r0, -EFAULT .section __ex_table, "a" .word 1b,4b /* * int __strnlen_user(char __user *str, int maxlen); * * Returns: * 0 on error * maxlen + 1 if no NUL byte found within maxlen bytes * size of the string (including NUL byte) */ .text .globl __strnlen_user; |
13851966d microblaze: Add .... |
77 |
.type __strnlen_user, @function |
0d6de9532 microblaze_mmu_v2... |
78 79 |
.align 4; __strnlen_user: |
cb5edfe3e microblaze: Use d... |
80 |
beqid r6,3f |
0d6de9532 microblaze_mmu_v2... |
81 |
addik r3,r6,0 |
0d6de9532 microblaze_mmu_v2... |
82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
1: lbu r4,r5,r0 beqid r4,2f /* break on NUL */ addik r3,r3,-1 /* delay slot */ bneid r3,1b addik r5,r5,1 /* delay slot */ addik r3,r3,-1 /* for break on len */ 2: rsubk r3,r3,r6 3: rtsd r15,8 nop |
13851966d microblaze: Add .... |
96 |
.size __strnlen_user, . - __strnlen_user |
0d6de9532 microblaze_mmu_v2... |
97 |
|
0d6de9532 microblaze_mmu_v2... |
98 99 100 101 102 103 104 |
.section .fixup,"ax" 4: brid 3b addk r3,r0,r0 .section __ex_table,"a" .word 1b,4b |
ebe211254 microblaze: Add l... |
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
/* Loop unrolling for __copy_tofrom_user */ #define COPY(offset) \ 1: lwi r4 , r6, 0x0000 + offset; \ 2: lwi r19, r6, 0x0004 + offset; \ 3: lwi r20, r6, 0x0008 + offset; \ 4: lwi r21, r6, 0x000C + offset; \ 5: lwi r22, r6, 0x0010 + offset; \ 6: lwi r23, r6, 0x0014 + offset; \ 7: lwi r24, r6, 0x0018 + offset; \ 8: lwi r25, r6, 0x001C + offset; \ 9: swi r4 , r5, 0x0000 + offset; \ 10: swi r19, r5, 0x0004 + offset; \ 11: swi r20, r5, 0x0008 + offset; \ 12: swi r21, r5, 0x000C + offset; \ 13: swi r22, r5, 0x0010 + offset; \ 14: swi r23, r5, 0x0014 + offset; \ 15: swi r24, r5, 0x0018 + offset; \ 16: swi r25, r5, 0x001C + offset; \ .section __ex_table,"a"; \ .word 1b, 0f; \ .word 2b, 0f; \ .word 3b, 0f; \ .word 4b, 0f; \ .word 5b, 0f; \ .word 6b, 0f; \ .word 7b, 0f; \ .word 8b, 0f; \ .word 9b, 0f; \ .word 10b, 0f; \ .word 11b, 0f; \ .word 12b, 0f; \ .word 13b, 0f; \ .word 14b, 0f; \ .word 15b, 0f; \ .word 16b, 0f; \ .text #define COPY_80(offset) \ COPY(0x00 + offset);\ COPY(0x20 + offset);\ COPY(0x40 + offset);\ COPY(0x60 + offset); |
0d6de9532 microblaze_mmu_v2... |
147 148 149 150 151 152 153 154 |
/* * int __copy_tofrom_user(char *to, char *from, int len) * Return: * 0 on success * number of not copied bytes on error */ .text .globl __copy_tofrom_user; |
13851966d microblaze: Add .... |
155 |
.type __copy_tofrom_user, @function |
0d6de9532 microblaze_mmu_v2... |
156 157 158 159 160 161 162 163 |
.align 4; __copy_tofrom_user: /* * r5 - to * r6 - from * r7, r3 - count * r4 - tempval */ |
9b133f8d8 microblaze: Chang... |
164 |
beqid r7, 0f /* zero size is not likely */ |
ca3865bae microblaze: Suppo... |
165 |
or r3, r5, r6 /* find if is any to/from unaligned */ |
782d491fc microblaze: Simpl... |
166 167 168 |
or r3, r3, r7 /* find if count is unaligned */ andi r3, r3, 0x3 /* mask last 3 bits */ bneid r3, bu1 /* if r3 is not zero then byte copying */ |
ca3865bae microblaze: Suppo... |
169 |
or r3, r0, r0 |
ebe211254 microblaze: Add l... |
170 171 172 |
rsubi r3, r7, PAGE_SIZE /* detect PAGE_SIZE */ beqid r3, page; or r3, r0, r0 |
c83858b3e microblaze: Chang... |
173 174 |
w1: lw r4, r6, r3 /* at least one 4 byte copy */ w2: sw r4, r5, r3 |
ca3865bae microblaze: Suppo... |
175 |
addik r7, r7, -4 |
c83858b3e microblaze: Chang... |
176 |
bneid r7, w1 |
ca3865bae microblaze: Suppo... |
177 178 179 180 |
addik r3, r3, 4 addik r3, r7, 0 rtsd r15, 8 nop |
eedac7914 microblaze: Separ... |
181 182 |
.section __ex_table,"a" |
c83858b3e microblaze: Chang... |
183 184 |
.word w1, 0f; .word w2, 0f; |
eedac7914 microblaze: Separ... |
185 |
.text |
ebe211254 microblaze: Add l... |
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
.align 4 /* Alignment is important to keep icache happy */ page: /* Create room on stack and save registers for storign values */ addik r1, r1, -32 swi r19, r1, 4 swi r20, r1, 8 swi r21, r1, 12 swi r22, r1, 16 swi r23, r1, 20 swi r24, r1, 24 swi r25, r1, 28 loop: /* r4, r19, r20, r21, r22, r23, r24, r25 are used for storing values */ /* Loop unrolling to get performance boost */ COPY_80(0x000); COPY_80(0x080); COPY_80(0x100); COPY_80(0x180); /* copy loop */ addik r6, r6, 0x200 addik r7, r7, -0x200 bneid r7, loop addik r5, r5, 0x200 /* Restore register content */ lwi r19, r1, 4 lwi r20, r1, 8 lwi r21, r1, 12 lwi r22, r1, 16 lwi r23, r1, 20 lwi r24, r1, 24 lwi r25, r1, 28 addik r1, r1, 32 /* return back */ addik r3, r7, 0 rtsd r15, 8 nop .align 4 /* Alignment is important to keep icache happy */ |
c83858b3e microblaze: Chang... |
222 223 |
bu1: lbu r4,r6,r3 bu2: sb r4,r5,r3 |
ca3865bae microblaze: Suppo... |
224 |
addik r7,r7,-1 |
c83858b3e microblaze: Chang... |
225 |
bneid r7,bu1 |
ca3865bae microblaze: Suppo... |
226 |
addik r3,r3,1 /* delay slot */ |
9b133f8d8 microblaze: Chang... |
227 |
0: |
ca3865bae microblaze: Suppo... |
228 |
addik r3,r7,0 |
0d6de9532 microblaze_mmu_v2... |
229 230 |
rtsd r15,8 nop |
13851966d microblaze: Add .... |
231 |
.size __copy_tofrom_user, . - __copy_tofrom_user |
0d6de9532 microblaze_mmu_v2... |
232 |
|
0d6de9532 microblaze_mmu_v2... |
233 |
.section __ex_table,"a" |
c83858b3e microblaze: Chang... |
234 235 |
.word bu1, 0b; .word bu2, 0b; |
eedac7914 microblaze: Separ... |
236 |
.text |