9 #include <linux/mman.h>
11 #include <linux/kernel.h>
12 #include <linux/ptrace.h>
15 #include <linux/bitops.h>
16 #include <linux/module.h>
18 #include <asm/setup.h>
19 #include <asm/traps.h>
20 #include <asm/uaccess.h>
22 #include <asm/pgtable.h>
24 #include <asm/segment.h>
25 #include <asm/oplib.h>
26 #include <asm/mmu_context.h>
31 #define DEBUG_PROM_MAPS
37 #define CONTEXTS_NUM 8
38 #define SEGMAPS_PER_CONTEXT_NUM 2048
39 #define PAGES_PER_SEGMENT 16
41 #define PMEG_MASK 0xFF
74 printk (
" pte=%lx [addr=%lx",
91 unsigned long val =
pte_val (pte);
102 switch (val & SUN3_PAGE_TYPE_MASK) {
107 default: type =
"unknown?";
break;
110 printk (
" pte=%08lx [%07lx %s %s]\n",
111 val, (val & SUN3_PAGE_PGNUM_MASK) <<
PAGE_SHIFT, flags, type);
118 printk (
" vaddr=%lx [%02lx]", vaddr, sun3_get_segmap (vaddr));
130 memset(rom_pages, 0,
sizeof(rom_pages));
146 for(num = 0xf0; num <= 0xff; num++)
151 i = sun3_get_segmap(seg);
163 for (num=0, seg=0x0F800000; seg<0x10000000; seg+=16*
PAGE_SIZE) {
165 #ifdef DEBUG_PROM_MAPS
166 for(i = 0; i < 16; i++) {
194 i = sun3_get_segmap(seg);
196 (*(
romvec->pv_setctxt))(
j, (
void *)seg, i);
209 unsigned char oldctx;
213 if(!ctx_alloc[context])
214 panic(
"clear_context: context not allocated\n");
221 oldctx = sun3_get_context();
223 sun3_put_context(context);
227 sun3_put_segmap(
pmeg_vaddr[i], SUN3_INVALID_PMEG);
234 sun3_put_context(oldctx);
245 unsigned long new = 1;
246 static unsigned char next_to_die = 1;
252 next_to_die = (next_to_die + 1) & 0x7;
264 panic(
"get_free_context: failed to find free context");
283 static unsigned char curr_pmeg = 128;
295 printk(
"mmu_emu_map_pmeg: pmeg %x to context %d vaddr %x\n",
296 curr_pmeg, context, vaddr);
301 sun3_put_context(
pmeg_ctx[curr_pmeg]);
303 sun3_put_context(context);
314 sun3_put_segmap (vaddr, curr_pmeg);
316 sun3_put_context(context);
324 sun3_put_segmap (vaddr, curr_pmeg);
364 context =
current->mm->context;
372 printk (
"mmu_emu_handle_fault: vaddr=%lx type=%s crp=%p\n",
373 vaddr, read_flag ?
"read" :
"write", crp);
380 printk (
"mmu_emu_handle_fault: segment=%lx offset=%lx\n", segment, offset);