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