summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2006-07-07 19:36:57 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2006-07-07 19:36:57 +0000
commit82591ef1eb156d609b57ff16c71feb7d88b92aa1 (patch)
treebed7f06fa18738e1cb562de5837f81adfdf8a63a /sys/arch
parent3b8d87766176c8c22119cca9b60143e0b8b842d3 (diff)
Get rid of the fixed iomap for device mappings, and allocated va ranges
off kernel_map whenever necessary.
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/mvme88k/dev/mainbus.c105
-rw-r--r--sys/arch/mvme88k/include/param.h8
-rw-r--r--sys/arch/mvme88k/mvme88k/machdep.c25
3 files changed, 64 insertions, 74 deletions
diff --git a/sys/arch/mvme88k/dev/mainbus.c b/sys/arch/mvme88k/dev/mainbus.c
index 504e13cdcdf..171d2f76428 100644
--- a/sys/arch/mvme88k/dev/mainbus.c
+++ b/sys/arch/mvme88k/dev/mainbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mainbus.c,v 1.20 2006/05/06 16:59:28 miod Exp $ */
+/* $OpenBSD: mainbus.c,v 1.21 2006/07/07 19:36:50 miod Exp $ */
/*
* Copyright (c) 1998 Steve Murphree, Jr.
* Copyright (c) 2004, Miodrag Vallat.
@@ -32,6 +32,7 @@
#include <sys/device.h>
#include <sys/disklabel.h>
#include <sys/extent.h>
+#include <sys/malloc.h>
#include <uvm/uvm_extern.h>
@@ -75,14 +76,14 @@ const struct mvme88k_bus_space_tag mainbus_bustag = {
mainbus_vaddr
};
-extern struct extent *iomap_extent;
-extern struct vm_map *iomap_map;
+bus_addr_t bs_threshold;
+struct extent *bs_extent;
/*
* Obio (internal IO) space is mapped 1:1 (see pmap_bootstrap() for details).
*
* However, sram attaches as a child of mainbus, but does not reside in
- * internal IO space. As a result, we have to allow both 1:1 and iomap
+ * internal IO space. As a result, we have to allow both 1:1 and regular
* translations, depending upon the address to map.
*/
@@ -91,25 +92,8 @@ mainbus_map(bus_addr_t addr, bus_size_t size, int flags,
bus_space_handle_t *ret)
{
vaddr_t map;
- static bus_addr_t threshold = 0;
-
- if (threshold == 0) {
-#ifdef M88100
- if (CPU_IS88100)
- threshold = BATC8_VA; /* hardwired BATC */
-#endif
-#ifdef MVME197
- if (CPU_IS88110)
- threshold = OBIO197_START;
-#endif
- }
-
- if (addr >= threshold)
- map = (vaddr_t)addr;
- else {
- map = mapiodev((paddr_t)addr, size);
- }
+ map = mapiodev((paddr_t)addr, size);
if (map == NULL)
return ENOMEM;
@@ -138,7 +122,7 @@ mainbus_vaddr(bus_space_handle_t handle)
}
/*
- * Map a range [pa, pa+size] in the given map to a kernel address
+ * Map a range [pa, pa+size) in the given map to a kernel address
* in iomap space.
*
* Note: To be flexible, I did not put a restriction on the alignment
@@ -146,41 +130,50 @@ mainbus_vaddr(bus_space_handle_t handle)
* we might have several mappings for a given chunk of the IO page.
*/
vaddr_t
-mapiodev(pa, size)
- paddr_t pa;
+mapiodev(addr, size)
+ paddr_t addr;
int size;
{
- vaddr_t iova, tva, off;
- paddr_t ppa;
+ vaddr_t va, iova, off;
+ paddr_t pa;
int s, error;
if (size <= 0)
return NULL;
- ppa = trunc_page(pa);
- off = pa & PGOFSET;
+ if (addr >= bs_threshold)
+ return ((vaddr_t)addr);
+
+ pa = trunc_page(addr);
+ off = addr & PGOFSET;
size = round_page(off + size);
s = splhigh();
- error = extent_alloc(iomap_extent, size, PAGE_SIZE, 0, EX_NOBOUNDARY,
- EX_WAITSPACE, &iova);
+ error = extent_alloc_region(bs_extent, pa, size,
+ EX_MALLOCOK | (cold ? 0 : EX_WAITSPACE));
splx(s);
if (error != 0)
return NULL;
- tva = iova;
+ va = uvm_km_valloc(kernel_map, size);
+ if (va == 0) {
+ extent_free(bs_extent, pa, size,
+ EX_MALLOCOK | (cold ? 0 : EX_WAITSPACE));
+ return NULL;
+ }
+
+ iova = va + off;
while (size != 0) {
- pmap_enter(vm_map_pmap(iomap_map), tva, ppa,
- VM_PROT_WRITE | VM_PROT_READ,
- VM_PROT_WRITE | VM_PROT_READ | PMAP_WIRED);
+ pmap_enter(pmap_kernel(), va, pa, UVM_PROT_RW,
+ UVM_PROT_RW | PMAP_WIRED);
size -= PAGE_SIZE;
- tva += PAGE_SIZE;
- ppa += PAGE_SIZE;
+ va += PAGE_SIZE;
+ pa += PAGE_SIZE;
}
- pmap_update(vm_map_pmap(iomap_map));
+ pmap_update(pmap_kernel());
- return (iova + off);
+ return (iova);
}
/*
@@ -192,20 +185,30 @@ unmapiodev(va, size)
int size;
{
vaddr_t kva, off;
+ paddr_t pa;
int s, error;
+ if (va >= bs_threshold)
+ return;
+
off = va & PGOFSET;
kva = trunc_page(va);
size = round_page(off + size);
- pmap_remove(vm_map_pmap(iomap_map), kva, kva + size);
- pmap_update(vm_map_pmap(iomap_map));
+ if (pmap_extract(pmap_kernel(), kva, &pa) == FALSE)
+ panic("unmapiodev(%p,%p)", kva, size);
+
+ pmap_remove(pmap_kernel(), kva, kva + size);
+ pmap_update(pmap_kernel());
+ uvm_km_free(kernel_map, kva, size);
s = splhigh();
- error = extent_free(iomap_extent, kva, size, EX_NOWAIT);
+ error = extent_free(bs_extent, pa, size,
+ EX_MALLOCOK | (cold ? 0 : EX_WAITSPACE));
#ifdef DIAGNOSTIC
if (error != 0)
- printf("unmapiodev: extent_free failed\n");
+ printf("unmapiodev(%p pa %p, %p): extent_free failed\n",
+ kva, pa, size);
#endif
splx(s);
}
@@ -278,5 +281,21 @@ mainbus_attach(parent, self, args)
*/
cpu_configuration_print(1);
+ /*
+ * Initialize an extent to keep track of I/O mappings.
+ */
+#ifdef M88100
+ if (CPU_IS88100)
+ bs_threshold = BATC8_VA; /* hardwired BATC */
+#endif
+#ifdef MVME197
+ if (CPU_IS88110)
+ bs_threshold = OBIO197_START;
+#endif
+ bs_extent = extent_create("bus_space", physmem,
+ bs_threshold, M_DEVBUF, NULL, 0, EX_NOWAIT);
+ if (bs_extent == NULL)
+ panic("unable to allocate bus_space extent");
+
(void)config_search(mainbus_scan, self, args);
}
diff --git a/sys/arch/mvme88k/include/param.h b/sys/arch/mvme88k/include/param.h
index 7249e14268b..85f6c35a77e 100644
--- a/sys/arch/mvme88k/include/param.h
+++ b/sys/arch/mvme88k/include/param.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: param.h,v 1.37 2005/11/27 23:48:44 miod Exp $ */
+/* $OpenBSD: param.h,v 1.38 2006/07/07 19:36:52 miod Exp $ */
/*
* Copyright (c) 1999 Steve Murphree, Jr.
* Copyright (c) 1988 University of Utah.
@@ -53,12 +53,6 @@
#define KERNBASE 0x00000000 /* start of kernel virtual */
#define KERNTEXTOFF 0x00010000 /* start of kernel text */
-/*
- * IO space
- */
-
-#define IOMAP_SIZE 0x01000000 /* roughly 0xff000000 - 0xffffffff */
-
#ifdef _KERNEL
#if !defined(_LOCORE)
extern int brdtyp;
diff --git a/sys/arch/mvme88k/mvme88k/machdep.c b/sys/arch/mvme88k/mvme88k/machdep.c
index 15453c1598b..b6b8d2270dd 100644
--- a/sys/arch/mvme88k/mvme88k/machdep.c
+++ b/sys/arch/mvme88k/mvme88k/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.183 2006/05/08 14:36:10 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.184 2006/07/07 19:36:56 miod Exp $ */
/*
* Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr.
* Copyright (c) 1996 Nivas Madhur
@@ -128,18 +128,6 @@ int physmem; /* available physical memory, in pages */
struct vm_map *exec_map = NULL;
struct vm_map *phys_map = NULL;
-/*
- * iomap stuff is for managing chunks of virtual address space that
- * can be allocated to IO devices.
- * VMEbus drivers use this at this now. Only on-board IO devices' addresses
- * are mapped so that pa == va. XXX smurph.
- */
-
-vaddr_t iomapbase;
-
-struct extent *iomap_extent;
-struct vm_map *iomap_map;
-
#ifdef MULTIPROCESSOR
__cpu_simple_lock_t cpu_mutex = __SIMPLELOCK_UNLOCKED;
#endif
@@ -448,17 +436,6 @@ cpu_startup()
phys_map = uvm_km_suballoc(kernel_map, &minaddr, &maxaddr,
VM_PHYS_SIZE, 0, FALSE, NULL);
- /*
- * Allocate map for external I/O.
- */
- iomap_map = uvm_km_suballoc(kernel_map, &iomapbase, &maxaddr,
- IOMAP_SIZE, 0, FALSE, NULL);
-
- iomap_extent = extent_create("iomap", iomapbase,
- iomapbase + IOMAP_SIZE, M_DEVBUF, NULL, 0, EX_NOWAIT);
- if (iomap_extent == NULL)
- panic("unable to allocate extent for iomap");
-
printf("avail mem = %ld (%d pages)\n", ptoa(uvmexp.free), uvmexp.free);
printf("using %d buffers containing %d bytes of memory\n", nbuf,
bufpages * PAGE_SIZE);