diff options
author | Artur Grabowski <art@cvs.openbsd.org> | 2001-06-08 08:09:45 +0000 |
---|---|---|
committer | Artur Grabowski <art@cvs.openbsd.org> | 2001-06-08 08:09:45 +0000 |
commit | 95da2243c76760307b218cb7f05645e68a73e8af (patch) | |
tree | 594a78dc6e16ba4f07e3c1bc9c44def6966cf19e /sys/arch | |
parent | 0579d34f9bf07b4a6bfebb51a83de3ac8356c01f (diff) |
Change the paddr_t pmap_extract(struct pmap *, vaddr_t) interface to
boolean_t pmap_extract(struct pmap *, vaddr_t, paddr_t *).
Matches NetBSD. Tested by various people on various platforms.
Diffstat (limited to 'sys/arch')
54 files changed, 389 insertions, 498 deletions
diff --git a/sys/arch/alpha/alpha/pmap.c b/sys/arch/alpha/alpha/pmap.c index 772c2d8c9ac..5bda6c5c171 100644 --- a/sys/arch/alpha/alpha/pmap.c +++ b/sys/arch/alpha/alpha/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.13 2001/05/09 15:31:23 art Exp $ */ +/* $OpenBSD: pmap.c,v 1.14 2001/06/08 08:08:35 art Exp $ */ /* $NetBSD: pmap.c,v 1.148 2000/09/22 05:23:37 thorpej Exp $ */ /*- @@ -2183,8 +2183,8 @@ pmap_unwire(pmap_t pmap, vaddr_t va) * Extract the physical address associated with the given * pmap/virtual address pair. */ -paddr_t -pmap_extract(pmap_t pmap, vaddr_t va) +boolean_t +pmap_extract(pmap_t pmap, vaddr_t va, paddr_t *pap) { pt_entry_t *l1pte, *l2pte, *l3pte; paddr_t pa = 0; @@ -2218,7 +2218,8 @@ pmap_extract(pmap_t pmap, vaddr_t va) printf("failed\n"); } #endif - return (pa); + *pap = pa; + return (pa != 0); } /* diff --git a/sys/arch/alpha/alpha/vm_machdep.c b/sys/arch/alpha/alpha/vm_machdep.c index cffe4adcd0b..0bd241f5e1e 100644 --- a/sys/arch/alpha/alpha/vm_machdep.c +++ b/sys/arch/alpha/alpha/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.21 2001/05/06 00:45:45 art Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.22 2001/06/08 08:08:38 art Exp $ */ /* $NetBSD: vm_machdep.c,v 1.55 2000/03/29 03:49:48 simonb Exp $ */ /* @@ -376,8 +376,8 @@ vmapbuf(bp, len) bp->b_data = (caddr_t)(taddr + off); len = atop(len); while (len--) { - if ((pa = pmap_extract(vm_map_pmap(&p->p_vmspace->vm_map), - faddr)) == 0) + if (pmap_extract(vm_map_pmap(&p->p_vmspace->vm_map), + faddr, &pa) == FALSE) panic("vmapbuf: null page frame"); pmap_enter(vm_map_pmap(phys_map), taddr, trunc_page(pa), VM_PROT_READ|VM_PROT_WRITE, TRUE, 0); diff --git a/sys/arch/alpha/dev/bus_dma.c b/sys/arch/alpha/dev/bus_dma.c index 0b6eb960e2f..28119359342 100644 --- a/sys/arch/alpha/dev/bus_dma.c +++ b/sys/arch/alpha/dev/bus_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_dma.c,v 1.1 2001/03/21 17:26:38 art Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.2 2001/06/08 08:08:39 art Exp $ */ /* $NetBSD: bus_dma.c,v 1.40 2000/07/17 04:47:56 thorpej Exp $ */ /*- @@ -158,8 +158,8 @@ _bus_dmamap_load_buffer_direct_common(t, map, buf, buflen, p, flags, * Get the physical address for this segment. */ if (p != NULL) - curaddr = pmap_extract(p->p_vmspace->vm_map.pmap, - vaddr); + pmap_extract(p->p_vmspace->vm_map.pmap, vaddr, + &curaddr); else curaddr = vtophys(vaddr); diff --git a/sys/arch/alpha/dev/sgmap_typedep.c b/sys/arch/alpha/dev/sgmap_typedep.c index 54e292ec50b..1b14b54f588 100644 --- a/sys/arch/alpha/dev/sgmap_typedep.c +++ b/sys/arch/alpha/dev/sgmap_typedep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sgmap_typedep.c,v 1.1 2001/03/21 17:26:38 art Exp $ */ +/* $OpenBSD: sgmap_typedep.c,v 1.2 2001/06/08 08:08:40 art Exp $ */ /* $NetBSD: sgmap_typedep.c,v 1.13 1999/07/08 18:05:23 thorpej Exp $ */ /*- @@ -185,7 +185,7 @@ __C(SGMAP_TYPE,_load)(t, map, buf, buflen, p, flags, sgmap) * Get the physical address for this segment. */ if (p != NULL) - pa = pmap_extract(p->p_vmspace->vm_map.pmap, va); + pmap_extract(p->p_vmspace->vm_map.pmap, va, &pa); else pa = vtophys(va); diff --git a/sys/arch/amiga/amiga/pmap.c b/sys/arch/amiga/amiga/pmap.c index b2829290896..f80c5316c1c 100644 --- a/sys/arch/amiga/amiga/pmap.c +++ b/sys/arch/amiga/amiga/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.30 2001/05/15 14:19:58 jj Exp $ */ +/* $OpenBSD: pmap.c,v 1.31 2001/06/08 08:08:41 art Exp $ */ /* $NetBSD: pmap.c,v 1.68 1999/06/19 19:44:09 is Exp $ */ /*- @@ -589,7 +589,7 @@ bogons: addr = (vaddr_t)kmem_alloc(kernel_map, s); #endif Segtabzero = (u_int *)addr; - Segtabzeropa = (u_int *)pmap_extract(pmap_kernel(), addr); + pmap_extract(pmap_kernel(), addr, (paddr_t *)&Segtabzeropa); addr += AMIGA_STSIZE; @@ -677,7 +677,7 @@ bogons: (--kpt_pages)->kpt_next = kpt_free_list; kpt_free_list = kpt_pages; kpt_pages->kpt_va = addr2; - kpt_pages->kpt_pa = pmap_extract(pmap_kernel(), addr2); + pmap_extract(pmap_kernel(), addr2, &kpt_pages->kpt_pa); } while (addr != addr2); #ifdef DEBUG @@ -1552,10 +1552,11 @@ pmap_unwire(pmap, va) * with the given map/virtual_address pair. */ -paddr_t -pmap_extract(pmap, va) +boolean_t +pmap_extract(pmap, va, pap) pmap_t pmap; vaddr_t va; + paddr_t *pap; { paddr_t pa; @@ -1563,16 +1564,16 @@ pmap_extract(pmap, va) if (pmapdebug & PDB_FOLLOW) printf("pmap_extract(%p, %lx) -> ", pmap, va); #endif - pa = 0; if (pmap && pmap_ste_v(pmap, va)) pa = *(int *)pmap_pte(pmap, va); - if (pa) - pa = (pa & PG_FRAME) | (va & ~PG_FRAME); + else + return (FALSE); + *pap = (pa & PG_FRAME) | (va & ~PG_FRAME); #ifdef DEBUG if (pmapdebug & PDB_FOLLOW) - printf("%lx\n", pa); + printf("%lx\n", *pap); #endif - return (pa); + return (TRUE); } /* @@ -1725,7 +1726,7 @@ ok: * We call pmap_remove to take care of invalidating ST * and Sysptmap entries. */ - kpa = pmap_extract(pmap, pv->pv_va); + pmap_extract(pmap, pv->pv_va, &kpa); pmap_remove_mapping(pmap, pv->pv_va, PT_ENTRY_NULL, PRM_TFLUSH|PRM_CFLUSH); @@ -2399,8 +2400,8 @@ pmap_enter_ptpage(pmap, va) pmap->pm_stab = (u_int *) kmem_alloc(kernel_map, AMIGA_STSIZE); #endif - pmap->pm_stpa = (u_int *)pmap_extract( - pmap_kernel(), (vaddr_t)pmap->pm_stab); + pmap_extract(pmap_kernel(), (vaddr_t)pmap->pm_stab, + (paddr_t *)&pmap->pm_stpa); #if defined(M68040) || defined(M68060) if (mmutype == MMU_68040) { #if defined(M68060) diff --git a/sys/arch/amiga/amiga/sys_machdep.c b/sys/arch/amiga/amiga/sys_machdep.c index ba752670db2..f26599f711a 100644 --- a/sys/arch/amiga/amiga/sys_machdep.c +++ b/sys/arch/amiga/amiga/sys_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_machdep.c,v 1.8 2000/06/23 02:14:35 mickey Exp $ */ +/* $OpenBSD: sys_machdep.c,v 1.9 2001/06/08 08:08:42 art Exp $ */ /* $NetBSD: sys_machdep.c,v 1.16 1997/05/19 10:14:47 veego Exp $ */ /* @@ -97,10 +97,9 @@ cachectl(req, addr, len) */ if (!doall && (pa == 0 || ((int)addr & PGOFSET) == 0)) { - pa = pmap_extract( + if (pmap_extract( curproc->p_vmspace->vm_map.pmap, - (vm_offset_t)addr); - if (pa == 0) + (vm_offset_t)addr, &pa) == FALSE) doall = 1; } switch (req) { diff --git a/sys/arch/amiga/amiga/vm_machdep.c b/sys/arch/amiga/amiga/vm_machdep.c index 99ec2cb90a9..e0586ed10c6 100644 --- a/sys/arch/amiga/amiga/vm_machdep.c +++ b/sys/arch/amiga/amiga/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.18 2001/05/06 00:45:47 art Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.19 2001/06/08 08:08:42 art Exp $ */ /* $NetBSD: vm_machdep.c,v 1.30 1997/05/19 10:14:50 veego Exp $ */ /* @@ -175,23 +175,25 @@ cpu_exit(p) */ void pagemove(from, to, size) - register caddr_t from, to; + caddr_t from, to; size_t size; { - register vm_offset_t pa; + vm_offset_t pa; #ifdef DEBUG if ((size & PAGE_MASK) != 0) panic("pagemove"); #endif while (size > 0) { - pa = pmap_extract(pmap_kernel(), (vm_offset_t)from); + pmap_extract(pmap_kernel(), (vm_offset_t)from, &pa); #ifdef DEBUG +#if 0 if (pa == 0) panic("pagemove 2"); - if (pmap_extract(pmap_kernel(), (vm_offset_t)to) != 0) + if (pmap_extract(pmap_kernel(), (vm_offset_t)to, XXX) != FALSE) panic("pagemove 3"); #endif +#endif pmap_remove(pmap_kernel(), (vm_offset_t)from, (vm_offset_t)from + PAGE_SIZE); pmap_enter(pmap_kernel(), (vm_offset_t)to, pa, @@ -342,14 +344,13 @@ setredzone(pte, vaddr) */ int kvtop(addr) - register caddr_t addr; + caddr_t addr; { - vm_offset_t va; + paddr_t pa; - va = pmap_extract(pmap_kernel(), (vm_offset_t)addr); - if (va == 0) + if (pmap_extract(pmap_kernel(), (vm_offset_t)addr, &pa) == FALSE) panic("kvtop: zero page frame"); - return((int)va); + return((int)pa); } extern vm_map_t phys_map; @@ -386,7 +387,7 @@ vmapbuf(bp, len) upmap = vm_map_pmap(&bp->b_proc->p_vmspace->vm_map); kpmap = vm_map_pmap(phys_map); do { - if ((pa = pmap_extract(upmap, uva)) == 0) + if (pmap_extract(upmap, uva, &pa) == FALSE) panic("vmapbuf: null page frame"); pmap_enter(kpmap, kva, pa, VM_PROT_READ|VM_PROT_WRITE, TRUE, 0); diff --git a/sys/arch/hp300/hp300/pmap.c b/sys/arch/hp300/hp300/pmap.c index ccc6d05297a..d1c384ffaa6 100644 --- a/sys/arch/hp300/hp300/pmap.c +++ b/sys/arch/hp300/hp300/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.22 2001/06/05 16:13:15 millert Exp $ */ +/* $OpenBSD: pmap.c,v 1.23 2001/06/08 08:08:43 art Exp $ */ /* $NetBSD: pmap.c,v 1.80 1999/09/16 14:52:06 chs Exp $ */ /*- @@ -456,7 +456,7 @@ bogons: #endif Segtabzero = (st_entry_t *) addr; - Segtabzeropa = (st_entry_t *) pmap_extract(pmap_kernel(), addr); + pmap_extract(pmap_kernel(), addr, (paddr_t *)Segtabzeropa); addr += HP_STSIZE; pv_table = (struct pv_entry *) addr; @@ -532,7 +532,7 @@ bogons: (--kpt_pages)->kpt_next = kpt_free_list; kpt_free_list = kpt_pages; kpt_pages->kpt_va = addr2; - kpt_pages->kpt_pa = pmap_extract(pmap_kernel(), addr2); + pmap_extract(pmap_kernel(), addr2, &kpt_pages->kpt_pa); } while (addr != addr2); PMAP_DPRINTF(PDB_INIT, ("pmap_init: KPT: %ld pages from %lx to %lx\n", @@ -1655,25 +1655,28 @@ pmap_unwire(pmap, va) * Extract the physical address associated with the given * pmap/virtual address pair. */ -paddr_t -pmap_extract(pmap, va) +boolean_t +pmap_extract(pmap, va, pap) pmap_t pmap; vaddr_t va; + paddr_t *pap; { paddr_t pa; PMAP_DPRINTF(PDB_FOLLOW, ("pmap_extract(%p, %lx) -> ", pmap, va)); - pa = 0; if (pmap && pmap_ste_v(pmap, va)) pa = *pmap_pte(pmap, va); + else + return (FALSE); if (pa) pa = (pa & PG_FRAME) | (va & ~PG_FRAME); PMAP_DPRINTF(PDB_FOLLOW, ("%lx\n", pa)); - return (pa); + *pap = pa; + return (TRUE); } /* @@ -1831,7 +1834,7 @@ ok: * We call pmap_remove_entry to take care of invalidating * ST and Sysptmap entries. */ - kpa = pmap_extract(pmap, pv->pv_va); + pmap_extract(pmap, pv->pv_va, &kpa); pmap_remove_mapping(pmap, pv->pv_va, PT_ENTRY_NULL, PRM_TFLUSH|PRM_CFLUSH); /* @@ -2664,8 +2667,8 @@ pmap_enter_ptpage(pmap, va) pmap->pm_stab = (st_entry_t *) kmem_alloc(st_map, HP_STSIZE); #endif - pmap->pm_stpa = (st_entry_t *) - pmap_extract(pmap_kernel(), (vaddr_t)pmap->pm_stab); + pmap_extract(pmap_kernel(), (vaddr_t)pmap->pm_stab, + (paddr_t *)&pmap->pm_stpa); #if defined(M68040) if (mmutype == MMU_68040) { #ifdef DEBUG diff --git a/sys/arch/hp300/hp300/sys_machdep.c b/sys/arch/hp300/hp300/sys_machdep.c index 6259bbacdf4..3f1ae5b72bd 100644 --- a/sys/arch/hp300/hp300/sys_machdep.c +++ b/sys/arch/hp300/hp300/sys_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_machdep.c,v 1.8 2001/05/11 23:24:57 millert Exp $ */ +/* $OpenBSD: sys_machdep.c,v 1.9 2001/06/08 08:08:45 art Exp $ */ /* $NetBSD: sys_machdep.c,v 1.17 1997/05/19 10:15:00 veego Exp $ */ /* @@ -119,9 +119,9 @@ cachectl(req, addr, len) */ if (!doall && (pa == 0 || ((int)addr & PGOFSET) == 0)) { - pa = pmap_extract(curproc->p_vmspace->vm_map.pmap, - addr); - if (pa == 0) + if (pmap_extract( + curproc->p_vmspace->vm_map.pmap, + addr, &pa) == FALSE) doall = 1; } switch (req) { diff --git a/sys/arch/hp300/hp300/trap.c b/sys/arch/hp300/hp300/trap.c index 5b84697759b..4c419d80d81 100644 --- a/sys/arch/hp300/hp300/trap.c +++ b/sys/arch/hp300/hp300/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.22 2001/05/13 17:19:56 millert Exp $ */ +/* $OpenBSD: trap.c,v 1.23 2001/06/08 08:08:45 art Exp $ */ /* $NetBSD: trap.c,v 1.57 1998/02/16 20:58:31 thorpej Exp $ */ /* @@ -829,12 +829,15 @@ writeback(fp, docachepush) * cache push after a signal handler has been called. */ if (docachepush) { + paddr_t pa; + pmap_enter(pmap_kernel(), (vaddr_t)vmmap, trunc_page((vaddr_t)f->f_fa), VM_PROT_WRITE, TRUE, VM_PROT_WRITE); fa = (u_int)&vmmap[(f->f_fa & PGOFSET) & ~0xF]; bcopy((caddr_t)&f->f_pd0, (caddr_t)fa, 16); - DCFL(pmap_extract(pmap_kernel(), (vaddr_t)fa)); + pmap_extract(pmap_kernel(), (vaddr_t)fa, &pa); + DCFL(pa); pmap_remove(pmap_kernel(), (vaddr_t)vmmap, (vaddr_t)&vmmap[NBPG]); } else @@ -1059,8 +1062,7 @@ dumpwb(num, s, a, d) num, a, d, f7sz[(s & SSW4_SZMASK) >> 5], f7tt[(s & SSW4_TTMASK) >> 3], f7tm[s & SSW4_TMMASK]); printf(" PA "); - pa = pmap_extract(p->p_vmspace->vm_map.pmap, (vaddr_t)a); - if (pa == 0) + if (pmap_extract(p->p_vmspace->vm_map.pmap, (vaddr_t)a, &pa) == FALSE) printf("<invalid address>"); else printf("%lx, current value %lx", pa, fuword((caddr_t)a)); diff --git a/sys/arch/hp300/hp300/vm_machdep.c b/sys/arch/hp300/hp300/vm_machdep.c index a629bb7e72d..4173cc45a88 100644 --- a/sys/arch/hp300/hp300/vm_machdep.c +++ b/sys/arch/hp300/hp300/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.23 2001/05/28 21:08:36 millert Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.24 2001/06/08 08:08:46 art Exp $ */ /* $NetBSD: vm_machdep.c,v 1.47 1999/03/26 23:41:29 mycroft Exp $ */ /* @@ -236,13 +236,15 @@ pagemove(from, to, size) panic("pagemove"); #endif while (size > 0) { - pa = pmap_extract(pmap_kernel(), (vaddr_t)from); + pmap_extract(pmap_kernel(), (vaddr_t)from, &pa); #ifdef DEBUG +#if 0 if (pa == 0) panic("pagemove 2"); - if (pmap_extract(pmap_kernel(), (vaddr_t)to) != 0) + if (pmap_extract(pmap_kernel(), (vaddr_t)to, XXX) != FALSE) panic("pagemove 3"); #endif +#endif #ifdef PMAP_NEW pmap_kremove((vaddr_t)from, PAGE_SIZE); pmap_kenter_pa((vaddr_t)to, pa, VM_PROT_READ|VM_PROT_WRITE); @@ -303,8 +305,7 @@ kvtop(addr) { paddr_t pa; - pa = pmap_extract(pmap_kernel(), (vaddr_t)addr); - if (pa == 0) + if (pmap_extract(pmap_kernel(), (vaddr_t)addr, &pa) == FALSE) panic("kvtop: zero page frame"); return((int)pa); } @@ -346,8 +347,7 @@ vmapbuf(bp, len) upmap = vm_map_pmap(&bp->b_proc->p_vmspace->vm_map); kpmap = vm_map_pmap(phys_map); do { - pa = pmap_extract(upmap, uva); - if (pa == 0) + if (pmap_extract(upmap, uva, &pa) == FALSE) panic("vmapbuf: null page frame"); pmap_enter(kpmap, kva, pa, VM_PROT_READ|VM_PROT_WRITE, TRUE, 0); uva += PAGE_SIZE; diff --git a/sys/arch/hppa/hppa/pmap.c b/sys/arch/hppa/hppa/pmap.c index 39df5f46d6f..5a1062f3eb3 100644 --- a/sys/arch/hppa/hppa/pmap.c +++ b/sys/arch/hppa/hppa/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.44 2001/05/09 15:31:24 art Exp $ */ +/* $OpenBSD: pmap.c,v 1.45 2001/06/08 08:08:48 art Exp $ */ /* * Copyright (c) 1998-2001 Michael Shalayeff @@ -1299,17 +1299,19 @@ pmap_unwire(pmap, va) } /* - * pmap_extract(pmap, va) - * returns the physical address corrsponding to the - * virtual address specified by pmap and va if the - * virtual address is mapped and 0 if it is not. + * pmap_extract(pmap, va, pap) + * fills in the physical address corrsponding to the + * virtual address specified by pmap and va into the + * storage pointed to by pap and returns TRUE if the + * virtual address is mapped. returns FALSE in not mapped. */ -paddr_t -pmap_extract(pmap, va) +boolean_t +pmap_extract(pmap, va, pap) pmap_t pmap; vaddr_t va; + paddr_t *pap; { - register struct pv_entry *pv; + struct pv_entry *pv; va = hppa_trunc_page(va); #ifdef PMAPDEBUG @@ -1318,9 +1320,11 @@ pmap_extract(pmap, va) #endif if (!(pv = pmap_find_va(pmap_sid(pmap, va), va & ~PGOFSET))) - return(0); - else - return tlbptob(pv->pv_tlbpage) + (va & PGOFSET); + return (FALSE); + else { + *pap = tlbptob(pv->pv_tlbpage) + (va & PGOFSET); + return (TRUE); + } } /* diff --git a/sys/arch/hppa/hppa/vm_machdep.c b/sys/arch/hppa/hppa/vm_machdep.c index 13b4339ac6e..6c253d533f7 100644 --- a/sys/arch/hppa/hppa/vm_machdep.c +++ b/sys/arch/hppa/hppa/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.21 2001/05/06 00:45:49 art Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.22 2001/06/08 08:08:49 art Exp $ */ /* * Copyright (c) 1999-2000 Michael Shalayeff @@ -107,7 +107,7 @@ pagemove(from, to, size) register paddr_t pa; while (size > 0) { - pa = pmap_extract(pmap_kernel(), (vaddr_t)from); + pmap_extract(pmap_kernel(), (vaddr_t)from, &pa); pmap_remove(pmap_kernel(), (vaddr_t)from, (vaddr_t)from + PAGE_SIZE); pmap_enter(pmap_kernel(), (vaddr_t)to, pa, @@ -345,11 +345,8 @@ vmapbuf(bp, len) /* not needed, thanks to PMAP_PREFER() */ /* fdcache(vm_map_pmap(map)->pmap_space, addr, PAGE_SIZE); */ - pa = pmap_extract(vm_map_pmap(map), addr); -#ifdef DIAGNOSTIC - if (pa == 0) + if (pmap_extract(vm_map_pmap(map), addr, &pa) == FALSE) panic("vmapbuf: null page frame"); -#endif pmap_enter(vm_map_pmap(phys_map), kva, pa, VM_PROT_READ|VM_PROT_WRITE, TRUE, 0); diff --git a/sys/arch/i386/i386/machdep.c b/sys/arch/i386/i386/machdep.c index b7a1104ec13..620f5d5c242 100644 --- a/sys/arch/i386/i386/machdep.c +++ b/sys/arch/i386/i386/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.162 2001/05/17 18:41:48 provos Exp $ */ +/* $OpenBSD: machdep.c,v 1.163 2001/06/08 08:08:51 art Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -2728,7 +2728,8 @@ bus_space_unmap(t, bsh, size) panic("bus_space_unmap: overflow"); #endif - bpa = pmap_extract(pmap_kernel(), va) + (bsh & PGOFSET); + pmap_extract(pmap_kernel(), va, &bpa); + bpa += (bsh & PGOFSET); /* * Free the kernel virtual mapping. @@ -3197,7 +3198,7 @@ _bus_dmamap_load_buffer(t, map, buf, buflen, p, flags, lastaddrp, segp, first) /* * Get the physical address for this segment. */ - curaddr = (bus_addr_t)pmap_extract(pmap, (vm_offset_t)vaddr); + pmap_extract(pmap, (vm_offset_t)vaddr, (paddr_t *)&curaddr); /* * Compute the segment size, and adjust counts. diff --git a/sys/arch/i386/i386/pmap.c b/sys/arch/i386/i386/pmap.c index 86a7055d625..05b40b2b80d 100644 --- a/sys/arch/i386/i386/pmap.c +++ b/sys/arch/i386/i386/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.40 2001/05/09 15:31:25 art Exp $ */ +/* $OpenBSD: pmap.c,v 1.41 2001/06/08 08:08:52 art Exp $ */ /* $NetBSD: pmap.c,v 1.84 2000/02/21 02:01:24 chs Exp $ */ /* @@ -1782,7 +1782,7 @@ pmap_pinit(pmap) pmap->pm_pdir = (pd_entry_t *) uvm_km_alloc(kernel_map, NBPG); if (pmap->pm_pdir == NULL) panic("pmap_pinit: kernel_map out of virtual space!"); - (void) _pmap_extract(pmap_kernel(), (vaddr_t)pmap->pm_pdir, + (void) pmap_extract(pmap_kernel(), (vaddr_t)pmap->pm_pdir, (paddr_t *)&pmap->pm_pdirpa); /* init PDP */ @@ -2032,7 +2032,7 @@ pmap_deactivate(p) */ boolean_t -_pmap_extract(pmap, va, pap) +pmap_extract(pmap, va, pap) struct pmap *pmap; vaddr_t va; paddr_t *pap; @@ -2051,18 +2051,6 @@ _pmap_extract(pmap, va, pap) return (FALSE); } -paddr_t -pmap_extract(pmap, va) - pmap_t pmap; - vaddr_t va; -{ - paddr_t pa; - - if (_pmap_extract(pmap, va, &pa)) - return (pa); - return (NULL); -} - /* * pmap_virtual_space: used during bootup [pmap_steal_memory] to * determine the bounds of the kernel virtual addess space. diff --git a/sys/arch/i386/i386/rbus_machdep.c b/sys/arch/i386/i386/rbus_machdep.c index 96a1e7ad42d..0bbacc29ef3 100644 --- a/sys/arch/i386/i386/rbus_machdep.c +++ b/sys/arch/i386/i386/rbus_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rbus_machdep.c,v 1.9 2001/05/05 23:25:40 art Exp $ */ +/* $OpenBSD: rbus_machdep.c,v 1.10 2001/06/08 08:08:53 art Exp $ */ /* $NetBSD: rbus_machdep.c,v 1.2 1999/10/15 06:43:06 haya Exp $ */ /* @@ -98,14 +98,10 @@ _bus_space_unmap(t, bsh, size, adrp) } #endif -#if __NetBSD_Version__ > 104050000 if (pmap_extract(pmap_kernel(), va, &bpa) == FALSE) { panic("_i386_memio_unmap:i386/rbus_machdep.c wrong virtual address"); } bpa += (bsh & PGOFSET); -#else - bpa = pmap_extract(pmap_kernel(), va) + (bsh & PGOFSET); -#endif /* * Free the kernel virtual mapping. diff --git a/sys/arch/i386/i386/vm_machdep.c b/sys/arch/i386/i386/vm_machdep.c index 03a6bb80cf9..fde7a189ed0 100644 --- a/sys/arch/i386/i386/vm_machdep.c +++ b/sys/arch/i386/i386/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.26 2001/05/06 00:45:50 art Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.27 2001/06/08 08:08:53 art Exp $ */ /* $NetBSD: vm_machdep.c,v 1.61 1996/05/03 19:42:35 christos Exp $ */ /*- @@ -329,12 +329,11 @@ pagemove(from, to, size) */ int kvtop(addr) - register caddr_t addr; + caddr_t addr; { vm_offset_t pa; - pa = pmap_extract(pmap_kernel(), (vm_offset_t)addr); - if (pa == 0) + if (pmap_extract(pmap_kernel(), (vm_offset_t)addr, &pa) == FALSE) panic("kvtop: zero page frame"); return((int)pa); } @@ -387,8 +386,8 @@ vmapbuf(bp, len) * mapping is removed). */ while (len) { - fpa = pmap_extract(vm_map_pmap(&bp->b_proc->p_vmspace->vm_map), - faddr); + pmap_extract(vm_map_pmap(&bp->b_proc->p_vmspace->vm_map), + faddr, &fpa); pmap_enter(vm_map_pmap(phys_map), taddr, fpa, VM_PROT_READ | VM_PROT_WRITE, TRUE, VM_PROT_READ | VM_PROT_WRITE); diff --git a/sys/arch/i386/isa/isa_machdep.c b/sys/arch/i386/isa/isa_machdep.c index f7a414d7782..c94cea7cc40 100644 --- a/sys/arch/i386/isa/isa_machdep.c +++ b/sys/arch/i386/isa/isa_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: isa_machdep.c,v 1.35 2000/07/06 08:44:28 ho Exp $ */ +/* $OpenBSD: isa_machdep.c,v 1.36 2001/06/08 08:08:55 art Exp $ */ /* $NetBSD: isa_machdep.c,v 1.22 1997/06/12 23:57:32 thorpej Exp $ */ #define ISA_DMA_STATS @@ -1047,7 +1047,7 @@ _isa_dma_check_buffer(buf, buflen, segcnt, boundary, p) /* * Get physical address for this segment. */ - pa = pmap_extract(pmap, (vm_offset_t)vaddr); + pmap_extract(pmap, (vm_offset_t)vaddr, &pa); pa = trunc_page(pa); /* diff --git a/sys/arch/m68k/m68k/mappedcopy.c b/sys/arch/m68k/m68k/mappedcopy.c index 6bf28be9d43..3dd26fd08b2 100644 --- a/sys/arch/m68k/m68k/mappedcopy.c +++ b/sys/arch/m68k/m68k/mappedcopy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mappedcopy.c,v 1.4 2001/05/15 01:43:16 millert Exp $ */ +/* $OpenBSD: mappedcopy.c,v 1.5 2001/06/08 08:08:57 art Exp $ */ /* $NetBSD: mappedcopy.c,v 1.1 1997/02/02 06:54:10 thorpej Exp $ */ /* @@ -108,8 +108,7 @@ mappedcopyin(fromp, top, count) /* * Map in the page and bcopy data in from it */ - upa = pmap_extract(upmap, trunc_page((vaddr_t)fromp)); - if (upa == 0) + if (pmap_extract(upmap, trunc_page((vaddr_t)fromp), &upa) == FALSE) panic("mappedcopyin: null page frame"); len = min(count, (PAGE_SIZE - off)); pmap_enter(pmap_kernel(), kva, upa, VM_PROT_READ, TRUE, @@ -160,8 +159,7 @@ mappedcopyout(fromp, top, count) /* * Map in the page and bcopy data out to it */ - upa = pmap_extract(upmap, trunc_page((vaddr_t)top)); - if (upa == 0) + if (pmap_extract(upmap, trunc_page((vaddr_t)top), &upa) == FALSE) panic("mappedcopyout: null page frame"); len = min(count, (PAGE_SIZE - off)); pmap_enter(pmap_kernel(), kva, upa, diff --git a/sys/arch/mac68k/dev/asc.c b/sys/arch/mac68k/dev/asc.c index 77c933e2395..07e2a3618b0 100644 --- a/sys/arch/mac68k/dev/asc.c +++ b/sys/arch/mac68k/dev/asc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: asc.c,v 1.9 1999/04/24 06:39:40 downsj Exp $ */ +/* $OpenBSD: asc.c,v 1.10 2001/06/08 08:08:58 art Exp $ */ /* $NetBSD: asc.c,v 1.20 1997/02/24 05:47:33 scottr Exp $ */ /* @@ -278,11 +278,11 @@ ascmmap(dev, off, prot) { int unit = ASCUNIT(dev); struct asc_softc *sc; - vm_offset_t pa; + paddr_t pa; sc = asc_cd.cd_devs[unit]; if (off >= 0 && off < MAC68K_ASC_LEN) { - pa = pmap_extract(pmap_kernel(), (vm_offset_t)sc->sc_handle); + pmap_extract(pmap_kernel(), (vm_offset_t)sc->sc_handle, &pa); return m68k_btop(pa + off); } diff --git a/sys/arch/mac68k/dev/ite.c b/sys/arch/mac68k/dev/ite.c index 1f815f83b3f..90ea12baed0 100644 --- a/sys/arch/mac68k/dev/ite.c +++ b/sys/arch/mac68k/dev/ite.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ite.c,v 1.17 1998/05/03 07:12:58 gene Exp $ */ +/* $OpenBSD: ite.c,v 1.18 2001/06/08 08:08:59 art Exp $ */ /* $NetBSD: ite.c,v 1.32 1997/02/20 00:23:25 scottr Exp $ */ /* @@ -935,11 +935,11 @@ itematch(parent, vcf, aux) { struct grfbus_attach_args *ga = aux; struct grfmode *gm = ga->ga_grfmode; - vm_offset_t pa; + paddr_t pa; if (strcmp(ga->ga_name, "ite")) return 0; - pa = pmap_extract(pmap_kernel(), (vm_offset_t) gm->fbbase + gm->fboff); + pmap_extract(pmap_kernel(), (vm_offset_t) gm->fbbase + gm->fboff, &pa); return (pa == (vm_offset_t) mac68k_vidphys); } diff --git a/sys/arch/mac68k/dev/nubus.c b/sys/arch/mac68k/dev/nubus.c index afad4676933..f1a931ac2f3 100644 --- a/sys/arch/mac68k/dev/nubus.c +++ b/sys/arch/mac68k/dev/nubus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nubus.c,v 1.15 2001/05/08 17:30:40 aaron Exp $ */ +/* $OpenBSD: nubus.c,v 1.16 2001/06/08 08:09:00 art Exp $ */ /* $NetBSD: nubus.c,v 1.35 1997/04/22 20:20:32 scottr Exp $ */ /* @@ -311,7 +311,7 @@ probe_slot(slot, fmt) #ifdef DEBUG if (nubus_debug & NDB_PROBE) { - pa = pmap_extract(pmap_kernel(), (vm_offset_t) rom_probe - 1); + pmap_extract(pmap_kernel(), (vm_offset_t) rom_probe - 1, &pa); printf("probing slot %d, first probe at %p (PA %lx).\n", slot, rom_probe - 1, pa); } diff --git a/sys/arch/mac68k/mac68k/bus_space.c b/sys/arch/mac68k/mac68k/bus_space.c index f8cf87f22d5..cbae298e2c3 100644 --- a/sys/arch/mac68k/mac68k/bus_space.c +++ b/sys/arch/mac68k/mac68k/bus_space.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_space.c,v 1.5 2001/05/08 17:30:40 aaron Exp $ */ +/* $OpenBSD: bus_space.c,v 1.6 2001/06/08 08:09:01 art Exp $ */ /* $NetBSD: bus_space.c,v 1.5 1999/03/26 23:41:30 mycroft Exp $ */ /*- @@ -212,7 +212,7 @@ bus_space_unmap(t, bsh, size) panic("bus_space_unmap: overflow"); #endif - bpa = pmap_extract(pmap_kernel(), va) + (bsh & PGOFSET); + pmap_extract(pmap_kernel(), va, &bpa) + (bsh & PGOFSET); /* * Free the kernel virtual mapping. diff --git a/sys/arch/mac68k/mac68k/pmap.c b/sys/arch/mac68k/mac68k/pmap.c index 40fdcd9cbcd..578814224fc 100644 --- a/sys/arch/mac68k/mac68k/pmap.c +++ b/sys/arch/mac68k/mac68k/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.20 2001/06/08 02:47:39 aaron Exp $ */ +/* $OpenBSD: pmap.c,v 1.21 2001/06/08 08:09:02 art Exp $ */ /* $NetBSD: pmap.c,v 1.55 1999/04/22 04:24:53 chs Exp $ */ /* @@ -413,7 +413,7 @@ pmap_init() #endif Segtabzero = (st_entry_t *)addr; - Segtabzeropa = (st_entry_t *)pmap_extract(pmap_kernel(), addr); + pmap_extract(pmap_kernel(), addr, (paddr_t *)Segtabzeropa); addr += MAC_STSIZE; pv_table = (struct pv_entry *)addr; @@ -489,7 +489,7 @@ pmap_init() (--kpt_pages)->kpt_next = kpt_free_list; kpt_free_list = kpt_pages; kpt_pages->kpt_va = addr2; - kpt_pages->kpt_pa = pmap_extract(pmap_kernel(), addr2); + pmap_extract(pmap_kernel(), addr2, &kpt_pages->kpt_pa); } while (addr != addr2); PMAP_DPRINTF(PDB_INIT, ("pmap_init: KPT: %ld pages from %lx to %lx\n", @@ -1445,25 +1445,28 @@ pmap_unwire(pmap, va) * Extract the physical address associated with the given * pmap/virtual address pair. */ -paddr_t -pmap_extract(pmap, va) +boolean_t +pmap_extract(pmap, va, pap) pmap_t pmap; vaddr_t va; + paddr_t *pap; { paddr_t pa; PMAP_DPRINTF(PDB_FOLLOW, ("pmap_extract(%p, %lx) -> ", pmap, va)); - pa = 0; if (pmap && pmap_ste_v(pmap, va)) pa = *pmap_pte(pmap, va); - if (pa) - pa = (pa & PG_FRAME) | (va & ~PG_FRAME); + else + return (FALSE); + + pa = (pa & PG_FRAME) | (va & ~PG_FRAME); PMAP_DPRINTF(PDB_FOLLOW, ("%lx\n", pa)); - return (pa); + *pap = pa; + return (TRUE); } /* @@ -1621,7 +1624,7 @@ ok: * We call pmap_remove_entry to take care of invalidating * ST and Sysptmap entries. */ - kpa = pmap_extract(pmap, pv->pv_va); + pmap_extract(pmap, pv->pv_va, &kpa); pmap_remove_mapping(pmap, pv->pv_va, PT_ENTRY_NULL, PRM_TFLUSH|PRM_CFLUSH); /* @@ -2230,8 +2233,8 @@ pmap_enter_ptpage(pmap, va) #else pmap->pm_stab = (st_entry_t *)kmem_alloc(st_map, MAC_STSIZE); #endif - pmap->pm_stpa = (st_entry_t *) - pmap_extract(pmap_kernel(), (vaddr_t)pmap->pm_stab); + pmap_extract(pmap_kernel(), (vaddr_t)pmap->pm_stab, + (paddr_t *)pmap->pm_stpa); #if defined(M68040) if (mmutype == MMU_68040) { #ifdef DEBUG @@ -2355,7 +2358,7 @@ pmap_enter_ptpage(pmap, va) panic("pmap_enter: vm_fault failed"); } #endif - ptpa = pmap_extract(pmap_kernel(), va); + pmap_extract(pmap_kernel(), va, &ptpa); /* * Mark the page clean now to avoid its pageout (and * hence creation of a pager) between now and when it diff --git a/sys/arch/mac68k/mac68k/trap.c b/sys/arch/mac68k/mac68k/trap.c index 9b63f6411c4..a561a7907f4 100644 --- a/sys/arch/mac68k/mac68k/trap.c +++ b/sys/arch/mac68k/mac68k/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.21 2001/05/08 17:30:41 aaron Exp $ */ +/* $OpenBSD: trap.c,v 1.22 2001/06/08 08:09:02 art Exp $ */ /* $NetBSD: trap.c,v 1.68 1998/12/22 08:47:07 scottr Exp $ */ /* @@ -784,12 +784,15 @@ writeback(fp, docachepush) * cache push after a signal handler has been called. */ if (docachepush) { + paddr_t pa; + pmap_enter(pmap_kernel(), (vaddr_t)vmmap, trunc_page((vaddr_t)f->f_fa), VM_PROT_WRITE, TRUE, VM_PROT_WRITE); fa = (u_int)&vmmap[(f->f_fa & PGOFSET) & ~0xF]; bcopy((caddr_t)&f->f_pd0, (caddr_t)fa, 16); - DCFL(pmap_extract(pmap_kernel(), (vaddr_t)fa)); + pmap_extract(pmap_kernel(), (vaddr_t)fa, &pa) + DCFL(pa); pmap_remove(pmap_kernel(), (vaddr_t)vmmap, (vaddr_t)&vmmap[NBPG]); } else @@ -1015,8 +1018,7 @@ dumpwb(num, s, a, d) num, a, d, f7sz[(s & SSW4_SZMASK) >> 5], f7tt[(s & SSW4_TTMASK) >> 3], f7tm[s & SSW4_TMMASK]); printf(" PA "); - pa = pmap_extract(p->p_vmspace->vm_map.pmap, (vaddr_t)a); - if (pa == 0) + if (pmap_extract(p->p_vmspace->vm_map.pmap, (vaddr_t)a, &pa) == FALSE) printf("<invalid address>"); else printf("%lx, current value %lx", pa, fuword((caddr_t)a)); diff --git a/sys/arch/mac68k/mac68k/vm_machdep.c b/sys/arch/mac68k/mac68k/vm_machdep.c index af1dde63019..0fa9ce56a89 100644 --- a/sys/arch/mac68k/mac68k/vm_machdep.c +++ b/sys/arch/mac68k/mac68k/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.19 2001/05/08 17:30:41 aaron Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.20 2001/06/08 08:09:03 art Exp $ */ /* $NetBSD: vm_machdep.c,v 1.29 1998/07/28 18:34:55 thorpej Exp $ */ /* @@ -262,13 +262,15 @@ pagemove(from, to, size) panic("pagemove"); #endif while (size > 0) { - pa = pmap_extract(pmap_kernel(), (vm_offset_t) from); + pmap_extract(pmap_kernel(), (vm_offset_t) from, &pa); #ifdef DEBUG +#if 0 if (pa == 0) panic("pagemove 2"); - if (pmap_extract(pmap_kernel(), (vm_offset_t)to) != 0) + if (pmap_extract(pmap_kernel(), (vm_offset_t)to, XXX) != 0) panic("pagemove 3"); #endif +#endif pmap_remove(pmap_kernel(), (vm_offset_t)from, (vm_offset_t)from + PAGE_SIZE); pmap_enter(pmap_kernel(), @@ -345,12 +347,11 @@ int kvtop(addr) caddr_t addr; { - vm_offset_t va; + paddr_t pa; - va = pmap_extract(pmap_kernel(), (vm_offset_t)addr); - if (va == 0) + if (pmap_extract(pmap_kernel(), (vm_offset_t)addr, &pa) == FALSE) panic("kvtop: zero page frame"); - return((int)va); + return((int)pa); } extern vm_map_t phys_map; @@ -390,8 +391,7 @@ vmapbuf(bp, len) upmap = vm_map_pmap(&bp->b_proc->p_vmspace->vm_map); kpmap = vm_map_pmap(phys_map); do { - pa = pmap_extract(upmap, uva); - if (pa == 0) + if (pmap_extract(upmap, uva, &pa) == FALSE) panic("vmapbuf: null page frame"); pmap_enter(kpmap, kva, pa, VM_PROT_READ|VM_PROT_WRITE, TRUE, 0); uva += PAGE_SIZE; diff --git a/sys/arch/mips/mips/vm_machdep.c b/sys/arch/mips/mips/vm_machdep.c index b26122da8f0..071fea29571 100644 --- a/sys/arch/mips/mips/vm_machdep.c +++ b/sys/arch/mips/mips/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.13 2001/05/06 00:45:52 art Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.14 2001/06/08 08:09:04 art Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -313,9 +313,8 @@ vmapbuf(bp, len) bp->b_un.b_addr = (caddr_t) (kva + off); sz = atop(sz); while (sz--) { - pa = pmap_extract(vm_map_pmap(&p->p_vmspace->vm_map), - (vm_offset_t)addr); - if (pa == 0) + if (pmap_extract(vm_map_pmap(&p->p_vmspace->vm_map), + (vm_offset_t)addr, &pa) == FALSE) panic("vmapbuf: null page frame"); pmap_enter(vm_map_pmap(phys_map), kva, trunc_page(pa), VM_PROT_READ|VM_PROT_WRITE, TRUE, 0); diff --git a/sys/arch/mvme68k/dev/if_ie.c b/sys/arch/mvme68k/dev/if_ie.c index fb020f7cd3a..52ac91b4309 100644 --- a/sys/arch/mvme68k/dev/if_ie.c +++ b/sys/arch/mvme68k/dev/if_ie.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ie.c,v 1.12 2001/02/20 19:39:31 mickey Exp $ */ +/* $OpenBSD: if_ie.c,v 1.13 2001/06/08 08:09:06 art Exp $ */ /*- * Copyright (c) 1999 Steve Murphree, Jr. @@ -169,8 +169,6 @@ vm_map_t ie_map; /* for obio */ #define NTXBUF 2 /* number of transmit commands */ #define IE_TBUF_SIZE ETHER_MAX_LEN /* length of transmit buffer */ -#define CACHED_TO_PHYS(x) pmap_extract(pmap_kernel(), (vm_offset_t)(x)) - struct ie_softc { struct device sc_dev; /* device structure */ struct intrhand sc_ih, sc_failih; /* interrupt info */ @@ -364,8 +362,8 @@ ie_obreset(sc) ieo->portlow = a >> 16; delay(1000); - a = (u_long)CACHED_TO_PHYS(sc->scp) | - IE_PORT_NEWSCPADDR; + pmap_extract(pmap_kernel(), sc->scp, &a); + a |= IE_PORT_NEWSCPADDR; ieo->porthigh = a & 0xffff; t = 0; t = 1; ieo->portlow = a >> 16; @@ -402,7 +400,7 @@ ieattach(parent, self, aux) register struct bootpath *bp; int pri = ca->ca_ipl; volatile struct ieob *ieo; - vm_offset_t pa; + paddr_t pa; sc->reset_596 = ie_obreset; sc->chan_attn = ie_obattend; @@ -420,8 +418,8 @@ ieattach(parent, self, aux) /* get the first avaliable etherbuf */ sc->sc_maddr = etherbuf; /* maddr = vaddr */ if (sc->sc_maddr == NULL) panic("ie: too many ethernet boards"); - pa = CACHED_TO_PHYS(sc->sc_maddr); - if (pa == 0) panic("ie: pmap_extract"); + if (pmap_extract(pmap_kernel(), sc->sc_maddr, &pa) == FALSE) + panic("ie: pmap_extract"); sc->sc_iobase = (caddr_t)pa; /* iobase = paddr (24 bit) */ /*printf("maddrP %x iobaseV %x\n", sc->sc_maddr, sc->sc_iobase);*/ @@ -436,7 +434,8 @@ ieattach(parent, self, aux) /*printf("scpV %x iscpV %x scbV %x\n", sc->scp, sc->iscp, sc->scb);*/ sc->scp->ie_bus_use = 0x44; - SWT_32(sc->scp->ie_iscp_ptr, CACHED_TO_PHYS(sc->iscp)); + pmap_extract(pmap_kernel(), sc->iscp, &pa); + SWT_32(sc->scp->ie_iscp_ptr, pa); /* * rest of first page is unused (wasted!), rest of ram * for buffers diff --git a/sys/arch/mvme68k/dev/sbicdma.c b/sys/arch/mvme68k/dev/sbicdma.c index e6d4c96c5fb..cecb7ef21cb 100644 --- a/sys/arch/mvme68k/dev/sbicdma.c +++ b/sys/arch/mvme68k/dev/sbicdma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sbicdma.c,v 1.4 1996/11/23 21:46:00 kstailey Exp $ */ +/* $OpenBSD: sbicdma.c,v 1.5 2001/06/08 08:09:07 art Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -178,7 +178,7 @@ sbicdma_dmago(sc, va, count, flags) u_char csr; u_long pa; - pa = (u_long)pmap_extract(pmap_kernel(), (vm_offset_t)va); + pmap_extract(pmap_kernel(), (vm_offset_t)va, &pa); #ifdef DEBUG if (sbicdma_debug) printf("%s: dmago: va 0x%x pa 0x%x cnt %d flags %x\n", diff --git a/sys/arch/mvme68k/mvme68k/pmap.c b/sys/arch/mvme68k/mvme68k/pmap.c index 886d019eb8c..698130099d3 100644 --- a/sys/arch/mvme68k/mvme68k/pmap.c +++ b/sys/arch/mvme68k/mvme68k/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.19 2001/05/09 15:31:25 art Exp $ */ +/* $OpenBSD: pmap.c,v 1.20 2001/06/08 08:09:08 art Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -488,7 +488,7 @@ bogons: addr = (vm_offset_t) kmem_alloc(kernel_map, s); Segtabzero = (st_entry_t *) addr; - Segtabzeropa = (st_entry_t *) pmap_extract(pmap_kernel(), addr); + pmap_extract(pmap_kernel(), addr, (paddr_t *)&Segtabzeropa); #ifdef M68060 if (mmutype == MMU_68060) { addr2 = addr; @@ -562,7 +562,7 @@ bogons: (--kpt_pages)->kpt_next = kpt_free_list; kpt_free_list = kpt_pages; kpt_pages->kpt_va = addr2; - kpt_pages->kpt_pa = pmap_extract(pmap_kernel(), addr2); + pmap_extract(pmap_kernel(), addr2, &kpt_pages->kpt_pa); #ifdef M68060 if (mmutype == MMU_68060) { pmap_changebit(kpt_pages->kpt_pa, PG_CCB, 0); @@ -1472,27 +1472,28 @@ pmap_unwire(pmap, va) * with the given map/virtual_address pair. */ -vm_offset_t -pmap_extract(pmap, va) - register pmap_t pmap; +boolean_t +pmap_extract(pmap, va, pap) + pmap_t pmap; vm_offset_t va; + paddr_t *pap; { - register vm_offset_t pa; + paddr_t pa; #ifdef DEBUG if (pmapdebug & PDB_FOLLOW) printf("pmap_extract(%x, %x) -> ", pmap, va); #endif - pa = 0; if (pmap && pmap_ste_v(pmap, va)) pa = *pmap_pte(pmap, va); - if (pa) - pa = (pa & PG_FRAME) | (va & ~PG_FRAME); + else + return (FALSE); + *pap = (pa & PG_FRAME) | (va & ~PG_FRAME); #ifdef DEBUG if (pmapdebug & PDB_FOLLOW) - printf("%x\n", pa); + printf("%x\n", *pap); #endif - return(pa); + return (TRUE); } /* @@ -1652,7 +1653,7 @@ ok: * We call pmap_remove_entry to take care of invalidating * ST and Sysptmap entries. */ - kpa = pmap_extract(pmap, pv->pv_va); + pmap_extract(pmap, pv->pv_va, &kpa); pmap_remove_mapping(pmap, pv->pv_va, PT_ENTRY_NULL, PRM_TFLUSH|PRM_CFLUSH); /* @@ -2264,8 +2265,8 @@ pmap_enter_ptpage(pmap, va) if (pmap->pm_stab == Segtabzero) { pmap->pm_stab = (st_entry_t *) kmem_alloc(st_map, M68K_STSIZE); - pmap->pm_stpa = (st_entry_t *) - pmap_extract(pmap_kernel(), (vm_offset_t)pmap->pm_stab); + pmap_extract(pmap_kernel(), (vm_offset_t)pmap->pm_stab, + (paddr_t *)&pmap->pm_stpa); #if defined(M68040) || defined(M68060) if (mmutype <= MMU_68040) { #ifdef DEBUG @@ -2411,7 +2412,7 @@ pmap_enter_ptpage(pmap, va) printf("vm_fault(pt_map, %x, RW, 0) -> %d\n", va, s); panic("pmap_enter: vm_fault failed"); } - ptpa = pmap_extract(pmap_kernel(), va); + pmap_extract(pmap_kernel(), va, &ptpa); /* * Mark the page clean now to avoid its pageout (and * hence creation of a pager) between now and when it diff --git a/sys/arch/mvme68k/mvme68k/sys_machdep.c b/sys/arch/mvme68k/mvme68k/sys_machdep.c index 39a1841aa86..edd5d7e5179 100644 --- a/sys/arch/mvme68k/mvme68k/sys_machdep.c +++ b/sys/arch/mvme68k/mvme68k/sys_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sys_machdep.c,v 1.9 2000/06/23 02:14:37 mickey Exp $ */ +/* $OpenBSD: sys_machdep.c,v 1.10 2001/06/08 08:09:09 art Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -115,9 +115,8 @@ int len; */ if (!doall && (pa == 0 || ((int)addr & PGOFSET) == 0)) { - pa = pmap_extract(curproc->p_vmspace->vm_map.pmap, - (vm_offset_t)addr); - if (pa == 0) + if (pmap_extract(curproc->p_vmspace->vm_map.pmap, + (vm_offset_t)addr, &pa) == FALSE) doall = 1; } switch (req) { diff --git a/sys/arch/mvme68k/mvme68k/trap.c b/sys/arch/mvme68k/mvme68k/trap.c index 9363eb9353d..a081cf14def 100644 --- a/sys/arch/mvme68k/mvme68k/trap.c +++ b/sys/arch/mvme68k/mvme68k/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.29 2001/05/05 21:26:39 art Exp $ */ +/* $OpenBSD: trap.c,v 1.30 2001/06/08 08:09:09 art Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -723,11 +723,14 @@ int docachepush; * cache push after a signal handler has been called. */ if (docachepush) { + paddr_t pa; + pmap_enter(pmap_kernel(), (vm_offset_t)vmmap, trunc_page((vaddr_t)f->f_fa), VM_PROT_WRITE, TRUE, VM_PROT_WRITE); fa = (u_int)&vmmap[(f->f_fa & PGOFSET) & ~0xF]; bcopy((caddr_t)&f->f_pd0, (caddr_t)fa, 16); - DCFL(pmap_extract(pmap_kernel(), (vm_offset_t)fa)); + pmap_extract(pmap_kernel(), (vm_offset_t)fa, &pa); + DCFL(pa); pmap_remove(pmap_kernel(), (vm_offset_t)vmmap, (vm_offset_t)&vmmap[NBPG]); } else @@ -950,8 +953,7 @@ u_int a, d; num, a, d, f7sz[(s & SSW4_SZMASK) >> 5], f7tt[(s & SSW4_TTMASK) >> 3], f7tm[s & SSW4_TMMASK]); printf(" PA "); - pa = pmap_extract(p->p_vmspace->vm_map.pmap, (vm_offset_t)a); - if (pa == 0) + if (pmap_extract(p->p_vmspace->vm_map.pmap, (vm_offset_t)a, &pa) == FALSE) printf("<invalid address>"); else printf("%x, current value %x", pa, fuword((caddr_t)a)); diff --git a/sys/arch/mvme68k/mvme68k/vm_machdep.c b/sys/arch/mvme68k/mvme68k/vm_machdep.c index a0c9e50259e..2dd2f2da07c 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.22 2001/05/06 00:45:52 art Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.23 2001/06/08 08:09:10 art Exp $ */ /* * Copyright (c) 1988 University of Utah. @@ -172,13 +172,15 @@ pagemove(from, to, size) panic("pagemove"); #endif while (size > 0) { - pa = pmap_extract(pmap_kernel(), (vm_offset_t)from); + pmap_extract(pmap_kernel(), (vm_offset_t)from, &pa); #ifdef DEBUG +#if 0 if (pa == 0) panic("pagemove 2"); - if (pmap_extract(pmap_kernel(), (vm_offset_t)to) != 0) + if (pmap_extract(pmap_kernel(), (vm_offset_t)to, XXX) != 0) panic("pagemove 3"); #endif +#endif pmap_remove(pmap_kernel(), (vm_offset_t)from, (vm_offset_t)from + PAGE_SIZE); pmap_enter(pmap_kernel(), @@ -246,14 +248,13 @@ setredzone(pte, vaddr) * Convert kernel VA to physical address */ kvtop(addr) - register caddr_t addr; + caddr_t addr; { - vm_offset_t va; + paddr_t pa; - va = pmap_extract(pmap_kernel(), (vm_offset_t)addr); - if (va == 0) + if (pmap_extract(pmap_kernel(), (vm_offset_t)addr, &pa) == FALSE) panic("kvtop: zero page frame"); - return((int)va); + return((int)pa); } extern vm_map_t phys_map; @@ -288,9 +289,8 @@ vmapbuf(bp, siz) kva = kmem_alloc_wait(phys_map, ctob(npf)); bp->b_data = (caddr_t)(kva + off); while (npf--) { - pa = pmap_extract(vm_map_pmap(&p->p_vmspace->vm_map), - (vm_offset_t)addr); - if (pa == 0) + if (pmap_extract(vm_map_pmap(&p->p_vmspace->vm_map), + (vm_offset_t)addr, &pa) == FALSE) panic("vmapbuf: null page frame"); pmap_enter(vm_map_pmap(phys_map), kva, trunc_page(pa), VM_PROT_READ|VM_PROT_WRITE, TRUE, VM_PROT_READ|VM_PROT_WRITE); diff --git a/sys/arch/mvme88k/ddb/db_interface.c b/sys/arch/mvme88k/ddb/db_interface.c index 49bca971001..24b98ae206f 100644 --- a/sys/arch/mvme88k/ddb/db_interface.c +++ b/sys/arch/mvme88k/ddb/db_interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_interface.c,v 1.8 2001/03/16 00:01:51 miod Exp $ */ +/* $OpenBSD: db_interface.c,v 1.9 2001/06/08 08:09:11 art Exp $ */ /* * Mach Operating System * Copyright (c) 1993-1991 Carnegie Mellon University @@ -577,7 +577,7 @@ db_write_bytes(addr, size, data) #endif *dst++ = *data++; } - physaddr = pmap_extract(kernel_pmap, (vm_offset_t)addr); + pmap_extract(kernel_pmap, (vm_offset_t)addr, &physaddr); cmmu_flush_cache(physaddr, i); } diff --git a/sys/arch/mvme88k/dev/if_ie.c b/sys/arch/mvme88k/dev/if_ie.c index f42566b9d4d..b1c7d9a4368 100644 --- a/sys/arch/mvme88k/dev/if_ie.c +++ b/sys/arch/mvme88k/dev/if_ie.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ie.c,v 1.10 2001/03/09 05:44:38 smurph Exp $ */ +/* $OpenBSD: if_ie.c,v 1.11 2001/06/08 08:09:13 art Exp $ */ /*- * Copyright (c) 1998 Steve Murphree, Jr. @@ -161,8 +161,6 @@ vm_map_t ie_map; /* for obio */ #define NTXBUF 2 /* number of transmit commands */ #define IE_TBUF_SIZE ETHER_MAX_LEN /* length of transmit buffer */ -#define CACHED_TO_PHYS(x) pmap_extract(pmap_kernel(), (vm_offset_t)(x)) - struct ie_softc { struct device sc_dev; /* device structure */ struct intrhand sc_ih, sc_failih; /* interrupt info */ @@ -362,8 +360,8 @@ ie_obreset(sc) ieo->portlow = a >> 16; delay(1000); - a = (u_long)CACHED_TO_PHYS(sc->scp) | - IE_PORT_NEWSCPADDR; + pmap_extract(pmap_kernel(), sc->scp, &a); + a |= IE_PORT_NEWSCPADDR; ieo->porthigh = a & 0xffff; t = 0; t = 1; ieo->portlow = a >> 16; @@ -417,8 +415,8 @@ ieattach(parent, self, aux) /* get the first avaliable etherbuf */ sc->sc_maddr = etherbuf; /* maddr = vaddr */ if (sc->sc_maddr == NULL) panic("ie: too many ethernet boards"); - pa = CACHED_TO_PHYS(sc->sc_maddr); - if (pa == 0) panic("ie: pmap_extract"); + if (pmap_extract(pmap_kernel(), sc->sc_maddr, &pa) == FALSE) + panic("ie: pmap_extract"); sc->sc_iobase = (caddr_t)pa; /* iobase = paddr (24 bit) */ /*printf("maddrP %x iobaseV %x\n", sc->sc_maddr, sc->sc_iobase);*/ @@ -433,7 +431,8 @@ ieattach(parent, self, aux) /*printf("scpV %x iscpV %x scbV %x\n", sc->scp, sc->iscp, sc->scb);*/ sc->scp->ie_bus_use = 0x44; - SWT_32(sc->scp->ie_iscp_ptr, CACHED_TO_PHYS(sc->iscp)); + pmap_extract(pmap_kernel(), sc->iscp, &pa); + SWT_32(sc->scp->ie_iscp_ptr, pa); /* * rest of first page is unused (wasted!), rest of ram * for buffers diff --git a/sys/arch/mvme88k/mvme88k/pmap.c b/sys/arch/mvme88k/mvme88k/pmap.c index 6bf3e432933..f647a14b34b 100644 --- a/sys/arch/mvme88k/mvme88k/pmap.c +++ b/sys/arch/mvme88k/mvme88k/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.27 2001/05/16 12:49:47 ho Exp $ */ +/* $OpenBSD: pmap.c,v 1.28 2001/06/08 08:09:14 art Exp $ */ /* * Copyright (c) 1996 Nivas Madhur * All rights reserved. @@ -1709,18 +1709,24 @@ pmap_pinit(pmap_t p) if (segdt == NULL) panic("pmap_create: kmem_alloc failure"); +#if !defined(UVM) + /* uvm_km_zalloc gives zeroed memory */ /* use pmap zero page to zero it out */ addr = (vm_offset_t)segdt; for (i=0; i<atop(s); i++) { - pmap_zero_page(pmap_extract(kernel_pmap, addr)); + paddr_t pa; + + pmap_extract(kernel_pmap, addr, &pa); + pmap_zero_page(pa); addr += PAGE_SIZE; } +#endif /* * Initialize pointer to segment table both virtual and physical. */ p->sdt_vaddr = segdt; - p->sdt_paddr = (sdt_entry_t *)pmap_extract(kernel_pmap,(vm_offset_t)segdt); + pmap_extract(kernel_pmap, (vaddr_t)segdt, (paddr_t *)&p->sdt_paddr); if (!PAGE_ALIGNED(p->sdt_paddr)) { printf("pmap_create: std table = %x\n",(int)p->sdt_paddr); @@ -2654,7 +2660,6 @@ pmap_expand(pmap_t map, vm_offset_t v) vm_offset_t pdt_vaddr, pdt_paddr; sdt_entry_t *sdt; pt_entry_t *pte; - vm_offset_t pmap_extract(); if (map == PMAP_NULL) { panic("pmap_expand: pmap is NULL"); @@ -2688,7 +2693,7 @@ pmap_expand(pmap_t map, vm_offset_t v) #else pdt_vaddr = kmem_alloc (kernel_map, PAGE_SIZE); #endif - pdt_paddr = pmap_extract(kernel_pmap, pdt_vaddr); + pmap_extract(kernel_pmap, pdt_vaddr, &pdt_paddr); #ifdef MVME188 if (cputyp == CPU_188) { @@ -3110,6 +3115,7 @@ pmap_unwire(pmap_t map, vm_offset_t v) * Parameters: * pmap pointer to pmap structure * va virtual address + * pap storage for result. * * Calls: * PMAP_LOCK, PMAP_UNLOCK @@ -3125,12 +3131,12 @@ pmap_unwire(pmap_t map, vm_offset_t v) * then 0 address is returned. Otherwise, the physical page address from * the PTE is returned. */ -vm_offset_t -pmap_extract(pmap_t pmap, vm_offset_t va) +boolean_t +pmap_extract(pmap_t pmap, vm_offset_t va, paddr_t *pap) { - register pt_entry_t *pte; - register vm_offset_t pa; - register int i; + pt_entry_t *pte; + paddr_t pa; + int i; int spl; if (pmap == PMAP_NULL) @@ -3142,28 +3148,31 @@ pmap_extract(pmap_t pmap, vm_offset_t va) if (pmap == kernel_pmap && batc_used > 0) for (i = batc_used-1; i > 0; i--) if (batc_entry[i].lba == M88K_BTOBLK(va)) { - pa = (batc_entry[i].pba << BATC_BLKSHIFT) | + *pap = (batc_entry[i].pba << BATC_BLKSHIFT) | (va & BATC_BLKMASK ); - return (pa); + return (TRUE); } PMAP_LOCK(pmap, spl); - if ((pte = pmap_pte(pmap, va)) == PT_ENTRY_NULL) - pa = (vm_offset_t) 0; - else { + if ((pte = pmap_pte(pmap, va)) == PT_ENTRY_NULL) { + goto fail; + } else { if (PDT_VALID(pte)) pa = M88K_PTOB(pte->pfn); else - pa = (vm_offset_t) 0; + goto fail; } - if (pa) - pa |= (va & M88K_PGOFSET); /* offset within page */ + pa |= (va & M88K_PGOFSET); /* offset within page */ + *pap = pa; PMAP_UNLOCK(pmap, spl); - return (pa); -} /* pamp_extract() */ + return (TRUE); +fail: + PMAP_UNLOCK(pmap, spl); + return (FALSE); +} /* pmap_extract() */ /* a version for the kernel debugger diff --git a/sys/arch/mvme88k/mvme88k/vm_machdep.c b/sys/arch/mvme88k/mvme88k/vm_machdep.c index 828a9e94356..2a502a4d25b 100644 --- a/sys/arch/mvme88k/mvme88k/vm_machdep.c +++ b/sys/arch/mvme88k/mvme88k/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.24 2001/05/06 00:45:54 art Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.25 2001/06/08 08:09:16 art Exp $ */ /* * Copyright (c) 1998 Steve Murphree, Jr. @@ -243,7 +243,8 @@ vmapbuf(bp, len) vm_size_t len; { register caddr_t addr; - register vm_offset_t pa, kva, off; + register vm_offset_t kva, off; + vm_offset_t pa; struct pmap *pmap; #ifdef DIAGNOSTIC @@ -279,8 +280,7 @@ vmapbuf(bp, len) bp->b_data = (caddr_t)(kva + off); while (len > 0) { - pa = pmap_extract(pmap, (vm_offset_t)addr); - if (pa == 0) + if (pmap_extract(pmap, (vm_offset_t)addr, &pa) == FALSE) panic("vmapbuf: null page frame"); pmap_enter(vm_map_pmap(phys_map), kva, pa, VM_PROT_READ|VM_PROT_WRITE, TRUE, 0); @@ -502,22 +502,26 @@ badpaddr(caddr_t pa, int size) * Move pages from one kernel virtual address to another. */ void -pagemove(caddr_t from, caddr_t to, size_t size) +pagemove(from, to, size) + caddr_t from, to; + size_t size; { - register vm_offset_t pa; + vm_offset_t pa; #ifdef DEBUG if ((size & PAGE_MASK) != 0) panic("pagemove"); #endif while (size > 0) { - pa = pmap_extract(kernel_pmap, (vm_offset_t)from); + pmap_extract(kernel_pmap, (vm_offset_t)from, &pa); #ifdef DEBUG +#if 0 if (pa == 0) panic("pagemove 2"); - if (pmap_extract(kernel_pmap, (vm_offset_t)to) != 0) + if (pmap_extract(kernel_pmap, (vm_offset_t)to, XXX) != 0) panic("pagemove 3"); #endif +#endif pmap_remove(kernel_pmap, (vm_offset_t)from, (vm_offset_t)from + NBPG); pmap_enter(kernel_pmap, @@ -530,45 +534,12 @@ pagemove(caddr_t from, caddr_t to, size_t size) } u_int -kvtop(vm_offset_t va) +kvtop(va) + vm_offset_t va; { + vm_offset_t pa; extern pmap_t kernel_pmap; - return ((u_int)pmap_extract(kernel_pmap, va)); -} -/* - * Map `size' bytes of physical memory starting at `paddr' into - * kernel VA space at `vaddr'. Read/write and cache-inhibit status - * are specified by `prot'. - */ -#if 0 -physaccess(vaddr, paddr, size, prot) - void *vaddr, *paddr; - register int size, prot; -{ -/* register pt_entry_t *pte;*/ - pte_template_t *pte; - register u_int page; - - pte = kvtopte(vaddr); - page = (u_int)paddr & PG_FRAME; - for (size = btoc(size); size; size--) { - *pte++ = PG_V | prot | page; - page += NBPG; - } - TBIAS(); + pmap_extract(kernel_pmap, va, &pa); + return ((u_int)pa); } - -physunaccess(vaddr, size) - caddr_t vaddr; - register int size; -{ - register pt_entry_t *pte; - - pte = kvtopte(vaddr); - for (size = btoc(size); size; size--) - *pte++ = PG_NV; - TBIAS(); -} - -#endif diff --git a/sys/arch/pmax/pmax/pmap.c b/sys/arch/pmax/pmax/pmap.c index 786f65faf54..d64d974b49f 100644 --- a/sys/arch/pmax/pmax/pmap.c +++ b/sys/arch/pmax/pmax/pmap.c @@ -1103,12 +1103,13 @@ pmap_unwire(pmap, va) * Extract the physical page address associated * with the given map/virtual_address pair. */ -vm_offset_t -pmap_extract(pmap, va) - register pmap_t pmap; - vm_offset_t va; +boolean_t +pmap_extract(pmap, va, pap) + pmap_t pmap; + vaddr_t va; + paddr_t *pap; { - register vm_offset_t pa; + paddr_t pa; #ifdef DEBUG if (pmapdebug & PDB_FOLLOW) @@ -1125,20 +1126,20 @@ pmap_extract(pmap, va) register pt_entry_t *pte; if (!(pte = pmap_segmap(pmap, va))) - pa = 0; + return (FALSE); else { pte += (va >> PGSHIFT) & (NPTEPG - 1); pa = pte->pt_entry & PG_FRAME; } } - if (pa) - pa |= va & PGOFSET; + pa |= va & PGOFSET; + *pap = pa; #ifdef DEBUG if (pmapdebug & PDB_FOLLOW) printf("pmap_extract: pa %lx\n", pa); #endif - return (pa); + return (TRUE); } /* diff --git a/sys/arch/pmax/pmax/vm_machdep.c b/sys/arch/pmax/pmax/vm_machdep.c index 1a6cfb2c868..b0118085e04 100644 --- a/sys/arch/pmax/pmax/vm_machdep.c +++ b/sys/arch/pmax/pmax/vm_machdep.c @@ -297,7 +297,8 @@ vmapbuf(bp, len) register struct buf *bp; vm_size_t len; { - register vm_offset_t faddr, taddr, off, pa; + register vm_offset_t faddr, taddr, off; + vm_offset_t pa; struct proc *p; if ((bp->b_flags & B_PHYS) == 0) @@ -310,8 +311,8 @@ vmapbuf(bp, len) bp->b_data = (caddr_t) (taddr + off); len = atop(len); while (len--) { - pa = pmap_extract(vm_map_pmap(&p->p_vmspace->vm_map), faddr); - if (pa == 0) + if (pmap_extract(vm_map_pmap(&p->p_vmspace->vm_map), faddr, + &pa) == FALSE) panic("vmapbuf: null page frame"); pmap_enter(vm_map_pmap(phys_map), taddr, trunc_page(pa), VM_PROT_READ|VM_PROT_WRITE, TRUE, 0); diff --git a/sys/arch/powerpc/pci/mpcpcibus.c b/sys/arch/powerpc/pci/mpcpcibus.c index 0b802ab3368..7d5611df67c 100644 --- a/sys/arch/powerpc/pci/mpcpcibus.c +++ b/sys/arch/powerpc/pci/mpcpcibus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpcpcibus.c,v 1.25 2001/03/29 20:05:04 drahn Exp $ */ +/* $OpenBSD: mpcpcibus.c,v 1.26 2001/06/08 08:09:20 art Exp $ */ /* * Copyright (c) 1997 Per Fogelstrom @@ -722,7 +722,7 @@ vtophys(p) pa = va; } else { - pa = pmap_extract(vm_map_pmap(phys_map), va); + pmap_extract(vm_map_pmap(phys_map), va, &pa); } return(pa | ((pci_map_a == 1) ? MPC106_PCI_CPUMEM : 0 )); } diff --git a/sys/arch/powerpc/powerpc/dma.c b/sys/arch/powerpc/powerpc/dma.c index e441e55062d..ca02c114b77 100644 --- a/sys/arch/powerpc/powerpc/dma.c +++ b/sys/arch/powerpc/powerpc/dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dma.c,v 1.3 2000/08/03 03:02:50 rahnds Exp $ */ +/* $OpenBSD: dma.c,v 1.4 2001/06/08 08:09:21 art Exp $ */ /* $NetBSD: machdep.c,v 1.214 1996/11/10 03:16:17 thorpej Exp $ */ /*- @@ -162,7 +162,7 @@ _dmamap_load(t, map, buf, buflen, p, flags) /* * Get the physical address for this segment. */ - curaddr = (bus_addr_t)pmap_extract(pmap, (vm_offset_t)vaddr); + pmap_extract(pmap, (vm_offset_t)vaddr, (paddr_t *)&curaddr); /* * Compute the segment size, and adjust counts. diff --git a/sys/arch/powerpc/powerpc/machdep.c b/sys/arch/powerpc/powerpc/machdep.c index bdd812a02bb..142a74f0063 100644 --- a/sys/arch/powerpc/powerpc/machdep.c +++ b/sys/arch/powerpc/powerpc/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.61 2001/05/17 18:41:50 provos Exp $ */ +/* $OpenBSD: machdep.c,v 1.62 2001/06/08 08:09:22 art Exp $ */ /* $NetBSD: machdep.c,v 1.4 1996/10/16 19:33:11 ws Exp $ */ /* @@ -748,7 +748,7 @@ sendsig(catcher, sig, mask, code, type, val) - (p->p_emul->e_esigcode - p->p_emul->e_sigcode)); #if WHEN_WE_ONLY_FLUSH_DATA_WHEN_DOING_PMAP_ENTER - pa = pmap_extract(vm_map_pmap(&p->p_vmspace->vm_map),tf->srr0); + pmap_extract(vm_map_pmap(&p->p_vmspace->vm_map),tf->srr0, &pa); syncicache(pa, (p->p_emul->e_esigcode - p->p_emul->e_sigcode)); #endif } @@ -1140,7 +1140,7 @@ bus_space_unmap_p(t, bsh, size) { bus_addr_t paddr; - paddr = (bus_addr_t) pmap_extract(pmap_kernel(), bsh); + pmap_extract(pmap_kernel(), bsh, &paddr); bus_space_unmap((t), (bsh), (size)); return paddr ; } @@ -1165,7 +1165,7 @@ bus_space_unmap(t, bsh, size) kmem_free_wakeup(phys_map, sva, len); #endif #if 0 - bpa = pmap_extract(pmap_kernel(), sva); + pmap_extract(pmap_kernel(), sva, &bpa); if (extent_free(devio_ex, bpa, size, EX_NOWAIT | (ppc_malloc_ok ? EX_MALLOCOK : 0))) { diff --git a/sys/arch/powerpc/powerpc/pmap.c b/sys/arch/powerpc/powerpc/pmap.c index e476316b6fb..486e2bf48f5 100644 --- a/sys/arch/powerpc/powerpc/pmap.c +++ b/sys/arch/powerpc/powerpc/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.29 2001/05/09 15:31:26 art Exp $ */ +/* $OpenBSD: pmap.c,v 1.30 2001/06/08 08:09:22 art Exp $ */ /* $NetBSD: pmap.c,v 1.1 1996/09/30 16:34:52 ws Exp $ */ /* @@ -37,6 +37,7 @@ #include <sys/user.h> #include <sys/queue.h> #include <sys/systm.h> +#include <sys/pool.h> #include <vm/vm.h> #include <vm/vm_kern.h> @@ -257,38 +258,11 @@ struct pv_entry { struct pv_entry *pv_table; -struct pv_page; -struct pv_page_info { - LIST_ENTRY(pv_page) pgi_list; - struct pv_entry *pgi_freelist; - int pgi_nfree; -}; -#define NPVPPG ((NBPG - sizeof(struct pv_page_info)) / sizeof(struct pv_entry)) -struct pv_page { - struct pv_page_info pvp_pgi; - struct pv_entry pvp_pv[NPVPPG]; -}; -LIST_HEAD(pv_page_list, pv_page) pv_page_freelist; -int pv_nfree; -int pv_pcnt; +struct pool pmap_pv_pool; static struct pv_entry *pmap_alloc_pv __P((void)); static void pmap_free_pv __P((struct pv_entry *)); -struct po_page; -struct po_page_info { - LIST_ENTRY(po_page) pgi_list; - vm_page_t pgi_page; - LIST_HEAD(po_freelist, pte_ovfl) pgi_freelist; - int pgi_nfree; -}; -#define NPOPPG ((NBPG - sizeof(struct po_page_info)) / sizeof(struct pte_ovfl)) -struct po_page { - struct po_page_info pop_pgi; - struct pte_ovfl pop_po[NPOPPG]; -}; -LIST_HEAD(po_page_list, po_page) po_page_freelist; -int po_nfree; -int po_pcnt; +struct pool pmap_po_pool; static struct pte_ovfl *poalloc __P((void)); static void pofree __P((struct pte_ovfl *, int)); @@ -629,7 +603,6 @@ avail_end = npgs * NBPG; bcopy(mp + 1, mp, (cnt - (mp - avail)) * sizeof *mp); for (i = 0; i < ptab_cnt; i++) LIST_INIT(potable + i); - LIST_INIT(&pv_page_freelist); /* use only one memory list */ { @@ -741,7 +714,10 @@ pmap_init() pv = pv_table = (struct pv_entry *)addr; for (i = npgs; --i >= 0;) pv++->pv_idx = -1; - LIST_INIT(&pv_page_freelist); + pool_init(&pmap_pv_pool, sizeof(struct pv_entry), 0, 0, 0, "pvpl", + 0, NULL, NULL, M_VMPMAP); + pool_init(&pmap_po_pool, sizeof(struct pte_ovfl), 0, 0, 0, "popl", + 0, NULL, NULL, M_VMPMAP); pmap_attrib = (char *)pv; bzero(pv, npgs); #ifdef MACHINE_NEW_NONCONTIG @@ -1019,34 +995,29 @@ pmap_copy_page(src, dst) static struct pv_entry * pmap_alloc_pv() { - struct pv_page *pvp; struct pv_entry *pv; - int i; - - if (pv_nfree == 0) { -#ifdef UVM - if (!(pvp = (struct pv_page *)uvm_km_zalloc(kernel_map, NBPG))) - panic("pmap_alloc_pv: uvm_km_zalloc() failed"); -#else - if (!(pvp = (struct pv_page *)kmem_alloc(kernel_map, NBPG))) - panic("pmap_alloc_pv: kmem_alloc() failed"); -#endif - pv_pcnt++; - pvp->pvp_pgi.pgi_freelist = pv = &pvp->pvp_pv[1]; - for (i = NPVPPG - 2; --i >= 0; pv++) - pv->pv_next = pv + 1; - pv->pv_next = 0; - pv_nfree += pvp->pvp_pgi.pgi_nfree = NPVPPG - 1; - LIST_INSERT_HEAD(&pv_page_freelist, pvp, pvp_pgi.pgi_list); - pv = pvp->pvp_pv; - } else { - pv_nfree--; - pvp = pv_page_freelist.lh_first; - if (--pvp->pvp_pgi.pgi_nfree <= 0) - LIST_REMOVE(pvp, pvp_pgi.pgi_list); - pv = pvp->pvp_pgi.pgi_freelist; - pvp->pvp_pgi.pgi_freelist = pv->pv_next; - } + int s; + + /* + * XXX - this splimp can go away once we have PMAP_NEW and + * a correct implementation of pmap_kenter. + */ + /* + * Note that it's completly ok to use a pool here because it will + * never map anything or call pmap_enter because we have + * PMAP_MAP_POOLPAGE. + */ + s = splimp(); + pv = pool_get(&pmap_pv_pool, PR_NOWAIT); + splx(s); + /* + * XXX - some day we might want to implement pv stealing, or + * to pass down flags from pmap_enter about allowed failure. + * Right now - just panic. + */ + if (pv == NULL) + panic("pmap_alloc_pv: failed to allocate pv"); + return pv; } @@ -1054,73 +1025,34 @@ static void pmap_free_pv(pv) struct pv_entry *pv; { - struct pv_page *pvp; - - pvp = (struct pv_page *)trunc_page((vaddr_t)pv); - switch (++pvp->pvp_pgi.pgi_nfree) { - case 1: - LIST_INSERT_HEAD(&pv_page_freelist, pvp, pvp_pgi.pgi_list); - default: - pv->pv_next = pvp->pvp_pgi.pgi_freelist; - pvp->pvp_pgi.pgi_freelist = pv; - pv_nfree++; - break; - case NPVPPG: - pv_nfree -= NPVPPG - 1; - pv_pcnt--; - LIST_REMOVE(pvp, pvp_pgi.pgi_list); -#ifdef UVM - uvm_km_free(kernel_map, (vaddr_t)pvp, NBPG); -#else - kmem_free(kernel_map, (vm_offset_t)pvp, NBPG); -#endif - break; - } + int s; + + /* XXX - see pmap_alloc_pv */ + s = splimp(); + pool_put(&pmap_pv_pool, pv); + splx(s); } /* * We really hope that we don't need overflow entries * before the VM system is initialized! XXX + * XXX - see pmap_alloc_pv */ static struct pte_ovfl * poalloc() { - struct po_page *pop; struct pte_ovfl *po; - vm_page_t mem; - int i; + int s; +#ifdef DIAGNOSTIC if (!pmap_initialized) panic("poalloc"); - - if (po_nfree == 0) { - /* - * Since we cannot use maps for potable allocation, - * we have to steal some memory from the VM system. XXX - */ -#ifdef UVM - mem = uvm_pagealloc(NULL, 0, NULL, UVM_PGA_USERESERVE); -#else - mem = vm_page_alloc(NULL, NULL); #endif - po_pcnt++; - pop = (struct po_page *)VM_PAGE_TO_PHYS(mem); - pop->pop_pgi.pgi_page = mem; - LIST_INIT(&pop->pop_pgi.pgi_freelist); - for (i = NPOPPG - 1, po = pop->pop_po + 1; --i >= 0; po++) - LIST_INSERT_HEAD(&pop->pop_pgi.pgi_freelist, po, po_list); - po_nfree += pop->pop_pgi.pgi_nfree = NPOPPG - 1; - LIST_INSERT_HEAD(&po_page_freelist, pop, pop_pgi.pgi_list); - po = pop->pop_po; - } else { - po_nfree--; - pop = po_page_freelist.lh_first; - if (--pop->pop_pgi.pgi_nfree <= 0) - LIST_REMOVE(pop, pop_pgi.pgi_list); - po = pop->pop_pgi.pgi_freelist.lh_first; - LIST_REMOVE(po, po_list); - } - return po; + s = splimp(); + po = pool_get(&pmap_po_pool, PR_NOWAIT); + splx(s); + if (po == NULL) + panic("poalloc: failed to alloc po"); } static void @@ -1128,29 +1060,10 @@ pofree(po, freepage) struct pte_ovfl *po; int freepage; { - struct po_page *pop; - - pop = (struct po_page *)trunc_page((vaddr_t)po); - switch (++pop->pop_pgi.pgi_nfree) { - case NPOPPG: - if (!freepage) - break; - po_nfree -= NPOPPG - 1; - po_pcnt--; - LIST_REMOVE(pop, pop_pgi.pgi_list); -#ifdef UVM - uvm_pagefree(pop->pop_pgi.pgi_page); -#else - vm_page_free(pop->pop_pgi.pgi_page); -#endif - return; - case 1: - LIST_INSERT_HEAD(&po_page_freelist, pop, pop_pgi.pgi_list); - default: - break; - } - LIST_INSERT_HEAD(&pop->pop_pgi.pgi_freelist, po, po_list); - po_nfree++; + int s; + s = splimp(); + pool_put(&pmap_po_pool, po); + splx(s); } /* @@ -1474,28 +1387,30 @@ pte_find(pm, va) /* * Get the physical page address for the given pmap/virtual address. */ -vm_offset_t -pmap_extract(pm, va) +boolean_t +pmap_extract(pm, va, pap) struct pmap *pm; - vm_offset_t va; + vaddr_t va; + paddr_t *pap; { pte_t *ptp; - vm_offset_t o; int s = splimp(); + boolean_t ret; if (!(ptp = pte_find(pm, va))) { /* return address 0 if not mapped??? */ - o = 0; + ret = FALSE; if (pm == pmap_kernel() && va < 0x80000000){ /* if in kernel, va==pa for 0 - 0x80000000 */ - o = va; + *pap = va; + ret = TRUE; } splx(s); - return o; + return ret; } - o = (ptp->pte_lo & PTE_RPGN) | (va & ADDR_POFF); + *pap = (ptp->pte_lo & PTE_RPGN) | (va & ADDR_POFF); splx(s); - return o; + return TRUE; } /* diff --git a/sys/arch/powerpc/powerpc/vm_machdep.c b/sys/arch/powerpc/powerpc/vm_machdep.c index 1e2d82d5d2e..addcc7b77c9 100644 --- a/sys/arch/powerpc/powerpc/vm_machdep.c +++ b/sys/arch/powerpc/powerpc/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.15 2001/05/05 21:26:40 art Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.16 2001/06/08 08:09:23 art Exp $ */ /* $NetBSD: vm_machdep.c,v 1.1 1996/09/30 16:34:57 ws Exp $ */ /* @@ -71,7 +71,8 @@ cpu_fork(p1, p2, stack, stacksize) pcb->pcb_pm = p2->p_vmspace->vm_map.pmap; - pcb->pcb_pmreal = (struct pmap *)pmap_extract(pmap_kernel(), (vm_offset_t)pcb->pcb_pm); + pmap_extract(pmap_kernel(), + (vm_offset_t)pcb->pcb_pm, (paddr_t *)&pcb->pcb_pmreal); /* * Setup the trap frame for the new process @@ -137,7 +138,8 @@ cpu_swapin(p) { struct pcb *pcb = &p->p_addr->u_pcb; - pcb->pcb_pmreal = (struct pmap *)pmap_extract(pmap_kernel(), (vm_offset_t)pcb->pcb_pm); + pmap_extract(pmap_kernel(), + (vm_offset_t)pcb->pcb_pm, (paddr_t *)pcb->pcb_pmreal); } /* @@ -148,10 +150,11 @@ pagemove(from, to, size) caddr_t from, to; size_t size; { - vm_offset_t pa, va; + vaddr_t va; + paddr_t pa; for (va = (vm_offset_t)from; size > 0; size -= NBPG) { - pa = pmap_extract(pmap_kernel(), va); + pmap_extract(pmap_kernel(), va, &pa); pmap_remove(pmap_kernel(), va, va + NBPG); pmap_enter(pmap_kernel(), (vm_offset_t)to, pa, VM_PROT_READ | VM_PROT_WRITE, 1, @@ -247,7 +250,7 @@ vmapbuf(bp, len) #endif bp->b_data = (caddr_t)(taddr + off); for (; len > 0; len -= NBPG) { - pa = pmap_extract(vm_map_pmap(&bp->b_proc->p_vmspace->vm_map), faddr); + pmap_extract(vm_map_pmap(&bp->b_proc->p_vmspace->vm_map), faddr, &pa); pmap_enter(vm_map_pmap(phys_map), taddr, pa, VM_PROT_READ | VM_PROT_WRITE, 1, 0); faddr += NBPG; diff --git a/sys/arch/sparc/dev/if_ie.c b/sys/arch/sparc/dev/if_ie.c index d83ec7f417f..55771f3d02e 100644 --- a/sys/arch/sparc/dev/if_ie.c +++ b/sys/arch/sparc/dev/if_ie.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ie.c,v 1.15 2001/05/10 10:34:44 art Exp $ */ +/* $OpenBSD: if_ie.c,v 1.16 2001/06/08 08:09:24 art Exp $ */ /* $NetBSD: if_ie.c,v 1.33 1997/07/29 17:55:38 fair Exp $ */ /*- @@ -565,8 +565,7 @@ ieattach(parent, self, aux) * to IEOB_ADBASE to be safe. */ - pa = pmap_extract(pmap_kernel(), (vaddr_t)sc->sc_maddr); - if (pa == 0) + if (pmap_extract(pmap_kernel(), (vaddr_t)sc->sc_maddr, &pa) == FALSE) panic("ie pmap_extract"); pmap_enter(pmap_kernel(), trunc_page(IEOB_ADBASE+IE_SCP_ADDR), (paddr_t)pa | PMAP_NC /*| PMAP_IOC*/, diff --git a/sys/arch/sparc/include/pmap.h b/sys/arch/sparc/include/pmap.h index 2cf54275ecd..7d55872bbe5 100644 --- a/sys/arch/sparc/include/pmap.h +++ b/sys/arch/sparc/include/pmap.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.h,v 1.17 2001/05/09 15:31:27 art Exp $ */ +/* $OpenBSD: pmap.h,v 1.18 2001/06/08 08:09:26 art Exp $ */ /* $NetBSD: pmap.h,v 1.30 1997/08/04 20:00:47 pk Exp $ */ /* @@ -421,7 +421,7 @@ extern void (*pmap_clear_reference_p) __P((paddr_t pa)); extern void (*pmap_copy_page_p) __P((paddr_t, paddr_t)); extern void (*pmap_enter_p) __P((pmap_t, vaddr_t, paddr_t, vm_prot_t, boolean_t, vm_prot_t)); -extern paddr_t (*pmap_extract_p) __P((pmap_t, vaddr_t)); +extern boolean_t (*pmap_extract_p) __P((pmap_t, vaddr_t, paddr_t *)); #ifdef PMAP_NEW extern boolean_t (*pmap_is_modified_p) __P((struct vm_page *)); extern boolean_t (*pmap_is_referenced_p) __P((struct vm_page *)); diff --git a/sys/arch/sparc/sparc/iommu.c b/sys/arch/sparc/sparc/iommu.c index 687a683807e..87a3fc8908e 100644 --- a/sys/arch/sparc/sparc/iommu.c +++ b/sys/arch/sparc/sparc/iommu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: iommu.c,v 1.7 2001/05/10 10:34:46 art Exp $ */ +/* $OpenBSD: iommu.c,v 1.8 2001/06/08 08:09:27 art Exp $ */ /* $NetBSD: iommu.c,v 1.13 1997/07/29 09:42:04 fair Exp $ */ /* @@ -371,7 +371,7 @@ if ((int)sc->sc_dvmacur + len > 0) iovaddr = tva = sc->sc_dvmacur; sc->sc_dvmacur += len; while (len) { - pa = pmap_extract(pmap_kernel(), va); + pmap_extract(pmap_kernel(), va, &pa); #define IOMMU_PPNSHIFT 8 #define IOMMU_V 0x00000002 diff --git a/sys/arch/sparc/sparc/vm_machdep.c b/sys/arch/sparc/sparc/vm_machdep.c index bb529b07999..4bfe64e8f0d 100644 --- a/sys/arch/sparc/sparc/vm_machdep.c +++ b/sys/arch/sparc/sparc/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.25 2001/05/18 08:25:03 miod Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.26 2001/06/08 08:09:28 art Exp $ */ /* $NetBSD: vm_machdep.c,v 1.30 1997/03/10 23:55:40 pk Exp $ */ /* @@ -88,8 +88,7 @@ pagemove(from, to, size) panic("pagemove 1"); #endif while (size > 0) { - pa = pmap_extract(pmap_kernel(), (vaddr_t)from); - if (pa == 0) + if (pmap_extract(pmap_kernel(), (vaddr_t)from, &pa) == FALSE) panic("pagemove 2"); pmap_remove(pmap_kernel(), (vaddr_t)from, (vaddr_t)from + PAGE_SIZE); @@ -216,8 +215,7 @@ dvma_mapin_space(map, va, len, canwait, space) kva = tva; while (npf--) { - pa = pmap_extract(vm_map_pmap(map), va); - if (pa == 0) + if (pmap_extract(vm_map_pmap(map), va, &pa) == FALSE) panic("dvma_mapin: null page frame"); pa = trunc_page(pa); @@ -328,8 +326,7 @@ vmapbuf(bp, sz) bp->b_data = (caddr_t)(kva + off); while (size > 0) { - pa = pmap_extract(pmap, uva); - if (pa == 0) + if (pmap_extract(pmap, uva, &pa) == FALSE) panic("vmapbuf: null page frame"); /* diff --git a/sys/arch/sun3/sun3/pmap.c b/sys/arch/sun3/sun3/pmap.c index 10453292b79..cd2dab4d32d 100644 --- a/sys/arch/sun3/sun3/pmap.c +++ b/sys/arch/sun3/sun3/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.23 2001/05/30 20:40:04 miod Exp $ */ +/* $OpenBSD: pmap.c,v 1.24 2001/06/08 08:09:29 art Exp $ */ /* $NetBSD: pmap.c,v 1.64 1996/11/20 18:57:35 gwr Exp $ */ /*- @@ -2797,13 +2797,13 @@ pmap_copy(dst_pmap, src_pmap, dst_addr, len, src_addr) * with the given map/virtual_address pair. * Returns FALSE if VA not valid. */ -vm_offset_t -pmap_extract(pmap, va) +boolean_t +pmap_extract(pmap, va, pap) pmap_t pmap; vaddr_t va; + paddr_t *pap; { int s, sme, segnum, ptenum, pte; - vm_offset_t pa; pte = 0; PMAP_LOCK(); @@ -2825,15 +2825,15 @@ pmap_extract(pmap, va) printf("pmap_extract: invalid va=0x%x\n", va); Debugger(); #endif - pte = 0; + return (FALSE); } - pa = PG_PA(pte); + *pap = PG_PA(pte); #ifdef DIAGNOSTIC if (pte & PG_TYPE) { panic("pmap_extract: not main mem, va=0x%x", va); } #endif - return (pa); + return (TRUE); } /* diff --git a/sys/arch/sun3/sun3/vm_machdep.c b/sys/arch/sun3/sun3/vm_machdep.c index ed6d185761b..a1180c3dbe4 100644 --- a/sys/arch/sun3/sun3/vm_machdep.c +++ b/sys/arch/sun3/sun3/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.15 2001/05/30 20:40:04 miod Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.16 2001/06/08 08:09:30 art Exp $ */ /* $NetBSD: vm_machdep.c,v 1.35 1996/04/26 18:38:06 gwr Exp $ */ /* @@ -297,7 +297,7 @@ pagemove(from, to, size) register caddr_t from, to; size_t size; { - register vm_offset_t pa; + vm_offset_t pa; #ifdef DIAGNOSTIC if ((size & PAGE_MASK) != 0 || @@ -306,11 +306,8 @@ pagemove(from, to, size) panic("pagemove 1"); #endif while (size > 0) { - pa = pmap_extract(pmap_kernel(), (vm_offset_t)from); -#ifdef DIAGNOSTIC - if (pa == 0) + if (pmap_extract(pmap_kernel(), (vm_offset_t)from, &pa) == FALSE) panic("pagemove 2"); -#endif /* this does the cache flush work itself */ pmap_remove(pmap_kernel(), (vm_offset_t)from, (vm_offset_t)from + NBPG); @@ -353,7 +350,8 @@ vmapbuf(bp, sz) register struct buf *bp; vm_size_t sz; { - register vm_offset_t addr, kva, pa; + register vm_offset_t addr, kva; + vm_offset_t pa; register vm_size_t size, off; register int npf; struct proc *p; @@ -377,10 +375,10 @@ vmapbuf(bp, sz) npf = btoc(size); while (npf--) { - pa = pmap_extract(vm_map_pmap(map), (vm_offset_t)addr); - pa = trunc_page(pa); /* page type in low bits? */ - if (pa == 0) + if (pmap_extract(vm_map_pmap(map), (vm_offset_t)addr, + &pa) == FALSE) panic("vmapbuf: null page frame"); + pa = trunc_page(pa); /* page type in low bits? */ #ifdef HAVECACHE /* flush write-back on old mappings */ if (cache_size) diff --git a/sys/arch/vax/vax/bus_dma.c b/sys/arch/vax/vax/bus_dma.c index ec111ba3d22..7434034b8b4 100644 --- a/sys/arch/vax/vax/bus_dma.c +++ b/sys/arch/vax/vax/bus_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_dma.c,v 1.1 2000/04/27 01:10:10 bjc Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.2 2001/06/08 08:09:31 art Exp $ */ /* $NetBSD: bus_dma.c,v 1.5 1999/11/13 00:32:20 thorpej Exp $ */ /*- @@ -585,8 +585,7 @@ _bus_dmamap_load_buffer(t, map, buf, buflen, p, flags, lastaddrp, segp, first) /* * Get the physical address for this segment. */ - curaddr = pmap_extract(pmap, (vaddr_t)vaddr); - + pmap_extract(pmap, (vaddr_t)vaddr, &curaddr); #if 0 /* * Make sure we're in an allowed DMA range. diff --git a/sys/arch/vax/vax/pmap.c b/sys/arch/vax/vax/pmap.c index a619e1d4887..93aa69ba9fe 100644 --- a/sys/arch/vax/vax/pmap.c +++ b/sys/arch/vax/vax/pmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pmap.c,v 1.16 2001/05/16 17:29:39 hugh Exp $ */ +/* $OpenBSD: pmap.c,v 1.17 2001/06/08 08:09:32 art Exp $ */ /* $NetBSD: pmap.c,v 1.74 1999/11/13 21:32:25 matt Exp $ */ /* * Copyright (c) 1994, 1998, 1999 Ludd, University of Lule}, Sweden. @@ -860,10 +860,11 @@ if(startpmapdebug) return(virtuell+(count-pstart)+KERNBASE); } -paddr_t -pmap_extract(pmap, va) +boolean_t +pmap_extract(pmap, va, pap) pmap_t pmap; vaddr_t va; + paddr_t *pap; { paddr_t pa = 0; int *pte, sva; @@ -874,23 +875,26 @@ if(startpmapdebug)printf("pmap_extract: pmap %p, va %lx\n",pmap, va); if (va & KERNBASE) { pa = kvtophys(va); /* Is 0 if not mapped */ - return(pa); + *pap = pa; + return (TRUE); } sva = PG_PFNUM(va); if (va < 0x40000000) { if (sva > (pmap->pm_p0lr & ~AST_MASK)) - return NULL; + return (FALSE); pte = (int *)pmap->pm_p0br; } else { if (sva < pmap->pm_p1lr) - return NULL; + return (FALSE); pte = (int *)pmap->pm_p1br; } - if (kvtopte(&pte[sva])->pg_pfn) - return ((pte[sva] & PG_FRAME) << VAX_PGSHIFT); + if (kvtopte(&pte[sva])->pg_pfn) { + *pap = ((pte[sva] & PG_FRAME) << VAX_PGSHIFT); + return (TRUE); + } - return (NULL); + return (FALSE); } /* diff --git a/sys/arch/vax/vax/sgmap.c b/sys/arch/vax/vax/sgmap.c index 4d420a42b88..d9353f0e486 100644 --- a/sys/arch/vax/vax/sgmap.c +++ b/sys/arch/vax/vax/sgmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sgmap.c,v 1.3 2001/02/06 04:27:45 hugh Exp $ */ +/* $OpenBSD: sgmap.c,v 1.4 2001/06/08 08:09:33 art Exp $ */ /* $NetBSD: sgmap.c,v 1.8 2000/06/29 07:14:34 mrg Exp $ */ /*- @@ -243,7 +243,7 @@ vax_sgmap_load(t, map, buf, buflen, p, flags, sgmap) * Get the physical address for this segment. */ if (p != NULL) - pa = pmap_extract(p->p_vmspace->vm_map.pmap, va); + pmap_extract(p->p_vmspace->vm_map.pmap, va, &pa); else pa = kvtophys(va); diff --git a/sys/arch/vax/vax/vm_machdep.c b/sys/arch/vax/vax/vm_machdep.c index cc0fa99ecb8..7b2e7000d19 100644 --- a/sys/arch/vax/vax/vm_machdep.c +++ b/sys/arch/vax/vax/vm_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vm_machdep.c,v 1.20 2001/05/05 21:26:42 art Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.21 2001/06/08 08:09:33 art Exp $ */ /* $NetBSD: vm_machdep.c,v 1.67 2000/06/29 07:14:34 mrg Exp $ */ /* @@ -348,8 +348,8 @@ vmapbuf(bp, len) bp->b_data = (caddr_t)(taddr + off); len = atop(len); while (len--) { - if ((pa = pmap_extract(vm_map_pmap(&p->p_vmspace->vm_map), faddr)) - == FALSE) + if (pmap_extract(vm_map_pmap(&p->p_vmspace->vm_map), faddr, + &pa) == FALSE) panic("vmapbuf: null page frame"); pmap_enter(vm_map_pmap(phys_map), taddr, trunc_page(pa), VM_PROT_READ|VM_PROT_WRITE, TRUE, VM_PROT_READ|VM_PROT_WRITE); |