Source-Changes-HG archive

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

[src/netbsd-1-5]: src/sys/arch/mac68k Pullups approved by thorpej --



details:   https://anonhg.NetBSD.org/src/rev/c5551c40ad84
branches:  netbsd-1-5
changeset: 488890:c5551c40ad84
user:      briggs <briggs%NetBSD.org@localhost>
date:      Sun Aug 06 02:08:01 2000 +0000

description:
Pullups approved by thorpej --
Add byte-swap and stride options to bus_space.  Allocate as normal, then
call mac68k_bus_space_handle_swapped() or mac68k_bus_space_handle_set_stride().
Stride is untested.  Swapped code works for SMC ethernet.

Add bus_space_*_stream_N functions to bus_space.

Add a DIAGNOSTIC panic if (count-using) bus_space macros are called with
a count of zero.  Some drivers do this accidentally and some bus_space
implementations will fail if count is passed as zero (they are set up in
a do-{}-while structure).

There were some bogus assumptions about bus_space_handle_t and some
function calls that didn't match prototypes--fix those here, too.

diffstat:

 sys/arch/mac68k/dev/if_ae.c        |    11 +-
 sys/arch/mac68k/include/bus.h      |   704 +++++++++++++++--------
 sys/arch/mac68k/mac68k/bus_space.c |  1063 +++++++++++++++++++++++++++++++++++-
 sys/arch/mac68k/nubus/grf_nubus.c  |     8 +-
 sys/arch/mac68k/obio/asc.c         |     5 +-
 sys/arch/mac68k/obio/grf_obio.c    |     6 +-
 6 files changed, 1517 insertions(+), 280 deletions(-)

diffs (truncated from 2045 to 300 lines):

diff -r f4edaa8cd43e -r c5551c40ad84 sys/arch/mac68k/dev/if_ae.c
--- a/sys/arch/mac68k/dev/if_ae.c       Sun Aug 06 02:02:46 2000 +0000
+++ b/sys/arch/mac68k/dev/if_ae.c       Sun Aug 06 02:08:01 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_ae.c,v 1.67 1998/01/12 19:22:07 thorpej Exp $       */
+/*     $NetBSD: if_ae.c,v 1.67.26.1 2000/08/06 02:08:01 briggs Exp $   */
 
 /*
  * Device driver for National Semiconductor DS8390/WD83C690 based ethernet
@@ -113,9 +113,12 @@
        int buf;
 {
        u_char *data, savebyte[2];
+       u_int16_t *pshort;
        int len, wantbyte;
        u_short totlen = 0;
 
+       pshort = (u_int16_t *) &savebyte[0];
+
        wantbyte = 0;
 
        for (; m ; m = m->m_next) {
@@ -127,7 +130,7 @@
                        if (wantbyte) {
                                savebyte[1] = *data;
                                bus_space_write_region_2(sc->sc_buft,
-                                   sc->sc_bufh, buf, savebyte, 1);
+                                   sc->sc_bufh, buf, pshort, 1);
                                buf += 2;
                                data++;
                                len--;
@@ -136,7 +139,7 @@
                        /* Output contiguous words. */
                        if (len > 1) {
                                bus_space_write_region_2(sc->sc_buft,
-                                   sc->sc_bufh, buf, data, len >> 1);
+                                   sc->sc_bufh, buf, pshort, len >> 1);
                                buf += len & ~1;
                                data += len & ~1;
                                len &= 1;
@@ -152,7 +155,7 @@
        if (wantbyte) {
                savebyte[1] = 0;
                bus_space_write_region_2(sc->sc_buft, sc->sc_bufh,
-                   buf, savebyte, 1);
+                   buf, pshort, 1);
        }
        return (totlen);
 }
diff -r f4edaa8cd43e -r c5551c40ad84 sys/arch/mac68k/include/bus.h
--- a/sys/arch/mac68k/include/bus.h     Sun Aug 06 02:02:46 2000 +0000
+++ b/sys/arch/mac68k/include/bus.h     Sun Aug 06 02:08:01 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus.h,v 1.13 2000/01/25 22:13:22 drochner Exp $        */
+/*     $NetBSD: bus.h,v 1.13.4.1 2000/08/06 02:08:03 briggs Exp $      */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -80,8 +80,104 @@
 /*
  * Access methods for bus resources and address space.
  */
