pacache.S 24.0 KB
Newer Older
L
Linus Torvalds 已提交
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
L
Linus Torvalds 已提交
30 31 32 33 34 35
	.level	2.0w
#else
	.level	2.0
#endif

#include <asm/psw.h>
36
#include <asm/assembly.h>
L
Linus Torvalds 已提交
37 38
#include <asm/pgtable.h>
#include <asm/cache.h>
39
#include <linux/linkage.h>
40
#include <linux/init.h>
L
Linus Torvalds 已提交
41

42
	__HEAD
L
Linus Torvalds 已提交
43 44
	.align	128

45
ENTRY(flush_tlb_all_local)
L
Linus Torvalds 已提交
46 47 48 49 50 51 52 53 54 55 56
	.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.
	 */

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

	rsm		PSW_SM_Q, %r0		/* prep to load iia queue */
L
Linus Torvalds 已提交
67 68 69 70 71
	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 */
72 73
	load32		REAL_MODE_PSW, %r1
	mtctl           %r1, %ipsw
L
Linus Torvalds 已提交
74 75 76
	rfi
	nop

77
1:      load32		PA(cache_info), %r1
L
Linus Torvalds 已提交
78 79 80 81 82 83 84 85 86 87 88

	/* 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

89
	addib,COND(=)		-1, %arg3, fitoneloop	/* Preadjust and test */
L
Linus Torvalds 已提交
90 91 92 93 94 95 96 97 98
	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 */
99
	addib,COND(>)		-1, %r31, fitmanymiddle	/* Adjusted inner loop decr */
L
Linus Torvalds 已提交
100 101
	pitlbe		0(%sr1, %r28)
	pitlbe,m	%arg1(%sr1, %r28)	/* Last pitlbe and addr adjust */
102
	addib,COND(>)		-1, %r29, fitmanymiddle	/* Middle loop decr */
L
Linus Torvalds 已提交
103 104 105
	copy		%arg3, %r31		/* Re-init inner loop count */

	movb,tr		%arg0, %r28, fitmanyloop /* Re-init base addr */
106
	addib,COND(<=),n	-1, %r22, fitdone	/* Outer loop count decr */
L
Linus Torvalds 已提交
107 108 109 110 111 112 113

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 */
114
	addib,COND(>)		-1, %r29, fitonemiddle	/* Middle loop count decr */
L
Linus Torvalds 已提交
115 116
	pitlbe,m	%arg1(%sr1, %r28)	/* pitlbe for one loop */

117
	addib,COND(>)		-1, %r22, fitoneloop	/* Outer loop count decr */
L
Linus Torvalds 已提交
118 119 120 121 122 123 124 125 126 127 128 129 130 131
	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

132
	addib,COND(=)		-1, %arg3, fdtoneloop	/* Preadjust and test */
L
Linus Torvalds 已提交
133 134 135 136 137 138 139 140 141
	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 */
142
	addib,COND(>)		-1, %r31, fdtmanymiddle	/* Adjusted inner loop decr */
L
Linus Torvalds 已提交
143 144
	pdtlbe		0(%sr1, %r28)
	pdtlbe,m	%arg1(%sr1, %r28)	/* Last pdtlbe and addr adjust */
145
	addib,COND(>)		-1, %r29, fdtmanymiddle	/* Middle loop decr */
L
Linus Torvalds 已提交
146 147 148
	copy		%arg3, %r31		/* Re-init inner loop count */

	movb,tr		%arg0, %r28, fdtmanyloop /* Re-init base addr */
149
	addib,COND(<=),n	-1, %r22,fdtdone	/* Outer loop count decr */
L
Linus Torvalds 已提交
150 151 152 153 154 155 156

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 */
157
	addib,COND(>)		-1, %r29, fdtonemiddle	/* Middle loop count decr */
L
Linus Torvalds 已提交
158 159
	pdtlbe,m	%arg1(%sr1, %r28)	/* pdtlbe for one loop */

160
	addib,COND(>)		-1, %r22, fdtoneloop	/* Outer loop count decr */
L
Linus Torvalds 已提交
161 162 163
	add		%r21, %r20, %r20	/* increment space */


164 165 166 167 168 169 170 171 172 173 174 175
fdtdone:
	/*
	 * Switch back to virtual mode
	 */
	/* pcxt_ssm_bug */
	rsm		PSW_SM_I, %r0
	load32		2f, %r1
	nop
	nop
	nop
	nop
	nop
L
Linus Torvalds 已提交
176

