]> Pileus Git - ~andy/linux/blob - drivers/staging/csr/unifi_os.h
nfs: disintegrate UAPI for nfs
[~andy/linux] / drivers / staging / csr / unifi_os.h
1 /*
2  * ---------------------------------------------------------------------------
3  *
4  * FILE: os_linux/unifi_os.h
5  *
6  * PURPOSE:
7  *      This header file provides the OS-dependent facilities for a linux
8  *      environment.
9  *
10  * Copyright (C) 2005-2008 by Cambridge Silicon Radio Ltd.
11  *
12  * Refer to LICENSE.txt included with this source code for details on
13  * the license terms.
14  *
15  * ---------------------------------------------------------------------------
16  */
17 #ifndef __UNIFI_OS_LINUX_H__
18 #define __UNIFI_OS_LINUX_H__ 1
19
20 #include <linux/kernel.h>
21 #include <linux/time.h>
22 #include <linux/list.h>
23 #include <linux/delay.h>
24 #include <linux/string.h>
25
26 /*
27  * Needed for core/signals.c
28  */
29 #include <stddef.h>
30
31
32 /* Define INLINE directive*/
33 #define INLINE      inline
34
35 /* Malloc and free */
36 CsrResult unifi_net_data_malloc(void *ospriv, bulk_data_desc_t *bulk_data_slot, unsigned int size);
37 void unifi_net_data_free(void *ospriv, bulk_data_desc_t *bulk_data_slot);
38 #define CSR_WIFI_ALIGN_BYTES    4
39 CsrResult unifi_net_dma_align(void *ospriv, bulk_data_desc_t *bulk_data_slot);
40
41 /*
42  * Byte Order
43  * Note that __le*_to_cpu and __cpu_to_le* return an unsigned value!
44  */
45 #ifdef __KERNEL__
46 #define unifi2host_16(n)        (__le16_to_cpu((n)))
47 #define unifi2host_32(n)        (__le32_to_cpu((n)))
48 #define host2unifi_16(n)        (__cpu_to_le16((n)))
49 #define host2unifi_32(n)        (__cpu_to_le32((n)))
50 #endif
51
52 /* Module parameters */
53 extern int unifi_debug;
54
55 /* debugging */
56 #ifdef UNIFI_DEBUG
57 /*
58  * unifi_debug is a verbosity level for debug messages
59  * UDBG0 msgs are always printed if UNIFI_DEBUG is defined
60  * UDBG1 msgs are printed if UNIFI_DEBUG is defined and unifi_debug > 0
61  * etc.
62  */
63
64 #define func_enter()                                    \
65     do {                                                \
66         if (unifi_debug >= 5) {                         \
67             printk("unifi: => %s\n", __FUNCTION__);     \
68         }                                               \
69     } while (0)
70 #define func_exit()                                     \
71     do {                                                \
72         if (unifi_debug >= 5) {                         \
73             printk("unifi: <= %s\n", __FUNCTION__);     \
74         }                                               \
75     } while (0)
76 #define func_exit_r(_rc)                                        \
77     do {                                                        \
78         if (unifi_debug >= 5) {                                 \
79             printk("unifi: <= %s %d\n", __FUNCTION__, (int)(_rc));   \
80         }                                                       \
81     } while (0)
82
83
84 #define ASSERT(cond)                                            \
85     do {                                                            \
86         if (!(cond)) {                                              \
87             printk("Assertion failed in %s at %s:%d: %s\n",         \
88                     __FUNCTION__, __FILE__, __LINE__, #cond);        \
89         }                                                           \
90     } while (0)
91
92
93 void unifi_dump(void *ospriv, int lvl, const char *msg, void *mem, u16 len);
94 void dump(void *mem, u16 len);
95 void dump16(void *mem, u16 len);
96 #ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
97 void dump_str(void *mem, u16 len);
98 #endif /* CSR_WIFI_HIP_DEBUG_OFFLINE */
99
100 void unifi_error(void* ospriv, const char *fmt, ...);
101 void unifi_warning(void* ospriv, const char *fmt, ...);
102 void unifi_notice(void* ospriv, const char *fmt, ...);
103 void unifi_info(void* ospriv, const char *fmt, ...);
104
105 void unifi_trace(void* ospriv, int level, const char *fmt, ...);
106
107 #else
108
109 /* Stubs */
110 #define func_enter()
111 #define func_exit()
112 #define func_exit_r(_rc)
113
114 #define ASSERT(cond)
115
116 static inline void unifi_dump(void *ospriv, int lvl, const char *msg, void *mem, u16 len) {}
117 static inline void dump(void *mem, u16 len) {}
118 static inline void dump16(void *mem, u16 len) {}
119 #ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
120 static inline void dump_str(void *mem, u16 len) {}
121 #endif /* CSR_WIFI_HIP_DEBUG_OFFLINE */
122
123 void unifi_error_nop(void* ospriv, const char *fmt, ...);
124 void unifi_trace_nop(void* ospriv, int level, const char *fmt, ...);
125 #define unifi_error if(1);else unifi_error_nop
126 #define unifi_warning if(1);else unifi_error_nop
127 #define unifi_notice if(1);else unifi_error_nop
128 #define unifi_info if(1);else unifi_error_nop
129 #define unifi_trace if(1);else unifi_trace_nop
130
131 #endif /* UNIFI_DEBUG */
132
133
134 /* Different levels of diagnostic detail... */
135 #define UDBG0       0   /* always prints in debug build */
136 #define UDBG1       1
137 #define UDBG2       2
138 #define UDBG3       3
139 #define UDBG4       4
140 #define UDBG5       5
141 #define UDBG6       6
142 #define UDBG7       7
143
144
145 #endif /* __UNIFI_OS_LINUX_H__ */