PERFORCE change 61549 for review

Julian Elischer julian at FreeBSD.org
Wed Sep 15 11:57:03 PDT 2004


http://perforce.freebsd.org/chv.cgi?CH=61549

Change 61549 by julian at julian_ref on 2004/09/15 18:56:32

	IFC at 61548

Affected files ...

.. //depot/projects/nsched/sys/alpha/isa/isa_dma.c#3 integrate
.. //depot/projects/nsched/sys/amd64/isa/isa_dma.c#4 integrate
.. //depot/projects/nsched/sys/amd64/isa/isa_dma.h#3 delete
.. //depot/projects/nsched/sys/contrib/pf/net/if_pflog.c#6 integrate
.. //depot/projects/nsched/sys/contrib/pf/net/if_pfsync.c#7 integrate
.. //depot/projects/nsched/sys/contrib/pf/net/pf_if.c#3 integrate
.. //depot/projects/nsched/sys/contrib/pf/net/pf_ioctl.c#8 integrate
.. //depot/projects/nsched/sys/dev/aha/aha_mca.c#2 integrate
.. //depot/projects/nsched/sys/dev/amr/amr.c#5 integrate
.. //depot/projects/nsched/sys/dev/buslogic/bt_mca.c#2 integrate
.. //depot/projects/nsched/sys/dev/fdc/fdc.c#8 integrate
.. //depot/projects/nsched/sys/dev/fdc/fdc_isa.c#4 integrate
.. //depot/projects/nsched/sys/dev/fdc/fdc_pccard.c#3 integrate
.. //depot/projects/nsched/sys/dev/fdc/fdcvar.h#3 integrate
.. //depot/projects/nsched/sys/dev/md/md.c#11 integrate
.. //depot/projects/nsched/sys/dev/nge/if_nge.c#7 integrate
.. //depot/projects/nsched/sys/dev/nge/if_ngereg.h#2 integrate
.. //depot/projects/nsched/sys/dev/pst/pst-iop.h#2 integrate
.. //depot/projects/nsched/sys/dev/pst/pst-pci.c#2 integrate
.. //depot/projects/nsched/sys/dev/pst/pst-raid.c#2 integrate
.. //depot/projects/nsched/sys/i386/isa/isa_dma.c#4 integrate
.. //depot/projects/nsched/sys/i386/isa/isa_dma.h#3 delete
.. //depot/projects/nsched/sys/ia64/isa/isa_dma.c#3 integrate
.. //depot/projects/nsched/sys/isa/isavar.h#2 integrate
.. //depot/projects/nsched/sys/kern/kern_event.c#9 integrate
.. //depot/projects/nsched/sys/kern/kern_switch.c#31 integrate
.. //depot/projects/nsched/sys/kern/kern_thread.c#36 integrate
.. //depot/projects/nsched/sys/net/if_clone.c#3 integrate
.. //depot/projects/nsched/sys/pc98/pc98/isa_dma.c#4 integrate
.. //depot/projects/nsched/sys/vm/vm_page.c#9 integrate

Differences ...

==== //depot/projects/nsched/sys/alpha/isa/isa_dma.c#3 (text+ko) ====

@@ -44,7 +44,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/alpha/isa/isa_dma.c,v 1.11 2004/04/05 21:00:51 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/alpha/isa/isa_dma.c,v 1.12 2004/09/15 12:09:49 phk Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -93,10 +93,8 @@
 /*
  * Setup a DMA channel's bounce buffer.
  */
-void
-isa_dmainit(chan, bouncebufsize)
-	int chan;
-	u_int bouncebufsize;
+int
+isa_dma_init(int chan, u_int bouncebufsize, int flag __unused)
 {
 	static int initted = 0;
 	bus_addr_t boundary = chan >= 4 ? 0x20000 : 0x10000;
@@ -114,10 +112,10 @@
 
 #ifdef DIAGNOSTIC
 	if (chan & ~VALID_DMA_MASK)
-		panic("isa_dmainit: channel out of range");
+		panic("isa_dma_init: channel out of range");
 
 	if (dma_tag[chan] || dma_map[chan])
-		panic("isa_dmainit: impossible request"); 
+		panic("isa_dma_init: impossible request"); 
 #endif
 
 	if (bus_dma_tag_create(/*parent*/NULL,
@@ -132,13 +130,13 @@
 			       /*lockfunc*/busdma_lock_mutex,
 			       /*lockarg*/&Giant,
 			       &dma_tag[chan]) != 0) {
-		panic("isa_dmainit: unable to create dma tag\n");
+		panic("isa_dma_init: unable to create dma tag\n");
 	}
 	
 	if (bus_dmamap_create(dma_tag[chan], 0, &dma_map[chan])) {
-		panic("isa_dmainit: unable to create dma map\n");
+		panic("isa_dma_init: unable to create dma map\n");
 	}
-
+	return (0);
 }
 
 /*
@@ -349,7 +347,7 @@
 #endif
 
 	if (!dma_tag || !dma_map[chan])
-		panic("isa_dmastart: called without isa_dmainit");
+		panic("isa_dmastart: called without isa_dma_init");
 
 	dma_busy |= (1 << chan);
 

==== //depot/projects/nsched/sys/amd64/isa/isa_dma.c#4 (text+ko) ====

@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/amd64/isa/isa_dma.c,v 1.19 2004/08/16 22:51:13 peter Exp $");
+__FBSDID("$FreeBSD: src/sys/amd64/isa/isa_dma.c,v 1.20 2004/09/15 12:09:49 phk Exp $");
 
 /*
  * code to manage AT bus
@@ -96,15 +96,13 @@
 /*
  * Setup a DMA channel's bounce buffer.
  */
