summaryrefslogtreecommitdiffstats
path: root/sys/i386/isa
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1999-04-16 21:22:55 +0000
committerpeter <peter@FreeBSD.org>1999-04-16 21:22:55 +0000
commit087d4857e56f150a8f549600150404f273efb895 (patch)
treecf4e27432c59d956f4e5784207180115ee8fef9d /sys/i386/isa
parentc5fe612b8411a32a8e6e426fc1a70cba0cca3d31 (diff)
downloadFreeBSD-src-087d4857e56f150a8f549600150404f273efb895.zip
FreeBSD-src-087d4857e56f150a8f549600150404f273efb895.tar.gz
Bring the 'new-bus' to the i386. This extensively changes the way the
i386 platform boots, it is no longer ISA-centric, and is fully dynamic. Most old drivers compile and run without modification via 'compatability shims' to enable a smoother transition. eisa, isapnp and pccard* are not yet using the new resource manager. Once fully converted, all drivers will be loadable, including PCI and ISA. (Some other changes appear to have snuck in, including a port of Soren's ATA driver to the Alpha. Soren, back this out if you need to.) This is a checkpoint of work-in-progress, but is quite functional. The bulk of the work was done over the last few years by Doug Rabson and Garrett Wollman. Approved by: core
Diffstat (limited to 'sys/i386/isa')
-rw-r--r--sys/i386/isa/aha_isa.c7
-rw-r--r--sys/i386/isa/fd.c1139
-rw-r--r--sys/i386/isa/fdc.h6
-rw-r--r--sys/i386/isa/if_cs.c7
-rw-r--r--sys/i386/isa/if_ed.c7
-rw-r--r--sys/i386/isa/intr_machdep.c4
-rw-r--r--sys/i386/isa/isa.c1462
-rw-r--r--sys/i386/isa/isa_compat.c255
-rw-r--r--sys/i386/isa/isa_compat.h378
-rw-r--r--sys/i386/isa/isa_device.h29
-rw-r--r--sys/i386/isa/isa_dma.c510
-rw-r--r--sys/i386/isa/isa_dma.h51
-rw-r--r--sys/i386/isa/nmi.c4
-rw-r--r--sys/i386/isa/npx.c159
-rw-r--r--sys/i386/isa/rp.c8
-rw-r--r--sys/i386/isa/snd/sound.c5
-rw-r--r--sys/i386/isa/sound/ad1848.c5
-rw-r--r--sys/i386/isa/wd.c25
18 files changed, 2464 insertions, 1597 deletions
diff --git a/sys/i386/isa/aha_isa.c b/sys/i386/isa/aha_isa.c
index 9426679..c3704df 100644
--- a/sys/i386/isa/aha_isa.c
+++ b/sys/i386/isa/aha_isa.c
@@ -28,7 +28,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: aha_isa.c,v 1.5 1998/11/10 06:44:54 gibbs Exp $
+ * $Id: aha_isa.c,v 1.6 1999/01/20 06:21:23 imp Exp $
*/
#include "pnp.h"
@@ -257,7 +257,6 @@ static void
ahapnp_attach(u_long csn, u_long vend_id, char *name, struct isa_device *dev)
{
struct pnp_cinfo d;
- struct isa_device *dvp;
if (dev->id_unit >= NAHATOT)
return;
@@ -278,9 +277,7 @@ ahapnp_attach(u_long csn, u_long vend_id, char *name, struct isa_device *dev)
if (dev->id_driver == NULL) {
dev->id_driver = &ahadriver;
- dvp = find_isadev(isa_devtab_tty, &ahadriver, 0);
- if (dvp != NULL)
- dev->id_id = dvp->id_id;
+ dev->id_id = isa_compat_nextid();
}
if ((dev->id_alive = aha_isa_probe(dev)) != 0)
diff --git a/sys/i386/isa/fd.c b/sys/i386/isa/fd.c
index 07223f1..0414b18 100644
--- a/sys/i386/isa/fd.c
+++ b/sys/i386/isa/fd.c
@@ -47,7 +47,7 @@
* SUCH DAMAGE.
*
* from: @(#)fd.c 7.4 (Berkeley) 5/25/91
- * $Id: fd.c,v 1.133 1999/02/10 00:03:32 ken Exp $
+ * $Id: fd.c,v 1.134 1999/04/06 03:06:51 peter Exp $
*
*/
@@ -60,26 +60,37 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
+#include <sys/buf.h>
+#include <sys/bus.h>
#include <sys/conf.h>
-#include <sys/fcntl.h>
-#include <machine/clock.h>
-#include <machine/ioctl_fd.h>
#include <sys/disklabel.h>
-#include <sys/buf.h>
#include <sys/devicestat.h>
+#include <sys/fcntl.h>
#include <sys/malloc.h>
+#include <sys/module.h>
#include <sys/proc.h>
#include <sys/syslog.h>
-#include <i386/isa/isa.h>
-#include <i386/isa/isa_device.h>
-#include <i386/isa/fdreg.h>
-#include <i386/isa/fdc.h>
-#include <i386/isa/rtc.h>
+
+#include <sys/bus.h>
+#include <machine/bus.h>
+#include <sys/rman.h>
+
+#include <machine/clock.h>
+#include <machine/ioctl_fd.h>
+#include <machine/resource.h>
#include <machine/stdarg.h>
+
#ifdef DEVFS
#include <sys/devfsext.h>
#endif /* DEVFS */
+#include <isa/isavar.h>
+#include <i386/isa/isa.h>
+#include <i386/isa/isa_dma.h>
+#include <i386/isa/fdreg.h>
+#include <i386/isa/fdc.h>
+#include <i386/isa/rtc.h>
+
/* misuse a flag to identify format operation */
#define B_FORMAT B_XXX
@@ -151,13 +162,13 @@ static struct fd_type fd_types[NUMTYPES] =
/***********************************************************************\
* Per controller structure. *
\***********************************************************************/
-struct fdc_data fdc_data[NFDC];
+static devclass_t fdc_devclass;
/***********************************************************************\
* Per drive structure. *
* N per controller (DRVS_PER_CTLR) *
\***********************************************************************/
-static struct fd_data {
+struct fd_data {
struct fdc_data *fdc; /* pointer to controller structure */
int fdsu; /* this units number on this controller */
int type; /* Drive type (FD_1440...) */
@@ -179,7 +190,10 @@ static struct fd_data {
void *bdevs[1 + NUMDENS + MAXPARTITIONS];
void *cdevs[1 + NUMDENS + MAXPARTITIONS];
#endif
-} fd_data[NFD];
+ device_t dev;
+ fdu_t fdu;
+};
+static devclass_t fd_devclass;
/***********************************************************************\
* Throughout this file the following conventions will be used: *
@@ -195,29 +209,26 @@ static struct fd_data {
static int yeattach(struct isa_device *);
#endif
-/* autoconfig functions */
-static int fdprobe(struct isa_device *);
-static int fdattach(struct isa_device *);
-
/* needed for ft driver, thus exported */
-int in_fdc(fdcu_t);
-int out_fdc(fdcu_t, int);
+int in_fdc(struct fdc_data *);
+int out_fdc(struct fdc_data *, int);
/* internal functions */
-static void set_motor(fdcu_t, int, int);
+static void fdc_add_device(device_t, const char *, int);
+static void fdc_intr(void *);
+static void set_motor(struct fdc_data *, int, int);
# define TURNON 1
# define TURNOFF 0
static timeout_t fd_turnoff;
static timeout_t fd_motor_on;
-static void fd_turnon(fdu_t);
+static void fd_turnon(struct fd_data *);
static void fdc_reset(fdc_p);
-static int fd_in(fdcu_t, int *);
-static void fdstart(fdcu_t);
+static int fd_in(struct fdc_data *, int *);
+static void fdstart(struct fdc_data *);
static timeout_t fd_iotimeout;
static timeout_t fd_pseudointr;
-static ointhand2_t fdintr;
-static int fdstate(fdcu_t, fdc_p);
-static int retrier(fdcu_t);
+static int fdstate(struct fdc_data *);
+static int retrier(struct fdc_data *);
static int fdformat(dev_t, struct fd_formb *, struct proc *);
static int enable_fifo(fdc_p fdc);
@@ -356,13 +367,6 @@ static int yeintr(struct pccard_devinfo *devi)
#endif /* NCARD > 0 */
#endif /* FDC_YE */
-
-/* autoconfig structure */
-
-struct isa_driver fdcdriver = {
- fdprobe, fdattach, "fdc",
-};
-
static d_open_t Fdopen; /* NOTE, not fdopen */
static d_read_t fdread;
static d_write_t fdwrite;
@@ -374,28 +378,18 @@ static d_strategy_t fdstrategy;
#define CDEV_MAJOR 9
#define BDEV_MAJOR 2
-
-static struct cdevsw fd_cdevsw = {
- Fdopen, fdclose, fdread, fdwrite,
- fdioctl, nostop, nullreset, nodevtotty,
- seltrue, nommap, fdstrategy, "fd",
- NULL, -1, nodump, nopsize,
- D_DISK, 0, -1 };
-
-
-static struct isa_device *fdcdevs[NFDC];
-
-
static int
-fdc_err(fdcu_t fdcu, const char *s)
+fdc_err(struct fdc_data *fdc, const char *s)
{
- fdc_data[fdcu].fdc_errs++;
- if(s) {
- if(fdc_data[fdcu].fdc_errs < FDC_ERRMAX)
- printf("fdc%d: %s", fdcu, s);
- else if(fdc_data[fdcu].fdc_errs == FDC_ERRMAX)
- printf("fdc%d: too many errors, not logging any more\n",
- fdcu);
+ fdc->fdc_errs++;
+ if (s) {
+ if (fdc->fdc_errs < FDC_ERRMAX) {
+ device_print_prettyname(fdc->fdc_dev);
+ printf("%s", s);
+ } else if (fdc->fdc_errs == FDC_ERRMAX) {
+ device_print_prettyname(fdc->fdc_dev);
+ printf("too many errors, not logging any more\n");
+ }
}
return FD_FAILED;
@@ -407,9 +401,8 @@ fdc_err(fdcu_t fdcu, const char *s)
* # of output bytes, output bytes as ints ...,
* # of input bytes, input bytes as ints ...
*/
-
static int
-fd_cmd(fdcu_t fdcu, int n_out, ...)
+fd_cmd(struct fdc_data *fdc, int n_out, ...)
{
u_char cmd;
int n_in;
@@ -422,26 +415,26 @@ fd_cmd(fdcu_t fdcu, int n_out, ...)
va_start(ap, n_out);
for (n = 0; n < n_out; n++)
{
- if (out_fdc(fdcu, va_arg(ap, int)) < 0)
+ if (out_fdc(fdc, va_arg(ap, int)) < 0)
{
char msg[50];
snprintf(msg, sizeof(msg),
"cmd %x failed at out byte %d of %d\n",
cmd, n + 1, n_out);
- return fdc_err(fdcu, msg);
+ return fdc_err(fdc, msg);
}
}
n_in = va_arg(ap, int);
for (n = 0; n < n_in; n++)
{
int *ptr = va_arg(ap, int *);
- if (fd_in(fdcu, ptr) < 0)
+ if (fd_in(fdc, ptr) < 0)
{
char msg[50];
snprintf(msg, sizeof(msg),
"cmd %02x failed at in byte %d of %d\n",
cmd, n + 1, n_in);
- return fdc_err(fdcu, msg);
+ return fdc_err(fdc, msg);
}
}
@@ -462,8 +455,8 @@ enable_fifo(fdc_p fdc)
* first byte, and check for an early turn of data directon.
*/
- if (out_fdc(fdc->fdcu, I8207X_CONFIGURE) < 0)
- return fdc_err(fdc->fdcu, "Enable FIFO failed\n");
+ if (out_fdc(fdc, I8207X_CONFIGURE) < 0)
+ return fdc_err(fdc, "Enable FIFO failed\n");
/* If command is invalid, return */
j = 100000;
@@ -474,17 +467,17 @@ enable_fifo(fdc_p fdc)
return FD_FAILED;
}
if (j<0 ||
- fd_cmd(fdc->fdcu, 3,
+ fd_cmd(fdc, 3,
0, (fifo_threshold - 1) & 0xf, 0, 0) < 0) {
fdc_reset(fdc);
- return fdc_err(fdc->fdcu, "Enable FIFO failed\n");
+ return fdc_err(fdc, "Enable FIFO failed\n");
}
fdc->flags |= FDC_HAS_FIFO;
return 0;
}
- if (fd_cmd(fdc->fdcu, 4,
+ if (fd_cmd(fdc, 4,
I8207X_CONFIGURE, 0, (fifo_threshold - 1) & 0xf, 0, 0) < 0)
- return fdc_err(fdc->fdcu, "Re-enable FIFO failed\n");
+ return fdc_err(fdc, "Re-enable FIFO failed\n");
return 0;
}
@@ -493,9 +486,9 @@ fd_sense_drive_status(fdc_p fdc, int *st3p)
{
int st3;
- if (fd_cmd(fdc->fdcu, 2, NE7CMD_SENSED, fdc->fdu, 1, &st3))
+ if (fd_cmd(fdc, 2, NE7CMD_SENSED, fdc->fdu, 1, &st3))
{
- return fdc_err(fdc->fdcu, "Sense Drive Status failed\n");
+ return fdc_err(fdc, "Sense Drive Status failed\n");
}
if (st3p)
*st3p = st3;
@@ -506,13 +499,11 @@ fd_sense_drive_status(fdc_p fdc, int *st3p)
static int
fd_sense_int(fdc_p fdc, int *st0p, int *cylp)
{
- int st0, cyl;
+ int cyl, st0, ret;
- int ret = fd_cmd(fdc->fdcu, 1, NE7CMD_SENSEI, 1, &st0);
-
- if (ret)
- {
- (void)fdc_err(fdc->fdcu,
+ ret = fd_cmd(fdc, 1, NE7CMD_SENSEI, 1, &st0);
+ if (ret) {
+ (void)fdc_err(fdc,
"sense intr err reading stat reg 0\n");
return ret;
}
@@ -520,17 +511,15 @@ fd_sense_int(fdc_p fdc, int *st0p, int *cylp)
if (st0p)
*st0p = st0;
- if ((st0 & NE7_ST0_IC) == NE7_ST0_IC_IV)
- {
+ if ((st0 & NE7_ST0_IC) == NE7_ST0_IC_IV) {
/*
* There doesn't seem to have been an interrupt.
*/
return FD_NOT_VALID;
}
- if (fd_in(fdc->fdcu, &cyl) < 0)
- {
- return fdc_err(fdc->fdcu, "can't get cyl num\n");
+ if (fd_in(fdc, &cyl) < 0) {
+ return fdc_err(fdc, "can't get cyl num\n");
}
if (cylp)
@@ -545,8 +534,7 @@ fd_read_status(fdc_p fdc, int fdsu)
{
int i, ret;
- for (i = 0; i < 7; i++)
- {
+ for (i = 0; i < 7; i++) {
/*
* XXX types are poorly chosen. Only bytes can by read
* from the hardware, but fdc->status[] wants u_ints and
@@ -554,7 +542,7 @@ fd_read_status(fdc_p fdc, int fdsu)
*/
int status;
- ret = fd_in(fdc->fdcu, &status);
+ ret = fd_in(fdc, &status);
fdc->status[i] = status;
if (ret != 0)
break;
@@ -572,34 +560,92 @@ fd_read_status(fdc_p fdc, int fdsu)
/* autoconfiguration stuff */
/****************************************************************************/
-/*
- * probe for existance of controller
- */
static int
-fdprobe(struct isa_device *dev)
+fdc_probe(device_t dev)
{
- fdcu_t fdcu = dev->id_unit;
- if(fdc_data[fdcu].flags & FDC_ATTACHED)
- {
- printf("fdc%d: unit used multiple times\n", fdcu);
- return 0;
+ int error, i, ic_type;
+ struct fdc_data *fdc;
+ char myname[8]; /* better be long enough */
+
+ fdc = device_get_softc(dev);
+ bzero(fdc, sizeof *fdc);
+ fdc->fdc_dev = dev;
+ fdc->rid_ioport = fdc->rid_irq = fdc->rid_drq = 0;
+ fdc->res_ioport = fdc->res_irq = fdc->res_drq = 0;
+
+ fdc->res_ioport = bus_alloc_resource(dev, SYS_RES_IOPORT,
+ &fdc->rid_ioport, 0ul, ~0ul,
+ IO_FDCSIZE, RF_ACTIVE);
+ if (fdc->res_ioport == 0) {
+ device_print_prettyname(dev);
+ printf("cannot reserve I/O port range\n");
+ error = ENXIO;
+ goto out;
}
-
- fdcdevs[fdcu] = dev;
- fdc_data[fdcu].baseport = dev->id_iobase;
+ fdc->baseport = fdc->res_ioport->r_start;
+
+ fdc->res_irq = bus_alloc_resource(dev, SYS_RES_IRQ,
+ &fdc->rid_irq, 0ul, ~0ul, 1,
+ RF_ACTIVE);
+ if (fdc->res_irq == 0) {
+ device_print_prettyname(dev);
+ printf("cannot reserve interrupt line\n");
+ error = ENXIO;
+ goto out;
+ }
+ fdc->res_drq = bus_alloc_resource(dev, SYS_RES_DRQ,
+ &fdc->rid_drq, 0ul, ~0ul, 1,
+ RF_ACTIVE);
+ if (fdc->res_drq == 0) {
+ device_print_prettyname(dev);
+ printf("cannot reserve DMA request line\n");
+ error = ENXIO;
+ goto out;
+ }
+ fdc->dmachan = fdc->res_drq->r_start;
+ error = BUS_SETUP_INTR(device_get_parent(dev), dev,
+ fdc->res_irq, fdc_intr, fdc, &fdc->fdc_intr);
/* First - lets reset the floppy controller */
- outb(dev->id_iobase+FDOUT, 0);
+ outb(fdc->baseport + FDOUT, 0);
DELAY(100);
- outb(dev->id_iobase+FDOUT, FDO_FRST);
+ outb(fdc->baseport + FDOUT, FDO_FRST);
/* see if it can handle a command */
- if (fd_cmd(fdcu,
- 3, NE7CMD_SPECIFY, NE7_SPEC_1(3, 240), NE7_SPEC_2(2, 0),
- 0))
- {
- return(0);
+ if (fd_cmd(fdc, 3, NE7CMD_SPECIFY, NE7_SPEC_1(3, 240),
+ NE7_SPEC_2(2, 0), 0)) {
+ error = ENXIO;
+ goto out;
+ }
+
+ if (fd_cmd(fdc, 1, NE7CMD_VERSION, 1, &ic_type) == 0) {
+ ic_type = (u_char)ic_type;
+ switch (ic_type) {
+ case 0x80:
+ device_set_desc(dev, "NEC 765 or clone");
+ fdc->fdct = FDC_NE765;
+ break;
+ case 0x81:
+ device_set_desc(dev, "Intel 82077 or clone");
+ fdc->fdct = FDC_I82077;
+ break;
+ case 0x90:
+ device_set_desc(dev, "NEC 72065B or clone");
+ fdc->fdct = FDC_NE72065;
+ break;
+ default:
+ device_set_desc(dev, "generic floppy controller");
+ fdc->fdct = FDC_UNKNOWN;
+ break;
+ }
}
+
+ snprintf(myname, sizeof(myname), "%s%d", device_get_name(dev),
+ device_get_unit(dev));
+ for (i = resource_query_string(-1, "at", myname); i != -1;
+ i = resource_query_string(i, "at", myname))
+ fdc_add_device(dev, resource_query_name(i),
+ resource_query_unit(i));
#ifdef FDC_YE
/*
* don't succeed on probe; wait
@@ -608,277 +654,312 @@ fdprobe(struct isa_device *dev)
if (dev->id_flags & FDC_IS_PCMCIA)
return(0);
#endif
- return (IO_FDCSIZE);
+ return (0);
+
+out:
+ if (fdc->fdc_intr)
+ BUS_TEARDOWN_INTR(device_get_parent(dev), dev, fdc->res_irq,
+ fdc->fdc_intr);
+ if (fdc->res_irq != 0) {
+ bus_deactivate_resource(dev, SYS_RES_IRQ, fdc->rid_irq,
+ fdc->res_irq);
+ bus_release_resource(dev, SYS_RES_IRQ, fdc->rid_irq,
+ fdc->res_irq);
+ }
+ if (fdc->res_ioport != 0) {
+ bus_deactivate_resource(dev, SYS_RES_IOPORT, fdc->rid_ioport,
+ fdc->res_ioport);
+ bus_release_resource(dev, SYS_RES_IOPORT, fdc->rid_ioport,
+ fdc->res_ioport);
+ }
+ if (fdc->res_drq != 0) {
+ bus_deactivate_resource(dev, SYS_RES_DRQ, fdc->rid_drq,
+ fdc->res_drq);
+ bus_release_resource(dev, SYS_RES_DRQ, fdc->rid_drq,
+ fdc->res_drq);
+ }
+ return (error);
}
/*
- * wire controller into system, look for floppy units
+ * Aped dfr@freebsd.org's isa_add_device().
*/
+static void
+fdc_add_device(device_t dev, const char *name, int unit)
+{
+ int disabled, *ivar;
+ device_t child;
+
+ ivar = malloc(sizeof *ivar, M_DEVBUF /* XXX */, M_NOWAIT);
+ if (ivar == 0)
+ return;
+ if (resource_int_value(name, unit, "drive", ivar) == 0)
+ *ivar = 0;
+ child = device_add_child(dev, name, unit, ivar);
+ if (child == 0)
+ return;
+ if (resource_int_value(name, unit, "disabled", &disabled) == 0)
+ device_disable(child);
+}
+
static int
-fdattach(struct isa_device *dev)
+fdc_attach(device_t dev)
{
- unsigned fdt;
- fdu_t fdu;
- fdcu_t fdcu = dev->id_unit;
- fdc_p fdc = fdc_data + fdcu;
- fd_p fd;
- int fdsu, st0, st3, i;
- struct isa_device *fdup;
- int ic_type = 0;
-#ifdef DEVFS
- int mynor;
- int typemynor;
- int typesize;
-#endif
+ struct fdc_data *fdc = device_get_softc(dev);
+ fdcu_t fdcu = device_get_unit(dev);
- dev->id_ointr = fdintr;
fdc->fdcu = fdcu;
fdc->flags |= FDC_ATTACHED;
- fdc->dmachan = dev->id_drq;
+
/* Acquire the DMA channel forever, The driver will do the rest */
+ /* XXX should integrate with rman */
isa_dma_acquire(fdc->dmachan);
isa_dmainit(fdc->dmachan, 128 << 3 /* XXX max secsize */);
fdc->state = DEVIDLE;
+
/* reset controller, turn motor off, clear fdout mirror reg */
outb(fdc->baseport + FDOUT, ((fdc->fdout = 0)));
bufq_init(&fdc->head);
- /* check for each floppy drive */
- for (fdup = isa_biotab_fdc; fdup->id_driver != 0; fdup++) {
- if (fdup->id_iobase != dev->id_iobase)
- continue;
- fdu = fdup->id_unit;
- fd = &fd_data[fdu];
- if (fdu >= (NFD))
- continue;
- fdsu = fdup->id_physid;
- /* look up what bios thinks we have */
- switch (fdu) {
- case 0: if (dev->id_flags & FDC_PRETEND_D0)
- fdt = RTCFDT_144M | RTCFDT_144M_PRETENDED;
- else
- fdt = (rtcin(RTC_FDISKETTE) & 0xf0);
- break;
- case 1: fdt = ((rtcin(RTC_FDISKETTE) << 4) & 0xf0);
- break;
- default: fdt = RTCFDT_NONE;
- break;
- }
- /* is there a unit? */
- if ((fdt == RTCFDT_NONE)
- ) {
- fd->type = NO_TYPE;
- continue;
- }
+#ifdef FIFO_BEFORE_MOTORON
+ /* Hmm, this doesn't work here - is set_motor() magic? -Peter */
+ if (fdc->fdct != FDC_NE765 && fdc->fdct != FDC_UNKNOWN
+ && enable_fifo(fdc) == 0) {
+ device_print_prettyname(dev);
+ printf("FIFO enabled, %d bytes threshold\n", fifo_threshold);
+ }
+#endif
+ /*
+ * Probe and attach any children as were configured above.
+ */
+ return (bus_generic_attach(dev));
+}
- /* select it */
- set_motor(fdcu, fdsu, TURNON);
- DELAY(1000000); /* 1 sec */
+static void
+fdc_print_child(device_t me, device_t child)
+{
+ printf(" at %s%d drive %d", device_get_name(me), device_get_unit(me),
+ *(int *)device_get_ivars(child));
+}
- if (ic_type == 0 &&
- fd_cmd(fdcu, 1, NE7CMD_VERSION, 1, &ic_type) == 0)
- {
-#ifdef FDC_PRINT_BOGUS_CHIPTYPE
- printf("fdc%d: ", fdcu);
-#endif
- ic_type = (u_char)ic_type;
- switch( ic_type ) {
- case 0x80:
-#ifdef FDC_PRINT_BOGUS_CHIPTYPE
- printf("NEC 765\n");
-#endif
- fdc->fdct = FDC_NE765;
- break;
- case 0x81:
-#ifdef FDC_PRINT_BOGUS_CHIPTYPE
- printf("Intel 82077\n");
-#endif
- fdc->fdct = FDC_I82077;
- break;
- case 0x90:
-#ifdef FDC_PRINT_BOGUS_CHIPTYPE
- printf("NEC 72065B\n");
+static int
+fd_probe(device_t dev)
+{
+ int i;
+ u_int fdt, st0, st3;
+ struct fd_data *fd;
+ struct fdc_data *fdc;
+ fdsu_t fdsu;
+#ifndef FIFO_BEFORE_MOTORON
+ static int fd_fifo = 0;
#endif
- fdc->fdct = FDC_NE72065;
- break;
- default:
-#ifdef FDC_PRINT_BOGUS_CHIPTYPE
- printf("unknown IC type %02x\n", ic_type);
+
+ fdsu = *(int *)device_get_ivars(dev); /* xxx cheat a bit... */
+ fd = device_get_softc(dev);
+ fdc = device_get_softc(device_get_parent(dev));
+
+ bzero(fd, sizeof *fd);
+ fd->dev = dev;
+ fd->fdc = fdc;
+ fd->fdsu = fdsu;
+ fd->fdu = device_get_unit(dev);
+
+ /* look up what bios thinks we have */
+ switch (fd->fdu) {
+ case 0:
+ if (isa_get_flags(fdc->fdc_dev) & FDC_PRETEND_D0)
+ fdt = RTCFDT_144M | RTCFDT_144M_PRETENDED;
+ else
+ fdt = (rtcin(RTC_FDISKETTE) & 0xf0);
+ break;
+ case 1:
+ fdt = ((rtcin(RTC_FDISKETTE) << 4) & 0xf0);
+ break;
+ default:
+ fdt = RTCFDT_NONE;
+ break;
+ }
+
+ /* is there a unit? */
+ if (fdt == RTCFDT_NONE)
+ return (ENXIO);
+
+ /* select it */
+ set_motor(fdc, fdsu, TURNON);
+ DELAY(1000000); /* 1 sec */
+
+#ifndef FIFO_BEFORE_MOTORON
+ if (fd_fifo == 0 && fdc->fdct != FDC_NE765 && fdc->fdct != FDC_UNKNOWN
+ && enable_fifo(fdc) == 0) {
+ device_print_prettyname(device_get_parent(dev));
+ printf("FIFO enabled, %d bytes threshold\n", fifo_threshold);
+ }
+ fd_fifo = 1;
#endif
- fdc->fdct = FDC_UNKNOWN;
- break;
- }
- if (fdc->fdct != FDC_NE765 &&
- fdc->fdct != FDC_UNKNOWN &&
- enable_fifo(fdc) == 0) {
- printf("fdc%d: FIFO enabled", fdcu);
- printf(", %d bytes threshold\n",
- fifo_threshold);
- }
- }
- if ((fd_cmd(fdcu, 2, NE7CMD_SENSED, fdsu, 1, &st3) == 0) &&
- (st3 & NE7_ST3_T0)) {
- /* if at track 0, first seek inwards */
- /* seek some steps: */
- (void)fd_cmd(fdcu, 3, NE7CMD_SEEK, fdsu, 10, 0);
- DELAY(300000); /* ...wait a moment... */
- (void)fd_sense_int(fdc, 0, 0); /* make ctrlr happy */
- }
- /* If we're at track 0 first seek inwards. */
- if ((fd_sense_drive_status(fdc, &st3) == 0) &&
- (st3 & NE7_ST3_T0)) {
- /* Seek some steps... */
- if (fd_cmd(fdcu, 3, NE7CMD_SEEK, fdsu, 10, 0) == 0) {
- /* ...wait a moment... */
- DELAY(300000);
- /* make ctrlr happy: */
- (void)fd_sense_int(fdc, 0, 0);
- }
+ if ((fd_cmd(fdc, 2, NE7CMD_SENSED, fdsu, 1, &st3) == 0)
+ && (st3 & NE7_ST3_T0)) {
+ /* if at track 0, first seek inwards */
+ /* seek some steps: */
+ fd_cmd(fdc, 3, NE7CMD_SEEK, fdsu, 10, 0);
+ DELAY(300000); /* ...wait a moment... */
+ fd_sense_int(fdc, 0, 0); /* make ctrlr happy */
+ }
+
+ /* If we're at track 0 first seek inwards. */
+ if ((fd_sense_drive_status(fdc, &st3) == 0) && (st3 & NE7_ST3_T0)) {
+ /* Seek some steps... */
+ if (fd_cmd(fdc, 3, NE7CMD_SEEK, fdsu, 10, 0) == 0) {
+ /* ...wait a moment... */
+ DELAY(300000);
+ /* make ctrlr happy: */
+ fd_sense_int(fdc, 0, 0);
}
+ }
- for(i = 0; i < 2; i++) {
- /*
- * we must recalibrate twice, just in case the
- * heads have been beyond cylinder 76, since most
- * FDCs still barf when attempting to recalibrate
- * more than 77 steps
- */
- /* go back to 0: */
- if (fd_cmd(fdcu, 2, NE7CMD_RECAL, fdsu, 0) == 0) {
- /* a second being enough for full stroke seek*/
- DELAY(i == 0? 1000000: 300000);
+ for (i = 0; i < 2; i++) {
+ /*
+ * we must recalibrate twice, just in case the
+ * heads have been beyond cylinder 76, since most
+ * FDCs still barf when attempting to recalibrate
+ * more than 77 steps
+ */
+ /* go back to 0: */
+ if (fd_cmd(fdc, 2, NE7CMD_RECAL, fdsu, 0) == 0) {
+ /* a second being enough for full stroke seek*/
+ DELAY(i == 0 ? 1000000 : 300000);
- /* anything responding? */
- if (fd_sense_int(fdc, &st0, 0) == 0 &&
- (st0 & NE7_ST0_EC) == 0)
- break; /* already probed succesfully */
- }
+ /* anything responding? */
+ if (fd_sense_int(fdc, &st0, 0) == 0 &&
+ (st0 & NE7_ST0_EC) == 0)
+ break; /* already probed succesfully */
}
+ }
- set_motor(fdcu, fdsu, TURNOFF);
+ set_motor(fdc, fdsu, TURNOFF);
- if (st0 & NE7_ST0_EC) /* no track 0 -> no drive present */
- continue;
+ if (st0 & NE7_ST0_EC) /* no track 0 -> no drive present */
+ return (ENXIO);
- fd->track = FD_NO_TRACK;
- fd->fdc = fdc;
- fd->fdsu = fdsu;
- fd->options = 0;
- callout_handle_init(&fd->toffhandle);
- callout_handle_init(&fd->tohandle);
- printf("fd%d: ", fdu);
-
- switch (fdt) {
- case RTCFDT_12M:
- printf("1.2MB 5.25in\n");
- fd->type = FD_1200;
- break;
- case RTCFDT_144M | RTCFDT_144M_PRETENDED:
- printf("config-pretended ");
- fdt = RTCFDT_144M;
- /* fallthrough */
- case RTCFDT_144M:
- printf("1.44MB 3.5in\n");
- fd->type = FD_1440;
+ fd->track = FD_NO_TRACK;
+ fd->fdc = fdc;
+ fd->fdsu = fdsu;
+ fd->options = 0;
+ callout_handle_init(&fd->toffhandle);
+ callout_handle_init(&fd->tohandle);
+
+ switch (fdt) {
+ case RTCFDT_12M:
+ device_set_desc(dev, "1200-KB 5.25\" drive");
+ fd->type = FD_1200;
+ break;
+ case RTCFDT_144M | RTCFDT_144M_PRETENDED:
+ device_set_desc(dev, "config-pretended 1440-MB 3.5\" drive");
+ fdt = RTCFDT_144M;
+ fd->type = FD_1440;
+ case RTCFDT_144M:
+ device_set_desc(dev, "1440-KB 3.5\" drive");
+ fd->type = FD_1440;
+ break;
+ case RTCFDT_288M:
+ case RTCFDT_288M_1:
+ device_set_desc(dev, "2880-KB 3.5\" drive (in 1440-KB mode)");
+ fd->type = FD_1440;
+ break;
+ case RTCFDT_360K:
+ device_set_desc(dev, "360-KB 5.25\" drive");
+ fd->type = FD_360;
+ break;
+ case RTCFDT_720K:
+ printf("720-KB 3.5\" drive");
+ fd->type = FD_720;
+ break;
+ default:
+ return (ENXIO);
+ }
+ return (0);
+}
+
+static int
+fd_attach(device_t dev)
+{
+ struct fd_data *fd;
+
+ fd = device_get_softc(dev);
+
+#ifdef DEVFS /* XXX bitrot */
+ mynor = fdu << 6;
+ fd->bdevs[0] = devfs_add_devswf(&fd_cdevsw, mynor, DV_BLK,
+ UID_ROOT, GID_OPERATOR, 0640,
+ "fd%d", fdu);
+ fd->cdevs[0] = devfs_add_devswf(&fd_cdevsw, mynor, DV_CHR,
+ UID_ROOT, GID_OPERATOR, 0640,
+ "rfd%d", fdu);
+ for (i = 1; i < 1 + NUMDENS; i++) {
+ /*
+ * XXX this and the lookup in Fdopen() should be
+ * data driven.
+ */
+ switch (fd->type) {
+ case FD_360:
+ if (i != FD_360)
+ continue;
break;
- case RTCFDT_288M:
- case RTCFDT_288M_1:
- printf("2.88MB 3.5in - 1.44MB mode\n");
- fd->type = FD_1440;
+ case FD_720:
+ if (i != FD_720 && i != FD_800 && i != FD_820)
+ continue;
break;
- case RTCFDT_360K:
- printf("360KB 5.25in\n");
- fd->type = FD_360;
+ case FD_1200:
+ if (i != FD_360 && i != FD_720 && i != FD_800
+ && i != FD_820 && i != FD_1200
+ && i != FD_1440 && i != FD_1480)
+ continue;
break;
- case RTCFDT_720K:
- printf("720KB 3.5in\n");
- fd->type = FD_720;
+ case FD_1440:
+ if (i != FD_720 && i != FD_800 && i != FD_820
+ && i != FD_1200 && i != FD_1440
+ && i != FD_1480 && i != FD_1720)
+ continue;
break;
- default:
- printf("unknown\n");
- fd->type = NO_TYPE;
- continue;
}
-#ifdef DEVFS
- mynor = fdu << 6;
- fd->bdevs[0] = devfs_add_devswf(&fd_cdevsw, mynor, DV_BLK,
- UID_ROOT, GID_OPERATOR, 0640,
- "fd%d", fdu);
- fd->cdevs[0] = devfs_add_devswf(&fd_cdevsw, mynor, DV_CHR,
- UID_ROOT, GID_OPERATOR, 0640,
- "rfd%d", fdu);
- for (i = 1; i < 1 + NUMDENS; i++) {
- /*
- * XXX this and the lookup in Fdopen() should be
- * data driven.
- */
- switch (fd->type) {
- case FD_360:
- if (i != FD_360)
- continue;
- break;
- case FD_720:
- if (i != FD_720 && i != FD_800 && i != FD_820)
- continue;
- break;
- case FD_1200:
- if (i != FD_360 && i != FD_720 && i != FD_800
- && i != FD_820 && i != FD_1200
- && i != FD_1440 && i != FD_1480)
- continue;
- break;
- case FD_1440:
- if (i != FD_720 && i != FD_800 && i != FD_820
- && i != FD_1200 && i != FD_1440
- && i != FD_1480 && i != FD_1720)
- continue;
- break;
- }
- typesize = fd_types[i - 1].size / 2;
- /*
- * XXX all these conversions give bloated code and
- * confusing names.
- */
- if (typesize == 1476)
- typesize = 1480;
- if (typesize == 1722)
- typesize = 1720;
- typemynor = mynor | i;
- fd->bdevs[i] =
- devfs_add_devswf(&fd_cdevsw, typemynor, DV_BLK,
- UID_ROOT, GID_OPERATOR, 0640,
- "fd%d.%d", fdu, typesize);
- fd->cdevs[i] =
- devfs_add_devswf(&fd_cdevsw, typemynor, DV_CHR,
- UID_ROOT, GID_OPERATOR, 0640,
- "rfd%d.%d", fdu, typesize);
- }
-
- for (i = 0; i < MAXPARTITIONS; i++) {
- fd->bdevs[1 + NUMDENS + i] = devfs_makelink(fd->bdevs[0],
- "fd%d%c", fdu, 'a' + i);
- fd->cdevs[1 + NUMDENS + i] =
- devfs_makelink(fd->cdevs[0],
- "rfd%d%c", fdu, 'a' + i);
- }
-#endif /* DEVFS */
+ typesize = fd_types[i - 1].size / 2;
/*
- * Export the drive to the devstat interface.
+ * XXX all these conversions give bloated code and
+ * confusing names.
*/
- devstat_add_entry(&fd->device_stats, "fd",
- fdu, 512,
- DEVSTAT_NO_ORDERED_TAGS,
- DEVSTAT_TYPE_FLOPPY | DEVSTAT_TYPE_IF_OTHER,
- DEVSTAT_PRIORITY_FD);
-
+ if (typesize == 1476)
+ typesize = 1480;
+ if (typesize == 1722)
+ typesize = 1720;
+ typemynor = mynor | i;
+ fd->bdevs[i] =
+ devfs_add_devswf(&fd_cdevsw, typemynor, DV_BLK,
+ UID_ROOT, GID_OPERATOR, 0640,
+ "fd%d.%d", fdu, typesize);
+ fd->cdevs[i] =
+ devfs_add_devswf(&fd_cdevsw, typemynor, DV_CHR,
+ UID_ROOT, GID_OPERATOR, 0640,
+ "rfd%d.%d", fdu, typesize);
}
- return (1);
+ for (i = 0; i < MAXPARTITIONS; i++) {
+ fd->bdevs[1 + NUMDENS + i] = devfs_makelink(fd->bdevs[0],
+ "fd%d%c", fdu, 'a' + i);
+ fd->cdevs[1 + NUMDENS + i] =
+ devfs_makelink(fd->cdevs[0],
+ "rfd%d%c", fdu, 'a' + i);
+ }
+#endif /* DEVFS */
+ /*
+ * Export the drive to the devstat interface.
+ */
+ devstat_add_entry(&fd->device_stats, device_get_name(dev),
+ device_get_unit(dev), 512, DEVSTAT_NO_ORDERED_TAGS,
+ DEVSTAT_TYPE_FLOPPY | DEVSTAT_TYPE_IF_OTHER,
+ DEVSTAT_PRIORITY_FD);
+ return (0);
}
-
-
#ifdef FDC_YE
/*
* this is a subset of fdattach() optimized for the Y-E Data
@@ -1016,9 +1097,9 @@ static int yeattach(struct isa_device *dev)
/* remember to not deselect the drive we're working on */
/****************************************************************************/
static void
-set_motor(fdcu_t fdcu, int fdsu, int turnon)
+set_motor(struct fdc_data *fdc, int fdsu, int turnon)
{
- int fdout = fdc_data[fdcu].fdout;
+ int fdout = fdc->fdout;
int needspecify = 0;
if(turnon) {
@@ -1038,83 +1119,78 @@ set_motor(fdcu_t fdcu, int fdsu, int turnon)
fdout |= (FDO_FRST|FDO_FDMAEN);
}
- outb(fdc_data[fdcu].baseport+FDOUT, fdout);
- fdc_data[fdcu].fdout = fdout;
+ outb(fdc->baseport+FDOUT, fdout);
+ fdc->fdout = fdout;
TRACE1("[0x%x->FDOUT]", fdout);
- if(needspecify) {
+ if (needspecify) {
/*
* XXX
* special case: since we have just woken up the FDC
* from its sleep, we silently assume the command will
* be accepted, and do not test for a timeout
*/
- (void)fd_cmd(fdcu, 3, NE7CMD_SPECIFY,
+ (void)fd_cmd(fdc, 3, NE7CMD_SPECIFY,
NE7_SPEC_1(3, 240), NE7_SPEC_2(2, 0),
0);
- if (fdc_data[fdcu].flags & FDC_HAS_FIFO)
- (void) enable_fifo(&fdc_data[fdcu]);
+ if (fdc->flags & FDC_HAS_FIFO)
+ (void) enable_fifo(fdc);
}
}
static void
-fd_turnoff(void *arg1)
+fd_turnoff(void *xfd)
{
- fdu_t fdu = (fdu_t)arg1;
int s;
- fd_p fd = fd_data + fdu;
+ fd_p fd = xfd;
- TRACE1("[fd%d: turnoff]", fdu);
+ TRACE1("[fd%d: turnoff]", fd->fdu);
/*
* Don't turn off the motor yet if the drive is active.
* XXX shouldn't even schedule turnoff until drive is inactive
* and nothing is queued on it.
*/
- if (fd->fdc->state != DEVIDLE && fd->fdc->fdu == fdu) {
- fd->toffhandle = timeout(fd_turnoff, arg1, 4 * hz);
+ if (fd->fdc->state != DEVIDLE && fd->fdc->fdu == fd->fdu) {
+ fd->toffhandle = timeout(fd_turnoff, fd, 4 * hz);
return;
}
s = splbio();
fd->flags &= ~FD_MOTOR;
- set_motor(fd->fdc->fdcu, fd->fdsu, TURNOFF);
+ set_motor(fd->fdc, fd->fdsu, TURNOFF);
splx(s);
}
static void
-fd_motor_on(void *arg1)
+fd_motor_on(void *xfd)
{
- fdu_t fdu = (fdu_t)arg1;
int s;
+ fd_p fd = xfd;
- fd_p fd = fd_data + fdu;
s = splbio();
fd->flags &= ~FD_MOTOR_WAIT;
if((fd->fdc->fd == fd) && (fd->fdc->state == MOTORWAIT))
{
- fdintr(fd->fdc->fdcu);
+ fdc_intr(fd->fdc);
}
splx(s);
}
static void
-fd_turnon(fdu_t fdu)
+fd_turnon(fd_p fd)
{
- fd_p fd = fd_data + fdu;
if(!(fd->flags & FD_MOTOR))
{
fd->flags |= (FD_MOTOR + FD_MOTOR_WAIT);
- set_motor(fd->fdc->fdcu, fd->fdsu, TURNON);
- timeout(fd_motor_on, (caddr_t)fdu, hz); /* in 1 sec its ok */
+ set_motor(fd->fdc, fd->fdsu, TURNON);
+ timeout(fd_motor_on, fd, hz); /* in 1 sec its ok */
}
}
static void
fdc_reset(fdc_p fdc)
{
- fdcu_t fdcu = fdc->fdcu;
-
/* Try a reset, keep motor on */
outb(fdc->baseport + FDOUT, fdc->fdout & ~(FDO_FRST|FDO_FDMAEN));
TRACE1("[0x%x->FDOUT]", fdc->fdout & ~(FDO_FRST|FDO_FDMAEN));
@@ -1127,7 +1203,7 @@ fdc_reset(fdc_p fdc)
TRACE1("[0x%x->FDOUT]", fdc->fdout);
/* XXX after a reset, silently believe the FDC will accept commands */
- (void)fd_cmd(fdcu, 3, NE7CMD_SPECIFY,
+ (void)fd_cmd(fdc, 3, NE7CMD_SPECIFY,
NE7_SPEC_1(3, 240), NE7_SPEC_2(2, 0),
0);
if (fdc->flags & FDC_HAS_FIFO)
@@ -1138,16 +1214,16 @@ fdc_reset(fdc_p fdc)
/* fdc in/out */
/****************************************************************************/
int
-in_fdc(fdcu_t fdcu)
+in_fdc(struct fdc_data *fdc)
{
- int baseport = fdc_data[fdcu].baseport;
+ int baseport = fdc->baseport;
int i, j = 100000;
while ((i = inb(baseport+FDSTS) & (NE7_DIO|NE7_RQM))
!= (NE7_DIO|NE7_RQM) && j-- > 0)
if (i == NE7_RQM)
- return fdc_err(fdcu, "ready for output in input\n");
+ return fdc_err(fdc, "ready for output in input\n");
if (j <= 0)
- return fdc_err(fdcu, bootverbose? "input ready timeout\n": 0);
+ return fdc_err(fdc, bootverbose? "input ready timeout\n": 0);
#ifdef FDC_DEBUG
i = inb(baseport+FDDATA);
TRACE1("[FDDATA->0x%x]", (unsigned char)i);
@@ -1161,16 +1237,16 @@ in_fdc(fdcu_t fdcu)
* fd_in: Like in_fdc, but allows you to see if it worked.
*/
static int
-fd_in(fdcu_t fdcu, int *ptr)
+fd_in(struct fdc_data *fdc, int *ptr)
{
- int baseport = fdc_data[fdcu].baseport;
+ int baseport = fdc->baseport;
int i, j = 100000;
while ((i = inb(baseport+FDSTS) & (NE7_DIO|NE7_RQM))
!= (NE7_DIO|NE7_RQM) && j-- > 0)
if (i == NE7_RQM)
- return fdc_err(fdcu, "ready for output in input\n");
+ return fdc_err(fdc, "ready for output in input\n");
if (j <= 0)
- return fdc_err(fdcu, bootverbose? "input ready timeout\n": 0);
+ return fdc_err(fdc, bootverbose? "input ready timeout\n": 0);
#ifdef FDC_DEBUG
i = inb(baseport+FDDATA);
TRACE1("[FDDATA->0x%x]", (unsigned char)i);
@@ -1185,21 +1261,21 @@ fd_in(fdcu_t fdcu, int *ptr)
}
int
-out_fdc(fdcu_t fdcu, int x)
+out_fdc(struct fdc_data *fdc, int x)
{
- int baseport = fdc_data[fdcu].baseport;
+ int baseport = fdc->baseport;
int i;
/* Check that the direction bit is set */
i = 100000;
while ((inb(baseport+FDSTS) & NE7_DIO) && i-- > 0);
- if (i <= 0) return fdc_err(fdcu, "direction bit not set\n");
+ if (i <= 0) return fdc_err(fdc, "direction bit not set\n");
/* Check that the floppy controller is ready for a command */
i = 100000;
while ((inb(baseport+FDSTS) & NE7_RQM) == 0 && i-- > 0);
if (i <= 0)
- return fdc_err(fdcu, bootverbose? "output ready timeout\n": 0);
+ return fdc_err(fdc, bootverbose? "output ready timeout\n": 0);
/* Send the command and return */
outb(baseport+FDDATA, x);
@@ -1215,32 +1291,33 @@ Fdopen(dev_t dev, int flags, int mode, struct proc *p)
{
fdu_t fdu = FDUNIT(minor(dev));
int type = FDTYPE(minor(dev));
+ fd_p fd;
fdc_p fdc;
/* check bounds */
- if (fdu >= NFD)
- return(ENXIO);
- fdc = fd_data[fdu].fdc;
- if ((fdc == NULL) || (fd_data[fdu].type == NO_TYPE))
- return(ENXIO);
+ if ((fd = devclass_get_softc(fd_devclass, fdu)) == 0)
+ return (ENXIO);
+ fdc = fd->fdc;
+ if ((fdc == NULL) || (fd->type == NO_TYPE))
+ return (ENXIO);
if (type > NUMDENS)
- return(ENXIO);
+ return (ENXIO);
if (type == 0)
- type = fd_data[fdu].type;
+ type = fd->type;
else {
/*
* For each type of basic drive, make sure we are trying
* to open a type it can do,
*/
- if (type != fd_data[fdu].type) {
- switch (fd_data[fdu].type) {
+ if (type != fd->type) {
+ switch (fd->type) {
case FD_360:
- return(ENXIO);
+ return (ENXIO);
case FD_720:
if ( type != FD_820
&& type != FD_800
)
- return(ENXIO);
+ return (ENXIO);
break;
case FD_1200:
switch (type) {
@@ -1279,9 +1356,10 @@ Fdopen(dev_t dev, int flags, int mode, struct proc *p)
}
}
}
- fd_data[fdu].ft = fd_types + type - 1;
- fd_data[fdu].flags |= FD_OPEN;
-
+ fd->ft = fd_types + type - 1;
+ fd->flags |= FD_OPEN;
+ device_busy(fd->dev);
+ device_busy(fd->fdc->fdc_dev);
return 0;
}
@@ -1289,11 +1367,13 @@ int
fdclose(dev_t dev, int flags, int mode, struct proc *p)
{
fdu_t fdu = FDUNIT(minor(dev));
+ struct fd_data *fd;
- fd_data[fdu].flags &= ~FD_OPEN;
- fd_data[fdu].options &= ~FDOPT_NORETRY;
+ fd = devclass_get_softc(fd_devclass, fdu);
+ fd->flags &= ~FD_OPEN;
+ fd->options &= ~FDOPT_NORETRY;
- return(0);
+ return (0);
}
static int
@@ -1317,16 +1397,17 @@ fdstrategy(struct buf *bp)
{
unsigned nblocks, blknum, cando;
int s;
- fdcu_t fdcu;
fdu_t fdu;
fdc_p fdc;
fd_p fd;
size_t fdblk;
fdu = FDUNIT(minor(bp->b_dev));
- fd = &fd_data[fdu];
+ fd = devclass_get_softc(fd_devclass, fdu);
+ if (fd == 0)
+ panic("fdstrategy: buf for nonexistent device (%#lx, %#lx)",
+ (u_long)major(bp->b_dev), (u_long)minor(bp->b_dev));
fdc = fd->fdc;
- fdcu = fdc->fdcu;
#ifdef FDC_YE
if (fd->type == NO_TYPE) {
bp->b_error = ENXIO;
@@ -1341,7 +1422,7 @@ fdstrategy(struct buf *bp)
fdblk = 128 << (fd->ft->secsize);
if (!(bp->b_flags & B_FORMAT)) {
- if ((fdu >= NFD) || (bp->b_blkno < 0)) {
+ if (bp->b_blkno < 0) {
printf(
"fd%d: fdstrat: bad request blkno = %lu, bcount = %ld\n",
fdu, (u_long)bp->b_blkno, bp->b_bcount);
@@ -1386,12 +1467,12 @@ fdstrategy(struct buf *bp)
bp->b_pblkno = bp->b_blkno;
s = splbio();
bufqdisksort(&fdc->head, bp);
- untimeout(fd_turnoff, (caddr_t)fdu, fd->toffhandle); /* a good idea */
+ untimeout(fd_turnoff, fd, fd->toffhandle); /* a good idea */
/* Tell devstat we are starting on the transaction */
devstat_start_transaction(&fd->device_stats);
- fdstart(fdcu);
+ fdstart(fdc);
splx(s);
return;
@@ -1409,27 +1490,25 @@ bad:
* will pick up our work when the present work completes *
\***************************************************************/
static void
-fdstart(fdcu_t fdcu)
+fdstart(struct fdc_data *fdc)
{
int s;
s = splbio();
- if(fdc_data[fdcu].state == DEVIDLE)
+ if(fdc->state == DEVIDLE)
{
- fdintr(fdcu);
+ fdc_intr(fdc);
}
splx(s);
}
static void
-fd_iotimeout(void *arg1)
+fd_iotimeout(void *xfdc)
{
fdc_p fdc;
- fdcu_t fdcu;
int s;
- fdcu = (fdcu_t)arg1;
- fdc = fdc_data + fdcu;
+ fdc = xfdc;
TRACE1("fd%d[fd_iotimeout()]", fdc->fdu);
/*
@@ -1447,19 +1526,18 @@ fd_iotimeout(void *arg1)
fdc->status[0] = NE7_ST0_IC_IV;
fdc->flags &= ~FDC_STAT_VALID;
fdc->state = IOTIMEDOUT;
- fdintr(fdcu);
+ fdc_intr(fdc);
splx(s);
}
/* just ensure it has the right spl */
static void
-fd_pseudointr(void *arg1)
+fd_pseudointr(void *xfdc)
{
- fdcu_t fdcu = (fdcu_t)arg1;
int s;
s = splbio();
- fdintr(fdcu);
+ fdc_intr(xfdc);
splx(s);
}
@@ -1469,11 +1547,11 @@ fd_pseudointr(void *arg1)
* ALWAYS called at SPLBIO *
\***********************************************************************/
static void
-fdintr(fdcu_t fdcu)
+fdc_intr(void *xfdc)
{
- fdc_p fdc = fdc_data + fdcu;
- while(fdstate(fdcu, fdc))
- ;
+ fdc_p fdc = xfdc;
+ while(fdstate(fdc))
+ ;
}
#ifdef FDC_YE
@@ -1513,7 +1591,7 @@ static int fdcpio(fdcu_t fdcu, long flags, caddr_t addr, u_int count)
* if it returns a non zero value, it should be called again immediatly *
\***********************************************************************/
static int
-fdstate(fdcu_t fdcu, fdc_p fdc)
+fdstate(fdc_p fdc)
{
int read, format, head, i, sec = 0, sectrac, st0, cyl, st3;
unsigned blknum = 0, b_cylinder = 0;
@@ -1537,26 +1615,25 @@ fdstate(fdcu_t fdcu, fdc_p fdc)
* Force into the IDLE state, *
\***********************************************/
fdc->state = DEVIDLE;
- if(fdc->fd)
- {
- printf("fd%d: unexpected valid fd pointer\n",
- fdc->fdu);
+ if (fdc->fd) {
+ device_print_prettyname(fdc->fdc_dev);
+ printf("unexpected valid fd pointer\n");
fdc->fd = (fd_p) 0;
fdc->fdu = -1;
}
- TRACE1("[fdc%d IDLE]", fdcu);
- return(0);
+ TRACE1("[fdc%d IDLE]", fdc->fdcu);
+ return (0);
}
fdu = FDUNIT(minor(bp->b_dev));
- fd = fd_data + fdu;
+ fd = devclass_get_softc(fd_devclass, fdu);
fdblk = 128 << fd->ft->secsize;
- if (fdc->fd && (fd != fdc->fd))
- {
- printf("fd%d: confused fd pointers\n", fdu);
+ if (fdc->fd && (fd != fdc->fd)) {
+ device_print_prettyname(fd->dev);
+ printf("confused fd pointers\n");
}
read = bp->b_flags & B_READ;
format = bp->b_flags & B_FORMAT;
- if(format) {
+ if (format) {
finfo = (struct fd_formb *)bp->b_data;
fd->skip = (char *)&(finfo->fd_formb_cylno(0))
- (char *)finfo;
@@ -1569,8 +1646,8 @@ fdstate(fdcu_t fdcu, fdc_p fdc)
TRACE1("fd%d", fdu);
TRACE1("[%s]", fdstates[fdc->state]);
TRACE1("(0x%x)", fd->flags);
- untimeout(fd_turnoff, (caddr_t)fdu, fd->toffhandle);
- fd->toffhandle = timeout(fd_turnoff, (caddr_t)fdu, 4 * hz);
+ untimeout(fd_turnoff, fd, fd->toffhandle);
+ fd->toffhandle = timeout(fd_turnoff, fd, 4 * hz);
switch (fdc->state)
{
case DEVIDLE:
@@ -1585,10 +1662,9 @@ fdstate(fdcu_t fdcu, fdc_p fdc)
* If the next drive has a motor startup pending, then *
* it will start up in its own good time *
\*******************************************************/
- if(fd->flags & FD_MOTOR_WAIT)
- {
+ if(fd->flags & FD_MOTOR_WAIT) {
fdc->state = MOTORWAIT;
- return(0); /* come back later */
+ return (0); /* come back later */
}
/*******************************************************\
* Maybe if it's not starting, it SHOULD be starting *
@@ -1596,12 +1672,12 @@ fdstate(fdcu_t fdcu, fdc_p fdc)
if (!(fd->flags & FD_MOTOR))
{
fdc->state = MOTORWAIT;
- fd_turnon(fdu);
- return(0);
+ fd_turnon(fd);
+ return (0);
}
else /* at least make sure we are selected */
{
- set_motor(fdcu, fd->fdsu, TURNON);
+ set_motor(fdc, fd->fdsu, TURNON);
}
if (fdc->flags & FDC_NEEDS_RESET) {
fdc->state = RESETCTLR;
@@ -1615,7 +1691,7 @@ fdstate(fdcu_t fdcu, fdc_p fdc)
fdc->state = SEEKCOMPLETE;
break;
}
- if (fd_cmd(fdcu, 3, NE7CMD_SEEK,
+ if (fd_cmd(fdc, 3, NE7CMD_SEEK,
fd->fdsu, b_cylinder * fd->ft->steptrac,
0))
{
@@ -1624,20 +1700,19 @@ fdstate(fdcu_t fdcu, fdc_p fdc)
* the FDC went off to the Saints...
*/
fdc->retry = 6; /* try a reset */
- return(retrier(fdcu));
+ return(retrier(fdc));
}
fd->track = FD_NO_TRACK;
fdc->state = SEEKWAIT;
return(0); /* will return later */
case SEEKWAIT:
/* allow heads to settle */
- timeout(fd_pseudointr, (caddr_t)fdcu, hz / 16);
+ timeout(fd_pseudointr, fdc, hz / 16);
fdc->state = SEEKCOMPLETE;
return(0); /* will return later */
case SEEKCOMPLETE : /* SEEK DONE, START DMA */
/* Make sure seek really happened*/
- if(fd->track == FD_NO_TRACK)
- {
+ if(fd->track == FD_NO_TRACK) {
int descyl = b_cylinder * fd->ft->steptrac;
do {
/*
@@ -1669,8 +1744,7 @@ fdstate(fdcu_t fdcu, fdc_p fdc)
return 0; /* hope for a real intr */
} while ((st0 & NE7_ST0_IC) == NE7_ST0_IC_RC);
- if (0 == descyl)
- {
+ if (0 == descyl) {
int failed = 0;
/*
* seek to cyl 0 requested; make sure we are
@@ -1685,22 +1759,20 @@ fdstate(fdcu_t fdcu, fdc_p fdc)
failed = 1;
}
- if (failed)
- {
+ if (failed) {
if(fdc->retry < 3)
fdc->retry = 3;
- return(retrier(fdcu));
+ return (retrier(fdc));
}
}
- if (cyl != descyl)
- {
+ if (cyl != descyl) {
printf(
"fd%d: Seek to cyl %d failed; am at cyl %d (ST0 = 0x%x)\n",
fdu, descyl, cyl, st0);
if (fdc->retry < 3)
fdc->retry = 3;
- return(retrier(fdcu));
+ return (retrier(fdc));
}
}
@@ -1726,7 +1798,7 @@ fdstate(fdcu_t fdcu, fdc_p fdc)
format ? bp->b_bcount : fdblk,
fdc->dmachan);
fdc->retry = 6; /* reset the beast */
- return(retrier(fdcu));
+ return (retrier(fdc));
}
if(st3 & NE7_ST3_WP)
{
@@ -1749,8 +1821,7 @@ fdstate(fdcu_t fdcu, fdc_p fdc)
}
}
- if(format)
- {
+ if (format) {
#ifdef FDC_YE
if (fdc->flags & FDC_PCMCIA)
(void)fdcpio(fdcu,bp->b_flags,
@@ -1758,25 +1829,19 @@ fdstate(fdcu_t fdcu, fdc_p fdc)
bp->b_bcount);
#endif
/* formatting */
- if(fd_cmd(fdcu, 6,
- NE7CMD_FORMAT,
- head << 2 | fdu,
+ if(fd_cmd(fdc, 6, NE7CMD_FORMAT, head << 2 | fdu,
finfo->fd_formb_secshift,
finfo->fd_formb_nsecs,
finfo->fd_formb_gaplen,
- finfo->fd_formb_fillbyte,
- 0))
- {
+ finfo->fd_formb_fillbyte, 0)) {
/* controller fell over */
isa_dmadone(bp->b_flags, bp->b_data + fd->skip,
format ? bp->b_bcount : fdblk,
fdc->dmachan);
fdc->retry = 6;
- return(retrier(fdcu));
+ return (retrier(fdc));
}
- }
- else
- {
+ } else {
#ifdef FDC_YE
if (fdc->flags & FDC_PCMCIA) {
/*
@@ -1795,7 +1860,7 @@ fdstate(fdcu_t fdcu, fdc_p fdc)
fdblk);
}
#endif
- if (fd_cmd(fdcu, 9,
+ if (fd_cmd(fdc, 9,
(read ? NE7CMD_READ : NE7CMD_WRITE),
head << 2 | fdu, /* head & unit */
fd->track, /* track */
@@ -1805,14 +1870,13 @@ fdstate(fdcu_t fdcu, fdc_p fdc)
sectrac, /* sectors/track */
fd->ft->gap, /* gap size */
fd->ft->datalen, /* data length */
- 0))
- {
+ 0)) {
/* the beast is sleeping again */
isa_dmadone(bp->b_flags, bp->b_data + fd->skip,
format ? bp->b_bcount : fdblk,
fdc->dmachan);
fdc->retry = 6;
- return(retrier(fdcu));
+ return (retrier(fdc));
}
}
#ifdef FDC_YE
@@ -1834,8 +1898,8 @@ fdstate(fdcu_t fdcu, fdc_p fdc)
*/
#endif
fdc->state = IOCOMPLETE;
- fd->tohandle = timeout(fd_iotimeout, (caddr_t)fdcu, hz);
- return(0); /* will return later */
+ fd->tohandle = timeout(fd_iotimeout, fdc, hz);
+ return (0); /* will return later */
#ifdef FDC_YE
case PIOREAD:
/*
@@ -1847,16 +1911,15 @@ fdstate(fdcu_t fdcu, fdc_p fdc)
/* FALLTHROUGH */
#endif
case IOCOMPLETE: /* IO DONE, post-analyze */
- untimeout(fd_iotimeout, (caddr_t)fdcu, fd->tohandle);
+ untimeout(fd_iotimeout, fdc, fd->tohandle);
- if (fd_read_status(fdc, fd->fdsu))
- {
+ if (fd_read_status(fdc, fd->fdsu)) {
isa_dmadone(bp->b_flags, bp->b_data + fd->skip,
format ? bp->b_bcount : fdblk,
fdc->dmachan);
if (fdc->retry < 6)
fdc->retry = 6; /* force a reset */
- return retrier(fdcu);
+ return (retrier(fdc));
}
fdc->state = IOTIMEDOUT;
@@ -1869,8 +1932,7 @@ fdstate(fdcu_t fdcu, fdc_p fdc)
#endif
isa_dmadone(bp->b_flags, bp->b_data + fd->skip,
format ? bp->b_bcount : fdblk, fdc->dmachan);
- if (fdc->status[0] & NE7_ST0_IC)
- {
+ if (fdc->status[0] & NE7_ST0_IC) {
if ((fdc->status[0] & NE7_ST0_IC) == NE7_ST0_IC_AT
&& fdc->status[1] & NE7_ST1_OR) {
/*
@@ -1890,17 +1952,14 @@ fdstate(fdcu_t fdcu, fdc_p fdc)
&& fdc->status[2] & NE7_ST2_WC
&& fdc->retry < 3)
fdc->retry = 3; /* force recalibrate */
- return(retrier(fdcu));
+ return (retrier(fdc));
}
/* All OK */
fd->skip += fdblk;
- if (!format && fd->skip < bp->b_bcount - bp->b_resid)
- {
+ if (!format && fd->skip < bp->b_bcount - bp->b_resid) {
/* set up next transfer */
fdc->state = DOSEEK;
- }
- else
- {
+ } else {
/* ALL DONE */
fd->skip = 0;
fdc->bp = NULL;
@@ -1915,7 +1974,7 @@ fdstate(fdcu_t fdcu, fdc_p fdc)
fdc->fdu = -1;
fdc->state = FINDWORK;
}
- return(1);
+ return (1);
case RESETCTLR:
fdc_reset(fdc);
fdc->retry++;
@@ -1931,21 +1990,18 @@ fdstate(fdcu_t fdcu, fdc_p fdc)
fdc->state = STARTRECAL;
/* Fall through. */
case STARTRECAL:
- if(fd_cmd(fdcu,
- 2, NE7CMD_RECAL, fdu,
- 0)) /* Recalibrate Function */
- {
+ if(fd_cmd(fdc, 2, NE7CMD_RECAL, fdu, 0)) {
/* arrgl */
fdc->retry = 6;
- return(retrier(fdcu));
+ return (retrier(fdc));
}
fdc->state = RECALWAIT;
- return(0); /* will return later */
+ return (0); /* will return later */
case RECALWAIT:
/* allow heads to settle */
- timeout(fd_pseudointr, (caddr_t)fdcu, hz / 8);
+ timeout(fd_pseudointr, fdc, hz / 8);
fdc->state = RECALCOMPLETE;
- return(0); /* will return later */
+ return (0); /* will return later */
case RECALCOMPLETE:
do {
/*
@@ -1971,16 +2027,16 @@ fdstate(fdcu_t fdcu, fdc_p fdc)
printf("fd%d: recal failed ST0 %b cyl %d\n",
fdu, st0, NE7_ST0BITS, cyl);
if(fdc->retry < 3) fdc->retry = 3;
- return(retrier(fdcu));
+ return (retrier(fdc));
}
fd->track = 0;
/* Seek (probably) necessary */
fdc->state = DOSEEK;
- return(1); /* will return immediatly */
+ return (1); /* will return immediatly */
case MOTORWAIT:
if(fd->flags & FD_MOTOR_WAIT)
{
- return(0); /* time's not up yet */
+ return (0); /* time's not up yet */
}
if (fdc->flags & FDC_NEEDS_RESET) {
fdc->state = RESETCTLR;
@@ -1993,9 +2049,10 @@ fdstate(fdcu_t fdcu, fdc_p fdc)
*/
fdc->state = STARTRECAL;
}
- return(1); /* will return immediatly */
+ return (1); /* will return immediatly */
default:
- printf("fdc%d: Unexpected FD int->", fdcu);
+ device_print_prettyname(fdc->fdc_dev);
+ printf("unexpected FD int->");
if (fd_read_status(fdc, fd->fdsu) == 0)
printf("FDC status :%x %x %x %x %x %x %x ",
fdc->status[0],
@@ -2010,28 +2067,31 @@ fdstate(fdcu_t fdcu, fdc_p fdc)
if (fd_sense_int(fdc, &st0, &cyl) != 0)
{
printf("[controller is dead now]\n");
- return(0);
+ return (0);
}
printf("ST0 = %x, PCN = %x\n", st0, cyl);
- return(0);
+ return (0);
}
/*XXX confusing: some branches return immediately, others end up here*/
- return(1); /* Come back immediatly to new state */
+ return (1); /* Come back immediatly to new state */
}
static int
-retrier(fdcu)
- fdcu_t fdcu;
+retrier(struct fdc_data *fdc)
{
- fdc_p fdc = fdc_data + fdcu;
register struct buf *bp;
+ struct fd_data *fd;
+ int fdu;
bp = fdc->bp;
- if(fd_data[FDUNIT(minor(bp->b_dev))].options & FDOPT_NORETRY)
+ /* XXX shouldn't this be cached somewhere? */
+ fdu = FDUNIT(minor(bp->b_dev));
+ fd = devclass_get_softc(fd_devclass, fdu);
+ if (fd->options & FDOPT_NORETRY)
goto fail;
- switch(fdc->retry)
- {
+
+ switch (fdc->retry) {
case 0: case 1: case 2:
fdc->state = SEEKCOMPLETE;
break;
@@ -2084,10 +2144,10 @@ retrier(fdcu)
fdc->flags |= FDC_NEEDS_RESET;
fdc->fd = (fd_p) 0;
fdc->fdu = -1;
- return(1);
+ return (1);
}
fdc->retry++;
- return(1);
+ return (1);
}
static int
@@ -2104,7 +2164,7 @@ fdformat(dev, finfo, p)
size_t fdblk;
fdu = FDUNIT(minor(dev));
- fd = &fd_data[fdu];
+ fd = devclass_get_softc(fd_devclass, fdu);
fdblk = 128 << fd->ft->secsize;
/* set up a buffer header for fdstrategy() */
@@ -2135,20 +2195,19 @@ fdformat(dev, finfo, p)
/* ...and wait for it to complete */
s = splbio();
- while(!(bp->b_flags & B_DONE))
- {
+ while(!(bp->b_flags & B_DONE)) {
rv = tsleep((caddr_t)bp, PRIBIO, "fdform", 20 * hz);
- if(rv == EWOULDBLOCK)
+ if (rv == EWOULDBLOCK)
break;
}
splx(s);
- if(rv == EWOULDBLOCK) {
+ if (rv == EWOULDBLOCK) {
/* timed out */
rv = EIO;
biodone(bp);
}
- if(bp->b_flags & B_ERROR)
+ if (bp->b_flags & B_ERROR)
rv = bp->b_error;
/*
* allow the process to be swapped
@@ -2171,7 +2230,7 @@ fdioctl(dev, cmd, addr, flag, p)
struct proc *p;
{
fdu_t fdu = FDUNIT(minor(dev));
- fd_p fd = &fd_data[fdu];
+ fd_p fd = devclass_get_softc(fd_devclass, fdu);
size_t fdblk;
struct fd_type *fdt;
@@ -2181,13 +2240,12 @@ fdioctl(dev, cmd, addr, flag, p)
fdblk = 128 << fd->ft->secsize;
- switch (cmd)
- {
+ switch (cmd) {
case DIOCGDINFO:
bzero(buffer, sizeof (buffer));
dl = (struct disklabel *)buffer;
dl->d_secsize = fdblk;
- fdt = fd_data[FDUNIT(minor(dev))].ft;
+ fdt = fd->ft;
dl->d_secpercyl = fdt->size / fdt->tracks;
dl->d_type = DTYPE_FLOPPY;
@@ -2211,8 +2269,7 @@ fdioctl(dev, cmd, addr, flag, p)
break;
case DIOCWDINFO:
- if ((flag & FWRITE) == 0)
- {
+ if ((flag & FWRITE) == 0) {
error = EBADF;
break;
}
@@ -2227,9 +2284,9 @@ fdioctl(dev, cmd, addr, flag, p)
(struct disklabel *)buffer);
break;
case FD_FORM:
- if((flag & FWRITE) == 0)
+ if ((flag & FWRITE) == 0)
error = EBADF; /* must be opened for writing */
- else if(((struct fd_formb *)addr)->format_version !=
+ else if (((struct fd_formb *)addr)->format_version !=
FD_FORMAT_VERSION)
error = EINVAL; /* wrong version of formatting prog */
else
@@ -2242,7 +2299,7 @@ fdioctl(dev, cmd, addr, flag, p)
case FD_STYPE: /* set drive type */
/* this is considered harmful; only allow for superuser */
- if(suser(p->p_ucred, &p->p_acflag) != 0)
+ if (suser(p->p_ucred, &p->p_acflag) != 0)
return EPERM;
*fd->ft = *(struct fd_type *)addr;
break;
@@ -2262,22 +2319,62 @@ fdioctl(dev, cmd, addr, flag, p)
return (error);
}
+static device_method_t fdc_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, fdc_probe),
+ DEVMETHOD(device_attach, fdc_attach),
+ DEVMETHOD(device_detach, bus_generic_detach),
+ DEVMETHOD(device_shutdown, bus_generic_shutdown),
+ DEVMETHOD(device_suspend, bus_generic_suspend),
+ DEVMETHOD(device_resume, bus_generic_resume),
-static fd_devsw_installed = 0;
+ /* Bus interface */
+ DEVMETHOD(bus_print_child, fdc_print_child),
+ /* Our children never use any other bus interface methods. */
-static void fd_drvinit(void *notused )
-{
+ { 0, 0 }
+};
- if( ! fd_devsw_installed ) {
- cdevsw_add_generic(BDEV_MAJOR,CDEV_MAJOR, &fd_cdevsw);
- fd_devsw_installed = 1;
- }
-}
+static driver_t fdc_driver = {
+ "fdc",
+ fdc_methods,
+ DRIVER_TYPE_BIO,
+ sizeof(struct fdc_data)
+};
-SYSINIT(fddev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,fd_drvinit,NULL)
+DRIVER_MODULE(fdc, isa, fdc_driver, fdc_devclass, 0, 0);
+static device_method_t fd_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, fd_probe),
+ DEVMETHOD(device_attach, fd_attach),
+ DEVMETHOD(device_detach, bus_generic_detach),
+ DEVMETHOD(device_shutdown, bus_generic_shutdown),
+ DEVMETHOD(device_suspend, bus_generic_suspend), /* XXX */
+ DEVMETHOD(device_resume, bus_generic_resume), /* XXX */
-#endif
+ { 0, 0 }
+};
+
+static driver_t fd_driver = {
+ "fd",
+ fd_methods,
+ DRIVER_TYPE_BIO,
+ sizeof(struct fd_data)
+};
+
+static struct cdevsw fd_cdevsw = {
+ Fdopen, fdclose, fdread, fdwrite,
+ fdioctl, nostop, nullreset, nodevtotty,
+ seltrue, nommap, fdstrategy, "fd",
+ NULL, -1, nodump, nopsize,
+ D_DISK, 0, -1
+};
+
+BDEV_DRIVER_MODULE(fd, fdc, fd_driver, fd_devclass, BDEV_MAJOR, CDEV_MAJOR,
+ fd_cdevsw, 0, 0);
+
+#endif /* NFDC > 0 */
/*
* Hello emacs, these are the
diff --git a/sys/i386/isa/fdc.h b/sys/i386/isa/fdc.h
index 43bf9f8..83e291f 100644
--- a/sys/i386/isa/fdc.h
+++ b/sys/i386/isa/fdc.h
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* from: @(#)fd.c 7.4 (Berkeley) 5/25/91
- * $Id: fdc.h,v 1.12 1998/12/12 08:16:01 imp Exp $
+ * $Id: fdc.h,v 1.13 1999/01/15 09:15:27 bde Exp $
*
*/
@@ -70,6 +70,10 @@ struct fdc_data
int fdc_errs; /* number of logged errors */
struct buf_queue_head head;
struct buf *bp; /* active buffer */
+ struct resource *res_ioport, *res_irq, *res_drq;
+ int rid_ioport, rid_irq, rid_drq;
+ void *fdc_intr;
+ struct device *fdc_dev;
};
/***********************************************************************\
diff --git a/sys/i386/isa/if_cs.c b/sys/i386/isa/if_cs.c
index 4a9c390..f96f024 100644
--- a/sys/i386/isa/if_cs.c
+++ b/sys/i386/isa/if_cs.c
@@ -27,7 +27,7 @@
*/
/*
- * $Id: if_cs.c,v 1.8 1999/01/12 00:27:43 eivind Exp $
+ * $Id: if_cs.c,v 1.9 1999/01/28 01:59:53 dillon Exp $
*
* Device driver for Crystal Semiconductor CS8920 based ethernet
* adapters. By Maxim Bolotin and Oleg Sharoiko, 27-April-1997
@@ -1352,7 +1352,6 @@ cs_pnp_attach(u_long csn, u_long vend_id, char *name,
int iobase, unit, flags;
u_int irq;
int drq;
- struct isa_device *dvp;
struct cs_softc *sc = malloc(sizeof *sc, M_DEVBUF, M_NOWAIT);
if (read_pnp_parms ( &d , ldn ) == 0 ) {
@@ -1373,9 +1372,7 @@ cs_pnp_attach(u_long csn, u_long vend_id, char *name,
if (dev->id_driver == NULL) {
dev->id_driver = &csdriver;
- dvp = find_isadev(isa_devtab_net, &csdriver, 0);
- if (dvp != NULL)
- dev->id_id = dvp->id_id;
+ dev->id_id = isa_compat_nextid();
}
if (!sc) return;
diff --git a/sys/i386/isa/if_ed.c b/sys/i386/isa/if_ed.c
index 1408b2b..29bb9d1 100644
--- a/sys/i386/isa/if_ed.c
+++ b/sys/i386/isa/if_ed.c
@@ -24,7 +24,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: if_ed.c,v 1.149 1999/01/28 01:59:53 dillon Exp $
+ * $Id: if_ed.c,v 1.150 1999/03/17 16:44:51 luigi Exp $
*/
/*
@@ -3488,7 +3488,6 @@ static void
edpnp_attach(u_long csn, u_long vend_id, char *name, struct isa_device *dev)
{
struct pnp_cinfo d;
- struct isa_device *dvp;
if (dev->id_unit >= NEDTOT)
return;
@@ -3509,9 +3508,7 @@ edpnp_attach(u_long csn, u_long vend_id, char *name, struct isa_device *dev)
if (dev->id_driver == NULL) {
dev->id_driver = &eddriver;
- dvp = find_isadev(isa_devtab_net, &eddriver, 0);
- if (dvp != NULL)
- dev->id_id = dvp->id_id;
+ dev->id_id = isa_compat_nextid();
}
if ((dev->id_alive = ed_probe(dev)) != 0)
diff --git a/sys/i386/isa/intr_machdep.c b/sys/i386/isa/intr_machdep.c
index 944eb4e..4f7c1e9 100644
--- a/sys/i386/isa/intr_machdep.c
+++ b/sys/i386/isa/intr_machdep.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)isa.c 7.2 (Berkeley) 5/13/91
- * $Id: intr_machdep.c,v 1.16 1999/01/08 19:17:48 bde Exp $
+ * $Id: intr_machdep.c,v 1.17 1999/04/14 14:26:36 bde Exp $
*/
#include "opt_auto_eoi.h"
@@ -328,6 +328,7 @@ isa_get_nameunit(int id)
return ("clk0"); /* XXX may also be sloppy driver */
if (id == 1)
return ("rtc0");
+#if 0
for (dp = isa_devtab_bio; dp->id_driver != NULL; dp++)
if (dp->id_id == id)
goto found_device;
@@ -343,6 +344,7 @@ isa_get_nameunit(int id)
for (dp = isa_devtab_tty; dp->id_driver != NULL; dp++)
if (dp->id_id == id)
goto found_device;
+#endif
return "???";
found_device:
diff --git a/sys/i386/isa/isa.c b/sys/i386/isa/isa.c
index 1e91da8..4b48e36 100644
--- a/sys/i386/isa/isa.c
+++ b/sys/i386/isa/isa.c
@@ -1,10 +1,7 @@
/*-
- * Copyright (c) 1991 The Regents of the University of California.
+ * Copyright (c) 1998 Doug Rabson
* All rights reserved.
*
- * This code is derived from software contributed to Berkeley by
- * William Jolitz.
- *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -13,18 +10,11 @@
* 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.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
*
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * 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 REGENTS OR CONTRIBUTORS BE LIABLE
+ * 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)
@@ -33,1041 +23,601 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * from: @(#)isa.c 7.2 (Berkeley) 5/13/91
- * $Id: isa.c,v 1.117 1998/11/29 15:42:40 phk Exp $
+ * $Id: isa.c,v 1.4 1998/09/16 08:23:51 dfr Exp $
*/
/*
- * code to manage AT bus
+ * Modifications for Intel architecture by Garrett A. Wollman.
+ * Copyright 1998 Massachusetts Institute of Technology
*
- * 92/08/18 Frank P. MacLachlan (fpm@crash.cts.com):
- * Fixed uninitialized variable problem and added code to deal
- * with DMA page boundaries in isa_dmarangecheck(). Fixed word
- * mode DMA count compution and reorganized DMA setup code in
- * isa_dmastart()
+ * Permission to use, copy, modify, and distribute this software and
+ * its documentation for any purpose and without fee is hereby
+ * granted, provided that both the above copyright notice and this
+ * permission notice appear in all copies, that both the above
+ * copyright notice and this permission notice appear in all
+ * supporting documentation, and that the name of M.I.T. not be used
+ * in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. M.I.T. makes
+ * no representations about the suitability of this software for any
+ * purpose. It is provided "as is" without express or implied
+ * warranty.
+ *
+ * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
+ * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
+ * SHALL M.I.T. 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.
*/
#include <sys/param.h>
#include <sys/systm.h>
-#include <sys/buf.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
#include <sys/malloc.h>
-#include <machine/ipl.h>
-#include <machine/md_var.h>
-#ifdef APIC_IO
-#include <machine/smp.h>
-#endif /* APIC_IO */
-#include <vm/vm.h>
-#include <vm/vm_param.h>
-#include <vm/pmap.h>
-#include <i386/isa/isa_device.h>
-#include <i386/isa/intr_machdep.h>
-#include <i386/isa/isa.h>
-#include <i386/isa/ic/i8237.h>
-
-#include <sys/interrupt.h>
-
-#include "pnp.h"
-#if NPNP > 0
-#include <i386/isa/pnp.h>
-#endif
+#include <sys/module.h>
+#include <machine/bus.h>
+#include <sys/rman.h>
-/*
-** Register definitions for DMA controller 1 (channels 0..3):
-*/
-#define DMA1_CHN(c) (IO_DMA1 + 1*(2*(c))) /* addr reg for channel c */
-#define DMA1_SMSK (IO_DMA1 + 1*10) /* single mask register */
-#define DMA1_MODE (IO_DMA1 + 1*11) /* mode register */
-#define DMA1_FFC (IO_DMA1 + 1*12) /* clear first/last FF */
+#include <machine/resource.h>
-/*
-** Register definitions for DMA controller 2 (channels 4..7):
-*/
-#define DMA2_CHN(c) (IO_DMA2 + 2*(2*(c))) /* addr reg for channel c */
-#define DMA2_SMSK (IO_DMA2 + 2*10) /* single mask register */
-#define DMA2_MODE (IO_DMA2 + 2*11) /* mode register */
-#define DMA2_FFC (IO_DMA2 + 2*12) /* clear first/last FF */
+#include <isa/isavar.h>
-static void config_isadev __P((struct isa_device *isdp, u_int *mp));
-static void config_isadev_c __P((struct isa_device *isdp, u_int *mp,
- int reconfig));
-static void conflict __P((struct isa_device *dvp, struct isa_device *tmpdvp,
- int item, char const *whatnot, char const *reason,
- char const *format));
-static int haveseen __P((struct isa_device *dvp, struct isa_device *tmpdvp,
- u_int checkbits));
-static int isa_dmarangecheck __P((caddr_t va, u_int length, int chan));
+MALLOC_DEFINE(M_ISADEV, "isadev", "ISA device");
/*
- * print a conflict message
+ * The structure used to attach devices to the isa bus.
*/
+struct isa_device {
+ short id_port[ISA_NPORT_IVARS];
+ u_short id_portsize[ISA_NPORT_IVARS];
+ vm_offset_t id_maddr[ISA_NMEM_IVARS];
+ vm_size_t id_msize[ISA_NMEM_IVARS];
+ int id_irq[ISA_NIRQ_IVARS];
+ int id_drq[ISA_NDRQ_IVARS];
+ int id_flags;
+ struct resource *id_portres[ISA_NPORT_IVARS];
+ struct resource *id_memres[ISA_NMEM_IVARS];
+ struct resource *id_irqres[ISA_NIRQ_IVARS];
+ struct resource *id_drqres[ISA_NDRQ_IVARS];
+};
+
+#define DEVTOISA(dev) ((struct isa_device *) device_get_ivars(dev))
+
+static devclass_t isa_devclass;
+
static void
-conflict(dvp, tmpdvp, item, whatnot, reason, format)
- struct isa_device *dvp;
- struct isa_device *tmpdvp;
- int item;
- char const *whatnot;
- char const *reason;
- char const *format;
+isa_add_device(device_t dev, const char *name, int unit)
{
- printf("%s%d not %sed due to %s conflict with %s%d at ",
- dvp->id_driver->name, dvp->id_unit, whatnot, reason,
- tmpdvp->id_driver->name, tmpdvp->id_unit);
- printf(format, item);
- printf("\n");
-}
+ struct isa_device *idev;
+ device_t child;
+ int sensitive, t;
+ static device_t last_sensitive;
-/*
- * Check to see if things are already in use, like IRQ's, I/O addresses
- * and Memory addresses.
- */
-static int
-haveseen(dvp, tmpdvp, checkbits)
- struct isa_device *dvp;
- struct isa_device *tmpdvp;
- u_int checkbits;
-{
- /*
- * Ignore all conflicts except IRQ ones if conflicts are allowed.
- */
- if (dvp->id_conflicts)
- checkbits &= ~(CC_DRQ | CC_IOADDR | CC_MEMADDR);
- /*
- * Only check against devices that have already been found.
- */
- if (tmpdvp->id_alive) {
- char const *whatnot;
+ if (resource_int_value(name, unit, "sensitive", &sensitive) != 0)
+ sensitive = 0;
- /*
- * Check for device driver & unit conflict; just drop probing
- * a device which has already probed true. This is usually
- * not strictly a conflict, but rather the case of somebody
- * having specified several mutually exclusive configurations
- * for a single device.
- */
- if (tmpdvp->id_driver == dvp->id_driver &&
- tmpdvp->id_unit == dvp->id_unit) {
- return 1;
- }
+ idev = malloc(sizeof(struct isa_device), M_ISADEV, M_NOWAIT);
+ if (!idev)
+ return;
+ bzero(idev, sizeof *idev);
- whatnot = checkbits & CC_ATTACH ? "attach" : "prob";
- /*
- * Check for I/O address conflict. We can only check the
- * starting address of the device against the range of the
- * device that has already been probed since we do not
- * know how many I/O addresses this device uses.
- */
- if (checkbits & CC_IOADDR && tmpdvp->id_alive != -1) {
- if ((dvp->id_iobase >= tmpdvp->id_iobase) &&
- (dvp->id_iobase <=
- (tmpdvp->id_iobase + tmpdvp->id_alive - 1))) {
- if (!(checkbits & CC_QUIET))
- conflict(dvp, tmpdvp, dvp->id_iobase,
- whatnot, "I/O address", "0x%x");
- return 1;
- }
- }
- /*
- * Check for Memory address conflict. We can check for
- * range overlap, but it will not catch all cases since the
- * driver may adjust the msize paramater during probe, for
- * now we just check that the starting address does not
- * fall within any allocated region.
- * XXX could add a second check after the probe for overlap,
- * since at that time we would know the full range.
- * XXX KERNBASE is a hack, we should have vaddr in the table!
- */
- if (checkbits & CC_MEMADDR && tmpdvp->id_maddr) {
- if ((KERNBASE + dvp->id_maddr >= tmpdvp->id_maddr) &&
- (KERNBASE + dvp->id_maddr <=
- (tmpdvp->id_maddr + tmpdvp->id_msize - 1))) {
- if (!(checkbits & CC_QUIET))
- conflict(dvp, tmpdvp,
- (int)dvp->id_maddr, whatnot,
- "maddr", "0x%x");
- return 1;
- }
- }
- /*
- * Check for IRQ conflicts.
- */
- if (checkbits & CC_IRQ && tmpdvp->id_irq) {
- if (tmpdvp->id_irq == dvp->id_irq) {
- if (!(checkbits & CC_QUIET))
- conflict(dvp, tmpdvp,
- ffs(dvp->id_irq) - 1, whatnot,
- "irq", "%d");
- return 1;
- }
- }
- /*
- * Check for DRQ conflicts.
- */
- if (checkbits & CC_DRQ && tmpdvp->id_drq != -1) {
- if (tmpdvp->id_drq == dvp->id_drq) {
- if (!(checkbits & CC_QUIET))
- conflict(dvp, tmpdvp, dvp->id_drq,
- whatnot, "drq", "%d");
- return 1;
- }
- }
- }
- return 0;
-}
+ if (resource_int_value(name, unit, "port", &t) == 0)
+ idev->id_port[0] = t;
+ else
+ idev->id_port[0] = -1;
+ idev->id_port[1] = 0;
-#ifdef RESOURCE_CHECK
-#include <sys/drvresource.h>
+ if (resource_int_value(name, unit, "portsize", &t) == 0)
+ idev->id_portsize[0] = t;
+ else
+ idev->id_portsize[0] = 0;
+ idev->id_portsize[1] = 0;
-static int
-checkone (struct isa_device *dvp, int type, addr_t low, addr_t high,
- char *resname, char *resfmt, int attaching)
-{
- int result = 0;
- if (bootverbose) {
- if (low == high)
- printf("\tcheck %s: 0x%x\n", resname, low);
- else
- printf("\tcheck %s: 0x%x to 0x%x\n",
- resname, low, high);
- }
- if (resource_check(type, RESF_NONE, low, high) != NULL) {
- char *whatnot = attaching ? "attach" : "prob";
- static struct isa_device dummydev;
- static struct isa_driver dummydrv;
- struct isa_device *tmpdvp = &dummydev;
+ if (resource_int_value(name, unit, "maddr", &t) == 0)
+ idev->id_maddr[0] = t;
+ else
+ idev->id_maddr[0] = 0;
+ idev->id_maddr[1] = 0;
- dummydev.id_driver = &dummydrv;
- dummydev.id_unit = 0;
- dummydrv.name = "pci";
- conflict(dvp, tmpdvp, low, whatnot, resname, resfmt);
- result = 1;
- } else if (attaching) {
- if (low == high)
- printf("\tregister %s: 0x%x\n", resname, low);
- else
- printf("\tregister %s: 0x%x to 0x%x\n",
- resname, low, high);
- resource_claim(dvp, type, RESF_NONE, low, high);
- }
- return (result);
-}
+ if (resource_int_value(name, unit, "msize", &t) == 0)
+ idev->id_msize[0] = t;
+ else
+ idev->id_msize[0] = 0;
+ idev->id_msize[1] = 0;
-static int
-check_pciconflict(struct isa_device *dvp, int checkbits)
-{
- int result = 0;
- int attaching = (checkbits & CC_ATTACH) != 0;
+ if (resource_int_value(name, unit, "flags", &t) == 0)
+ idev->id_flags = t;
+ else
+ idev->id_flags = 0;
- if (checkbits & CC_MEMADDR) {
- long maddr = dvp->id_maddr;
- long msize = dvp->id_msize;
- if (msize > 0) {
- if (checkone(dvp, REST_MEM, maddr, maddr + msize - 1,
- "maddr", "0x%x", attaching) != 0) {
- result = 1;
- attaching = 0;
- }
- }
- }
- if (checkbits & CC_IOADDR) {
- unsigned iobase = dvp->id_iobase;
- unsigned iosize = dvp->id_alive;
- if (iosize == -1)
- iosize = 1; /* XXX can't do much about this ... */
- if (iosize > 0) {
- if (checkone(dvp, REST_PORT, iobase, iobase + iosize -1,
- "I/O address", "0x%x", attaching) != 0) {
- result = 1;
- attaching = 0;
- }
- }
- }
- if (checkbits & CC_IRQ) {
- int irq = ffs(dvp->id_irq) - 1;
- if (irq >= 0) {
- if (checkone(dvp, REST_INT, irq, irq,
- "irq", "%d", attaching) != 0) {
- result = 1;
- attaching = 0;
- }
- }
- }
- if (checkbits & CC_DRQ) {
- int drq = dvp->id_drq;
- if (drq >= 0) {
- if (checkone(dvp, REST_DMA, drq, drq,
- "drq", "%d", attaching) != 0) {
- result = 1;
- attaching = 0;
- }
- }
- }
- if (result != 0)
- resource_free (dvp);
- return (result);
-}
-#endif /* RESOURCE_CHECK */
+ if (resource_int_value(name, unit, "irq", &t) == 0)
+ idev->id_irq[0] = t;
+ else
+ idev->id_irq[0] = -1;
+ idev->id_irq[1] = -1;
-/*
- * Search through all the isa_devtab_* tables looking for anything that
- * conflicts with the current device.
- */
-int
-haveseen_isadev(dvp, checkbits)
- struct isa_device *dvp;
- u_int checkbits;
-{
-#if NPNP > 0
- struct pnp_dlist_node *nod;
-#endif
- struct isa_device *tmpdvp;
- int status = 0;
+ if (resource_int_value(name, unit, "drq", &t) == 0)
+ idev->id_drq[0] = t;
+ else
+ idev->id_drq[0] = -1;
+ idev->id_drq[1] = -1;
- for (tmpdvp = isa_devtab_tty; tmpdvp->id_driver; tmpdvp++) {
- status |= haveseen(dvp, tmpdvp, checkbits);
- if (status)
- return status;
- }
- for (tmpdvp = isa_devtab_bio; tmpdvp->id_driver; tmpdvp++) {
- status |= haveseen(dvp, tmpdvp, checkbits);
- if (status)
- return status;
- }
- for (tmpdvp = isa_devtab_net; tmpdvp->id_driver; tmpdvp++) {
- status |= haveseen(dvp, tmpdvp, checkbits);
- if (status)
- return status;
- }
- for (tmpdvp = isa_devtab_cam; tmpdvp->id_driver; tmpdvp++) {
- status |= haveseen(dvp, tmpdvp, checkbits);
- if (status)
- return status;
- }
- for (tmpdvp = isa_devtab_null; tmpdvp->id_driver; tmpdvp++) {
- status |= haveseen(dvp, tmpdvp, checkbits);
- if (status)
- return status;
- }
-#if NPNP > 0
- for (nod = pnp_device_list; nod != NULL; nod = nod->next)
- if (status |= haveseen(dvp, &(nod->dev), checkbits))
- return status;
-#endif
-#ifdef RESOURCE_CHECK
- if (!dvp->id_conflicts)
- status = check_pciconflict(dvp, checkbits);
- else if (bootverbose)
- printf("\tnot checking for resource conflicts ...\n");
-#endif /* RESOURCE_CHECK */
- return(status);
+ if (sensitive)
+ child = device_add_child_after(dev, last_sensitive, name,
+ unit, idev);
+ else
+ child = device_add_child(dev, name, unit, idev);
+ if (child == 0)
+ return;
+ else if (sensitive)
+ last_sensitive = child;
+
+ if (resource_int_value(name, unit, "disabled", &t) == 0 && t != 0)
+ device_disable(child);
}
/*
- * Configure all ISA devices
+ * At 'probe' time, we add all the devices which we know about to the
+ * bus. The generic attach routine will probe and attach them if they
+ * are alive.
*/
-void
-isa_configure()
+static int
+isa_probe(device_t dev)
{
- struct isa_device *dvp;
+ int i;
+ static char buf[] = "isaXXX";
- printf("Probing for devices on the ISA bus:\n");
- /* First probe all the sensitive probes */
- for (dvp = isa_devtab_tty; dvp->id_driver; dvp++)
- if (dvp->id_driver->sensitive_hw)
- config_isadev(dvp, &tty_imask);
- for (dvp = isa_devtab_bio; dvp->id_driver; dvp++)
- if (dvp->id_driver->sensitive_hw)
- config_isadev(dvp, &bio_imask);
- for (dvp = isa_devtab_net; dvp->id_driver; dvp++)
- if (dvp->id_driver->sensitive_hw)
- config_isadev(dvp, &net_imask);
- for (dvp = isa_devtab_cam; dvp->id_driver; dvp++)
- if (dvp->id_driver->sensitive_hw)
- config_isadev(dvp, &cam_imask);
- for (dvp = isa_devtab_null; dvp->id_driver; dvp++)
- if (dvp->id_driver->sensitive_hw)
- config_isadev(dvp, (u_int *)NULL);
-
- /* Then all the bad ones */
- for (dvp = isa_devtab_tty; dvp->id_driver; dvp++)
- if (!dvp->id_driver->sensitive_hw)
- config_isadev(dvp, &tty_imask);
- for (dvp = isa_devtab_bio; dvp->id_driver; dvp++)
- if (!dvp->id_driver->sensitive_hw)
- config_isadev(dvp, &bio_imask);
- for (dvp = isa_devtab_net; dvp->id_driver; dvp++)
- if (!dvp->id_driver->sensitive_hw)
- config_isadev(dvp, &net_imask);
- for (dvp = isa_devtab_cam; dvp->id_driver; dvp++)
- if (!dvp->id_driver->sensitive_hw)
- config_isadev(dvp, &cam_imask);
- for (dvp = isa_devtab_null; dvp->id_driver; dvp++)
- if (!dvp->id_driver->sensitive_hw)
- config_isadev(dvp, (u_int *)NULL);
-
-/*
- * XXX we should really add the tty device to net_imask when the line is
- * switched to SLIPDISC, and then remove it when it is switched away from
- * SLIPDISC. No need to block out ALL ttys during a splimp when only one
- * of them is running slip.
- *
- * XXX actually, blocking all ttys during a splimp doesn't matter so much
- * with sio because the serial interrupt layer doesn't use tty_imask. Only
- * non-serial ttys suffer. It's more stupid that ALL 'net's are blocked
- * during spltty.
- */
-#include "sl.h"
-#if NSL > 0
- net_imask |= tty_imask;
- tty_imask = net_imask;
-#endif
-
- if (bootverbose)
- printf("imasks: bio %x, tty %x, net %x\n",
- bio_imask, tty_imask, net_imask);
+ device_set_desc(dev, "ISA bus");
/*
- * Finish initializing intr_mask[]. Note that the partly
- * constructed masks aren't actually used since we're at splhigh.
- * For fully dynamic initialization, register_intr() and
- * icu_unset() will have to adjust the masks for _all_
- * interrupts and for tty_imask, etc.
+ * Add all devices configured to be attached to isa0.
*/
- for (dvp = isa_devtab_tty; dvp->id_driver; dvp++)
- register_imask(dvp, tty_imask);
- for (dvp = isa_devtab_bio; dvp->id_driver; dvp++)
- register_imask(dvp, bio_imask);
- for (dvp = isa_devtab_net; dvp->id_driver; dvp++)
- register_imask(dvp, net_imask);
- for (dvp = isa_devtab_cam; dvp->id_driver; dvp++)
- register_imask(dvp, cam_imask);
- for (dvp = isa_devtab_null; dvp->id_driver; dvp++)
- register_imask(dvp, SWI_CLOCK_MASK);
-}
-
-/*
- * Configure an ISA device.
- */
-static void
-config_isadev(isdp, mp)
- struct isa_device *isdp;
- u_int *mp;
-{
- config_isadev_c(isdp, mp, 0);
-}
-
-void
-reconfig_isadev(isdp, mp)
- struct isa_device *isdp;
- u_int *mp;
-{
- config_isadev_c(isdp, mp, 1);
-}
-
-static void
-config_isadev_c(isdp, mp, reconfig)
- struct isa_device *isdp;
- u_int *mp;
- int reconfig;
-{
- u_int checkbits;
- int id_alive;
- int last_alive;
- struct isa_driver *dp = isdp->id_driver;
-
- if (!isdp->id_enabled) {
- if (bootverbose)
- printf("%s%d: disabled, not probed.\n", dp->name, isdp->id_unit);
- return;
+ sprintf(buf, "isa%d", device_get_unit(dev));
+ for (i = resource_query_string(-1, "at", buf);
+ i != -1;
+ i = resource_query_string(i, "at", buf)) {
+ isa_add_device(dev, resource_query_name(i),
+ resource_query_unit(i));
}
- checkbits = CC_DRQ | CC_IOADDR | CC_MEMADDR;
- if (!reconfig && haveseen_isadev(isdp, checkbits))
- return;
- if (!reconfig && isdp->id_maddr) {
- isdp->id_maddr -= ISA_HOLE_START;
- isdp->id_maddr += atdevbase;
- }
- if (reconfig) {
- last_alive = isdp->id_alive;
- isdp->id_reconfig = 1;
- }
- else {
- last_alive = 0;
- isdp->id_reconfig = 0;
- }
- id_alive = (*dp->probe)(isdp);
- if (id_alive) {
- /*
- * Only print the I/O address range if id_alive != -1
- * Right now this is a temporary fix just for the new
- * NPX code so that if it finds a 486 that can use trap
- * 16 it will not report I/O addresses.
- * Rod Grimes 04/26/94
- */
- if (!isdp->id_reconfig) {
- printf("%s%d", dp->name, isdp->id_unit);
- if (id_alive != -1) {
- if (isdp->id_iobase == -1)
- printf(" at");
- else {
- printf(" at 0x%x", isdp->id_iobase);
- if (isdp->id_iobase + id_alive - 1 !=
- isdp->id_iobase) {
- printf("-0x%x",
- isdp->id_iobase + id_alive - 1);
- }
- }
- }
- if (isdp->id_irq)
- printf(" irq %d", ffs(isdp->id_irq) - 1);
- if (isdp->id_drq != -1)
- printf(" drq %d", isdp->id_drq);
- if (isdp->id_maddr)
- printf(" maddr 0x%lx", kvtop(isdp->id_maddr));
- if (isdp->id_msize)
- printf(" msize %d", isdp->id_msize);
- if (isdp->id_flags)
- printf(" flags 0x%x", isdp->id_flags);
- if (isdp->id_iobase && !(isdp->id_iobase & 0xf300)) {
- printf(" on motherboard");
- } else if (isdp->id_iobase >= 0x1000 &&
- !(isdp->id_iobase & 0x300)) {
- printf (" on eisa slot %d",
- isdp->id_iobase >> 12);
- } else {
- printf (" on isa");
- }
- printf("\n");
- /*
- * Check for conflicts again. The driver may have
- * changed *dvp. We should weaken the early check
- * since the driver may have been able to change
- * *dvp to avoid conflicts if given a chance. We
- * already skip the early check for IRQs and force
- * a check for IRQs in the next group of checks.
- */
- checkbits |= CC_ATTACH | CC_IRQ;
- if (haveseen_isadev(isdp, checkbits))
- return;
- isdp->id_alive = id_alive;
- }
- (*dp->attach)(isdp);
- if (isdp->id_irq != 0 && isdp->id_intr == NULL)
- printf("%s%d: irq with no handler\n",
- dp->name, isdp->id_unit);
- if (isdp->id_irq != 0 && isdp->id_intr != NULL) {
-#ifdef APIC_IO
- /*
- * Some motherboards use upper IRQs for traditional
- * ISA INTerrupt sources. In particular we have
- * seen the secondary IDE connected to IRQ20.
- * This code detects and fixes this situation.
- */
- u_int apic_mask;
- int rirq;
- apic_mask = isa_apic_mask(isdp->id_irq);
- if (apic_mask != isdp->id_irq) {
- rirq = ffs(isdp->id_irq) - 1;
- isdp->id_irq = apic_mask;
- undirect_isa_irq(rirq); /* free for ISA */
- }
-#endif /* APIC_IO */
- register_intr(ffs(isdp->id_irq) - 1, isdp->id_id,
- isdp->id_ri_flags, isdp->id_intr,
- mp, isdp->id_unit);
- }
- } else {
- if (isdp->id_reconfig) {
- (*dp->attach)(isdp); /* reconfiguration attach */
- }
- if (!last_alive) {
- if (!isdp->id_reconfig) {
- printf("%s%d not found",
- dp->name, isdp->id_unit);
- if (isdp->id_iobase != -1)
- printf(" at 0x%x", isdp->id_iobase);
- printf("\n");
- }
- } else {
-#if 0
- /* This code has not been tested.... */
- if (isdp->id_irq != 0 && isdp->id_intr != NULL) {
- icu_unset(ffs(isdp->id_irq) - 1,
- isdp->id_intr);
- if (mp)
- INTRUNMASK(*mp, isdp->id_irq);
- }
-#else
- printf ("icu_unset() not supported here ...\n");
-#endif
- }
+ /*
+ * and isa?
+ */
+ for (i = resource_query_string(-1, "at", "isa");
+ i != -1;
+ i = resource_query_string(i, "at", "isa")) {
+ isa_add_device(dev, resource_query_name(i),
+ resource_query_unit(i));
}
-}
-static caddr_t dma_bouncebuf[8];
-static u_int dma_bouncebufsize[8];
-static u_int8_t dma_bounced = 0;
-static u_int8_t dma_busy = 0; /* Used in isa_dmastart() */
-static u_int8_t dma_inuse = 0; /* User for acquire/release */
-static u_int8_t dma_auto_mode = 0;
+ isa_wrap_old_drivers();
-#define VALID_DMA_MASK (7)
+ return 0;
+}
-/* high byte of address is stored in this port for i-th dma channel */
-static int dmapageport[8] = { 0x87, 0x83, 0x81, 0x82, 0x8f, 0x8b, 0x89, 0x8a };
+extern device_t isa_bus_device;
-/*
- * Setup a DMA channel's bounce buffer.
- */
-void
-isa_dmainit(chan, bouncebufsize)
- int chan;
- u_int bouncebufsize;
+static int
+isa_attach(device_t dev)
{
- void *buf;
-
-#ifdef DIAGNOSTIC
- if (chan & ~VALID_DMA_MASK)
- panic("isa_dmainit: channel out of range");
-
- if (dma_bouncebuf[chan] != NULL)
- panic("isa_dmainit: impossible request");
-#endif
-
- dma_bouncebufsize[chan] = bouncebufsize;
-
- /* Try malloc() first. It works better if it works. */
- buf = malloc(bouncebufsize, M_DEVBUF, M_NOWAIT);
- if (buf != NULL) {
- if (isa_dmarangecheck(buf, bouncebufsize, chan) == 0) {
- dma_bouncebuf[chan] = buf;
- return;
- }
- free(buf, M_DEVBUF);
- }
- buf = contigmalloc(bouncebufsize, M_DEVBUF, M_NOWAIT, 0ul, 0xfffffful,
- 1ul, chan & 4 ? 0x20000ul : 0x10000ul);
- if (buf == NULL)
- printf("isa_dmainit(%d, %d) failed\n", chan, bouncebufsize);
- else
- dma_bouncebuf[chan] = buf;
+ /*
+ * Arrange for bus_generic_attach(dev) to be called later.
+ */
+ isa_bus_device = dev;
+ return 0;
}
-/*
- * Register a DMA channel's usage. Usually called from a device driver
- * in open() or during its initialization.
- */
-int
-isa_dma_acquire(chan)
- int chan;
+static void
+isa_print_child(device_t bus, device_t dev)
{
-#ifdef DIAGNOSTIC
- if (chan & ~VALID_DMA_MASK)
- panic("isa_dma_acquire: channel out of range");
-#endif
-
- if (dma_inuse & (1 << chan)) {
- printf("isa_dma_acquire: channel %d already in use\n", chan);
- return (EBUSY);
- }
- dma_inuse |= (1 << chan);
- dma_auto_mode &= ~(1 << chan);
-
- return (0);
+ struct isa_device *id = DEVTOISA(dev);
+
+ if (id->id_port[0] > 0 || id->id_port[1] > 0
+ || id->id_maddr[0] > 0 || id->id_maddr[1] > 0
+ || id->id_irq[0] >= 0 || id->id_irq[1] >= 0
+ || id->id_drq[0] >= 0 || id->id_drq[1] >= 0)
+ printf(" at");
+ if (id->id_port[0] > 0 && id->id_port[1] > 0) {
+ printf(" ports %#x", (u_int)id->id_port[0]);
+ if (id->id_portsize[0] > 1)
+ printf("-%#x", (u_int)(id->id_port[0]
+ + id->id_portsize[0] - 1));
+ printf(" and %#x", (u_int)id->id_port[1]);
+ if (id->id_portsize[1] > 1)
+ printf("-%#x", (u_int)(id->id_port[1]
+ + id->id_portsize[1] - 1));
+ } else if (id->id_port[0] > 0) {
+ printf(" port %#x", (u_int)id->id_port[0]);
+ if (id->id_portsize[0] > 1)
+ printf("-%#x", (u_int)(id->id_port[0]
+ + id->id_portsize[0] - 1));
+ } else if (id->id_port[1] > 0) {
+ printf(" port %#x", (u_int)id->id_port[1]);
+ if (id->id_portsize[1] > 1)
+ printf("-%#x", (u_int)(id->id_port[1]
+ + id->id_portsize[1] - 1));
+ }
+ if (id->id_maddr[0] && id->id_maddr[1]) {
+ printf(" iomem %#x", (u_int)id->id_maddr[0]);
+ if (id->id_msize[0])
+ printf("-%#x", (u_int)(id->id_maddr[0]
+ + id->id_msize[0] - 1));
+ printf(" and %#x", (u_int)id->id_maddr[1]);
+ if (id->id_msize[1])
+ printf("-%#x", (u_int)(id->id_maddr[1]
+ + id->id_msize[1] - 1));
+ } else if (id->id_maddr[0]) {
+ printf(" iomem %#x", (u_int)id->id_maddr[0]);
+ if (id->id_msize[0])
+ printf("-%#x", (u_int)(id->id_maddr[0]
+ + id->id_msize[0] - 1));
+ } else if (id->id_maddr[1]) {
+ printf(" iomem %#x", (u_int)id->id_maddr[1]);
+ if (id->id_msize[1])
+ printf("-%#x", (u_int)(id->id_maddr[1]
+ + id->id_msize[1] - 1));
+ }
+ if (id->id_irq[0] >= 0 && id->id_irq[1] >= 0)
+ printf(" irqs %d and %d", id->id_irq[0], id->id_irq[1]);
+ else if (id->id_irq[0] >= 0)
+ printf(" irq %d", id->id_irq[0]);
+ else if (id->id_irq[1] >= 0)
+ printf(" irq %d", id->id_irq[1]);
+ if (id->id_drq[0] >= 0 && id->id_drq[1] >= 0)
+ printf(" drqs %d and %d", id->id_drq[0], id->id_drq[1]);
+ else if (id->id_drq[0] >= 0)
+ printf(" drq %d", id->id_drq[0]);
+ else if (id->id_drq[1] >= 0)
+ printf(" drq %d", id->id_drq[1]);
+
+ if (id->id_flags)
+ printf(" flags %#x", id->id_flags);
+
+ printf(" on %s%d",
+ device_get_name(bus), device_get_unit(bus));
}
-/*
- * Unregister a DMA channel's usage. Usually called from a device driver
- * during close() or during its shutdown.
- */
-void
-isa_dma_release(chan)
- int chan;
+static int
+isa_read_ivar(device_t bus, device_t dev, int index, uintptr_t * result)
{
-#ifdef DIAGNOSTIC
- if (chan & ~VALID_DMA_MASK)
- panic("isa_dma_release: channel out of range");
-
- if ((dma_inuse & (1 << chan)) == 0)
- printf("isa_dma_release: channel %d not in use\n", chan);
-#endif
-
- if (dma_busy & (1 << chan)) {
- dma_busy &= ~(1 << chan);
- /*
- * XXX We should also do "dma_bounced &= (1 << chan);"
- * because we are acting on behalf of isa_dmadone() which
- * was not called to end the last DMA operation. This does
- * not matter now, but it may in the future.
- */
- }
-
- dma_inuse &= ~(1 << chan);
- dma_auto_mode &= ~(1 << chan);
+ struct isa_device* idev = DEVTOISA(dev);
+
+ switch (index) {
+ case ISA_IVAR_PORT_0:
+ *result = idev->id_port[0];
+ break;
+ case ISA_IVAR_PORT_1:
+ *result = idev->id_port[1];
+ break;
+ case ISA_IVAR_PORTSIZE_0:
+ *result = idev->id_portsize[0];
+ break;
+ case ISA_IVAR_PORTSIZE_1:
+ *result = idev->id_portsize[1];
+ break;
+ case ISA_IVAR_MADDR_0:
+ *result = idev->id_maddr[0];
+ break;
+ case ISA_IVAR_MADDR_1:
+ *result = idev->id_maddr[1];
+ break;
+ case ISA_IVAR_MSIZE_0:
+ *result = idev->id_msize[0];
+ break;
+ case ISA_IVAR_MSIZE_1:
+ *result = idev->id_msize[1];
+ break;
+ case ISA_IVAR_IRQ_0:
+ *result = idev->id_irq[0];
+ break;
+ case ISA_IVAR_IRQ_1:
+ *result = idev->id_irq[1];
+ break;
+ case ISA_IVAR_DRQ_0:
+ *result = idev->id_drq[0];
+ break;
+ case ISA_IVAR_DRQ_1:
+ *result = idev->id_drq[1];
+ break;
+ case ISA_IVAR_FLAGS:
+ *result = idev->id_flags;
+ break;
+ }
+ return ENOENT;
}
/*
- * isa_dmacascade(): program 8237 DMA controller channel to accept
- * external dma control by a board.
+ * XXX -- this interface is pretty much irrelevant in the presence of
+ * BUS_ALLOC_RESOURCE / BUS_RELEASE_RESOURCE (at least for the ivars which
+ * are defined at this point).
*/
-void
-isa_dmacascade(chan)
- int chan;
+static int
+isa_write_ivar(device_t bus, device_t dev,
+ int index, uintptr_t value)
{
-#ifdef DIAGNOSTIC
- if (chan & ~VALID_DMA_MASK)
- panic("isa_dmacascade: channel out of range");
-#endif
-
- /* set dma channel mode, and set dma channel mode */
- if ((chan & 4) == 0) {
- outb(DMA1_MODE, DMA37MD_CASCADE | chan);
- outb(DMA1_SMSK, chan);
- } else {
- outb(DMA2_MODE, DMA37MD_CASCADE | (chan & 3));
- outb(DMA2_SMSK, chan & 3);
+ struct isa_device* idev = DEVTOISA(dev);
+
+ switch (index) {
+ case ISA_IVAR_PORT_0:
+ idev->id_port[0] = value;
+ break;
+ case ISA_IVAR_PORT_1:
+ idev->id_port[1] = value;
+ break;
+ case ISA_IVAR_PORTSIZE_0:
+ idev->id_portsize[0] = value;
+ break;
+ case ISA_IVAR_PORTSIZE_1:
+ idev->id_portsize[1] = value;
+ break;
+ case ISA_IVAR_MADDR_0:
+ idev->id_maddr[0] = value;
+ break;
+ case ISA_IVAR_MADDR_1:
+ idev->id_maddr[1] = value;
+ break;
+ case ISA_IVAR_MSIZE_0:
+ idev->id_msize[0] = value;
+ break;
+ case ISA_IVAR_MSIZE_1:
+ idev->id_msize[1] = value;
+ break;
+ case ISA_IVAR_IRQ_0:
+ idev->id_irq[0] = value;
+ break;
+ case ISA_IVAR_IRQ_1:
+ idev->id_irq[1] = value;
+ break;
+ case ISA_IVAR_DRQ_0:
+ idev->id_drq[0] = value;
+ break;
+ case ISA_IVAR_DRQ_1:
+ idev->id_drq[1] = value;
+ break;
+ case ISA_IVAR_FLAGS:
+ idev->id_flags = value;
+ break;
+ default:
+ return (ENOENT);
}
+ return (0);
}
/*
- * isa_dmastart(): program 8237 DMA controller channel, avoid page alignment
- * problems by using a bounce buffer.
+ * This implementation simply passes the request up to the parent
+ * bus, which in our case is the special i386 nexus, substituting any
+ * configured values if the caller defaulted. We can get away with
+ * this because there is no special mapping for ISA resources on an Intel
+ * platform. When porting this code to another architecture, it may be
+ * necessary to interpose a mapping layer here.
*/
-void
-isa_dmastart(int flags, caddr_t addr, u_int nbytes, int chan)
+static struct resource *
+isa_alloc_resource(device_t bus, device_t child, int type, int *rid,
+ u_long start, u_long end, u_long count, u_int flags)
{
- vm_offset_t phys;
- int waport;
- caddr_t newaddr;
+ int isdefault;
+ struct resource *rv, **rvp = 0;
+ struct isa_device *id = DEVTOISA(child);
-#ifdef DIAGNOSTIC
- if (chan & ~VALID_DMA_MASK)
- panic("isa_dmastart: channel out of range");
-
- if ((chan < 4 && nbytes > (1<<16))
- || (chan >= 4 && (nbytes > (1<<17) || (u_int)addr & 1)))
- panic("isa_dmastart: impossible request");
-
- if ((dma_inuse & (1 << chan)) == 0)
- printf("isa_dmastart: channel %d not acquired\n", chan);
-#endif
-
-#if 0
- /*
- * XXX This should be checked, but drivers like ad1848 only call
- * isa_dmastart() once because they use Auto DMA mode. If we
- * leave this in, drivers that do this will print this continuously.
- */
- if (dma_busy & (1 << chan))
- printf("isa_dmastart: channel %d busy\n", chan);
-#endif
-
- dma_busy |= (1 << chan);
-
- if (isa_dmarangecheck(addr, nbytes, chan)) {
- if (dma_bouncebuf[chan] == NULL
- || dma_bouncebufsize[chan] < nbytes)
- panic("isa_dmastart: bad bounce buffer");
- dma_bounced |= (1 << chan);
- newaddr = dma_bouncebuf[chan];
-
- /* copy bounce buffer on write */
- if (!(flags & B_READ))
- bcopy(addr, newaddr, nbytes);
- addr = newaddr;
- }
-
- /* translate to physical */
- phys = pmap_extract(pmap_kernel(), (vm_offset_t)addr);
-
- if (flags & B_RAW) {
- dma_auto_mode |= (1 << chan);
- } else {
- dma_auto_mode &= ~(1 << chan);
- }
-
- if ((chan & 4) == 0) {
+ if (child) {
/*
- * Program one of DMA channels 0..3. These are
- * byte mode channels.
+ * If this is our child, then use the isa_device to find
+ * defaults and to record results.
*/
- /* set dma channel mode, and reset address ff */
-
- /* If B_RAW flag is set, then use autoinitialise mode */
- if (flags & B_RAW) {
- if (flags & B_READ)
- outb(DMA1_MODE, DMA37MD_AUTO|DMA37MD_WRITE|chan);
- else
- outb(DMA1_MODE, DMA37MD_AUTO|DMA37MD_READ|chan);
- }
- else
- if (flags & B_READ)
- outb(DMA1_MODE, DMA37MD_SINGLE|DMA37MD_WRITE|chan);
+ if (device_get_devclass(device_get_parent(child)) == isa_devclass)
+ id = DEVTOISA(child);
else
- outb(DMA1_MODE, DMA37MD_SINGLE|DMA37MD_READ|chan);
- outb(DMA1_FFC, 0);
-
- /* send start address */
- waport = DMA1_CHN(chan);
- outb(waport, phys);
- outb(waport, phys>>8);
- outb(dmapageport[chan], phys>>16);
-
- /* send count */
- outb(waport + 1, --nbytes);
- outb(waport + 1, nbytes>>8);
-
- /* unmask channel */
- outb(DMA1_SMSK, chan);
- } else {
- /*
- * Program one of DMA channels 4..7. These are
- * word mode channels.
- */
- /* set dma channel mode, and reset address ff */
-
- /* If B_RAW flag is set, then use autoinitialise mode */
- if (flags & B_RAW) {
- if (flags & B_READ)
- outb(DMA2_MODE, DMA37MD_AUTO|DMA37MD_WRITE|(chan&3));
- else
- outb(DMA2_MODE, DMA37MD_AUTO|DMA37MD_READ|(chan&3));
+ id = NULL;
+ } else
+ id = NULL;
+ isdefault = (id != NULL && start == 0UL && end == ~0UL && *rid == 0);
+ if (*rid > 1)
+ return 0;
+
+ switch (type) {
+ case SYS_RES_IRQ:
+ if (isdefault && id->id_irq[0] >= 0) {
+ start = id->id_irq[0];
+ end = id->id_irq[0];
+ count = 1;
}
- else
- if (flags & B_READ)
- outb(DMA2_MODE, DMA37MD_SINGLE|DMA37MD_WRITE|(chan&3));
- else
- outb(DMA2_MODE, DMA37MD_SINGLE|DMA37MD_READ|(chan&3));
- outb(DMA2_FFC, 0);
-
- /* send start address */
- waport = DMA2_CHN(chan - 4);
- outb(waport, phys>>1);
- outb(waport, phys>>9);
- outb(dmapageport[chan], phys>>16);
-
- /* send count */
- nbytes >>= 1;
- outb(waport + 2, --nbytes);
- outb(waport + 2, nbytes>>8);
+ if (id)
+ rvp = &id->id_irqres[*rid];
+ break;
+
+ case SYS_RES_DRQ:
+ if (isdefault && id->id_drq[0] >= 0) {
+ start = id->id_drq[0];
+ end = id->id_drq[0];
+ count = 1;
+ }
+ if (id)
+ rvp = &id->id_drqres[*rid];
+ break;
+
+ case SYS_RES_MEMORY:
+ if (isdefault && id->id_maddr[0]) {
+ start = id->id_maddr[0];
+ count = max(count, (u_long)id->id_msize[0]);
+ end = id->id_maddr[0] + count;
+ }
+ if (id)
+ rvp = &id->id_memres[*rid];
+ break;
+
+ case SYS_RES_IOPORT:
+ if (isdefault && id->id_port[0]) {
+ start = id->id_port[0];
+ count = max(count, (u_long)id->id_portsize[0]);
+ end = id->id_port[0] + count;
+ }
+ if (id)
+ rvp = &id->id_portres[*rid];
+ break;
- /* unmask channel */
- outb(DMA2_SMSK, chan & 3);
+ default:
+ return 0;
}
-}
-
-void
-isa_dmadone(int flags, caddr_t addr, int nbytes, int chan)
-{
-#ifdef DIAGNOSTIC
- if (chan & ~VALID_DMA_MASK)
- panic("isa_dmadone: channel out of range");
-
- if ((dma_inuse & (1 << chan)) == 0)
- printf("isa_dmadone: channel %d not acquired\n", chan);
-#endif
-
- if (((dma_busy & (1 << chan)) == 0) &&
- (dma_auto_mode & (1 << chan)) == 0 )
- printf("isa_dmadone: channel %d not busy\n", chan);
- if ((dma_auto_mode & (1 << chan)) == 0)
- outb(chan & 4 ? DMA2_SMSK : DMA1_SMSK, (chan & 3) | 4);
-
- if (dma_bounced & (1 << chan)) {
- /* copy bounce buffer on read */
- if (flags & B_READ)
- bcopy(dma_bouncebuf[chan], addr, nbytes);
+ /*
+ * If the client attempts to reallocate a resource without
+ * releasing what was there previously, die horribly so that
+ * he knows how he !@#$ed up.
+ */
+ if (rvp && *rvp != 0)
+ panic("%s%d: (%d, %d) not free for %s%d\n",
+ device_get_name(bus), device_get_unit(bus),
+ type, *rid,
+ device_get_name(child), device_get_unit(child));
- dma_bounced &= ~(1 << chan);
+ /*
+ * nexus_alloc_resource had better not change *rid...
+ */
+ rv = BUS_ALLOC_RESOURCE(device_get_parent(bus), child, type, rid,
+ start, end, count, flags);
+ if (rvp && (*rvp = rv) != 0) {
+ switch (type) {
+ case SYS_RES_MEMORY:
+ id->id_maddr[*rid] = rv->r_start;
+ id->id_msize[*rid] = count;
+ break;
+ case SYS_RES_IOPORT:
+ id->id_port[*rid] = rv->r_start;
+ id->id_portsize[*rid] = count;
+ break;
+ case SYS_RES_IRQ:
+ id->id_irq[*rid] = rv->r_start;
+ break;
+ case SYS_RES_DRQ:
+ id->id_drq[*rid] = rv->r_start;
+ break;
+ }
}
- dma_busy &= ~(1 << chan);
+ return rv;
}
-/*
- * Check for problems with the address range of a DMA transfer
- * (non-contiguous physical pages, outside of bus address space,
- * crossing DMA page boundaries).
- * Return true if special handling needed.
- */
-
static int
-isa_dmarangecheck(caddr_t va, u_int length, int chan)
+isa_release_resource(device_t bus, device_t child, int type, int rid,
+ struct resource *r)
{
- vm_offset_t phys, priorpage = 0, endva;
- u_int dma_pgmsk = (chan & 4) ? ~(128*1024-1) : ~(64*1024-1);
-
- endva = (vm_offset_t)round_page((vm_offset_t)va + length);
- for (; va < (caddr_t) endva ; va += PAGE_SIZE) {
- phys = trunc_page(pmap_extract(pmap_kernel(), (vm_offset_t)va));
-#define ISARAM_END RAM_END
- if (phys == 0)
- panic("isa_dmacheck: no physical page present");
- if (phys >= ISARAM_END)
- return (1);
- if (priorpage) {
- if (priorpage + PAGE_SIZE != phys)
- return (1);
- /* check if crossing a DMA page boundary */
- if (((u_int)priorpage ^ (u_int)phys) & dma_pgmsk)
- return (1);
- }
- priorpage = phys;
- }
- return (0);
-}
+ int rv;
+ struct isa_device *id = DEVTOISA(child);
-/*
- * Query the progress of a transfer on a DMA channel.
- *
- * To avoid having to interrupt a transfer in progress, we sample
- * each of the high and low databytes twice, and apply the following
- * logic to determine the correct count.
- *
- * Reads are performed with interrupts disabled, thus it is to be
- * expected that the time between reads is very small. At most
- * one rollover in the low count byte can be expected within the
- * four reads that are performed.
- *
- * There are three gaps in which a rollover can occur :
- *
- * - read low1
- * gap1
- * - read high1
- * gap2
- * - read low2
- * gap3
- * - read high2
- *
- * If a rollover occurs in gap1 or gap2, the low2 value will be
- * greater than the low1 value. In this case, low2 and high2 are a
- * corresponding pair.
- *
- * In any other case, low1 and high1 can be considered to be correct.
- *
- * The function returns the number of bytes remaining in the transfer,
- * or -1 if the channel requested is not active.
- *
- */
-int
-isa_dmastatus(int chan)
-{
- u_long cnt = 0;
- int ffport, waport;
- u_long low1, high1, low2, high2;
+ if (rid > 1)
+ return EINVAL;
- /* channel active? */
- if ((dma_inuse & (1 << chan)) == 0) {
- printf("isa_dmastatus: channel %d not active\n", chan);
- return(-1);
+ switch (type) {
+ case SYS_RES_IRQ:
+ case SYS_RES_DRQ:
+ case SYS_RES_IOPORT:
+ case SYS_RES_MEMORY:
+ break;
+ default:
+ return (ENOENT);
}
- /* channel busy? */
- if (((dma_busy & (1 << chan)) == 0) &&
- (dma_auto_mode & (1 << chan)) == 0 ) {
- printf("chan %d not busy\n", chan);
- return -2 ;
- }
- if (chan < 4) { /* low DMA controller */
- ffport = DMA1_FFC;
- waport = DMA1_CHN(chan) + 1;
- } else { /* high DMA controller */
- ffport = DMA2_FFC;
- waport = DMA2_CHN(chan - 4) + 2;
- }
+ rv = BUS_RELEASE_RESOURCE(device_get_parent(bus), child, type, rid, r);
- disable_intr(); /* no interrupts Mr Jones! */
- outb(ffport, 0); /* clear register LSB flipflop */
- low1 = inb(waport);
- high1 = inb(waport);
- outb(ffport, 0); /* clear again */
- low2 = inb(waport);
- high2 = inb(waport);
- enable_intr(); /* enable interrupts again */
+#if 0
+ if (rv) {
+ /* Kludge, isa as a child of pci doesn't have mapping regs */
+ printf("WARNING: isa_release_resource: BUS_RELEASE_RESOURCE() failed: %d\n", rv);
+ rv = 0;
+ }
+#endif
- /*
- * Now decide if a wrap has tried to skew our results.
- * Note that after TC, the count will read 0xffff, while we want
- * to return zero, so we add and then mask to compensate.
- */
- if (low1 >= low2) {
- cnt = (low1 + (high1 << 8) + 1) & 0xffff;
- } else {
- cnt = (low2 + (high2 << 8) + 1) & 0xffff;
+ if (rv == 0) {
+ switch (type) {
+ case SYS_RES_IRQ:
+ id->id_irqres[rid] = 0;
+ id->id_irq[rid] = -1;
+ break;
+
+ case SYS_RES_DRQ:
+ id->id_drqres[rid] = 0;
+ id->id_drq[rid] = -1;
+ break;
+
+ case SYS_RES_MEMORY:
+ id->id_memres[rid] = 0;
+ id->id_maddr[rid] = 0;
+ id->id_msize[rid] = 0;
+ break;
+
+ case SYS_RES_IOPORT:
+ id->id_portres[rid] = 0;
+ id->id_port[rid] = 0;
+ id->id_portsize[rid] = 0;
+ break;
+
+ default:
+ return ENOENT;
+ }
}
- if (chan >= 4) /* high channels move words */
- cnt *= 2;
- return(cnt);
+ return rv;
}
/*
- * Stop a DMA transfer currently in progress.
+ * We can't use the bus_generic_* versions of these methods because those
+ * methods always pass the bus param as the requesting device, and we need
+ * to pass the child (the i386 nexus knows about this and is prepared to
+ * deal).
*/
-int
-isa_dmastop(int chan)
+static int
+isa_setup_intr(device_t bus, device_t child, struct resource *r,
+ void (*ihand)(void *), void *arg, void **cookiep)
{
- if ((dma_inuse & (1 << chan)) == 0)
- printf("isa_dmastop: channel %d not acquired\n", chan);
-
- if (((dma_busy & (1 << chan)) == 0) &&
- ((dma_auto_mode & (1 << chan)) == 0)) {
- printf("chan %d not busy\n", chan);
- return -2 ;
- }
-
- if ((chan & 4) == 0) {
- outb(DMA1_SMSK, (chan & 3) | 4 /* disable mask */);
- } else {
- outb(DMA2_SMSK, (chan & 3) | 4 /* disable mask */);
- }
- return(isa_dmastatus(chan));
+ return (BUS_SETUP_INTR(device_get_parent(bus), child, r, ihand, arg,
+ cookiep));
}
-/*
- * Find the highest priority enabled display device. Since we can't
- * distinguish display devices from ttys, depend on display devices
- * being sensitive and before sensitive non-display devices (if any)
- * in isa_devtab_tty.
- *
- * XXX we should add capability flags IAMDISPLAY and ISUPPORTCONSOLES.
- */
-struct isa_device *
-find_display()
+static int
+isa_teardown_intr(device_t bus, device_t child, struct resource *r,
+ void *cookie)
{
- struct isa_device *dvp;
-
- for (dvp = isa_devtab_tty; dvp->id_driver != NULL; dvp++)
- if (dvp->id_driver->sensitive_hw && dvp->id_enabled)
- return (dvp);
- return (NULL);
+ return (BUS_TEARDOWN_INTR(device_get_parent(bus), child, r, cookie));
}
+static device_method_t isa_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, isa_probe),
+ DEVMETHOD(device_attach, isa_attach),
+ DEVMETHOD(device_detach, bus_generic_detach),
+ DEVMETHOD(device_shutdown, bus_generic_shutdown),
+ DEVMETHOD(device_suspend, bus_generic_suspend),
+ DEVMETHOD(device_resume, bus_generic_resume),
+
+ /* Bus interface */
+ DEVMETHOD(bus_print_child, isa_print_child),
+ DEVMETHOD(bus_read_ivar, isa_read_ivar),
+ DEVMETHOD(bus_write_ivar, isa_write_ivar),
+ DEVMETHOD(bus_alloc_resource, isa_alloc_resource),
+ DEVMETHOD(bus_release_resource, isa_release_resource),
+ DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
+ DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
+ DEVMETHOD(bus_setup_intr, isa_setup_intr),
+ DEVMETHOD(bus_teardown_intr, isa_teardown_intr),
+
+ { 0, 0 }
+};
+
+static driver_t isa_driver = {
+ "isa",
+ isa_methods,
+ DRIVER_TYPE_MISC,
+ 1, /* no softc */
+};
+
/*
- * find an ISA device in a given isa_devtab_* table, given
- * the table to search, the expected id_driver entry, and the unit number.
- *
- * this function is defined in isa_device.h, and this location is debatable;
- * i put it there because it's useless w/o, and directly operates on
- * the other stuff in that file.
- *
+ * ISA can be attached to a PCI-ISA bridge or directly to the nexus.
*/
-
-struct isa_device *
-find_isadev(table, driverp, unit)
- struct isa_device *table;
- struct isa_driver *driverp;
- int unit;
-{
- if (driverp == NULL) /* sanity check */
- return (NULL);
-
- while ((table->id_driver != driverp) || (table->id_unit != unit)) {
- if (table->id_driver == 0)
- return NULL;
-
- table++;
- }
-
- return (table);
-}
+DRIVER_MODULE(isa, isab, isa_driver, isa_devclass, 0, 0);
+DRIVER_MODULE(isa, nexus, isa_driver, isa_devclass, 0, 0);
diff --git a/sys/i386/isa/isa_compat.c b/sys/i386/isa/isa_compat.c
new file mode 100644
index 0000000..82e6185
--- /dev/null
+++ b/sys/i386/isa/isa_compat.c
@@ -0,0 +1,255 @@
+/*-
+ * 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.
+ *
+ * $Id$
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/kernel.h>
+#include <sys/bus.h>
+#include <sys/malloc.h>
+#include <sys/module.h>
+#include <machine/bus.h>
+#include <sys/rman.h>
+
+#include <machine/resource.h>
+#include <isa/isavar.h>
+#include <i386/isa/isa_compat.h>
+#include <i386/isa/isa_device.h>
+
+struct isa_compat_resources {
+ struct resource *ports;
+ struct resource *memory;
+ struct resource *drq;
+ 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)
+{
+ int rid;
+
+ if (isa_get_port(dev) != -1) {
+ rid = 0;
+ res->ports = bus_alloc_resource(dev, SYS_RES_IOPORT,
+ &rid, 0ul, ~0ul, 1,
+ RF_ACTIVE);
+ if (res->ports == NULL)
+ printf("isa_compat: didn't get ports for %s\n",
+ device_get_name(dev));
+ } else
+ res->ports = 0;
+
+ if (isa_get_maddr(dev) != 0) {
+ rid = 0;
+ res->memory = bus_alloc_resource(dev, SYS_RES_MEMORY,
+ &rid, 0ul, ~0ul, 1,
+ RF_ACTIVE);
+ if (res->memory == NULL)
+ printf("isa_compat: didn't get memory for %s\n",
+ device_get_name(dev));
+ } else
+ res->memory = 0;
+
+ if (isa_get_drq(dev) != -1) {
+ rid = 0;
+ res->drq = bus_alloc_resource(dev, SYS_RES_DRQ,
+ &rid, 0ul, ~0ul, 1,
+ RF_ACTIVE);
+ if (res->drq == NULL)
+ printf("isa_compat: didn't get drq for %s\n",
+ device_get_name(dev));
+ } else
+ res->drq = 0;
+
+ if (isa_get_irq(dev) != -1) {
+ rid = 0;
+ res->irq = bus_alloc_resource(dev, SYS_RES_IRQ,
+ &rid, 0ul, ~0ul, 1,
+ RF_SHAREABLE | RF_ACTIVE);
+ if (res->irq == NULL)
+ printf("isa_compat: didn't get irq for %s\n",
+ device_get_name(dev));
+ } else
+ res->irq = 0;
+}
+
+static void
+isa_compat_release_resources(device_t dev, struct isa_compat_resources *res)
+{
+ if (res->ports) {
+ bus_release_resource(dev, SYS_RES_IOPORT, 0, res->ports);
+ res->ports = 0;
+ }
+ if (res->memory) {
+ bus_release_resource(dev, SYS_RES_MEMORY, 0, res->memory);
+ res->memory = 0;
+ }
+ if (res->drq) {
+ bus_release_resource(dev, SYS_RES_DRQ, 0, res->drq);
+ res->drq = 0;
+ }
+ if (res->irq) {
+ bus_release_resource(dev, SYS_RES_IRQ, 0, res->irq);
+ res->irq = 0;
+ }
+}
+
+static int
+isa_compat_probe(device_t dev)
+{
+ struct isa_device *dvp = device_get_softc(dev);
+ struct isa_compat_resources res;
+
+ bzero(&res, sizeof(res));
+ /*
+ * Fill in the isa_device fields.
+ */
+ dvp->id_id = isa_compat_nextid();
+ dvp->id_driver = device_get_driver(dev)->priv;
+ dvp->id_iobase = isa_get_port(dev);
+ dvp->id_irq = (1 << 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);
+ dvp->id_unit = device_get_unit(dev);
+ dvp->id_flags = isa_get_flags(dev);
+ dvp->id_enabled = device_is_enabled(dev);
+
+ /*
+ * Do the wrapped probe.
+ */
+ if (dvp->id_driver->probe) {
+ int portsize;
+ isa_compat_alloc_resources(dev, &res);
+ if (res.memory)
+ dvp->id_maddr = rman_get_virtual(res.memory);
+ else
+ dvp->id_maddr = 0;
+ 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 != (1 << 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 != (void *) isa_get_maddr(dev))
+ isa_set_maddr(dev, (int) dvp->id_maddr);
+ if (dvp->id_msize != isa_get_msize(dev))
+ isa_set_msize(dev, dvp->id_msize);
+ return 0;
+ }
+ }
+ return ENXIO;
+}
+
+static int
+isa_compat_attach(device_t dev)
+{
+ struct isa_device *dvp = device_get_softc(dev);
+ struct isa_compat_resources res;
+ int error;
+
+ bzero(&res, sizeof(res));
+ isa_compat_alloc_resources(dev, &res);
+ if (dvp->id_driver->attach)
+ dvp->id_driver->attach(dvp);
+ if (res.irq && dvp->id_irq && dvp->id_intr) {
+ void *ih;
+
+ error = BUS_SETUP_INTR(device_get_parent(dev), dev,
+ res.irq,
+ dvp->id_intr,
+ (void *)(uintptr_t)dvp->id_unit,
+ &ih);
+ if (error)
+ printf("isa_compat_attach: failed to setup intr: %d\n",
+ error);
+ }
+ return 0;
+}
+
+static device_method_t isa_compat_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, isa_compat_probe),
+ DEVMETHOD(device_attach, isa_compat_attach),
+
+ { 0, 0 }
+};
+
+/*
+ * Create a new style driver around each old isa driver.
+ */
+void
+isa_wrap_old_drivers(void)
+{
+ int i;
+ struct old_isa_driver *op;
+ devclass_t isa_devclass = devclass_find("isa");
+
+ for (i = 0, op = &old_drivers[0]; i < old_drivers_count; i++, op++) {
+ driver_t *driver;
+ driver = malloc(sizeof(driver_t), M_DEVBUF, M_NOWAIT);
+ if (!driver)
+ continue;
+ bzero(driver, sizeof(driver_t));
+ driver->name = op->driver->name;
+ driver->methods = isa_compat_methods;
+ driver->type = op->type;
+ driver->softc = sizeof(struct isa_device *);
+ driver->priv = op->driver;
+ devclass_add_driver(isa_devclass, driver);
+ }
+}
+
+int
+haveseen_isadev(dvp, checkbits)
+ struct isa_device *dvp;
+ u_int checkbits;
+{
+ printf("haveseen_isadev() called - FIXME!\n");
+ return 0;
+}
+
+void
+reconfig_isadev(isdp, mp)
+ struct isa_device *isdp;
+ u_int *mp;
+{
+ printf("reconfig_isadev() called - FIXME!\n");
+}
diff --git a/sys/i386/isa/isa_compat.h b/sys/i386/isa/isa_compat.h
new file mode 100644
index 0000000..5e48b89
--- /dev/null
+++ b/sys/i386/isa/isa_compat.h
@@ -0,0 +1,378 @@
+/*-
+ * 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.
+ *
+ * $Id$
+ */
+
+#include "vt.h"
+#include "bt.h"
+#include "adv.h"
+#include "aha.h"
+#include "wdc.h"
+#include "mse.h"
+#include "ar.h"
+#include "cs.h"
+#include "cx.h"
+#include "ed.h"
+#include "el.h"
+#include "ep.h"
+#include "ex.h"
+#include "fe.h"
+#include "ie.h"
+#include "le.h"
+#include "lnc.h"
+#include "rdp.h"
+#include "sr.h"
+#include "wl.h"
+#include "ze.h"
+#include "zp.h"
+#include "oltr.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 "pca.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 "joy.h"
+#include "cy.h"
+#include "dgb.h"
+#include "dgm.h"
+#include "labpc.h"
+#include "rc.h"
+#include "rp.h"
+#include "tw.h"
+#include "si.h"
+#include "asc.h"
+#include "stl.h"
+#include "stli.h"
+#include "loran.h"
+#include "pcf.h"
+#include "isic.h"
+#include "tina.h"
+#include "ppc.h"
+
+struct old_isa_driver {
+ int type;
+ struct isa_driver *driver;
+};
+
+extern struct isa_driver vtdriver;
+extern struct isa_driver btdriver;
+extern struct isa_driver advdriver;
+extern struct isa_driver ahadriver;
+extern struct isa_driver wdcdriver;
+extern struct isa_driver msedriver;
+extern struct isa_driver ardriver;
+extern struct isa_driver csdriver;
+extern struct isa_driver cxdriver;
+extern struct isa_driver eddriver;
+extern struct isa_driver eldriver;
+extern struct isa_driver epdriver;
+extern struct isa_driver exdriver;
+extern struct isa_driver fedriver;
+extern struct isa_driver iedriver;
+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 zedriver;
+extern struct isa_driver zpdriver;
+extern struct isa_driver oltrdriver;
+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 pcadriver;
+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 joydriver;
+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 sidriver;
+extern struct isa_driver ascdriver;
+extern struct isa_driver stldriver;
+extern struct isa_driver stlidriver;
+extern struct isa_driver lorandriver;
+extern struct isa_driver pcfdriver;
+extern struct isa_driver isicdriver;
+extern struct isa_driver tinadriver;
+extern struct isa_driver ppcdriver;
+
+
+static struct old_isa_driver old_drivers[] = {
+
+/* Sensitive TTY */
+
+/* Sensitive BIO */
+
+/* Sensitive NET */
+#if NED > 0
+ { DRIVER_TYPE_NET, &eddriver },
+#endif
+#if NFE > 0
+ { DRIVER_TYPE_NET, &fedriver },
+#endif
+#if NRDP > 0
+ { DRIVER_TYPE_NET, &rdpdriver },
+#endif
+
+/* Sensitive CAM */
+
+/* TTY */
+
+#if NVT > 0
+ { DRIVER_TYPE_TTY, &vtdriver },
+#endif
+#if NMSE > 0
+ { DRIVER_TYPE_TTY, &msedriver },
+#endif
+#if NPCA > 0
+ { DRIVER_TYPE_TTY, &pcadriver },
+#endif
+#if NGP > 0
+ { DRIVER_TYPE_TTY, &gpdriver },
+#endif
+#if NGSC > 0
+ { DRIVER_TYPE_TTY, &gscdriver },
+#endif
+#if NCY > 0
+ { DRIVER_TYPE_TTY, &cydriver },
+#endif
+#if NDGB > 0
+ { DRIVER_TYPE_TTY, &dgbdriver },
+#endif
+#if NDGM > 0
+ { DRIVER_TYPE_TTY, &dgmdriver },
+#endif
+#if NLABPC > 0
+ { DRIVER_TYPE_TTY, &labpcdriver },
+#endif
+#if NRCD > 0
+ { DRIVER_TYPE_TTY, &rcdriver },
+#endif
+#if NRP > 0
+ { DRIVER_TYPE_TTY, &rpdriver },
+#endif
+#if NTW > 0
+ { DRIVER_TYPE_TTY, &twdriver },
+#endif
+#if NSI > 0
+ { DRIVER_TYPE_TTY, &sidriver },
+#endif
+#if NASC > 0
+ { DRIVER_TYPE_TTY, &ascdriver },
+#endif
+#if NSTL > 0
+ { DRIVER_TYPE_TTY, &stldriver },
+#endif
+#if NSTLI > 0
+ { DRIVER_TYPE_TTY, &stlidriver },
+#endif
+#if NLORAN > 0
+ { DRIVER_TYPE_TTY, &lorandriver },
+#endif
+#if NPPC > 0
+ { DRIVER_TYPE_TTY, &ppcdriver },
+#endif
+
+/* BIO */
+
+#if NWDC > 0
+ { DRIVER_TYPE_BIO, &wdcdriver },
+#endif
+#if NMCD > 0
+ { DRIVER_TYPE_BIO, &mcddriver },
+#endif
+#if NSCD > 0
+ { DRIVER_TYPE_BIO, &scddriver },
+#endif
+#if NMATCD > 0
+ { DRIVER_TYPE_BIO, &matcddriver },
+#endif
+#if NWT > 0
+ { DRIVER_TYPE_BIO, &wtdriver },
+#endif
+
+/* NET */
+
+#if NIE > 0
+ { DRIVER_TYPE_NET, &iedriver },
+#endif
+#if NEP > 0
+ { DRIVER_TYPE_NET, &epdriver },
+#endif
+#if NEX > 0
+ { DRIVER_TYPE_NET, &exdriver },
+#endif
+#if NLE > 0
+ { DRIVER_TYPE_NET, &ledriver },
+#endif
+#if NLNC > 0
+ { DRIVER_TYPE_NET, &lncdriver },
+#endif
+#if NZE > 0
+ { DRIVER_TYPE_NET, &zedriver },
+#endif
+#if NZP > 0
+ { DRIVER_TYPE_NET, &zpdriver },
+#endif
+#if NCS > 0
+ { DRIVER_TYPE_NET, &csdriver },
+#endif
+#if NAR > 0
+ { DRIVER_TYPE_NET, &ardriver },
+#endif
+#if NCX > 0
+ { DRIVER_TYPE_NET, &cxdriver },
+#endif
+#if NEL > 0
+ { DRIVER_TYPE_NET, &eldriver },
+#endif
+#if NSR > 0
+ { DRIVER_TYPE_NET, &srdriver },
+#endif
+#if NWL > 0
+ { DRIVER_TYPE_NET, &wldriver },
+#endif
+#if NPCF > 0
+ { DRIVER_TYPE_NET, &pcfdriver },
+#endif
+#if NISIC > 0
+ { DRIVER_TYPE_NET, &isicdriver },
+#endif
+#if NTINA > 0
+ { DRIVER_TYPE_NET, &tinadriver },
+#endif
+
+/* CAM */
+
+#if NBT > 0
+ { DRIVER_TYPE_CAM, &btdriver },
+#endif
+#if NADV > 0
+ { DRIVER_TYPE_CAM, &advdriver },
+#endif
+#if NAHA > 0
+ { DRIVER_TYPE_CAM, &ahadriver },
+#endif
+
+/* MISC */
+
+#if NOLTR > 0
+ { DRIVER_TYPE_MISC, &oltrdriver },
+#endif
+#if NPAS > 0
+ { DRIVER_TYPE_MISC, &pasdriver },
+#endif
+#if NSB > 0
+ { DRIVER_TYPE_MISC, &sbdriver },
+#endif
+#if NSBVXI > 0
+ { DRIVER_TYPE_MISC, &sbxvidriver },
+#endif
+#if NSBMIDI > 0
+ { DRIVER_TYPE_MISC, &sbmididriver },
+#endif
+#if NAWE > 0
+ { DRIVER_TYPE_MISC, &awedriver },
+#endif
+#if NGUS > 0
+ { DRIVER_TYPE_MISC, &gusdriver },
+#endif
+#if NMSS > 0
+ { DRIVER_TYPE_MISC, &mssdriver },
+#endif
+#if NCSS > 0
+ { DRIVER_TYPE_MISC, &cssdriver },
+#endif
+#if NSSCAPE > 0
+ { DRIVER_TYPE_MISC, &sscapedriver },
+#endif
+#if NTRIX > 0
+ { DRIVER_TYPE_MISC, &trixdriver },
+#endif
+#if NSSCAPE > 0
+ { DRIVER_TYPE_MISC, &sscape_mssdriver },
+#endif
+#if NOPL > 0
+ { DRIVER_TYPE_MISC, &opldriver },
+#endif
+#if NMPU > 0
+ { DRIVER_TYPE_MISC, &mpudriver },
+#endif
+#if NUART > 0
+ { DRIVER_TYPE_MISC, &uartdriver },
+#endif
+#if NCTX > 0
+ { DRIVER_TYPE_MISC, &ctxdriver },
+#endif
+#if NSPIGOT > 0
+ { DRIVER_TYPE_MISC, &spigotdriver },
+#endif
+#if NJOY > 0
+ { DRIVER_TYPE_MISC, &joydriver },
+#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 d23f701..a7c1022 100644
--- a/sys/i386/isa/isa_device.h
+++ b/sys/i386/isa/isa_device.h
@@ -31,12 +31,16 @@
* SUCH DAMAGE.
*
* from: @(#)isa_device.h 7.1 (Berkeley) 5/9/91
- * $Id: isa_device.h,v 1.56 1998/10/22 05:58:39 bde Exp $
+ * $Id: isa_device.h,v 1.57 1999/01/17 06:33:43 bde Exp $
*/
#ifndef _I386_ISA_ISA_DEVICE_H_
#define _I386_ISA_ISA_DEVICE_H_
+#ifdef KERNEL
+#include <i386/isa/isa_dma.h>
+#endif
+
/*
* ISA Bus Autoconfiguration
*/
@@ -105,30 +109,9 @@ struct isa_driver {
#ifdef KERNEL
-extern struct isa_device isa_biotab_fdc[];
-extern struct isa_device isa_biotab_wdc[];
-extern struct isa_device isa_devtab_bio[];
-extern struct isa_device isa_devtab_net[];
-extern struct isa_device isa_devtab_cam[];
-extern struct isa_device isa_devtab_null[];
-extern struct isa_device isa_devtab_tty[];
-
-struct isa_device *
- find_display __P((void));
-struct isa_device *
- find_isadev __P((struct isa_device *table, struct isa_driver *driverp,
- int unit));
int haveseen_isadev __P((struct isa_device *dvp, u_int checkbits));
-void isa_configure __P((void));
-void isa_dmacascade __P((int chan));
-void isa_dmadone __P((int flags, caddr_t addr, int nbytes, int chan));
-void isa_dmainit __P((int chan, u_int bouncebufsize));
-void isa_dmastart __P((int flags, caddr_t addr, u_int nbytes, int chan));
-int isa_dma_acquire __P((int chan));
-void isa_dma_release __P((int chan));
-int isa_dmastatus __P((int chan));
-int isa_dmastop __P((int chan));
void reconfig_isadev __P((struct isa_device *isdp, u_int *mp));
+int isa_compat_nextid __P((void));
#endif /* KERNEL */
diff --git a/sys/i386/isa/isa_dma.c b/sys/i386/isa/isa_dma.c
new file mode 100644
index 0000000..abea7f8
--- /dev/null
+++ b/sys/i386/isa/isa_dma.c
@@ -0,0 +1,510 @@
+/*-
+ * Copyright (c) 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * from: @(#)isa.c 7.2 (Berkeley) 5/13/91
+ * $Id: isa.c,v 1.117 1998/11/29 15:42:40 phk Exp $
+ */
+
+/*
+ * code to manage AT bus
+ *
+ * 92/08/18 Frank P. MacLachlan (fpm@crash.cts.com):
+ * Fixed uninitialized variable problem and added code to deal
+ * with DMA page boundaries in isa_dmarangecheck(). Fixed word
+ * mode DMA count compution and reorganized DMA setup code in
+ * isa_dmastart()
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/buf.h>
+#include <sys/malloc.h>
+#include <machine/ipl.h>
+#include <machine/md_var.h>
+#ifdef APIC_IO
+#include <machine/smp.h>
+#endif /* APIC_IO */
+#include <vm/vm.h>
+#include <vm/vm_param.h>
+#include <vm/pmap.h>
+#include <i386/isa/isa_device.h>
+#include <i386/isa/intr_machdep.h>
+#include <i386/isa/isa.h>
+#include <i386/isa/ic/i8237.h>
+
+#include <sys/interrupt.h>
+
+#include "pnp.h"
+#if NPNP > 0
+#include <i386/isa/pnp.h>
+#endif
+
+/*
+** Register definitions for DMA controller 1 (channels 0..3):
+*/
+#define DMA1_CHN(c) (IO_DMA1 + 1*(2*(c))) /* addr reg for channel c */
+#define DMA1_SMSK (IO_DMA1 + 1*10) /* single mask register */
+#define DMA1_MODE (IO_DMA1 + 1*11) /* mode register */
+#define DMA1_FFC (IO_DMA1 + 1*12) /* clear first/last FF */
+
+/*
+** Register definitions for DMA controller 2 (channels 4..7):
+*/
+#define DMA2_CHN(c) (IO_DMA2 + 2*(2*(c))) /* addr reg for channel c */
+#define DMA2_SMSK (IO_DMA2 + 2*10) /* single mask register */
+#define DMA2_MODE (IO_DMA2 + 2*11) /* mode register */
+#define DMA2_FFC (IO_DMA2 + 2*12) /* clear first/last FF */
+
+static int isa_dmarangecheck __P((caddr_t va, u_int length, int chan));
+
+static caddr_t dma_bouncebuf[8];
+static u_int dma_bouncebufsize[8];
+static u_int8_t dma_bounced = 0;
+static u_int8_t dma_busy = 0; /* Used in isa_dmastart() */
+static u_int8_t dma_inuse = 0; /* User for acquire/release */
+static u_int8_t dma_auto_mode = 0;
+
+#define VALID_DMA_MASK (7)
+
+/* high byte of address is stored in this port for i-th dma channel */
+static int dmapageport[8] = { 0x87, 0x83, 0x81, 0x82, 0x8f, 0x8b, 0x89, 0x8a };
+
+/*
+ * Setup a DMA channel's bounce buffer.
+ */
+void
+isa_dmainit(chan, bouncebufsize)
+ int chan;
+ u_int bouncebufsize;
+{
+ void *buf;
+
+#ifdef DIAGNOSTIC
+ if (chan & ~VALID_DMA_MASK)
+ panic("isa_dmainit: channel out of range");
+
+ if (dma_bouncebuf[chan] != NULL)
+ panic("isa_dmainit: impossible request");
+#endif
+
+ dma_bouncebufsize[chan] = bouncebufsize;
+
+ /* Try malloc() first. It works better if it works. */
+ buf = malloc(bouncebufsize, M_DEVBUF, M_NOWAIT);
+ if (buf != NULL) {
+ if (isa_dmarangecheck(buf, bouncebufsize, chan) == 0) {
+ dma_bouncebuf[chan] = buf;
+ return;
+ }
+ free(buf, M_DEVBUF);
+ }
+ buf = contigmalloc(bouncebufsize, M_DEVBUF, M_NOWAIT, 0ul, 0xfffffful,
+ 1ul, chan & 4 ? 0x20000ul : 0x10000ul);
+ if (buf == NULL)
+ printf("isa_dmainit(%d, %d) failed\n", chan, bouncebufsize);
+ else
+ dma_bouncebuf[chan] = buf;
+}
+
+/*
+ * Register a DMA channel's usage. Usually called from a device driver
+ * in open() or during its initialization.
+ */
+int
+isa_dma_acquire(chan)
+ int chan;
+{
+#ifdef DIAGNOSTIC
+ if (chan & ~VALID_DMA_MASK)
+ panic("isa_dma_acquire: channel out of range");
+#endif
+
+ if (dma_inuse & (1 << chan)) {
+ printf("isa_dma_acquire: channel %d already in use\n", chan);
+ return (EBUSY);
+ }
+ dma_inuse |= (1 << chan);
+ dma_auto_mode &= ~(1 << chan);
+
+ return (0);
+}
+
+/*
+ * Unregister a DMA channel's usage. Usually called from a device driver
+ * during close() or during its shutdown.
+ */
+void
+isa_dma_release(chan)
+ int chan;
+{
+#ifdef DIAGNOSTIC
+ if (chan & ~VALID_DMA_MASK)
+ panic("isa_dma_release: channel out of range");
+
+ if ((dma_inuse & (1 << chan)) == 0)
+ printf("isa_dma_release: channel %d not in use\n", chan);
+#endif
+
+ if (dma_busy & (1 << chan)) {
+ dma_busy &= ~(1 << chan);
+ /*
+ * XXX We should also do "dma_bounced &= (1 << chan);"
+ * because we are acting on behalf of isa_dmadone() which
+ * was not called to end the last DMA operation. This does
+ * not matter now, but it may in the future.
+ */
+ }
+
+ dma_inuse &= ~(1 << chan);
+ dma_auto_mode &= ~(1 << chan);
+}
+
+/*
+ * isa_dmacascade(): program 8237 DMA controller channel to accept
+ * external dma control by a board.
+ */
+void
+isa_dmacascade(chan)
+ int chan;
+{
+#ifdef DIAGNOSTIC
+ if (chan & ~VALID_DMA_MASK)
+ panic("isa_dmacascade: channel out of range");
+#endif
+
+ /* set dma channel mode, and set dma channel mode */
+ if ((chan & 4) == 0) {
+ outb(DMA1_MODE, DMA37MD_CASCADE | chan);
+ outb(DMA1_SMSK, chan);
+ } else {
+ outb(DMA2_MODE, DMA37MD_CASCADE | (chan & 3));
+ outb(DMA2_SMSK, chan & 3);
+ }
+}
+
+/*
+ * isa_dmastart(): program 8237 DMA controller channel, avoid page alignment
+ * problems by using a bounce buffer.
+ */
+void
+isa_dmastart(int flags, caddr_t addr, u_int nbytes, int chan)
+{
+ vm_offset_t phys;
+ int waport;
+ caddr_t newaddr;
+
+#ifdef DIAGNOSTIC
+ if (chan & ~VALID_DMA_MASK)
+ panic("isa_dmastart: channel out of range");
+
+ if ((chan < 4 && nbytes > (1<<16))
+ || (chan >= 4 && (nbytes > (1<<17) || (u_int)addr & 1)))
+ panic("isa_dmastart: impossible request");
+
+ if ((dma_inuse & (1 << chan)) == 0)
+ printf("isa_dmastart: channel %d not acquired\n", chan);
+#endif
+
+#if 0
+ /*
+ * XXX This should be checked, but drivers like ad1848 only call
+ * isa_dmastart() once because they use Auto DMA mode. If we
+ * leave this in, drivers that do this will print this continuously.
+ */
+ if (dma_busy & (1 << chan))
+ printf("isa_dmastart: channel %d busy\n", chan);
+#endif
+
+ dma_busy |= (1 << chan);
+
+ if (isa_dmarangecheck(addr, nbytes, chan)) {
+ if (dma_bouncebuf[chan] == NULL
+ || dma_bouncebufsize[chan] < nbytes)
+ panic("isa_dmastart: bad bounce buffer");
+ dma_bounced |= (1 << chan);
+ newaddr = dma_bouncebuf[chan];
+
+ /* copy bounce buffer on write */
+ if (!(flags & B_READ))
+ bcopy(addr, newaddr, nbytes);
+ addr = newaddr;
+ }
+
+ /* translate to physical */
+ phys = pmap_extract(pmap_kernel(), (vm_offset_t)addr);
+
+ if (flags & B_RAW) {
+ dma_auto_mode |= (1 << chan);
+ } else {
+ dma_auto_mode &= ~(1 << chan);
+ }
+
+ if ((chan & 4) == 0) {
+ /*
+ * Program one of DMA channels 0..3. These are
+ * byte mode channels.
+ */
+ /* set dma channel mode, and reset address ff */
+
+ /* If B_RAW flag is set, then use autoinitialise mode */
+ if (flags & B_RAW) {
+ if (flags & B_READ)
+ outb(DMA1_MODE, DMA37MD_AUTO|DMA37MD_WRITE|chan);
+ else
+ outb(DMA1_MODE, DMA37MD_AUTO|DMA37MD_READ|chan);
+ }
+ else
+ if (flags & B_READ)
+ outb(DMA1_MODE, DMA37MD_SINGLE|DMA37MD_WRITE|chan);
+ else
+ outb(DMA1_MODE, DMA37MD_SINGLE|DMA37MD_READ|chan);
+ outb(DMA1_FFC, 0);
+
+ /* send start address */
+ waport = DMA1_CHN(chan);
+ outb(waport, phys);
+ outb(waport, phys>>8);
+ outb(dmapageport[chan], phys>>16);
+
+ /* send count */
+ outb(waport + 1, --nbytes);
+ outb(waport + 1, nbytes>>8);
+
+ /* unmask channel */
+ outb(DMA1_SMSK, chan);
+ } else {
+ /*
+ * Program one of DMA channels 4..7. These are
+ * word mode channels.
+ */
+ /* set dma channel mode, and reset address ff */
+
+ /* If B_RAW flag is set, then use autoinitialise mode */
+ if (flags & B_RAW) {
+ if (flags & B_READ)
+ outb(DMA2_MODE, DMA37MD_AUTO|DMA37MD_WRITE|(chan&3));
+ else
+ outb(DMA2_MODE, DMA37MD_AUTO|DMA37MD_READ|(chan&3));
+ }
+ else
+ if (flags & B_READ)
+ outb(DMA2_MODE, DMA37MD_SINGLE|DMA37MD_WRITE|(chan&3));
+ else
+ outb(DMA2_MODE, DMA37MD_SINGLE|DMA37MD_READ|(chan&3));
+ outb(DMA2_FFC, 0);
+
+ /* send start address */
+ waport = DMA2_CHN(chan - 4);
+ outb(waport, phys>>1);
+ outb(waport, phys>>9);
+ outb(dmapageport[chan], phys>>16);
+
+ /* send count */
+ nbytes >>= 1;
+ outb(waport + 2, --nbytes);
+ outb(waport + 2, nbytes>>8);
+
+ /* unmask channel */
+ outb(DMA2_SMSK, chan & 3);
+ }
+}
+
+void
+isa_dmadone(int flags, caddr_t addr, int nbytes, int chan)
+{
+#ifdef DIAGNOSTIC
+ if (chan & ~VALID_DMA_MASK)
+ panic("isa_dmadone: channel out of range");
+
+ if ((dma_inuse & (1 << chan)) == 0)
+ printf("isa_dmadone: channel %d not acquired\n", chan);
+#endif
+
+ if (((dma_busy & (1 << chan)) == 0) &&
+ (dma_auto_mode & (1 << chan)) == 0 )
+ printf("isa_dmadone: channel %d not busy\n", chan);
+
+ if ((dma_auto_mode & (1 << chan)) == 0)
+ outb(chan & 4 ? DMA2_SMSK : DMA1_SMSK, (chan & 3) | 4);
+
+ if (dma_bounced & (1 << chan)) {
+ /* copy bounce buffer on read */
+ if (flags & B_READ)
+ bcopy(dma_bouncebuf[chan], addr, nbytes);
+
+ dma_bounced &= ~(1 << chan);
+ }
+ dma_busy &= ~(1 << chan);
+}
+
+/*
+ * Check for problems with the address range of a DMA transfer
+ * (non-contiguous physical pages, outside of bus address space,
+ * crossing DMA page boundaries).
+ * Return true if special handling needed.
+ */
+
+static int
+isa_dmarangecheck(caddr_t va, u_int length, int chan)
+{
+ vm_offset_t phys, priorpage = 0, endva;
+ u_int dma_pgmsk = (chan & 4) ? ~(128*1024-1) : ~(64*1024-1);
+
+ endva = (vm_offset_t)round_page((vm_offset_t)va + length);
+ for (; va < (caddr_t) endva ; va += PAGE_SIZE) {
+ phys = trunc_page(pmap_extract(pmap_kernel(), (vm_offset_t)va));
+#define ISARAM_END RAM_END
+ if (phys == 0)
+ panic("isa_dmacheck: no physical page present");
+ if (phys >= ISARAM_END)
+ return (1);
+ if (priorpage) {
+ if (priorpage + PAGE_SIZE != phys)
+ return (1);
+ /* check if crossing a DMA page boundary */
+ if (((u_int)priorpage ^ (u_int)phys) & dma_pgmsk)
+ return (1);
+ }
+ priorpage = phys;
+ }
+ return (0);
+}
+
+/*
+ * Query the progress of a transfer on a DMA channel.
+ *
+ * To avoid having to interrupt a transfer in progress, we sample
+ * each of the high and low databytes twice, and apply the following
+ * logic to determine the correct count.
+ *
+ * Reads are performed with interrupts disabled, thus it is to be
+ * expected that the time between reads is very small. At most
+ * one rollover in the low count byte can be expected within the
+ * four reads that are performed.
+ *
+ * There are three gaps in which a rollover can occur :
+ *
+ * - read low1
+ * gap1
+ * - read high1
+ * gap2
+ * - read low2
+ * gap3
+ * - read high2
+ *
+ * If a rollover occurs in gap1 or gap2, the low2 value will be
+ * greater than the low1 value. In this case, low2 and high2 are a
+ * corresponding pair.
+ *
+ * In any other case, low1 and high1 can be considered to be correct.
+ *
+ * The function returns the number of bytes remaining in the transfer,
+ * or -1 if the channel requested is not active.
+ *
+ */
+int
+isa_dmastatus(int chan)
+{
+ u_long cnt = 0;
+ int ffport, waport;
+ u_long low1, high1, low2, high2;
+
+ /* channel active? */
+ if ((dma_inuse & (1 << chan)) == 0) {
+ printf("isa_dmastatus: channel %d not active\n", chan);
+ return(-1);
+ }
+ /* channel busy? */
+
+ if (((dma_busy & (1 << chan)) == 0) &&
+ (dma_auto_mode & (1 << chan)) == 0 ) {
+ printf("chan %d not busy\n", chan);
+ return -2 ;
+ }
+ if (chan < 4) { /* low DMA controller */
+ ffport = DMA1_FFC;
+ waport = DMA1_CHN(chan) + 1;
+ } else { /* high DMA controller */
+ ffport = DMA2_FFC;
+ waport = DMA2_CHN(chan - 4) + 2;
+ }
+
+ disable_intr(); /* no interrupts Mr Jones! */
+ outb(ffport, 0); /* clear register LSB flipflop */
+ low1 = inb(waport);
+ high1 = inb(waport);
+ outb(ffport, 0); /* clear again */
+ low2 = inb(waport);
+ high2 = inb(waport);
+ enable_intr(); /* enable interrupts again */
+
+ /*
+ * Now decide if a wrap has tried to skew our results.
+ * Note that after TC, the count will read 0xffff, while we want
+ * to return zero, so we add and then mask to compensate.
+ */
+ if (low1 >= low2) {
+ cnt = (low1 + (high1 << 8) + 1) & 0xffff;
+ } else {
+ cnt = (low2 + (high2 << 8) + 1) & 0xffff;
+ }
+
+ if (chan >= 4) /* high channels move words */
+ cnt *= 2;
+ return(cnt);
+}
+
+/*
+ * Stop a DMA transfer currently in progress.
+ */
+int
+isa_dmastop(int chan)
+{
+ if ((dma_inuse & (1 << chan)) == 0)
+ printf("isa_dmastop: channel %d not acquired\n", chan);
+
+ if (((dma_busy & (1 << chan)) == 0) &&
+ ((dma_auto_mode & (1 << chan)) == 0)) {
+ printf("chan %d not busy\n", chan);
+ return -2 ;
+ }
+
+ if ((chan & 4) == 0) {
+ outb(DMA1_SMSK, (chan & 3) | 4 /* disable mask */);
+ } else {
+ outb(DMA2_SMSK, (chan & 3) | 4 /* disable mask */);
+ }
+ return(isa_dmastatus(chan));
+}
diff --git a/sys/i386/isa/isa_dma.h b/sys/i386/isa/isa_dma.h
new file mode 100644
index 0000000..3fe234c
--- /dev/null
+++ b/sys/i386/isa/isa_dma.h
@@ -0,0 +1,51 @@
+/*-
+ * Copyright (c) 1991 The Regents of the University of California.
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
+ *
+ * from: @(#)isa_device.h 7.1 (Berkeley) 5/9/91
+ * $Id: isa_device.h,v 1.57 1999/01/17 06:33:43 bde Exp $
+ */
+
+#ifndef _I386_ISA_ISA_DMA_H_
+#define _I386_ISA_ISA_DMA_H_
+
+#ifdef KERNEL
+void isa_dmacascade __P((int chan));
+void isa_dmadone __P((int flags, caddr_t addr, int nbytes, int chan));
+void isa_dmainit __P((int chan, u_int bouncebufsize));
+void isa_dmastart __P((int flags, caddr_t addr, u_int nbytes, int chan));
+int isa_dma_acquire __P((int chan));
+void isa_dma_release __P((int chan));
+int isa_dmastatus __P((int chan));
+int isa_dmastop __P((int chan));
+#endif /* KERNEL */
+
+#endif /* !_I386_ISA_ISA_DMA_H_ */
diff --git a/sys/i386/isa/nmi.c b/sys/i386/isa/nmi.c
index 944eb4e..4f7c1e9 100644
--- a/sys/i386/isa/nmi.c
+++ b/sys/i386/isa/nmi.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)isa.c 7.2 (Berkeley) 5/13/91
- * $Id: intr_machdep.c,v 1.16 1999/01/08 19:17:48 bde Exp $
+ * $Id: intr_machdep.c,v 1.17 1999/04/14 14:26:36 bde Exp $
*/
#include "opt_auto_eoi.h"
@@ -328,6 +328,7 @@ isa_get_nameunit(int id)
return ("clk0"); /* XXX may also be sloppy driver */
if (id == 1)
return ("rtc0");
+#if 0
for (dp = isa_devtab_bio; dp->id_driver != NULL; dp++)
if (dp->id_id == id)
goto found_device;
@@ -343,6 +344,7 @@ isa_get_nameunit(int id)
for (dp = isa_devtab_tty; dp->id_driver != NULL; dp++)
if (dp->id_id == id)
goto found_device;
+#endif
return "???";
found_device:
diff --git a/sys/i386/isa/npx.c b/sys/i386/isa/npx.c
index 2371e7b..dc2eb73 100644
--- a/sys/i386/isa/npx.c
+++ b/sys/i386/isa/npx.c
@@ -32,7 +32,7 @@
* SUCH DAMAGE.
*
* from: @(#)npx.c 7.2 (Berkeley) 5/12/91
- * $Id: npx.c,v 1.65 1999/01/08 16:29:59 bde Exp $
+ * $Id: npx.c,v 1.66 1999/03/28 23:28:18 dt Exp $
*/
#include "npx.h"
@@ -43,10 +43,14 @@
#include <sys/param.h>
#include <sys/systm.h>
+#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/malloc.h>
+#include <sys/module.h>
#include <sys/sysctl.h>
#include <sys/proc.h>
+#include <machine/bus.h>
+#include <sys/rman.h>
#ifdef NPX_DEBUG
#include <sys/syslog.h>
#endif
@@ -64,6 +68,7 @@
#ifndef SMP
#include <machine/clock.h>
#endif
+#include <machine/resource.h>
#include <machine/specialreg.h>
#include <machine/segments.h>
@@ -72,7 +77,6 @@
#include <i386/isa/intr_machdep.h>
#include <i386/isa/isa.h>
#endif
-#include <i386/isa/isa_device.h>
/*
* 387 and 287 Numeric Coprocessor Extension (NPX) Driver.
@@ -83,9 +87,6 @@
#define NPX_DISABLE_I586_OPTIMIZED_BZERO (1 << 1)
#define NPX_DISABLE_I586_OPTIMIZED_COPYIO (1 << 2)
-/* XXX - should be in header file. */
-ointhand2_t npxintr;
-
#ifdef __GNUC__
#define fldcw(addr) __asm("fldcw %0" : : "m" (*(addr)))
@@ -119,18 +120,15 @@ void stop_emulating __P((void));
typedef u_char bool_t;
-static int npxattach __P((struct isa_device *dvp));
-static int npxprobe __P((struct isa_device *dvp));
-static int npxprobe1 __P((struct isa_device *dvp));
+static int npx_attach __P((device_t dev));
+ void npx_intr __P((void *));
+static int npx_probe __P((device_t dev));
+static int npx_probe1 __P((device_t dev));
#ifdef I586_CPU
static long timezero __P((const char *funcname,
void (*func)(void *buf, size_t len)));
#endif /* I586_CPU */
-struct isa_driver npxdriver = {
- npxprobe, npxattach, "npx",
-};
-
int hw_float; /* XXX currently just alias for npx_exists */
SYSCTL_INT(_hw,HW_FLOATINGPT, floatingpoint,
@@ -191,12 +189,13 @@ __asm(" \n\
* need to use interrupts. Return 1 if device exists.
*/
static int
-npxprobe(dvp)
- struct isa_device *dvp;
+npx_probe(dev)
+ device_t dev;
{
-#ifdef SMP
+/*#ifdef SMP*/
+#if 1
- return npxprobe1(dvp);
+ return npx_probe1(dev);
#else /* SMP */
@@ -213,20 +212,20 @@ npxprobe(dvp)
* install suitable handlers and run with interrupts enabled so we
* won't need to do so much here.
*/
- npx_intrno = NRSVIDT + ffs(dvp->id_irq) - 1;
+ npx_intrno = NRSVIDT + 13;
save_eflags = read_eflags();
disable_intr();
save_icu1_mask = inb(IO_ICU1 + 1);
save_icu2_mask = inb(IO_ICU2 + 1);
save_idt_npxintr = idt[npx_intrno];
save_idt_npxtrap = idt[16];
- outb(IO_ICU1 + 1, ~(IRQ_SLAVE | dvp->id_irq));
- outb(IO_ICU2 + 1, ~(dvp->id_irq >> 8));
+ outb(IO_ICU1 + 1, ~IRQ_SLAVE);
+ outb(IO_ICU2 + 1, ~(1 << (13 - 8)));
setidt(16, probetrap, SDT_SYS386TGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
setidt(npx_intrno, probeintr, SDT_SYS386IGT, SEL_KPL, GSEL(GCODE_SEL, SEL_KPL));
npx_idt_probeintr = idt[npx_intrno];
enable_intr();
- result = npxprobe1(dvp);
+ result = npx_probe1(dev);
disable_intr();
outb(IO_ICU1 + 1, save_icu1_mask);
outb(IO_ICU2 + 1, save_icu2_mask);
@@ -239,8 +238,8 @@ npxprobe(dvp)
}
static int
-npxprobe1(dvp)
- struct isa_device *dvp;
+npx_probe1(dev)
+ device_t dev;
{
#ifndef SMP
u_short control;
@@ -280,21 +279,18 @@ npxprobe1(dvp)
*/
fninit();
-#ifdef SMP
-
+/*#ifdef SMP*/
+#if 1
/*
* Exception 16 MUST work for SMP.
*/
npx_irq13 = 0;
npx_ex16 = hw_float = npx_exists = 1;
- dvp->id_irq = 0; /* zap the interrupt */
- /*
- * special return value to flag that we do not
- * actually use any I/O registers
- */
- return (-1);
+ device_set_desc(dev, "math processor");
+ return (0);
-#else /* SMP */
+#else /* !SMP */
+ device_set_desc(dev, "math processor");
/*
* Don't use fwait here because it might hang.
@@ -335,14 +331,12 @@ npxprobe1(dvp)
* Good, exception 16 works.
*/
npx_ex16 = 1;
- dvp->id_irq = 0; /* zap the interrupt */
- /*
- * special return value to flag that we do not
- * actually use any I/O registers
- */
- return (-1);
+ return (0);
}
if (npx_intrs_while_probing != 0) {
+ int rid;
+ struct resource *r;
+ void *intr;
/*
* Bad, we are stuck with IRQ13.
*/
@@ -350,8 +344,30 @@ npxprobe1(dvp)
/*
* npxattach would be too late to set npx0_imask.
*/
- npx0_imask |= dvp->id_irq;
- return (IO_NPXSIZE);
+ npx0_imask |= (1 << 13);
+
+ /*
+ * We allocate these resources permanently,
+ * so there is no need to keep track of them.
+ */
+ rid = 0;
+ r = bus_alloc_resource(dev, SYS_RES_IOPORT,
+ &rid, IO_NPX, IO_NPX,
+ IO_NPXSIZE, RF_ACTIVE);
+ if (r == 0)
+ panic("npx: can't get ports");
+ rid = 0;
+ r = bus_alloc_resource(dev, SYS_RES_IRQ,
+ &rid, 13, 13,
+ 1, RF_ACTIVE);
+ if (r == 0)
+ panic("npx: can't get IRQ");
+ BUS_SETUP_INTR(device_get_parent(dev),
+ dev, r, npx_intr, 0, &intr);
+ if (intr == 0)
+ panic("npx: can't create intr");
+
+ return (0);
}
/*
* Worse, even IRQ13 is broken. Use emulator.
@@ -363,13 +379,7 @@ npxprobe1(dvp)
* emulator and say that it has been installed. XXX handle devices
* that aren't really devices better.
*/
- dvp->id_irq = 0;
- /*
- * special return value to flag that we do not
- * actually use any I/O registers
- */
- return (-1);
-
+ return (0);
#endif /* SMP */
}
@@ -377,14 +387,15 @@ npxprobe1(dvp)
* Attach routine - announce which it is, and wire into system
*/
int
-npxattach(dvp)
- struct isa_device *dvp;
+npx_attach(dev)
+ device_t dev;
{
- dvp->id_ointr = npxintr;
+ int flags;
- /* The caller has printed "irq 13" for the npx_irq13 case. */
- if (!npx_irq13) {
- printf("npx%d: ", dvp->id_unit);
+ device_print_prettyname(dev);
+ if (npx_irq13) {
+ printf("using IRQ 13 interface\n");
+ } else {
if (npx_ex16)
printf("INT 16 interface\n");
#if defined(MATH_EMULATE) || defined(GPL_MATH_EMULATE)
@@ -401,23 +412,26 @@ npxattach(dvp)
npxinit(__INITIAL_NPXCW__);
#ifdef I586_CPU
+ if (resource_int_value("npx", 0, "flags", &flags) != 0)
+ flags = 0;
+
if (cpu_class == CPUCLASS_586 && npx_ex16 &&
timezero("i586_bzero()", i586_bzero) <
timezero("bzero()", bzero) * 4 / 5) {
- if (!(dvp->id_flags & NPX_DISABLE_I586_OPTIMIZED_BCOPY)) {
+ if (!(flags & NPX_DISABLE_I586_OPTIMIZED_BCOPY)) {
bcopy_vector = i586_bcopy;
ovbcopy_vector = i586_bcopy;
}
- if (!(dvp->id_flags & NPX_DISABLE_I586_OPTIMIZED_BZERO))
+ if (!(flags & NPX_DISABLE_I586_OPTIMIZED_BZERO))
bzero = i586_bzero;
- if (!(dvp->id_flags & NPX_DISABLE_I586_OPTIMIZED_COPYIO)) {
+ if (!(flags & NPX_DISABLE_I586_OPTIMIZED_COPYIO)) {
copyin_vector = i586_copyin;
copyout_vector = i586_copyout;
}
}
#endif
- return (1); /* XXX unused */
+ return (0); /* XXX unused */
}
/*
@@ -494,8 +508,8 @@ npxexit(p)
* solution for signals other than SIGFPE.
*/
void
-npxintr(unit)
- int unit;
+npx_intr(dummy)
+ void *dummy;
{
int code;
struct intrframe *frame;
@@ -518,7 +532,7 @@ npxintr(unit)
/*
* Pass exception to process.
*/
- frame = (struct intrframe *)&unit; /* XXX */
+ frame = (struct intrframe *)&dummy; /* XXX */
if ((ISPL(frame->if_cs) == SEL_UPL) || (frame->if_eflags & PSL_VM)) {
/*
* Interrupt is essentially a trap, so we can afford to call
@@ -686,4 +700,31 @@ timezero(funcname, func)
}
#endif /* I586_CPU */
+static device_method_t npx_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, npx_probe),
+ DEVMETHOD(device_attach, npx_attach),
+ DEVMETHOD(device_detach, bus_generic_detach),
+ DEVMETHOD(device_shutdown, bus_generic_shutdown),
+ DEVMETHOD(device_suspend, bus_generic_suspend),
+ DEVMETHOD(device_resume, bus_generic_resume),
+
+ { 0, 0 }
+};
+
+static driver_t npx_driver = {
+ "npx",
+ npx_methods,
+ DRIVER_TYPE_MISC,
+ 1, /* no softc */
+};
+
+static devclass_t npx_devclass;
+
+/*
+ * We prefer to attach to the root nexus so that the usual case (exception 16)
+ * doesn't describe the processor as being `on isa'.
+ */
+DRIVER_MODULE(npx, nexus, npx_driver, npx_devclass, 0, 0);
+
#endif /* NNPX > 0 */
diff --git a/sys/i386/isa/rp.c b/sys/i386/isa/rp.c
index 3ac4ee9..e9357fa 100644
--- a/sys/i386/isa/rp.c
+++ b/sys/i386/isa/rp.c
@@ -1180,7 +1180,6 @@ int
rpattach(dev)
struct isa_device *dev;
{
- struct isa_device *idev;
dev_t rp_dev;
int iobase, unit, /*rpmajor,*/ oldspl;
int num_ports, num_chan, num_aiops;
@@ -1280,13 +1279,6 @@ struct isa_device *dev;
}
}
- idev = find_isadev(isa_devtab_tty, &rpdriver,
- RP_MPMASTER(dev) + rp_pcicount);
- if(idev == NULL) {
- printf("rp%d: master device %d not configured\n",
- dev->id_unit, RP_MPMASTER(dev));
- }
-/* printf("COOL!! Device is found!!\n");
for(rpmajor=0;rpmajor<nchrdev;rpmajor++)
if(cdevsw[rpmajor].d_open == rpopen)
printf("From %d entries: Found entry at major = %d\n",nchrdev,rpmajor);
diff --git a/sys/i386/isa/snd/sound.c b/sys/i386/isa/snd/sound.c
index 6a5a92d..267901e 100644
--- a/sys/i386/isa/snd/sound.c
+++ b/sys/i386/isa/snd/sound.c
@@ -236,7 +236,6 @@ int
pcmattach(struct isa_device * dev)
{
snddev_info *d = NULL ;
- struct isa_device *dvp;
int stat = 0;
dev->id_ointr = pcmintr;
@@ -292,9 +291,7 @@ pcmattach(struct isa_device * dev)
*/
if (dev->id_driver == NULL) {
dev->id_driver = &pcmdriver ;
- dvp=find_isadev(isa_devtab_tty, &pcmdriver, 0);
- if (dvp)
- dev->id_id = dvp->id_id;
+ dev->id_id = isa_compat_nextid();
}
/*
diff --git a/sys/i386/isa/sound/ad1848.c b/sys/i386/isa/sound/ad1848.c
index 243ed78..18751d4 100644
--- a/sys/i386/isa/sound/ad1848.c
+++ b/sys/i386/isa/sound/ad1848.c
@@ -165,6 +165,10 @@ short ipri_to_irq(u_short ipri);
void
adintr(unit)
{
+#if 1
+ /* this isn't ideal but should work */
+ ad1848_interrupt(-1);
+#else
static short unit_to_irq[4] = {9, -1, -1, -1};
struct isa_device *dev;
@@ -183,6 +187,7 @@ adintr(unit)
ad1848_interrupt(unit_to_irq[unit]);
}
}
+#endif
}
static int
diff --git a/sys/i386/isa/wd.c b/sys/i386/isa/wd.c
index fdf1fa6..9db2fee 100644
--- a/sys/i386/isa/wd.c
+++ b/sys/i386/isa/wd.c
@@ -34,7 +34,7 @@
* SUCH DAMAGE.
*
* from: @(#)wd.c 7.2 (Berkeley) 5/9/91
- * $Id: wd.c,v 1.192 1999/04/13 19:38:11 peter Exp $
+ * $Id: wd.c,v 1.193 1999/04/13 20:22:30 peter Exp $
*/
/* TODO:
@@ -73,6 +73,7 @@
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/conf.h>
+#include <sys/bus.h>
#include <sys/disklabel.h>
#include <sys/diskslice.h>
#include <sys/buf.h>
@@ -400,10 +401,10 @@ wdattach(struct isa_device *dvp)
#if defined(DEVFS)
int mynor;
#endif
- u_int unit, lunit;
- struct isa_device *wdup;
+ int unit, lunit, flags, i;
struct disk *du;
struct wdparams *wp;
+ static char buf[] = "wdcXXX";
dvp->id_intr = wdintr;
@@ -418,14 +419,22 @@ wdattach(struct isa_device *dvp)
} else
bufq_init(&wdtab[dvp->id_unit].controller_queue);
- for (wdup = isa_biotab_wdc; wdup->id_driver != 0; wdup++) {
- if (wdup->id_iobase != dvp->id_iobase)
+ sprintf(buf, "wdc%d", dvp->id_unit);
+ for (i = resource_query_string(-1, "at", buf);
+ i != -1;
+ i = resource_query_string(i, "at", buf)) {
+ if (strcmp(resource_query_name(i), "wd"))
+ /* Avoid a bit of foot shooting. */
continue;
- lunit = wdup->id_unit;
+
+ lunit = resource_query_unit(i);
if (lunit >= NWD)
continue;
- unit = wdup->id_physid;
+ if (resource_int_value("wd", lunit, "drive", &unit) != 0)
+ continue;
+ if (resource_int_value("wd", lunit, "flags", &flags) != 0)
+ flags = 0;
du = malloc(sizeof *du, M_TEMP, M_NOWAIT);
if (du == NULL)
@@ -450,7 +459,7 @@ wdattach(struct isa_device *dvp)
* Use the individual device flags or the controller
* flags.
*/
- du->cfg_flags = wdup->id_flags |
+ du->cfg_flags = flags |
((dvp->id_flags) >> (16 * unit));
if (wdgetctlr(du) == 0) {
OpenPOWER on IntegriCloud