diff options
author | Steve Murphree <smurph@cvs.openbsd.org> | 2001-03-12 07:38:34 +0000 |
---|---|---|
committer | Steve Murphree <smurph@cvs.openbsd.org> | 2001-03-12 07:38:34 +0000 |
commit | 13a6a29647ee6b88dff15c2d9c76dcb4e509cf08 (patch) | |
tree | 777f2593da65dde2163c1d5494feb4152d582763 | |
parent | 01cc1fb0ce388c35df8114b144b2bab836cece11 (diff) |
Initial code for UVM. not tested yet...
-rw-r--r-- | sys/arch/mvme68k/mvme68k/genassym.cf | 11 | ||||
-rw-r--r-- | sys/arch/mvme68k/mvme68k/locore.s | 6 | ||||
-rw-r--r-- | sys/arch/mvme68k/mvme68k/machdep.c | 113 | ||||
-rw-r--r-- | sys/arch/mvme68k/mvme68k/mem.c | 21 | ||||
-rw-r--r-- | sys/arch/mvme68k/mvme68k/pmap.c | 167 | ||||
-rw-r--r-- | sys/arch/mvme68k/mvme68k/pmap_bootstrap.c | 10 | ||||
-rw-r--r-- | sys/arch/mvme68k/mvme68k/trap.c | 41 | ||||
-rw-r--r-- | sys/arch/mvme68k/mvme68k/vm_machdep.c | 21 |
8 files changed, 341 insertions, 49 deletions
diff --git a/sys/arch/mvme68k/mvme68k/genassym.cf b/sys/arch/mvme68k/mvme68k/genassym.cf index c100d3e5a17..2159793ab3f 100644 --- a/sys/arch/mvme68k/mvme68k/genassym.cf +++ b/sys/arch/mvme68k/mvme68k/genassym.cf @@ -1,4 +1,4 @@ -# $OpenBSD: genassym.cf,v 1.4 2000/07/06 12:56:18 art Exp $ +# $OpenBSD: genassym.cf,v 1.5 2001/03/12 07:38:29 smurph Exp $ # # Copyright (c) 1995 Theo de Raadt @@ -83,6 +83,10 @@ include <machine/prom.h> include <machine/pte.h> include <vm/vm.h> +ifdef UVM +include <uvm/uvm_extern.h> +endif + define __XXX_BUG_FODDER 0 # CPU options @@ -128,7 +132,12 @@ define SRUN SRUN # interrupt/fault metering define V_SWTCH offsetof(struct vmmeter, v_swtch) + +ifdef UVM +define UVMEXP_INTRS offsetof(struct uvmexp, intrs) +else define V_INTR offsetof(struct vmmeter, v_intr) +endif # trap types (should just include trap.h?) define T_BUSERR T_BUSERR diff --git a/sys/arch/mvme68k/mvme68k/locore.s b/sys/arch/mvme68k/mvme68k/locore.s index 2c10c1ceb0b..ba338ef4161 100644 --- a/sys/arch/mvme68k/mvme68k/locore.s +++ b/sys/arch/mvme68k/mvme68k/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.22 2000/07/06 12:56:18 art Exp $ */ +/* $OpenBSD: locore.s,v 1.23 2001/03/12 07:38:31 smurph Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -456,7 +456,7 @@ Lstart2: #endif /* do pmap_bootstrap stuff */ - RELOC(_mmutype, a0) + RELOC(_mmutype, a0) cmpl #MMU_68060,a0@ | 68060? jne Lpmap040 | no, skip pea a5@ | firstpa @@ -1827,7 +1827,7 @@ _getdfc: /* * Load a new user segment table pointer. */ -ENTRY(loadustp) /* XXX - smuprh */ +ENTRY(loadustp) /* XXX - smurph */ movl sp@(4),d0 | new USTP moveq #PGSHIFT,d1 lsll d1,d0 | convert to addr diff --git a/sys/arch/mvme68k/mvme68k/machdep.c b/sys/arch/mvme68k/mvme68k/machdep.c index 6ea693627e1..74c749ef921 100644 --- a/sys/arch/mvme68k/mvme68k/machdep.c +++ b/sys/arch/mvme68k/mvme68k/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.33 2000/03/23 09:59:55 art Exp $ */ +/* $OpenBSD: machdep.c,v 1.34 2001/03/12 07:38:31 smurph Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -117,10 +117,21 @@ #define MAXMEM 64*1024*CLSIZE /* XXX - from cmap.h */ #include <vm/vm_kern.h> +#if defined(UVM) +#include <uvm/uvm_extern.h> +#endif + /* the following is used externally (sysctl_hw) */ char machine[] = "mvme68k"; /* cpu "architecture" */ +#if defined(UVM) +vm_map_t exec_map = NULL; +vm_map_t mb_map = NULL; +vm_map_t phys_map = NULL; +#else vm_map_t buffer_map; +#endif + extern vm_offset_t avail_end; /* @@ -188,12 +199,15 @@ mvme68k_init() * Tell the VM system about available physical memory. The * hp300 only has one segment. */ + #if defined(UVM) + uvmexp.pagesize = NBPG; + uvm_setpagesize(); uvm_page_physload(atop(avail_start), atop(avail_end), - atop(avail_start), atop(avail_end)); + atop(avail_start), atop(avail_end), VM_FREELIST_DEFAULT); #else vm_page_physload(atop(avail_start), atop(avail_end), - atop(avail_start), atop(avail_end)); + atop(avail_start), atop(avail_end)); #endif /* UVM */ #endif /* MACHINE_NEW_NONCONTIG */ @@ -239,7 +253,12 @@ cpu_startup() register unsigned i; register caddr_t v, firstaddr; int base, residual; + +#if defined(UVM) + vaddr_t minaddr, maxaddr; +#else vm_offset_t minaddr, maxaddr; +#endif vm_size_t size; #ifdef BUFFERS_UNMANAGED vm_offset_t bufmemp; @@ -330,18 +349,28 @@ cpu_startup() if (nswbuf > 256) nswbuf = 256; /* sanity */ } +#if !defined(UVM) valloc(swbuf, struct buf, nswbuf); +#endif valloc(buf, struct buf, nbuf); /* * End of first pass, size has been calculated so allocate memory */ if (firstaddr == 0) { size = (vm_size_t)(v - firstaddr); +#if defined(UVM) + firstaddr = (caddr_t) uvm_km_zalloc(kernel_map, round_page(size)); +#else firstaddr = (caddr_t) kmem_alloc(kernel_map, round_page(size)); +#endif if (firstaddr == 0) panic("startup: no room for tables"); #ifdef BUFFERS_UNMANAGED +#if defined(UVM) + buffermem = (caddr_t) uvm_km_zalloc(kernel_map, bufpages*CLBYTES); +#else buffermem = (caddr_t) kmem_alloc(kernel_map, bufpages*CLBYTES); +#endif if (buffermem == 0) panic("startup: no room for buffers"); #endif @@ -357,15 +386,55 @@ cpu_startup() * in that they usually occupy more virtual memory than physical. */ size = MAXBSIZE * nbuf; + +#if defined(UVM) + if (uvm_map(kernel_map, (vaddr_t *) &buffers, m88k_round_page(size), + NULL, UVM_UNKNOWN_OFFSET, + UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE, + UVM_ADV_NORMAL, 0)) != KERN_SUCCESS) + panic("cpu_startup: cannot allocate VM for buffers"); + minaddr = (vaddr_t)buffers; +#else buffer_map = kmem_suballoc(kernel_map, (vm_offset_t *)&buffers, - &maxaddr, size, TRUE); + &maxaddr, size, TRUE); minaddr = (vm_offset_t)buffers; if (vm_map_find(buffer_map, vm_object_allocate(size), (vm_offset_t)0, - &minaddr, size, FALSE) != KERN_SUCCESS) + (vm_offset_t *)&minaddr, size, FALSE) != KERN_SUCCESS) panic("startup: cannot allocate buffers"); +#endif + + if ((bufpages / nbuf) >= btoc(MAXBSIZE)) { + /* don't want to alloc more physical mem than needed */ + bufpages = btoc(MAXBSIZE) * nbuf; + } base = bufpages / nbuf; residual = bufpages % nbuf; - for (i = 0; i < nbuf; i++) { +#if defined(UVM) + vsize_t curbufsize; + vaddr_t curbuf; + struct vm_page *pg; + + /* + * Each buffer has MAXBSIZE bytes of VM space allocated. Of + * that MAXBSIZE space, we allocate and map (base+1) pages + * for the first "residual" buffers, and then we allocate + * "base" pages for the rest. + */ + curbuf = (vm_offset_t) buffers + (i * MAXBSIZE); + curbufsize = CLBYTES * ((i < residual) ? (base+1) : base); + + while (curbufsize) { + pg = uvm_pagealloc(NULL, 0, NULL, 0); + if (pg == NULL) + panic("cpu_startup: not enough memory for " + "buffer cache"); + pmap_enter(kernel_map->pmap, curbuf, + VM_PAGE_TO_PHYS(pg), VM_PROT_ALL, TRUE, + VM_PROT_READ|VM_PROT_WRITE); + curbuf += PAGE_SIZE; + curbufsize -= PAGE_SIZE; + } +#else vm_size_t curbufsize; vm_offset_t curbuf; @@ -378,20 +447,32 @@ cpu_startup() */ curbuf = (vm_offset_t)buffers + i * MAXBSIZE; curbufsize = CLBYTES * (i < residual ? base+1 : base); + /* this faults in the required physical pages */ vm_map_pageable(buffer_map, curbuf, curbuf+curbufsize, FALSE); vm_map_simplify(buffer_map, curbuf); +#endif } /* * Allocate a submap for exec arguments. This map effectively * limits the number of processes exec'ing at any time. */ +#if defined(UVM) + exec_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, + 16*NCARGS, VM_MAP_PAGEABLE, FALSE, NULL); +#else exec_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr, - 16*NCARGS, TRUE); + 16*NCARGS, TRUE); +#endif /* * Allocate a submap for physio */ - phys_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr, - VM_PHYS_SIZE, TRUE); +#if defined(UVM) + phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr, + VM_PHYS_SIZE, 0, FALSE, NULL); +#else + phys_map = kmem_suballoc(kernel_map, &minaddr, &maxaddr, + VM_PHYS_SIZE, TRUE); +#endif /* * Finally, allocate mbuf pool. Since mclrefcnt is an off-size @@ -400,8 +481,13 @@ cpu_startup() mclrefcnt = (char *)malloc(NMBCLUSTERS+CLBYTES/MCLBYTES, M_MBUF, M_NOWAIT); bzero(mclrefcnt, NMBCLUSTERS+CLBYTES/MCLBYTES); +#if defined(UVM) + mb_map = uvm_km_suballoc(kernel_map, (vaddr_t *)&mbutl, &maxaddr, + VM_MBUF_SIZE, VM_MAP_INTRSAFE, FALSE, NULL); +#else mb_map = kmem_suballoc(kernel_map, (vm_offset_t *)&mbutl, &maxaddr, - VM_MBUF_SIZE, FALSE); + VM_MBUF_SIZE, FALSE); +#endif /* * Initialize timeouts */ @@ -410,7 +496,12 @@ cpu_startup() #ifdef DEBUG pmapdebug = opmapdebug; #endif - printf("avail mem = %d\n", ptoa(cnt.v_free_count)); +#if defined(UVM) + printf("avail mem = %ld (%ld pages)\n", ptoa(uvmexp.free), uvmexp.free); +#else + printf("avail mem = %ld (%ld pages)\n", ptoa(cnt.v_free_count), + ptoa(cnt.v_free_count)/NBPG); +#endif printf("using %d buffers containing %d bytes of memory\n", nbuf, bufpages * CLBYTES); #ifdef MFS diff --git a/sys/arch/mvme68k/mvme68k/mem.c b/sys/arch/mvme68k/mvme68k/mem.c index 32045ee18be..6f96bcc0a0e 100644 --- a/sys/arch/mvme68k/mvme68k/mem.c +++ b/sys/arch/mvme68k/mvme68k/mem.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mem.c,v 1.9 1999/11/22 19:22:00 matthieu Exp $ */ +/* $OpenBSD: mem.c,v 1.10 2001/03/12 07:38:32 smurph Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -83,6 +83,9 @@ #include <machine/cpu.h> #include <vm/vm.h> +#if defined(UVM) +#include <uvm/uvm_extern.h> +#endif extern u_int lowram; static caddr_t devzeropage; @@ -161,11 +164,11 @@ mmrw(dev, uio, flags) } #endif - pmap_enter(pmap_kernel(), (vm_offset_t)vmmap, - trunc_page(v), - uio->uio_rw == UIO_READ ? VM_PROT_READ : VM_PROT_WRITE, - TRUE, - uio->uio_rw == UIO_READ ? VM_PROT_READ : VM_PROT_WRITE); + pmap_enter(pmap_kernel(), (vm_offset_t)vmmap, + trunc_page(v), + uio->uio_rw == UIO_READ ? VM_PROT_READ : VM_PROT_WRITE, + TRUE, + uio->uio_rw == UIO_READ ? VM_PROT_READ : VM_PROT_WRITE); o = uio->uio_offset & PGOFSET; c = min(uio->uio_resid, (int)(NBPG - o)); @@ -178,9 +181,15 @@ mmrw(dev, uio, flags) case 1: v = uio->uio_offset; c = min(iov->iov_len, MAXPHYS); +#if defined(UVM) + if (!uvm_kernacc((caddr_t)v, c, + uio->uio_rw == UIO_READ ? B_READ : B_WRITE)) + return (EFAULT); +#else if (!kernacc((caddr_t)v, c, uio->uio_rw == UIO_READ ? B_READ : B_WRITE)) return (EFAULT); +#endif if (v < NBPG) return (EFAULT); error = uiomove((caddr_t)v, c, uio); diff --git a/sys/arch/mvme68k/mvme68k/pmap.c b/sys/arch/mvme68k/mvme68k/pmap.c index e4e7948695b..c37d5f132f9 100644 --- a/sys/arch/mvme68k/mvme68k/pmap.c +++ b/sys/arch/mvme68k/mvme68k/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.15 2000/07/06 12:56:18 art Exp $ */ +/* $OpenBSD: pmap.c,v 1.16 2001/03/12 07:38:32 smurph Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -133,6 +133,9 @@ #include <vm/vm.h> #include <vm/vm_kern.h> #include <vm/vm_page.h> +#if defined(UVM) +#include <uvm/uvm.h> +#endif #include <machine/cpu.h> @@ -286,6 +289,10 @@ vm_size_t Sysptsize = VM_KERNEL_PT_PAGES; struct pmap kernel_pmap_store; vm_map_t st_map, pt_map; +#if defined(UVM) +struct vm_map pt_map_store; +#endif + vm_offset_t avail_start; /* PA of first available physical page */ vm_offset_t avail_end; /* PA of last available physical page */ @@ -430,7 +437,9 @@ pmap_init(phys_start, phys_end) char *attr; int bank; #endif - +#if defined(UVM) + vm_map_entry_t *out_entry_list; +#endif #ifdef DEBUG if (pmapdebug & PDB_FOLLOW) @@ -444,6 +453,30 @@ pmap_init(phys_start, phys_end) * Now that kernel map has been allocated, we can mark as * unavailable regions which we have mapped in pmap_bootstrap(). */ +#if defined(UVM) + addr = (vm_offset_t) intiobase; + if (uvm_map(kernel_map, &addr, + m68k_ptob(iiomapsize+EIOMAPSIZE), + NULL, UVM_UNKNOWN_OFFSET, + UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, + UVM_INH_NONE, UVM_ADV_RANDOM, + UVM_FLAG_FIXED)) != KERN_SUCCESS) + goto bogons; + addr = (vm_offset_t) Sysmap; + if (uvm_map(kernel_map, &addr, M68K_MAX_PTSIZE, + NULL, UVM_UNKNOWN_OFFSET, + UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, + UVM_INH_NONE, UVM_ADV_RANDOM, + UVM_FLAG_FIXED)) != KERN_SUCCESS) { + /* + * If this fails, it is probably because the static + * portion of the kernel page table isn't big enough + * and we overran the page table map. + */ +bogons: + panic("pmap_init: bogons in the VM system!\n"); + } +#else addr = (vm_offset_t) intiobase; (void) vm_map_find(kernel_map, NULL, (vm_offset_t) 0, &addr, m68k_ptob(iiomapsize+EIOMAPSIZE), FALSE); @@ -461,7 +494,7 @@ pmap_init(phys_start, phys_end) if (addr != (vm_offset_t)Sysmap) bogons: panic("pmap_init: bogons in the VM system!"); - +#endif #ifdef DEBUG if (pmapdebug & PDB_INIT) { printf("pmap_init: Sysseg %x, Sysmap %x, Sysptmap %x\n", @@ -485,7 +518,11 @@ bogons: s += page_cnt * sizeof(struct pv_entry); /* pv table */ s += page_cnt * sizeof(char); /* attribute table */ s = round_page(s); - addr = (vm_offset_t) kmem_alloc(kernel_map, s); +#if defined(UVM) + addr = (vm_offset_t)uvm_km_zalloc(kernel_map, s); +#else + addr = (vm_offset_t)kmem_alloc(kernel_map, s); +#endif Segtabzero = (st_entry_t *) addr; Segtabzeropa = (st_entry_t *) pmap_extract(pmap_kernel(), addr); @@ -542,17 +579,32 @@ bogons: * Verify that space will be allocated in region for which * we already have kernel PT pages. */ +#if defined(UVM) + addr = 0; + rv = uvm_map(kernel_map, &addr, s, NULL, UVM_UNKNOWN_OFFSET, + UVM_MAPFLAG(UVM_PROT_NONE, UVM_PROT_NONE, UVM_INH_NONE, + UVM_ADV_RANDOM, UVM_FLAG_NOMERGE)); + if (rv != KERN_SUCCESS || (addr + s) >= (vm_offset_t)Sysmap) + panic("pmap_init: kernel PT too small"); + rv = uvm_unmap(kernel_map, addr, addr + s); + if (rv != KERN_SUCCESS) + panic("pmap_init: uvm_unmap failed"); +#else addr = 0; rv = vm_map_find(kernel_map, NULL, 0, &addr, s, TRUE); if (rv != KERN_SUCCESS || addr + s >= (vm_offset_t)Sysmap) panic("pmap_init: kernel PT too small"); - vm_map_remove(kernel_map, addr, addr + s); +#endif /* * Now allocate the space and link the pages together to * form the KPT free list. */ - addr = (vm_offset_t) kmem_alloc(kernel_map, s); +#if defined(UVM) + addr = (vm_offset_t)uvm_km_zalloc(kernel_map, s); +#else + addr = (vm_offset_t)kmem_alloc(kernel_map, s); +#endif s = ptoa(npages); addr2 = addr + s; kpt_pages = &((struct kpt_page *)addr2)[npages]; @@ -580,6 +632,25 @@ bogons: atop(s), addr, addr + s); #endif +#if defined(UVM) + /* + * Allocate the segment table map and the page table map. + */ + addr = M68K_PTBASE; + if ((M68K_PTMAXSIZE / M68K_MAX_PTSIZE) < maxproc) { + s = M68K_PTMAXSIZE; + /* + * XXX We don't want to hang when we run out of + * page tables, so we lower maxproc so that fork() + * will fail instead. Note that root could still raise + * this value via sysctl(2). + */ + maxproc = (M68K_PTMAXSIZE / M68K_MAX_PTSIZE);; + } else + s = (maxproc * M68K_MAX_PTSIZE); + pt_map = uvm_km_suballoc(kernel_map, &addr, &addr2, s, VM_MAP_PAGEABLE, + TRUE, &pt_map_store); +#else /* * Allocate the segment table map */ @@ -613,6 +684,7 @@ bogons: rv = vm_map_submap(kernel_map, addr, addr2, pt_map); if (rv != KERN_SUCCESS) panic("pmap_init: cannot map range to pt_map"); +#endif #ifdef DEBUG if (pmapdebug & PDB_INIT) printf("pmap_init: pt_map [%x - %x)\n", addr, addr2); @@ -644,9 +716,15 @@ pmap_alloc_pv() int i; if (pv_nfree == 0) { +#if defined(UVM) + pvp = (struct pv_page *)uvm_km_zalloc(kernel_map, NBPG); + if (pvp == 0) + panic("pmap_alloc_pv: uvm_km_zalloc() failed"); +#else pvp = (struct pv_page *)kmem_alloc(kernel_map, NBPG); if (pvp == 0) panic("pmap_alloc_pv: kmem_alloc() failed"); +#endif pvp->pvp_pgi.pgi_freelist = pv = &pvp->pvp_pv[1]; for (i = NPVPPG - 2; i; i--, pv++) pv->pv_next = pv + 1; @@ -689,7 +767,11 @@ pmap_free_pv(pv) case NPVPPG: pv_nfree -= NPVPPG - 1; TAILQ_REMOVE(&pv_page_freelist, pvp, pvp_pgi.pgi_list); +#if defined(UVM) + uvm_km_free(kernel_map, (vm_offset_t)pvp, NBPG); +#else kmem_free(kernel_map, (vm_offset_t)pvp, NBPG); +#endif break; } } @@ -747,7 +829,11 @@ pmap_collect_pv() for (pvp = pv_page_collectlist.tqh_first; pvp; pvp = npvp) { npvp = pvp->pvp_pgi.pgi_list.tqe_next; +#if defined(UVM) + uvm_km_free(kernel_map, (vm_offset_t)pvp, NBPG); +#else kmem_free(kernel_map, (vm_offset_t)pvp, NBPG); +#endif } } @@ -896,13 +982,21 @@ pmap_release(pmap) if (pmap->pm_count != 1) panic("pmap_release count"); #endif - +#if defined(UVM) + if (pmap->pm_ptab) + uvm_km_free_wakeup(pt_map, (vm_offset_t)pmap->pm_ptab, + M68K_MAX_PTSIZE); + if (pmap->pm_stab != Segtabzero) + uvm_km_free_wakeup(kernel_map, (vm_offset_t)pmap->pm_stab, + M68K_STSIZE); +#else if (pmap->pm_ptab) kmem_free_wakeup(pt_map, (vm_offset_t)pmap->pm_ptab, M68K_MAX_PTSIZE); if (pmap->pm_stab != Segtabzero) - kmem_free_wakeup(st_map, (vm_offset_t)pmap->pm_stab, + kmem_free_wakeup(kernel_map, (vm_offset_t)pmap->pm_stab, M68K_STSIZE); +#endif } /* @@ -1207,7 +1301,11 @@ pmap_enter(pmap, va, pa, prot, wired, access_type) */ if (pmap->pm_ptab == NULL) pmap->pm_ptab = (pt_entry_t *) +#if defined(UVM) + uvm_km_valloc_wait(pt_map, M68K_MAX_PTSIZE); +#else kmem_alloc_wait(pt_map, M68K_MAX_PTSIZE); +#endif /* * Segment table entry not valid, we need a new PT page @@ -1286,8 +1384,13 @@ pmap_enter(pmap, va, pa, prot, wired, access_type) * is a valid mapping in the page. */ if (pmap != pmap_kernel()) +#if defined(UVM) + (void) uvm_map_pageable(pt_map, trunc_page(pte), + round_page(pte+1), FALSE); +#else (void) vm_map_pageable(pt_map, trunc_page(pte), round_page(pte+1), FALSE); +#endif /* * Enter on the PV list if part of our managed memory @@ -2024,8 +2127,13 @@ pmap_remove_mapping(pmap, va, pte, flags) * PT page. */ if (pmap != pmap_kernel()) { +#if defined(UVM) + (void) uvm_map_pageable(pt_map, trunc_page(pte), + round_page(pte+1), TRUE); +#else (void) vm_map_pageable(pt_map, trunc_page(pte), round_page(pte+1), TRUE); +#endif #ifdef DEBUG if (pmapdebug & PDB_WIRING) pmap_check_wiring("remove", trunc_page(pte)); @@ -2126,9 +2234,15 @@ pmap_remove_mapping(pmap, va, pte, flags) printf("remove: free stab %x\n", ptpmap->pm_stab); #endif +#if defined(UVM) + uvm_km_free_wakeup(st_map, + (vm_offset_t)ptpmap->pm_stab, + M68K_STSIZE); +#else kmem_free_wakeup(st_map, (vm_offset_t)ptpmap->pm_stab, M68K_STSIZE); +#endif ptpmap->pm_stab = Segtabzero; ptpmap->pm_stpa = Segtabzeropa; #if defined(M68040) || defined(M68060) @@ -2264,10 +2378,15 @@ pmap_changebit(pa, bit, setem) * XXX don't write protect pager mappings */ if (bit == PG_RO) { +#if defined(UVM) + if (va >= uvm.pager_sva && va < uvm.pager_eva) + continue; +#else extern vm_offset_t pager_sva, pager_eva; if (va >= pager_sva && va < pager_eva) continue; +#endif } pte = pmap_pte(pv->pv_pmap, va); @@ -2342,8 +2461,12 @@ pmap_enter_ptpage(pmap, va) * reference count drops to zero. */ if (pmap->pm_stab == Segtabzero) { - pmap->pm_stab = (st_entry_t *) + pmap->pm_stab = (st_entry_t *) +#if defined(UVM) + uvm_km_zalloc(st_map, M68K_STSIZE); +#else kmem_alloc(st_map, M68K_STSIZE); +#endif pmap->pm_stpa = (st_entry_t *) pmap_extract(pmap_kernel(), (vm_offset_t)pmap->pm_stab); #if defined(M68040) || defined(M68060) @@ -2486,11 +2609,15 @@ pmap_enter_ptpage(pmap, va) if (pmapdebug & (PDB_ENTER|PDB_PTPAGE)) printf("enter: about to fault UPT pg at %x\n", va); #endif - s = vm_fault(pt_map, va, VM_PROT_READ|VM_PROT_WRITE, FALSE); - if (s != KERN_SUCCESS) { - printf("vm_fault(pt_map, %x, RW, 0) -> %d\n", va, s); +#if defined(UVM) + if (uvm_fault(pt_map, va, 0, VM_PROT_READ|VM_PROT_WRITE) + != KERN_SUCCESS) + panic("pmap_enter: uvm_fault failed"); +#else + if (vm_fault(pt_map, va, VM_PROT_READ|VM_PROT_WRITE, FALSE) + != KERN_SUCCESS) panic("pmap_enter: vm_fault failed"); - } +#endif ptpa = pmap_extract(pmap_kernel(), va); /* * Mark the page clean now to avoid its pageout (and @@ -2498,8 +2625,10 @@ pmap_enter_ptpage(pmap, va) * is wired; i.e. while it is on a paging queue. */ PHYS_TO_VM_PAGE(ptpa)->flags |= PG_CLEAN; +#if !defined(UVM) #ifdef DEBUG - PHYS_TO_VM_PAGE(ptpa)->flags |= PG_PTPAGE; + PHYS_TO_VM_PAGE(ptpa)->flags |= PG_PTPAGE; +#endif #endif } #if defined(M68040) || defined(M68060) @@ -2634,11 +2763,17 @@ pmap_check_wiring(str, va) if (!pmap_ste_v(pmap_kernel(), va) || !pmap_pte_v(pmap_pte(pmap_kernel(), va))) return; - +#if defined(UVM) + if (!uvm_map_lookup_entry(pt_map, va, &entry)) { + printf("wired_check: entry for %lx not found\n", va); + return; + } +#else if (!vm_map_lookup_entry(pt_map, va, &entry)) { - printf("wired_check: entry for %x not found\n", va); + printf("wired_check: entry for %lx not found\n", va); return; } +#endif count = 0; for (pte = (pt_entry_t *)va; pte < (pt_entry_t *)(va + NBPG); pte++) if (*pte) diff --git a/sys/arch/mvme68k/mvme68k/pmap_bootstrap.c b/sys/arch/mvme68k/mvme68k/pmap_bootstrap.c index fc09967e427..1a8ce411869 100644 --- a/sys/arch/mvme68k/mvme68k/pmap_bootstrap.c +++ b/sys/arch/mvme68k/mvme68k/pmap_bootstrap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap_bootstrap.c,v 1.5 2000/02/22 19:27:54 deraadt Exp $ */ +/* $OpenBSD: pmap_bootstrap.c,v 1.6 2001/03/12 07:38:32 smurph Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -364,10 +364,10 @@ register vm_offset_t firstpa; * iiomapsize pages prior to external IO space at end of static * kernel page table. */ - RELOC(intiobase, char *) = (char *) - m68k_ptob(nptpages*NPTEPG - (RELOC(iiomapsize, int)+EIOMAPSIZE)); - RELOC(intiolimit, char *) = (char *) - m68k_ptob(nptpages*NPTEPG - EIOMAPSIZE); + RELOC(intiobase, char *) = + (char *)m68k_ptob(nptpages*NPTEPG - (RELOC(iiomapsize, int)+EIOMAPSIZE)); + RELOC(intiolimit, char *) = + (char *)m68k_ptob(nptpages*NPTEPG - EIOMAPSIZE); /* * extiobase: base of external (DIO-II) IO space. * EIOMAPSIZE pages at the end of the static kernel page table. diff --git a/sys/arch/mvme68k/mvme68k/trap.c b/sys/arch/mvme68k/mvme68k/trap.c index fb33ef7c7a6..62d58f3ebdf 100644 --- a/sys/arch/mvme68k/mvme68k/trap.c +++ b/sys/arch/mvme68k/mvme68k/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.25 2000/11/10 18:15:39 art Exp $ */ +/* $OpenBSD: trap.c,v 1.26 2001/03/12 07:38:32 smurph Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -98,6 +98,9 @@ extern struct emul emul_sunos; #include <vm/vm.h> #include <vm/pmap.h> +#if defined(UVM) +#include <uvm/uvm_extern.h> +#endif #ifdef COMPAT_HPUX #include <compat/hpux/hpux.h> @@ -278,7 +281,11 @@ struct frame frame; #endif register union sigval sv; +#if defined(UVM) + uvmexp.traps++; +#else cnt.v_trap++; +#endif p = curproc; ucode = 0; if (USERMODE(frame.f_sr)) { @@ -518,7 +525,11 @@ copyfault: while (bit = ffs(ssir)) { --bit; ssir &= ~(1 << bit); +#if defined(UVM) + uvmexp.softs++; +#else cnt.v_soft++; +#endif if (sir_routines[bit]) sir_routines[bit](sir_args[bit]); } @@ -596,17 +607,30 @@ copyfault: rv = pmap_mapmulti(map->pmap, va); if (rv != KERN_SUCCESS) { bva = HPMMBASEADDR(va); +#if defined(UVM) + rv = uvm_fault(map, bva, 0, ftype); +#else rv = vm_fault(map, bva, ftype, FALSE); +#endif if (rv == KERN_SUCCESS) (void) pmap_mapmulti(map->pmap, va); } } else #endif - rv = vm_fault(map, va, ftype, FALSE); +#if defined(UVM) + rv = uvm_fault(map, va, 0, ftype); +#else + rv = vm_fault(map, va, ftype, FALSE); +#endif #ifdef DEBUG if (rv && MDB_ISPID(p->p_pid)) +#if defined(UVM) + printf("uvm_fault(%x, %x, 0, %x) -> %x\n", + map, va, ftype, rv); +#else printf("vm_fault(%x, %x, %x, 0) -> %x\n", map, va, ftype, rv); +#endif #endif /* * If this was a stack access we keep track of the maximum @@ -637,9 +661,14 @@ copyfault: } if (type == T_MMUFLT) { if (p && p->p_addr->u_pcb.pcb_onfault) - goto copyfault; + goto copyfault; +#if defined(UVM) + printf("uvm_fault(%x, %x, 0, %x) -> %x\n", + map, va, ftype, rv); +#else printf("vm_fault(%x, %x, %x, 0) -> %x\n", map, va, ftype, rv); +#endif printf(" type %x, code [mmu,,ssw]: %x\n", type, code); goto dopanic; @@ -977,8 +1006,12 @@ struct frame frame; #ifdef COMPAT_SUNOS extern struct emul emul_sunos; #endif - +#if defined(UVM) + uvmexp.syscalls++; +#else cnt.v_syscall++; +#endif + if (!USERMODE(frame.f_sr)) panic("syscall"); p = curproc; diff --git a/sys/arch/mvme68k/mvme68k/vm_machdep.c b/sys/arch/mvme68k/mvme68k/vm_machdep.c index 9accf7688d7..9b05657c5cc 100644 --- a/sys/arch/mvme68k/mvme68k/vm_machdep.c +++ b/sys/arch/mvme68k/mvme68k/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.18 2000/07/06 12:56:19 art Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.19 2001/03/12 07:38:33 smurph Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -57,6 +57,9 @@ #include <vm/vm.h> #include <vm/vm_kern.h> +#if defined(UVM) +#include <uvm/uvm_extern.h> +#endif /* * Finish a fork operation, with process p2 nearly set up. @@ -92,13 +95,13 @@ cpu_fork(p1, p2, stack, stacksize) p2->p_md.md_regs = (int *)tf; *tf = *(struct trapframe *)p1->p_md.md_regs; - /* + /* * If specified, give the child a different stack. */ if (stack != NULL) tf->tf_regs[15] = (u_int)stack + stacksize; - sf = (struct switchframe *)tf - 1; + sf = (struct switchframe *)tf - 1; sf->sf_pc = (u_int)proc_trampoline; pcb->pcb_regs[6] = (int)child_return; /* A2 */ @@ -130,7 +133,11 @@ cpu_exit(p) { (void) splimp(); +#if defined(UVM) + uvmexp.swtch++; +#else cnt.v_swtch++; +#endif switch_exit(p); /* NOTREACHED */ } @@ -286,7 +293,11 @@ vmapbuf(bp, siz) off = (int)addr & PGOFSET; p = bp->b_proc; npf = btoc(round_page(bp->b_bcount + off)); +#if defined(UVM) + kva = uvm_km_valloc_wait(phys_map, ctob(npf)); +#else kva = kmem_alloc_wait(phys_map, ctob(npf)); +#endif bp->b_data = (caddr_t)(kva + off); while (npf--) { pa = pmap_extract(vm_map_pmap(&p->p_vmspace->vm_map), @@ -317,7 +328,11 @@ vunmapbuf(bp, siz) addr = bp->b_data; npf = btoc(round_page(bp->b_bcount + ((int)addr & PGOFSET))); kva = (vm_offset_t)((int)addr & ~PGOFSET); +#if defined(UVM) + uvm_km_free_wakeup(phys_map, kva, ctob(npf)); +#else kmem_free_wakeup(phys_map, kva, ctob(npf)); +#endif bp->b_data = bp->b_saveaddr; bp->b_saveaddr = NULL; } |