-void
-isa_dmainit(chan, bouncebufsize)
-	int chan;
-	u_int bouncebufsize;
+int
+isa_dma_init(int chan, u_int bouncebufsize, int flag)
 {
 	void *buf;
 
 	/*
-	 * If a DMA channel is shared, both drivers have to call isa_dmainit
+	 * If a DMA channel is shared, both drivers have to call isa_dma_init
 	 * since they don't know that the other driver will do it.
 	 * Just return if we're already set up good.
 	 * XXX: this only works if they agree on the bouncebuf size.  This
@@ -112,30 +110,30 @@
 	 * XXX: the same driver.
 	 */
 	if (dma_bouncebuf[chan] != NULL)
-		return;
+		return (0);
 
 #ifdef DIAGNOSTIC
 	if (chan & ~VALID_DMA_MASK)
-		panic("isa_dmainit: channel out of range");
+		panic("isa_dma_init: channel out of range");
 #endif
 
 	dma_bouncebufsize[chan] = bouncebufsize;
 
 	/* Try malloc() first.  It works better if it works. */
-	buf = malloc(bouncebufsize, M_DEVBUF, M_NOWAIT);
+	buf = malloc(bouncebufsize, M_DEVBUF, flag);
 	if (buf != NULL) {
 		if (isa_dmarangecheck(buf, bouncebufsize, chan) == 0) {
 			dma_bouncebuf[chan] = buf;
-			return;
+			return (0);
 		}
 		free(buf, M_DEVBUF);
 	}
-	buf = contigmalloc(bouncebufsize, M_DEVBUF, M_NOWAIT, 0ul, 0xfffffful,
+	buf = contigmalloc(bouncebufsize, M_DEVBUF, flag, 0ul, 0xfffffful,
 			   1ul, chan & 4 ? 0x20000ul : 0x10000ul);
 	if (buf == NULL)
-		printf("isa_dmainit(%d, %d) failed\n", chan, bouncebufsize);
-	else
-		dma_bouncebuf[chan] = buf;
+		return (ENOMEM);
+	dma_bouncebuf[chan] = buf;
+	return (0);
 }
 
 /*

==== //depot/projects/nsched/sys/contrib/pf/net/if_pflog.c#6 (text+ko) ====

@@ -1,4 +1,4 @@
-/*	$FreeBSD: src/sys/contrib/pf/net/if_pflog.c,v 1.9 2004/06/22 20:13:24 brooks Exp $	*/
+/*	$FreeBSD: src/sys/contrib/pf/net/if_pflog.c,v 1.10 2004/09/14 03:12:01 mlaier Exp $	*/
 /*	$OpenBSD: if_pflog.c,v 1.11 2003/12/31 11:18:25 cedric Exp $	*/
 /*
  * The authors of this code are John Ioannidis (ji at tla.org),
@@ -377,6 +377,6 @@
 
 #define PFLOG_MODVER 1
 
-DECLARE_MODULE(pflog, pflog_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
+DECLARE_MODULE(pflog, pflog_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY);
 MODULE_VERSION(pflog, PFLOG_MODVER);
 #endif /* __FreeBSD__ */

==== //depot/projects/nsched/sys/contrib/pf/net/if_pfsync.c#7 (text+ko) ====

@@ -1,4 +1,4 @@
-/*	$FreeBSD: src/sys/contrib/pf/net/if_pfsync.c,v 1.11 2004/08/14 15:32:40 dwmalone Exp $	*/
+/*	$FreeBSD: src/sys/contrib/pf/net/if_pfsync.c,v 1.12 2004/09/14 03:12:01 mlaier Exp $	*/
 /*	$OpenBSD: if_pfsync.c,v 1.26 2004/03/28 18:14:20 mcbride Exp $	*/
 
 /*
@@ -1662,6 +1662,6 @@
 
 #define PFSYNC_MODVER 1
 
-DECLARE_MODULE(pfsync, pfsync_mod, SI_SUB_PSEUDO, SI_ORDER_ANY);
+DECLARE_MODULE(pfsync, pfsync_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY);
 MODULE_VERSION(pfsync, PFSYNC_MODVER);
 #endif /* __FreeBSD__ */

==== //depot/projects/nsched/sys/contrib/pf/net/pf_if.c#3 (text+ko) ====

@@ -1,4 +1,4 @@
-/*	$FreeBSD: src/sys/contrib/pf/net/pf_if.c,v 1.5 2004/08/16 17:58:12 mlaier Exp $ */
+/*	$FreeBSD: src/sys/contrib/pf/net/pf_if.c,v 1.6 2004/09/14 15:20:24 mlaier Exp $ */
 /*	$OpenBSD: pf_if.c,v 1.11 2004/03/15 11:38:23 cedric Exp $ */
 /* add	$OpenBSD: pf_if.c,v 1.19 2004/08/11 12:06:44 henning Exp $ */
 
@@ -638,8 +638,16 @@
 		af = ia->ifa_addr->sa_family;
 		if (af != AF_INET && af != AF_INET6)
 			continue;
-#ifdef notyet
-		if (!(ia->ifa_flags & IFA_ROUTE))
+#ifdef __FreeBSD__
+		/*
+		 * XXX: For point-to-point interfaces, (ifname:0) and IPv4,
+		 *	jump over addresses without a proper route to work
+		 *	around a problem with ppp not fully removing the
+		 *	address used during IPCP.
+		 */
+		if ((ifp->if_flags & IFF_POINTOPOINT) &&
+		    !(ia->ifa_flags & IFA_ROUTE) &&
+		    (flags & PFI_AFLAG_NOALIAS) && (af == AF_INET))
 			continue;
 #endif
 		if ((flags & PFI_AFLAG_BROADCAST) && af == AF_INET6)

==== //depot/projects/nsched/sys/contrib/pf/net/pf_ioctl.c#8 (text+ko) ====

@@ -1,4 +1,4 @@
-/*	$FreeBSD: src/sys/contrib/pf/net/pf_ioctl.c,v 1.13 2004/08/22 15:23:48 mlaier Exp $	*/
+/*	$FreeBSD: src/sys/contrib/pf/net/pf_ioctl.c,v 1.14 2004/09/14 03:12:01 mlaier Exp $	*/
 /*	$OpenBSD: pf_ioctl.c,v 1.112.2.2 2004/07/24 18:28:12 brad Exp $ */
 
 /*
@@ -3411,6 +3411,6 @@
 	0
 };
 
-DECLARE_MODULE(pf, pf_mod, SI_SUB_PSEUDO, SI_ORDER_FIRST);
+DECLARE_MODULE(pf, pf_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_FIRST);
 MODULE_VERSION(pf, PF_MODVER);
 #endif	/* __FreeBSD__ */

==== //depot/projects/nsched/sys/dev/aha/aha_mca.c#2 (text+ko) ====

@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/aha/aha_mca.c,v 1.11 2004/03/17 17:50:24 njl Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/aha/aha_mca.c,v 1.12 2004/09/15 11:58:34 phk Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -41,7 +41,7 @@
 #include <machine/resource.h>
 #include <sys/rman.h>
 
-#include <i386/isa/isa_dma.h>
+#include <isa/isavar.h>
 
 #include <dev/mca/mca_busreg.h>
 #include <dev/mca/mca_busvar.h>

==== //depot/projects/nsched/sys/dev/amr/amr.c#5 (text+ko) ====

@@ -55,7 +55,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/amr/amr.c,v 1.54 2004/08/16 17:23:09 ambrisko Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/amr/amr.c,v 1.55 2004/09/14 16:36:12 scottl Exp $");
 
 /*
  * Driver for the AMI MegaRaid family of controllers.
@@ -708,7 +708,7 @@
     if ((result = malloc(bufsize, M_DEVBUF, M_NOWAIT)) == NULL)
 	goto out;
     /* set command flags */
-    ac->ac_flags |= AMR_CMD_PRIORITY | AMR_CMD_DATAOUT;
+    ac->ac_flags |= AMR_CMD_PRIORITY | AMR_CMD_DATAIN;
     
     /* point the command at our data */
     ac->ac_data = result;

==== //depot/projects/nsched/sys/dev/buslogic/bt_mca.c#2 (text+ko) ====

@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/buslogic/bt_mca.c,v 1.9 2004/03/17 17:50:29 njl Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/buslogic/bt_mca.c,v 1.10 2004/09/15 11:58:34 phk Exp $");
 
 /*
  * Written using the bt_isa/bt_pci code as a reference.
@@ -55,7 +55,7 @@
 #include <dev/mca/mca_busreg.h>
 #include <dev/mca/mca_busvar.h>
 
-#include <i386/isa/isa_dma.h>
+#include <isa/isavar.h>
 
 #include <dev/buslogic/btreg.h>
 

==== //depot/projects/nsched/sys/dev/fdc/fdc.c#8 (text+ko) ====

@@ -51,7 +51,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/fdc/fdc.c,v 1.286 2004/08/27 17:08:24 phk Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/fdc/fdc.c,v 1.288 2004/09/14 17:28:51 imp Exp $");
 
 #include "opt_fdc.h"
 
@@ -197,9 +197,18 @@
 #define	FDCTL	7	/* Control Register (W) */
 
 /*
- * this is the secret PIO data port (offset from base)
+ * The YE-DATA PC Card floppies use PIO to read in the data rather than
+ * DMA due to the wild variability of DMA for the PC Card devices.  In
+ * addition, if we cannot setup the DMA resources for the ISA attachment,
+ * we'll use this same offset for data transfer.
+ *
+ * For this mode, offset 0 and 1 must be used to setup the transfer
+ * for this floppy.  This means they are only available on those systems
+ * that map them to the floppy drive.  Newer systems do not do this, and
+ * we should likely prohibit access to them (or disallow NODMA to be set).
  */
-#define FDC_YE_DATAPORT 6
+#define FDBCDR		0	/* And 1 */
+#define FD_YE_DATAPORT	6	/* Drive Data port */
 
 #define	FDI_DCHG	0x80	/* diskette has been changed */
 				/* requires drive and motor being selected */
@@ -337,6 +346,19 @@
 	return bus_space_read_1(fdc->ctlt, fdc->ctlh, fdc->ctl_off);
 }
 
