Split out the ISA bus front end code into its own file. PCCARD attachment

coming later this week.  Mitsuru IWASAKI provided a patch to -mobile which
I used to make sure I was doing the right thing but only a small part of
the actual patch was used.
This commit is contained in:
Matthew N. Dodd 2000-05-01 09:05:19 +00:00
parent 4eaed34ba0
commit 68c68f014d
5 changed files with 478 additions and 302 deletions

View File

@ -129,7 +129,8 @@ dev/ep/if_ep_eisa.c optional ep eisa
dev/ep/if_ep_isa.c optional ep isa
dev/ep/if_ep_mca.c optional ep mca
dev/ep/if_ep_pccard.c optional ep card
dev/ex/if_ex.c optional ex isa
dev/ex/if_ex.c optional ex
dev/ex/if_ex_isa.c optional ex isa
dev/hea/eni.c optional hea
dev/hea/eni_buffer.c optional hea
dev/hea/eni_globals.c optional hea

View File

@ -69,6 +69,7 @@
#include <isa/pnpvar.h>
#include <dev/ex/if_exreg.h>
#include <dev/ex/if_exvar.h>
#ifdef EXDEBUG
# define Start_End 1
@ -82,59 +83,16 @@ static int exintr_count = 0;
# define DODEBUG(level, action)
#endif
#define CARD_TYPE_EX_10 1
#define CARD_TYPE_EX_10_PLUS 2
struct ex_softc {
struct arpcom arpcom; /* Ethernet common data */
struct ifmedia ifmedia;
device_t dev;
struct resource *ioport;
struct resource *irq;
u_int iobase; /* I/O base address. */
u_short irq_no; /* IRQ number. */
char * irq2ee; /* irq <-> internal */
u_char * ee2irq; /* representation conversion */
u_int mem_size; /* Total memory size, in bytes. */
u_int rx_mem_size; /* Rx memory size (by default, */
/* first 3/4 of total memory). */
u_int rx_lower_limit; /* Lower and upper limits of */
u_int rx_upper_limit; /* receive buffer. */
u_int rx_head; /* Head of receive ring buffer. */
u_int tx_mem_size; /* Tx memory size (by default, */
/* last quarter of total memory).*/
u_int tx_lower_limit; /* Lower and upper limits of */
u_int tx_upper_limit; /* transmit buffer. */
u_int tx_head; /* Head and tail of */
u_int tx_tail; /* transmit ring buffer. */
u_int tx_last; /* Pointer to beginning of last */
/* frame in the chain. */
};
static char irq2eemap[] =
char irq2eemap[] =
{ -1, -1, 0, 1, -1, 2, -1, -1, -1, 0, 3, 4, -1, -1, -1, -1 };
static u_char ee2irqmap[] =
u_char ee2irqmap[] =
{ 9, 3, 5, 10, 11, 0, 0, 0 };
static char plus_irq2eemap[] =
char plus_irq2eemap[] =
{ -1, -1, -1, 0, 1, 2, -1, 3, -1, 4, 5, 6, 7, -1, -1, -1 };
static u_char plus_ee2irqmap[] =
u_char plus_ee2irqmap[] =
{ 3, 4, 5, 7, 9, 10, 11, 12 };
/* Bus Front End Functions */
static void ex_isa_identify __P((driver_t *, device_t));
static int ex_isa_probe __P((device_t));
static int ex_isa_attach __P((device_t));
/* Network Interface Functions */
static void ex_init __P((void *));
static void ex_start __P((struct ifnet *));
@ -145,42 +103,16 @@ static void ex_watchdog __P((struct ifnet *));
static int ex_ifmedia_upd __P((struct ifnet *));
static void ex_ifmedia_sts __P((struct ifnet *, struct ifmediareq *));
static int ex_get_media __P((u_int32_t iobase));
static void ex_stop __P((struct ex_softc *));
static void ex_reset __P((struct ex_softc *));
static driver_intr_t ex_intr;
static void ex_tx_intr __P((struct ex_softc *));
static void ex_rx_intr __P((struct ex_softc *));
static u_short eeprom_read __P((int, int));
static device_method_t ex_methods[] = {
/* Device interface */
DEVMETHOD(device_identify, ex_isa_identify),
DEVMETHOD(device_probe, ex_isa_probe),
DEVMETHOD(device_attach, ex_isa_attach),
{ 0, 0 }
};
static driver_t ex_driver = {
"ex",
ex_methods,
sizeof(struct ex_softc),
};
static devclass_t ex_devclass;
DRIVER_MODULE(ex, isa, ex_driver, ex_devclass, 0, 0);
static struct isa_pnp_id ex_ids[] = {
{ 0x3110d425, NULL }, /* INT1031 */
{ 0x3010d425, NULL }, /* INT1030 */
{ 0, NULL },
};
static int
look_for_card (u_int iobase)
int
look_for_card (u_int32_t iobase)
{
int count1, count2;
@ -197,24 +129,7 @@ look_for_card (u_int iobase)
return((count2 & Counter_bits) == ((count1 + 0xc0) & Counter_bits));
}
static int
ex_get_media (u_int32_t iobase)
{
int tmp;
outb(iobase + CMD_REG, Bank2_Sel);
tmp = inb(iobase + REG3);
outb(iobase + CMD_REG, Bank0_Sel);
if (tmp & TPE_bit)
return(IFM_ETHER|IFM_10_T);
if (tmp & BNC_bit)
return(IFM_ETHER|IFM_10_2);
return (IFM_ETHER|IFM_10_5);
}
static void
void
ex_get_address (u_int32_t iobase, u_char *enaddr)
{
u_int16_t eaddr_tmp;
@ -232,7 +147,7 @@ ex_get_address (u_int32_t iobase, u_char *enaddr)
return;
}
static int
int
ex_card_type (u_char *enaddr)
{
if ((enaddr[0] == 0x00) && (enaddr[1] == 0xA0) && (enaddr[2] == 0xC9))
@ -242,207 +157,70 @@ ex_card_type (u_char *enaddr)
}
/*
* Non-destructive identify.
* Caller is responsible for eventually calling
* ex_release_resources() on failure.
*/
static void
ex_isa_identify (driver_t *driver, device_t parent)
int
ex_alloc_resources (device_t dev)
{
device_t child;
u_int32_t ioport;
u_char enaddr[6];
u_int irq;
int tmp;
const char * desc;
struct ex_softc * sc = device_get_softc(dev);
int error = 0;
if (bootverbose)
printf("ex_isa_identify()\n");
sc->ioport = bus_alloc_resource(dev, SYS_RES_IOPORT, &sc->ioport_rid,
0, ~0, 1, RF_ACTIVE);
if (!sc->ioport) {
device_printf(dev, "No I/O space?!\n");
error = ENOMEM;
goto bad;
}
for (ioport = 0x200; ioport < 0x3a0; ioport += 0x10) {
sc->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &sc->irq_rid,
0, ~0, 1, RF_ACTIVE);
/* No board found at address */
if (!look_for_card(ioport)) {
continue;
}
if (!sc->irq) {
device_printf(dev, "No IRQ?!\n");
error = ENOMEM;
goto bad;
}
if (bootverbose)
printf("ex: Found card at 0x%03x!\n", ioport);
bad:
return (error);
}
/* Board in PnP mode */
if (eeprom_read(ioport, EE_W0) & EE_W0_PNP) {
/* Reset the card. */
outb(ioport + CMD_REG, Reset_CMD);
DELAY(500);
if (bootverbose)
printf("ex: card at 0x%03x in PnP mode!\n", ioport);
continue;
}
void
ex_release_resources (device_t dev)
{
struct ex_softc * sc = device_get_softc(dev);
bzero(enaddr, sizeof(enaddr));
if (sc->ih) {
bus_teardown_intr(dev, sc->irq, sc->ih);
sc->ih = NULL;
}
/* Reset the card. */
outb(ioport + CMD_REG, Reset_CMD);
DELAY(400);
if (sc->ioport) {
bus_release_resource(dev, SYS_RES_IOPORT,
sc->ioport_rid, sc->ioport);
sc->ioport = NULL;
}
ex_get_address(ioport, enaddr);
tmp = eeprom_read(ioport, EE_W1) & EE_W1_INT_SEL;
/* work out which set of irq <-> internal tables to use */
if (ex_card_type(enaddr) == CARD_TYPE_EX_10_PLUS) {
irq = plus_ee2irqmap[tmp];
desc = "Intel Pro/10+";
} else {
irq = ee2irqmap[tmp];
desc = "Intel Pro/10";
}
child = BUS_ADD_CHILD(parent, ISA_ORDER_SPECULATIVE, "ex", -1);
device_set_desc_copy(child, desc);
device_set_driver(child, driver);
bus_set_resource(child, SYS_RES_IRQ, 0, irq, 1);
bus_set_resource(child, SYS_RES_IOPORT, 0, ioport, EX_IOSIZE);
if (bootverbose)
printf("ex: Adding board at 0x%03x, irq %d\n", ioport, irq);
if (sc->irq) {
bus_release_resource(dev, SYS_RES_IRQ,
sc->irq_rid, sc->irq);
sc->irq = NULL;
}
return;
}
static int
ex_isa_probe(device_t dev)
{
u_int iobase;
u_int irq;
char * irq2ee;
u_char * ee2irq;
u_char enaddr[6];
int tmp;
int error;
DODEBUG(Start_End, printf("ex_probe: start\n"););
/* Check isapnp ids */
error = ISA_PNP_PROBE(device_get_parent(dev), dev, ex_ids);
/* If the card had a PnP ID that didn't match any we know about */
if (error == ENXIO) {
return(error);
}
/* If we had some other problem. */
if (!(error == 0 || error == ENOENT)) {
return(error);
}
iobase = bus_get_resource_start(dev, SYS_RES_IOPORT, 0);
if (!iobase) {
printf("ex: no iobase?\n");
return(ENXIO);
}
if (!look_for_card(iobase)) {
printf("ex: no card found at 0x%03x\n", iobase);
return(ENXIO);
}
if (bootverbose)
printf("ex: ex_isa_probe() found card at 0x%03x\n", iobase);
/*
* Reset the card.
*/
outb(iobase + CMD_REG, Reset_CMD);
DELAY(800);
ex_get_address(iobase, enaddr);
/* work out which set of irq <-> internal tables to use */
if (ex_card_type(enaddr) == CARD_TYPE_EX_10_PLUS) {
irq2ee = plus_irq2eemap;
ee2irq = plus_ee2irqmap;
} else {
irq2ee = irq2eemap;
ee2irq = ee2irqmap;
}
tmp = eeprom_read(iobase, EE_W1) & EE_W1_INT_SEL;
irq = bus_get_resource_start(dev, SYS_RES_IRQ, 0);
if (irq > 0) {
/* This will happen if board is in PnP mode. */
if (ee2irq[tmp] != irq) {
printf("ex: WARNING: board's EEPROM is configured"
" for IRQ %d, using %d\n",
ee2irq[tmp], irq);
}
} else {
irq = ee2irq[tmp];
bus_set_resource(dev, SYS_RES_IRQ, 0, irq, 1);
}
if (irq == 0) {
printf("ex: invalid IRQ.\n");
return(ENXIO);
}
DODEBUG(Start_End, printf("ex_probe: finish\n"););
return(0);
}
static int
ex_isa_attach(device_t dev)
int
ex_attach(device_t dev)
{
struct ex_softc * sc = device_get_softc(dev);
struct ifnet * ifp = &sc->arpcom.ac_if;
struct ifmedia * ifm;
int unit = device_get_unit(dev);
int error;
int rid;
void * ih;
u_int16_t temp;
DODEBUG(Start_End, device_printf(dev, "start\n"););
rid = 0;
sc->ioport = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid,
0, ~0, 1, RF_ACTIVE);
if (!sc->ioport) {
device_printf(dev, "No I/O space?!\n");
goto bad;
}
rid = 0;
sc->irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid,
0, ~0, 1, RF_ACTIVE);
if (!sc->irq) {
device_printf(dev, "No IRQ?!\n");
goto bad;
}
error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET,
ex_intr, (void *)sc, &ih);
if (error) {
device_printf(dev, "bus_setup_intr() failed!\n");
goto bad;
}
/*
* Fill in several fields of the softc structure:
* - I/O base address.
* - Hardware Ethernet address.
* - IRQ number (if not supplied in config file, read it from EEPROM).
* - Connector type.
*/
sc->dev = dev;
sc->iobase = rman_get_start(sc->ioport);
sc->irq_no = rman_get_start(sc->irq);
ex_get_address(sc->iobase, sc->arpcom.ac_enaddr);
/* work out which set of irq <-> internal tables to use */
if (ex_card_type(sc->arpcom.ac_enaddr) == CARD_TYPE_EX_10_PLUS) {
sc->irq2ee = plus_irq2eemap;
@ -491,36 +269,16 @@ ex_isa_attach(device_t dev)
if_attach(ifp);
ether_ifattach(ifp);
temp = eeprom_read(sc->iobase, EE_W0);
device_printf(sc->dev, "%s config, %s bus, ",
(temp & EE_W0_PNP) ? "PnP" : "Manual",
(temp & EE_W0_BUS16) ? "16-bit" : "8-bit");
temp = eeprom_read(sc->iobase, EE_W6);
printf("board id 0x%03x, stepping 0x%01x\n",
(temp & EE_W6_BOARD_MASK) >> EE_W6_BOARD_SHIFT,
temp & EE_W6_STEP_MASK);
device_printf(sc->dev, "Ethernet address %6D\n",
sc->arpcom.ac_enaddr, ":");
/*
* If BPF is in the kernel, call the attach for it
*/
bpfattach(ifp, DLT_EN10MB, sizeof(struct ether_header));
DODEBUG(Start_End, printf("ex_isa_attach%d: finish\n", unit););
return(0);
bad:
if (sc->ioport)
bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->ioport);
if (sc->irq)
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->irq);
return (-1);
}
static void
ex_init(void *xsc)
{
@ -537,7 +295,7 @@ ex_init(void *xsc)
return;
}
s = splimp();
sc->arpcom.ac_if.if_timer = 0;
ifp->if_timer = 0;
/*
* Load the ethernet address into the card.
@ -822,8 +580,7 @@ ex_stop(struct ex_softc *sc)
return;
}
static void
void
ex_intr(void *arg)
{
struct ex_softc * sc = (struct ex_softc *)arg;
@ -1143,6 +900,23 @@ ex_watchdog(struct ifnet *ifp)
return;
}
static int
ex_get_media (u_int32_t iobase)
{
int tmp;
outb(iobase + CMD_REG, Bank2_Sel);
tmp = inb(iobase + REG3);
outb(iobase + CMD_REG, Bank0_Sel);
if (tmp & TPE_bit)
return(IFM_ETHER|IFM_10_T);
if (tmp & BNC_bit)
return(IFM_ETHER|IFM_10_2);
return (IFM_ETHER|IFM_10_5);
}
static int
ex_ifmedia_upd (ifp)
struct ifnet * ifp;
@ -1164,8 +938,8 @@ ex_ifmedia_sts(ifp, ifmr)
return;
}
static u_short
eeprom_read(int iobase, int location)
u_short
eeprom_read(u_int32_t iobase, int location)
{
int i;
u_short data = 0;

313
sys/dev/ex/if_ex_isa.c Normal file
View File

@ -0,0 +1,313 @@
/*-
* Copyright (c) 2000 Matthew N. Dodd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#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 <machine/bus.h>
#include <machine/resource.h>
#include <sys/rman.h>
#include <net/if.h>
#include <net/if_arp.h>
#include <net/if_media.h>
#include <machine/clock.h>
#include <isa/isavar.h>
#include <isa/pnpvar.h>
#include <dev/ex/if_exreg.h>
#include <dev/ex/if_exvar.h>
/* Bus Front End Functions */
static void ex_isa_identify __P((driver_t *, device_t));
static int ex_isa_probe __P((device_t));
static int ex_isa_attach __P((device_t));
#if 0
static void ex_pnp_wakeup (void *);
SYSINIT(ex_pnpwakeup, SI_SUB_CPU, SI_ORDER_ANY, ex_pnp_wakeup, NULL);
#endif
static device_method_t ex_methods[] = {
/* Device interface */
DEVMETHOD(device_identify, ex_isa_identify),
DEVMETHOD(device_probe, ex_isa_probe),
DEVMETHOD(device_attach, ex_isa_attach),
{ 0, 0 }
};
static driver_t ex_driver = {
"ex",
ex_methods,
sizeof(struct ex_softc),
};
static devclass_t ex_devclass;
DRIVER_MODULE(ex, isa, ex_driver, ex_devclass, 0, 0);
static struct isa_pnp_id ex_ids[] = {
{ 0x3110d425, NULL }, /* INT1031 */
{ 0x3010d425, NULL }, /* INT1030 */
{ 0, NULL },
};
#if 0
#define EX_PNP_WAKE 0x279
static u_int8_t ex_pnp_wake_seq[] =
{ 0x6A, 0xB5, 0xDA, 0xED, 0xF6, 0xFB, 0x7D, 0xBE,
0xDF, 0x6F, 0x37, 0x1B, 0x0D, 0x86, 0xC3, 0x61,
0xB0, 0x58, 0x2C, 0x16, 0x8B, 0x45, 0xA2, 0xD1,
0xE8, 0x74, 0x3A, 0x9D, 0xCE, 0xE7, 0x73, 0x43 };
static void
ex_pnp_wakeup (void * dummy)
{
int tmp;
if (bootverbose)
printf("ex_pnp_wakeup()\n");
outb(EX_PNP_WAKE, 0);
outb(EX_PNP_WAKE, 0);
for (tmp = 0; tmp < 32; tmp++) {
outb(EX_PNP_WAKE, ex_pnp_wake_seq[tmp]);
}
}
#endif
/*
* Non-destructive identify.
*/
static void
ex_isa_identify (driver_t *driver, device_t parent)
{
device_t child;
u_int32_t ioport;
u_char enaddr[6];
u_int irq;
int tmp;
const char * desc;
if (bootverbose)
printf("ex_isa_identify()\n");
for (ioport = 0x200; ioport < 0x3a0; ioport += 0x10) {
/* No board found at address */
if (!look_for_card(ioport)) {
continue;
}
if (bootverbose)
printf("ex: Found card at 0x%03x!\n", ioport);
/* Board in PnP mode */
if (eeprom_read(ioport, EE_W0) & EE_W0_PNP) {
/* Reset the card. */
outb(ioport + CMD_REG, Reset_CMD);
DELAY(500);
if (bootverbose)
printf("ex: card at 0x%03x in PnP mode!\n", ioport);
continue;
}
bzero(enaddr, sizeof(enaddr));
/* Reset the card. */
outb(ioport + CMD_REG, Reset_CMD);
DELAY(400);
ex_get_address(ioport, enaddr);
tmp = eeprom_read(ioport, EE_W1) & EE_W1_INT_SEL;
/* work out which set of irq <-> internal tables to use */
if (ex_card_type(enaddr) == CARD_TYPE_EX_10_PLUS) {
irq = plus_ee2irqmap[tmp];
desc = "Intel Pro/10+";
} else {
irq = ee2irqmap[tmp];
desc = "Intel Pro/10";
}
child = BUS_ADD_CHILD(parent, ISA_ORDER_SPECULATIVE, "ex", -1);
device_set_desc_copy(child, desc);
device_set_driver(child, driver);
bus_set_resource(child, SYS_RES_IRQ, 0, irq, 1);
bus_set_resource(child, SYS_RES_IOPORT, 0, ioport, EX_IOSIZE);
if (bootverbose)
printf("ex: Adding board at 0x%03x, irq %d\n", ioport, irq);
}
return;
}
static int
ex_isa_probe(device_t dev)
{
u_int iobase;
u_int irq;
char * irq2ee;
u_char * ee2irq;
u_char enaddr[6];
int tmp;
int error;
/* Check isapnp ids */
error = ISA_PNP_PROBE(device_get_parent(dev), dev, ex_ids);
/* If the card had a PnP ID that didn't match any we know about */
if (error == ENXIO) {
return(error);
}
/* If we had some other problem. */
if (!(error == 0 || error == ENOENT)) {
return(error);
}
iobase = bus_get_resource_start(dev, SYS_RES_IOPORT, 0);
if (!iobase) {
printf("ex: no iobase?\n");
return(ENXIO);
}
if (!look_for_card(iobase)) {
printf("ex: no card found at 0x%03x\n", iobase);
return(ENXIO);
}
if (bootverbose)
printf("ex: ex_isa_probe() found card at 0x%03x\n", iobase);
/*
* Reset the card.
*/
outb(iobase + CMD_REG, Reset_CMD);
DELAY(800);
ex_get_address(iobase, enaddr);
/* work out which set of irq <-> internal tables to use */
if (ex_card_type(enaddr) == CARD_TYPE_EX_10_PLUS) {
irq2ee = plus_irq2eemap;
ee2irq = plus_ee2irqmap;
} else {
irq2ee = irq2eemap;
ee2irq = ee2irqmap;
}
tmp = eeprom_read(iobase, EE_W1) & EE_W1_INT_SEL;
irq = bus_get_resource_start(dev, SYS_RES_IRQ, 0);
if (irq > 0) {
/* This will happen if board is in PnP mode. */
if (ee2irq[tmp] != irq) {
printf("ex: WARNING: board's EEPROM is configured"
" for IRQ %d, using %d\n",
ee2irq[tmp], irq);
}
} else {
irq = ee2irq[tmp];
bus_set_resource(dev, SYS_RES_IRQ, 0, irq, 1);
}
if (irq == 0) {
printf("ex: invalid IRQ.\n");
return(ENXIO);
}
return(0);
}
static int
ex_isa_attach(device_t dev)
{
struct ex_softc * sc = device_get_softc(dev);
int error = 0;
u_int16_t temp;
sc->dev = dev;
sc->ioport_rid = 0;
sc->irq_rid = 0;
if ((error = ex_alloc_resources(dev)) != 0) {
device_printf(dev, "ex_alloc_resources() failed!\n");
goto bad;
}
/*
* Fill in several fields of the softc structure:
* - I/O base address.
* - Hardware Ethernet address.
* - IRQ number (if not supplied in config file, read it from EEPROM).
* - Connector type.
*/
sc->iobase = rman_get_start(sc->ioport);
sc->irq_no = rman_get_start(sc->irq);
ex_get_address(sc->iobase, sc->arpcom.ac_enaddr);
temp = eeprom_read(sc->iobase, EE_W0);
device_printf(sc->dev, "%s config, %s bus, ",
(temp & EE_W0_PNP) ? "PnP" : "Manual",
(temp & EE_W0_BUS16) ? "16-bit" : "8-bit");
temp = eeprom_read(sc->iobase, EE_W6);
printf("board id 0x%03x, stepping 0x%01x\n",
(temp & EE_W6_BOARD_MASK) >> EE_W6_BOARD_SHIFT,
temp & EE_W6_STEP_MASK);
if ((error = ex_attach(dev)) != 0) {
device_printf(dev, "ex_attach() failed!\n");
goto bad;
}
error = bus_setup_intr(dev, sc->irq, INTR_TYPE_NET,
ex_intr, (void *)sc, &sc->ih);
if (error) {
device_printf(dev, "bus_setup_intr() failed!\n");
goto bad;
}
return(0);
bad:
ex_release_resources(dev);
return (error);
}

