summaryrefslogtreecommitdiff
path: root/sys/arch/mvme88k/dev
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2007-02-11 12:41:30 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2007-02-11 12:41:30 +0000
commit577734564eba54fb00df422cabefe80d3c032bb5 (patch)
treea336a62954eb54a1e88956e4de82bc932ac0e62d /sys/arch/mvme88k/dev
parent95f34c382a82c70a9c4893f0c42d515af72a2694 (diff)
Rework the i/o mapping logic so that it allows the 1:1 region to not go up to
the end of the address space; allows the A16D16 VME space to be mapped correctly again on MVME197.
Diffstat (limited to 'sys/arch/mvme88k/dev')
-rw-r--r--sys/arch/mvme88k/dev/mainbus.c91
1 files changed, 55 insertions, 36 deletions
diff --git a/sys/arch/mvme88k/dev/mainbus.c b/sys/arch/mvme88k/dev/mainbus.c
index 171d2f76428..f8a92d0c1a5 100644
--- a/sys/arch/mvme88k/dev/mainbus.c
+++ b/sys/arch/mvme88k/dev/mainbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mainbus.c,v 1.21 2006/07/07 19:36:50 miod Exp $ */
+/* $OpenBSD: mainbus.c,v 1.22 2007/02/11 12:41:29 miod Exp $ */
/*
* Copyright (c) 1998 Steve Murphree, Jr.
* Copyright (c) 2004, Miodrag Vallat.
@@ -76,7 +76,8 @@ const struct mvme88k_bus_space_tag mainbus_bustag = {
mainbus_vaddr
};
-bus_addr_t bs_threshold;
+bus_addr_t bs_obio_start;
+bus_addr_t bs_obio_end;
struct extent *bs_extent;
/*
@@ -130,26 +131,36 @@ mainbus_vaddr(bus_space_handle_t handle)
* we might have several mappings for a given chunk of the IO page.
*/
vaddr_t
-mapiodev(addr, size)
- paddr_t addr;
- int size;
+mapiodev(paddr_t addr, int _size)
{
vaddr_t va, iova, off;
- paddr_t pa;
+ paddr_t pa, epa;
+ psize_t size;
int s, error;
- if (size <= 0)
+ /* sanity checks */
+ if (_size <= 0)
+ return NULL;
+ size = (psize_t)_size;
+ epa = addr + size;
+ if (epa < addr && epa != 0)
return NULL;
- if (addr >= bs_threshold)
- return ((vaddr_t)addr);
+ /* check for 1:1 mapping */
+ if (addr >= bs_obio_start) {
+ if (bs_obio_end == 0 || epa <= bs_obio_end)
+ return ((vaddr_t)addr);
+ else if (addr <= bs_obio_end)
+ /* accross obio and non-obio, not supported */
+ return NULL;
+ }
pa = trunc_page(addr);
off = addr & PGOFSET;
size = round_page(off + size);
s = splhigh();
- error = extent_alloc_region(bs_extent, pa, size,
+ error = extent_alloc_region(bs_extent, atop(pa), atop(size),
EX_MALLOCOK | (cold ? 0 : EX_WAITSPACE));
splx(s);
@@ -158,7 +169,7 @@ mapiodev(addr, size)
va = uvm_km_valloc(kernel_map, size);
if (va == 0) {
- extent_free(bs_extent, pa, size,
+ extent_free(bs_extent, atop(pa), atop(size),
EX_MALLOCOK | (cold ? 0 : EX_WAITSPACE));
return NULL;
}
@@ -180,17 +191,30 @@ mapiodev(addr, size)
* Free up the mapping in iomap.
*/
void
-unmapiodev(va, size)
- vaddr_t va;
- int size;
+unmapiodev(vaddr_t va, int _size)
{
- vaddr_t kva, off;
+ vaddr_t eva, kva, off;
+ vsize_t size;
paddr_t pa;
int s, error;
- if (va >= bs_threshold)
+ /* sanity checks */
+ if (_size <= 0)
+ return;
+ size = (vsize_t)_size;
+ eva = va + size;
+ if (eva < va && eva != 0)
return;
+ /* check for 1:1 mapping */
+ if (va >= bs_obio_start) {
+ if (bs_obio_end == 0 || eva <= bs_obio_end)
+ return;
+ else if (va <= bs_obio_end)
+ /* accross obio and non-obio, not supported */
+ return;
+ }
+
off = va & PGOFSET;
kva = trunc_page(va);
size = round_page(off + size);
@@ -203,7 +227,7 @@ unmapiodev(va, size)
uvm_km_free(kernel_map, kva, size);
s = splhigh();
- error = extent_free(bs_extent, pa, size,
+ error = extent_free(bs_extent, atop(pa), atop(size),
EX_MALLOCOK | (cold ? 0 : EX_WAITSPACE));
#ifdef DIAGNOSTIC
if (error != 0)
@@ -226,18 +250,13 @@ struct cfdriver mainbus_cd = {
};
int
-mainbus_match(parent, cf, args)
- struct device *parent;
- void *cf;
- void *args;
+mainbus_match(struct device *parent, void *cf, void *args)
{
return (1);
}
int
-mainbus_print(args, bus)
- void *args;
- const char *bus;
+mainbus_print(void *args, const char *bus)
{
struct confargs *ca = args;
@@ -247,9 +266,7 @@ mainbus_print(args, bus)
}
int
-mainbus_scan(parent, child, args)
- struct device *parent;
- void *child, *args;
+mainbus_scan(struct device *parent, void *child, void *args)
{
struct cfdata *cf = child;
struct confargs oca;
@@ -268,9 +285,7 @@ mainbus_scan(parent, child, args)
}
void
-mainbus_attach(parent, self, args)
- struct device *parent, *self;
- void *args;
+mainbus_attach(struct device *parent, struct device *self, void *args)
{
extern char cpu_model[];
@@ -285,15 +300,19 @@ mainbus_attach(parent, self, args)
* Initialize an extent to keep track of I/O mappings.
*/
#ifdef M88100
- if (CPU_IS88100)
- bs_threshold = BATC8_VA; /* hardwired BATC */
+ if (CPU_IS88100) {
+ bs_obio_start = BATC8_VA; /* hardwired BATC */
+ bs_obio_end = 0;
+ }
#endif
#ifdef MVME197
- if (CPU_IS88110)
- bs_threshold = OBIO197_START;
+ if (CPU_IS88110) {
+ bs_obio_start = OBIO197_START;
+ bs_obio_end = OBIO197_START + OBIO197_SIZE;
+ }
#endif
- bs_extent = extent_create("bus_space", physmem,
- bs_threshold, M_DEVBUF, NULL, 0, EX_NOWAIT);
+ bs_extent = extent_create("bus_space", atop(physmem),
+ 1 + atop(0U - PAGE_SIZE), M_DEVBUF, NULL, 0, EX_NOWAIT);
if (bs_extent == NULL)
panic("unable to allocate bus_space extent");