+/*
+ * Magic pseudo-DMA initialization for YE FDC. Sets count and
+ * direction.
+ */
+static void
+fdbcdr_wr(struct fdc_data *fdc, int iswrite, uint16_t count)
+{
+	bus_space_write_1(fdc->portt, fdc->porth, fdc->port_off + FDBCDR,
+	    (count - 1) & 0xff);
+	bus_space_write_1(fdc->portt, fdc->porth, fdc->port_off + FDBCDR + 1,
+	  ((iswrite ? 0x80 : 0) | (((count - 1) >> 8) & 0x7f)));
+}
+
 static int
 fdc_err(struct fdc_data *fdc, const char *s)
 {
@@ -634,18 +656,6 @@
 }
 
 /*
- * Magic pseudo-DMA initialization for YE FDC. Sets count and
- * direction.
- */
-#define SET_BCDR(fdc,wr,cnt,port) \
-	do { \
-	bus_space_write_1(fdc->portt, fdc->porth, fdc->port_off + port,	 \
-	    ((cnt)-1) & 0xff);						 \
-	bus_space_write_1(fdc->portt, fdc->porth, fdc->port_off + port + 1, \
-	    ((wr ? 0x80 : 0) | ((((cnt)-1) >> 8) & 0x7f))); \
-	} while (0)
-
-/*
  * fdc_pio(): perform programmed IO read/write for YE PCMCIA floppy.
  */
 static void
