uaccess_old.S 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * Copyright (C) 2009 Michal Simek <monstr@monstr.eu>
  3. * Copyright (C) 2009 PetaLogix
  4. * Copyright (C) 2007 LynuxWorks, Inc.
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file "COPYING" in the main directory of this archive
  8. * for more details.
  9. */
  10. #include <linux/errno.h>
  11. #include <linux/linkage.h>
  12. /*
  13. * int __strncpy_user(char *to, char *from, int len);
  14. *
  15. * Returns:
  16. * -EFAULT for an exception
  17. * len if we hit the buffer limit
  18. * bytes copied
  19. */
  20. .text
  21. .globl __strncpy_user;
  22. .align 4;
  23. __strncpy_user:
  24. /*
  25. * r5 - to
  26. * r6 - from
  27. * r7 - len
  28. * r3 - temp count
  29. * r4 - temp val
  30. */
  31. addik r3,r7,0 /* temp_count = len */
  32. beqi r3,3f
  33. 1:
  34. lbu r4,r6,r0
  35. sb r4,r5,r0
  36. addik r3,r3,-1
  37. beqi r3,2f /* break on len */
  38. addik r5,r5,1
  39. bneid r4,1b
  40. addik r6,r6,1 /* delay slot */
  41. addik r3,r3,1 /* undo "temp_count--" */
  42. 2:
  43. rsubk r3,r3,r7 /* temp_count = len - temp_count */
  44. 3:
  45. rtsd r15,8
  46. nop
  47. .section .fixup, "ax"
  48. .align 2
  49. 4:
  50. brid 3b
  51. addik r3,r0, -EFAULT
  52. .section __ex_table, "a"
  53. .word 1b,4b
  54. /*
  55. * int __strnlen_user(char __user *str, int maxlen);
  56. *
  57. * Returns:
  58. * 0 on error
  59. * maxlen + 1 if no NUL byte found within maxlen bytes
  60. * size of the string (including NUL byte)
  61. */
  62. .text
  63. .globl __strnlen_user;
  64. .align 4;
  65. __strnlen_user:
  66. addik r3,r6,0
  67. beqi r3,3f
  68. 1:
  69. lbu r4,r5,r0
  70. beqid r4,2f /* break on NUL */
  71. addik r3,r3,-1 /* delay slot */
  72. bneid r3,1b
  73. addik r5,r5,1 /* delay slot */
  74. addik r3,r3,-1 /* for break on len */
  75. 2:
  76. rsubk r3,r3,r6
  77. 3:
  78. rtsd r15,8
  79. nop
  80. .section .fixup,"ax"
  81. 4:
  82. brid 3b
  83. addk r3,r0,r0
  84. .section __ex_table,"a"
  85. .word 1b,4b
  86. /*
  87. * int __copy_tofrom_user(char *to, char *from, int len)
  88. * Return:
  89. * 0 on success
  90. * number of not copied bytes on error
  91. */
  92. .text
  93. .globl __copy_tofrom_user;
  94. .align 4;
  95. __copy_tofrom_user:
  96. /*
  97. * r5 - to
  98. * r6 - from
  99. * r7, r3 - count
  100. * r4 - tempval
  101. */
  102. addik r3,r7,0
  103. beqi r3,3f
  104. 1:
  105. lbu r4,r6,r0
  106. addik r6,r6,1
  107. 2:
  108. sb r4,r5,r0
  109. addik r3,r3,-1
  110. bneid r3,1b
  111. addik r5,r5,1 /* delay slot */
  112. 3:
  113. rtsd r15,8
  114. nop
  115. .section __ex_table,"a"
  116. .word 1b,3b,2b,3b