2 * arch/ppc64/lib/copyuser.S
4 * Copyright (C) 2002 Paul Mackerras, IBM Corp.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
11 #include <asm/processor.h>
12 #include <asm/ppc_asm.h>
15 _GLOBAL(__copy_tofrom_user)
16 /* first check for a whole page copy on a page boundary */
20 neg r6,r3 /* LS 3 bits = # bytes to 8-byte dest bdry */
23 crand cr0*4+2,cr0*4+2,cr6*4+2
83 24: ld r9,0(r4) /* 3+2n loads, 2+2n stores */
94 28: ld r0,0(r4) /* 4+2n loads, 3+2n stores */
140 mtcrf 0x01,r6 /* put #bytes to 8B bdry into cr7 */
185 * exception handlers follow
186 * we have to return the number of bytes not copied
187 * for an exception on a load, we set the rest of the destination to 0
220 * here we have had a fault on a load and r3 points to the first
221 * unmodified byte of the destination
228 subf r5,r6,r5 /* #bytes left to go */
231 * first see if we can copy any more bytes before hitting another exception
239 li r3,0 /* huh? all copied successfully this time? */
243 * here we have trapped again, need to clear ctr bytes starting at r3
248 mr r3,r5 /* return the number of bytes not copied */
272 * exception handlers for stores: we just need to work
273 * out how many bytes weren't copied
305 subf r3,r3,r6 /* #bytes not copied */
309 blr /* #bytes not copied in r3 */
311 .section __ex_table,"a"
364 * Routine to copy a whole page of data, optimized for POWER4.
365 * On POWER4 it is more than 50% faster than the simple loop
366 * above (following the .Ldst_aligned label) but it runs slightly
483 * on an exception, reset to the beginning and jump back into the
484 * standard __copy_tofrom_user
503 .section __ex_table,"a"