1/* 2 * linux/arch/unicore32/lib/clear_user.S 3 * 4 * Code specific to PKUnity SoC and UniCore ISA 5 * 6 * Copyright (C) 2001-2010 GUAN Xue-tao 7 * 8 * This program is free software; you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License version 2 as 10 * published by the Free Software Foundation. 11 */ 12#include <linux/linkage.h> 13#include <asm/assembler.h> 14 15 .text 16 17/* Prototype: int __clear_user(void *addr, size_t sz) 18 * Purpose : clear some user memory 19 * Params : addr - user memory address to clear 20 * : sz - number of bytes to clear 21 * Returns : number of bytes NOT cleared 22 */ 23WEAK(__clear_user) 24 stm.w (lr), [sp-] 25 stm.w (r1), [sp-] 26 mov r2, #0 27 csub.a r1, #4 28 bsl 2f 29 and.a ip, r0, #3 30 beq 1f 31 csub.a ip, #2 32 strusr r2, r0, 1 33 strusr r2, r0, 1, el 34 strusr r2, r0, 1, sl 35 rsub ip, ip, #4 36 sub r1, r1, ip @ 7 6 5 4 3 2 1 371: sub.a r1, r1, #8 @ -1 -2 -3 -4 -5 -6 -7 38 strusr r2, r0, 4, ns, rept=2 39 bns 1b 40 add.a r1, r1, #4 @ 3 2 1 0 -1 -2 -3 41 strusr r2, r0, 4, ns 422: cand.a r1, #2 @ 1x 1x 0x 0x 1x 1x 0x 43 strusr r2, r0, 1, ne, rept=2 44 cand.a r1, #1 @ x1 x0 x1 x0 x1 x0 x1 45 beq 3f 46USER( stb.u r2, [r0]) 473: mov r0, #0 48 ldm.w (r1), [sp]+ 49 ldm.w (pc), [sp]+ 50ENDPROC(__clear_user) 51 52 .pushsection .fixup,"ax" 53 .align 0 549001: ldm.w (r0), [sp]+ 55 ldm.w (pc), [sp]+ 56 .popsection 57 58