csumpartialcopyuser.S 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * linux/arch/arm26/lib/csumpartialcopyuser.S
  3. *
  4. * Copyright (C) 1995-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/errno.h>
  13. #include <asm/asm-offsets.h>
  14. .text
  15. .macro save_regs
  16. stmfd sp!, {r1 - r2, r4 - r9, fp, ip, lr, pc}
  17. mov r9, sp, lsr #13
  18. mov r9, r9, lsl #13
  19. ldr r9, [r9, #TSK_ADDR_LIMIT]
  20. mov r9, r9, lsr #24
  21. .endm
  22. .macro load_regs,flags
  23. ldm\flags fp, {r1, r2, r4-r9, fp, sp, pc}^
  24. .endm
  25. .macro load1b, reg1
  26. tst r9, #0x01
  27. 9999: ldreqbt \reg1, [r0], #1
  28. ldrneb \reg1, [r0], #1
  29. .section __ex_table, "a"
  30. .align 3
  31. .long 9999b, 6001f
  32. .previous
  33. .endm
  34. .macro load2b, reg1, reg2
  35. tst r9, #0x01
  36. 9999: ldreqbt \reg1, [r0], #1
  37. ldrneb \reg1, [r0], #1
  38. 9998: ldreqbt \reg2, [r0], #1
  39. ldrneb \reg2, [r0], #1
  40. .section __ex_table, "a"
  41. .long 9999b, 6001f
  42. .long 9998b, 6001f
  43. .previous
  44. .endm
  45. .macro load1l, reg1
  46. tst r9, #0x01
  47. 9999: ldreqt \reg1, [r0], #4
  48. ldrne \reg1, [r0], #4
  49. .section __ex_table, "a"
  50. .align 3
  51. .long 9999b, 6001f
  52. .previous
  53. .endm
  54. .macro load2l, reg1, reg2
  55. tst r9, #0x01
  56. ldmneia r0!, {\reg1, \reg2}
  57. 9999: ldreqt \reg1, [r0], #4
  58. 9998: ldreqt \reg2, [r0], #4
  59. .section __ex_table, "a"
  60. .long 9999b, 6001f
  61. .long 9998b, 6001f
  62. .previous
  63. .endm
  64. .macro load4l, reg1, reg2, reg3, reg4
  65. tst r9, #0x01
  66. ldmneia r0!, {\reg1, \reg2, \reg3, \reg4}
  67. 9999: ldreqt \reg1, [r0], #4
  68. 9998: ldreqt \reg2, [r0], #4
  69. 9997: ldreqt \reg3, [r0], #4
  70. 9996: ldreqt \reg4, [r0], #4
  71. .section __ex_table, "a"
  72. .long 9999b, 6001f
  73. .long 9998b, 6001f
  74. .long 9997b, 6001f
  75. .long 9996b, 6001f
  76. .previous
  77. .endm
  78. /*
  79. * unsigned int
  80. * csum_partial_copy_from_user(const char *src, char *dst, int len, int sum, int *err_ptr)
  81. * r0 = src, r1 = dst, r2 = len, r3 = sum, [sp] = *err_ptr
  82. * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
  83. */
  84. #define FN_ENTRY ENTRY(csum_partial_copy_from_user)
  85. #include "csumpartialcopygeneric.S"
  86. /*
  87. * FIXME: minor buglet here
  88. * We don't return the checksum for the data present in the buffer. To do
  89. * so properly, we would have to add in whatever registers were loaded before
  90. * the fault, which, with the current asm above is not predictable.
  91. */
  92. .align 4
  93. 6001: mov r4, #-EFAULT
  94. ldr r5, [fp, #4] @ *err_ptr
  95. str r4, [r5]
  96. ldmia sp, {r1, r2} @ retrieve dst, len
  97. add r2, r2, r1
  98. mov r0, #0 @ zero the buffer
  99. 6002: teq r2, r1
  100. strneb r0, [r1], #1
  101. bne 6002b
  102. load_regs ea