@@ -660,13 +670,13 @@
 	count = fdc->fd->fd_iosize;
 
 	if (bp->bio_cmd == BIO_READ) {
-		SET_BCDR(fdc, 0, count, 0);
+		fdbcdr_wr(fdc, 0, count);
 		bus_space_read_multi_1(fdc->portt, fdc->porth, fdc->port_off +
-		    FDC_YE_DATAPORT, cptr, count);
+		    FD_YE_DATAPORT, cptr, count);
 	} else {
 		bus_space_write_multi_1(fdc->portt, fdc->porth, fdc->port_off +
-		    FDC_YE_DATAPORT, cptr, count);
-		SET_BCDR(fdc, 0, count, 0);
+		    FD_YE_DATAPORT, cptr, count);
+		fdbcdr_wr(fdc, 0, count);	/* needed? */
 	}
 }
 
@@ -940,7 +950,7 @@
 	/* Do PIO if we have to */
 	if (fdc->flags & FDC_NODMA) {
 		if (bp->bio_cmd & (BIO_READ|BIO_WRITE|BIO_FMT))
-			SET_BCDR(fdc, 1, fd->fd_iosize, 0);
+			fdbcdr_wr(fdc, 1, fd->fd_iosize);
 		if (bp->bio_cmd & (BIO_WRITE|BIO_FMT))
 			fdc_pio(fdc);
 	}
@@ -1484,39 +1494,30 @@
 	device_t dev;
 
 	dev = fdc->fdc_dev;
-	if (fdc->fdc_intr) {
+	if (fdc->fdc_intr)
 		BUS_TEARDOWN_INTR(device_get_parent(dev), dev, fdc->res_irq,
 		    fdc->fdc_intr);
-		fdc->fdc_intr = NULL;
-	}
-	if (fdc->res_irq != 0) {
-		bus_deactivate_resource(dev, SYS_RES_IRQ, fdc->rid_irq,
-					fdc->res_irq);
+	fdc->fdc_intr = NULL;
+	if (fdc->res_irq != NULL)
 		bus_release_resource(dev, SYS_RES_IRQ, fdc->rid_irq,
-				     fdc->res_irq);
-		fdc->res_irq = NULL;
-	}
-	if (fdc->res_ctl != 0) {
-		bus_deactivate_resource(dev, SYS_RES_IOPORT, fdc->rid_ctl,
-					fdc->res_ctl);
+		    fdc->res_irq);
+	fdc->res_irq = NULL;
+	if (fdc->res_ctl != NULL)
 		bus_release_resource(dev, SYS_RES_IOPORT, fdc->rid_ctl,
-				     fdc->res_ctl);
-		fdc->res_ctl = NULL;
-	}
-	if (fdc->res_ioport != 0) {
-		bus_deactivate_resource(dev, SYS_RES_IOPORT, fdc->rid_ioport,
-					fdc->res_ioport);
+		    fdc->res_ctl);
+	fdc->res_ctl = NULL;
+	if (fdc->res_sts != NULL)
+		bus_release_resource(dev, SYS_RES_IOPORT, fdc->rid_sts,
+		    fdc->res_sts);
+	fdc->res_sts = NULL;
+	if (fdc->res_ioport != NULL)
 		bus_release_resource(dev, SYS_RES_IOPORT, fdc->rid_ioport,
-				     fdc->res_ioport);
-		fdc->res_ioport = NULL;
-	}
-	if (fdc->res_drq != 0) {
-		bus_deactivate_resource(dev, SYS_RES_DRQ, fdc->rid_drq,
-					fdc->res_drq);
+		    fdc->res_ioport);
+	fdc->res_ioport = NULL;
+	if (fdc->res_drq != NULL)
 		bus_release_resource(dev, SYS_RES_DRQ, fdc->rid_drq,
-				     fdc->res_drq);
-		fdc->res_drq = NULL;
-	}
+		    fdc->res_drq);
+	fdc->res_drq = NULL;
 }
 
 int
@@ -1685,7 +1686,7 @@
 		device_printf(dev, "does not respond\n");
 		return (error);
 	}
