#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/socket.h>
#include <sys/module.h>
#include <sys/bus.h>
#include <sys/rman.h>
#include <net/ethernet.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <net/if_media.h>
#include <machine/clock.h>
#include "if_snreg.h"
#include "if_snvar.h"
#include <bus/pccard/pccardvar.h>
#include "card_if.h"
#include "pccarddevs.h"
static const struct pccard_product sn_pccard_products[] = {
PCMCIA_CARD(DSPSI, XJACK, 0),
PCMCIA_CARD(NEWMEDIA, BASICS, 0),
#if 0
PCMCIA_CARD(SMC, 8020BT, 0),
#endif
{ NULL }
};
static int
sn_pccard_match(device_t dev)
{
const struct pccard_product *pp;
if ((pp = pccard_product_lookup(dev, sn_pccard_products,
sizeof(sn_pccard_products[0]), NULL)) != NULL) {
if (pp->pp_name != NULL)
device_set_desc(dev, pp->pp_name);
return 0;
}
return EIO;
}
static int
sn_pccard_probe(device_t dev)
{
return (sn_probe(dev, 1));
}
static int
sn_pccard_attach(device_t dev)
{
struct sn_softc *sc = device_get_softc(dev);
int i;
uint8_t sum;
const uint8_t *ether_addr;
sc->pccard_enaddr = 0;
ether_addr = pccard_get_ether(dev);
for (i = 0, sum = 0; i < ETHER_ADDR_LEN; i++)
sum |= ether_addr[i];
if (sum) {
sc->pccard_enaddr = 1;
bcopy(ether_addr, sc->arpcom.ac_enaddr, ETHER_ADDR_LEN);
}
return (sn_attach(dev));
}
static int
sn_pccard_detach(device_t dev)
{
struct sn_softc *sc = device_get_softc(dev);
struct ifnet *ifp = &sc->arpcom.ac_if;
lwkt_serialize_enter(ifp->if_serializer);
ifp->if_flags &= ~IFF_RUNNING;
bus_teardown_intr(dev, sc->irq_res, sc->intrhand);
lwkt_serialize_enter(ifp->if_serializer);
ether_ifdetach(&sc->arpcom.ac_if);
sn_deactivate(dev);
return 0;
}
static device_method_t sn_pccard_methods[] = {
DEVMETHOD(device_probe, pccard_compat_probe),
DEVMETHOD(device_attach, pccard_compat_attach),
DEVMETHOD(device_detach, sn_pccard_detach),
DEVMETHOD(card_compat_match, sn_pccard_match),
DEVMETHOD(card_compat_probe, sn_pccard_probe),
DEVMETHOD(card_compat_attach, sn_pccard_attach),
DEVMETHOD_END
};
static driver_t sn_pccard_driver = {
"sn",
sn_pccard_methods,
sizeof(struct sn_softc),
};
extern devclass_t sn_devclass;
DRIVER_MODULE(if_sn, pccard, sn_pccard_driver, sn_devclass, NULL, NULL);