Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/x68k/include Performance hack.



details:   https://anonhg.NetBSD.org/src/rev/160f5751aad7
branches:  trunk
changeset: 503021:160f5751aad7
user:      itohy <itohy%NetBSD.org@localhost>
date:      Mon Jan 29 01:09:29 2001 +0000

description:
Performance hack.
Mainly for the Neptune-X Ethernet adaptor,
and improves ftp(1) speed by ~10%.

        get: 219 KB/s -> 246 KB/s
        put: 226 KB/s -> 247 KB/s
        (X68030, MC68030 25MHz)

diffstat:

 sys/arch/x68k/include/bus.h |  236 +++++++++++++++++++++++++++++++------------
 1 files changed, 169 insertions(+), 67 deletions(-)

diffs (truncated from 451 to 300 lines):

diff -r 82c589b81226 -r 160f5751aad7 sys/arch/x68k/include/bus.h
--- a/sys/arch/x68k/include/bus.h       Mon Jan 29 00:24:24 2001 +0000
+++ b/sys/arch/x68k/include/bus.h       Mon Jan 29 01:09:29 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus.h,v 1.5 2000/06/26 04:56:16 simonb Exp $   */
+/*     $NetBSD: bus.h,v 1.6 2001/01/29 01:09:29 itohy Exp $    */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -44,6 +44,14 @@
 #ifndef _X68K_BUS_H_
 #define _X68K_BUS_H_
 
+#ifndef X68K_BUS_PERFORMANCE_HACK
+#if defined(__GNUC__) && defined(__STDC__)
+#define X68K_BUS_PERFORMANCE_HACK      1
+#else
+#define X68K_BUS_PERFORMANCE_HACK      0
+#endif
+#endif
+
 /*
  * Bus address and size types
  */
@@ -258,15 +266,17 @@
             bus_space_handle_t, bus_size_t, bus_size_t));
 
 
+#define __X68K_BUS_ADDR(tag, handle, offset)   \
+       (((long)(handle) < 0 ? (offset) * 2 : (offset)) \
+               + ((handle) & 0x7fffffff))
+
 static inline u_int8_t
 _bus_space_read_1(t, bsh, offset)
        bus_space_tag_t t;
        bus_space_handle_t bsh;
        bus_size_t offset;
 {
-       return (*((volatile u_int8_t *) ((bsh&0x80000000)
-                                        ? (bsh&0x7fffffff) + offset*2
-                                        : bsh + offset)));
+       return (*((volatile u_int8_t *) __X68K_BUS_ADDR(t, bsh, offset)));
 }
 
 static inline u_int16_t
@@ -275,9 +285,7 @@
        bus_space_handle_t bsh;
        bus_size_t offset;
 {
-       return (*((volatile u_int16_t *) ((bsh&0x80000000)
-                                         ? (bsh&0x7fffffff) + offset*2
-                                         : bsh + offset)));
+       return (*((volatile u_int16_t *) __X68K_BUS_ADDR(t, bsh, offset)));
 }
 
 static inline u_int32_t
@@ -286,9 +294,7 @@
        bus_space_handle_t bsh;
        bus_size_t offset;
 {
-       return (*((volatile u_int32_t *) ((bsh&0x80000000)
-                                         ? (bsh&0x7fffffff) + offset*2
-                                         : bsh + offset)));
+       return (*((volatile u_int32_t *) __X68K_BUS_ADDR(t, bsh, offset)));
 }
 
 static inline void
@@ -299,12 +305,18 @@
        u_int8_t *datap;
        bus_size_t count;
 {
+#if X68K_BUS_PERFORMANCE_HACK
+       u_int8_t *regadr = (u_int8_t *) __X68K_BUS_ADDR(t, bsh, offset);
+       for (; count; count--) {
+               __asm("| avoid optim. _bus_space_read_multi_1" : : : "memory");
+               *datap++ = *regadr;
+       }
+#else
        while (count-- > 0) {
-               *datap++ = *(volatile u_int8_t *) ((bsh&0x80000000)
-                                                  ? ((bsh&0x7fffffff)
-                                                     + offset*2)
-                                                  : bsh + offset);
+               *datap++ = *(volatile u_int8_t *)
+                               __X68K_BUS_ADDR(t, bsh, offset);
        }
+#endif
 }
 
 static inline void
