clear_user.S 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. #include <asm/unwind.h>
  13. #include <asm/export.h>
  14. .text
  15. /* Prototype: unsigned long arm_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. ENTRY(__clear_user_std)
  22. WEAK(arm_clear_user)
  23. UNWIND(.fnstart)
  24. UNWIND(.save {r1, lr})
  25. stmfd sp!, {r1, lr}
  26. mov r2, #0
  27. cmp r1, #4
  28. blt 2f
  29. ands ip, r0, #3
  30. beq 1f
  31. cmp ip, #2
  32. strusr r2, r0, 1
  33. strusr r2, r0, 1, le
  34. strusr r2, r0, 1, lt
  35. rsb ip, ip, #4
  36. sub r1, r1, ip @ 7 6 5 4 3 2 1
  37. 1: subs r1, r1, #8 @ -1 -2 -3 -4 -5 -6 -7
  38. strusr r2, r0, 4, pl, rept=2
  39. bpl 1b
  40. adds r1, r1, #4 @ 3 2 1 0 -1 -2 -3
  41. strusr r2, r0, 4, pl
  42. 2: tst r1, #2 @ 1x 1x 0x 0x 1x 1x 0x
  43. strusr r2, r0, 1, ne, rept=2
  44. tst r1, #1 @ x1 x0 x1 x0 x1 x0 x1
  45. it ne @ explicit IT needed for the label
  46. USER( strnebt r2, [r0])
  47. mov r0, #0
  48. ldmfd sp!, {r1, pc}
  49. UNWIND(.fnend)
  50. ENDPROC(arm_clear_user)
  51. ENDPROC(__clear_user_std)
  52. #ifndef CONFIG_UACCESS_WITH_MEMCPY
  53. EXPORT_SYMBOL(arm_clear_user)
  54. #endif
  55. .pushsection .text.fixup,"ax"
  56. .align 0
  57. 9001: ldmfd sp!, {r0, pc}
  58. .popsection