^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * hypersparc.S: High speed Hypersparc mmu/cache operations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 1997 David S. Miller (davem@caip.rutgers.edu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <asm/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <asm/psr.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <asm/asm-offsets.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <asm/asi.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <asm/page.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <asm/pgtable.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <asm/pgtsrmmu.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) .text
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) .align 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) .globl hypersparc_flush_cache_all, hypersparc_flush_cache_mm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) .globl hypersparc_flush_cache_range, hypersparc_flush_cache_page
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) .globl hypersparc_flush_page_to_ram
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) .globl hypersparc_flush_page_for_dma, hypersparc_flush_sig_insns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) .globl hypersparc_flush_tlb_all, hypersparc_flush_tlb_mm
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) .globl hypersparc_flush_tlb_range, hypersparc_flush_tlb_page
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) hypersparc_flush_cache_all:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) WINDOW_FLUSH(%g4, %g5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) sethi %hi(vac_cache_size), %g4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) ld [%g4 + %lo(vac_cache_size)], %g5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) sethi %hi(vac_line_size), %g1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) ld [%g1 + %lo(vac_line_size)], %g2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) subcc %g5, %g2, %g5 ! hyper_flush_unconditional_combined
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) bne 1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) sta %g0, [%g5] ASI_M_FLUSH_CTX
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) retl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) sta %g0, [%g0] ASI_M_FLUSH_IWHOLE ! hyper_flush_whole_icache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) /* We expand the window flush to get maximum performance. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) hypersparc_flush_cache_mm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #ifndef CONFIG_SMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) ld [%o0 + AOFF_mm_context], %g1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) cmp %g1, -1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) be hypersparc_flush_cache_mm_out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) WINDOW_FLUSH(%g4, %g5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) sethi %hi(vac_line_size), %g1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) ld [%g1 + %lo(vac_line_size)], %o1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) sethi %hi(vac_cache_size), %g2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) ld [%g2 + %lo(vac_cache_size)], %o0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) add %o1, %o1, %g1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) add %o1, %g1, %g2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) add %o1, %g2, %g3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) add %o1, %g3, %g4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) add %o1, %g4, %g5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) add %o1, %g5, %o4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) add %o1, %o4, %o5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) /* BLAMMO! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) subcc %o0, %o5, %o0 ! hyper_flush_cache_user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) sta %g0, [%o0 + %g0] ASI_M_FLUSH_USER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) sta %g0, [%o0 + %o1] ASI_M_FLUSH_USER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) sta %g0, [%o0 + %g1] ASI_M_FLUSH_USER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) sta %g0, [%o0 + %g2] ASI_M_FLUSH_USER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) sta %g0, [%o0 + %g3] ASI_M_FLUSH_USER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) sta %g0, [%o0 + %g4] ASI_M_FLUSH_USER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) sta %g0, [%o0 + %g5] ASI_M_FLUSH_USER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) bne 1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) sta %g0, [%o0 + %o4] ASI_M_FLUSH_USER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) hypersparc_flush_cache_mm_out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) retl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) nop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) /* The things we do for performance... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) hypersparc_flush_cache_range:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) ld [%o0 + VMA_VM_MM], %o0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) #ifndef CONFIG_SMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) ld [%o0 + AOFF_mm_context], %g1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) cmp %g1, -1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) be hypersparc_flush_cache_range_out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) WINDOW_FLUSH(%g4, %g5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) sethi %hi(vac_line_size), %g1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) ld [%g1 + %lo(vac_line_size)], %o4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) sethi %hi(vac_cache_size), %g2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) ld [%g2 + %lo(vac_cache_size)], %o3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) /* Here comes the fun part... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) add %o2, (PAGE_SIZE - 1), %o2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) andn %o1, (PAGE_SIZE - 1), %o1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) add %o4, %o4, %o5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) andn %o2, (PAGE_SIZE - 1), %o2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) add %o4, %o5, %g1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) sub %o2, %o1, %g4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) add %o4, %g1, %g2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) sll %o3, 2, %g5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) add %o4, %g2, %g3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) cmp %g4, %g5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) add %o4, %g3, %g4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) blu 0f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) add %o4, %g4, %g5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) add %o4, %g5, %g7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) /* Flush entire user space, believe it or not this is quicker
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) * than page at a time flushings for range > (cache_size<<2).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) subcc %o3, %g7, %o3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) sta %g0, [%o3 + %g0] ASI_M_FLUSH_USER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) sta %g0, [%o3 + %o4] ASI_M_FLUSH_USER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) sta %g0, [%o3 + %o5] ASI_M_FLUSH_USER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) sta %g0, [%o3 + %g1] ASI_M_FLUSH_USER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) sta %g0, [%o3 + %g2] ASI_M_FLUSH_USER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) sta %g0, [%o3 + %g3] ASI_M_FLUSH_USER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) sta %g0, [%o3 + %g4] ASI_M_FLUSH_USER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) bne 1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) sta %g0, [%o3 + %g5] ASI_M_FLUSH_USER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) retl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) nop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) /* Below our threshold, flush one page at a time. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 0:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) ld [%o0 + AOFF_mm_context], %o0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) mov SRMMU_CTX_REG, %g7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) lda [%g7] ASI_M_MMUREGS, %o3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) sta %o0, [%g7] ASI_M_MMUREGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) add %o2, -PAGE_SIZE, %o0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) or %o0, 0x400, %g7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) lda [%g7] ASI_M_FLUSH_PROBE, %g7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) orcc %g7, 0, %g0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) be,a 3f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) mov %o0, %o2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) add %o4, %g5, %g7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) sub %o2, %g7, %o2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) sta %g0, [%o2 + %g0] ASI_M_FLUSH_PAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) sta %g0, [%o2 + %o4] ASI_M_FLUSH_PAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) sta %g0, [%o2 + %o5] ASI_M_FLUSH_PAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) sta %g0, [%o2 + %g1] ASI_M_FLUSH_PAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) sta %g0, [%o2 + %g2] ASI_M_FLUSH_PAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) sta %g0, [%o2 + %g3] ASI_M_FLUSH_PAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) andcc %o2, 0xffc, %g0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) sta %g0, [%o2 + %g4] ASI_M_FLUSH_PAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) bne 2b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) sta %g0, [%o2 + %g5] ASI_M_FLUSH_PAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) cmp %o2, %o1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) bne 1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) add %o2, -PAGE_SIZE, %o0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) mov SRMMU_FAULT_STATUS, %g5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) lda [%g5] ASI_M_MMUREGS, %g0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) mov SRMMU_CTX_REG, %g7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) sta %o3, [%g7] ASI_M_MMUREGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) hypersparc_flush_cache_range_out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) retl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) nop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) /* HyperSparc requires a valid mapping where we are about to flush
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) * in order to check for a physical tag match during the flush.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) /* Verified, my ass... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) hypersparc_flush_cache_page:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) ld [%o0 + VMA_VM_MM], %o0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) ld [%o0 + AOFF_mm_context], %g2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) #ifndef CONFIG_SMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) cmp %g2, -1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) be hypersparc_flush_cache_page_out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) WINDOW_FLUSH(%g4, %g5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) sethi %hi(vac_line_size), %g1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) ld [%g1 + %lo(vac_line_size)], %o4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) mov SRMMU_CTX_REG, %o3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) andn %o1, (PAGE_SIZE - 1), %o1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) lda [%o3] ASI_M_MMUREGS, %o2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) sta %g2, [%o3] ASI_M_MMUREGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) or %o1, 0x400, %o5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) lda [%o5] ASI_M_FLUSH_PROBE, %g1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) orcc %g0, %g1, %g0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) be 2f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) add %o4, %o4, %o5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) sub %o1, -PAGE_SIZE, %o1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) add %o4, %o5, %g1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) add %o4, %g1, %g2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) add %o4, %g2, %g3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) add %o4, %g3, %g4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) add %o4, %g4, %g5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) add %o4, %g5, %g7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) /* BLAMMO! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) sub %o1, %g7, %o1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) sta %g0, [%o1 + %g0] ASI_M_FLUSH_PAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) sta %g0, [%o1 + %o4] ASI_M_FLUSH_PAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) sta %g0, [%o1 + %o5] ASI_M_FLUSH_PAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) sta %g0, [%o1 + %g1] ASI_M_FLUSH_PAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) sta %g0, [%o1 + %g2] ASI_M_FLUSH_PAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) sta %g0, [%o1 + %g3] ASI_M_FLUSH_PAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) andcc %o1, 0xffc, %g0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) sta %g0, [%o1 + %g4] ASI_M_FLUSH_PAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) bne 1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) sta %g0, [%o1 + %g5] ASI_M_FLUSH_PAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) mov SRMMU_FAULT_STATUS, %g7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) mov SRMMU_CTX_REG, %g4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) lda [%g7] ASI_M_MMUREGS, %g0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) sta %o2, [%g4] ASI_M_MMUREGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) hypersparc_flush_cache_page_out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) retl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) nop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) hypersparc_flush_sig_insns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) flush %o1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) retl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) flush %o1 + 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) /* HyperSparc is copy-back. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) hypersparc_flush_page_to_ram:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) sethi %hi(vac_line_size), %g1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) ld [%g1 + %lo(vac_line_size)], %o4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) andn %o0, (PAGE_SIZE - 1), %o0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) add %o4, %o4, %o5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) or %o0, 0x400, %g7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) lda [%g7] ASI_M_FLUSH_PROBE, %g5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) add %o4, %o5, %g1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) orcc %g5, 0, %g0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) be 2f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) add %o4, %g1, %g2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) add %o4, %g2, %g3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) sub %o0, -PAGE_SIZE, %o0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) add %o4, %g3, %g4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) add %o4, %g4, %g5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) add %o4, %g5, %g7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) /* BLAMMO! */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) sub %o0, %g7, %o0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) sta %g0, [%o0 + %g0] ASI_M_FLUSH_PAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) sta %g0, [%o0 + %o4] ASI_M_FLUSH_PAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) sta %g0, [%o0 + %o5] ASI_M_FLUSH_PAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) sta %g0, [%o0 + %g1] ASI_M_FLUSH_PAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) sta %g0, [%o0 + %g2] ASI_M_FLUSH_PAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) sta %g0, [%o0 + %g3] ASI_M_FLUSH_PAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) andcc %o0, 0xffc, %g0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) sta %g0, [%o0 + %g4] ASI_M_FLUSH_PAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) bne 1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) sta %g0, [%o0 + %g5] ASI_M_FLUSH_PAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) mov SRMMU_FAULT_STATUS, %g1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) retl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) lda [%g1] ASI_M_MMUREGS, %g0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) /* HyperSparc is IO cache coherent. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) hypersparc_flush_page_for_dma:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) retl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) nop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) /* It was noted that at boot time a TLB flush all in a delay slot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) * can deliver an illegal instruction to the processor if the timing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) * is just right...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) hypersparc_flush_tlb_all:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) mov 0x400, %g1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) sta %g0, [%g1] ASI_M_FLUSH_PROBE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) retl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) nop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) hypersparc_flush_tlb_mm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) mov SRMMU_CTX_REG, %g1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) ld [%o0 + AOFF_mm_context], %o1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) lda [%g1] ASI_M_MMUREGS, %g5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) #ifndef CONFIG_SMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) cmp %o1, -1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) be hypersparc_flush_tlb_mm_out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) mov 0x300, %g2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) sta %o1, [%g1] ASI_M_MMUREGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) sta %g0, [%g2] ASI_M_FLUSH_PROBE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) hypersparc_flush_tlb_mm_out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) retl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) sta %g5, [%g1] ASI_M_MMUREGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) hypersparc_flush_tlb_range:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) ld [%o0 + VMA_VM_MM], %o0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) mov SRMMU_CTX_REG, %g1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) ld [%o0 + AOFF_mm_context], %o3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) lda [%g1] ASI_M_MMUREGS, %g5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) #ifndef CONFIG_SMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) cmp %o3, -1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) be hypersparc_flush_tlb_range_out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) sethi %hi(~((1 << PGDIR_SHIFT) - 1)), %o4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) sta %o3, [%g1] ASI_M_MMUREGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) and %o1, %o4, %o1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) add %o1, 0x200, %o1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) sta %g0, [%o1] ASI_M_FLUSH_PROBE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) sub %o1, %o4, %o1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) cmp %o1, %o2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) blu,a 1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) sta %g0, [%o1] ASI_M_FLUSH_PROBE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) hypersparc_flush_tlb_range_out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) retl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) sta %g5, [%g1] ASI_M_MMUREGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) hypersparc_flush_tlb_page:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) ld [%o0 + VMA_VM_MM], %o0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) mov SRMMU_CTX_REG, %g1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) ld [%o0 + AOFF_mm_context], %o3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) andn %o1, (PAGE_SIZE - 1), %o1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) #ifndef CONFIG_SMP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) cmp %o3, -1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) be hypersparc_flush_tlb_page_out
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) lda [%g1] ASI_M_MMUREGS, %g5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) sta %o3, [%g1] ASI_M_MMUREGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) sta %g0, [%o1] ASI_M_FLUSH_PROBE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) hypersparc_flush_tlb_page_out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) retl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) sta %g5, [%g1] ASI_M_MMUREGS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) __INIT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) /* High speed page clear/copy. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) hypersparc_bzero_1page:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) /* NOTE: This routine has to be shorter than 40insns --jj */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) clr %g1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) mov 32, %g2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) mov 64, %g3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) mov 96, %g4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) mov 128, %g5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) mov 160, %g7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) mov 192, %o2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) mov 224, %o3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) mov 16, %o1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) stda %g0, [%o0 + %g0] ASI_M_BFILL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) stda %g0, [%o0 + %g2] ASI_M_BFILL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) stda %g0, [%o0 + %g3] ASI_M_BFILL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) stda %g0, [%o0 + %g4] ASI_M_BFILL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) stda %g0, [%o0 + %g5] ASI_M_BFILL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) stda %g0, [%o0 + %g7] ASI_M_BFILL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) stda %g0, [%o0 + %o2] ASI_M_BFILL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) stda %g0, [%o0 + %o3] ASI_M_BFILL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) subcc %o1, 1, %o1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) bne 1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) add %o0, 256, %o0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) retl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) nop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) hypersparc_copy_1page:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) /* NOTE: This routine has to be shorter than 70insns --jj */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) sub %o1, %o0, %o2 ! difference
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) mov 16, %g1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) sta %o0, [%o0 + %o2] ASI_M_BCOPY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) add %o0, 32, %o0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) sta %o0, [%o0 + %o2] ASI_M_BCOPY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) add %o0, 32, %o0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) sta %o0, [%o0 + %o2] ASI_M_BCOPY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) add %o0, 32, %o0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) sta %o0, [%o0 + %o2] ASI_M_BCOPY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) add %o0, 32, %o0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) sta %o0, [%o0 + %o2] ASI_M_BCOPY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) add %o0, 32, %o0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) sta %o0, [%o0 + %o2] ASI_M_BCOPY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) add %o0, 32, %o0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) sta %o0, [%o0 + %o2] ASI_M_BCOPY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) add %o0, 32, %o0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) sta %o0, [%o0 + %o2] ASI_M_BCOPY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) subcc %g1, 1, %g1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) bne 1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) add %o0, 32, %o0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) retl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) nop
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) .globl hypersparc_setup_blockops
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) hypersparc_setup_blockops:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) sethi %hi(bzero_1page), %o0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) or %o0, %lo(bzero_1page), %o0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) sethi %hi(hypersparc_bzero_1page), %o1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) or %o1, %lo(hypersparc_bzero_1page), %o1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) sethi %hi(hypersparc_copy_1page), %o2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) or %o2, %lo(hypersparc_copy_1page), %o2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) ld [%o1], %o4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) add %o1, 4, %o1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) st %o4, [%o0]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) add %o0, 4, %o0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) cmp %o1, %o2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) bne 1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) ld [%o1], %o4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) sethi %hi(__copy_1page), %o0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) or %o0, %lo(__copy_1page), %o0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) sethi %hi(hypersparc_setup_blockops), %o2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) or %o2, %lo(hypersparc_setup_blockops), %o2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) ld [%o1], %o4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) add %o1, 4, %o1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) st %o4, [%o0]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) add %o0, 4, %o0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) cmp %o1, %o2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) bne 1b
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) ld [%o1], %o4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) sta %g0, [%g0] ASI_M_FLUSH_IWHOLE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) retl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) nop