blockops.S 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. /* Zero out 64 bytes of memory at (buf + offset).
  9. * Assumes %g1 contains zero.
  10. */
  11. #define BLAST_BLOCK(buf, offset) \
  12. std %g0, [buf + offset + 0x38]; \
  13. std %g0, [buf + offset + 0x30]; \
  14. std %g0, [buf + offset + 0x28]; \
  15. std %g0, [buf + offset + 0x20]; \
  16. std %g0, [buf + offset + 0x18]; \
  17. std %g0, [buf + offset + 0x10]; \
  18. std %g0, [buf + offset + 0x08]; \
  19. std %g0, [buf + offset + 0x00];
  20. /* Copy 32 bytes of memory at (src + offset) to
  21. * (dst + offset).
  22. */
  23. #define MIRROR_BLOCK(dst, src, offset, t0, t1, t2, t3, t4, t5, t6, t7) \
  24. ldd [src + offset + 0x18], t0; \
  25. ldd [src + offset + 0x10], t2; \
  26. ldd [src + offset + 0x08], t4; \
  27. ldd [src + offset + 0x00], t6; \
  28. std t0, [dst + offset + 0x18]; \
  29. std t2, [dst + offset + 0x10]; \
  30. std t4, [dst + offset + 0x08]; \
  31. std t6, [dst + offset + 0x00];
  32. /* Profiling evidence indicates that memset() is
  33. * commonly called for blocks of size PAGE_SIZE,
  34. * and (2 * PAGE_SIZE) (for kernel stacks)
  35. * and with a second arg of zero. We assume in
  36. * all of these cases that the buffer is aligned
  37. * on at least an 8 byte boundary.
  38. *
  39. * Therefore we special case them to make them
  40. * as fast as possible.
  41. */
  42. .text
  43. ENTRY(bzero_1page)
  44. /* NOTE: If you change the number of insns of this routine, please check
  45. * arch/sparc/mm/hypersparc.S */
  46. /* %o0 = buf */
  47. or %g0, %g0, %g1
  48. or %o0, %g0, %o1
  49. or %g0, (PAGE_SIZE >> 8), %g2
  50. 1:
  51. BLAST_BLOCK(%o0, 0x00)
  52. BLAST_BLOCK(%o0, 0x40)
  53. BLAST_BLOCK(%o0, 0x80)
  54. BLAST_BLOCK(%o0, 0xc0)
  55. subcc %g2, 1, %g2
  56. bne 1b
  57. add %o0, 0x100, %o0
  58. retl
  59. nop
  60. ENDPROC(bzero_1page)
  61. ENTRY(__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
  81. ENDPROC(__copy_1page)