Home | History | Annotate | Line # | Download | only in tc
if_le_ioasic.c revision 1.27.14.1
      1  1.27.14.1     rmind /*	$NetBSD: if_le_ioasic.c,v 1.27.14.1 2007/03/12 05:57:14 rmind Exp $	*/
      2        1.1       cgd 
      3        1.1       cgd /*
      4        1.1       cgd  * Copyright (c) 1996 Carnegie-Mellon University.
      5        1.1       cgd  * All rights reserved.
      6        1.1       cgd  *
      7        1.1       cgd  * Author: Chris G. Demetriou
      8        1.1       cgd  *
      9        1.1       cgd  * Permission to use, copy, modify and distribute this software and
     10        1.1       cgd  * its documentation is hereby granted, provided that both the copyright
     11        1.1       cgd  * notice and this permission notice appear in all copies of the
     12        1.1       cgd  * software, derivative works or modified versions, and any portions
     13        1.1       cgd  * thereof, and that both notices appear in supporting documentation.
     14        1.1       cgd  *
     15        1.1       cgd  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
     16        1.1       cgd  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
     17        1.1       cgd  * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
     18        1.1       cgd  *
     19        1.1       cgd  * Carnegie Mellon requests users of this software to return to
     20        1.1       cgd  *
     21        1.1       cgd  *  Software Distribution Coordinator  or  Software.Distribution (at) CS.CMU.EDU
     22        1.1       cgd  *  School of Computer Science
     23        1.1       cgd  *  Carnegie Mellon University
     24        1.1       cgd  *  Pittsburgh PA 15213-3890
     25        1.1       cgd  *
     26        1.1       cgd  * any improvements or extensions that they make and grant Carnegie the
     27        1.1       cgd  * rights to redistribute these changes.
     28        1.1       cgd  */
     29        1.1       cgd 
     30        1.1       cgd /*
     31        1.1       cgd  * LANCE on DEC IOCTL ASIC.
     32        1.1       cgd  */
     33        1.9  jonathan 
     34       1.18     lukem #include <sys/cdefs.h>
     35  1.27.14.1     rmind __KERNEL_RCSID(0, "$NetBSD: if_le_ioasic.c,v 1.27.14.1 2007/03/12 05:57:14 rmind Exp $");
     36       1.11  jonathan 
     37       1.11  jonathan #include "opt_inet.h"
     38        1.1       cgd 
     39        1.1       cgd #include <sys/param.h>
     40        1.1       cgd #include <sys/systm.h>
     41        1.1       cgd #include <sys/mbuf.h>
     42        1.1       cgd #include <sys/syslog.h>
     43        1.1       cgd #include <sys/socket.h>
     44        1.1       cgd #include <sys/device.h>
     45        1.1       cgd 
     46        1.1       cgd #include <net/if.h>
     47        1.5       cgd #include <net/if_ether.h>
     48        1.6   thorpej #include <net/if_media.h>
     49        1.1       cgd 
     50        1.1       cgd #ifdef INET
     51        1.1       cgd #include <netinet/in.h>
     52        1.4        is #include <netinet/if_inarp.h>
     53        1.1       cgd #endif
     54        1.1       cgd 
     55       1.12  drochner #include <dev/ic/lancereg.h>
     56       1.12  drochner #include <dev/ic/lancevar.h>
     57        1.1       cgd #include <dev/ic/am7990reg.h>
     58        1.1       cgd #include <dev/ic/am7990var.h>
     59        1.1       cgd 
     60        1.2   thorpej #include <dev/tc/if_levar.h>
     61        1.1       cgd #include <dev/tc/tcvar.h>
     62       1.13  nisimura #include <dev/tc/ioasicreg.h>
     63        1.1       cgd #include <dev/tc/ioasicvar.h>
     64        1.1       cgd 
     65       1.16  nisimura struct le_ioasic_softc {
     66       1.16  nisimura 	struct	am7990_softc sc_am7990;	/* glue to MI code */
     67       1.16  nisimura 	struct	lereg1 *sc_r1;		/* LANCE registers */
     68       1.16  nisimura 	/* XXX must match with le_softc of if_levar.h XXX */
     69       1.12  drochner 
     70       1.16  nisimura 	bus_dma_tag_t sc_dmat;		/* bus dma tag */
     71       1.16  nisimura 	bus_dmamap_t sc_dmamap;		/* bus dmamap */
     72       1.16  nisimura };
     73       1.13  nisimura 
     74       1.22     perry static int  le_ioasic_match(struct device *, struct cfdata *, void *);
     75       1.22     perry static void le_ioasic_attach(struct device *, struct device *, void *);
     76       1.13  nisimura 
     77       1.20   thorpej CFATTACH_DECL(le_ioasic, sizeof(struct le_softc),
     78       1.21   thorpej     le_ioasic_match, le_ioasic_attach, NULL, NULL);
     79       1.13  nisimura 
     80       1.22     perry static void le_ioasic_copytobuf_gap2(struct lance_softc *, void *, int, int);
     81       1.22     perry static void le_ioasic_copyfrombuf_gap2(struct lance_softc *, void *, int, int);
     82       1.22     perry static void le_ioasic_copytobuf_gap16(struct lance_softc *, void *, int, int);
     83       1.22     perry static void le_ioasic_copyfrombuf_gap16(struct lance_softc *, void *,
     84       1.22     perry 	    int, int);
     85       1.22     perry static void le_ioasic_zerobuf_gap16(struct lance_softc *, int, int);
     86        1.2   thorpej 
     87       1.16  nisimura static int
     88       1.27   thorpej le_ioasic_match(struct device *parent, struct cfdata *match, void *aux)
     89        1.1       cgd {
     90        1.1       cgd 	struct ioasicdev_attach_args *d = aux;
     91        1.1       cgd 
     92       1.16  nisimura 	if (strncmp("PMAD-BA ", d->iada_modname, TC_ROM_LLEN) != 0)
     93       1.16  nisimura 		return 0;
     94        1.1       cgd 
     95       1.16  nisimura 	return 1;
     96        1.1       cgd }
     97        1.1       cgd 
     98       1.16  nisimura /* IOASIC LANCE DMA needs 128KB boundary aligned 128KB chunk */
     99       1.16  nisimura #define	LE_IOASIC_MEMSIZE	(128*1024)
    100       1.16  nisimura #define	LE_IOASIC_MEMALIGN	(128*1024)
    101       1.16  nisimura 
    102       1.16  nisimura static void
    103       1.27   thorpej le_ioasic_attach(struct device *parent, struct device *self, void *aux)
    104        1.1       cgd {
    105       1.25   thorpej 	struct le_ioasic_softc *sc = device_private(self);
    106        1.1       cgd 	struct ioasicdev_attach_args *d = aux;
    107       1.16  nisimura 	struct lance_softc *le = &sc->sc_am7990.lsc;
    108       1.26   thorpej 	struct ioasic_softc *iosc = device_private(parent);
    109       1.16  nisimura 	bus_space_tag_t ioasic_bst;
    110       1.16  nisimura 	bus_space_handle_t ioasic_bsh;
    111       1.16  nisimura 	bus_dma_tag_t dmat;
    112       1.16  nisimura 	bus_dma_segment_t seg;
    113       1.16  nisimura 	tc_addr_t tca;
    114       1.16  nisimura 	u_int32_t ssr;
    115       1.16  nisimura 	int rseg;
    116  1.27.14.1     rmind 	void *le_iomem;
    117        1.1       cgd 
    118       1.26   thorpej 	ioasic_bst = iosc->sc_bst;
    119       1.26   thorpej 	ioasic_bsh = iosc->sc_bsh;
    120       1.26   thorpej 	dmat = sc->sc_dmat = iosc->sc_dmat;
    121       1.16  nisimura 	/*
    122       1.16  nisimura 	 * Allocate a DMA area for the chip.
    123       1.16  nisimura 	 */
    124       1.16  nisimura 	if (bus_dmamem_alloc(dmat, LE_IOASIC_MEMSIZE, LE_IOASIC_MEMALIGN,
    125       1.16  nisimura 	    0, &seg, 1, &rseg, BUS_DMA_NOWAIT)) {
    126       1.16  nisimura 		printf("can't allocate DMA area for LANCE\n");
    127       1.16  nisimura 		return;
    128       1.16  nisimura 	}
    129       1.16  nisimura 	if (bus_dmamem_map(dmat, &seg, rseg, LE_IOASIC_MEMSIZE,
    130       1.16  nisimura 	    &le_iomem, BUS_DMA_NOWAIT|BUS_DMA_COHERENT)) {
    131       1.16  nisimura 		printf("can't map DMA area for LANCE\n");
    132       1.16  nisimura 		bus_dmamem_free(dmat, &seg, rseg);
    133       1.13  nisimura 		return;
    134       1.13  nisimura 	}
    135       1.16  nisimura 	/*
    136       1.16  nisimura 	 * Create and load the DMA map for the DMA area.
    137       1.16  nisimura 	 */
    138       1.16  nisimura 	if (bus_dmamap_create(dmat, LE_IOASIC_MEMSIZE, 1,
    139       1.16  nisimura 	    LE_IOASIC_MEMSIZE, 0, BUS_DMA_NOWAIT, &sc->sc_dmamap)) {
    140       1.16  nisimura 		printf("can't create DMA map\n");
    141       1.16  nisimura 		goto bad;
    142       1.16  nisimura 	}
    143       1.16  nisimura 	if (bus_dmamap_load(dmat, sc->sc_dmamap,
    144       1.16  nisimura 	    le_iomem, LE_IOASIC_MEMSIZE, NULL, BUS_DMA_NOWAIT)) {
    145       1.16  nisimura 		printf("can't load DMA map\n");
    146       1.16  nisimura 		goto bad;
    147       1.16  nisimura 	}
    148       1.16  nisimura 	/*
    149       1.16  nisimura 	 * Bind 128KB buffer with IOASIC DMA.
    150       1.16  nisimura 	 */
    151       1.17   thorpej 	tca = IOASIC_DMA_ADDR(sc->sc_dmamap->dm_segs[0].ds_addr);
    152       1.16  nisimura 	bus_space_write_4(ioasic_bst, ioasic_bsh, IOASIC_LANCE_DMAPTR, tca);
    153       1.16  nisimura 	ssr = bus_space_read_4(ioasic_bst, ioasic_bsh, IOASIC_CSR);
    154       1.16  nisimura 	ssr |= IOASIC_CSR_DMAEN_LANCE;
    155       1.16  nisimura 	bus_space_write_4(ioasic_bst, ioasic_bsh, IOASIC_CSR, ssr);
    156       1.13  nisimura 
    157       1.16  nisimura 	sc->sc_r1 = (struct lereg1 *)
    158        1.1       cgd 		TC_DENSE_TO_SPARSE(TC_PHYS_TO_UNCACHED(d->iada_addr));
    159       1.16  nisimura 	le->sc_mem = (void *)TC_PHYS_TO_UNCACHED(le_iomem);
    160       1.16  nisimura 	le->sc_copytodesc = le_ioasic_copytobuf_gap2;
    161       1.16  nisimura 	le->sc_copyfromdesc = le_ioasic_copyfrombuf_gap2;
    162       1.16  nisimura 	le->sc_copytobuf = le_ioasic_copytobuf_gap16;
    163       1.16  nisimura 	le->sc_copyfrombuf = le_ioasic_copyfrombuf_gap16;
    164       1.16  nisimura 	le->sc_zerobuf = le_ioasic_zerobuf_gap16;
    165       1.16  nisimura 
    166       1.16  nisimura 	dec_le_common_attach(&sc->sc_am7990,
    167       1.26   thorpej 	    (u_char *)iosc->sc_base + IOASIC_SLOT_2_START);
    168        1.1       cgd 
    169        1.2   thorpej 	ioasic_intr_establish(parent, d->iada_cookie, TC_IPL_NET,
    170        1.2   thorpej 	    am7990_intr, sc);
    171       1.16  nisimura 	return;
    172       1.16  nisimura 
    173       1.16  nisimura  bad:
    174       1.16  nisimura 	bus_dmamem_unmap(dmat, le_iomem, LE_IOASIC_MEMSIZE);
    175       1.16  nisimura 	bus_dmamem_free(dmat, &seg, rseg);
    176        1.2   thorpej }
    177        1.2   thorpej 
    178        1.2   thorpej /*
    179        1.2   thorpej  * Special memory access functions needed by ioasic-attached LANCE
    180        1.2   thorpej  * chips.
    181        1.2   thorpej  */
    182        1.2   thorpej 
    183        1.2   thorpej /*
    184        1.2   thorpej  * gap2: two bytes of data followed by two bytes of pad.
    185        1.2   thorpej  *
    186        1.2   thorpej  * Buffers must be 4-byte aligned.  The code doesn't worry about
    187        1.2   thorpej  * doing an extra byte.
    188        1.2   thorpej  */
    189        1.2   thorpej 
    190        1.2   thorpej void
    191       1.27   thorpej le_ioasic_copytobuf_gap2(struct lance_softc *sc, void *fromv, int boff, int len)
    192        1.2   thorpej {
    193  1.27.14.1     rmind 	volatile void *buf = sc->sc_mem;
    194  1.27.14.1     rmind 	char *from = fromv;
    195       1.23     perry 	volatile u_int16_t *bptr;
    196        1.2   thorpej 
    197        1.2   thorpej 	if (boff & 0x1) {
    198        1.2   thorpej 		/* handle unaligned first byte */
    199        1.2   thorpej 		bptr = ((volatile u_int16_t *)buf) + (boff - 1);
    200        1.2   thorpej 		*bptr = (*from++ << 8) | (*bptr & 0xff);
    201       1.23     perry 		bptr += 2;
    202        1.2   thorpej 		len--;
    203        1.2   thorpej 	} else
    204        1.2   thorpej 		bptr = ((volatile u_int16_t *)buf) + boff;
    205        1.2   thorpej 	while (len > 1) {
    206        1.2   thorpej 		*bptr = (from[1] << 8) | (from[0] & 0xff);
    207        1.2   thorpej 		bptr += 2;
    208        1.2   thorpej 		from += 2;
    209        1.2   thorpej 		len -= 2;
    210        1.2   thorpej 	}
    211        1.2   thorpej 	if (len == 1)
    212        1.2   thorpej 		*bptr = (u_int16_t)*from;
    213        1.2   thorpej }
    214        1.2   thorpej 
    215        1.2   thorpej void
    216       1.27   thorpej le_ioasic_copyfrombuf_gap2(struct lance_softc *sc, void *tov, int boff, int len)
    217        1.2   thorpej {
    218  1.27.14.1     rmind 	volatile void *buf = sc->sc_mem;
    219  1.27.14.1     rmind 	char *to = tov;
    220       1.15  augustss 	volatile u_int16_t *bptr;
    221       1.15  augustss 	u_int16_t tmp;
    222        1.2   thorpej 
    223        1.2   thorpej 	if (boff & 0x1) {
    224        1.2   thorpej 		/* handle unaligned first byte */
    225        1.2   thorpej 		bptr = ((volatile u_int16_t *)buf) + (boff - 1);
    226        1.2   thorpej 		*to++ = (*bptr >> 8) & 0xff;
    227        1.2   thorpej 		bptr += 2;
    228        1.2   thorpej 		len--;
    229        1.2   thorpej 	} else
    230        1.2   thorpej 		bptr = ((volatile u_int16_t *)buf) + boff;
    231        1.2   thorpej 	while (len > 1) {
    232        1.2   thorpej 		tmp = *bptr;
    233        1.2   thorpej 		*to++ = tmp & 0xff;
    234        1.2   thorpej 		*to++ = (tmp >> 8) & 0xff;
    235        1.2   thorpej 		bptr += 2;
    236        1.2   thorpej 		len -= 2;
    237        1.2   thorpej 	}
    238        1.2   thorpej 	if (len == 1)
    239        1.2   thorpej 		*to = *bptr & 0xff;
    240        1.2   thorpej }
    241        1.2   thorpej 
    242        1.2   thorpej /*
    243        1.2   thorpej  * gap16: 16 bytes of data followed by 16 bytes of pad.
    244        1.2   thorpej  *
    245        1.2   thorpej  * Buffers must be 32-byte aligned.
    246        1.2   thorpej  */
    247        1.2   thorpej 
    248        1.2   thorpej void
    249       1.27   thorpej le_ioasic_copytobuf_gap16(struct lance_softc *sc, void *fromv, int boff,
    250       1.27   thorpej     int len)
    251        1.2   thorpej {
    252  1.27.14.1     rmind 	char *buf = (char *)sc->sc_mem;
    253  1.27.14.1     rmind 	char *from = fromv;
    254  1.27.14.1     rmind 	char *bptr;
    255        1.2   thorpej 
    256        1.2   thorpej 	bptr = buf + ((boff << 1) & ~0x1f);
    257        1.2   thorpej 	boff &= 0xf;
    258        1.8  jonathan 
    259        1.8  jonathan 	/*
    260        1.8  jonathan 	 * Dispose of boff so destination of subsequent copies is
    261        1.8  jonathan 	 * 16-byte aligned.
    262        1.8  jonathan 	 */
    263        1.8  jonathan 	if (boff) {
    264       1.15  augustss 		int xfer;
    265        1.8  jonathan 		xfer = min(len, 16 - boff);
    266        1.2   thorpej 		bcopy(from, bptr + boff, xfer);
    267        1.2   thorpej 		from += xfer;
    268        1.2   thorpej 		bptr += 32;
    269        1.2   thorpej 		len -= xfer;
    270        1.2   thorpej 	}
    271        1.8  jonathan 
    272        1.8  jonathan 	/* Destination of  copies is now 16-byte aligned. */
    273        1.8  jonathan 	if (len >= 16)
    274        1.8  jonathan 		switch ((u_long)from & (sizeof(u_int32_t) -1)) {
    275        1.8  jonathan 		case 2:
    276        1.8  jonathan 			/*  Ethernet headers make this the dominant case. */
    277        1.8  jonathan 		do {
    278       1.15  augustss 			u_int32_t *dst = (u_int32_t*)bptr;
    279       1.15  augustss 			u_int16_t t0;
    280       1.15  augustss 			u_int32_t t1,  t2, t3, t4;
    281        1.8  jonathan 
    282        1.8  jonathan 			/* read from odd-16-bit-aligned, cached src */
    283        1.8  jonathan 			t0 = *(u_int16_t*)from;
    284        1.8  jonathan 			t1 = *(u_int32_t*)(from+2);
    285        1.8  jonathan 			t2 = *(u_int32_t*)(from+6);
    286        1.8  jonathan 			t3 = *(u_int32_t*)(from+10);
    287        1.8  jonathan 			t4 = *(u_int16_t*)(from+14);
    288        1.8  jonathan 
    289        1.8  jonathan 			/* DMA buffer is uncached on mips */
    290        1.8  jonathan 			dst[0] =         t0 |  (t1 << 16);
    291        1.8  jonathan 			dst[1] = (t1 >> 16) |  (t2 << 16);
    292        1.8  jonathan 			dst[2] = (t2 >> 16) |  (t3 << 16);
    293        1.8  jonathan 			dst[3] = (t3 >> 16) |  (t4 << 16);
    294        1.8  jonathan 
    295        1.8  jonathan 			from += 16;
    296        1.8  jonathan 			bptr += 32;
    297        1.8  jonathan 			len -= 16;
    298        1.8  jonathan 		} while (len >= 16);
    299        1.8  jonathan 		break;
    300        1.8  jonathan 
    301        1.8  jonathan 		case 0:
    302        1.8  jonathan 		do {
    303       1.15  augustss 			u_int32_t *src = (u_int32_t*)from;
    304       1.15  augustss 			u_int32_t *dst = (u_int32_t*)bptr;
    305       1.15  augustss 			u_int32_t t0, t1, t2, t3;
    306        1.8  jonathan 
    307        1.8  jonathan 			t0 = src[0]; t1 = src[1]; t2 = src[2]; t3 = src[3];
    308        1.8  jonathan 			dst[0] = t0; dst[1] = t1; dst[2] = t2; dst[3] = t3;
    309        1.8  jonathan 
    310        1.8  jonathan 			from += 16;
    311        1.8  jonathan 			bptr += 32;
    312        1.8  jonathan 			len -= 16;
    313        1.8  jonathan 		} while (len >= 16);
    314        1.8  jonathan 		break;
    315        1.8  jonathan 
    316       1.23     perry 		default:
    317        1.8  jonathan 		/* Does odd-aligned case ever happen? */
    318        1.8  jonathan 		do {
    319        1.8  jonathan 			bcopy(from, bptr, 16);
    320        1.8  jonathan 			from += 16;
    321        1.8  jonathan 			bptr += 32;
    322        1.8  jonathan 			len -= 16;
    323        1.8  jonathan 		} while (len >= 16);
    324        1.8  jonathan 		break;
    325        1.8  jonathan 	}
    326        1.8  jonathan 	if (len)
    327        1.8  jonathan 		bcopy(from, bptr, len);
    328        1.2   thorpej }
    329        1.2   thorpej 
    330        1.2   thorpej void
    331       1.27   thorpej le_ioasic_copyfrombuf_gap16(struct lance_softc *sc, void *tov, int boff,
    332       1.27   thorpej     int len)
    333        1.2   thorpej {
    334  1.27.14.1     rmind 	char *buf = sc->sc_mem;
    335  1.27.14.1     rmind 	char *to = tov;
    336  1.27.14.1     rmind 	char *bptr;
    337        1.2   thorpej 
    338        1.2   thorpej 	bptr = buf + ((boff << 1) & ~0x1f);
    339        1.2   thorpej 	boff &= 0xf;
    340        1.8  jonathan 
    341        1.8  jonathan 	/* Dispose of boff. source of copy is subsequently 16-byte aligned. */
    342        1.8  jonathan 	if (boff) {
    343       1.15  augustss 		int xfer;
    344        1.8  jonathan 		xfer = min(len, 16 - boff);
    345        1.8  jonathan 		bcopy(bptr+boff, to, xfer);
    346        1.2   thorpej 		to += xfer;
    347        1.2   thorpej 		bptr += 32;
    348        1.2   thorpej 		len -= xfer;
    349        1.2   thorpej 	}
    350        1.8  jonathan 	if (len >= 16)
    351        1.8  jonathan 	switch ((u_long)to & (sizeof(u_int32_t) -1)) {
    352        1.8  jonathan 	case 2:
    353        1.8  jonathan 		/*
    354        1.8  jonathan 		 * to is aligned to an odd 16-bit boundary.  Ethernet headers
    355        1.8  jonathan 		 * make this the dominant case (98% or more).
    356        1.8  jonathan 		 */
    357        1.8  jonathan 		do {
    358       1.15  augustss 			u_int32_t *src = (u_int32_t*)bptr;
    359       1.15  augustss 			u_int32_t t0, t1, t2, t3;
    360        1.8  jonathan 
    361        1.8  jonathan 			/* read from uncached aligned DMA buf */
    362        1.8  jonathan 			t0 = src[0]; t1 = src[1]; t2 = src[2]; t3 = src[3];
    363        1.8  jonathan 
    364        1.8  jonathan 			/* write to odd-16-bit-word aligned dst */
    365        1.8  jonathan 			*(u_int16_t *) (to+0)  = (u_short)  t0;
    366        1.8  jonathan 			*(u_int32_t *) (to+2)  = (t0 >> 16) |  (t1 << 16);
    367        1.8  jonathan 			*(u_int32_t *) (to+6)  = (t1 >> 16) |  (t2 << 16);
    368        1.8  jonathan 			*(u_int32_t *) (to+10) = (t2 >> 16) |  (t3 << 16);
    369        1.8  jonathan 			*(u_int16_t *) (to+14) = (t3 >> 16);
    370        1.8  jonathan 			bptr += 32;
    371        1.8  jonathan 			to += 16;
    372        1.8  jonathan 			len -= 16;
    373        1.8  jonathan 		} while (len > 16);
    374        1.8  jonathan 		break;
    375        1.8  jonathan 	case 0:
    376        1.8  jonathan 		/* 32-bit aligned aligned copy. Rare. */
    377        1.8  jonathan 		do {
    378       1.15  augustss 			u_int32_t *src = (u_int32_t*)bptr;
    379       1.15  augustss 			u_int32_t *dst = (u_int32_t*)to;
    380       1.15  augustss 			u_int32_t t0, t1, t2, t3;
    381        1.8  jonathan 
    382        1.8  jonathan 			t0 = src[0]; t1 = src[1]; t2 = src[2]; t3 = src[3];
    383        1.8  jonathan 			dst[0] = t0; dst[1] = t1; dst[2] = t2; dst[3] = t3;
    384        1.8  jonathan 			to += 16;
    385        1.8  jonathan 			bptr += 32;
    386        1.8  jonathan 			len -= 16;
    387        1.8  jonathan 		} while (len  > 16);
    388        1.8  jonathan 		break;
    389        1.8  jonathan 
    390        1.8  jonathan 	/* XXX Does odd-byte-aligned case ever happen? */
    391        1.8  jonathan 	default:
    392        1.8  jonathan 		do {
    393        1.8  jonathan 			bcopy(bptr, to, 16);
    394        1.8  jonathan 			to += 16;
    395        1.8  jonathan 			bptr += 32;
    396        1.8  jonathan 			len -= 16;
    397        1.8  jonathan 		} while (len  > 16);
    398        1.8  jonathan 		break;
    399        1.8  jonathan 	}
    400        1.8  jonathan 	if (len)
    401        1.8  jonathan 		bcopy(bptr, to, len);
    402        1.2   thorpej }
    403        1.2   thorpej 
    404        1.2   thorpej void
    405       1.27   thorpej le_ioasic_zerobuf_gap16(struct lance_softc *sc, int boff, int len)
    406        1.2   thorpej {
    407  1.27.14.1     rmind 	char *buf = sc->sc_mem;
    408  1.27.14.1     rmind 	char *bptr;
    409       1.15  augustss 	int xfer;
    410        1.2   thorpej 
    411        1.2   thorpej 	bptr = buf + ((boff << 1) & ~0x1f);
    412        1.2   thorpej 	boff &= 0xf;
    413        1.2   thorpej 	xfer = min(len, 16 - boff);
    414        1.2   thorpej 	while (len > 0) {
    415        1.2   thorpej 		bzero(bptr + boff, xfer);
    416        1.2   thorpej 		bptr += 32;
    417        1.2   thorpej 		boff = 0;
    418        1.2   thorpej 		len -= xfer;
    419        1.2   thorpej 		xfer = min(len, 16);
    420        1.2   thorpej 	}
    421        1.1       cgd }
    422