source: bootcd/isolinux/syslinux-6.03/gpxe/src/drivers/net/wlan_compat.h

Last change on this file was e16e8f2, checked in by Edwin Eefting <edwin@datux.nl>, 3 years ago

bootstuff

  • Property mode set to 100644
File size: 20.1 KB
Line 
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
48FILE_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
229typedef unsigned char   UINT8;
230typedef unsigned short  UINT16;
231typedef unsigned long   UINT32;
232
233typedef signed char     INT8;
234typedef signed short    INT16;
235typedef signed long     INT32;
236
237typedef unsigned int    UINT;
238typedef signed int      INT;
239
240typedef unsigned long long      UINT64;
241typedef signed long long        INT64;
242
243#define UINT8_MAX       (0xffUL)
244#define UINT16_MAX      (0xffffUL)
245#define UINT32_MAX      (0xffffffffUL)
246
247#define INT8_MAX        (0x7fL)
248#define INT16_MAX       (0x7fffL)
249#define INT32_MAX       (0x7fffffffL)
250
251/*=============================================================*/
252/*------ Compiler Portability Macros --------------------------*/
253/*=============================================================*/
254#define __WLAN_ATTRIB_PACK__            __attribute__ ((packed))
255#define __WLAN_PRAGMA_PACK1__
256#define __WLAN_PRAGMA_PACKDFLT__
257#define __WLAN_INLINE__                 inline
258#define WLAN_MIN_ARRAY                  0
259
260/*=============================================================*/
261/*------ OS Portability Macros --------------------------------*/
262/*=============================================================*/
263
264#ifndef WLAN_DBVAR
265#define WLAN_DBVAR      wlan_debug
266#endif
267
268#if (WLAN_OS == WLAN_LINUX_KERNEL)
269        #define WLAN_LOG_ERROR0(x) printk(KERN_ERR "%s: " x , __FUNCTION__ );
270        #define WLAN_LOG_ERROR1(x,n) printk(KERN_ERR "%s: " x , __FUNCTION__ , (n));
271        #define WLAN_LOG_ERROR2(x,n1,n2) printk(KERN_ERR "%s: " x , __FUNCTION__ , (n1), (n2));
272        #define WLAN_LOG_ERROR3(x,n1,n2,n3) printk(KERN_ERR "%s: " x , __FUNCTION__, (n1), (n2), (n3));
273        #define WLAN_LOG_ERROR4(x,n1,n2,n3,n4) printk(KERN_ERR "%s: " x , __FUNCTION__, (n1), (n2), (n3), (n4));
274
275        #define WLAN_LOG_WARNING0(x) printk(KERN_WARNING "%s: " x , __FUNCTION__);
276        #define WLAN_LOG_WARNING1(x,n) printk(KERN_WARNING "%s: " x , __FUNCTION__, (n));
277        #define WLAN_LOG_WARNING2(x,n1,n2) printk(KERN_WARNING "%s: " x , __FUNCTION__, (n1), (n2));
278        #define WLAN_LOG_WARNING3(x,n1,n2,n3) printk(KERN_WARNING "%s: " x , __FUNCTION__, (n1), (n2), (n3));
279        #define WLAN_LOG_WARNING4(x,n1,n2,n3,n4) printk(KERN_WARNING "%s: " x , __FUNCTION__ , (n1), (n2), (n3), (n4));
280
281        #define WLAN_LOG_NOTICE0(x) printk(KERN_NOTICE "%s: " x , __FUNCTION__);
282        #define WLAN_LOG_NOTICE1(x,n) printk(KERN_NOTICE "%s: " x , __FUNCTION__, (n));
283        #define WLAN_LOG_NOTICE2(x,n1,n2) printk(KERN_NOTICE "%s: " x , __FUNCTION__, (n1), (n2));
284        #define WLAN_LOG_NOTICE3(x,n1,n2,n3) printk(KERN_NOTICE "%s: " x , __FUNCTION__, (n1), (n2), (n3));
285        #define WLAN_LOG_NOTICE4(x,n1,n2,n3,n4) printk(KERN_NOTICE "%s: " x , __FUNCTION__, (n1), (n2), (n3), (n4));
286
287        #define WLAN_LOG_INFO0(x) printk(KERN_INFO x);
288        #define WLAN_LOG_INFO1(x,n) printk(KERN_INFO x, (n));
289        #define WLAN_LOG_INFO2(x,n1,n2) printk(KERN_INFO x, (n1), (n2));
290        #define WLAN_LOG_INFO3(x,n1,n2,n3) printk(KERN_INFO x, (n1), (n2), (n3));
291        #define WLAN_LOG_INFO4(x,n1,n2,n3,n4) printk(KERN_INFO x, (n1), (n2), (n3), (n4));
292        #define WLAN_LOG_INFO5(x,n1,n2,n3,n4,n5) printk(KERN_INFO x, (n1), (n2), (n3), (n4), (n5));
293
294        #if defined(WLAN_INCLUDE_DEBUG)
295                #define WLAN_ASSERT(c) if ((!(c)) && WLAN_DBVAR >= 1) { \
296                        WLAN_LOG_DEBUG0(1, "Assertion failure!\n"); }
297                #define WLAN_HEX_DUMP( l, x, p, n)      if( WLAN_DBVAR >= (l) ){ \
298                        int __i__; \
299                        printk(KERN_DEBUG x ":"); \
300                        for( __i__=0; __i__ < (n); __i__++) \
301                                printk( " %02x", ((UINT8*)(p))[__i__]); \
302                        printk("\n"); }
303
304                #define DBFENTER { if ( WLAN_DBVAR >= 4 ){ WLAN_LOG_DEBUG0(3,"Enter\n"); } }
305                #define DBFEXIT  { if ( WLAN_DBVAR >= 4 ){ WLAN_LOG_DEBUG0(3,"Exit\n"); } }
306
307                #define WLAN_LOG_DEBUG0(l,x) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s: " x ,  __FUNCTION__ );
308                #define WLAN_LOG_DEBUG1(l,x,n) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s: " x , __FUNCTION__ , (n));
309                #define WLAN_LOG_DEBUG2(l,x,n1,n2) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s: " x , __FUNCTION__ , (n1), (n2));
310                #define WLAN_LOG_DEBUG3(l,x,n1,n2,n3) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s: " x , __FUNCTION__ , (n1), (n2), (n3));
311                #define WLAN_LOG_DEBUG4(l,x,n1,n2,n3,n4) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s: " x , __FUNCTION__ , (n1), (n2), (n3), (n4));
312                #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));
313                #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));
314        #else
315                #define WLAN_ASSERT(c)
316                #define WLAN_HEX_DUMP( l, s, p, n)
317
318                #define DBFENTER
319                #define DBFEXIT
320
321                #define WLAN_LOG_DEBUG0(l, s)
322                #define WLAN_LOG_DEBUG1(l, s,n)
323                #define WLAN_LOG_DEBUG2(l, s,n1,n2)
324                #define WLAN_LOG_DEBUG3(l, s,n1,n2,n3)
325                #define WLAN_LOG_DEBUG4(l, s,n1,n2,n3,n4)
326                #define WLAN_LOG_DEBUG5(l, s,n1,n2,n3,n4,n5)
327        #endif
328#else
329        #define WLAN_LOG_ERROR0(s)
330        #define WLAN_LOG_ERROR1(s,n)
331        #define WLAN_LOG_ERROR2(s,n1,n2)
332        #define WLAN_LOG_ERROR3(s,n1,n2,n3)
333        #define WLAN_LOG_ERROR4(s,n1,n2,n3,n4)
334
335        #define WLAN_LOG_WARNING0(s)
336        #define WLAN_LOG_WARNING1(s,n)
337        #define WLAN_LOG_WARNING2(s,n1,n2)
338        #define WLAN_LOG_WARNING3(s,n1,n2,n3)
339        #define WLAN_LOG_WARNING4(s,n1,n2,n3,n4)
340
341        #define WLAN_LOG_NOTICE0(s)
342        #define WLAN_LOG_NOTICE1(s,n)
343        #define WLAN_LOG_NOTICE2(s,n1,n2)
344        #define WLAN_LOG_NOTICE3(s,n1,n2,n3)
345        #define WLAN_LOG_NOTICE4(s,n1,n2,n3,n4)
346
347                #define WLAN_ASSERT(c)
348                #define WLAN_HEX_DUMP( l, s, p, n)
349
350                #define DBFENTER
351                #define DBFEXIT
352
353                #define WLAN_LOG_INFO0(s)
354                #define WLAN_LOG_INFO1(s,n)
355                #define WLAN_LOG_INFO2(s,n1,n2)
356                #define WLAN_LOG_INFO3(s,n1,n2,n3)
357                #define WLAN_LOG_INFO4(s,n1,n2,n3,n4)
358                #define WLAN_LOG_INFO5(s,n1,n2,n3,n4,n5)
359
360                #define WLAN_LOG_DEBUG0(l, s)
361                #define WLAN_LOG_DEBUG1(l, s,n)
362                #define WLAN_LOG_DEBUG2(l, s,n1,n2)
363                #define WLAN_LOG_DEBUG3(l, s,n1,n2,n3)
364                #define WLAN_LOG_DEBUG4(l, s,n1,n2,n3,n4)
365                #define WLAN_LOG_DEBUG5(l, s,n1,n2,n3,n4,n5)
366#endif
367
368#define wlan_ms_per_tick                (1000UL / (wlan_ticks_per_sec))
369#define wlan_ms_to_ticks(n)             ( (n) / (wlan_ms_per_tick))
370#define wlan_tu2ticks(n)                ( (n) / (wlan_ms_per_tick))
371#define WLAN_INT_DISABLE(n)             { save_flags((n)); cli(); }
372#define WLAN_INT_ENABLE(n)              { sti(); restore_flags((n)); }
373
374#ifdef CONFIG_MODVERSIONS
375#define MODVERSIONS             1
376#include <linux/modversions.h>
377#endif
378
379#ifdef CONFIG_SMP
380#define __SMP__                 1
381#endif 
382
383#ifndef KERNEL_VERSION
384#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
385#endif
386
387#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,17))
388#define CONFIG_NETLINK          1
389#endif
390
391#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0))
392#define kfree_s(a, b)   kfree((a))
393#endif
394
395#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18))
396#ifndef init_waitqueue_head
397#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,0,16))
398#define init_waitqueue_head(p)  (*(p) = NULL)
399#else
400#define init_waitqueue_head(p)  init_waitqueue(p)
401#endif
402typedef struct wait_queue *wait_queue_head_t;
403typedef struct wait_queue wait_queue_t;
404#define set_current_state(b)  { current->state = (b); mb(); }
405#define init_waitqueue_entry(a, b) { (a)->task = current; }
406#endif
407#endif
408
409#ifndef wait_event_interruptible_timeout
410// retval == 0; signal met; we're good.
411// retval < 0; interrupted by signal.
412// retval > 0; timed out.
413#define __wait_event_interruptible_timeout(wq, condition, timeout, ret)   \
414do {                                                                      \
415        int __ret = 0;                                                    \
416        if (!(condition)) {                                               \
417          wait_queue_t __wait;                                            \
418          unsigned long expire;                                           \
419          init_waitqueue_entry(&__wait, current);                         \
420                                                                          \
421          expire = timeout + jiffies;                                     \
422          add_wait_queue(&wq, &__wait);                                   \
423          for (;;) {                                                      \
424                  set_current_state(TASK_INTERRUPTIBLE);                  \
425                  if (condition)                                          \
426                          break;                                          \
427                  if (jiffies > expire) {                                 \
428                          ret = jiffies - expire;                         \
429                          break;                                          \
430                  }                                                       \
431                  if (!signal_pending(current)) {                         \
432                          schedule_timeout(timeout);                      \
433                          continue;                                       \
434                  }                                                       \
435                  ret = -ERESTARTSYS;                                     \
436                  break;                                                  \
437          }                                                               \
438          set_current_state(TASK_RUNNING);                                \
439          remove_wait_queue(&wq, &__wait);                                \
440        }                                                                 \
441} while (0)
442
443#define wait_event_interruptible_timeout(wq, condition, timeout)        \
444({                                                                      \
445        int __ret = 0;                                                  \
446        if (!(condition))                                               \
447                __wait_event_interruptible_timeout(wq, condition,       \
448                                                timeout, __ret);        \
449        __ret;                                                          \
450})
451
452#endif
453
454#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,90))
455#define spin_lock(l)            do { } while (0)
456#define spin_unlock(l)          do { } while (0)
457#define spin_lock_irqsave(l,f)  do { save_flags(f); cli(); } while (0)
458#define spin_unlock_irqrestore(l,f) do { restore_flags(f); } while (0)
459#define spin_lock_init(s)       do { } while (0)
460#define spin_trylock(l)         (1)
461typedef int spinlock_t;
462#endif
463
464#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
465#ifdef CONFIG_SMP
466#define spin_is_locked(x)       (*(volatile char *)(&(x)->lock) <= 0)
467#else
468#define spin_is_locked(l)       (0)
469#endif
470#endif
471
472#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38))
473typedef struct device netdevice_t;
474#elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,4))
475typedef struct net_device netdevice_t;
476#else
477#undef netdevice_t
478typedef struct net_device netdevice_t;
479#endif
480
481#ifdef WIRELESS_EXT
482#if (WIRELESS_EXT < 13)
483struct iw_request_info
484{
485        __u16           cmd;            /* Wireless Extension command */
486        __u16           flags;          /* More to come ;-) */
487};
488#endif
489#endif
490
491
492#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,18))
493#define MODULE_PARM(a,b)        extern int __bogus_decl
494#define MODULE_AUTHOR(a)        extern int __bogus_decl
495#define MODULE_DESCRIPTION(a)   extern int __bogus_decl
496#define MODULE_SUPPORTED_DEVICE(a) extern int __bogus_decl
497#undef  GET_USE_COUNT
498#define GET_USE_COUNT(m)        mod_use_count_
499#endif
500
501#ifndef MODULE_LICENSE
502#define MODULE_LICENSE(m)       extern int __bogus_decl
503#endif
504
505/* TODO:  Do we care about this? */
506#ifndef MODULE_DEVICE_TABLE
507#define MODULE_DEVICE_TABLE(foo,bar)
508#endif
509
510#define wlan_minutes2ticks(a) ((a)*(wlan_ticks_per_sec *  60))
511#define wlan_seconds2ticks(a) ((a)*(wlan_ticks_per_sec))
512
513/*=============================================================*/
514/*------ Hardware Portability Macros --------------------------*/
515/*=============================================================*/
516
517#define ieee2host16(n)  __le16_to_cpu(n)
518#define ieee2host32(n)  __le32_to_cpu(n)
519#define host2ieee16(n)  __cpu_to_le16(n)
520#define host2ieee32(n)  __cpu_to_le32(n)
521
522#if (WLAN_CPU_FAMILY == WLAN_PPC)
523       #define wlan_inw(a)                     in_be16((unsigned short *)((a)+_IO_BASE))
524       #define wlan_inw_le16_to_cpu(a)         inw((a))
525       #define wlan_outw(v,a)                  out_be16((unsigned short *)((a)+_IO_BASE), (v))
526       #define wlan_outw_cpu_to_le16(v,a)      outw((v),(a))
527#else
528       #define wlan_inw(a)                     inw((a))
529       #define wlan_inw_le16_to_cpu(a)         __cpu_to_le16(inw((a)))
530       #define wlan_outw(v,a)                  outw((v),(a))
531       #define wlan_outw_cpu_to_le16(v,a)      outw(__cpu_to_le16((v)),(a))
532#endif
533
534/*=============================================================*/
535/*--- General Macros ------------------------------------------*/
536/*=============================================================*/
537
538#define wlan_max(a, b) (((a) > (b)) ? (a) : (b))
539#define wlan_min(a, b) (((a) < (b)) ? (a) : (b))
540
541#define wlan_isprint(c) (((c) > (0x19)) && ((c) < (0x7f)))
542
543#define wlan_hexchar(x) (((x) < 0x0a) ? ('0' + (x)) : ('a' + ((x) - 0x0a)))
544
545/* Create a string of printable chars from something that might not be */
546/* It's recommended that the str be 4*len + 1 bytes long */
547#define wlan_mkprintstr(buf, buflen, str, strlen) \
548{ \
549        int i = 0; \
550        int j = 0; \
551        memset(str, 0, (strlen)); \
552        for (i = 0; i < (buflen); i++) { \
553                if ( wlan_isprint((buf)[i]) ) { \
554                        (str)[j] = (buf)[i]; \
555                        j++; \
556                } else { \
557                        (str)[j] = '\\'; \
558                        (str)[j+1] = 'x'; \
559                        (str)[j+2] = wlan_hexchar(((buf)[i] & 0xf0) >> 4); \
560                        (str)[j+3] = wlan_hexchar(((buf)[i] & 0x0f)); \
561                        j += 4; \
562                } \
563        } \
564}
565
566/*=============================================================*/
567/*--- Variables -----------------------------------------------*/
568/*=============================================================*/
569
570extern int wlan_debug;
571extern int wlan_ethconv;                /* What's the default ethconv? */
572
573/*=============================================================*/
574/*--- Functions -----------------------------------------------*/
575/*=============================================================*/
576#endif /* _WLAN_COMPAT_H */
577
Note: See TracBrowser for help on using the repository browser.