2 * Copyright (c) 2002-2004 Sam Leffler, Errno Consulting, Atheros
3 * Communications, Inc. All rights reserved.
4 * Copyright (c) 2013 Qualcomm Atheros, Inc.
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:
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
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
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.
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.
39 #ifndef _ATH_AH_OSDEP_H_
40 #define _ATH_AH_OSDEP_H_
42 * Atheros Hardware Access Layer (HAL) OS Dependent Definitions.
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).
52 * XXX A lot of functions have __ahdecl in their definition but not declaration
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
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>
74 /* CONFIG_REGPARM has been removed from 2.6.20 onwards.
75 * Since this is relevant only for i386 architectures, changing check to
80 #define __ahdecl __attribute__((regparm(0)))
85 #define adf_os_packed __attribute__((__packed__))
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>
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))
105 * Linux/BSD gcc compatibility shims.
107 #ifdef TODO //freebsd has definition
108 #define __printflike(_a,_b) \
109 __attribute__ ((__format__ (__printf__, _a, _b)))
112 #define __va_list va_list
114 #ifdef TODO //freebsd has definition
115 #define OS_INLINE __inline
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 */
124 * Delay n microseconds.
126 extern void __ahdecl ath_hal_delay(a_int32_t);
127 #define OS_DELAY(_n) ath_hal_delay(_n)
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)
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);
136 #define abs(_a) __builtin_abs(_a)
140 extern a_uint32_t __ahdecl ath_hal_getuptime(struct ath_hal *);
141 #define OS_GETUPTIME(_ah) ath_hal_getuptime(_ah)
144 #define __bswap32(_x) (_x)
147 #define __bswap16(_x) (_x)
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_ */