162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * hypersparc.S: High speed Hypersparc mmu/cache operations.
462306a36Sopenharmony_ci *
562306a36Sopenharmony_ci * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
662306a36Sopenharmony_ci */
762306a36Sopenharmony_ci
862306a36Sopenharmony_ci#include <asm/ptrace.h>
962306a36Sopenharmony_ci#include <asm/psr.h>
1062306a36Sopenharmony_ci#include <asm/asm-offsets.h>
1162306a36Sopenharmony_ci#include <asm/asi.h>
1262306a36Sopenharmony_ci#include <asm/page.h>
1362306a36Sopenharmony_ci#include <asm/pgtable.h>
1462306a36Sopenharmony_ci#include <asm/pgtsrmmu.h>
1562306a36Sopenharmony_ci#include <linux/init.h>
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci	.text
1862306a36Sopenharmony_ci	.align	4
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci	.globl	hypersparc_flush_cache_all, hypersparc_flush_cache_mm
2162306a36Sopenharmony_ci	.globl	hypersparc_flush_cache_range, hypersparc_flush_cache_page
2262306a36Sopenharmony_ci	.globl	hypersparc_flush_page_to_ram
2362306a36Sopenharmony_ci	.globl	hypersparc_flush_page_for_dma, hypersparc_flush_sig_insns
2462306a36Sopenharmony_ci	.globl	hypersparc_flush_tlb_all, hypersparc_flush_tlb_mm
2562306a36Sopenharmony_ci	.globl	hypersparc_flush_tlb_range, hypersparc_flush_tlb_page
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_cihypersparc_flush_cache_all:
2862306a36Sopenharmony_ci	WINDOW_FLUSH(%g4, %g5)
2962306a36Sopenharmony_ci	sethi	%hi(vac_cache_size), %g4
3062306a36Sopenharmony_ci	ld	[%g4 + %lo(vac_cache_size)], %g5
3162306a36Sopenharmony_ci	sethi	%hi(vac_line_size), %g1
3262306a36Sopenharmony_ci	ld	[%g1 + %lo(vac_line_size)], %g2
3362306a36Sopenharmony_ci1:
3462306a36Sopenharmony_ci	subcc	%g5, %g2, %g5			! hyper_flush_unconditional_combined
3562306a36Sopenharmony_ci	bne	1b
3662306a36Sopenharmony_ci	 sta	%g0, [%g5] ASI_M_FLUSH_CTX
3762306a36Sopenharmony_ci	retl
3862306a36Sopenharmony_ci	 sta	%g0, [%g0] ASI_M_FLUSH_IWHOLE	! hyper_flush_whole_icache
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ci	/* We expand the window flush to get maximum performance. */
4162306a36Sopenharmony_cihypersparc_flush_cache_mm:
4262306a36Sopenharmony_ci#ifndef CONFIG_SMP
4362306a36Sopenharmony_ci	ld	[%o0 + AOFF_mm_context], %g1
4462306a36Sopenharmony_ci	cmp	%g1, -1
4562306a36Sopenharmony_ci	be	hypersparc_flush_cache_mm_out
4662306a36Sopenharmony_ci#endif
4762306a36Sopenharmony_ci	WINDOW_FLUSH(%g4, %g5)
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ci	sethi	%hi(vac_line_size), %g1
5062306a36Sopenharmony_ci	ld	[%g1 + %lo(vac_line_size)], %o1
5162306a36Sopenharmony_ci	sethi	%hi(vac_cache_size), %g2
5262306a36Sopenharmony_ci	ld	[%g2 + %lo(vac_cache_size)], %o0
5362306a36Sopenharmony_ci	add	%o1, %o1, %g1
5462306a36Sopenharmony_ci	add	%o1, %g1, %g2
5562306a36Sopenharmony_ci	add	%o1, %g2, %g3
5662306a36Sopenharmony_ci	add	%o1, %g3, %g4
5762306a36Sopenharmony_ci	add	%o1, %g4, %g5
5862306a36Sopenharmony_ci	add	%o1, %g5, %o4
5962306a36Sopenharmony_ci	add	%o1, %o4, %o5
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ci	/* BLAMMO! */
6262306a36Sopenharmony_ci1:
6362306a36Sopenharmony_ci	subcc	%o0, %o5, %o0				! hyper_flush_cache_user
6462306a36Sopenharmony_ci	sta	%g0, [%o0 + %g0] ASI_M_FLUSH_USER
6562306a36Sopenharmony_ci	sta	%g0, [%o0 + %o1] ASI_M_FLUSH_USER
6662306a36Sopenharmony_ci	sta	%g0, [%o0 + %g1] ASI_M_FLUSH_USER
6762306a36Sopenharmony_ci	sta	%g0, [%o0 + %g2] ASI_M_FLUSH_USER
6862306a36Sopenharmony_ci	sta	%g0, [%o0 + %g3] ASI_M_FLUSH_USER
6962306a36Sopenharmony_ci	sta	%g0, [%o0 + %g4] ASI_M_FLUSH_USER
7062306a36Sopenharmony_ci	sta	%g0, [%o0 + %g5] ASI_M_FLUSH_USER
7162306a36Sopenharmony_ci	bne	1b
7262306a36Sopenharmony_ci	 sta	%g0, [%o0 + %o4] ASI_M_FLUSH_USER
7362306a36Sopenharmony_cihypersparc_flush_cache_mm_out:
7462306a36Sopenharmony_ci	retl
7562306a36Sopenharmony_ci	 nop
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci	/* The things we do for performance... */
7862306a36Sopenharmony_cihypersparc_flush_cache_range:
7962306a36Sopenharmony_ci	ld	[%o0 + VMA_VM_MM], %o0
8062306a36Sopenharmony_ci#ifndef CONFIG_SMP
8162306a36Sopenharmony_ci	ld	[%o0 + AOFF_mm_context], %g1
8262306a36Sopenharmony_ci	cmp	%g1, -1
8362306a36Sopenharmony_ci	be	hypersparc_flush_cache_range_out
8462306a36Sopenharmony_ci#endif
8562306a36Sopenharmony_ci	WINDOW_FLUSH(%g4, %g5)
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci	sethi	%hi(vac_line_size), %g1
8862306a36Sopenharmony_ci	ld	[%g1 + %lo(vac_line_size)], %o4
8962306a36Sopenharmony_ci	sethi	%hi(vac_cache_size), %g2
9062306a36Sopenharmony_ci	ld	[%g2 + %lo(vac_cache_size)], %o3
9162306a36Sopenharmony_ci
9262306a36Sopenharmony_ci	/* Here comes the fun part... */
9362306a36Sopenharmony_ci	add	%o2, (PAGE_SIZE - 1), %o2
9462306a36Sopenharmony_ci	andn	%o1, (PAGE_SIZE - 1), %o1
9562306a36Sopenharmony_ci	add	%o4, %o4, %o5
9662306a36Sopenharmony_ci	andn	%o2, (PAGE_SIZE - 1), %o2
9762306a36Sopenharmony_ci	add	%o4, %o5, %g1
9862306a36Sopenharmony_ci	sub	%o2, %o1, %g4
9962306a36Sopenharmony_ci	add	%o4, %g1, %g2
10062306a36Sopenharmony_ci	sll	%o3, 2, %g5
10162306a36Sopenharmony_ci	add	%o4, %g2, %g3
10262306a36Sopenharmony_ci	cmp	%g4, %g5
10362306a36Sopenharmony_ci	add	%o4, %g3, %g4
10462306a36Sopenharmony_ci	blu	0f
10562306a36Sopenharmony_ci	 add	%o4, %g4, %g5
10662306a36Sopenharmony_ci	add	%o4, %g5, %g7
10762306a36Sopenharmony_ci
10862306a36Sopenharmony_ci	/* Flush entire user space, believe it or not this is quicker
10962306a36Sopenharmony_ci	 * than page at a time flushings for range > (cache_size<<2).
11062306a36Sopenharmony_ci	 */
11162306a36Sopenharmony_ci1:
11262306a36Sopenharmony_ci	subcc	%o3, %g7, %o3
11362306a36Sopenharmony_ci	sta	%g0, [%o3 + %g0] ASI_M_FLUSH_USER
11462306a36Sopenharmony_ci	sta	%g0, [%o3 + %o4] ASI_M_FLUSH_USER
11562306a36Sopenharmony_ci	sta	%g0, [%o3 + %o5] ASI_M_FLUSH_USER
11662306a36Sopenharmony_ci	sta	%g0, [%o3 + %g1] ASI_M_FLUSH_USER
11762306a36Sopenharmony_ci	sta	%g0, [%o3 + %g2] ASI_M_FLUSH_USER
11862306a36Sopenharmony_ci	sta	%g0, [%o3 + %g3] ASI_M_FLUSH_USER
11962306a36Sopenharmony_ci	sta	%g0, [%o3 + %g4] ASI_M_FLUSH_USER
12062306a36Sopenharmony_ci	bne	1b
12162306a36Sopenharmony_ci	 sta	%g0, [%o3 + %g5] ASI_M_FLUSH_USER
12262306a36Sopenharmony_ci	retl
12362306a36Sopenharmony_ci	 nop
12462306a36Sopenharmony_ci
12562306a36Sopenharmony_ci	/* Below our threshold, flush one page at a time. */
12662306a36Sopenharmony_ci0:
12762306a36Sopenharmony_ci	ld	[%o0 + AOFF_mm_context], %o0
12862306a36Sopenharmony_ci	mov	SRMMU_CTX_REG, %g7
12962306a36Sopenharmony_ci	lda	[%g7] ASI_M_MMUREGS, %o3
13062306a36Sopenharmony_ci	sta	%o0, [%g7] ASI_M_MMUREGS
13162306a36Sopenharmony_ci	add	%o2, -PAGE_SIZE, %o0
13262306a36Sopenharmony_ci1:
13362306a36Sopenharmony_ci	or	%o0, 0x400, %g7
13462306a36Sopenharmony_ci	lda	[%g7] ASI_M_FLUSH_PROBE, %g7
13562306a36Sopenharmony_ci	orcc	%g7, 0, %g0
13662306a36Sopenharmony_ci	be,a	3f
13762306a36Sopenharmony_ci	 mov	%o0, %o2
13862306a36Sopenharmony_ci	add	%o4, %g5, %g7
13962306a36Sopenharmony_ci2:
14062306a36Sopenharmony_ci	sub	%o2, %g7, %o2
14162306a36Sopenharmony_ci	sta	%g0, [%o2 + %g0] ASI_M_FLUSH_PAGE
14262306a36Sopenharmony_ci	sta	%g0, [%o2 + %o4] ASI_M_FLUSH_PAGE
14362306a36Sopenharmony_ci	sta	%g0, [%o2 + %o5] ASI_M_FLUSH_PAGE
14462306a36Sopenharmony_ci	sta	%g0, [%o2 + %g1] ASI_M_FLUSH_PAGE
14562306a36Sopenharmony_ci	sta	%g0, [%o2 + %g2] ASI_M_FLUSH_PAGE
14662306a36Sopenharmony_ci	sta	%g0, [%o2 + %g3] ASI_M_FLUSH_PAGE
14762306a36Sopenharmony_ci	andcc	%o2, 0xffc, %g0
14862306a36Sopenharmony_ci	sta	%g0, [%o2 + %g4] ASI_M_FLUSH_PAGE
14962306a36Sopenharmony_ci	bne	2b
15062306a36Sopenharmony_ci	 sta	%g0, [%o2 + %g5] ASI_M_FLUSH_PAGE
15162306a36Sopenharmony_ci3:
15262306a36Sopenharmony_ci	cmp	%o2, %o1
15362306a36Sopenharmony_ci	bne	1b
15462306a36Sopenharmony_ci	 add	%o2, -PAGE_SIZE, %o0
15562306a36Sopenharmony_ci	mov	SRMMU_FAULT_STATUS, %g5
15662306a36Sopenharmony_ci	lda	[%g5] ASI_M_MMUREGS, %g0
15762306a36Sopenharmony_ci	mov	SRMMU_CTX_REG, %g7
15862306a36Sopenharmony_ci	sta	%o3, [%g7] ASI_M_MMUREGS
15962306a36Sopenharmony_cihypersparc_flush_cache_range_out:
16062306a36Sopenharmony_ci	retl
16162306a36Sopenharmony_ci	 nop
16262306a36Sopenharmony_ci
16362306a36Sopenharmony_ci	/* HyperSparc requires a valid mapping where we are about to flush
16462306a36Sopenharmony_ci	 * in order to check for a physical tag match during the flush.
16562306a36Sopenharmony_ci	 */
16662306a36Sopenharmony_ci	/* Verified, my ass... */
16762306a36Sopenharmony_cihypersparc_flush_cache_page:
16862306a36Sopenharmony_ci	ld	[%o0 + VMA_VM_MM], %o0
16962306a36Sopenharmony_ci	ld	[%o0 + AOFF_mm_context], %g2
17062306a36Sopenharmony_ci#ifndef CONFIG_SMP
17162306a36Sopenharmony_ci	cmp	%g2, -1
17262306a36Sopenharmony_ci	be	hypersparc_flush_cache_page_out
17362306a36Sopenharmony_ci#endif
17462306a36Sopenharmony_ci	WINDOW_FLUSH(%g4, %g5)
17562306a36Sopenharmony_ci
17662306a36Sopenharmony_ci	sethi	%hi(vac_line_size), %g1
17762306a36Sopenharmony_ci	ld	[%g1 + %lo(vac_line_size)], %o4
17862306a36Sopenharmony_ci	mov	SRMMU_CTX_REG, %o3
17962306a36Sopenharmony_ci	andn	%o1, (PAGE_SIZE - 1), %o1
18062306a36Sopenharmony_ci	lda	[%o3] ASI_M_MMUREGS, %o2
18162306a36Sopenharmony_ci	sta	%g2, [%o3] ASI_M_MMUREGS
18262306a36Sopenharmony_ci	or	%o1, 0x400, %o5
18362306a36Sopenharmony_ci	lda	[%o5] ASI_M_FLUSH_PROBE, %g1
18462306a36Sopenharmony_ci	orcc	%g0, %g1, %g0
18562306a36Sopenharmony_ci	be	2f
18662306a36Sopenharmony_ci	 add	%o4, %o4, %o5
18762306a36Sopenharmony_ci	sub	%o1, -PAGE_SIZE, %o1
18862306a36Sopenharmony_ci	add	%o4, %o5, %g1
18962306a36Sopenharmony_ci	add	%o4, %g1, %g2
19062306a36Sopenharmony_ci	add	%o4, %g2, %g3
19162306a36Sopenharmony_ci	add	%o4, %g3, %g4
19262306a36Sopenharmony_ci	add	%o4, %g4, %g5
19362306a36Sopenharmony_ci	add	%o4, %g5, %g7
19462306a36Sopenharmony_ci
19562306a36Sopenharmony_ci	/* BLAMMO! */
19662306a36Sopenharmony_ci1:
19762306a36Sopenharmony_ci	sub	%o1, %g7, %o1
19862306a36Sopenharmony_ci	sta	%g0, [%o1 + %g0] ASI_M_FLUSH_PAGE
19962306a36Sopenharmony_ci	sta	%g0, [%o1 + %o4] ASI_M_FLUSH_PAGE
20062306a36Sopenharmony_ci	sta	%g0, [%o1 + %o5] ASI_M_FLUSH_PAGE
20162306a36Sopenharmony_ci	sta	%g0, [%o1 + %g1] ASI_M_FLUSH_PAGE
20262306a36Sopenharmony_ci	sta	%g0, [%o1 + %g2] ASI_M_FLUSH_PAGE
20362306a36Sopenharmony_ci	sta	%g0, [%o1 + %g3] ASI_M_FLUSH_PAGE
20462306a36Sopenharmony_ci	andcc	%o1, 0xffc, %g0
20562306a36Sopenharmony_ci	sta	%g0, [%o1 + %g4] ASI_M_FLUSH_PAGE
20662306a36Sopenharmony_ci	bne	1b
20762306a36Sopenharmony_ci	 sta	%g0, [%o1 + %g5] ASI_M_FLUSH_PAGE
20862306a36Sopenharmony_ci2:
20962306a36Sopenharmony_ci	mov	SRMMU_FAULT_STATUS, %g7
21062306a36Sopenharmony_ci	mov	SRMMU_CTX_REG, %g4
21162306a36Sopenharmony_ci	lda	[%g7] ASI_M_MMUREGS, %g0
21262306a36Sopenharmony_ci	sta	%o2, [%g4] ASI_M_MMUREGS
21362306a36Sopenharmony_cihypersparc_flush_cache_page_out:
21462306a36Sopenharmony_ci	retl
21562306a36Sopenharmony_ci	 nop
21662306a36Sopenharmony_ci
21762306a36Sopenharmony_cihypersparc_flush_sig_insns:
21862306a36Sopenharmony_ci	flush	%o1
21962306a36Sopenharmony_ci	retl
22062306a36Sopenharmony_ci	 flush	%o1 + 4
22162306a36Sopenharmony_ci
22262306a36Sopenharmony_ci	/* HyperSparc is copy-back. */
22362306a36Sopenharmony_cihypersparc_flush_page_to_ram:
22462306a36Sopenharmony_ci	sethi	%hi(vac_line_size), %g1
22562306a36Sopenharmony_ci	ld	[%g1 + %lo(vac_line_size)], %o4
22662306a36Sopenharmony_ci	andn	%o0, (PAGE_SIZE - 1), %o0
22762306a36Sopenharmony_ci	add	%o4, %o4, %o5
22862306a36Sopenharmony_ci	or	%o0, 0x400, %g7
22962306a36Sopenharmony_ci	lda	[%g7] ASI_M_FLUSH_PROBE, %g5
23062306a36Sopenharmony_ci	add	%o4, %o5, %g1
23162306a36Sopenharmony_ci	orcc	%g5, 0, %g0
23262306a36Sopenharmony_ci	be	2f
23362306a36Sopenharmony_ci	 add	%o4, %g1, %g2
23462306a36Sopenharmony_ci	add	%o4, %g2, %g3
23562306a36Sopenharmony_ci	sub	%o0, -PAGE_SIZE, %o0
23662306a36Sopenharmony_ci	add	%o4, %g3, %g4
23762306a36Sopenharmony_ci	add	%o4, %g4, %g5
23862306a36Sopenharmony_ci	add	%o4, %g5, %g7
23962306a36Sopenharmony_ci
24062306a36Sopenharmony_ci	/* BLAMMO! */
24162306a36Sopenharmony_ci1:
24262306a36Sopenharmony_ci	sub	%o0, %g7, %o0
24362306a36Sopenharmony_ci	sta	%g0, [%o0 + %g0] ASI_M_FLUSH_PAGE
24462306a36Sopenharmony_ci	sta	%g0, [%o0 + %o4] ASI_M_FLUSH_PAGE
24562306a36Sopenharmony_ci	sta	%g0, [%o0 + %o5] ASI_M_FLUSH_PAGE
24662306a36Sopenharmony_ci	sta	%g0, [%o0 + %g1] ASI_M_FLUSH_PAGE
24762306a36Sopenharmony_ci	sta	%g0, [%o0 + %g2] ASI_M_FLUSH_PAGE
24862306a36Sopenharmony_ci	sta	%g0, [%o0 + %g3] ASI_M_FLUSH_PAGE
24962306a36Sopenharmony_ci	andcc	%o0, 0xffc, %g0
25062306a36Sopenharmony_ci	sta	%g0, [%o0 + %g4] ASI_M_FLUSH_PAGE
25162306a36Sopenharmony_ci	bne	1b
25262306a36Sopenharmony_ci	 sta	%g0, [%o0 + %g5] ASI_M_FLUSH_PAGE
25362306a36Sopenharmony_ci2:
25462306a36Sopenharmony_ci	mov	SRMMU_FAULT_STATUS, %g1
25562306a36Sopenharmony_ci	retl
25662306a36Sopenharmony_ci	 lda	[%g1] ASI_M_MMUREGS, %g0
25762306a36Sopenharmony_ci
25862306a36Sopenharmony_ci	/* HyperSparc is IO cache coherent. */
25962306a36Sopenharmony_cihypersparc_flush_page_for_dma:
26062306a36Sopenharmony_ci	retl
26162306a36Sopenharmony_ci	 nop
26262306a36Sopenharmony_ci
26362306a36Sopenharmony_ci	/* It was noted that at boot time a TLB flush all in a delay slot
26462306a36Sopenharmony_ci	 * can deliver an illegal instruction to the processor if the timing
26562306a36Sopenharmony_ci	 * is just right...
26662306a36Sopenharmony_ci	 */
26762306a36Sopenharmony_cihypersparc_flush_tlb_all:
26862306a36Sopenharmony_ci	mov	0x400, %g1
26962306a36Sopenharmony_ci	sta	%g0, [%g1] ASI_M_FLUSH_PROBE
27062306a36Sopenharmony_ci	retl
27162306a36Sopenharmony_ci	 nop
27262306a36Sopenharmony_ci
27362306a36Sopenharmony_cihypersparc_flush_tlb_mm:
27462306a36Sopenharmony_ci	mov	SRMMU_CTX_REG, %g1
27562306a36Sopenharmony_ci	ld	[%o0 + AOFF_mm_context], %o1
27662306a36Sopenharmony_ci	lda	[%g1] ASI_M_MMUREGS, %g5
27762306a36Sopenharmony_ci#ifndef CONFIG_SMP
27862306a36Sopenharmony_ci	cmp	%o1, -1
27962306a36Sopenharmony_ci	be	hypersparc_flush_tlb_mm_out
28062306a36Sopenharmony_ci#endif
28162306a36Sopenharmony_ci	 mov	0x300, %g2
28262306a36Sopenharmony_ci	sta	%o1, [%g1] ASI_M_MMUREGS
28362306a36Sopenharmony_ci	sta	%g0, [%g2] ASI_M_FLUSH_PROBE
28462306a36Sopenharmony_cihypersparc_flush_tlb_mm_out:
28562306a36Sopenharmony_ci	retl
28662306a36Sopenharmony_ci	 sta	%g5, [%g1] ASI_M_MMUREGS
28762306a36Sopenharmony_ci
28862306a36Sopenharmony_cihypersparc_flush_tlb_range:
28962306a36Sopenharmony_ci	ld	[%o0 + VMA_VM_MM], %o0
29062306a36Sopenharmony_ci	mov	SRMMU_CTX_REG, %g1
29162306a36Sopenharmony_ci	ld	[%o0 + AOFF_mm_context], %o3
29262306a36Sopenharmony_ci	lda	[%g1] ASI_M_MMUREGS, %g5
29362306a36Sopenharmony_ci#ifndef CONFIG_SMP
29462306a36Sopenharmony_ci	cmp	%o3, -1
29562306a36Sopenharmony_ci	be	hypersparc_flush_tlb_range_out
29662306a36Sopenharmony_ci#endif
29762306a36Sopenharmony_ci	 sethi	%hi(~((1 << PGDIR_SHIFT) - 1)), %o4
29862306a36Sopenharmony_ci	sta	%o3, [%g1] ASI_M_MMUREGS
29962306a36Sopenharmony_ci	and	%o1, %o4, %o1
30062306a36Sopenharmony_ci	add	%o1, 0x200, %o1
30162306a36Sopenharmony_ci	sta	%g0, [%o1] ASI_M_FLUSH_PROBE
30262306a36Sopenharmony_ci1:
30362306a36Sopenharmony_ci	sub	%o1, %o4, %o1
30462306a36Sopenharmony_ci	cmp	%o1, %o2
30562306a36Sopenharmony_ci	blu,a	1b
30662306a36Sopenharmony_ci	 sta	%g0, [%o1] ASI_M_FLUSH_PROBE
30762306a36Sopenharmony_cihypersparc_flush_tlb_range_out:
30862306a36Sopenharmony_ci	retl
30962306a36Sopenharmony_ci	 sta	%g5, [%g1] ASI_M_MMUREGS
31062306a36Sopenharmony_ci
31162306a36Sopenharmony_cihypersparc_flush_tlb_page:
31262306a36Sopenharmony_ci	ld	[%o0 + VMA_VM_MM], %o0
31362306a36Sopenharmony_ci	mov	SRMMU_CTX_REG, %g1
31462306a36Sopenharmony_ci	ld	[%o0 + AOFF_mm_context], %o3
31562306a36Sopenharmony_ci	andn	%o1, (PAGE_SIZE - 1), %o1
31662306a36Sopenharmony_ci#ifndef CONFIG_SMP
31762306a36Sopenharmony_ci	cmp	%o3, -1
31862306a36Sopenharmony_ci	be	hypersparc_flush_tlb_page_out
31962306a36Sopenharmony_ci#endif
32062306a36Sopenharmony_ci	 lda	[%g1] ASI_M_MMUREGS, %g5
32162306a36Sopenharmony_ci	sta	%o3, [%g1] ASI_M_MMUREGS
32262306a36Sopenharmony_ci	sta	%g0, [%o1] ASI_M_FLUSH_PROBE
32362306a36Sopenharmony_cihypersparc_flush_tlb_page_out:
32462306a36Sopenharmony_ci	retl
32562306a36Sopenharmony_ci	 sta	%g5, [%g1] ASI_M_MMUREGS
32662306a36Sopenharmony_ci
32762306a36Sopenharmony_ci	__INIT
32862306a36Sopenharmony_ci
32962306a36Sopenharmony_ci	/* High speed page clear/copy. */
33062306a36Sopenharmony_cihypersparc_bzero_1page:
33162306a36Sopenharmony_ci/* NOTE: This routine has to be shorter than 40insns --jj */
33262306a36Sopenharmony_ci	clr	%g1
33362306a36Sopenharmony_ci	mov	32, %g2
33462306a36Sopenharmony_ci	mov	64, %g3
33562306a36Sopenharmony_ci	mov	96, %g4
33662306a36Sopenharmony_ci	mov	128, %g5
33762306a36Sopenharmony_ci	mov	160, %g7
33862306a36Sopenharmony_ci	mov	192, %o2
33962306a36Sopenharmony_ci	mov	224, %o3
34062306a36Sopenharmony_ci	mov	16, %o1
34162306a36Sopenharmony_ci1:
34262306a36Sopenharmony_ci	stda	%g0, [%o0 + %g0] ASI_M_BFILL
34362306a36Sopenharmony_ci	stda	%g0, [%o0 + %g2] ASI_M_BFILL
34462306a36Sopenharmony_ci	stda	%g0, [%o0 + %g3] ASI_M_BFILL
34562306a36Sopenharmony_ci	stda	%g0, [%o0 + %g4] ASI_M_BFILL
34662306a36Sopenharmony_ci	stda	%g0, [%o0 + %g5] ASI_M_BFILL
34762306a36Sopenharmony_ci	stda	%g0, [%o0 + %g7] ASI_M_BFILL
34862306a36Sopenharmony_ci	stda	%g0, [%o0 + %o2] ASI_M_BFILL
34962306a36Sopenharmony_ci	stda	%g0, [%o0 + %o3] ASI_M_BFILL
35062306a36Sopenharmony_ci	subcc	%o1, 1, %o1
35162306a36Sopenharmony_ci	bne	1b
35262306a36Sopenharmony_ci	 add	%o0, 256, %o0
35362306a36Sopenharmony_ci
35462306a36Sopenharmony_ci	retl
35562306a36Sopenharmony_ci	 nop
35662306a36Sopenharmony_ci
35762306a36Sopenharmony_cihypersparc_copy_1page:
35862306a36Sopenharmony_ci/* NOTE: This routine has to be shorter than 70insns --jj */
35962306a36Sopenharmony_ci	sub	%o1, %o0, %o2		! difference
36062306a36Sopenharmony_ci	mov	16, %g1
36162306a36Sopenharmony_ci1:
36262306a36Sopenharmony_ci	sta	%o0, [%o0 + %o2] ASI_M_BCOPY
36362306a36Sopenharmony_ci	add	%o0, 32, %o0
36462306a36Sopenharmony_ci	sta	%o0, [%o0 + %o2] ASI_M_BCOPY
36562306a36Sopenharmony_ci	add	%o0, 32, %o0
36662306a36Sopenharmony_ci	sta	%o0, [%o0 + %o2] ASI_M_BCOPY
36762306a36Sopenharmony_ci	add	%o0, 32, %o0
36862306a36Sopenharmony_ci	sta	%o0, [%o0 + %o2] ASI_M_BCOPY
36962306a36Sopenharmony_ci	add	%o0, 32, %o0
37062306a36Sopenharmony_ci	sta	%o0, [%o0 + %o2] ASI_M_BCOPY
37162306a36Sopenharmony_ci	add	%o0, 32, %o0
37262306a36Sopenharmony_ci	sta	%o0, [%o0 + %o2] ASI_M_BCOPY
37362306a36Sopenharmony_ci	add	%o0, 32, %o0
37462306a36Sopenharmony_ci	sta	%o0, [%o0 + %o2] ASI_M_BCOPY
37562306a36Sopenharmony_ci	add	%o0, 32, %o0
37662306a36Sopenharmony_ci	sta	%o0, [%o0 + %o2] ASI_M_BCOPY
37762306a36Sopenharmony_ci	subcc	%g1, 1, %g1
37862306a36Sopenharmony_ci	bne	1b
37962306a36Sopenharmony_ci	 add	%o0, 32, %o0
38062306a36Sopenharmony_ci
38162306a36Sopenharmony_ci	retl
38262306a36Sopenharmony_ci	 nop
38362306a36Sopenharmony_ci
38462306a36Sopenharmony_ci	.globl	hypersparc_setup_blockops
38562306a36Sopenharmony_cihypersparc_setup_blockops:
38662306a36Sopenharmony_ci	sethi	%hi(bzero_1page), %o0
38762306a36Sopenharmony_ci	or	%o0, %lo(bzero_1page), %o0
38862306a36Sopenharmony_ci	sethi	%hi(hypersparc_bzero_1page), %o1
38962306a36Sopenharmony_ci	or	%o1, %lo(hypersparc_bzero_1page), %o1
39062306a36Sopenharmony_ci	sethi	%hi(hypersparc_copy_1page), %o2
39162306a36Sopenharmony_ci	or	%o2, %lo(hypersparc_copy_1page), %o2
39262306a36Sopenharmony_ci	ld	[%o1], %o4
39362306a36Sopenharmony_ci1:
39462306a36Sopenharmony_ci	add	%o1, 4, %o1
39562306a36Sopenharmony_ci	st	%o4, [%o0]
39662306a36Sopenharmony_ci	add	%o0, 4, %o0
39762306a36Sopenharmony_ci	cmp	%o1, %o2
39862306a36Sopenharmony_ci	bne	1b
39962306a36Sopenharmony_ci	 ld	[%o1], %o4
40062306a36Sopenharmony_ci	sethi	%hi(__copy_1page), %o0
40162306a36Sopenharmony_ci	or	%o0, %lo(__copy_1page), %o0
40262306a36Sopenharmony_ci	sethi	%hi(hypersparc_setup_blockops), %o2
40362306a36Sopenharmony_ci	or	%o2, %lo(hypersparc_setup_blockops), %o2
40462306a36Sopenharmony_ci	ld	[%o1], %o4
40562306a36Sopenharmony_ci1:
40662306a36Sopenharmony_ci	add	%o1, 4, %o1
40762306a36Sopenharmony_ci	st	%o4, [%o0]
40862306a36Sopenharmony_ci	add	%o0, 4, %o0
40962306a36Sopenharmony_ci	cmp	%o1, %o2
41062306a36Sopenharmony_ci	bne	1b
41162306a36Sopenharmony_ci	 ld	[%o1], %o4
41262306a36Sopenharmony_ci	sta	%g0, [%g0] ASI_M_FLUSH_IWHOLE
41362306a36Sopenharmony_ci	retl
41462306a36Sopenharmony_ci	 nop
415