177
	rsm		PSW_SM_Q, %r0		/* prep to load iia queue */
L
Linus Torvalds 已提交
178 179 180 181 182
	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 */
183 184 185
	load32		KERNEL_PSW, %r1
	or		%r1, %r19, %r1	/* I-bit to state on entry */
	mtctl		%r1, %ipsw	/* restore I-bit (entire PSW) */
L
Linus Torvalds 已提交
186 187 188 189 190 191
	rfi
	nop

2:      bv		%r0(%r2)
	nop

192
	.exit
L
Linus Torvalds 已提交
193
	.procend
194
ENDPROC(flush_tlb_all_local)
L
Linus Torvalds 已提交
195 196 197

	.import cache_info,data

198
ENTRY(flush_instruction_cache_local)
L
Linus Torvalds 已提交
199 200 201 202 203
	.proc
	.callinfo NO_CALLS
	.entry

	mtsp		%r0, %sr1
204
	load32		cache_info, %r1
L
Linus Torvalds 已提交
205 206 207 208 209 210 211 212

	/* Flush Instruction Cache */

	LDREG		ICACHE_BASE(%r1), %arg0
	LDREG		ICACHE_STRIDE(%r1), %arg1
	LDREG		ICACHE_COUNT(%r1), %arg2
	LDREG		ICACHE_LOOP(%r1), %arg3
	rsm             PSW_SM_I, %r22		/* No mmgt ops during loop*/
213
	addib,COND(=)		-1, %arg3, fioneloop	/* Preadjust and test */
L
Linus Torvalds 已提交
214 215 216
	movb,<,n	%arg3, %r31, fisync	/* If loop < 0, do sync */

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

fioneloop:					/* Loop if LOOP = 1 */
224
	addib,COND(>)		-1, %arg2, fioneloop	/* Outer loop count decr */
L
Linus Torvalds 已提交
225 226 227 228
	fice,m		%arg1(%sr1, %arg0)	/* Fice for one loop */

fisync:
	sync
229
	mtsm		%r22			/* restore I-bit */
L
Linus Torvalds 已提交
230 231 232 233 234
	bv		%r0(%r2)
	nop
	.exit

	.procend
235
ENDPROC(flush_instruction_cache_local)
L
Linus Torvalds 已提交
236 237


238 239
	.import cache_info, data
ENTRY(flush_data_cache_local)
L
Linus Torvalds 已提交
240 241 242 243 244
	.proc
	.callinfo NO_CALLS
	.entry

	mtsp		%r0, %sr1
245
	load32 		cache_info, %r1
L
Linus Torvalds 已提交
246 247 248 249 250 251 252 253

	/* Flush Data Cache */

	LDREG		DCACHE_BASE(%r1), %arg0
	LDREG		DCACHE_STRIDE(%r1), %arg1
	LDREG		DCACHE_COUNT(%r1), %arg2
	LDREG		DCACHE_LOOP(%r1), %arg3
	rsm		PSW_SM_I, %r22
254
	addib,COND(=)		-1, %arg3, fdoneloop	/* Preadjust and test */
L
Linus Torvalds 已提交
255 256 257
	movb,<,n	%arg3, %r31, fdsync	/* If loop < 0, do sync */

fdmanyloop:					/* Loop if LOOP >= 2 */
258
	addib,COND(>)		-1, %r31, fdmanyloop	/* Adjusted inner loop decr */
259
	fdce		%r0(%sr1, %arg0)
L
Linus Torvalds 已提交
260 261
	fdce,m		%arg1(%sr1, %arg0)	/* Last fdce and addr adjust */
	movb,tr		%arg3, %r31, fdmanyloop	/* Re-init inner loop count */
262
	addib,COND(<=),n	-1, %arg2, fdsync	/* Outer loop decr */
L
Linus Torvalds 已提交
263 264

fdoneloop:					/* Loop if LOOP = 1 */
265
	addib,COND(>)		-1, %arg2, fdoneloop	/* Outer loop count decr */
L
Linus Torvalds 已提交
266 267 268 269 270
	fdce,m		%arg1(%sr1, %arg0)	/* Fdce for one loop */

fdsync:
	syncdma
	sync
271
	mtsm		%r22			/* restore I-bit */
L
Linus Torvalds 已提交
272 273 274 275 276
	bv		%r0(%r2)
	nop
	.exit

	.procend
277
ENDPROC(flush_data_cache_local)
L
Linus Torvalds 已提交
278 279 280

	.align	16

