X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=arch%2Fm68k%2Fsun3%2Fmmu_emu.c;h=7a0e3a22068708a47b1872c4dcc35507a3f515c5;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=864c980e5a7092a42cf679b0ef4d445cbc694846;hpb=5273a3df6485dc2ad6aa7ddd441b9a21970f003b;p=linux-2.6.git diff --git a/arch/m68k/sun3/mmu_emu.c b/arch/m68k/sun3/mmu_emu.c index 864c980e5..7a0e3a220 100644 --- a/arch/m68k/sun3/mmu_emu.c +++ b/arch/m68k/sun3/mmu_emu.c @@ -12,6 +12,8 @@ #include #include #include +#include +#include #include #include @@ -21,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -46,6 +47,8 @@ extern void prom_reboot (char *) __attribute__ ((__noreturn__)); */ unsigned long vmalloc_end; +EXPORT_SYMBOL(vmalloc_end); + unsigned long pmeg_vaddr[PMEGS_NUM]; unsigned char pmeg_alloc[PMEGS_NUM]; unsigned char pmeg_ctx[PMEGS_NUM]; @@ -125,12 +128,12 @@ void mmu_emu_init(unsigned long bootmem_end) { unsigned long seg, num; int i,j; - + memset(rom_pages, 0, sizeof(rom_pages)); memset(pmeg_vaddr, 0, sizeof(pmeg_vaddr)); memset(pmeg_alloc, 0, sizeof(pmeg_alloc)); memset(pmeg_ctx, 0, sizeof(pmeg_ctx)); - + /* pmeg align the end of bootmem, adding another pmeg, * later bootmem allocations will likely need it */ bootmem_end = (bootmem_end + (2 * SUN3_PMEG_SIZE)) & ~SUN3_PMEG_MASK; @@ -148,7 +151,7 @@ void mmu_emu_init(unsigned long bootmem_end) /* liberate all existing mappings in the rest of kernel space */ for(seg = bootmem_end; seg < 0x0f800000; seg += SUN3_PMEG_SIZE) { i = sun3_get_segmap(seg); - + if(!pmeg_alloc[i]) { #ifdef DEBUG_MMU_EMU printk("freed: "); @@ -179,13 +182,13 @@ void mmu_emu_init(unsigned long bootmem_end) pmeg_alloc[sun3_get_segmap(seg)] = 2; } } - + dvma_init(); - - + + /* blank everything below the kernel, and we've got the base mapping to start all the contexts off with... */ - for(seg = 0; seg < PAGE_OFFSET; seg += SUN3_PMEG_SIZE) + for(seg = 0; seg < PAGE_OFFSET; seg += SUN3_PMEG_SIZE) sun3_put_segmap(seg, SUN3_INVALID_PMEG); set_fs(MAKE_MM_SEG(3)); @@ -195,7 +198,7 @@ void mmu_emu_init(unsigned long bootmem_end) (*(romvec->pv_setctxt))(j, (void *)seg, i); } set_fs(KERNEL_DS); - + } /* erase the mappings for a dead context. Uses the pg_dir for hints @@ -207,9 +210,9 @@ void clear_context(unsigned long context) { unsigned char oldctx; unsigned long i; - + if(context) { - if(!ctx_alloc[context]) + if(!ctx_alloc[context]) panic("clear_context: context not allocated\n"); ctx_alloc[context]->context = SUN3_INVALID_CONTEXT; @@ -229,7 +232,7 @@ void clear_context(unsigned long context) pmeg_vaddr[i] = 0; } } - + sun3_put_context(oldctx); } @@ -239,7 +242,7 @@ void clear_context(unsigned long context) sure it could be much more intellegent... but it gets the job done for now without much overhead in making it's decision. */ /* todo: come up with optimized scheme for flushing contexts */ -unsigned long get_free_context(struct mm_struct *mm) +unsigned long get_free_context(struct mm_struct *mm) { unsigned long new = 1; static unsigned char next_to_die = 1; @@ -259,7 +262,7 @@ unsigned long get_free_context(struct mm_struct *mm) break; } // check to make sure one was really free... - if(new == CONTEXTS_NUM) + if(new == CONTEXTS_NUM) panic("get_free_context: failed to find free context"); } @@ -307,7 +310,7 @@ printk("mmu_emu_map_pmeg: pmeg %x to context %d vaddr %x\n", if(vaddr >= PAGE_OFFSET) { /* map kernel pmegs into all contexts */ unsigned char i; - + for(i = 0; i < CONTEXTS_NUM; i++) { sun3_put_context(i); sun3_put_segmap (vaddr, curr_pmeg); @@ -315,7 +318,7 @@ printk("mmu_emu_map_pmeg: pmeg %x to context %d vaddr %x\n", sun3_put_context(context); pmeg_alloc[curr_pmeg] = 2; pmeg_ctx[curr_pmeg] = 0; - + } else { pmeg_alloc[curr_pmeg] = 1; @@ -326,7 +329,7 @@ printk("mmu_emu_map_pmeg: pmeg %x to context %d vaddr %x\n", pmeg_vaddr[curr_pmeg] = vaddr; /* Set hardware mapping and clear the old PTE entries. */ - for (i=0; imm->context; - if(kernel_fault) + if(kernel_fault) crp = swapper_pg_dir; else crp = current->mm->pgd; @@ -390,11 +393,11 @@ int mmu_emu_handle_fault (unsigned long vaddr, int read_flag, int kernel_fault) pte = (pte_t *) __va ((unsigned long)(pte + offset)); /* Make sure this is a valid page */ - if (!(pte_val (*pte) & SUN3_PAGE_VALID)) + if (!(pte_val (*pte) & SUN3_PAGE_VALID)) return 0; /* Make sure there's a pmeg allocated for the page */ - if (sun3_get_segmap (vaddr&~SUN3_PMEG_MASK) == SUN3_INVALID_PMEG) + if (sun3_get_segmap (vaddr&~SUN3_PMEG_MASK) == SUN3_INVALID_PMEG) mmu_emu_map_pmeg (context, vaddr); /* Write the pte value to hardware MMU */ @@ -409,7 +412,7 @@ int mmu_emu_handle_fault (unsigned long vaddr, int read_flag, int kernel_fault) if (pte_val (*pte) & SUN3_PAGE_WRITEABLE) pte_val (*pte) |= (SUN3_PAGE_ACCESSED | SUN3_PAGE_MODIFIED); - else + else return 0; /* Write-protect error. */ } else pte_val (*pte) |= SUN3_PAGE_ACCESSED;