+#define BSH_T  struct bus_space_handle_s
 typedef int    bus_space_tag_t;
-typedef u_long bus_space_handle_t;
+typedef struct bus_space_handle_s {
+       u_long  base;
+       int     swapped;
+       int     stride;
+       
+       u_int8_t        (*bsr1) __P((bus_space_tag_t t,
+                                       BSH_T *h, bus_size_t o));
+       u_int16_t       (*bsr2) __P((bus_space_tag_t t,
+                                       BSH_T *h, bus_size_t o));
+       u_int32_t       (*bsr4) __P((bus_space_tag_t t,
+                                       BSH_T *h, bus_size_t o));
+       u_int8_t        (*bsrs1) __P((bus_space_tag_t t,
+                                       BSH_T *h, bus_size_t o));
+       u_int16_t       (*bsrs2) __P((bus_space_tag_t t,
+                                       BSH_T *h, bus_size_t o));
+       u_int32_t       (*bsrs4) __P((bus_space_tag_t t,
+                                       BSH_T *h, bus_size_t o));
+       void            (*bsrm1) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int8_t *a, size_t c));
+       void            (*bsrm2) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int16_t *a, size_t c));
+       void            (*bsrm4) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int32_t *a, size_t c));
+       void            (*bsrms1) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int8_t *a, size_t c));
+       void            (*bsrms2) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int16_t *a, size_t c));
+       void            (*bsrms4) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int32_t *a, size_t c));
+       void            (*bsrr1) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int8_t *a, size_t c));
+       void            (*bsrr2) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int16_t *a, size_t c));
+       void            (*bsrr4) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int32_t *a, size_t c));
+       void            (*bsrrs1) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int8_t *a, size_t c));
+       void            (*bsrrs2) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int16_t *a, size_t c));
+       void            (*bsrrs4) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int32_t *a, size_t c));
+       void            (*bsw1) __P((bus_space_tag_t t, BSH_T *h,
+                                 bus_size_t o, u_int8_t v));
+       void            (*bsw2) __P((bus_space_tag_t t, BSH_T *h,
+                                 bus_size_t o, u_int16_t v));
+       void            (*bsw4) __P((bus_space_tag_t t, BSH_T *h,
+                                 bus_size_t o, u_int32_t v));
+       void            (*bsws1) __P((bus_space_tag_t t, BSH_T *h,
+                                 bus_size_t o, u_int8_t v));
+       void            (*bsws2) __P((bus_space_tag_t t, BSH_T *h,
+                                 bus_size_t o, u_int16_t v));
+       void            (*bsws4) __P((bus_space_tag_t t, BSH_T *h,
+                                 bus_size_t o, u_int32_t v));
+       void            (*bswm1) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int8_t *a, size_t c));
+       void            (*bswm2) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int16_t *a, size_t c));
+       void            (*bswm4) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int32_t *a, size_t c));
+       void            (*bswms1) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int8_t *a, size_t c));
+       void            (*bswms2) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int16_t *a, size_t c));
+       void            (*bswms4) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int32_t *a, size_t c));
+       void            (*bswr1) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int8_t *a, size_t c));
+       void            (*bswr2) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int16_t *a, size_t c));
+       void            (*bswr4) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int32_t *a, size_t c));
+       void            (*bswrs1) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int8_t *a, size_t c));
+       void            (*bswrs2) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int16_t *a, size_t c));
+       void            (*bswrs4) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int32_t *a, size_t c));
+       void            (*bssm1) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int8_t v, size_t c));
+       void            (*bssm2) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int16_t v, size_t c));
+       void            (*bssm4) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int32_t v, size_t c));
+       void            (*bssr1) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int8_t v, size_t c));
+       void            (*bssr2) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int16_t v, size_t c));
+       void            (*bssr4) __P((bus_space_tag_t t, BSH_T *h,
+                                  bus_size_t o, u_int32_t v, size_t c));
+} bus_space_handle_t;
+#undef BSH_T
+
+void   mac68k_bus_space_handle_swapped __P((bus_space_tag_t t,
+               bus_space_handle_t *h));
+void   mac68k_bus_space_handle_set_stride __P((bus_space_tag_t t,
+               bus_space_handle_t *h, int stride));
 
 /*
  *     int bus_space_map __P((bus_space_tag_t t, bus_addr_t addr,
@@ -162,17 +258,38 @@
  * described by tag/handle/offset.
  */
 
