pacache.S 29.9 KB
Newer Older
Linus Torvalds's avatar
Linus Torvalds committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
 *  PARISC TLB and cache flushing support
 *  Copyright (C) 2000-2001 Hewlett-Packard (John Marvin)
 *  Copyright (C) 2001 Matthew Wilcox (willy at parisc-linux.org)
 *  Copyright (C) 2002 Richard Hirst (rhirst with parisc-linux.org)
 *
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 2, or (at your option)
 *    any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License
 *    along with this program; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

/*
 * NOTE: fdc,fic, and pdc instructions that use base register modification
 *       should only use index and base registers that are not shadowed,
 *       so that the fast path emulation in the non access miss handler
 *       can be used.
 */

29
#ifdef CONFIG_64BIT
Linus Torvalds's avatar
Linus Torvalds committed
30
31
32
33
34
35
	.level	2.0w
#else
	.level	2.0
#endif

#include <asm/psw.h>
36
#include <asm/assembly.h>
Linus Torvalds's avatar
Linus Torvalds committed
37
38
#include <asm/pgtable.h>
#include <asm/cache.h>
39
#include <linux/linkage.h>
Linus Torvalds's avatar
Linus Torvalds committed
40

41
	.text
Linus Torvalds's avatar
Linus Torvalds committed
42
43
	.align	128

44
ENTRY_CFI(flush_tlb_all_local)
Linus Torvalds's avatar
Linus Torvalds committed
45
46
47
48
49
50
51
52
53
54
55
	.proc
	.callinfo NO_CALLS
	.entry

	/*
	 * The pitlbe and pdtlbe instructions should only be used to
	 * flush the entire tlb. Also, there needs to be no intervening
	 * tlb operations, e.g. tlb misses, so the operation needs
	 * to happen in real mode with all interruptions disabled.
	 */

56
	/* pcxt_ssm_bug	- relied upon translation! PA 2.0 Arch. F-4 and F-5 */
57
	rsm		PSW_SM_I, %r19		/* save I-bit state */
58
	load32		PA(1f), %r1
Linus Torvalds's avatar
Linus Torvalds committed
59
60
61
62
63
	nop
	nop
	nop
	nop
	nop
64
65

	rsm		PSW_SM_Q, %r0		/* prep to load iia queue */
Linus Torvalds's avatar
Linus Torvalds committed
66
67
68
69
70
	mtctl		%r0, %cr17		/* Clear IIASQ tail */
	mtctl		%r0, %cr17		/* Clear IIASQ head */
	mtctl		%r1, %cr18		/* IIAOQ head */
	ldo		4(%r1), %r1
	mtctl		%r1, %cr18		/* IIAOQ tail */
71
72
	load32		REAL_MODE_PSW, %r1
	mtctl           %r1, %ipsw
Linus Torvalds's avatar
Linus Torvalds committed
73
74
75
	rfi
	nop

76
1:      load32		PA(cache_info), %r1
Linus Torvalds's avatar
Linus Torvalds committed
77
78
79
80
81
82
83
84
85
86
87

	/* Flush Instruction Tlb */

	LDREG		ITLB_SID_BASE(%r1), %r20
	LDREG		ITLB_SID_STRIDE(%r1), %r21
	LDREG		ITLB_SID_COUNT(%r1), %r22
	LDREG		ITLB_OFF_BASE(%r1), %arg0
	LDREG		ITLB_OFF_STRIDE(%r1), %arg1
	LDREG		ITLB_OFF_COUNT(%r1), %arg2
	LDREG		ITLB_LOOP(%r1), %arg3

88
	addib,COND(=)		-1, %arg3, fitoneloop	/* Preadjust and test */
Linus Torvalds's avatar
Linus Torvalds committed
89
90
91
92
93
94
95
96
97
	movb,<,n	%arg3, %r31, fitdone	/* If loop < 0, skip */
	copy		%arg0, %r28		/* Init base addr */

fitmanyloop:					/* Loop if LOOP >= 2 */
	mtsp		%r20, %sr1
	add		%r21, %r20, %r20	/* increment space */
	copy		%arg2, %r29		/* Init middle loop count */

fitmanymiddle:					/* Loop if LOOP >= 2 */
98
	addib,COND(>)		-1, %r31, fitmanymiddle	/* Adjusted inner loop decr */
99
	pitlbe		%r0(%sr1, %r28)
Linus Torvalds's avatar
Linus Torvalds committed
100
	pitlbe,m	%arg1(%sr1, %r28)	/* Last pitlbe and addr adjust */
101
	addib,COND(>)		-1, %r29, fitmanymiddle	/* Middle loop decr */
Linus Torvalds's avatar
Linus Torvalds committed
102
103
104
	copy		%arg3, %r31		/* Re-init inner loop count */

	movb,tr		%arg0, %r28, fitmanyloop /* Re-init base addr */
105
	addib,COND(<=),n	-1, %r22, fitdone	/* Outer loop count decr */
Linus Torvalds's avatar
Linus Torvalds committed
106
107
108
109
110
111
112

fitoneloop:					/* Loop if LOOP = 1 */
	mtsp		%r20, %sr1
	copy		%arg0, %r28		/* init base addr */
	copy		%arg2, %r29		/* init middle loop count */

fitonemiddle:					/* Loop if LOOP = 1 */
113
	addib,COND(>)		-1, %r29, fitonemiddle	/* Middle loop count decr */
Linus Torvalds's avatar
Linus Torvalds committed
114
115
	pitlbe,m	%arg1(%sr1, %r28)	/* pitlbe for one loop */

116
	addib,COND(>)		-1, %r22, fitoneloop	/* Outer loop count decr */
Linus Torvalds's avatar
Linus Torvalds committed
117
118
119
120
121
122
123
124
125
126
127
128
129
130
	add		%r21, %r20, %r20		/* increment space */

fitdone:

	/* Flush Data Tlb */

	LDREG		DTLB_SID_BASE(%r1), %r20
	LDREG		DTLB_SID_STRIDE(%r1), %r21
	LDREG		DTLB_SID_COUNT(%r1), %r22
	LDREG		DTLB_OFF_BASE(%r1), %arg0
	LDREG		DTLB_OFF_STRIDE(%r1), %arg1
	LDREG		DTLB_OFF_COUNT(%r1), %arg2
	LDREG		DTLB_LOOP(%r1), %arg3

131
	addib,COND(=)		-1, %arg3, fdtoneloop	/* Preadjust and test */
Linus Torvalds's avatar
Linus Torvalds committed
132
133
134
135
136
137
138
139
140
	movb,<,n	%arg3, %r31, fdtdone	/* If loop < 0, skip */
	copy		%arg0, %r28		/* Init base addr */

fdtmanyloop:					/* Loop if LOOP >= 2 */
	mtsp		%r20, %sr1
	add		%r21, %r20, %r20	/* increment space */
	copy		%arg2, %r29		/* Init middle loop count */

fdtmanymiddle:					/* Loop if LOOP >= 2 */
141
	addib,COND(>)		-1, %r31, fdtmanymiddle	/* Adjusted inner loop decr */
142
	pdtlbe		%r0(%sr1, %r28)
Linus Torvalds's avatar
Linus Torvalds committed
143
	pdtlbe,m	%arg1(%sr1, %r28)	/* Last pdtlbe and addr adjust */
144
	addib,COND(>)		-1, %r29, fdtmanymiddle	/* Middle loop decr */
