diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-05-07 07:38:52 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1996-05-07 07:38:52 +0000 |
commit | a18dd829375e446ca22af98dc283f34da965edbc (patch) | |
tree | 0c5bbc9a1a0ce73f792bd62db356a18c8af92e32 /sys/dev/ic | |
parent | c78ff01b45ca78d491b3e8db520c2cb877a273d4 (diff) |
sync with 0504 -- prototypes and bus.h
Diffstat (limited to 'sys/dev/ic')
-rw-r--r-- | sys/dev/ic/com.c | 70 | ||||
-rw-r--r-- | sys/dev/ic/elink3.c | 222 | ||||
-rw-r--r-- | sys/dev/ic/elink3reg.h | 6 | ||||
-rw-r--r-- | sys/dev/ic/elink3var.h | 8 |
4 files changed, 176 insertions, 130 deletions
diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c index 5570f7ef424..112b40fad55 100644 --- a/sys/dev/ic/com.c +++ b/sys/dev/ic/com.c @@ -1,5 +1,5 @@ -/* $OpenBSD: com.c,v 1.12 1996/04/29 14:16:15 hvozda Exp $ */ -/* $NetBSD: com.c,v 1.79 1996/04/15 18:54:31 cgd Exp $ */ +/* $OpenBSD: com.c,v 1.13 1996/05/07 07:36:25 deraadt Exp $ */ +/* $NetBSD: com.c,v 1.80 1996/04/29 20:03:00 christos Exp $ */ /*- * Copyright (c) 1993, 1994, 1995, 1996 @@ -75,6 +75,7 @@ #include "com.h" + #define COM_IBUFSIZE (2 * 512) #define COM_IHIGHWATER ((3 * COM_IBUFSIZE) / 4) @@ -121,15 +122,25 @@ struct com_softc { #ifdef COM_HAYESP int comprobeHAYESP __P((bus_io_handle_t hayespioh, struct com_softc *sc)); #endif -int comopen __P((dev_t, int, int, struct proc *)); -int comclose __P((dev_t, int, int, struct proc *)); -void comdiag __P((void *)); -int comintr __P((void *)); -void compoll __P((void *)); -int comparam __P((struct tty *, struct termios *)); -void comstart __P((struct tty *)); -void com_absent_notify __P((struct com_softc *sc)); -void comstart_pending __P((void *arg)); +void comdiag __P((void *)); +int comspeed __P((long)); +int comparam __P((struct tty *, struct termios *)); +void comstart __P((struct tty *)); +int comintr __P((void *)); +void compoll __P((void *)); + +/* XXX: These belong elsewhere */ +cdev_decl(com); +bdev_decl(com); + +struct consdev; +void comcnprobe __P((struct consdev *)); +void comcninit __P((struct consdev *)); +int comcngetc __P((dev_t)); +void comcnputc __P((dev_t, int)); +void comcnpollc __P((dev_t, int)); + +static u_char tiocm_xxx2mcr __P((int)); /* * XXX the following two cfattach structs should be different, and possibly @@ -155,7 +166,7 @@ struct cfdriver com_cd = { NULL, "com", DV_TTY }; -int cominit __P((bus_chipset_tag_t, bus_io_handle_t, int)); +void cominit __P((bus_chipset_tag_t, bus_io_handle_t, int)); #ifndef CONSPEED #define CONSPEED B9600 @@ -194,20 +205,18 @@ extern int kgdb_debug_init; #if NCOM_PCMCIA #include <dev/pcmcia/pcmciavar.h> -int com_pcmcia_match __P((struct device *, void *, void *)); -void com_pcmcia_attach __P((struct device *, struct device *, void *)); -int com_pcmcia_detach __P((struct device *)); +int com_pcmcia_match __P((struct device *, void *, void *)); +void com_pcmcia_attach __P((struct device *, struct device *, void *)); +int com_pcmcia_detach __P((struct device *)); struct cfattach com_pcmcia_ca = { sizeof(struct com_softc), com_pcmcia_match, comattach, com_pcmcia_detach }; -int -com_pcmcia_mod __P((struct pcmcia_link *pc_link, - struct device *self, - struct pcmcia_conf *pc_cf, - struct cfdata *cf)); +int com_pcmcia_mod __P((struct pcmcia_link *pc_link, struct device *self, + struct pcmcia_conf *pc_cf, struct cfdata *cf)); +void com_absent_notify __P((struct com_softc *sc)); /* additional setup needed for pcmcia devices */ /* modify config entry */ @@ -507,7 +516,6 @@ comprobe(parent, match, aux) struct device *parent; void *match, *aux; { - struct cfdata *cf = match; bus_chipset_tag_t bc; bus_io_handle_t ioh; int iobase, needioh; @@ -537,6 +545,7 @@ comprobe(parent, match, aux) #endif #if NCOM_COMMULTI if (1) { + struct cfdata *cf = match; struct commulti_attach_args *ca = aux; if (cf->cf_loc[0] != -1 && cf->cf_loc[0] != ca->ca_slave) @@ -580,11 +589,9 @@ comattach(parent, self, aux) void *aux; { struct com_softc *sc = (void *)self; - struct cfdata *cf = sc->sc_dev.dv_cfdata; int iobase, irq; bus_chipset_tag_t bc; bus_io_handle_t ioh; - struct tty *tp; #ifdef COM_HAYESP int hayesp_ports[] = { 0x140, 0x180, 0x280, 0x300, 0 }; int *hayespp; @@ -715,7 +722,7 @@ comattach(parent, self, aux) if (ISSET(sc->sc_hwflags, COM_HW_CONSOLE)) kgdb_dev = -1; /* can't debug over console port */ else { - (void) cominit(bc, ioh, kgdb_rate); + cominit(bc, ioh, kgdb_rate); if (kgdb_debug_init) { /* * Print prefix of device name, @@ -1342,9 +1349,10 @@ stopped: /* * Stop output on a line. */ -void +int comstop(tp, flag) struct tty *tp; + int flag; { int s; @@ -1353,6 +1361,7 @@ comstop(tp, flag) if (!ISSET(tp->t_state, TS_TTSTOP)) SET(tp->t_state, TS_FLUSH); splx(s); + return 0; } void @@ -1607,14 +1616,11 @@ void comcnprobe(cp) struct consdev *cp; { - bus_chipset_tag_t bc; + /* XXX NEEDS TO BE FIXED XXX */ + bus_chipset_tag_t bc = 0; bus_io_handle_t ioh; int found; -#if 0 - XXX NEEDS TO BE FIXED XXX - bc = ???; -#endif if (bus_io_map(bc, CONADDR, COM_NPORTS, &ioh)) { cp->cn_pri = CN_DEAD; return; @@ -1657,6 +1663,7 @@ comcninit(cp) comconsinit = 0; } +void cominit(bc, ioh, rate) bus_chipset_tag_t bc; bus_io_handle_t ioh; @@ -1676,6 +1683,7 @@ cominit(bc, ioh, rate) splx(s); } +int comcngetc(dev) dev_t dev; { @@ -1710,7 +1718,7 @@ comcnputc(dev, c) if (dev != kgdb_dev) #endif if (comconsinit == 0) { - (void) cominit(bc, ioh, comdefaultrate); + cominit(bc, ioh, comdefaultrate); comconsinit = 1; } /* wait for any pending transmission to finish */ diff --git a/sys/dev/ic/elink3.c b/sys/dev/ic/elink3.c index 36ef54701b3..fa99384c50a 100644 --- a/sys/dev/ic/elink3.c +++ b/sys/dev/ic/elink3.c @@ -1,4 +1,4 @@ -/* $NetBSD: elink3.c,v 1.1 1996/04/25 02:17:34 thorpej Exp $ */ +/* $NetBSD: elink3.c,v 1.4 1996/05/03 19:08:47 christos Exp $ */ /* * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca> @@ -33,6 +33,7 @@ #include "bpfilter.h" #include <sys/param.h> +#include <sys/systm.h> #include <sys/mbuf.h> #include <sys/socket.h> #include <sys/ioctl.h> @@ -61,7 +62,7 @@ #endif #include <machine/cpu.h> -#include <machine/pio.h> +#include <machine/bus.h> #include <dev/ic/elink3var.h> #include <dev/ic/elink3reg.h> @@ -74,7 +75,7 @@ struct cfdriver ep_cd = { NULL, "ep", DV_IFNET }; -static void epxstat __P((struct ep_softc *)); +static void eptxstat __P((struct ep_softc *)); static int epstatus __P((struct ep_softc *)); void epinit __P((struct ep_softc *)); int epioctl __P((struct ifnet *, u_long, caddr_t)); @@ -83,12 +84,10 @@ void epwatchdog __P((int)); void epreset __P((struct ep_softc *)); void epread __P((struct ep_softc *)); struct mbuf *epget __P((struct ep_softc *, int)); -void epmbuffill __P((struct ep_softc *)); +void epmbuffill __P((void *)); void epmbufempty __P((struct ep_softc *)); -void epstop __P((struct ep_softc *)); void epsetfilter __P((struct ep_softc *)); void epsetlink __P((struct ep_softc *)); -u_short epreadeeprom __P((int id_port, int offset)); static int epbusyeeprom __P((struct ep_softc *)); @@ -97,6 +96,8 @@ epconfig(sc, conn) struct ep_softc *sc; u_int conn; { + bus_chipset_tag_t bc = sc->sc_bc; + bus_io_handle_t ioh = sc->sc_ioh; u_short i; struct ifnet *ifp = &sc->sc_arpcom.ac_if; @@ -128,10 +129,10 @@ epconfig(sc, conn) u_short x; if (epbusyeeprom(sc)) return; - outw(BASE + EP_W0_EEPROM_COMMAND, READ_EEPROM | i); + bus_io_write_2(bc, ioh, EP_W0_EEPROM_COMMAND, READ_EEPROM | i); if (epbusyeeprom(sc)) return; - x = inw(BASE + EP_W0_EEPROM_DATA); + x = bus_io_read_2(bc, ioh, EP_W0_EEPROM_DATA); sc->sc_arpcom.ac_enaddr[(i << 1)] = x >> 8; sc->sc_arpcom.ac_enaddr[(i << 1) + 1] = x; } @@ -166,40 +167,43 @@ epinit(sc) register struct ep_softc *sc; { register struct ifnet *ifp = &sc->sc_arpcom.ac_if; + bus_chipset_tag_t bc = sc->sc_bc; + bus_io_handle_t ioh = sc->sc_ioh; int i; - while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS) + while (bus_io_read_2(bc, ioh, EP_STATUS) & S_COMMAND_IN_PROGRESS) ; if (sc->bustype != EP_BUS_PCI) { GO_WINDOW(0); - outw(BASE + EP_W0_CONFIG_CTRL, 0); - outw(BASE + EP_W0_CONFIG_CTRL, ENABLE_DRQ_IRQ); + bus_io_write_2(bc, ioh, EP_W0_CONFIG_CTRL, 0); + bus_io_write_2(bc, ioh, EP_W0_CONFIG_CTRL, ENABLE_DRQ_IRQ); } if (sc->bustype == EP_BUS_PCMCIA) { #ifdef EP_COAX_DEFAULT - outw(BASE + EP_W0_ADDRESS_CFG,3<<14); + bus_io_write_2(bc, ioh, EP_W0_ADDRESS_CFG,3<<14); #else - outw(BASE + EP_W0_ADDRESS_CFG,0<<14); + bus_io_write_2(bc, ioh, EP_W0_ADDRESS_CFG,0<<14); #endif - outw(BASE + EP_W0_RESOURCE_CFG, 0x3f00); + bus_io_write_2(bc, ioh, EP_W0_RESOURCE_CFG, 0x3f00); } GO_WINDOW(2); for (i = 0; i < 6; i++) /* Reload the ether_addr. */ - outb(BASE + EP_W2_ADDR_0 + i, sc->sc_arpcom.ac_enaddr[i]); + bus_io_write_1(bc, ioh, EP_W2_ADDR_0 + i, + sc->sc_arpcom.ac_enaddr[i]); - outw(BASE + EP_COMMAND, RX_RESET); - outw(BASE + EP_COMMAND, TX_RESET); + bus_io_write_2(bc, ioh, EP_COMMAND, RX_RESET); + bus_io_write_2(bc, ioh, EP_COMMAND, TX_RESET); GO_WINDOW(1); /* Window 1 is operating window */ for (i = 0; i < 31; i++) - inb(BASE + EP_W1_TX_STATUS); + bus_io_read_1(bc, ioh, EP_W1_TX_STATUS); - outw(BASE + EP_COMMAND, SET_RD_0_MASK | S_CARD_FAILURE | + bus_io_write_2(bc, ioh, EP_COMMAND, SET_RD_0_MASK | S_CARD_FAILURE | S_RX_COMPLETE | S_TX_COMPLETE | S_TX_AVAIL); - outw(BASE + EP_COMMAND, SET_INTR_MASK | S_CARD_FAILURE | + bus_io_write_2(bc, ioh, EP_COMMAND, SET_INTR_MASK | S_CARD_FAILURE | S_RX_COMPLETE | S_TX_COMPLETE | S_TX_AVAIL); /* @@ -208,13 +212,13 @@ epinit(sc) * already be queued. However, a single stray interrupt is * unimportant. */ - outw(BASE + EP_COMMAND, ACK_INTR | 0xff); + bus_io_write_2(bc, ioh, EP_COMMAND, ACK_INTR | 0xff); epsetfilter(sc); epsetlink(sc); - outw(BASE + EP_COMMAND, RX_ENABLE); - outw(BASE + EP_COMMAND, TX_ENABLE); + bus_io_write_2(bc, ioh, EP_COMMAND, RX_ENABLE); + bus_io_write_2(bc, ioh, EP_COMMAND, TX_ENABLE); epmbuffill(sc); @@ -233,7 +237,7 @@ epsetfilter(sc) register struct ifnet *ifp = &sc->sc_arpcom.ac_if; GO_WINDOW(1); /* Window 1 is operating window */ - outw(BASE + EP_COMMAND, SET_RX_FILTER | + bus_io_write_2(sc->sc_bc, sc->sc_ioh, EP_COMMAND, SET_RX_FILTER | FIL_INDIVIDUAL | FIL_BRDCST | ((ifp->if_flags & IFF_MULTICAST) ? FIL_MULTICAST : 0 ) | ((ifp->if_flags & IFF_PROMISC) ? FIL_PROMISC : 0 )); @@ -244,6 +248,8 @@ epsetlink(sc) register struct ep_softc *sc; { register struct ifnet *ifp = &sc->sc_arpcom.ac_if; + bus_chipset_tag_t bc = sc->sc_bc; + bus_io_handle_t ioh = sc->sc_ioh; /* * you can `ifconfig (link0|-link0) ep0' to get the following @@ -254,26 +260,27 @@ epsetlink(sc) * set too, then you get the UTP port. */ GO_WINDOW(4); - outw(BASE + EP_W4_MEDIA_TYPE, DISABLE_UTP); + bus_io_write_2(bc, ioh, EP_W4_MEDIA_TYPE, DISABLE_UTP); if (!(ifp->if_flags & IFF_LINK0) && (sc->ep_connectors & BNC)) { if (sc->bustype == EP_BUS_PCMCIA) { GO_WINDOW(0); - outw(BASE + EP_W0_ADDRESS_CFG,3<<14); + bus_io_write_2(bc, ioh, EP_W0_ADDRESS_CFG,3<<14); GO_WINDOW(1); } - outw(BASE + EP_COMMAND, START_TRANSCEIVER); + bus_io_write_2(bc, ioh, EP_COMMAND, START_TRANSCEIVER); delay(1000); } if (ifp->if_flags & IFF_LINK0) { - outw(BASE + EP_COMMAND, STOP_TRANSCEIVER); + bus_io_write_2(bc, ioh, EP_COMMAND, STOP_TRANSCEIVER); delay(1000); if ((ifp->if_flags & IFF_LINK1) && (sc->ep_connectors & UTP)) { if (sc->bustype == EP_BUS_PCMCIA) { GO_WINDOW(0); - outw(BASE + EP_W0_ADDRESS_CFG,0<<14); + bus_io_write_2(bc, ioh, + EP_W0_ADDRESS_CFG,0<<14); GO_WINDOW(4); } - outw(BASE + EP_W4_MEDIA_TYPE, ENABLE_UTP); + bus_io_write_2(bc, ioh, EP_W4_MEDIA_TYPE, ENABLE_UTP); } } GO_WINDOW(1); @@ -288,6 +295,8 @@ epstart(ifp) struct ifnet *ifp; { register struct ep_softc *sc = ep_cd.cd_devs[ifp->if_unit]; + bus_chipset_tag_t bc = sc->sc_bc; + bus_io_handle_t ioh = sc->sc_ioh; struct mbuf *m, *m0; int sh, len, pad; @@ -321,20 +330,22 @@ startagain: goto readcheck; } - if (inw(BASE + EP_W1_FREE_TX) < len + pad + 4) { - outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | (len + pad + 4)); + if (bus_io_read_2(bc, ioh, EP_W1_FREE_TX) < len + pad + 4) { + bus_io_write_2(bc, ioh, EP_COMMAND, + SET_TX_AVAIL_THRESH | (len + pad + 4)); /* not enough room in FIFO */ ifp->if_flags |= IFF_OACTIVE; return; } else { - outw(BASE + EP_COMMAND, SET_TX_AVAIL_THRESH | 2044); + bus_io_write_2(bc, ioh, EP_COMMAND, + SET_TX_AVAIL_THRESH | 2044); } IF_DEQUEUE(&ifp->if_snd, m0); if (m0 == 0) /* not really needed */ return; - outw(BASE + EP_COMMAND, SET_TX_START_THRESH | + bus_io_write_2(bc, ioh, EP_COMMAND, SET_TX_START_THRESH | (len / 4 + sc->tx_start_thresh)); #if NBPFILTER > 0 @@ -348,43 +359,47 @@ startagain: */ sh = splhigh(); - outw(BASE + EP_W1_TX_PIO_WR_1, len); - outw(BASE + EP_W1_TX_PIO_WR_1, 0xffff); /* Second dword meaningless */ + bus_io_write_2(bc, ioh, EP_W1_TX_PIO_WR_1, len); + bus_io_write_2(bc, ioh, EP_W1_TX_PIO_WR_1, + 0xffff); /* Second dword meaningless */ if (EP_IS_BUS_32(sc->bustype)) { for (m = m0; m; ) { if (m->m_len > 3) - outsl(BASE + EP_W1_TX_PIO_WR_1, - mtod(m, caddr_t), m->m_len / 4); + bus_io_write_multi_4(bc, ioh, + EP_W1_TX_PIO_WR_1, mtod(m, u_int32_t *), + m->m_len / 4); if (m->m_len & 3) - outsb(BASE + EP_W1_TX_PIO_WR_1, - mtod(m, caddr_t) + (m->m_len & ~3), - m->m_len & 3); + bus_io_write_multi_1(bc, ioh, + EP_W1_TX_PIO_WR_1, + mtod(m, u_int8_t *) + (m->m_len & ~3), + m->m_len & 3); MFREE(m, m0); m = m0; } } else { for (m = m0; m; ) { if (m->m_len > 1) - outsw(BASE + EP_W1_TX_PIO_WR_1, - mtod(m, caddr_t), m->m_len / 2); + bus_io_write_multi_2(bc, ioh, + EP_W1_TX_PIO_WR_1, mtod(m, u_int16_t *), + m->m_len / 2); if (m->m_len & 1) - outb(BASE + EP_W1_TX_PIO_WR_1, - *(mtod(m, caddr_t) + m->m_len - 1)); + bus_io_write_1(bc, ioh, EP_W1_TX_PIO_WR_1, + *(mtod(m, u_int8_t *) + m->m_len - 1)); MFREE(m, m0); m = m0; } } while (pad--) - outb(BASE + EP_W1_TX_PIO_WR_1, 0); + bus_io_write_1(bc, ioh, EP_W1_TX_PIO_WR_1, 0); splx(sh); ++ifp->if_opackets; readcheck: - if ((inw(BASE + EP_W1_RX_STATUS) & ERR_INCOMPLETE) == 0) { + if ((bus_io_read_2(bc, ioh, EP_W1_RX_STATUS) & ERR_INCOMPLETE) == 0) { /* We received a complete packet. */ - u_short status = inw(BASE + EP_STATUS); + u_short status = bus_io_read_2(bc, ioh, EP_STATUS); if ((status & S_INTR_LATCH) == 0) { /* @@ -423,13 +438,15 @@ static int epstatus(sc) register struct ep_softc *sc; { + bus_chipset_tag_t bc = sc->sc_bc; + bus_io_handle_t ioh = sc->sc_ioh; u_short fifost; /* * Check the FIFO status and act accordingly */ GO_WINDOW(4); - fifost = inw(BASE + EP_W4_FIFO_DIAG); + fifost = bus_io_read_2(bc, ioh, EP_W4_FIFO_DIAG); GO_WINDOW(1); if (fifost & FIFOS_RX_UNDERRUN) { @@ -466,14 +483,16 @@ static void eptxstat(sc) register struct ep_softc *sc; { + bus_chipset_tag_t bc = sc->sc_bc; + bus_io_handle_t ioh = sc->sc_ioh; int i; /* * We need to read+write TX_STATUS until we get a 0 status * in order to turn off the interrupt flag. */ - while ((i = inb(BASE + EP_W1_TX_STATUS)) & TXS_COMPLETE) { - outb(BASE + EP_W1_TX_STATUS, 0x0); + while ((i = bus_io_read_1(bc, ioh, EP_W1_TX_STATUS)) & TXS_COMPLETE) { + bus_io_write_1(bc, ioh, EP_W1_TX_STATUS, 0x0); if (i & TXS_JABBER) { ++sc->sc_arpcom.ac_if.if_oerrors; @@ -494,11 +513,10 @@ eptxstat(sc) epreset(sc); } else if (i & TXS_MAX_COLLISION) { ++sc->sc_arpcom.ac_if.if_collisions; - outw(BASE + EP_COMMAND, TX_ENABLE); + bus_io_write_2(bc, ioh, EP_COMMAND, TX_ENABLE); sc->sc_arpcom.ac_if.if_flags &= ~IFF_OACTIVE; } else sc->tx_succ_ok = (sc->tx_succ_ok+1) & 127; - } } @@ -507,14 +525,16 @@ epintr(arg) void *arg; { register struct ep_softc *sc = arg; + bus_chipset_tag_t bc = sc->sc_bc; + bus_io_handle_t ioh = sc->sc_ioh; struct ifnet *ifp = &sc->sc_arpcom.ac_if; u_short status; int ret = 0; for (;;) { - outw(BASE + EP_COMMAND, C_INTR_LATCH); + bus_io_write_2(bc, ioh, EP_COMMAND, C_INTR_LATCH); - status = inw(BASE + EP_STATUS); + status = bus_io_read_2(bc, ioh, EP_STATUS); if ((status & (S_TX_COMPLETE | S_TX_AVAIL | S_RX_COMPLETE | S_CARD_FAILURE)) == 0) @@ -528,7 +548,7 @@ epintr(arg) * Due to the i386 interrupt queueing, we may get spurious * interrupts occasionally. */ - outw(BASE + EP_COMMAND, ACK_INTR | status); + bus_io_write_2(bc, ioh, EP_COMMAND, ACK_INTR | status); if (status & S_RX_COMPLETE) epread(sc); @@ -556,12 +576,14 @@ void epread(sc) register struct ep_softc *sc; { + bus_chipset_tag_t bc = sc->sc_bc; + bus_io_handle_t ioh = sc->sc_ioh; struct ifnet *ifp = &sc->sc_arpcom.ac_if; struct mbuf *m; struct ether_header *eh; int len; - len = inw(BASE + EP_W1_RX_STATUS); + len = bus_io_read_2(bc, ioh, EP_W1_RX_STATUS); again: if (ifp->if_flags & IFF_DEBUG) { @@ -653,7 +675,7 @@ again: * I'll modify epread() so that it can handle RX_EARLY interrupts. */ if (epstatus(sc)) { - len = inw(BASE + EP_W1_RX_STATUS); + len = bus_io_read_2(bc, ioh, EP_W1_RX_STATUS); /* Check if we are stuck and reset [see XXX comment] */ if (len & ERR_INCOMPLETE) { if (ifp->if_flags & IFF_DEBUG) @@ -668,8 +690,8 @@ again: return; abort: - outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK); - while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS) + bus_io_write_2(bc, ioh, EP_COMMAND, RX_DISCARD_TOP_PACK); + while (bus_io_read_2(bc, ioh, EP_STATUS) & S_COMMAND_IN_PROGRESS) ; } @@ -678,6 +700,8 @@ epget(sc, totlen) struct ep_softc *sc; int totlen; { + bus_chipset_tag_t bc = sc->sc_bc; + bus_io_handle_t ioh = sc->sc_ioh; struct ifnet *ifp = &sc->sc_arpcom.ac_if; struct mbuf *top, **mp, *m; int len; @@ -736,19 +760,22 @@ epget(sc, totlen) if (EP_IS_BUS_32(sc->bustype)) { if (len > 3) { len &= ~3; - insl(BASE + EP_W1_RX_PIO_RD_1, - mtod(m, caddr_t), len / 4); + bus_io_read_multi_4(bc, ioh, + EP_W1_RX_PIO_RD_1, mtod(m, u_int32_t *), + len / 4); } else - insb(BASE + EP_W1_RX_PIO_RD_1, - mtod(m, caddr_t), len); + bus_io_read_multi_1(bc, ioh, + EP_W1_RX_PIO_RD_1, mtod(m, u_int8_t *), + len); } else { if (len > 1) { len &= ~1; - insw(BASE + EP_W1_RX_PIO_RD_1, - mtod(m, caddr_t), len / 2); + bus_io_read_multi_2(bc, ioh, + EP_W1_RX_PIO_RD_1, mtod(m, u_int16_t *), + len / 2); } else - *(mtod(m, caddr_t)) = - inb(BASE + EP_W1_RX_PIO_RD_1); + *(mtod(m, u_int8_t *)) = + bus_io_read_1(bc, ioh, EP_W1_RX_PIO_RD_1); } m->m_len = len; totlen -= len; @@ -756,8 +783,8 @@ epget(sc, totlen) mp = &m->m_next; } - outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK); - while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS) + bus_io_write_2(bc, ioh, EP_COMMAND, RX_DISCARD_TOP_PACK); + while (bus_io_read_2(bc, ioh, EP_STATUS) & S_COMMAND_IN_PROGRESS) ; splx(sh); @@ -778,7 +805,7 @@ epioctl(ifp, cmd, data) s = splnet(); - if ((error = ether_ioctl(ifp, sc->sc_arpcom, cmd, data)) > 0) { + if ((error = ether_ioctl(ifp, &sc->sc_arpcom, cmd, data)) > 0) { splx(s); return error; } @@ -881,19 +908,21 @@ void epstop(sc) register struct ep_softc *sc; { + bus_chipset_tag_t bc = sc->sc_bc; + bus_io_handle_t ioh = sc->sc_ioh; - outw(BASE + EP_COMMAND, RX_DISABLE); - outw(BASE + EP_COMMAND, RX_DISCARD_TOP_PACK); - while (inw(BASE + EP_STATUS) & S_COMMAND_IN_PROGRESS) + bus_io_write_2(bc, ioh, EP_COMMAND, RX_DISABLE); + bus_io_write_2(bc, ioh, EP_COMMAND, RX_DISCARD_TOP_PACK); + while (bus_io_read_2(bc, ioh, EP_STATUS) & S_COMMAND_IN_PROGRESS) ; - outw(BASE + EP_COMMAND, TX_DISABLE); - outw(BASE + EP_COMMAND, STOP_TRANSCEIVER); - outw(BASE + EP_COMMAND, RX_RESET); - outw(BASE + EP_COMMAND, TX_RESET); - outw(BASE + EP_COMMAND, C_INTR_LATCH); - outw(BASE + EP_COMMAND, SET_RD_0_MASK); - outw(BASE + EP_COMMAND, SET_INTR_MASK); - outw(BASE + EP_COMMAND, SET_RX_FILTER); + bus_io_write_2(bc, ioh, EP_COMMAND, TX_DISABLE); + bus_io_write_2(bc, ioh, EP_COMMAND, STOP_TRANSCEIVER); + bus_io_write_2(bc, ioh, EP_COMMAND, RX_RESET); + bus_io_write_2(bc, ioh, EP_COMMAND, TX_RESET); + bus_io_write_2(bc, ioh, EP_COMMAND, C_INTR_LATCH); + bus_io_write_2(bc, ioh, EP_COMMAND, SET_RD_0_MASK); + bus_io_write_2(bc, ioh, EP_COMMAND, SET_INTR_MASK); + bus_io_write_2(bc, ioh, EP_COMMAND, SET_RX_FILTER); epmbufempty(sc); } @@ -909,20 +938,24 @@ epstop(sc) * each card compares the data on the bus; if there is a difference * then that card goes into ID_WAIT state again). In the meantime; * one bit of data is returned in the AX register which is conveniently - * returned to us by inb(). Hence; we read 16 times getting one + * returned to us by bus_io_read_1(). Hence; we read 16 times getting one * bit of data with each read. + * + * NOTE: the caller must provide an i/o handle for ELINK_ID_PORT! */ -u_short -epreadeeprom(id_port, offset) - int id_port; - int offset; +u_int16_t +epreadeeprom(bc, ioh, offset) + bus_chipset_tag_t bc; + bus_io_handle_t ioh; + int offset; { - int i, data = 0; + u_int16_t data = 0; + int i; - outb(id_port, 0x80 + offset); + bus_io_write_1(bc, ioh, 0, 0x80 + offset); delay(1000); for (i = 0; i < 16; i++) - data = (data << 1) | (inw(id_port) & 1); + data = (data << 1) | (bus_io_read_2(bc, ioh, 0) & 1); return (data); } @@ -930,6 +963,8 @@ static int epbusyeeprom(sc) struct ep_softc *sc; { + bus_chipset_tag_t bc = sc->sc_bc; + bus_io_handle_t ioh = sc->sc_ioh; int i = 100, j; if (sc->bustype == EP_BUS_PCMCIA) { @@ -938,7 +973,7 @@ epbusyeeprom(sc) } while (i--) { - j = inw(BASE + EP_W0_EEPROM_COMMAND); + j = bus_io_read_2(bc, ioh, EP_W0_EEPROM_COMMAND); if (j & EEPROM_BUSY) delay(100); else @@ -958,9 +993,10 @@ epbusyeeprom(sc) } void -epmbuffill(sc) - struct ep_softc *sc; +epmbuffill(v) + void *v; { + struct ep_softc *sc = v; int s, i; s = splnet(); diff --git a/sys/dev/ic/elink3reg.h b/sys/dev/ic/elink3reg.h index a125013030e..721ee04f163 100644 --- a/sys/dev/ic/elink3reg.h +++ b/sys/dev/ic/elink3reg.h @@ -1,4 +1,4 @@ -/* $NetBSD: elink3reg.h,v 1.1 1996/04/25 02:17:35 thorpej Exp $ */ +/* $NetBSD: elink3reg.h,v 1.2 1996/04/30 22:32:39 thorpej Exp $ */ /* * Copyright (c) 1995 Herb Peyerl <hpeyerl@novatel.ca> @@ -318,8 +318,8 @@ #define ENABLE_DRQ_IRQ 0x0001 #define MFG_ID 0x506d /* `TCM' */ #define PROD_ID 0x5090 -#define BASE sc->ep_iobase -#define GO_WINDOW(x) outw(BASE+EP_COMMAND, WINDOW_SELECT|x) +#define GO_WINDOW(x) bus_io_write_2(sc->sc_bc, \ + sc->sc_ioh, EP_COMMAND, WINDOW_SELECT|x) #define AUI 0x1 #define BNC 0x2 #define UTP 0x4 diff --git a/sys/dev/ic/elink3var.h b/sys/dev/ic/elink3var.h index a048a44c2a7..534c68d8c66 100644 --- a/sys/dev/ic/elink3var.h +++ b/sys/dev/ic/elink3var.h @@ -1,4 +1,4 @@ -/* $NetBSD: elink3var.h,v 1.1 1996/04/25 02:17:36 thorpej Exp $ */ +/* $NetBSD: elink3var.h,v 1.3 1996/05/03 19:08:48 christos Exp $ */ /* * Copyright (c) 1994 Herb Peyerl <hpeyerl@novatel.ca> @@ -38,7 +38,8 @@ struct ep_softc { void *sc_ih; struct arpcom sc_arpcom; /* Ethernet common part */ - int ep_iobase; /* i/o bus address */ + bus_chipset_tag_t sc_bc; /* bus cookie */ + bus_io_handle_t sc_ioh; /* bus i/o handle */ char ep_connectors; /* Connectors on this card. */ #define MAX_MBS 8 /* # of mbufs we keep around */ struct mbuf *mb[MAX_MBS]; /* spare mbuf storage. */ @@ -60,6 +61,7 @@ struct ep_softc { #define EP_ABSENT 0x02 }; -u_short epreadeeprom __P((int id_port, int offset)); +u_int16_t epreadeeprom __P((bus_chipset_tag_t, bus_io_handle_t, int)); void epconfig __P((struct ep_softc *, u_int)); int epintr __P((void *)); +void epstop __P((struct ep_softc *)); |