diff options
author | kstailey <kstailey@cvs.openbsd.org> | 1997-01-07 23:36:38 +0000 |
---|---|---|
committer | kstailey <kstailey@cvs.openbsd.org> | 1997-01-07 23:36:38 +0000 |
commit | 1a190ef5412cf740c35f6e234ede308c9745b639 (patch) | |
tree | 73ba393da5a081446a8d47c9e1e21b4684bda58e /sys/arch/sun3/dev/if_ie.c | |
parent | 5e87748eb0e9353770bea311de7b4d88a3fe8cdd (diff) |
backed out prev. netbsd merge except for smaller proc table
Diffstat (limited to 'sys/arch/sun3/dev/if_ie.c')
-rw-r--r-- | sys/arch/sun3/dev/if_ie.c | 106 |
1 files changed, 44 insertions, 62 deletions
diff --git a/sys/arch/sun3/dev/if_ie.c b/sys/arch/sun3/dev/if_ie.c index 3486a1fa4c9..32f52c05e8f 100644 --- a/sys/arch/sun3/dev/if_ie.c +++ b/sys/arch/sun3/dev/if_ie.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ie.c,v 1.16 1996/12/17 21:10:44 gwr Exp $ */ +/* $NetBSD: if_ie.c,v 1.15 1996/10/30 00:24:33 gwr Exp $ */ /*- * Copyright (c) 1993, 1994, 1995 Charles Hannum. @@ -135,16 +135,16 @@ #include <vm/vm.h> -#include <machine/autoconf.h> -#include <machine/cpu.h> -#include <machine/pmap.h> - /* * ugly byte-order hack for SUNs */ -#define XSWAP(y) ( ((y) >> 8) | ((y) << 8) ) #define SWAP(x) ((u_short)(XSWAP((u_short)(x)))) +#define XSWAP(y) ( ((y) >> 8) | ((y) << 8) ) + +#include <machine/autoconf.h> +#include <machine/cpu.h> +#include <machine/pmap.h> #include "i82586.h" #include "if_iereg.h" @@ -172,35 +172,15 @@ int ieinit __P((struct ie_softc *)); int ieioctl __P((struct ifnet *, u_long, caddr_t)); void iestart __P((struct ifnet *)); void iereset __P((struct ie_softc *)); -int ie_setupram __P((struct ie_softc *sc)); - -static void chan_attn_timeout __P((void *arg)); -static int cmd_and_wait __P((struct ie_softc *, int, void *, int)); - -static void ie_drop_packet_buffer __P((struct ie_softc *)); static void ie_readframe __P((struct ie_softc *, int)); -static void ie_setup_config __P((struct ie_config_cmd *, int, int)); - +static void ie_drop_packet_buffer __P((struct ie_softc *)); +static int command_and_wait __P((struct ie_softc *, int, + void volatile *, int)); static void ierint __P((struct ie_softc *)); -static void iestop __P((struct ie_softc *)); static void ietint __P((struct ie_softc *)); -static void iexmit __P((struct ie_softc *)); - +static void setup_bufs __P((struct ie_softc *)); static int mc_setup __P((struct ie_softc *, void *)); static void mc_reset __P((struct ie_softc *)); -static void run_tdr __P((struct ie_softc *, struct ie_tdr_cmd *)); -static void setup_bufs __P((struct ie_softc *)); - -static inline caddr_t Align __P((caddr_t ptr)); -static inline void ie_ack __P((struct ie_softc *, u_int)); -static inline u_short ether_cmp __P((u_char *, u_char *)); -static inline int check_eh __P((struct ie_softc *, - struct ether_header *eh, int *)); -static inline int ie_buflen __P((struct ie_softc *, int)); -static inline int ie_packet_len __P((struct ie_softc *)); -static inline int ieget __P((struct ie_softc *sc, - struct mbuf **mp, struct ether_header *ehp, int *to_bpf)); - #ifdef IEDEBUG void print_rbd __P((volatile struct ie_recv_buf_desc *)); @@ -235,7 +215,7 @@ struct cfdriver ie_cd = { */ static inline void ie_setup_config(cmd, promiscuous, manchester) - struct ie_config_cmd *cmd; + volatile struct ie_config_cmd *cmd; int promiscuous, manchester; { @@ -273,7 +253,7 @@ ie_ack(sc, mask) { volatile struct ie_sys_ctl_block *scb = sc->scb; - cmd_and_wait(sc, scb->ie_status & mask, 0, 0); + command_and_wait(sc, scb->ie_status & mask, 0, 0); } @@ -369,8 +349,8 @@ ie_intr(v) volatile struct ievme *iev = (volatile struct ievme *)sc->sc_reg; if (iev->status & IEVME_PERR) { printf("%s: parity error (ctrl %x @ %02x%04x)\n", - sc->sc_dev.dv_xname, iev->pectrl, - iev->pectrl & IEVME_HADDR, iev->peaddr); + iev->pectrl, iev->pectrl & IEVME_HADDR, + iev->peaddr); iev->pectrl = iev->pectrl | IEVME_PARACK; } } @@ -457,7 +437,7 @@ ierint(sc) MK_16(sc->sc_maddr, sc->rbuffs[0]); scb->ie_recv_list = MK_16(sc->sc_maddr, sc->rframes[0]); - cmd_and_wait(sc, IE_RU_START, 0, 0); + command_and_wait(sc, IE_RU_START, 0, 0); } break; } @@ -475,6 +455,7 @@ ietint(sc) struct ie_softc *sc; { int status; + int i; sc->sc_arpcom.ac_if.if_timer = 0; sc->sc_arpcom.ac_if.if_flags &= ~IFF_OACTIVE; @@ -710,7 +691,7 @@ ie_packet_len(sc) * command to the chip to be executed. On the way, if we have a BPF listener * also give him a copy. */ -static void +inline static void iexmit(sc) struct ie_softc *sc; { @@ -741,7 +722,7 @@ iexmit(sc) sc->scb->ie_command_list = MK_16(sc->sc_maddr, sc->xmit_cmds[sc->xctail]); - cmd_and_wait(sc, IE_CU_START, 0, 0); + command_and_wait(sc, IE_CU_START, 0, 0); sc->xmit_busy = 1; sc->sc_arpcom.ac_if.if_timer = 5; @@ -1170,10 +1151,10 @@ iereset(sc) /* * Stop i82586 dead in its tracks. */ - if (cmd_and_wait(sc, IE_RU_ABORT | IE_CU_ABORT, 0, 0)) + if (command_and_wait(sc, IE_RU_ABORT | IE_CU_ABORT, 0, 0)) printf("%s: abort commands timed out\n", sc->sc_dev.dv_xname); - if (cmd_and_wait(sc, IE_RU_DISABLE | IE_CU_STOP, 0, 0)) + if (command_and_wait(sc, IE_RU_DISABLE | IE_CU_STOP, 0, 0)) printf("%s: disable commands timed out\n", sc->sc_dev.dv_xname); #ifdef notdef @@ -1191,10 +1172,10 @@ iereset(sc) * This is called if we time out. */ static void -chan_attn_timeout(arg) - void *arg; +chan_attn_timeout(rock) + caddr_t rock; { - *((int *)arg) = 1; + *(int *) rock = 1; } /* @@ -1207,10 +1188,10 @@ chan_attn_timeout(arg) * to become true. */ static int -cmd_and_wait(sc, cmd, pcmd, mask) +command_and_wait(sc, cmd, pcmd, mask) struct ie_softc *sc; int cmd; - void * pcmd; + volatile void *pcmd; int mask; { volatile struct ie_cmd_common *cc = pcmd; @@ -1235,7 +1216,7 @@ cmd_and_wait(sc, cmd, pcmd, mask) * .369 seconds, which we round up to .4. */ - timeout(chan_attn_timeout, (void *)&timedout, 2 * hz / 5); + timeout(chan_attn_timeout, (caddr_t)&timedout, 2 * hz / 5); /* * Now spin-lock waiting for status. This is not a very nice @@ -1248,7 +1229,7 @@ cmd_and_wait(sc, cmd, pcmd, mask) if ((cc->ie_cmd_status & mask) || timedout) break; - untimeout(chan_attn_timeout, (void *)&timedout); + untimeout(chan_attn_timeout, (caddr_t)&timedout); return timedout; } else { @@ -1281,7 +1262,7 @@ run_tdr(sc, cmd) sc->scb->ie_command_list = MK_16(sc->sc_maddr, cmd); cmd->ie_tdr_time = SWAP(0); - if (cmd_and_wait(sc, IE_CU_START, cmd, IE_STAT_COMPL) || + if (command_and_wait(sc, IE_CU_START, cmd, IE_STAT_COMPL) || !(cmd->com.ie_cmd_status & IE_STAT_OK)) result = 0x10000; /* XXX */ else @@ -1326,7 +1307,9 @@ setup_bufs(sc) struct ie_softc *sc; { caddr_t ptr = sc->buf_area; /* memory pool */ - u_int n, r; + volatile struct ie_recv_frame_desc *rfd = (void *) ptr; + volatile struct ie_recv_buf_desc *rbd; + int n, r; /* * step 0: zero memory and figure out how many recv buffers and @@ -1335,16 +1318,14 @@ setup_bufs(sc) (sc->sc_bzero)(ptr, sc->buf_area_sz); ptr = Align(ptr); /* set alignment and stick with it */ - n = ALIGN(sizeof(struct ie_xmit_cmd)) + - ALIGN(sizeof(struct ie_xmit_buf)) + - IE_TBUF_SIZE; + n = (int)Align(sizeof(struct ie_xmit_cmd)) + + (int)Align(sizeof(struct ie_xmit_buf)) + IE_TBUF_SIZE; n *= NTXBUF; /* n = total size of xmit area */ n = sc->buf_area_sz - n;/* n = free space for recv stuff */ - r = ALIGN(sizeof(struct ie_recv_frame_desc)) + - ((ALIGN(sizeof(struct ie_recv_buf_desc)) + - IE_RBUF_SIZE) * B_PER_F); + r = (int)Align(sizeof(struct ie_recv_frame_desc)) + + (((int)Align(sizeof(struct ie_recv_buf_desc)) + IE_RBUF_SIZE) * B_PER_F); /* r = size of one R frame */ @@ -1455,7 +1436,7 @@ mc_setup(sc, ptr) struct ie_softc *sc; void *ptr; { - struct ie_mcast_cmd *cmd = ptr; + volatile struct ie_mcast_cmd *cmd = ptr; cmd->com.ie_cmd_status = SWAP(0); cmd->com.ie_cmd_cmd = IE_CMD_MCAST | IE_CMD_LAST; @@ -1468,7 +1449,7 @@ mc_setup(sc, ptr) SWAP(sc->mcast_count * ETHER_ADDR_LEN); /* grrr... */ sc->scb->ie_command_list = MK_16(sc->sc_maddr, cmd); - if (cmd_and_wait(sc, IE_CU_START, cmd, IE_STAT_COMPL) || + if (command_and_wait(sc, IE_CU_START, cmd, IE_STAT_COMPL) || !(cmd->com.ie_cmd_status & IE_STAT_OK)) { printf("%s: multicast address setup command failed\n", sc->sc_dev.dv_xname); @@ -1490,6 +1471,7 @@ ieinit(sc) { volatile struct ie_sys_ctl_block *scb = sc->scb; void *ptr; + int n; ptr = sc->buf_area; @@ -1497,7 +1479,7 @@ ieinit(sc) * Send the configure command first. */ { - struct ie_config_cmd *cmd = ptr; + volatile struct ie_config_cmd *cmd = ptr; scb->ie_command_list = MK_16(sc->sc_maddr, cmd); cmd->com.ie_cmd_status = SWAP(0); @@ -1506,7 +1488,7 @@ ieinit(sc) ie_setup_config(cmd, sc->promisc, 0); - if (cmd_and_wait(sc, IE_CU_START, cmd, IE_STAT_COMPL) || + if (command_and_wait(sc, IE_CU_START, cmd, IE_STAT_COMPL) || !(cmd->com.ie_cmd_status & IE_STAT_OK)) { printf("%s: configure command failed\n", sc->sc_dev.dv_xname); @@ -1518,7 +1500,7 @@ ieinit(sc) * Now send the Individual Address Setup command. */ { - struct ie_iasetup_cmd *cmd = ptr; + volatile struct ie_iasetup_cmd *cmd = ptr; scb->ie_command_list = MK_16(sc->sc_maddr, cmd); cmd->com.ie_cmd_status = SWAP(0); @@ -1528,7 +1510,7 @@ ieinit(sc) (sc->sc_bcopy)(sc->sc_arpcom.ac_enaddr, (caddr_t)&cmd->ie_address, sizeof cmd->ie_address); - if (cmd_and_wait(sc, IE_CU_START, cmd, IE_STAT_COMPL) || + if (command_and_wait(sc, IE_CU_START, cmd, IE_STAT_COMPL) || !(cmd->com.ie_cmd_status & IE_STAT_OK)) { printf("%s: individual address setup command failed\n", sc->sc_dev.dv_xname); @@ -1555,7 +1537,7 @@ ieinit(sc) sc->sc_arpcom.ac_if.if_flags |= IFF_RUNNING; sc->scb->ie_recv_list = MK_16(sc->sc_maddr, sc->rframes[0]); - cmd_and_wait(sc, IE_RU_START, 0, 0); + command_and_wait(sc, IE_RU_START, 0, 0); ie_ack(sc, IE_ST_WHENCE); @@ -1570,7 +1552,7 @@ iestop(sc) struct ie_softc *sc; { - cmd_and_wait(sc, IE_RU_DISABLE, 0, 0); + command_and_wait(sc, IE_RU_DISABLE, 0, 0); } int |