Linus Torvalds's avatar
Linus Torvalds committed
145
146
147
	copy		%arg3, %r31		/* Re-init inner loop count */

	movb,tr		%arg0, %r28, fdtmanyloop /* Re-init base addr */
148
	addib,COND(<=),n	-1, %r22,fdtdone	/* Outer loop count decr */
Linus Torvalds's avatar
Linus Torvalds committed
149
150
151
152
153
154
155

fdtoneloop:					/* Loop if LOOP = 1 */
	mtsp		%r20, %sr1
	copy		%arg0, %r28		/* init base addr */
	copy		%arg2, %r29		/* init middle loop count */

fdtonemiddle:					/* Loop if LOOP = 1 */
156
	addib,COND(>)		-1, %r29, fdtonemiddle	/* Middle loop count decr */
Linus Torvalds's avatar
Linus Torvalds committed
157
158
	pdtlbe,m	%arg1(%sr1, %r28)	/* pdtlbe for one loop */

159
	addib,COND(>)		-1, %r22, fdtoneloop	/* Outer loop count decr */
Linus Torvalds's avatar
Linus Torvalds committed
160
161
162
	add		%r21, %r20, %r20	/* increment space */


163
164
165
166
167
168
169
170
171
172
173
174
fdtdone:
	/*
	 * Switch back to virtual mode
	 */
	/* pcxt_ssm_bug */
	rsm		PSW_SM_I, %r0
	load32		2f, %r1
	nop
	nop
	nop
	nop
	nop
Linus Torvalds's avatar
Linus Torvalds committed
175

176
	rsm		PSW_SM_Q, %r0		/* prep to load iia queue */
Linus Torvalds's avatar
Linus Torvalds committed
177
178
179
180
181
	mtctl		%r0, %cr17		/* Clear IIASQ tail */
	mtctl		%r0, %cr17		/* Clear IIASQ head */
	mtctl		%r1, %cr18		/* IIAOQ head */
	ldo		4(%r1), %r1
	mtctl		%r1, %cr18		/* IIAOQ tail */
182
183
184
	load32		KERNEL_PSW, %r1
	or		%r1, %r19, %r1	/* I-bit to state on entry */
	mtctl		%r1, %ipsw	/* restore I-bit (entire PSW) */
Linus Torvalds's avatar
Linus Torvalds committed
185
186
187
188
189
190
	rfi
	nop

2:      bv		%r0(%r2)
	nop

191
	.exit
Linus Torvalds's avatar
Linus Torvalds committed
192
	.procend
193
ENDPROC_CFI(flush_tlb_all_local)
Linus Torvalds's avatar
Linus Torvalds committed
194
195
196

	.import cache_info,data

197
ENTRY_CFI(flush_instruction_cache_local)
Linus Torvalds's avatar
Linus Torvalds committed
198
199
200
201
	.proc
	.callinfo NO_CALLS
	.entry

202
	load32		cache_info, %r1
Linus Torvalds's avatar
Linus Torvalds committed
203
204
205
206
207
208
209

	/* Flush Instruction Cache */

	LDREG		ICACHE_BASE(%r1), %arg0
	LDREG		ICACHE_STRIDE(%r1), %arg1
	LDREG		ICACHE_COUNT(%r1), %arg2
	LDREG		ICACHE_LOOP(%r1), %arg3
210
211
	rsm		PSW_SM_I, %r22		/* No mmgt ops during loop*/
	mtsp		%r0, %sr1
212
	addib,COND(=)		-1, %arg3, fioneloop	/* Preadjust and test */
Linus Torvalds's avatar
Linus Torvalds committed
213
214
215
	movb,<,n	%arg3, %r31, fisync	/* If loop < 0, do sync */

fimanyloop:					/* Loop if LOOP >= 2 */
216
	addib,COND(>)		-1, %r31, fimanyloop	/* Adjusted inner loop decr */
217
	fice            %r0(%sr1, %arg0)
Linus Torvalds's avatar
Linus Torvalds committed
218
219
	fice,m		%arg1(%sr1, %arg0)	/* Last fice and addr adjust */
	movb,tr		%arg3, %r31, fimanyloop	/* Re-init inner loop count */
220
	addib,COND(<=),n	-1, %arg2, fisync	/* Outer loop decr */
Linus Torvalds's avatar
Linus Torvalds committed
221
222

fioneloop:					/* Loop if LOOP = 1 */
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
	/* Some implementations may flush with a single fice instruction */
	cmpib,COND(>>=),n	15, %arg2, fioneloop2

fioneloop1:
	fice,m		%arg1(%sr1, %arg0)
	fice,m		%arg1(%sr1, %arg0)
	fice,m		%arg1(%sr1, %arg0)
	fice,m		%arg1(%sr1, %arg0)
	fice,m		%arg1(%sr1, %arg0)
	fice,m		%arg1(%sr1, %arg0)
	fice,m		%arg1(%sr1, %arg0)
	fice,m		%arg1(%sr1, %arg0)
	fice,m		%arg1(%sr1, %arg0)
	fice,m		%arg1(%sr1, %arg0)
	fice,m		%arg1(%sr1, %arg0)
	fice,m		%arg1(%sr1, %arg0)
	fice,m		%arg1(%sr1, %arg0)
	fice,m		%arg1(%sr1, %arg0)
	fice,m		%arg1(%sr1, %arg0)
	addib,COND(>)	-16, %arg2, fioneloop1
	fice,m		%arg1(%sr1, %arg0)

	/* Check if done */
	cmpb,COND(=),n	%arg2, %r0, fisync	/* Predict branch taken */

fioneloop2:
	addib,COND(>)	-1, %arg2, fioneloop2	/* Outer loop count decr */
Linus Torvalds's avatar
Linus Torvalds committed
250
251
252
253
	fice,m		%arg1(%sr1, %arg0)	/* Fice for one loop */

fisync:
	sync
254
	mtsm		%r22			/* restore I-bit */
Linus Torvalds's avatar
Linus Torvalds committed
255
256
257
258
259
	bv		%r0(%r2)
	nop
	.exit

	.procend
260
ENDPROC_CFI(flush_instruction_cache_local)
Linus Torvalds's avatar
Linus Torvalds committed
261
262


263
	.import cache_info, data
264
ENTRY_CFI(flush_data_cache_local)
Linus Torvalds's avatar
Linus Torvalds committed
265
266
267
268
	.proc
	.callinfo NO_CALLS
	.entry

269
	load32		cache_info, %r1
Linus Torvalds's avatar
Linus Torvalds committed
270
271
272
273
274
275
276

	/* Flush Data Cache */

	LDREG		DCACHE_BASE(%r1), %arg0
	LDREG		DCACHE_STRIDE(%r1), %arg1
	LDREG		DCACHE_COUNT(%r1), %arg2
	LDREG		DCACHE_LOOP(%r1), %arg3
277
278
	rsm		PSW_SM_I, %r22		/* No mmgt ops during loop*/
	mtsp		%r0, %sr1
279
	addib,COND(=)		-1, %arg3, fdoneloop	/* Preadjust and test */
Linus Torvalds's avatar
Linus Torvalds committed
280
281
282
	movb,<,n	%arg3, %r31, fdsync	/* If loop < 0, do sync */

fdmanyloop:					/* Loop if LOOP >= 2 */
283
	addib,COND(>)		-1, %r31, fdmanyloop	/* Adjusted inner loop decr */
