Source-Changes-HG archive

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

[src/trunk]: src/sys The entity passed to the HAL as a HAL_BUS_HANDLE needs t...



details:   https://anonhg.NetBSD.org/src/rev/16098aa7803b
branches:  trunk
changeset: 584326:16098aa7803b
user:      martin <martin%NetBSD.org@localhost>
date:      Tue Sep 13 05:50:29 2005 +0000

description:
The entity passed to the HAL as a HAL_BUS_HANDLE needs to be an integral
or pointer type. So on sparc64 (and maybe others too?) where
bus_space_handle_t is a struct, pass the address of the bus_space_handle_t
and adjust the register access functions accordingly.

While there, slightly optimize the bus_space_* usage in the register
access functions and macros.

diffstat:

 sys/contrib/dev/ic/athhal_osdep.c |  27 ++++++++++++++++-----------
 sys/contrib/dev/ic/athhal_osdep.h |  26 ++++++++++++++++++--------
 sys/dev/ic/ath.c                  |   7 ++++---
 3 files changed, 38 insertions(+), 22 deletions(-)

diffs (173 lines):

diff -r 52112661956b -r 16098aa7803b sys/contrib/dev/ic/athhal_osdep.c
--- a/sys/contrib/dev/ic/athhal_osdep.c Tue Sep 13 04:40:42 2005 +0000
+++ b/sys/contrib/dev/ic/athhal_osdep.c Tue Sep 13 05:50:29 2005 +0000
@@ -33,7 +33,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGES.
  *
- * $Id: athhal_osdep.c,v 1.3 2005/07/04 05:35:09 dyoung Exp $
+ * $Id: athhal_osdep.c,v 1.4 2005/09/13 05:50:29 martin Exp $
  */
 #include "opt_ah.h"
 
