Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-6]: src/sys/dev/pci Pull up revision 1.7 (requested by tron in ...



details:   https://anonhg.NetBSD.org/src/rev/325edec173ba
branches:  netbsd-1-6
changeset: 530288:325edec173ba
user:      grant <grant%NetBSD.org@localhost>
date:      Mon Jun 16 13:20:48 2003 +0000

description:
Pull up revision 1.7 (requested by tron in ticket #1249):

FreeBSD fix for problems reported (to FreeBSD) with 16-bit accesses
to 32-bit device registers. Add (untested) NetBSD fix for big-endian hosts.
>From FreeBSD versions:
        if_bge.c:       1.26 and 1.27
        if_bgereg.h: 1.12

FreeBSD (MFC) comment:

MFC:  Avoid 16-bit accesses to device memory.  Use volatile where
appropriate in referencing device memory.  Parenthesize BGE_HOSTADDR
define properly.

diffstat:

 sys/dev/pci/if_bgereg.h |  28 +++++++++-------------------
 1 files changed, 9 insertions(+), 19 deletions(-)

diffs (56 lines):

diff -r 240544db8ab9 -r 325edec173ba sys/dev/pci/if_bgereg.h
--- a/sys/dev/pci/if_bgereg.h   Mon Jun 16 13:20:21 2003 +0000
+++ b/sys/dev/pci/if_bgereg.h   Mon Jun 16 13:20:48 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_bgereg.h,v 1.6.2.2 2003/01/28 06:20:12 jmc Exp $    */
+/*     $NetBSD: if_bgereg.h,v 1.6.2.3 2003/06/16 13:20:48 grant Exp $  */
 /*
  * Copyright (c) 2001 Wind River Systems
  * Copyright (c) 1997, 1998, 1999, 2001
@@ -1699,7 +1699,7 @@
 #define BGE_HOSTADDR(x)        (x).bge_addr_lo
 
 static __inline void
-bge_set_hostaddr(bge_hostaddr *x, bus_addr_t y)
+bge_set_hostaddr(volatile bge_hostaddr *x, bus_addr_t y)
 {
        x->bge_addr_lo = y & 0xffffffff;
        if (sizeof (bus_addr_t) == 8)
@@ -1711,30 +1711,20 @@
 /* Ring control block structure */
 struct bge_rcb {
        bge_hostaddr            bge_hostaddr;
-#if BYTE_ORDER == BIG_ENDIAN
-       u_int16_t               bge_max_len;
-       u_int16_t               bge_flags;
-#else
-       u_int16_t               bge_flags;
-       u_int16_t               bge_max_len;
-#endif
+       u_int32_t               bge_maxlen_flags;       /* two 16-bit fields */
        u_int32_t               bge_nicaddr;
 };
 
+#if BYTE_ORDER == BIG_ENDIAN
+#define        BGE_RCB_MAXLEN_FLAGS(maxlen, flags)     ((flags) << 16 | (maxlen))
+#else
+#define        BGE_RCB_MAXLEN_FLAGS(maxlen, flags)     ((maxlen) << 16 | (flags))
+#endif
+
 #define RCB_WRITE_4(sc, rcb, offset, val) \
        bus_space_write_4(sc->bge_btag, sc->bge_bhandle, \
                          rcb + offsetof(struct bge_rcb, offset), val)
 
-#define RCB_WRITE_2(sc, rcb, offset, val) \
-       bus_space_write_2(sc->bge_btag, sc->bge_bhandle, \
-                         rcb + offsetof(struct bge_rcb, offset), val)
-
-struct bge_rcb_opaque {
-       u_int32_t               bge_reg0;
-       u_int32_t               bge_reg1;
-       u_int32_t               bge_reg2;
-       u_int32_t               bge_reg3;
-};
 
 #define BGE_RCB_FLAG_USE_EXT_RX_BD     0x0001
 #define BGE_RCB_FLAG_RING_DISABLED     0x0002



Home | Main Index | Thread Index | Old Index