-	error = BUS_SETUP_INTR(device_get_parent(dev), dev, fdc->res_irq,
+	error = bus_setup_intr(dev, fdc->res_irq,
            INTR_TYPE_BIO | INTR_ENTROPY | INTR_FAST | INTR_MPSAFE,
 	   fdc_intr, fdc, &fdc->fdc_intr);
 	if (error) {

==== //depot/projects/nsched/sys/dev/fdc/fdc_isa.c#4 (text+ko) ====

@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/fdc/fdc_isa.c,v 1.12 2004/08/31 20:37:10 imp Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/fdc/fdc_isa.c,v 1.13 2004/09/14 07:06:49 imp Exp $");
 
 #include <sys/param.h>
 #include <sys/bio.h>
@@ -57,9 +57,8 @@
 int
 fdc_isa_alloc_resources(device_t dev, struct fdc_data *fdc)
 {
-	int ispnp, nports;
+	int nports = 6;
 
-	ispnp = (fdc->flags & FDC_ISPNP) != 0;
 	fdc->fdc_dev = dev;
 	fdc->rid_ioport = 0;
 	fdc->rid_irq = 0;
@@ -69,99 +68,89 @@
 	/*
 	 * On standard ISA, we don't just use an 8 port range
 	 * (e.g. 0x3f0-0x3f7) since that covers an IDE control
-	 * register at 0x3f6.
+	 * register at 0x3f6.  So, on older hardware, we use
+	 * 0x3f0-0x3f5 and 0x3f7.  However, some BIOSs omit the
+	 * control port, while others start at 0x3f2.  Of the latter,
+	 * sometimes we have two resources, other times we have one.
+	 * We have to deal with the following cases:
+	 *
+	 * 1:	0x3f0-0x3f5			# very rare
+	 * 2:	0x3f0				# hints -> 0x3f0-0x3f5,0x3f7
+	 * 3:	0x3f0-0x3f5,0x3f7		# Most common
+	 * 4:	0x3f2-0x3f5,0x3f7		# Second most common
+	 * 5:	0x3f2-0x3f5			# implies 0x3f7 too.
+	 * 6:	0x3f2-0x3f3,0x3f4-0x3f5,0x3f7	# becoming common
+	 * 7:	0x3f2-0x3f3,0x3f4-0x3f5		# rare
 	 *
-	 * Isn't PC hardware wonderful.
+	 * The following code is generic for any value of 0x3fx :-)
 	 */
-	nports = ispnp ? 1 : 6;
 
 	/*
-	 * Some ACPI BIOSen have _CRS objects for the floppy device that
-	 * split the I/O port resource into several resources.  We detect
-	 * this case by checking if there are more than 2 IOPORT resources.
-	 * If so, we use the resource with the smallest start address as
-	 * the port RID and the largest start address as the control RID.
+	 * First, allocated the main range of ports.  In the best of
+	 * worlds, this is 4 or 6 ports.  In others, well, that's
+	 * why this function is so complicated.
 	 */
-	if (bus_get_resource_count(dev, SYS_RES_IOPORT, 2) != 0) {
-		u_long min_start, max_start, tmp;
-		int i;
-
-		/* Find the min/max start addresses and their RIDs. */
-		max_start = 0ul;
-		min_start = ~0ul;
-		for (i = 0; bus_get_resource_count(dev, SYS_RES_IOPORT, i) > 0;
-		    i++) {
-			tmp = bus_get_resource_start(dev, SYS_RES_IOPORT, i);
-			KASSERT(tmp != 0, ("bogus resource"));
-			if (tmp < min_start) {
-				min_start = tmp;
-				fdc->rid_ioport = i;
-			}
-			if (tmp > max_start) {
-				max_start = tmp;
-				fdc->rid_ctl = i;
-			}
-		}
-	}
-
 	fdc->res_ioport = bus_alloc_resource(dev, SYS_RES_IOPORT,
 	    &fdc->rid_ioport, 0ul, ~0ul, nports, RF_ACTIVE);
 	if (fdc->res_ioport == 0) {
-		device_printf(dev, "cannot reserve I/O port range (%d ports)\n",
-			      nports);
-		return ENXIO;
+		device_printf(dev, "cannot allocate I/O port (%d ports)\n",
+		    nports);
+		return (ENXIO);
 	}
 	fdc->portt = rman_get_bustag(fdc->res_ioport);
 	fdc->porth = rman_get_bushandle(fdc->res_ioport);
 
 	/*
-	 * Some BIOSen report the device at 0x3f2-0x3f5,0x3f7
-	 * and some at 0x3f0-0x3f5,0x3f7. We detect the former
-	 * by checking the size and adjust the port address
-	 * accordingly.
+	 * Handle cases 4-7 above
 	 */
-	if (bus_get_resource_count(dev, SYS_RES_IOPORT, 0) == 4)
-		fdc->port_off = -2;
+	fdc->port_off = -(fdc->porth & 0x7);
 
 	/*
-	 * Register the control port range as rid 1 if it
-	 * isn't there already. Most PnP BIOSen will have
-	 * already done this but non-PnP configurations don't.
-	 *
-	 * And some (!!) report 0x3f2-0x3f5 and completely
-	 * leave out the control register!  It seems that some
-	 * non-antique controller chips have a different
-	 * method of programming the transfer speed which
-	 * doesn't require the control register, but it's
-	 * mighty bogus as the chip still responds to the
-	 * address for the control register.
+	 * Deal with case 6 and 7: FDSTS and FDSATA are in rid 1.
 	 */
-	if (bus_get_resource_count(dev, SYS_RES_IOPORT, 1) == 0) {
-		u_long ctlstart;
-		/* Find the control port, usually 0x3f7 */
-		ctlstart = rman_get_start(fdc->res_ioport) + fdc->port_off + 7;
-		bus_set_resource(dev, SYS_RES_IOPORT, 1, ctlstart, 1);
+	if (rman_get_size(fdc->res_ioport) == 2) {
+		fdc->rid_sts = 1;
+		fdc->res_sts = bus_alloc_resource_any(dev, SYS_RES_IOPORT,
+		    &fdc->rid_sts, RF_ACTIVE);
+		if (fdc->res_sts == NULL) {
+			device_printf(dev, "Can't alloc rid 1");
+			fdc_release_resources(fdc);
+			return (ENXIO);
+		}
+		fdc->rid_ctl++;
+		fdc->sts_off = -4;
+		fdc->stst = rman_get_bustag(fdc->res_sts);
+		fdc->stsh = rman_get_bushandle(fdc->res_sts);
+	} else {
+		fdc->res_sts = NULL;
+		fdc->sts_off = fdc->port_off;
+		fdc->stst = fdc->portt;
+		fdc->stsh = fdc->porth;
 	}
 
 	/*
-	 * Now (finally!) allocate the control port.
+	 * allocate the control port.  For cases 1, 2, 5 and 7, we
+	 * fake it from the ioports resource.  XXX IS THIS THE RIGHT THING
+	 * TO DO, OR SHOULD WE CREATE A NEW RID? (I think we need a new rid)
 	 */
 	fdc->res_ctl = bus_alloc_resource_any(dev, SYS_RES_IOPORT,
 	    &fdc->rid_ctl, RF_ACTIVE);
-	if (fdc->res_ctl == 0) {
-		device_printf(dev,
-		    "cannot reserve control I/O port range (control port)\n");
-		return ENXIO;
+	if (fdc->res_ctl == NULL) {
+		fdc->ctl_off = 7 + fdc->port_off;
+		fdc->res_ctl = NULL;
+		fdc->ctlt = fdc->portt;
+		fdc->ctlh = fdc->porth;
+	} else {
+		fdc->ctl_off = 0;
+		fdc->ctlt = rman_get_bustag(fdc->res_ctl);
+		fdc->ctlh = rman_get_bushandle(fdc->res_ctl);
 	}
-	fdc->ctlt = rman_get_bustag(fdc->res_ctl);
-	fdc->ctlh = rman_get_bushandle(fdc->res_ctl);
-	fdc->ctl_off = 0;
 
 	fdc->res_irq = bus_alloc_resource_any(dev, SYS_RES_IRQ, &fdc->rid_irq,
-					      RF_ACTIVE | RF_SHAREABLE);
+	    RF_ACTIVE | RF_SHAREABLE);
 	if (fdc->res_irq == 0) {
 		device_printf(dev, "cannot reserve interrupt line\n");
-		return ENXIO;
+		return (ENXIO);
 	}
 
 	if ((fdc->flags & FDC_NODMA) == 0) {
@@ -169,12 +158,13 @@
 		    &fdc->rid_drq, RF_ACTIVE | RF_SHAREABLE);
 		if (fdc->res_drq == 0) {
 			device_printf(dev, "cannot reserve DMA request line\n");
+			/* This is broken and doesn't work for ISA case */
 			fdc->flags |= FDC_NODMA;
 		} else
 			fdc->dmachan = rman_get_start(fdc->res_drq);
 	}
 
-	return 0;
+	return (0);
 }
 
 static int

==== //depot/projects/nsched/sys/dev/fdc/fdc_pccard.c#3 (text+ko) ====

@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/fdc/fdc_pccard.c,v 1.9 2004/08/20 15:14:25 phk Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/fdc/fdc_pccard.c,v 1.10 2004/09/14 07:06:49 imp Exp $");
 
 #include <sys/param.h>
 #include <sys/bio.h>
@@ -65,6 +65,9 @@
 	}
 	fdc->portt = rman_get_bustag(fdc->res_ioport);
 	fdc->porth = rman_get_bushandle(fdc->res_ioport);
+	fdc->stst = fdc->portt;
+	fdc->stsh = fdc->porth;
+	fdc->sts_off = 0;
 	fdc->ctlt = fdc->portt;
 	fdc->ctlh = fdc->porth;
 	fdc->ctl_off = 7;
@@ -86,8 +89,7 @@
 
 	if ((pp = pccard_product_lookup(dev, fdc_pccard_products,
 	    sizeof(fdc_pccard_products[0]), NULL)) != NULL) {
-		if (pp->pp_name != NULL)
-			device_set_desc(dev, pp->pp_name);
+		device_set_desc(dev, "PC Card Floppy");
 		return (0);
 	}
 	return (ENXIO);
@@ -98,8 +100,7 @@
 {
 	int error;
 	struct	fdc_data *fdc;
-
-	return ENXIO;
+	device_t child;
 
 	fdc = device_get_softc(dev);
 	fdc->flags = FDC_NODMA;
@@ -107,6 +108,11 @@
 	error = fdc_pccard_alloc_resources(dev, fdc);
 	if (error == 0)
 		error = fdc_attach(dev);
+	if (error == 0) {
+		child = fdc_add_child(dev, "fd", -1);
+		device_set_flags(child, 0x24);
+		error = bus_generic_attach(dev);
+	}
 	if (error)
 		fdc_release_resources(fdc);
 	return (error);

==== //depot/projects/nsched/sys/dev/fdc/fdcvar.h#3 (text+ko) ====

@@ -25,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/dev/fdc/fdcvar.h,v 1.4 2004/08/20 15:14:25 phk Exp $
+ * $FreeBSD: src/sys/dev/fdc/fdcvar.h,v 1.5 2004/09/14 07:06:49 imp Exp $
  */
 
 /* XXX should audit this file to see if additional copyrights needed */
@@ -57,14 +57,17 @@
 	int	fdc_errs;	/* number of logged errors */
 	struct	bio_queue_head head;
 	struct	bio *bp;	/* active buffer */
-	struct	resource *res_ioport, *res_ctl, *res_irq, *res_drq;
-	int	rid_ioport, rid_ctl, rid_irq, rid_drq;
-	int	port_off;
+	struct	resource *res_ioport, *res_sts, *res_ctl, *res_irq, *res_drq;
+	int	rid_ioport, rid_sts, rid_ctl, rid_irq, rid_drq;
 	bus_space_tag_t portt;
 	bus_space_handle_t porth;
+	bus_space_tag_t stst;
+	bus_space_handle_t stsh;
 	bus_space_tag_t ctlt;
 	bus_space_handle_t ctlh;
+	int	port_off;
 	int	ctl_off;
+	int	sts_off;
 	void	*fdc_intr;
 	struct	device *fdc_dev;
 	struct mtx fdc_mtx;

==== //depot/projects/nsched/sys/dev/md/md.c#11 (text+ko) ====

@@ -6,7 +6,7 @@
  * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
  * ----------------------------------------------------------------------------
  *
- * $FreeBSD: src/sys/dev/md/md.c,v 1.130 2004/09/07 07:54:45 phk Exp $
+ * $FreeBSD: src/sys/dev/md/md.c,v 1.134 2004/09/14 19:55:07 pjd Exp $
  *
  */
 
@@ -828,6 +828,7 @@
 		}
 	}
 	if (error)  {
+		uma_zdestroy(sc->uma);
 		mddestroy(sc, NULL);
 		return (error);
 	}
