^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * vDSO provided cache flush routines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  *                    IBM Corp.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include <asm/processor.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <asm/ppc_asm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <asm/vdso.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <asm/vdso_datapage.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <asm/asm-offsets.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 	.text
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)  * Default "generic" version of __kernel_sync_dicache.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)  * void __kernel_sync_dicache(unsigned long start, unsigned long end)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)  * Flushes the data cache & invalidate the instruction cache for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)  * provided range [start, end[
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) V_FUNCTION_BEGIN(__kernel_sync_dicache)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)   .cfi_startproc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	mflr	r12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)   .cfi_register lr,r12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	get_datapage	r10, r0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	mtlr	r12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	lwz	r7,CFG_DCACHE_BLOCKSZ(r10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	addi	r5,r7,-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	andc	r6,r3,r5		/* round low to line bdy */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	subf	r8,r6,r4		/* compute length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	add	r8,r8,r5		/* ensure we get enough */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	lwz	r9,CFG_DCACHE_LOGBLOCKSZ(r10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	srd.	r8,r8,r9		/* compute line count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	crclr	cr0*4+so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	beqlr				/* nothing to do? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	mtctr	r8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 1:	dcbst	0,r6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	add	r6,r6,r7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	bdnz	1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	sync
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) /* Now invalidate the instruction cache */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	lwz	r7,CFG_ICACHE_BLOCKSZ(r10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	addi	r5,r7,-1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	andc	r6,r3,r5		/* round low to line bdy */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	subf	r8,r6,r4		/* compute length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	add	r8,r8,r5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	lwz	r9,CFG_ICACHE_LOGBLOCKSZ(r10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	srd.	r8,r8,r9		/* compute line count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	crclr	cr0*4+so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	beqlr				/* nothing to do? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	mtctr	r8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 2:	icbi	0,r6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	add	r6,r6,r7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 	bdnz	2b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 	isync
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 	li	r3,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	blr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)   .cfi_endproc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) V_FUNCTION_END(__kernel_sync_dicache)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)  * POWER5 version of __kernel_sync_dicache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) V_FUNCTION_BEGIN(__kernel_sync_dicache_p5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)   .cfi_startproc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 	crclr	cr0*4+so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 	sync
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 	isync
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 	li	r3,0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) 	blr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)   .cfi_endproc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) V_FUNCTION_END(__kernel_sync_dicache_p5)