Sync with sys/i386/isa/if_ed.c revision up to 1.132.

This commit is contained in:
KATO Takenori 1998-02-05 10:17:57 +00:00
parent d13e38ae9d
commit 7b0c16d8af

View File

@ -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.36 1997/11/25 09:42:25 kato Exp $
* $Id: if_ed.c,v 1.37 1998/01/08 23:42:06 eivind Exp $
*/
/*
@ -60,7 +60,19 @@
#include "ed.h"
#include "bpfilter.h"
#include "opt_diagnostic.h"
#include "opt_inet.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/systm.h>
@ -89,6 +101,10 @@
#include <net/bpf.h>
#endif
#if NPNP > 0
#include <i386/isa/pnp.h>
#endif
#include <machine/clock.h>
#include <machine/md_var.h>
@ -164,7 +180,7 @@ struct ed_softc {
#endif
};
static struct ed_softc ed_softc[NED];
static struct ed_softc ed_softc[NEDTOT];
#ifdef PC98
#include <pc98/pc98/if_ed98.h>
@ -229,8 +245,10 @@ static void ed_setrcr(struct ed_softc *);
static u_long ds_crc(u_char *ep);
#if NCARD > 0
#if (NCARD > 0) || (NPNP > 0)
#include <sys/kernel.h>
#endif
#if NCARD > 0
#include <sys/select.h>
#include <pccard/cardinfo.h>
#include <pccard/driver.h>
@ -264,7 +282,7 @@ edinit(struct pccard_devinfo *devi)
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
@ -4197,3 +4215,95 @@ ds_getmcaf(sc, mcaf)
af[index >> 3] |= 1 << (index & 7);
}
}
/*
* 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"},
{ 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_ri_flags = RI_FAST;
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