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>
11 #include <asm/asm-offsets.h>
15 #include <asm/pgtsrmmu.h>
16 #include <asm/viking.h>
21 sun4dsmp_flush_tlb_spin:
28 .globl viking_flush_cache_all, viking_flush_cache_mm
29 .globl viking_flush_cache_range, viking_flush_cache_page
30 .globl viking_flush_page, viking_mxcc_flush_page
31 .globl viking_flush_page_for_dma, viking_flush_page_to_ram
32 .globl viking_flush_sig_insns
33 .globl viking_flush_tlb_all, viking_flush_tlb_mm
34 .globl viking_flush_tlb_range, viking_flush_tlb_page
37 sethi %hi(PAGE_OFFSET), %g2
39 srl %g3, 12, %g1 ! ppage >> 12
41 clr %o1 ! set counter, 0 - 127
42 sethi %hi(PAGE_OFFSET + PAGE_SIZE - 0x80000000), %o3
43 sethi %hi(0x80000000), %o4
44 sethi %hi(VIKING_PTAG_VALID), %o5
45 sethi %hi(2*PAGE_SIZE), %o0
46 sethi %hi(PAGE_SIZE), %g7
47 clr %o2 ! block counter, 0 - 3
50 or %g4, %o4, %g4 ! 0x80000000 | (set << 5)
52 sll %o2, 26, %g5 ! block << 26
55 ldda [%g5] ASI_M_DATAC_TAG, %g2
56 cmp %g3, %g1 ! ptag == ppage?
60 andcc %g2, %o5, %g0 ! ptag VALID?
62 add %g4, %o3, %g2 ! (PAGE_OFFSET + PAGE_SIZE) | (set << 5)
79 sll %o2, 26, %g5 ! block << 26
89 viking_mxcc_flush_page:
90 sethi %hi(PAGE_OFFSET), %g2
92 sub %g3, -PAGE_SIZE, %g3 ! ppage + PAGE_SIZE
93 sethi %hi(MXCC_SRCSTREAM), %o3 ! assume %hi(MXCC_SRCSTREAM) == %hi(MXCC_DESTSTREAM)
94 mov 0x10, %g2 ! set cacheable bit
95 or %o3, %lo(MXCC_SRCSTREAM), %o2
96 or %o3, %lo(MXCC_DESSTREAM), %o3
97 sub %g3, MXCC_STREAM_SIZE, %g3
99 stda %g2, [%o2] ASI_M_MXCC
100 stda %g2, [%o3] ASI_M_MXCC
101 andncc %g3, PAGE_MASK, %g0
103 sub %g3, MXCC_STREAM_SIZE, %g3
108 viking_flush_cache_page:
109 viking_flush_cache_range:
111 ld [%o0 + VMA_VM_MM], %o0
113 viking_flush_cache_mm:
115 ld [%o0 + AOFF_mm_context], %g1
117 bne viking_flush_cache_all
119 b,a viking_flush_cache_out
121 viking_flush_cache_all:
122 WINDOW_FLUSH(%g4, %g5)
123 viking_flush_cache_out:
127 viking_flush_tlb_all:
130 sta %g0, [%g1] ASI_M_FLUSH_PROBE
133 mov SRMMU_CTX_REG, %g1
134 ld [%o0 + AOFF_mm_context], %o1
135 lda [%g1] ASI_M_MMUREGS, %g5
141 sta %o1, [%g1] ASI_M_MMUREGS
142 sta %g0, [%g2] ASI_M_FLUSH_PROBE
144 sta %g5, [%g1] ASI_M_MMUREGS
150 viking_flush_tlb_range:
151 ld [%o0 + VMA_VM_MM], %o0
152 mov SRMMU_CTX_REG, %g1
153 ld [%o0 + AOFF_mm_context], %o3
154 lda [%g1] ASI_M_MMUREGS, %g5
159 sethi %hi(~((1 << SRMMU_PGDIR_SHIFT) - 1)), %o4
160 sta %o3, [%g1] ASI_M_MMUREGS
163 sta %g0, [%o1] ASI_M_FLUSH_PROBE
167 sta %g0, [%o1] ASI_M_FLUSH_PROBE
169 sta %g5, [%g1] ASI_M_MMUREGS
175 viking_flush_tlb_page:
176 ld [%o0 + VMA_VM_MM], %o0
177 mov SRMMU_CTX_REG, %g1
178 ld [%o0 + AOFF_mm_context], %o3
179 lda [%g1] ASI_M_MMUREGS, %g5
184 and %o1, PAGE_MASK, %o1
185 sta %o3, [%g1] ASI_M_MMUREGS
186 sta %g0, [%o1] ASI_M_FLUSH_PROBE
188 sta %g5, [%g1] ASI_M_MMUREGS
194 viking_flush_page_to_ram:
195 viking_flush_page_for_dma:
196 viking_flush_sig_insns:
201 .globl sun4dsmp_flush_tlb_all, sun4dsmp_flush_tlb_mm
202 .globl sun4dsmp_flush_tlb_range, sun4dsmp_flush_tlb_page
203 sun4dsmp_flush_tlb_all:
204 sethi %hi(sun4dsmp_flush_tlb_spin), %g3
205 1: ldstub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
209 sta %g0, [%g1] ASI_M_FLUSH_PROBE
211 stb %g0, [%g3 + %lo(sun4dsmp_flush_tlb_spin)]
214 ldub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
217 sun4dsmp_flush_tlb_mm:
218 sethi %hi(sun4dsmp_flush_tlb_spin), %g3
219 1: ldstub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
222 mov SRMMU_CTX_REG, %g1
223 ld [%o0 + AOFF_mm_context], %o1
224 lda [%g1] ASI_M_MMUREGS, %g5
226 sta %o1, [%g1] ASI_M_MMUREGS
227 sta %g0, [%g2] ASI_M_FLUSH_PROBE
228 sta %g5, [%g1] ASI_M_MMUREGS
230 stb %g0, [%g3 + %lo(sun4dsmp_flush_tlb_spin)]
233 ldub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
236 sun4dsmp_flush_tlb_range:
237 sethi %hi(sun4dsmp_flush_tlb_spin), %g3
238 1: ldstub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
241 mov SRMMU_CTX_REG, %g1
242 ld [%o0 + VMA_VM_MM], %o0
243 ld [%o0 + AOFF_mm_context], %o3
244 lda [%g1] ASI_M_MMUREGS, %g5
245 sethi %hi(~((1 << SRMMU_PGDIR_SHIFT) - 1)), %o4
246 sta %o3, [%g1] ASI_M_MMUREGS
249 sta %g0, [%o1] ASI_M_FLUSH_PROBE
253 sta %g0, [%o1] ASI_M_FLUSH_PROBE
254 sta %g5, [%g1] ASI_M_MMUREGS
256 stb %g0, [%g3 + %lo(sun4dsmp_flush_tlb_spin)]
259 ldub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
262 sun4dsmp_flush_tlb_page:
263 sethi %hi(sun4dsmp_flush_tlb_spin), %g3
264 1: ldstub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5
267 mov SRMMU_CTX_REG, %g1
268 ld [%o0 + VMA_VM_MM], %o0
269 ld [%o0 + AOFF_mm_context], %o3
270 lda [%g1] ASI_M_MMUREGS, %g5
271 and %o1, PAGE_MASK, %o1
272 sta %o3, [%g1] ASI_M_MMUREGS
273 sta %g0, [%o1] ASI_M_FLUSH_PROBE
274 sta %g5, [%g1] ASI_M_MMUREGS
276 stb %g0, [%g3 + %lo(sun4dsmp_flush_tlb_spin)]
279 ldub [%g3 + %lo(sun4dsmp_flush_tlb_spin)], %g5