#include "bpfilter.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/mbuf.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/errno.h>
#include <sys/syslog.h>
#include <sys/device.h>
#include <net/if.h>
#include <net/if_media.h>
#include <netinet/in.h>
#include <netinet/if_ether.h>
#if NBPFILTER > 0
#include <net/bpf.h>
#endif
#include <machine/intr.h>
#include <machine/bus.h>
#include <dev/ic/dp8390reg.h>
#include <dev/ic/dp8390var.h>
#include <dev/ic/ne2000reg.h>
#include <dev/ic/ne2000var.h>
#include <dev/ic/rtl80x9reg.h>
#include <dev/ic/rtl80x9var.h>
#include <dev/isa/isavar.h>
#include <dev/isa/isapnpreg.h>
static int ne_isapnp_match(struct device *, void *, void *);
static void ne_isapnp_attach(struct device *, struct device *, void *);
struct ne_isapnp_softc {
struct ne2000_softc sc_ne2000;
void *sc_ih;
};
const struct cfattach ne_isapnp_ca = {
sizeof(struct ne_isapnp_softc), ne_isapnp_match, ne_isapnp_attach
};
static int
ne_isapnp_match(struct device *parent, void *match, void *aux)
{
return (1);
}
static void
ne_isapnp_attach(struct device *parent, struct device *self, void *aux)
{
struct ne_isapnp_softc * const isc = (struct ne_isapnp_softc *)self;
struct ne2000_softc * const nsc = &isc->sc_ne2000;
struct dp8390_softc * const dsc = &nsc->sc_dp8390;
struct isa_attach_args * const ipa = aux;
bus_space_tag_t nict;
bus_space_handle_t nich;
bus_space_tag_t asict;
bus_space_handle_t asich;
const char *typestr;
int netype;
nict = ipa->ia_iot;
nich = ipa->ipa_io[0].h;
asict = nict;
if (bus_space_subregion(nict, nich, NE2000_ASIC_OFFSET,
NE2000_ASIC_NPORTS, &asich)) {
printf("%s: can't subregion i/o space\n", dsc->sc_dev.dv_xname);
return;
}
dsc->sc_regt = nict;
dsc->sc_regh = nich;
nsc->sc_asict = asict;
nsc->sc_asich = asich;
netype = ne2000_detect(nsc);
switch (netype) {
case NE2000_TYPE_NE1000:
typestr = "NE1000";
break;
case NE2000_TYPE_NE2000:
typestr = "NE2000";
bus_space_write_1(nict, nich, ED_P0_CR,
ED_CR_PAGE_0 | ED_CR_STP);
if (bus_space_read_1(nict, nich, NERTL_RTL0_8019ID0) ==
RTL0_8019ID0 &&
bus_space_read_1(nict, nich, NERTL_RTL0_8019ID1) ==
RTL0_8019ID1) {
typestr = "NE2000 (RTL8019)";
dsc->sc_mediachange = rtl80x9_mediachange;
dsc->sc_mediastatus = rtl80x9_mediastatus;
dsc->init_card = rtl80x9_init_card;
dsc->sc_media_init = rtl80x9_media_init;
}
break;
default:
printf(": where did the card go?!\n");
return;
}
printf(": %s", typestr);
dsc->sc_enabled = 1;
ne2000_attach(nsc, NULL);
isc->sc_ih = isa_intr_establish(ipa->ia_ic, ipa->ipa_irq[0].num,
IST_EDGE, IPL_NET, dp8390_intr, dsc,
dsc->sc_dev.dv_xname);
if (isc->sc_ih == NULL)
printf(": couldn't establish interrupt handler\n");
}