summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/dev/ep/if_ep_pccard.c18
-rw-r--r--sys/dev/pccard/card_if.m40
-rw-r--r--sys/dev/pccard/pccard.c31
-rw-r--r--sys/dev/pccard/pccardvar.h4
-rw-r--r--sys/dev/sn/if_sn.c30
-rw-r--r--sys/dev/sn/if_sn_isa.c2
-rw-r--r--sys/dev/sn/if_sn_pccard.c31
-rw-r--r--sys/pccard/pccard_nbk.c16
8 files changed, 148 insertions, 24 deletions
diff --git a/sys/dev/ep/if_ep_pccard.c b/sys/dev/ep/if_ep_pccard.c
index 6b39711..d27d5fd 100644
--- a/sys/dev/ep/if_ep_pccard.c
+++ b/sys/dev/ep/if_ep_pccard.c
@@ -58,6 +58,9 @@
#include <dev/ep/if_epreg.h>
#include <dev/ep/if_epvar.h>
+#include "card_if.h"
+#include <dev/pccard/pccardvar.h>
+
static const char *ep_pccard_identify(u_short id);
/*
@@ -238,12 +241,23 @@ ep_pccard_detach(device_t dev)
return (0);
}
+static int
+ep_pccard_match(device_t dev)
+{
+ return EIO;
+}
+
static device_method_t ep_pccard_methods[] = {
/* Device interface */
- DEVMETHOD(device_probe, ep_pccard_probe),
- DEVMETHOD(device_attach, ep_pccard_attach),
+ DEVMETHOD(device_probe, pccard_compat_probe),
+ DEVMETHOD(device_attach, pccard_compat_attach),
DEVMETHOD(device_detach, ep_pccard_detach),
+ /* Card interface */
+ DEVMETHOD(card_compat_match, ep_pccard_match),
+ DEVMETHOD(card_compat_probe, ep_pccard_probe),
+ DEVMETHOD(card_compat_attach, ep_pccard_attach),
+
{ 0, 0 }
};
diff --git a/sys/dev/pccard/card_if.m b/sys/dev/pccard/card_if.m
index 641e398..5e0bfd8 100644
--- a/sys/dev/pccard/card_if.m
+++ b/sys/dev/pccard/card_if.m
@@ -119,3 +119,43 @@ METHOD int deactivate_function {
device_t dev;
device_t child;
}
+
+#
+# Compatibility methods for OLDCARD drivers. We use these routines to make
+# it possible to call the OLDCARD driver's probe routine in the context that
+# it expects. For OLDCARD these are implemented as pass throughs to the
+# device_{probe,attach} routines. For NEWCARD they are implemented such
+# such that probe becomes strictly a matching routine and attach does both
+# the old probe and old attach.
+#
+# compat devices should use the following:
+#
+# /* Device interface */
+# DEVMETHOD(device_probe), pccard_compat_probe),
+# DEVMETHOD(device_attach), pccard_compat_attach),
+# /* Card interface */
+# DEVMETHOD(card_compat_match, foo_match), /* newly written */
+# DEVMETHOD(card_compat_probe, foo_probe), /* old probe */
+# DEVMETHOD(card_compat_attach, foo_attach), /* old attach */
+#
+# This will allow a single driver binary image to be used for both
+# OLDCARD and NEWCARD.
+#
+# Drivers wishing to not retain OLDCARD compatibility needn't do this.
+#
+METHOD int compat_probe {
+ device_t dev;
+}
+
+METHOD int compat_attach {
+ device_t dev;
+}
+
+#
+# Helper method for the above. When a compatibility driver is converted,
+# one must write a match routine. This routine is unused on OLDCARD but
+# is used as a discriminator for NEWCARD.
+#
+METHOD int compat_match {
+ device_t dev;
+}
diff --git a/sys/dev/pccard/pccard.c b/sys/dev/pccard/pccard.c
index 375b74c..39564fe 100644
--- a/sys/dev/pccard/pccard.c
+++ b/sys/dev/pccard/pccard.c
@@ -505,6 +505,28 @@ pccard_io_unmap(struct pccard_function *pf, int window)
}
#endif
+/*
+ * simulate the old "probe" routine. In the new world order, the driver
+ * needs to grab devices while in the old they were assigned to the device by
+ * the pccardd process. These symbols are exported to the upper layers.
+ */
+int
+pccard_compat_probe(device_t dev)
+{
+ return (CARD_COMPAT_MATCH(dev));
+}
+
+int
+pccard_compat_attach(device_t dev)
+{
+ int err;
+
+ err = CARD_COMPAT_PROBE(dev);
+ if (err == 0)
+ err = CARD_COMPAT_ATTACH(dev);
+ return (err);
+}
+
#define PCCARD_NPORT 2
#define PCCARD_NMEM 5
#define PCCARD_NIRQ 1
@@ -661,6 +683,14 @@ pccard_set_memory_offset(device_t dev, device_t child, int rid,
offset);
}
+static int
+pccard_read_ivar(device_t bus, device_t child, int which, u_char *result)
+{
+ /* PCCARD_IVAR_ETHADDR unhandled from oldcard */
+ return ENOENT;
+}
+
+
static device_method_t pccard_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, pccard_probe),
@@ -682,6 +712,7 @@ static device_method_t pccard_methods[] = {
DEVMETHOD(bus_set_resource, pccard_set_resource),
DEVMETHOD(bus_get_resource, pccard_get_resource),
DEVMETHOD(bus_delete_resource, pccard_delete_resource),
+ DEVMETHOD(bus_read_ivar, pccard_read_ivar),
/* Card Interface */
DEVMETHOD(card_set_res_flags, pccard_set_res_flags),
diff --git a/sys/dev/pccard/pccardvar.h b/sys/dev/pccard/pccardvar.h
index 19a25a3..a91d2fb 100644
--- a/sys/dev/pccard/pccardvar.h
+++ b/sys/dev/pccard/pccardvar.h
@@ -269,6 +269,10 @@ void pccard_io_unmap(struct pccard_function *, int);
#define pccard_mem_unmap(pf, window) \
(pccard_chip_mem_unmap((pf)->sc->pct, (pf)->sc->pch, (window)))
+/* compat layer */
+int pccard_compat_probe(device_t dev);
+int pccard_compat_attach(device_t dev);
+
/* ivar interface */
enum {
PCCARD_IVAR_ETHADDR, /* read ethernet address from CIS tupple */
diff --git a/sys/dev/sn/if_sn.c b/sys/dev/sn/if_sn.c
index 2794442..f1d2840 100644
--- a/sys/dev/sn/if_sn.c
+++ b/sys/dev/sn/if_sn.c
@@ -78,8 +78,7 @@
* Multicast support by Kei TANAKA <kei@pal.xerox.com>
* Special thanks to itojun@itojun.org
*/
-
-#undef SN_DEBUG /* (by hosokawa) */
+#define SN_DEBUG
#include <sys/param.h>
#include <sys/systm.h>
@@ -361,6 +360,7 @@ snstart(struct ifnet *ifp)
u_short numPages;
u_char packet_no;
int time_out;
+ int junk = 0;
s = splimp();
@@ -443,7 +443,7 @@ startagain:
break;
} while (--time_out);
- if (!time_out) {
+ if (!time_out || junk > 10) {
/*
* No memory now. Oh well, wait until the chip finds memory
@@ -469,7 +469,8 @@ startagain:
*/
packet_no = inb(BASE + ALLOC_RESULT_REG_B);
if (packet_no & ARR_FAILED) {
- printf("sn%d: Memory allocation failed\n", ifp->if_unit);
+ if (junk++ > 10)
+ printf("sn%d: Memory allocation failed\n", ifp->if_unit);
goto startagain;
}
/*
@@ -1243,9 +1244,8 @@ sn_activate(device_t dev)
sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->port_rid,
0, ~0, SMC_IO_EXTENT, RF_ACTIVE);
if (!sc->port_res) {
-#ifdef SN_DEBUG
- device_printf(dev, "Cannot allocate ioport\n");
-#endif
+ if (bootverbose)
+ device_printf(dev, "Cannot allocate ioport\n");
return ENOMEM;
}
@@ -1253,9 +1253,8 @@ sn_activate(device_t dev)
sc->irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irq_rid,
0, ~0, 1, RF_ACTIVE);
if (!sc->irq_res) {
-#ifdef SN_DEBUG
- device_printf(dev, "Cannot allocate irq\n");
-#endif
+ if (bootverbose)
+ device_printf(dev, "Cannot allocate irq\n");
sn_deactivate(dev);
return ENOMEM;
}
@@ -1317,7 +1316,9 @@ sn_probe(device_t dev, int pccard)
return err;
ioaddr = sc->sn_io_addr;
-
+#ifdef SN_DEBUG
+ device_printf(dev, "ioaddr is 0x%x\n", ioaddr);
+#endif
/*
* First, see if the high byte is 0x33
*/
@@ -1361,11 +1362,6 @@ sn_probe(device_t dev, int pccard)
* Well, the base address register didn't match. Must not
* have been a SMC chip after all.
*/
- /*
- * printf("sn: ioaddr %x doesn't match card configuration
- * (%x)\n", ioaddr, base_address_register >> 3 & 0x3E0 );
- */
-
#ifdef SN_DEBUG
device_printf(dev, "test3 failed ioaddr = 0x%x, "
"base_address_register = 0x%x\n", ioaddr,
@@ -1373,6 +1369,7 @@ sn_probe(device_t dev, int pccard)
#endif
goto error;
}
+
/*
* Check if the revision register is something that I recognize.
* These might need to be added to later, as future revisions could
@@ -1390,6 +1387,7 @@ sn_probe(device_t dev, int pccard)
#endif
goto error;
}
+
/*
* at this point I'll assume that the chip is an SMC9xxx. It might be
* prudent to check a listing of MAC addresses against the hardware
diff --git a/sys/dev/sn/if_sn_isa.c b/sys/dev/sn/if_sn_isa.c
index e32b1bb..78d9bd0 100644
--- a/sys/dev/sn/if_sn_isa.c
+++ b/sys/dev/sn/if_sn_isa.c
@@ -96,4 +96,4 @@ static driver_t sn_isa_driver = {
extern devclass_t sn_devclass;
-DRIVER_MODULE(sn, isa, sn_isa_driver, sn_devclass, 0, 0);
+DRIVER_MODULE(if_sn, isa, sn_isa_driver, sn_devclass, 0, 0);
diff --git a/sys/dev/sn/if_sn_pccard.c b/sys/dev/sn/if_sn_pccard.c
index 4220dea..5e41bec 100644
--- a/sys/dev/sn/if_sn_pccard.c
+++ b/sys/dev/sn/if_sn_pccard.c
@@ -55,13 +55,22 @@
#include <dev/sn/if_snvar.h>
#include <dev/pccard/pccardvar.h>
+#include <dev/pccard/pccarddevs.h>
+
+#include "card_if.h"
+
/*
* Initialize the device - called from Slot manager.
*/
static int
sn_pccard_probe(device_t dev)
{
- return (sn_probe(dev, 1));
+ int err;
+
+ printf ("Probing sn driver\n");
+ err = sn_probe(dev, 1);
+ printf("sn_probe says %d\n", err);
+ return (err);
}
static int
@@ -80,7 +89,6 @@ sn_pccard_attach(device_t dev)
sc->pccard_enaddr = 1;
bcopy(ether_addr, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
}
-
return (sn_attach(dev));
}
@@ -95,12 +103,23 @@ sn_pccard_detach(device_t dev)
return 0;
}
+static int
+sn_pccard_match(device_t dev)
+{
+ return EIO;
+}
+
static device_method_t sn_pccard_methods[] = {
/* Device interface */
- DEVMETHOD(device_probe, sn_pccard_probe),
- DEVMETHOD(device_attach, sn_pccard_attach),
+ DEVMETHOD(device_probe, pccard_compat_probe),
+ DEVMETHOD(device_attach, pccard_compat_attach),
DEVMETHOD(device_detach, sn_pccard_detach),
+ /* Card interface */
+ DEVMETHOD(card_compat_match, sn_pccard_match),
+ DEVMETHOD(card_compat_probe, sn_pccard_probe),
+ DEVMETHOD(card_compat_attach, sn_pccard_attach),
+
{ 0, 0 }
};
@@ -112,4 +131,6 @@ static driver_t sn_pccard_driver = {
extern devclass_t sn_devclass;
-DRIVER_MODULE(sn, pccard, sn_pccard_driver, sn_devclass, 0, 0);
+DRIVER_MODULE(if_sn, pccard, sn_pccard_driver, sn_devclass, 0, 0);
+MODULE_DEPEND(if_sn, pccard, 1, 1, 1);
+MODULE_DEPEND(if_sn, pcic, 1, 1, 1); /* XXX */
diff --git a/sys/pccard/pccard_nbk.c b/sys/pccard/pccard_nbk.c
index 37e9557..5d86e9b 100644
--- a/sys/pccard/pccard_nbk.c
+++ b/sys/pccard/pccard_nbk.c
@@ -81,6 +81,21 @@ devclass_t pccard_devclass;
#define PCCARD_DEVINFO(d) (struct pccard_devinfo *) device_get_ivars(d)
+/*
+ * glue for NEWCARD/OLDCARD compat layer
+ */
+int
+pccard_compat_probe(device_t dev)
+{
+ return (CARD_COMPAT_PROBE(dev));
+}
+
+int
+pccard_compat_attach(device_t dev)
+{
+ return (CARD_COMPAT_ATTACH(dev));
+}
+
static int
pccard_probe(device_t dev)
{
@@ -371,3 +386,4 @@ static driver_t pccard_driver = {
DRIVER_MODULE(pccard, pcic, pccard_driver, pccard_devclass, 0, 0);
DRIVER_MODULE(pccard, pc98pcic, pccard_driver, pccard_devclass, 0, 0);
DRIVER_MODULE(pccard, cbb, pccard_driver, pccard_devclass, 0, 0);
+MODULE_VERSION(pccard, 1);
OpenPOWER on IntegriCloud