Add qemu 2.4.0
[kvmfornfv.git] / qemu / roms / ipxe / src / drivers / net / wlan_compat.h
1 /* src/include/wlan/wlan_compat.h
2 *
3 * Types and macros to aid in portability
4 *
5 * Copyright (C) 1999 AbsoluteValue Systems, Inc.  All Rights Reserved.
6 * --------------------------------------------------------------------
7 *
8 * linux-wlan
9 *
10 *   The contents of this file are subject to the Mozilla Public
11 *   License Version 1.1 (the "License"); you may not use this file
12 *   except in compliance with the License. You may obtain a copy of
13 *   the License at http://www.mozilla.org/MPL/
14 *
15 *   Software distributed under the License is distributed on an "AS
16 *   IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
17 *   implied. See the License for the specific language governing
18 *   rights and limitations under the License.
19 *
20 *   Alternatively, the contents of this file may be used under the
21 *   terms of the GNU Public License version 2 (the "GPL"), in which
22 *   case the provisions of the GPL are applicable instead of the
23 *   above.  If you wish to allow the use of your version of this file
24 *   only under the terms of the GPL and not to allow others to use
25 *   your version of this file under the MPL, indicate your decision
26 *   by deleting the provisions above and replace them with the notice
27 *   and other provisions required by the GPL.  If you do not delete
28 *   the provisions above, a recipient may use your version of this
29 *   file under either the MPL or the GPL.
30 *
31 * --------------------------------------------------------------------
32 *
33 * Inquiries regarding the linux-wlan Open Source project can be
34 * made directly to:
35 *
36 * AbsoluteValue Systems Inc.
37 * info@linux-wlan.com
38 * http://www.linux-wlan.com
39 *
40 * --------------------------------------------------------------------
41 *
42 * Portions of the development of this software were funded by
43 * Intersil Corporation as part of PRISM(R) chipset product development.
44 *
45 * --------------------------------------------------------------------
46 */
47
48 FILE_LICENCE ( GPL2_ONLY );
49
50 #ifndef _WLAN_COMPAT_H
51 #define _WLAN_COMPAT_H
52
53 /*=============================================================*/
54 /*------ Establish Platform Identity --------------------------*/
55 /*=============================================================*/
56 /* Key macros: */
57 /* WLAN_CPU_FAMILY */
58         #define WLAN_Ix86                       1
59         #define WLAN_PPC                        2
60         #define WLAN_Ix96                       3
61         #define WLAN_ARM                        4
62         #define WLAN_ALPHA                      5
63         #define WLAN_MIPS                       6
64         #define WLAN_HPPA                       7
65 /* WLAN_CPU_CORE */
66         #define WLAN_I386CORE                   1
67         #define WLAN_PPCCORE                    2
68         #define WLAN_I296                       3
69         #define WLAN_ARMCORE                    4
70         #define WLAN_ALPHACORE                  5
71         #define WLAN_MIPSCORE                   6
72         #define WLAN_HPPACORE                   7
73 /* WLAN_CPU_PART */
74         #define WLAN_I386PART                   1
75         #define WLAN_MPC860                     2
76         #define WLAN_MPC823                     3
77         #define WLAN_I296SA                     4
78         #define WLAN_PPCPART                    5
79         #define WLAN_ARMPART                    6
80         #define WLAN_ALPHAPART                  7
81         #define WLAN_MIPSPART                   8
82         #define WLAN_HPPAPART                   9
83 /* WLAN_SYSARCH */
84         #define WLAN_PCAT                       1
85         #define WLAN_MBX                        2
86         #define WLAN_RPX                        3
87         #define WLAN_LWARCH                     4
88         #define WLAN_PMAC                       5
89         #define WLAN_SKIFF                      6
90         #define WLAN_BITSY                      7
91         #define WLAN_ALPHAARCH                  7
92         #define WLAN_MIPSARCH                   9
93         #define WLAN_HPPAARCH                   10
94 /* WLAN_OS */
95         #define WLAN_LINUX_KERNEL               1
96         #define WLAN_LINUX_USER                 2
97 /* WLAN_HOSTIF (generally set on the command line, not detected) */
98         #define WLAN_PCMCIA                     1
99         #define WLAN_ISA                        2
100         #define WLAN_PCI                        3
101         #define WLAN_USB                        4
102         #define WLAN_PLX                        5
103
104 /* Note: the PLX HOSTIF above refers to some vendors implementations for */
105 /*       PCI.  It's a PLX chip that is a PCI to PCMCIA adapter, but it   */
106 /*       isn't a real PCMCIA host interface adapter providing all the    */
107 /*       card&socket services.                                           */
108
109 /* Lets try to figure out what we've got.  Kernel mode or User mode? */
110 #if defined(__KERNEL__)
111         #define WLAN_OS                         WLAN_LINUX_KERNEL
112 #else
113         #define WLAN_OS                         WLAN_LINUX_USER
114 #endif
115
116 #ifdef __powerpc__
117 #ifndef __ppc__
118 #define __ppc__
119 #endif
120 #endif
121
122 #if (defined(CONFIG_PPC) || defined(CONFIG_8xx))
123 #ifndef __ppc__
124 #define __ppc__
125 #endif
126 #endif
127
128 #if defined(__KERNEL__)
129 #if defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__)
130         #define WLAN_CPU_FAMILY         WLAN_Ix86
131         #define WLAN_CPU_CORE           WLAN_I386CORE
132         #define WLAN_CPU_PART           WLAN_I386PART
133         #define WLAN_SYSARCH            WLAN_PCAT
134 #elif defined(__ppc__)
135         #define WLAN_CPU_FAMILY         WLAN_PPC
136         #define WLAN_CPU_CORE           WLAN_PPCCORE
137         #if defined(CONFIG_MBX)
138                 #define WLAN_CPU_PART   WLAN_MPC860
139                 #define WLAN_SYSARCH    WLAN_MBX
140         #elif defined(CONFIG_RPXLITE)
141                 #define WLAN_CPU_PART   WLAN_MPC823
142                 #define WLAN_SYSARCH    WLAN_RPX
143         #elif defined(CONFIG_RPXCLASSIC)
144                 #define WLAN_CPU_PART   WLAN_MPC860
145                 #define WLAN_SYSARCH    WLAN_RPX
146         #else
147                 #define WLAN_CPU_PART   WLAN_PPCPART
148                 #define WLAN_SYSARCH    WLAN_PMAC
149         #endif
150 #elif defined(__arm__)
151         #define WLAN_CPU_FAMILY         WLAN_ARM
152         #define WLAN_CPU_CORE           WLAN_ARMCORE
153         #define WLAN_CPU_PART           WLAN_ARM_PART
154         #define WLAN_SYSARCH            WLAN_SKIFF
155 #elif defined(__alpha__)
156         #define WLAN_CPU_FAMILY         WLAN_ALPHA
157         #define WLAN_CPU_CORE           WLAN_ALPHACORE
158         #define WLAN_CPU_PART           WLAN_ALPHAPART
159         #define WLAN_SYSARCH            WLAN_ALPHAARCH
160 #elif defined(__mips__)
161         #define WLAN_CPU_FAMILY         WLAN_MIPS
162         #define WLAN_CPU_CORE           WLAN_MIPSCORE
163         #define WLAN_CPU_PART           WLAN_MIPSPART
164         #define WLAN_SYSARCH            WLAN_MIPSARCH
165 #elif defined(__hppa__)
166         #define WLAN_CPU_FAMILY         WLAN_HPPA
167         #define WLAN_CPU_CORE           WLAN_HPPACORE
168         #define WLAN_CPU_PART           WLAN_HPPAPART
169         #define WLAN_SYSARCH            WLAN_HPPAARCH
170 #else
171         #error "No CPU identified!"
172 #endif
173 #endif /* __KERNEL__ */
174
175 /*
176    Some big endian machines implicitly do all I/O in little endian mode.
177
178    In particular:
179           Linux/PPC on PowerMacs (PCI)
180           Arm/Intel Xscale (PCI)
181
182    This may also affect PLX boards and other BE &| PPC platforms;
183    as new ones are discovered, add them below.
184 */
185
186 #if (WLAN_HOSTIF == WLAN_PCI)
187 #if ((WLAN_SYSARCH == WLAN_SKIFF) || (WLAN_SYSARCH == WLAN_PMAC))
188 #define REVERSE_ENDIAN
189 #endif
190 #endif
191
192 /*=============================================================*/
193 /*------ Bit settings -----------------------------------------*/
194 /*=============================================================*/
195
196 #define BIT0    0x00000001
197 #define BIT1    0x00000002
198 #define BIT2    0x00000004
199 #define BIT3    0x00000008
200 #define BIT4    0x00000010
201 #define BIT5    0x00000020
202 #define BIT6    0x00000040
203 #define BIT7    0x00000080
204 #define BIT8    0x00000100
205 #define BIT9    0x00000200
206 #define BIT10   0x00000400
207 #define BIT11   0x00000800
208 #define BIT12   0x00001000
209 #define BIT13   0x00002000
210 #define BIT14   0x00004000
211 #define BIT15   0x00008000
212 #define BIT16   0x00010000
213 #define BIT17   0x00020000
214 #define BIT18   0x00040000
215 #define BIT19   0x00080000
216 #define BIT20   0x00100000
217 #define BIT21   0x00200000
218 #define BIT22   0x00400000
219 #define BIT23   0x00800000
220 #define BIT24   0x01000000
221 #define BIT25   0x02000000
222 #define BIT26   0x04000000
223 #define BIT27   0x08000000
224 #define BIT28   0x10000000
225 #define BIT29   0x20000000
226 #define BIT30   0x40000000
227 #define BIT31   0x80000000
228
229 /*=============================================================*/
230 /*------ Compiler Portability Macros --------------------------*/
231 /*=============================================================*/
232 #define __WLAN_ATTRIB_PACK__            __attribute__ ((packed))
233 #define __WLAN_PRAGMA_PACK1__
234 #define __WLAN_PRAGMA_PACKDFLT__
235 #define __WLAN_INLINE__                 inline
236 #define WLAN_MIN_ARRAY                  0
237
238 /*=============================================================*/
239 /*------ OS Portability Macros --------------------------------*/
240 /*=============================================================*/
241
242 #ifndef WLAN_DBVAR
243 #define WLAN_DBVAR      wlan_debug
244 #endif
245
246 #if (WLAN_OS == WLAN_LINUX_KERNEL)
247         #define WLAN_LOG_ERROR0(x) printk(KERN_ERR "%s: " x , __FUNCTION__ );
248         #define WLAN_LOG_ERROR1(x,n) printk(KERN_ERR "%s: " x , __FUNCTION__ , (n));
249         #define WLAN_LOG_ERROR2(x,n1,n2) printk(KERN_ERR "%s: " x , __FUNCTION__ , (n1), (n2));
250         #define WLAN_LOG_ERROR3(x,n1,n2,n3) printk(KERN_ERR "%s: " x , __FUNCTION__, (n1), (n2), (n3));
251         #define WLAN_LOG_ERROR4(x,n1,n2,n3,n4) printk(KERN_ERR "%s: " x , __FUNCTION__, (n1), (n2), (n3), (n4));
252
253         #define WLAN_LOG_WARNING0(x) printk(KERN_WARNING "%s: " x , __FUNCTION__);
254         #define WLAN_LOG_WARNING1(x,n) printk(KERN_WARNING "%s: " x , __FUNCTION__, (n));
255         #define WLAN_LOG_WARNING2(x,n1,n2) printk(KERN_WARNING "%s: " x , __FUNCTION__, (n1), (n2));
256         #define WLAN_LOG_WARNING3(x,n1,n2,n3) printk(KERN_WARNING "%s: " x , __FUNCTION__, (n1), (n2), (n3));
257         #define WLAN_LOG_WARNING4(x,n1,n2,n3,n4) printk(KERN_WARNING "%s: " x , __FUNCTION__ , (n1), (n2), (n3), (n4));
258
259         #define WLAN_LOG_NOTICE0(x) printk(KERN_NOTICE "%s: " x , __FUNCTION__);
260         #define WLAN_LOG_NOTICE1(x,n) printk(KERN_NOTICE "%s: " x , __FUNCTION__, (n));
261         #define WLAN_LOG_NOTICE2(x,n1,n2) printk(KERN_NOTICE "%s: " x , __FUNCTION__, (n1), (n2));
262         #define WLAN_LOG_NOTICE3(x,n1,n2,n3) printk(KERN_NOTICE "%s: " x , __FUNCTION__, (n1), (n2), (n3));
263         #define WLAN_LOG_NOTICE4(x,n1,n2,n3,n4) printk(KERN_NOTICE "%s: " x , __FUNCTION__, (n1), (n2), (n3), (n4));
264
265         #define WLAN_LOG_INFO0(x) printk(KERN_INFO x);
266         #define WLAN_LOG_INFO1(x,n) printk(KERN_INFO x, (n));
267         #define WLAN_LOG_INFO2(x,n1,n2) printk(KERN_INFO x, (n1), (n2));
268         #define WLAN_LOG_INFO3(x,n1,n2,n3) printk(KERN_INFO x, (n1), (n2), (n3));
269         #define WLAN_LOG_INFO4(x,n1,n2,n3,n4) printk(KERN_INFO x, (n1), (n2), (n3), (n4));
270         #define WLAN_LOG_INFO5(x,n1,n2,n3,n4,n5) printk(KERN_INFO x, (n1), (n2), (n3), (n4), (n5));
271
272         #if defined(WLAN_INCLUDE_DEBUG)
273                 #define WLAN_ASSERT(c) if ((!(c)) && WLAN_DBVAR >= 1) { \
274                         WLAN_LOG_DEBUG0(1, "Assertion failure!\n"); }
275                 #define WLAN_HEX_DUMP( l, x, p, n)      if( WLAN_DBVAR >= (l) ){ \
276                         int __i__; \
277                         printk(KERN_DEBUG x ":"); \
278                         for( __i__=0; __i__ < (n); __i__++) \
279                                 printk( " %02x", ((uint8_t*)(p))[__i__]); \
280                         printk("\n"); }
281
282                 #define DBFENTER { if ( WLAN_DBVAR >= 4 ){ WLAN_LOG_DEBUG0(3,"Enter\n"); } }
283                 #define DBFEXIT  { if ( WLAN_DBVAR >= 4 ){ WLAN_LOG_DEBUG0(3,"Exit\n"); } }
284
285                 #define WLAN_LOG_DEBUG0(l,x) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s: " x ,  __FUNCTION__ );
286                 #define WLAN_LOG_DEBUG1(l,x,n) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s: " x , __FUNCTION__ , (n));
287                 #define WLAN_LOG_DEBUG2(l,x,n1,n2) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s: " x , __FUNCTION__ , (n1), (n2));
288                 #define WLAN_LOG_DEBUG3(l,x,n1,n2,n3) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s: " x , __FUNCTION__ , (n1), (n2), (n3));
289                 #define WLAN_LOG_DEBUG4(l,x,n1,n2,n3,n4) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s: " x , __FUNCTION__ , (n1), (n2), (n3), (n4));
290                 #define WLAN_LOG_DEBUG5(l,x,n1,n2,n3,n4,n5) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s: " x , __FUNCTION__ , (n1), (n2), (n3), (n4), (n5));
291                 #define WLAN_LOG_DEBUG6(l,x,n1,n2,n3,n4,n5,n6) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s: " x , __FUNCTION__ , (n1), (n2), (n3), (n4), (n5), (n6));
292         #else
293                 #define WLAN_ASSERT(c)
294                 #define WLAN_HEX_DUMP( l, s, p, n)
295
296                 #define DBFENTER
297                 #define DBFEXIT
298
299                 #define WLAN_LOG_DEBUG0(l, s)
300                 #define WLAN_LOG_DEBUG1(l, s,n)
301                 #define WLAN_LOG_DEBUG2(l, s,n1,n2)
302                 #define WLAN_LOG_DEBUG3(l, s,n1,n2,n3)
303                 #define WLAN_LOG_DEBUG4(l, s,n1,n2,n3,n4)
304                 #define WLAN_LOG_DEBUG5(l, s,n1,n2,n3,n4,n5)
305         #endif
306 #else
307         #define WLAN_LOG_ERROR0(s)
308         #define WLAN_LOG_ERROR1(s,n)
309         #define WLAN_LOG_ERROR2(s,n1,n2)
310         #define WLAN_LOG_ERROR3(s,n1,n2,n3)
311         #define WLAN_LOG_ERROR4(s,n1,n2,n3,n4)
312
313         #define WLAN_LOG_WARNING0(s)
314         #define WLAN_LOG_WARNING1(s,n)
315         #define WLAN_LOG_WARNING2(s,n1,n2)
316         #define WLAN_LOG_WARNING3(s,n1,n2,n3)
317         #define WLAN_LOG_WARNING4(s,n1,n2,n3,n4)
318
319         #define WLAN_LOG_NOTICE0(s)
320         #define WLAN_LOG_NOTICE1(s,n)
321         #define WLAN_LOG_NOTICE2(s,n1,n2)
322         #define WLAN_LOG_NOTICE3(s,n1,n2,n3)
323         #define WLAN_LOG_NOTICE4(s,n1,n2,n3,n4)
324
325                 #define WLAN_ASSERT(c)
326                 #define WLAN_HEX_DUMP( l, s, p, n)
327
328                 #define DBFENTER
329                 #define DBFEXIT
330
331                 #define WLAN_LOG_INFO0(s)
332                 #define WLAN_LOG_INFO1(s,n)
333                 #define WLAN_LOG_INFO2(s,n1,n2)
334                 #define WLAN_LOG_INFO3(s,n1,n2,n3)
335                 #define WLAN_LOG_INFO4(s,n1,n2,n3,n4)
336                 #define WLAN_LOG_INFO5(s,n1,n2,n3,n4,n5)
337
338                 #define WLAN_LOG_DEBUG0(l, s)
339                 #define WLAN_LOG_DEBUG1(l, s,n)
340                 #define WLAN_LOG_DEBUG2(l, s,n1,n2)
341                 #define WLAN_LOG_DEBUG3(l, s,n1,n2,n3)
342                 #define WLAN_LOG_DEBUG4(l, s,n1,n2,n3,n4)
343                 #define WLAN_LOG_DEBUG5(l, s,n1,n2,n3,n4,n5)
344 #endif
345
346 #define wlan_ms_per_tick                (1000UL / (wlan_ticks_per_sec))
347 #define wlan_ms_to_ticks(n)             ( (n) / (wlan_ms_per_tick))
348 #define wlan_tu2ticks(n)                ( (n) / (wlan_ms_per_tick))
349 #define WLAN_INT_DISABLE(n)             { save_flags((n)); cli(); }
350 #define WLAN_INT_ENABLE(n)              { sti(); restore_flags((n)); }
351
352 #ifdef CONFIG_MODVERSIONS
353 #define MODVERSIONS             1
354 #include <linux/modversions.h>
355 #endif
356
357 #ifdef CONFIG_SMP
358 #define __SMP__                 1
359 #endif
360
361 #ifndef KERNEL_VERSION
362 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
363 #endif
364
365 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,17))
366 #define CONFIG_NETLINK          1
367 #endif
368
369 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0))
370 #define kfree_s(a, b)   kfree((a))
371 #endif
372
373 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18))
374 #ifndef init_waitqueue_head
375 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,0,16))
376 #define init_waitqueue_head(p)  (*(p) = NULL)
377 #else
378 #define init_waitqueue_head(p)  init_waitqueue(p)
379 #endif
380 typedef struct wait_queue *wait_queue_head_t;
381 typedef struct wait_queue wait_queue_t;
382 #define set_current_state(b)  { current->state = (b); mb(); }
383 #define init_waitqueue_entry(a, b) { (a)->task = current; }
384 #endif
385 #endif
386
387 #ifndef wait_event_interruptible_timeout
388 // retval == 0; signal met; we're good.
389 // retval < 0; interrupted by signal.
390 // retval > 0; timed out.
391 #define __wait_event_interruptible_timeout(wq, condition, timeout, ret)   \
392 do {                                                                      \
393         int __ret = 0;                                                    \
394         if (!(condition)) {                                               \
395           wait_queue_t __wait;                                            \
396           unsigned long expire;                                           \
397           init_waitqueue_entry(&__wait, current);                         \
398                                                                           \
399           expire = timeout + jiffies;                                     \
400           add_wait_queue(&wq, &__wait);                                   \
401           for (;;) {                                                      \
402                   set_current_state(TASK_INTERRUPTIBLE);                  \
403                   if (condition)                                          \
404                           break;                                          \
405                   if (jiffies > expire) {                                 \
406                           ret = jiffies - expire;                         \
407                           break;                                          \
408                   }                                                       \
409                   if (!signal_pending(current)) {                         \
410                           schedule_timeout(timeout);                      \
411                           continue;                                       \
412                   }                                                       \
413                   ret = -ERESTARTSYS;                                     \
414                   break;                                                  \
415           }                                                               \
416           set_current_state(TASK_RUNNING);                                \
417           remove_wait_queue(&wq, &__wait);                                \
418         }                                                                 \
419 } while (0)
420
421 #define wait_event_interruptible_timeout(wq, condition, timeout)        \
422 ({                                                                      \
423         int __ret = 0;                                                  \
424         if (!(condition))                                               \
425                 __wait_event_interruptible_timeout(wq, condition,       \
426                                                 timeout, __ret);        \
427         __ret;                                                          \
428 })
429
430 #endif
431
432 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,90))
433 #define spin_lock(l)            do { } while (0)
434 #define spin_unlock(l)          do { } while (0)
435 #define spin_lock_irqsave(l,f)  do { save_flags(f); cli(); } while (0)
436 #define spin_unlock_irqrestore(l,f) do { restore_flags(f); } while (0)
437 #define spin_lock_init(s)       do { } while (0)
438 #define spin_trylock(l)         (1)
439 typedef int spinlock_t;
440 #endif
441
442 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
443 #ifdef CONFIG_SMP
444 #define spin_is_locked(x)       (*(volatile char *)(&(x)->lock) <= 0)
445 #else
446 #define spin_is_locked(l)       (0)
447 #endif
448 #endif
449
450 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38))
451 typedef struct device netdevice_t;
452 #elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,4))
453 typedef struct net_device netdevice_t;
454 #else
455 #undef netdevice_t
456 typedef struct net_device netdevice_t;
457 #endif
458
459 #ifdef WIRELESS_EXT
460 #if (WIRELESS_EXT < 13)
461 struct iw_request_info
462 {
463         __u16           cmd;            /* Wireless Extension command */
464         __u16           flags;          /* More to come ;-) */
465 };
466 #endif
467 #endif
468
469
470 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,18))
471 #define MODULE_PARM(a,b)        extern int __bogus_decl
472 #define MODULE_AUTHOR(a)        extern int __bogus_decl
473 #define MODULE_DESCRIPTION(a)   extern int __bogus_decl
474 #define MODULE_SUPPORTED_DEVICE(a) extern int __bogus_decl
475 #undef  GET_USE_COUNT
476 #define GET_USE_COUNT(m)        mod_use_count_
477 #endif
478
479 #ifndef MODULE_LICENSE
480 #define MODULE_LICENSE(m)       extern int __bogus_decl
481 #endif
482
483 /* TODO:  Do we care about this? */
484 #ifndef MODULE_DEVICE_TABLE
485 #define MODULE_DEVICE_TABLE(foo,bar)
486 #endif
487
488 #define wlan_minutes2ticks(a) ((a)*(wlan_ticks_per_sec *  60))
489 #define wlan_seconds2ticks(a) ((a)*(wlan_ticks_per_sec))
490
491 /*=============================================================*/
492 /*------ Hardware Portability Macros --------------------------*/
493 /*=============================================================*/
494
495 #define ieee2host16(n)  __le16_to_cpu(n)
496 #define ieee2host32(n)  __le32_to_cpu(n)
497 #define host2ieee16(n)  __cpu_to_le16(n)
498 #define host2ieee32(n)  __cpu_to_le32(n)
499
500 #if (WLAN_CPU_FAMILY == WLAN_PPC)
501        #define wlan_inw(a)                     in_be16((unsigned short *)((a)+_IO_BASE))
502        #define wlan_inw_le16_to_cpu(a)         inw((a))
503        #define wlan_outw(v,a)                  out_be16((unsigned short *)((a)+_IO_BASE), (v))
504        #define wlan_outw_cpu_to_le16(v,a)      outw((v),(a))
505 #else
506        #define wlan_inw(a)                     inw((a))
507        #define wlan_inw_le16_to_cpu(a)         __cpu_to_le16(inw((a)))
508        #define wlan_outw(v,a)                  outw((v),(a))
509        #define wlan_outw_cpu_to_le16(v,a)      outw(__cpu_to_le16((v)),(a))
510 #endif
511
512 /*=============================================================*/
513 /*--- General Macros ------------------------------------------*/
514 /*=============================================================*/
515
516 #define wlan_max(a, b) (((a) > (b)) ? (a) : (b))
517 #define wlan_min(a, b) (((a) < (b)) ? (a) : (b))
518
519 #define wlan_isprint(c) (((c) > (0x19)) && ((c) < (0x7f)))
520
521 #define wlan_hexchar(x) (((x) < 0x0a) ? ('0' + (x)) : ('a' + ((x) - 0x0a)))
522
523 /* Create a string of printable chars from something that might not be */
524 /* It's recommended that the str be 4*len + 1 bytes long */
525 #define wlan_mkprintstr(buf, buflen, str, strlen) \
526 { \
527         int i = 0; \
528         int j = 0; \
529         memset(str, 0, (strlen)); \
530         for (i = 0; i < (buflen); i++) { \
531                 if ( wlan_isprint((buf)[i]) ) { \
532                         (str)[j] = (buf)[i]; \
533                         j++; \
534                 } else { \
535                         (str)[j] = '\\'; \
536                         (str)[j+1] = 'x'; \
537                         (str)[j+2] = wlan_hexchar(((buf)[i] & 0xf0) >> 4); \
538                         (str)[j+3] = wlan_hexchar(((buf)[i] & 0x0f)); \
539                         j += 4; \
540                 } \
541         } \
542 }
543
544 /*=============================================================*/
545 /*--- Variables -----------------------------------------------*/
546 /*=============================================================*/
547
548 extern int wlan_debug;
549 extern int wlan_ethconv;                /* What's the default ethconv? */
550
551 /*=============================================================*/
552 /*--- Functions -----------------------------------------------*/
553 /*=============================================================*/
554 #endif /* _WLAN_COMPAT_H */
555