281
ENTRY(copy_user_page_asm)
L
Linus Torvalds 已提交
282 283 284 285
	.proc
	.callinfo NO_CALLS
	.entry

286
#ifdef CONFIG_64BIT
L
Linus Torvalds 已提交
287 288 289 290 291 292
	/* 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.
	 */

	ldd		0(%r25), %r19
293
	ldi		(PAGE_SIZE / 128), %r1
294

L
Linus Torvalds 已提交
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
	ldw		64(%r25), %r0		/* prefetch 1 cacheline ahead */
	ldw		128(%r25), %r0		/* prefetch 2 */

1:	ldd		8(%r25), %r20
	ldw		192(%r25), %r0		/* prefetch 3 */
	ldw		256(%r25), %r0		/* prefetch 4 */

	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
	std		%r19, 96(%r26)
	std		%r20, 104(%r26)

	ldo		128(%r25), %r25
	std		%r21, 112(%r26)
	std		%r22, 120(%r26)
	ldo		128(%r26), %r26

342 343 344 345
	/* 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.
	 */
346
	addib,COND(>),n	-1, %r1, 1b		/* bundle 10 */
L
Linus Torvalds 已提交
347 348 349 350 351 352 353 354 355 356 357
	ldd		0(%r25), %r19		/* start next loads */

#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.
	 */
358
	ldw		0(%r25), %r19
359
	ldi		(PAGE_SIZE / 64), %r1
L
Linus Torvalds 已提交
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

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)
391
	ldo		64(%r25), %r25
L
Linus Torvalds 已提交
392 393 394
	stw		%r21, 56(%r26)
	stw		%r22, 60(%r26)
	ldo		64(%r26), %r26
395
	addib,COND(>),n	-1, %r1, 1b
396
	ldw		0(%r25), %r19
L
Linus Torvalds 已提交
397 398 399 400 401 402
#endif
	bv		%r0(%r2)
	nop
	.exit

	.procend
403
ENDPROC(copy_user_page_asm)
L
Linus Torvalds 已提交
404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440

/*
 * 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
 */

#if 0

	/*
	 * We can't do this since copy_user_page is used to bring in
	 * file data that might have instructions. Since the data would
	 * then need to be flushed out so the i-fetch can see it, it
	 * makes more sense to just copy through the kernel translation
	 * and flush it.
	 *
	 * 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.
	 */

441
ENTRY(copy_user_page_asm)
L
Linus Torvalds 已提交
442 443 444 445 446 447 448 449 450
	.proc
	.callinfo NO_CALLS
	.entry

	ldil		L%(__PAGE_OFFSET), %r1
	sub		%r26, %r1, %r26
	sub		%r25, %r1, %r23		/* move physical addr into non shadowed reg */

	ldil		L%(TMPALIAS_MAP_START), %r28
451
	/* FIXME for different page sizes != 4k */
452
#ifdef CONFIG_64BIT
L
Linus Torvalds 已提交
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 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518
	extrd,u		%r26,56,32, %r26		/* convert phys addr to tlb insert format */
	extrd,u		%r23,56,32, %r23		/* convert phys addr to tlb insert format */
	depd		%r24,63,22, %r28		/* Form aliased virtual address 'to' */
	depdi		0, 63,12, %r28		/* Clear any offset bits */
	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' */
	depwi		0, 31,12, %r28		/* Clear any offset bits */
	copy		%r28, %r29
	depwi		1, 9,1, %r29		/* Form aliased virtual address 'from' */
#endif

	/* Purge any old translations */

	pdtlb		0(%r28)
	pdtlb		0(%r29)

	ldi		64, %r1

	/*
	 * 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.
	 */


1:
	ldw		0(%r29), %r19
	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
519
	addib,COND(>)		-1, %r1,1b
L
Linus Torvalds 已提交
520 521 522 523 524 525 526
	ldo		64(%r29), %r29

	bv		%r0(%r2)
	nop
	.exit

	.procend
527
ENDPROC(copy_user_page_asm)
L
Linus Torvalds 已提交
528 529
#endif

530
ENTRY(__clear_user_page_asm)
L
Linus Torvalds 已提交
531 532 533 534 535 536 537
	.proc
	.callinfo NO_CALLS
	.entry

	tophys_r1	%r26

	ldil		L%(TMPALIAS_MAP_START), %r28
538
#ifdef CONFIG_64BIT
L
Linus Torvalds 已提交
539 540
#if (TMPALIAS_MAP_START >= 0x80000000)
	depdi		0, 31,32, %r28		/* clear any sign extension */
