xref: /linux/arch/parisc/kernel/pacache.S (revision 4c5fe5db1ac6420ec9c0a62ab764572ef79472b3)
11da177e4SLinus Torvalds/*
21da177e4SLinus Torvalds *  PARISC TLB and cache flushing support
31da177e4SLinus Torvalds *  Copyright (C) 2000-2001 Hewlett-Packard (John Marvin)
41da177e4SLinus Torvalds *  Copyright (C) 2001 Matthew Wilcox (willy at parisc-linux.org)
51da177e4SLinus Torvalds *  Copyright (C) 2002 Richard Hirst (rhirst with parisc-linux.org)
61da177e4SLinus Torvalds *
71da177e4SLinus Torvalds *    This program is free software; you can redistribute it and/or modify
81da177e4SLinus Torvalds *    it under the terms of the GNU General Public License as published by
91da177e4SLinus Torvalds *    the Free Software Foundation; either version 2, or (at your option)
101da177e4SLinus Torvalds *    any later version.
111da177e4SLinus Torvalds *
121da177e4SLinus Torvalds *    This program is distributed in the hope that it will be useful,
131da177e4SLinus Torvalds *    but WITHOUT ANY WARRANTY; without even the implied warranty of
141da177e4SLinus Torvalds *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
151da177e4SLinus Torvalds *    GNU General Public License for more details.
161da177e4SLinus Torvalds *
171da177e4SLinus Torvalds *    You should have received a copy of the GNU General Public License
181da177e4SLinus Torvalds *    along with this program; if not, write to the Free Software
191da177e4SLinus Torvalds *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
201da177e4SLinus Torvalds */
211da177e4SLinus Torvalds
221da177e4SLinus Torvalds/*
231da177e4SLinus Torvalds * NOTE: fdc,fic, and pdc instructions that use base register modification
241da177e4SLinus Torvalds *       should only use index and base registers that are not shadowed,
251da177e4SLinus Torvalds *       so that the fast path emulation in the non access miss handler
261da177e4SLinus Torvalds *       can be used.
271da177e4SLinus Torvalds */
281da177e4SLinus Torvalds
29413059f2SGrant Grundler#ifdef CONFIG_64BIT
301da177e4SLinus Torvalds	.level	2.0w
311da177e4SLinus Torvalds#else
321da177e4SLinus Torvalds	.level	2.0
331da177e4SLinus Torvalds#endif
341da177e4SLinus Torvalds
351da177e4SLinus Torvalds#include <asm/psw.h>
36896a3756SGrant Grundler#include <asm/assembly.h>
371da177e4SLinus Torvalds#include <asm/pgtable.h>
381da177e4SLinus Torvalds#include <asm/cache.h>
3988776c0eSHelge Deller#include <asm/ldcw.h>
403847dab7SHelge Deller#include <asm/alternative.h>
418e9e9844SHelge Deller#include <linux/linkage.h>
422a03bb9eSHelge Deller#include <linux/init.h>
431da177e4SLinus Torvalds
442a03bb9eSHelge Deller	.section .text.hot
452a03bb9eSHelge Deller	.align	16
461da177e4SLinus Torvalds
47f39cce65SHelge DellerENTRY_CFI(flush_tlb_all_local)
481da177e4SLinus Torvalds	/*
491da177e4SLinus Torvalds	 * The pitlbe and pdtlbe instructions should only be used to
501da177e4SLinus Torvalds	 * flush the entire tlb. Also, there needs to be no intervening
511da177e4SLinus Torvalds	 * tlb operations, e.g. tlb misses, so the operation needs
521da177e4SLinus Torvalds	 * to happen in real mode with all interruptions disabled.
531da177e4SLinus Torvalds	 */
541da177e4SLinus Torvalds
55896a3756SGrant Grundler	/* pcxt_ssm_bug	- relied upon translation! PA 2.0 Arch. F-4 and F-5 */
56896a3756SGrant Grundler	rsm		PSW_SM_I, %r19		/* save I-bit state */
57896a3756SGrant Grundler	load32		PA(1f), %r1
581da177e4SLinus Torvalds	nop
591da177e4SLinus Torvalds	nop
601da177e4SLinus Torvalds	nop
611da177e4SLinus Torvalds	nop
621da177e4SLinus Torvalds	nop
631da177e4SLinus Torvalds
64896a3756SGrant Grundler	rsm		PSW_SM_Q, %r0		/* prep to load iia queue */
651da177e4SLinus Torvalds	mtctl		%r0, %cr17		/* Clear IIASQ tail */
661da177e4SLinus Torvalds	mtctl		%r0, %cr17		/* Clear IIASQ head */
671da177e4SLinus Torvalds	mtctl		%r1, %cr18		/* IIAOQ head */
681da177e4SLinus Torvalds	ldo		4(%r1), %r1
691da177e4SLinus Torvalds	mtctl		%r1, %cr18		/* IIAOQ tail */
70896a3756SGrant Grundler	load32		REAL_MODE_PSW, %r1
71896a3756SGrant Grundler	mtctl           %r1, %ipsw
721da177e4SLinus Torvalds	rfi
731da177e4SLinus Torvalds	nop
741da177e4SLinus Torvalds
752fd83038SHelge Deller1:      load32		PA(cache_info), %r1
761da177e4SLinus Torvalds
771da177e4SLinus Torvalds	/* Flush Instruction Tlb */
781da177e4SLinus Torvalds
791da177e4SLinus Torvalds	LDREG		ITLB_SID_BASE(%r1), %r20
801da177e4SLinus Torvalds	LDREG		ITLB_SID_STRIDE(%r1), %r21
811da177e4SLinus Torvalds	LDREG		ITLB_SID_COUNT(%r1), %r22
821da177e4SLinus Torvalds	LDREG		ITLB_OFF_BASE(%r1), %arg0
831da177e4SLinus Torvalds	LDREG		ITLB_OFF_STRIDE(%r1), %arg1
841da177e4SLinus Torvalds	LDREG		ITLB_OFF_COUNT(%r1), %arg2
851da177e4SLinus Torvalds	LDREG		ITLB_LOOP(%r1), %arg3
861da177e4SLinus Torvalds
87872f6debSKyle McMartin	addib,COND(=)		-1, %arg3, fitoneloop	/* Preadjust and test */
881da177e4SLinus Torvalds	movb,<,n	%arg3, %r31, fitdone	/* If loop < 0, skip */
891da177e4SLinus Torvalds	copy		%arg0, %r28		/* Init base addr */
901da177e4SLinus Torvalds
911da177e4SLinus Torvaldsfitmanyloop:					/* Loop if LOOP >= 2 */
921da177e4SLinus Torvalds	mtsp		%r20, %sr1
931da177e4SLinus Torvalds	add		%r21, %r20, %r20	/* increment space */
941da177e4SLinus Torvalds	copy		%arg2, %r29		/* Init middle loop count */
951da177e4SLinus Torvalds
961da177e4SLinus Torvaldsfitmanymiddle:					/* Loop if LOOP >= 2 */
97872f6debSKyle McMartin	addib,COND(>)		-1, %r31, fitmanymiddle	/* Adjusted inner loop decr */
985035b230SJohn David Anglin	pitlbe		%r0(%sr1, %r28)
991da177e4SLinus Torvalds	pitlbe,m	%arg1(%sr1, %r28)	/* Last pitlbe and addr adjust */
100872f6debSKyle McMartin	addib,COND(>)		-1, %r29, fitmanymiddle	/* Middle loop decr */
1011da177e4SLinus Torvalds	copy		%arg3, %r31		/* Re-init inner loop count */
1021da177e4SLinus Torvalds
1031da177e4SLinus Torvalds	movb,tr		%arg0, %r28, fitmanyloop /* Re-init base addr */
104872f6debSKyle McMartin	addib,COND(<=),n	-1, %r22, fitdone	/* Outer loop count decr */
1051da177e4SLinus Torvalds
1061da177e4SLinus Torvaldsfitoneloop:					/* Loop if LOOP = 1 */
1071da177e4SLinus Torvalds	mtsp		%r20, %sr1
1081da177e4SLinus Torvalds	copy		%arg0, %r28		/* init base addr */
1091da177e4SLinus Torvalds	copy		%arg2, %r29		/* init middle loop count */
1101da177e4SLinus Torvalds
1111da177e4SLinus Torvaldsfitonemiddle:					/* Loop if LOOP = 1 */
112872f6debSKyle McMartin	addib,COND(>)		-1, %r29, fitonemiddle	/* Middle loop count decr */
1131da177e4SLinus Torvalds	pitlbe,m	%arg1(%sr1, %r28)	/* pitlbe for one loop */
1141da177e4SLinus Torvalds
115872f6debSKyle McMartin	addib,COND(>)		-1, %r22, fitoneloop	/* Outer loop count decr */
1161da177e4SLinus Torvalds	add		%r21, %r20, %r20		/* increment space */
1171da177e4SLinus Torvalds
1181da177e4SLinus Torvaldsfitdone:
1191da177e4SLinus Torvalds
1201da177e4SLinus Torvalds	/* Flush Data Tlb */
1211da177e4SLinus Torvalds
1221da177e4SLinus Torvalds	LDREG		DTLB_SID_BASE(%r1), %r20
1231da177e4SLinus Torvalds	LDREG		DTLB_SID_STRIDE(%r1), %r21
1241da177e4SLinus Torvalds	LDREG		DTLB_SID_COUNT(%r1), %r22
1251da177e4SLinus Torvalds	LDREG		DTLB_OFF_BASE(%r1), %arg0
1261da177e4SLinus Torvalds	LDREG		DTLB_OFF_STRIDE(%r1), %arg1
1271da177e4SLinus Torvalds	LDREG		DTLB_OFF_COUNT(%r1), %arg2
1281da177e4SLinus Torvalds	LDREG		DTLB_LOOP(%r1), %arg3
1291da177e4SLinus Torvalds
130872f6debSKyle McMartin	addib,COND(=)		-1, %arg3, fdtoneloop	/* Preadjust and test */
1311da177e4SLinus Torvalds	movb,<,n	%arg3, %r31, fdtdone	/* If loop < 0, skip */
1321da177e4SLinus Torvalds	copy		%arg0, %r28		/* Init base addr */
1331da177e4SLinus Torvalds
1341da177e4SLinus Torvaldsfdtmanyloop:					/* Loop if LOOP >= 2 */
1351da177e4SLinus Torvalds	mtsp		%r20, %sr1
1361da177e4SLinus Torvalds	add		%r21, %r20, %r20	/* increment space */
1371da177e4SLinus Torvalds	copy		%arg2, %r29		/* Init middle loop count */
1381da177e4SLinus Torvalds
1391da177e4SLinus Torvaldsfdtmanymiddle:					/* Loop if LOOP >= 2 */
140872f6debSKyle McMartin	addib,COND(>)		-1, %r31, fdtmanymiddle	/* Adjusted inner loop decr */
1415035b230SJohn David Anglin	pdtlbe		%r0(%sr1, %r28)
1421da177e4SLinus Torvalds	pdtlbe,m	%arg1(%sr1, %r28)	/* Last pdtlbe and addr adjust */
143872f6debSKyle McMartin	addib,COND(>)		-1, %r29, fdtmanymiddle	/* Middle loop decr */
1441da177e4SLinus Torvalds	copy		%arg3, %r31		/* Re-init inner loop count */
1451da177e4SLinus Torvalds
1461da177e4SLinus Torvalds	movb,tr		%arg0, %r28, fdtmanyloop /* Re-init base addr */
147872f6debSKyle McMartin	addib,COND(<=),n	-1, %r22,fdtdone	/* Outer loop count decr */
1481da177e4SLinus Torvalds
1491da177e4SLinus Torvaldsfdtoneloop:					/* Loop if LOOP = 1 */
1501da177e4SLinus Torvalds	mtsp		%r20, %sr1
1511da177e4SLinus Torvalds	copy		%arg0, %r28		/* init base addr */
1521da177e4SLinus Torvalds	copy		%arg2, %r29		/* init middle loop count */
1531da177e4SLinus Torvalds
1541da177e4SLinus Torvaldsfdtonemiddle:					/* Loop if LOOP = 1 */
155872f6debSKyle McMartin	addib,COND(>)		-1, %r29, fdtonemiddle	/* Middle loop count decr */
1561da177e4SLinus Torvalds	pdtlbe,m	%arg1(%sr1, %r28)	/* pdtlbe for one loop */
1571da177e4SLinus Torvalds
158872f6debSKyle McMartin	addib,COND(>)		-1, %r22, fdtoneloop	/* Outer loop count decr */
1591da177e4SLinus Torvalds	add		%r21, %r20, %r20	/* increment space */
1601da177e4SLinus Torvalds
161896a3756SGrant Grundler
1621da177e4SLinus Torvaldsfdtdone:
163896a3756SGrant Grundler	/*
164896a3756SGrant Grundler	 * Switch back to virtual mode
165896a3756SGrant Grundler	 */
166896a3756SGrant Grundler	/* pcxt_ssm_bug */
167896a3756SGrant Grundler	rsm		PSW_SM_I, %r0
168896a3756SGrant Grundler	load32		2f, %r1
169896a3756SGrant Grundler	nop
170896a3756SGrant Grundler	nop
171896a3756SGrant Grundler	nop
172896a3756SGrant Grundler	nop
173896a3756SGrant Grundler	nop
1741da177e4SLinus Torvalds
175896a3756SGrant Grundler	rsm		PSW_SM_Q, %r0		/* prep to load iia queue */
1761da177e4SLinus Torvalds	mtctl		%r0, %cr17		/* Clear IIASQ tail */
1771da177e4SLinus Torvalds	mtctl		%r0, %cr17		/* Clear IIASQ head */
1781da177e4SLinus Torvalds	mtctl		%r1, %cr18		/* IIAOQ head */
1791da177e4SLinus Torvalds	ldo		4(%r1), %r1
1801da177e4SLinus Torvalds	mtctl		%r1, %cr18		/* IIAOQ tail */
181896a3756SGrant Grundler	load32		KERNEL_PSW, %r1
182896a3756SGrant Grundler	or		%r1, %r19, %r1	/* I-bit to state on entry */
183896a3756SGrant Grundler	mtctl		%r1, %ipsw	/* restore I-bit (entire PSW) */
1841da177e4SLinus Torvalds	rfi
1851da177e4SLinus Torvalds	nop
1861da177e4SLinus Torvalds
1871da177e4SLinus Torvalds2:      bv		%r0(%r2)
1881da177e4SLinus Torvalds	nop
189f39cce65SHelge DellerENDPROC_CFI(flush_tlb_all_local)
1901da177e4SLinus Torvalds
1911da177e4SLinus Torvalds	.import cache_info,data
1921da177e4SLinus Torvalds
193f39cce65SHelge DellerENTRY_CFI(flush_instruction_cache_local)
1943847dab7SHelge Deller88:	load32		cache_info, %r1
1951da177e4SLinus Torvalds
1961da177e4SLinus Torvalds	/* Flush Instruction Cache */
1971da177e4SLinus Torvalds
1981da177e4SLinus Torvalds	LDREG		ICACHE_BASE(%r1), %arg0
1991da177e4SLinus Torvalds	LDREG		ICACHE_STRIDE(%r1), %arg1
2001da177e4SLinus Torvalds	LDREG		ICACHE_COUNT(%r1), %arg2
2011da177e4SLinus Torvalds	LDREG		ICACHE_LOOP(%r1), %arg3
2021da177e4SLinus Torvalds	rsm		PSW_SM_I, %r22		/* No mmgt ops during loop*/
2036d2ddc2fSJohn David Anglin	mtsp		%r0, %sr1
204872f6debSKyle McMartin	addib,COND(=)		-1, %arg3, fioneloop	/* Preadjust and test */
2051da177e4SLinus Torvalds	movb,<,n	%arg3, %r31, fisync	/* If loop < 0, do sync */
2061da177e4SLinus Torvalds
2071da177e4SLinus Torvaldsfimanyloop:					/* Loop if LOOP >= 2 */
208872f6debSKyle McMartin	addib,COND(>)		-1, %r31, fimanyloop	/* Adjusted inner loop decr */
2099b3b331dSGrant Grundler	fice            %r0(%sr1, %arg0)
2101da177e4SLinus Torvalds	fice,m		%arg1(%sr1, %arg0)	/* Last fice and addr adjust */
2111da177e4SLinus Torvalds	movb,tr		%arg3, %r31, fimanyloop	/* Re-init inner loop count */
212872f6debSKyle McMartin	addib,COND(<=),n	-1, %arg2, fisync	/* Outer loop decr */
2131da177e4SLinus Torvalds
2141da177e4SLinus Torvaldsfioneloop:					/* Loop if LOOP = 1 */
2156d2ddc2fSJohn David Anglin	/* Some implementations may flush with a single fice instruction */
2166d2ddc2fSJohn David Anglin	cmpib,COND(>>=),n	15, %arg2, fioneloop2
2176d2ddc2fSJohn David Anglin
2186d2ddc2fSJohn David Anglinfioneloop1:
2196d2ddc2fSJohn David Anglin	fice,m		%arg1(%sr1, %arg0)
2206d2ddc2fSJohn David Anglin	fice,m		%arg1(%sr1, %arg0)
2216d2ddc2fSJohn David Anglin	fice,m		%arg1(%sr1, %arg0)
2226d2ddc2fSJohn David Anglin	fice,m		%arg1(%sr1, %arg0)
2236d2ddc2fSJohn David Anglin	fice,m		%arg1(%sr1, %arg0)
2246d2ddc2fSJohn David Anglin	fice,m		%arg1(%sr1, %arg0)
2256d2ddc2fSJohn David Anglin	fice,m		%arg1(%sr1, %arg0)
2266d2ddc2fSJohn David Anglin	fice,m		%arg1(%sr1, %arg0)
2276d2ddc2fSJohn David Anglin	fice,m		%arg1(%sr1, %arg0)
2286d2ddc2fSJohn David Anglin	fice,m		%arg1(%sr1, %arg0)
2296d2ddc2fSJohn David Anglin	fice,m		%arg1(%sr1, %arg0)
2306d2ddc2fSJohn David Anglin	fice,m		%arg1(%sr1, %arg0)
2316d2ddc2fSJohn David Anglin	fice,m		%arg1(%sr1, %arg0)
2326d2ddc2fSJohn David Anglin	fice,m		%arg1(%sr1, %arg0)
2336d2ddc2fSJohn David Anglin	fice,m		%arg1(%sr1, %arg0)
2346d2ddc2fSJohn David Anglin	addib,COND(>)	-16, %arg2, fioneloop1
2356d2ddc2fSJohn David Anglin	fice,m		%arg1(%sr1, %arg0)
2366d2ddc2fSJohn David Anglin
2376d2ddc2fSJohn David Anglin	/* Check if done */
2386d2ddc2fSJohn David Anglin	cmpb,COND(=),n	%arg2, %r0, fisync	/* Predict branch taken */
2396d2ddc2fSJohn David Anglin
2406d2ddc2fSJohn David Anglinfioneloop2:
2416d2ddc2fSJohn David Anglin	addib,COND(>)	-1, %arg2, fioneloop2	/* Outer loop count decr */
2421da177e4SLinus Torvalds	fice,m		%arg1(%sr1, %arg0)	/* Fice for one loop */
2431da177e4SLinus Torvalds
2441da177e4SLinus Torvaldsfisync:
2451da177e4SLinus Torvalds	sync
246896a3756SGrant Grundler	mtsm		%r22			/* restore I-bit */
2473847dab7SHelge Deller89:	ALTERNATIVE(88b, 89b, ALT_COND_NO_ICACHE, INSN_NOP)
2481da177e4SLinus Torvalds	bv		%r0(%r2)
2491da177e4SLinus Torvalds	nop
250f39cce65SHelge DellerENDPROC_CFI(flush_instruction_cache_local)
2511da177e4SLinus Torvalds
2528e9e9844SHelge Deller
2531da177e4SLinus Torvalds	.import cache_info, data
254f39cce65SHelge DellerENTRY_CFI(flush_data_cache_local)
2553847dab7SHelge Deller88:	load32		cache_info, %r1
2561da177e4SLinus Torvalds
2571da177e4SLinus Torvalds	/* Flush Data Cache */
2581da177e4SLinus Torvalds
2591da177e4SLinus Torvalds	LDREG		DCACHE_BASE(%r1), %arg0
2601da177e4SLinus Torvalds	LDREG		DCACHE_STRIDE(%r1), %arg1
2611da177e4SLinus Torvalds	LDREG		DCACHE_COUNT(%r1), %arg2
2621da177e4SLinus Torvalds	LDREG		DCACHE_LOOP(%r1), %arg3
2636d2ddc2fSJohn David Anglin	rsm		PSW_SM_I, %r22		/* No mmgt ops during loop*/
2646d2ddc2fSJohn David Anglin	mtsp		%r0, %sr1
265872f6debSKyle McMartin	addib,COND(=)		-1, %arg3, fdoneloop	/* Preadjust and test */
2661da177e4SLinus Torvalds	movb,<,n	%arg3, %r31, fdsync	/* If loop < 0, do sync */
2671da177e4SLinus Torvalds
2681da177e4SLinus Torvaldsfdmanyloop:					/* Loop if LOOP >= 2 */
269872f6debSKyle McMartin	addib,COND(>)		-1, %r31, fdmanyloop	/* Adjusted inner loop decr */
2709b3b331dSGrant Grundler	fdce		%r0(%sr1, %arg0)
2711da177e4SLinus Torvalds	fdce,m		%arg1(%sr1, %arg0)	/* Last fdce and addr adjust */
2721da177e4SLinus Torvalds	movb,tr		%arg3, %r31, fdmanyloop	/* Re-init inner loop count */
273872f6debSKyle McMartin	addib,COND(<=),n	-1, %arg2, fdsync	/* Outer loop decr */
2741da177e4SLinus Torvalds
2751da177e4SLinus Torvaldsfdoneloop:					/* Loop if LOOP = 1 */
2766d2ddc2fSJohn David Anglin	/* Some implementations may flush with a single fdce instruction */
2776d2ddc2fSJohn David Anglin	cmpib,COND(>>=),n	15, %arg2, fdoneloop2
2786d2ddc2fSJohn David Anglin
2796d2ddc2fSJohn David Anglinfdoneloop1:
2806d2ddc2fSJohn David Anglin	fdce,m		%arg1(%sr1, %arg0)
2816d2ddc2fSJohn David Anglin	fdce,m		%arg1(%sr1, %arg0)
2826d2ddc2fSJohn David Anglin	fdce,m		%arg1(%sr1, %arg0)
2836d2ddc2fSJohn David Anglin	fdce,m		%arg1(%sr1, %arg0)
2846d2ddc2fSJohn David Anglin	fdce,m		%arg1(%sr1, %arg0)
2856d2ddc2fSJohn David Anglin	fdce,m		%arg1(%sr1, %arg0)
2866d2ddc2fSJohn David Anglin	fdce,m		%arg1(%sr1, %arg0)
2876d2ddc2fSJohn David Anglin	fdce,m		%arg1(%sr1, %arg0)
2886d2ddc2fSJohn David Anglin	fdce,m		%arg1(%sr1, %arg0)
2896d2ddc2fSJohn David Anglin	fdce,m		%arg1(%sr1, %arg0)
2906d2ddc2fSJohn David Anglin	fdce,m		%arg1(%sr1, %arg0)
2916d2ddc2fSJohn David Anglin	fdce,m		%arg1(%sr1, %arg0)
2926d2ddc2fSJohn David Anglin	fdce,m		%arg1(%sr1, %arg0)
2936d2ddc2fSJohn David Anglin	fdce,m		%arg1(%sr1, %arg0)
2946d2ddc2fSJohn David Anglin	fdce,m		%arg1(%sr1, %arg0)
2956d2ddc2fSJohn David Anglin	addib,COND(>)	-16, %arg2, fdoneloop1
2966d2ddc2fSJohn David Anglin	fdce,m		%arg1(%sr1, %arg0)
2976d2ddc2fSJohn David Anglin
2986d2ddc2fSJohn David Anglin	/* Check if done */
2996d2ddc2fSJohn David Anglin	cmpb,COND(=),n	%arg2, %r0, fdsync	/* Predict branch taken */
3006d2ddc2fSJohn David Anglin
3016d2ddc2fSJohn David Anglinfdoneloop2:
3026d2ddc2fSJohn David Anglin	addib,COND(>)	-1, %arg2, fdoneloop2	/* Outer loop count decr */
3031da177e4SLinus Torvalds	fdce,m		%arg1(%sr1, %arg0)	/* Fdce for one loop */
3041da177e4SLinus Torvalds
3051da177e4SLinus Torvaldsfdsync:
3061da177e4SLinus Torvalds	syncdma
3071da177e4SLinus Torvalds	sync
308896a3756SGrant Grundler	mtsm		%r22			/* restore I-bit */
3093847dab7SHelge Deller89:	ALTERNATIVE(88b, 89b, ALT_COND_NO_DCACHE, INSN_NOP)
3101da177e4SLinus Torvalds	bv		%r0(%r2)
3111da177e4SLinus Torvalds	nop
312f39cce65SHelge DellerENDPROC_CFI(flush_data_cache_local)
3131da177e4SLinus Torvalds
3146d2ddc2fSJohn David Anglin/* Macros to serialize TLB purge operations on SMP.  */
3156d2ddc2fSJohn David Anglin
3166d2ddc2fSJohn David Anglin	.macro	tlb_lock	la,flags,tmp
3176d2ddc2fSJohn David Anglin#ifdef CONFIG_SMP
3183847dab7SHelge Deller98:
31988776c0eSHelge Deller#if __PA_LDCW_ALIGNMENT > 4
32088776c0eSHelge Deller	load32		pa_tlb_lock + __PA_LDCW_ALIGNMENT-1, \la
32188776c0eSHelge Deller	depi		0,31,__PA_LDCW_ALIGN_ORDER, \la
32288776c0eSHelge Deller#else
32388776c0eSHelge Deller	load32		pa_tlb_lock, \la
32488776c0eSHelge Deller#endif
3256d2ddc2fSJohn David Anglin	rsm		PSW_SM_I,\flags
3266d2ddc2fSJohn David Anglin1:	LDCW		0(\la),\tmp
3276d2ddc2fSJohn David Anglin	cmpib,<>,n	0,\tmp,3f
3286d2ddc2fSJohn David Anglin2:	ldw		0(\la),\tmp
3296d2ddc2fSJohn David Anglin	cmpb,<>		%r0,\tmp,1b
3306d2ddc2fSJohn David Anglin	nop
3316d2ddc2fSJohn David Anglin	b,n		2b
3326d2ddc2fSJohn David Anglin3:
3333847dab7SHelge Deller99:	ALTERNATIVE(98b, 99b, ALT_COND_NO_SMP, INSN_NOP)
3346d2ddc2fSJohn David Anglin#endif
3356d2ddc2fSJohn David Anglin	.endm
3366d2ddc2fSJohn David Anglin
3376d2ddc2fSJohn David Anglin	.macro	tlb_unlock	la,flags,tmp
3386d2ddc2fSJohn David Anglin#ifdef CONFIG_SMP
3393847dab7SHelge Deller98:	ldi		1,\tmp
340fedb8da9SJohn David Anglin	sync
3416d2ddc2fSJohn David Anglin	stw		\tmp,0(\la)
3426d2ddc2fSJohn David Anglin	mtsm		\flags
3433847dab7SHelge Deller99:	ALTERNATIVE(98b, 99b, ALT_COND_NO_SMP, INSN_NOP)
3446d2ddc2fSJohn David Anglin#endif
3456d2ddc2fSJohn David Anglin	.endm
3466d2ddc2fSJohn David Anglin
3476d2ddc2fSJohn David Anglin/* Clear page using kernel mapping.  */
3486d2ddc2fSJohn David Anglin
349f39cce65SHelge DellerENTRY_CFI(clear_page_asm)
3506d2ddc2fSJohn David Anglin#ifdef CONFIG_64BIT
3516d2ddc2fSJohn David Anglin
3526d2ddc2fSJohn David Anglin	/* Unroll the loop.  */
3536d2ddc2fSJohn David Anglin	ldi		(PAGE_SIZE / 128), %r1
3546d2ddc2fSJohn David Anglin
3556d2ddc2fSJohn David Anglin1:
3566d2ddc2fSJohn David Anglin	std		%r0, 0(%r26)
3576d2ddc2fSJohn David Anglin	std		%r0, 8(%r26)
3586d2ddc2fSJohn David Anglin	std		%r0, 16(%r26)
3596d2ddc2fSJohn David Anglin	std		%r0, 24(%r26)
3606d2ddc2fSJohn David Anglin	std		%r0, 32(%r26)
3616d2ddc2fSJohn David Anglin	std		%r0, 40(%r26)
3626d2ddc2fSJohn David Anglin	std		%r0, 48(%r26)
3636d2ddc2fSJohn David Anglin	std		%r0, 56(%r26)
3646d2ddc2fSJohn David Anglin	std		%r0, 64(%r26)
3656d2ddc2fSJohn David Anglin	std		%r0, 72(%r26)
3666d2ddc2fSJohn David Anglin	std		%r0, 80(%r26)
3676d2ddc2fSJohn David Anglin	std		%r0, 88(%r26)
3686d2ddc2fSJohn David Anglin	std		%r0, 96(%r26)
3696d2ddc2fSJohn David Anglin	std		%r0, 104(%r26)
3706d2ddc2fSJohn David Anglin	std		%r0, 112(%r26)
3716d2ddc2fSJohn David Anglin	std		%r0, 120(%r26)
3726d2ddc2fSJohn David Anglin
3736d2ddc2fSJohn David Anglin	/* Note reverse branch hint for addib is taken.  */
3746d2ddc2fSJohn David Anglin	addib,COND(>),n	-1, %r1, 1b
3756d2ddc2fSJohn David Anglin	ldo		128(%r26), %r26
3766d2ddc2fSJohn David Anglin
3776d2ddc2fSJohn David Anglin#else
3786d2ddc2fSJohn David Anglin
3796d2ddc2fSJohn David Anglin	/*
3806d2ddc2fSJohn David Anglin	 * Note that until (if) we start saving the full 64-bit register
3816d2ddc2fSJohn David Anglin	 * values on interrupt, we can't use std on a 32 bit kernel.
3826d2ddc2fSJohn David Anglin	 */
3836d2ddc2fSJohn David Anglin	ldi		(PAGE_SIZE / 64), %r1
3846d2ddc2fSJohn David Anglin
3856d2ddc2fSJohn David Anglin1:
3866d2ddc2fSJohn David Anglin	stw		%r0, 0(%r26)
3876d2ddc2fSJohn David Anglin	stw		%r0, 4(%r26)
3886d2ddc2fSJohn David Anglin	stw		%r0, 8(%r26)
3896d2ddc2fSJohn David Anglin	stw		%r0, 12(%r26)
3906d2ddc2fSJohn David Anglin	stw		%r0, 16(%r26)
3916d2ddc2fSJohn David Anglin	stw		%r0, 20(%r26)
3926d2ddc2fSJohn David Anglin	stw		%r0, 24(%r26)
3936d2ddc2fSJohn David Anglin	stw		%r0, 28(%r26)
3946d2ddc2fSJohn David Anglin	stw		%r0, 32(%r26)
3956d2ddc2fSJohn David Anglin	stw		%r0, 36(%r26)
3966d2ddc2fSJohn David Anglin	stw		%r0, 40(%r26)
3976d2ddc2fSJohn David Anglin	stw		%r0, 44(%r26)
3986d2ddc2fSJohn David Anglin	stw		%r0, 48(%r26)
3996d2ddc2fSJohn David Anglin	stw		%r0, 52(%r26)
4006d2ddc2fSJohn David Anglin	stw		%r0, 56(%r26)
4016d2ddc2fSJohn David Anglin	stw		%r0, 60(%r26)
4026d2ddc2fSJohn David Anglin
4036d2ddc2fSJohn David Anglin	addib,COND(>),n	-1, %r1, 1b
4046d2ddc2fSJohn David Anglin	ldo		64(%r26), %r26
4056d2ddc2fSJohn David Anglin#endif
4066d2ddc2fSJohn David Anglin	bv		%r0(%r2)
4076d2ddc2fSJohn David Anglin	nop
408f39cce65SHelge DellerENDPROC_CFI(clear_page_asm)
4096d2ddc2fSJohn David Anglin
4106d2ddc2fSJohn David Anglin/* Copy page using kernel mapping.  */
4116d2ddc2fSJohn David Anglin
412f39cce65SHelge DellerENTRY_CFI(copy_page_asm)
413413059f2SGrant Grundler#ifdef CONFIG_64BIT
4141da177e4SLinus Torvalds	/* PA8x00 CPUs can consume 2 loads or 1 store per cycle.
4151da177e4SLinus Torvalds	 * Unroll the loop by hand and arrange insn appropriately.
4166d2ddc2fSJohn David Anglin	 * Prefetch doesn't improve performance on rp3440.
4176d2ddc2fSJohn David Anglin	 * GCC probably can do this just as well...
4181da177e4SLinus Torvalds	 */
4191da177e4SLinus Torvalds
4206ebeafffSKyle McMartin	ldi		(PAGE_SIZE / 128), %r1
4212fd83038SHelge Deller
4226d2ddc2fSJohn David Anglin1:	ldd		0(%r25), %r19
4236d2ddc2fSJohn David Anglin	ldd		8(%r25), %r20
4241da177e4SLinus Torvalds
4251da177e4SLinus Torvalds	ldd		16(%r25), %r21
4261da177e4SLinus Torvalds	ldd		24(%r25), %r22
4271da177e4SLinus Torvalds	std		%r19, 0(%r26)
4281da177e4SLinus Torvalds	std		%r20, 8(%r26)
4291da177e4SLinus Torvalds
4301da177e4SLinus Torvalds	ldd		32(%r25), %r19
4311da177e4SLinus Torvalds	ldd		40(%r25), %r20
4321da177e4SLinus Torvalds	std		%r21, 16(%r26)
4331da177e4SLinus Torvalds	std		%r22, 24(%r26)
4341da177e4SLinus Torvalds
4351da177e4SLinus Torvalds	ldd		48(%r25), %r21
4361da177e4SLinus Torvalds	ldd		56(%r25), %r22
4371da177e4SLinus Torvalds	std		%r19, 32(%r26)
4381da177e4SLinus Torvalds	std		%r20, 40(%r26)
4391da177e4SLinus Torvalds
4401da177e4SLinus Torvalds	ldd		64(%r25), %r19
4411da177e4SLinus Torvalds	ldd		72(%r25), %r20
4421da177e4SLinus Torvalds	std		%r21, 48(%r26)
4431da177e4SLinus Torvalds	std		%r22, 56(%r26)
4441da177e4SLinus Torvalds
4451da177e4SLinus Torvalds	ldd		80(%r25), %r21
4461da177e4SLinus Torvalds	ldd		88(%r25), %r22
4471da177e4SLinus Torvalds	std		%r19, 64(%r26)
4481da177e4SLinus Torvalds	std		%r20, 72(%r26)
4491da177e4SLinus Torvalds
4501da177e4SLinus Torvalds	ldd		 96(%r25), %r19
4511da177e4SLinus Torvalds	ldd		104(%r25), %r20
4521da177e4SLinus Torvalds	std		%r21, 80(%r26)
4531da177e4SLinus Torvalds	std		%r22, 88(%r26)
4541da177e4SLinus Torvalds
4551da177e4SLinus Torvalds	ldd		112(%r25), %r21
4561da177e4SLinus Torvalds	ldd		120(%r25), %r22
4576d2ddc2fSJohn David Anglin	ldo		128(%r25), %r25
4581da177e4SLinus Torvalds	std		%r19, 96(%r26)
4591da177e4SLinus Torvalds	std		%r20, 104(%r26)
4601da177e4SLinus Torvalds
4611da177e4SLinus Torvalds	std		%r21, 112(%r26)
4621da177e4SLinus Torvalds	std		%r22, 120(%r26)
4631da177e4SLinus Torvalds
4646d2ddc2fSJohn David Anglin	/* Note reverse branch hint for addib is taken.  */
4656d2ddc2fSJohn David Anglin	addib,COND(>),n	-1, %r1, 1b
4666d2ddc2fSJohn David Anglin	ldo		128(%r26), %r26
4671da177e4SLinus Torvalds
4681da177e4SLinus Torvalds#else
4691da177e4SLinus Torvalds
4701da177e4SLinus Torvalds	/*
4711da177e4SLinus Torvalds	 * This loop is optimized for PCXL/PCXL2 ldw/ldw and stw/stw
4721da177e4SLinus Torvalds	 * bundles (very restricted rules for bundling).
4731da177e4SLinus Torvalds	 * Note that until (if) we start saving
4741da177e4SLinus Torvalds	 * the full 64 bit register values on interrupt, we can't
4751da177e4SLinus Torvalds	 * use ldd/std on a 32 bit kernel.
4761da177e4SLinus Torvalds	 */
47737318a3cSGrant Grundler	ldw		0(%r25), %r19
4786ebeafffSKyle McMartin	ldi		(PAGE_SIZE / 64), %r1
4791da177e4SLinus Torvalds
4801da177e4SLinus Torvalds1:
4811da177e4SLinus Torvalds	ldw		4(%r25), %r20
4821da177e4SLinus Torvalds	ldw		8(%r25), %r21
4831da177e4SLinus Torvalds	ldw		12(%r25), %r22
4841da177e4SLinus Torvalds	stw		%r19, 0(%r26)
4851da177e4SLinus Torvalds	stw		%r20, 4(%r26)
4861da177e4SLinus Torvalds	stw		%r21, 8(%r26)
4871da177e4SLinus Torvalds	stw		%r22, 12(%r26)
4881da177e4SLinus Torvalds	ldw		16(%r25), %r19
4891da177e4SLinus Torvalds	ldw		20(%r25), %r20
4901da177e4SLinus Torvalds	ldw		24(%r25), %r21
4911da177e4SLinus Torvalds	ldw		28(%r25), %r22
4921da177e4SLinus Torvalds	stw		%r19, 16(%r26)
4931da177e4SLinus Torvalds	stw		%r20, 20(%r26)
4941da177e4SLinus Torvalds	stw		%r21, 24(%r26)
4951da177e4SLinus Torvalds	stw		%r22, 28(%r26)
4961da177e4SLinus Torvalds	ldw		32(%r25), %r19
4971da177e4SLinus Torvalds	ldw		36(%r25), %r20
4981da177e4SLinus Torvalds	ldw		40(%r25), %r21
4991da177e4SLinus Torvalds	ldw		44(%r25), %r22
5001da177e4SLinus Torvalds	stw		%r19, 32(%r26)
5011da177e4SLinus Torvalds	stw		%r20, 36(%r26)
5021da177e4SLinus Torvalds	stw		%r21, 40(%r26)
5031da177e4SLinus Torvalds	stw		%r22, 44(%r26)
5041da177e4SLinus Torvalds	ldw		48(%r25), %r19
5051da177e4SLinus Torvalds	ldw		52(%r25), %r20
5061da177e4SLinus Torvalds	ldw		56(%r25), %r21
5071da177e4SLinus Torvalds	ldw		60(%r25), %r22
5081da177e4SLinus Torvalds	stw		%r19, 48(%r26)
5091da177e4SLinus Torvalds	stw		%r20, 52(%r26)
51037318a3cSGrant Grundler	ldo		64(%r25), %r25
5111da177e4SLinus Torvalds	stw		%r21, 56(%r26)
5121da177e4SLinus Torvalds	stw		%r22, 60(%r26)
5131da177e4SLinus Torvalds	ldo		64(%r26), %r26
514872f6debSKyle McMartin	addib,COND(>),n	-1, %r1, 1b
51537318a3cSGrant Grundler	ldw		0(%r25), %r19
5161da177e4SLinus Torvalds#endif
5171da177e4SLinus Torvalds	bv		%r0(%r2)
5181da177e4SLinus Torvalds	nop
519f39cce65SHelge DellerENDPROC_CFI(copy_page_asm)
5201da177e4SLinus Torvalds
5211da177e4SLinus Torvalds/*
5221da177e4SLinus Torvalds * NOTE: Code in clear_user_page has a hard coded dependency on the
5231da177e4SLinus Torvalds *       maximum alias boundary being 4 Mb. We've been assured by the
5241da177e4SLinus Torvalds *       parisc chip designers that there will not ever be a parisc
5251da177e4SLinus Torvalds *       chip with a larger alias boundary (Never say never :-) ).
5261da177e4SLinus Torvalds *
5271da177e4SLinus Torvalds *       Subtle: the dtlb miss handlers support the temp alias region by
5281da177e4SLinus Torvalds *       "knowing" that if a dtlb miss happens within the temp alias
5291da177e4SLinus Torvalds *       region it must have occurred while in clear_user_page. Since
5301da177e4SLinus Torvalds *       this routine makes use of processor local translations, we
5311da177e4SLinus Torvalds *       don't want to insert them into the kernel page table. Instead,
5321da177e4SLinus Torvalds *       we load up some general registers (they need to be registers
5331da177e4SLinus Torvalds *       which aren't shadowed) with the physical page numbers (preshifted
5341da177e4SLinus Torvalds *       for tlb insertion) needed to insert the translations. When we
5351da177e4SLinus Torvalds *       miss on the translation, the dtlb miss handler inserts the
5361da177e4SLinus Torvalds *       translation into the tlb using these values:
5371da177e4SLinus Torvalds *
5381da177e4SLinus Torvalds *          %r26 physical page (shifted for tlb insert) of "to" translation
5391da177e4SLinus Torvalds *          %r23 physical page (shifted for tlb insert) of "from" translation
5401da177e4SLinus Torvalds */
5411da177e4SLinus Torvalds
5426a45716aSHelge Deller        /* Drop prot bits and convert to page addr for iitlbt and idtlbt */
5436a45716aSHelge Deller        #define PAGE_ADD_SHIFT  (PAGE_SHIFT-12)
5446a45716aSHelge Deller        .macro          convert_phys_for_tlb_insert20  phys
5456a45716aSHelge Deller        extrd,u         \phys, 56-PAGE_ADD_SHIFT, 32-PAGE_ADD_SHIFT, \phys
5466a45716aSHelge Deller#if _PAGE_SIZE_ENCODING_DEFAULT
5476a45716aSHelge Deller        depdi           _PAGE_SIZE_ENCODING_DEFAULT, 63, (63-58), \phys
5486a45716aSHelge Deller#endif
5496a45716aSHelge Deller	.endm
5506a45716aSHelge Deller
5511da177e4SLinus Torvalds	/*
552910a8643SJohn David Anglin	 * copy_user_page_asm() performs a page copy using mappings
553910a8643SJohn David Anglin	 * equivalent to the user page mappings.  It can be used to
554910a8643SJohn David Anglin	 * implement copy_user_page() but unfortunately both the `from'
555910a8643SJohn David Anglin	 * and `to' pages need to be flushed through mappings equivalent
556910a8643SJohn David Anglin	 * to the user mappings after the copy because the kernel accesses
557910a8643SJohn David Anglin	 * the `from' page through the kmap kernel mapping and the `to'
558910a8643SJohn David Anglin	 * page needs to be flushed since code can be copied.  As a
559910a8643SJohn David Anglin	 * result, this implementation is less efficient than the simpler
560910a8643SJohn David Anglin	 * copy using the kernel mapping.  It only needs the `from' page
561910a8643SJohn David Anglin	 * to flushed via the user mapping.  The kunmap routines handle
562910a8643SJohn David Anglin	 * the flushes needed for the kernel mapping.
5631da177e4SLinus Torvalds	 *
5641da177e4SLinus Torvalds	 * I'm still keeping this around because it may be possible to
5651da177e4SLinus Torvalds	 * use it if more information is passed into copy_user_page().
5661da177e4SLinus Torvalds	 * Have to do some measurements to see if it is worthwhile to
5671da177e4SLinus Torvalds	 * lobby for such a change.
5686d2ddc2fSJohn David Anglin	 *
5691da177e4SLinus Torvalds	 */
5701da177e4SLinus Torvalds
571f39cce65SHelge DellerENTRY_CFI(copy_user_page_asm)
5726d2ddc2fSJohn David Anglin	/* Convert virtual `to' and `from' addresses to physical addresses.
5736d2ddc2fSJohn David Anglin	   Move `from' physical address to non shadowed register.  */
5741da177e4SLinus Torvalds	ldil		L%(__PAGE_OFFSET), %r1
5751da177e4SLinus Torvalds	sub		%r26, %r1, %r26
5766d2ddc2fSJohn David Anglin	sub		%r25, %r1, %r23
5771da177e4SLinus Torvalds
5781da177e4SLinus Torvalds	ldil		L%(TMPALIAS_MAP_START), %r28
579413059f2SGrant Grundler#ifdef CONFIG_64BIT
5806d2ddc2fSJohn David Anglin#if (TMPALIAS_MAP_START >= 0x80000000)
5816d2ddc2fSJohn David Anglin	depdi		0, 31,32, %r28		/* clear any sign extension */
5826d2ddc2fSJohn David Anglin#endif
5836a45716aSHelge Deller	convert_phys_for_tlb_insert20 %r26	/* convert phys addr to tlb insert format */
5846a45716aSHelge Deller	convert_phys_for_tlb_insert20 %r23	/* convert phys addr to tlb insert format */
5851da177e4SLinus Torvalds	depd		%r24,63,22, %r28	/* Form aliased virtual address 'to' */
5866a45716aSHelge Deller	depdi		0, 63,PAGE_SHIFT, %r28	/* Clear any offset bits */
5871da177e4SLinus Torvalds	copy		%r28, %r29
5881da177e4SLinus Torvalds	depdi		1, 41,1, %r29		/* Form aliased virtual address 'from' */
5891da177e4SLinus Torvalds#else
5901da177e4SLinus Torvalds	extrw,u		%r26, 24,25, %r26	/* convert phys addr to tlb insert format */
5911da177e4SLinus Torvalds	extrw,u		%r23, 24,25, %r23	/* convert phys addr to tlb insert format */
5921da177e4SLinus Torvalds	depw		%r24, 31,22, %r28	/* Form aliased virtual address 'to' */
593d845b5fbSHelge Deller	depwi		0, 31,PAGE_SHIFT, %r28	/* Clear any offset bits */
5941da177e4SLinus Torvalds	copy		%r28, %r29
5951da177e4SLinus Torvalds	depwi		1, 9,1, %r29		/* Form aliased virtual address 'from' */
5961da177e4SLinus Torvalds#endif
5971da177e4SLinus Torvalds
5981da177e4SLinus Torvalds	/* Purge any old translations */
5991da177e4SLinus Torvalds
6006d2ddc2fSJohn David Anglin#ifdef CONFIG_PA20
6015035b230SJohn David Anglin	pdtlb,l		%r0(%r28)
6025035b230SJohn David Anglin	pdtlb,l		%r0(%r29)
6036d2ddc2fSJohn David Anglin#else
6046d2ddc2fSJohn David Anglin	tlb_lock	%r20,%r21,%r22
6053847dab7SHelge Deller0:	pdtlb		%r0(%r28)
6063847dab7SHelge Deller1:	pdtlb		%r0(%r29)
6076d2ddc2fSJohn David Anglin	tlb_unlock	%r20,%r21,%r22
6083847dab7SHelge Deller	ALTERNATIVE(0b, 0b+4, ALT_COND_NO_SMP, INSN_PxTLB)
6093847dab7SHelge Deller	ALTERNATIVE(1b, 1b+4, ALT_COND_NO_SMP, INSN_PxTLB)
6106d2ddc2fSJohn David Anglin#endif
6111da177e4SLinus Torvalds
6126d2ddc2fSJohn David Anglin#ifdef CONFIG_64BIT
6136d2ddc2fSJohn David Anglin	/* PA8x00 CPUs can consume 2 loads or 1 store per cycle.
6146d2ddc2fSJohn David Anglin	 * Unroll the loop by hand and arrange insn appropriately.
6156d2ddc2fSJohn David Anglin	 * GCC probably can do this just as well.
6166d2ddc2fSJohn David Anglin	 */
6176d2ddc2fSJohn David Anglin
6186d2ddc2fSJohn David Anglin	ldd		0(%r29), %r19
6196d2ddc2fSJohn David Anglin	ldi		(PAGE_SIZE / 128), %r1
6206d2ddc2fSJohn David Anglin
6216d2ddc2fSJohn David Anglin1:	ldd		8(%r29), %r20
6226d2ddc2fSJohn David Anglin
6236d2ddc2fSJohn David Anglin	ldd		16(%r29), %r21
6246d2ddc2fSJohn David Anglin	ldd		24(%r29), %r22
6256d2ddc2fSJohn David Anglin	std		%r19, 0(%r28)
6266d2ddc2fSJohn David Anglin	std		%r20, 8(%r28)
6276d2ddc2fSJohn David Anglin
6286d2ddc2fSJohn David Anglin	ldd		32(%r29), %r19
6296d2ddc2fSJohn David Anglin	ldd		40(%r29), %r20
6306d2ddc2fSJohn David Anglin	std		%r21, 16(%r28)
6316d2ddc2fSJohn David Anglin	std		%r22, 24(%r28)
6326d2ddc2fSJohn David Anglin
6336d2ddc2fSJohn David Anglin	ldd		48(%r29), %r21
6346d2ddc2fSJohn David Anglin	ldd		56(%r29), %r22
6356d2ddc2fSJohn David Anglin	std		%r19, 32(%r28)
6366d2ddc2fSJohn David Anglin	std		%r20, 40(%r28)
6376d2ddc2fSJohn David Anglin
6386d2ddc2fSJohn David Anglin	ldd		64(%r29), %r19
6396d2ddc2fSJohn David Anglin	ldd		72(%r29), %r20
6406d2ddc2fSJohn David Anglin	std		%r21, 48(%r28)
6416d2ddc2fSJohn David Anglin	std		%r22, 56(%r28)
6426d2ddc2fSJohn David Anglin
6436d2ddc2fSJohn David Anglin	ldd		80(%r29), %r21
6446d2ddc2fSJohn David Anglin	ldd		88(%r29), %r22
6456d2ddc2fSJohn David Anglin	std		%r19, 64(%r28)
6466d2ddc2fSJohn David Anglin	std		%r20, 72(%r28)
6476d2ddc2fSJohn David Anglin
6486d2ddc2fSJohn David Anglin	ldd		 96(%r29), %r19
6496d2ddc2fSJohn David Anglin	ldd		104(%r29), %r20
6506d2ddc2fSJohn David Anglin	std		%r21, 80(%r28)
6516d2ddc2fSJohn David Anglin	std		%r22, 88(%r28)
6526d2ddc2fSJohn David Anglin
6536d2ddc2fSJohn David Anglin	ldd		112(%r29), %r21
6546d2ddc2fSJohn David Anglin	ldd		120(%r29), %r22
6556d2ddc2fSJohn David Anglin	std		%r19, 96(%r28)
6566d2ddc2fSJohn David Anglin	std		%r20, 104(%r28)
6576d2ddc2fSJohn David Anglin
6586d2ddc2fSJohn David Anglin	ldo		128(%r29), %r29
6596d2ddc2fSJohn David Anglin	std		%r21, 112(%r28)
6606d2ddc2fSJohn David Anglin	std		%r22, 120(%r28)
6616d2ddc2fSJohn David Anglin	ldo		128(%r28), %r28
6626d2ddc2fSJohn David Anglin
6636d2ddc2fSJohn David Anglin	/* conditional branches nullify on forward taken branch, and on
6646d2ddc2fSJohn David Anglin	 * non-taken backward branch. Note that .+4 is a backwards branch.
6656d2ddc2fSJohn David Anglin	 * The ldd should only get executed if the branch is taken.
6666d2ddc2fSJohn David Anglin	 */
6676d2ddc2fSJohn David Anglin	addib,COND(>),n	-1, %r1, 1b		/* bundle 10 */
6686d2ddc2fSJohn David Anglin	ldd		0(%r29), %r19		/* start next loads */
6696d2ddc2fSJohn David Anglin
6706d2ddc2fSJohn David Anglin#else
6716d2ddc2fSJohn David Anglin	ldi		(PAGE_SIZE / 64), %r1
6721da177e4SLinus Torvalds
6731da177e4SLinus Torvalds	/*
6741da177e4SLinus Torvalds	 * This loop is optimized for PCXL/PCXL2 ldw/ldw and stw/stw
6751da177e4SLinus Torvalds	 * bundles (very restricted rules for bundling). It probably
6761da177e4SLinus Torvalds	 * does OK on PCXU and better, but we could do better with
6771da177e4SLinus Torvalds	 * ldd/std instructions. Note that until (if) we start saving
6781da177e4SLinus Torvalds	 * the full 64 bit register values on interrupt, we can't
6791da177e4SLinus Torvalds	 * use ldd/std on a 32 bit kernel.
6801da177e4SLinus Torvalds	 */
6811da177e4SLinus Torvalds
6826d2ddc2fSJohn David Anglin1:	ldw		0(%r29), %r19
6831da177e4SLinus Torvalds	ldw		4(%r29), %r20
6841da177e4SLinus Torvalds	ldw		8(%r29), %r21
6851da177e4SLinus Torvalds	ldw		12(%r29), %r22
6861da177e4SLinus Torvalds	stw		%r19, 0(%r28)
6871da177e4SLinus Torvalds	stw		%r20, 4(%r28)
6881da177e4SLinus Torvalds	stw		%r21, 8(%r28)
6891da177e4SLinus Torvalds	stw		%r22, 12(%r28)
6901da177e4SLinus Torvalds	ldw		16(%r29), %r19
6911da177e4SLinus Torvalds	ldw		20(%r29), %r20
6921da177e4SLinus Torvalds	ldw		24(%r29), %r21
6931da177e4SLinus Torvalds	ldw		28(%r29), %r22
6941da177e4SLinus Torvalds	stw		%r19, 16(%r28)
6951da177e4SLinus Torvalds	stw		%r20, 20(%r28)
6961da177e4SLinus Torvalds	stw		%r21, 24(%r28)
6971da177e4SLinus Torvalds	stw		%r22, 28(%r28)
6981da177e4SLinus Torvalds	ldw		32(%r29), %r19
6991da177e4SLinus Torvalds	ldw		36(%r29), %r20
7001da177e4SLinus Torvalds	ldw		40(%r29), %r21
7011da177e4SLinus Torvalds	ldw		44(%r29), %r22
7021da177e4SLinus Torvalds	stw		%r19, 32(%r28)
7031da177e4SLinus Torvalds	stw		%r20, 36(%r28)
7041da177e4SLinus Torvalds	stw		%r21, 40(%r28)
7051da177e4SLinus Torvalds	stw		%r22, 44(%r28)
7061da177e4SLinus Torvalds	ldw		48(%r29), %r19
7071da177e4SLinus Torvalds	ldw		52(%r29), %r20
7081da177e4SLinus Torvalds	ldw		56(%r29), %r21
7091da177e4SLinus Torvalds	ldw		60(%r29), %r22
7101da177e4SLinus Torvalds	stw		%r19, 48(%r28)
7111da177e4SLinus Torvalds	stw		%r20, 52(%r28)
7121da177e4SLinus Torvalds	stw		%r21, 56(%r28)
7131da177e4SLinus Torvalds	stw		%r22, 60(%r28)
7141da177e4SLinus Torvalds	ldo		64(%r28), %r28
7156d2ddc2fSJohn David Anglin
716872f6debSKyle McMartin	addib,COND(>)		-1, %r1,1b
7171da177e4SLinus Torvalds	ldo		64(%r29), %r29
7186d2ddc2fSJohn David Anglin#endif
7191da177e4SLinus Torvalds
7201da177e4SLinus Torvalds	bv		%r0(%r2)
7211da177e4SLinus Torvalds	nop
722f39cce65SHelge DellerENDPROC_CFI(copy_user_page_asm)
7231da177e4SLinus Torvalds
724f39cce65SHelge DellerENTRY_CFI(clear_user_page_asm)
7251da177e4SLinus Torvalds	tophys_r1	%r26
7261da177e4SLinus Torvalds
7271da177e4SLinus Torvalds	ldil		L%(TMPALIAS_MAP_START), %r28
728413059f2SGrant Grundler#ifdef CONFIG_64BIT
7291da177e4SLinus Torvalds#if (TMPALIAS_MAP_START >= 0x80000000)
7301da177e4SLinus Torvalds	depdi		0, 31,32, %r28		/* clear any sign extension */
7311da177e4SLinus Torvalds#endif
7326a45716aSHelge Deller	convert_phys_for_tlb_insert20 %r26	/* convert phys addr to tlb insert format */
7331da177e4SLinus Torvalds	depd		%r25, 63,22, %r28	/* Form aliased virtual address 'to' */
7346a45716aSHelge Deller	depdi		0, 63,PAGE_SHIFT, %r28	/* Clear any offset bits */
7351da177e4SLinus Torvalds#else
7361da177e4SLinus Torvalds	extrw,u		%r26, 24,25, %r26	/* convert phys addr to tlb insert format */
7371da177e4SLinus Torvalds	depw		%r25, 31,22, %r28	/* Form aliased virtual address 'to' */
738d845b5fbSHelge Deller	depwi		0, 31,PAGE_SHIFT, %r28	/* Clear any offset bits */
7391da177e4SLinus Torvalds#endif
7401da177e4SLinus Torvalds
7411da177e4SLinus Torvalds	/* Purge any old translation */
7421da177e4SLinus Torvalds
7436d2ddc2fSJohn David Anglin#ifdef CONFIG_PA20
7445035b230SJohn David Anglin	pdtlb,l		%r0(%r28)
7456d2ddc2fSJohn David Anglin#else
7466d2ddc2fSJohn David Anglin	tlb_lock	%r20,%r21,%r22
7473847dab7SHelge Deller0:	pdtlb		%r0(%r28)
7486d2ddc2fSJohn David Anglin	tlb_unlock	%r20,%r21,%r22
7493847dab7SHelge Deller	ALTERNATIVE(0b, 0b+4, ALT_COND_NO_SMP, INSN_PxTLB)
7506d2ddc2fSJohn David Anglin#endif
7511da177e4SLinus Torvalds
752413059f2SGrant Grundler#ifdef CONFIG_64BIT
7536ebeafffSKyle McMartin	ldi		(PAGE_SIZE / 128), %r1
7541da177e4SLinus Torvalds
7551da177e4SLinus Torvalds	/* PREFETCH (Write) has not (yet) been proven to help here */
7561da177e4SLinus Torvalds	/* #define	PREFETCHW_OP	ldd		256(%0), %r0 */
7571da177e4SLinus Torvalds
7581da177e4SLinus Torvalds1:	std		%r0, 0(%r28)
7591da177e4SLinus Torvalds	std		%r0, 8(%r28)
7601da177e4SLinus Torvalds	std		%r0, 16(%r28)
7611da177e4SLinus Torvalds	std		%r0, 24(%r28)
7621da177e4SLinus Torvalds	std		%r0, 32(%r28)
7631da177e4SLinus Torvalds	std		%r0, 40(%r28)
7641da177e4SLinus Torvalds	std		%r0, 48(%r28)
7651da177e4SLinus Torvalds	std		%r0, 56(%r28)
7661da177e4SLinus Torvalds	std		%r0, 64(%r28)
7671da177e4SLinus Torvalds	std		%r0, 72(%r28)
7681da177e4SLinus Torvalds	std		%r0, 80(%r28)
7691da177e4SLinus Torvalds	std		%r0, 88(%r28)
7701da177e4SLinus Torvalds	std		%r0, 96(%r28)
7711da177e4SLinus Torvalds	std		%r0, 104(%r28)
7721da177e4SLinus Torvalds	std		%r0, 112(%r28)
7731da177e4SLinus Torvalds	std		%r0, 120(%r28)
774872f6debSKyle McMartin	addib,COND(>)		-1, %r1, 1b
7751da177e4SLinus Torvalds	ldo		128(%r28), %r28
7761da177e4SLinus Torvalds
777413059f2SGrant Grundler#else	/* ! CONFIG_64BIT */
7786ebeafffSKyle McMartin	ldi		(PAGE_SIZE / 64), %r1
7791da177e4SLinus Torvalds
7806d2ddc2fSJohn David Anglin1:	stw		%r0, 0(%r28)
7811da177e4SLinus Torvalds	stw		%r0, 4(%r28)
7821da177e4SLinus Torvalds	stw		%r0, 8(%r28)
7831da177e4SLinus Torvalds	stw		%r0, 12(%r28)
7841da177e4SLinus Torvalds	stw		%r0, 16(%r28)
7851da177e4SLinus Torvalds	stw		%r0, 20(%r28)
7861da177e4SLinus Torvalds	stw		%r0, 24(%r28)
7871da177e4SLinus Torvalds	stw		%r0, 28(%r28)
7881da177e4SLinus Torvalds	stw		%r0, 32(%r28)
7891da177e4SLinus Torvalds	stw		%r0, 36(%r28)
7901da177e4SLinus Torvalds	stw		%r0, 40(%r28)
7911da177e4SLinus Torvalds	stw		%r0, 44(%r28)
7921da177e4SLinus Torvalds	stw		%r0, 48(%r28)
7931da177e4SLinus Torvalds	stw		%r0, 52(%r28)
7941da177e4SLinus Torvalds	stw		%r0, 56(%r28)
7951da177e4SLinus Torvalds	stw		%r0, 60(%r28)
796872f6debSKyle McMartin	addib,COND(>)		-1, %r1, 1b
7971da177e4SLinus Torvalds	ldo		64(%r28), %r28
798413059f2SGrant Grundler#endif	/* CONFIG_64BIT */
7991da177e4SLinus Torvalds
8001da177e4SLinus Torvalds	bv		%r0(%r2)
8011da177e4SLinus Torvalds	nop
802f39cce65SHelge DellerENDPROC_CFI(clear_user_page_asm)
8031da177e4SLinus Torvalds
804f39cce65SHelge DellerENTRY_CFI(flush_dcache_page_asm)
805f311847cSJames Bottomley	ldil		L%(TMPALIAS_MAP_START), %r28
806f311847cSJames Bottomley#ifdef CONFIG_64BIT
807f311847cSJames Bottomley#if (TMPALIAS_MAP_START >= 0x80000000)
808f311847cSJames Bottomley	depdi		0, 31,32, %r28		/* clear any sign extension */
809f311847cSJames Bottomley#endif
8106a45716aSHelge Deller	convert_phys_for_tlb_insert20 %r26	/* convert phys addr to tlb insert format */
811f311847cSJames Bottomley	depd		%r25, 63,22, %r28	/* Form aliased virtual address 'to' */
8126a45716aSHelge Deller	depdi		0, 63,PAGE_SHIFT, %r28	/* Clear any offset bits */
813f311847cSJames Bottomley#else
814f311847cSJames Bottomley	extrw,u		%r26, 24,25, %r26	/* convert phys addr to tlb insert format */
815f311847cSJames Bottomley	depw		%r25, 31,22, %r28	/* Form aliased virtual address 'to' */
816d845b5fbSHelge Deller	depwi		0, 31,PAGE_SHIFT, %r28	/* Clear any offset bits */
817f311847cSJames Bottomley#endif
818f311847cSJames Bottomley
819f311847cSJames Bottomley	/* Purge any old translation */
820f311847cSJames Bottomley
8216d2ddc2fSJohn David Anglin#ifdef CONFIG_PA20
8225035b230SJohn David Anglin	pdtlb,l		%r0(%r28)
8236d2ddc2fSJohn David Anglin#else
8246d2ddc2fSJohn David Anglin	tlb_lock	%r20,%r21,%r22
8253847dab7SHelge Deller0:	pdtlb		%r0(%r28)
8266d2ddc2fSJohn David Anglin	tlb_unlock	%r20,%r21,%r22
8273847dab7SHelge Deller	ALTERNATIVE(0b, 0b+4, ALT_COND_NO_SMP, INSN_PxTLB)
8286d2ddc2fSJohn David Anglin#endif
829f311847cSJames Bottomley
8303847dab7SHelge Deller88:	ldil		L%dcache_stride, %r1
831d65ea48dSJohn David Anglin	ldw		R%dcache_stride(%r1), r31
832f311847cSJames Bottomley
833f311847cSJames Bottomley#ifdef CONFIG_64BIT
834f311847cSJames Bottomley	depdi,z		1, 63-PAGE_SHIFT,1, %r25
835f311847cSJames Bottomley#else
836f311847cSJames Bottomley	depwi,z		1, 31-PAGE_SHIFT,1, %r25
837f311847cSJames Bottomley#endif
838f311847cSJames Bottomley	add		%r28, %r25, %r25
839d65ea48dSJohn David Anglin	sub		%r25, r31, %r25
840f311847cSJames Bottomley
841d65ea48dSJohn David Anglin1:	fdc,m		r31(%r28)
842d65ea48dSJohn David Anglin	fdc,m		r31(%r28)
843d65ea48dSJohn David Anglin	fdc,m		r31(%r28)
844d65ea48dSJohn David Anglin	fdc,m		r31(%r28)
845d65ea48dSJohn David Anglin	fdc,m		r31(%r28)
846d65ea48dSJohn David Anglin	fdc,m		r31(%r28)
847d65ea48dSJohn David Anglin	fdc,m		r31(%r28)
848d65ea48dSJohn David Anglin	fdc,m		r31(%r28)
849d65ea48dSJohn David Anglin	fdc,m		r31(%r28)
850d65ea48dSJohn David Anglin	fdc,m		r31(%r28)
851d65ea48dSJohn David Anglin	fdc,m		r31(%r28)
852d65ea48dSJohn David Anglin	fdc,m		r31(%r28)
853d65ea48dSJohn David Anglin	fdc,m		r31(%r28)
854d65ea48dSJohn David Anglin	fdc,m		r31(%r28)
855d65ea48dSJohn David Anglin	fdc,m		r31(%r28)
856*4c5fe5dbSJohn David Anglin	cmpb,COND(>>)	%r25, %r28, 1b /* predict taken */
857d65ea48dSJohn David Anglin	fdc,m		r31(%r28)
858f311847cSJames Bottomley
8593847dab7SHelge Deller89:	ALTERNATIVE(88b, 89b, ALT_COND_NO_DCACHE, INSN_NOP)
860f311847cSJames Bottomley	sync
861f311847cSJames Bottomley	bv		%r0(%r2)
8626d2ddc2fSJohn David Anglin	nop
863f39cce65SHelge DellerENDPROC_CFI(flush_dcache_page_asm)
864f311847cSJames Bottomley
865*4c5fe5dbSJohn David AnglinENTRY_CFI(purge_dcache_page_asm)
866*4c5fe5dbSJohn David Anglin	ldil		L%(TMPALIAS_MAP_START), %r28
867*4c5fe5dbSJohn David Anglin#ifdef CONFIG_64BIT
868*4c5fe5dbSJohn David Anglin#if (TMPALIAS_MAP_START >= 0x80000000)
869*4c5fe5dbSJohn David Anglin	depdi		0, 31,32, %r28		/* clear any sign extension */
870*4c5fe5dbSJohn David Anglin#endif
871*4c5fe5dbSJohn David Anglin	convert_phys_for_tlb_insert20 %r26	/* convert phys addr to tlb insert format */
872*4c5fe5dbSJohn David Anglin	depd		%r25, 63,22, %r28	/* Form aliased virtual address 'to' */
873*4c5fe5dbSJohn David Anglin	depdi		0, 63,PAGE_SHIFT, %r28	/* Clear any offset bits */
874*4c5fe5dbSJohn David Anglin#else
875*4c5fe5dbSJohn David Anglin	extrw,u		%r26, 24,25, %r26	/* convert phys addr to tlb insert format */
876*4c5fe5dbSJohn David Anglin	depw		%r25, 31,22, %r28	/* Form aliased virtual address 'to' */
877*4c5fe5dbSJohn David Anglin	depwi		0, 31,PAGE_SHIFT, %r28	/* Clear any offset bits */
878*4c5fe5dbSJohn David Anglin#endif
879*4c5fe5dbSJohn David Anglin
880*4c5fe5dbSJohn David Anglin	/* Purge any old translation */
881*4c5fe5dbSJohn David Anglin
882*4c5fe5dbSJohn David Anglin#ifdef CONFIG_PA20
883*4c5fe5dbSJohn David Anglin	pdtlb,l		%r0(%r28)
884*4c5fe5dbSJohn David Anglin#else
885*4c5fe5dbSJohn David Anglin	tlb_lock	%r20,%r21,%r22
886*4c5fe5dbSJohn David Anglin0:	pdtlb		%r0(%r28)
887*4c5fe5dbSJohn David Anglin	tlb_unlock	%r20,%r21,%r22
888*4c5fe5dbSJohn David Anglin	ALTERNATIVE(0b, 0b+4, ALT_COND_NO_SMP, INSN_PxTLB)
889*4c5fe5dbSJohn David Anglin#endif
890*4c5fe5dbSJohn David Anglin
891*4c5fe5dbSJohn David Anglin88:	ldil		L%dcache_stride, %r1
892*4c5fe5dbSJohn David Anglin	ldw		R%dcache_stride(%r1), r31
893*4c5fe5dbSJohn David Anglin
894*4c5fe5dbSJohn David Anglin#ifdef CONFIG_64BIT
895*4c5fe5dbSJohn David Anglin	depdi,z		1, 63-PAGE_SHIFT,1, %r25
896*4c5fe5dbSJohn David Anglin#else
897*4c5fe5dbSJohn David Anglin	depwi,z		1, 31-PAGE_SHIFT,1, %r25
898*4c5fe5dbSJohn David Anglin#endif
899*4c5fe5dbSJohn David Anglin	add		%r28, %r25, %r25
900*4c5fe5dbSJohn David Anglin	sub		%r25, r31, %r25
901*4c5fe5dbSJohn David Anglin
902*4c5fe5dbSJohn David Anglin1:      pdc,m		r31(%r28)
903*4c5fe5dbSJohn David Anglin	pdc,m		r31(%r28)
904*4c5fe5dbSJohn David Anglin	pdc,m		r31(%r28)
905*4c5fe5dbSJohn David Anglin	pdc,m		r31(%r28)
906*4c5fe5dbSJohn David Anglin	pdc,m		r31(%r28)
907*4c5fe5dbSJohn David Anglin	pdc,m		r31(%r28)
908*4c5fe5dbSJohn David Anglin	pdc,m		r31(%r28)
909*4c5fe5dbSJohn David Anglin	pdc,m		r31(%r28)
910*4c5fe5dbSJohn David Anglin	pdc,m		r31(%r28)
911*4c5fe5dbSJohn David Anglin	pdc,m		r31(%r28)
912*4c5fe5dbSJohn David Anglin	pdc,m		r31(%r28)
913*4c5fe5dbSJohn David Anglin	pdc,m		r31(%r28)
914*4c5fe5dbSJohn David Anglin	pdc,m		r31(%r28)
915*4c5fe5dbSJohn David Anglin	pdc,m		r31(%r28)
916*4c5fe5dbSJohn David Anglin	pdc,m		r31(%r28)
917*4c5fe5dbSJohn David Anglin	cmpb,COND(>>)	%r25, %r28, 1b /* predict taken */
918*4c5fe5dbSJohn David Anglin	pdc,m		r31(%r28)
919*4c5fe5dbSJohn David Anglin
920*4c5fe5dbSJohn David Anglin89:	ALTERNATIVE(88b, 89b, ALT_COND_NO_DCACHE, INSN_NOP)
921*4c5fe5dbSJohn David Anglin	sync
922*4c5fe5dbSJohn David Anglin	bv		%r0(%r2)
923*4c5fe5dbSJohn David Anglin	nop
924*4c5fe5dbSJohn David AnglinENDPROC_CFI(purge_dcache_page_asm)
925*4c5fe5dbSJohn David Anglin
926f39cce65SHelge DellerENTRY_CFI(flush_icache_page_asm)
927f311847cSJames Bottomley	ldil		L%(TMPALIAS_MAP_START), %r28
928f311847cSJames Bottomley#ifdef CONFIG_64BIT
929f311847cSJames Bottomley#if (TMPALIAS_MAP_START >= 0x80000000)
930f311847cSJames Bottomley	depdi		0, 31,32, %r28		/* clear any sign extension */
931f311847cSJames Bottomley#endif
9326a45716aSHelge Deller	convert_phys_for_tlb_insert20 %r26	/* convert phys addr to tlb insert format */
933f311847cSJames Bottomley	depd		%r25, 63,22, %r28	/* Form aliased virtual address 'to' */
9346a45716aSHelge Deller	depdi		0, 63,PAGE_SHIFT, %r28	/* Clear any offset bits */
935f311847cSJames Bottomley#else
936f311847cSJames Bottomley	extrw,u		%r26, 24,25, %r26	/* convert phys addr to tlb insert format */
937f311847cSJames Bottomley	depw		%r25, 31,22, %r28	/* Form aliased virtual address 'to' */
938d845b5fbSHelge Deller	depwi		0, 31,PAGE_SHIFT, %r28	/* Clear any offset bits */
939f311847cSJames Bottomley#endif
940f311847cSJames Bottomley
9415035b230SJohn David Anglin	/* Purge any old translation.  Note that the FIC instruction
9425035b230SJohn David Anglin	 * may use either the instruction or data TLB.  Given that we
9435035b230SJohn David Anglin	 * have a flat address space, it's not clear which TLB will be
9445035b230SJohn David Anglin	 * used.  So, we purge both entries.  */
945f311847cSJames Bottomley
9466d2ddc2fSJohn David Anglin#ifdef CONFIG_PA20
9475035b230SJohn David Anglin	pdtlb,l		%r0(%r28)
9483847dab7SHelge Deller1:	pitlb,l         %r0(%sr4,%r28)
9493847dab7SHelge Deller	ALTERNATIVE(1b, 1b+4, ALT_COND_NO_SPLIT_TLB, INSN_NOP)
9506d2ddc2fSJohn David Anglin#else
9516d2ddc2fSJohn David Anglin	tlb_lock        %r20,%r21,%r22
9523847dab7SHelge Deller0:	pdtlb		%r0(%r28)
9533847dab7SHelge Deller1:	pitlb           %r0(%sr4,%r28)
9546d2ddc2fSJohn David Anglin	tlb_unlock      %r20,%r21,%r22
9553847dab7SHelge Deller	ALTERNATIVE(0b, 0b+4, ALT_COND_NO_SMP, INSN_PxTLB)
9563847dab7SHelge Deller	ALTERNATIVE(1b, 1b+4, ALT_COND_NO_SMP, INSN_PxTLB)
9573847dab7SHelge Deller	ALTERNATIVE(1b, 1b+4, ALT_COND_NO_SPLIT_TLB, INSN_NOP)
9586d2ddc2fSJohn David Anglin#endif
959f311847cSJames Bottomley
9603847dab7SHelge Deller88:	ldil		L%icache_stride, %r1
961d65ea48dSJohn David Anglin	ldw		R%icache_stride(%r1), %r31
962f311847cSJames Bottomley
963f311847cSJames Bottomley#ifdef CONFIG_64BIT
964f311847cSJames Bottomley	depdi,z		1, 63-PAGE_SHIFT,1, %r25
965f311847cSJames Bottomley#else
966f311847cSJames Bottomley	depwi,z		1, 31-PAGE_SHIFT,1, %r25
967f311847cSJames Bottomley#endif
968f311847cSJames Bottomley	add		%r28, %r25, %r25
969d65ea48dSJohn David Anglin	sub		%r25, %r31, %r25
970f311847cSJames Bottomley
971207f583dSJohn David Anglin	/* fic only has the type 26 form on PA1.1, requiring an
972207f583dSJohn David Anglin	 * explicit space specification, so use %sr4 */
973d65ea48dSJohn David Anglin1:      fic,m		%r31(%sr4,%r28)
974d65ea48dSJohn David Anglin	fic,m		%r31(%sr4,%r28)
975d65ea48dSJohn David Anglin	fic,m		%r31(%sr4,%r28)
976d65ea48dSJohn David Anglin	fic,m		%r31(%sr4,%r28)
977d65ea48dSJohn David Anglin	fic,m		%r31(%sr4,%r28)
978d65ea48dSJohn David Anglin	fic,m		%r31(%sr4,%r28)
979d65ea48dSJohn David Anglin	fic,m		%r31(%sr4,%r28)
980d65ea48dSJohn David Anglin	fic,m		%r31(%sr4,%r28)
981d65ea48dSJohn David Anglin	fic,m		%r31(%sr4,%r28)
982d65ea48dSJohn David Anglin	fic,m		%r31(%sr4,%r28)
983d65ea48dSJohn David Anglin	fic,m		%r31(%sr4,%r28)
984d65ea48dSJohn David Anglin	fic,m		%r31(%sr4,%r28)
985d65ea48dSJohn David Anglin	fic,m		%r31(%sr4,%r28)
986d65ea48dSJohn David Anglin	fic,m		%r31(%sr4,%r28)
987d65ea48dSJohn David Anglin	fic,m		%r31(%sr4,%r28)
988*4c5fe5dbSJohn David Anglin	cmpb,COND(>>)	%r25, %r28, 1b /* predict taken */
989d65ea48dSJohn David Anglin	fic,m		%r31(%sr4,%r28)
990f311847cSJames Bottomley
9913847dab7SHelge Deller89:	ALTERNATIVE(88b, 89b, ALT_COND_NO_ICACHE, INSN_NOP)
992f311847cSJames Bottomley	sync
9936d2ddc2fSJohn David Anglin	bv		%r0(%r2)
9946d2ddc2fSJohn David Anglin	nop
995f39cce65SHelge DellerENDPROC_CFI(flush_icache_page_asm)
996f311847cSJames Bottomley
997f39cce65SHelge DellerENTRY_CFI(flush_kernel_dcache_page_asm)
9983847dab7SHelge Deller88:	ldil		L%dcache_stride, %r1
9991da177e4SLinus Torvalds	ldw		R%dcache_stride(%r1), %r23
10001da177e4SLinus Torvalds
1001413059f2SGrant Grundler#ifdef CONFIG_64BIT
10021da177e4SLinus Torvalds	depdi,z		1, 63-PAGE_SHIFT,1, %r25
10031da177e4SLinus Torvalds#else
10041da177e4SLinus Torvalds	depwi,z		1, 31-PAGE_SHIFT,1, %r25
10051da177e4SLinus Torvalds#endif
10061da177e4SLinus Torvalds	add		%r26, %r25, %r25
10071da177e4SLinus Torvalds	sub		%r25, %r23, %r25
10081da177e4SLinus Torvalds
10091da177e4SLinus Torvalds1:      fdc,m		%r23(%r26)
10101da177e4SLinus Torvalds	fdc,m		%r23(%r26)
10111da177e4SLinus Torvalds	fdc,m		%r23(%r26)
10121da177e4SLinus Torvalds	fdc,m		%r23(%r26)
10131da177e4SLinus Torvalds	fdc,m		%r23(%r26)
10141da177e4SLinus Torvalds	fdc,m		%r23(%r26)
10151da177e4SLinus Torvalds	fdc,m		%r23(%r26)
10161da177e4SLinus Torvalds	fdc,m		%r23(%r26)
10171da177e4SLinus Torvalds	fdc,m		%r23(%r26)
10181da177e4SLinus Torvalds	fdc,m		%r23(%r26)
10191da177e4SLinus Torvalds	fdc,m		%r23(%r26)
10201da177e4SLinus Torvalds	fdc,m		%r23(%r26)
10211da177e4SLinus Torvalds	fdc,m		%r23(%r26)
10221da177e4SLinus Torvalds	fdc,m		%r23(%r26)
10231da177e4SLinus Torvalds	fdc,m		%r23(%r26)
1024*4c5fe5dbSJohn David Anglin	cmpb,COND(>>)	%r25, %r26, 1b /* predict taken */
10251da177e4SLinus Torvalds	fdc,m		%r23(%r26)
10261da177e4SLinus Torvalds
10273847dab7SHelge Deller89:	ALTERNATIVE(88b, 89b, ALT_COND_NO_DCACHE, INSN_NOP)
10281da177e4SLinus Torvalds	sync
10291da177e4SLinus Torvalds	bv		%r0(%r2)
10301da177e4SLinus Torvalds	nop
1031f39cce65SHelge DellerENDPROC_CFI(flush_kernel_dcache_page_asm)
10321da177e4SLinus Torvalds
1033f39cce65SHelge DellerENTRY_CFI(purge_kernel_dcache_page_asm)
10343847dab7SHelge Deller88:	ldil		L%dcache_stride, %r1
10351da177e4SLinus Torvalds	ldw		R%dcache_stride(%r1), %r23
10361da177e4SLinus Torvalds
1037413059f2SGrant Grundler#ifdef CONFIG_64BIT
10381da177e4SLinus Torvalds	depdi,z		1, 63-PAGE_SHIFT,1, %r25
10391da177e4SLinus Torvalds#else
10401da177e4SLinus Torvalds	depwi,z		1, 31-PAGE_SHIFT,1, %r25
10411da177e4SLinus Torvalds#endif
10421da177e4SLinus Torvalds	add		%r26, %r25, %r25
10431da177e4SLinus Torvalds	sub		%r25, %r23, %r25
10441da177e4SLinus Torvalds
10451da177e4SLinus Torvalds1:      pdc,m		%r23(%r26)
10461da177e4SLinus Torvalds	pdc,m		%r23(%r26)
10471da177e4SLinus Torvalds	pdc,m		%r23(%r26)
10481da177e4SLinus Torvalds	pdc,m		%r23(%r26)
10491da177e4SLinus Torvalds	pdc,m		%r23(%r26)
10501da177e4SLinus Torvalds	pdc,m		%r23(%r26)
10511da177e4SLinus Torvalds	pdc,m		%r23(%r26)
10521da177e4SLinus Torvalds	pdc,m		%r23(%r26)
10531da177e4SLinus Torvalds	pdc,m		%r23(%r26)
10541da177e4SLinus Torvalds	pdc,m		%r23(%r26)
10551da177e4SLinus Torvalds	pdc,m		%r23(%r26)
10561da177e4SLinus Torvalds	pdc,m		%r23(%r26)
10571da177e4SLinus Torvalds	pdc,m		%r23(%r26)
10581da177e4SLinus Torvalds	pdc,m		%r23(%r26)
10591da177e4SLinus Torvalds	pdc,m		%r23(%r26)
1060*4c5fe5dbSJohn David Anglin	cmpb,COND(>>)	%r25, %r26, 1b /* predict taken */
10611da177e4SLinus Torvalds	pdc,m		%r23(%r26)
10621da177e4SLinus Torvalds
10633847dab7SHelge Deller89:	ALTERNATIVE(88b, 89b, ALT_COND_NO_DCACHE, INSN_NOP)
10641da177e4SLinus Torvalds	sync
10651da177e4SLinus Torvalds	bv		%r0(%r2)
10661da177e4SLinus Torvalds	nop
1067f39cce65SHelge DellerENDPROC_CFI(purge_kernel_dcache_page_asm)
10681da177e4SLinus Torvalds
1069f39cce65SHelge DellerENTRY_CFI(flush_user_dcache_range_asm)
10703847dab7SHelge Deller88:	ldil		L%dcache_stride, %r1
10711da177e4SLinus Torvalds	ldw		R%dcache_stride(%r1), %r23
10721da177e4SLinus Torvalds	ldo		-1(%r23), %r21
10731da177e4SLinus Torvalds	ANDCM		%r26, %r21, %r26
10741da177e4SLinus Torvalds
1075*4c5fe5dbSJohn David Anglin#ifdef CONFIG_64BIT
1076*4c5fe5dbSJohn David Anglin	depd,z		%r23, 59, 60, %r21
1077*4c5fe5dbSJohn David Anglin#else
1078*4c5fe5dbSJohn David Anglin	depw,z		%r23, 27, 28, %r21
1079*4c5fe5dbSJohn David Anglin#endif
1080*4c5fe5dbSJohn David Anglin	add		%r26, %r21, %r22
1081*4c5fe5dbSJohn David Anglin	cmpb,COND(>>),n	%r22, %r25, 2f /* predict not taken */
1082*4c5fe5dbSJohn David Anglin1:	add		%r22, %r21, %r22
1083*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%sr3, %r26)
1084*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%sr3, %r26)
1085*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%sr3, %r26)
1086*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%sr3, %r26)
1087*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%sr3, %r26)
1088*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%sr3, %r26)
1089*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%sr3, %r26)
1090*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%sr3, %r26)
1091*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%sr3, %r26)
1092*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%sr3, %r26)
1093*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%sr3, %r26)
1094*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%sr3, %r26)
1095*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%sr3, %r26)
1096*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%sr3, %r26)
1097*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%sr3, %r26)
1098*4c5fe5dbSJohn David Anglin	cmpb,COND(<<=)	%r22, %r25, 1b /* predict taken */
1099*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%sr3, %r26)
1100*4c5fe5dbSJohn David Anglin
1101*4c5fe5dbSJohn David Anglin2:	cmpb,COND(>>),n	%r25, %r26, 2b
11021da177e4SLinus Torvalds	fdc,m		%r23(%sr3, %r26)
11031da177e4SLinus Torvalds
11043847dab7SHelge Deller89:	ALTERNATIVE(88b, 89b, ALT_COND_NO_DCACHE, INSN_NOP)
11051da177e4SLinus Torvalds	sync
11061da177e4SLinus Torvalds	bv		%r0(%r2)
11071da177e4SLinus Torvalds	nop
1108f39cce65SHelge DellerENDPROC_CFI(flush_user_dcache_range_asm)
11091da177e4SLinus Torvalds
1110f39cce65SHelge DellerENTRY_CFI(flush_kernel_dcache_range_asm)
11113847dab7SHelge Deller88:	ldil		L%dcache_stride, %r1
11121da177e4SLinus Torvalds	ldw		R%dcache_stride(%r1), %r23
11131da177e4SLinus Torvalds	ldo		-1(%r23), %r21
11141da177e4SLinus Torvalds	ANDCM		%r26, %r21, %r26
11151da177e4SLinus Torvalds
1116*4c5fe5dbSJohn David Anglin#ifdef CONFIG_64BIT
1117*4c5fe5dbSJohn David Anglin	depd,z		%r23, 59, 60, %r21
1118*4c5fe5dbSJohn David Anglin#else
1119*4c5fe5dbSJohn David Anglin	depw,z		%r23, 27, 28, %r21
1120*4c5fe5dbSJohn David Anglin#endif
1121*4c5fe5dbSJohn David Anglin	add		%r26, %r21, %r22
1122*4c5fe5dbSJohn David Anglin	cmpb,COND(>>),n	%r22, %r25, 2f /* predict not taken */
1123*4c5fe5dbSJohn David Anglin1:	add		%r22, %r21, %r22
1124*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%r26)
1125*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%r26)
1126*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%r26)
1127*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%r26)
1128*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%r26)
1129*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%r26)
1130*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%r26)
1131*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%r26)
1132*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%r26)
1133*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%r26)
1134*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%r26)
1135*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%r26)
1136*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%r26)
1137*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%r26)
1138*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%r26)
1139*4c5fe5dbSJohn David Anglin	cmpb,COND(<<=)	%r22, %r25, 1b /* predict taken */
1140*4c5fe5dbSJohn David Anglin	fdc,m		%r23(%r26)
1141*4c5fe5dbSJohn David Anglin
1142*4c5fe5dbSJohn David Anglin2:	cmpb,COND(>>),n	%r25, %r26, 2b /* predict taken */
11431da177e4SLinus Torvalds	fdc,m		%r23(%r26)
11441da177e4SLinus Torvalds
11451da177e4SLinus Torvalds	sync
11463847dab7SHelge Deller89:	ALTERNATIVE(88b, 89b, ALT_COND_NO_DCACHE, INSN_NOP)
11471da177e4SLinus Torvalds	syncdma
11481da177e4SLinus Torvalds	bv		%r0(%r2)
11491da177e4SLinus Torvalds	nop
1150f39cce65SHelge DellerENDPROC_CFI(flush_kernel_dcache_range_asm)
11511da177e4SLinus Torvalds
11520adb24e0SJohn David AnglinENTRY_CFI(purge_kernel_dcache_range_asm)
11533847dab7SHelge Deller88:	ldil		L%dcache_stride, %r1
11540adb24e0SJohn David Anglin	ldw		R%dcache_stride(%r1), %r23
11550adb24e0SJohn David Anglin	ldo		-1(%r23), %r21
11560adb24e0SJohn David Anglin	ANDCM		%r26, %r21, %r26
11570adb24e0SJohn David Anglin
1158*4c5fe5dbSJohn David Anglin#ifdef CONFIG_64BIT
1159*4c5fe5dbSJohn David Anglin	depd,z		%r23, 59, 60, %r21
1160*4c5fe5dbSJohn David Anglin#else
1161*4c5fe5dbSJohn David Anglin	depw,z		%r23, 27, 28, %r21
1162*4c5fe5dbSJohn David Anglin#endif
1163*4c5fe5dbSJohn David Anglin	add		%r26, %r21, %r22
1164*4c5fe5dbSJohn David Anglin	cmpb,COND(>>),n	%r22, %r25, 2f /* predict not taken */
1165*4c5fe5dbSJohn David Anglin1:	add		%r22, %r21, %r22
1166*4c5fe5dbSJohn David Anglin	pdc,m		%r23(%r26)
1167*4c5fe5dbSJohn David Anglin	pdc,m		%r23(%r26)
1168*4c5fe5dbSJohn David Anglin	pdc,m		%r23(%r26)
1169*4c5fe5dbSJohn David Anglin	pdc,m		%r23(%r26)
1170*4c5fe5dbSJohn David Anglin	pdc,m		%r23(%r26)
1171*4c5fe5dbSJohn David Anglin	pdc,m		%r23(%r26)
1172*4c5fe5dbSJohn David Anglin	pdc,m		%r23(%r26)
1173*4c5fe5dbSJohn David Anglin	pdc,m		%r23(%r26)
1174*4c5fe5dbSJohn David Anglin	pdc,m		%r23(%r26)
1175*4c5fe5dbSJohn David Anglin	pdc,m		%r23(%r26)
1176*4c5fe5dbSJohn David Anglin	pdc,m		%r23(%r26)
1177*4c5fe5dbSJohn David Anglin	pdc,m		%r23(%r26)
1178*4c5fe5dbSJohn David Anglin	pdc,m		%r23(%r26)
1179*4c5fe5dbSJohn David Anglin	pdc,m		%r23(%r26)
1180*4c5fe5dbSJohn David Anglin	pdc,m		%r23(%r26)
1181*4c5fe5dbSJohn David Anglin	cmpb,COND(<<=)	%r22, %r25, 1b /* predict taken */
1182*4c5fe5dbSJohn David Anglin	pdc,m		%r23(%r26)
1183*4c5fe5dbSJohn David Anglin
1184*4c5fe5dbSJohn David Anglin2:	cmpb,COND(>>),n	%r25, %r26, 2b /* predict taken */
11850adb24e0SJohn David Anglin	pdc,m		%r23(%r26)
11860adb24e0SJohn David Anglin
11870adb24e0SJohn David Anglin	sync
11883847dab7SHelge Deller89:	ALTERNATIVE(88b, 89b, ALT_COND_NO_DCACHE, INSN_NOP)
11890adb24e0SJohn David Anglin	syncdma
11900adb24e0SJohn David Anglin	bv		%r0(%r2)
11910adb24e0SJohn David Anglin	nop
11920adb24e0SJohn David AnglinENDPROC_CFI(purge_kernel_dcache_range_asm)
11930adb24e0SJohn David Anglin
1194f39cce65SHelge DellerENTRY_CFI(flush_user_icache_range_asm)
11953847dab7SHelge Deller88:	ldil		L%icache_stride, %r1
11961da177e4SLinus Torvalds	ldw		R%icache_stride(%r1), %r23
11971da177e4SLinus Torvalds	ldo		-1(%r23), %r21
11981da177e4SLinus Torvalds	ANDCM		%r26, %r21, %r26
11991da177e4SLinus Torvalds
1200*4c5fe5dbSJohn David Anglin#ifdef CONFIG_64BIT
1201*4c5fe5dbSJohn David Anglin	depd,z		%r23, 59, 60, %r21
1202*4c5fe5dbSJohn David Anglin#else
1203*4c5fe5dbSJohn David Anglin	depw,z		%r23, 27, 28, %r21
1204*4c5fe5dbSJohn David Anglin#endif
1205*4c5fe5dbSJohn David Anglin	add		%r26, %r21, %r22
1206*4c5fe5dbSJohn David Anglin	cmpb,COND(>>),n	%r22, %r25, 2f /* predict not taken */
1207*4c5fe5dbSJohn David Anglin1:	add		%r22, %r21, %r22
1208*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr3, %r26)
1209*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr3, %r26)
1210*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr3, %r26)
1211*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr3, %r26)
1212*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr3, %r26)
1213*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr3, %r26)
1214*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr3, %r26)
1215*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr3, %r26)
1216*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr3, %r26)
1217*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr3, %r26)
1218*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr3, %r26)
1219*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr3, %r26)
1220*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr3, %r26)
1221*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr3, %r26)
1222*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr3, %r26)
1223*4c5fe5dbSJohn David Anglin	cmpb,COND(<<=)	%r22, %r25, 1b /* predict taken */
1224*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr3, %r26)
1225*4c5fe5dbSJohn David Anglin
1226*4c5fe5dbSJohn David Anglin2:	cmpb,COND(>>),n	%r25, %r26, 2b
12271da177e4SLinus Torvalds	fic,m		%r23(%sr3, %r26)
12281da177e4SLinus Torvalds
12293847dab7SHelge Deller89:	ALTERNATIVE(88b, 89b, ALT_COND_NO_ICACHE, INSN_NOP)
12301da177e4SLinus Torvalds	sync
12311da177e4SLinus Torvalds	bv		%r0(%r2)
12321da177e4SLinus Torvalds	nop
1233f39cce65SHelge DellerENDPROC_CFI(flush_user_icache_range_asm)
12341da177e4SLinus Torvalds
1235f39cce65SHelge DellerENTRY_CFI(flush_kernel_icache_page)
12363847dab7SHelge Deller88:	ldil		L%icache_stride, %r1
12371da177e4SLinus Torvalds	ldw		R%icache_stride(%r1), %r23
12381da177e4SLinus Torvalds
1239413059f2SGrant Grundler#ifdef CONFIG_64BIT
12401da177e4SLinus Torvalds	depdi,z		1, 63-PAGE_SHIFT,1, %r25
12411da177e4SLinus Torvalds#else
12421da177e4SLinus Torvalds	depwi,z		1, 31-PAGE_SHIFT,1, %r25
12431da177e4SLinus Torvalds#endif
12441da177e4SLinus Torvalds	add		%r26, %r25, %r25
12451da177e4SLinus Torvalds	sub		%r25, %r23, %r25
12461da177e4SLinus Torvalds
12471da177e4SLinus Torvalds
1248e635c96eSMatthew Wilcox1:      fic,m		%r23(%sr4, %r26)
1249e635c96eSMatthew Wilcox	fic,m		%r23(%sr4, %r26)
1250e635c96eSMatthew Wilcox	fic,m		%r23(%sr4, %r26)
1251e635c96eSMatthew Wilcox	fic,m		%r23(%sr4, %r26)
1252e635c96eSMatthew Wilcox	fic,m		%r23(%sr4, %r26)
1253e635c96eSMatthew Wilcox	fic,m		%r23(%sr4, %r26)
1254e635c96eSMatthew Wilcox	fic,m		%r23(%sr4, %r26)
1255e635c96eSMatthew Wilcox	fic,m		%r23(%sr4, %r26)
1256e635c96eSMatthew Wilcox	fic,m		%r23(%sr4, %r26)
1257e635c96eSMatthew Wilcox	fic,m		%r23(%sr4, %r26)
1258e635c96eSMatthew Wilcox	fic,m		%r23(%sr4, %r26)
1259e635c96eSMatthew Wilcox	fic,m		%r23(%sr4, %r26)
1260e635c96eSMatthew Wilcox	fic,m		%r23(%sr4, %r26)
1261e635c96eSMatthew Wilcox	fic,m		%r23(%sr4, %r26)
1262e635c96eSMatthew Wilcox	fic,m		%r23(%sr4, %r26)
1263*4c5fe5dbSJohn David Anglin	cmpb,COND(>>)	%r25, %r26, 1b /* predict taken */
1264e635c96eSMatthew Wilcox	fic,m		%r23(%sr4, %r26)
12651da177e4SLinus Torvalds
12663847dab7SHelge Deller89:	ALTERNATIVE(88b, 89b, ALT_COND_NO_ICACHE, INSN_NOP)
12671da177e4SLinus Torvalds	sync
12681da177e4SLinus Torvalds	bv		%r0(%r2)
12691da177e4SLinus Torvalds	nop
1270f39cce65SHelge DellerENDPROC_CFI(flush_kernel_icache_page)
12711da177e4SLinus Torvalds
1272f39cce65SHelge DellerENTRY_CFI(flush_kernel_icache_range_asm)
12733847dab7SHelge Deller88:	ldil		L%icache_stride, %r1
12741da177e4SLinus Torvalds	ldw		R%icache_stride(%r1), %r23
12751da177e4SLinus Torvalds	ldo		-1(%r23), %r21
12761da177e4SLinus Torvalds	ANDCM		%r26, %r21, %r26
12771da177e4SLinus Torvalds
1278*4c5fe5dbSJohn David Anglin#ifdef CONFIG_64BIT
1279*4c5fe5dbSJohn David Anglin	depd,z		%r23, 59, 60, %r21
1280*4c5fe5dbSJohn David Anglin#else
1281*4c5fe5dbSJohn David Anglin	depw,z		%r23, 27, 28, %r21
1282*4c5fe5dbSJohn David Anglin#endif
1283*4c5fe5dbSJohn David Anglin	add		%r26, %r21, %r22
1284*4c5fe5dbSJohn David Anglin	cmpb,COND(>>),n	%r22, %r25, 2f /* predict not taken */
1285*4c5fe5dbSJohn David Anglin1:	add		%r22, %r21, %r22
1286*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr4, %r26)
1287*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr4, %r26)
1288*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr4, %r26)
1289*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr4, %r26)
1290*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr4, %r26)
1291*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr4, %r26)
1292*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr4, %r26)
1293*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr4, %r26)
1294*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr4, %r26)
1295*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr4, %r26)
1296*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr4, %r26)
1297*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr4, %r26)
1298*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr4, %r26)
1299*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr4, %r26)
1300*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr4, %r26)
1301*4c5fe5dbSJohn David Anglin	cmpb,COND(<<=)	%r22, %r25, 1b /* predict taken */
1302*4c5fe5dbSJohn David Anglin	fic,m		%r23(%sr4, %r26)
1303*4c5fe5dbSJohn David Anglin
1304*4c5fe5dbSJohn David Anglin2:	cmpb,COND(>>),n	%r25, %r26, 2b /* predict taken */
1305e635c96eSMatthew Wilcox	fic,m		%r23(%sr4, %r26)
13061da177e4SLinus Torvalds
13073847dab7SHelge Deller89:	ALTERNATIVE(88b, 89b, ALT_COND_NO_ICACHE, INSN_NOP)
13081da177e4SLinus Torvalds	sync
13091da177e4SLinus Torvalds	bv		%r0(%r2)
13101da177e4SLinus Torvalds	nop
1311f39cce65SHelge DellerENDPROC_CFI(flush_kernel_icache_range_asm)
13121da177e4SLinus Torvalds
13132a03bb9eSHelge Deller	__INIT
13142a03bb9eSHelge Deller
1315896a3756SGrant Grundler	/* align should cover use of rfi in disable_sr_hashing_asm and
1316896a3756SGrant Grundler	 * srdis_done.
1317896a3756SGrant Grundler	 */
1318896a3756SGrant Grundler	.align	256
1319f39cce65SHelge DellerENTRY_CFI(disable_sr_hashing_asm)
1320896a3756SGrant Grundler	/*
1321896a3756SGrant Grundler	 * Switch to real mode
1322896a3756SGrant Grundler	 */
1323896a3756SGrant Grundler	/* pcxt_ssm_bug */
1324896a3756SGrant Grundler	rsm		PSW_SM_I, %r0
1325896a3756SGrant Grundler	load32		PA(1f), %r1
13261da177e4SLinus Torvalds	nop
13271da177e4SLinus Torvalds	nop
13281da177e4SLinus Torvalds	nop
13291da177e4SLinus Torvalds	nop
13301da177e4SLinus Torvalds	nop
13311da177e4SLinus Torvalds
1332896a3756SGrant Grundler	rsm		PSW_SM_Q, %r0		/* prep to load iia queue */
13331da177e4SLinus Torvalds	mtctl		%r0, %cr17		/* Clear IIASQ tail */
13341da177e4SLinus Torvalds	mtctl		%r0, %cr17		/* Clear IIASQ head */
13351da177e4SLinus Torvalds	mtctl		%r1, %cr18		/* IIAOQ head */
13361da177e4SLinus Torvalds	ldo		4(%r1), %r1
13371da177e4SLinus Torvalds	mtctl		%r1, %cr18		/* IIAOQ tail */
1338896a3756SGrant Grundler	load32		REAL_MODE_PSW, %r1
1339896a3756SGrant Grundler	mtctl		%r1, %ipsw
13401da177e4SLinus Torvalds	rfi
13411da177e4SLinus Torvalds	nop
13421da177e4SLinus Torvalds
13431da177e4SLinus Torvalds1:      cmpib,=,n	SRHASH_PCXST, %r26,srdis_pcxs
13441da177e4SLinus Torvalds	cmpib,=,n	SRHASH_PCXL, %r26,srdis_pcxl
13451da177e4SLinus Torvalds	cmpib,=,n	SRHASH_PA20, %r26,srdis_pa20
13461da177e4SLinus Torvalds	b,n		srdis_done
13471da177e4SLinus Torvalds
13481da177e4SLinus Torvaldssrdis_pcxs:
13491da177e4SLinus Torvalds
13501da177e4SLinus Torvalds	/* Disable Space Register Hashing for PCXS,PCXT,PCXT' */
13511da177e4SLinus Torvalds
13521da177e4SLinus Torvalds	.word		0x141c1a00		/* mfdiag %dr0, %r28 */
13531da177e4SLinus Torvalds	.word		0x141c1a00		/* must issue twice */
13541da177e4SLinus Torvalds	depwi		0,18,1, %r28		/* Clear DHE (dcache hash enable) */
13551da177e4SLinus Torvalds	depwi		0,20,1, %r28		/* Clear IHE (icache hash enable) */
13561da177e4SLinus Torvalds	.word		0x141c1600		/* mtdiag %r28, %dr0 */
13571da177e4SLinus Torvalds	.word		0x141c1600		/* must issue twice */
13581da177e4SLinus Torvalds	b,n		srdis_done
13591da177e4SLinus Torvalds
13601da177e4SLinus Torvaldssrdis_pcxl:
13611da177e4SLinus Torvalds
13621da177e4SLinus Torvalds	/* Disable Space Register Hashing for PCXL */
13631da177e4SLinus Torvalds
13641da177e4SLinus Torvalds	.word		0x141c0600		/* mfdiag %dr0, %r28 */
13651da177e4SLinus Torvalds	depwi           0,28,2, %r28		/* Clear DHASH_EN & IHASH_EN */
13661da177e4SLinus Torvalds	.word		0x141c0240		/* mtdiag %r28, %dr0 */
13671da177e4SLinus Torvalds	b,n		srdis_done
13681da177e4SLinus Torvalds
13691da177e4SLinus Torvaldssrdis_pa20:
13701da177e4SLinus Torvalds
1371896a3756SGrant Grundler	/* Disable Space Register Hashing for PCXU,PCXU+,PCXW,PCXW+,PCXW2 */
13721da177e4SLinus Torvalds
13731da177e4SLinus Torvalds	.word		0x144008bc		/* mfdiag %dr2, %r28 */
13741da177e4SLinus Torvalds	depdi		0, 54,1, %r28		/* clear DIAG_SPHASH_ENAB (bit 54) */
13751da177e4SLinus Torvalds	.word		0x145c1840		/* mtdiag %r28, %dr2 */
13761da177e4SLinus Torvalds
1377896a3756SGrant Grundler
13781da177e4SLinus Torvaldssrdis_done:
13791da177e4SLinus Torvalds	/* Switch back to virtual mode */
1380896a3756SGrant Grundler	rsm		PSW_SM_I, %r0		/* prep to load iia queue */
1381896a3756SGrant Grundler	load32 	   	2f, %r1
1382896a3756SGrant Grundler	nop
1383896a3756SGrant Grundler	nop
1384896a3756SGrant Grundler	nop
1385896a3756SGrant Grundler	nop
1386896a3756SGrant Grundler	nop
13871da177e4SLinus Torvalds
1388896a3756SGrant Grundler	rsm		PSW_SM_Q, %r0		/* prep to load iia queue */
13891da177e4SLinus Torvalds	mtctl		%r0, %cr17		/* Clear IIASQ tail */
13901da177e4SLinus Torvalds	mtctl		%r0, %cr17		/* Clear IIASQ head */
13911da177e4SLinus Torvalds	mtctl		%r1, %cr18		/* IIAOQ head */
13921da177e4SLinus Torvalds	ldo		4(%r1), %r1
13931da177e4SLinus Torvalds	mtctl		%r1, %cr18		/* IIAOQ tail */
1394896a3756SGrant Grundler	load32		KERNEL_PSW, %r1
1395896a3756SGrant Grundler	mtctl		%r1, %ipsw
13961da177e4SLinus Torvalds	rfi
13971da177e4SLinus Torvalds	nop
13981da177e4SLinus Torvalds
13991da177e4SLinus Torvalds2:      bv		%r0(%r2)
14001da177e4SLinus Torvalds	nop
1401f39cce65SHelge DellerENDPROC_CFI(disable_sr_hashing_asm)
14021da177e4SLinus Torvalds
14031da177e4SLinus Torvalds	.end
1404