1 /* $Id: viking.S,v 1.19 2001/12/21 04:56:15 davem 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 <linux/config.h>
10 #include <asm/ptrace.h>
12 #include <asm/asm-offsets.h>
16 #include <asm/pgtsrmmu.h>
17 #include <asm/viking.h>
18 #include <asm/btfixup.h>
23 sun4dsmp_flush_tlb_spin:
30 .globl viking_flush_cache_all, viking_flush_cache_mm
31 .globl viking_flush_cache_range, viking_flush_cache_page
32 .globl viking_flush_page, viking_mxcc_flush_page
33 .globl viking_flush_page_for_dma, viking_flush_page_to_ram
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
39 sethi %hi(PAGE_OFFSET), %g2
41 srl %g3, 12, %g1 ! ppage >> 12
43 clr %o1 ! set counter, 0 - 127
44 sethi %hi(PAGE_OFFSET + PAGE_SIZE - 0x80000000), %o3
45 sethi %hi(0x80000000), %o4
46 sethi %hi(VIKING_PTAG_VALID), %o5
47 sethi %hi(2*PAGE_SIZE), %o0
48 sethi %hi(PAGE_SIZE), %g7
49 clr %o2 ! block counter, 0 - 3
52 or %g4, %o4, %g4 ! 0x80000000 | (set << 5)
54 sll %o2, 26, %g5 ! block << 26
57 ldda [%g5] ASI_M_DATAC_TAG, %g2
58 cmp %g3, %g1 ! ptag == ppage?
62 andcc %g2, %o5, %g0 ! ptag VALID?
64 add %g4, %o3, %g2 ! (PAGE_OFFSET + PAGE_SIZE) | (set << 5)
81 sll %o2, 26, %g5 ! block << 26
91 viking_mxcc_flush_page:
92 sethi %hi(PAGE_OFFSET), %g2
94 sub %g3, -PAGE_SIZE, %g3 ! ppage + PAGE_SIZE
95 sethi %hi(MXCC_SRCSTREAM), %o3 ! assume %hi(MXCC_SRCSTREAM) == %hi(MXCC_DESTSTREAM)
96 mov 0x10, %g2 ! set cacheable bit
97 or %o3, %lo(MXCC_SRCSTREAM), %o2
98 or %o3, %lo(MXCC_DESSTREAM), %o3
99 sub %g3, MXCC_STREAM_SIZE, %g3
101 stda %g2, [%o2] ASI_M_MXCC
102 stda %g2, [%o3] ASI_M_MXCC
103 andncc %g3, PAGE_MASK, %g0
105 sub %g3, MXCC_STREAM_SIZE, %g3
110 viking_flush_cache_page:
111 viking_flush_cache_range:
113 ld [%o0 + 0x0], %o0 /* XXX vma->vm_mm, GROSS XXX */
115 viking_flush_cache_mm:
117 ld [%o0 + AOFF_mm_context], %g1
119 bne viking_flush_cache_all
121 b,a viking_flush_cache_out
123 viking_flush_cache_all:
124 WINDOW_FLUSH(%g4, %g5)
125 viking_flush_cache_out:
129 viking_flush_tlb_all:
132 sta %g0, [%g1] ASI_M_FLUSH_PROBE
135 mov SRMMU_CTX_REG, %g1
136 ld [%o0 + AOFF_mm_context], %o1
137 lda [%g1] ASI_M_MMUREGS, %g5
143 sta %o1, [%g1] ASI_M_MMUREGS
144 sta %g0, [%g2] ASI_M_FLUSH_PROBE
146 sta %g5, [%g1] ASI_M_MMUREGS
152 viking_flush_tlb_range:
153 ld [%o0 + 0x00], %o0 /* XXX vma->vm_mm GROSS XXX */
154 mov SRMMU_CTX_REG, %g1
155 ld [%o0 + AOFF_mm_context], %o3
156 lda [%g1] ASI_M_MMUREGS, %g5
161 sethi %hi(~((1 << SRMMU_PGDIR_SHIFT) - 1)), %o4
162 sta %o3, [%g1] ASI_M_MMUREGS
165 sta %g0, [%o1] ASI_M_FLUSH_PROBE
169 sta %g0, [%o1] ASI_M_FLUSH_PROBE
171 sta %g5, [%g1] ASI_M_MMUREGS
177 viking_flush_tlb_page:
178 ld [%o0 + 0x00], %o0 /* XXX vma->vm_mm GROSS XXX */
179 mov SRMMU_CTX_REG, %g1
180 ld [%o0 + AOFF_mm_context], %o3
181 lda [%g1] ASI_M_MMUREGS, %g5
186 and %o1, PAGE_MASK, %o1
187 sta %o3, [%g1] ASI_M_MMUREGS
188 sta %g0, [%o1] ASI_M_FLUSH_PROBE
190 sta %g5, [%g1] ASI_M_MMUREGS
196 viking_flush_page_to_ram:
197 viking_flush_page_for_dma:
198 viking_flush_sig_insns:
203 .globl sun4dsmp_flush_tlb_all, sun4dsmp_flush_tlb_mm
204 .globl sun4dsmp_flush_tlb_range, sun4dsmp_flush_tlb_page
205 sun4dsmp_flush_tlb_all:
206 sethi %hi(sun4dsmp_flush_tlb_spin), %g3
207 1: ldstub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
211 sta %g0, [%g1] ASI_M_FLUSH_PROBE
213 stb %g0, [%g3 + %lo(sun4dsmp_flush_tlb_spin)]
216 ldub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
219 sun4dsmp_flush_tlb_mm:
220 sethi %hi(sun4dsmp_flush_tlb_spin), %g3
221 1: ldstub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
224 mov SRMMU_CTX_REG, %g1
225 ld [%o0 + AOFF_mm_context], %o1
226 lda [%g1] ASI_M_MMUREGS, %g5
228 sta %o1, [%g1] ASI_M_MMUREGS
229 sta %g0, [%g2] ASI_M_FLUSH_PROBE
230 sta %g5, [%g1] ASI_M_MMUREGS
232 stb %g0, [%g3 + %lo(sun4dsmp_flush_tlb_spin)]
235 ldub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
238 sun4dsmp_flush_tlb_range:
239 sethi %hi(sun4dsmp_flush_tlb_spin), %g3
240 1: ldstub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
243 mov SRMMU_CTX_REG, %g1
244 ld [%o0 + 0x00], %o0 /* XXX vma->vm_mm GROSS XXX */
245 ld [%o0 + AOFF_mm_context], %o3
246 lda [%g1] ASI_M_MMUREGS, %g5
247 sethi %hi(~((1 << SRMMU_PGDIR_SHIFT) - 1)), %o4
248 sta %o3, [%g1] ASI_M_MMUREGS
251 sta %g0, [%o1] ASI_M_FLUSH_PROBE
255 sta %g0, [%o1] ASI_M_FLUSH_PROBE
256 sta %g5, [%g1] ASI_M_MMUREGS
258 stb %g0, [%g3 + %lo(sun4dsmp_flush_tlb_spin)]
261 ldub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
264 sun4dsmp_flush_tlb_page:
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 + 0x00], %o0 /* XXX vma->vm_mm GROSS XXX */
271 ld [%o0 + AOFF_mm_context], %o3
272 lda [%g1] ASI_M_MMUREGS, %g5
273 and %o1, PAGE_MASK, %o1
274 sta %o3, [%g1] ASI_M_MMUREGS
275 sta %g0, [%o1] ASI_M_FLUSH_PROBE
276 sta %g5, [%g1] ASI_M_MMUREGS
278 stb %g0, [%g3 + %lo(sun4dsmp_flush_tlb_spin)]
281 ldub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5