541
	/* FIXME: page size dependend */
L
Linus Torvalds 已提交
542 543 544 545 546 547 548 549 550 551 552 553 554 555
#endif
	extrd,u		%r26, 56,32, %r26	/* convert phys addr to tlb insert format */
	depd		%r25, 63,22, %r28	/* Form aliased virtual address 'to' */
	depdi		0, 63,12, %r28		/* Clear any offset bits */
#else
	extrw,u		%r26, 24,25, %r26	/* convert phys addr to tlb insert format */
	depw		%r25, 31,22, %r28	/* Form aliased virtual address 'to' */
	depwi		0, 31,12, %r28		/* Clear any offset bits */
#endif

	/* Purge any old translation */

	pdtlb		0(%r28)

556
#ifdef CONFIG_64BIT
557
	ldi		(PAGE_SIZE / 128), %r1
L
Linus Torvalds 已提交
558 559

	/* PREFETCH (Write) has not (yet) been proven to help here */
560
	/* #define	PREFETCHW_OP	ldd		256(%0), %r0 */
L
Linus Torvalds 已提交
561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577

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)
578
	addib,COND(>)		-1, %r1, 1b
L
Linus Torvalds 已提交
579 580
	ldo		128(%r28), %r28

581
#else	/* ! CONFIG_64BIT */
582
	ldi		(PAGE_SIZE / 64), %r1
L
Linus Torvalds 已提交
583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600

1:
	stw		%r0, 0(%r28)
	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)
601
	addib,COND(>)		-1, %r1, 1b
L
Linus Torvalds 已提交
602
	ldo		64(%r28), %r28
603
#endif	/* CONFIG_64BIT */
L
Linus Torvalds 已提交
604 605 606 607 608 609

	bv		%r0(%r2)
	nop
	.exit

	.procend
610
ENDPROC(__clear_user_page_asm)
L
Linus Torvalds 已提交
611

612
ENTRY(flush_kernel_dcache_page_asm)
L
Linus Torvalds 已提交
613 614 615 616 617 618 619
	.proc
	.callinfo NO_CALLS
	.entry

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

620
#ifdef CONFIG_64BIT
L
Linus Torvalds 已提交
621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643
	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:      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)
644
	cmpb,COND(<<)		%r26, %r25,1b
L
Linus Torvalds 已提交
645 646 647 648 649 650 651 652
	fdc,m		%r23(%r26)

	sync
	bv		%r0(%r2)
	nop
	.exit

	.procend
653
ENDPROC(flush_kernel_dcache_page_asm)
L
Linus Torvalds 已提交
654
	
655
ENTRY(flush_user_dcache_page)
L
Linus Torvalds 已提交
656 657 658 659 660 661 662
	.proc
	.callinfo NO_CALLS
	.entry

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

663
#ifdef CONFIG_64BIT
L
Linus Torvalds 已提交
664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686
	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:      fdc,m		%r23(%sr3, %r26)
	fdc,m		%r23(%sr3, %r26)
	fdc,m		%r23(%sr3, %r26)
	fdc,m		%r23(%sr3, %r26)
	fdc,m		%r23(%sr3, %r26)
	fdc,m		%r23(%sr3, %r26)
	fdc,m		%r23(%sr3, %r26)
	fdc,m		%r23(%sr3, %r26)
	fdc,m		%r23(%sr3, %r26)
	fdc,m		%r23(%sr3, %r26)
	fdc,m		%r23(%sr3, %r26)
	fdc,m		%r23(%sr3, %r26)
	fdc,m		%r23(%sr3, %r26)
	fdc,m		%r23(%sr3, %r26)
	fdc,m		%r23(%sr3, %r26)
687
	cmpb,COND(<<)		%r26, %r25,1b
L
Linus Torvalds 已提交
688 689 690 691 692 693 694 695
	fdc,m		%r23(%sr3, %r26)

	sync
	bv		%r0(%r2)
	nop
	.exit

	.procend
696
ENDPROC(flush_user_dcache_page)
L
Linus Torvalds 已提交
697

698
ENTRY(flush_user_icache_page)
L
Linus Torvalds 已提交
699 700 701 702 703 704 705
	.proc
	.callinfo NO_CALLS
	.entry

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

