Home | History | Annotate | Line # | Download | only in netboot
if_ie.c revision 1.11.50.1
      1  1.11.50.1      matt /*	if_ie.c,v 1.11 2005/12/24 22:45:35 perry Exp	*/
      2        1.1     chuck 
      3        1.1     chuck /*
      4        1.1     chuck  * Copyright (c) 1995 Theo de Raadt
      5        1.1     chuck  *
      6        1.1     chuck  * Redistribution and use in source and binary forms, with or without
      7        1.1     chuck  * modification, are permitted provided that the following conditions
      8        1.1     chuck  * are met:
      9        1.1     chuck  * 1. Redistributions of source code must retain the above copyright
     10        1.1     chuck  *    notice, this list of conditions and the following disclaimer.
     11        1.1     chuck  * 2. Redistributions in binary form must reproduce the above copyright
     12        1.1     chuck  *    notice, this list of conditions and the following disclaimer in the
     13        1.1     chuck  *    documentation and/or other materials provided with the distribution.
     14        1.1     chuck  *
     15        1.1     chuck  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
     16        1.1     chuck  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     17        1.1     chuck  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     18        1.1     chuck  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
     19        1.1     chuck  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     20        1.1     chuck  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     21        1.1     chuck  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     22        1.1     chuck  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     23        1.1     chuck  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     24        1.1     chuck  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     25        1.1     chuck  * SUCH DAMAGE.
     26        1.1     chuck  */
     27        1.1     chuck 
     28        1.1     chuck #include <sys/param.h>
     29        1.1     chuck #include <sys/types.h>
     30        1.3       scw #include <sys/socket.h>
     31        1.1     chuck 
     32        1.1     chuck #include <netinet/in.h>
     33        1.1     chuck #include <netinet/in_systm.h>
     34        1.3       scw 
     35        1.3       scw #include <net/if.h>
     36        1.3       scw #include <net/if_ether.h>
     37        1.1     chuck 
     38        1.5  jdolecek #include <lib/libkern/libkern.h>
     39        1.5  jdolecek #include <lib/libsa/stand.h>
     40        1.5  jdolecek #include <lib/libsa/net.h>
     41        1.5  jdolecek 
     42        1.1     chuck #define NTXBUF	1
     43        1.1     chuck #define NRXBUF	16
     44        1.1     chuck #define IE_RBUF_SIZE	ETHER_MAX_LEN
     45        1.1     chuck 
     46        1.1     chuck #include <machine/prom.h>
     47        1.1     chuck 
     48        1.1     chuck #include "libsa.h"
     49        1.1     chuck #include "netif.h"
     50        1.1     chuck #include "config.h"
     51        1.5  jdolecek #include "dev_net.h"
     52        1.1     chuck 
     53        1.1     chuck #include "i82586.h"
     54        1.1     chuck #include "if_iereg.h"
     55        1.1     chuck 
     56        1.1     chuck int     ie_debug = 0;
     57        1.1     chuck 
     58  1.11.50.1      matt void ie_stop(struct netif *);
     59  1.11.50.1      matt void ie_end(struct netif *);
     60  1.11.50.1      matt void ie_error(struct netif *, char *, volatile struct iereg *);
     61  1.11.50.1      matt int ie_get(struct iodesc *, void *, size_t, time_t);
     62  1.11.50.1      matt void ie_init(struct iodesc *, void *);
     63  1.11.50.1      matt int ie_match(struct netif *, void *);
     64  1.11.50.1      matt int ie_poll(struct iodesc *, void *, int);
     65  1.11.50.1      matt int ie_probe(struct netif *, void *);
     66  1.11.50.1      matt int ie_put(struct iodesc *, void *, size_t);
     67  1.11.50.1      matt void ie_reset(struct netif *, u_char *);
     68  1.11.50.1      matt void ieack(volatile struct iereg *, struct iemem *);
     69        1.1     chuck 
     70        1.1     chuck struct netif_stats ie_stats;
     71        1.1     chuck 
     72        1.1     chuck struct netif_dif ie0_dif = {
     73        1.1     chuck 	0,			/* unit */
     74        1.1     chuck 	1,			/* nsel */
     75        1.1     chuck 	&ie_stats,
     76        1.1     chuck 	0,
     77        1.1     chuck 	0,
     78        1.1     chuck };
     79        1.1     chuck 
     80        1.1     chuck struct netif_driver ie_driver = {
     81        1.1     chuck 	"ie",			/* netif_bname */
     82        1.1     chuck 	ie_match,		/* match */
     83        1.1     chuck 	ie_probe,		/* probe */
     84        1.1     chuck 	ie_init,		/* init */
     85        1.1     chuck 	ie_get,			/* get */
     86        1.1     chuck 	ie_put,			/* put */
     87        1.1     chuck 	ie_end,			/* end */
     88        1.1     chuck 	&ie0_dif,		/* netif_ifs */
     89        1.1     chuck 	1,			/* netif_nifs */
     90        1.1     chuck };
     91        1.1     chuck 
     92        1.1     chuck struct ie_configuration {
     93        1.1     chuck 	u_int   phys_addr;
     94        1.1     chuck 	int     used;
     95        1.1     chuck } ie_config[] = {
     96        1.1     chuck 	{ INTEL_REG_ADDR, 0 }
     97        1.1     chuck };
     98        1.1     chuck 
     99  1.11.50.1      matt int     nie_config = __arraycount(ie_config);
    100        1.1     chuck 
    101        1.1     chuck struct {
    102        1.1     chuck 	struct iereg *sc_reg;	/* IE registers */
    103        1.1     chuck 	struct iemem *sc_mem;	/* RAM */
    104        1.1     chuck }       ie_softc;
    105        1.1     chuck 
    106        1.1     chuck int
    107  1.11.50.1      matt ie_match(struct netif *nif, void *machdep_hint)
    108        1.1     chuck {
    109        1.1     chuck 	char   *name;
    110        1.1     chuck 	int     i, val = 0;
    111        1.1     chuck 
    112        1.1     chuck 	if (bugargs.cputyp == CPU_147)
    113  1.11.50.1      matt 		return 0;
    114        1.1     chuck 	name = machdep_hint;
    115        1.6       scw 	if (name && !memcmp(ie_driver.netif_bname, name, 2))
    116        1.1     chuck 		val += 10;
    117        1.1     chuck 	for (i = 0; i < nie_config; i++) {
    118        1.1     chuck 		if (ie_config[i].used)
    119        1.1     chuck 			continue;
    120        1.1     chuck 		if (ie_debug)
    121        1.1     chuck 			printf("ie%d: ie_match --> %d\n", i, val + 1);
    122        1.1     chuck 		ie_config[i].used++;
    123        1.1     chuck 		return (val + 1);
    124        1.1     chuck 	}
    125        1.1     chuck 	if (ie_debug)
    126        1.1     chuck 		printf("ie%d: ie_match --> 0\n", i);
    127  1.11.50.1      matt 	return 0;
    128        1.1     chuck }
    129        1.1     chuck 
    130        1.1     chuck int
    131  1.11.50.1      matt ie_probe(struct netif *nif, void *machdep_hint)
    132        1.1     chuck {
    133        1.1     chuck 
    134        1.1     chuck 	/* the set unit is the current unit */
    135        1.1     chuck 	if (ie_debug)
    136        1.1     chuck 		printf("ie%d: ie_probe called\n", nif->nif_unit);
    137        1.1     chuck 
    138        1.1     chuck 	if (bugargs.cputyp != CPU_147)
    139  1.11.50.1      matt 		return 0;
    140  1.11.50.1      matt 	return 1;
    141        1.1     chuck }
    142        1.1     chuck 
    143        1.1     chuck void
    144  1.11.50.1      matt ie_error(struct netif *nif, char *str, volatile struct iereg *ier)
    145        1.1     chuck {
    146  1.11.50.1      matt 
    147        1.7    provos 	panic("ie%d: unknown error", nif->nif_unit);
    148        1.1     chuck }
    149        1.1     chuck 
    150        1.5  jdolecek void
    151  1.11.50.1      matt ieack(volatile struct iereg *ier, struct iemem *iem)
    152        1.1     chuck {
    153  1.11.50.1      matt 
    154        1.1     chuck 	/* ack the `interrupt' */
    155        1.1     chuck 	iem->im_scb.ie_command = iem->im_scb.ie_status & IE_ST_WHENCE;
    156        1.1     chuck 	ier->ie_attention = 1;	/* chan attention! */
    157        1.1     chuck 	while (iem->im_scb.ie_command)
    158        1.1     chuck 		;
    159        1.1     chuck }
    160        1.1     chuck 
    161        1.1     chuck void
    162  1.11.50.1      matt ie_reset(struct netif *nif, u_char *myea)
    163        1.1     chuck {
    164        1.1     chuck 	volatile struct iereg *ier = ie_softc.sc_reg;
    165        1.1     chuck 	struct iemem *iem = ie_softc.sc_mem;
    166        1.5  jdolecek 	int     timo = 10000, i;
    167        1.1     chuck 	volatile int t;
    168        1.1     chuck 	u_int   a;
    169        1.1     chuck 
    170        1.1     chuck 	if (ie_debug)
    171        1.1     chuck 		printf("ie%d: ie_reset called\n", nif->nif_unit);
    172        1.1     chuck 
    173        1.1     chuck 	/*printf("ier %x iem %x\n", ier, iem);*/
    174        1.1     chuck 
    175        1.1     chuck 	*(u_char *)0xfff4202a = 0x40;
    176        1.1     chuck 
    177        1.6       scw 	memset(iem, 0, sizeof(*iem));
    178        1.1     chuck 	iem->im_scp.scp_sysbus = 0;
    179  1.11.50.1      matt 	iem->im_scp.scp_iscp_low = (int)&iem->im_iscp & 0xffff;
    180  1.11.50.1      matt 	iem->im_scp.scp_iscp_high = (int)&iem->im_iscp >> 16;
    181        1.1     chuck 
    182  1.11.50.1      matt 	iem->im_iscp.iscp_scboffset = (int)&iem->im_scb - (int) iem;
    183        1.1     chuck 	iem->im_iscp.iscp_busy = 1;
    184  1.11.50.1      matt 	iem->im_iscp.iscp_base_low = (int)iem & 0xffff;
    185  1.11.50.1      matt 	iem->im_iscp.iscp_base_high = (int)iem >> 16;
    186        1.1     chuck 
    187        1.1     chuck 	/*
    188        1.1     chuck 	 * completely and utterly unlike what i expected, the
    189        1.1     chuck 	 * "write" order is:
    190        1.1     chuck 	 * 1st:	d15-d0 -> high address
    191        1.1     chuck 	 * 2nd:	d31-d16 -> low address
    192        1.1     chuck 	 */
    193        1.1     chuck 
    194        1.1     chuck 	/* reset chip */
    195        1.1     chuck 	a = IE_PORT_RESET;
    196        1.1     chuck 	ier->ie_porthigh = a & 0xffff;
    197        1.1     chuck 	t = 0;
    198        1.1     chuck 	t = 1;
    199        1.1     chuck 	ier->ie_portlow = a >> 16;
    200        1.1     chuck 	for (t = timo; t--;)
    201        1.1     chuck 		;
    202        1.1     chuck 
    203        1.1     chuck 	/* set new SCP pointer */
    204        1.1     chuck 	a = (int) &iem->im_scp | IE_PORT_NEWSCP;
    205        1.1     chuck 	ier->ie_porthigh = a & 0xffff;
    206        1.1     chuck 	t = 0;
    207        1.1     chuck 	t = 1;
    208        1.1     chuck 	ier->ie_portlow = a >> 16;
    209        1.1     chuck 	for (t = timo; t--;)
    210        1.1     chuck 		;
    211        1.1     chuck 
    212        1.1     chuck 	ier->ie_attention = 1;	/* chan attention! */
    213        1.1     chuck 	for (t = timo * 10; t--;)
    214        1.1     chuck 		;
    215        1.1     chuck 
    216        1.1     chuck 	/* send CONFIGURE command */
    217        1.1     chuck 	iem->im_scb.ie_command = IE_CU_START;
    218        1.1     chuck 	iem->im_scb.ie_command_list = (int) &iem->im_cc - (int) iem;
    219        1.1     chuck 	iem->im_cc.com.ie_cmd_status = 0;
    220        1.1     chuck 	iem->im_cc.com.ie_cmd_cmd = IE_CMD_CONFIG | IE_CMD_LAST;
    221        1.1     chuck 	iem->im_cc.com.ie_cmd_link = 0xffff;
    222        1.1     chuck 	iem->im_cc.ie_config_count = 0x0c;
    223        1.1     chuck 	iem->im_cc.ie_fifo = 8;
    224        1.1     chuck 	iem->im_cc.ie_save_bad = 0x40;
    225        1.1     chuck 	iem->im_cc.ie_addr_len = 0x2e;
    226        1.1     chuck 	iem->im_cc.ie_priority = 0;
    227        1.1     chuck 	iem->im_cc.ie_ifs = 0x60;
    228        1.1     chuck 	iem->im_cc.ie_slot_low = 0;
    229        1.1     chuck 	iem->im_cc.ie_slot_high = 0xf2;
    230        1.1     chuck 	iem->im_cc.ie_promisc = 0;
    231        1.1     chuck 	iem->im_cc.ie_crs_cdt = 0;
    232        1.1     chuck 	iem->im_cc.ie_min_len = 64;
    233        1.1     chuck 	iem->im_cc.ie_junk = 0xff;
    234        1.1     chuck 
    235        1.1     chuck 	ier->ie_attention = 1;	/* chan attention! */
    236        1.1     chuck 	for (t = timo * 10; t--;)
    237        1.1     chuck 		;
    238        1.1     chuck 
    239        1.1     chuck 	ieack(ier, iem);
    240        1.1     chuck 
    241        1.1     chuck 	/*printf("ic %x\n", &iem->im_ic);*/
    242        1.1     chuck 	/* send IASETUP command */
    243        1.1     chuck 	iem->im_scb.ie_command = IE_CU_START;
    244  1.11.50.1      matt 	iem->im_scb.ie_command_list = (int)&iem->im_ic - (int)iem;
    245        1.1     chuck 	iem->im_ic.com.ie_cmd_status = 0;
    246        1.1     chuck 	iem->im_ic.com.ie_cmd_cmd = IE_CMD_IASETUP | IE_CMD_LAST;
    247        1.1     chuck 	iem->im_ic.com.ie_cmd_link = 0xffff;
    248        1.6       scw 	memcpy((void *)&iem->im_ic.ie_address, myea,
    249  1.11.50.1      matt 	    sizeof(iem->im_ic.ie_address));
    250        1.1     chuck 
    251        1.1     chuck 	ier->ie_attention = 1;	/* chan attention! */
    252        1.1     chuck 	for (t = timo * 10; t--;)
    253        1.1     chuck 		;
    254        1.1     chuck 
    255        1.1     chuck 	ieack(ier, iem);
    256        1.1     chuck 
    257        1.1     chuck 	/* setup buffers */
    258        1.1     chuck 
    259        1.1     chuck 	for (i = 0; i < NRXBUF; i++) {
    260  1.11.50.1      matt 		iem->im_rfd[i].ie_fd_next = (int)&iem->im_rfd[(i+1) % NRXBUF] -
    261  1.11.50.1      matt 		    (int)iem;
    262  1.11.50.1      matt 		iem->im_rbd[i].ie_rbd_next = (int)&iem->im_rbd[(i+1) % NRXBUF] -
    263  1.11.50.1      matt 		    (int)iem;
    264  1.11.50.1      matt 		a = (int)&iem->im_rxbuf[i * IE_RBUF_SIZE];
    265        1.1     chuck 		iem->im_rbd[i].ie_rbd_buffer_low = a & 0xffff;
    266        1.1     chuck 		iem->im_rbd[i].ie_rbd_buffer_high = a >> 16;
    267        1.1     chuck 		iem->im_rbd[i].ie_rbd_length = IE_RBUF_SIZE;
    268        1.1     chuck 	}
    269  1.11.50.1      matt 	iem->im_rfd[NRXBUF - 1].ie_fd_last |= IE_FD_LAST;
    270  1.11.50.1      matt 	iem->im_rbd[NRXBUF - 1].ie_rbd_length |= IE_RBD_LAST;
    271  1.11.50.1      matt 	iem->im_rfd[0].ie_fd_buf_desc = (int)&iem->im_rbd[0] - (int)iem;
    272  1.11.50.1      matt 
    273  1.11.50.1      matt #if 0
    274  1.11.50.1      matt 	printf("rfd[0] %x rbd[0] %x buf[0] %x\n", &iem->im_rfd, &iem->im_rbd,
    275  1.11.50.1      matt 	    &iem->im_rxbuf);
    276  1.11.50.1      matt #endif
    277        1.1     chuck 
    278        1.1     chuck 	/* send receiver start command */
    279        1.1     chuck 	iem->im_scb.ie_command = IE_RU_START;
    280        1.1     chuck 	iem->im_scb.ie_command_list = 0;
    281        1.1     chuck 	iem->im_scb.ie_recv_list = (int) &iem->im_rfd[0] - (int) iem;
    282        1.1     chuck 	ier->ie_attention = 1;	/* chan attention! */
    283        1.1     chuck 	while (iem->im_scb.ie_command)
    284        1.1     chuck 		;
    285        1.1     chuck 
    286        1.1     chuck 	ieack(ier, iem);
    287        1.1     chuck }
    288        1.1     chuck 
    289        1.1     chuck int
    290  1.11.50.1      matt ie_poll(struct iodesc *desc, void *pkt, int len)
    291        1.1     chuck {
    292        1.1     chuck 	volatile struct iereg *ier = ie_softc.sc_reg;
    293        1.1     chuck 	struct iemem *iem = ie_softc.sc_mem;
    294        1.1     chuck 	static int slot;
    295  1.11.50.1      matt 	int length = 0;
    296        1.1     chuck 	u_short status;
    297        1.1     chuck 
    298       1.11     perry 	__asm(".word	0xf518\n");
    299        1.1     chuck 	status = iem->im_rfd[slot].ie_fd_status;
    300        1.1     chuck 	if (status & IE_FD_BUSY)
    301  1.11.50.1      matt 		return 0;
    302        1.1     chuck 
    303        1.1     chuck 	/* printf("slot %d: %x\n", slot, status); */
    304  1.11.50.1      matt 	if ((status & (IE_FD_COMPLETE | IE_FD_OK)) ==
    305  1.11.50.1      matt 	    (IE_FD_COMPLETE | IE_FD_OK)) {
    306        1.1     chuck 		if (status & IE_FD_OK) {
    307        1.1     chuck 			length = iem->im_rbd[slot].ie_rbd_actual & 0x3fff;
    308        1.1     chuck 			if (length > len)
    309        1.1     chuck 				length = len;
    310        1.6       scw 			memcpy(pkt, (void *)&iem->im_rxbuf[slot * IE_RBUF_SIZE],
    311        1.6       scw 			    length);
    312        1.1     chuck 
    313        1.1     chuck 			iem->im_rfd[slot].ie_fd_status = 0;
    314        1.1     chuck 			iem->im_rfd[slot].ie_fd_last |= IE_FD_LAST;
    315        1.1     chuck 			iem->im_rfd[(slot+NRXBUF-1)%NRXBUF].ie_fd_last &=
    316        1.1     chuck 			    ~IE_FD_LAST;
    317        1.1     chuck 			iem->im_rbd[slot].ie_rbd_actual = 0;
    318        1.1     chuck 			iem->im_rbd[slot].ie_rbd_length |= IE_RBD_LAST;
    319        1.1     chuck 			iem->im_rbd[(slot+NRXBUF-1)%NRXBUF].ie_rbd_length &=
    320        1.1     chuck 			    ~IE_RBD_LAST;
    321  1.11.50.1      matt #if 0
    322  1.11.50.1      matt 			printf("S%d\n", slot);
    323  1.11.50.1      matt #endif
    324        1.1     chuck 		} else {
    325        1.1     chuck 			printf("shit\n");
    326        1.1     chuck 		}
    327        1.1     chuck 		slot++;
    328        1.1     chuck 		/* should move descriptor onto end of queue... */
    329        1.1     chuck 	}
    330        1.1     chuck 	if ((iem->im_scb.ie_status & IE_RU_READY) == 0) {
    331        1.1     chuck 		printf("RR\n");
    332        1.1     chuck 
    333        1.1     chuck 		for (slot = 0; slot < NRXBUF; slot++) {
    334        1.1     chuck 			iem->im_rbd[slot].ie_rbd_length &= ~IE_RBD_LAST;
    335        1.1     chuck 			iem->im_rfd[slot].ie_fd_last &= ~IE_FD_LAST;
    336        1.1     chuck 		}
    337        1.1     chuck 		iem->im_rbd[NRXBUF-1].ie_rbd_length |= IE_RBD_LAST;
    338        1.1     chuck 		iem->im_rfd[NRXBUF-1].ie_fd_last |= IE_FD_LAST;
    339        1.1     chuck 
    340        1.1     chuck 		iem->im_rfd[0].ie_fd_buf_desc = (int)&iem->im_rbd[0] - (int)iem;
    341        1.1     chuck 
    342        1.1     chuck 		iem->im_scb.ie_command = IE_RU_START;
    343        1.1     chuck 		iem->im_scb.ie_command_list = 0;
    344        1.1     chuck 		iem->im_scb.ie_recv_list = (int)&iem->im_rfd[0] - (int)iem;
    345        1.1     chuck 		ier->ie_attention = 1;	/* chan attention! */
    346        1.1     chuck 		while (iem->im_scb.ie_command)
    347        1.1     chuck 			;
    348        1.1     chuck 		slot = 0;
    349        1.1     chuck 	}
    350        1.1     chuck 	slot = slot % NRXBUF;
    351  1.11.50.1      matt 	return length;
    352        1.1     chuck }
    353        1.1     chuck 
    354        1.1     chuck int
    355  1.11.50.1      matt ie_put(struct iodesc *desc, void *pkt, size_t len)
    356        1.1     chuck {
    357        1.1     chuck 	volatile struct iereg *ier = ie_softc.sc_reg;
    358        1.1     chuck 	struct iemem *iem = ie_softc.sc_mem;
    359        1.1     chuck 	u_char *p = pkt;
    360  1.11.50.1      matt 	u_int a;
    361  1.11.50.1      matt 	int xx = 0;
    362        1.1     chuck 
    363        1.1     chuck 	/* send transmit command */
    364        1.1     chuck 
    365        1.1     chuck 	while (iem->im_scb.ie_command)
    366        1.1     chuck 		;
    367        1.1     chuck 
    368        1.1     chuck 	/* copy data */
    369        1.6       scw 	memcpy((void *)&iem->im_txbuf[xx], p, len);
    370        1.1     chuck 
    371        1.1     chuck 	len = MAX(len, ETHER_MIN_LEN);
    372        1.1     chuck 
    373        1.1     chuck 	/* build transmit descriptor */
    374        1.1     chuck 	iem->im_xd[xx].ie_xmit_flags = len | IE_XMIT_LAST;
    375        1.1     chuck 	iem->im_xd[xx].ie_xmit_next = 0xffff;
    376        1.1     chuck 	a = (int) &iem->im_txbuf[xx];
    377        1.1     chuck 	iem->im_xd[xx].ie_xmit_buf_low = a & 0xffff;
    378        1.1     chuck 	iem->im_xd[xx].ie_xmit_buf_high = a >> 16;
    379        1.1     chuck 
    380        1.1     chuck 	/* transmit command */
    381        1.1     chuck 	iem->im_xc[xx].com.ie_cmd_status = 0;
    382        1.1     chuck 	iem->im_xc[xx].com.ie_cmd_cmd = IE_CMD_XMIT | IE_CMD_LAST;
    383        1.1     chuck 	iem->im_xc[xx].com.ie_cmd_link = 0xffff;
    384  1.11.50.1      matt 	iem->im_xc[xx].ie_xmit_desc = (int)&iem->im_xd[xx] - (int)iem;
    385        1.1     chuck 	iem->im_xc[xx].ie_xmit_length = len;
    386        1.6       scw 	memcpy((void *)&iem->im_xc[xx].ie_xmit_addr, p,
    387        1.1     chuck 	    sizeof iem->im_xc[xx].ie_xmit_addr);
    388        1.1     chuck 
    389        1.1     chuck 	iem->im_scb.ie_command = IE_CU_START;
    390  1.11.50.1      matt 	iem->im_scb.ie_command_list = (int)&iem->im_xc[xx] - (int)iem;
    391        1.1     chuck 
    392        1.1     chuck 	ier->ie_attention = 1;	/* chan attention! */
    393        1.1     chuck 
    394        1.1     chuck 	if (ie_debug) {
    395        1.1     chuck 		printf("ie%d: send %d to %x:%x:%x:%x:%x:%x\n",
    396        1.8  drochner 		    ((struct netif *)desc->io_netif)->nif_unit, len,
    397        1.1     chuck 		    p[0], p[1], p[2], p[3], p[4], p[5]);
    398        1.1     chuck 	}
    399  1.11.50.1      matt 	return len;
    400        1.1     chuck }
    401        1.1     chuck 
    402        1.1     chuck int
    403  1.11.50.1      matt ie_get(struct iodesc *desc, void *pkt, size_t len, time_t timeout)
    404        1.1     chuck {
    405        1.1     chuck 	time_t  t;
    406        1.1     chuck 	int     cc;
    407        1.1     chuck 
    408        1.1     chuck 	t = getsecs();
    409        1.1     chuck 	cc = 0;
    410        1.1     chuck 	while (((getsecs() - t) < timeout) && !cc) {
    411        1.1     chuck 		cc = ie_poll(desc, pkt, len);
    412        1.1     chuck 	}
    413  1.11.50.1      matt 	return cc;
    414        1.1     chuck }
    415        1.1     chuck /*
    416        1.1     chuck  * init ie device.   return 0 on failure, 1 if ok.
    417        1.1     chuck  */
    418        1.1     chuck void
    419  1.11.50.1      matt ie_init(struct iodesc *desc, void *machdep_hint)
    420        1.1     chuck {
    421        1.1     chuck 	struct netif *nif = desc->io_netif;
    422        1.1     chuck 
    423        1.1     chuck 	if (ie_debug)
    424        1.8  drochner 		printf("ie%d: ie_init called\n", nif->nif_unit);
    425        1.1     chuck 	machdep_common_ether(desc->myea);
    426        1.6       scw 	memset(&ie_softc, 0, sizeof(ie_softc));
    427        1.1     chuck 	ie_softc.sc_reg =
    428  1.11.50.1      matt 	    (struct iereg *)ie_config[nif->nif_unit].phys_addr;
    429  1.11.50.1      matt 	ie_softc.sc_mem = (struct iemem *)0x3e0000;
    430        1.1     chuck 	ie_reset(desc->io_netif, desc->myea);
    431        1.1     chuck 	printf("device: %s%d attached to %s\n", nif->nif_driver->netif_bname,
    432        1.1     chuck 	    nif->nif_unit, ether_sprintf(desc->myea));
    433        1.1     chuck }
    434        1.1     chuck 
    435        1.1     chuck void
    436  1.11.50.1      matt ie_stop(struct netif *nif)
    437        1.1     chuck {
    438        1.1     chuck 	volatile struct iereg *ier = ie_softc.sc_reg;
    439        1.1     chuck 	struct iemem *iem = ie_softc.sc_mem;
    440  1.11.50.1      matt 	int timo = 10000;
    441        1.1     chuck 	volatile int t;
    442  1.11.50.1      matt 	u_int a;
    443        1.1     chuck 
    444        1.1     chuck 	iem->im_iscp.iscp_busy = 1;
    445        1.1     chuck 	/* reset chip */
    446        1.1     chuck 	a = IE_PORT_RESET;
    447        1.1     chuck 	ier->ie_porthigh = a & 0xffff;
    448        1.1     chuck 	t = 0;
    449        1.1     chuck 	t = 1;
    450        1.1     chuck 	ier->ie_portlow = a >> 16;
    451        1.1     chuck 	for (t = timo; t--;)
    452        1.1     chuck 		;
    453        1.1     chuck 
    454        1.1     chuck 	/* reset chip again */
    455        1.1     chuck 	a = IE_PORT_RESET;
    456        1.1     chuck 	ier->ie_porthigh = a & 0xffff;
    457        1.1     chuck 	t = 0;
    458        1.1     chuck 	t = 1;
    459        1.1     chuck 	ier->ie_portlow = a >> 16;
    460        1.1     chuck 	for (t = timo; t--;)
    461        1.1     chuck 		;
    462        1.1     chuck 
    463  1.11.50.1      matt #if 0
    464  1.11.50.1      matt 	printf("status %x busy %x\n", iem->im_scb.ie_status,
    465  1.11.50.1      matt 	    iem->im_iscp.iscp_busy);
    466  1.11.50.1      matt #endif
    467        1.1     chuck }
    468        1.1     chuck 
    469        1.1     chuck void
    470  1.11.50.1      matt ie_end(struct netif *nif)
    471        1.1     chuck {
    472  1.11.50.1      matt 
    473        1.1     chuck 	if (ie_debug)
    474        1.1     chuck 		printf("ie%d: ie_end called\n", nif->nif_unit);
    475        1.1     chuck 
    476        1.1     chuck 	ie_stop(nif);
    477        1.1     chuck 
    478  1.11.50.1      matt #if 0
    479  1.11.50.1      matt 	*(u_char *)0xfff42002 = 0;
    480  1.11.50.1      matt #endif
    481        1.1     chuck }
    482