Deleted Added
full compact
27c27
< * $FreeBSD: head/sys/dev/xe/if_xe.c 52632 1999-10-29 17:28:09Z imp $
---
> * $FreeBSD: head/sys/dev/xe/if_xe.c 55723 2000-01-10 08:05:53Z imp $
30a31,43
> * XXX TODO XXX
> *
> * I've pushed this fairly far, but there are some things that need to be
> * done here. I'm documenting them here in case I get destracted. -- imp
> *
> * xe_memwrite -- maybe better handled pccard layer?
> * xe_cem56fix -- need to figure out how to map the extra stuff.
> * xe_activate -- need to write it, and add some stuff to it. Look at if_sn
> * for guidance. resources/interrupts.
> * xe_deactivate -- turn off resources/interrupts.
> */
>
> /*
106,115d118
< #include "xe.h"
< #include "card.h"
< #include "apm.h"
<
< #if NXE > 0
<
< #undef NCARD
< #define NCARD 0
< #if NCARD > 0
<
128a132,138
> #include <sys/module.h>
> #include <sys/bus.h>
>
> #include <machine/bus.h>
> #include <machine/resource.h>
> #include <sys/rman.h>
>
137,139c147,149
< #include <i386/isa/isa.h>
< #include <i386/isa/isa_device.h>
< #include <dev/pccard/if_xereg.h>
---
> #include <dev/xe/if_xereg.h>
> #include <dev/xe/if_xevar.h>
>
141,143d150
< #if NAPM > 0
< #include <machine/apm_bios.h>
< #endif /* NAPM > 0 */
145,151d151
< #include <pccard/cardinfo.h>
< #include <pccard/cis.h>
< #include <pccard/driver.h>
< #include <pccard/slot.h>
<
<
<
153,190d152
< * One of these structures per allocated device
< */
< struct xe_softc {
< struct arpcom arpcom;
< struct ifmedia ifmedia;
< struct ifmib_iso_8802_3 mibdata;
< struct callout_handle chand;
< struct isa_device *dev;
< struct pccard_devinfo *crd;
< struct ifnet *ifp;
< struct ifmedia *ifm;
< char *card_type; /* Card model name */
< char *vendor; /* Card manufacturer */
< int unit; /* Unit number, from dev->id_unit */
< int srev; /* Silicon revision */
< int tx_queued; /* Packets currently waiting to transmit */
< int tx_tpr; /* Last value of TPR reg on card */
< int tx_collisions; /* Collisions since last successful send */
< int tx_timeouts; /* Count of transmit timeouts */
< int autoneg_status; /* Autonegotiation progress state */
< int media; /* Private media word */
< u_char version; /* Bonding Version register from card */
< u_char modem; /* 1 = Card has a modem */
< u_char ce2; /* 1 = Card has CE2 silicon */
< u_char mohawk; /* 1 = Card has Mohawk (CE3) silicon */
< u_char dingo; /* 1 = Card has Dingo (CEM56) silicon */
< u_char phy_ok; /* 1 = MII-compliant PHY found and initialised */
< u_char gone; /* 1 = Card bailed out */
< #if NAPM > 0
< struct apmhook suspend_hook;
< struct apmhook resume_hook;
< #endif /* NAPM > 0 */
< };
<
< static struct xe_softc *sca[MAXSLOT];
<
<
< /*
203,220d164
< * For accessing card registers
< */
< #define XE_INB(r) inb(scp->dev->id_iobase+(r))
< #define XE_INW(r) inw(scp->dev->id_iobase+(r))
< #define XE_OUTB(r, b) outb(scp->dev->id_iobase+(r), (b))
< #define XE_OUTW(r, w) outw(scp->dev->id_iobase+(r), (w))
< #define XE_SELECT_PAGE(p) XE_OUTB(XE_PR, (p))
<
< /*
< * Horrid stuff for accessing CIS tuples
< */
< #define CARD_MAJOR 50
< #define CISTPL_BUFSIZE 512
< #define CISTPL_TYPE(tpl) tpl[0]
< #define CISTPL_LEN(tpl) tpl[2]
< #define CISTPL_DATA(tpl,pos) tpl[4 + ((pos)<<1)]
<
< /*
233,235c177,181
< static int xe_probe (struct isa_device *dev);
< static int xe_card_init (struct pccard_devinfo *devi);
< static int xe_attach (struct isa_device *dev);
---
> static int xe_probe (device_t dev);
> static int xe_attach (device_t dev);
> static int xe_detach (device_t dev);
> static int xe_activate (device_t dev);
> static void xe_deactivate (device_t dev);
239d184
< static int xe_card_intr (struct pccard_devinfo *devi);
252d196
< static void xe_card_unload (struct pccard_devinfo *devi);
280d223
< #if NAPM > 0
282,335d224
< * APM hook functions
< */
< static int xe_suspend (void *xunit);
< static int xe_resume (void *xunit);
< #endif /* NAPM > 0 */
<
<
< /*
< * PCMCIA driver hooks
< */
< #ifdef PCCARD_MODULE
< PCCARD_MODULE(xe, xe_card_init, xe_card_unload, xe_card_intr, 0, net_imask);
< #else
< static struct pccard_device xe_info = { /* For pre 3.1-STABLE code */
< "xe",
< xe_card_init,
< xe_card_unload,
< xe_card_intr,
< 0,
< &net_imask
< };
< DATA_SET(pccarddrv_set, xe_info);
< #endif /* PCCARD_MODULE */
<
<
< /*
< * ISA driver hooks. I'd like to do without these but the kernel config stuff
< * seems to require them.
< */
< struct isa_driver xedriver = {
< xe_probe,
< xe_attach,
< "xe"
< };
<
<
<
< /*
< * ISA probe routine.
< * All of the supported devices are PCMCIA cards. I have no idea if it's even
< * possible to successfully probe/attach these at boot time (pccardd normally
< * does a lot of setup work) so I don't even bother trying.
< */
< static int
< xe_probe (struct isa_device *dev) {
< #ifdef XE_DEBUG
< printf("xe%d: probe\n", dev->id_unit);
< #endif
< bzero(sca, MAXSLOT * sizeof(sca[0]));
< return 0;
< }
<
<
< /*
344c233
< xe_memwrite(struct pccard_devinfo *devi, off_t offset, u_char byte)
---
> xe_memwrite(device_t dev, off_t offset, u_char byte)
346,362c235
< struct iovec iov;
< struct uio uios;
<
< iov.iov_base = &byte;
< iov.iov_len = sizeof(byte);
<
< uios.uio_iov = &iov;
< uios.uio_iovcnt = 1;
< uios.uio_offset = offset;
< uios.uio_resid = sizeof(byte);
< uios.uio_segflg = UIO_SYSSPACE;
< uios.uio_rw = UIO_WRITE;
< uios.uio_procp = 0;
<
< #if 0 /* THIS IS BOGUS */
< return cdevsw[CARD_MAJOR]->d_write(makedev(CARD_MAJOR, devi->slt->slotnum), &uios, 0);
< #else
---
> /* XXX */
364d236
< #endif
367,392d238
<
< static int
< xe_memread(struct pccard_devinfo *devi, off_t offset, u_char *buf, int size)
< {
< struct iovec iov;
< struct uio uios;
<
< iov.iov_base = buf;
< iov.iov_len = size;
<
< uios.uio_iov = &iov;
< uios.uio_iovcnt = 1;
< uios.uio_offset = offset;
< uios.uio_resid = size;
< uios.uio_segflg = UIO_SYSSPACE;
< uios.uio_rw = UIO_READ;
< uios.uio_procp = 0;
<
< #if 0 /* THIS IS BOGUS */
< return cdevsw[CARD_MAJOR]->d_read(makedev(CARD_MAJOR, devi->slt->slotnum), &uios, 0);
< #else
< return (-1);
< #endif
< }
<
<
399,401c245
< struct pccard_devinfo *devi;
< struct slot *slt;
< struct slot_ctrl *ctrl;
---
> #if XXX /* Need to revisit */
404,408d247
< /* initialise a few variables */
< devi = scp->crd;
< slt = devi->slt;
< ctrl = slt->ctrl;
<
423c262
< printf( "xe%d: user requested ioport 0x%x\n", scp->unit, XE_IOBASE );
---
> device_printf(scp->dev, "user requested ioport 0x%x\n", XE_IOBASE );
440c279
< printf( "xe%d: xe_cem56fix: no free address space\n", scp->unit );
---
> device_printf(scp->dev, "xe_cem56fix: no free address space\n");
447c286
< printf( "xe%d: using 0x%x for RealPort ethernet\n", scp->unit, ioport );
---
> device_printf(scp->dev, "using 0x%x for RealPort ethernet\n", ioport);
448a288
> #if 0
450a291
> #endif
453,456c294,298
< xe_memwrite( devi, DINGO_ECOR, DINGO_ECOR_IRQ_LEVEL|DINGO_ECOR_INT_ENABLE|
< DINGO_ECOR_IOB_ENABLE|DINGO_ECOR_ETH_ENABLE );
< xe_memwrite( devi, DINGO_EBAR0, ioport & 0xff );
< xe_memwrite( devi, DINGO_EBAR1, (ioport >> 8) & 0xff );
---
> xe_memwrite( scp->dev, DINGO_ECOR, DINGO_ECOR_IRQ_LEVEL|
> DINGO_ECOR_INT_ENABLE|DINGO_ECOR_IOB_ENABLE|
> DINGO_ECOR_ETH_ENABLE );
> xe_memwrite( scp->dev, DINGO_EBAR0, ioport & 0xff );
> xe_memwrite( scp->dev, DINGO_EBAR1, (ioport >> 8) & 0xff );
458,462c300,304
< xe_memwrite( devi, DINGO_DCOR0, DINGO_DCOR0_SF_INT );
< xe_memwrite( devi, DINGO_DCOR1, DINGO_DCOR1_INT_LEVEL|DINGO_DCOR1_EEDIO );
< xe_memwrite( devi, DINGO_DCOR2, 0x00 );
< xe_memwrite( devi, DINGO_DCOR3, 0x00 );
< xe_memwrite( devi, DINGO_DCOR4, 0x00 );
---
> xe_memwrite( scp->dev, DINGO_DCOR0, DINGO_DCOR0_SF_INT );
> xe_memwrite( scp->dev, DINGO_DCOR1, DINGO_DCOR1_INT_LEVEL|DINGO_DCOR1_EEDIO );
> xe_memwrite( scp->dev, DINGO_DCOR2, 0x00 );
> xe_memwrite( scp->dev, DINGO_DCOR3, 0x00 );
> xe_memwrite( scp->dev, DINGO_DCOR4, 0x00 );
465a308,310
> #else
> return -1;
> #endif /* XXX */
467d311
<
476c320
< xe_card_init(struct pccard_devinfo *devi)
---
> xe_probe(device_t dev)
478,480c322,323
< struct xe_softc *scp;
< struct isa_device *dev;
< u_char buf[CISTPL_BUFSIZE];
---
> struct xe_softc *scp = (struct xe_softc *) device_get_softc(dev);
> u_char *buf;
483c326,328
< int unit, success, rc, i;
---
> int success, rc, i;
> int rid;
> struct resource *r;
485,487d329
< unit = devi->isahd.id_unit;
< scp = sca[unit];
< dev = &devi->isahd;
491c333
< printf("xe: Probing for unit %d\n", unit);
---
> device_printf(dev, "xe: Probing\n");
494,497c336,343
< /* Check that unit number is OK */
< if (unit > MAXSLOT) {
< printf("xe%d: bad unit\n", unit);
< return (ENODEV);
---
> /* Map in the CIS */
> /* XXX This CANNOT work as it needs RF_PCCARD_ATTR support */
> r = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid, 0, ~0, 4 << 10, RF_ACTIVE);
> if (!r) {
> #ifdef XE_DEBUG
> device_printf(dev, "Can't map in cis\n");
> #endif
> return ENOMEM;
498a345
> buf = (u_char *) rman_get_start(r);
500,520d346
< /* Don't attach an active device */
< if (scp && !scp->gone) {
< printf("xe%d: already attached\n", unit);
< return (EBUSY);
< }
<
< /* Allocate per-instance storage */
< if (!scp) {
< if ((scp = malloc(sizeof(*scp), M_DEVBUF, M_NOWAIT)) == NULL) {
< printf("xe%d: failed to allocage driver storage\n", unit);
< return (ENOMEM);
< }
< bzero(scp, sizeof(*scp));
< }
<
< /* Re-attach an existing device */
< if (scp->gone) {
< scp->gone = 0;
< return 0;
< }
<
527,533c353
< /*
< * Read tuples one at a time into buf. Sucks, but it only happens once.
< * XXX - This assumes that attribute has been mapped by pccardd, which
< * XXX - seems to be the default situation. If not, we're well and truly
< * XXX - FUBAR. This is a general PCCARD problem, not our fault :)
< */
< if ((rc = xe_memread( devi, offs, buf, CISTPL_BUFSIZE )) == 0) {
---
> switch (CISTPL_TYPE(buf)) {
535,537c355
< switch (CISTPL_TYPE(buf)) {
<
< case 0x15: /* Grab version string (needed to ID some weird CE2's) */
---
> case 0x15: /* Grab version string (needed to ID some weird CE2's) */
539c357
< printf("xe%d: Got version string (0x15)\n", unit);
---
> device_printf(dev, "Got version string (0x15)\n");
541,545c359,363
< for (i = 0; i < CISTPL_LEN(buf); ver_str[i] = CISTPL_DATA(buf, i++));
< ver_str[i] = '\0';
< ver_str[(CISTPL_BUFSIZE>>1) - 1] = CISTPL_LEN(buf);
< success++;
< break;
---
> for (i = 0; i < CISTPL_LEN(buf); ver_str[i] = CISTPL_DATA(buf, i++));
> ver_str[i] = '\0';
> ver_str[(CISTPL_BUFSIZE>>1) - 1] = CISTPL_LEN(buf);
> success++;
> break;
547c365
< case 0x20: /* Figure out what type of card we have */
---
> case 0x20: /* Figure out what type of card we have */
549c367
< printf("xe%d: Got card ID (0x20)\n", unit);
---
> device_printf(dev, "Got card ID (0x20)\n");
551,554c369,372
< vendor = CISTPL_DATA(buf, 0) + (CISTPL_DATA(buf, 1) << 8);
< rev = CISTPL_DATA(buf, 2);
< media = CISTPL_DATA(buf, 3);
< prod = CISTPL_DATA(buf, 4);
---
> vendor = CISTPL_DATA(buf, 0) + (CISTPL_DATA(buf, 1) << 8);
> rev = CISTPL_DATA(buf, 2);
> media = CISTPL_DATA(buf, 3);
> prod = CISTPL_DATA(buf, 4);
556,566c374,384
< switch (vendor) { /* Get vendor ID */
< case 0x0105:
< scp->vendor = "Xircom"; break;
< case 0x0138:
< case 0x0183:
< scp->vendor = "Compaq"; break;
< case 0x0089:
< scp->vendor = "Intel"; break;
< default:
< scp->vendor = "Unknown";
< }
---
> switch (vendor) { /* Get vendor ID */
> case 0x0105:
> scp->vendor = "Xircom"; break;
> case 0x0138:
> case 0x0183:
> scp->vendor = "Compaq"; break;
> case 0x0089:
> scp->vendor = "Intel"; break;
> default:
> scp->vendor = "Unknown";
> }
568c386
< if (!((prod & 0x40) && (media & 0x01))) {
---
> if (!((prod & 0x40) && (media & 0x01))) {
570c388
< printf("xe%d: Not a PCMCIA Ethernet card!\n", unit);
---
> device_printf(dev, "Not a PCMCIA Ethernet card!\n");
572,575c390,392
< rc = ENODEV; /* Not a PCMCIA Ethernet device */
< }
< else {
< if (media & 0x10) { /* Ethernet/modem cards */
---
> rc = ENODEV; /* Not a PCMCIA Ethernet device */
> } else {
> if (media & 0x10) { /* Ethernet/modem cards */
577c394
< printf("xe%d: Card is Ethernet/modem combo\n", unit);
---
> device_printf(dev, "Card is Ethernet/modem combo\n");
579,602c396,418
< scp->modem = 1;
< switch (prod & 0x0f) {
< case 1:
< scp->card_type = "CEM"; break;
< case 2:
< scp->ce2 = 1;
< scp->card_type = "CEM2"; break;
< case 3:
< scp->ce2 = 1;
< scp->card_type = "CEM3"; break;
< case 4:
< scp->ce2 = 1;
< scp->card_type = "CEM33"; break;
< case 5:
< scp->mohawk = 1;
< scp->card_type = "CEM56M"; break;
< case 6:
< case 7: /* Some kind of RealPort card */
< scp->mohawk = 1;
< scp->dingo = 1;
< scp->card_type = "CEM56"; break;
< default:
< rc = ENODEV;
< }
---
> scp->modem = 1;
> switch (prod & 0x0f) {
> case 1:
> scp->card_type = "CEM"; break;
> case 2:
> scp->ce2 = 1;
> scp->card_type = "CEM2"; break;
> case 3:
> scp->ce2 = 1;
> scp->card_type = "CEM3"; break;
> case 4:
> scp->ce2 = 1;
> scp->card_type = "CEM33"; break;
> case 5:
> scp->mohawk = 1;
> scp->card_type = "CEM56M"; break;
> case 6:
> case 7: /* Some kind of RealPort card */
> scp->mohawk = 1;
> scp->dingo = 1;
> scp->card_type = "CEM56"; break;
> default:
> rc = ENODEV;
604c420
< else { /* Ethernet-only cards */
---
> } else { /* Ethernet-only cards */
606c422
< printf("xe%d: Card is Ethernet only\n", unit);
---
> device_printf(dev, "Card is Ethernet only\n");
608,619c424,434
< switch (prod & 0x0f) {
< case 1:
< scp->card_type = "CE"; break;
< case 2:
< scp->ce2 = 1;
< scp->card_type = "CE2"; break;
< case 3:
< scp->mohawk = 1;
< scp->card_type = "CE3"; break;
< default:
< rc = ENODEV;
< }
---
> switch (prod & 0x0f) {
> case 1:
> scp->card_type = "CE"; break;
> case 2:
> scp->ce2 = 1;
> scp->card_type = "CE2"; break;
> case 3:
> scp->mohawk = 1;
> scp->card_type = "CE3"; break;
> default:
> rc = ENODEV;
622,623c437,439
< success++;
< break;
---
> }
> success++;
> break;
625,628c441,444
< case 0x22: /* Get MAC address */
< if ((CISTPL_LEN(buf) == 8) &&
< (CISTPL_DATA(buf, 0) == 0x04) &&
< (CISTPL_DATA(buf, 1) == ETHER_ADDR_LEN)) {
---
> case 0x22: /* Get MAC address */
> if ((CISTPL_LEN(buf) == 8) &&
> (CISTPL_DATA(buf, 0) == 0x04) &&
> (CISTPL_DATA(buf, 1) == ETHER_ADDR_LEN)) {
630c446
< printf("xe%d: Got MAC address (0x22)\n", unit);
---
> device_printf(dev, "Got MAC address (0x22)\n");
632,636c448,449
< for (i = 0; i < ETHER_ADDR_LEN; scp->arpcom.ac_enaddr[i] = CISTPL_DATA(buf, i+2), i++);
< }
< success++;
< break;
< default:
---
> for (i = 0; i < ETHER_ADDR_LEN; i++)
> scp->arpcom.ac_enaddr[i] = CISTPL_DATA(buf, i+2);
637a451,454
> success++;
> break;
> default:
> break;
639a457,458
> if (CISTPL_TYPE(buf) == 0xff)
> break;
641c460
< offs += ((CISTPL_LEN(buf) + 2) << 1);
---
> buf += ((CISTPL_LEN(buf) + 2) << 1);
643c462
< } while ((CISTPL_TYPE(buf) != 0xff) && (CISTPL_LEN(buf) != 0xff) && (rc == 0));
---
> } while (1);
644a464,465
> /* unmap the cis */
> bus_release_resource(dev, SYS_RES_MEMORY, rid, r);
647,650c468,469
< if ((rc != 0) || (success < 3)) {
< free(scp, M_DEVBUF);
< return rc;
< }
---
> if (success < 3)
> return ENXIO;
656c475
< printf("xe%d: Checking for weird CE2 string\n", unit);
---
> device_printf(dev, "Checking for weird CE2 string\n");
670,671c489,490
< printf("xe%d: Sorry, your %s card is not supported :(\n", unit, scp->card_type);
< free(scp, M_DEVBUF);
---
> device_printf(dev, "Sorry, your %s card is not supported :(\n",
> scp->card_type);
674a494,526
> /* Success */
> return 0;
> }
>
> /*
> * The device entry is being removed, probably because someone ejected the
> * card. The interface should have been brought down manually before calling
> * this function; if not you may well lose packets. In any case, I shut down
> * the card and the interface, and hope for the best.
> */
> static int
> xe_detach(device_t dev) {
> struct xe_softc *sc = device_get_softc(dev);
>
> sc->arpcom.ac_if.if_flags &= ~IFF_RUNNING;
> if_detach(&sc->arpcom.ac_if);
> xe_deactivate(dev);
> return 0;
> }
>
> /*
> * Attach a device.
> */
> static int
> xe_attach (device_t dev) {
> struct xe_softc *scp = device_get_softc(dev);
>
> #ifdef XE_DEBUG
> device_printf(dev, "attach\n");
> #endif
>
> xe_activate(dev);
>
676,678d527
< sca[unit] = scp;
< scp->dev = &devi->isahd;
< scp->crd = devi;
681d529
< scp->unit = unit;
686,688c534,535
< printf( "xe%d: Unable to fix your RealPort\n", unit );
< sca[unit] = 0;
< free(scp, M_DEVBUF);
---
> device_printf(dev, "Unable to fix your RealPort\n");
> xe_deactivate(dev);
696,735c543
< /* Attempt to attach the device */
< if (!xe_attach(scp->dev)) {
< sca[unit] = 0;
< free(scp, M_DEVBUF);
< return ENXIO;
< }
<
< #if NAPM > 0
< /* Establish APM hooks once device attached */
< scp->suspend_hook.ah_name = "xe_suspend";
< scp->suspend_hook.ah_fun = xe_suspend;
< scp->suspend_hook.ah_arg = (void *)unit;
< scp->suspend_hook.ah_order = APM_MIN_ORDER;
< apm_hook_establish(APM_HOOK_SUSPEND, &scp->suspend_hook);
< scp->resume_hook.ah_name = "xe_resume";
< scp->resume_hook.ah_fun = xe_resume;
< scp->resume_hook.ah_arg = (void *)unit;
< scp->resume_hook.ah_order = APM_MIN_ORDER;
< apm_hook_establish(APM_HOOK_RESUME, &scp->resume_hook);
< #endif /* NAPM > 0 */
<
< /* Success */
< return 0;
< }
<
<
< /*
< * Attach a device (called when xe_card_init succeeds). Assume that the probe
< * routine has set up the softc structure correctly and that we can trust the
< * unit number.
< */
< static int
< xe_attach (struct isa_device *dev) {
< struct xe_softc *scp = sca[dev->id_unit];
< int i;
<
< #ifdef XE_DEBUG
< printf("xe%d: attach\n", scp->unit);
< #endif
<
---
> scp->dev = dev;
740c548
< scp->ifp->if_unit = scp->unit;
---
> scp->ifp->if_unit = device_get_unit(dev);
776,778c584
< printf("\n");
< printf("xe%d: %s %s, bonding version %#x%s%s\n",
< scp->unit,
---
> device_printf(dev, "%s %s, bonding version %#x%s%s\n",
786,787c592
< printf("xe%d: DingoID = %#x, RevisionID = %#x, VendorID = %#x\n",
< scp->unit,
---
> device_printf(dev, "DingoID = %#x, RevisionID = %#x, VendorID = %#x\n",
794,796c599
< printf("xe%d: CE2 version = %#x\n",
< scp->unit,
< XE_INB(XE_REV));
---
> device_printf(dev, "CE2 version = %#x\n", XE_INB(XE_REV));
800,804c603
< printf("xe%d: Ethernet address %02x", scp->unit, scp->arpcom.ac_enaddr[0]);
< for (i = 1; i < ETHER_ADDR_LEN; i++) {
< printf(":%02x", scp->arpcom.ac_enaddr[i]);
< }
< printf("\n");
---
> device_printf(dev, "Ethernet address %6D\n", scp->arpcom.ac_enaddr, ":");
810c609
< /* If BPF is in the kernel, call the attach for it */
---
> /* BPF is in the kernel, call the attach for it */
812c611
< printf("xe%d: BPF listener attached\n", scp->unit);
---
> device_printf(dev, "BPF listener attached\n");
832c631
< printf("xe%d: init\n", scp->unit);
---
> device_printf(scp->dev, "init\n");
835,836d633
< if (scp->gone) return;
<
918,919d714
< if (scp->gone) return;
<
947c742
< printf("xe%d: sending output packet to BPF\n", scp->unit);
---
> device_printf(scp->dev, "sending output packet to BPF\n");
971,974d765
< if (scp->gone) {
< return ENXIO;
< }
<
1032,1034c823
< * Card interrupt handler: should return true if the interrupt was for us, in
< * case we are sharing our IRQ line with other devices (this will probably be
< * the case for multifunction cards).
---
> * Card interrupt handler.
1051,1053c840,843
< static int
< xe_card_intr(struct pccard_devinfo *devi) {
< struct xe_softc *scp;
---
> static void
> xe_intr(void *xscp)
> {
> struct xe_softc *scp = (struct xe_softc *) xscp;
1055c845
< int unit, result;
---
> int result;
1059,1060d848
< unit = devi->isahd.id_unit;
< scp = sca[unit];
1065,1067d852
< if (scp->gone)
< return 0;
<
1259c1044,1045
< insw(scp->dev->id_iobase+XE_EDP, ehp, len >> 1);
---
> bus_space_read_multi_2(scp->bst, scp->bsh, XE_EDP,
> (u_int16_t *) ehp, len >> 1);
1262c1048,1049
< insw(scp->dev->id_iobase+XE_EDP, ehp, len >> 1);
---
> bus_space_read_multi_2(scp->bst, scp->bsh, XE_EDP,
> (u_int16_t *) ehp, len >> 1);
1270c1057
< printf("xe%d: passing input packet to BPF\n", scp->unit);
---
> device_printf(scp->dev, "passing input packet to BPF\n");
1322c1109
< return result;
---
> return;
1336,1338c1123
< if (scp->gone) return;
<
< printf("xe%d: watchdog timeout; resetting card\n", scp->unit);
---
> device_printf(scp->dev, "watchdog timeout; resetting card\n");
1399c1184
< printf("xe%d: setmedia\n", scp->unit);
---
> device_printf(scp->dev, "setmedia\n");
1446c1231
< printf("xe%d: Waiting for idle transmitter\n", scp->unit);
---
> device_printf(scp->dev, "Waiting for idle transmitter\n");
1457c1242
< printf("xe%d: Starting autonegotiation\n", scp->unit);
---
> device_printf(scp->dev, "Starting autonegotiation\n");
1482c1267
< printf("xe%d: Autonegotiation complete!\n", scp->unit);
---
> device_printf(scp->dev, "Autonegotiation complete!\n");
1521c1306
< printf("xe%d: Autonegotiation failed; trying 100baseTX\n", scp->unit);
---
> device_printf(scp->dev, "Autonegotiation failed; trying 100baseTX\n");
1542c1327
< printf("xe%d: Got 100baseTX link!\n", scp->unit);
---
> device_printf(scp->dev, "Got 100baseTX link!\n");
1552c1337
< printf("xe%d: Autonegotiation failed; disabling PHY\n", scp->unit);
---
> device_printf(scp->dev, "Autonegotiation failed; disabling PHY\n");
1572c1357
< printf("xe%d: Selecting 10baseX\n", scp->unit);
---
> device_printf(scp->dev, "Selecting 10baseX\n");
1602c1387
< printf("xe%d: Selecting 100baseTX\n", scp->unit);
---
> device_printf(scp->dev, "Selecting 100baseTX\n");
1617c1402
< printf("xe%d: Selecting 10baseT\n", scp->unit);
---
> device_printf(csp->dev, "Selecting 10baseT\n");
1632c1417
< printf("xe%d: Selecting 10base2\n", scp->unit);
---
> device_printf(scp->dev, "Selecting 10base2\n");
1646c1431
< printf("xe%d: Setting LEDs\n", scp->unit);
---
> device_printf(scp->dev, "Setting LEDs\n");
1676c1461
< printf("xe%d: hard_reset\n", scp->unit);
---
> device_printf(scp->dev, "hard_reset\n");
1679,1680d1463
< if (scp->gone) return;
<
1713c1496
< printf("xe%d: soft_reset\n", scp->unit);
---
> device_printf(scp->dev, "soft_reset\n");
1716,1717d1498
< if (scp->gone) return;
<
1753c1534
< printf("xe%d: silicon revision = %d\n", scp->unit, scp->srev);
---
> device_printf(scp->dev, "silicon revision = %d\n", scp->srev);
1784c1565
< printf("xe%d: stop\n", scp->unit);
---
> device_printf(scp->dev, "stop\n");
1787,1788d1567
< if (scp->gone) return;
<
1820c1599
< printf("xe%d: enable_intr\n", scp->unit);
---
> device_printf(scp->dev, "enable_intr\n");
1844c1623
< printf("xe%d: disable_intr\n", scp->unit);
---
> device_printf(scp->dev, "disable_intr\n");
1945c1724
< printf("xe%d: individual addresses %d: %x", scp->unit, slot, addr[0]);
---
> device_printf(scp->dev, "individual addresses %d: %x", slot, addr[0]);
2016c1795,1796
< outsw(scp->dev->id_iobase+XE_EDP, data, len >> 1);
---
> bus_space_write_multi_2(scp->bst, scp->bsh, XE_EDP, (u_int16_t *) data,
> len >> 1);
2046d1825
<
2048,2076d1826
< * The device entry is being removed, probably because someone ejected the
< * card. The interface should have been brought down manually before calling
< * this function; if not you may well lose packets. In any case, I shut down
< * the card and the interface, and hope for the best. The 'gone' flag is set,
< * so hopefully no-one else will try to access the missing card.
< */
< static void
< xe_card_unload(struct pccard_devinfo *devi) {
< struct xe_softc *scp;
< struct ifnet *ifp;
< int unit;
<
< unit = devi->isahd.id_unit;
< scp = sca[unit];
< ifp = &scp->arpcom.ac_if;
<
< if (scp->gone) {
< printf("xe%d: already unloaded\n", unit);
< return;
< }
<
< if_down(ifp);
< ifp->if_flags &= ~(IFF_RUNNING|IFF_OACTIVE);
< xe_stop(scp);
< scp->gone = 1;
< }
<
<
< /*
2177c1927
< printf("xe%d: no PHY found, %0x\n", scp->unit, status);
---
> device_printf(scp->dev, "no PHY found, %0x\n", status);
2183c1933
< printf("xe%d: PHY OK!\n", scp->unit);
---
> device_printf(scp->dev, "PHY OK!\n");
2406c2156
< printf("xe%d: MII registers: ", scp->unit);
---
> device_printf(scp->dev, "MII registers: ");
2424c2174
< printf("xe%d: Common registers: ", scp->unit);
---
> device_printf(scp->dev, "Common registers: ");
2431c2181
< printf("xe%d: Register page %2.2x: ", scp->unit, page);
---
> device_printf(scp->dev, "Register page %2.2x: ", page);
2445c2195
< printf("xe%d: Register page %2.2x: ", scp->unit, page);
---
> device_printf(scp->dev, "Register page %2.2x: ", page);
2456a2207,2211
> int
> xe_activate(device_t dev)
> {
> struct xe_softc *sc = device_get_softc(dev);
> int err;
2457a2213,2221
> sc->port_rid = 0;
> sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->port_rid,
> 0, ~0, 16, RF_ACTIVE);
> if (!sc->port_res) {
> #if XE_DEBUG > 0
> device_printf(dev, "Cannot allocate ioport\n");
> #endif
> return ENOMEM;
> }
2459,2475c2223,2228
< #if NAPM > 0
< /**************************************************************
< * *
< * A P M F U N C T I O N S *
< * *
< **************************************************************/
<
< /*
< * This is called when we go into suspend/standby mode
< */
< static int
< xe_suspend(void *xunit) {
<
< #ifdef XE_DEBUG
< struct xe_softc *scp = sca[(int)xunit];
<
< printf("xe%d: APM suspend\n", scp->unit);
---
> sc->irq_rid = 0;
> sc->irq_res = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irq_rid,
> 0, ~0, 1, RF_ACTIVE);
> if (!sc->irq_res) {
> #if XE_DEBUG > 0
> device_printf(dev, "Cannot allocate irq\n");
2476a2230,2242
> xe_deactivate(dev);
> return ENOMEM;
> }
> if ((err = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET, xe_intr, sc,
> &sc->intrhand)) != 0) {
> xe_deactivate(dev);
> return err;
> }
>
> sc->bst = rman_get_bustag(sc->port_res);
> sc->bsh = rman_get_bushandle(sc->port_res);
> return (0);
> }
2478c2244,2260
< return 0;
---
> void
> xe_deactivate(device_t dev)
> {
> struct xe_softc *sc = device_get_softc(dev);
>
> if (sc->intrhand)
> bus_teardown_intr(dev, sc->irq_res, sc->intrhand);
> sc->intrhand = 0;
> if (sc->port_res)
> bus_release_resource(dev, SYS_RES_IOPORT, sc->port_rid,
> sc->port_res);
> sc->port_res = 0;
> if (sc->irq_res)
> bus_release_resource(dev, SYS_RES_IRQ, sc->irq_rid,
> sc->irq_res);
> sc->irq_res = 0;
> return;
2481,2485c2263,2267
< /*
< * This is called when we wake up again
< */
< static int
< xe_resume(void *xunit) {
---
> static device_method_t xe_pccard_methods[] = {
> /* Device interface */
> DEVMETHOD(device_probe, xe_probe),
> DEVMETHOD(device_attach, xe_attach),
> DEVMETHOD(device_detach, xe_detach),
2487,2488c2269,2270
< #ifdef XE_DEBUG
< struct xe_softc *scp = sca[(int)xunit];
---
> { 0, 0 }
> };
2490,2491c2272,2276
< printf("xe%d: APM resume\n", scp->unit);
< #endif
---
> static driver_t xe_pccard_driver = {
> "xe",
> xe_pccard_methods,
> sizeof(struct xe_softc),
> };
2493,2494c2278
< return 0;
< }
---
> devclass_t xe_devclass;
2496,2500c2280
< #endif /* NAPM > 0 */
<
< #endif /* NCARD > 0 */
<
< #endif /* NXE > 0 */
---
> DRIVER_MODULE(xe, pccard, xe_pccard_driver, xe_devclass, 0, 0);