Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * blockops.S: Common block zero optimized routines.
0004  *
0005  * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
0006  */
0007 
0008 #include <linux/linkage.h>
0009 #include <asm/page.h>
0010 #include <asm/export.h>
0011 
0012     /* Zero out 64 bytes of memory at (buf + offset).
0013      * Assumes %g1 contains zero.
0014      */
0015 #define BLAST_BLOCK(buf, offset) \
0016     std %g0, [buf + offset + 0x38]; \
0017     std %g0, [buf + offset + 0x30]; \
0018     std %g0, [buf + offset + 0x28]; \
0019     std %g0, [buf + offset + 0x20]; \
0020     std %g0, [buf + offset + 0x18]; \
0021     std %g0, [buf + offset + 0x10]; \
0022     std %g0, [buf + offset + 0x08]; \
0023     std %g0, [buf + offset + 0x00];
0024 
0025     /* Copy 32 bytes of memory at (src + offset) to
0026      * (dst + offset).
0027      */
0028 #define MIRROR_BLOCK(dst, src, offset, t0, t1, t2, t3, t4, t5, t6, t7) \
0029     ldd [src + offset + 0x18], t0; \
0030     ldd [src + offset + 0x10], t2; \
0031     ldd [src + offset + 0x08], t4; \
0032     ldd [src + offset + 0x00], t6; \
0033     std t0, [dst + offset + 0x18]; \
0034     std t2, [dst + offset + 0x10]; \
0035     std t4, [dst + offset + 0x08]; \
0036     std t6, [dst + offset + 0x00];
0037 
0038     /* Profiling evidence indicates that memset() is
0039      * commonly called for blocks of size PAGE_SIZE,
0040      * and (2 * PAGE_SIZE) (for kernel stacks)
0041      * and with a second arg of zero.  We assume in
0042      * all of these cases that the buffer is aligned
0043      * on at least an 8 byte boundary.
0044      *
0045      * Therefore we special case them to make them
0046      * as fast as possible.
0047      */
0048 
0049     .text
0050 ENTRY(bzero_1page)
0051 /* NOTE: If you change the number of insns of this routine, please check
0052  * arch/sparc/mm/hypersparc.S */
0053     /* %o0 = buf */
0054     or  %g0, %g0, %g1
0055     or  %o0, %g0, %o1
0056     or  %g0, (PAGE_SIZE >> 8), %g2
0057 1:
0058     BLAST_BLOCK(%o0, 0x00)
0059     BLAST_BLOCK(%o0, 0x40)
0060     BLAST_BLOCK(%o0, 0x80)
0061     BLAST_BLOCK(%o0, 0xc0)
0062     subcc   %g2, 1, %g2
0063     bne 1b
0064      add    %o0, 0x100, %o0
0065 
0066     retl
0067      nop
0068 ENDPROC(bzero_1page)
0069 EXPORT_SYMBOL(bzero_1page)
0070 
0071 ENTRY(__copy_1page)
0072 /* NOTE: If you change the number of insns of this routine, please check
0073  * arch/sparc/mm/hypersparc.S */
0074     /* %o0 = dst, %o1 = src */
0075     or  %g0, (PAGE_SIZE >> 8), %g1
0076 1:
0077     MIRROR_BLOCK(%o0, %o1, 0x00, %o2, %o3, %o4, %o5, %g2, %g3, %g4, %g5)
0078     MIRROR_BLOCK(%o0, %o1, 0x20, %o2, %o3, %o4, %o5, %g2, %g3, %g4, %g5)
0079     MIRROR_BLOCK(%o0, %o1, 0x40, %o2, %o3, %o4, %o5, %g2, %g3, %g4, %g5)
0080     MIRROR_BLOCK(%o0, %o1, 0x60, %o2, %o3, %o4, %o5, %g2, %g3, %g4, %g5)
0081     MIRROR_BLOCK(%o0, %o1, 0x80, %o2, %o3, %o4, %o5, %g2, %g3, %g4, %g5)
0082     MIRROR_BLOCK(%o0, %o1, 0xa0, %o2, %o3, %o4, %o5, %g2, %g3, %g4, %g5)
0083     MIRROR_BLOCK(%o0, %o1, 0xc0, %o2, %o3, %o4, %o5, %g2, %g3, %g4, %g5)
0084     MIRROR_BLOCK(%o0, %o1, 0xe0, %o2, %o3, %o4, %o5, %g2, %g3, %g4, %g5)
0085     subcc   %g1, 1, %g1
0086     add %o0, 0x100, %o0
0087     bne 1b
0088      add    %o1, 0x100, %o1
0089 
0090     retl
0091      nop
0092 ENDPROC(__copy_1page)
0093 EXPORT_SYMBOL(__copy_1page)