summaryrefslogtreecommitdiffstats
path: root/sys/dev/sn/if_sn.c
diff options
context:
space:
mode:
authorimp <imp@FreeBSD.org>2000-09-19 04:39:20 +0000
committerimp <imp@FreeBSD.org>2000-09-19 04:39:20 +0000
commit222e32bc4941211d514ad22676414f71c1360b50 (patch)
tree0f24f269148f98c6cc905cfdaff28f51b9f78ecf /sys/dev/sn/if_sn.c
parent2186ce0d36ca105027459f0241b56f0740595d42 (diff)
downloadFreeBSD-src-222e32bc4941211d514ad22676414f71c1360b50.zip
FreeBSD-src-222e32bc4941211d514ad22676414f71c1360b50.tar.gz
Implement indirection in the pccard probe/attach. This should make it
possible to have different probe/attach semantics between the two systems and yet still use the same driver for both. 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. ep driver minorly updated. sn driver updated more than minorly. Add module dependencies to allow module to load. Also change name to if_sn. Add some debugging code. attempt to fix the cannot allocate memory problem I'd been seeing. Minor formatting nits.
Diffstat (limited to 'sys/dev/sn/if_sn.c')
-rw-r--r--sys/dev/sn/if_sn.c30
1 files changed, 14 insertions, 16 deletions
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
OpenPOWER on IntegriCloud