Deleted Added
full compact
27c27
< * $FreeBSD: head/sys/dev/ed/if_ed.c 50808 1999-09-02 15:06:23Z kato $
---
> * $FreeBSD: head/sys/dev/ed/if_ed.c 50852 1999-09-03 19:10:56Z peter $
40d39
< #include "ed.h"
42d40
< #include "pnp.h"
44,53d41
< #ifndef EXTRA_ED
< # if NPNP > 0
< # define EXTRA_ED 8
< # else
< # define EXTRA_ED 0
< # endif
< #endif
<
< #define NEDTOT (NED + EXTRA_ED)
<
55a44
> #include <sys/kernel.h>
61a51,57
> #include <sys/module.h>
> #include <sys/bus.h>
>
> #include <machine/bus.h>
> #include <sys/rman.h>
> #include <machine/resource.h>
>
79,80d74
< #include <i386/isa/isa_device.h>
< #include <i386/isa/icu.h>
81a76
> #include <i386/isa/if_edvar.h>
83,85c78,79
< #if NPNP > 0
< #include <i386/isa/pnp.h>
< #endif
---
> #include <isa/isavar.h>
> #include <isa/pnpvar.h>
87,91c81,84
< /*
< * ed_softc: per line info and status
< */
< struct ed_softc {
< struct arpcom arpcom; /* ethernet common */
---
> static int ed_alloc_port __P((device_t, int, int));
> static int ed_alloc_memory __P((device_t, int, int));
> static int ed_alloc_irq __P((device_t, int, int));
> static void ed_release_resources __P((device_t));
93,140d85
< char *type_str; /* pointer to type string */
< u_char vendor; /* interface vendor */
< u_char type; /* interface type code */
< u_char gone; /* HW missing, presumed having a good time */
<
< u_short asic_addr; /* ASIC I/O bus address */
< u_short nic_addr; /* NIC (DS8390) I/O bus address */
<
< /*
< * The following 'proto' variable is part of a work-around for 8013EBT asics
< * being write-only. It's sort of a prototype/shadow of the real thing.
< */
< u_char wd_laar_proto;
< u_char cr_proto;
< u_char isa16bit; /* width of access to card 0=8 or 1=16 */
< int is790; /* set by the probe code if the card is 790
< * based */
<
< /*
< * HP PC LAN PLUS card support.
< */
<
< u_short hpp_options; /* flags controlling behaviour of the HP card */
< u_short hpp_id; /* software revision and other fields */
< caddr_t hpp_mem_start; /* Memory-mapped IO register address */
<
< caddr_t mem_start; /* NIC memory start address */
< caddr_t mem_end; /* NIC memory end address */
< u_long mem_size; /* total NIC memory size */
< caddr_t mem_ring; /* start of RX ring-buffer (in NIC mem) */
<
< u_char mem_shared; /* NIC memory is shared with host */
< u_char xmit_busy; /* transmitter is busy */
< u_char txb_cnt; /* number of transmit buffers */
< u_char txb_inuse; /* number of TX buffers currently in-use */
<
< u_char txb_new; /* pointer to where new buffer will be added */
< u_char txb_next_tx; /* pointer to next buffer ready to xmit */
< u_short txb_len[8]; /* buffered xmit buffer lengths */
< u_char tx_page_start; /* first page of TX buffer area */
< u_char rec_page_start; /* first page of RX ring-buffer */
< u_char rec_page_stop; /* last page of RX ring-buffer */
< u_char next_packet; /* pointer to next unread RX packet */
< struct ifmib_iso_8802_3 mibdata; /* stuff for network mgmt */
< };
<
< static struct ed_softc ed_softc[NEDTOT];
<
142c87
< static int ed_attach_isa __P((struct isa_device *));
---
> static int ed_isa_attach __P((device_t));
145c90
< static ointhand2_t edintr;
---
> static driver_intr_t edintr;
147c92
< static int ed_probe __P((struct isa_device *));
---
> static int ed_isa_probe __P((device_t));
154,158c99,103
< static int ed_probe_WD80x3 __P((struct isa_device *));
< static int ed_probe_3Com __P((struct isa_device *));
< static int ed_probe_Novell __P((struct isa_device *));
< static int ed_probe_Novell_generic __P((struct ed_softc *, int, int, int));
< static int ed_probe_HP_pclanp __P((struct isa_device *));
---
> static int ed_probe_WD80x3 __P((device_t));
> static int ed_probe_3Com __P((device_t));
> static int ed_probe_Novell __P((device_t));
> static int ed_probe_Novell_generic __P((device_t, int, int));
> static int ed_probe_HP_pclanp __P((device_t));
162c107
< void *ed_attach_NE2000_pci __P((int, int));
---
> int ed_attach_NE2000_pci __P((device_t, int));
166c111
< #if NCARD > 0
---
> #if NCARDxx > 0
190d134
< void edintr_sc __P((struct ed_softc *));
196,199c140
< #if (NCARD > 0) || (NPNP > 0)
< #include <sys/kernel.h>
< #endif
< #if NCARD > 0
---
> #if NCARDxx > 0
240c181
< if (ed_attach_isa(&devi->isahd) == 0)
---
> if (ed_isa_attach(&devi->isahd) == 0)
278c219
< edintr_sc(&ed_softc[devi->isahd.id_unit]);
---
> edintr(&ed_softc[devi->isahd.id_unit]);
283,289d223
< struct isa_driver eddriver = {
< ed_probe,
< ed_attach_isa,
< "ed",
< 1 /* We are ultra sensitive */
< };
<
292d225
< * (IRQ* are defined in icu.h)
294,302c227,235
< static unsigned short ed_intr_mask[] = {
< IRQ9,
< IRQ3,
< IRQ5,
< IRQ7,
< IRQ10,
< IRQ11,
< IRQ15,
< IRQ4
---
> static unsigned short ed_intr_val[] = {
> 9,
> 3,
> 5,
> 7,
> 10,
> 11,
> 15,
> 4
308c241
< static unsigned short ed_790_intr_mask[] = {
---
> static unsigned short ed_790_intr_val[] = {
310,316c243,249
< IRQ9,
< IRQ3,
< IRQ5,
< IRQ7,
< IRQ10,
< IRQ11,
< IRQ15
---
> 9,
> 3,
> 5,
> 7,
> 10,
> 11,
> 15
323c256
< static unsigned short ed_hpp_intr_mask[] = {
---
> static unsigned short ed_hpp_intr_val[] = {
327,331c260,264
< IRQ3, /* 3 */
< IRQ4, /* 4 */
< IRQ5, /* 5 */
< IRQ6, /* 6 */
< IRQ7, /* 7 */
---
> 3, /* 3 */
> 4, /* 4 */
> 5, /* 5 */
> 6, /* 6 */
> 7, /* 7 */
333,336c266,269
< IRQ9, /* 9 */
< IRQ10, /* 10 */
< IRQ11, /* 11 */
< IRQ12, /* 12 */
---
> 9, /* 9 */
> 10, /* 10 */
> 11, /* 11 */
> 12, /* 12 */
339c272
< IRQ15 /* 15 */
---
> 15 /* 15 */
342,350c275,285
< /*
< * Determine if the device is present
< *
< * on entry:
< * a pointer to an isa_device struct
< * on exit:
< * NULL if device not found
< * or # of i/o addresses used (if found)
< */
---
> static struct isa_pnp_id ed_ids[] = {
> { 0xd680d041, "NE2000 Compatible" }, /* PNP80d6 */
> { 0x1980635e, "WSC8019" }, /* WSC8019 */
> { 0x0131d805, "Acer ALN-101T" }, /* ANX3101 */
> { 0x01200507, "PLANET ENW-2401" }, /* AXE2001 */
> { 0x19808c4a, "Realtek Plug & Play Ethernet Card" }, /* RTL8019 */
> { 0x0090252a, "CNet NE2000 Compatible" }, /* JQE9000 */
> { 0x0020832e, "Kingston EtheRX KNE20 Plug & Play ISA" }, /* KTC2000 */
> { 0, NULL}
> };
>
352,353c287,288
< ed_probe(isa_dev)
< struct isa_device *isa_dev;
---
> ed_isa_probe(dev)
> device_t dev;
355c290,291
< int nports;
---
> struct ed_softc *sc = device_get_softc(dev);
> int error = 0;
357,359c293
< nports = ed_probe_WD80x3(isa_dev);
< if (nports)
< return (nports);
---
> bzero(sc, sizeof(struct ed_softc));
361,363c295,296
< nports = ed_probe_3Com(isa_dev);
< if (nports)
< return (nports);
---
> /* Check isapnp ids */
> error = ISA_PNP_PROBE(device_get_parent(dev), dev, ed_ids);
365,367c298,300
< nports = ed_probe_Novell(isa_dev);
< if (nports)
< return (nports);
---
> /* If the card had a PnP ID that didn't match any we know about */
> if (error == ENXIO)
> goto end;
369,371c302,308
< nports = ed_probe_HP_pclanp(isa_dev);
< if (nports)
< return (nports);
---
> /* If we found a PnP card. */
> if (error == 0) {
> error = ed_probe_Novell(dev);
> goto end;
> }
>
> /* Heuristic probes */
373c310,335
< return (0);
---
> error = ed_probe_WD80x3(dev);
> if (error == 0)
> goto end;
> ed_release_resources(dev);
>
> error = ed_probe_3Com(dev);
> if (error == 0)
> goto end;
> ed_release_resources(dev);
>
> error = ed_probe_Novell(dev);
> if (error == 0)
> goto end;
> ed_release_resources(dev);
>
> error = ed_probe_HP_pclanp(dev);
> if (error == 0)
> goto end;
> ed_release_resources(dev);
>
> end:
> if (error == 0)
> error = ed_alloc_irq(dev, 0, 0);
>
> ed_release_resources(dev);
> return (error);
417,418c379,380
< ed_probe_WD80x3(isa_dev)
< struct isa_device *isa_dev;
---
> ed_probe_WD80x3(dev)
> device_t dev;
420c382,383
< struct ed_softc *sc = &ed_softc[isa_dev->id_unit];
---
> struct ed_softc *sc = device_get_softc(dev);
> int error;
421a385
> int flags = isa_get_flags(dev);
423a388
> u_long conf_maddr, conf_msize, irq, junk;
425c390,394
< sc->asic_addr = isa_dev->id_iobase;
---
> error = ed_alloc_port(dev, 0, ED_WD_IO_PORTS);
> if (error)
> return (error);
>
> sc->asic_addr = rman_get_start(sc->port_res);
452c421
< return (0);
---
> return (ENXIO);
586a556,561
> error = ISA_GET_RESOURCE(device_get_parent(dev), dev,
> SYS_RES_MEMORY, 0,
> &conf_maddr, &conf_msize);
> if (error)
> return (error);
>
589c564
< sc->type, sc->type_str, isa16bit, memsize, isa_dev->id_msize);
---
> sc->type, sc->type_str, isa16bit, memsize, conf_msize);
597,598c572,573
< if (isa_dev->id_msize)
< memsize = isa_dev->id_msize;
---
> if (conf_msize > 1)
> memsize = conf_msize;
600c575
< maddr = (u_int) isa_dev->id_maddr & 0xffffff;
---
> maddr = conf_maddr;
602,604c577,579
< printf("ed%d: Invalid ISA memory address range configured: 0x%x - 0x%x\n",
< isa_dev->id_unit, maddr, maddr + memsize);
< return 0;
---
> device_printf(dev, "Invalid ISA memory address range configured: 0x%x - 0x%x\n",
> maddr, maddr + memsize);
> return (ENXIO);
611c586
< if (isa_dev->id_flags & ED_FLAGS_FORCE_16BIT_MODE)
---
> if (flags & ED_FLAGS_FORCE_16BIT_MODE)
613c588
< if (isa_dev->id_flags & ED_FLAGS_FORCE_8BIT_MODE)
---
> if (flags & ED_FLAGS_FORCE_8BIT_MODE)
625,626c600,601
< iptr = (inb(isa_dev->id_iobase + ED_WD_ICR) & ED_WD_ICR_IR2) |
< ((inb(isa_dev->id_iobase + ED_WD_IRR) &
---
> iptr = (inb(sc->asic_addr + ED_WD_ICR) & ED_WD_ICR_IR2) |
> ((inb(sc->asic_addr + ED_WD_IRR) &
632,633c607,614
< if (isa_dev->id_irq <= 0)
< isa_dev->id_irq = ed_intr_mask[iptr];
---
> error = ISA_GET_RESOURCE(device_get_parent(dev), dev,
> SYS_RES_IRQ, 0,
> &irq, &junk);
> if (error) {
> ISA_SET_RESOURCE(device_get_parent(dev), dev,
> SYS_RES_IRQ, 0,
> ed_intr_val[iptr], 1);
> }
638,639c619,620
< outb(isa_dev->id_iobase + ED_WD_IRR,
< inb(isa_dev->id_iobase + ED_WD_IRR) | ED_WD_IRR_IEN);
---
> outb(sc->asic_addr + ED_WD_IRR,
> inb(sc->asic_addr + ED_WD_IRR) | ED_WD_IRR_IEN);
642,645c623,626
< outb(isa_dev->id_iobase + ED_WD790_HWR,
< inb(isa_dev->id_iobase + ED_WD790_HWR) | ED_WD790_HWR_SWH);
< iptr = (((inb(isa_dev->id_iobase + ED_WD790_GCR) & ED_WD790_GCR_IR2) >> 4) |
< (inb(isa_dev->id_iobase + ED_WD790_GCR) &
---
> outb(sc->asic_addr + ED_WD790_HWR,
> inb(sc->asic_addr + ED_WD790_HWR) | ED_WD790_HWR_SWH);
> iptr = (((inb(sc->asic_addr + ED_WD790_GCR) & ED_WD790_GCR_IR2) >> 4) |
> (inb(sc->asic_addr + ED_WD790_GCR) &
647,648c628,629
< outb(isa_dev->id_iobase + ED_WD790_HWR,
< inb(isa_dev->id_iobase + ED_WD790_HWR) & ~ED_WD790_HWR_SWH);
---
> outb(sc->asic_addr + ED_WD790_HWR,
> inb(sc->asic_addr + ED_WD790_HWR) & ~ED_WD790_HWR_SWH);
653,654c634,641
< if (isa_dev->id_irq <= 0)
< isa_dev->id_irq = ed_790_intr_mask[iptr];
---
> error = ISA_GET_RESOURCE(device_get_parent(dev), dev,
> SYS_RES_IRQ, 0,
> &irq, &junk);
> if (error) {
> ISA_SET_RESOURCE(device_get_parent(dev), dev,
> SYS_RES_IRQ, 0,
> ed_790_intr_val[iptr], 1);
> }
659,660c646,647
< outb(isa_dev->id_iobase + ED_WD790_ICR,
< inb(isa_dev->id_iobase + ED_WD790_ICR) | ED_WD790_ICR_EIL);
---
> outb(sc->asic_addr + ED_WD790_ICR,
> inb(sc->asic_addr + ED_WD790_ICR) | ED_WD790_ICR_EIL);
662,665c649,655
< if (isa_dev->id_irq <= 0) {
< printf("ed%d: %s cards don't support auto-detected/assigned interrupts.\n",
< isa_dev->id_unit, sc->type_str);
< return (0);
---
> error = ISA_GET_RESOURCE(device_get_parent(dev), dev,
> SYS_RES_IRQ, 0,
> &irq, &junk);
> if (error) {
> device_printf(dev, "%s cards don't support auto-detected/assigned interrupts.\n",
> sc->type_str);
> return (ENXIO);
669,670d658
< isa_dev->id_msize = memsize;
< sc->mem_start = (caddr_t) isa_dev->id_maddr;
671a660,664
> error = ed_alloc_memory(dev, 0, memsize);
> if (error)
> return (error);
> sc->mem_start = (caddr_t) rman_get_virtual(sc->mem_res);
>
676c669
< (isa_dev->id_flags & ED_FLAGS_NO_MULTI_BUFFERING)) {
---
> (flags & ED_FLAGS_NO_MULTI_BUFFERING)) {
760,761c753,754
< printf("ed%d: failed to clear shared memory at %lx - check configuration\n",
< isa_dev->id_unit, kvtop(sc->mem_start + i));
---
> device_printf(dev, "failed to clear shared memory at %lx - check configuration\n",
> kvtop(sc->mem_start + i));
773c766
< return (0);
---
> return (ENXIO);
792c785
< return (ED_WD_IO_PORTS);
---
> return (0);
799,800c792,793
< ed_probe_3Com(isa_dev)
< struct isa_device *isa_dev;
---
> ed_probe_3Com(dev)
> device_t dev;
802c795,796
< struct ed_softc *sc = &ed_softc[isa_dev->id_unit];
---
> struct ed_softc *sc = device_get_softc(dev);
> int error;
803a798
> int flags = isa_get_flags(dev);
805a801
> u_long conf_maddr, conf_msize, irq, junk;
807,808c803,805
< sc->asic_addr = isa_dev->id_iobase + ED_3COM_ASIC_OFFSET;
< sc->nic_addr = isa_dev->id_iobase + ED_3COM_NIC_OFFSET;
---
> error = ed_alloc_port(dev, 0, ED_3COM_IO_PORTS);
> if (error)
> return (error);
809a807,809
> sc->asic_addr = rman_get_start(sc->port_res) + ED_3COM_ASIC_OFFSET;
> sc->nic_addr = rman_get_start(sc->port_res) + ED_3COM_NIC_OFFSET;
>
816,817c816,817
< if (isa_dev->id_iobase != 0x300)
< return (0);
---
> if (rman_get_start(sc->port_res) != 0x300)
> return (ENXIO);
820,821c820,821
< if (isa_dev->id_iobase != 0x310)
< return (0);
---
> if (rman_get_start(sc->port_res) != 0x310)
> return (ENXIO);
824,825c824,825
< if (isa_dev->id_iobase != 0x330)
< return (0);
---
> if (rman_get_start(sc->port_res) != 0x330)
> return (ENXIO);
828,829c828,829
< if (isa_dev->id_iobase != 0x350)
< return (0);
---
> if (rman_get_start(sc->port_res) != 0x350)
> return (ENXIO);
832,833c832,833
< if (isa_dev->id_iobase != 0x250)
< return (0);
---
> if (rman_get_start(sc->port_res) != 0x250)
> return (ENXIO);
836,837c836,837
< if (isa_dev->id_iobase != 0x280)
< return (0);
---
> if (rman_get_start(sc->port_res) != 0x280)
> return (ENXIO);
840,841c840,841
< if (isa_dev->id_iobase != 0x2a0)
< return (0);
---
> if (rman_get_start(sc->port_res) != 0x2a0)
> return (ENXIO);
844,845c844,845
< if (isa_dev->id_iobase != 0x2e0)
< return (0);
---
> if (rman_get_start(sc->port_res) != 0x2e0)
> return (ENXIO);
848c848
< return (0);
---
> return (ENXIO);
850a851,856
> error = ISA_GET_RESOURCE(device_get_parent(dev), dev,
> SYS_RES_MEMORY, 0,
> &conf_maddr, &conf_msize);
> if (error)
> return (error);
>
857,858c863,864
< if (kvtop(isa_dev->id_maddr) != 0xdc000)
< return (0);
---
> if (conf_maddr != 0xdc000)
> return (ENXIO);
861,862c867,868
< if (kvtop(isa_dev->id_maddr) != 0xd8000)
< return (0);
---
> if (conf_maddr != 0xd8000)
> return (ENXIO);
865,866c871,872
< if (kvtop(isa_dev->id_maddr) != 0xcc000)
< return (0);
---
> if (conf_maddr != 0xcc000)
> return (ENXIO);
869,870c875,876
< if (kvtop(isa_dev->id_maddr) != 0xc8000)
< return (0);
---
> if (conf_maddr != 0xc8000)
> return (ENXIO);
873c879
< return (0);
---
> return (ENXIO);
965c971,975
< sc->mem_start = (caddr_t) isa_dev->id_maddr;
---
> error = ed_alloc_memory(dev, 0, memsize);
> if (error)
> return (error);
>
> sc->mem_start = (caddr_t) rman_get_virtual(sc->mem_res);
979c989
< if (isa_dev->id_flags & ED_FLAGS_NO_MULTI_BUFFERING)
---
> if (flags & ED_FLAGS_NO_MULTI_BUFFERING)
1010,1011c1020,1027
< switch (isa_dev->id_irq) {
< case IRQ2:
---
> error = ISA_GET_RESOURCE(device_get_parent(dev), dev,
> SYS_RES_IRQ, 0,
> &irq, &junk);
> if (error)
> return (error);
>
> switch (irq) {
> case 2:
1014c1030
< case IRQ3:
---
> case 3:
1017c1033
< case IRQ4:
---
> case 4:
1020c1036
< case IRQ5:
---
> case 5:
1024,1026c1040,1042
< printf("ed%d: Invalid irq configuration (%d) must be 3-5,9 for 3c503\n",
< isa_dev->id_unit, ffs(isa_dev->id_irq) - 1);
< return (0);
---
> device_printf(dev, "Invalid irq configuration (%ld) must be 3-5,9 for 3c503\n",
> irq);
> return (ENXIO);
1053,1055c1069,1071
< printf("ed%d: failed to clear shared memory at %lx - check configuration\n",
< isa_dev->id_unit, kvtop(sc->mem_start + i));
< return (0);
---
> device_printf(dev, "failed to clear shared memory at %lx - check configuration\n",
> kvtop(sc->mem_start + i));
> return (ENXIO);
1057,1058c1073
< isa_dev->id_msize = memsize;
< return (ED_3COM_IO_PORTS);
---
> return (0);
1065,1068c1080,1082
< ed_probe_Novell_generic(sc, port, unit, flags)
< struct ed_softc *sc;
< int port;
< int unit;
---
> ed_probe_Novell_generic(dev, port_rid, flags)
> device_t dev;
> int port_rid;
1070a1085
> struct ed_softc *sc = device_get_softc(dev);
1074a1090
> int error;
1076,1077c1092,1094
< sc->asic_addr = port + ED_NOVELL_ASIC_OFFSET;
< sc->nic_addr = port + ED_NOVELL_NIC_OFFSET;
---
> error = ed_alloc_port(dev, port_rid, ED_NOVELL_IO_PORTS);
> if (error)
> return (error);
1078a1096,1098
> sc->asic_addr = rman_get_start(sc->port_res) + ED_NOVELL_ASIC_OFFSET;
> sc->nic_addr = rman_get_start(sc->port_res) + ED_NOVELL_NIC_OFFSET;
>
1111c1131
< return (0);
---
> return (ENXIO);
1161c1181
< return (0); /* not an NE2000 either */
---
> return (ENXIO); /* not an NE2000 either */
1216,1217c1236,1237
< printf("ed%d: Cannot find start of RAM.\n", unit);
< return 0;
---
> device_printf(dev, "Cannot find start of RAM.\n");
> return (ENXIO);
1238,1239c1258,1259
< printf("ed%d: Cannot find any RAM, start : %d, x = %d.\n", unit, mstart, x);
< return 0;
---
> device_printf(dev, "Cannot find any RAM, start : %d, x = %d.\n", mstart, x);
> return (ENXIO);
1241c1261
< printf("ed%d: RAM start at %d, size : %d.\n", unit, mstart, msize);
---
> device_printf(dev, "RAM start at %d, size : %d.\n", mstart, msize);
1277c1297
< return (ED_NOVELL_IO_PORTS);
---
> return (0);
1281,1282c1301,1302
< ed_probe_Novell(isa_dev)
< struct isa_device *isa_dev;
---
> ed_probe_Novell(dev)
> device_t dev;
1284,1292c1304
< struct ed_softc *sc = &ed_softc[isa_dev->id_unit];
< int nports;
<
< nports = ed_probe_Novell_generic(sc, isa_dev->id_iobase,
< isa_dev->id_unit, isa_dev->id_flags);
< if (nports)
< isa_dev->id_maddr = 0;
<
< return (nports);
---
> return ed_probe_Novell_generic(dev, 0, isa_get_flags(dev));
1295c1307
< #if NCARD > 0
---
> #if NCARDxx > 0
1346,1347c1358,1359
< ed_probe_HP_pclanp(isa_dev)
< struct isa_device *isa_dev;
---
> ed_probe_HP_pclanp(dev)
> device_t dev;
1349c1361,1362
< struct ed_softc *sc = &ed_softc[isa_dev->id_unit];
---
> struct ed_softc *sc = device_get_softc(dev);
> int error;
1355a1369
> u_long conf_maddr, conf_msize, conf_irq, junk;
1356a1371,1373
> error = ed_alloc_port(dev, 0, ED_HPP_IO_PORTS);
> if (error)
> return (error);
1359,1360c1376,1377
< sc->asic_addr = isa_dev->id_iobase + ED_HPP_ASIC_OFFSET;
< sc->nic_addr = isa_dev->id_iobase + ED_HPP_NIC_OFFSET;
---
> sc->asic_addr = rman_get_start(sc->port_res) + ED_HPP_ASIC_OFFSET;
> sc->nic_addr = rman_get_start(sc->port_res) + ED_HPP_NIC_OFFSET;
1440c1457
< if (irq >= (sizeof(ed_hpp_intr_mask) / sizeof(ed_hpp_intr_mask[0])))
---
> if (irq >= (sizeof(ed_hpp_intr_val) / sizeof(ed_hpp_intr_val[0])))
1447a1465,1475
> error = ISA_GET_RESOURCE(device_get_parent(dev), dev,
> SYS_RES_IRQ, 0,
> &conf_irq, &junk);
> if (error) {
> ISA_SET_RESOURCE(device_get_parent(dev), dev,
> SYS_RES_IRQ, 0,
> ed_hpp_intr_val[irq], 1);
> } else {
> if (conf_irq != ed_hpp_intr_val[irq])
> return (ENXIO);
> }
1449,1453d1476
< if (isa_dev->id_irq <= 0)
< isa_dev->id_irq = ed_hpp_intr_mask[irq];
< else if (isa_dev->id_irq != ed_hpp_intr_mask[irq])
< return 0;
<
1467a1491,1497
> * The board has 32KB of memory. Is there a way to determine
> * this programmatically?
> */
>
> memsize = 32768;
>
> /*
1485a1516,1520
> error = ISA_GET_RESOURCE(device_get_parent(dev), dev,
> SYS_RES_MEMORY, 0,
> &conf_maddr, &conf_msize);
> if (error)
> return (error);
1487c1522
< if (mem_addr != kvtop(isa_dev->id_maddr))
---
> if (mem_addr != conf_maddr)
1490c1525,1529
< sc->hpp_mem_start = isa_dev->id_maddr;
---
> error = ed_alloc_memory(dev, 0, memsize);
> if (error)
> return (error);
>
> sc->hpp_mem_start = rman_get_virtual(sc->mem_res);
1494,1500d1532
< * The board has 32KB of memory. Is there a way to determine
< * this programmatically?
< */
<
< memsize = 32768;
<
< /*
1510c1542
< if (isa_dev->id_flags & ED_FLAGS_NO_MULTI_BUFFERING)
---
> if (isa_get_flags(dev) & ED_FLAGS_NO_MULTI_BUFFERING)
1637a1670,1680
> /*
> * Allocate a port resource with the given resource id.
> */
> static int
> ed_alloc_port(dev, rid, size)
> device_t dev;
> int rid;
> int size;
> {
> struct ed_softc *sc = device_get_softc(dev);
> struct resource *res;
1638a1682,1693
> res = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
> 0ul, ~0ul, size, RF_ACTIVE);
> if (res) {
> sc->port_rid = rid;
> sc->port_res = res;
> sc->port_used = 1;
> return (0);
> } else {
> return (ENOENT);
> }
> }
>
1639a1695,1767
> * Allocate a memory resource with the given resource id.
> */
> static int
> ed_alloc_memory(dev, rid, size)
> device_t dev;
> int rid;
> int size;
> {
> struct ed_softc *sc = device_get_softc(dev);
> struct resource *res;
>
> res = bus_alloc_resource(dev, SYS_RES_MEMORY, &rid,
> 0ul, ~0ul, size, RF_ACTIVE);
> if (res) {
> sc->mem_rid = rid;
> sc->mem_res = res;
> sc->mem_used = 1;
> return (0);
> } else {
> return (ENOENT);
> }
> }
>
> /*
> * Allocate an irq resource with the given resource id.
> */
> static int
> ed_alloc_irq(dev, rid, flags)
> device_t dev;
> int rid;
> int flags;
> {
> struct ed_softc *sc = device_get_softc(dev);
> struct resource *res;
>
> res = bus_alloc_resource(dev, SYS_RES_IRQ, &rid,
> 0ul, ~0ul, 1, (RF_ACTIVE | flags));
> if (res) {
> sc->irq_rid = rid;
> sc->irq_res = res;
> return (0);
> } else {
> return (ENOENT);
> }
> }
>
> /*
> * Release all resources
> */
> static void
> ed_release_resources(dev)
> device_t dev;
> {
> struct ed_softc *sc = device_get_softc(dev);
>
> if (sc->port_res) {
> bus_release_resource(dev, SYS_RES_IOPORT,
> sc->port_rid, sc->port_res);
> sc->port_res = 0;
> }
> if (sc->mem_res) {
> bus_release_resource(dev, SYS_RES_MEMORY,
> sc->mem_rid, sc->mem_res);
> sc->mem_res = 0;
> }
> if (sc->irq_res) {
> bus_release_resource(dev, SYS_RES_IRQ,
> sc->irq_rid, sc->irq_res);
> sc->irq_res = 0;
> }
> }
>
> /*
1731c1859
< return 1;
---
> return (0);
1735,1736c1863,1864
< ed_attach_isa(isa_dev)
< struct isa_device *isa_dev;
---
> ed_isa_attach(dev)
> device_t dev;
1738,1740c1866,1868
< int unit = isa_dev->id_unit;
< struct ed_softc *sc = &ed_softc[unit];
< int flags = isa_dev->id_flags;
---
> struct ed_softc *sc = device_get_softc(dev);
> int flags = isa_get_flags(dev);
> int error;
1742,1743c1870,1883
< isa_dev->id_ointr = edintr;
< return ed_attach(sc, unit, flags);
---
> if (sc->port_used > 0)
> ed_alloc_port(dev, sc->port_rid, 1);
> if (sc->mem_used)
> ed_alloc_memory(dev, sc->mem_rid, 1);
> ed_alloc_irq(dev, sc->irq_rid, 0);
>
> error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
> edintr, sc, &sc->irq_handle);
> if (error) {
> ed_release_resources(dev);
> return (error);
> }
>
> return ed_attach(sc, device_get_unit(dev), flags);
1747,1750c1887,1890
< void *
< ed_attach_NE2000_pci(unit, port)
< int unit;
< int port;
---
> int
> ed_attach_NE2000_pci(dev, port_rid)
> device_t dev;
> int port_rid;
1752,1753c1892,1894
< struct ed_softc *sc = malloc(sizeof *sc, M_DEVBUF, M_NOWAIT);
< int isa_flags = 0;
---
> struct ed_softc *sc = device_get_softc(dev);
> int flags = 0;
> int error;
1755,1756c1896,1898
< if (!sc)
< return sc;
---
> error = ed_probe_Novell_generic(dev, port_rid, flags);
> if (error)
> return (error);
1758,1762c1900,1903
< bzero(sc, sizeof *sc);
< if (ed_probe_Novell_generic(sc, port, unit, isa_flags) == 0
< || ed_attach(sc, unit, isa_flags) == 0) {
< free(sc, M_DEVBUF);
< return NULL;
---
> error = ed_alloc_irq(dev, 0, RF_SHAREABLE);
> if (error) {
> ed_release_resources(dev);
> return (error);
1764c1905,1913
< return sc;
---
>
> error = bus_setup_intr(dev, sc->irq_res, INTR_TYPE_NET,
> edintr, sc, &sc->irq_handle);
> if (error) {
> ed_release_resources(dev);
> return (error);
> }
>
> return ed_attach(sc, device_get_unit(dev), flags);
2336,2338c2485,2487
< void
< edintr_sc(sc)
< struct ed_softc *sc;
---
> static void
> edintr(arg)
> void *arg;
2339a2489
> struct ed_softc *sc = (struct ed_softc*) arg;
2578,2584d2727
< static void
< edintr(unit)
< int unit;
< {
< edintr_sc (&ed_softc[unit]);
< }
<
3442,3444c3585,3588
< /*
< * support PnP cards if we are using 'em
< */
---
> static device_method_t ed_isa_methods[] = {
> /* Device interface */
> DEVMETHOD(device_probe, ed_isa_probe),
> DEVMETHOD(device_attach, ed_isa_attach),
3446,3450c3590
< #if NPNP > 0
<
< static pnpid_t edpnp_ids[] = {
< { 0xd680d041, "NE2000"},
< { 0 }
---
> { 0, 0 }
3453,3463c3593,3596
< 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
---
> static driver_t ed_isa_driver = {
> "ed",
> ed_isa_methods,
> sizeof(struct ed_softc)
3465d3597
< DATA_SET (pnpdevice_set, edpnp);
3467,3471c3599
< static char *
< edpnp_probe(u_long csn, u_long vend_id)
< {
< pnpid_t *id;
< char *s = NULL;
---
> static devclass_t ed_isa_devclass;
3473,3525c3601
< for(id = edpnp_ids; id->vend_id != 0; id++) {
< if (vend_id == id->vend_id) {
< s = id->id_str;
< break;
< }
< }
<
< if (s) {
< struct pnp_cinfo d;
< read_pnp_parms(&d, 0);
< if (d.enable == 0 || d.flags & 1) {
< printf("CSN %lu 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;
<
< 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_ointr = edintr;
< dev->id_drq = -1;
<
< if (dev->id_driver == NULL) {
< dev->id_driver = &eddriver;
< dev->id_id = isa_compat_nextid();
< }
<
< if ((dev->id_alive = ed_probe(dev)) != 0)
< ed_attach_isa(dev);
< else
< printf("ed%d: probe failed\n", dev->id_unit);
< }
< #endif
---
> DRIVER_MODULE(ed, isa, ed_isa_driver, ed_isa_devclass, 0, 0);