-#define        bus_space_read_1(t, h, o)                                       \
-    ((void) t, (*(volatile u_int8_t *)((h) + (o))))
+u_int8_t mac68k_bsr1 __P((bus_space_tag_t tag, bus_space_handle_t *bsh,
+                          bus_size_t offset));
+u_int8_t mac68k_bsr1_gen __P((bus_space_tag_t tag, bus_space_handle_t *bsh,
+                          bus_size_t offset));
+u_int16_t mac68k_bsr2 __P((bus_space_tag_t tag, bus_space_handle_t *bsh,
+                          bus_size_t offset));
+u_int16_t mac68k_bsr2_swap __P((bus_space_tag_t tag, bus_space_handle_t *bsh,
+                               bus_size_t offset));
+u_int16_t mac68k_bsr2_gen __P((bus_space_tag_t tag, bus_space_handle_t *bsh,
+                               bus_size_t offset));
+u_int16_t mac68k_bsrs2_gen __P((bus_space_tag_t tag, bus_space_handle_t *bsh,
+                               bus_size_t offset));
+u_int32_t mac68k_bsr4 __P((bus_space_tag_t tag, bus_space_handle_t *bsh,
+                          bus_size_t offset));
+u_int32_t mac68k_bsr4_swap __P((bus_space_tag_t tag, bus_space_handle_t *bsh,
+                               bus_size_t offset));
+u_int32_t mac68k_bsr4_gen __P((bus_space_tag_t tag, bus_space_handle_t *bsh,
+                               bus_size_t offset));
+u_int32_t mac68k_bsrs4_gen __P((bus_space_tag_t tag, bus_space_handle_t *bsh,
+                               bus_size_t offset));
 
-#define        bus_space_read_2(t, h, o)                                       \
-    ((void) t, (*(volatile u_int16_t *)((h) + (o))))
-
-#define        bus_space_read_4(t, h, o)                                       \
-    ((void) t, (*(volatile u_int32_t *)((h) + (o))))
+#define        bus_space_read_1(t,h,o) (h).bsr1((t), &(h), (o))
+#define        bus_space_read_2(t,h,o) (h).bsr2((t), &(h), (o))
+#define        bus_space_read_4(t,h,o) (h).bsr4((t), &(h), (o))
+#define        bus_space_read_stream_1(t,h,o)  (h).bsrs1((t), &(h), (o))
+#define        bus_space_read_stream_2(t,h,o)  (h).bsrs2((t), &(h), (o))
+#define        bus_space_read_stream_4(t,h,o)  (h).bsrs4((t), &(h), (o))
 
 #if 0  /* Cause a link error for bus_space_read_8 */
 #define        bus_space_read_8(t, h, o)       !!! bus_space_read_8 unimplemented !!!
+#define        bus_space_read_stream_8(t, h, o) \
+                               !!! bus_space_read_stream_8 unimplemented !!!
 #endif
 
 /*
@@ -184,50 +301,67 @@
  * described by tag/handle/offset and copy into buffer provided.
  */
 