View File

@ -35,6 +35,9 @@
* Several constants.
*/
#define CARD_TYPE_EX_10 1
#define CARD_TYPE_EX_10_PLUS 2
/* Length of an ethernet address. */
#define ETHER_ADDR_LEN 6
/* Default RAM size in board. */

85
sys/dev/ex/if_exvar.h Normal file
View File

@ -0,0 +1,85 @@
/*-
* Copyright (c) 1996, Javier Mart^mn Rueda (jmrueda@diatel.upm.es)
* All rights reserved.
*
* Copyright (c) 2000 Matthew N. Dodd
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
struct ex_softc {
struct arpcom arpcom; /* Ethernet common data */
struct ifmedia ifmedia;
device_t dev;
struct resource *ioport;
int ioport_rid;
struct resource *irq;
int irq_rid;
void * ih;
u_int iobase; /* I/O base address. */
u_short irq_no; /* IRQ number. */
char * irq2ee; /* irq <-> internal */
u_char * ee2irq; /* representation conversion */
u_int mem_size; /* Total memory size, in bytes. */
u_int rx_mem_size; /* Rx memory size (by default, */
/* first 3/4 of total memory). */
u_int rx_lower_limit; /* Lower and upper limits of */
u_int rx_upper_limit; /* receive buffer. */
u_int rx_head; /* Head of receive ring buffer. */
u_int tx_mem_size; /* Tx memory size (by default, */
/* last quarter of total memory).*/
u_int tx_lower_limit; /* Lower and upper limits of */
u_int tx_upper_limit; /* transmit buffer. */
u_int tx_head; /* Head and tail of */
u_int tx_tail; /* transmit ring buffer. */
u_int tx_last; /* Pointer to beginning of last */
/* frame in the chain. */
};
extern char irq2eemap[];
extern u_char ee2irqmap[];
extern char plus_irq2eemap[];
extern u_char plus_ee2irqmap[];
int ex_alloc_resources (device_t);
void ex_release_resources (device_t);
int ex_attach (device_t);
driver_intr_t ex_intr;
u_int16_t eeprom_read (u_int32_t, int);
int look_for_card (u_int32_t);
void ex_get_address (u_int32_t, u_char *);
int ex_card_type (u_char *);