clear_user.S 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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. .text
  15. /* Prototype: int __clear_user(void *addr, size_t sz)
  16. * Purpose : clear some user memory
  17. * Params : addr - user memory address to clear
  18. * : sz - number of bytes to clear
  19. * Returns : number of bytes NOT cleared
  20. */
  21. WEAK(__clear_user)
  22. stm.w (lr), [sp-]
  23. stm.w (r1), [sp-]
  24. mov r2, #0
  25. csub.a r1, #4
  26. bsl 2f
  27. and.a ip, r0, #3
  28. beq 1f
  29. csub.a ip, #2
  30. strusr r2, r0, 1
  31. strusr r2, r0, 1, el
  32. strusr r2, r0, 1, sl
  33. rsub ip, ip, #4
  34. sub r1, r1, ip @ 7 6 5 4 3 2 1
  35. 1: sub.a r1, r1, #8 @ -1 -2 -3 -4 -5 -6 -7
  36. strusr r2, r0, 4, ns, rept=2
  37. bns 1b
  38. add.a r1, r1, #4 @ 3 2 1 0 -1 -2 -3
  39. strusr r2, r0, 4, ns
  40. 2: cand.a r1, #2 @ 1x 1x 0x 0x 1x 1x 0x
  41. strusr r2, r0, 1, ne, rept=2
  42. cand.a r1, #1 @ x1 x0 x1 x0 x1 x0 x1
  43. beq 3f
  44. USER( stb.u r2, [r0])
  45. 3: mov r0, #0
  46. ldm.w (r1), [sp]+
  47. ldm.w (pc), [sp]+
  48. ENDPROC(__clear_user)
  49. .pushsection .fixup,"ax"
  50. .align 0
  51. 9001: ldm.w (r0), [sp]+
  52. ldm.w (pc), [sp]+
  53. .popsection