@@ -891,15 +892,16 @@
 	NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, mdio->md_file, td);
 	error = vn_open(&nd, &flags, 0, -1);
 	if (error) {
+		NDFREE(&nd, NDF_ONLY_PNBUF);
 		if (error != EACCES && error != EPERM && error != EROFS)
 			return (error);
 		flags &= ~FWRITE;
 		NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, mdio->md_file, td);
 		error = vn_open(&nd, &flags, 0, -1);
-		if (error)
-			return (error);
 	}
 	NDFREE(&nd, NDF_ONLY_PNBUF);
+	if (error)
+		return (error);
 	if (nd.ni_vp->v_type != VREG ||
 	    (error = VOP_GETATTR(nd.ni_vp, &vattr, td->td_ucred, td))) {
 		VOP_UNLOCK(nd.ni_vp, 0, td);
@@ -938,11 +940,13 @@
 	else
 		sc->nsect = vattr.va_size / sc->secsize; /* XXX: round up ? */
 	if (sc->nsect == 0) {
+		(void) vn_close(nd.ni_vp, flags, td->td_ucred, td);
 		mddestroy(sc, td);
 		return (EINVAL);
 	}
 	error = mdsetcred(sc, td->td_ucred);
 	if (error) {
+		(void) vn_close(nd.ni_vp, flags, td->td_ucred, td);
 		mddestroy(sc, td);
 		return (error);
 	}
@@ -1053,6 +1057,8 @@
 	}
 	error = mdsetcred(sc, td->td_ucred);
 	if (error) {
+		vm_object_deallocate(sc->object);
+		sc->object = NULL;
 		mddestroy(sc, td);
 		return (error);
 	}