706
#ifdef CONFIG_64BIT
L
Linus Torvalds 已提交
707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729
	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:      fic,m		%r23(%sr3, %r26)
	fic,m		%r23(%sr3, %r26)
	fic,m		%r23(%sr3, %r26)
	fic,m		%r23(%sr3, %r26)
	fic,m		%r23(%sr3, %r26)
	fic,m		%r23(%sr3, %r26)
	fic,m		%r23(%sr3, %r26)
	fic,m		%r23(%sr3, %r26)
	fic,m		%r23(%sr3, %r26)
	fic,m		%r23(%sr3, %r26)
	fic,m		%r23(%sr3, %r26)
	fic,m		%r23(%sr3, %r26)
	fic,m		%r23(%sr3, %r26)
	fic,m		%r23(%sr3, %r26)
	fic,m		%r23(%sr3, %r26)
730
	cmpb,COND(<<)		%r26, %r25,1b
L
Linus Torvalds 已提交
731 732 733 734 735 736 737 738
	fic,m		%r23(%sr3, %r26)

	sync
	bv		%r0(%r2)
	nop
	.exit

	.procend
739
ENDPROC(flush_user_icache_page)
L
Linus Torvalds 已提交
740 741


742
ENTRY(purge_kernel_dcache_page)
L
Linus Torvalds 已提交
743 744 745 746 747 748 749
	.proc
	.callinfo NO_CALLS
	.entry

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

750
#ifdef CONFIG_64BIT
L
Linus Torvalds 已提交
751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772
	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)
773
	cmpb,COND(<<)		%r26, %r25, 1b
L
Linus Torvalds 已提交
774 775 776 777 778 779 780 781
	pdc,m		%r23(%r26)

	sync
	bv		%r0(%r2)
	nop
	.exit

	.procend
782
ENDPROC(purge_kernel_dcache_page)
L
Linus Torvalds 已提交
783 784 785 786 787 788

#if 0
	/* Currently not used, but it still is a possible alternate
	 * solution.
	 */

789
ENTRY(flush_alias_page)
L
Linus Torvalds 已提交
790 791 792 793 794 795 796
	.proc
	.callinfo NO_CALLS
	.entry

	tophys_r1		%r26

	ldil		L%(TMPALIAS_MAP_START), %r28
797
#ifdef CONFIG_64BIT
L
Linus Torvalds 已提交
798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813
	extrd,u		%r26, 56,32, %r26	/* convert phys addr to tlb insert format */
	depd		%r25, 63,22, %r28	/* Form aliased virtual address 'to' */
	depdi		0, 63,12, %r28		/* Clear any offset bits */
#else
	extrw,u		%r26, 24,25, %r26	/* convert phys addr to tlb insert format */
	depw		%r25, 31,22, %r28	/* Form aliased virtual address 'to' */
	depwi		0, 31,12, %r28		/* Clear any offset bits */
#endif

	/* Purge any old translation */

	pdtlb		0(%r28)

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

814
#ifdef CONFIG_64BIT
L
Linus Torvalds 已提交
815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836
	depdi,z		1, 63-PAGE_SHIFT,1, %r29
#else
	depwi,z		1, 31-PAGE_SHIFT,1, %r29
#endif
	add		%r28, %r29, %r29
	sub		%r29, %r23, %r29

1:      fdc,m		%r23(%r28)
	fdc,m		%r23(%r28)
	fdc,m		%r23(%r28)
	fdc,m		%r23(%r28)
	fdc,m		%r23(%r28)
	fdc,m		%r23(%r28)
	fdc,m		%r23(%r28)
	fdc,m		%r23(%r28)
	fdc,m		%r23(%r28)
	fdc,m		%r23(%r28)
	fdc,m		%r23(%r28)
	fdc,m		%r23(%r28)
	fdc,m		%r23(%r28)
	fdc,m		%r23(%r28)
	fdc,m		%r23(%r28)
837
	cmpb,COND(<<)		%r28, %r29, 1b
L
Linus Torvalds 已提交
838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859
	fdc,m		%r23(%r28)

	sync
	bv		%r0(%r2)
	nop
	.exit

	.procend
#endif

	.export flush_user_dcache_range_asm

flush_user_dcache_range_asm:
	.proc
	.callinfo NO_CALLS
	.entry

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

860
1:      cmpb,COND(<<),n	%r26, %r25, 1b
L
Linus Torvalds 已提交
861 862 863 864 865 866 867 868
	fdc,m		%r23(%sr3, %r26)

	sync
	bv		%r0(%r2)
	nop
	.exit

	.procend
869
ENDPROC(flush_alias_page)
L
Linus Torvalds 已提交
870

871
ENTRY(flush_kernel_dcache_range_asm)
L
Linus Torvalds 已提交
872 873 874 875 876 877 878 879 880
	.proc
	.callinfo NO_CALLS
	.entry

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

