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. .text
  7. .globl memset
  8. .type memset, #function
  9. 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. .globl __bzero
  20. .type __bzero, #function
  21. __bzero: /* %o0=buf, %o1=len */
  22. clr %o2
  23. 1: mov %o0, %o3
  24. brz,pn %o1, __bzero_done
  25. cmp %o1, 16
  26. bl,pn %icc, __bzero_tiny
  27. prefetch [%o0 + 0x000], #n_writes
  28. andcc %o0, 0x3, %g0
  29. be,pt %icc, 2f
  30. 1: stb %o2, [%o0 + 0x00]
  31. add %o0, 1, %o0
  32. andcc %o0, 0x3, %g0
  33. bne,pn %icc, 1b
  34. sub %o1, 1, %o1
  35. 2: andcc %o0, 0x7, %g0
  36. be,pt %icc, 3f
  37. stw %o2, [%o0 + 0x00]
  38. sub %o1, 4, %o1
  39. add %o0, 4, %o0
  40. 3: and %o1, 0x38, %g1
  41. cmp %o1, 0x40
  42. andn %o1, 0x3f, %o4
  43. bl,pn %icc, 5f
  44. and %o1, 0x7, %o1
  45. prefetch [%o0 + 0x040], #n_writes
  46. prefetch [%o0 + 0x080], #n_writes
  47. prefetch [%o0 + 0x0c0], #n_writes
  48. prefetch [%o0 + 0x100], #n_writes
  49. prefetch [%o0 + 0x140], #n_writes
  50. 4: prefetch [%o0 + 0x180], #n_writes
  51. stx %o2, [%o0 + 0x00]
  52. stx %o2, [%o0 + 0x08]
  53. stx %o2, [%o0 + 0x10]
  54. stx %o2, [%o0 + 0x18]
  55. stx %o2, [%o0 + 0x20]
  56. stx %o2, [%o0 + 0x28]
  57. stx %o2, [%o0 + 0x30]
  58. stx %o2, [%o0 + 0x38]
  59. subcc %o4, 0x40, %o4
  60. bne,pt %icc, 4b
  61. add %o0, 0x40, %o0
  62. brz,pn %g1, 6f
  63. nop
  64. 5: stx %o2, [%o0 + 0x00]
  65. subcc %g1, 8, %g1
  66. bne,pt %icc, 5b
  67. add %o0, 0x8, %o0
  68. 6: brz,pt %o1, __bzero_done
  69. nop
  70. __bzero_tiny:
  71. 1: stb %o2, [%o0 + 0x00]
  72. subcc %o1, 1, %o1
  73. bne,pt %icc, 1b
  74. add %o0, 1, %o0
  75. __bzero_done:
  76. retl
  77. mov %o3, %o0
  78. .size __bzero, .-__bzero
  79. .size memset, .-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. .globl __clear_user
  88. .type __clear_user, #function
  89. __clear_user: /* %o0=buf, %o1=len */
  90. brz,pn %o1, __clear_user_done
  91. cmp %o1, 16
  92. bl,pn %icc, __clear_user_tiny
  93. EX_ST(prefetcha [%o0 + 0x00] %asi, #n_writes)
  94. andcc %o0, 0x3, %g0
  95. be,pt %icc, 2f
  96. 1: EX_ST(stba %g0, [%o0 + 0x00] %asi)
  97. add %o0, 1, %o0
  98. andcc %o0, 0x3, %g0
  99. bne,pn %icc, 1b
  100. sub %o1, 1, %o1
  101. 2: andcc %o0, 0x7, %g0
  102. be,pt %icc, 3f
  103. EX_ST(stwa %g0, [%o0 + 0x00] %asi)
  104. sub %o1, 4, %o1
  105. add %o0, 4, %o0
  106. 3: and %o1, 0x38, %g1
  107. cmp %o1, 0x40
  108. andn %o1, 0x3f, %o4
  109. bl,pn %icc, 5f
  110. and %o1, 0x7, %o1
  111. EX_ST(prefetcha [%o0 + 0x040] %asi, #n_writes)
  112. EX_ST(prefetcha [%o0 + 0x080] %asi, #n_writes)
  113. EX_ST(prefetcha [%o0 + 0x0c0] %asi, #n_writes)
  114. EX_ST(prefetcha [%o0 + 0x100] %asi, #n_writes)
  115. EX_ST(prefetcha [%o0 + 0x140] %asi, #n_writes)
  116. 4: EX_ST(prefetcha [%o0 + 0x180] %asi, #n_writes)
  117. EX_ST(stxa %g0, [%o0 + 0x00] %asi)
  118. EX_ST(stxa %g0, [%o0 + 0x08] %asi)
  119. EX_ST(stxa %g0, [%o0 + 0x10] %asi)
  120. EX_ST(stxa %g0, [%o0 + 0x18] %asi)
  121. EX_ST(stxa %g0, [%o0 + 0x20] %asi)
  122. EX_ST(stxa %g0, [%o0 + 0x28] %asi)
  123. EX_ST(stxa %g0, [%o0 + 0x30] %asi)
  124. EX_ST(stxa %g0, [%o0 + 0x38] %asi)
  125. subcc %o4, 0x40, %o4
  126. bne,pt %icc, 4b
  127. add %o0, 0x40, %o0
  128. brz,pn %g1, 6f
  129. nop
  130. 5: EX_ST(stxa %g0, [%o0 + 0x00] %asi)
  131. subcc %g1, 8, %g1
  132. bne,pt %icc, 5b
  133. add %o0, 0x8, %o0
  134. 6: brz,pt %o1, __clear_user_done
  135. nop
  136. __clear_user_tiny:
  137. 1: EX_ST(stba %g0, [%o0 + 0x00] %asi)
  138. subcc %o1, 1, %o1
  139. bne,pt %icc, 1b
  140. add %o0, 1, %o0
  141. __clear_user_done:
  142. retl
  143. clr %o0
  144. .size __clear_user, .-__clear_user