blockops.S 2.7 KB

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