==== //depot/projects/nsched/sys/dev/nge/if_nge.c#7 (text+ko) ====

@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/dev/nge/if_nge.c,v 1.65 2004/08/13 23:22:53 rwatson Exp $");
+__FBSDID("$FreeBSD: src/sys/dev/nge/if_nge.c,v 1.68 2004/09/15 03:39:17 alc Exp $");
 
 /*
  * National Semiconductor DP83820/DP83821 gigabit ethernet driver
@@ -149,20 +149,21 @@
 static int nge_attach(device_t);
 static int nge_detach(device_t);
 
-static int nge_alloc_jumbo_mem(struct nge_softc *);
-static void nge_free_jumbo_mem(struct nge_softc *);
-static void *nge_jalloc(struct nge_softc *);
-static void nge_jfree(void *, void *);
-
 static int nge_newbuf(struct nge_softc *, struct nge_desc *, struct mbuf *);
 static int nge_encap(struct nge_softc *, struct mbuf *, u_int32_t *);
+#ifdef NGE_FIXUP_RX
+static __inline void nge_fixup_rx (struct mbuf *);
+#endif
 static void nge_rxeof(struct nge_softc *);
 static void nge_txeof(struct nge_softc *);
 static void nge_intr(void *);
 static void nge_tick(void *);
+static void nge_tick_locked(struct nge_softc *);
 static void nge_start(struct ifnet *);
+static void nge_start_locked(struct ifnet *);
 static int nge_ioctl(struct ifnet *, u_long, caddr_t);
 static void nge_init(void *);
+static void nge_init_locked(struct nge_softc *);
 static void nge_stop(struct nge_softc *);
 static void nge_watchdog(struct ifnet *);
 static void nge_shutdown(device_t);
@@ -441,9 +442,7 @@
 	struct nge_mii_frame	*frame;
 	
 {
-	int			i, ack, s;
-
-	s = splimp();
+	int			i, ack;
 
 	/*
 	 * Set up frame for RX.
@@ -518,8 +517,6 @@
 	SIO_SET(NGE_MEAR_MII_CLK);
 	DELAY(1);
 
-	splx(s);
-
 	if (ack)
 		return(1);
 	return(0);
@@ -534,9 +531,7 @@
 	struct nge_mii_frame	*frame;
 	
 {
-	int			s;
 
-	s = splimp();
 	/*
 	 * Set up frame for TX.
 	 */