284
	fdce		%r0(%sr1, %arg0)
Linus Torvalds's avatar
Linus Torvalds committed
285
286
	fdce,m		%arg1(%sr1, %arg0)	/* Last fdce and addr adjust */
	movb,tr		%arg3, %r31, fdmanyloop	/* Re-init inner loop count */
287
	addib,COND(<=),n	-1, %arg2, fdsync	/* Outer loop decr */
Linus Torvalds's avatar
Linus Torvalds committed
288
289

fdoneloop:					/* Loop if LOOP = 1 */
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
	/* Some implementations may flush with a single fdce instruction */
	cmpib,COND(>>=),n	15, %arg2, fdoneloop2

fdoneloop1:
	fdce,m		%arg1(%sr1, %arg0)
	fdce,m		%arg1(%sr1, %arg0)
	fdce,m		%arg1(%sr1, %arg0)
	fdce,m		%arg1(%sr1, %arg0)
	fdce,m		%arg1(%sr1, %arg0)
	fdce,m		%arg1(%sr1, %arg0)
	fdce,m		%arg1(%sr1, %arg0)
	fdce,m		%arg1(%sr1, %arg0)
	fdce,m		%arg1(%sr1, %arg0)
	fdce,m		%arg1(%sr1, %arg0)
	fdce,m		%arg1(%sr1, %arg0)
	fdce,m		%arg1(%sr1, %arg0)
	fdce,m		%arg1(%sr1, %arg0)
	fdce,m		%arg1(%sr1, %arg0)
	fdce,m		%arg1(%sr1, %arg0)
	addib,COND(>)	-16, %arg2, fdoneloop1
	fdce,m		%arg1(%sr1, %arg0)

	/* Check if done */
	cmpb,COND(=),n	%arg2, %r0, fdsync	/* Predict branch taken */

fdoneloop2:
	addib,COND(>)	-1, %arg2, fdoneloop2	/* Outer loop count decr */
Linus Torvalds's avatar
Linus Torvalds committed
317
318
319
320
321
	fdce,m		%arg1(%sr1, %arg0)	/* Fdce for one loop */

fdsync:
	syncdma
	sync
322
	mtsm		%r22			/* restore I-bit */
Linus Torvalds's avatar
Linus Torvalds committed
323
324
325
326
327
	bv		%r0(%r2)
	nop
	.exit

	.procend
328
ENDPROC_CFI(flush_data_cache_local)
Linus Torvalds's avatar
Linus Torvalds committed
329
330
331

	.align	16

332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
/* Macros to serialize TLB purge operations on SMP.  */

	.macro	tlb_lock	la,flags,tmp
#ifdef CONFIG_SMP
	ldil		L%pa_tlb_lock,%r1
	ldo		R%pa_tlb_lock(%r1),\la
	rsm		PSW_SM_I,\flags
1:	LDCW		0(\la),\tmp
	cmpib,<>,n	0,\tmp,3f
2:	ldw		0(\la),\tmp
	cmpb,<>		%r0,\tmp,1b
	nop
	b,n		2b
3:
#endif
	.endm

	.macro	tlb_unlock	la,flags,tmp
#ifdef CONFIG_SMP
	ldi		1,\tmp
	stw		\tmp,0(\la)
	mtsm		\flags
#endif
	.endm

/* Clear page using kernel mapping.  */

359
ENTRY_CFI(clear_page_asm)
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
	.proc
	.callinfo NO_CALLS
	.entry

#ifdef CONFIG_64BIT

	/* Unroll the loop.  */
	ldi		(PAGE_SIZE / 128), %r1

1:
	std		%r0, 0(%r26)
	std		%r0, 8(%r26)
	std		%r0, 16(%r26)
	std		%r0, 24(%r26)
	std		%r0, 32(%r26)
	std		%r0, 40(%r26)
	std		%r0, 48(%r26)
	std		%r0, 56(%r26)
	std		%r0, 64(%r26)
	std		%r0, 72(%r26)
	std		%r0, 80(%r26)
	std		%r0, 88(%r26)
	std		%r0, 96(%r26)
	std		%r0, 104(%r26)
	std		%r0, 112(%r26)
	std		%r0, 120(%r26)

	/* Note reverse branch hint for addib is taken.  */
	addib,COND(>),n	-1, %r1, 1b
	ldo		128(%r26), %r26

#else

	/*
	 * Note that until (if) we start saving the full 64-bit register
	 * values on interrupt, we can't use std on a 32 bit kernel.
	 */
	ldi		(PAGE_SIZE / 64), %r1

1:
	stw		%r0, 0(%r26)
	stw		%r0, 4(%r26)
	stw		%r0, 8(%r26)
	stw		%r0, 12(%r26)
	stw		%r0, 16(%r26)
	stw		%r0, 20(%r26)
	stw		%r0, 24(%r26)
	stw		%r0, 28(%r26)
	stw		%r0, 32(%r26)
	stw		%r0, 36(%r26)
	stw		%r0, 40(%r26)
	stw		%r0, 44(%r26)
	stw		%r0, 48(%r26)
	stw		%r0, 52(%r26)
	stw		%r0, 56(%r26)
	stw		%r0, 60(%r26)

	addib,COND(>),n	-1, %r1, 1b
	ldo		64(%r26), %r26
#endif
	bv		%r0(%r2)
	nop
	.exit

	.procend
425
ENDPROC_CFI(clear_page_asm)
426
427
428

/* Copy page using kernel mapping.  */

429
ENTRY_CFI(copy_page_asm)
Linus Torvalds's avatar
Linus Torvalds committed
430
431
432
433
	.proc
	.callinfo NO_CALLS
	.entry

434
#ifdef CONFIG_64BIT
Linus Torvalds's avatar
Linus Torvalds committed
435
436
	/* PA8x00 CPUs can consume 2 loads or 1 store per cycle.
	 * Unroll the loop by hand and arrange insn appropriately.
437
438
	 * Prefetch doesn't improve performance on rp3440.
	 * GCC probably can do this just as well...
Linus Torvalds's avatar
Linus Torvalds committed
439
440
	 */

441
	ldi		(PAGE_SIZE / 128), %r1
442

443
444
1:	ldd		0(%r25), %r19
	ldd		8(%r25), %r20
Linus Torvalds's avatar
Linus Torvalds committed
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477

	ldd		16(%r25), %r21
	ldd		24(%r25), %r22
	std		%r19, 0(%r26)
	std		%r20, 8(%r26)

	ldd		32(%r25), %r19
	ldd		40(%r25), %r20
	std		%r21, 16(%r26)
	std		%r22, 24(%r26)

	ldd		48(%r25), %r21
	ldd		56(%r25), %r22
	std		%r19, 32(%r26)
	std		%r20, 40(%r26)

	ldd		64(%r25), %r19
	ldd		72(%r25), %r20
	std		%r21, 48(%r26)
	std		%r22, 56(%r26)

	ldd		80(%r25), %r21
	ldd		88(%r25), %r22
	std		%r19, 64(%r26)
	std		%r20, 72(%r26)

	ldd		 96(%r25), %r19
	ldd		104(%r25), %r20
	std		%r21, 80(%r26)
	std		%r22, 88(%r26)

	ldd		112(%r25), %r21
	ldd		120(%r25), %r22
478
	ldo		128(%r25), %r25