@@ -315,12 +327,18 @@
        u_int16_t *datap;
        bus_size_t count;
 {
+#if X68K_BUS_PERFORMANCE_HACK
+       u_int16_t *regadr = (u_int16_t *) __X68K_BUS_ADDR(t, bsh, offset);
+       for (; count; count--) {
+               __asm("| avoid optim. _bus_space_read_multi_2" : : : "memory");
+               *datap++ = *regadr;
+       }
+#else
        while (count-- > 0) {
-               *datap++ = *(volatile u_int16_t *) ((bsh&0x80000000)
-                                                   ? ((bsh&0x7fffffff)
-                                                      + offset*2)
-                                                   : bsh + offset);
+               *datap++ = *(volatile u_int16_t *)
+                               __X68K_BUS_ADDR(t, bsh, offset);
        }
+#endif
 }
 
 static inline void
@@ -331,12 +349,18 @@
        u_int32_t *datap;
        bus_size_t count;
 {
+#if X68K_BUS_PERFORMANCE_HACK
+       u_int32_t *regadr = (u_int32_t *) __X68K_BUS_ADDR(t, bsh, offset);
+       for (; count; count--) {
+               __asm("| avoid optim. _bus_space_read_multi_4" : : : "memory");
+               *datap++ = *regadr;
+       }
+#else
        while (count-- > 0) {
-               *datap++ = *(volatile u_int32_t *) ((bsh&0x80000000)
-                                                   ? ((bsh&0x7fffffff)
-                                                      + offset*2)
-                                                   : bsh + offset);
+               *datap++ = *(volatile u_int32_t *)
+                               __X68K_BUS_ADDR(t, bsh, offset);
        }
+#endif
 }
 
 static inline void
@@ -347,13 +371,20 @@
        u_int8_t *datap;
        bus_size_t count;
 {
-       volatile u_int8_t *addr = (void *) ((bsh&0x80000000)
-                                           ? (bsh&0x7fffffff) + offset*2
-                                           : bsh + offset);
+#if X68K_BUS_PERFORMANCE_HACK
+       u_int8_t *addr = (void *) __X68K_BUS_ADDR(t, bsh, offset);
+
+       for (; count; count--) {
+               __asm("| avoid optim. _bus_space_read_region_1" : : : "memory");
+               *datap++ = *addr++;
+       }
+#else
+       volatile u_int8_t *addr = (void *) __X68K_BUS_ADDR(t, bsh, offset);
 
        while (count-- > 0) {
                *datap++ = *addr++;
        }
+#endif
 }
 
 static inline void
@@ -364,13 +395,20 @@
        u_int16_t *datap;
        bus_size_t count;
 {
-       volatile u_int16_t *addr = (void *) ((bsh&0x80000000)
-                                            ? (bsh&0x7fffffff) + offset*2
-                                            : bsh + offset);
+#if X68K_BUS_PERFORMANCE_HACK
+       u_int16_t *addr = (void *) __X68K_BUS_ADDR(t, bsh, offset);
+
+       for (; count; count--) {
+               __asm("| avoid optim. _bus_space_read_region_2" : : : "memory");
+               *datap++ = *addr++;
+       }
+#else
+       volatile u_int16_t *addr = (void *) __X68K_BUS_ADDR(t, bsh, offset);
 
        while (count-- > 0) {
                *datap++ = *addr++;
        }
+#endif
 }
 
 static inline void
