summaryrefslogtreecommitdiffstats
path: root/sys/i386
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2000-05-28 13:30:44 +0000
committerpeter <peter@FreeBSD.org>2000-05-28 13:30:44 +0000
commitacf1d9baa5dba9a9188d0de92398abb8751b88bd (patch)
treece1454ae234018f3f7a3da74a3b5737f948aeb57 /sys/i386
parent93273a1f231197296d12c4368772cc7a4837b0bc (diff)
downloadFreeBSD-src-acf1d9baa5dba9a9188d0de92398abb8751b88bd.zip
FreeBSD-src-acf1d9baa5dba9a9188d0de92398abb8751b88bd.tar.gz
Redo the isa compat driver shim so that each driver is self contained
and does not require that evil list of drivers in isa_compat.h. It uses the same strategy that pci drivers use, namely a COMPAT_ISA_DRIVER() macro that creates the glue on the fly. Theoretically old-style isa drivers should be preloadable now.
Diffstat (limited to 'sys/i386')
-rw-r--r--sys/i386/isa/isa.c5
-rw-r--r--sys/i386/isa/isa_compat.c47
-rw-r--r--sys/i386/isa/isa_compat.h277
-rw-r--r--sys/i386/isa/isa_device.h19
4 files changed, 35 insertions, 313 deletions
diff --git a/sys/i386/isa/isa.c b/sys/i386/isa/isa.c
index e9e8203..9c96c4c 100644
--- a/sys/i386/isa/isa.c
+++ b/sys/i386/isa/isa.c
@@ -56,8 +56,6 @@
* SUCH DAMAGE.
*/
-#include "opt_compat_oldisa.h"
-
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/malloc.h>
@@ -72,9 +70,6 @@
void
isa_init(void)
{
-#ifdef COMPAT_OLDISA
- isa_wrap_old_drivers();
-#endif
}
/*
diff --git a/sys/i386/isa/isa_compat.c b/sys/i386/isa/isa_compat.c
index 5f328f0..ef7d358 100644
--- a/sys/i386/isa/isa_compat.c
+++ b/sys/i386/isa/isa_compat.c
@@ -43,7 +43,6 @@
#include <machine/resource.h>
#include <isa/isavar.h>
-#include <i386/isa/isa_compat.h>
#include <i386/isa/isa_device.h>
struct isa_compat_resources {
@@ -53,14 +52,6 @@ struct isa_compat_resources {
struct resource *irq;
};
-int
-isa_compat_nextid(void)
-{
- static int id = 2; /* id_id of -1, 0 and 1 are "used" */
-
- return id++;
-}
-
static void
isa_compat_alloc_resources(device_t dev, struct isa_compat_resources *res)
{
@@ -145,7 +136,6 @@ isa_compat_probe(device_t dev)
{
struct isa_device *dvp = device_get_softc(dev);
struct isa_compat_resources res;
- struct old_isa_driver *op;
u_long start, count;
/* No pnp support */
@@ -156,9 +146,7 @@ isa_compat_probe(device_t dev)
/*
* Fill in the isa_device fields.
*/
- op = device_get_driver(dev)->priv;
- dvp->id_id = isa_compat_nextid();
- dvp->id_driver = op->driver;
+ dvp->id_driver = device_get_driver(dev)->priv;
if (bus_get_resource(dev, SYS_RES_IOPORT, 0,
&start, &count) == 0)
dvp->id_iobase = start;
@@ -246,12 +234,10 @@ isa_compat_attach(device_t dev)
if (dvp->id_driver->attach)
dvp->id_driver->attach(dvp);
if (res.irq && dvp->id_irq && dvp->id_intr) {
- struct old_isa_driver *op;
void *ih;
- op = device_get_driver(dev)->priv;
error = BUS_SETUP_INTR(device_get_parent(dev), dev,
- res.irq, op->type,
+ res.irq, dvp->id_driver->intrflags,
dvp->id_intr,
(void *)(uintptr_t)dvp->id_unit,
&ih);
@@ -274,25 +260,32 @@ static device_method_t isa_compat_methods[] = {
/*
* Create a new style driver around each old isa driver.
*/
-void
-isa_wrap_old_drivers(void)
+int
+compat_isa_handler(module_t mod, int type, void *data)
{
- int i;
- struct old_isa_driver *op;
+ struct isa_driver *id = (struct isa_driver *)data;
+ driver_t *driver;
devclass_t isa_devclass = devclass_find("isa");
- for (i = 0, op = &old_drivers[0]; i < old_drivers_count; i++, op++) {
- driver_t *driver;
+ switch (type) {
+ case MOD_LOAD:
driver = malloc(sizeof(driver_t), M_DEVBUF, M_NOWAIT);
if (!driver)
- continue;
+ return ENOMEM;
bzero(driver, sizeof(driver_t));
- driver->name = op->driver->name;
+ driver->name = id->name;
driver->methods = isa_compat_methods;
driver->size = sizeof(struct isa_device);
- driver->priv = op;
- if (op->driver->sensitive_hw)
- resource_set_int(op->driver->name, -1, "sensitive", 1);
+ driver->priv = id;
+ if (id->sensitive_hw)
+ resource_set_int(id->name, -1, "sensitive", 1);
devclass_add_driver(isa_devclass, driver);
+ break;
+ case MOD_UNLOAD:
+ printf("%s: module unload not supported!\n", id->name);
+ return EOPNOTSUPP;
+ default:
+ break;
}
+ return 0;
}
diff --git a/sys/i386/isa/isa_compat.h b/sys/i386/isa/isa_compat.h
deleted file mode 100644
index 32cf844..0000000
--- a/sys/i386/isa/isa_compat.h
+++ /dev/null
@@ -1,277 +0,0 @@
-/*-
- * Copyright (c) 1998 Doug Rabson
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#include "ar.h"
-#include "cx.h"
-#include "el.h"
-#include "fe.h"
-#include "le.h"
-#include "lnc.h"
-#include "rdp.h"
-#include "sr.h"
-#include "wl.h"
-#include "pcm.h"
-#include "pas.h"
-#include "sb.h"
-#include "sbxvi.h"
-#include "sbmidi.h"
-#include "awe.h"
-#include "gus.h"
-#include "mss.h"
-#include "css.h"
-#include "sscape.h"
-#include "trix.h"
-#include "opl.h"
-#include "mpu.h"
-#include "uart.h"
-#include "mcd.h"
-#include "scd.h"
-#include "matcd.h"
-#include "wt.h"
-#include "ctx.h"
-#include "spigot.h"
-#include "gp.h"
-#include "gsc.h"
-#include "cy.h"
-#include "dgb.h"
-#include "dgm.h"
-#include "labpc.h"
-#include "rc.h"
-#include "rp.h"
-#include "tw.h"
-#include "asc.h"
-#include "stl.h"
-#include "stli.h"
-#include "loran.h"
-#include "tina.h"
-#include "fla.h"
-
-struct old_isa_driver {
- int type;
- struct isa_driver *driver;
-};
-
-extern struct isa_driver ardriver;
-extern struct isa_driver cxdriver;
-extern struct isa_driver eldriver;
-extern struct isa_driver fedriver;
-extern struct isa_driver ledriver;
-extern struct isa_driver lncdriver;
-extern struct isa_driver rdpdriver;
-extern struct isa_driver srdriver;
-extern struct isa_driver wldriver;
-extern struct isa_driver pasdriver;
-extern struct isa_driver sbdriver;
-extern struct isa_driver sbxvidriver;
-extern struct isa_driver sbmididriver;
-extern struct isa_driver awedriver;
-extern struct isa_driver gusdriver;
-extern struct isa_driver mssdriver;
-extern struct isa_driver cssdriver;
-extern struct isa_driver sscapedriver;
-extern struct isa_driver trixdriver;
-extern struct isa_driver sscape_mssdriver;
-extern struct isa_driver opldriver;
-extern struct isa_driver mpudriver;
-extern struct isa_driver uartdriver;
-extern struct isa_driver mcddriver;
-extern struct isa_driver scddriver;
-extern struct isa_driver matcddriver;
-extern struct isa_driver wtdriver;
-extern struct isa_driver ctxdriver;
-extern struct isa_driver spigotdriver;
-extern struct isa_driver gpdriver;
-extern struct isa_driver gscdriver;
-extern struct isa_driver cydriver;
-extern struct isa_driver dgbdriver;
-extern struct isa_driver dgmdriver;
-extern struct isa_driver labpcdriver;
-extern struct isa_driver rcdriver;
-extern struct isa_driver rpdriver;
-extern struct isa_driver twdriver;
-extern struct isa_driver ascdriver;
-extern struct isa_driver stldriver;
-extern struct isa_driver stlidriver;
-extern struct isa_driver lorandriver;
-extern struct isa_driver tinadriver;
-
-
-static struct old_isa_driver old_drivers[] = {
-
-/* Sensitive TTY */
-
-/* Sensitive BIO */
-
-/* Sensitive NET */
-#if NFE > 0
- { INTR_TYPE_NET, &fedriver },
-#endif
-#if NRDP > 0
- { INTR_TYPE_NET, &rdpdriver },
-#endif
-
-/* Sensitive CAM */
-
-/* TTY */
-
-#if NGP > 0
- { INTR_TYPE_TTY, &gpdriver },
-#endif
-#if NGSC > 0
- { INTR_TYPE_TTY, &gscdriver },
-#endif
-#if NCY > 0
- { INTR_TYPE_TTY | INTR_TYPE_FAST, &cydriver },
-#endif
-#if NDGB > 0
- { INTR_TYPE_TTY, &dgbdriver },
-#endif
-#if NDGM > 0
- { INTR_TYPE_TTY, &dgmdriver },
-#endif
-#if NLABPC > 0
- { INTR_TYPE_TTY, &labpcdriver },
-#endif
-#if NRC > 0
- { INTR_TYPE_TTY, &rcdriver },
-#endif
-#if NRP > 0
- { INTR_TYPE_TTY, &rpdriver },
-#endif
-#if NTW > 0
- { INTR_TYPE_TTY, &twdriver },
-#endif
-#if NASC > 0
- { INTR_TYPE_TTY, &ascdriver },
-#endif
-#if NSTL > 0
- { INTR_TYPE_TTY, &stldriver },
-#endif
-#if NSTLI > 0
- { INTR_TYPE_TTY, &stlidriver },
-#endif
-#if NLORAN > 0
- { INTR_TYPE_TTY | INTR_TYPE_FAST, &lorandriver },
-#endif
-
-/* BIO */
-
-#if NMCD > 0
- { INTR_TYPE_BIO, &mcddriver },
-#endif
-#if NSCD > 0
- { INTR_TYPE_BIO, &scddriver },
-#endif
-#if NMATCD > 0
- { INTR_TYPE_BIO, &matcddriver },
-#endif
-#if NWT > 0
- { INTR_TYPE_BIO, &wtdriver },
-#endif
-
-/* NET */
-
-#if NLE > 0
- { INTR_TYPE_NET, &ledriver },
-#endif
-#if NLNC > 0
- { INTR_TYPE_NET, &lncdriver },
-#endif
-#if NAR > 0
- { INTR_TYPE_NET, &ardriver },
-#endif
-#if NCX > 0
- { INTR_TYPE_NET, &cxdriver },
-#endif
-#if NEL > 0
- { INTR_TYPE_NET, &eldriver },
-#endif
-#if NSR > 0
- { INTR_TYPE_NET, &srdriver },
-#endif
-#if NWL > 0
- { INTR_TYPE_NET, &wldriver },
-#endif
-#if NTINA > 0
- { INTR_TYPE_NET, &tinadriver },
-#endif
-
-/* MISC */
-
-#if NPAS > 0
- { INTR_TYPE_MISC, &pasdriver },
-#endif
-#if NSB > 0
- { INTR_TYPE_MISC, &sbdriver },
-#endif
-#if NSBXVI > 0
- { INTR_TYPE_MISC, &sbxvidriver },
-#endif
-#if NSBMIDI > 0
- { INTR_TYPE_MISC, &sbmididriver },
-#endif
-#if NAWE > 0
- { INTR_TYPE_MISC, &awedriver },
-#endif
-#if NGUS > 0
- { INTR_TYPE_MISC, &gusdriver },
-#endif
-#if NMSS > 0
- { INTR_TYPE_MISC, &mssdriver },
-#endif
-#if NCSS > 0
- { INTR_TYPE_MISC, &cssdriver },
-#endif
-#if NSSCAPE > 0
- { INTR_TYPE_MISC, &sscapedriver },
-#endif
-#if NTRIX > 0
- { INTR_TYPE_MISC, &trixdriver },
-#endif
-#if NSSCAPE > 0
- { INTR_TYPE_MISC, &sscape_mssdriver },
-#endif
-#if NOPL > 0
- { INTR_TYPE_MISC, &opldriver },
-#endif
-#if NMPU > 0
- { INTR_TYPE_MISC, &mpudriver },
-#endif
-#if NUART > 0
- { INTR_TYPE_MISC, &uartdriver },
-#endif
-#if NCTX > 0
- { INTR_TYPE_MISC, &ctxdriver },
-#endif
-#if NSPIGOT > 0
- { INTR_TYPE_MISC, &spigotdriver },
-#endif
-
-};
-
-#define old_drivers_count (sizeof(old_drivers) / sizeof(old_drivers[0]))
diff --git a/sys/i386/isa/isa_device.h b/sys/i386/isa/isa_device.h
index c89dca0..372401c 100644
--- a/sys/i386/isa/isa_device.h
+++ b/sys/i386/isa/isa_device.h
@@ -53,7 +53,6 @@
* Per device structure.
*/
struct isa_device {
- int id_id; /* device id */
struct isa_driver *id_driver;
int id_iobase; /* base i/o address */
int id_iosize; /* base i/o length */
@@ -82,16 +81,28 @@ struct isa_device {
* These are used at boot time by the configuration program.
*/
struct isa_driver {
- int (*probe) __P((struct isa_device *idp));
+ int intrflags;
+ int (*probe)(struct isa_device *idp);
/* test whether device is present */
- int (*attach) __P((struct isa_device *idp));
+ int (*attach)(struct isa_device *idp);
/* setup driver for a device */
char *name; /* device name */
int sensitive_hw; /* true if other probes confuse us */
};
#ifdef _KERNEL
-int isa_compat_nextid __P((void));
+
+/* Wrappers */
+struct module;
+int compat_isa_handler(struct module *, int, void *);
+#define COMPAT_ISA_DRIVER(name, isadata) \
+static moduledata_t name##_mod = { \
+ #name, \
+ compat_isa_handler, \
+ &isadata \
+}; \
+DECLARE_MODULE(name, name##_mod, SI_SUB_DRIVERS, SI_ORDER_ANY) \
+
#endif
#endif /* COMPAT_OLDISA */
OpenPOWER on IntegriCloud