1 /*
2  * Copyright (c) 2013-2014 The Linux Foundation. All rights reserved.
3  *
4  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5  *
6  *
7  * Permission to use, copy, modify, and/or distribute this software for
8  * any purpose with or without fee is hereby granted, provided that the
9  * above copyright notice and this permission notice appear in all
10  * copies.
11  *
12  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19  * PERFORMANCE OF THIS SOFTWARE.
20  */
21 
22 /*
23  * This file was originally distributed by Qualcomm Atheros, Inc.
24  * under proprietary terms before Copyright ownership was assigned
25  * to the Linux Foundation.
26  */
27 
28 /* ============================================================================== */
29 /* This file contains the definitions of the basic atheros data types. */
30 /* It is used to map the data types in atheros files to a platform specific */
31 /* type. */
32 /* */
33 /* Author(s): ="Atheros" */
34 /* ============================================================================== */
35 #ifndef _A_OSAPI_H_
36 #define _A_OSAPI_H_
37 
38 #if defined(__linux__) && !defined(LINUX_EMULATION)
39 #include "osapi_linux.h"
40 #endif
41 
42 /*=== the following primitives have the same definition for all platforms ===*/
43 
44 #define A_COMPILE_TIME_ASSERT(assertion_name, predicate) \
45 	typedef char assertion_name[(predicate) ? 1 : -1]
46 
47 /*
48  * If N is a power of 2, then N and N-1 are orthogonal
49  * (N-1 has all the least-significant bits set which are zero in N)
50  * so  N ^ (N-1) = (N << 1) - 1
51  */
52 #define A_COMPILE_TIME_ASSERT_IS_PWR2(assertion_name, value) \
53 	A_COMPILE_TIME_ASSERT (assertion_name,			  \
54 			       (((value) ^ ((value)-1)) == ((value) << 1) - 1))
55 
56 #ifndef __ubicom32__
57 #define HIF_MALLOC_DIAGMEM(osdev, size, pa, context, retry) \
58 	os_malloc_CONSISTENT(osdev, size, pa, context, retry)
59 #define HIF_FREE_DIAGMEM(osdev, size, vaddr, pa, context) \
60 	OS_FREE_CONSISTENT(osdev, size, vaddr, pa, context)
61 #define HIF_DIAGMEM_SYNC(osdev, pa, size, dir, context)
62 #else
63 #define HIF_MALLOC_DIAGMEM(osdev, size, pa, context, retry) \
64 	os_malloc_NONCONSISTENT(osdev, size, pa, context, retry)
65 #define HIF_FREE_DIAGMEM(osdev, size, vaddr, pa, context) \
66 	OS_FREE_NONCONSISTENT(osdev, size, vaddr, pa, context)
67 #define HIF_DIAGMEM_SYNC(osdev, pa, size, dir, context)	\
68 	OS_SYNC_SINGLE(osdev, pa, size, dir, context)
69 #endif /* ubicom32 */
70 
71 #endif /* _OSAPI_H_ */
72