summaryrefslogtreecommitdiffstats
path: root/sys/i386/isa/isa_compat.c
diff options
context:
space:
mode:
authordfr <dfr@FreeBSD.org>1999-05-22 15:18:28 +0000
committerdfr <dfr@FreeBSD.org>1999-05-22 15:18:28 +0000
commit6f9e5e854190ab2e7fbe71ec2b59354a448a1950 (patch)
treeafd3454efd3e35a02a2f525336e9c7188ac49147 /sys/i386/isa/isa_compat.c
parentcd70cc4f2c802c38796d000c8a8ad692a695e9f5 (diff)
downloadFreeBSD-src-6f9e5e854190ab2e7fbe71ec2b59354a448a1950.zip
FreeBSD-src-6f9e5e854190ab2e7fbe71ec2b59354a448a1950.tar.gz
* Factor out the common code between the isa bus drivers for i386 and alpha.
* Re-work the resource allocation code to use helper functions in subr_bus.c. * Add simple isa interface for manipulating the resource ranges which can be allocated and remove the code from isa_write_ivar() which was previously used for this purpose.
Diffstat (limited to 'sys/i386/isa/isa_compat.c')
-rw-r--r--sys/i386/isa/isa_compat.c80
1 files changed, 57 insertions, 23 deletions
diff --git a/sys/i386/isa/isa_compat.c b/sys/i386/isa/isa_compat.c
index e1959f6..2bf5377 100644
--- a/sys/i386/isa/isa_compat.c
+++ b/sys/i386/isa/isa_compat.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: isa_compat.c,v 1.8 1999/05/08 18:20:03 peter Exp $
+ * $Id: isa_compat.c,v 1.9 1999/05/08 21:59:25 dfr Exp $
*/
#include <sys/param.h>
@@ -64,9 +64,12 @@ isa_compat_nextid(void)
static void
isa_compat_alloc_resources(device_t dev, struct isa_compat_resources *res)
{
+ device_t parent = device_get_parent(dev);
int rid;
+ u_long start, count;
- if (isa_get_port(dev) != -1) {
+ if (ISA_GET_RESOURCE(parent, dev, SYS_RES_IOPORT, 0,
+ &start, &count) == 0) {
rid = 0;
res->ports = bus_alloc_resource(dev, SYS_RES_IOPORT,
&rid, 0ul, ~0ul, 1,
@@ -77,7 +80,8 @@ isa_compat_alloc_resources(device_t dev, struct isa_compat_resources *res)
} else
res->ports = 0;
- if (isa_get_maddr(dev) != 0) {
+ if (ISA_GET_RESOURCE(parent, dev, SYS_RES_MEMORY, 0,
+ &start, &count) == 0) {
rid = 0;
res->memory = bus_alloc_resource(dev, SYS_RES_MEMORY,
&rid, 0ul, ~0ul, 1,
@@ -88,7 +92,8 @@ isa_compat_alloc_resources(device_t dev, struct isa_compat_resources *res)
} else
res->memory = 0;
- if (isa_get_drq(dev) != -1) {
+ if (ISA_GET_RESOURCE(parent, dev, SYS_RES_DRQ, 0,
+ &start, &count) == 0) {
rid = 0;
res->drq = bus_alloc_resource(dev, SYS_RES_DRQ,
&rid, 0ul, ~0ul, 1,
@@ -99,7 +104,8 @@ isa_compat_alloc_resources(device_t dev, struct isa_compat_resources *res)
} else
res->drq = 0;
- if (isa_get_irq(dev) != -1) {
+ if (ISA_GET_RESOURCE(parent, dev, SYS_RES_IRQ, 0,
+ &start, &count) == 0) {
rid = 0;
res->irq = bus_alloc_resource(dev, SYS_RES_IRQ,
&rid, 0ul, ~0ul, 1,
@@ -137,9 +143,11 @@ isa_compat_release_resources(device_t dev, struct isa_compat_resources *res)
static int
isa_compat_probe(device_t dev)
{
+ device_t parent = device_get_parent(dev);
struct isa_device *dvp = device_get_softc(dev);
struct isa_compat_resources res;
struct old_isa_driver *op;
+ u_long start, count;
bzero(&res, sizeof(res));
/*
@@ -148,11 +156,29 @@ isa_compat_probe(device_t dev)
op = device_get_driver(dev)->priv;
dvp->id_id = isa_compat_nextid();
dvp->id_driver = op->driver;
- dvp->id_iobase = isa_get_port(dev);
- dvp->id_irq = irqmask(isa_get_irq(dev));
- dvp->id_drq = isa_get_drq(dev);
- dvp->id_maddr = (void *)isa_get_maddr(dev);
- dvp->id_msize = isa_get_msize(dev);
+ if (ISA_GET_RESOURCE(parent, dev, SYS_RES_IOPORT, 0,
+ &start, &count) == 0)
+ dvp->id_iobase = start;
+ else
+ dvp->id_iobase = -1;
+ if (ISA_GET_RESOURCE(parent, dev, SYS_RES_IRQ, 0,
+ &start, &count) == 0)
+ dvp->id_irq = irqmask(start);
+ else
+ dvp->id_irq = 0;
+ if (ISA_GET_RESOURCE(parent, dev, SYS_RES_DRQ, 0,
+ &start, &count) == 0)
+ dvp->id_drq = start;
+ else
+ dvp->id_drq = -1;
+ if (ISA_GET_RESOURCE(parent, dev, SYS_RES_MEMORY,
+ 0, &start, &count) == 0) {
+ dvp->id_maddr = (void *)start;
+ dvp->id_msize = count;
+ } else {
+ dvp->id_maddr = NULL;
+ dvp->id_msize = 0;
+ }
dvp->id_unit = device_get_unit(dev);
dvp->id_flags = isa_get_flags(dev);
dvp->id_enabled = device_is_enabled(dev); /* XXX unused */
@@ -164,6 +190,7 @@ isa_compat_probe(device_t dev)
if (dvp->id_driver->probe) {
int portsize;
void *maddr;
+ struct isa_device old;
isa_compat_alloc_resources(dev, &res);
if (res.memory)
@@ -171,26 +198,33 @@ isa_compat_probe(device_t dev)
else
maddr = 0;
dvp->id_maddr = maddr;
+ old = *dvp;
portsize = dvp->id_driver->probe(dvp);
isa_compat_release_resources(dev, &res);
if (portsize != 0) {
- if (portsize > 0)
- isa_set_portsize(dev, portsize);
- if (dvp->id_iobase != isa_get_port(dev))
- isa_set_port(dev, dvp->id_iobase);
- if (dvp->id_irq != irqmask(isa_get_irq(dev)))
- isa_set_irq(dev, ffs(dvp->id_irq) - 1);
- if (dvp->id_drq != isa_get_drq(dev))
- isa_set_drq(dev, dvp->id_drq);
- if (dvp->id_maddr != maddr) {
+ if (portsize > 0 || dvp->id_iobase != old.id_iobase)
+ ISA_SET_RESOURCE(parent, dev, SYS_RES_IOPORT,
+ 0, dvp->id_iobase, portsize);
+ if (dvp->id_irq != old.id_irq)
+ ISA_SET_RESOURCE(parent, dev, SYS_RES_IRQ, 0,
+ ffs(dvp->id_irq) - 1, 1);
+ if (dvp->id_drq != old.id_drq)
+ ISA_SET_RESOURCE(parent, dev, SYS_RES_DRQ, 0,
+ dvp->id_drq, 1);
+ if (dvp->id_maddr != old.id_maddr
+ || dvp->id_msize != old.id_msize) {
maddr = dvp->id_maddr;
if (maddr != NULL)
- isa_set_maddr(dev, kvtop(maddr));
+ ISA_SET_RESOURCE(parent, dev,
+ SYS_RES_MEMORY,
+ 0,
+ kvtop(maddr),
+ dvp->id_msize);
else
- isa_set_maddr(dev, (int)maddr);
+ ISA_SET_RESOURCE(parent, dev,
+ SYS_RES_MEMORY,
+ 0, 0, 0);
}
- if (dvp->id_msize != isa_get_msize(dev))
- isa_set_msize(dev, dvp->id_msize);
return 0;
}
}
OpenPOWER on IntegriCloud