summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorHenric Jungheim <henric@cvs.openbsd.org>2003-02-17 01:29:22 +0000
committerHenric Jungheim <henric@cvs.openbsd.org>2003-02-17 01:29:22 +0000
commitecebaec0fd1a08a0975b8f756936722a40ae03a6 (patch)
tree59277d25c05e37b02700a112ccaf0a5859342f3b /sys/dev
parent914c2239132eb3f27af97793d1c7534d2e08045d (diff)
Add support for the Sun Enterprise 450
Reduce the size of a GENERIC kernel by ~190k Remove the nasty pointer/bus_space_handle_t casts Adds debug bus_space code including the ability to trace bus operations (it actually works now). The following rules are now followed (and verfified by the debug code): 1. A "bus_space_handle_t" may only be used with the "bus_space_tag_t" that created it. 2. Only "bus_space_map()" may create "bus_space_handle_t"s. 3. A "bus_space_handle_t" may not be modified after it has been created (other than being destroyed by "bus_space_unmap()"). Thanks to help from mcbride, marc, jason, drahn, to anyone that might have slipped my mind at the moment. ok jason@, deraadt@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/sbus/apio.c4
-rw-r--r--sys/dev/sbus/asio.c6
-rw-r--r--sys/dev/sbus/be.c14
-rw-r--r--sys/dev/sbus/cs4231.c10
-rw-r--r--sys/dev/sbus/dma_sbus.c57
-rw-r--r--sys/dev/sbus/esp_sbus.c33
-rw-r--r--sys/dev/sbus/if_hme_sbus.c12
-rw-r--r--sys/dev/sbus/if_le_ledma.c4
-rw-r--r--sys/dev/sbus/isp_sbus.c10
-rw-r--r--sys/dev/sbus/lebuffer.c9
-rw-r--r--sys/dev/sbus/qe.c10
-rw-r--r--sys/dev/sbus/qec.c60
-rw-r--r--sys/dev/sbus/sbusvar.h6
13 files changed, 148 insertions, 87 deletions
diff --git a/sys/dev/sbus/apio.c b/sys/dev/sbus/apio.c
index 239ad949dd5..bde2325a5e1 100644
--- a/sys/dev/sbus/apio.c
+++ b/sys/dev/sbus/apio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: apio.c,v 1.2 2002/04/08 17:49:42 jason Exp $ */
+/* $OpenBSD: apio.c,v 1.3 2003/02/17 01:29:20 henric Exp $ */
/*
* Copyright (c) 2002 Jason L. Wright (jason@thought.net)
@@ -175,7 +175,7 @@ apio_print(aux, name)
void *aux;
const char *name;
{
- struct apio_attach_args *aaa;
+ struct apio_attach_args *aaa = aux;
if (name != NULL)
printf("%s at %s", aaa->aaa_name, name);
diff --git a/sys/dev/sbus/asio.c b/sys/dev/sbus/asio.c
index 7d42e909f29..ed4dc00f389 100644
--- a/sys/dev/sbus/asio.c
+++ b/sys/dev/sbus/asio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: asio.c,v 1.5 2002/04/08 17:49:42 jason Exp $ */
+/* $OpenBSD: asio.c,v 1.6 2003/02/17 01:29:20 henric Exp $ */
/*
* Copyright (c) 2002 Jason L. Wright (jason@thought.net)
@@ -182,7 +182,7 @@ asio_print(aux, name)
void *aux;
const char *name;
{
- struct asio_attach_args *aaa;
+ struct asio_attach_args *aaa = aux;
if (name != NULL)
printf("%s at %s", aaa->aaa_name, name);
@@ -231,7 +231,7 @@ com_asio_attach(parent, self, aux)
sc->sc_iot = aaa->aaa_iot;
sc->sc_ioh = aaa->aaa_ioh;
- sc->sc_iobase = sc->sc_ioh;
+ sc->sc_iobase = 0; /* XXX WTF is iobase for? It used to be the lower 32 bits of ioh's vaddr... */
sc->sc_hwflags = 0;
sc->sc_swflags = 0;
sc->sc_frequency = BAUD_BASE;
diff --git a/sys/dev/sbus/be.c b/sys/dev/sbus/be.c
index ce8734d2464..998e81a56ab 100644
--- a/sys/dev/sbus/be.c
+++ b/sys/dev/sbus/be.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: be.c,v 1.9 2002/06/14 21:34:59 todd Exp $ */
+/* $OpenBSD: be.c,v 1.10 2003/02/17 01:29:20 henric Exp $ */
/* $NetBSD: be.c,v 1.26 2001/03/20 15:39:20 pk Exp $ */
/*-
@@ -251,8 +251,8 @@ beattach(parent, self, aux)
return;
}
- if (bus_space_map2(sa->sa_bustag,
- (bus_type_t)sa->sa_reg[0].sbr_slot,
+ if (sbus_bus_map(sa->sa_bustag,
+ sa->sa_reg[0].sbr_slot,
(bus_addr_t)sa->sa_reg[0].sbr_offset,
(bus_size_t)sa->sa_reg[0].sbr_size,
BUS_SPACE_MAP_LINEAR, 0, &sc->sc_cr) != 0) {
@@ -260,8 +260,8 @@ beattach(parent, self, aux)
return;
}
- if (bus_space_map2(sa->sa_bustag,
- (bus_type_t)sa->sa_reg[1].sbr_slot,
+ if (sbus_bus_map(sa->sa_bustag,
+ sa->sa_reg[1].sbr_slot,
(bus_addr_t)sa->sa_reg[1].sbr_offset,
(bus_size_t)sa->sa_reg[1].sbr_size,
BUS_SPACE_MAP_LINEAR, 0, &sc->sc_br) != 0) {
@@ -269,8 +269,8 @@ beattach(parent, self, aux)
return;
}
- if (bus_space_map2(sa->sa_bustag,
- (bus_type_t)sa->sa_reg[2].sbr_slot,
+ if (sbus_bus_map(sa->sa_bustag,
+ sa->sa_reg[2].sbr_slot,
(bus_addr_t)sa->sa_reg[2].sbr_offset,
(bus_size_t)sa->sa_reg[2].sbr_size,
BUS_SPACE_MAP_LINEAR, 0, &sc->sc_tr) != 0) {
diff --git a/sys/dev/sbus/cs4231.c b/sys/dev/sbus/cs4231.c
index 88d8b47c1ff..c530986f2c6 100644
--- a/sys/dev/sbus/cs4231.c
+++ b/sys/dev/sbus/cs4231.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cs4231.c,v 1.15 2002/10/04 01:51:45 jason Exp $ */
+/* $OpenBSD: cs4231.c,v 1.16 2003/02/17 01:29:20 henric Exp $ */
/*
* Copyright (c) 1999 Jason L. Wright (jason@thought.net)
@@ -250,11 +250,11 @@ cs4231_attach(parent, self, aux)
}
if (sbus_bus_map(sa->sa_bustag,
- (bus_type_t)sa->sa_reg[0].sbr_slot,
+ sa->sa_reg[0].sbr_slot,
(bus_addr_t)sa->sa_reg[0].sbr_offset,
(bus_size_t)sa->sa_reg[0].sbr_size,
BUS_SPACE_MAP_LINEAR, 0, &sc->sc_regs) != 0) {
- printf(": couldn't map registers\n", self->dv_xname);
+ printf(": couldn't map registers\n");
return;
}
@@ -1548,7 +1548,7 @@ cs4231_trigger_output(addr, start, end, blksize, intr, arg, param)
for (p = sc->sc_dmas; p->addr != start; p = p->next)
/*EMPTY*/;
if (p == NULL) {
- printf("%s: trigger_output: bad addr: %x\n",
+ printf("%s: trigger_output: bad addr: %p\n",
sc->sc_dev.dv_xname, start);
return (EINVAL);
}
@@ -1613,7 +1613,7 @@ cs4231_trigger_input(addr, start, end, blksize, intr, arg, param)
for (p = sc->sc_dmas; p->addr != start; p = p->next)
/*EMPTY*/;
if (p == NULL) {
- printf("%s: trigger_input: bad addr: %x\n",
+ printf("%s: trigger_input: bad addr: %p\n",
sc->sc_dev.dv_xname, start);
return (EINVAL);
}
diff --git a/sys/dev/sbus/dma_sbus.c b/sys/dev/sbus/dma_sbus.c
index 1f6420f80c7..7feaed06a80 100644
--- a/sys/dev/sbus/dma_sbus.c
+++ b/sys/dev/sbus/dma_sbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dma_sbus.c,v 1.7 2002/03/14 03:16:07 millert Exp $ */
+/* $OpenBSD: dma_sbus.c,v 1.8 2003/02/17 01:29:20 henric Exp $ */
/* $NetBSD: dma_sbus.c,v 1.5 2000/07/09 20:57:42 pk Exp $ */
/*-
@@ -101,6 +101,7 @@ int dmaprint_sbus(void *, const char *);
void *dmabus_intr_establish(
bus_space_tag_t,
+ bus_space_tag_t,
int, /*bus interrupt priority*/
int, /*`device class' level*/
int, /*flags*/
@@ -172,18 +173,23 @@ dmaattach_sbus(parent, self, aux)
sc->sc_dmatag = sa->sa_dmatag;
/* Map registers */
- if (sa->sa_npromvaddrs != 0)
- sc->sc_regs = (bus_space_handle_t)sa->sa_promvaddrs[0];
- else {
- if (sbus_bus_map(sa->sa_bustag, sa->sa_slot,
- sa->sa_offset,
- sa->sa_size,
- 0, 0, &bh) != 0) {
+ if (sa->sa_npromvaddrs != 0) {
+ if (sbus_bus_map(sa->sa_bustag, 0,
+ sa->sa_promvaddrs[0],
+ sa->sa_size, /* ???? */
+ BUS_SPACE_MAP_PROMADDRESS,
+ 0, &bh) != 0) {
printf("%s: cannot map registers\n", self->dv_xname);
return;
}
- sc->sc_regs = bh;
+ } else if (sbus_bus_map(sa->sa_bustag, sa->sa_slot,
+ sa->sa_offset,
+ sa->sa_size,
+ 0, 0, &bh) != 0) {
+ printf("%s: cannot map registers\n", self->dv_xname);
+ return;
}
+ sc->sc_regs = bh;
/*
* Get transfer burst size from PROM and plug it into the
@@ -246,13 +252,14 @@ dmaattach_sbus(parent, self, aux)
}
void *
-dmabus_intr_establish(t, pri, level, flags, handler, arg)
- bus_space_tag_t t;
- int pri;
- int level;
- int flags;
- int (*handler)(void *);
- void *arg;
+dmabus_intr_establish(
+ bus_space_tag_t t,
+ bus_space_tag_t t0,
+ int pri,
+ int level,
+ int flags,
+ int (*handler)(void *),
+ void *arg)
{
struct lsi64854_softc *sc = t->cookie;
@@ -263,24 +270,32 @@ dmabus_intr_establish(t, pri, level, flags, handler, arg)
handler = lsi64854_enet_intr;
arg = sc;
}
- return (bus_intr_establish(sc->sc_bustag, pri, level, flags,
- handler, arg));
+
+ for (t = t->parent; t; t = t->parent) {
+ if (t->sparc_intr_establish != NULL)
+ return ((*t->sparc_intr_establish)
+ (t, t0, pri, level, flags, handler, arg));
+
+ }
+
+ return (NULL);
}
bus_space_tag_t
dma_alloc_bustag(sc)
struct dma_softc *sc;
{
- bus_space_tag_t sbt;
+ struct sparc_bus_space_tag *sbt;
- sbt = (bus_space_tag_t)
- malloc(sizeof(struct sparc_bus_space_tag), M_DEVBUF, M_NOWAIT);
+ sbt = malloc(sizeof(*sbt), M_DEVBUF, M_NOWAIT);
if (sbt == NULL)
return (NULL);
bzero(sbt, sizeof *sbt);
sbt->cookie = sc;
sbt->parent = sc->sc_lsi64854.sc_bustag;
+ sbt->asi = sbt->parent->asi;
+ sbt->sasi = sbt->parent->sasi;
sbt->sparc_intr_establish = dmabus_intr_establish;
return (sbt);
}
diff --git a/sys/dev/sbus/esp_sbus.c b/sys/dev/sbus/esp_sbus.c
index 61cdfd24bc6..ecb90505f71 100644
--- a/sys/dev/sbus/esp_sbus.c
+++ b/sys/dev/sbus/esp_sbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: esp_sbus.c,v 1.10 2003/02/11 19:20:28 mickey Exp $ */
+/* $OpenBSD: esp_sbus.c,v 1.11 2003/02/17 01:29:20 henric Exp $ */
/* $NetBSD: esp_sbus.c,v 1.14 2001/04/25 17:53:37 bouyer Exp $ */
/*-
@@ -226,7 +226,7 @@ espattach_sbus(parent, self, aux)
sizeof (lsc->sc_dev.dv_xname));
/* Map dma registers */
- if (bus_space_map2(sa->sa_bustag,
+ if (sbus_bus_map(sa->sa_bustag,
sa->sa_reg[0].sbr_slot,
sa->sa_reg[0].sbr_offset,
sa->sa_reg[0].sbr_size,
@@ -332,9 +332,16 @@ espattach_sbus(parent, self, aux)
* Map my registers in, if they aren't already in virtual
* address space.
*/
- if (sa->sa_npromvaddrs)
- esc->sc_reg = (bus_space_handle_t)sa->sa_promvaddrs[0];
- else {
+ if (sa->sa_npromvaddrs) {
+ if (bus_space_map(sa->sa_bustag, sa->sa_promvaddrs[0],
+ sa->sa_size,
+ BUS_SPACE_MAP_PROMADDRESS | BUS_SPACE_MAP_LINEAR,
+ &esc->sc_reg) != 0) {
+ printf("%s @ sbus: cannot map registers\n",
+ self->dv_xname);
+ return;
+ }
+ } else {
if (sbus_bus_map(sa->sa_bustag, sa->sa_slot,
sa->sa_offset,
sa->sa_size,
@@ -394,10 +401,18 @@ espattach_dma(parent, self, aux)
* Map my registers in, if they aren't already in virtual
* address space.
*/
- if (sa->sa_npromvaddrs)
- esc->sc_reg = (bus_space_handle_t)sa->sa_promvaddrs[0];
- else {
- if (bus_space_map2(sa->sa_bustag,
+ if (sa->sa_npromvaddrs) {
+ if (bus_space_map(sa->sa_bustag,
+ sa->sa_promvaddrs[0],
+ sa->sa_size, /* ??? */
+ BUS_SPACE_MAP_PROMADDRESS | BUS_SPACE_MAP_LINEAR,
+ &esc->sc_reg) != 0) {
+ printf("%s @ dma: cannot map registers\n",
+ self->dv_xname);
+ return;
+ }
+ } else {
+ if (sbus_bus_map(sa->sa_bustag,
sa->sa_slot,
sa->sa_offset,
sa->sa_size,
diff --git a/sys/dev/sbus/if_hme_sbus.c b/sys/dev/sbus/if_hme_sbus.c
index e3f36e74ced..7d0cb7375d4 100644
--- a/sys/dev/sbus/if_hme_sbus.c
+++ b/sys/dev/sbus/if_hme_sbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_hme_sbus.c,v 1.3 2002/03/14 01:27:02 millert Exp $ */
+/* $OpenBSD: if_hme_sbus.c,v 1.4 2003/02/17 01:29:20 henric Exp $ */
/* $NetBSD: if_hme_sbus.c,v 1.6 2001/02/28 14:52:48 mrg Exp $ */
/*-
@@ -134,7 +134,7 @@ hmeattach_sbus(parent, self, aux)
*
*/
if (sbus_bus_map(sa->sa_bustag,
- (bus_type_t)sa->sa_reg[0].sbr_slot,
+ sa->sa_reg[0].sbr_slot,
(bus_addr_t)sa->sa_reg[0].sbr_offset,
(bus_size_t)sa->sa_reg[0].sbr_size,
BUS_SPACE_MAP_LINEAR, 0, &sc->sc_seb) != 0) {
@@ -142,7 +142,7 @@ hmeattach_sbus(parent, self, aux)
return;
}
if (sbus_bus_map(sa->sa_bustag,
- (bus_type_t)sa->sa_reg[1].sbr_slot,
+ sa->sa_reg[1].sbr_slot,
(bus_addr_t)sa->sa_reg[1].sbr_offset,
(bus_size_t)sa->sa_reg[1].sbr_size,
BUS_SPACE_MAP_LINEAR, 0, &sc->sc_etx) != 0) {
@@ -150,7 +150,7 @@ hmeattach_sbus(parent, self, aux)
return;
}
if (sbus_bus_map(sa->sa_bustag,
- (bus_type_t)sa->sa_reg[2].sbr_slot,
+ sa->sa_reg[2].sbr_slot,
(bus_addr_t)sa->sa_reg[2].sbr_offset,
(bus_size_t)sa->sa_reg[2].sbr_size,
BUS_SPACE_MAP_LINEAR, 0, &sc->sc_erx) != 0) {
@@ -158,7 +158,7 @@ hmeattach_sbus(parent, self, aux)
return;
}
if (sbus_bus_map(sa->sa_bustag,
- (bus_type_t)sa->sa_reg[3].sbr_slot,
+ sa->sa_reg[3].sbr_slot,
(bus_addr_t)sa->sa_reg[3].sbr_offset,
(bus_size_t)sa->sa_reg[3].sbr_size,
BUS_SPACE_MAP_LINEAR, 0, &sc->sc_mac) != 0) {
@@ -166,7 +166,7 @@ hmeattach_sbus(parent, self, aux)
return;
}
if (sbus_bus_map(sa->sa_bustag,
- (bus_type_t)sa->sa_reg[4].sbr_slot,
+ sa->sa_reg[4].sbr_slot,
(bus_addr_t)sa->sa_reg[4].sbr_offset,
(bus_size_t)sa->sa_reg[4].sbr_size,
BUS_SPACE_MAP_LINEAR, 0, &sc->sc_mif) != 0) {
diff --git a/sys/dev/sbus/if_le_ledma.c b/sys/dev/sbus/if_le_ledma.c
index 9cb22328524..598bf78490a 100644
--- a/sys/dev/sbus/if_le_ledma.c
+++ b/sys/dev/sbus/if_le_ledma.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_le_ledma.c,v 1.6 2002/03/14 01:27:02 millert Exp $ */
+/* $OpenBSD: if_le_ledma.c,v 1.7 2003/02/17 01:29:21 henric Exp $ */
/* $NetBSD: if_le_ledma.c,v 1.14 2001/05/30 11:46:35 mrg Exp $ */
/*-
@@ -354,7 +354,7 @@ leattach_ledma(parent, self, aux)
lesc->sc_dma->sc_client = lesc;
/* Map device registers */
- if (bus_space_map2(sa->sa_bustag,
+ if (sbus_bus_map(sa->sa_bustag,
sa->sa_slot,
sa->sa_offset,
sa->sa_size,
diff --git a/sys/dev/sbus/isp_sbus.c b/sys/dev/sbus/isp_sbus.c
index 391f8bfd1b5..d1183f8fa76 100644
--- a/sys/dev/sbus/isp_sbus.c
+++ b/sys/dev/sbus/isp_sbus.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: isp_sbus.c,v 1.4 2002/10/12 01:09:44 krw Exp $ */
+/* $OpenBSD: isp_sbus.c,v 1.5 2003/02/17 01:29:21 henric Exp $ */
/* $NetBSD: isp_sbus.c,v 1.46 2001/09/26 20:53:14 eeh Exp $ */
/*
@@ -169,7 +169,13 @@ isp_sbus_attach(struct device *parent, struct device *self, void *aux)
sbc->sbus_mdvec = mdvec;
if (sa->sa_npromvaddrs != 0) {
- sbc->sbus_reg = (bus_space_handle_t)sa->sa_promvaddrs[0];
+ if (bus_space_map(sa->sa_bustag, sa->sa_promvaddrs[0],
+ sa->sa_size,
+ BUS_SPACE_MAP_PROMADDRESS | BUS_SPACE_MAP_LINEAR,
+ &sbc->sbus_reg) == 0) {
+ printf("%s: cannot map registers\n", self->dv_xname);
+ return;
+ }
} else {
if (sbus_bus_map(sa->sa_bustag, sa->sa_slot, sa->sa_offset,
sa->sa_size, BUS_SPACE_MAP_LINEAR, 0,
diff --git a/sys/dev/sbus/lebuffer.c b/sys/dev/sbus/lebuffer.c
index a73dd9bf5b5..6a8618914b5 100644
--- a/sys/dev/sbus/lebuffer.c
+++ b/sys/dev/sbus/lebuffer.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lebuffer.c,v 1.2 2002/05/13 18:16:38 jason Exp $ */
+/* $OpenBSD: lebuffer.c,v 1.3 2003/02/17 01:29:21 henric Exp $ */
/* $NetBSD: lebuffer.c,v 1.12 2002/03/11 16:00:57 pk Exp $ */
/*-
@@ -99,7 +99,7 @@ lebufattach(parent, self, aux)
struct lebuf_softc *sc = (void *)self;
int node;
int sbusburst;
- bus_space_tag_t sbt;
+ struct sparc_bus_space_tag *sbt;
bus_space_handle_t bh;
sc->sc_bustag = sa->sa_bustag;
@@ -140,13 +140,12 @@ lebufattach(parent, self, aux)
sbus_establish(&sc->sc_sd, &sc->sc_dev);
/* Allocate a bus tag */
- sbt = (bus_space_tag_t) malloc(sizeof(struct sparc_bus_space_tag),
- M_DEVBUF, M_NOWAIT);
+ sbt = malloc(sizeof(*sbt), M_DEVBUF, M_NOWAIT);
if (sbt == NULL) {
printf("%s: attach: out of memory\n", self->dv_xname);
return;
}
- bzero(sbt, sizeof(struct sparc_bus_space_tag));
+ bzero(sbt, sizeof(*sbt));
printf(": %dK memory\n", sc->sc_bufsiz / 1024);
diff --git a/sys/dev/sbus/qe.c b/sys/dev/sbus/qe.c
index 79df101ba4b..3f8dae7a0cd 100644
--- a/sys/dev/sbus/qe.c
+++ b/sys/dev/sbus/qe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: qe.c,v 1.9 2002/03/14 01:27:02 millert Exp $ */
+/* $OpenBSD: qe.c,v 1.10 2003/02/17 01:29:21 henric Exp $ */
/* $NetBSD: qe.c,v 1.16 2001/03/30 17:30:18 christos Exp $ */
/*-
@@ -218,8 +218,8 @@ qeattach(parent, self, aux)
return;
}
- if (bus_space_map2(sa->sa_bustag,
- (bus_type_t)sa->sa_reg[0].sbr_slot,
+ if (sbus_bus_map(sa->sa_bustag,
+ sa->sa_reg[0].sbr_slot,
(bus_addr_t)sa->sa_reg[0].sbr_offset,
(bus_size_t)sa->sa_reg[0].sbr_size,
BUS_SPACE_MAP_LINEAR, 0, &sc->sc_cr) != 0) {
@@ -227,8 +227,8 @@ qeattach(parent, self, aux)
return;
}
- if (bus_space_map2(sa->sa_bustag,
- (bus_type_t)sa->sa_reg[1].sbr_slot,
+ if (sbus_bus_map(sa->sa_bustag,
+ sa->sa_reg[1].sbr_slot,
(bus_addr_t)sa->sa_reg[1].sbr_offset,
(bus_size_t)sa->sa_reg[1].sbr_size,
BUS_SPACE_MAP_LINEAR, 0, &sc->sc_mr) != 0) {
diff --git a/sys/dev/sbus/qec.c b/sys/dev/sbus/qec.c
index 969f430b166..e11e836ef85 100644
--- a/sys/dev/sbus/qec.c
+++ b/sys/dev/sbus/qec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: qec.c,v 1.4 2002/03/14 03:16:08 millert Exp $ */
+/* $OpenBSD: qec.c,v 1.5 2003/02/17 01:29:21 henric Exp $ */
/* $NetBSD: qec.c,v 1.12 2000/12/04 20:12:55 fvdl Exp $ */
/*-
@@ -60,14 +60,14 @@ void qec_init(struct qec_softc *);
static int qec_bus_map(
bus_space_tag_t,
- bus_type_t, /*slot*/
+ bus_space_tag_t,
bus_addr_t, /*offset*/
bus_size_t, /*size*/
int, /*flags*/
- vaddr_t, /*preferred virtual address */
bus_space_handle_t *);
static void *qec_intr_establish(
bus_space_tag_t,
+ bus_space_tag_t,
int, /*bus interrupt priority*/
int, /*`device class' interrupt level*/
int, /*flags*/
@@ -121,7 +121,7 @@ qecattach(parent, self, aux)
struct qec_softc *sc = (void *)self;
int node;
int sbusburst;
- bus_space_tag_t sbt;
+ struct sparc_bus_space_tag *sbt;
bus_space_handle_t bh;
int error;
@@ -157,7 +157,7 @@ qecattach(parent, self, aux)
printf("%s: attach: cannot map registers\n", self->dv_xname);
return;
}
- sc->sc_buffer = (caddr_t)(u_long)bh;
+ sc->sc_buffer = (caddr_t)bus_space_vaddr(sc->sc_bustag, bh);
sc->sc_bufsiz = (bus_size_t)sa->sa_reg[1].sbr_size;
/* Get number of on-board channels */
@@ -198,16 +198,18 @@ qecattach(parent, self, aux)
}
/* Allocate a bus tag */
- sbt = (bus_space_tag_t)
- malloc(sizeof(struct sparc_bus_space_tag), M_DEVBUF, M_NOWAIT);
+ sbt = malloc(sizeof(*sbt), M_DEVBUF, M_NOWAIT);
if (sbt == NULL) {
printf("%s: attach: out of memory\n", self->dv_xname);
return;
}
bzero(sbt, sizeof *sbt);
+ strlcpy(sbt->name, sc->sc_dev.dv_xname, sizeof(sbt->name));
sbt->cookie = sc;
sbt->parent = sc->sc_bustag;
+ sbt->asi = sbt->parent->asi;
+ sbt->sasi = sbt->parent->sasi;
sbt->sparc_bus_map = qec_bus_map;
sbt->sparc_intr_establish = qec_intr_establish;
@@ -238,22 +240,37 @@ qecattach(parent, self, aux)
}
int
-qec_bus_map(t, btype, offset, size, flags, vaddr, hp)
+qec_bus_map(t, t0, addr, size, flags, hp)
bus_space_tag_t t;
- bus_type_t btype;
- bus_addr_t offset;
+ bus_space_tag_t t0;
+ bus_addr_t addr;
bus_size_t size;
int flags;
- vaddr_t vaddr;
bus_space_handle_t *hp;
{
struct qec_softc *sc = t->cookie;
- int slot = btype;
+ int slot = BUS_ADDR_IOSPACE(addr);
+ bus_addr_t offset = BUS_ADDR_PADDR(addr);
int i;
+ for (t = t->parent; t; t = t->parent) {
+ if (t->sparc_bus_map != NULL)
+ break;
+ }
+
+ if (t == NULL) {
+ printf("\nqec_bus_map: invalid parent");
+ return (EINVAL);
+ }
+
+ if (flags & BUS_SPACE_MAP_PROMADDRESS) {
+ return ((*t->sparc_bus_map)
+ (t, t0, offset, size, flags, hp));
+ }
+
for (i = 0; i < sc->sc_nrange; i++) {
bus_addr_t paddr;
- bus_type_t iospace;
+ int iospace;
if (sc->sc_range[i].cspace != slot)
continue;
@@ -261,16 +278,17 @@ qec_bus_map(t, btype, offset, size, flags, vaddr, hp)
/* We've found the connection to the parent bus */
paddr = sc->sc_range[i].poffset + offset;
iospace = sc->sc_range[i].pspace;
- return (bus_space_map2(sc->sc_bustag, iospace, paddr,
- size, flags, vaddr, hp));
+ return ((*t->sparc_bus_map)
+ (t, t0, BUS_ADDR(iospace, paddr), size, flags, hp));
}
return (EINVAL);
}
void *
-qec_intr_establish(t, pri, level, flags, handler, arg)
+qec_intr_establish(t, t0, pri, level, flags, handler, arg)
bus_space_tag_t t;
+ bus_space_tag_t t0;
int pri;
int level;
int flags;
@@ -292,7 +310,15 @@ qec_intr_establish(t, pri, level, flags, handler, arg)
pri = sc->sc_intr->sbi_pri;
}
- return (bus_intr_establish(t->parent, pri, level, flags, handler, arg));
+ if (t->parent == 0 || t->parent->sparc_bus_mmap == 0) {
+ printf("\nebus_bus_mmap: invalid parent");
+ return (NULL);
+ }
+
+ t = t->parent;
+
+ return ((*t->sparc_intr_establish)(t, t0, pri, level, flags,
+ handler, arg));
}
void
diff --git a/sys/dev/sbus/sbusvar.h b/sys/dev/sbus/sbusvar.h
index 7784d8ff847..712e958c1d1 100644
--- a/sys/dev/sbus/sbusvar.h
+++ b/sys/dev/sbus/sbusvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sbusvar.h,v 1.6 2002/06/14 21:34:59 todd Exp $ */
+/* $OpenBSD: sbusvar.h,v 1.7 2003/02/17 01:29:21 henric Exp $ */
/* $NetBSD: sbusvar.h,v 1.11 2000/11/01 06:18:45 eeh Exp $ */
/*-
@@ -115,8 +115,8 @@ int sbus_setup_attach_args(
void sbus_destroy_attach_args(struct sbus_attach_args *);
-#define sbus_bus_map(t, bt, a, s, f, v, hp) \
- bus_space_map2(t, bt, a, s, f, v, hp)
+#define sbus_bus_map(t, slot, offset, sz, flags, unused, hp) \
+ bus_space_map(t, BUS_ADDR(slot, offset), sz, flags, hp)
#if notyet
/* variables per Sbus */