blockops.S 2.6 KB

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