Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(327)

Side by Side Diff: chromeos/drivers/ath6kl/os/linux/include/osapi_linux.h

Issue 646055: Atheros AR600x driver + build glue (Closed)
Patch Set: Created 10 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 * This file contains the definitions of the basic atheros data types.
3 * It is used to map the data types in atheros files to a platform specific
4 * type.
5 *
6 * Copyright 2003-2005 Atheros Communications, Inc., All Rights Reserved.
7 *
8 *
9 // This program is free software; you can redistribute it and/or modify
10 // it under the terms of the GNU General Public License version 2 as
11 // published by the Free Software Foundation;
12 //
13 // Software distributed under the License is distributed on an "AS
14 // IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
15 // implied. See the License for the specific language governing
16 // rights and limitations under the License.
17 //
18 //
19 *
20 */
21
22 #ifndef _OSAPI_LINUX_H_
23 #define _OSAPI_LINUX_H_
24
25 #ifdef __KERNEL__
26
27 #include <linux/version.h>
28 #include <linux/types.h>
29 #include <linux/kernel.h>
30 #include <linux/string.h>
31 #include <linux/skbuff.h>
32 #include <linux/netdevice.h>
33 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
34 #include <linux/jiffies.h>
35 #endif
36 #include <linux/timer.h>
37 #include <linux/delay.h>
38 #include <linux/wait.h>
39 #ifdef KERNEL_2_4
40 #include <asm/arch/irq.h>
41 #include <asm/irq.h>
42 #endif
43
44 #include <linux/cache.h>
45
46 #ifdef __GNUC__
47 #define __ATTRIB_PACK __attribute__ ((packed))
48 #define __ATTRIB_PRINTF __attribute__ ((format (printf, 1, 2)))
49 #define __ATTRIB_NORETURN __attribute__ ((noreturn))
50 #ifndef INLINE
51 #define INLINE __inline__
52 #endif
53 #else /* Not GCC */
54 #define __ATTRIB_PACK
55 #define __ATTRIB_PRINTF
56 #define __ATTRIB_NORETURN
57 #ifndef INLINE
58 #define INLINE __inline
59 #endif
60 #endif /* End __GNUC__ */
61
62 #define PREPACK
63 #define POSTPACK __ATTRIB_PACK
64
65 /*
66 * Endianes macros
67 */
68 #define A_BE2CPU8(x) ntohb(x)
69 #define A_BE2CPU16(x) ntohs(x)
70 #define A_BE2CPU32(x) ntohl(x)
71
72 #define A_LE2CPU8(x) (x)
73 #define A_LE2CPU16(x) (x)
74 #define A_LE2CPU32(x) (x)
75
76 #define A_CPU2BE8(x) htonb(x)
77 #define A_CPU2BE16(x) htons(x)
78 #define A_CPU2BE32(x) htonl(x)
79
80 #define A_MEMCPY(dst, src, len) memcpy((A_UINT8 *)(dst), (src), (len))
81 #define A_MEMZERO(addr, len) memset(addr, 0, len)
82 #define A_MEMCMP(addr1, addr2, len) memcmp((addr1), (addr2), (len))
83 #define A_MALLOC(size) kmalloc((size), GFP_KERNEL)
84 #define A_MALLOC_NOWAIT(size) kmalloc((size), GFP_ATOMIC)
85 #define A_FREE(addr) kfree(addr)
86 #define A_PRINTF(args...) printk(KERN_ALERT args)
87 #define A_PRINTF_LOG(args...) printk(args)
88 #define A_SPRINTF(buf, args...) sprintf (buf, args)
89
90 /* Mutual Exclusion */
91 typedef spinlock_t A_MUTEX_T;
92 #define A_MUTEX_INIT(mutex) spin_lock_init(mutex)
93 #define A_MUTEX_LOCK(mutex) spin_lock_bh(mutex)
94 #define A_MUTEX_UNLOCK(mutex) spin_unlock_bh(mutex)
95 #define A_IS_MUTEX_VALID(mutex) TRUE /* okay to return true, since A_MU TEX_DELETE does nothing */
96 #define A_MUTEX_DELETE(mutex) /* spin locks are not kernel resources s o nothing to free.. */
97
98 /* Get current time in ms adding a constant offset (in ms) */
99 #define A_GET_MS(offset) \
100 (jiffies + ((offset) / 1000) * HZ)
101
102 /*
103 * Timer Functions
104 */
105 #define A_MDELAY(msecs) mdelay(msecs)
106 typedef struct timer_list A_TIMER;
107
108 #define A_INIT_TIMER(pTimer, pFunction, pArg) do { \
109 init_timer(pTimer); \
110 (pTimer)->function = (pFunction); \
111 (pTimer)->data = (unsigned long)(pArg); \
112 } while (0)
113
114 /*
115 * Start a Timer that elapses after 'periodMSec' milli-seconds
116 * Support is provided for a one-shot timer. The 'repeatFlag' is
117 * ignored.
118 */
119 #define A_TIMEOUT_MS(pTimer, periodMSec, repeatFlag) do { \
120 if (repeatFlag) { \
121 printk("\n" __FILE__ ":%d: Timer Repeat requested\n",__LINE__); \
122 panic("Timer Repeat"); \
123 } \
124 mod_timer((pTimer), jiffies + HZ * (periodMSec) / 1000); \
125 } while (0)
126
127 /*
128 * Cancel the Timer.
129 */
130 #define A_UNTIMEOUT(pTimer) do { \
131 del_timer((pTimer)); \
132 } while (0)
133
134 #define A_DELETE_TIMER(pTimer) do { \
135 } while (0)
136
137 /*
138 * Wait Queue related functions
139 */
140 typedef wait_queue_head_t A_WAITQUEUE_HEAD;
141 #define A_INIT_WAITQUEUE_HEAD(head) init_waitqueue_head(head)
142 #ifndef wait_event_interruptible_timeout
143 #define __wait_event_interruptible_timeout(wq, condition, ret) \
144 do { \
145 wait_queue_t __wait; \
146 init_waitqueue_entry(&__wait, current); \
147 \
148 add_wait_queue(&wq, &__wait); \
149 for (;;) { \
150 set_current_state(TASK_INTERRUPTIBLE); \
151 if (condition) \
152 break; \
153 if (!signal_pending(current)) { \
154 ret = schedule_timeout(ret); \
155 if (!ret) \
156 break; \
157 continue; \
158 } \
159 ret = -ERESTARTSYS; \
160 break; \
161 } \
162 current->state = TASK_RUNNING; \
163 remove_wait_queue(&wq, &__wait); \
164 } while (0)
165
166 #define wait_event_interruptible_timeout(wq, condition, timeout) \
167 ({ \
168 long __ret = timeout; \
169 if (!(condition)) \
170 __wait_event_interruptible_timeout(wq, condition, __ret); \
171 __ret; \
172 })
173 #endif /* wait_event_interruptible_timeout */
174
175 #define A_WAIT_EVENT_INTERRUPTIBLE_TIMEOUT(head, condition, timeout) do { \
176 wait_event_interruptible_timeout(head, condition, timeout); \
177 } while (0)
178
179 #define A_WAKE_UP(head) wake_up(head)
180
181 #ifdef DEBUG
182 extern unsigned int panic_on_assert;
183 #define A_ASSERT(expr) \
184 if (!(expr)) { \
185 printk(KERN_ALERT"Debug Assert Caught, File %s, Line: %d, Test:%s \n",__ FILE__, __LINE__,#expr); \
186 if (panic_on_assert) panic(#expr); \
187 }
188 #else
189 #define A_ASSERT(expr)
190 #endif /* DEBUG */
191
192 /*
193 * Initialization of the network buffer subsystem
194 */
195 #define A_NETBUF_INIT()
196
197 /*
198 * Network buffer queue support
199 */
200 typedef struct sk_buff_head A_NETBUF_QUEUE_T;
201
202 #define A_NETBUF_QUEUE_INIT(q) \
203 a_netbuf_queue_init(q)
204
205 #define A_NETBUF_ENQUEUE(q, pkt) \
206 a_netbuf_enqueue((q), (pkt))
207 #define A_NETBUF_PREQUEUE(q, pkt) \
208 a_netbuf_prequeue((q), (pkt))
209 #define A_NETBUF_DEQUEUE(q) \
210 (a_netbuf_dequeue(q))
211 #define A_NETBUF_QUEUE_SIZE(q) \
212 a_netbuf_queue_size(q)
213 #define A_NETBUF_QUEUE_EMPTY(q) \
214 a_netbuf_queue_empty(q)
215
216 /*
217 * Network buffer support
218 */
219 #define A_NETBUF_ALLOC(size) \
220 a_netbuf_alloc(size)
221 #define A_NETBUF_ALLOC_RAW(size) \
222 a_netbuf_alloc_raw(size)
223 #define A_NETBUF_FREE(bufPtr) \
224 a_netbuf_free(bufPtr)
225 #define A_NETBUF_DATA(bufPtr) \
226 a_netbuf_to_data(bufPtr)
227 #define A_NETBUF_LEN(bufPtr) \
228 a_netbuf_to_len(bufPtr)
229 #define A_NETBUF_PUSH(bufPtr, len) \
230 a_netbuf_push(bufPtr, len)
231 #define A_NETBUF_PUT(bufPtr, len) \
232 a_netbuf_put(bufPtr, len)
233 #define A_NETBUF_TRIM(bufPtr,len) \
234 a_netbuf_trim(bufPtr, len)
235 #define A_NETBUF_PULL(bufPtr, len) \
236 a_netbuf_pull(bufPtr, len)
237 #define A_NETBUF_HEADROOM(bufPtr)\
238 a_netbuf_headroom(bufPtr)
239 #define A_NETBUF_SETLEN(bufPtr,len) \
240 a_netbuf_setlen(bufPtr, len)
241
242 /* Add data to end of a buffer */
243 #define A_NETBUF_PUT_DATA(bufPtr, srcPtr, len) \
244 a_netbuf_put_data(bufPtr, srcPtr, len)
245
246 /* Add data to start of the buffer */
247 #define A_NETBUF_PUSH_DATA(bufPtr, srcPtr, len) \
248 a_netbuf_push_data(bufPtr, srcPtr, len)
249
250 /* Remove data at start of the buffer */
251 #define A_NETBUF_PULL_DATA(bufPtr, dstPtr, len) \
252 a_netbuf_pull_data(bufPtr, dstPtr, len)
253
254 /* Remove data from the end of the buffer */
255 #define A_NETBUF_TRIM_DATA(bufPtr, dstPtr, len) \
256 a_netbuf_trim_data(bufPtr, dstPtr, len)
257
258 /* View data as "size" contiguous bytes of type "t" */
259 #define A_NETBUF_VIEW_DATA(bufPtr, t, size) \
260 (t )( ((struct skbuf *)(bufPtr))->data)
261
262 /* return the beginning of the headroom for the buffer */
263 #define A_NETBUF_HEAD(bufPtr) \
264 ((((struct sk_buff *)(bufPtr))->head))
265
266 /*
267 * OS specific network buffer access routines
268 */
269 void *a_netbuf_alloc(int size);
270 void *a_netbuf_alloc_raw(int size);
271 void a_netbuf_free(void *bufPtr);
272 void *a_netbuf_to_data(void *bufPtr);
273 A_UINT32 a_netbuf_to_len(void *bufPtr);
274 A_STATUS a_netbuf_push(void *bufPtr, A_INT32 len);
275 A_STATUS a_netbuf_push_data(void *bufPtr, char *srcPtr, A_INT32 len);
276 A_STATUS a_netbuf_put(void *bufPtr, A_INT32 len);
277 A_STATUS a_netbuf_put_data(void *bufPtr, char *srcPtr, A_INT32 len);
278 A_STATUS a_netbuf_pull(void *bufPtr, A_INT32 len);
279 A_STATUS a_netbuf_pull_data(void *bufPtr, char *dstPtr, A_INT32 len);
280 A_STATUS a_netbuf_trim(void *bufPtr, A_INT32 len);
281 A_STATUS a_netbuf_trim_data(void *bufPtr, char *dstPtr, A_INT32 len);
282 A_STATUS a_netbuf_setlen(void *bufPtr, A_INT32 len);
283 A_INT32 a_netbuf_headroom(void *bufPtr);
284 void a_netbuf_enqueue(A_NETBUF_QUEUE_T *q, void *pkt);
285 void a_netbuf_prequeue(A_NETBUF_QUEUE_T *q, void *pkt);
286 void *a_netbuf_dequeue(A_NETBUF_QUEUE_T *q);
287 int a_netbuf_queue_size(A_NETBUF_QUEUE_T *q);
288 int a_netbuf_queue_empty(A_NETBUF_QUEUE_T *q);
289 int a_netbuf_queue_empty(A_NETBUF_QUEUE_T *q);
290 void a_netbuf_queue_init(A_NETBUF_QUEUE_T *q);
291
292 /*
293 * Kernel v.s User space functions
294 */
295 A_UINT32 a_copy_to_user(void *to, const void *from, A_UINT32 n);
296 A_UINT32 a_copy_from_user(void *to, const void *from, A_UINT32 n);
297
298 /* In linux, WLAN Rx and Tx run in different contexts, so no need to check
299 * for any commands/data queued for WLAN */
300 #define A_CHECK_DRV_TX()
301
302 #define A_GET_CACHE_LINE_BYTES() L1_CACHE_BYTES
303
304 static inline void *A_ALIGN_TO_CACHE_LINE(void *ptr) {
305 return (void *)L1_CACHE_ALIGN((A_UINT32)ptr);
306 }
307
308 #else /* __KERNEL__ */
309
310 #ifdef __GNUC__
311 #define __ATTRIB_PACK __attribute__ ((packed))
312 #define __ATTRIB_PRINTF __attribute__ ((format (printf, 1, 2)))
313 #define __ATTRIB_NORETURN __attribute__ ((noreturn))
314 #ifndef INLINE
315 #define INLINE __inline__
316 #endif
317 #else /* Not GCC */
318 #define __ATTRIB_PACK
319 #define __ATTRIB_PRINTF
320 #define __ATTRIB_NORETURN
321 #ifndef INLINE
322 #define INLINE __inline
323 #endif
324 #endif /* End __GNUC__ */
325
326 #define PREPACK
327 #define POSTPACK __ATTRIB_PACK
328
329 #define A_MEMCPY(dst, src, len) memcpy((dst), (src), (len))
330 #define A_MEMZERO(addr, len) memset((addr), 0, (len))
331 #define A_MEMCMP(addr1, addr2, len) memcmp((addr1), (addr2), (len))
332 #define A_MALLOC(size) malloc(size)
333 #define A_FREE(addr) free(addr)
334 #endif /* __KERNEL__ */
335
336 #endif /* _OSAPI_LINUX_H_ */
OLDNEW
« no previous file with comments | « chromeos/drivers/ath6kl/os/linux/include/ieee80211_ioctl.h ('k') | chromeos/drivers/ath6kl/os/linux/include/wlan_config.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698