Linus Torvalds's avatar
Linus Torvalds committed
479
480
481
482
483
484
	std		%r19, 96(%r26)
	std		%r20, 104(%r26)

	std		%r21, 112(%r26)
	std		%r22, 120(%r26)

485
486
487
	/* Note reverse branch hint for addib is taken.  */
	addib,COND(>),n	-1, %r1, 1b
	ldo		128(%r26), %r26
Linus Torvalds's avatar
Linus Torvalds committed
488
489
490
491
492
493
494
495
496
497

#else

	/*
	 * This loop is optimized for PCXL/PCXL2 ldw/ldw and stw/stw
	 * bundles (very restricted rules for bundling).
	 * Note that until (if) we start saving
	 * the full 64 bit register values on interrupt, we can't
	 * use ldd/std on a 32 bit kernel.
	 */
498
	ldw		0(%r25), %r19
499
	ldi		(PAGE_SIZE / 64), %r1
Linus Torvalds's avatar
Linus Torvalds committed
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530

1:
	ldw		4(%r25), %r20
	ldw		8(%r25), %r21
	ldw		12(%r25), %r22
	stw		%r19, 0(%r26)
	stw		%r20, 4(%r26)
	stw		%r21, 8(%r26)
	stw		%r22, 12(%r26)
	ldw		16(%r25), %r19
	ldw		20(%r25), %r20
	ldw		24(%r25), %r21
	ldw		28(%r25), %r22
	stw		%r19, 16(%r26)
	stw		%r20, 20(%r26)
	stw		%r21, 24(%r26)
	stw		%r22, 28(%r26)
	ldw		32(%r25), %r19
	ldw		36(%r25), %r20
	ldw		40(%r25), %r21
	ldw		44(%r25), %r22
	stw		%r19, 32(%r26)
	stw		%r20, 36(%r26)
	stw		%r21, 40(%r26)
	stw		%r22, 44(%r26)
	ldw		48(%r25), %r19
	ldw		52(%r25), %r20
	ldw		56(%r25), %r21
	ldw		60(%r25), %r22
	stw		%r19, 48(%r26)
	stw		%r20, 52(%r26)
531
	ldo		64(%r25), %r25
Linus Torvalds's avatar
Linus Torvalds committed
532
533
534
	stw		%r21, 56(%r26)
	stw		%r22, 60(%r26)
	ldo		64(%r26), %r26
535
	addib,COND(>),n	-1, %r1, 1b
536
	ldw		0(%r25), %r19
Linus Torvalds's avatar
Linus Torvalds committed
537
538
539
540
541
542
#endif
	bv		%r0(%r2)
	nop
	.exit

	.procend
543
ENDPROC_CFI(copy_page_asm)
Linus Torvalds's avatar
Linus Torvalds committed
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565

/*
 * NOTE: Code in clear_user_page has a hard coded dependency on the
 *       maximum alias boundary being 4 Mb. We've been assured by the
 *       parisc chip designers that there will not ever be a parisc
 *       chip with a larger alias boundary (Never say never :-) ).
 *
 *       Subtle: the dtlb miss handlers support the temp alias region by
 *       "knowing" that if a dtlb miss happens within the temp alias
 *       region it must have occurred while in clear_user_page. Since
 *       this routine makes use of processor local translations, we
 *       don't want to insert them into the kernel page table. Instead,
 *       we load up some general registers (they need to be registers
 *       which aren't shadowed) with the physical page numbers (preshifted
 *       for tlb insertion) needed to insert the translations. When we
 *       miss on the translation, the dtlb miss handler inserts the
 *       translation into the tlb using these values:
 *
 *          %r26 physical page (shifted for tlb insert) of "to" translation
 *          %r23 physical page (shifted for tlb insert) of "from" translation
 */

566
567
568
569
570
571
572
573
574
        /* Drop prot bits and convert to page addr for iitlbt and idtlbt */
        #define PAGE_ADD_SHIFT  (PAGE_SHIFT-12)
        .macro          convert_phys_for_tlb_insert20  phys
        extrd,u         \phys, 56-PAGE_ADD_SHIFT, 32-PAGE_ADD_SHIFT, \phys
#if _PAGE_SIZE_ENCODING_DEFAULT
        depdi           _PAGE_SIZE_ENCODING_DEFAULT, 63, (63-58), \phys
#endif
	.endm

Linus Torvalds's avatar
Linus Torvalds committed
575
	/*
576
577
578
579
580
581
582
583
584
585
586
	 * copy_user_page_asm() performs a page copy using mappings
	 * equivalent to the user page mappings.  It can be used to
	 * implement copy_user_page() but unfortunately both the `from'
	 * and `to' pages need to be flushed through mappings equivalent
	 * to the user mappings after the copy because the kernel accesses
	 * the `from' page through the kmap kernel mapping and the `to'
	 * page needs to be flushed since code can be copied.  As a
	 * result, this implementation is less efficient than the simpler
	 * copy using the kernel mapping.  It only needs the `from' page
	 * to flushed via the user mapping.  The kunmap routines handle
	 * the flushes needed for the kernel mapping.
Linus Torvalds's avatar
Linus Torvalds committed
587
588
589
590
591
	 *
	 * I'm still keeping this around because it may be possible to
	 * use it if more information is passed into copy_user_page().
	 * Have to do some measurements to see if it is worthwhile to
	 * lobby for such a change.
592
	 *
Linus Torvalds's avatar
Linus Torvalds committed
593
594
	 */

595
ENTRY_CFI(copy_user_page_asm)
Linus Torvalds's avatar
Linus Torvalds committed
596
597
598
599
	.proc
	.callinfo NO_CALLS
	.entry

600
601
	/* Convert virtual `to' and `from' addresses to physical addresses.
	   Move `from' physical address to non shadowed register.  */
Linus Torvalds's avatar
Linus Torvalds committed
602
603
	ldil		L%(__PAGE_OFFSET), %r1
	sub		%r26, %r1, %r26
604
	sub		%r25, %r1, %r23
Linus Torvalds's avatar
Linus Torvalds committed
605
606

	ldil		L%(TMPALIAS_MAP_START), %r28
607
#ifdef CONFIG_64BIT
608
609
610
#if (TMPALIAS_MAP_START >= 0x80000000)
	depdi		0, 31,32, %r28		/* clear any sign extension */
#endif
611
612
	convert_phys_for_tlb_insert20 %r26	/* convert phys addr to tlb insert format */
	convert_phys_for_tlb_insert20 %r23	/* convert phys addr to tlb insert format */
613
	depd		%r24,63,22, %r28	/* Form aliased virtual address 'to' */
614
	depdi		0, 63,PAGE_SHIFT, %r28	/* Clear any offset bits */
Linus Torvalds's avatar
Linus Torvalds committed
615
616
617
618
619
620
	copy		%r28, %r29
	depdi		1, 41,1, %r29		/* Form aliased virtual address 'from' */
#else
	extrw,u		%r26, 24,25, %r26	/* convert phys addr to tlb insert format */
	extrw,u		%r23, 24,25, %r23	/* convert phys addr to tlb insert format */
	depw		%r24, 31,22, %r28	/* Form aliased virtual address 'to' */
621
	depwi		0, 31,PAGE_SHIFT, %r28	/* Clear any offset bits */
