Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* $Id: ultra.S,v 1.72 2002/02/09 19:49:31 davem Exp $ |
| 2 | * ultra.S: Don't expand these all over the place... |
| 3 | * |
| 4 | * Copyright (C) 1997, 2000 David S. Miller (davem@redhat.com) |
| 5 | */ |
| 6 | |
| 7 | #include <linux/config.h> |
| 8 | #include <asm/asi.h> |
| 9 | #include <asm/pgtable.h> |
| 10 | #include <asm/page.h> |
| 11 | #include <asm/spitfire.h> |
| 12 | #include <asm/mmu_context.h> |
David S. Miller | 2ef2777 | 2005-08-30 20:21:34 -0700 | [diff] [blame] | 13 | #include <asm/mmu.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <asm/pil.h> |
| 15 | #include <asm/head.h> |
| 16 | #include <asm/thread_info.h> |
| 17 | #include <asm/cacheflush.h> |
| 18 | |
| 19 | /* Basically, most of the Spitfire vs. Cheetah madness |
| 20 | * has to do with the fact that Cheetah does not support |
| 21 | * IMMU flushes out of the secondary context. Someone needs |
| 22 | * to throw a south lake birthday party for the folks |
| 23 | * in Microelectronics who refused to fix this shit. |
| 24 | */ |
| 25 | |
| 26 | /* This file is meant to be read efficiently by the CPU, not humans. |
| 27 | * Staraj sie tego nikomu nie pierdolnac... |
| 28 | */ |
| 29 | .text |
| 30 | .align 32 |
| 31 | .globl __flush_tlb_mm |
| 32 | __flush_tlb_mm: /* %o0=(ctx & TAG_CONTEXT_BITS), %o1=SECONDARY_CONTEXT */ |
| 33 | ldxa [%o1] ASI_DMMU, %g2 |
| 34 | cmp %g2, %o0 |
| 35 | bne,pn %icc, __spitfire_flush_tlb_mm_slow |
| 36 | mov 0x50, %g3 |
| 37 | stxa %g0, [%g3] ASI_DMMU_DEMAP |
| 38 | stxa %g0, [%g3] ASI_IMMU_DEMAP |
David S. Miller | 4da808c | 2006-01-31 18:33:00 -0800 | [diff] [blame^] | 39 | sethi %hi(KERNBASE), %g3 |
| 40 | flush %g3 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | retl |
David S. Miller | 4da808c | 2006-01-31 18:33:00 -0800 | [diff] [blame^] | 42 | nop |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | nop |
| 44 | nop |
| 45 | nop |
| 46 | nop |
| 47 | nop |
| 48 | nop |
| 49 | nop |
David S. Miller | 2ef2777 | 2005-08-30 20:21:34 -0700 | [diff] [blame] | 50 | nop |
| 51 | nop |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
| 53 | .align 32 |
| 54 | .globl __flush_tlb_pending |
| 55 | __flush_tlb_pending: |
| 56 | /* %o0 = context, %o1 = nr, %o2 = vaddrs[] */ |
| 57 | rdpr %pstate, %g7 |
| 58 | sllx %o1, 3, %o1 |
| 59 | andn %g7, PSTATE_IE, %g2 |
| 60 | wrpr %g2, %pstate |
| 61 | mov SECONDARY_CONTEXT, %o4 |
| 62 | ldxa [%o4] ASI_DMMU, %g2 |
| 63 | stxa %o0, [%o4] ASI_DMMU |
| 64 | 1: sub %o1, (1 << 3), %o1 |
| 65 | ldx [%o2 + %o1], %o3 |
| 66 | andcc %o3, 1, %g0 |
| 67 | andn %o3, 1, %o3 |
| 68 | be,pn %icc, 2f |
| 69 | or %o3, 0x10, %o3 |
| 70 | stxa %g0, [%o3] ASI_IMMU_DEMAP |
| 71 | 2: stxa %g0, [%o3] ASI_DMMU_DEMAP |
| 72 | membar #Sync |
| 73 | brnz,pt %o1, 1b |
| 74 | nop |
| 75 | stxa %g2, [%o4] ASI_DMMU |
David S. Miller | 4da808c | 2006-01-31 18:33:00 -0800 | [diff] [blame^] | 76 | sethi %hi(KERNBASE), %o4 |
| 77 | flush %o4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | retl |
| 79 | wrpr %g7, 0x0, %pstate |
David S. Miller | fef43da | 2005-07-05 19:45:24 -0700 | [diff] [blame] | 80 | nop |
David S. Miller | 2ef2777 | 2005-08-30 20:21:34 -0700 | [diff] [blame] | 81 | nop |
| 82 | nop |
| 83 | nop |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | |
| 85 | .align 32 |
| 86 | .globl __flush_tlb_kernel_range |
| 87 | __flush_tlb_kernel_range: /* %o0=start, %o1=end */ |
| 88 | cmp %o0, %o1 |
| 89 | be,pn %xcc, 2f |
| 90 | sethi %hi(PAGE_SIZE), %o4 |
| 91 | sub %o1, %o0, %o3 |
| 92 | sub %o3, %o4, %o3 |
| 93 | or %o0, 0x20, %o0 ! Nucleus |
| 94 | 1: stxa %g0, [%o0 + %o3] ASI_DMMU_DEMAP |
| 95 | stxa %g0, [%o0 + %o3] ASI_IMMU_DEMAP |
| 96 | membar #Sync |
| 97 | brnz,pt %o3, 1b |
| 98 | sub %o3, %o4, %o3 |
David S. Miller | 4da808c | 2006-01-31 18:33:00 -0800 | [diff] [blame^] | 99 | 2: sethi %hi(KERNBASE), %o3 |
| 100 | flush %o3 |
| 101 | retl |
| 102 | nop |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | |
| 104 | __spitfire_flush_tlb_mm_slow: |
| 105 | rdpr %pstate, %g1 |
| 106 | wrpr %g1, PSTATE_IE, %pstate |
| 107 | stxa %o0, [%o1] ASI_DMMU |
| 108 | stxa %g0, [%g3] ASI_DMMU_DEMAP |
| 109 | stxa %g0, [%g3] ASI_IMMU_DEMAP |
| 110 | flush %g6 |
| 111 | stxa %g2, [%o1] ASI_DMMU |
David S. Miller | 4da808c | 2006-01-31 18:33:00 -0800 | [diff] [blame^] | 112 | sethi %hi(KERNBASE), %o1 |
| 113 | flush %o1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | retl |
| 115 | wrpr %g1, 0, %pstate |
| 116 | |
| 117 | /* |
| 118 | * The following code flushes one page_size worth. |
| 119 | */ |
| 120 | #if (PAGE_SHIFT == 13) |
| 121 | #define ITAG_MASK 0xfe |
| 122 | #elif (PAGE_SHIFT == 16) |
| 123 | #define ITAG_MASK 0x7fe |
| 124 | #else |
| 125 | #error unsupported PAGE_SIZE |
| 126 | #endif |
Prasanna S Panchamukhi | 8300516 | 2005-09-06 15:19:31 -0700 | [diff] [blame] | 127 | .section .kprobes.text, "ax" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 128 | .align 32 |
| 129 | .globl __flush_icache_page |
| 130 | __flush_icache_page: /* %o0 = phys_page */ |
| 131 | membar #StoreStore |
| 132 | srlx %o0, PAGE_SHIFT, %o0 |
| 133 | sethi %uhi(PAGE_OFFSET), %g1 |
| 134 | sllx %o0, PAGE_SHIFT, %o0 |
| 135 | sethi %hi(PAGE_SIZE), %g2 |
| 136 | sllx %g1, 32, %g1 |
| 137 | add %o0, %g1, %o0 |
| 138 | 1: subcc %g2, 32, %g2 |
| 139 | bne,pt %icc, 1b |
| 140 | flush %o0 + %g2 |
| 141 | retl |
| 142 | nop |
| 143 | |
| 144 | #ifdef DCACHE_ALIASING_POSSIBLE |
| 145 | |
| 146 | #if (PAGE_SHIFT != 13) |
| 147 | #error only page shift of 13 is supported by dcache flush |
| 148 | #endif |
| 149 | |
| 150 | #define DTAG_MASK 0x3 |
| 151 | |
David S. Miller | c5bd50a | 2005-09-26 16:06:03 -0700 | [diff] [blame] | 152 | /* This routine is Spitfire specific so the hardcoded |
| 153 | * D-cache size and line-size are OK. |
| 154 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 155 | .align 64 |
| 156 | .globl __flush_dcache_page |
| 157 | __flush_dcache_page: /* %o0=kaddr, %o1=flush_icache */ |
| 158 | sethi %uhi(PAGE_OFFSET), %g1 |
| 159 | sllx %g1, 32, %g1 |
David S. Miller | c5bd50a | 2005-09-26 16:06:03 -0700 | [diff] [blame] | 160 | sub %o0, %g1, %o0 ! physical address |
| 161 | srlx %o0, 11, %o0 ! make D-cache TAG |
| 162 | sethi %hi(1 << 14), %o2 ! D-cache size |
| 163 | sub %o2, (1 << 5), %o2 ! D-cache line size |
| 164 | 1: ldxa [%o2] ASI_DCACHE_TAG, %o3 ! load D-cache TAG |
| 165 | andcc %o3, DTAG_MASK, %g0 ! Valid? |
| 166 | be,pn %xcc, 2f ! Nope, branch |
| 167 | andn %o3, DTAG_MASK, %o3 ! Clear valid bits |
| 168 | cmp %o3, %o0 ! TAG match? |
| 169 | bne,pt %xcc, 2f ! Nope, branch |
| 170 | nop |
| 171 | stxa %g0, [%o2] ASI_DCACHE_TAG ! Invalidate TAG |
| 172 | membar #Sync |
| 173 | 2: brnz,pt %o2, 1b |
| 174 | sub %o2, (1 << 5), %o2 ! D-cache line size |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | |
| 176 | /* The I-cache does not snoop local stores so we |
| 177 | * better flush that too when necessary. |
| 178 | */ |
| 179 | brnz,pt %o1, __flush_icache_page |
| 180 | sllx %o0, 11, %o0 |
| 181 | retl |
| 182 | nop |
| 183 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 184 | #endif /* DCACHE_ALIASING_POSSIBLE */ |
| 185 | |
David S. Miller | c5bd50a | 2005-09-26 16:06:03 -0700 | [diff] [blame] | 186 | .previous |
| 187 | |
David S. Miller | 2ef2777 | 2005-08-30 20:21:34 -0700 | [diff] [blame] | 188 | /* Cheetah specific versions, patched at boot time. */ |
David S. Miller | 4da808c | 2006-01-31 18:33:00 -0800 | [diff] [blame^] | 189 | __cheetah_flush_tlb_mm: /* 19 insns */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 190 | rdpr %pstate, %g7 |
| 191 | andn %g7, PSTATE_IE, %g2 |
| 192 | wrpr %g2, 0x0, %pstate |
| 193 | wrpr %g0, 1, %tl |
| 194 | mov PRIMARY_CONTEXT, %o2 |
| 195 | mov 0x40, %g3 |
| 196 | ldxa [%o2] ASI_DMMU, %g2 |
David S. Miller | 2ef2777 | 2005-08-30 20:21:34 -0700 | [diff] [blame] | 197 | srlx %g2, CTX_PGSZ1_NUC_SHIFT, %o1 |
| 198 | sllx %o1, CTX_PGSZ1_NUC_SHIFT, %o1 |
| 199 | or %o0, %o1, %o0 /* Preserve nucleus page size fields */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | stxa %o0, [%o2] ASI_DMMU |
| 201 | stxa %g0, [%g3] ASI_DMMU_DEMAP |
| 202 | stxa %g0, [%g3] ASI_IMMU_DEMAP |
| 203 | stxa %g2, [%o2] ASI_DMMU |
David S. Miller | 4da808c | 2006-01-31 18:33:00 -0800 | [diff] [blame^] | 204 | sethi %hi(KERNBASE), %o2 |
| 205 | flush %o2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 206 | wrpr %g0, 0, %tl |
| 207 | retl |
| 208 | wrpr %g7, 0x0, %pstate |
| 209 | |
David S. Miller | 4da808c | 2006-01-31 18:33:00 -0800 | [diff] [blame^] | 210 | __cheetah_flush_tlb_pending: /* 27 insns */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | /* %o0 = context, %o1 = nr, %o2 = vaddrs[] */ |
| 212 | rdpr %pstate, %g7 |
| 213 | sllx %o1, 3, %o1 |
| 214 | andn %g7, PSTATE_IE, %g2 |
| 215 | wrpr %g2, 0x0, %pstate |
| 216 | wrpr %g0, 1, %tl |
| 217 | mov PRIMARY_CONTEXT, %o4 |
| 218 | ldxa [%o4] ASI_DMMU, %g2 |
David S. Miller | 2ef2777 | 2005-08-30 20:21:34 -0700 | [diff] [blame] | 219 | srlx %g2, CTX_PGSZ1_NUC_SHIFT, %o3 |
| 220 | sllx %o3, CTX_PGSZ1_NUC_SHIFT, %o3 |
| 221 | or %o0, %o3, %o0 /* Preserve nucleus page size fields */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 222 | stxa %o0, [%o4] ASI_DMMU |
| 223 | 1: sub %o1, (1 << 3), %o1 |
| 224 | ldx [%o2 + %o1], %o3 |
| 225 | andcc %o3, 1, %g0 |
| 226 | be,pn %icc, 2f |
| 227 | andn %o3, 1, %o3 |
| 228 | stxa %g0, [%o3] ASI_IMMU_DEMAP |
| 229 | 2: stxa %g0, [%o3] ASI_DMMU_DEMAP |
David S. Miller | b445e26 | 2005-06-27 15:42:04 -0700 | [diff] [blame] | 230 | membar #Sync |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 231 | brnz,pt %o1, 1b |
David S. Miller | b445e26 | 2005-06-27 15:42:04 -0700 | [diff] [blame] | 232 | nop |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | stxa %g2, [%o4] ASI_DMMU |
David S. Miller | 4da808c | 2006-01-31 18:33:00 -0800 | [diff] [blame^] | 234 | sethi %hi(KERNBASE), %o4 |
| 235 | flush %o4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | wrpr %g0, 0, %tl |
| 237 | retl |
| 238 | wrpr %g7, 0x0, %pstate |
| 239 | |
| 240 | #ifdef DCACHE_ALIASING_POSSIBLE |
David S. Miller | c5bd50a | 2005-09-26 16:06:03 -0700 | [diff] [blame] | 241 | __cheetah_flush_dcache_page: /* 11 insns */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | sethi %uhi(PAGE_OFFSET), %g1 |
| 243 | sllx %g1, 32, %g1 |
| 244 | sub %o0, %g1, %o0 |
| 245 | sethi %hi(PAGE_SIZE), %o4 |
| 246 | 1: subcc %o4, (1 << 5), %o4 |
| 247 | stxa %g0, [%o0 + %o4] ASI_DCACHE_INVALIDATE |
| 248 | membar #Sync |
| 249 | bne,pt %icc, 1b |
| 250 | nop |
| 251 | retl /* I-cache flush never needed on Cheetah, see callers. */ |
| 252 | nop |
| 253 | #endif /* DCACHE_ALIASING_POSSIBLE */ |
| 254 | |
| 255 | cheetah_patch_one: |
| 256 | 1: lduw [%o1], %g1 |
| 257 | stw %g1, [%o0] |
| 258 | flush %o0 |
| 259 | subcc %o2, 1, %o2 |
| 260 | add %o1, 4, %o1 |
| 261 | bne,pt %icc, 1b |
| 262 | add %o0, 4, %o0 |
| 263 | retl |
| 264 | nop |
| 265 | |
| 266 | .globl cheetah_patch_cachetlbops |
| 267 | cheetah_patch_cachetlbops: |
| 268 | save %sp, -128, %sp |
| 269 | |
| 270 | sethi %hi(__flush_tlb_mm), %o0 |
| 271 | or %o0, %lo(__flush_tlb_mm), %o0 |
| 272 | sethi %hi(__cheetah_flush_tlb_mm), %o1 |
| 273 | or %o1, %lo(__cheetah_flush_tlb_mm), %o1 |
| 274 | call cheetah_patch_one |
David S. Miller | 4da808c | 2006-01-31 18:33:00 -0800 | [diff] [blame^] | 275 | mov 19, %o2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | |
| 277 | sethi %hi(__flush_tlb_pending), %o0 |
| 278 | or %o0, %lo(__flush_tlb_pending), %o0 |
| 279 | sethi %hi(__cheetah_flush_tlb_pending), %o1 |
| 280 | or %o1, %lo(__cheetah_flush_tlb_pending), %o1 |
| 281 | call cheetah_patch_one |
David S. Miller | 4da808c | 2006-01-31 18:33:00 -0800 | [diff] [blame^] | 282 | mov 27, %o2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 283 | |
| 284 | #ifdef DCACHE_ALIASING_POSSIBLE |
| 285 | sethi %hi(__flush_dcache_page), %o0 |
| 286 | or %o0, %lo(__flush_dcache_page), %o0 |
David S. Miller | c5bd50a | 2005-09-26 16:06:03 -0700 | [diff] [blame] | 287 | sethi %hi(__cheetah_flush_dcache_page), %o1 |
| 288 | or %o1, %lo(__cheetah_flush_dcache_page), %o1 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 289 | call cheetah_patch_one |
| 290 | mov 11, %o2 |
| 291 | #endif /* DCACHE_ALIASING_POSSIBLE */ |
| 292 | |
| 293 | ret |
| 294 | restore |
| 295 | |
| 296 | #ifdef CONFIG_SMP |
| 297 | /* These are all called by the slaves of a cross call, at |
| 298 | * trap level 1, with interrupts fully disabled. |
| 299 | * |
| 300 | * Register usage: |
| 301 | * %g5 mm->context (all tlb flushes) |
| 302 | * %g1 address arg 1 (tlb page and range flushes) |
| 303 | * %g7 address arg 2 (tlb range flush only) |
| 304 | * |
David S. Miller | 56fb4df | 2006-02-26 23:24:22 -0800 | [diff] [blame] | 305 | * %g6 scratch 1 |
| 306 | * %g2 scratch 2 |
| 307 | * %g3 scratch 3 |
| 308 | * %g4 scratch 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | */ |
| 310 | .align 32 |
| 311 | .globl xcall_flush_tlb_mm |
| 312 | xcall_flush_tlb_mm: |
| 313 | mov PRIMARY_CONTEXT, %g2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | ldxa [%g2] ASI_DMMU, %g3 |
David S. Miller | 2ef2777 | 2005-08-30 20:21:34 -0700 | [diff] [blame] | 315 | srlx %g3, CTX_PGSZ1_NUC_SHIFT, %g4 |
| 316 | sllx %g4, CTX_PGSZ1_NUC_SHIFT, %g4 |
| 317 | or %g5, %g4, %g5 /* Preserve nucleus page size fields */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | stxa %g5, [%g2] ASI_DMMU |
David S. Miller | 2ef2777 | 2005-08-30 20:21:34 -0700 | [diff] [blame] | 319 | mov 0x40, %g4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | stxa %g0, [%g4] ASI_DMMU_DEMAP |
| 321 | stxa %g0, [%g4] ASI_IMMU_DEMAP |
| 322 | stxa %g3, [%g2] ASI_DMMU |
| 323 | retry |
| 324 | |
| 325 | .globl xcall_flush_tlb_pending |
| 326 | xcall_flush_tlb_pending: |
| 327 | /* %g5=context, %g1=nr, %g7=vaddrs[] */ |
| 328 | sllx %g1, 3, %g1 |
| 329 | mov PRIMARY_CONTEXT, %g4 |
| 330 | ldxa [%g4] ASI_DMMU, %g2 |
David S. Miller | 2ef2777 | 2005-08-30 20:21:34 -0700 | [diff] [blame] | 331 | srlx %g2, CTX_PGSZ1_NUC_SHIFT, %g4 |
| 332 | sllx %g4, CTX_PGSZ1_NUC_SHIFT, %g4 |
| 333 | or %g5, %g4, %g5 |
| 334 | mov PRIMARY_CONTEXT, %g4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 335 | stxa %g5, [%g4] ASI_DMMU |
| 336 | 1: sub %g1, (1 << 3), %g1 |
| 337 | ldx [%g7 + %g1], %g5 |
| 338 | andcc %g5, 0x1, %g0 |
| 339 | be,pn %icc, 2f |
| 340 | |
| 341 | andn %g5, 0x1, %g5 |
| 342 | stxa %g0, [%g5] ASI_IMMU_DEMAP |
| 343 | 2: stxa %g0, [%g5] ASI_DMMU_DEMAP |
| 344 | membar #Sync |
| 345 | brnz,pt %g1, 1b |
| 346 | nop |
| 347 | stxa %g2, [%g4] ASI_DMMU |
| 348 | retry |
| 349 | |
| 350 | .globl xcall_flush_tlb_kernel_range |
| 351 | xcall_flush_tlb_kernel_range: |
| 352 | sethi %hi(PAGE_SIZE - 1), %g2 |
| 353 | or %g2, %lo(PAGE_SIZE - 1), %g2 |
| 354 | andn %g1, %g2, %g1 |
| 355 | andn %g7, %g2, %g7 |
| 356 | sub %g7, %g1, %g3 |
| 357 | add %g2, 1, %g2 |
| 358 | sub %g3, %g2, %g3 |
| 359 | or %g1, 0x20, %g1 ! Nucleus |
| 360 | 1: stxa %g0, [%g1 + %g3] ASI_DMMU_DEMAP |
| 361 | stxa %g0, [%g1 + %g3] ASI_IMMU_DEMAP |
| 362 | membar #Sync |
| 363 | brnz,pt %g3, 1b |
| 364 | sub %g3, %g2, %g3 |
| 365 | retry |
| 366 | nop |
| 367 | nop |
| 368 | |
| 369 | /* This runs in a very controlled environment, so we do |
| 370 | * not need to worry about BH races etc. |
| 371 | */ |
| 372 | .globl xcall_sync_tick |
| 373 | xcall_sync_tick: |
| 374 | rdpr %pstate, %g2 |
| 375 | wrpr %g2, PSTATE_IG | PSTATE_AG, %pstate |
| 376 | rdpr %pil, %g2 |
| 377 | wrpr %g0, 15, %pil |
| 378 | sethi %hi(109f), %g7 |
| 379 | b,pt %xcc, etrap_irq |
| 380 | 109: or %g7, %lo(109b), %g7 |
| 381 | call smp_synchronize_tick_client |
| 382 | nop |
| 383 | clr %l6 |
| 384 | b rtrap_xcall |
| 385 | ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %l1 |
| 386 | |
| 387 | /* NOTE: This is SPECIAL!! We do etrap/rtrap however |
| 388 | * we choose to deal with the "BH's run with |
| 389 | * %pil==15" problem (described in asm/pil.h) |
| 390 | * by just invoking rtrap directly past where |
| 391 | * BH's are checked for. |
| 392 | * |
| 393 | * We do it like this because we do not want %pil==15 |
| 394 | * lockups to prevent regs being reported. |
| 395 | */ |
| 396 | .globl xcall_report_regs |
| 397 | xcall_report_regs: |
| 398 | rdpr %pstate, %g2 |
| 399 | wrpr %g2, PSTATE_IG | PSTATE_AG, %pstate |
| 400 | rdpr %pil, %g2 |
| 401 | wrpr %g0, 15, %pil |
| 402 | sethi %hi(109f), %g7 |
| 403 | b,pt %xcc, etrap_irq |
| 404 | 109: or %g7, %lo(109b), %g7 |
| 405 | call __show_regs |
| 406 | add %sp, PTREGS_OFF, %o0 |
| 407 | clr %l6 |
| 408 | /* Has to be a non-v9 branch due to the large distance. */ |
| 409 | b rtrap_xcall |
| 410 | ldx [%sp + PTREGS_OFF + PT_V9_TSTATE], %l1 |
| 411 | |
| 412 | #ifdef DCACHE_ALIASING_POSSIBLE |
| 413 | .align 32 |
| 414 | .globl xcall_flush_dcache_page_cheetah |
| 415 | xcall_flush_dcache_page_cheetah: /* %g1 == physical page address */ |
| 416 | sethi %hi(PAGE_SIZE), %g3 |
| 417 | 1: subcc %g3, (1 << 5), %g3 |
| 418 | stxa %g0, [%g1 + %g3] ASI_DCACHE_INVALIDATE |
| 419 | membar #Sync |
| 420 | bne,pt %icc, 1b |
| 421 | nop |
| 422 | retry |
| 423 | nop |
| 424 | #endif /* DCACHE_ALIASING_POSSIBLE */ |
| 425 | |
| 426 | .globl xcall_flush_dcache_page_spitfire |
| 427 | xcall_flush_dcache_page_spitfire: /* %g1 == physical page address |
| 428 | %g7 == kernel page virtual address |
| 429 | %g5 == (page->mapping != NULL) */ |
| 430 | #ifdef DCACHE_ALIASING_POSSIBLE |
| 431 | srlx %g1, (13 - 2), %g1 ! Form tag comparitor |
| 432 | sethi %hi(L1DCACHE_SIZE), %g3 ! D$ size == 16K |
| 433 | sub %g3, (1 << 5), %g3 ! D$ linesize == 32 |
| 434 | 1: ldxa [%g3] ASI_DCACHE_TAG, %g2 |
| 435 | andcc %g2, 0x3, %g0 |
| 436 | be,pn %xcc, 2f |
| 437 | andn %g2, 0x3, %g2 |
| 438 | cmp %g2, %g1 |
| 439 | |
| 440 | bne,pt %xcc, 2f |
| 441 | nop |
| 442 | stxa %g0, [%g3] ASI_DCACHE_TAG |
| 443 | membar #Sync |
| 444 | 2: cmp %g3, 0 |
| 445 | bne,pt %xcc, 1b |
| 446 | sub %g3, (1 << 5), %g3 |
| 447 | |
| 448 | brz,pn %g5, 2f |
| 449 | #endif /* DCACHE_ALIASING_POSSIBLE */ |
| 450 | sethi %hi(PAGE_SIZE), %g3 |
| 451 | |
| 452 | 1: flush %g7 |
| 453 | subcc %g3, (1 << 5), %g3 |
| 454 | bne,pt %icc, 1b |
| 455 | add %g7, (1 << 5), %g7 |
| 456 | |
| 457 | 2: retry |
| 458 | nop |
| 459 | nop |
| 460 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 461 | /* These just get rescheduled to PIL vectors. */ |
| 462 | .globl xcall_call_function |
| 463 | xcall_call_function: |
| 464 | wr %g0, (1 << PIL_SMP_CALL_FUNC), %set_softint |
| 465 | retry |
| 466 | |
| 467 | .globl xcall_receive_signal |
| 468 | xcall_receive_signal: |
| 469 | wr %g0, (1 << PIL_SMP_RECEIVE_SIGNAL), %set_softint |
| 470 | retry |
| 471 | |
| 472 | .globl xcall_capture |
| 473 | xcall_capture: |
| 474 | wr %g0, (1 << PIL_SMP_CAPTURE), %set_softint |
| 475 | retry |
| 476 | |
| 477 | #endif /* CONFIG_SMP */ |