00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef _ATH_AH_OSDEP_H_
00039 #define _ATH_AH_OSDEP_H_
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051 #ifdef CONFIG_REGPARM
00052 #define __ahdecl __attribute__((regparm(0)))
00053 #else
00054 #define __ahdecl
00055 #endif
00056 #ifndef __packed
00057 #define __packed __attribute__((__packed__))
00058 #endif
00059
00060
00061
00062
00063
00064
00065 #ifndef _LINUX_TYPES_H
00066
00067 typedef signed char int8_t;
00068 typedef short int16_t;
00069 typedef int int32_t;
00070 typedef long long int64_t;
00071
00072 typedef unsigned char u_int8_t;
00073 typedef unsigned short u_int16_t;
00074 typedef unsigned int u_int32_t;
00075 typedef unsigned long long u_int64_t;
00076
00077 typedef unsigned int size_t;
00078 typedef unsigned int u_int;
00079 typedef void *va_list;
00080 #endif
00081
00082
00083
00084
00085 #define __printflike(_a,_b) \
00086 __attribute__ ((__format__ (__printf__, _a, _b)))
00087 #define __va_list va_list
00088 #define OS_INLINE __inline
00089
00090 typedef void* HAL_SOFTC;
00091 typedef int HAL_BUS_TAG;
00092 typedef void* HAL_BUS_HANDLE;
00093 typedef u_int32_t HAL_BUS_ADDR;
00094
00095
00096
00097
00098 extern void __ahdecl ath_hal_delay(int);
00099 #define OS_DELAY(_n) ath_hal_delay(_n)
00100
00101 #define OS_MEMZERO(_a, _n) ath_hal_memzero((_a), (_n))
00102 extern void __ahdecl ath_hal_memzero(void *, size_t);
00103 #define OS_MEMCPY(_d, _s, _n) ath_hal_memcpy(_d,_s,_n)
00104 extern void * __ahdecl ath_hal_memcpy(void *, const void *, size_t);
00105
00106 #ifndef abs
00107 #define abs(_a) __builtin_abs(_a)
00108 #endif
00109
00110 struct ath_hal;
00111 extern u_int32_t __ahdecl ath_hal_getuptime(struct ath_hal *);
00112 #define OS_GETUPTIME(_ah) ath_hal_getuptime(_ah)
00113
00114
00115
00116
00117 #define AH_LITTLE_ENDIAN 1234
00118 #define AH_BIG_ENDIAN 4321
00119
00120 #if AH_BYTE_ORDER == AH_BIG_ENDIAN
00121
00122
00123
00124
00125 static inline u_int32_t
00126 __bswap32(u_int32_t _x)
00127 {
00128 return ((u_int32_t)(
00129 (((const u_int8_t *)(&_x))[0] ) |
00130 (((const u_int8_t *)(&_x))[1]<< 8) |
00131 (((const u_int8_t *)(&_x))[2]<<16) |
00132 (((const u_int8_t *)(&_x))[3]<<24))
00133 );
00134 }
00135 #else
00136 #define __bswap32(_x) (_x)
00137 #endif
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155 #if AH_BYTE_ORDER == AH_BIG_ENDIAN
00156 #define _OS_REG_WRITE(_ah, _reg, _val) do { \
00157 if ( (_reg) >= 0x4000 && (_reg) < 0x5000) \
00158 *((volatile u_int32_t *)((_ah)->ah_sh + (_reg))) = \
00159 __bswap32((_val)); \
00160 else \
00161 *((volatile u_int32_t *)((_ah)->ah_sh + (_reg))) = (_val); \
00162 } while (0)
00163 #define _OS_REG_READ(_ah, _reg) \
00164 (((_reg) >= 0x4000 && (_reg) < 0x5000) ? \
00165 __bswap32(*((volatile u_int32_t *)((_ah)->ah_sh + (_reg)))) : \
00166 *((volatile u_int32_t *)((_ah)->ah_sh + (_reg))))
00167 #else
00168 #define _OS_REG_WRITE(_ah, _reg, _val) do { \
00169 *((volatile u_int32_t *)((_ah)->ah_sh + (_reg))) = (_val); \
00170 } while (0)
00171 #define _OS_REG_READ(_ah, _reg) \
00172 *((volatile u_int32_t *)((_ah)->ah_sh + (_reg)))
00173 #endif
00174
00175 #if defined(AH_DEBUG) || defined(AH_REGOPS_FUNC) || defined(AH_DEBUG_ALQ)
00176
00177 #define OS_REG_WRITE(_ah, _reg, _val) ath_hal_reg_write(_ah, _reg, _val)
00178 #define OS_REG_READ(_ah, _reg) ath_hal_reg_read(_ah, _reg)
00179
00180 extern void __ahdecl ath_hal_reg_write(struct ath_hal *ah,
00181 u_int reg, u_int32_t val);
00182 extern u_int32_t __ahdecl ath_hal_reg_read(struct ath_hal *ah, u_int reg);
00183 #else
00184
00185 #define OS_REG_WRITE(_ah, _reg, _val) _OS_REG_WRITE(_ah, _reg, _val)
00186 #define OS_REG_READ(_ah, _reg) _OS_REG_READ(_ah, _reg)
00187 #endif
00188
00189 #ifdef AH_DEBUG_ALQ
00190 extern void __ahdecl OS_MARK(struct ath_hal *, u_int id, u_int32_t value);
00191 #else
00192 #define OS_MARK(_ah, _id, _v)
00193 #endif
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206 extern struct ath_hal *_ath_hal_attach(u_int16_t devid, HAL_SOFTC,
00207 HAL_BUS_TAG, HAL_BUS_HANDLE, void* status);
00208 extern void ath_hal_detach(struct ath_hal *);
00209
00210 #endif