Linus Torvalds's avatar
Linus Torvalds committed
622
623
624
625
626
627
	copy		%r28, %r29
	depwi		1, 9,1, %r29		/* Form aliased virtual address 'from' */
#endif

	/* Purge any old translations */

628
#ifdef CONFIG_PA20
629
630
	pdtlb,l		%r0(%r28)
	pdtlb,l		%r0(%r29)
631
632
#else
	tlb_lock	%r20,%r21,%r22
633
634
	pdtlb		%r0(%r28)
	pdtlb		%r0(%r29)
635
636
637
638
639
640
641
642
	tlb_unlock	%r20,%r21,%r22
#endif

#ifdef CONFIG_64BIT
	/* PA8x00 CPUs can consume 2 loads or 1 store per cycle.
	 * Unroll the loop by hand and arrange insn appropriately.
	 * GCC probably can do this just as well.
	 */
Linus Torvalds's avatar
Linus Torvalds committed
643

644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
	ldd		0(%r29), %r19
	ldi		(PAGE_SIZE / 128), %r1

1:	ldd		8(%r29), %r20

	ldd		16(%r29), %r21
	ldd		24(%r29), %r22
	std		%r19, 0(%r28)
	std		%r20, 8(%r28)

	ldd		32(%r29), %r19
	ldd		40(%r29), %r20
	std		%r21, 16(%r28)
	std		%r22, 24(%r28)

	ldd		48(%r29), %r21
	ldd		56(%r29), %r22
	std		%r19, 32(%r28)
	std		%r20, 40(%r28)

	ldd		64(%r29), %r19
	ldd		72(%r29), %r20
	std		%r21, 48(%r28)
	std		%r22, 56(%r28)

	ldd		80(%r29), %r21
	ldd		88(%r29), %r22
	std		%r19, 64(%r28)
	std		%r20, 72(%r28)

	ldd		 96(%r29), %r19
	ldd		104(%r29), %r20
	std		%r21, 80(%r28)
	std		%r22, 88(%r28)

	ldd		112(%r29), %r21
	ldd		120(%r29), %r22
	std		%r19, 96(%r28)
	std		%r20, 104(%r28)

	ldo		128(%r29), %r29
	std		%r21, 112(%r28)
	std		%r22, 120(%r28)
	ldo		128(%r28), %r28

	/* conditional branches nullify on forward taken branch, and on
	 * non-taken backward branch. Note that .+4 is a backwards branch.
	 * The ldd should only get executed if the branch is taken.
	 */
	addib,COND(>),n	-1, %r1, 1b		/* bundle 10 */
	ldd		0(%r29), %r19		/* start next loads */

#else
	ldi		(PAGE_SIZE / 64), %r1
Linus Torvalds's avatar
Linus Torvalds committed
698
699
700
701
702
703
704
705
706
707

	/*
	 * This loop is optimized for PCXL/PCXL2 ldw/ldw and stw/stw
	 * bundles (very restricted rules for bundling). It probably
	 * does OK on PCXU and better, but we could do better with
	 * ldd/std instructions. Note that until (if) we start saving
	 * the full 64 bit register values on interrupt, we can't
	 * use ldd/std on a 32 bit kernel.
	 */

708
1:	ldw		0(%r29), %r19
Linus Torvalds's avatar
Linus Torvalds committed
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
	ldw		4(%r29), %r20
	ldw		8(%r29), %r21
	ldw		12(%r29), %r22
	stw		%r19, 0(%r28)
	stw		%r20, 4(%r28)
	stw		%r21, 8(%r28)
	stw		%r22, 12(%r28)
	ldw		16(%r29), %r19
	ldw		20(%r29), %r20
	ldw		24(%r29), %r21
	ldw		28(%r29), %r22
	stw		%r19, 16(%r28)
	stw		%r20, 20(%r28)
	stw		%r21, 24(%r28)
	stw		%r22, 28(%r28)
	ldw		32(%r29), %r19
	ldw		36(%r29), %r20
	ldw		40(%r29), %r21
	ldw		44(%r29), %r22
	stw		%r19, 32(%r28)
	stw		%r20, 36(%r28)
	stw		%r21, 40(%r28)
	stw		%r22, 44(%r28)
	ldw		48(%r29), %r19
	ldw		52(%r29), %r20
	ldw		56(%r29), %r21
	ldw		60(%r29), %r22
	stw		%r19, 48(%r28)
	stw		%r20, 52(%r28)
	stw		%r21, 56(%r28)
	stw		%r22, 60(%r28)
	ldo		64(%r28), %r28
741

742
	addib,COND(>)		-1, %r1,1b
Linus Torvalds's avatar
Linus Torvalds committed
743
	ldo		64(%r29), %r29
744
#endif
Linus Torvalds's avatar
Linus Torvalds committed
745
746
747
748
749
750

	bv		%r0(%r2)
	nop
	.exit

	.procend
751
ENDPROC_CFI(copy_user_page_asm)
Linus Torvalds's avatar
Linus Torvalds committed
752

753
ENTRY_CFI(clear_user_page_asm)
Linus Torvalds's avatar
Linus Torvalds committed
754
755
756
757
758
759
760
	.proc
	.callinfo NO_CALLS
	.entry

	tophys_r1	%r26

	ldil		L%(TMPALIAS_MAP_START), %r28
761
#ifdef CONFIG_64BIT
Linus Torvalds's avatar
Linus Torvalds committed
762
763
764
#if (TMPALIAS_MAP_START >= 0x80000000)
	depdi		0, 31,32, %r28		/* clear any sign extension */
#endif
765
	convert_phys_for_tlb_insert20 %r26	/* convert phys addr to tlb insert format */
Linus Torvalds's avatar
Linus Torvalds committed
766
	depd		%r25, 63,22, %r28	/* Form aliased virtual address 'to' */
767
	depdi		0, 63,PAGE_SHIFT, %r28	/* Clear any offset bits */
Linus Torvalds's avatar
Linus Torvalds committed
768
769
770
#else
	extrw,u		%r26, 24,25, %r26	/* convert phys addr to tlb insert format */
	depw		%r25, 31,22, %r28	/* Form aliased virtual address 'to' */
771
	depwi		0, 31,PAGE_SHIFT, %r28	/* Clear any offset bits */
Linus Torvalds's avatar
Linus Torvalds committed
772
773
774
775
#endif

	/* Purge any old translation */

776
#ifdef CONFIG_PA20
777
	pdtlb,l		%r0(%r28)
778
779
#else
	tlb_lock	%r20,%r21,%r22
780
	pdtlb		%r0(%r28)
781
782
	tlb_unlock	%r20,%r21,%r22
#endif
Linus Torvalds's avatar
Linus Torvalds committed
783

784
#ifdef CONFIG_64BIT
785
	ldi		(PAGE_SIZE / 128), %r1
Linus Torvalds's avatar
Linus Torvalds committed
786
787

	/* PREFETCH (Write) has not (yet) been proven to help here */
788
	/* #define	PREFETCHW_OP	ldd		256(%0), %r0 */
Linus Torvalds's avatar
Linus Torvalds committed
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805

1:	std		%r0, 0(%r28)
	std		%r0, 8(%r28)
	std		%r0, 16(%r28)
	std		%r0, 24(%r28)
	std		%r0, 32(%r28)
	std		%r0, 40(%r28)
	std		%r0, 48(%r28)
	std		%r0, 56(%r28)
	std		%r0, 64(%r28)
	std		%r0, 72(%r28)
	std		%r0, 80(%r28)
	std		%r0, 88(%r28)
	std		%r0, 96(%r28)
	std		%r0, 104(%r28)
	std		%r0, 112(%r28)
	std		%r0, 120(%r28)
