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