1 /* $Id: viking.S,v 1.14 1999/08/14 03:51:50 anton Exp $
2 * viking.S: High speed Viking cache/mmu operations
4 * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
5 * Copyright (C) 1997,1998,1999 Jakub Jelinek (jj@ultra.linux.cz)
6 * Copyright (C) 1999 Pavel Semerad (semerad@ss1000.ms.mff.cuni.cz)
9 #include <asm/ptrace.h>
14 #include <asm/pgtsrmmu.h>
15 #include <asm/viking.h>
16 #include <asm/cprefix.h>
17 #include <asm/btfixup.h>
22 sun4dsmp_flush_tlb_spin:
29 .globl viking_flush_cache_all, viking_flush_cache_mm
30 .globl viking_flush_cache_range, viking_flush_cache_page
31 .globl viking_flush_page, viking_mxcc_flush_page
32 .globl viking_flush_page_for_dma, viking_flush_page_to_ram
33 .globl viking_flush_chunk, viking_mxcc_flush_chunk
34 .globl viking_flush_sig_insns
35 .globl viking_flush_tlb_all, viking_flush_tlb_mm
36 .globl viking_flush_tlb_range, viking_flush_tlb_page
38 .globl viking_c_flush_chunk, viking_s_flush_chunk
41 sethi %hi(KERNBASE), %g2
46 sethi %hi(KERNBASE), %g2
50 sethi BTFIXUP_SETHI(page_contig_offset), %g2
56 sethi %hi(C_LABEL(srmmu_v2p_hash)), %g2
58 or %g2, %lo(C_LABEL(srmmu_v2p_hash)), %g2
61 and %o0, PAGE_MASK, %o0
65 2: srl %g3, 12, %g1 ! ppage >> 12
67 clr %o1 ! set counter, 0 - 127
68 sethi %hi(KERNBASE + PAGE_SIZE - 0x80000000), %o3
69 sethi %hi(0x80000000), %o4
70 sethi %hi(VIKING_PTAG_VALID), %o5
71 sethi %hi(2*PAGE_SIZE), %o0
72 sethi %hi(PAGE_SIZE), %g7
73 clr %o2 ! block counter, 0 - 3
76 or %g4, %o4, %g4 ! 0x80000000 | (set << 5)
78 sll %o2, 26, %g5 ! block << 26
81 ldda [%g5] ASI_M_DATAC_TAG, %g2
82 cmp %g3, %g1 ! ptag == ppage?
86 andcc %g2, %o5, %g0 ! ptag VALID?
88 add %g4, %o3, %g2 ! (KERNBASE + PAGE_SIZE) | (set << 5)
105 sll %o2, 26, %g5 ! block << 26
115 viking_mxcc_flush_page:
116 sethi %hi(C_LABEL(srmmu_v2p_hash)), %g2
118 or %g2, %lo(C_LABEL(srmmu_v2p_hash)), %g2
121 and %o0, PAGE_MASK, %o0
125 2: sub %g3, -PAGE_SIZE, %g3 ! ppage + PAGE_SIZE
126 sethi %hi(MXCC_SRCSTREAM), %o3 ! assume %hi(MXCC_SRCSTREAM) == %hi(MXCC_DESTSTREAM)
127 mov 0x10, %g2 ! set cacheable bit
128 or %o3, %lo(MXCC_SRCSTREAM), %o2
129 or %o3, %lo(MXCC_DESSTREAM), %o3
130 sub %g3, MXCC_STREAM_SIZE, %g3
132 stda %g2, [%o2] ASI_M_MXCC
133 stda %g2, [%o3] ASI_M_MXCC
134 andncc %g3, PAGE_MASK, %g0
136 sub %g3, MXCC_STREAM_SIZE, %g3
141 viking_mxcc_flush_chunk:
145 #define WINDOW_FLUSH(tmp1, tmp2) \
147 98: ld [%g6 + AOFF_task_thread + AOFF_thread_uwinmask], tmp2; \
148 orcc %g0, tmp2, %g0; \
151 save %sp, -64, %sp; \
152 99: subcc tmp1, 1, tmp1; \
154 restore %g0, %g0, %g0;
156 viking_flush_cache_page:
158 ld [%o0 + 0x0], %o0 /* XXX vma->vm_mm, GROSS XXX */
160 viking_flush_cache_mm:
161 viking_flush_cache_range:
163 ld [%o0 + AOFF_mm_context], %g1
165 bne viking_flush_cache_all
167 b,a viking_flush_cache_out
169 viking_flush_cache_all:
170 WINDOW_FLUSH(%g4, %g5)
171 viking_flush_cache_out:
175 viking_flush_tlb_all:
178 sta %g0, [%g1] ASI_M_FLUSH_PROBE
181 mov SRMMU_CTX_REG, %g1
182 ld [%o0 + AOFF_mm_context], %o1
183 lda [%g1] ASI_M_MMUREGS, %g5
189 sta %o1, [%g1] ASI_M_MMUREGS
190 sta %g0, [%g2] ASI_M_FLUSH_PROBE
192 sta %g5, [%g1] ASI_M_MMUREGS
198 viking_flush_tlb_range:
199 mov SRMMU_CTX_REG, %g1
200 ld [%o0 + AOFF_mm_context], %o3
201 lda [%g1] ASI_M_MMUREGS, %g5
206 sethi %hi(~((1 << SRMMU_PGDIR_SHIFT) - 1)), %o4
207 sta %o3, [%g1] ASI_M_MMUREGS
210 sta %g0, [%o1] ASI_M_FLUSH_PROBE
214 sta %g0, [%o1] ASI_M_FLUSH_PROBE
216 sta %g5, [%g1] ASI_M_MMUREGS
222 viking_flush_tlb_page:
223 ld [%o0 + 0x00], %o0 /* XXX vma->vm_mm GROSS XXX */
224 mov SRMMU_CTX_REG, %g1
225 ld [%o0 + AOFF_mm_context], %o3
226 lda [%g1] ASI_M_MMUREGS, %g5
231 and %o1, PAGE_MASK, %o1
232 sta %o3, [%g1] ASI_M_MMUREGS
233 sta %g0, [%o1] ASI_M_FLUSH_PROBE
235 sta %g5, [%g1] ASI_M_MMUREGS
241 viking_flush_page_to_ram:
242 viking_flush_page_for_dma:
243 viking_flush_sig_insns:
248 .globl sun4dsmp_flush_tlb_all, sun4dsmp_flush_tlb_mm
249 .globl sun4dsmp_flush_tlb_range, sun4dsmp_flush_tlb_page
250 sun4dsmp_flush_tlb_all:
251 sethi %hi(sun4dsmp_flush_tlb_spin), %g3
252 1: ldstub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
256 sta %g0, [%g1] ASI_M_FLUSH_PROBE
258 stb %g0, [%g3 + %lo(sun4dsmp_flush_tlb_spin)]
261 ldub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
264 sun4dsmp_flush_tlb_mm:
265 sethi %hi(sun4dsmp_flush_tlb_spin), %g3
266 1: ldstub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
269 mov SRMMU_CTX_REG, %g1
270 ld [%o0 + AOFF_mm_context], %o1
271 lda [%g1] ASI_M_MMUREGS, %g5
273 sta %o1, [%g1] ASI_M_MMUREGS
274 sta %g0, [%g2] ASI_M_FLUSH_PROBE
275 sta %g5, [%g1] ASI_M_MMUREGS
277 stb %g0, [%g3 + %lo(sun4dsmp_flush_tlb_spin)]
280 ldub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
283 sun4dsmp_flush_tlb_range:
284 sethi %hi(sun4dsmp_flush_tlb_spin), %g3
285 1: ldstub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
288 mov SRMMU_CTX_REG, %g1
289 ld [%o0 + AOFF_mm_context], %o3
290 lda [%g1] ASI_M_MMUREGS, %g5
291 sethi %hi(~((1 << SRMMU_PGDIR_SHIFT) - 1)), %o4
292 sta %o3, [%g1] ASI_M_MMUREGS
295 sta %g0, [%o1] ASI_M_FLUSH_PROBE
299 sta %g0, [%o1] ASI_M_FLUSH_PROBE
300 sta %g5, [%g1] ASI_M_MMUREGS
302 stb %g0, [%g3 + %lo(sun4dsmp_flush_tlb_spin)]
305 ldub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
308 sun4dsmp_flush_tlb_page:
309 sethi %hi(sun4dsmp_flush_tlb_spin), %g3
310 1: ldstub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
313 mov SRMMU_CTX_REG, %g1
314 ld [%o0 + 0x00], %o0 /* XXX vma->vm_mm GROSS XXX */
315 ld [%o0 + AOFF_mm_context], %o3
316 lda [%g1] ASI_M_MMUREGS, %g5
317 and %o1, PAGE_MASK, %o1
318 sta %o3, [%g1] ASI_M_MMUREGS
319 sta %g0, [%o1] ASI_M_FLUSH_PROBE
320 sta %g5, [%g1] ASI_M_MMUREGS
322 stb %g0, [%g3 + %lo(sun4dsmp_flush_tlb_spin)]
325 ldub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5