@@ -288,6 +288,8 @@
 void
 ath_hal_reg_write(struct ath_hal *ah, u_int32_t reg, u_int32_t val)
 {
+       bus_space_handle_t h = ATH_HAL2BUSHDNLE(ah->ah_sh);
+
        if (ath_hal_alq) {
                struct ale *ale = ath_hal_alq_get(ah);
                if (ale) {
@@ -300,22 +302,25 @@
        }
 #if _BYTE_ORDER == _BIG_ENDIAN
        if (reg >= 0x4000 && reg < 0x5000)
-               bus_space_write_stream_4(ah->ah_st, ah->ah_sh, reg, htole32(val));
+               bus_space_write_4(ah->ah_st, h, reg, val);
        else
 #endif
-               bus_space_write_stream_4(ah->ah_st, ah->ah_sh, reg, val);
+               bus_space_write_stream_4(ah->ah_st, h, reg, val);
 }
 
 u_int32_t
 ath_hal_reg_read(struct ath_hal *ah, u_int32_t reg)
 {
        u_int32_t val;
+       bus_space_handle_t h = ATH_HAL2BUSHDNLE(ah->ah_sh);
 
-       val = bus_space_read_stream_4(ah->ah_st, ah->ah_sh, reg);
 #if _BYTE_ORDER == _BIG_ENDIAN
        if (reg >= 0x4000 && reg < 0x5000)
-               val = le32toh(val);
+               val = bus_space_read_4(ah->ah_st, h, reg);
+       else
 #endif
+               val = bus_space_read_stream_4(ah->ah_st, h, reg);
+
        if (ath_hal_alq) {
                struct ale *ale = ath_hal_alq_get(ah);
                if (ale) {
@@ -358,25 +363,25 @@
 void
 ath_hal_reg_write(struct ath_hal *ah, u_int32_t reg, u_int32_t val)
 {
+       bus_space_handle_t h = ATH_HAL2BUSHDNLE(ah->ah_sh);
 #if _BYTE_ORDER == _BIG_ENDIAN
        if (reg >= 0x4000 && reg < 0x5000)
-               bus_space_write_stream_4(ah->ah_st, ah->ah_sh, reg, htole32(val));
+               bus_space_write_4(ah->ah_st, h, reg, val);
        else
 #endif
-               bus_space_write_stream_4(ah->ah_st, ah->ah_sh, reg, val);
+               bus_space_write_stream_4(ah->ah_st, h, reg, val);
 }
 
 u_int32_t
 ath_hal_reg_read(struct ath_hal *ah, u_int32_t reg)
 {
-       u_int32_t val;
+       bus_space_handle_t h = ATH_HAL2BUSHDNLE(ah->ah_sh);
 
-       val = bus_space_read_stream_4(ah->ah_st, ah->ah_sh, reg);
 #if _BYTE_ORDER == _BIG_ENDIAN
        if (reg >= 0x4000 && reg < 0x5000)
-               val = le32toh(val);
+               return bus_space_read_4(ah->ah_st, h, reg);
 #endif
-       return val;
+       return bus_space_read_stream_4(ah->ah_st, h, reg);
 }
 #endif /* AH_DEBUG || AH_REGOPS_FUNC */
 
diff -r 52112661956b -r 16098aa7803b sys/contrib/dev/ic/athhal_osdep.h
--- a/sys/contrib/dev/ic/athhal_osdep.h Tue Sep 13 04:40:42 2005 +0000
+++ b/sys/contrib/dev/ic/athhal_osdep.h Tue Sep 13 05:50:29 2005 +0000
@@ -33,7 +33,7 @@
  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGES.
  *
- * $Id: athhal_osdep.h,v 1.3 2005/07/04 05:35:09 dyoung Exp $
+ * $Id: athhal_osdep.h,v 1.4 2005/09/13 05:50:29 martin Exp $
  */
 #ifndef _ATH_AH_OSDEP_H_
 #define _ATH_AH_OSDEP_H_
@@ -46,9 +46,19 @@
 
 #include <machine/bus.h>
 
+#ifdef __sparc64__
+/* the HAL wants a pointer type, but bus_space_handle_t is a struct */
+typedef bus_space_handle_t *HAL_BUS_HANDLE;
+#define ATH_BUSHANDLE2HAL(HNDL)        (&(HNDL))
+#define ATH_HAL2BUSHDNLE(HH)   (*(HH))
+#else
+typedef bus_space_handle_t HAL_BUS_HANDLE;
+#define ATH_BUSHANDLE2HAL(HNDL)        (HNDL)
+#define ATH_HAL2BUSHDNLE(HH)   (HH)
+#endif
+
 typedef void* HAL_SOFTC;
 typedef bus_space_tag_t HAL_BUS_TAG;
-typedef bus_space_handle_t HAL_BUS_HANDLE;
 typedef bus_addr_t HAL_BUS_ADDR;
 
 /*
@@ -99,22 +109,22 @@
 #if _BYTE_ORDER == _BIG_ENDIAN
 #define OS_REG_WRITE(_ah, _reg, _val) do {                             \
        if ( (_reg) >= 0x4000 && (_reg) < 0x5000)                       \
-               bus_space_write_stream_4((_ah)->ah_st, (_ah)->ah_sh,            \
-                       (_reg), htole32(_val));                 \
+               bus_space_write_4((_ah)->ah_st, (_ah)->ah_sh,           \
+                       (_reg), (_val));                                \
        else                                                            \
-               bus_space_write_stream_4((_ah)->ah_st, (_ah)->ah_sh,            \
+               bus_space_write_stream_4((_ah)->ah_st, (_ah)->ah_sh,    \
                        (_reg), (_val));                                \
 } while (0)
 #define OS_REG_READ(_ah, _reg)                                         \
        (((_reg) >= 0x4000 && (_reg) < 0x5000) ?                        \
-               le32toh(bus_space_read_stream_4((_ah)->ah_st, (_ah)->ah_sh,     \
+               bus_space_read_4((_ah)->ah_st, (_ah)->ah_sh,            \
                        (_reg))) :                                      \
                bus_space_read_stream_4((_ah)->ah_st, (_ah)->ah_sh, (_reg)))
 #else /* _BYTE_ORDER == _LITTLE_ENDIAN */
 #define        OS_REG_WRITE(_ah, _reg, _val)                                   \
-       bus_space_write_stream_4((_ah)->ah_st, (_ah)->ah_sh, (_reg), (_val))
+       bus_space_write_4((_ah)->ah_st, (_ah)->ah_sh, (_reg), (_val))
 #define        OS_REG_READ(_ah, _reg)                                          \
-       ((u_int32_t) bus_space_read_stream_4((_ah)->ah_st, (_ah)->ah_sh, (_reg)))
+       ((u_int32_t) bus_space_read_4((_ah)->ah_st, (_ah)->ah_sh, (_reg)))
 #endif /* _BYTE_ORDER */
 #endif /* AH_DEBUG || AH_REGFUNC || AH_DEBUG_ALQ */
 
diff -r 52112661956b -r 16098aa7803b sys/dev/ic/ath.c
--- a/sys/dev/ic/ath.c  Tue Sep 13 04:40:42 2005 +0000
+++ b/sys/dev/ic/ath.c  Tue Sep 13 05:50:29 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ath.c,v 1.58 2005/08/21 00:25:51 dyoung Exp $  */
+/*     $NetBSD: ath.c,v 1.59 2005/09/13 05:50:29 martin Exp $  */
 
 /*-
  * Copyright (c) 2002-2005 Sam Leffler, Errno Consulting
@@ -41,7 +41,7 @@
 __FBSDID("$FreeBSD: src/sys/dev/ath/if_ath.c,v 1.94 2005/07/07 00:04:50 sam Exp $");
 #endif
 #ifdef __NetBSD__
-__KERNEL_RCSID(0, "$NetBSD: ath.c,v 1.58 2005/08/21 00:25:51 dyoung Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ath.c,v 1.59 2005/09/13 05:50:29 martin Exp $");
 #endif
 
 /*
@@ -308,7 +308,8 @@
 
        memcpy(ifp->if_xname, sc->sc_dev.dv_xname, IFNAMSIZ);
 
-       ah = ath_hal_attach(devid, sc, sc->sc_st, sc->sc_sh, &status);
+       ah = ath_hal_attach(devid, sc, sc->sc_st, ATH_BUSHANDLE2HAL(sc->sc_sh),
+           &status);
        if (ah == NULL) {
                if_printf(ifp, "unable to attach hardware; HAL status %u\n",
                        status);



Home | Main Index | Thread Index | Old Index