usercopy_32.S 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright 2010 Tilera Corporation. All Rights Reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation, version 2.
  7. *
  8. * This program is distributed in the hope that it will be useful, but
  9. * WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
  11. * NON INFRINGEMENT. See the GNU General Public License for
  12. * more details.
  13. */
  14. #include <linux/linkage.h>
  15. #include <asm/errno.h>
  16. #include <asm/cache.h>
  17. #include <arch/chip.h>
  18. /* Access user memory, but use MMU to avoid propagating kernel exceptions. */
  19. /*
  20. * clear_user_asm takes the user target address in r0 and the
  21. * number of bytes to zero in r1.
  22. * It returns the number of uncopiable bytes (hopefully zero) in r0.
  23. * Note that we don't use a separate .fixup section here since we fall
  24. * through into the "fixup" code as the last straight-line bundle anyway.
  25. */
  26. STD_ENTRY(clear_user_asm)
  27. { bz r1, 2f; or r2, r0, r1 }
  28. andi r2, r2, 3
  29. bzt r2, .Lclear_aligned_user_asm
  30. 1: { sb r0, zero; addi r0, r0, 1; addi r1, r1, -1 }
  31. bnzt r1, 1b
  32. 2: { move r0, r1; jrp lr }
  33. .pushsection __ex_table,"a"
  34. .align 4
  35. .word 1b, 2b
  36. .popsection
  37. .Lclear_aligned_user_asm:
  38. 1: { sw r0, zero; addi r0, r0, 4; addi r1, r1, -4 }
  39. bnzt r1, 1b
  40. 2: { move r0, r1; jrp lr }
  41. STD_ENDPROC(clear_user_asm)
  42. .pushsection __ex_table,"a"
  43. .align 4
  44. .word 1b, 2b
  45. .popsection
  46. /*
  47. * flush_user_asm takes the user target address in r0 and the
  48. * number of bytes to flush in r1.
  49. * It returns the number of unflushable bytes (hopefully zero) in r0.
  50. */
  51. STD_ENTRY(flush_user_asm)
  52. bz r1, 2f
  53. { movei r2, L2_CACHE_BYTES; add r1, r0, r1 }
  54. { sub r2, zero, r2; addi r1, r1, L2_CACHE_BYTES-1 }
  55. { and r0, r0, r2; and r1, r1, r2 }
  56. { sub r1, r1, r0 }
  57. 1: { flush r0; addi r1, r1, -CHIP_FLUSH_STRIDE() }
  58. { addi r0, r0, CHIP_FLUSH_STRIDE(); bnzt r1, 1b }
  59. 2: { move r0, r1; jrp lr }
  60. STD_ENDPROC(flush_user_asm)
  61. .pushsection __ex_table,"a"
  62. .align 4
  63. .word 1b, 2b
  64. .popsection
  65. /*
  66. * finv_user_asm takes the user target address in r0 and the
  67. * number of bytes to flush-invalidate in r1.
  68. * It returns the number of not finv'able bytes (hopefully zero) in r0.
  69. */
  70. STD_ENTRY(finv_user_asm)
  71. bz r1, 2f
  72. { movei r2, L2_CACHE_BYTES; add r1, r0, r1 }
  73. { sub r2, zero, r2; addi r1, r1, L2_CACHE_BYTES-1 }
  74. { and r0, r0, r2; and r1, r1, r2 }
  75. { sub r1, r1, r0 }
  76. 1: { finv r0; addi r1, r1, -CHIP_FINV_STRIDE() }
  77. { addi r0, r0, CHIP_FINV_STRIDE(); bnzt r1, 1b }
  78. 2: { move r0, r1; jrp lr }
  79. STD_ENDPROC(finv_user_asm)
  80. .pushsection __ex_table,"a"
  81. .align 4
  82. .word 1b, 2b
  83. .popsection