Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/mvme68k/include Simplify bus_space_{read, write}_N. ...



details:   https://anonhg.NetBSD.org/src/rev/fa8b4d1c0167
branches:  trunk
changeset: 554084:fa8b4d1c0167
user:      scw <scw%NetBSD.org@localhost>
date:      Sat Oct 25 08:47:14 2003 +0000

description:
Simplify bus_space_{read,write}_N. Gcc3 emits better code than the old
compiler with straight C, rather than inline asm. (The latter was slightly
broken anyway with gcc3's more aggressive optimisation).

diffstat:

 sys/arch/mvme68k/include/bus_space.h |  75 +++++++++--------------------------
 1 files changed, 19 insertions(+), 56 deletions(-)

diffs (96 lines):

diff -r 126b0842f2ec -r fa8b4d1c0167 sys/arch/mvme68k/include/bus_space.h
--- a/sys/arch/mvme68k/include/bus_space.h      Sat Oct 25 08:39:05 2003 +0000
+++ b/sys/arch/mvme68k/include/bus_space.h      Sat Oct 25 08:47:14 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus_space.h,v 1.7 2000/11/29 09:18:32 scw Exp $ */
+/*     $NetBSD: bus_space.h,v 1.8 2003/10/25 08:47:14 scw Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -210,38 +210,12 @@
  * Read a 1, 2, 4, or 8 byte quantity from bus space
  * described by tag/handle/offset.
  */
-static __inline u_int8_t
-bus_space_read_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
-{
-       u_int8_t rv;
-
-       __asm __volatile("movb %1,%0" : "=dm" (rv) :
-                                       "g"   (*((u_int8_t *)(h + o))));
-
-       return (rv);
-}
-
-static __inline u_int16_t
-bus_space_read_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
-{
-       u_int16_t rv;
-
-       __asm __volatile("movw %1,%0" : "=dm" (rv) :
-                                       "g"   (*((u_int16_t *)(h + o))));
-
-       return (rv);
-}
-
-static __inline u_int32_t
-bus_space_read_4(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)
-{
-       u_int32_t rv;
-
-       __asm __volatile("movl %1,%0" : "=rm" (rv) :
-                                       "g"   (*((u_int32_t *)(h + o))));
-
-       return (rv);
-}
+#define        bus_space_read_1(t,h,o) \
+           (*((volatile u_int8_t *)(intptr_t)((h) + (o))))
+#define        bus_space_read_2(t,h,o) \
+           (*((volatile u_int16_t *)(intptr_t)((h) + (o))))
+#define        bus_space_read_4(t,h,o) \
+           (*((volatile u_int32_t *)(intptr_t)((h) + (o))))
 
 /*
  *     void bus_space_read_multi_N(bus_space_tag_t tag,
@@ -362,29 +336,18 @@
  * Write the 1, 2, 4, or 8 byte value `value' to bus space
  * described by tag/handle/offset.
  */
-static __inline void
-bus_space_write_1(bus_space_tag_t t, bus_space_handle_t h,
-    bus_size_t o, u_int8_t v)
-{
-       __asm __volatile("movb %0,%1" ::
-           "dim" (v), "g" (*((u_int8_t *)(h + o))));
-}
-
-static __inline void
-bus_space_write_2(bus_space_tag_t t, bus_space_handle_t h,
-    bus_size_t o, u_int16_t v)
-{
-       __asm __volatile("movw %0,%1" ::
-           "dim" (v), "g" (*((u_int16_t *)(h + o))));
-}
-
-static __inline void
-bus_space_write_4(bus_space_tag_t t, bus_space_handle_t h,
-    bus_size_t o, u_int32_t v)
-{
-       __asm __volatile("movl %0,%1" ::
-           "g" (v), "g" (*((u_int32_t *)(h + o))));
-}
+#define        bus_space_write_1(t,h,o,v)                                      \
+       do {                                                            \
+               *((volatile u_int8_t *)(intptr_t)((h) + (o))) = (v);    \
+       } while (/*CONSTCOND*/0)
+#define        bus_space_write_2(t,h,o,v)                                      \
+       do {                                                            \
+               *((volatile u_int16_t *)(intptr_t)((h) + (o))) = (v);   \
+       } while (/*CONSTCOND*/0)
+#define        bus_space_write_4(t,h,o,v)                                      \
+       do {                                                            \
+               *((volatile u_int32_t *)(intptr_t)((h) + (o))) = (v);   \
+       } while (/*CONSTCOND*/0)
 
 /*
  *     void bus_space_write_multi_N(bus_space_tag_t tag,



Home | Main Index | Thread Index | Old Index