1 /* $Id: hypersparc.S,v 1.18 2001/12/21 04:56:15 davem Exp $
2 * hypersparc.S: High speed Hypersparc mmu/cache operations.
4 * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
7 #include <asm/ptrace.h>
9 #include <asm/asm_offsets.h>
12 #include <asm/pgtsrmmu.h>
13 #include <linux/config.h>
14 #include <linux/init.h>
19 .globl hypersparc_flush_cache_all, hypersparc_flush_cache_mm
20 .globl hypersparc_flush_cache_range, hypersparc_flush_cache_page
21 .globl hypersparc_flush_page_to_ram
22 .globl hypersparc_flush_page_for_dma, hypersparc_flush_sig_insns
23 .globl hypersparc_flush_tlb_all, hypersparc_flush_tlb_mm
24 .globl hypersparc_flush_tlb_range, hypersparc_flush_tlb_page
26 hypersparc_flush_cache_all:
27 WINDOW_FLUSH(%g4, %g5)
28 sethi %hi(vac_cache_size), %g4
29 ld [%g4 + %lo(vac_cache_size)], %g5
30 sethi %hi(vac_line_size), %g1
31 ld [%g1 + %lo(vac_line_size)], %g2
33 subcc %g5, %g2, %g5 ! hyper_flush_unconditional_combined
35 sta %g0, [%g5] ASI_M_FLUSH_CTX
37 sta %g0, [%g0] ASI_M_FLUSH_IWHOLE ! hyper_flush_whole_icache
39 /* We expand the window flush to get maximum performance. */
40 hypersparc_flush_cache_mm:
42 ld [%o0 + AOFF_mm_context], %g1
44 be hypersparc_flush_cache_mm_out
46 WINDOW_FLUSH(%g4, %g5)
48 sethi %hi(vac_line_size), %g1
49 ld [%g1 + %lo(vac_line_size)], %o1
50 sethi %hi(vac_cache_size), %g2
51 ld [%g2 + %lo(vac_cache_size)], %o0
62 subcc %o0, %o5, %o0 ! hyper_flush_cache_user
63 sta %g0, [%o0 + %g0] ASI_M_FLUSH_USER
64 sta %g0, [%o0 + %o1] ASI_M_FLUSH_USER
65 sta %g0, [%o0 + %g1] ASI_M_FLUSH_USER
66 sta %g0, [%o0 + %g2] ASI_M_FLUSH_USER
67 sta %g0, [%o0 + %g3] ASI_M_FLUSH_USER
68 sta %g0, [%o0 + %g4] ASI_M_FLUSH_USER
69 sta %g0, [%o0 + %g5] ASI_M_FLUSH_USER
71 sta %g0, [%o0 + %o4] ASI_M_FLUSH_USER
72 hypersparc_flush_cache_mm_out:
76 /* The things we do for performance... */
77 hypersparc_flush_cache_range:
78 ld [%o0 + 0x0], %o0 /* XXX vma->vm_mm, GROSS XXX */
80 ld [%o0 + AOFF_mm_context], %g1
82 be hypersparc_flush_cache_range_out
84 WINDOW_FLUSH(%g4, %g5)
86 sethi %hi(vac_line_size), %g1
87 ld [%g1 + %lo(vac_line_size)], %o4
88 sethi %hi(vac_cache_size), %g2
89 ld [%g2 + %lo(vac_cache_size)], %o3
91 /* Here comes the fun part... */
92 add %o2, (PAGE_SIZE - 1), %o2
93 andn %o1, (PAGE_SIZE - 1), %o1
95 andn %o2, (PAGE_SIZE - 1), %o2
107 /* Flush entire user space, believe it or not this is quicker
108 * than page at a time flushings for range > (cache_size<<2).
112 sta %g0, [%o3 + %g0] ASI_M_FLUSH_USER
113 sta %g0, [%o3 + %o4] ASI_M_FLUSH_USER
114 sta %g0, [%o3 + %o5] ASI_M_FLUSH_USER
115 sta %g0, [%o3 + %g1] ASI_M_FLUSH_USER
116 sta %g0, [%o3 + %g2] ASI_M_FLUSH_USER
117 sta %g0, [%o3 + %g3] ASI_M_FLUSH_USER
118 sta %g0, [%o3 + %g4] ASI_M_FLUSH_USER
120 sta %g0, [%o3 + %g5] ASI_M_FLUSH_USER
124 /* Below our threshold, flush one page at a time. */
126 ld [%o0 + AOFF_mm_context], %o0
127 mov SRMMU_CTX_REG, %g7
128 lda [%g7] ASI_M_MMUREGS, %o3
129 sta %o0, [%g7] ASI_M_MMUREGS
130 add %o2, -PAGE_SIZE, %o0
133 lda [%g7] ASI_M_FLUSH_PROBE, %g7
140 sta %g0, [%o2 + %g0] ASI_M_FLUSH_PAGE
141 sta %g0, [%o2 + %o4] ASI_M_FLUSH_PAGE
142 sta %g0, [%o2 + %o5] ASI_M_FLUSH_PAGE
143 sta %g0, [%o2 + %g1] ASI_M_FLUSH_PAGE
144 sta %g0, [%o2 + %g2] ASI_M_FLUSH_PAGE
145 sta %g0, [%o2 + %g3] ASI_M_FLUSH_PAGE
146 andcc %o2, 0xffc, %g0
147 sta %g0, [%o2 + %g4] ASI_M_FLUSH_PAGE
149 sta %g0, [%o2 + %g5] ASI_M_FLUSH_PAGE
153 add %o2, -PAGE_SIZE, %o0
154 mov SRMMU_FAULT_STATUS, %g5
155 lda [%g5] ASI_M_MMUREGS, %g0
156 mov SRMMU_CTX_REG, %g7
157 sta %o3, [%g7] ASI_M_MMUREGS
158 hypersparc_flush_cache_range_out:
162 /* HyperSparc requires a valid mapping where we are about to flush
163 * in order to check for a physical tag match during the flush.
165 /* Verified, my ass... */
166 hypersparc_flush_cache_page:
167 ld [%o0 + 0x0], %o0 /* XXX vma->vm_mm, GROSS XXX */
168 ld [%o0 + AOFF_mm_context], %g2
171 be hypersparc_flush_cache_page_out
173 WINDOW_FLUSH(%g4, %g5)
175 sethi %hi(vac_line_size), %g1
176 ld [%g1 + %lo(vac_line_size)], %o4
177 mov SRMMU_CTX_REG, %o3
178 andn %o1, (PAGE_SIZE - 1), %o1
179 lda [%o3] ASI_M_MMUREGS, %o2
180 sta %g2, [%o3] ASI_M_MMUREGS
182 lda [%o5] ASI_M_FLUSH_PROBE, %g1
186 sub %o1, -PAGE_SIZE, %o1
197 sta %g0, [%o1 + %g0] ASI_M_FLUSH_PAGE
198 sta %g0, [%o1 + %o4] ASI_M_FLUSH_PAGE
199 sta %g0, [%o1 + %o5] ASI_M_FLUSH_PAGE
200 sta %g0, [%o1 + %g1] ASI_M_FLUSH_PAGE
201 sta %g0, [%o1 + %g2] ASI_M_FLUSH_PAGE
202 sta %g0, [%o1 + %g3] ASI_M_FLUSH_PAGE
203 andcc %o1, 0xffc, %g0
204 sta %g0, [%o1 + %g4] ASI_M_FLUSH_PAGE
206 sta %g0, [%o1 + %g5] ASI_M_FLUSH_PAGE
208 mov SRMMU_FAULT_STATUS, %g7
209 mov SRMMU_CTX_REG, %g4
210 lda [%g7] ASI_M_MMUREGS, %g0
211 sta %o2, [%g4] ASI_M_MMUREGS
212 hypersparc_flush_cache_page_out:
216 hypersparc_flush_sig_insns:
221 /* HyperSparc is copy-back. */
222 hypersparc_flush_page_to_ram:
223 sethi %hi(vac_line_size), %g1
224 ld [%g1 + %lo(vac_line_size)], %o4
225 andn %o0, (PAGE_SIZE - 1), %o0
228 lda [%g7] ASI_M_FLUSH_PROBE, %g5
234 sub %o0, -PAGE_SIZE, %o0
242 sta %g0, [%o0 + %g0] ASI_M_FLUSH_PAGE
243 sta %g0, [%o0 + %o4] ASI_M_FLUSH_PAGE
244 sta %g0, [%o0 + %o5] ASI_M_FLUSH_PAGE
245 sta %g0, [%o0 + %g1] ASI_M_FLUSH_PAGE
246 sta %g0, [%o0 + %g2] ASI_M_FLUSH_PAGE
247 sta %g0, [%o0 + %g3] ASI_M_FLUSH_PAGE
248 andcc %o0, 0xffc, %g0
249 sta %g0, [%o0 + %g4] ASI_M_FLUSH_PAGE
251 sta %g0, [%o0 + %g5] ASI_M_FLUSH_PAGE
253 mov SRMMU_FAULT_STATUS, %g1
255 lda [%g1] ASI_M_MMUREGS, %g0
257 /* HyperSparc is IO cache coherent. */
258 hypersparc_flush_page_for_dma:
262 /* It was noted that at boot time a TLB flush all in a delay slot
263 * can deliver an illegal instruction to the processor if the timing
266 hypersparc_flush_tlb_all:
268 sta %g0, [%g1] ASI_M_FLUSH_PROBE
272 hypersparc_flush_tlb_mm:
273 mov SRMMU_CTX_REG, %g1
274 ld [%o0 + AOFF_mm_context], %o1
275 lda [%g1] ASI_M_MMUREGS, %g5
278 be hypersparc_flush_tlb_mm_out
281 sta %o1, [%g1] ASI_M_MMUREGS
282 sta %g0, [%g2] ASI_M_FLUSH_PROBE
283 hypersparc_flush_tlb_mm_out:
285 sta %g5, [%g1] ASI_M_MMUREGS
287 hypersparc_flush_tlb_range:
288 ld [%o0 + 0x00], %o0 /* XXX vma->vm_mm GROSS XXX */
289 mov SRMMU_CTX_REG, %g1
290 ld [%o0 + AOFF_mm_context], %o3
291 lda [%g1] ASI_M_MMUREGS, %g5
294 be hypersparc_flush_tlb_range_out
296 sethi %hi(~((1 << SRMMU_PGDIR_SHIFT) - 1)), %o4
297 sta %o3, [%g1] ASI_M_MMUREGS
300 sta %g0, [%o1] ASI_M_FLUSH_PROBE
305 sta %g0, [%o1] ASI_M_FLUSH_PROBE
306 hypersparc_flush_tlb_range_out:
308 sta %g5, [%g1] ASI_M_MMUREGS
310 hypersparc_flush_tlb_page:
311 ld [%o0 + 0x00], %o0 /* XXX vma->vm_mm GROSS XXX */
312 mov SRMMU_CTX_REG, %g1
313 ld [%o0 + AOFF_mm_context], %o3
314 andn %o1, (PAGE_SIZE - 1), %o1
317 be hypersparc_flush_tlb_page_out
319 lda [%g1] ASI_M_MMUREGS, %g5
320 sta %o3, [%g1] ASI_M_MMUREGS
321 sta %g0, [%o1] ASI_M_FLUSH_PROBE
322 hypersparc_flush_tlb_page_out:
324 sta %g5, [%g1] ASI_M_MMUREGS
328 /* High speed page clear/copy. */
329 hypersparc_bzero_1page:
330 /* NOTE: This routine has to be shorter than 40insns --jj */
341 stda %g0, [%o0 + %g0] ASI_M_BFILL
342 stda %g0, [%o0 + %g2] ASI_M_BFILL
343 stda %g0, [%o0 + %g3] ASI_M_BFILL
344 stda %g0, [%o0 + %g4] ASI_M_BFILL
345 stda %g0, [%o0 + %g5] ASI_M_BFILL
346 stda %g0, [%o0 + %g7] ASI_M_BFILL
347 stda %g0, [%o0 + %o2] ASI_M_BFILL
348 stda %g0, [%o0 + %o3] ASI_M_BFILL
356 hypersparc_copy_1page:
357 /* NOTE: This routine has to be shorter than 70insns --jj */
358 sub %o1, %o0, %o2 ! difference
361 sta %o0, [%o0 + %o2] ASI_M_BCOPY
363 sta %o0, [%o0 + %o2] ASI_M_BCOPY
365 sta %o0, [%o0 + %o2] ASI_M_BCOPY
367 sta %o0, [%o0 + %o2] ASI_M_BCOPY
369 sta %o0, [%o0 + %o2] ASI_M_BCOPY
371 sta %o0, [%o0 + %o2] ASI_M_BCOPY
373 sta %o0, [%o0 + %o2] ASI_M_BCOPY
375 sta %o0, [%o0 + %o2] ASI_M_BCOPY
383 .globl hypersparc_setup_blockops
384 hypersparc_setup_blockops:
385 sethi %hi(bzero_1page), %o0
386 or %o0, %lo(bzero_1page), %o0
387 sethi %hi(hypersparc_bzero_1page), %o1
388 or %o1, %lo(hypersparc_bzero_1page), %o1
389 sethi %hi(hypersparc_copy_1page), %o2
390 or %o2, %lo(hypersparc_copy_1page), %o2
399 sethi %hi(__copy_1page), %o0
400 or %o0, %lo(__copy_1page), %o0
401 sethi %hi(hypersparc_setup_blockops), %o2
402 or %o2, %lo(hypersparc_setup_blockops), %o2
411 sta %g0, [%g0] ASI_M_FLUSH_IWHOLE