Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Change the semantics of `sc_regshift'; it is now the...



details:   https://anonhg.NetBSD.org/src/rev/d48db28992b9
branches:  trunk
changeset: 476349:d48db28992b9
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Tue Sep 14 05:52:21 1999 +0000

description:
Change the semantics of `sc_regshift'; it is now the shift required to
make a CSR index number into a CSR offset.  Introduce a couple of macros
to handle CSR name -> offset conversion.

diffstat:

 sys/dev/ic/tulip.c       |  9 ++++++---
 sys/dev/ic/tulipreg.h    |  4 +++-
 sys/dev/ic/tulipvar.h    |  9 ++++++---
 sys/dev/pci/if_tlp_pci.c |  9 +++++++--
 4 files changed, 22 insertions(+), 9 deletions(-)

diffs (100 lines):

diff -r 9778d4b0c7f9 -r d48db28992b9 sys/dev/ic/tulip.c
--- a/sys/dev/ic/tulip.c        Tue Sep 14 05:04:21 1999 +0000
+++ b/sys/dev/ic/tulip.c        Tue Sep 14 05:52:21 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tulip.c,v 1.7 1999/09/14 00:55:38 thorpej Exp $        */
+/*     $NetBSD: tulip.c,v 1.8 1999/09/14 05:52:21 thorpej Exp $        */
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -1486,13 +1486,16 @@
         */
        switch (sc->sc_chip) {
        case TULIP_CHIP_WB89C840F:
+           {
                /* XXX Do this with stream writes? */
+               bus_addr_t cpa = TULIP_CSR_OFFSET(sc, CSR_WINB_CPA0);
+
                for (i = 0; i < ETHER_ADDR_LEN; i++) {
                        bus_space_write_1(sc->sc_st, sc->sc_sh,
-                           (CSR_WINB_CPA0 >> sc->sc_regshift) + i,
-                           LLADDR(ifp->if_sadl)[i]);
+                           cpa + i, LLADDR(ifp->if_sadl)[i]);
                }
                break;
+           }
 
        default:
                /* Nothing. */
diff -r 9778d4b0c7f9 -r d48db28992b9 sys/dev/ic/tulipreg.h
--- a/sys/dev/ic/tulipreg.h     Tue Sep 14 05:04:21 1999 +0000
+++ b/sys/dev/ic/tulipreg.h     Tue Sep 14 05:52:21 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tulipreg.h,v 1.4 1999/09/14 00:55:39 thorpej Exp $     */
+/*     $NetBSD: tulipreg.h,v 1.5 1999/09/14 05:52:22 thorpej Exp $     */
 
 /*-
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -289,6 +289,8 @@
 #define        TULIP_CSR19     0x98
 #define        TULIP_CSR20     0xa0
 
+#define        TULIP_CSR_INDEX(csr)    ((csr) >> 3)
+
 /* CSR0 - Bus Mode */
 #define        CSR_BUSMODE             TULIP_CSR0
 #define        BUSMODE_SWR             0x00000001      /* software reset */
diff -r 9778d4b0c7f9 -r d48db28992b9 sys/dev/ic/tulipvar.h
--- a/sys/dev/ic/tulipvar.h     Tue Sep 14 05:04:21 1999 +0000
+++ b/sys/dev/ic/tulipvar.h     Tue Sep 14 05:52:21 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tulipvar.h,v 1.7 1999/09/14 00:55:38 thorpej Exp $     */
+/*     $NetBSD: tulipvar.h,v 1.8 1999/09/14 05:52:22 thorpej Exp $     */
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -358,13 +358,16 @@
 } while (0)
 
 /* CSR access */
+#define        TULIP_CSR_OFFSET(sc, csr)                                       \
+       (TULIP_CSR_INDEX(csr) << (sc)->sc_regshift)
+
 #define        TULIP_READ(sc, reg)                                             \
        bus_space_read_4((sc)->sc_st, (sc)->sc_sh,                      \
-           (reg) >> (sc)->sc_regshift)
+           TULIP_CSR_OFFSET((sc), (reg)))
 
 #define        TULIP_WRITE(sc, reg, val)                                       \
        bus_space_write_4((sc)->sc_st, (sc)->sc_sh,                     \
-           (reg) >> (sc)->sc_regshift, (val))
+           TULIP_CSR_OFFSET((sc), (reg)), (val))
 
 #define        TULIP_SET(sc, reg, mask)                                        \
        TULIP_WRITE((sc), (reg), TULIP_READ((sc), (reg)) | (mask))
diff -r 9778d4b0c7f9 -r d48db28992b9 sys/dev/pci/if_tlp_pci.c
--- a/sys/dev/pci/if_tlp_pci.c  Tue Sep 14 05:04:21 1999 +0000
+++ b/sys/dev/pci/if_tlp_pci.c  Tue Sep 14 05:52:21 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_tlp_pci.c,v 1.5 1999/09/14 00:55:39 thorpej Exp $   */
+/*     $NetBSD: if_tlp_pci.c,v 1.6 1999/09/14 05:52:23 thorpej Exp $   */
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -254,10 +254,15 @@
        sc->sc_chip = tpp->tpp_chip;
 
        /*
+        * By default, Tulip registers are 8 bytes long (4 bytes
+        * followed by a 4 byte pad).
+        */
+       sc->sc_regshift = 3;
+
+       /*
         * Get revision info, and set some chip-specific variables.
         */
        sc->sc_rev = PCI_REVISION(pa->pa_class);
-       sc->sc_regshift = 0;
        switch (sc->sc_chip) {
        case TULIP_CHIP_21140:
                if (sc->sc_rev >= 0x20)



Home | Main Index | Thread Index | Old Index