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