-#define        bus_space_read_multi_1(t, h, o, a, c) do {                      \
-       (void) t;                                                       \
-       __asm __volatile ("                                             \
-               movl    %0,a0                                   ;       \
-               movl    %1,a1                                   ;       \
-               movl    %2,d0                                   ;       \
-       1:      movb    a0@,a1@+                                ;       \
-               subql   #1,d0                                   ;       \
-               jne     1b"                                     :       \
-                                                               :       \
-                   "r" ((h) + (o)), "g" (a), "g" ((size_t)(c)) :       \
-                   "a0","a1","d0");                                    \
-} while (0)
+void mac68k_bsrm1 __P((bus_space_tag_t t, bus_space_handle_t *h,
+                                  bus_size_t o, u_int8_t *a, size_t c));
+void mac68k_bsrm1_gen __P((bus_space_tag_t t, bus_space_handle_t *h,
+                                  bus_size_t o, u_int8_t *a, size_t c));
+void mac68k_bsrm2 __P((bus_space_tag_t t, bus_space_handle_t *h,
+                                  bus_size_t o, u_int16_t *a, size_t c));
+void mac68k_bsrm2_swap __P((bus_space_tag_t t, bus_space_handle_t *h,
+                                  bus_size_t o, u_int16_t *a, size_t c));
+void mac68k_bsrm2_gen __P((bus_space_tag_t t, bus_space_handle_t *h,
+                                  bus_size_t o, u_int16_t *a, size_t c));
+void mac68k_bsrms2_gen __P((bus_space_tag_t t, bus_space_handle_t *h,
+                                  bus_size_t o, u_int16_t *a, size_t c));
+void mac68k_bsrm4 __P((bus_space_tag_t t, bus_space_handle_t *h,
+                                  bus_size_t o, u_int32_t *a, size_t c));
+void mac68k_bsrms4 __P((bus_space_tag_t t, bus_space_handle_t *h,
+                                  bus_size_t o, u_int32_t *a, size_t c));
+void mac68k_bsrm4_swap __P((bus_space_tag_t t, bus_space_handle_t *h,
+                                  bus_size_t o, u_int32_t *a, size_t c));
+void mac68k_bsrm4_gen __P((bus_space_tag_t t, bus_space_handle_t *h,
+                                  bus_size_t o, u_int32_t *a, size_t c));
+void mac68k_bsrms4_gen __P((bus_space_tag_t t, bus_space_handle_t *h,
+                                  bus_size_t o, u_int32_t *a, size_t c));
 
-#define        bus_space_read_multi_2(t, h, o, a, c) do {                      \
-       (void) t;                                                       \
-       __asm __volatile ("                                             \
-               movl    %0,a0                                   ;       \
-               movl    %1,a1                                   ;       \
-               movl    %2,d0                                   ;       \
-       1:      movw    a0@,a1@+                                ;       \
-               subql   #1,d0                                   ;       \
-               jne     1b"                                     :       \
-                                                               :       \
-                   "r" ((h) + (o)), "g" (a), "g" ((size_t)(c)) :       \
-                   "a0","a1","d0");                                    \
-} while (0)
-
-#define        bus_space_read_multi_4(t, h, o, a, c) do {                      \
-       (void) t;                                                       \
-       __asm __volatile ("                                             \
-               movl    %0,a0                                   ;       \
-               movl    %1,a1                                   ;       \
-               movl    %2,d0                                   ;       \
-       1:      movl    a0@,a1@+                                ;       \
-               subql   #1,d0                                   ;       \
-               jne     1b"                                     :       \
-                                                               :       \
-                   "r" ((h) + (o)), "g" (a), "g" ((size_t)(c)) :       \
-                   "a0","a1","d0");                                    \
-} while (0)
+#if defined(DIAGNOSTIC)
+#define        bus_space_read_multi_1(t, h, o, a, c) do {                       \
+       if (!c) panic("bus_space_read_multi_1 called with zero count."); \
+       (h).bsrm1(t,&(h),o,a,c); } while (0)
+#define        bus_space_read_multi_2(t, h, o, a, c) do {                       \
+       if (!c) panic("bus_space_read_multi_2 called with zero count."); \
+       (h).bsrm2(t,&(h),o,a,c); } while (0)
+#define        bus_space_read_multi_4(t, h, o, a, c) do {                       \
+       if (!c) panic("bus_space_read_multi_4 called with zero count."); \
+       (h).bsrm4(t,&(h),o,a,c); } while (0)
+#define        bus_space_read_multi_stream_1(t, h, o, a, c) do {                \
+       if (!c) panic("bus_space_read_multi_stream_1 called with count=0."); \
+       (h).bsrms1(t,&(h),o,a,c); } while (0)
+#define        bus_space_read_multi_stream_2(t, h, o, a, c) do {                \
+       if (!c) panic("bus_space_read_multi_stream_2 called with count=0."); \
+       (h).bsrms2(t,&(h),o,a,c); } while (0)
+#define        bus_space_read_multi_stream_4(t, h, o, a, c) do {                \
+       if (!c) panic("bus_space_read_multi_stream_4 called with count=0."); \
+       (h).bsrms4(t,&(h),o,a,c); } while (0)
+#else
+#define        bus_space_read_multi_1(t, h, o, a, c) \
+       do { if (c) (h).bsrm1(t, &(h), o, a, c); } while (0)
+#define        bus_space_read_multi_2(t, h, o, a, c) \



Home | Main Index | Thread Index | Old Index