diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2004-06-02 13:49:44 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2004-06-02 13:49:44 +0000 |
commit | fedac08c79b2b41bd42aa47525d76b27ca027c4a (patch) | |
tree | fcc01948dd2c4def4461f8c78473f2991234bb11 | |
parent | 9bb777f068fbb34930ccc6fbf86342bd7b1ad4ed (diff) |
More realistic kernel pdt sizing for the Luna88k (sync with recent mvme88k
changes) - makes almost 3MB more memory available for userland.
Tested by aoyama@
-rw-r--r-- | sys/arch/luna88k/include/pmap.h | 4 | ||||
-rw-r--r-- | sys/arch/luna88k/luna88k/machdep.c | 9 | ||||
-rw-r--r-- | sys/arch/luna88k/luna88k/pmap.c | 203 | ||||
-rw-r--r-- | sys/arch/luna88k/luna88k/pmap_table.c | 47 |
4 files changed, 71 insertions, 192 deletions
diff --git a/sys/arch/luna88k/include/pmap.h b/sys/arch/luna88k/include/pmap.h index d8864c577a7..6bac2b51e93 100644 --- a/sys/arch/luna88k/include/pmap.h +++ b/sys/arch/luna88k/include/pmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.h,v 1.2 2004/05/20 09:20:42 kettenis Exp $ */ +/* $OpenBSD: pmap.h,v 1.3 2004/06/02 13:49:41 miod Exp $ */ /* * Mach Operating System * Copyright (c) 1991 Carnegie Mellon University @@ -70,7 +70,7 @@ extern caddr_t vmmap; #define pmap_proc_iflush(p,va,len) do { /* nothing */ } while (0) -void pmap_bootstrap(vaddr_t, paddr_t *, paddr_t *, vaddr_t *, vaddr_t *); +void pmap_bootstrap(vaddr_t); void pmap_cache_ctrl(pmap_t, vaddr_t, vaddr_t, u_int); boolean_t pmap_unsetbit(struct vm_page *, int); diff --git a/sys/arch/luna88k/luna88k/machdep.c b/sys/arch/luna88k/luna88k/machdep.c index 7bccea52c0b..de60f0c84ab 100644 --- a/sys/arch/luna88k/luna88k/machdep.c +++ b/sys/arch/luna88k/luna88k/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.4 2004/05/10 10:30:24 aoyama Exp $ */ +/* $OpenBSD: machdep.c,v 1.5 2004/06/02 13:49:43 miod Exp $ */ /* * Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr. * Copyright (c) 1996 Nivas Madhur @@ -1685,15 +1685,14 @@ luna88k_bootstrap() #ifdef DEBUG printf("LUNA88K boot: memory from 0x%x to 0x%x\n", avail_start, avail_end); #endif - pmap_bootstrap((vaddr_t)trunc_page((unsigned)&kernelstart) /* = loadpt */, - &avail_start, &avail_end, &virtual_avail, - &virtual_end); + pmap_bootstrap((vaddr_t)trunc_page((unsigned)&kernelstart)); + /* * Tell the VM system about available physical memory. * luna88k only has one segment. */ uvm_page_physload(atop(avail_start), atop(avail_end), - atop(avail_start), atop(avail_end),VM_FREELIST_DEFAULT); + atop(avail_start), atop(avail_end),VM_FREELIST_DEFAULT); /* Initialize cached PTEs for u-area mapping. */ save_u_area(&proc0, (vaddr_t)proc0paddr); diff --git a/sys/arch/luna88k/luna88k/pmap.c b/sys/arch/luna88k/luna88k/pmap.c index 94131804dff..b53c23ee762 100644 --- a/sys/arch/luna88k/luna88k/pmap.c +++ b/sys/arch/luna88k/luna88k/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.3 2004/05/23 21:09:49 miod Exp $ */ +/* $OpenBSD: pmap.c,v 1.4 2004/06/02 13:49:43 miod Exp $ */ /* * Copyright (c) 2001, 2002, 2003 Miodrag Vallat * Copyright (c) 1998-2001 Steve Murphree, Jr. @@ -142,25 +142,6 @@ struct kpdt_entry { kpdt_entry_t kpdt_free; /* - * MAX_KERNEL_VA_SIZE must fit into the virtual address space between - * VM_MIN_KERNEL_ADDRESS and VM_MAX_KERNEL_ADDRESS. - */ - -#define MAX_KERNEL_VA_SIZE (256*1024*1024) /* 256 Mb */ - -/* - * Size of kernel page tables, which is enough to map MAX_KERNEL_VA_SIZE - */ -#define KERNEL_PDT_SIZE (atop(MAX_KERNEL_VA_SIZE) * sizeof(pt_entry_t)) - -/* - * Size of kernel page tables for mapping onboard IO space. - */ -#define OBIO_PDT_SIZE (atop(OBIO_SIZE) * sizeof(pt_entry_t)) - -#define MAX_KERNEL_PDT_SIZE (KERNEL_PDT_SIZE + OBIO_PDT_SIZE) - -/* * Two pages of scratch space per cpu. * Used in pmap_copy_page() and pmap_zero_page(). */ @@ -653,10 +634,6 @@ pmap_cache_ctrl(pmap_t pmap, vaddr_t s, vaddr_t e, u_int mode) * * Parameters: * load_start PA where kernel was loaded - * &phys_start PA of first available physical page - * &phys_end PA of last available physical page - * &virtual_avail VA of first available page (after kernel bss) - * &virtual_end VA of last available page (end of kernel address space) * * Extern/Global: * @@ -674,9 +651,7 @@ pmap_cache_ctrl(pmap_t pmap, vaddr_t s, vaddr_t e, u_int mode) * virtual address for which it was (presumably) linked. Immediately * following the end of the kernel code/data, sufficient page of * physical memory are reserved to hold translation tables for the kernel - * address space. The 'phys_start' parameter is adjusted upward to - * reflect this allocation. This space is mapped in virtual memory - * immediately following the kernel code/data map. + * address space. * * A pair of virtual pages per cpu are reserved for debugging and * IO purposes. They are arbitrarily mapped when needed. They are used, @@ -689,26 +664,18 @@ pmap_cache_ctrl(pmap_t pmap, vaddr_t s, vaddr_t e, u_int mode) */ void -pmap_bootstrap(vaddr_t load_start, paddr_t *phys_start, paddr_t *phys_end, - vaddr_t *virt_start, vaddr_t *virt_end) +pmap_bootstrap(vaddr_t load_start) { kpdt_entry_t kpdt_virt; sdt_entry_t *kmap; - vaddr_t vaddr, virt, kernel_pmap_size, pdt_size; + vaddr_t vaddr, virt; paddr_t s_text, e_text, kpdt_phys; pt_entry_t *pte; + unsigned int kernel_pmap_size, pdt_size; int i; pmap_table_t ptable; extern void *kernelstart, *etext; -#ifdef DEBUG - if (pmap_con_dbg & CD_BOOT) { - printf("pmap_bootstrap: \"load_start\" 0x%x\n", load_start); - } - if (!PAGE_ALIGNED(load_start)) - panic("pmap_bootstrap: \"load_start\" not on the m88k page boundary: 0x%x", load_start); -#endif - simple_lock_init(&kernel_pmap->pm_lock); /* @@ -722,11 +689,11 @@ pmap_bootstrap(vaddr_t load_start, paddr_t *phys_start, paddr_t *phys_end, * kernelstart is the first symbol in the load image. * We link the kernel such that &kernelstart == 0x20000 * The expression (&kernelstart - load_start) will end up as - * 0, making *virt_start == *phys_start, giving a 1-to-1 map) + * 0, making virtual_avail == avail_start, giving a 1-to-1 map) */ - *phys_start = round_page(*phys_start); - *virt_start = *phys_start + + avail_start = round_page(avail_start); + virtual_avail = avail_start + (trunc_page((vaddr_t)&kernelstart) - load_start); /* @@ -734,16 +701,9 @@ pmap_bootstrap(vaddr_t load_start, paddr_t *phys_start, paddr_t *phys_end, */ kernel_pmap->pm_count = 1; kernel_pmap->pm_cpus = 0; - kmap = (sdt_entry_t *)(*phys_start); - kernel_pmap->pm_stab = (sdt_entry_t *)(*virt_start); - kmapva = *virt_start; - -#ifdef DEBUG - if ((pmap_con_dbg & (CD_BOOT | CD_FULL)) == (CD_BOOT | CD_FULL)) { - printf("kernel_pmap->pm_stab = 0x%x (pa 0x%x)\n", - kernel_pmap->pm_stab, kmap); - } -#endif + kmap = (sdt_entry_t *)(avail_start); + kernel_pmap->pm_stab = (sdt_entry_t *)virtual_avail; + kmapva = virtual_avail; /* * Reserve space for segment table entries. @@ -760,48 +720,41 @@ pmap_bootstrap(vaddr_t load_start, paddr_t *phys_start, paddr_t *phys_end, kernel_pmap_size = 2 * SDT_SIZE; #ifdef DEBUG - if ((pmap_con_dbg & (CD_BOOT | CD_FULL)) == (CD_BOOT | CD_FULL)) { - printf("kernel segment table size = 0x%x\n", kernel_pmap_size); - } + printf("kernel segment table size = 0x%x\n", kernel_pmap_size); #endif /* init all segment descriptors to zero */ bzero(kernel_pmap->pm_stab, kernel_pmap_size); - *phys_start += kernel_pmap_size; - *virt_start += kernel_pmap_size; + avail_start += kernel_pmap_size; + virtual_avail += kernel_pmap_size; /* make sure page tables are page aligned!! XXX smurph */ - *phys_start = round_page(*phys_start); - *virt_start = round_page(*virt_start); + avail_start = round_page(avail_start); + virtual_avail = round_page(virtual_avail); /* save pointers to where page table entries start in physical memory */ - kpdt_phys = *phys_start; - kpdt_virt = (kpdt_entry_t)*virt_start; - - /* might as well round up to a page - XXX smurph */ - pdt_size = round_page(MAX_KERNEL_PDT_SIZE); + kpdt_phys = avail_start; + kpdt_virt = (kpdt_entry_t)virtual_avail; + + /* Compute how much space we need for the kernel page table */ + pdt_size = atop(VM_MAX_KERNEL_ADDRESS - VM_MIN_KERNEL_ADDRESS) + * sizeof(pt_entry_t); + for (ptable = pmap_table_build(); ptable->size != (vsize_t)-1; ptable++) + pdt_size += atop(ptable->size) * sizeof(pt_entry_t); + pdt_size = round_page(pdt_size); kernel_pmap_size += pdt_size; - *phys_start += pdt_size; - *virt_start += pdt_size; + avail_start += pdt_size; + virtual_avail += pdt_size; /* init all page descriptors to zero */ bzero((void *)kpdt_phys, pdt_size); #ifdef DEBUG - if ((pmap_con_dbg & (CD_BOOT | CD_FULL)) == (CD_BOOT | CD_FULL)) { - printf("--------------------------------------\n"); - printf(" kernel page start = 0x%x\n", kpdt_phys); - printf(" kernel page table size = 0x%x\n", pdt_size); - printf(" kernel page end = 0x%x\n", *phys_start); - } -#endif + printf("--------------------------------------\n"); + printf(" kernel page start = 0x%x\n", kpdt_phys); + printf(" kernel page table size = 0x%x\n", pdt_size); + printf(" kernel page end = 0x%x\n", avail_start); -#ifdef DEBUG - if ((pmap_con_dbg & (CD_BOOT | CD_FULL)) == (CD_BOOT | CD_FULL)) { - printf("kpdt_phys = 0x%x\n", kpdt_phys); - printf("kpdt_virt = 0x%x\n", kpdt_virt); - printf("end of kpdt at (virt)0x%08x, (phys)0x%08x\n", - *virt_start, *phys_start); - } + printf("kpdt_virt = 0x%x\n", kpdt_virt); #endif /* * init the kpdt queue @@ -825,11 +778,9 @@ pmap_bootstrap(vaddr_t load_start, paddr_t *phys_start, paddr_t *phys_end, /* paddr of end of text section*/ e_text = round_page(e_text); -#if 0 /* map the first 128k (PROM work) read only, cache inhibited (? XXX) */ vaddr = pmap_map(0, 0, 0x20000, VM_PROT_WRITE | VM_PROT_READ, CACHE_INH); -#endif /* map the kernel text read only */ vaddr = pmap_map(trunc_page((vaddr_t)&kernelstart), @@ -846,60 +797,23 @@ pmap_bootstrap(vaddr_t load_start, paddr_t *phys_start, paddr_t *phys_end, * here... */ if (kmapva != vaddr) { -#ifdef DEBUG - if ((pmap_con_dbg & (CD_BOOT | CD_FULL)) == (CD_BOOT | CD_FULL)) { - printf("(pmap_bootstrap) correcting vaddr\n"); - } -#endif - while (vaddr < (*virt_start - kernel_pmap_size)) + while (vaddr < (virtual_avail - kernel_pmap_size)) vaddr = round_page(vaddr + 1); } - vaddr = pmap_map(vaddr, (paddr_t)kmap, *phys_start, + vaddr = pmap_map(vaddr, (paddr_t)kmap, avail_start, VM_PROT_WRITE | VM_PROT_READ, CACHE_INH); -#if defined (MVME187) || defined (MVME197) - /* - * Get ethernet buffer - need etherlen bytes physically contiguous. - * 1 to 1 mapped as well???. There is actually a bug in the macros - * used by the 1x7 ethernet driver. Remove this when that is fixed. - * XXX -nivas - */ - if (brdtyp == BRD_187 || brdtyp == BRD_8120 || brdtyp == BRD_197) { - *phys_start = vaddr; - etherlen = ETHERPAGES * PAGE_SIZE; - etherbuf = (void *)vaddr; - - vaddr = pmap_map(vaddr, *phys_start, *phys_start + etherlen, - VM_PROT_WRITE | VM_PROT_READ, CACHE_INH); - - *virt_start += etherlen; - *phys_start += etherlen; - - if (vaddr != *virt_start) { -#ifdef DEBUG - if ((pmap_con_dbg & (CD_BOOT | CD_FULL)) == (CD_BOOT | CD_FULL)) { - printf("2: vaddr %x *virt_start %x *phys_start %x\n", vaddr, - *virt_start, *phys_start); - } -#endif - *virt_start = vaddr; - *phys_start = round_page(*phys_start); - } - } - -#endif /* defined (MVME187) || defined (MVME197) */ - - *virt_start = round_page(*virt_start); - *virt_end = VM_MAX_KERNEL_ADDRESS; + virtual_avail = round_page(virtual_avail); + virtual_end = VM_MAX_KERNEL_ADDRESS; /* * Map two pages per cpu for copying/zeroing. */ - phys_map_vaddr = *virt_start; - phys_map_vaddr_end = *virt_start + 2 * (max_cpus << PAGE_SHIFT); - *phys_start += 2 * (max_cpus << PAGE_SHIFT); - *virt_start += 2 * (max_cpus << PAGE_SHIFT); + phys_map_vaddr = virtual_avail; + phys_map_vaddr_end = virtual_avail + 2 * (max_cpus << PAGE_SHIFT); + avail_start += 2 * (max_cpus << PAGE_SHIFT); + virtual_avail += 2 * (max_cpus << PAGE_SHIFT); /* * Map all IO space 1-to-1. Ideally, I would like to not do this @@ -911,20 +825,12 @@ pmap_bootstrap(vaddr_t load_start, paddr_t *phys_start, paddr_t *phys_end, * OBIO should be mapped cache inhibited. */ - ptable = pmap_table_build(); -#ifdef DEBUG - if ((pmap_con_dbg & (CD_BOOT | CD_FULL)) == (CD_BOOT | CD_FULL)) { - printf("pmap_bootstrap: -> pmap_table_build\n"); - } -#endif - - for (; ptable->size != (vsize_t)(-1); ptable++){ - if (ptable->size) { + for (ptable = pmap_table_build(); ptable->size != (vsize_t)-1; ptable++) + if (ptable->size != 0) { pmap_map(ptable->virt_start, ptable->phys_start, ptable->phys_start + ptable->size, ptable->prot, ptable->cacheability); } - } /* * Allocate all the submaps we need. Note that SYSMAP just allocates @@ -943,14 +849,14 @@ pmap_bootstrap(vaddr_t load_start, paddr_t *phys_start, paddr_t *phys_end, virt += ((n) * PAGE_SIZE); \ }) - virt = *virt_start; + virt = virtual_avail; SYSMAP(caddr_t, vmpte, vmmap, 1); invalidate_pte(vmpte); SYSMAP(struct msgbuf *, msgbufmap, msgbufp, btoc(MSGBUFSIZE)); - *virt_start = virt; + virtual_avail = virt; /* * Set translation for UPAGES at UADDR. The idea is we want to @@ -961,11 +867,6 @@ pmap_bootstrap(vaddr_t load_start, paddr_t *phys_start, paddr_t *phys_end, */ for (i = 0, virt = UADDR; i < UPAGES; i++, virt += PAGE_SIZE) { -#ifdef DEBUG - if ((pmap_con_dbg & (CD_BOOT | CD_FULL)) == (CD_BOOT | CD_FULL)) { - printf("setting up mapping for Upage %d @ %x\n", i, virt); - } -#endif if ((pte = pmap_pte(kernel_pmap, virt)) == PT_ENTRY_NULL) pmap_expand_kmap(virt, VM_PROT_READ | VM_PROT_WRITE); } @@ -976,11 +877,7 @@ pmap_bootstrap(vaddr_t load_start, paddr_t *phys_start, paddr_t *phys_end, kernel_pmap->pm_apr = (atop(kmap) << PG_SHIFT) | CACHE_GLOBAL | CACHE_WT | APR_V; -#ifdef DEBUG - if ((pmap_con_dbg & (CD_BOOT | CD_FULL)) == (CD_BOOT | CD_FULL)) { - show_apr(kernel_pmap->pm_apr); - } -#endif + /* Invalidate entire kernel TLB and get ready for address translation */ for (i = 0; i < MAX_CPUS; i++) if (cpu_sets[i]) { @@ -989,18 +886,10 @@ pmap_bootstrap(vaddr_t load_start, paddr_t *phys_start, paddr_t *phys_end, /* Load supervisor pointer to segment table. */ cmmu_set_sapr(i, kernel_pmap->pm_apr); #ifdef DEBUG - if ((pmap_con_dbg & (CD_BOOT | CD_FULL)) == (CD_BOOT | CD_FULL)) { - printf("Processor %d running virtual.\n", i); - } + printf("cpu%d: running virtual\n", i); #endif SETBIT_CPUSET(i, &kernel_pmap->pm_cpus); } - -#ifdef DEBUG - if ((pmap_con_dbg & (CD_BOOT | CD_FULL)) == (CD_BOOT | CD_FULL)) { - printf("running virtual - avail_next 0x%x\n", *phys_start); - } -#endif } /* diff --git a/sys/arch/luna88k/luna88k/pmap_table.c b/sys/arch/luna88k/luna88k/pmap_table.c index 9800edd714c..2979b902a72 100644 --- a/sys/arch/luna88k/luna88k/pmap_table.c +++ b/sys/arch/luna88k/luna88k/pmap_table.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap_table.c,v 1.1 2004/04/21 15:24:13 aoyama Exp $ */ +/* $OpenBSD: pmap_table.c,v 1.2 2004/06/02 13:49:43 miod Exp $ */ /* * Mach Operating System @@ -43,27 +43,19 @@ /* phys_start, virt_start, size, prot, cacheability */ const pmap_table_entry luna88k_board_table[] = { -#if 0 - { 0 , VEQR_ADDR , 48*1024*1024 /* XXX memory size */, RW, CG}, -#endif - { 0 , 0 , round_page(0x20000) /* XXX kernel start */, RW, CG}, - { OBIO_START , OBIO_START , round_page(OBIO_SIZE), RW, CI }, -#if 0 - { TRI_PORT_RAM, TRI_PORT_RAM, TRI_PORT_RAM_SPACE, RW, CI }, - { 0 , VEQR_ADDR , 48*1024*1024 /* XXX memory size */, RW, CG}, - { 0 , 0 , 0x20000 /* XXX kernel start */, RW, CG}, - { PROM_ADDR , PROM_ADDR , PROM_SPACE , R, C }, + { PROM_ADDR , PROM_ADDR , PROM_SPACE , R, CI }, { FUSE_ROM_ADDR, FUSE_ROM_ADDR, FUSE_ROM_SPACE, RW, CI }, { NVRAM_ADDR , NVRAM_ADDR , NVRAM_SPACE , RW, CI }, - { OBIO_PIO0_BASE, OBIO_PIO0_BASE, PAGE, RW, CI }, - { OBIO_PIO1_BASE, OBIO_PIO1_BASE, PAGE, RW, CI }, - { OBIO_SIO , OBIO_SIO, PAGE, RW, CI }, - { OBIO_TAS , OBIO_TAS, PAGE, RW, CI }, - { OBIO_CLOCK0 , OBIO_CLOCK0, PAGE, RW, CI }, - { INT_ST_MASK0 , INT_ST_MASK0, PAGE, RW, CI }, - { SOFT_INT0 , SOFT_INT0, PAGE, W, CI }, - { SOFT_INT_FLAG0, SOFT_INT_FLAG0, PAGE, RW, CI }, - { RESET_CPU0 , RESET_CPU0, PAGE, RW, CI }, + { OBIO_PIO0_BASE, OBIO_PIO0_BASE, PAGE_SIZE, RW, CI }, + { OBIO_PIO1_BASE, OBIO_PIO1_BASE, PAGE_SIZE, RW, CI }, + { OBIO_SIO , OBIO_SIO, PAGE_SIZE, RW, CI }, + { OBIO_TAS , OBIO_TAS, PAGE_SIZE, RW, CI }, + { OBIO_CLOCK0 , OBIO_CLOCK0, PAGE_SIZE, RW, CI }, + { INT_ST_MASK0 , INT_ST_MASK0, PAGE_SIZE, RW, CI }, + { SOFT_INT0 , SOFT_INT0, PAGE_SIZE, RW, CI }, + { SOFT_INT_FLAG0, SOFT_INT_FLAG0, PAGE_SIZE, RW, CI }, + { RESET_CPU0 , RESET_CPU0, PAGE_SIZE, RW, CI }, + { TRI_PORT_RAM, TRI_PORT_RAM, TRI_PORT_RAM_SPACE, RW, CI }, #if 0 { EXT_A_ADDR , EXT_A_ADDR, EXT_A_SPACE, RW, CI }, { EXT_B_ADDR , EXT_B_ADDR, EXT_B_SPACE, RW, CI }, @@ -71,14 +63,13 @@ luna88k_board_table[] = { #endif { MROM_ADDR , MROM_ADDR, MROM_SPACE, R, CI }, { BMAP_START , BMAP_START, BMAP_SPACE, RW, CI }, - { BMAP_PALLET0 , BMAP_PALLET0, PAGE, RW, CI }, - { BMAP_PALLET1 , BMAP_PALLET1, PAGE, RW, CI }, - { BMAP_PALLET2 , BMAP_PALLET2, PAGE, RW, CI }, - { BOARD_CHECK_REG, BOARD_CHECK_REG,PAGE, RW, CI }, - { BMAP_CRTC, BMAP_CRTC, PAGE, RW, CI }, - { SCSI_ADDR, SCSI_ADDR, PAGE, RW, C}, - { LANCE_ADDR, LANCE_ADDR, PAGE, RW, CI }, -#endif + { BMAP_PALLET0 , BMAP_PALLET0, PAGE_SIZE, RW, CI }, + { BMAP_PALLET1 , BMAP_PALLET1, PAGE_SIZE, RW, CI }, + { BMAP_PALLET2 , BMAP_PALLET2, PAGE_SIZE, RW, CI }, + { BOARD_CHECK_REG, BOARD_CHECK_REG,PAGE_SIZE, RW, CI }, + { BMAP_CRTC, BMAP_CRTC, PAGE_SIZE, RW, CI }, + { SCSI_ADDR, SCSI_ADDR, PAGE_SIZE, RW, CI }, + { LANCE_ADDR, LANCE_ADDR, PAGE_SIZE, RW, CI }, { 0, 0, 0xffffffff, 0, 0 }, }; |