Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* $Id: sun4c.c,v 1.212 2001/12/21 04:56:15 davem Exp $ |
| 2 | * sun4c.c: Doing in software what should be done in hardware. |
| 3 | * |
| 4 | * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) |
| 5 | * Copyright (C) 1996 Eddie C. Dost (ecd@skynet.be) |
| 6 | * Copyright (C) 1996 Andrew Tridgell (Andrew.Tridgell@anu.edu.au) |
| 7 | * Copyright (C) 1997-2000 Anton Blanchard (anton@samba.org) |
| 8 | * Copyright (C) 1998 Jakub Jelinek (jj@sunsite.mff.cuni.cz) |
| 9 | */ |
| 10 | |
| 11 | #define NR_TASK_BUCKETS 512 |
| 12 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/kernel.h> |
| 14 | #include <linux/mm.h> |
| 15 | #include <linux/init.h> |
| 16 | #include <linux/bootmem.h> |
| 17 | #include <linux/highmem.h> |
| 18 | #include <linux/fs.h> |
| 19 | #include <linux/seq_file.h> |
| 20 | |
| 21 | #include <asm/scatterlist.h> |
| 22 | #include <asm/page.h> |
| 23 | #include <asm/pgalloc.h> |
| 24 | #include <asm/pgtable.h> |
| 25 | #include <asm/vaddrs.h> |
| 26 | #include <asm/idprom.h> |
| 27 | #include <asm/machines.h> |
| 28 | #include <asm/memreg.h> |
| 29 | #include <asm/processor.h> |
| 30 | #include <asm/auxio.h> |
| 31 | #include <asm/io.h> |
| 32 | #include <asm/oplib.h> |
| 33 | #include <asm/openprom.h> |
| 34 | #include <asm/mmu_context.h> |
| 35 | #include <asm/sun4paddr.h> |
| 36 | #include <asm/highmem.h> |
| 37 | #include <asm/btfixup.h> |
| 38 | #include <asm/cacheflush.h> |
| 39 | #include <asm/tlbflush.h> |
| 40 | |
| 41 | /* Because of our dynamic kernel TLB miss strategy, and how |
| 42 | * our DVMA mapping allocation works, you _MUST_: |
| 43 | * |
| 44 | * 1) Disable interrupts _and_ not touch any dynamic kernel |
| 45 | * memory while messing with kernel MMU state. By |
| 46 | * dynamic memory I mean any object which is not in |
| 47 | * the kernel image itself or a thread_union (both of |
| 48 | * which are locked into the MMU). |
| 49 | * 2) Disable interrupts while messing with user MMU state. |
| 50 | */ |
| 51 | |
| 52 | extern int num_segmaps, num_contexts; |
| 53 | |
| 54 | extern unsigned long page_kernel; |
| 55 | |
| 56 | #ifdef CONFIG_SUN4 |
| 57 | #define SUN4C_VAC_SIZE sun4c_vacinfo.num_bytes |
| 58 | #else |
| 59 | /* That's it, we prom_halt() on sun4c if the cache size is something other than 65536. |
| 60 | * So let's save some cycles and just use that everywhere except for that bootup |
| 61 | * sanity check. |
| 62 | */ |
| 63 | #define SUN4C_VAC_SIZE 65536 |
| 64 | #endif |
| 65 | |
| 66 | #define SUN4C_KERNEL_BUCKETS 32 |
| 67 | |
| 68 | /* Flushing the cache. */ |
| 69 | struct sun4c_vac_props sun4c_vacinfo; |
| 70 | unsigned long sun4c_kernel_faults; |
| 71 | |
| 72 | /* Invalidate every sun4c cache line tag. */ |
| 73 | static void __init sun4c_flush_all(void) |
| 74 | { |
| 75 | unsigned long begin, end; |
| 76 | |
| 77 | if (sun4c_vacinfo.on) |
| 78 | panic("SUN4C: AIEEE, trying to invalidate vac while it is on."); |
| 79 | |
| 80 | /* Clear 'valid' bit in all cache line tags */ |
| 81 | begin = AC_CACHETAGS; |
| 82 | end = (AC_CACHETAGS + SUN4C_VAC_SIZE); |
| 83 | while (begin < end) { |
| 84 | __asm__ __volatile__("sta %%g0, [%0] %1\n\t" : : |
| 85 | "r" (begin), "i" (ASI_CONTROL)); |
| 86 | begin += sun4c_vacinfo.linesize; |
| 87 | } |
| 88 | } |
| 89 | |
| 90 | static void sun4c_flush_context_hw(void) |
| 91 | { |
| 92 | unsigned long end = SUN4C_VAC_SIZE; |
| 93 | |
| 94 | __asm__ __volatile__( |
| 95 | "1: addcc %0, -4096, %0\n\t" |
| 96 | " bne 1b\n\t" |
| 97 | " sta %%g0, [%0] %2" |
| 98 | : "=&r" (end) |
| 99 | : "0" (end), "i" (ASI_HWFLUSHCONTEXT) |
| 100 | : "cc"); |
| 101 | } |
| 102 | |
| 103 | /* Must be called minimally with IRQs disabled. */ |
| 104 | static void sun4c_flush_segment_hw(unsigned long addr) |
| 105 | { |
| 106 | if (sun4c_get_segmap(addr) != invalid_segment) { |
| 107 | unsigned long vac_size = SUN4C_VAC_SIZE; |
| 108 | |
| 109 | __asm__ __volatile__( |
| 110 | "1: addcc %0, -4096, %0\n\t" |
| 111 | " bne 1b\n\t" |
| 112 | " sta %%g0, [%2 + %0] %3" |
| 113 | : "=&r" (vac_size) |
| 114 | : "0" (vac_size), "r" (addr), "i" (ASI_HWFLUSHSEG) |
| 115 | : "cc"); |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | /* File local boot time fixups. */ |
| 120 | BTFIXUPDEF_CALL(void, sun4c_flush_page, unsigned long) |
| 121 | BTFIXUPDEF_CALL(void, sun4c_flush_segment, unsigned long) |
| 122 | BTFIXUPDEF_CALL(void, sun4c_flush_context, void) |
| 123 | |
| 124 | #define sun4c_flush_page(addr) BTFIXUP_CALL(sun4c_flush_page)(addr) |
| 125 | #define sun4c_flush_segment(addr) BTFIXUP_CALL(sun4c_flush_segment)(addr) |
| 126 | #define sun4c_flush_context() BTFIXUP_CALL(sun4c_flush_context)() |
| 127 | |
| 128 | /* Must be called minimally with interrupts disabled. */ |
| 129 | static void sun4c_flush_page_hw(unsigned long addr) |
| 130 | { |
| 131 | addr &= PAGE_MASK; |
| 132 | if ((int)sun4c_get_pte(addr) < 0) |
| 133 | __asm__ __volatile__("sta %%g0, [%0] %1" |
| 134 | : : "r" (addr), "i" (ASI_HWFLUSHPAGE)); |
| 135 | } |
| 136 | |
| 137 | /* Don't inline the software version as it eats too many cache lines if expanded. */ |
| 138 | static void sun4c_flush_context_sw(void) |
| 139 | { |
| 140 | unsigned long nbytes = SUN4C_VAC_SIZE; |
| 141 | unsigned long lsize = sun4c_vacinfo.linesize; |
| 142 | |
| 143 | __asm__ __volatile__( |
| 144 | "add %2, %2, %%g1\n\t" |
| 145 | "add %2, %%g1, %%g2\n\t" |
| 146 | "add %2, %%g2, %%g3\n\t" |
| 147 | "add %2, %%g3, %%g4\n\t" |
| 148 | "add %2, %%g4, %%g5\n\t" |
| 149 | "add %2, %%g5, %%o4\n\t" |
| 150 | "add %2, %%o4, %%o5\n" |
| 151 | "1:\n\t" |
| 152 | "subcc %0, %%o5, %0\n\t" |
| 153 | "sta %%g0, [%0] %3\n\t" |
| 154 | "sta %%g0, [%0 + %2] %3\n\t" |
| 155 | "sta %%g0, [%0 + %%g1] %3\n\t" |
| 156 | "sta %%g0, [%0 + %%g2] %3\n\t" |
| 157 | "sta %%g0, [%0 + %%g3] %3\n\t" |
| 158 | "sta %%g0, [%0 + %%g4] %3\n\t" |
| 159 | "sta %%g0, [%0 + %%g5] %3\n\t" |
| 160 | "bg 1b\n\t" |
| 161 | " sta %%g0, [%1 + %%o4] %3\n" |
| 162 | : "=&r" (nbytes) |
| 163 | : "0" (nbytes), "r" (lsize), "i" (ASI_FLUSHCTX) |
| 164 | : "g1", "g2", "g3", "g4", "g5", "o4", "o5", "cc"); |
| 165 | } |
| 166 | |
| 167 | /* Don't inline the software version as it eats too many cache lines if expanded. */ |
| 168 | static void sun4c_flush_segment_sw(unsigned long addr) |
| 169 | { |
| 170 | if (sun4c_get_segmap(addr) != invalid_segment) { |
| 171 | unsigned long nbytes = SUN4C_VAC_SIZE; |
| 172 | unsigned long lsize = sun4c_vacinfo.linesize; |
| 173 | |
| 174 | __asm__ __volatile__( |
| 175 | "add %2, %2, %%g1\n\t" |
| 176 | "add %2, %%g1, %%g2\n\t" |
| 177 | "add %2, %%g2, %%g3\n\t" |
| 178 | "add %2, %%g3, %%g4\n\t" |
| 179 | "add %2, %%g4, %%g5\n\t" |
| 180 | "add %2, %%g5, %%o4\n\t" |
| 181 | "add %2, %%o4, %%o5\n" |
| 182 | "1:\n\t" |
| 183 | "subcc %1, %%o5, %1\n\t" |
| 184 | "sta %%g0, [%0] %6\n\t" |
| 185 | "sta %%g0, [%0 + %2] %6\n\t" |
| 186 | "sta %%g0, [%0 + %%g1] %6\n\t" |
| 187 | "sta %%g0, [%0 + %%g2] %6\n\t" |
| 188 | "sta %%g0, [%0 + %%g3] %6\n\t" |
| 189 | "sta %%g0, [%0 + %%g4] %6\n\t" |
| 190 | "sta %%g0, [%0 + %%g5] %6\n\t" |
| 191 | "sta %%g0, [%0 + %%o4] %6\n\t" |
| 192 | "bg 1b\n\t" |
| 193 | " add %0, %%o5, %0\n" |
| 194 | : "=&r" (addr), "=&r" (nbytes), "=&r" (lsize) |
| 195 | : "0" (addr), "1" (nbytes), "2" (lsize), |
| 196 | "i" (ASI_FLUSHSEG) |
| 197 | : "g1", "g2", "g3", "g4", "g5", "o4", "o5", "cc"); |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | /* Don't inline the software version as it eats too many cache lines if expanded. */ |
| 202 | static void sun4c_flush_page_sw(unsigned long addr) |
| 203 | { |
| 204 | addr &= PAGE_MASK; |
| 205 | if ((sun4c_get_pte(addr) & (_SUN4C_PAGE_NOCACHE | _SUN4C_PAGE_VALID)) == |
| 206 | _SUN4C_PAGE_VALID) { |
| 207 | unsigned long left = PAGE_SIZE; |
| 208 | unsigned long lsize = sun4c_vacinfo.linesize; |
| 209 | |
| 210 | __asm__ __volatile__( |
| 211 | "add %2, %2, %%g1\n\t" |
| 212 | "add %2, %%g1, %%g2\n\t" |
| 213 | "add %2, %%g2, %%g3\n\t" |
| 214 | "add %2, %%g3, %%g4\n\t" |
| 215 | "add %2, %%g4, %%g5\n\t" |
| 216 | "add %2, %%g5, %%o4\n\t" |
| 217 | "add %2, %%o4, %%o5\n" |
| 218 | "1:\n\t" |
| 219 | "subcc %1, %%o5, %1\n\t" |
| 220 | "sta %%g0, [%0] %6\n\t" |
| 221 | "sta %%g0, [%0 + %2] %6\n\t" |
| 222 | "sta %%g0, [%0 + %%g1] %6\n\t" |
| 223 | "sta %%g0, [%0 + %%g2] %6\n\t" |
| 224 | "sta %%g0, [%0 + %%g3] %6\n\t" |
| 225 | "sta %%g0, [%0 + %%g4] %6\n\t" |
| 226 | "sta %%g0, [%0 + %%g5] %6\n\t" |
| 227 | "sta %%g0, [%0 + %%o4] %6\n\t" |
| 228 | "bg 1b\n\t" |
| 229 | " add %0, %%o5, %0\n" |
| 230 | : "=&r" (addr), "=&r" (left), "=&r" (lsize) |
| 231 | : "0" (addr), "1" (left), "2" (lsize), |
| 232 | "i" (ASI_FLUSHPG) |
| 233 | : "g1", "g2", "g3", "g4", "g5", "o4", "o5", "cc"); |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | /* The sun4c's do have an on chip store buffer. And the way you |
| 238 | * clear them out isn't so obvious. The only way I can think of |
| 239 | * to accomplish this is to read the current context register, |
| 240 | * store the same value there, then read an external hardware |
| 241 | * register. |
| 242 | */ |
| 243 | void sun4c_complete_all_stores(void) |
| 244 | { |
| 245 | volatile int _unused; |
| 246 | |
| 247 | _unused = sun4c_get_context(); |
| 248 | sun4c_set_context(_unused); |
| 249 | #ifdef CONFIG_SUN_AUXIO |
| 250 | _unused = get_auxio(); |
| 251 | #endif |
| 252 | } |
| 253 | |
| 254 | /* Bootup utility functions. */ |
| 255 | static inline void sun4c_init_clean_segmap(unsigned char pseg) |
| 256 | { |
| 257 | unsigned long vaddr; |
| 258 | |
| 259 | sun4c_put_segmap(0, pseg); |
| 260 | for (vaddr = 0; vaddr < SUN4C_REAL_PGDIR_SIZE; vaddr += PAGE_SIZE) |
| 261 | sun4c_put_pte(vaddr, 0); |
| 262 | sun4c_put_segmap(0, invalid_segment); |
| 263 | } |
| 264 | |
| 265 | static inline void sun4c_init_clean_mmu(unsigned long kernel_end) |
| 266 | { |
| 267 | unsigned long vaddr; |
| 268 | unsigned char savectx, ctx; |
| 269 | |
| 270 | savectx = sun4c_get_context(); |
| 271 | kernel_end = SUN4C_REAL_PGDIR_ALIGN(kernel_end); |
| 272 | for (ctx = 0; ctx < num_contexts; ctx++) { |
| 273 | sun4c_set_context(ctx); |
| 274 | for (vaddr = 0; vaddr < 0x20000000; vaddr += SUN4C_REAL_PGDIR_SIZE) |
| 275 | sun4c_put_segmap(vaddr, invalid_segment); |
| 276 | for (vaddr = 0xe0000000; vaddr < KERNBASE; vaddr += SUN4C_REAL_PGDIR_SIZE) |
| 277 | sun4c_put_segmap(vaddr, invalid_segment); |
| 278 | for (vaddr = kernel_end; vaddr < KADB_DEBUGGER_BEGVM; vaddr += SUN4C_REAL_PGDIR_SIZE) |
| 279 | sun4c_put_segmap(vaddr, invalid_segment); |
| 280 | for (vaddr = LINUX_OPPROM_ENDVM; vaddr; vaddr += SUN4C_REAL_PGDIR_SIZE) |
| 281 | sun4c_put_segmap(vaddr, invalid_segment); |
| 282 | } |
| 283 | sun4c_set_context(savectx); |
| 284 | } |
| 285 | |
| 286 | void __init sun4c_probe_vac(void) |
| 287 | { |
| 288 | sun4c_disable_vac(); |
| 289 | |
| 290 | if (ARCH_SUN4) { |
| 291 | switch (idprom->id_machtype) { |
| 292 | |
| 293 | case (SM_SUN4|SM_4_110): |
| 294 | sun4c_vacinfo.type = VAC_NONE; |
| 295 | sun4c_vacinfo.num_bytes = 0; |
| 296 | sun4c_vacinfo.linesize = 0; |
| 297 | sun4c_vacinfo.do_hwflushes = 0; |
| 298 | prom_printf("No VAC. Get some bucks and buy a real computer."); |
| 299 | prom_halt(); |
| 300 | break; |
| 301 | |
| 302 | case (SM_SUN4|SM_4_260): |
| 303 | sun4c_vacinfo.type = VAC_WRITE_BACK; |
| 304 | sun4c_vacinfo.num_bytes = 128 * 1024; |
| 305 | sun4c_vacinfo.linesize = 16; |
| 306 | sun4c_vacinfo.do_hwflushes = 0; |
| 307 | break; |
| 308 | |
| 309 | case (SM_SUN4|SM_4_330): |
| 310 | sun4c_vacinfo.type = VAC_WRITE_THROUGH; |
| 311 | sun4c_vacinfo.num_bytes = 128 * 1024; |
| 312 | sun4c_vacinfo.linesize = 16; |
| 313 | sun4c_vacinfo.do_hwflushes = 0; |
| 314 | break; |
| 315 | |
| 316 | case (SM_SUN4|SM_4_470): |
| 317 | sun4c_vacinfo.type = VAC_WRITE_BACK; |
| 318 | sun4c_vacinfo.num_bytes = 128 * 1024; |
| 319 | sun4c_vacinfo.linesize = 32; |
| 320 | sun4c_vacinfo.do_hwflushes = 0; |
| 321 | break; |
| 322 | |
| 323 | default: |
| 324 | prom_printf("Cannot initialize VAC - weird sun4 model idprom->id_machtype = %d", idprom->id_machtype); |
| 325 | prom_halt(); |
| 326 | }; |
| 327 | } else { |
| 328 | sun4c_vacinfo.type = VAC_WRITE_THROUGH; |
| 329 | |
| 330 | if ((idprom->id_machtype == (SM_SUN4C | SM_4C_SS1)) || |
| 331 | (idprom->id_machtype == (SM_SUN4C | SM_4C_SS1PLUS))) { |
| 332 | /* PROM on SS1 lacks this info, to be super safe we |
| 333 | * hard code it here since this arch is cast in stone. |
| 334 | */ |
| 335 | sun4c_vacinfo.num_bytes = 65536; |
| 336 | sun4c_vacinfo.linesize = 16; |
| 337 | } else { |
| 338 | sun4c_vacinfo.num_bytes = |
| 339 | prom_getintdefault(prom_root_node, "vac-size", 65536); |
| 340 | sun4c_vacinfo.linesize = |
| 341 | prom_getintdefault(prom_root_node, "vac-linesize", 16); |
| 342 | } |
| 343 | sun4c_vacinfo.do_hwflushes = |
| 344 | prom_getintdefault(prom_root_node, "vac-hwflush", 0); |
| 345 | |
| 346 | if (sun4c_vacinfo.do_hwflushes == 0) |
| 347 | sun4c_vacinfo.do_hwflushes = |
| 348 | prom_getintdefault(prom_root_node, "vac_hwflush", 0); |
| 349 | |
| 350 | if (sun4c_vacinfo.num_bytes != 65536) { |
| 351 | prom_printf("WEIRD Sun4C VAC cache size, " |
| 352 | "tell sparclinux@vger.kernel.org"); |
| 353 | prom_halt(); |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | sun4c_vacinfo.num_lines = |
| 358 | (sun4c_vacinfo.num_bytes / sun4c_vacinfo.linesize); |
| 359 | switch (sun4c_vacinfo.linesize) { |
| 360 | case 16: |
| 361 | sun4c_vacinfo.log2lsize = 4; |
| 362 | break; |
| 363 | case 32: |
| 364 | sun4c_vacinfo.log2lsize = 5; |
| 365 | break; |
| 366 | default: |
| 367 | prom_printf("probe_vac: Didn't expect vac-linesize of %d, halting\n", |
| 368 | sun4c_vacinfo.linesize); |
| 369 | prom_halt(); |
| 370 | }; |
| 371 | |
| 372 | sun4c_flush_all(); |
| 373 | sun4c_enable_vac(); |
| 374 | } |
| 375 | |
| 376 | /* Patch instructions for the low level kernel fault handler. */ |
| 377 | extern unsigned long invalid_segment_patch1, invalid_segment_patch1_ff; |
| 378 | extern unsigned long invalid_segment_patch2, invalid_segment_patch2_ff; |
| 379 | extern unsigned long invalid_segment_patch1_1ff, invalid_segment_patch2_1ff; |
| 380 | extern unsigned long num_context_patch1, num_context_patch1_16; |
| 381 | extern unsigned long num_context_patch2_16; |
| 382 | extern unsigned long vac_linesize_patch, vac_linesize_patch_32; |
| 383 | extern unsigned long vac_hwflush_patch1, vac_hwflush_patch1_on; |
| 384 | extern unsigned long vac_hwflush_patch2, vac_hwflush_patch2_on; |
| 385 | |
| 386 | #define PATCH_INSN(src, dst) do { \ |
| 387 | daddr = &(dst); \ |
| 388 | iaddr = &(src); \ |
| 389 | *daddr = *iaddr; \ |
| 390 | } while (0) |
| 391 | |
| 392 | static void __init patch_kernel_fault_handler(void) |
| 393 | { |
| 394 | unsigned long *iaddr, *daddr; |
| 395 | |
| 396 | switch (num_segmaps) { |
| 397 | case 128: |
| 398 | /* Default, nothing to do. */ |
| 399 | break; |
| 400 | case 256: |
| 401 | PATCH_INSN(invalid_segment_patch1_ff, |
| 402 | invalid_segment_patch1); |
| 403 | PATCH_INSN(invalid_segment_patch2_ff, |
| 404 | invalid_segment_patch2); |
| 405 | break; |
| 406 | case 512: |
| 407 | PATCH_INSN(invalid_segment_patch1_1ff, |
| 408 | invalid_segment_patch1); |
| 409 | PATCH_INSN(invalid_segment_patch2_1ff, |
| 410 | invalid_segment_patch2); |
| 411 | break; |
| 412 | default: |
| 413 | prom_printf("Unhandled number of segmaps: %d\n", |
| 414 | num_segmaps); |
| 415 | prom_halt(); |
| 416 | }; |
| 417 | switch (num_contexts) { |
| 418 | case 8: |
| 419 | /* Default, nothing to do. */ |
| 420 | break; |
| 421 | case 16: |
| 422 | PATCH_INSN(num_context_patch1_16, |
| 423 | num_context_patch1); |
| 424 | break; |
| 425 | default: |
| 426 | prom_printf("Unhandled number of contexts: %d\n", |
| 427 | num_contexts); |
| 428 | prom_halt(); |
| 429 | }; |
| 430 | |
| 431 | if (sun4c_vacinfo.do_hwflushes != 0) { |
| 432 | PATCH_INSN(vac_hwflush_patch1_on, vac_hwflush_patch1); |
| 433 | PATCH_INSN(vac_hwflush_patch2_on, vac_hwflush_patch2); |
| 434 | } else { |
| 435 | switch (sun4c_vacinfo.linesize) { |
| 436 | case 16: |
| 437 | /* Default, nothing to do. */ |
| 438 | break; |
| 439 | case 32: |
| 440 | PATCH_INSN(vac_linesize_patch_32, vac_linesize_patch); |
| 441 | break; |
| 442 | default: |
| 443 | prom_printf("Impossible VAC linesize %d, halting...\n", |
| 444 | sun4c_vacinfo.linesize); |
| 445 | prom_halt(); |
| 446 | }; |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | static void __init sun4c_probe_mmu(void) |
| 451 | { |
| 452 | if (ARCH_SUN4) { |
| 453 | switch (idprom->id_machtype) { |
| 454 | case (SM_SUN4|SM_4_110): |
| 455 | prom_printf("No support for 4100 yet\n"); |
| 456 | prom_halt(); |
| 457 | num_segmaps = 256; |
| 458 | num_contexts = 8; |
| 459 | break; |
| 460 | |
| 461 | case (SM_SUN4|SM_4_260): |
| 462 | /* should be 512 segmaps. when it get fixed */ |
| 463 | num_segmaps = 256; |
| 464 | num_contexts = 16; |
| 465 | break; |
| 466 | |
| 467 | case (SM_SUN4|SM_4_330): |
| 468 | num_segmaps = 256; |
| 469 | num_contexts = 16; |
| 470 | break; |
| 471 | |
| 472 | case (SM_SUN4|SM_4_470): |
| 473 | /* should be 1024 segmaps. when it get fixed */ |
| 474 | num_segmaps = 256; |
| 475 | num_contexts = 64; |
| 476 | break; |
| 477 | default: |
| 478 | prom_printf("Invalid SUN4 model\n"); |
| 479 | prom_halt(); |
| 480 | }; |
| 481 | } else { |
| 482 | if ((idprom->id_machtype == (SM_SUN4C | SM_4C_SS1)) || |
| 483 | (idprom->id_machtype == (SM_SUN4C | SM_4C_SS1PLUS))) { |
| 484 | /* Hardcode these just to be safe, PROM on SS1 does |
| 485 | * not have this info available in the root node. |
| 486 | */ |
| 487 | num_segmaps = 128; |
| 488 | num_contexts = 8; |
| 489 | } else { |
| 490 | num_segmaps = |
| 491 | prom_getintdefault(prom_root_node, "mmu-npmg", 128); |
| 492 | num_contexts = |
| 493 | prom_getintdefault(prom_root_node, "mmu-nctx", 0x8); |
| 494 | } |
| 495 | } |
| 496 | patch_kernel_fault_handler(); |
| 497 | } |
| 498 | |
Al Viro | a329729 | 2005-12-06 05:56:39 -0500 | [diff] [blame] | 499 | volatile unsigned long __iomem *sun4c_memerr_reg = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 500 | |
| 501 | void __init sun4c_probe_memerr_reg(void) |
| 502 | { |
| 503 | int node; |
| 504 | struct linux_prom_registers regs[1]; |
| 505 | |
| 506 | if (ARCH_SUN4) { |
| 507 | sun4c_memerr_reg = ioremap(sun4_memreg_physaddr, PAGE_SIZE); |
| 508 | } else { |
| 509 | node = prom_getchild(prom_root_node); |
| 510 | node = prom_searchsiblings(prom_root_node, "memory-error"); |
| 511 | if (!node) |
| 512 | return; |
| 513 | if (prom_getproperty(node, "reg", (char *)regs, sizeof(regs)) <= 0) |
| 514 | return; |
| 515 | /* hmm I think regs[0].which_io is zero here anyways */ |
| 516 | sun4c_memerr_reg = ioremap(regs[0].phys_addr, regs[0].reg_size); |
| 517 | } |
| 518 | } |
| 519 | |
| 520 | static inline void sun4c_init_ss2_cache_bug(void) |
| 521 | { |
| 522 | extern unsigned long start; |
| 523 | |
| 524 | if ((idprom->id_machtype == (SM_SUN4C | SM_4C_SS2)) || |
| 525 | (idprom->id_machtype == (SM_SUN4C | SM_4C_IPX)) || |
| 526 | (idprom->id_machtype == (SM_SUN4 | SM_4_330)) || |
| 527 | (idprom->id_machtype == (SM_SUN4C | SM_4C_ELC))) { |
| 528 | /* Whee.. */ |
| 529 | printk("SS2 cache bug detected, uncaching trap table page\n"); |
| 530 | sun4c_flush_page((unsigned int) &start); |
| 531 | sun4c_put_pte(((unsigned long) &start), |
| 532 | (sun4c_get_pte((unsigned long) &start) | _SUN4C_PAGE_NOCACHE)); |
| 533 | } |
| 534 | } |
| 535 | |
| 536 | /* Addr is always aligned on a page boundary for us already. */ |
| 537 | static int sun4c_map_dma_area(dma_addr_t *pba, unsigned long va, |
| 538 | unsigned long addr, int len) |
| 539 | { |
| 540 | unsigned long page, end; |
| 541 | |
| 542 | *pba = addr; |
| 543 | |
| 544 | end = PAGE_ALIGN((addr + len)); |
| 545 | while (addr < end) { |
| 546 | page = va; |
| 547 | sun4c_flush_page(page); |
| 548 | page -= PAGE_OFFSET; |
| 549 | page >>= PAGE_SHIFT; |
| 550 | page |= (_SUN4C_PAGE_VALID | _SUN4C_PAGE_DIRTY | |
| 551 | _SUN4C_PAGE_NOCACHE | _SUN4C_PAGE_PRIV); |
| 552 | sun4c_put_pte(addr, page); |
| 553 | addr += PAGE_SIZE; |
| 554 | va += PAGE_SIZE; |
| 555 | } |
| 556 | |
| 557 | return 0; |
| 558 | } |
| 559 | |
| 560 | static struct page *sun4c_translate_dvma(unsigned long busa) |
| 561 | { |
| 562 | /* Fortunately for us, bus_addr == uncached_virt in sun4c. */ |
| 563 | unsigned long pte = sun4c_get_pte(busa); |
| 564 | return pfn_to_page(pte & SUN4C_PFN_MASK); |
| 565 | } |
| 566 | |
| 567 | static void sun4c_unmap_dma_area(unsigned long busa, int len) |
| 568 | { |
| 569 | /* Fortunately for us, bus_addr == uncached_virt in sun4c. */ |
| 570 | /* XXX Implement this */ |
| 571 | } |
| 572 | |
| 573 | /* TLB management. */ |
| 574 | |
| 575 | /* Don't change this struct without changing entry.S. This is used |
| 576 | * in the in-window kernel fault handler, and you don't want to mess |
| 577 | * with that. (See sun4c_fault in entry.S). |
| 578 | */ |
| 579 | struct sun4c_mmu_entry { |
| 580 | struct sun4c_mmu_entry *next; |
| 581 | struct sun4c_mmu_entry *prev; |
| 582 | unsigned long vaddr; |
| 583 | unsigned char pseg; |
| 584 | unsigned char locked; |
| 585 | |
| 586 | /* For user mappings only, and completely hidden from kernel |
| 587 | * TLB miss code. |
| 588 | */ |
| 589 | unsigned char ctx; |
| 590 | struct sun4c_mmu_entry *lru_next; |
| 591 | struct sun4c_mmu_entry *lru_prev; |
| 592 | }; |
| 593 | |
| 594 | static struct sun4c_mmu_entry mmu_entry_pool[SUN4C_MAX_SEGMAPS]; |
| 595 | |
| 596 | static void __init sun4c_init_mmu_entry_pool(void) |
| 597 | { |
| 598 | int i; |
| 599 | |
| 600 | for (i=0; i < SUN4C_MAX_SEGMAPS; i++) { |
| 601 | mmu_entry_pool[i].pseg = i; |
| 602 | mmu_entry_pool[i].next = NULL; |
| 603 | mmu_entry_pool[i].prev = NULL; |
| 604 | mmu_entry_pool[i].vaddr = 0; |
| 605 | mmu_entry_pool[i].locked = 0; |
| 606 | mmu_entry_pool[i].ctx = 0; |
| 607 | mmu_entry_pool[i].lru_next = NULL; |
| 608 | mmu_entry_pool[i].lru_prev = NULL; |
| 609 | } |
| 610 | mmu_entry_pool[invalid_segment].locked = 1; |
| 611 | } |
| 612 | |
| 613 | static inline void fix_permissions(unsigned long vaddr, unsigned long bits_on, |
| 614 | unsigned long bits_off) |
| 615 | { |
| 616 | unsigned long start, end; |
| 617 | |
| 618 | end = vaddr + SUN4C_REAL_PGDIR_SIZE; |
| 619 | for (start = vaddr; start < end; start += PAGE_SIZE) |
| 620 | if (sun4c_get_pte(start) & _SUN4C_PAGE_VALID) |
| 621 | sun4c_put_pte(start, (sun4c_get_pte(start) | bits_on) & |
| 622 | ~bits_off); |
| 623 | } |
| 624 | |
| 625 | static inline void sun4c_init_map_kernelprom(unsigned long kernel_end) |
| 626 | { |
| 627 | unsigned long vaddr; |
| 628 | unsigned char pseg, ctx; |
| 629 | #ifdef CONFIG_SUN4 |
| 630 | /* sun4/110 and 260 have no kadb. */ |
| 631 | if ((idprom->id_machtype != (SM_SUN4 | SM_4_260)) && |
| 632 | (idprom->id_machtype != (SM_SUN4 | SM_4_110))) { |
| 633 | #endif |
| 634 | for (vaddr = KADB_DEBUGGER_BEGVM; |
| 635 | vaddr < LINUX_OPPROM_ENDVM; |
| 636 | vaddr += SUN4C_REAL_PGDIR_SIZE) { |
| 637 | pseg = sun4c_get_segmap(vaddr); |
| 638 | if (pseg != invalid_segment) { |
| 639 | mmu_entry_pool[pseg].locked = 1; |
| 640 | for (ctx = 0; ctx < num_contexts; ctx++) |
| 641 | prom_putsegment(ctx, vaddr, pseg); |
| 642 | fix_permissions(vaddr, _SUN4C_PAGE_PRIV, 0); |
| 643 | } |
| 644 | } |
| 645 | #ifdef CONFIG_SUN4 |
| 646 | } |
| 647 | #endif |
| 648 | for (vaddr = KERNBASE; vaddr < kernel_end; vaddr += SUN4C_REAL_PGDIR_SIZE) { |
| 649 | pseg = sun4c_get_segmap(vaddr); |
| 650 | mmu_entry_pool[pseg].locked = 1; |
| 651 | for (ctx = 0; ctx < num_contexts; ctx++) |
| 652 | prom_putsegment(ctx, vaddr, pseg); |
| 653 | fix_permissions(vaddr, _SUN4C_PAGE_PRIV, _SUN4C_PAGE_NOCACHE); |
| 654 | } |
| 655 | } |
| 656 | |
| 657 | static void __init sun4c_init_lock_area(unsigned long start, unsigned long end) |
| 658 | { |
| 659 | int i, ctx; |
| 660 | |
| 661 | while (start < end) { |
| 662 | for (i = 0; i < invalid_segment; i++) |
| 663 | if (!mmu_entry_pool[i].locked) |
| 664 | break; |
| 665 | mmu_entry_pool[i].locked = 1; |
| 666 | sun4c_init_clean_segmap(i); |
| 667 | for (ctx = 0; ctx < num_contexts; ctx++) |
| 668 | prom_putsegment(ctx, start, mmu_entry_pool[i].pseg); |
| 669 | start += SUN4C_REAL_PGDIR_SIZE; |
| 670 | } |
| 671 | } |
| 672 | |
| 673 | /* Don't change this struct without changing entry.S. This is used |
| 674 | * in the in-window kernel fault handler, and you don't want to mess |
| 675 | * with that. (See sun4c_fault in entry.S). |
| 676 | */ |
| 677 | struct sun4c_mmu_ring { |
| 678 | struct sun4c_mmu_entry ringhd; |
| 679 | int num_entries; |
| 680 | }; |
| 681 | |
| 682 | static struct sun4c_mmu_ring sun4c_context_ring[SUN4C_MAX_CONTEXTS]; /* used user entries */ |
| 683 | static struct sun4c_mmu_ring sun4c_ufree_ring; /* free user entries */ |
| 684 | static struct sun4c_mmu_ring sun4c_ulru_ring; /* LRU user entries */ |
| 685 | struct sun4c_mmu_ring sun4c_kernel_ring; /* used kernel entries */ |
| 686 | struct sun4c_mmu_ring sun4c_kfree_ring; /* free kernel entries */ |
| 687 | |
| 688 | static inline void sun4c_init_rings(void) |
| 689 | { |
| 690 | int i; |
| 691 | |
| 692 | for (i = 0; i < SUN4C_MAX_CONTEXTS; i++) { |
| 693 | sun4c_context_ring[i].ringhd.next = |
| 694 | sun4c_context_ring[i].ringhd.prev = |
| 695 | &sun4c_context_ring[i].ringhd; |
| 696 | sun4c_context_ring[i].num_entries = 0; |
| 697 | } |
| 698 | sun4c_ufree_ring.ringhd.next = sun4c_ufree_ring.ringhd.prev = |
| 699 | &sun4c_ufree_ring.ringhd; |
| 700 | sun4c_ufree_ring.num_entries = 0; |
| 701 | sun4c_ulru_ring.ringhd.lru_next = sun4c_ulru_ring.ringhd.lru_prev = |
| 702 | &sun4c_ulru_ring.ringhd; |
| 703 | sun4c_ulru_ring.num_entries = 0; |
| 704 | sun4c_kernel_ring.ringhd.next = sun4c_kernel_ring.ringhd.prev = |
| 705 | &sun4c_kernel_ring.ringhd; |
| 706 | sun4c_kernel_ring.num_entries = 0; |
| 707 | sun4c_kfree_ring.ringhd.next = sun4c_kfree_ring.ringhd.prev = |
| 708 | &sun4c_kfree_ring.ringhd; |
| 709 | sun4c_kfree_ring.num_entries = 0; |
| 710 | } |
| 711 | |
| 712 | static void add_ring(struct sun4c_mmu_ring *ring, |
| 713 | struct sun4c_mmu_entry *entry) |
| 714 | { |
| 715 | struct sun4c_mmu_entry *head = &ring->ringhd; |
| 716 | |
| 717 | entry->prev = head; |
| 718 | (entry->next = head->next)->prev = entry; |
| 719 | head->next = entry; |
| 720 | ring->num_entries++; |
| 721 | } |
| 722 | |
| 723 | static __inline__ void add_lru(struct sun4c_mmu_entry *entry) |
| 724 | { |
| 725 | struct sun4c_mmu_ring *ring = &sun4c_ulru_ring; |
| 726 | struct sun4c_mmu_entry *head = &ring->ringhd; |
| 727 | |
| 728 | entry->lru_next = head; |
| 729 | (entry->lru_prev = head->lru_prev)->lru_next = entry; |
| 730 | head->lru_prev = entry; |
| 731 | } |
| 732 | |
| 733 | static void add_ring_ordered(struct sun4c_mmu_ring *ring, |
| 734 | struct sun4c_mmu_entry *entry) |
| 735 | { |
| 736 | struct sun4c_mmu_entry *head = &ring->ringhd; |
| 737 | unsigned long addr = entry->vaddr; |
| 738 | |
| 739 | while ((head->next != &ring->ringhd) && (head->next->vaddr < addr)) |
| 740 | head = head->next; |
| 741 | |
| 742 | entry->prev = head; |
| 743 | (entry->next = head->next)->prev = entry; |
| 744 | head->next = entry; |
| 745 | ring->num_entries++; |
| 746 | |
| 747 | add_lru(entry); |
| 748 | } |
| 749 | |
| 750 | static __inline__ void remove_ring(struct sun4c_mmu_ring *ring, |
| 751 | struct sun4c_mmu_entry *entry) |
| 752 | { |
| 753 | struct sun4c_mmu_entry *next = entry->next; |
| 754 | |
| 755 | (next->prev = entry->prev)->next = next; |
| 756 | ring->num_entries--; |
| 757 | } |
| 758 | |
| 759 | static void remove_lru(struct sun4c_mmu_entry *entry) |
| 760 | { |
| 761 | struct sun4c_mmu_entry *next = entry->lru_next; |
| 762 | |
| 763 | (next->lru_prev = entry->lru_prev)->lru_next = next; |
| 764 | } |
| 765 | |
| 766 | static void free_user_entry(int ctx, struct sun4c_mmu_entry *entry) |
| 767 | { |
| 768 | remove_ring(sun4c_context_ring+ctx, entry); |
| 769 | remove_lru(entry); |
| 770 | add_ring(&sun4c_ufree_ring, entry); |
| 771 | } |
| 772 | |
| 773 | static void free_kernel_entry(struct sun4c_mmu_entry *entry, |
| 774 | struct sun4c_mmu_ring *ring) |
| 775 | { |
| 776 | remove_ring(ring, entry); |
| 777 | add_ring(&sun4c_kfree_ring, entry); |
| 778 | } |
| 779 | |
| 780 | static void __init sun4c_init_fill_kernel_ring(int howmany) |
| 781 | { |
| 782 | int i; |
| 783 | |
| 784 | while (howmany) { |
| 785 | for (i = 0; i < invalid_segment; i++) |
| 786 | if (!mmu_entry_pool[i].locked) |
| 787 | break; |
| 788 | mmu_entry_pool[i].locked = 1; |
| 789 | sun4c_init_clean_segmap(i); |
| 790 | add_ring(&sun4c_kfree_ring, &mmu_entry_pool[i]); |
| 791 | howmany--; |
| 792 | } |
| 793 | } |
| 794 | |
| 795 | static void __init sun4c_init_fill_user_ring(void) |
| 796 | { |
| 797 | int i; |
| 798 | |
| 799 | for (i = 0; i < invalid_segment; i++) { |
| 800 | if (mmu_entry_pool[i].locked) |
| 801 | continue; |
| 802 | sun4c_init_clean_segmap(i); |
| 803 | add_ring(&sun4c_ufree_ring, &mmu_entry_pool[i]); |
| 804 | } |
| 805 | } |
| 806 | |
| 807 | static void sun4c_kernel_unmap(struct sun4c_mmu_entry *kentry) |
| 808 | { |
| 809 | int savectx, ctx; |
| 810 | |
| 811 | savectx = sun4c_get_context(); |
| 812 | for (ctx = 0; ctx < num_contexts; ctx++) { |
| 813 | sun4c_set_context(ctx); |
| 814 | sun4c_put_segmap(kentry->vaddr, invalid_segment); |
| 815 | } |
| 816 | sun4c_set_context(savectx); |
| 817 | } |
| 818 | |
| 819 | static void sun4c_kernel_map(struct sun4c_mmu_entry *kentry) |
| 820 | { |
| 821 | int savectx, ctx; |
| 822 | |
| 823 | savectx = sun4c_get_context(); |
| 824 | for (ctx = 0; ctx < num_contexts; ctx++) { |
| 825 | sun4c_set_context(ctx); |
| 826 | sun4c_put_segmap(kentry->vaddr, kentry->pseg); |
| 827 | } |
| 828 | sun4c_set_context(savectx); |
| 829 | } |
| 830 | |
| 831 | #define sun4c_user_unmap(__entry) \ |
| 832 | sun4c_put_segmap((__entry)->vaddr, invalid_segment) |
| 833 | |
| 834 | static void sun4c_demap_context(struct sun4c_mmu_ring *crp, unsigned char ctx) |
| 835 | { |
| 836 | struct sun4c_mmu_entry *head = &crp->ringhd; |
| 837 | unsigned long flags; |
| 838 | |
| 839 | local_irq_save(flags); |
| 840 | if (head->next != head) { |
| 841 | struct sun4c_mmu_entry *entry = head->next; |
| 842 | int savectx = sun4c_get_context(); |
| 843 | |
| 844 | flush_user_windows(); |
| 845 | sun4c_set_context(ctx); |
| 846 | sun4c_flush_context(); |
| 847 | do { |
| 848 | struct sun4c_mmu_entry *next = entry->next; |
| 849 | |
| 850 | sun4c_user_unmap(entry); |
| 851 | free_user_entry(ctx, entry); |
| 852 | |
| 853 | entry = next; |
| 854 | } while (entry != head); |
| 855 | sun4c_set_context(savectx); |
| 856 | } |
| 857 | local_irq_restore(flags); |
| 858 | } |
| 859 | |
| 860 | static int sun4c_user_taken_entries; /* This is how much we have. */ |
| 861 | static int max_user_taken_entries; /* This limits us and prevents deadlock. */ |
| 862 | |
| 863 | static struct sun4c_mmu_entry *sun4c_kernel_strategy(void) |
| 864 | { |
| 865 | struct sun4c_mmu_entry *this_entry; |
| 866 | |
| 867 | /* If some are free, return first one. */ |
| 868 | if (sun4c_kfree_ring.num_entries) { |
| 869 | this_entry = sun4c_kfree_ring.ringhd.next; |
| 870 | return this_entry; |
| 871 | } |
| 872 | |
| 873 | /* Else free one up. */ |
| 874 | this_entry = sun4c_kernel_ring.ringhd.prev; |
| 875 | sun4c_flush_segment(this_entry->vaddr); |
| 876 | sun4c_kernel_unmap(this_entry); |
| 877 | free_kernel_entry(this_entry, &sun4c_kernel_ring); |
| 878 | this_entry = sun4c_kfree_ring.ringhd.next; |
| 879 | |
| 880 | return this_entry; |
| 881 | } |
| 882 | |
| 883 | /* Using this method to free up mmu entries eliminates a lot of |
| 884 | * potential races since we have a kernel that incurs tlb |
| 885 | * replacement faults. There may be performance penalties. |
| 886 | * |
| 887 | * NOTE: Must be called with interrupts disabled. |
| 888 | */ |
| 889 | static struct sun4c_mmu_entry *sun4c_user_strategy(void) |
| 890 | { |
| 891 | struct sun4c_mmu_entry *entry; |
| 892 | unsigned char ctx; |
| 893 | int savectx; |
| 894 | |
| 895 | /* If some are free, return first one. */ |
| 896 | if (sun4c_ufree_ring.num_entries) { |
| 897 | entry = sun4c_ufree_ring.ringhd.next; |
| 898 | goto unlink_out; |
| 899 | } |
| 900 | |
| 901 | if (sun4c_user_taken_entries) { |
| 902 | entry = sun4c_kernel_strategy(); |
| 903 | sun4c_user_taken_entries--; |
| 904 | goto kunlink_out; |
| 905 | } |
| 906 | |
| 907 | /* Grab from the beginning of the LRU list. */ |
| 908 | entry = sun4c_ulru_ring.ringhd.lru_next; |
| 909 | ctx = entry->ctx; |
| 910 | |
| 911 | savectx = sun4c_get_context(); |
| 912 | flush_user_windows(); |
| 913 | sun4c_set_context(ctx); |
| 914 | sun4c_flush_segment(entry->vaddr); |
| 915 | sun4c_user_unmap(entry); |
| 916 | remove_ring(sun4c_context_ring + ctx, entry); |
| 917 | remove_lru(entry); |
| 918 | sun4c_set_context(savectx); |
| 919 | |
| 920 | return entry; |
| 921 | |
| 922 | unlink_out: |
| 923 | remove_ring(&sun4c_ufree_ring, entry); |
| 924 | return entry; |
| 925 | kunlink_out: |
| 926 | remove_ring(&sun4c_kfree_ring, entry); |
| 927 | return entry; |
| 928 | } |
| 929 | |
| 930 | /* NOTE: Must be called with interrupts disabled. */ |
| 931 | void sun4c_grow_kernel_ring(void) |
| 932 | { |
| 933 | struct sun4c_mmu_entry *entry; |
| 934 | |
| 935 | /* Prevent deadlock condition. */ |
| 936 | if (sun4c_user_taken_entries >= max_user_taken_entries) |
| 937 | return; |
| 938 | |
| 939 | if (sun4c_ufree_ring.num_entries) { |
| 940 | entry = sun4c_ufree_ring.ringhd.next; |
| 941 | remove_ring(&sun4c_ufree_ring, entry); |
| 942 | add_ring(&sun4c_kfree_ring, entry); |
| 943 | sun4c_user_taken_entries++; |
| 944 | } |
| 945 | } |
| 946 | |
| 947 | /* 2 page buckets for task struct and kernel stack allocation. |
| 948 | * |
| 949 | * TASK_STACK_BEGIN |
| 950 | * bucket[0] |
| 951 | * bucket[1] |
| 952 | * [ ... ] |
| 953 | * bucket[NR_TASK_BUCKETS-1] |
| 954 | * TASK_STACK_BEGIN + (sizeof(struct task_bucket) * NR_TASK_BUCKETS) |
| 955 | * |
| 956 | * Each slot looks like: |
| 957 | * |
| 958 | * page 1 -- task struct + beginning of kernel stack |
| 959 | * page 2 -- rest of kernel stack |
| 960 | */ |
| 961 | |
| 962 | union task_union *sun4c_bucket[NR_TASK_BUCKETS]; |
| 963 | |
| 964 | static int sun4c_lowbucket_avail; |
| 965 | |
| 966 | #define BUCKET_EMPTY ((union task_union *) 0) |
| 967 | #define BUCKET_SHIFT (PAGE_SHIFT + 1) /* log2(sizeof(struct task_bucket)) */ |
| 968 | #define BUCKET_SIZE (1 << BUCKET_SHIFT) |
| 969 | #define BUCKET_NUM(addr) ((((addr) - SUN4C_LOCK_VADDR) >> BUCKET_SHIFT)) |
| 970 | #define BUCKET_ADDR(num) (((num) << BUCKET_SHIFT) + SUN4C_LOCK_VADDR) |
| 971 | #define BUCKET_PTE(page) \ |
| 972 | ((((page) - PAGE_OFFSET) >> PAGE_SHIFT) | pgprot_val(SUN4C_PAGE_KERNEL)) |
| 973 | #define BUCKET_PTE_PAGE(pte) \ |
| 974 | (PAGE_OFFSET + (((pte) & SUN4C_PFN_MASK) << PAGE_SHIFT)) |
| 975 | |
| 976 | static void get_locked_segment(unsigned long addr) |
| 977 | { |
| 978 | struct sun4c_mmu_entry *stolen; |
| 979 | unsigned long flags; |
| 980 | |
| 981 | local_irq_save(flags); |
| 982 | addr &= SUN4C_REAL_PGDIR_MASK; |
| 983 | stolen = sun4c_user_strategy(); |
| 984 | max_user_taken_entries--; |
| 985 | stolen->vaddr = addr; |
| 986 | flush_user_windows(); |
| 987 | sun4c_kernel_map(stolen); |
| 988 | local_irq_restore(flags); |
| 989 | } |
| 990 | |
| 991 | static void free_locked_segment(unsigned long addr) |
| 992 | { |
| 993 | struct sun4c_mmu_entry *entry; |
| 994 | unsigned long flags; |
| 995 | unsigned char pseg; |
| 996 | |
| 997 | local_irq_save(flags); |
| 998 | addr &= SUN4C_REAL_PGDIR_MASK; |
| 999 | pseg = sun4c_get_segmap(addr); |
| 1000 | entry = &mmu_entry_pool[pseg]; |
| 1001 | |
| 1002 | flush_user_windows(); |
| 1003 | sun4c_flush_segment(addr); |
| 1004 | sun4c_kernel_unmap(entry); |
| 1005 | add_ring(&sun4c_ufree_ring, entry); |
| 1006 | max_user_taken_entries++; |
| 1007 | local_irq_restore(flags); |
| 1008 | } |
| 1009 | |
| 1010 | static inline void garbage_collect(int entry) |
| 1011 | { |
| 1012 | int start, end; |
| 1013 | |
| 1014 | /* 32 buckets per segment... */ |
| 1015 | entry &= ~31; |
| 1016 | start = entry; |
| 1017 | for (end = (start + 32); start < end; start++) |
| 1018 | if (sun4c_bucket[start] != BUCKET_EMPTY) |
| 1019 | return; |
| 1020 | |
| 1021 | /* Entire segment empty, release it. */ |
| 1022 | free_locked_segment(BUCKET_ADDR(entry)); |
| 1023 | } |
| 1024 | |
| 1025 | static struct thread_info *sun4c_alloc_thread_info(void) |
| 1026 | { |
| 1027 | unsigned long addr, pages; |
| 1028 | int entry; |
| 1029 | |
| 1030 | pages = __get_free_pages(GFP_KERNEL, THREAD_INFO_ORDER); |
| 1031 | if (!pages) |
| 1032 | return NULL; |
| 1033 | |
| 1034 | for (entry = sun4c_lowbucket_avail; entry < NR_TASK_BUCKETS; entry++) |
| 1035 | if (sun4c_bucket[entry] == BUCKET_EMPTY) |
| 1036 | break; |
| 1037 | if (entry == NR_TASK_BUCKETS) { |
| 1038 | free_pages(pages, THREAD_INFO_ORDER); |
| 1039 | return NULL; |
| 1040 | } |
| 1041 | if (entry >= sun4c_lowbucket_avail) |
| 1042 | sun4c_lowbucket_avail = entry + 1; |
| 1043 | |
| 1044 | addr = BUCKET_ADDR(entry); |
| 1045 | sun4c_bucket[entry] = (union task_union *) addr; |
| 1046 | if(sun4c_get_segmap(addr) == invalid_segment) |
| 1047 | get_locked_segment(addr); |
| 1048 | |
| 1049 | /* We are changing the virtual color of the page(s) |
| 1050 | * so we must flush the cache to guarantee consistency. |
| 1051 | */ |
| 1052 | sun4c_flush_page(pages); |
| 1053 | #ifndef CONFIG_SUN4 |
| 1054 | sun4c_flush_page(pages + PAGE_SIZE); |
| 1055 | #endif |
| 1056 | |
| 1057 | sun4c_put_pte(addr, BUCKET_PTE(pages)); |
| 1058 | #ifndef CONFIG_SUN4 |
| 1059 | sun4c_put_pte(addr + PAGE_SIZE, BUCKET_PTE(pages + PAGE_SIZE)); |
| 1060 | #endif |
| 1061 | |
| 1062 | #ifdef CONFIG_DEBUG_STACK_USAGE |
| 1063 | memset((void *)addr, 0, PAGE_SIZE << THREAD_INFO_ORDER); |
| 1064 | #endif /* DEBUG_STACK_USAGE */ |
| 1065 | |
| 1066 | return (struct thread_info *) addr; |
| 1067 | } |
| 1068 | |
| 1069 | static void sun4c_free_thread_info(struct thread_info *ti) |
| 1070 | { |
| 1071 | unsigned long tiaddr = (unsigned long) ti; |
| 1072 | unsigned long pages = BUCKET_PTE_PAGE(sun4c_get_pte(tiaddr)); |
| 1073 | int entry = BUCKET_NUM(tiaddr); |
| 1074 | |
| 1075 | /* We are deleting a mapping, so the flush here is mandatory. */ |
| 1076 | sun4c_flush_page(tiaddr); |
| 1077 | #ifndef CONFIG_SUN4 |
| 1078 | sun4c_flush_page(tiaddr + PAGE_SIZE); |
| 1079 | #endif |
| 1080 | sun4c_put_pte(tiaddr, 0); |
| 1081 | #ifndef CONFIG_SUN4 |
| 1082 | sun4c_put_pte(tiaddr + PAGE_SIZE, 0); |
| 1083 | #endif |
| 1084 | sun4c_bucket[entry] = BUCKET_EMPTY; |
| 1085 | if (entry < sun4c_lowbucket_avail) |
| 1086 | sun4c_lowbucket_avail = entry; |
| 1087 | |
| 1088 | free_pages(pages, THREAD_INFO_ORDER); |
| 1089 | garbage_collect(entry); |
| 1090 | } |
| 1091 | |
| 1092 | static void __init sun4c_init_buckets(void) |
| 1093 | { |
| 1094 | int entry; |
| 1095 | |
| 1096 | if (sizeof(union thread_union) != (PAGE_SIZE << THREAD_INFO_ORDER)) { |
| 1097 | extern void thread_info_size_is_bolixed_pete(void); |
| 1098 | thread_info_size_is_bolixed_pete(); |
| 1099 | } |
| 1100 | |
| 1101 | for (entry = 0; entry < NR_TASK_BUCKETS; entry++) |
| 1102 | sun4c_bucket[entry] = BUCKET_EMPTY; |
| 1103 | sun4c_lowbucket_avail = 0; |
| 1104 | } |
| 1105 | |
| 1106 | static unsigned long sun4c_iobuffer_start; |
| 1107 | static unsigned long sun4c_iobuffer_end; |
| 1108 | static unsigned long sun4c_iobuffer_high; |
| 1109 | static unsigned long *sun4c_iobuffer_map; |
| 1110 | static int iobuffer_map_size; |
| 1111 | |
| 1112 | /* |
| 1113 | * Alias our pages so they do not cause a trap. |
| 1114 | * Also one page may be aliased into several I/O areas and we may |
| 1115 | * finish these I/O separately. |
| 1116 | */ |
| 1117 | static char *sun4c_lockarea(char *vaddr, unsigned long size) |
| 1118 | { |
| 1119 | unsigned long base, scan; |
| 1120 | unsigned long npages; |
| 1121 | unsigned long vpage; |
| 1122 | unsigned long pte; |
| 1123 | unsigned long apage; |
| 1124 | unsigned long high; |
| 1125 | unsigned long flags; |
| 1126 | |
| 1127 | npages = (((unsigned long)vaddr & ~PAGE_MASK) + |
| 1128 | size + (PAGE_SIZE-1)) >> PAGE_SHIFT; |
| 1129 | |
| 1130 | scan = 0; |
| 1131 | local_irq_save(flags); |
| 1132 | for (;;) { |
| 1133 | scan = find_next_zero_bit(sun4c_iobuffer_map, |
| 1134 | iobuffer_map_size, scan); |
| 1135 | if ((base = scan) + npages > iobuffer_map_size) goto abend; |
| 1136 | for (;;) { |
| 1137 | if (scan >= base + npages) goto found; |
| 1138 | if (test_bit(scan, sun4c_iobuffer_map)) break; |
| 1139 | scan++; |
| 1140 | } |
| 1141 | } |
| 1142 | |
| 1143 | found: |
| 1144 | high = ((base + npages) << PAGE_SHIFT) + sun4c_iobuffer_start; |
| 1145 | high = SUN4C_REAL_PGDIR_ALIGN(high); |
| 1146 | while (high > sun4c_iobuffer_high) { |
| 1147 | get_locked_segment(sun4c_iobuffer_high); |
| 1148 | sun4c_iobuffer_high += SUN4C_REAL_PGDIR_SIZE; |
| 1149 | } |
| 1150 | |
| 1151 | vpage = ((unsigned long) vaddr) & PAGE_MASK; |
| 1152 | for (scan = base; scan < base+npages; scan++) { |
| 1153 | pte = ((vpage-PAGE_OFFSET) >> PAGE_SHIFT); |
| 1154 | pte |= pgprot_val(SUN4C_PAGE_KERNEL); |
| 1155 | pte |= _SUN4C_PAGE_NOCACHE; |
| 1156 | set_bit(scan, sun4c_iobuffer_map); |
| 1157 | apage = (scan << PAGE_SHIFT) + sun4c_iobuffer_start; |
| 1158 | |
| 1159 | /* Flush original mapping so we see the right things later. */ |
| 1160 | sun4c_flush_page(vpage); |
| 1161 | |
| 1162 | sun4c_put_pte(apage, pte); |
| 1163 | vpage += PAGE_SIZE; |
| 1164 | } |
| 1165 | local_irq_restore(flags); |
| 1166 | return (char *) ((base << PAGE_SHIFT) + sun4c_iobuffer_start + |
| 1167 | (((unsigned long) vaddr) & ~PAGE_MASK)); |
| 1168 | |
| 1169 | abend: |
| 1170 | local_irq_restore(flags); |
| 1171 | printk("DMA vaddr=0x%p size=%08lx\n", vaddr, size); |
| 1172 | panic("Out of iobuffer table"); |
| 1173 | return NULL; |
| 1174 | } |
| 1175 | |
| 1176 | static void sun4c_unlockarea(char *vaddr, unsigned long size) |
| 1177 | { |
| 1178 | unsigned long vpage, npages; |
| 1179 | unsigned long flags; |
| 1180 | int scan, high; |
| 1181 | |
| 1182 | vpage = (unsigned long)vaddr & PAGE_MASK; |
| 1183 | npages = (((unsigned long)vaddr & ~PAGE_MASK) + |
| 1184 | size + (PAGE_SIZE-1)) >> PAGE_SHIFT; |
| 1185 | |
| 1186 | local_irq_save(flags); |
| 1187 | while (npages != 0) { |
| 1188 | --npages; |
| 1189 | |
| 1190 | /* This mapping is marked non-cachable, no flush necessary. */ |
| 1191 | sun4c_put_pte(vpage, 0); |
| 1192 | clear_bit((vpage - sun4c_iobuffer_start) >> PAGE_SHIFT, |
| 1193 | sun4c_iobuffer_map); |
| 1194 | vpage += PAGE_SIZE; |
| 1195 | } |
| 1196 | |
| 1197 | /* garbage collect */ |
| 1198 | scan = (sun4c_iobuffer_high - sun4c_iobuffer_start) >> PAGE_SHIFT; |
| 1199 | while (scan >= 0 && !sun4c_iobuffer_map[scan >> 5]) |
| 1200 | scan -= 32; |
| 1201 | scan += 32; |
| 1202 | high = sun4c_iobuffer_start + (scan << PAGE_SHIFT); |
| 1203 | high = SUN4C_REAL_PGDIR_ALIGN(high) + SUN4C_REAL_PGDIR_SIZE; |
| 1204 | while (high < sun4c_iobuffer_high) { |
| 1205 | sun4c_iobuffer_high -= SUN4C_REAL_PGDIR_SIZE; |
| 1206 | free_locked_segment(sun4c_iobuffer_high); |
| 1207 | } |
| 1208 | local_irq_restore(flags); |
| 1209 | } |
| 1210 | |
| 1211 | /* Note the scsi code at init time passes to here buffers |
| 1212 | * which sit on the kernel stack, those are already locked |
| 1213 | * by implication and fool the page locking code above |
| 1214 | * if passed to by mistake. |
| 1215 | */ |
| 1216 | static __u32 sun4c_get_scsi_one(char *bufptr, unsigned long len, struct sbus_bus *sbus) |
| 1217 | { |
| 1218 | unsigned long page; |
| 1219 | |
| 1220 | page = ((unsigned long)bufptr) & PAGE_MASK; |
| 1221 | if (!virt_addr_valid(page)) { |
| 1222 | sun4c_flush_page(page); |
| 1223 | return (__u32)bufptr; /* already locked */ |
| 1224 | } |
| 1225 | return (__u32)sun4c_lockarea(bufptr, len); |
| 1226 | } |
| 1227 | |
| 1228 | static void sun4c_get_scsi_sgl(struct scatterlist *sg, int sz, struct sbus_bus *sbus) |
| 1229 | { |
| 1230 | while (sz != 0) { |
| 1231 | --sz; |
| 1232 | sg[sz].dvma_address = (__u32)sun4c_lockarea(page_address(sg[sz].page) + sg[sz].offset, sg[sz].length); |
| 1233 | sg[sz].dvma_length = sg[sz].length; |
| 1234 | } |
| 1235 | } |
| 1236 | |
| 1237 | static void sun4c_release_scsi_one(__u32 bufptr, unsigned long len, struct sbus_bus *sbus) |
| 1238 | { |
| 1239 | if (bufptr < sun4c_iobuffer_start) |
| 1240 | return; /* On kernel stack or similar, see above */ |
| 1241 | sun4c_unlockarea((char *)bufptr, len); |
| 1242 | } |
| 1243 | |
| 1244 | static void sun4c_release_scsi_sgl(struct scatterlist *sg, int sz, struct sbus_bus *sbus) |
| 1245 | { |
| 1246 | while (sz != 0) { |
| 1247 | --sz; |
| 1248 | sun4c_unlockarea((char *)sg[sz].dvma_address, sg[sz].length); |
| 1249 | } |
| 1250 | } |
| 1251 | |
| 1252 | #define TASK_ENTRY_SIZE BUCKET_SIZE /* see above */ |
| 1253 | #define LONG_ALIGN(x) (((x)+(sizeof(long))-1)&~((sizeof(long))-1)) |
| 1254 | |
| 1255 | struct vm_area_struct sun4c_kstack_vma; |
| 1256 | |
| 1257 | static void __init sun4c_init_lock_areas(void) |
| 1258 | { |
| 1259 | unsigned long sun4c_taskstack_start; |
| 1260 | unsigned long sun4c_taskstack_end; |
| 1261 | int bitmap_size; |
| 1262 | |
| 1263 | sun4c_init_buckets(); |
| 1264 | sun4c_taskstack_start = SUN4C_LOCK_VADDR; |
| 1265 | sun4c_taskstack_end = (sun4c_taskstack_start + |
| 1266 | (TASK_ENTRY_SIZE * NR_TASK_BUCKETS)); |
| 1267 | if (sun4c_taskstack_end >= SUN4C_LOCK_END) { |
| 1268 | prom_printf("Too many tasks, decrease NR_TASK_BUCKETS please.\n"); |
| 1269 | prom_halt(); |
| 1270 | } |
| 1271 | |
| 1272 | sun4c_iobuffer_start = sun4c_iobuffer_high = |
| 1273 | SUN4C_REAL_PGDIR_ALIGN(sun4c_taskstack_end); |
| 1274 | sun4c_iobuffer_end = SUN4C_LOCK_END; |
| 1275 | bitmap_size = (sun4c_iobuffer_end - sun4c_iobuffer_start) >> PAGE_SHIFT; |
| 1276 | bitmap_size = (bitmap_size + 7) >> 3; |
| 1277 | bitmap_size = LONG_ALIGN(bitmap_size); |
| 1278 | iobuffer_map_size = bitmap_size << 3; |
| 1279 | sun4c_iobuffer_map = __alloc_bootmem(bitmap_size, SMP_CACHE_BYTES, 0UL); |
| 1280 | memset((void *) sun4c_iobuffer_map, 0, bitmap_size); |
| 1281 | |
| 1282 | sun4c_kstack_vma.vm_mm = &init_mm; |
| 1283 | sun4c_kstack_vma.vm_start = sun4c_taskstack_start; |
| 1284 | sun4c_kstack_vma.vm_end = sun4c_taskstack_end; |
| 1285 | sun4c_kstack_vma.vm_page_prot = PAGE_SHARED; |
| 1286 | sun4c_kstack_vma.vm_flags = VM_READ | VM_WRITE | VM_EXEC; |
| 1287 | insert_vm_struct(&init_mm, &sun4c_kstack_vma); |
| 1288 | } |
| 1289 | |
| 1290 | /* Cache flushing on the sun4c. */ |
| 1291 | static void sun4c_flush_cache_all(void) |
| 1292 | { |
| 1293 | unsigned long begin, end; |
| 1294 | |
| 1295 | flush_user_windows(); |
| 1296 | begin = (KERNBASE + SUN4C_REAL_PGDIR_SIZE); |
| 1297 | end = (begin + SUN4C_VAC_SIZE); |
| 1298 | |
| 1299 | if (sun4c_vacinfo.linesize == 32) { |
| 1300 | while (begin < end) { |
| 1301 | __asm__ __volatile__( |
| 1302 | "ld [%0 + 0x00], %%g0\n\t" |
| 1303 | "ld [%0 + 0x20], %%g0\n\t" |
| 1304 | "ld [%0 + 0x40], %%g0\n\t" |
| 1305 | "ld [%0 + 0x60], %%g0\n\t" |
| 1306 | "ld [%0 + 0x80], %%g0\n\t" |
| 1307 | "ld [%0 + 0xa0], %%g0\n\t" |
| 1308 | "ld [%0 + 0xc0], %%g0\n\t" |
| 1309 | "ld [%0 + 0xe0], %%g0\n\t" |
| 1310 | "ld [%0 + 0x100], %%g0\n\t" |
| 1311 | "ld [%0 + 0x120], %%g0\n\t" |
| 1312 | "ld [%0 + 0x140], %%g0\n\t" |
| 1313 | "ld [%0 + 0x160], %%g0\n\t" |
| 1314 | "ld [%0 + 0x180], %%g0\n\t" |
| 1315 | "ld [%0 + 0x1a0], %%g0\n\t" |
| 1316 | "ld [%0 + 0x1c0], %%g0\n\t" |
| 1317 | "ld [%0 + 0x1e0], %%g0\n" |
| 1318 | : : "r" (begin)); |
| 1319 | begin += 512; |
| 1320 | } |
| 1321 | } else { |
| 1322 | while (begin < end) { |
| 1323 | __asm__ __volatile__( |
| 1324 | "ld [%0 + 0x00], %%g0\n\t" |
| 1325 | "ld [%0 + 0x10], %%g0\n\t" |
| 1326 | "ld [%0 + 0x20], %%g0\n\t" |
| 1327 | "ld [%0 + 0x30], %%g0\n\t" |
| 1328 | "ld [%0 + 0x40], %%g0\n\t" |
| 1329 | "ld [%0 + 0x50], %%g0\n\t" |
| 1330 | "ld [%0 + 0x60], %%g0\n\t" |
| 1331 | "ld [%0 + 0x70], %%g0\n\t" |
| 1332 | "ld [%0 + 0x80], %%g0\n\t" |
| 1333 | "ld [%0 + 0x90], %%g0\n\t" |
| 1334 | "ld [%0 + 0xa0], %%g0\n\t" |
| 1335 | "ld [%0 + 0xb0], %%g0\n\t" |
| 1336 | "ld [%0 + 0xc0], %%g0\n\t" |
| 1337 | "ld [%0 + 0xd0], %%g0\n\t" |
| 1338 | "ld [%0 + 0xe0], %%g0\n\t" |
| 1339 | "ld [%0 + 0xf0], %%g0\n" |
| 1340 | : : "r" (begin)); |
| 1341 | begin += 256; |
| 1342 | } |
| 1343 | } |
| 1344 | } |
| 1345 | |
| 1346 | static void sun4c_flush_cache_mm(struct mm_struct *mm) |
| 1347 | { |
| 1348 | int new_ctx = mm->context; |
| 1349 | |
| 1350 | if (new_ctx != NO_CONTEXT) { |
| 1351 | flush_user_windows(); |
| 1352 | |
| 1353 | if (sun4c_context_ring[new_ctx].num_entries) { |
| 1354 | struct sun4c_mmu_entry *head = &sun4c_context_ring[new_ctx].ringhd; |
| 1355 | unsigned long flags; |
| 1356 | |
| 1357 | local_irq_save(flags); |
| 1358 | if (head->next != head) { |
| 1359 | struct sun4c_mmu_entry *entry = head->next; |
| 1360 | int savectx = sun4c_get_context(); |
| 1361 | |
| 1362 | sun4c_set_context(new_ctx); |
| 1363 | sun4c_flush_context(); |
| 1364 | do { |
| 1365 | struct sun4c_mmu_entry *next = entry->next; |
| 1366 | |
| 1367 | sun4c_user_unmap(entry); |
| 1368 | free_user_entry(new_ctx, entry); |
| 1369 | |
| 1370 | entry = next; |
| 1371 | } while (entry != head); |
| 1372 | sun4c_set_context(savectx); |
| 1373 | } |
| 1374 | local_irq_restore(flags); |
| 1375 | } |
| 1376 | } |
| 1377 | } |
| 1378 | |
| 1379 | static void sun4c_flush_cache_range(struct vm_area_struct *vma, unsigned long start, unsigned long end) |
| 1380 | { |
| 1381 | struct mm_struct *mm = vma->vm_mm; |
| 1382 | int new_ctx = mm->context; |
| 1383 | |
| 1384 | if (new_ctx != NO_CONTEXT) { |
| 1385 | struct sun4c_mmu_entry *head = &sun4c_context_ring[new_ctx].ringhd; |
| 1386 | struct sun4c_mmu_entry *entry; |
| 1387 | unsigned long flags; |
| 1388 | |
| 1389 | flush_user_windows(); |
| 1390 | |
| 1391 | local_irq_save(flags); |
| 1392 | /* All user segmap chains are ordered on entry->vaddr. */ |
| 1393 | for (entry = head->next; |
| 1394 | (entry != head) && ((entry->vaddr+SUN4C_REAL_PGDIR_SIZE) < start); |
| 1395 | entry = entry->next) |
| 1396 | ; |
| 1397 | |
| 1398 | /* Tracing various job mixtures showed that this conditional |
| 1399 | * only passes ~35% of the time for most worse case situations, |
| 1400 | * therefore we avoid all of this gross overhead ~65% of the time. |
| 1401 | */ |
| 1402 | if ((entry != head) && (entry->vaddr < end)) { |
| 1403 | int octx = sun4c_get_context(); |
| 1404 | sun4c_set_context(new_ctx); |
| 1405 | |
| 1406 | /* At this point, always, (start >= entry->vaddr) and |
| 1407 | * (entry->vaddr < end), once the latter condition |
| 1408 | * ceases to hold, or we hit the end of the list, we |
| 1409 | * exit the loop. The ordering of all user allocated |
| 1410 | * segmaps makes this all work out so beautifully. |
| 1411 | */ |
| 1412 | do { |
| 1413 | struct sun4c_mmu_entry *next = entry->next; |
| 1414 | unsigned long realend; |
| 1415 | |
| 1416 | /* "realstart" is always >= entry->vaddr */ |
| 1417 | realend = entry->vaddr + SUN4C_REAL_PGDIR_SIZE; |
| 1418 | if (end < realend) |
| 1419 | realend = end; |
| 1420 | if ((realend - entry->vaddr) <= (PAGE_SIZE << 3)) { |
| 1421 | unsigned long page = entry->vaddr; |
| 1422 | while (page < realend) { |
| 1423 | sun4c_flush_page(page); |
| 1424 | page += PAGE_SIZE; |
| 1425 | } |
| 1426 | } else { |
| 1427 | sun4c_flush_segment(entry->vaddr); |
| 1428 | sun4c_user_unmap(entry); |
| 1429 | free_user_entry(new_ctx, entry); |
| 1430 | } |
| 1431 | entry = next; |
| 1432 | } while ((entry != head) && (entry->vaddr < end)); |
| 1433 | sun4c_set_context(octx); |
| 1434 | } |
| 1435 | local_irq_restore(flags); |
| 1436 | } |
| 1437 | } |
| 1438 | |
| 1439 | static void sun4c_flush_cache_page(struct vm_area_struct *vma, unsigned long page) |
| 1440 | { |
| 1441 | struct mm_struct *mm = vma->vm_mm; |
| 1442 | int new_ctx = mm->context; |
| 1443 | |
| 1444 | /* Sun4c has no separate I/D caches so cannot optimize for non |
| 1445 | * text page flushes. |
| 1446 | */ |
| 1447 | if (new_ctx != NO_CONTEXT) { |
| 1448 | int octx = sun4c_get_context(); |
| 1449 | unsigned long flags; |
| 1450 | |
| 1451 | flush_user_windows(); |
| 1452 | local_irq_save(flags); |
| 1453 | sun4c_set_context(new_ctx); |
| 1454 | sun4c_flush_page(page); |
| 1455 | sun4c_set_context(octx); |
| 1456 | local_irq_restore(flags); |
| 1457 | } |
| 1458 | } |
| 1459 | |
| 1460 | static void sun4c_flush_page_to_ram(unsigned long page) |
| 1461 | { |
| 1462 | unsigned long flags; |
| 1463 | |
| 1464 | local_irq_save(flags); |
| 1465 | sun4c_flush_page(page); |
| 1466 | local_irq_restore(flags); |
| 1467 | } |
| 1468 | |
| 1469 | /* Sun4c cache is unified, both instructions and data live there, so |
| 1470 | * no need to flush the on-stack instructions for new signal handlers. |
| 1471 | */ |
| 1472 | static void sun4c_flush_sig_insns(struct mm_struct *mm, unsigned long insn_addr) |
| 1473 | { |
| 1474 | } |
| 1475 | |
| 1476 | /* TLB flushing on the sun4c. These routines count on the cache |
| 1477 | * flushing code to flush the user register windows so that we need |
| 1478 | * not do so when we get here. |
| 1479 | */ |
| 1480 | |
| 1481 | static void sun4c_flush_tlb_all(void) |
| 1482 | { |
| 1483 | struct sun4c_mmu_entry *this_entry, *next_entry; |
| 1484 | unsigned long flags; |
| 1485 | int savectx, ctx; |
| 1486 | |
| 1487 | local_irq_save(flags); |
| 1488 | this_entry = sun4c_kernel_ring.ringhd.next; |
| 1489 | savectx = sun4c_get_context(); |
| 1490 | flush_user_windows(); |
| 1491 | while (sun4c_kernel_ring.num_entries) { |
| 1492 | next_entry = this_entry->next; |
| 1493 | sun4c_flush_segment(this_entry->vaddr); |
| 1494 | for (ctx = 0; ctx < num_contexts; ctx++) { |
| 1495 | sun4c_set_context(ctx); |
| 1496 | sun4c_put_segmap(this_entry->vaddr, invalid_segment); |
| 1497 | } |
| 1498 | free_kernel_entry(this_entry, &sun4c_kernel_ring); |
| 1499 | this_entry = next_entry; |
| 1500 | } |
| 1501 | sun4c_set_context(savectx); |
| 1502 | local_irq_restore(flags); |
| 1503 | } |
| 1504 | |
| 1505 | static void sun4c_flush_tlb_mm(struct mm_struct *mm) |
| 1506 | { |
| 1507 | int new_ctx = mm->context; |
| 1508 | |
| 1509 | if (new_ctx != NO_CONTEXT) { |
| 1510 | struct sun4c_mmu_entry *head = &sun4c_context_ring[new_ctx].ringhd; |
| 1511 | unsigned long flags; |
| 1512 | |
| 1513 | local_irq_save(flags); |
| 1514 | if (head->next != head) { |
| 1515 | struct sun4c_mmu_entry *entry = head->next; |
| 1516 | int savectx = sun4c_get_context(); |
| 1517 | |
| 1518 | sun4c_set_context(new_ctx); |
| 1519 | sun4c_flush_context(); |
| 1520 | do { |
| 1521 | struct sun4c_mmu_entry *next = entry->next; |
| 1522 | |
| 1523 | sun4c_user_unmap(entry); |
| 1524 | free_user_entry(new_ctx, entry); |
| 1525 | |
| 1526 | entry = next; |
| 1527 | } while (entry != head); |
| 1528 | sun4c_set_context(savectx); |
| 1529 | } |
| 1530 | local_irq_restore(flags); |
| 1531 | } |
| 1532 | } |
| 1533 | |
| 1534 | static void sun4c_flush_tlb_range(struct vm_area_struct *vma, unsigned long start, unsigned long end) |
| 1535 | { |
| 1536 | struct mm_struct *mm = vma->vm_mm; |
| 1537 | int new_ctx = mm->context; |
| 1538 | |
| 1539 | if (new_ctx != NO_CONTEXT) { |
| 1540 | struct sun4c_mmu_entry *head = &sun4c_context_ring[new_ctx].ringhd; |
| 1541 | struct sun4c_mmu_entry *entry; |
| 1542 | unsigned long flags; |
| 1543 | |
| 1544 | local_irq_save(flags); |
| 1545 | /* See commentary in sun4c_flush_cache_range(). */ |
| 1546 | for (entry = head->next; |
| 1547 | (entry != head) && ((entry->vaddr+SUN4C_REAL_PGDIR_SIZE) < start); |
| 1548 | entry = entry->next) |
| 1549 | ; |
| 1550 | |
| 1551 | if ((entry != head) && (entry->vaddr < end)) { |
| 1552 | int octx = sun4c_get_context(); |
| 1553 | |
| 1554 | sun4c_set_context(new_ctx); |
| 1555 | do { |
| 1556 | struct sun4c_mmu_entry *next = entry->next; |
| 1557 | |
| 1558 | sun4c_flush_segment(entry->vaddr); |
| 1559 | sun4c_user_unmap(entry); |
| 1560 | free_user_entry(new_ctx, entry); |
| 1561 | |
| 1562 | entry = next; |
| 1563 | } while ((entry != head) && (entry->vaddr < end)); |
| 1564 | sun4c_set_context(octx); |
| 1565 | } |
| 1566 | local_irq_restore(flags); |
| 1567 | } |
| 1568 | } |
| 1569 | |
| 1570 | static void sun4c_flush_tlb_page(struct vm_area_struct *vma, unsigned long page) |
| 1571 | { |
| 1572 | struct mm_struct *mm = vma->vm_mm; |
| 1573 | int new_ctx = mm->context; |
| 1574 | |
| 1575 | if (new_ctx != NO_CONTEXT) { |
| 1576 | int savectx = sun4c_get_context(); |
| 1577 | unsigned long flags; |
| 1578 | |
| 1579 | local_irq_save(flags); |
| 1580 | sun4c_set_context(new_ctx); |
| 1581 | page &= PAGE_MASK; |
| 1582 | sun4c_flush_page(page); |
| 1583 | sun4c_put_pte(page, 0); |
| 1584 | sun4c_set_context(savectx); |
| 1585 | local_irq_restore(flags); |
| 1586 | } |
| 1587 | } |
| 1588 | |
| 1589 | static inline void sun4c_mapioaddr(unsigned long physaddr, unsigned long virt_addr) |
| 1590 | { |
David S. Miller | 14778d9 | 2006-03-21 02:29:39 -0800 | [diff] [blame] | 1591 | unsigned long page_entry, pg_iobits; |
| 1592 | |
| 1593 | pg_iobits = _SUN4C_PAGE_PRESENT | _SUN4C_READABLE | _SUN4C_WRITEABLE | |
| 1594 | _SUN4C_PAGE_IO | _SUN4C_PAGE_NOCACHE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1595 | |
| 1596 | page_entry = ((physaddr >> PAGE_SHIFT) & SUN4C_PFN_MASK); |
| 1597 | page_entry |= ((pg_iobits | _SUN4C_PAGE_PRIV) & ~(_SUN4C_PAGE_PRESENT)); |
| 1598 | sun4c_put_pte(virt_addr, page_entry); |
| 1599 | } |
| 1600 | |
| 1601 | static void sun4c_mapiorange(unsigned int bus, unsigned long xpa, |
| 1602 | unsigned long xva, unsigned int len) |
| 1603 | { |
| 1604 | while (len != 0) { |
| 1605 | len -= PAGE_SIZE; |
| 1606 | sun4c_mapioaddr(xpa, xva); |
| 1607 | xva += PAGE_SIZE; |
| 1608 | xpa += PAGE_SIZE; |
| 1609 | } |
| 1610 | } |
| 1611 | |
| 1612 | static void sun4c_unmapiorange(unsigned long virt_addr, unsigned int len) |
| 1613 | { |
| 1614 | while (len != 0) { |
| 1615 | len -= PAGE_SIZE; |
| 1616 | sun4c_put_pte(virt_addr, 0); |
| 1617 | virt_addr += PAGE_SIZE; |
| 1618 | } |
| 1619 | } |
| 1620 | |
| 1621 | static void sun4c_alloc_context(struct mm_struct *old_mm, struct mm_struct *mm) |
| 1622 | { |
| 1623 | struct ctx_list *ctxp; |
| 1624 | |
| 1625 | ctxp = ctx_free.next; |
| 1626 | if (ctxp != &ctx_free) { |
| 1627 | remove_from_ctx_list(ctxp); |
| 1628 | add_to_used_ctxlist(ctxp); |
| 1629 | mm->context = ctxp->ctx_number; |
| 1630 | ctxp->ctx_mm = mm; |
| 1631 | return; |
| 1632 | } |
| 1633 | ctxp = ctx_used.next; |
| 1634 | if (ctxp->ctx_mm == old_mm) |
| 1635 | ctxp = ctxp->next; |
| 1636 | remove_from_ctx_list(ctxp); |
| 1637 | add_to_used_ctxlist(ctxp); |
| 1638 | ctxp->ctx_mm->context = NO_CONTEXT; |
| 1639 | ctxp->ctx_mm = mm; |
| 1640 | mm->context = ctxp->ctx_number; |
| 1641 | sun4c_demap_context(&sun4c_context_ring[ctxp->ctx_number], |
| 1642 | ctxp->ctx_number); |
| 1643 | } |
| 1644 | |
| 1645 | /* Switch the current MM context. */ |
| 1646 | static void sun4c_switch_mm(struct mm_struct *old_mm, struct mm_struct *mm, struct task_struct *tsk, int cpu) |
| 1647 | { |
| 1648 | struct ctx_list *ctx; |
| 1649 | int dirty = 0; |
| 1650 | |
| 1651 | if (mm->context == NO_CONTEXT) { |
| 1652 | dirty = 1; |
| 1653 | sun4c_alloc_context(old_mm, mm); |
| 1654 | } else { |
| 1655 | /* Update the LRU ring of contexts. */ |
| 1656 | ctx = ctx_list_pool + mm->context; |
| 1657 | remove_from_ctx_list(ctx); |
| 1658 | add_to_used_ctxlist(ctx); |
| 1659 | } |
| 1660 | if (dirty || old_mm != mm) |
| 1661 | sun4c_set_context(mm->context); |
| 1662 | } |
| 1663 | |
| 1664 | static void sun4c_destroy_context(struct mm_struct *mm) |
| 1665 | { |
| 1666 | struct ctx_list *ctx_old; |
| 1667 | |
| 1668 | if (mm->context != NO_CONTEXT) { |
| 1669 | sun4c_demap_context(&sun4c_context_ring[mm->context], mm->context); |
| 1670 | ctx_old = ctx_list_pool + mm->context; |
| 1671 | remove_from_ctx_list(ctx_old); |
| 1672 | add_to_free_ctxlist(ctx_old); |
| 1673 | mm->context = NO_CONTEXT; |
| 1674 | } |
| 1675 | } |
| 1676 | |
| 1677 | static void sun4c_mmu_info(struct seq_file *m) |
| 1678 | { |
| 1679 | int used_user_entries, i; |
| 1680 | |
| 1681 | used_user_entries = 0; |
| 1682 | for (i = 0; i < num_contexts; i++) |
| 1683 | used_user_entries += sun4c_context_ring[i].num_entries; |
| 1684 | |
| 1685 | seq_printf(m, |
| 1686 | "vacsize\t\t: %d bytes\n" |
| 1687 | "vachwflush\t: %s\n" |
| 1688 | "vaclinesize\t: %d bytes\n" |
| 1689 | "mmuctxs\t\t: %d\n" |
| 1690 | "mmupsegs\t: %d\n" |
| 1691 | "kernelpsegs\t: %d\n" |
| 1692 | "kfreepsegs\t: %d\n" |
| 1693 | "usedpsegs\t: %d\n" |
| 1694 | "ufreepsegs\t: %d\n" |
| 1695 | "user_taken\t: %d\n" |
| 1696 | "max_taken\t: %d\n", |
| 1697 | sun4c_vacinfo.num_bytes, |
| 1698 | (sun4c_vacinfo.do_hwflushes ? "yes" : "no"), |
| 1699 | sun4c_vacinfo.linesize, |
| 1700 | num_contexts, |
| 1701 | (invalid_segment + 1), |
| 1702 | sun4c_kernel_ring.num_entries, |
| 1703 | sun4c_kfree_ring.num_entries, |
| 1704 | used_user_entries, |
| 1705 | sun4c_ufree_ring.num_entries, |
| 1706 | sun4c_user_taken_entries, |
| 1707 | max_user_taken_entries); |
| 1708 | } |
| 1709 | |
| 1710 | /* Nothing below here should touch the mmu hardware nor the mmu_entry |
| 1711 | * data structures. |
| 1712 | */ |
| 1713 | |
| 1714 | /* First the functions which the mid-level code uses to directly |
| 1715 | * manipulate the software page tables. Some defines since we are |
| 1716 | * emulating the i386 page directory layout. |
| 1717 | */ |
| 1718 | #define PGD_PRESENT 0x001 |
| 1719 | #define PGD_RW 0x002 |
| 1720 | #define PGD_USER 0x004 |
| 1721 | #define PGD_ACCESSED 0x020 |
| 1722 | #define PGD_DIRTY 0x040 |
| 1723 | #define PGD_TABLE (PGD_PRESENT | PGD_RW | PGD_USER | PGD_ACCESSED | PGD_DIRTY) |
| 1724 | |
| 1725 | static void sun4c_set_pte(pte_t *ptep, pte_t pte) |
| 1726 | { |
| 1727 | *ptep = pte; |
| 1728 | } |
| 1729 | |
| 1730 | static void sun4c_pgd_set(pgd_t * pgdp, pmd_t * pmdp) |
| 1731 | { |
| 1732 | } |
| 1733 | |
| 1734 | static void sun4c_pmd_set(pmd_t * pmdp, pte_t * ptep) |
| 1735 | { |
| 1736 | pmdp->pmdv[0] = PGD_TABLE | (unsigned long) ptep; |
| 1737 | } |
| 1738 | |
| 1739 | static void sun4c_pmd_populate(pmd_t * pmdp, struct page * ptep) |
| 1740 | { |
| 1741 | if (page_address(ptep) == NULL) BUG(); /* No highmem on sun4c */ |
| 1742 | pmdp->pmdv[0] = PGD_TABLE | (unsigned long) page_address(ptep); |
| 1743 | } |
| 1744 | |
| 1745 | static int sun4c_pte_present(pte_t pte) |
| 1746 | { |
| 1747 | return ((pte_val(pte) & (_SUN4C_PAGE_PRESENT | _SUN4C_PAGE_PRIV)) != 0); |
| 1748 | } |
| 1749 | static void sun4c_pte_clear(pte_t *ptep) { *ptep = __pte(0); } |
| 1750 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1751 | static int sun4c_pmd_bad(pmd_t pmd) |
| 1752 | { |
| 1753 | return (((pmd_val(pmd) & ~PAGE_MASK) != PGD_TABLE) || |
| 1754 | (!virt_addr_valid(pmd_val(pmd)))); |
| 1755 | } |
| 1756 | |
| 1757 | static int sun4c_pmd_present(pmd_t pmd) |
| 1758 | { |
| 1759 | return ((pmd_val(pmd) & PGD_PRESENT) != 0); |
| 1760 | } |
| 1761 | |
| 1762 | #if 0 /* if PMD takes one word */ |
| 1763 | static void sun4c_pmd_clear(pmd_t *pmdp) { *pmdp = __pmd(0); } |
| 1764 | #else /* if pmd_t is a longish aggregate */ |
| 1765 | static void sun4c_pmd_clear(pmd_t *pmdp) { |
| 1766 | memset((void *)pmdp, 0, sizeof(pmd_t)); |
| 1767 | } |
| 1768 | #endif |
| 1769 | |
| 1770 | static int sun4c_pgd_none(pgd_t pgd) { return 0; } |
| 1771 | static int sun4c_pgd_bad(pgd_t pgd) { return 0; } |
| 1772 | static int sun4c_pgd_present(pgd_t pgd) { return 1; } |
| 1773 | static void sun4c_pgd_clear(pgd_t * pgdp) { } |
| 1774 | |
| 1775 | /* |
| 1776 | * The following only work if pte_present() is true. |
| 1777 | * Undefined behaviour if not.. |
| 1778 | */ |
| 1779 | static pte_t sun4c_pte_mkwrite(pte_t pte) |
| 1780 | { |
| 1781 | pte = __pte(pte_val(pte) | _SUN4C_PAGE_WRITE); |
| 1782 | if (pte_val(pte) & _SUN4C_PAGE_MODIFIED) |
| 1783 | pte = __pte(pte_val(pte) | _SUN4C_PAGE_SILENT_WRITE); |
| 1784 | return pte; |
| 1785 | } |
| 1786 | |
| 1787 | static pte_t sun4c_pte_mkdirty(pte_t pte) |
| 1788 | { |
| 1789 | pte = __pte(pte_val(pte) | _SUN4C_PAGE_MODIFIED); |
| 1790 | if (pte_val(pte) & _SUN4C_PAGE_WRITE) |
| 1791 | pte = __pte(pte_val(pte) | _SUN4C_PAGE_SILENT_WRITE); |
| 1792 | return pte; |
| 1793 | } |
| 1794 | |
| 1795 | static pte_t sun4c_pte_mkyoung(pte_t pte) |
| 1796 | { |
| 1797 | pte = __pte(pte_val(pte) | _SUN4C_PAGE_ACCESSED); |
| 1798 | if (pte_val(pte) & _SUN4C_PAGE_READ) |
| 1799 | pte = __pte(pte_val(pte) | _SUN4C_PAGE_SILENT_READ); |
| 1800 | return pte; |
| 1801 | } |
| 1802 | |
| 1803 | /* |
| 1804 | * Conversion functions: convert a page and protection to a page entry, |
| 1805 | * and a page entry and page directory to the page they refer to. |
| 1806 | */ |
| 1807 | static pte_t sun4c_mk_pte(struct page *page, pgprot_t pgprot) |
| 1808 | { |
| 1809 | return __pte(page_to_pfn(page) | pgprot_val(pgprot)); |
| 1810 | } |
| 1811 | |
| 1812 | static pte_t sun4c_mk_pte_phys(unsigned long phys_page, pgprot_t pgprot) |
| 1813 | { |
| 1814 | return __pte((phys_page >> PAGE_SHIFT) | pgprot_val(pgprot)); |
| 1815 | } |
| 1816 | |
| 1817 | static pte_t sun4c_mk_pte_io(unsigned long page, pgprot_t pgprot, int space) |
| 1818 | { |
| 1819 | return __pte(((page - PAGE_OFFSET) >> PAGE_SHIFT) | pgprot_val(pgprot)); |
| 1820 | } |
| 1821 | |
| 1822 | static unsigned long sun4c_pte_pfn(pte_t pte) |
| 1823 | { |
| 1824 | return pte_val(pte) & SUN4C_PFN_MASK; |
| 1825 | } |
| 1826 | |
| 1827 | static pte_t sun4c_pgoff_to_pte(unsigned long pgoff) |
| 1828 | { |
| 1829 | return __pte(pgoff | _SUN4C_PAGE_FILE); |
| 1830 | } |
| 1831 | |
| 1832 | static unsigned long sun4c_pte_to_pgoff(pte_t pte) |
| 1833 | { |
| 1834 | return pte_val(pte) & ((1UL << PTE_FILE_MAX_BITS) - 1); |
| 1835 | } |
| 1836 | |
| 1837 | |
| 1838 | static __inline__ unsigned long sun4c_pmd_page_v(pmd_t pmd) |
| 1839 | { |
| 1840 | return (pmd_val(pmd) & PAGE_MASK); |
| 1841 | } |
| 1842 | |
| 1843 | static struct page *sun4c_pmd_page(pmd_t pmd) |
| 1844 | { |
| 1845 | return virt_to_page(sun4c_pmd_page_v(pmd)); |
| 1846 | } |
| 1847 | |
| 1848 | static unsigned long sun4c_pgd_page(pgd_t pgd) { return 0; } |
| 1849 | |
| 1850 | /* to find an entry in a page-table-directory */ |
| 1851 | static inline pgd_t *sun4c_pgd_offset(struct mm_struct * mm, unsigned long address) |
| 1852 | { |
| 1853 | return mm->pgd + (address >> SUN4C_PGDIR_SHIFT); |
| 1854 | } |
| 1855 | |
| 1856 | /* Find an entry in the second-level page table.. */ |
| 1857 | static pmd_t *sun4c_pmd_offset(pgd_t * dir, unsigned long address) |
| 1858 | { |
| 1859 | return (pmd_t *) dir; |
| 1860 | } |
| 1861 | |
| 1862 | /* Find an entry in the third-level page table.. */ |
| 1863 | pte_t *sun4c_pte_offset_kernel(pmd_t * dir, unsigned long address) |
| 1864 | { |
| 1865 | return (pte_t *) sun4c_pmd_page_v(*dir) + |
| 1866 | ((address >> PAGE_SHIFT) & (SUN4C_PTRS_PER_PTE - 1)); |
| 1867 | } |
| 1868 | |
| 1869 | static unsigned long sun4c_swp_type(swp_entry_t entry) |
| 1870 | { |
| 1871 | return (entry.val & SUN4C_SWP_TYPE_MASK); |
| 1872 | } |
| 1873 | |
| 1874 | static unsigned long sun4c_swp_offset(swp_entry_t entry) |
| 1875 | { |
| 1876 | return (entry.val >> SUN4C_SWP_OFF_SHIFT) & SUN4C_SWP_OFF_MASK; |
| 1877 | } |
| 1878 | |
| 1879 | static swp_entry_t sun4c_swp_entry(unsigned long type, unsigned long offset) |
| 1880 | { |
| 1881 | return (swp_entry_t) { |
| 1882 | (offset & SUN4C_SWP_OFF_MASK) << SUN4C_SWP_OFF_SHIFT |
| 1883 | | (type & SUN4C_SWP_TYPE_MASK) }; |
| 1884 | } |
| 1885 | |
| 1886 | static void sun4c_free_pte_slow(pte_t *pte) |
| 1887 | { |
| 1888 | free_page((unsigned long)pte); |
| 1889 | } |
| 1890 | |
| 1891 | static void sun4c_free_pgd_slow(pgd_t *pgd) |
| 1892 | { |
| 1893 | free_page((unsigned long)pgd); |
| 1894 | } |
| 1895 | |
| 1896 | static pgd_t *sun4c_get_pgd_fast(void) |
| 1897 | { |
| 1898 | unsigned long *ret; |
| 1899 | |
| 1900 | if ((ret = pgd_quicklist) != NULL) { |
| 1901 | pgd_quicklist = (unsigned long *)(*ret); |
| 1902 | ret[0] = ret[1]; |
| 1903 | pgtable_cache_size--; |
| 1904 | } else { |
| 1905 | pgd_t *init; |
| 1906 | |
| 1907 | ret = (unsigned long *)__get_free_page(GFP_KERNEL); |
| 1908 | memset (ret, 0, (KERNBASE / SUN4C_PGDIR_SIZE) * sizeof(pgd_t)); |
| 1909 | init = sun4c_pgd_offset(&init_mm, 0); |
| 1910 | memcpy (((pgd_t *)ret) + USER_PTRS_PER_PGD, init + USER_PTRS_PER_PGD, |
| 1911 | (PTRS_PER_PGD - USER_PTRS_PER_PGD) * sizeof(pgd_t)); |
| 1912 | } |
| 1913 | return (pgd_t *)ret; |
| 1914 | } |
| 1915 | |
| 1916 | static void sun4c_free_pgd_fast(pgd_t *pgd) |
| 1917 | { |
| 1918 | *(unsigned long *)pgd = (unsigned long) pgd_quicklist; |
| 1919 | pgd_quicklist = (unsigned long *) pgd; |
| 1920 | pgtable_cache_size++; |
| 1921 | } |
| 1922 | |
| 1923 | |
| 1924 | static __inline__ pte_t * |
| 1925 | sun4c_pte_alloc_one_fast(struct mm_struct *mm, unsigned long address) |
| 1926 | { |
| 1927 | unsigned long *ret; |
| 1928 | |
| 1929 | if ((ret = (unsigned long *)pte_quicklist) != NULL) { |
| 1930 | pte_quicklist = (unsigned long *)(*ret); |
| 1931 | ret[0] = ret[1]; |
| 1932 | pgtable_cache_size--; |
| 1933 | } |
| 1934 | return (pte_t *)ret; |
| 1935 | } |
| 1936 | |
| 1937 | static pte_t *sun4c_pte_alloc_one_kernel(struct mm_struct *mm, unsigned long address) |
| 1938 | { |
| 1939 | pte_t *pte; |
| 1940 | |
| 1941 | if ((pte = sun4c_pte_alloc_one_fast(mm, address)) != NULL) |
| 1942 | return pte; |
| 1943 | |
| 1944 | pte = (pte_t *)__get_free_page(GFP_KERNEL|__GFP_REPEAT); |
| 1945 | if (pte) |
| 1946 | memset(pte, 0, PAGE_SIZE); |
| 1947 | return pte; |
| 1948 | } |
| 1949 | |
| 1950 | static struct page *sun4c_pte_alloc_one(struct mm_struct *mm, unsigned long address) |
| 1951 | { |
| 1952 | pte_t *pte = sun4c_pte_alloc_one_kernel(mm, address); |
| 1953 | if (pte == NULL) |
| 1954 | return NULL; |
| 1955 | return virt_to_page(pte); |
| 1956 | } |
| 1957 | |
| 1958 | static __inline__ void sun4c_free_pte_fast(pte_t *pte) |
| 1959 | { |
| 1960 | *(unsigned long *)pte = (unsigned long) pte_quicklist; |
| 1961 | pte_quicklist = (unsigned long *) pte; |
| 1962 | pgtable_cache_size++; |
| 1963 | } |
| 1964 | |
| 1965 | static void sun4c_pte_free(struct page *pte) |
| 1966 | { |
| 1967 | sun4c_free_pte_fast(page_address(pte)); |
| 1968 | } |
| 1969 | |
| 1970 | /* |
| 1971 | * allocating and freeing a pmd is trivial: the 1-entry pmd is |
| 1972 | * inside the pgd, so has no extra memory associated with it. |
| 1973 | */ |
| 1974 | static pmd_t *sun4c_pmd_alloc_one(struct mm_struct *mm, unsigned long address) |
| 1975 | { |
| 1976 | BUG(); |
| 1977 | return NULL; |
| 1978 | } |
| 1979 | |
| 1980 | static void sun4c_free_pmd_fast(pmd_t * pmd) { } |
| 1981 | |
| 1982 | static void sun4c_check_pgt_cache(int low, int high) |
| 1983 | { |
| 1984 | if (pgtable_cache_size > high) { |
| 1985 | do { |
| 1986 | if (pgd_quicklist) |
| 1987 | sun4c_free_pgd_slow(sun4c_get_pgd_fast()); |
| 1988 | if (pte_quicklist) |
| 1989 | sun4c_free_pte_slow(sun4c_pte_alloc_one_fast(NULL, 0)); |
| 1990 | } while (pgtable_cache_size > low); |
| 1991 | } |
| 1992 | } |
| 1993 | |
| 1994 | /* An experiment, turn off by default for now... -DaveM */ |
| 1995 | #define SUN4C_PRELOAD_PSEG |
| 1996 | |
| 1997 | void sun4c_update_mmu_cache(struct vm_area_struct *vma, unsigned long address, pte_t pte) |
| 1998 | { |
| 1999 | unsigned long flags; |
| 2000 | int pseg; |
| 2001 | |
| 2002 | local_irq_save(flags); |
| 2003 | address &= PAGE_MASK; |
| 2004 | if ((pseg = sun4c_get_segmap(address)) == invalid_segment) { |
| 2005 | struct sun4c_mmu_entry *entry = sun4c_user_strategy(); |
| 2006 | struct mm_struct *mm = vma->vm_mm; |
| 2007 | unsigned long start, end; |
| 2008 | |
| 2009 | entry->vaddr = start = (address & SUN4C_REAL_PGDIR_MASK); |
| 2010 | entry->ctx = mm->context; |
| 2011 | add_ring_ordered(sun4c_context_ring + mm->context, entry); |
| 2012 | sun4c_put_segmap(entry->vaddr, entry->pseg); |
| 2013 | end = start + SUN4C_REAL_PGDIR_SIZE; |
| 2014 | while (start < end) { |
| 2015 | #ifdef SUN4C_PRELOAD_PSEG |
| 2016 | pgd_t *pgdp = sun4c_pgd_offset(mm, start); |
| 2017 | pte_t *ptep; |
| 2018 | |
| 2019 | if (!pgdp) |
| 2020 | goto no_mapping; |
| 2021 | ptep = sun4c_pte_offset_kernel((pmd_t *) pgdp, start); |
| 2022 | if (!ptep || !(pte_val(*ptep) & _SUN4C_PAGE_PRESENT)) |
| 2023 | goto no_mapping; |
| 2024 | sun4c_put_pte(start, pte_val(*ptep)); |
| 2025 | goto next; |
| 2026 | |
| 2027 | no_mapping: |
| 2028 | #endif |
| 2029 | sun4c_put_pte(start, 0); |
| 2030 | #ifdef SUN4C_PRELOAD_PSEG |
| 2031 | next: |
| 2032 | #endif |
| 2033 | start += PAGE_SIZE; |
| 2034 | } |
| 2035 | #ifndef SUN4C_PRELOAD_PSEG |
| 2036 | sun4c_put_pte(address, pte_val(pte)); |
| 2037 | #endif |
| 2038 | local_irq_restore(flags); |
| 2039 | return; |
| 2040 | } else { |
| 2041 | struct sun4c_mmu_entry *entry = &mmu_entry_pool[pseg]; |
| 2042 | |
| 2043 | remove_lru(entry); |
| 2044 | add_lru(entry); |
| 2045 | } |
| 2046 | |
| 2047 | sun4c_put_pte(address, pte_val(pte)); |
| 2048 | local_irq_restore(flags); |
| 2049 | } |
| 2050 | |
| 2051 | extern void sparc_context_init(int); |
| 2052 | extern unsigned long end; |
| 2053 | extern unsigned long bootmem_init(unsigned long *pages_avail); |
| 2054 | extern unsigned long last_valid_pfn; |
| 2055 | |
| 2056 | void __init sun4c_paging_init(void) |
| 2057 | { |
| 2058 | int i, cnt; |
| 2059 | unsigned long kernel_end, vaddr; |
| 2060 | extern struct resource sparc_iomap; |
| 2061 | unsigned long end_pfn, pages_avail; |
| 2062 | |
| 2063 | kernel_end = (unsigned long) &end; |
| 2064 | kernel_end += (SUN4C_REAL_PGDIR_SIZE * 4); |
| 2065 | kernel_end = SUN4C_REAL_PGDIR_ALIGN(kernel_end); |
| 2066 | |
| 2067 | pages_avail = 0; |
| 2068 | last_valid_pfn = bootmem_init(&pages_avail); |
| 2069 | end_pfn = last_valid_pfn; |
| 2070 | |
| 2071 | sun4c_probe_mmu(); |
| 2072 | invalid_segment = (num_segmaps - 1); |
| 2073 | sun4c_init_mmu_entry_pool(); |
| 2074 | sun4c_init_rings(); |
| 2075 | sun4c_init_map_kernelprom(kernel_end); |
| 2076 | sun4c_init_clean_mmu(kernel_end); |
| 2077 | sun4c_init_fill_kernel_ring(SUN4C_KERNEL_BUCKETS); |
| 2078 | sun4c_init_lock_area(sparc_iomap.start, IOBASE_END); |
| 2079 | sun4c_init_lock_area(DVMA_VADDR, DVMA_END); |
| 2080 | sun4c_init_lock_areas(); |
| 2081 | sun4c_init_fill_user_ring(); |
| 2082 | |
| 2083 | sun4c_set_context(0); |
| 2084 | memset(swapper_pg_dir, 0, PAGE_SIZE); |
| 2085 | memset(pg0, 0, PAGE_SIZE); |
| 2086 | memset(pg1, 0, PAGE_SIZE); |
| 2087 | memset(pg2, 0, PAGE_SIZE); |
| 2088 | memset(pg3, 0, PAGE_SIZE); |
| 2089 | |
| 2090 | /* Save work later. */ |
| 2091 | vaddr = VMALLOC_START; |
| 2092 | swapper_pg_dir[vaddr>>SUN4C_PGDIR_SHIFT] = __pgd(PGD_TABLE | (unsigned long) pg0); |
| 2093 | vaddr += SUN4C_PGDIR_SIZE; |
| 2094 | swapper_pg_dir[vaddr>>SUN4C_PGDIR_SHIFT] = __pgd(PGD_TABLE | (unsigned long) pg1); |
| 2095 | vaddr += SUN4C_PGDIR_SIZE; |
| 2096 | swapper_pg_dir[vaddr>>SUN4C_PGDIR_SHIFT] = __pgd(PGD_TABLE | (unsigned long) pg2); |
| 2097 | vaddr += SUN4C_PGDIR_SIZE; |
| 2098 | swapper_pg_dir[vaddr>>SUN4C_PGDIR_SHIFT] = __pgd(PGD_TABLE | (unsigned long) pg3); |
| 2099 | sun4c_init_ss2_cache_bug(); |
| 2100 | sparc_context_init(num_contexts); |
| 2101 | |
| 2102 | { |
| 2103 | unsigned long zones_size[MAX_NR_ZONES]; |
| 2104 | unsigned long zholes_size[MAX_NR_ZONES]; |
| 2105 | unsigned long npages; |
| 2106 | int znum; |
| 2107 | |
| 2108 | for (znum = 0; znum < MAX_NR_ZONES; znum++) |
| 2109 | zones_size[znum] = zholes_size[znum] = 0; |
| 2110 | |
| 2111 | npages = max_low_pfn - pfn_base; |
| 2112 | |
| 2113 | zones_size[ZONE_DMA] = npages; |
| 2114 | zholes_size[ZONE_DMA] = npages - pages_avail; |
| 2115 | |
| 2116 | npages = highend_pfn - max_low_pfn; |
| 2117 | zones_size[ZONE_HIGHMEM] = npages; |
| 2118 | zholes_size[ZONE_HIGHMEM] = npages - calc_highpages(); |
| 2119 | |
| 2120 | free_area_init_node(0, &contig_page_data, zones_size, |
| 2121 | pfn_base, zholes_size); |
| 2122 | } |
| 2123 | |
| 2124 | cnt = 0; |
| 2125 | for (i = 0; i < num_segmaps; i++) |
| 2126 | if (mmu_entry_pool[i].locked) |
| 2127 | cnt++; |
| 2128 | |
| 2129 | max_user_taken_entries = num_segmaps - cnt - 40 - 1; |
| 2130 | |
| 2131 | printk("SUN4C: %d mmu entries for the kernel\n", cnt); |
| 2132 | } |
| 2133 | |
David S. Miller | 14778d9 | 2006-03-21 02:29:39 -0800 | [diff] [blame] | 2134 | static pgprot_t sun4c_pgprot_noncached(pgprot_t prot) |
| 2135 | { |
| 2136 | prot |= __pgprot(_SUN4C_PAGE_IO | _SUN4C_PAGE_NOCACHE); |
| 2137 | |
| 2138 | return prot; |
| 2139 | } |
| 2140 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2141 | /* Load up routines and constants for sun4c mmu */ |
| 2142 | void __init ld_mmu_sun4c(void) |
| 2143 | { |
| 2144 | extern void ___xchg32_sun4c(void); |
| 2145 | |
| 2146 | printk("Loading sun4c MMU routines\n"); |
| 2147 | |
| 2148 | /* First the constants */ |
| 2149 | BTFIXUPSET_SIMM13(pgdir_shift, SUN4C_PGDIR_SHIFT); |
| 2150 | BTFIXUPSET_SETHI(pgdir_size, SUN4C_PGDIR_SIZE); |
| 2151 | BTFIXUPSET_SETHI(pgdir_mask, SUN4C_PGDIR_MASK); |
| 2152 | |
| 2153 | BTFIXUPSET_SIMM13(ptrs_per_pmd, SUN4C_PTRS_PER_PMD); |
| 2154 | BTFIXUPSET_SIMM13(ptrs_per_pgd, SUN4C_PTRS_PER_PGD); |
| 2155 | BTFIXUPSET_SIMM13(user_ptrs_per_pgd, KERNBASE / SUN4C_PGDIR_SIZE); |
| 2156 | |
| 2157 | BTFIXUPSET_INT(page_none, pgprot_val(SUN4C_PAGE_NONE)); |
| 2158 | BTFIXUPSET_INT(page_shared, pgprot_val(SUN4C_PAGE_SHARED)); |
| 2159 | BTFIXUPSET_INT(page_copy, pgprot_val(SUN4C_PAGE_COPY)); |
| 2160 | BTFIXUPSET_INT(page_readonly, pgprot_val(SUN4C_PAGE_READONLY)); |
| 2161 | BTFIXUPSET_INT(page_kernel, pgprot_val(SUN4C_PAGE_KERNEL)); |
| 2162 | page_kernel = pgprot_val(SUN4C_PAGE_KERNEL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2163 | |
| 2164 | /* Functions */ |
David S. Miller | 14778d9 | 2006-03-21 02:29:39 -0800 | [diff] [blame] | 2165 | BTFIXUPSET_CALL(pgprot_noncached, sun4c_pgprot_noncached, BTFIXUPCALL_NORM); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2166 | BTFIXUPSET_CALL(___xchg32, ___xchg32_sun4c, BTFIXUPCALL_NORM); |
| 2167 | BTFIXUPSET_CALL(do_check_pgt_cache, sun4c_check_pgt_cache, BTFIXUPCALL_NORM); |
| 2168 | |
| 2169 | BTFIXUPSET_CALL(flush_cache_all, sun4c_flush_cache_all, BTFIXUPCALL_NORM); |
| 2170 | |
| 2171 | if (sun4c_vacinfo.do_hwflushes) { |
| 2172 | BTFIXUPSET_CALL(sun4c_flush_page, sun4c_flush_page_hw, BTFIXUPCALL_NORM); |
| 2173 | BTFIXUPSET_CALL(sun4c_flush_segment, sun4c_flush_segment_hw, BTFIXUPCALL_NORM); |
| 2174 | BTFIXUPSET_CALL(sun4c_flush_context, sun4c_flush_context_hw, BTFIXUPCALL_NORM); |
| 2175 | } else { |
| 2176 | BTFIXUPSET_CALL(sun4c_flush_page, sun4c_flush_page_sw, BTFIXUPCALL_NORM); |
| 2177 | BTFIXUPSET_CALL(sun4c_flush_segment, sun4c_flush_segment_sw, BTFIXUPCALL_NORM); |
| 2178 | BTFIXUPSET_CALL(sun4c_flush_context, sun4c_flush_context_sw, BTFIXUPCALL_NORM); |
| 2179 | } |
| 2180 | |
| 2181 | BTFIXUPSET_CALL(flush_tlb_mm, sun4c_flush_tlb_mm, BTFIXUPCALL_NORM); |
| 2182 | BTFIXUPSET_CALL(flush_cache_mm, sun4c_flush_cache_mm, BTFIXUPCALL_NORM); |
| 2183 | BTFIXUPSET_CALL(destroy_context, sun4c_destroy_context, BTFIXUPCALL_NORM); |
| 2184 | BTFIXUPSET_CALL(switch_mm, sun4c_switch_mm, BTFIXUPCALL_NORM); |
| 2185 | BTFIXUPSET_CALL(flush_cache_page, sun4c_flush_cache_page, BTFIXUPCALL_NORM); |
| 2186 | BTFIXUPSET_CALL(flush_tlb_page, sun4c_flush_tlb_page, BTFIXUPCALL_NORM); |
| 2187 | BTFIXUPSET_CALL(flush_tlb_range, sun4c_flush_tlb_range, BTFIXUPCALL_NORM); |
| 2188 | BTFIXUPSET_CALL(flush_cache_range, sun4c_flush_cache_range, BTFIXUPCALL_NORM); |
| 2189 | BTFIXUPSET_CALL(__flush_page_to_ram, sun4c_flush_page_to_ram, BTFIXUPCALL_NORM); |
| 2190 | BTFIXUPSET_CALL(flush_tlb_all, sun4c_flush_tlb_all, BTFIXUPCALL_NORM); |
| 2191 | |
| 2192 | BTFIXUPSET_CALL(flush_sig_insns, sun4c_flush_sig_insns, BTFIXUPCALL_NOP); |
| 2193 | |
| 2194 | BTFIXUPSET_CALL(set_pte, sun4c_set_pte, BTFIXUPCALL_STO1O0); |
| 2195 | |
| 2196 | /* The 2.4.18 code does not set this on sun4c, how does it work? XXX */ |
| 2197 | /* BTFIXUPSET_SETHI(none_mask, 0x00000000); */ /* Defaults to zero? */ |
| 2198 | |
| 2199 | BTFIXUPSET_CALL(pte_pfn, sun4c_pte_pfn, BTFIXUPCALL_NORM); |
| 2200 | #if 0 /* PAGE_SHIFT <= 12 */ /* Eek. Investigate. XXX */ |
| 2201 | BTFIXUPSET_CALL(pmd_page, sun4c_pmd_page, BTFIXUPCALL_ANDNINT(PAGE_SIZE - 1)); |
| 2202 | #else |
| 2203 | BTFIXUPSET_CALL(pmd_page, sun4c_pmd_page, BTFIXUPCALL_NORM); |
| 2204 | #endif |
| 2205 | BTFIXUPSET_CALL(pmd_set, sun4c_pmd_set, BTFIXUPCALL_NORM); |
| 2206 | BTFIXUPSET_CALL(pmd_populate, sun4c_pmd_populate, BTFIXUPCALL_NORM); |
| 2207 | |
| 2208 | BTFIXUPSET_CALL(pte_present, sun4c_pte_present, BTFIXUPCALL_NORM); |
| 2209 | BTFIXUPSET_CALL(pte_clear, sun4c_pte_clear, BTFIXUPCALL_STG0O0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2210 | |
| 2211 | BTFIXUPSET_CALL(pmd_bad, sun4c_pmd_bad, BTFIXUPCALL_NORM); |
| 2212 | BTFIXUPSET_CALL(pmd_present, sun4c_pmd_present, BTFIXUPCALL_NORM); |
| 2213 | BTFIXUPSET_CALL(pmd_clear, sun4c_pmd_clear, BTFIXUPCALL_STG0O0); |
| 2214 | |
| 2215 | BTFIXUPSET_CALL(pgd_none, sun4c_pgd_none, BTFIXUPCALL_RETINT(0)); |
| 2216 | BTFIXUPSET_CALL(pgd_bad, sun4c_pgd_bad, BTFIXUPCALL_RETINT(0)); |
| 2217 | BTFIXUPSET_CALL(pgd_present, sun4c_pgd_present, BTFIXUPCALL_RETINT(1)); |
| 2218 | BTFIXUPSET_CALL(pgd_clear, sun4c_pgd_clear, BTFIXUPCALL_NOP); |
| 2219 | |
| 2220 | BTFIXUPSET_CALL(mk_pte, sun4c_mk_pte, BTFIXUPCALL_NORM); |
| 2221 | BTFIXUPSET_CALL(mk_pte_phys, sun4c_mk_pte_phys, BTFIXUPCALL_NORM); |
| 2222 | BTFIXUPSET_CALL(mk_pte_io, sun4c_mk_pte_io, BTFIXUPCALL_NORM); |
| 2223 | |
| 2224 | BTFIXUPSET_INT(pte_modify_mask, _SUN4C_PAGE_CHG_MASK); |
| 2225 | BTFIXUPSET_CALL(pmd_offset, sun4c_pmd_offset, BTFIXUPCALL_NORM); |
| 2226 | BTFIXUPSET_CALL(pte_offset_kernel, sun4c_pte_offset_kernel, BTFIXUPCALL_NORM); |
| 2227 | BTFIXUPSET_CALL(free_pte_fast, sun4c_free_pte_fast, BTFIXUPCALL_NORM); |
| 2228 | BTFIXUPSET_CALL(pte_free, sun4c_pte_free, BTFIXUPCALL_NORM); |
| 2229 | BTFIXUPSET_CALL(pte_alloc_one_kernel, sun4c_pte_alloc_one_kernel, BTFIXUPCALL_NORM); |
| 2230 | BTFIXUPSET_CALL(pte_alloc_one, sun4c_pte_alloc_one, BTFIXUPCALL_NORM); |
| 2231 | BTFIXUPSET_CALL(free_pmd_fast, sun4c_free_pmd_fast, BTFIXUPCALL_NOP); |
| 2232 | BTFIXUPSET_CALL(pmd_alloc_one, sun4c_pmd_alloc_one, BTFIXUPCALL_RETO0); |
| 2233 | BTFIXUPSET_CALL(free_pgd_fast, sun4c_free_pgd_fast, BTFIXUPCALL_NORM); |
| 2234 | BTFIXUPSET_CALL(get_pgd_fast, sun4c_get_pgd_fast, BTFIXUPCALL_NORM); |
| 2235 | |
| 2236 | BTFIXUPSET_HALF(pte_writei, _SUN4C_PAGE_WRITE); |
| 2237 | BTFIXUPSET_HALF(pte_dirtyi, _SUN4C_PAGE_MODIFIED); |
| 2238 | BTFIXUPSET_HALF(pte_youngi, _SUN4C_PAGE_ACCESSED); |
| 2239 | BTFIXUPSET_HALF(pte_filei, _SUN4C_PAGE_FILE); |
| 2240 | BTFIXUPSET_HALF(pte_wrprotecti, _SUN4C_PAGE_WRITE|_SUN4C_PAGE_SILENT_WRITE); |
| 2241 | BTFIXUPSET_HALF(pte_mkcleani, _SUN4C_PAGE_MODIFIED|_SUN4C_PAGE_SILENT_WRITE); |
| 2242 | BTFIXUPSET_HALF(pte_mkoldi, _SUN4C_PAGE_ACCESSED|_SUN4C_PAGE_SILENT_READ); |
| 2243 | BTFIXUPSET_CALL(pte_mkwrite, sun4c_pte_mkwrite, BTFIXUPCALL_NORM); |
| 2244 | BTFIXUPSET_CALL(pte_mkdirty, sun4c_pte_mkdirty, BTFIXUPCALL_NORM); |
| 2245 | BTFIXUPSET_CALL(pte_mkyoung, sun4c_pte_mkyoung, BTFIXUPCALL_NORM); |
| 2246 | BTFIXUPSET_CALL(update_mmu_cache, sun4c_update_mmu_cache, BTFIXUPCALL_NORM); |
| 2247 | |
| 2248 | BTFIXUPSET_CALL(pte_to_pgoff, sun4c_pte_to_pgoff, BTFIXUPCALL_NORM); |
| 2249 | BTFIXUPSET_CALL(pgoff_to_pte, sun4c_pgoff_to_pte, BTFIXUPCALL_NORM); |
| 2250 | |
| 2251 | BTFIXUPSET_CALL(mmu_lockarea, sun4c_lockarea, BTFIXUPCALL_NORM); |
| 2252 | BTFIXUPSET_CALL(mmu_unlockarea, sun4c_unlockarea, BTFIXUPCALL_NORM); |
| 2253 | |
| 2254 | BTFIXUPSET_CALL(mmu_get_scsi_one, sun4c_get_scsi_one, BTFIXUPCALL_NORM); |
| 2255 | BTFIXUPSET_CALL(mmu_get_scsi_sgl, sun4c_get_scsi_sgl, BTFIXUPCALL_NORM); |
| 2256 | BTFIXUPSET_CALL(mmu_release_scsi_one, sun4c_release_scsi_one, BTFIXUPCALL_NORM); |
| 2257 | BTFIXUPSET_CALL(mmu_release_scsi_sgl, sun4c_release_scsi_sgl, BTFIXUPCALL_NORM); |
| 2258 | |
| 2259 | BTFIXUPSET_CALL(mmu_map_dma_area, sun4c_map_dma_area, BTFIXUPCALL_NORM); |
| 2260 | BTFIXUPSET_CALL(mmu_unmap_dma_area, sun4c_unmap_dma_area, BTFIXUPCALL_NORM); |
| 2261 | BTFIXUPSET_CALL(mmu_translate_dvma, sun4c_translate_dvma, BTFIXUPCALL_NORM); |
| 2262 | |
| 2263 | BTFIXUPSET_CALL(sparc_mapiorange, sun4c_mapiorange, BTFIXUPCALL_NORM); |
| 2264 | BTFIXUPSET_CALL(sparc_unmapiorange, sun4c_unmapiorange, BTFIXUPCALL_NORM); |
| 2265 | |
| 2266 | BTFIXUPSET_CALL(__swp_type, sun4c_swp_type, BTFIXUPCALL_NORM); |
| 2267 | BTFIXUPSET_CALL(__swp_offset, sun4c_swp_offset, BTFIXUPCALL_NORM); |
| 2268 | BTFIXUPSET_CALL(__swp_entry, sun4c_swp_entry, BTFIXUPCALL_NORM); |
| 2269 | |
| 2270 | BTFIXUPSET_CALL(alloc_thread_info, sun4c_alloc_thread_info, BTFIXUPCALL_NORM); |
| 2271 | BTFIXUPSET_CALL(free_thread_info, sun4c_free_thread_info, BTFIXUPCALL_NORM); |
| 2272 | |
| 2273 | BTFIXUPSET_CALL(mmu_info, sun4c_mmu_info, BTFIXUPCALL_NORM); |
| 2274 | |
| 2275 | /* These should _never_ get called with two level tables. */ |
| 2276 | BTFIXUPSET_CALL(pgd_set, sun4c_pgd_set, BTFIXUPCALL_NOP); |
Dave McCracken | 46a82b2 | 2006-09-25 23:31:48 -0700 | [diff] [blame] | 2277 | BTFIXUPSET_CALL(pgd_page_vaddr, sun4c_pgd_page, BTFIXUPCALL_RETO0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2278 | } |