copy_to_user.S 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /*
  2. * linux/arch/unicore32/lib/copy_to_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. * Prototype:
  16. *
  17. * size_t __copy_to_user(void *to, const void *from, size_t n)
  18. *
  19. * Purpose:
  20. *
  21. * copy a block to user memory from kernel memory
  22. *
  23. * Params:
  24. *
  25. * to = user memory
  26. * from = kernel memory
  27. * n = number of bytes to copy
  28. *
  29. * Return value:
  30. *
  31. * Number of bytes NOT copied.
  32. */
  33. .macro ldr1w ptr reg abort
  34. ldw.w \reg, [\ptr]+, #4
  35. .endm
  36. .macro ldr4w ptr reg1 reg2 reg3 reg4 abort
  37. ldm.w (\reg1, \reg2, \reg3, \reg4), [\ptr]+
  38. .endm
  39. .macro ldr8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort
  40. ldm.w (\reg1, \reg2, \reg3, \reg4, \reg5, \reg6, \reg7, \reg8), [\ptr]+
  41. .endm
  42. .macro ldr1b ptr reg cond=al abort
  43. notcond \cond, .+8
  44. ldb.w \reg, [\ptr]+, #1
  45. .endm
  46. .macro str1w ptr reg abort
  47. strusr \reg, \ptr, 4, abort=\abort
  48. .endm
  49. .macro str8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort
  50. 100: stm.w (\reg1, \reg2, \reg3, \reg4, \reg5, \reg6, \reg7, \reg8), [\ptr]+
  51. .pushsection __ex_table, "a"
  52. .long 100b, \abort
  53. .popsection
  54. .endm
  55. .macro str1b ptr reg cond=al abort
  56. strusr \reg, \ptr, 1, \cond, abort=\abort
  57. .endm
  58. .macro enter
  59. mov r3, #0
  60. stm.w (r0, r2, r3), [sp-]
  61. .endm
  62. .macro exit
  63. add sp, sp, #8
  64. ldm.w (r0), [sp]+
  65. mov pc, lr
  66. .endm
  67. .text
  68. WEAK(__copy_to_user)
  69. #include "copy_template.S"
  70. ENDPROC(__copy_to_user)
  71. .pushsection .fixup,"ax"
  72. .align 0
  73. copy_abort_preamble
  74. ldm.w (r1, r2, r3), [sp]+
  75. sub r0, r0, r1
  76. rsub r0, r0, r2
  77. copy_abort_end
  78. .popsection