Module Name: src Committed By: martin Date: Tue Oct 27 21:47:23 UTC 2009
Modified Files: src/sys/dev/pci: ifpci2.c Log Message: Fix endianess issues when accessing the B-channel fifos. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/dev/pci/ifpci2.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/dev/pci/ifpci2.c diff -u src/sys/dev/pci/ifpci2.c:1.16 src/sys/dev/pci/ifpci2.c:1.17 --- src/sys/dev/pci/ifpci2.c:1.16 Tue May 12 08:23:01 2009 +++ src/sys/dev/pci/ifpci2.c Tue Oct 27 21:47:23 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: ifpci2.c,v 1.16 2009/05/12 08:23:01 cegger Exp $ */ +/* $NetBSD: ifpci2.c,v 1.17 2009/10/27 21:47:23 martin Exp $ */ /* * Copyright (c) 1999 Gary Jennejohn. All rights reserved. * @@ -36,14 +36,14 @@ * Fritz!Card PCI driver * ------------------------------------------------ * - * $Id: ifpci2.c,v 1.16 2009/05/12 08:23:01 cegger Exp $ + * $Id: ifpci2.c,v 1.17 2009/10/27 21:47:23 martin Exp $ * * last edit-date: [Fri Jan 5 11:38:58 2001] * *---------------------------------------------------------------------------*/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ifpci2.c,v 1.16 2009/05/12 08:23:01 cegger Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ifpci2.c,v 1.17 2009/10/27 21:47:23 martin Exp $"); #include <sys/param.h> @@ -418,20 +418,19 @@ static void hscx_read_fifo(int chan, void *buf, size_t len, struct isic_softc *sc) { - u_int32_t *ip; - size_t cnt; - int dataoff; + int dataoff; dataoff = chan ? HSCX_FIFO2 : HSCX_FIFO1; - - ip = (u_int32_t *)buf; - cnt = 0; - /* what if len isn't a multiple of sizeof(int) and buf is */ - /* too small ???? */ - while (cnt < len) - { - *ip++ = bus_space_read_4(sc->sc_maps[0].t, sc->sc_maps[0].h, dataoff); - cnt += 4; + bus_space_read_multi_stream_4(sc->sc_maps[0].t, sc->sc_maps[0].h, + dataoff, buf, len/4); + if (__predict_false((len&3)>0)) { + uint32_t tmp; + + buf = ((unsigned char*)buf) + (len & ~3u); + len &= 3u; + tmp = bus_space_read_stream_4(sc->sc_maps[0].t, + sc->sc_maps[0].h, dataoff); + memcpy(buf, &tmp, len); } } @@ -463,7 +462,6 @@ static void hscx_write_fifo(int chan, const void *buf, size_t len, struct isic_softc *sc) { - const u_int32_t *ip; size_t cnt; int dataoff; l1_bchan_state_t *Bchan = &sc->sc_chan[chan]; @@ -484,13 +482,17 @@ AVMA1PPSETCMDLONG(cnt); hscx_write_reg(chan, cnt, sc); - ip = (const u_int32_t *)buf; - cnt = 0; - while (cnt < len) - { - bus_space_write_4(sc->sc_maps[0].t, sc->sc_maps[0].h, dataoff, *ip); - ip++; - cnt += 4; + bus_space_write_multi_stream_4(sc->sc_maps[0].t, sc->sc_maps[0].h, + dataoff, buf, (len+3)/4); + if (__predict_false((len&3)>0)) { + uint32_t tmp; + + buf = (const unsigned char*)buf + (len & ~3u); + len &= 3u; + memset(&tmp, 0, sizeof(tmp)); + memcpy(&tmp, buf, len); + bus_space_write_stream_4(sc->sc_maps[0].t, sc->sc_maps[0].h, + dataoff, tmp); } }