881
1:      cmpb,COND(<<),n	%r26, %r25,1b
L
Linus Torvalds 已提交
882 883 884 885 886 887 888 889 890
	fdc,m		%r23(%r26)

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

	.procend
891
ENDPROC(flush_kernel_dcache_range_asm)
L
Linus Torvalds 已提交
892

893
ENTRY(flush_user_icache_range_asm)
L
Linus Torvalds 已提交
894 895 896 897 898 899 900 901 902
	.proc
	.callinfo NO_CALLS
	.entry

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

903
1:      cmpb,COND(<<),n	%r26, %r25,1b
L
Linus Torvalds 已提交
904 905 906 907 908 909 910 911
	fic,m		%r23(%sr3, %r26)

	sync
	bv		%r0(%r2)
	nop
	.exit

	.procend
912
ENDPROC(flush_user_icache_range_asm)
L
Linus Torvalds 已提交
913

914
ENTRY(flush_kernel_icache_page)
L
Linus Torvalds 已提交
915 916 917 918 919 920 921
	.proc
	.callinfo NO_CALLS
	.entry

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

922
#ifdef CONFIG_64BIT
L
Linus Torvalds 已提交
923 924 925 926 927 928 929 930
	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


931 932 933 934 935 936 937 938 939 940 941 942 943 944 945
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)
946
	cmpb,COND(<<)		%r26, %r25, 1b
947
	fic,m		%r23(%sr4, %r26)
L
Linus Torvalds 已提交
948 949 950 951 952 953 954

	sync
	bv		%r0(%r2)
	nop
	.exit

	.procend
955
ENDPROC(flush_kernel_icache_page)
L
Linus Torvalds 已提交
956

957
ENTRY(flush_kernel_icache_range_asm)
L
Linus Torvalds 已提交
958 959 960 961 962 963 964 965 966
	.proc
	.callinfo NO_CALLS
	.entry

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

967
1:      cmpb,COND(<<),n	%r26, %r25, 1b
968
	fic,m		%r23(%sr4, %r26)
L
Linus Torvalds 已提交
969 970 971 972 973 974

	sync
	bv		%r0(%r2)
	nop
	.exit
	.procend
975
ENDPROC(flush_kernel_icache_range_asm)
L
Linus Torvalds 已提交
976

977 978 979 980
	/* align should cover use of rfi in disable_sr_hashing_asm and
	 * srdis_done.
	 */
	.align	256
981
ENTRY(disable_sr_hashing_asm)
L
Linus Torvalds 已提交
982 983 984 985
	.proc
	.callinfo NO_CALLS
	.entry

986 987 988 989 990 991
	/*
	 * Switch to real mode
	 */
	/* pcxt_ssm_bug */
	rsm		PSW_SM_I, %r0
	load32		PA(1f), %r1
L
Linus Torvalds 已提交
992 993 994 995 996
	nop
	nop
	nop
	nop
	nop
997 998

	rsm		PSW_SM_Q, %r0		/* prep to load iia queue */
L
Linus Torvalds 已提交
999 1000 1001 1002 1003
	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 */
1004 1005
	load32		REAL_MODE_PSW, %r1
	mtctl		%r1, %ipsw
L
Linus Torvalds 已提交
1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036
	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:

1037
	/* Disable Space Register Hashing for PCXU,PCXU+,PCXW,PCXW+,PCXW2 */
L
Linus Torvalds 已提交
1038 1039 1040 1041 1042 1043

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


1044
srdis_done:
L
Linus Torvalds 已提交
1045
	/* Switch back to virtual mode */
1046 1047 1048 1049 1050 1051 1052
	rsm		PSW_SM_I, %r0		/* prep to load iia queue */
	load32 	   	2f, %r1
	nop
	nop
	nop
	nop
	nop
L
Linus Torvalds 已提交
1053

1054
	rsm		PSW_SM_Q, %r0		/* prep to load iia queue */
L
Linus Torvalds 已提交
1055 1056 1057 1058 1059
	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 */
1060 1061
	load32		KERNEL_PSW, %r1
	mtctl		%r1, %ipsw
L
Linus Torvalds 已提交
1062 1063 1064 1065 1066 1067 1068 1069
	rfi
	nop

2:      bv		%r0(%r2)
	nop
	.exit

	.procend
1070
ENDPROC(disable_sr_hashing_asm)
L
Linus Torvalds 已提交
1071 1072

	.end