806
	addib,COND(>)		-1, %r1, 1b
Linus Torvalds's avatar
Linus Torvalds committed
807
808
	ldo		128(%r28), %r28

809
#else	/* ! CONFIG_64BIT */
810
	ldi		(PAGE_SIZE / 64), %r1
Linus Torvalds's avatar
Linus Torvalds committed
811

812
1:	stw		%r0, 0(%r28)
Linus Torvalds's avatar
Linus Torvalds committed
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
	stw		%r0, 4(%r28)
	stw		%r0, 8(%r28)
	stw		%r0, 12(%r28)
	stw		%r0, 16(%r28)
	stw		%r0, 20(%r28)
	stw		%r0, 24(%r28)
	stw		%r0, 28(%r28)
	stw		%r0, 32(%r28)
	stw		%r0, 36(%r28)
	stw		%r0, 40(%r28)
	stw		%r0, 44(%r28)
	stw		%r0, 48(%r28)
	stw		%r0, 52(%r28)
	stw		%r0, 56(%r28)
	stw		%r0, 60(%r28)
828
	addib,COND(>)		-1, %r1, 1b
Linus Torvalds's avatar
Linus Torvalds committed
829
	ldo		64(%r28), %r28
830
#endif	/* CONFIG_64BIT */
Linus Torvalds's avatar
Linus Torvalds committed
831
832
833
834
835
836

	bv		%r0(%r2)
	nop
	.exit

	.procend
837
ENDPROC_CFI(clear_user_page_asm)
Linus Torvalds's avatar
Linus Torvalds committed
838

839
ENTRY_CFI(flush_dcache_page_asm)
Linus Torvalds's avatar
Linus Torvalds committed
840
841
842
843
	.proc
	.callinfo NO_CALLS
	.entry

844
845
846
847
848
	ldil		L%(TMPALIAS_MAP_START), %r28
#ifdef CONFIG_64BIT
#if (TMPALIAS_MAP_START >= 0x80000000)
	depdi		0, 31,32, %r28		/* clear any sign extension */
#endif
849
	convert_phys_for_tlb_insert20 %r26	/* convert phys addr to tlb insert format */
850
	depd		%r25, 63,22, %r28	/* Form aliased virtual address 'to' */
851
	depdi		0, 63,PAGE_SHIFT, %r28	/* Clear any offset bits */
852
853
854
#else
	extrw,u		%r26, 24,25, %r26	/* convert phys addr to tlb insert format */
	depw		%r25, 31,22, %r28	/* Form aliased virtual address 'to' */
855
	depwi		0, 31,PAGE_SHIFT, %r28	/* Clear any offset bits */
856
857
858
859
#endif

	/* Purge any old translation */

860
#ifdef CONFIG_PA20
861
	pdtlb,l		%r0(%r28)
862
863
#else
	tlb_lock	%r20,%r21,%r22
864
	pdtlb		%r0(%r28)
865
866
	tlb_unlock	%r20,%r21,%r22
#endif
867

Linus Torvalds's avatar
Linus Torvalds committed
868
	ldil		L%dcache_stride, %r1
869
	ldw		R%dcache_stride(%r1), r31
Linus Torvalds's avatar
Linus Torvalds committed
870

871
#ifdef CONFIG_64BIT
Linus Torvalds's avatar
Linus Torvalds committed
872
873
874
875
	depdi,z		1, 63-PAGE_SHIFT,1, %r25
#else
	depwi,z		1, 31-PAGE_SHIFT,1, %r25
#endif
876
	add		%r28, %r25, %r25
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
	sub		%r25, r31, %r25


1:      fdc,m		r31(%r28)
	fdc,m		r31(%r28)
	fdc,m		r31(%r28)
	fdc,m		r31(%r28)
	fdc,m		r31(%r28)
	fdc,m		r31(%r28)
	fdc,m		r31(%r28)
	fdc,m		r31(%r28)
	fdc,m		r31(%r28)
	fdc,m		r31(%r28)
	fdc,m		r31(%r28)
	fdc,m		r31(%r28)
	fdc,m		r31(%r28)
	fdc,m		r31(%r28)
	fdc,m		r31(%r28)
895
	cmpb,COND(<<)		%r28, %r25,1b
896
	fdc,m		r31(%r28)
Linus Torvalds's avatar
Linus Torvalds committed
897
898

	sync
899
900

#ifdef CONFIG_PA20
901
	pdtlb,l		%r0(%r25)
902
903
#else
	tlb_lock	%r20,%r21,%r22
904
	pdtlb		%r0(%r25)
905
906
907
	tlb_unlock	%r20,%r21,%r22
#endif

Linus Torvalds's avatar
Linus Torvalds committed
908
	bv		%r0(%r2)
909
	nop
Linus Torvalds's avatar
Linus Torvalds committed
910
911
912
	.exit

	.procend
913
ENDPROC_CFI(flush_dcache_page_asm)
914

915
ENTRY_CFI(flush_icache_page_asm)
Linus Torvalds's avatar
Linus Torvalds committed
916
917
918
919
	.proc
	.callinfo NO_CALLS
	.entry

920
	ldil		L%(TMPALIAS_MAP_START), %r28
921
#ifdef CONFIG_64BIT
922
923
924
#if (TMPALIAS_MAP_START >= 0x80000000)
	depdi		0, 31,32, %r28		/* clear any sign extension */
#endif
925
	convert_phys_for_tlb_insert20 %r26	/* convert phys addr to tlb insert format */
926
	depd		%r25, 63,22, %r28	/* Form aliased virtual address 'to' */
927
	depdi		0, 63,PAGE_SHIFT, %r28	/* Clear any offset bits */
Linus Torvalds's avatar
Linus Torvalds committed
928
#else
929
930
	extrw,u		%r26, 24,25, %r26	/* convert phys addr to tlb insert format */
	depw		%r25, 31,22, %r28	/* Form aliased virtual address 'to' */
931
	depwi		0, 31,PAGE_SHIFT, %r28	/* Clear any offset bits */
Linus Torvalds's avatar
Linus Torvalds committed
932
933
#endif

934
935
936
937
	/* Purge any old translation.  Note that the FIC instruction
	 * may use either the instruction or data TLB.  Given that we
	 * have a flat address space, it's not clear which TLB will be
	 * used.  So, we purge both entries.  */
Linus Torvalds's avatar
Linus Torvalds committed
938

939
#ifdef CONFIG_PA20
940
	pdtlb,l		%r0(%r28)
941
942
943
	pitlb,l         %r0(%sr4,%r28)
#else
	tlb_lock        %r20,%r21,%r22
944
945
	pdtlb		%r0(%r28)
	pitlb           %r0(%sr4,%r28)
946
947
	tlb_unlock      %r20,%r21,%r22
#endif
948
949

	ldil		L%icache_stride, %r1
950
	ldw		R%icache_stride(%r1), %r31
951
952
953
954
955
956
957

#ifdef CONFIG_64BIT
	depdi,z		1, 63-PAGE_SHIFT,1, %r25
#else
	depwi,z		1, 31-PAGE_SHIFT,1, %r25
#endif
	add		%r28, %r25, %r25
