2 * String handling functions for PowerPC.
4 * Copyright (C) 1996 Paul Mackerras.
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/errno.h>
13 #include <asm/ppc_asm.h>
33 bdnzf 2,1b /* dec ctr, branch if ctr != 0 && !cr0.eq */
71 andi. r0,r0,7 /* # bytes to be 8-byte aligned */
73 cmplw cr1,r5,r0 /* do we get that far? */
78 beq+ 3f /* if already 8-byte aligned */
135 bgt .backwards_memcpy
138 _GLOBAL(backwards_memcpy)
139 rlwinm. r7,r5,32-3,3,31 /* r0 = r5 >> 3 */
169 rlwinm. r7,r5,32-3,3,31
200 _GLOBAL(__clear_user)
206 /* clear a single word */
209 /* clear word sized chunks */
219 /* clear byte sized chunks */
236 .section __ex_table,"a"
243 /* r3 = dst, r4 = src, r5 = count */
244 _GLOBAL(__strncpy_from_user)
253 bdnzf 2,1b /* dec ctr, branch if ctr != 0 && !cr0.eq */
261 .section __ex_table,"a"
266 /* r3 = str, r4 = len (> 0) */
267 _GLOBAL(__strnlen_user)
269 mtctr r4 /* ctr = len */
270 1: lbzu r0,1(r7) /* get next byte */
272 bdnzf 2,1b /* loop if --ctr != 0 && byte != 0 */
274 subf r3,r3,r7 /* number of bytes we have looked at */
275 beqlr /* return if we found a 0 byte */
276 cmpw 0,r3,r4 /* did we look at all len bytes? */
277 blt 99f /* if not, must have hit top */
278 addi r3,r4,1 /* return len + 1 to indicate no null found */
280 99: li r3,0 /* bad address, return 0 */
283 .section __ex_table,"a"