blockops.S 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. * blockops.S: Common block zero optimized routines.
  3. *
  4. * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
  5. */
  6. #include <asm/page.h>
  7. /* Zero out 64 bytes of memory at (buf + offset).
  8. * Assumes %g1 contains zero.
  9. */
  10. #define BLAST_BLOCK(buf, offset) \
  11. std %g0, [buf + offset + 0x38]; \
  12. std %g0, [buf + offset + 0x30]; \
  13. std %g0, [buf + offset + 0x28]; \
  14. std %g0, [buf + offset + 0x20]; \
  15. std %g0, [buf + offset + 0x18]; \
  16. std %g0, [buf + offset + 0x10]; \
  17. std %g0, [buf + offset + 0x08]; \
  18. std %g0, [buf + offset + 0x00];
  19. /* Copy 32 bytes of memory at (src + offset) to
  20. * (dst + offset).
  21. */
  22. #define MIRROR_BLOCK(dst, src, offset, t0, t1, t2, t3, t4, t5, t6, t7) \
  23. ldd [src + offset + 0x18], t0; \
  24. ldd [src + offset + 0x10], t2; \
  25. ldd [src + offset + 0x08], t4; \
  26. ldd [src + offset + 0x00], t6; \
  27. std t0, [dst + offset + 0x18]; \
  28. std t2, [dst + offset + 0x10]; \
  29. std t4, [dst + offset + 0x08]; \
  30. std t6, [dst + offset + 0x00];
  31. /* Profiling evidence indicates that memset() is
  32. * commonly called for blocks of size PAGE_SIZE,
  33. * and (2 * PAGE_SIZE) (for kernel stacks)
  34. * and with a second arg of zero. We assume in
  35. * all of these cases that the buffer is aligned
  36. * on at least an 8 byte boundary.
  37. *
  38. * Therefore we special case them to make them
  39. * as fast as possible.
  40. */
  41. .text
  42. .align 4
  43. .globl bzero_1page, __copy_1page
  44. bzero_1page:
  45. /* NOTE: If you change the number of insns of this routine, please check
  46. * arch/sparc/mm/hypersparc.S */
  47. /* %o0 = buf */
  48. or %g0, %g0, %g1
  49. or %o0, %g0, %o1
  50. or %g0, (PAGE_SIZE >> 8), %g2
  51. 1:
  52. BLAST_BLOCK(%o0, 0x00)
  53. BLAST_BLOCK(%o0, 0x40)
  54. BLAST_BLOCK(%o0, 0x80)
  55. BLAST_BLOCK(%o0, 0xc0)
  56. subcc %g2, 1, %g2
  57. bne 1b
  58. add %o0, 0x100, %o0
  59. retl
  60. nop
  61. __copy_1page:
  62. /* NOTE: If you change the number of insns of this routine, please check
  63. * arch/sparc/mm/hypersparc.S */
  64. /* %o0 = dst, %o1 = src */
  65. or %g0, (PAGE_SIZE >> 8), %g1
  66. 1:
  67. MIRROR_BLOCK(%o0, %o1, 0x00, %o2, %o3, %o4, %o5, %g2, %g3, %g4, %g5)
  68. MIRROR_BLOCK(%o0, %o1, 0x20, %o2, %o3, %o4, %o5, %g2, %g3, %g4, %g5)
  69. MIRROR_BLOCK(%o0, %o1, 0x40, %o2, %o3, %o4, %o5, %g2, %g3, %g4, %g5)
  70. MIRROR_BLOCK(%o0, %o1, 0x60, %o2, %o3, %o4, %o5, %g2, %g3, %g4, %g5)
  71. MIRROR_BLOCK(%o0, %o1, 0x80, %o2, %o3, %o4, %o5, %g2, %g3, %g4, %g5)
  72. MIRROR_BLOCK(%o0, %o1, 0xa0, %o2, %o3, %o4, %o5, %g2, %g3, %g4, %g5)
  73. MIRROR_BLOCK(%o0, %o1, 0xc0, %o2, %o3, %o4, %o5, %g2, %g3, %g4, %g5)
  74. MIRROR_BLOCK(%o0, %o1, 0xe0, %o2, %o3, %o4, %o5, %g2, %g3, %g4, %g5)
  75. subcc %g1, 1, %g1
  76. add %o0, 0x100, %o0
  77. bne 1b
  78. add %o1, 0x100, %o1
  79. retl
  80. nop