in sun3/mmu_emu.c [126:200]
void __init 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;
/* mark all of the pmegs used thus far as reserved */
for (i=0; i < __pa(bootmem_end) / SUN3_PMEG_SIZE ; ++i)
pmeg_alloc[i] = 2;
/* I'm thinking that most of the top pmeg's are going to be
used for something, and we probably shouldn't risk it */
for(num = 0xf0; num <= 0xff; num++)
pmeg_alloc[num] = 2;
/* 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
pr_info("freed:");
print_pte_vaddr (seg);
#endif
sun3_put_segmap(seg, SUN3_INVALID_PMEG);
}
}
j = 0;
for (num=0, seg=0x0F800000; seg<0x10000000; seg+=16*PAGE_SIZE) {
if (sun3_get_segmap (seg) != SUN3_INVALID_PMEG) {
#ifdef DEBUG_PROM_MAPS
for(i = 0; i < 16; i++) {
pr_info("mapped:");
print_pte_vaddr (seg + (i*PAGE_SIZE));
break;
}
#endif
// the lowest mapping here is the end of our
// vmalloc region
if (!m68k_vmalloc_end)
m68k_vmalloc_end = seg;
// mark the segmap alloc'd, and reserve any
// of the first 0xbff pages the hardware is
// already using... does any sun3 support > 24mb?
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)
sun3_put_segmap(seg, SUN3_INVALID_PMEG);
set_fc(3);
for(seg = 0; seg < 0x10000000; seg += SUN3_PMEG_SIZE) {
i = sun3_get_segmap(seg);
for(j = 1; j < CONTEXTS_NUM; j++)
(*(romvec->pv_setctxt))(j, (void *)seg, i);
}
set_fc(USER_DATA);
}