diff --git a/sys/contrib/dev/ic/athhal_osdep.c b/sys/contrib/dev/ic/athhal_osdep.c index d9eb3676f747..09cb5eef41c8 100644 --- a/sys/contrib/dev/ic/athhal_osdep.c +++ b/sys/contrib/dev/ic/athhal_osdep.c @@ -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 @@ ath_hal_alq_get(struct ath_hal *ah) 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 @@ ath_hal_reg_write(struct ath_hal *ah, u_int32_t reg, u_int32_t val) } #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 @@ OS_MARK(struct ath_hal *ah, u_int id, u_int32_t v) 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 --git a/sys/contrib/dev/ic/athhal_osdep.h b/sys/contrib/dev/ic/athhal_osdep.h index d4a934dbd590..1ad21b9e34a8 100644 --- a/sys/contrib/dev/ic/athhal_osdep.h +++ b/sys/contrib/dev/ic/athhal_osdep.h @@ -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 +#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 @@ extern u_int32_t ath_hal_reg_read(struct ath_hal *ah, u_int reg); #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 --git a/sys/dev/ic/ath.c b/sys/dev/ic/ath.c index 87a0efb64a41..4f4e653bf53c 100644 --- a/sys/dev/ic/ath.c +++ b/sys/dev/ic/ath.c @@ -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 @@ ath_attach(u_int16_t devid, struct ath_softc *sc) 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);