diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2006-06-24 13:20:20 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2006-06-24 13:20:20 +0000 |
commit | 7e310a00247ef048ed5192a21b9ec288944134e8 (patch) | |
tree | 08a750f15d786c9565a60f9ca2ef6daeab73b9c2 | |
parent | 3ba7d7416274ba1a0db036e91103b4d88340ae04 (diff) |
Use pmap_kenter_cache() for device memory mapping, instead of physacc(0
which bites the dust.
-rw-r--r-- | sys/arch/hp300/hp300/autoconf.c | 56 | ||||
-rw-r--r-- | sys/arch/hp300/hp300/bus_space.c | 159 | ||||
-rw-r--r-- | sys/arch/hp300/hp300/locore.s | 33 | ||||
-rw-r--r-- | sys/arch/hp300/hp300/vm_machdep.c | 37 | ||||
-rw-r--r-- | sys/arch/hp300/include/cpu.h | 6 |
5 files changed, 78 insertions, 213 deletions
diff --git a/sys/arch/hp300/hp300/autoconf.c b/sys/arch/hp300/hp300/autoconf.c index fa1fe055ed9..eb59e03d38d 100644 --- a/sys/arch/hp300/hp300/autoconf.c +++ b/sys/arch/hp300/hp300/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.37 2005/12/31 18:13:44 miod Exp $ */ +/* $OpenBSD: autoconf.c,v 1.38 2006/06/24 13:20:17 miod Exp $ */ /* $NetBSD: autoconf.c,v 1.45 1999/04/10 17:31:02 kleink Exp $ */ /* @@ -93,6 +93,8 @@ #include <scsi/scsi_all.h> #include <scsi/scsiconf.h> +#include <uvm/uvm_extern.h> + #include "sgc.h" #if NSGC > 0 @@ -1209,49 +1211,55 @@ iomap(pa, size) caddr_t pa; int size; { + vaddr_t iova, tva, off; + paddr_t ppa; int error; - caddr_t kva; - if (size == 0) + if (size <= 0) return NULL; -#ifdef DEBUG - if (((int)pa & PGOFSET) || (size & PGOFSET)) - panic("iomap: unaligned"); -#endif + ppa = trunc_page((paddr_t)pa); + off = (paddr_t)pa & PAGE_MASK; + size = round_page(off + size); + error = extent_alloc(extio, size, PAGE_SIZE, 0, EX_NOBOUNDARY, - EX_NOWAIT | EX_MALLOCOK, (u_long *)&kva); + EX_NOWAIT | EX_MALLOCOK, &iova); if (error != 0) - return NULL; + return (NULL); - physaccess(kva, pa, size, PG_RW | PG_CI); - return (kva); + tva = iova; + while (size != 0) { + pmap_kenter_cache(tva, ppa, PG_RW | PG_CI); + size -= PAGE_SIZE; + tva += PAGE_SIZE; + ppa += PAGE_SIZE; + } + pmap_update(pmap_kernel()); + return ((void *)(iova + off)); } /* * Unmap a previously mapped device. */ void -iounmap(kva, size) - caddr_t kva; +iounmap(va, size) + caddr_t va; int size; { + vaddr_t kva, off; int error; -#ifdef DEBUG - extern int eiomapsize; + off = (vaddr_t)va & PAGE_MASK; + kva = trunc_page((vaddr_t)va); + size = round_page(off + size); - if (((int)kva & PGOFSET) || (size & PGOFSET)) - panic("iounmap: unaligned"); - if (kva < extiobase || kva >= extiobase + ctob(eiomapsize)) - panic("iounmap: bad address"); -#endif - - physunaccess(kva, size); - - error = extent_free(extio, (u_long)kva, size, EX_NOWAIT); + pmap_kremove(kva, size); + pmap_update(pmap_kernel()); + error = extent_free(extio, kva, size, EX_NOWAIT); +#ifdef DIAGNOSTIC if (error != 0) printf("iounmap: extent_free failed\n"); +#endif } diff --git a/sys/arch/hp300/hp300/bus_space.c b/sys/arch/hp300/hp300/bus_space.c index 754b54c5a12..7c08cb40fbc 100644 --- a/sys/arch/hp300/hp300/bus_space.c +++ b/sys/arch/hp300/hp300/bus_space.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_space.c,v 1.3 2005/09/15 18:52:44 martin Exp $ */ +/* $OpenBSD: bus_space.c,v 1.4 2006/06/24 13:20:17 miod Exp $ */ /* $NetBSD: bus_space.c,v 1.6 2002/09/27 15:36:02 provos Exp $ */ /*- @@ -50,15 +50,15 @@ #include <uvm/uvm_extern.h> -#include <hp300/dev/sgcvar.h> - -#include "sgc.h" - +#ifdef DIAGNOSTIC extern char *extiobase; +#endif extern struct extent *extio; extern int *nofault; -/* ARGSUSED */ +/* + * Memory mapped devices (intio, dio and sgc) + */ int bus_space_map(t, bpa, size, flags, bshp) bus_space_tag_t t; @@ -68,87 +68,54 @@ bus_space_map(t, bpa, size, flags, bshp) bus_space_handle_t *bshp; { u_long kva; + pt_entry_t template; int error; - pt_entry_t ptemask; switch (HP300_TAG_BUS(t)) { case HP300_BUS_INTIO: /* - * Intio space is direct-mapped in pmap_bootstrap(); just - * do the translation. + * intio space is direct-mapped in pmap_bootstrap(); just + * do the translation in this case. */ - *bshp = (bus_space_handle_t)IIOV(INTIOBASE + bpa); + *bshp = IIOV(INTIOBASE + bpa); return (0); - case HP300_BUS_DIO: - break; -#if NSGC > 0 - case HP300_BUS_SGC: -#if 0 - bpa += (bus_addr_t)sgc_slottopa(HP300_TAG_CODE(t)); -#endif - break; -#endif default: - panic("bus_space_map: bad space tag"); + break; } /* * Allocate virtual address space from the extio extent map. */ - size = round_page(size); + size = round_page(bpa + size) - trunc_page(bpa); error = extent_alloc(extio, size, PAGE_SIZE, 0, EX_NOBOUNDARY, EX_NOWAIT | EX_MALLOCOK, &kva); if (error) return (error); + *bshp = (bus_space_handle_t)kva + (bpa & PAGE_MASK); + bpa = trunc_page(bpa); + /* * Map the range. */ if (flags & BUS_SPACE_MAP_CACHEABLE) - ptemask = PG_RW; + template = PG_RW; else - ptemask = PG_RW | PG_CI; - physaccess((caddr_t)kva, (caddr_t)bpa, size, ptemask); + template = PG_RW | PG_CI; + while (size != 0) { + pmap_kenter_cache(kva, bpa, template); + size -= PAGE_SIZE; + kva += PAGE_SIZE; + bpa += PAGE_SIZE; + } + pmap_update(pmap_kernel()); /* * All done. */ - *bshp = (bus_space_handle_t)kva; return (0); } -/* ARGSUSED */ -int -bus_space_alloc(t, rstart, rend, size, alignment, boundary, flags, - bpap, bshp) - bus_space_tag_t t; - bus_addr_t rstart, rend; - bus_size_t size, alignment, boundary; - int flags; - bus_addr_t *bpap; - bus_space_handle_t *bshp; -{ - - /* - * Not meaningful on any currently-supported hp300 bus. - */ - return (EINVAL); -} - -/* ARGSUSED */ -void -bus_space_free(t, bsh, size) - bus_space_tag_t t; - bus_space_handle_t bsh; - bus_size_t size; -{ - - /* - * Not meaningful on any currently-supported hp300 bus. - */ - panic("bus_space_free: shouldn't be here"); -} - void bus_space_unmap(t, bsh, size) bus_space_tag_t t; @@ -158,47 +125,46 @@ bus_space_unmap(t, bsh, size) #ifdef DIAGNOSTIC extern int eiomapsize; #endif + int error; switch (HP300_TAG_BUS(t)) { case HP300_BUS_INTIO: /* - * Intio space is direct-mapped in pmap_bootstrap(); nothing + * intio space is direct-mapped in pmap_bootstrap(); nothing * to do. */ return; - case HP300_BUS_DIO: -#if NSGC > 0 - case HP300_BUS_SGC: -#endif -#ifdef DIAGNOSTIC - if ((caddr_t)bsh < extiobase || - (caddr_t)bsh >= (extiobase + ptoa(eiomapsize))) - panic("bus_space_unmap: bad bus space handle"); -#endif - break; default: - panic("bus_space_unmap: bad space tag"); + break; } - size = round_page(size); - #ifdef DIAGNOSTIC - if (bsh & PGOFSET) - panic("bus_space_unmap: unaligned"); + if ((caddr_t)bsh < extiobase || + (caddr_t)bsh >= extiobase + ptoa(eiomapsize)) { + printf("bus_space_unmap: bad bus space handle %x\n", bsh); + return; + } #endif + size = round_page(bsh + size) - trunc_page(bsh); + bsh = trunc_page(bsh); + /* * Unmap the range. */ - physunaccess((caddr_t)bsh, size); + pmap_kremove(bsh, size); + pmap_update(pmap_kernel()); /* * Free it from the extio extent map. */ - if (extent_free(extio, (u_long)bsh, size, - EX_NOWAIT | EX_MALLOCOK)) + error = extent_free(extio, (u_long)bsh, size, EX_NOWAIT | EX_MALLOCOK); +#ifdef DIAGNOSTIC + if (error != 0) { printf("bus_space_unmap: kva 0x%lx size 0x%lx: " - "can't free region\n", (u_long) bsh, size); + "can't free region (%d)\n", (vaddr_t)bsh, size, error); + } +#endif } /* ARGSUSED */ @@ -213,42 +179,3 @@ bus_space_subregion(t, bsh, offset, size, nbshp) *nbshp = bsh + offset; return (0); } - -/* ARGSUSED */ -int -hp300_bus_space_probe(t, bsh, offset, sz) - bus_space_tag_t t; - bus_space_handle_t bsh; - bus_size_t offset; - int sz; -{ - label_t faultbuf; - int i; - - nofault = (int *)&faultbuf; - if (setjmp((label_t *)nofault)) { - nofault = NULL; - return (0); - } - - switch (sz) { - case 1: - i = bus_space_read_1(t, bsh, offset); - break; - - case 2: - i = bus_space_read_2(t, bsh, offset); - break; - - case 4: - i = bus_space_read_4(t, bsh, offset); - break; - - default: - panic("bus_space_probe: unupported data size %d", sz); - /* NOTREACHED */ - } - - nofault = NULL; - return (1); -} diff --git a/sys/arch/hp300/hp300/locore.s b/sys/arch/hp300/hp300/locore.s index eb6979559d0..0d508bab1bb 100644 --- a/sys/arch/hp300/hp300/locore.s +++ b/sys/arch/hp300/hp300/locore.s @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.s,v 1.56 2006/06/11 20:57:41 miod Exp $ */ +/* $OpenBSD: locore.s,v 1.57 2006/06/24 13:20:17 miod Exp $ */ /* $NetBSD: locore.s,v 1.91 1998/11/11 06:41:25 thorpej Exp $ */ /* @@ -1622,37 +1622,6 @@ Lhpmmu5: #endif rts -/* - * Invalidate supervisor side of TLB - */ -ENTRY(TBIAS) -#if defined(M68040) - cmpl #MMU_68040,_C_LABEL(mmutype) | 68040? - jne Lmotommu5 | no, skip - .word 0xf518 | yes, pflusha (for now) XXX - rts -Lmotommu5: -#endif -#if defined(M68K_MMU_MOTOROLA) - tstl _C_LABEL(mmutype) | HP MMU? - jeq Lhpmmu7 | yes, skip - jpl Lmc68851c | 68851? - pflush #4,#4 | flush supervisor TLB entries - movl #DC_CLEAR,d0 - movc d0,cacr | invalidate on-chip d-cache - rts -Lmc68851c: - pflushs #4,#4 | flush supervisor TLB entries - rts -Lhpmmu7: -#endif -#if defined(M68K_MMU_HP) - MMUADDR(a0) - movl #0x8000,d0 | more - movl d0,a0@(MMUTBINVAL) | HP magic -#endif - rts - #if defined(COMPAT_HPUX) /* * Invalidate user side of TLB diff --git a/sys/arch/hp300/hp300/vm_machdep.c b/sys/arch/hp300/hp300/vm_machdep.c index d5cb0c6b87a..5a788973cd8 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.40 2006/06/23 13:46:05 mickey Exp $ */ +/* $OpenBSD: vm_machdep.c,v 1.41 2006/06/24 13:20:17 miod Exp $ */ /* $NetBSD: vm_machdep.c,v 1.60 2001/07/06 05:53:35 chs Exp $ */ /* @@ -231,41 +231,6 @@ pagemove(from, to, size) } /* - * 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'. - */ -void -physaccess(vaddr, paddr, size, prot) - caddr_t vaddr, paddr; - int size, prot; -{ - pt_entry_t *pte; - 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(); -} - -void -physunaccess(vaddr, size) - caddr_t vaddr; - int size; -{ - pt_entry_t *pte; - - pte = kvtopte(vaddr); - for (size = btoc(size); size; size--) - *pte++ = PG_NV; - TBIAS(); -} - -/* * Map a user I/O request into kernel virtual address space. * Note: the pages are already locked by uvm_vslock(), so we * do not need to pass an access_type to pmap_enter(). diff --git a/sys/arch/hp300/include/cpu.h b/sys/arch/hp300/include/cpu.h index 9f08406f383..0d9d1f30b10 100644 --- a/sys/arch/hp300/include/cpu.h +++ b/sys/arch/hp300/include/cpu.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cpu.h,v 1.30 2006/06/11 20:48:11 miod Exp $ */ +/* $OpenBSD: cpu.h,v 1.31 2006/06/24 13:20:19 miod Exp $ */ /* $NetBSD: cpu.h,v 1.28 1998/02/13 07:41:51 scottr Exp $ */ /* @@ -153,10 +153,6 @@ int badaddr(caddr_t); int badbaddr(caddr_t); void dumpconf(void); -/* vm_machdep.c functions */ -void physaccess(caddr_t, caddr_t, int, int); -void physunaccess(caddr_t, int); - #endif /* _KERNEL */ /* physical memory sections */ |