putuser.S 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * linux/arch/arm26/lib/putuser.S
  3. *
  4. * Copyright (C) 2001 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. * Idea from x86 version, (C) Copyright 1998 Linus Torvalds
  11. *
  12. * These functions have a non-standard call interface to make
  13. * them more efficient, especially as they return an error
  14. * value in addition to the "real" return value.
  15. *
  16. * __put_user_X
  17. *
  18. * Inputs: r0 contains the address
  19. * r1, r2 contains the value
  20. * Outputs: r0 is the error code
  21. * lr corrupted
  22. *
  23. * No other registers must be altered. (see include/asm-arm/uaccess.h
  24. * for specific ASM register usage).
  25. *
  26. * Note that ADDR_LIMIT is either 0 or 0xc0000000
  27. * Note also that it is intended that __put_user_bad is not global.
  28. */
  29. #include <asm/asm-offsets.h>
  30. #include <asm/thread_info.h>
  31. #include <asm/errno.h>
  32. .global __put_user_1
  33. __put_user_1:
  34. bic r2, sp, #0x1f00
  35. bic r2, r2, #0x00ff
  36. str lr, [sp, #-4]!
  37. ldr r2, [r2, #TI_ADDR_LIMIT]
  38. sub r2, r2, #1
  39. cmp r0, r2
  40. bge __put_user_bad
  41. 1: cmp r0, #0x02000000
  42. strlsbt r1, [r0]
  43. strgeb r1, [r0]
  44. mov r0, #0
  45. ldmfd sp!, {pc}^
  46. .global __put_user_2
  47. __put_user_2:
  48. bic r2, sp, #0x1f00
  49. bic r2, r2, #0x00ff
  50. str lr, [sp, #-4]!
  51. ldr r2, [r2, #TI_ADDR_LIMIT]
  52. sub r2, r2, #2
  53. cmp r0, r2
  54. bge __put_user_bad
  55. 2: cmp r0, #0x02000000
  56. strlsbt r1, [r0], #1
  57. strgeb r1, [r0], #1
  58. mov r1, r1, lsr #8
  59. 3: strlsbt r1, [r0]
  60. strgeb r1, [r0]
  61. mov r0, #0
  62. ldmfd sp!, {pc}^
  63. .global __put_user_4
  64. __put_user_4:
  65. bic r2, sp, #0x1f00
  66. bic r2, r2, #0x00ff
  67. str lr, [sp, #-4]!
  68. ldr r2, [r2, #TI_ADDR_LIMIT]
  69. sub r2, r2, #4
  70. cmp r0, r2
  71. 4: bge __put_user_bad
  72. cmp r0, #0x02000000
  73. strlst r1, [r0]
  74. strge r1, [r0]
  75. mov r0, #0
  76. ldmfd sp!, {pc}^
  77. .global __put_user_8
  78. __put_user_8:
  79. bic ip, sp, #0x1f00
  80. bic ip, ip, #0x00ff
  81. str lr, [sp, #-4]!
  82. ldr ip, [ip, #TI_ADDR_LIMIT]
  83. sub ip, ip, #8
  84. cmp r0, ip
  85. bge __put_user_bad
  86. cmp r0, #0x02000000
  87. 5: strlst r1, [r0], #4
  88. 6: strlst r2, [r0]
  89. strge r1, [r0], #4
  90. strge r2, [r0]
  91. mov r0, #0
  92. ldmfd sp!, {pc}^
  93. __put_user_bad:
  94. mov r0, #-EFAULT
  95. mov pc, lr
  96. .section __ex_table, "a"
  97. .long 1b, __put_user_bad
  98. .long 2b, __put_user_bad
  99. .long 3b, __put_user_bad
  100. .long 4b, __put_user_bad
  101. .long 5b, __put_user_bad
  102. .long 6b, __put_user_bad
  103. .previous