958
	sub		%r25, %r31, %r25
959
960


961
962
	/* fic only has the type 26 form on PA1.1, requiring an
	 * explicit space specification, so use %sr4 */
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
1:      fic,m		%r31(%sr4,%r28)
	fic,m		%r31(%sr4,%r28)
	fic,m		%r31(%sr4,%r28)
	fic,m		%r31(%sr4,%r28)
	fic,m		%r31(%sr4,%r28)
	fic,m		%r31(%sr4,%r28)
	fic,m		%r31(%sr4,%r28)
	fic,m		%r31(%sr4,%r28)
	fic,m		%r31(%sr4,%r28)
	fic,m		%r31(%sr4,%r28)
	fic,m		%r31(%sr4,%r28)
	fic,m		%r31(%sr4,%r28)
	fic,m		%r31(%sr4,%r28)
	fic,m		%r31(%sr4,%r28)
	fic,m		%r31(%sr4,%r28)
978
	cmpb,COND(<<)	%r28, %r25,1b
979
	fic,m		%r31(%sr4,%r28)
Linus Torvalds's avatar
Linus Torvalds committed
980
981

	sync
982
983

#ifdef CONFIG_PA20
984
	pdtlb,l		%r0(%r28)
985
986
987
	pitlb,l         %r0(%sr4,%r25)
#else
	tlb_lock        %r20,%r21,%r22
988
989
	pdtlb		%r0(%r28)
	pitlb           %r0(%sr4,%r25)
990
991
992
	tlb_unlock      %r20,%r21,%r22
#endif

Linus Torvalds's avatar
Linus Torvalds committed
993
	bv		%r0(%r2)
994
	nop
Linus Torvalds's avatar
Linus Torvalds committed
995
996
997
	.exit

	.procend
998
ENDPROC_CFI(flush_icache_page_asm)
Linus Torvalds's avatar
Linus Torvalds committed
999

1000
ENTRY_CFI(flush_kernel_dcache_page_asm)
Linus Torvalds's avatar
Linus Torvalds committed
1001
1002
1003
1004
1005
1006
1007
	.proc
	.callinfo NO_CALLS
	.entry

	ldil		L%dcache_stride, %r1
	ldw		R%dcache_stride(%r1), %r23

1008
#ifdef CONFIG_64BIT
Linus Torvalds's avatar
Linus Torvalds committed
1009
1010
1011
1012
1013
1014
1015
1016
	depdi,z		1, 63-PAGE_SHIFT,1, %r25
#else
	depwi,z		1, 31-PAGE_SHIFT,1, %r25
#endif
	add		%r26, %r25, %r25
	sub		%r25, %r23, %r25


1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1:      fdc,m		%r23(%r26)
	fdc,m		%r23(%r26)
	fdc,m		%r23(%r26)
	fdc,m		%r23(%r26)
	fdc,m		%r23(%r26)
	fdc,m		%r23(%r26)
	fdc,m		%r23(%r26)
	fdc,m		%r23(%r26)
	fdc,m		%r23(%r26)
	fdc,m		%r23(%r26)
	fdc,m		%r23(%r26)
	fdc,m		%r23(%r26)
	fdc,m		%r23(%r26)
	fdc,m		%r23(%r26)
	fdc,m		%r23(%r26)
1032
	cmpb,COND(<<)		%r26, %r25,1b
1033
	fdc,m		%r23(%r26)
Linus Torvalds's avatar
Linus Torvalds committed
1034
1035
1036
1037
1038
1039
1040

	sync
	bv		%r0(%r2)
	nop
	.exit

	.procend
1041
ENDPROC_CFI(flush_kernel_dcache_page_asm)
Linus Torvalds's avatar
Linus Torvalds committed
1042

1043
ENTRY_CFI(purge_kernel_dcache_page_asm)
Linus Torvalds's avatar
Linus Torvalds committed
1044
1045
1046
1047
1048
1049
1050
	.proc
	.callinfo NO_CALLS
	.entry

	ldil		L%dcache_stride, %r1
	ldw		R%dcache_stride(%r1), %r23

1051
#ifdef CONFIG_64BIT
Linus Torvalds's avatar
Linus Torvalds committed
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
	depdi,z		1, 63-PAGE_SHIFT,1, %r25
#else
	depwi,z		1, 31-PAGE_SHIFT,1, %r25
#endif
	add		%r26, %r25, %r25
	sub		%r25, %r23, %r25

1:      pdc,m		%r23(%r26)
	pdc,m		%r23(%r26)
	pdc,m		%r23(%r26)
	pdc,m		%r23(%r26)
	pdc,m		%r23(%r26)
	pdc,m		%r23(%r26)
	pdc,m		%r23(%r26)
	pdc,m		%r23(%r26)
	pdc,m		%r23(%r26)
	pdc,m		%r23(%r26)
	pdc,m		%r23(%r26)
	pdc,m		%r23(%r26)
	pdc,m		%r23(%r26)
	pdc,m		%r23(%r26)
	pdc,m		%r23(%r26)
1074
	cmpb,COND(<<)		%r26, %r25, 1b
Linus Torvalds's avatar
Linus Torvalds committed
1075
1076
1077
1078
1079
1080
1081
1082
	pdc,m		%r23(%r26)

	sync
	bv		%r0(%r2)
	nop
	.exit

	.procend
1083
ENDPROC_CFI(purge_kernel_dcache_page_asm)
Linus Torvalds's avatar
Linus Torvalds committed
1084

1085
ENTRY_CFI(flush_user_dcache_range_asm)
Linus Torvalds's avatar
Linus Torvalds committed
1086
1087
1088
1089
1090
1091
1092
1093
1094
	.proc
	.callinfo NO_CALLS
	.entry

	ldil		L%dcache_stride, %r1
	ldw		R%dcache_stride(%r1), %r23
	ldo		-1(%r23), %r21
	ANDCM		%r26, %r21, %r26

1095
1:      cmpb,COND(<<),n	%r26, %r25, 1b
Linus Torvalds's avatar
Linus Torvalds committed
1096
1097
1098
1099
1100
1101
1102
1103
	fdc,m		%r23(%sr3, %r26)

	sync
	bv		%r0(%r2)
	nop
	.exit

	.procend
1104
ENDPROC_CFI(flush_user_dcache_range_asm)
Linus Torvalds's avatar
Linus Torvalds committed
1105

1106
ENTRY_CFI(flush_kernel_dcache_range_asm)
Linus Torvalds's avatar
Linus Torvalds committed
1107
1108
1109
1110
1111
1112
1113
1114
1115
	.proc
	.callinfo NO_CALLS
	.entry

	ldil		L%dcache_stride, %r1
	ldw		R%dcache_stride(%r1), %r23
	ldo		-1(%r23), %r21
	ANDCM		%r26, %r21, %r26

1116
1:      cmpb,COND(<<),n	%r26, %r25,1b
Linus Torvalds's avatar
Linus Torvalds committed
1117
1118
1119
1120
1121
1122
1123
1124
1125
	fdc,m		%r23(%r26)

	sync
	syncdma
	bv		%r0(%r2)
	nop
	.exit

	.procend
1126
ENDPROC_CFI(flush_kernel_dcache_range_asm)
Linus Torvalds's avatar
Linus Torvalds committed
1127

