wlan_compat.h

Go to the documentation of this file.
00001 /* src/include/wlan/wlan_compat.h
00002 *
00003 * Types and macros to aid in portability
00004 *
00005 * Copyright (C) 1999 AbsoluteValue Systems, Inc.  All Rights Reserved.
00006 * --------------------------------------------------------------------
00007 *
00008 * linux-wlan
00009 *
00010 *   The contents of this file are subject to the Mozilla Public
00011 *   License Version 1.1 (the "License"); you may not use this file
00012 *   except in compliance with the License. You may obtain a copy of
00013 *   the License at http://www.mozilla.org/MPL/
00014 *
00015 *   Software distributed under the License is distributed on an "AS
00016 *   IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
00017 *   implied. See the License for the specific language governing
00018 *   rights and limitations under the License.
00019 *
00020 *   Alternatively, the contents of this file may be used under the
00021 *   terms of the GNU Public License version 2 (the "GPL"), in which
00022 *   case the provisions of the GPL are applicable instead of the
00023 *   above.  If you wish to allow the use of your version of this file
00024 *   only under the terms of the GPL and not to allow others to use
00025 *   your version of this file under the MPL, indicate your decision
00026 *   by deleting the provisions above and replace them with the notice
00027 *   and other provisions required by the GPL.  If you do not delete
00028 *   the provisions above, a recipient may use your version of this
00029 *   file under either the MPL or the GPL.
00030 *
00031 * --------------------------------------------------------------------
00032 *
00033 * Inquiries regarding the linux-wlan Open Source project can be
00034 * made directly to:
00035 *
00036 * AbsoluteValue Systems Inc.
00037 * info@linux-wlan.com
00038 * http://www.linux-wlan.com
00039 *
00040 * --------------------------------------------------------------------
00041 *
00042 * Portions of the development of this software were funded by 
00043 * Intersil Corporation as part of PRISM(R) chipset product development.
00044 *
00045 * --------------------------------------------------------------------
00046 */
00047 
00048 FILE_LICENCE ( GPL2_ONLY );
00049 
00050 #ifndef _WLAN_COMPAT_H
00051 #define _WLAN_COMPAT_H
00052 
00053 /*=============================================================*/
00054 /*------ Establish Platform Identity --------------------------*/
00055 /*=============================================================*/
00056 /* Key macros: */
00057 /* WLAN_CPU_FAMILY */
00058         #define WLAN_Ix86                       1
00059         #define WLAN_PPC                        2
00060         #define WLAN_Ix96                       3
00061         #define WLAN_ARM                        4
00062         #define WLAN_ALPHA                      5
00063         #define WLAN_MIPS                       6
00064         #define WLAN_HPPA                       7
00065 /* WLAN_CPU_CORE */
00066         #define WLAN_I386CORE                   1
00067         #define WLAN_PPCCORE                    2
00068         #define WLAN_I296                       3
00069         #define WLAN_ARMCORE                    4
00070         #define WLAN_ALPHACORE                  5
00071         #define WLAN_MIPSCORE                   6
00072         #define WLAN_HPPACORE                   7
00073 /* WLAN_CPU_PART */
00074         #define WLAN_I386PART                   1
00075         #define WLAN_MPC860                     2
00076         #define WLAN_MPC823                     3
00077         #define WLAN_I296SA                     4
00078         #define WLAN_PPCPART                    5
00079         #define WLAN_ARMPART                    6
00080         #define WLAN_ALPHAPART                  7
00081         #define WLAN_MIPSPART                   8
00082         #define WLAN_HPPAPART                   9
00083 /* WLAN_SYSARCH */
00084         #define WLAN_PCAT                       1
00085         #define WLAN_MBX                        2
00086         #define WLAN_RPX                        3
00087         #define WLAN_LWARCH                     4
00088         #define WLAN_PMAC                       5
00089         #define WLAN_SKIFF                      6
00090         #define WLAN_BITSY                      7
00091         #define WLAN_ALPHAARCH                  7
00092         #define WLAN_MIPSARCH                   9
00093         #define WLAN_HPPAARCH                   10
00094 /* WLAN_OS */
00095         #define WLAN_LINUX_KERNEL               1
00096         #define WLAN_LINUX_USER                 2
00097 /* WLAN_HOSTIF (generally set on the command line, not detected) */
00098         #define WLAN_PCMCIA                     1
00099         #define WLAN_ISA                        2
00100         #define WLAN_PCI                        3
00101         #define WLAN_USB                        4
00102         #define WLAN_PLX                        5
00103 
00104 /* Note: the PLX HOSTIF above refers to some vendors implementations for */
00105 /*       PCI.  It's a PLX chip that is a PCI to PCMCIA adapter, but it   */
00106 /*       isn't a real PCMCIA host interface adapter providing all the    */
00107 /*       card&socket services.                                           */
00108 
00109 /* Lets try to figure out what we've got.  Kernel mode or User mode? */
00110 #if defined(__KERNEL__)
00111         #define WLAN_OS                         WLAN_LINUX_KERNEL
00112 #else 
00113         #define WLAN_OS                         WLAN_LINUX_USER
00114 #endif
00115 
00116 #ifdef __powerpc__
00117 #ifndef __ppc__
00118 #define __ppc__
00119 #endif
00120 #endif
00121 
00122 #if (defined(CONFIG_PPC) || defined(CONFIG_8xx))
00123 #ifndef __ppc__
00124 #define __ppc__
00125 #endif
00126 #endif
00127 
00128 #if defined(__KERNEL__)
00129 #if defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__)
00130         #define WLAN_CPU_FAMILY         WLAN_Ix86
00131         #define WLAN_CPU_CORE           WLAN_I386CORE
00132         #define WLAN_CPU_PART           WLAN_I386PART
00133         #define WLAN_SYSARCH            WLAN_PCAT
00134 #elif defined(__ppc__)
00135         #define WLAN_CPU_FAMILY         WLAN_PPC
00136         #define WLAN_CPU_CORE           WLAN_PPCCORE
00137         #if defined(CONFIG_MBX)
00138                 #define WLAN_CPU_PART   WLAN_MPC860
00139                 #define WLAN_SYSARCH    WLAN_MBX
00140         #elif defined(CONFIG_RPXLITE)
00141                 #define WLAN_CPU_PART   WLAN_MPC823
00142                 #define WLAN_SYSARCH    WLAN_RPX
00143         #elif defined(CONFIG_RPXCLASSIC)
00144                 #define WLAN_CPU_PART   WLAN_MPC860
00145                 #define WLAN_SYSARCH    WLAN_RPX
00146         #else
00147                 #define WLAN_CPU_PART   WLAN_PPCPART
00148                 #define WLAN_SYSARCH    WLAN_PMAC
00149         #endif
00150 #elif defined(__arm__)
00151         #define WLAN_CPU_FAMILY         WLAN_ARM
00152         #define WLAN_CPU_CORE           WLAN_ARMCORE
00153         #define WLAN_CPU_PART           WLAN_ARM_PART
00154         #define WLAN_SYSARCH            WLAN_SKIFF
00155 #elif defined(__alpha__)
00156         #define WLAN_CPU_FAMILY         WLAN_ALPHA
00157         #define WLAN_CPU_CORE           WLAN_ALPHACORE
00158         #define WLAN_CPU_PART           WLAN_ALPHAPART
00159         #define WLAN_SYSARCH            WLAN_ALPHAARCH
00160 #elif defined(__mips__)
00161         #define WLAN_CPU_FAMILY         WLAN_MIPS
00162         #define WLAN_CPU_CORE           WLAN_MIPSCORE
00163         #define WLAN_CPU_PART           WLAN_MIPSPART
00164         #define WLAN_SYSARCH            WLAN_MIPSARCH
00165 #elif defined(__hppa__)
00166         #define WLAN_CPU_FAMILY         WLAN_HPPA
00167         #define WLAN_CPU_CORE           WLAN_HPPACORE
00168         #define WLAN_CPU_PART           WLAN_HPPAPART
00169         #define WLAN_SYSARCH            WLAN_HPPAARCH
00170 #else
00171         #error "No CPU identified!"
00172 #endif
00173 #endif /* __KERNEL__ */
00174 
00175 /*
00176    Some big endian machines implicitly do all I/O in little endian mode.
00177 
00178    In particular:
00179           Linux/PPC on PowerMacs (PCI)
00180           Arm/Intel Xscale (PCI)
00181 
00182    This may also affect PLX boards and other BE &| PPC platforms; 
00183    as new ones are discovered, add them below. 
00184 */
00185 
00186 #if (WLAN_HOSTIF == WLAN_PCI)
00187 #if ((WLAN_SYSARCH == WLAN_SKIFF) || (WLAN_SYSARCH == WLAN_PMAC))
00188 #define REVERSE_ENDIAN
00189 #endif
00190 #endif
00191 
00192 /*=============================================================*/
00193 /*------ Bit settings -----------------------------------------*/
00194 /*=============================================================*/
00195 
00196 #define BIT0    0x00000001
00197 #define BIT1    0x00000002
00198 #define BIT2    0x00000004
00199 #define BIT3    0x00000008
00200 #define BIT4    0x00000010
00201 #define BIT5    0x00000020
00202 #define BIT6    0x00000040
00203 #define BIT7    0x00000080
00204 #define BIT8    0x00000100
00205 #define BIT9    0x00000200
00206 #define BIT10   0x00000400
00207 #define BIT11   0x00000800
00208 #define BIT12   0x00001000
00209 #define BIT13   0x00002000
00210 #define BIT14   0x00004000
00211 #define BIT15   0x00008000
00212 #define BIT16   0x00010000
00213 #define BIT17   0x00020000
00214 #define BIT18   0x00040000
00215 #define BIT19   0x00080000
00216 #define BIT20   0x00100000
00217 #define BIT21   0x00200000
00218 #define BIT22   0x00400000
00219 #define BIT23   0x00800000
00220 #define BIT24   0x01000000
00221 #define BIT25   0x02000000
00222 #define BIT26   0x04000000
00223 #define BIT27   0x08000000
00224 #define BIT28   0x10000000
00225 #define BIT29   0x20000000
00226 #define BIT30   0x40000000
00227 #define BIT31   0x80000000
00228 
00229 typedef unsigned char   UINT8;
00230 typedef unsigned short  UINT16;
00231 typedef unsigned long   UINT32;
00232 
00233 typedef signed char     INT8;
00234 typedef signed short    INT16;
00235 typedef signed long     INT32;
00236 
00237 typedef unsigned int    UINT;
00238 typedef signed int      INT;
00239 
00240 typedef unsigned long long      UINT64;
00241 typedef signed long long        INT64;
00242 
00243 #define UINT8_MAX       (0xffUL)
00244 #define UINT16_MAX      (0xffffUL)
00245 #define UINT32_MAX      (0xffffffffUL)
00246 
00247 #define INT8_MAX        (0x7fL)
00248 #define INT16_MAX       (0x7fffL)
00249 #define INT32_MAX       (0x7fffffffL)
00250 
00251 /*=============================================================*/
00252 /*------ Compiler Portability Macros --------------------------*/
00253 /*=============================================================*/
00254 #define __WLAN_ATTRIB_PACK__            __attribute__ ((packed))
00255 #define __WLAN_PRAGMA_PACK1__
00256 #define __WLAN_PRAGMA_PACKDFLT__
00257 #define __WLAN_INLINE__                 inline
00258 #define WLAN_MIN_ARRAY                  0
00259 
00260 /*=============================================================*/
00261 /*------ OS Portability Macros --------------------------------*/
00262 /*=============================================================*/
00263 
00264 #ifndef WLAN_DBVAR
00265 #define WLAN_DBVAR      wlan_debug
00266 #endif
00267 
00268 #if (WLAN_OS == WLAN_LINUX_KERNEL)
00269         #define WLAN_LOG_ERROR0(x) printk(KERN_ERR "%s: " x , __FUNCTION__ );
00270         #define WLAN_LOG_ERROR1(x,n) printk(KERN_ERR "%s: " x , __FUNCTION__ , (n));
00271         #define WLAN_LOG_ERROR2(x,n1,n2) printk(KERN_ERR "%s: " x , __FUNCTION__ , (n1), (n2));
00272         #define WLAN_LOG_ERROR3(x,n1,n2,n3) printk(KERN_ERR "%s: " x , __FUNCTION__, (n1), (n2), (n3));
00273         #define WLAN_LOG_ERROR4(x,n1,n2,n3,n4) printk(KERN_ERR "%s: " x , __FUNCTION__, (n1), (n2), (n3), (n4));
00274 
00275         #define WLAN_LOG_WARNING0(x) printk(KERN_WARNING "%s: " x , __FUNCTION__);
00276         #define WLAN_LOG_WARNING1(x,n) printk(KERN_WARNING "%s: " x , __FUNCTION__, (n));
00277         #define WLAN_LOG_WARNING2(x,n1,n2) printk(KERN_WARNING "%s: " x , __FUNCTION__, (n1), (n2));
00278         #define WLAN_LOG_WARNING3(x,n1,n2,n3) printk(KERN_WARNING "%s: " x , __FUNCTION__, (n1), (n2), (n3));
00279         #define WLAN_LOG_WARNING4(x,n1,n2,n3,n4) printk(KERN_WARNING "%s: " x , __FUNCTION__ , (n1), (n2), (n3), (n4));
00280 
00281         #define WLAN_LOG_NOTICE0(x) printk(KERN_NOTICE "%s: " x , __FUNCTION__);
00282         #define WLAN_LOG_NOTICE1(x,n) printk(KERN_NOTICE "%s: " x , __FUNCTION__, (n));
00283         #define WLAN_LOG_NOTICE2(x,n1,n2) printk(KERN_NOTICE "%s: " x , __FUNCTION__, (n1), (n2));
00284         #define WLAN_LOG_NOTICE3(x,n1,n2,n3) printk(KERN_NOTICE "%s: " x , __FUNCTION__, (n1), (n2), (n3));
00285         #define WLAN_LOG_NOTICE4(x,n1,n2,n3,n4) printk(KERN_NOTICE "%s: " x , __FUNCTION__, (n1), (n2), (n3), (n4));
00286 
00287         #define WLAN_LOG_INFO0(x) printk(KERN_INFO x);
00288         #define WLAN_LOG_INFO1(x,n) printk(KERN_INFO x, (n));
00289         #define WLAN_LOG_INFO2(x,n1,n2) printk(KERN_INFO x, (n1), (n2));
00290         #define WLAN_LOG_INFO3(x,n1,n2,n3) printk(KERN_INFO x, (n1), (n2), (n3));
00291         #define WLAN_LOG_INFO4(x,n1,n2,n3,n4) printk(KERN_INFO x, (n1), (n2), (n3), (n4));
00292         #define WLAN_LOG_INFO5(x,n1,n2,n3,n4,n5) printk(KERN_INFO x, (n1), (n2), (n3), (n4), (n5));
00293 
00294         #if defined(WLAN_INCLUDE_DEBUG)
00295                 #define WLAN_ASSERT(c) if ((!(c)) && WLAN_DBVAR >= 1) { \
00296                         WLAN_LOG_DEBUG0(1, "Assertion failure!\n"); }
00297                 #define WLAN_HEX_DUMP( l, x, p, n)      if( WLAN_DBVAR >= (l) ){ \
00298                         int __i__; \
00299                         printk(KERN_DEBUG x ":"); \
00300                         for( __i__=0; __i__ < (n); __i__++) \
00301                                 printk( " %02x", ((UINT8*)(p))[__i__]); \
00302                         printk("\n"); }
00303 
00304                 #define DBFENTER { if ( WLAN_DBVAR >= 4 ){ WLAN_LOG_DEBUG0(3,"Enter\n"); } }
00305                 #define DBFEXIT  { if ( WLAN_DBVAR >= 4 ){ WLAN_LOG_DEBUG0(3,"Exit\n"); } }
00306 
00307                 #define WLAN_LOG_DEBUG0(l,x) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s: " x ,  __FUNCTION__ );
00308                 #define WLAN_LOG_DEBUG1(l,x,n) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s: " x , __FUNCTION__ , (n));
00309                 #define WLAN_LOG_DEBUG2(l,x,n1,n2) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s: " x , __FUNCTION__ , (n1), (n2));
00310                 #define WLAN_LOG_DEBUG3(l,x,n1,n2,n3) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s: " x , __FUNCTION__ , (n1), (n2), (n3));
00311                 #define WLAN_LOG_DEBUG4(l,x,n1,n2,n3,n4) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s: " x , __FUNCTION__ , (n1), (n2), (n3), (n4));
00312                 #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));
00313                 #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));
00314         #else
00315                 #define WLAN_ASSERT(c) 
00316                 #define WLAN_HEX_DUMP( l, s, p, n)
00317 
00318                 #define DBFENTER 
00319                 #define DBFEXIT 
00320 
00321                 #define WLAN_LOG_DEBUG0(l, s)
00322                 #define WLAN_LOG_DEBUG1(l, s,n)
00323                 #define WLAN_LOG_DEBUG2(l, s,n1,n2)
00324                 #define WLAN_LOG_DEBUG3(l, s,n1,n2,n3)
00325                 #define WLAN_LOG_DEBUG4(l, s,n1,n2,n3,n4)
00326                 #define WLAN_LOG_DEBUG5(l, s,n1,n2,n3,n4,n5)
00327         #endif
00328 #else
00329         #define WLAN_LOG_ERROR0(s)
00330         #define WLAN_LOG_ERROR1(s,n)
00331         #define WLAN_LOG_ERROR2(s,n1,n2)
00332         #define WLAN_LOG_ERROR3(s,n1,n2,n3)
00333         #define WLAN_LOG_ERROR4(s,n1,n2,n3,n4)
00334 
00335         #define WLAN_LOG_WARNING0(s)
00336         #define WLAN_LOG_WARNING1(s,n)
00337         #define WLAN_LOG_WARNING2(s,n1,n2)
00338         #define WLAN_LOG_WARNING3(s,n1,n2,n3)
00339         #define WLAN_LOG_WARNING4(s,n1,n2,n3,n4)
00340 
00341         #define WLAN_LOG_NOTICE0(s)
00342         #define WLAN_LOG_NOTICE1(s,n)
00343         #define WLAN_LOG_NOTICE2(s,n1,n2)
00344         #define WLAN_LOG_NOTICE3(s,n1,n2,n3)
00345         #define WLAN_LOG_NOTICE4(s,n1,n2,n3,n4)
00346 
00347                 #define WLAN_ASSERT(c) 
00348                 #define WLAN_HEX_DUMP( l, s, p, n)
00349 
00350                 #define DBFENTER 
00351                 #define DBFEXIT 
00352 
00353                 #define WLAN_LOG_INFO0(s)
00354                 #define WLAN_LOG_INFO1(s,n)
00355                 #define WLAN_LOG_INFO2(s,n1,n2)
00356                 #define WLAN_LOG_INFO3(s,n1,n2,n3)
00357                 #define WLAN_LOG_INFO4(s,n1,n2,n3,n4)
00358                 #define WLAN_LOG_INFO5(s,n1,n2,n3,n4,n5)
00359 
00360                 #define WLAN_LOG_DEBUG0(l, s)
00361                 #define WLAN_LOG_DEBUG1(l, s,n)
00362                 #define WLAN_LOG_DEBUG2(l, s,n1,n2)
00363                 #define WLAN_LOG_DEBUG3(l, s,n1,n2,n3)
00364                 #define WLAN_LOG_DEBUG4(l, s,n1,n2,n3,n4)
00365                 #define WLAN_LOG_DEBUG5(l, s,n1,n2,n3,n4,n5)
00366 #endif
00367 
00368 #define wlan_ms_per_tick                (1000UL / (wlan_ticks_per_sec))
00369 #define wlan_ms_to_ticks(n)             ( (n) / (wlan_ms_per_tick))
00370 #define wlan_tu2ticks(n)                ( (n) / (wlan_ms_per_tick))
00371 #define WLAN_INT_DISABLE(n)             { save_flags((n)); cli(); }
00372 #define WLAN_INT_ENABLE(n)              { sti(); restore_flags((n)); }
00373 
00374 #ifdef CONFIG_MODVERSIONS
00375 #define MODVERSIONS             1
00376 #include <linux/modversions.h>
00377 #endif
00378 
00379 #ifdef CONFIG_SMP
00380 #define __SMP__                 1
00381 #endif  
00382 
00383 #ifndef KERNEL_VERSION
00384 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
00385 #endif
00386 
00387 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,17))
00388 #define CONFIG_NETLINK          1
00389 #endif
00390 
00391 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0))
00392 #define kfree_s(a, b)   kfree((a))
00393 #endif
00394 
00395 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18))
00396 #ifndef init_waitqueue_head
00397 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,0,16))
00398 #define init_waitqueue_head(p)  (*(p) = NULL)
00399 #else
00400 #define init_waitqueue_head(p)  init_waitqueue(p)
00401 #endif
00402 typedef struct wait_queue *wait_queue_head_t;
00403 typedef struct wait_queue wait_queue_t;
00404 #define set_current_state(b)  { current->state = (b); mb(); }
00405 #define init_waitqueue_entry(a, b) { (a)->task = current; }
00406 #endif
00407 #endif
00408 
00409 #ifndef wait_event_interruptible_timeout
00410 // retval == 0; signal met; we're good.
00411 // retval < 0; interrupted by signal.
00412 // retval > 0; timed out.
00413 #define __wait_event_interruptible_timeout(wq, condition, timeout, ret)   \
00414 do {                                                                      \
00415         int __ret = 0;                                                    \
00416         if (!(condition)) {                                               \
00417           wait_queue_t __wait;                                            \
00418           unsigned long expire;                                           \
00419           init_waitqueue_entry(&__wait, current);                         \
00420                                                                           \
00421           expire = timeout + jiffies;                                     \
00422           add_wait_queue(&wq, &__wait);                                   \
00423           for (;;) {                                                      \
00424                   set_current_state(TASK_INTERRUPTIBLE);                  \
00425                   if (condition)                                          \
00426                           break;                                          \
00427                   if (jiffies > expire) {                                 \
00428                           ret = jiffies - expire;                         \
00429                           break;                                          \
00430                   }                                                       \
00431                   if (!signal_pending(current)) {                         \
00432                           schedule_timeout(timeout);                      \
00433                           continue;                                       \
00434                   }                                                       \
00435                   ret = -ERESTARTSYS;                                     \
00436                   break;                                                  \
00437           }                                                               \
00438           set_current_state(TASK_RUNNING);                                \
00439           remove_wait_queue(&wq, &__wait);                                \
00440         }                                                                 \
00441 } while (0)
00442 
00443 #define wait_event_interruptible_timeout(wq, condition, timeout)        \
00444 ({                                                                      \
00445         int __ret = 0;                                                  \
00446         if (!(condition))                                               \
00447                 __wait_event_interruptible_timeout(wq, condition,       \
00448                                                 timeout, __ret);        \
00449         __ret;                                                          \
00450 })
00451 
00452 #endif
00453 
00454 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,90))
00455 #define spin_lock(l)            do { } while (0)
00456 #define spin_unlock(l)          do { } while (0)
00457 #define spin_lock_irqsave(l,f)  do { save_flags(f); cli(); } while (0)
00458 #define spin_unlock_irqrestore(l,f) do { restore_flags(f); } while (0)
00459 #define spin_lock_init(s)       do { } while (0)
00460 #define spin_trylock(l)         (1)
00461 typedef int spinlock_t;
00462 #endif
00463 
00464 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
00465 #ifdef CONFIG_SMP
00466 #define spin_is_locked(x)       (*(volatile char *)(&(x)->lock) <= 0)
00467 #else
00468 #define spin_is_locked(l)       (0)
00469 #endif
00470 #endif
00471 
00472 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38))
00473 typedef struct device netdevice_t;
00474 #elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,4))
00475 typedef struct net_device netdevice_t;
00476 #else
00477 #undef netdevice_t
00478 typedef struct net_device netdevice_t;
00479 #endif
00480 
00481 #ifdef WIRELESS_EXT
00482 #if (WIRELESS_EXT < 13)
00483 struct iw_request_info
00484 {
00485         __u16           cmd;            /* Wireless Extension command */
00486         __u16           flags;          /* More to come ;-) */
00487 };
00488 #endif
00489 #endif
00490 
00491 
00492 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,18))
00493 #define MODULE_PARM(a,b)        extern int __bogus_decl
00494 #define MODULE_AUTHOR(a)        extern int __bogus_decl
00495 #define MODULE_DESCRIPTION(a)   extern int __bogus_decl
00496 #define MODULE_SUPPORTED_DEVICE(a) extern int __bogus_decl
00497 #undef  GET_USE_COUNT
00498 #define GET_USE_COUNT(m)        mod_use_count_
00499 #endif
00500 
00501 #ifndef MODULE_LICENSE
00502 #define MODULE_LICENSE(m)       extern int __bogus_decl
00503 #endif
00504 
00505 /* TODO:  Do we care about this? */
00506 #ifndef MODULE_DEVICE_TABLE
00507 #define MODULE_DEVICE_TABLE(foo,bar)
00508 #endif
00509 
00510 #define wlan_minutes2ticks(a) ((a)*(wlan_ticks_per_sec *  60))
00511 #define wlan_seconds2ticks(a) ((a)*(wlan_ticks_per_sec))
00512 
00513 /*=============================================================*/
00514 /*------ Hardware Portability Macros --------------------------*/
00515 /*=============================================================*/
00516 
00517 #define ieee2host16(n)  __le16_to_cpu(n)
00518 #define ieee2host32(n)  __le32_to_cpu(n)
00519 #define host2ieee16(n)  __cpu_to_le16(n)
00520 #define host2ieee32(n)  __cpu_to_le32(n)
00521 
00522 #if (WLAN_CPU_FAMILY == WLAN_PPC)
00523        #define wlan_inw(a)                     in_be16((unsigned short *)((a)+_IO_BASE))
00524        #define wlan_inw_le16_to_cpu(a)         inw((a))
00525        #define wlan_outw(v,a)                  out_be16((unsigned short *)((a)+_IO_BASE), (v))
00526        #define wlan_outw_cpu_to_le16(v,a)      outw((v),(a))
00527 #else
00528        #define wlan_inw(a)                     inw((a))
00529        #define wlan_inw_le16_to_cpu(a)         __cpu_to_le16(inw((a)))
00530        #define wlan_outw(v,a)                  outw((v),(a))
00531        #define wlan_outw_cpu_to_le16(v,a)      outw(__cpu_to_le16((v)),(a))
00532 #endif
00533 
00534 /*=============================================================*/
00535 /*--- General Macros ------------------------------------------*/
00536 /*=============================================================*/
00537 
00538 #define wlan_max(a, b) (((a) > (b)) ? (a) : (b))
00539 #define wlan_min(a, b) (((a) < (b)) ? (a) : (b))
00540 
00541 #define wlan_isprint(c) (((c) > (0x19)) && ((c) < (0x7f)))
00542 
00543 #define wlan_hexchar(x) (((x) < 0x0a) ? ('0' + (x)) : ('a' + ((x) - 0x0a)))
00544 
00545 /* Create a string of printable chars from something that might not be */
00546 /* It's recommended that the str be 4*len + 1 bytes long */
00547 #define wlan_mkprintstr(buf, buflen, str, strlen) \
00548 { \
00549         int i = 0; \
00550         int j = 0; \
00551         memset(str, 0, (strlen)); \
00552         for (i = 0; i < (buflen); i++) { \
00553                 if ( wlan_isprint((buf)[i]) ) { \
00554                         (str)[j] = (buf)[i]; \
00555                         j++; \
00556                 } else { \
00557                         (str)[j] = '\\'; \
00558                         (str)[j+1] = 'x'; \
00559                         (str)[j+2] = wlan_hexchar(((buf)[i] & 0xf0) >> 4); \
00560                         (str)[j+3] = wlan_hexchar(((buf)[i] & 0x0f)); \
00561                         j += 4; \
00562                 } \
00563         } \
00564 }
00565 
00566 /*=============================================================*/
00567 /*--- Variables -----------------------------------------------*/
00568 /*=============================================================*/
00569 
00570 extern int wlan_debug;
00571 extern int wlan_ethconv;                /* What's the default ethconv? */
00572 
00573 /*=============================================================*/
00574 /*--- Functions -----------------------------------------------*/
00575 /*=============================================================*/
00576 #endif /* _WLAN_COMPAT_H */
00577 

Generated on Tue Apr 6 20:01:06 2010 for gPXE by  doxygen 1.5.7.1