@@ -381,13 +419,20 @@
        u_int32_t *datap;
        bus_size_t count;
 {
-       volatile u_int32_t *addr = (void *) ((bsh&0x80000000)
-                                            ? (bsh&0x7fffffff) + offset*2
-                                            : bsh + offset);
+#if X68K_BUS_PERFORMANCE_HACK
+       u_int32_t *addr = (void *) __X68K_BUS_ADDR(t, bsh, offset);
+
+       for (; count; count--) {
+               __asm("| avoid optim. _bus_space_read_region_4" : : : "memory");
+               *datap++ = *addr++;
+       }
+#else
+       volatile u_int32_t *addr = (void *) __X68K_BUS_ADDR(t, bsh, offset);
 
        while (count-- > 0) {
                *datap++ = *addr++;
        }
+#endif
 }
 
 static inline void
@@ -397,9 +442,7 @@
        bus_size_t offset;
        u_int8_t value;
 {
-       *(volatile u_int8_t *) ((bsh&0x80000000)
-                               ? (bsh&0x7fffffff) + offset*2
-                               : bsh + offset) = value;
+       *(volatile u_int8_t *) __X68K_BUS_ADDR(t, bsh, offset) = value;
 }
 
 static inline void
@@ -409,9 +452,7 @@
        bus_size_t offset;
        u_int16_t value;
 {
-       *(volatile u_int16_t *) ((bsh&0x80000000)
-                                ? (bsh&0x7fffffff) + offset*2
-                                : bsh + offset) = value;
+       *(volatile u_int16_t *) __X68K_BUS_ADDR(t, bsh, offset) = value;
 }
 
 static inline void
@@ -421,9 +462,7 @@
        bus_size_t offset;
        u_int32_t value;
 {
-       *(volatile u_int32_t *) ((bsh&0x80000000)
-                                ? (bsh&0x7fffffff) + offset*2
-                                : bsh + offset) = value;
+       *(volatile u_int32_t *) __X68K_BUS_ADDR(t, bsh, offset) = value;
 }
 
 static inline void
@@ -434,11 +473,18 @@
        u_int8_t *datap;
        bus_size_t count;
 {
+#if X68K_BUS_PERFORMANCE_HACK
+       u_int8_t *regadr = (u_int8_t *) __X68K_BUS_ADDR(t, bsh, offset);
+       for (; count; count--) {
+               __asm("| avoid optim. _bus_space_write_multi_1" : : : "memory");
+               *regadr = *datap++;
+       }
+#else
        while (count-- > 0) {
-               *(volatile u_int8_t *) ((bsh&0x80000000)
-                                       ? (bsh&0x7fffffff) + offset*2
-                                       : bsh + offset) = *datap++;
+               *(volatile u_int8_t *) __X68K_BUS_ADDR(t, bsh, offset)
+                   = *datap++;
        }
+#endif
 }
 
 static inline void
@@ -449,11 +495,18 @@
        u_int16_t *datap;
        bus_size_t count;
 {
+#if X68K_BUS_PERFORMANCE_HACK
+       u_int16_t *regadr = (u_int16_t *) __X68K_BUS_ADDR(t, bsh, offset);
+       for (; count; count--) {
+               __asm("| avoid optim. _bus_space_write_multi_2" : : : "memory");
+               *regadr = *datap++;
+       }
+#else
        while (count-- > 0) {
-               *(volatile u_int16_t *) ((bsh&0x80000000)
-                                        ? (bsh&0x7fffffff) + offset*2
-                                        : bsh + offset) = *datap++;
+               *(volatile u_int16_t *) __X68K_BUS_ADDR(t, bsh, offset)
+                   = *datap++;
        }
+#endif
 }
 
 static inline void
@@ -464,11 +517,18 @@
        u_int32_t *datap;
        bus_size_t count;
 {
+#if X68K_BUS_PERFORMANCE_HACK
+       u_int32_t *regadr = (u_int32_t *) __X68K_BUS_ADDR(t, bsh, offset);
+       for (; count; count--) {
+               __asm("| avoid optim. _bus_space_write_multi_4" : : : "memory");
+               *regadr = *datap++;
+       }
+#else
        while (count-- > 0) {
-               *(volatile u_int32_t *) ((bsh&0x80000000)
-                                        ? (bsh&0x7fffffff) + offset*2
-                                        : bsh + offset) = *datap++;



Home | Main Index | Thread Index | Old Index