Merge pull request #37 from olerem/clean_2
[open-ath9k-htc-firmware.git] / target_firmware / wlan / ah_osdep.h
1 /*-
2  * Copyright (c) 2002-2004 Sam Leffler, Errno Consulting, Atheros
3  * Communications, Inc.  All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that the following conditions are met:
7  * 1. The materials contained herein are unmodified and are used
8  *    unmodified.
9  * 2. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following NO
11  *    ''WARRANTY'' disclaimer below (''Disclaimer''), without
12  *    modification.
13  * 3. Redistributions in binary form must reproduce at minimum a
14  *    disclaimer similar to the Disclaimer below and any redistribution
15  *    must be conditioned upon including a substantially similar
16  *    Disclaimer requirement for further binary redistribution.
17  * 4. Neither the names of the above-listed copyright holders nor the
18  *    names of any contributors may be used to endorse or promote
19  *    product derived from this software without specific prior written
20  *    permission.
21  *
22  * NO WARRANTY
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24  * ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25  * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT,
26  * MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27  * IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE
28  * FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
30  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
33  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34  * SUCH DAMAGES.
35  *
36  * $Id: //depot/sw/branches/fusion_usb/target_firmware/wlan/target/hal/main/linux/ah_osdep.h#1 $
37  */
38 #ifndef _ATH_AH_OSDEP_H_
39 #define _ATH_AH_OSDEP_H_
40 /*
41  * Atheros Hardware Access Layer (HAL) OS Dependent Definitions.
42  */
43
44 /*
45  * Starting with 2.6.4 the kernel supports a configuration option
46  * to pass parameters in registers.  If this is enabled we must
47  * mark all function interfaces in+out of the HAL to pass parameters
48  * on the stack as this is the convention used internally (for
49  * maximum portability).
50  *
51  * XXX A lot of functions have __ahdecl in their definition but not declaration
52  * So compile breaks.
53  * Since This is only an issue for i386 which has regparam enabled, instead of
54  * changing the vanilla FC3 kernel, for now, remove the regparm
55  * disabling.
56  */
57
58 #include <adf_os_types.h>
59 #include <adf_os_dma.h>
60 #include <adf_os_timer.h>
61 #include <adf_os_time.h>
62 #include <adf_os_lock.h>
63 #include <adf_os_io.h>
64 #include <adf_os_mem.h>
65 #include <adf_os_module.h>
66 #include <adf_os_util.h>
67 #include <adf_os_stdtypes.h>
68 #include <adf_os_defer.h>
69 #include <adf_os_atomic.h>
70 #include <adf_nbuf.h>
71 #include <adf_net.h>
72
73 /* CONFIG_REGPARM has been removed from 2.6.20 onwards.
74  * Since this is relevant only for i386 architectures, changing check to
75  * i386.
76  */
77
78 #ifdef __adf_i386__
79 #define __ahdecl    __attribute__((regparm(0)))
80 #else
81 #define __ahdecl
82 #endif
83 #ifndef adf_os_packed
84 #define adf_os_packed    __attribute__((__packed__))
85 #endif
86 #ifdef __FreeBSD__
87 /*
88  * When building the HAL proper we use no GPL-contaminated include
89  * files and must define these types ourself.  Beware of these being
90  * mismatched against the contents of <linux/types.h>
91  */
92 /* NB: arm defaults to unsigned so be explicit */
93 /* cometothis later when seperating os deps */
94 typedef __va_list va_list;
95 // typedef void *va_list;
96 #define va_start(ap, last) \
97         __builtin_stdarg_start((ap), (last))
98
99 #define va_end(ap) \
100         __builtin_va_end(ap)
101 #endif
102
103 /*
104  * Linux/BSD gcc compatibility shims.
105  */
106 #ifdef TODO //freebsd has definition
107 #define __printflike(_a,_b) \
108     __attribute__ ((__format__ (__printf__, _a, _b)))
109 #endif
110 #ifndef __va_list
111 #define __va_list   va_list
112 #endif
113 #ifdef TODO //freebsd has definition
114 #define OS_INLINE   __inline
115 #endif
116
117 typedef void* HAL_SOFTC;
118 typedef a_int32_t HAL_BUS_TAG;
119 typedef void* HAL_BUS_HANDLE;
120 typedef a_uint32_t HAL_BUS_ADDR;         /* XXX architecture dependent */
121
122 /*
123  * Delay n microseconds.
124  */
125 extern  void __ahdecl ath_hal_delay(a_int32_t);
126 #define OS_DELAY(_n)    ath_hal_delay(_n)
127
128 extern  void* __ahdecl ath_hal_ioremap(a_uint32_t addr, a_uint32_t len);
129 #define OS_REMAP(_addr, _len)       ath_hal_ioremap(_addr, _len)
130
131 #define OS_MEMCPY(_d, _s, _n)   ath_hal_memcpy(_d,_s,_n)
132 extern void * __ahdecl ath_hal_memcpy(void *, const void *, size_t);
133
134 #ifndef abs
135 #define abs(_a)     __builtin_abs(_a)
136 #endif
137
138 struct ath_hal;
139 extern  a_uint32_t __ahdecl ath_hal_getuptime(struct ath_hal *);
140 #define OS_GETUPTIME(_ah)   ath_hal_getuptime(_ah)
141
142 #ifndef __bswap32
143 #define __bswap32(_x)   (_x)
144 #endif
145 #ifndef __bswap16
146 #define __bswap16(_x)   (_x)
147 #endif
148
149 #define OS_REG_WRITE(_ah, _reg, _val)   ath_hal_reg_write_target(_ah, _reg, _val)
150 #define OS_REG_READ(_ah, _reg)      ath_hal_reg_read_target(_ah, _reg)
151
152 extern  void __ahdecl ath_hal_reg_write_target(struct ath_hal *ah,
153         a_uint32_t reg, a_uint32_t val);
154 extern  a_uint32_t __ahdecl ath_hal_reg_read_target(struct ath_hal *ah, a_uint32_t reg);
155
156 #define AH_USE_EEPROM     0x00000001
157 extern  struct ath_hal *_ath_hal_attach_tgt( a_uint32_t, HAL_SOFTC, adf_os_device_t,
158        a_uint32_t flags, void* status);
159 #endif /* _ATH_AH_OSDEP_H_ */