clear_user.S 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * linux/arch/arm/lib/clear_user.S
  3. *
  4. * Copyright (C) 1995, 1996,1997,1998 Russell King
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/linkage.h>
  11. #include <asm/assembler.h>
  12. .text
  13. /* Prototype: int __clear_user(void *addr, size_t sz)
  14. * Purpose : clear some user memory
  15. * Params : addr - user memory address to clear
  16. * : sz - number of bytes to clear
  17. * Returns : number of bytes NOT cleared
  18. */
  19. ENTRY(__clear_user)
  20. stmfd sp!, {r1, lr}
  21. mov r2, #0
  22. cmp r1, #4
  23. blt 2f
  24. ands ip, r0, #3
  25. beq 1f
  26. cmp ip, #2
  27. USER( strbt r2, [r0], #1)
  28. USER( strlebt r2, [r0], #1)
  29. USER( strltbt r2, [r0], #1)
  30. rsb ip, ip, #4
  31. sub r1, r1, ip @ 7 6 5 4 3 2 1
  32. 1: subs r1, r1, #8 @ -1 -2 -3 -4 -5 -6 -7
  33. USER( strplt r2, [r0], #4)
  34. USER( strplt r2, [r0], #4)
  35. bpl 1b
  36. adds r1, r1, #4 @ 3 2 1 0 -1 -2 -3
  37. USER( strplt r2, [r0], #4)
  38. 2: tst r1, #2 @ 1x 1x 0x 0x 1x 1x 0x
  39. USER( strnebt r2, [r0], #1)
  40. USER( strnebt r2, [r0], #1)
  41. tst r1, #1 @ x1 x0 x1 x0 x1 x0 x1
  42. USER( strnebt r2, [r0], #1)
  43. mov r0, #0
  44. ldmfd sp!, {r1, pc}
  45. .section .fixup,"ax"
  46. .align 0
  47. 9001: ldmfd sp!, {r0, pc}
  48. .previous