1128
ENTRY_CFI(flush_user_icache_range_asm)
Linus Torvalds's avatar
Linus Torvalds committed
1129
1130
1131
1132
1133
1134
1135
1136
1137
	.proc
	.callinfo NO_CALLS
	.entry

	ldil		L%icache_stride, %r1
	ldw		R%icache_stride(%r1), %r23
	ldo		-1(%r23), %r21
	ANDCM		%r26, %r21, %r26

1138
1:      cmpb,COND(<<),n	%r26, %r25,1b
Linus Torvalds's avatar
Linus Torvalds committed
1139
1140
1141
1142
1143
1144
1145
1146
	fic,m		%r23(%sr3, %r26)

	sync
	bv		%r0(%r2)
	nop
	.exit

	.procend
1147
ENDPROC_CFI(flush_user_icache_range_asm)
Linus Torvalds's avatar
Linus Torvalds committed
1148

1149
ENTRY_CFI(flush_kernel_icache_page)
Linus Torvalds's avatar
Linus Torvalds committed
1150
1151
1152
1153
1154
1155
1156
	.proc
	.callinfo NO_CALLS
	.entry

	ldil		L%icache_stride, %r1
	ldw		R%icache_stride(%r1), %r23

1157
#ifdef CONFIG_64BIT
Linus Torvalds's avatar
Linus Torvalds committed
1158
1159
1160
1161
1162
1163
1164
1165
	depdi,z		1, 63-PAGE_SHIFT,1, %r25
#else
	depwi,z		1, 31-PAGE_SHIFT,1, %r25
#endif
	add		%r26, %r25, %r25
	sub		%r25, %r23, %r25


1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1:      fic,m		%r23(%sr4, %r26)
	fic,m		%r23(%sr4, %r26)
	fic,m		%r23(%sr4, %r26)
	fic,m		%r23(%sr4, %r26)
	fic,m		%r23(%sr4, %r26)
	fic,m		%r23(%sr4, %r26)
	fic,m		%r23(%sr4, %r26)
	fic,m		%r23(%sr4, %r26)
	fic,m		%r23(%sr4, %r26)
	fic,m		%r23(%sr4, %r26)
	fic,m		%r23(%sr4, %r26)
	fic,m		%r23(%sr4, %r26)
	fic,m		%r23(%sr4, %r26)
	fic,m		%r23(%sr4, %r26)
	fic,m		%r23(%sr4, %r26)
1181
	cmpb,COND(<<)		%r26, %r25, 1b
1182
	fic,m		%r23(%sr4, %r26)
Linus Torvalds's avatar
Linus Torvalds committed
1183
1184
1185
1186
1187
1188
1189

	sync
	bv		%r0(%r2)
	nop
	.exit

	.procend
1190
ENDPROC_CFI(flush_kernel_icache_page)
Linus Torvalds's avatar
Linus Torvalds committed
1191

1192
ENTRY_CFI(flush_kernel_icache_range_asm)
Linus Torvalds's avatar
Linus Torvalds committed
1193
1194
1195
1196
1197
1198
1199
1200
1201
	.proc
	.callinfo NO_CALLS
	.entry

	ldil		L%icache_stride, %r1
	ldw		R%icache_stride(%r1), %r23
	ldo		-1(%r23), %r21
	ANDCM		%r26, %r21, %r26

1202
1:      cmpb,COND(<<),n	%r26, %r25, 1b
1203
	fic,m		%r23(%sr4, %r26)
Linus Torvalds's avatar
Linus Torvalds committed
1204
1205
1206
1207
1208
1209

	sync
	bv		%r0(%r2)
	nop
	.exit
	.procend
1210
ENDPROC_CFI(flush_kernel_icache_range_asm)
Linus Torvalds's avatar
Linus Torvalds committed
1211

1212
1213
1214
1215
	/* align should cover use of rfi in disable_sr_hashing_asm and
	 * srdis_done.
	 */
	.align	256
1216
ENTRY_CFI(disable_sr_hashing_asm)
Linus Torvalds's avatar
Linus Torvalds committed
1217
1218
1219
1220
	.proc
	.callinfo NO_CALLS
	.entry

1221
1222
1223
1224
1225
1226
	/*
	 * Switch to real mode
	 */
	/* pcxt_ssm_bug */
	rsm		PSW_SM_I, %r0
	load32		PA(1f), %r1
Linus Torvalds's avatar
Linus Torvalds committed
1227
1228
1229
1230
1231
	nop
	nop
	nop
	nop
	nop
1232
1233

	rsm		PSW_SM_Q, %r0		/* prep to load iia queue */
Linus Torvalds's avatar
Linus Torvalds committed
1234
1235
1236
1237
1238
	mtctl		%r0, %cr17		/* Clear IIASQ tail */
	mtctl		%r0, %cr17		/* Clear IIASQ head */
	mtctl		%r1, %cr18		/* IIAOQ head */
	ldo		4(%r1), %r1
	mtctl		%r1, %cr18		/* IIAOQ tail */
1239
1240
	load32		REAL_MODE_PSW, %r1
	mtctl		%r1, %ipsw
Linus Torvalds's avatar
Linus Torvalds committed
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
	rfi
	nop

1:      cmpib,=,n	SRHASH_PCXST, %r26,srdis_pcxs
	cmpib,=,n	SRHASH_PCXL, %r26,srdis_pcxl
	cmpib,=,n	SRHASH_PA20, %r26,srdis_pa20
	b,n		srdis_done

srdis_pcxs:

	/* Disable Space Register Hashing for PCXS,PCXT,PCXT' */

	.word		0x141c1a00		/* mfdiag %dr0, %r28 */
	.word		0x141c1a00		/* must issue twice */
	depwi		0,18,1, %r28		/* Clear DHE (dcache hash enable) */
	depwi		0,20,1, %r28		/* Clear IHE (icache hash enable) */
	.word		0x141c1600		/* mtdiag %r28, %dr0 */
	.word		0x141c1600		/* must issue twice */
	b,n		srdis_done

srdis_pcxl:

	/* Disable Space Register Hashing for PCXL */

	.word		0x141c0600		/* mfdiag %dr0, %r28 */
	depwi           0,28,2, %r28		/* Clear DHASH_EN & IHASH_EN */
	.word		0x141c0240		/* mtdiag %r28, %dr0 */
	b,n		srdis_done

srdis_pa20:

1272
	/* Disable Space Register Hashing for PCXU,PCXU+,PCXW,PCXW+,PCXW2 */
Linus Torvalds's avatar
Linus Torvalds committed
1273
1274
1275
1276
1277
1278

	.word		0x144008bc		/* mfdiag %dr2, %r28 */
	depdi		0, 54,1, %r28		/* clear DIAG_SPHASH_ENAB (bit 54) */
	.word		0x145c1840		/* mtdiag %r28, %dr2 */


1279
srdis_done:
Linus Torvalds's avatar
Linus Torvalds committed
1280
	/* Switch back to virtual mode */
1281
1282
1283
1284
1285
1286
1287
	rsm		PSW_SM_I, %r0		/* prep to load iia queue */
	load32 	   	2f, %r1
	nop
	nop
	nop
	nop
	nop
Linus Torvalds's avatar
Linus Torvalds committed
1288

1289
	rsm		PSW_SM_Q, %r0		/* prep to load iia queue */
Linus Torvalds's avatar
Linus Torvalds committed
1290
1291
1292
1293
1294
	mtctl		%r0, %cr17		/* Clear