Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci Fix endianess issues when accessing the B-channe...
details: https://anonhg.NetBSD.org/src/rev/0118321e83f1
branches: trunk
changeset: 748576:0118321e83f1
user: martin <martin%NetBSD.org@localhost>
date: Tue Oct 27 21:47:23 2009 +0000
description:
Fix endianess issues when accessing the B-channel fifos.
diffstat:
sys/dev/pci/ifpci2.c | 46 ++++++++++++++++++++++++----------------------
1 files changed, 24 insertions(+), 22 deletions(-)
diffs (90 lines):
diff -r f3333008250d -r 0118321e83f1 sys/dev/pci/ifpci2.c
--- a/sys/dev/pci/ifpci2.c Tue Oct 27 20:14:11 2009 +0000
+++ b/sys/dev/pci/ifpci2.c Tue Oct 27 21:47:23 2009 +0000
@@ -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;
+ 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;
- 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;
+ 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);
}
}
Home |
Main Index |
Thread Index |
Old Index