@@ -570,8 +565,6 @@
 	 */
 	SIO_CLR(NGE_MEAR_MII_DIR);
 
-	splx(s);
-
 	return(0);
 }
 
@@ -680,6 +673,7 @@
 	u_int32_t		h = 0, i, filtsave;
 	int			bit, index;
 
+	NGE_LOCK_ASSERT(sc);
 	ifp = &sc->arpcom.ac_if;
 
 	if (ifp->if_flags & IFF_ALLMULTI || ifp->if_flags & IFF_PROMISC) {
@@ -791,21 +785,17 @@
 nge_attach(dev)
 	device_t		dev;
 {
-	int			s;
 	u_char			eaddr[ETHER_ADDR_LEN];
 	struct nge_softc	*sc;
 	struct ifnet		*ifp;
 	int			unit, error = 0, rid;
 	const char		*sep = "";
 
-	s = splimp();
-
 	sc = device_get_softc(dev);
 	unit = device_get_unit(dev);
 	bzero(sc, sizeof(struct nge_softc));
 
-	mtx_init(&sc->nge_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK,
-	    MTX_DEF | MTX_RECURSE);
+	NGE_LOCK_INIT(sc, device_get_nameunit(dev));
 	/*
 	 * Map control/status registers.
 	 */
@@ -835,16 +825,6 @@
 		goto fail;
 	}
 
-	error = bus_setup_intr(dev, sc->nge_irq, INTR_TYPE_NET,
-	    nge_intr, sc, &sc->nge_intrhand);
-
-	if (error) {
-		bus_release_resource(dev, SYS_RES_IRQ, 0, sc->nge_irq);
-		bus_release_resource(dev, NGE_RES, NGE_RID, sc->nge_res);
-		printf("nge%d: couldn't set up irq\n", unit);
-		goto fail;
-	}
-
 	/* Reset the adapter. */
 	nge_reset(sc);
 
@@ -863,7 +843,6 @@
 
 	if (sc->nge_ldata == NULL) {
 		printf("nge%d: no memory for list buffers!\n", unit);
-		bus_teardown_intr(dev, sc->nge_irq, sc->nge_intrhand);
 		bus_release_resource(dev, SYS_RES_IRQ, 0, sc->nge_irq);
 		bus_release_resource(dev, NGE_RES, NGE_RID, sc->nge_res);
 		error = ENXIO;
@@ -871,25 +850,11 @@
 	}
 	bzero(sc->nge_ldata, sizeof(struct nge_list_data));
 
-	/* Try to allocate memory for jumbo buffers. */
-	if (nge_alloc_jumbo_mem(sc)) {
-		printf("nge%d: jumbo buffer allocation failed\n",
-                    sc->nge_unit);
-		contigfree(sc->nge_ldata,
-		    sizeof(struct nge_list_data), M_DEVBUF);
-		bus_teardown_intr(dev, sc->nge_irq, sc->nge_intrhand);
-		bus_release_resource(dev, SYS_RES_IRQ, 0, sc->nge_irq);
-		bus_release_resource(dev, NGE_RES, NGE_RID, sc->nge_res);
-		error = ENXIO;
-		goto fail;
-	}
-
 	ifp = &sc->arpcom.ac_if;
 	ifp->if_softc = sc;
 	if_initname(ifp, device_get_name(dev), device_get_unit(dev));
 	ifp->if_mtu = ETHERMTU;
-	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST |
-	    IFF_NEEDSGIANT;
+	ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
 	ifp->if_ioctl = nge_ioctl;
 	ifp->if_start = nge_start;
 	ifp->if_watchdog = nge_watchdog;
@@ -941,8 +906,6 @@
 	    
 		} else {
 			printf("nge%d: MII without any PHY!\n", sc->nge_unit);
-			nge_free_jumbo_mem(sc);
-			bus_teardown_intr(dev, sc->nge_irq, sc->nge_intrhand);
 			bus_release_resource(dev, SYS_RES_IRQ, 0, sc->nge_irq);
 			bus_release_resource(dev, NGE_RES, NGE_RID, 
 					 sc->nge_res);
@@ -955,12 +918,23 @@
 	 * Call MI attach routine.
 	 */
 	ether_ifattach(ifp, eaddr);
-	callout_handle_init(&sc->nge_stat_ch);
+	callout_init(&sc->nge_stat_ch, CALLOUT_MPSAFE);
+
+	/*

>>> TRUNCATED FOR MAIL (1000 lines) <<<


More information about the p4-projects mailing list