xref: /openbmc/linux/arch/sparc/lib/blockops.S (revision c900529f3d9161bfde5cca0754f83b4d3c3e0220)
1b2441318SGreg Kroah-Hartman/* SPDX-License-Identifier: GPL-2.0 */
288278ca2SAdrian Bunk/*
31da177e4SLinus Torvalds * blockops.S: Common block zero optimized routines.
41da177e4SLinus Torvalds *
51da177e4SLinus Torvalds * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu)
61da177e4SLinus Torvalds */
71da177e4SLinus Torvalds
8*4cdb71b6SMasahiro Yamada#include <linux/export.h>
98695c37dSDavid S. Miller#include <linux/linkage.h>
101da177e4SLinus Torvalds#include <asm/page.h>
111da177e4SLinus Torvalds
121da177e4SLinus Torvalds	/* Zero out 64 bytes of memory at (buf + offset).
131da177e4SLinus Torvalds	 * Assumes %g1 contains zero.
141da177e4SLinus Torvalds	 */
151da177e4SLinus Torvalds#define BLAST_BLOCK(buf, offset) \
161da177e4SLinus Torvalds	std	%g0, [buf + offset + 0x38]; \
171da177e4SLinus Torvalds	std	%g0, [buf + offset + 0x30]; \
181da177e4SLinus Torvalds	std	%g0, [buf + offset + 0x28]; \
191da177e4SLinus Torvalds	std	%g0, [buf + offset + 0x20]; \
201da177e4SLinus Torvalds	std	%g0, [buf + offset + 0x18]; \
211da177e4SLinus Torvalds	std	%g0, [buf + offset + 0x10]; \
221da177e4SLinus Torvalds	std	%g0, [buf + offset + 0x08]; \
231da177e4SLinus Torvalds	std	%g0, [buf + offset + 0x00];
241da177e4SLinus Torvalds
251da177e4SLinus Torvalds	/* Copy 32 bytes of memory at (src + offset) to
261da177e4SLinus Torvalds	 * (dst + offset).
271da177e4SLinus Torvalds	 */
281da177e4SLinus Torvalds#define MIRROR_BLOCK(dst, src, offset, t0, t1, t2, t3, t4, t5, t6, t7) \
291da177e4SLinus Torvalds	ldd	[src + offset + 0x18], t0; \
301da177e4SLinus Torvalds	ldd	[src + offset + 0x10], t2; \
311da177e4SLinus Torvalds	ldd	[src + offset + 0x08], t4; \
321da177e4SLinus Torvalds	ldd	[src + offset + 0x00], t6; \
331da177e4SLinus Torvalds	std	t0, [dst + offset + 0x18]; \
341da177e4SLinus Torvalds	std	t2, [dst + offset + 0x10]; \
351da177e4SLinus Torvalds	std	t4, [dst + offset + 0x08]; \
361da177e4SLinus Torvalds	std	t6, [dst + offset + 0x00];
371da177e4SLinus Torvalds
381da177e4SLinus Torvalds	/* Profiling evidence indicates that memset() is
391da177e4SLinus Torvalds	 * commonly called for blocks of size PAGE_SIZE,
401da177e4SLinus Torvalds	 * and (2 * PAGE_SIZE) (for kernel stacks)
411da177e4SLinus Torvalds	 * and with a second arg of zero.  We assume in
421da177e4SLinus Torvalds	 * all of these cases that the buffer is aligned
431da177e4SLinus Torvalds	 * on at least an 8 byte boundary.
441da177e4SLinus Torvalds	 *
451da177e4SLinus Torvalds	 * Therefore we special case them to make them
461da177e4SLinus Torvalds	 * as fast as possible.
471da177e4SLinus Torvalds	 */
481da177e4SLinus Torvalds
491da177e4SLinus Torvalds	.text
508695c37dSDavid S. MillerENTRY(bzero_1page)
511da177e4SLinus Torvalds/* NOTE: If you change the number of insns of this routine, please check
521da177e4SLinus Torvalds * arch/sparc/mm/hypersparc.S */
531da177e4SLinus Torvalds	/* %o0 = buf */
541da177e4SLinus Torvalds	or	%g0, %g0, %g1
551da177e4SLinus Torvalds	or	%o0, %g0, %o1
561da177e4SLinus Torvalds	or	%g0, (PAGE_SIZE >> 8), %g2
571da177e4SLinus Torvalds1:
581da177e4SLinus Torvalds	BLAST_BLOCK(%o0, 0x00)
591da177e4SLinus Torvalds	BLAST_BLOCK(%o0, 0x40)
601da177e4SLinus Torvalds	BLAST_BLOCK(%o0, 0x80)
611da177e4SLinus Torvalds	BLAST_BLOCK(%o0, 0xc0)
621da177e4SLinus Torvalds	subcc	%g2, 1, %g2
631da177e4SLinus Torvalds	bne	1b
641da177e4SLinus Torvalds	 add	%o0, 0x100, %o0
651da177e4SLinus Torvalds
661da177e4SLinus Torvalds	retl
671da177e4SLinus Torvalds	 nop
688695c37dSDavid S. MillerENDPROC(bzero_1page)
69d3867f04SAl ViroEXPORT_SYMBOL(bzero_1page)
701da177e4SLinus Torvalds
718695c37dSDavid S. MillerENTRY(__copy_1page)
721da177e4SLinus Torvalds/* NOTE: If you change the number of insns of this routine, please check
731da177e4SLinus Torvalds * arch/sparc/mm/hypersparc.S */
741da177e4SLinus Torvalds	/* %o0 = dst, %o1 = src */
751da177e4SLinus Torvalds	or	%g0, (PAGE_SIZE >> 8), %g1
761da177e4SLinus Torvalds1:
771da177e4SLinus Torvalds	MIRROR_BLOCK(%o0, %o1, 0x00, %o2, %o3, %o4, %o5, %g2, %g3, %g4, %g5)
781da177e4SLinus Torvalds	MIRROR_BLOCK(%o0, %o1, 0x20, %o2, %o3, %o4, %o5, %g2, %g3, %g4, %g5)
791da177e4SLinus Torvalds	MIRROR_BLOCK(%o0, %o1, 0x40, %o2, %o3, %o4, %o5, %g2, %g3, %g4, %g5)
801da177e4SLinus Torvalds	MIRROR_BLOCK(%o0, %o1, 0x60, %o2, %o3, %o4, %o5, %g2, %g3, %g4, %g5)
811da177e4SLinus Torvalds	MIRROR_BLOCK(%o0, %o1, 0x80, %o2, %o3, %o4, %o5, %g2, %g3, %g4, %g5)
821da177e4SLinus Torvalds	MIRROR_BLOCK(%o0, %o1, 0xa0, %o2, %o3, %o4, %o5, %g2, %g3, %g4, %g5)
831da177e4SLinus Torvalds	MIRROR_BLOCK(%o0, %o1, 0xc0, %o2, %o3, %o4, %o5, %g2, %g3, %g4, %g5)
841da177e4SLinus Torvalds	MIRROR_BLOCK(%o0, %o1, 0xe0, %o2, %o3, %o4, %o5, %g2, %g3, %g4, %g5)
851da177e4SLinus Torvalds	subcc	%g1, 1, %g1
861da177e4SLinus Torvalds	add	%o0, 0x100, %o0
871da177e4SLinus Torvalds	bne	1b
881da177e4SLinus Torvalds	 add	%o1, 0x100, %o1
891da177e4SLinus Torvalds
901da177e4SLinus Torvalds	retl
911da177e4SLinus Torvalds	 nop
928695c37dSDavid S. MillerENDPROC(__copy_1page)
93d3867f04SAl ViroEXPORT_SYMBOL(__copy_1page)
94