copy_to_user.S 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * linux/arch/arm/lib/copy_to_user.S
  3. *
  4. * Author: Nicolas Pitre
  5. * Created: Sep 29, 2005
  6. * Copyright: MontaVista Software, Inc.
  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. #include <asm/unwind.h>
  15. /*
  16. * Prototype:
  17. *
  18. * size_t arm_copy_to_user(void *to, const void *from, size_t n)
  19. *
  20. * Purpose:
  21. *
  22. * copy a block to user memory from kernel memory
  23. *
  24. * Params:
  25. *
  26. * to = user memory
  27. * from = kernel memory
  28. * n = number of bytes to copy
  29. *
  30. * Return value:
  31. *
  32. * Number of bytes NOT copied.
  33. */
  34. #define LDR1W_SHIFT 0
  35. #ifndef CONFIG_THUMB2_KERNEL
  36. #define STR1W_SHIFT 0
  37. #else
  38. #define STR1W_SHIFT 1
  39. #endif
  40. .macro ldr1w ptr reg abort
  41. W(ldr) \reg, [\ptr], #4
  42. .endm
  43. .macro ldr4w ptr reg1 reg2 reg3 reg4 abort
  44. ldmia \ptr!, {\reg1, \reg2, \reg3, \reg4}
  45. .endm
  46. .macro ldr8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort
  47. ldmia \ptr!, {\reg1, \reg2, \reg3, \reg4, \reg5, \reg6, \reg7, \reg8}
  48. .endm
  49. .macro ldr1b ptr reg cond=al abort
  50. ldr\cond\()b \reg, [\ptr], #1
  51. .endm
  52. .macro str1w ptr reg abort
  53. strusr \reg, \ptr, 4, abort=\abort
  54. .endm
  55. .macro str8w ptr reg1 reg2 reg3 reg4 reg5 reg6 reg7 reg8 abort
  56. str1w \ptr, \reg1, \abort
  57. str1w \ptr, \reg2, \abort
  58. str1w \ptr, \reg3, \abort
  59. str1w \ptr, \reg4, \abort
  60. str1w \ptr, \reg5, \abort
  61. str1w \ptr, \reg6, \abort
  62. str1w \ptr, \reg7, \abort
  63. str1w \ptr, \reg8, \abort
  64. .endm
  65. .macro str1b ptr reg cond=al abort
  66. strusr \reg, \ptr, 1, \cond, abort=\abort
  67. .endm
  68. .macro enter reg1 reg2
  69. mov r3, #0
  70. stmdb sp!, {r0, r2, r3, \reg1, \reg2}
  71. .endm
  72. .macro usave reg1 reg2
  73. UNWIND( .save {r0, r2, r3, \reg1, \reg2} )
  74. .endm
  75. .macro exit reg1 reg2
  76. add sp, sp, #8
  77. ldmfd sp!, {r0, \reg1, \reg2}
  78. .endm
  79. .text
  80. ENTRY(__copy_to_user_std)
  81. WEAK(arm_copy_to_user)
  82. #include "copy_template.S"
  83. ENDPROC(arm_copy_to_user)
  84. ENDPROC(__copy_to_user_std)
  85. .pushsection .text.fixup,"ax"
  86. .align 0
  87. copy_abort_preamble
  88. ldmfd sp!, {r1, r2, r3}
  89. sub r0, r0, r1
  90. rsb r0, r0, r2
  91. copy_abort_end
  92. .popsection