Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 30 May 1998 00:47:36 +0200 (MET DST)
From:      Ugo Paternostro <ugo@dsi.UNIFI.IT>
To:        FreeBSD-gnats-submit@FreeBSD.ORG
Subject:   i386/6792: Backported PnP support for if_ed to -stable
Message-ID:  <199805292247.AAA05562@pegasus.home.net>

next in thread | raw e-mail | index | archive | help

>Number:         6792
>Category:       i386
>Synopsis:       Backported PnP support for if_ed to -stable
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          open
>Quarter:
>Keywords:
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri May 29 17:40:01 PDT 1998
>Last-Modified:
>Originator:     Ugo Paternostro
>Organization:
Not an organization
>Release:        FreeBSD 2.2.6-STABLE i386
>Environment:

FreeBSD pegasus.home.net 2.2.6-STABLE FreeBSD 2.2.6-STABLE #1: Tue May 26 14:46:22 MET DST 1998     ugo@pegasus.home.net:/usr/src/sys/compile/PEGASUS  i386

>Description:

	Subject says it all: I ported PnP support for NE2000 and compatibles back
from -current to -stable (a lot of cut&paste ;-)

	Please note that I added a vendor ID that wasn't present in -current
sources (WSC9008), so you may think to commit that there too.

	P.S.: I hope that i386 is the right category for this report: I was in
doubt between kern and i386...

>How-To-Repeat:

	Insert a PnP NE2000 card into your -stable box.

>Fix:
	
Index: src/sys/i386/isa/if_ed.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/isa/if_ed.c,v
retrieving revision 1.107.2.7
diff -u -r1.107.2.7 if_ed.c
--- if_ed.c	1998/04/18 23:25:05	1.107.2.7
+++ if_ed.c	1998/05/29 22:01:40
@@ -39,7 +39,18 @@
 
 #include "ed.h"
 #include "bpfilter.h"
+#include "pnp.h"
 
+#ifndef EXTRA_ED
+# if NPNP > 0
+#  define EXTRA_ED 8
+# else
+#  define EXTRA_ED 0
+# endif
+#endif
+
+#define NEDTOT (NED + EXTRA_ED)
+
 #include <sys/param.h>
 #include <sys/kernel.h>
 #include <sys/systm.h>
@@ -85,6 +96,10 @@
 #include <i386/isa/icu.h>
 #include <i386/isa/if_edreg.h>
 
+#if NPNP > 0
+#include <i386/isa/pnp.h>
+#endif /* NPNP > 0 */
+
 /*
  * ed_softc: per line info and status
  */
@@ -137,7 +152,7 @@
 	struct	ifmib_iso_8802_3 mibdata; /* stuff for network mgmt */
 };
 
-static struct ed_softc ed_softc[NED];
+static struct ed_softc ed_softc[NEDTOT];
 
 static int ed_attach		__P((struct ed_softc *, int, int));
 static int ed_attach_isa	__P((struct isa_device *));
@@ -227,7 +242,7 @@
 	struct ed_softc *sc = &ed_softc[devi->isahd.id_unit];
 
 	/* validate unit number. */
-	if (devi->isahd.id_unit >= NED)
+	if (devi->isahd.id_unit >= NEDTOT)
 		return(ENODEV);
 	/*
 	 * Probe the device. If a value is returned, the
@@ -3415,3 +3430,95 @@
 		ETHER_NEXT_MULTI(step, enm);
 	}
 }
+
+/*
+ * support PnP cards if we are using 'em
+ */ 
+    
+#if NPNP > 0 
+    
+static struct edpnp_ids {
+	u_long vend_id;
+	char *id_str;
+} edpnp_ids[] = {
+	{ 0x1980635e, "WSC8019"},
+	{ 0x0890635e, "WSC9008"},
+	{ 0 }
+};
+
+static char *edpnp_probe(u_long csn, u_long vend_id);
+static void edpnp_attach(u_long csn, u_long vend_id, char *name,
+	struct isa_device *dev);
+static u_long nedpnp = NED;
+
+static struct pnp_device edpnp = {
+	"edpnp",
+	edpnp_probe,
+	edpnp_attach,
+	&nedpnp,
+	&net_imask
+};
+DATA_SET (pnpdevice_set, edpnp);
+
+static char *
+edpnp_probe(u_long csn, u_long vend_id)
+{
+	struct edpnp_ids *ids;
+	char *s = NULL;
+
+	for(ids = edpnp_ids; ids->vend_id != 0; ids++) {
+		if (vend_id == ids->vend_id) {
+			s = ids->id_str;
+			break;
+		}
+	}
+
+	if (s) {
+		struct pnp_cinfo d;
+		read_pnp_parms(&d, 0);
+		if (d.enable == 0 || d.flags & 1) {
+			printf("CSN %d is disabled.\n", csn);
+			return (NULL);
+		}
+
+	}
+
+	return (s);
+}
+
+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;
+
+	if (read_pnp_parms(&d, 0) == 0) {
+		printf("failed to read pnp parms\n");
+		return;
+	}
+
+	write_pnp_parms(&d, 0);
+
+	enable_pnp_card();
+
+	dev->id_iobase = d.port[0];
+	dev->id_irq = (1 << d.irq[0]);
+	dev->id_intr = edintr;
+	dev->id_drq = -1;
+
+	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;
+	}
+
+	if ((dev->id_alive = ed_probe(dev)) != 0)
+		ed_attach_isa(dev);
+	else
+		printf("ed%d: probe failed\n", dev->id_unit);
+}
+#endif
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199805292247.AAA05562>