bzero.S 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /* bzero.S: Simple prefetching memset, bzero, and clear_user
  2. * implementations.
  3. *
  4. * Copyright (C) 2005 David S. Miller <davem@davemloft.net>
  5. */
  6. #include <linux/linkage.h>
  7. #include <asm/export.h>
  8. .text
  9. ENTRY(memset) /* %o0=buf, %o1=pat, %o2=len */
  10. and %o1, 0xff, %o3
  11. mov %o2, %o1
  12. sllx %o3, 8, %g1
  13. or %g1, %o3, %o2
  14. sllx %o2, 16, %g1
  15. or %g1, %o2, %o2
  16. sllx %o2, 32, %g1
  17. ba,pt %xcc, 1f
  18. or %g1, %o2, %o2
  19. ENTRY(__bzero) /* %o0=buf, %o1=len */
  20. clr %o2
  21. 1: mov %o0, %o3
  22. brz,pn %o1, __bzero_done
  23. cmp %o1, 16
  24. bl,pn %icc, __bzero_tiny
  25. prefetch [%o0 + 0x000], #n_writes
  26. andcc %o0, 0x3, %g0
  27. be,pt %icc, 2f
  28. 1: stb %o2, [%o0 + 0x00]
  29. add %o0, 1, %o0
  30. andcc %o0, 0x3, %g0
  31. bne,pn %icc, 1b
  32. sub %o1, 1, %o1
  33. 2: andcc %o0, 0x7, %g0
  34. be,pt %icc, 3f
  35. stw %o2, [%o0 + 0x00]
  36. sub %o1, 4, %o1
  37. add %o0, 4, %o0
  38. 3: and %o1, 0x38, %g1
  39. cmp %o1, 0x40
  40. andn %o1, 0x3f, %o4
  41. bl,pn %icc, 5f
  42. and %o1, 0x7, %o1
  43. prefetch [%o0 + 0x040], #n_writes
  44. prefetch [%o0 + 0x080], #n_writes
  45. prefetch [%o0 + 0x0c0], #n_writes
  46. prefetch [%o0 + 0x100], #n_writes
  47. prefetch [%o0 + 0x140], #n_writes
  48. 4: prefetch [%o0 + 0x180], #n_writes
  49. stx %o2, [%o0 + 0x00]
  50. stx %o2, [%o0 + 0x08]
  51. stx %o2, [%o0 + 0x10]
  52. stx %o2, [%o0 + 0x18]
  53. stx %o2, [%o0 + 0x20]
  54. stx %o2, [%o0 + 0x28]
  55. stx %o2, [%o0 + 0x30]
  56. stx %o2, [%o0 + 0x38]
  57. subcc %o4, 0x40, %o4
  58. bne,pt %icc, 4b
  59. add %o0, 0x40, %o0
  60. brz,pn %g1, 6f
  61. nop
  62. 5: stx %o2, [%o0 + 0x00]
  63. subcc %g1, 8, %g1
  64. bne,pt %icc, 5b
  65. add %o0, 0x8, %o0
  66. 6: brz,pt %o1, __bzero_done
  67. nop
  68. __bzero_tiny:
  69. 1: stb %o2, [%o0 + 0x00]
  70. subcc %o1, 1, %o1
  71. bne,pt %icc, 1b
  72. add %o0, 1, %o0
  73. __bzero_done:
  74. retl
  75. mov %o3, %o0
  76. ENDPROC(__bzero)
  77. ENDPROC(memset)
  78. EXPORT_SYMBOL(__bzero)
  79. EXPORT_SYMBOL(memset)
  80. #define EX_ST(x,y) \
  81. 98: x,y; \
  82. .section __ex_table,"a";\
  83. .align 4; \
  84. .word 98b, __retl_o1; \
  85. .text; \
  86. .align 4;
  87. ENTRY(__clear_user) /* %o0=buf, %o1=len */
  88. brz,pn %o1, __clear_user_done
  89. cmp %o1, 16
  90. bl,pn %icc, __clear_user_tiny
  91. EX_ST(prefetcha [%o0 + 0x00] %asi, #n_writes)
  92. andcc %o0, 0x3, %g0
  93. be,pt %icc, 2f
  94. 1: EX_ST(stba %g0, [%o0 + 0x00] %asi)
  95. add %o0, 1, %o0
  96. andcc %o0, 0x3, %g0
  97. bne,pn %icc, 1b
  98. sub %o1, 1, %o1
  99. 2: andcc %o0, 0x7, %g0
  100. be,pt %icc, 3f
  101. EX_ST(stwa %g0, [%o0 + 0x00] %asi)
  102. sub %o1, 4, %o1
  103. add %o0, 4, %o0
  104. 3: and %o1, 0x38, %g1
  105. cmp %o1, 0x40
  106. andn %o1, 0x3f, %o4
  107. bl,pn %icc, 5f
  108. and %o1, 0x7, %o1
  109. EX_ST(prefetcha [%o0 + 0x040] %asi, #n_writes)
  110. EX_ST(prefetcha [%o0 + 0x080] %asi, #n_writes)
  111. EX_ST(prefetcha [%o0 + 0x0c0] %asi, #n_writes)
  112. EX_ST(prefetcha [%o0 + 0x100] %asi, #n_writes)
  113. EX_ST(prefetcha [%o0 + 0x140] %asi, #n_writes)
  114. 4: EX_ST(prefetcha [%o0 + 0x180] %asi, #n_writes)
  115. EX_ST(stxa %g0, [%o0 + 0x00] %asi)
  116. EX_ST(stxa %g0, [%o0 + 0x08] %asi)
  117. EX_ST(stxa %g0, [%o0 + 0x10] %asi)
  118. EX_ST(stxa %g0, [%o0 + 0x18] %asi)
  119. EX_ST(stxa %g0, [%o0 + 0x20] %asi)
  120. EX_ST(stxa %g0, [%o0 + 0x28] %asi)
  121. EX_ST(stxa %g0, [%o0 + 0x30] %asi)
  122. EX_ST(stxa %g0, [%o0 + 0x38] %asi)
  123. subcc %o4, 0x40, %o4
  124. bne,pt %icc, 4b
  125. add %o0, 0x40, %o0
  126. brz,pn %g1, 6f
  127. nop
  128. 5: EX_ST(stxa %g0, [%o0 + 0x00] %asi)
  129. subcc %g1, 8, %g1
  130. bne,pt %icc, 5b
  131. add %o0, 0x8, %o0
  132. 6: brz,pt %o1, __clear_user_done
  133. nop
  134. __clear_user_tiny:
  135. 1: EX_ST(stba %g0, [%o0 + 0x00] %asi)
  136. subcc %o1, 1, %o1
  137. bne,pt %icc, 1b
  138. add %o0, 1, %o0
  139. __clear_user_done:
  140. retl
  141. clr %o0
  142. ENDPROC(__clear_user)
  143. EXPORT_SYMBOL(__clear_user)