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 */
98 _GLOBAL(backwards_memcpy)
99 rlwinm. r7,r5,32-3,3,31 /* r0 = r5 >> 3 */
129 rlwinm. r7,r5,32-3,3,31
160 _GLOBAL(__clear_user)
166 /* clear a single word */
169 /* clear word sized chunks */
179 /* clear byte sized chunks */
196 .section __ex_table,"a"
203 /* r3 = dst, r4 = src, r5 = count */
204 _GLOBAL(__strncpy_from_user)
213 bdnzf 2,1b /* dec ctr, branch if ctr != 0 && !cr0.eq */
221 .section __ex_table,"a"
226 /* r3 = str, r4 = len (> 0) */
227 _GLOBAL(__strnlen_user)
229 mtctr r4 /* ctr = len */
230 1: lbzu r0,1(r7) /* get next byte */
232 bdnzf 2,1b /* loop if --ctr != 0 && byte != 0 */
234 subf r3,r3,r7 /* number of bytes we have looked at */
235 beqlr /* return if we found a 0 byte */
236 cmpw 0,r3,r4 /* did we look at all len bytes? */
237 blt 99f /* if not, must have hit top */
238 addi r3,r4,1 /* return len + 1 to indicate no null found */
240 99: li r3,0 /* bad address, return 0 */
243 .section __ex_table,"a"