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 #ifndef _WLAN_COMPAT_H
00049 #define _WLAN_COMPAT_H
00050 
00051 /*=============================================================*/
00052 /*------ Establish Platform Identity --------------------------*/
00053 /*=============================================================*/
00054 /* Key macros: */
00055 /* WLAN_CPU_FAMILY */
00056   #define WLAN_Ix86     1
00057   #define WLAN_PPC      2
00058   #define WLAN_Ix96     3
00059   #define WLAN_ARM      4
00060   #define WLAN_ALPHA      5
00061   #define WLAN_MIPS     6
00062   #define WLAN_HPPA     7
00063   #define WLAN_SPARC      8
00064   #define WLAN_SH         9
00065   #define WLAN_x86_64                     10
00066 /* WLAN_SYSARCH */
00067   #define WLAN_PCAT     1
00068   #define WLAN_MBX      2
00069   #define WLAN_RPX      3
00070   #define WLAN_LWARCH     4
00071   #define WLAN_PMAC     5
00072   #define WLAN_SKIFF      6
00073   #define WLAN_BITSY      7
00074   #define WLAN_ALPHAARCH      7
00075   #define WLAN_MIPSARCH     9
00076   #define WLAN_HPPAARCH     10
00077   #define WLAN_SPARCARCH      11
00078   #define WLAN_SHARCH         12
00079 
00080 /* Note: the PLX HOSTIF above refers to some vendors implementations for */
00081 /*       PCI.  It's a PLX chip that is a PCI to PCMCIA adapter, but it   */
00082 /*       isn't a real PCMCIA host interface adapter providing all the    */
00083 /*       card&socket services.                                           */
00084 
00085 #if (defined(CONFIG_PPC) || defined(CONFIG_8xx) || defined(__powerpc__))
00086 #ifndef __ppc__
00087 #define __ppc__
00088 #endif
00089 #endif
00090 
00091 #if defined(__KERNEL__)
00092 #if defined(__x86_64__)
00093   #define WLAN_CPU_FAMILY   WLAN_x86_64
00094   #define WLAN_SYSARCH    WLAN_PCAT
00095 #elif defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__)
00096   #define WLAN_CPU_FAMILY   WLAN_Ix86
00097   #define WLAN_SYSARCH    WLAN_PCAT
00098 #elif defined(__ppc__)
00099   #define WLAN_CPU_FAMILY   WLAN_PPC
00100   #if defined(CONFIG_MBX)
00101     #define WLAN_SYSARCH  WLAN_MBX
00102   #elif defined(CONFIG_RPXLITE)
00103     #define WLAN_SYSARCH  WLAN_RPX
00104   #elif defined(CONFIG_RPXCLASSIC)
00105     #define WLAN_SYSARCH  WLAN_RPX
00106   #else
00107     #define WLAN_SYSARCH  WLAN_PMAC
00108   #endif
00109 #elif defined(__arm__)
00110   #define WLAN_CPU_FAMILY   WLAN_ARM
00111   #define WLAN_SYSARCH    WLAN_SKIFF
00112 #elif defined(__alpha__)
00113   #define WLAN_CPU_FAMILY   WLAN_ALPHA
00114   #define WLAN_SYSARCH    WLAN_ALPHAARCH
00115 #elif defined(__mips__)
00116   #define WLAN_CPU_FAMILY   WLAN_MIPS
00117   #define WLAN_SYSARCH    WLAN_MIPSARCH
00118 #elif defined(__hppa__)
00119   #define WLAN_CPU_FAMILY   WLAN_HPPA
00120   #define WLAN_SYSARCH    WLAN_HPPAARCH
00121 #elif defined(__sparc__)
00122         #define WLAN_CPU_FAMILY         WLAN_SPARC
00123         #define WLAN_SYSARCH            WLAN_SPARC
00124 #elif defined(__sh__)
00125         #define WLAN_CPU_FAMILY         WLAN_SH    
00126         #define WLAN_SYSARCH            WLAN_SHARCH
00127         #ifndef __LITTLE_ENDIAN__
00128         #define __LITTLE_ENDIAN__
00129         #endif
00130 #else
00131   #error "No CPU identified!"
00132 #endif
00133 #endif /* __KERNEL__ */
00134 
00135 /*
00136    Some big endian machines implicitly do all I/O in little endian mode.
00137 
00138    In particular:
00139           Linux/PPC on PowerMacs (PCI)
00140     Arm/Intel Xscale (PCI)
00141 
00142    This may also affect PLX boards and other BE &| PPC platforms; 
00143    as new ones are discovered, add them below. 
00144 */
00145 
00146 #if defined(WLAN_HOSTIF)
00147 #if ((WLAN_HOSTIF == WLAN_PCI) || (WLAN_HOSTIF == WLAN_PLX))
00148 #if ((WLAN_SYSARCH == WLAN_SKIFF) || (WLAN_SYSARCH == WLAN_PMAC) || (WLAN_SYSARCH == WLAN_SPARC))
00149 #define REVERSE_ENDIAN
00150 #endif
00151 #endif
00152 #endif
00153 
00154 /*=============================================================*/
00155 /*------ Bit settings -----------------------------------------*/
00156 /*=============================================================*/
00157 
00158 #define BIT0  0x00000001
00159 #define BIT1  0x00000002
00160 #define BIT2  0x00000004
00161 #define BIT3  0x00000008
00162 #define BIT4  0x00000010
00163 #define BIT5  0x00000020
00164 #define BIT6  0x00000040
00165 #define BIT7  0x00000080
00166 #define BIT8  0x00000100
00167 #define BIT9  0x00000200
00168 #define BIT10 0x00000400
00169 #define BIT11 0x00000800
00170 #define BIT12 0x00001000
00171 #define BIT13 0x00002000
00172 #define BIT14 0x00004000
00173 #define BIT15 0x00008000
00174 #define BIT16 0x00010000
00175 #define BIT17 0x00020000
00176 #define BIT18 0x00040000
00177 #define BIT19 0x00080000
00178 #define BIT20 0x00100000
00179 #define BIT21 0x00200000
00180 #define BIT22 0x00400000
00181 #define BIT23 0x00800000
00182 #define BIT24 0x01000000
00183 #define BIT25 0x02000000
00184 #define BIT26 0x04000000
00185 #define BIT27 0x08000000
00186 #define BIT28 0x10000000
00187 #define BIT29 0x20000000
00188 #define BIT30 0x40000000
00189 #define BIT31 0x80000000
00190 
00191 #include <linux/types.h>
00192 
00193 typedef u_int8_t  UINT8;
00194 typedef u_int16_t UINT16;
00195 typedef u_int32_t UINT32;
00196 
00197 typedef int8_t    INT8;
00198 typedef int16_t   INT16;
00199 typedef int32_t   INT32;
00200 
00201 typedef unsigned int    UINT;
00202 typedef signed int      INT;
00203 
00204 typedef u_int64_t UINT64;
00205 typedef int64_t   INT64;
00206 
00207 #ifndef UINT8_MAX
00208 #define UINT8_MAX (0xffUL)
00209 #define UINT16_MAX  (0xffffUL)
00210 #define UINT32_MAX  (0xffffffffUL)
00211 
00212 #define INT8_MAX  (0x7fL)
00213 #define INT16_MAX (0x7fffL)
00214 #define INT32_MAX (0x7fffffffL)
00215 #endif
00216 
00217 /*=============================================================*/
00218 /*------ Compiler Portability Macros --------------------------*/
00219 /*=============================================================*/
00220 #define __WLAN_ATTRIB_PACK__    __attribute__ ((packed))
00221 
00222 /*=============================================================*/
00223 /*------ OS Portability Macros --------------------------------*/
00224 /*=============================================================*/
00225 
00226 #ifndef WLAN_DBVAR
00227 #define WLAN_DBVAR  wlan_debug
00228 #endif
00229 
00230 #ifndef KERNEL_VERSION
00231 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
00232 #endif
00233 
00234 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
00235 #  if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,8))
00236 #    include <linux/hardirq.h>
00237 #  else 
00238 #    include <asm/hardirq.h>
00239 #  endif
00240 #elif defined(__KERNEL__)
00241 #  define PREEMPT_MASK  (0x000000FFUL)
00242 #  define preempt_count() (0UL)
00243 #endif
00244 
00245 #define WLAN_LOG_ERROR(x,args...) printk(KERN_ERR "%s: " x , __FUNCTION__ , ##args);
00246 
00247 #define WLAN_LOG_WARNING(x,args...) printk(KERN_WARNING "%s: " x , __FUNCTION__ , ##args);
00248 
00249 #define WLAN_LOG_NOTICE(x,args...) printk(KERN_NOTICE "%s: " x , __FUNCTION__ , ##args);
00250 
00251 #define WLAN_LOG_INFO(args... ) printk(KERN_INFO args)
00252 
00253 #if defined(WLAN_INCLUDE_DEBUG)
00254   #define WLAN_ASSERT(c) if ((!(c)) && WLAN_DBVAR >= 1) { \
00255     WLAN_LOG_DEBUG(1, "Assertion failure!\n"); }
00256   #define WLAN_HEX_DUMP( l, x, p, n)  if( WLAN_DBVAR >= (l) ){ \
00257     int __i__; \
00258     printk(KERN_DEBUG x ":"); \
00259     for( __i__=0; __i__ < (n); __i__++) \
00260       printk( " %02x", ((UINT8*)(p))[__i__]); \
00261     printk("\n"); }
00262   #define DBFENTER { if ( WLAN_DBVAR >= 5 ){ WLAN_LOG_DEBUG(3,"---->\n"); } }
00263   #define DBFEXIT  { if ( WLAN_DBVAR >= 5 ){ WLAN_LOG_DEBUG(3,"<----\n"); } }
00264 
00265   #define WLAN_LOG_DEBUG(l,x,args...) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s(%lu): " x ,  __FUNCTION__, (preempt_count() & PREEMPT_MASK), ##args );
00266 #else
00267   #define WLAN_ASSERT(c) 
00268   #define WLAN_HEX_DUMP( l, s, p, n)
00269   #define DBFENTER 
00270   #define DBFEXIT 
00271 
00272   #define WLAN_LOG_DEBUG(l, s, args...)
00273 #endif
00274 
00275 #ifdef CONFIG_SMP
00276 #define __SMP__     1
00277 #endif  
00278 
00279 #if defined(__KERNEL__)
00280 
00281 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7))
00282 #  define del_singleshot_timer_sync(a)  del_timer_sync(a)
00283 #endif
00284 
00285 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,17))
00286 #define CONFIG_NETLINK    1
00287 #endif
00288 
00289 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0))
00290 #define kfree_s(a, b) kfree((a))
00291 #endif
00292 
00293 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18))
00294 #ifndef init_waitqueue_head
00295 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,0,16))
00296 #define init_waitqueue_head(p)  (*(p) = NULL)
00297 #else
00298 #define init_waitqueue_head(p)  init_waitqueue(p)
00299 #endif
00300 typedef struct wait_queue *wait_queue_head_t;
00301 typedef struct wait_queue wait_queue_t;
00302 #define set_current_state(b)  { current->state = (b); mb(); }
00303 #define init_waitqueue_entry(a, b) { (a)->task = current; }
00304 #endif
00305 #endif
00306 
00307 #ifndef wait_event_interruptible_timeout
00308 // retval == 0; signal met; we're good.
00309 // retval < 0; interrupted by signal.
00310 // retval > 0; timed out.
00311 
00312 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0))  // fixme?
00313 
00314 #define __wait_event_interruptible_timeout(wq, condition, ret)            \
00315 do {                                                                      \
00316           wait_queue_t __wait;                                            \
00317           init_waitqueue_entry(&__wait, current);                         \
00318                                                                     \
00319           add_wait_queue(&wq, &__wait);                                   \
00320           for (;;) {                                                      \
00321                   set_current_state(TASK_INTERRUPTIBLE);                  \
00322                   if (condition)                                          \
00323                           break;                                          \
00324                   if (!signal_pending(current)) {                         \
00325                           ret = schedule_timeout(ret)    ;                \
00326                           if (!ret)                                       \
00327                                  break;                                   \
00328                           continue;                                       \
00329                   }                                                       \
00330                   ret = -ERESTARTSYS;                                     \
00331                   break;                                                  \
00332           }                                                               \
00333           set_current_state(TASK_RUNNING);                                \
00334           remove_wait_queue(&wq, &__wait);                                \
00335 } while (0)
00336 
00337 #else // 2.2
00338 
00339 
00340 #define __wait_event_interruptible_timeout(wq, condition, ret)          \
00341 do {                                                                    \
00342         struct wait_queue __wait;                                       \
00343                                                                         \
00344         __wait.task = current;                                          \
00345         add_wait_queue(&wq, &__wait);                                   \
00346         for (;;) {                                                      \
00347                 current->state = TASK_INTERRUPTIBLE;                    \
00348                 if (condition)                                          \
00349                         break;                                          \
00350                 if (!signal_pending(current)) {                         \
00351                         ret = schedule_timeout(ret);                    \
00352                         if (!ret)                                       \
00353                                break;                                   \
00354                         continue;                                       \
00355                 }                                                       \
00356                 ret = -ERESTARTSYS;                                     \
00357                 break;                                                  \
00358         }                                                               \
00359         current->state = TASK_RUNNING;                                  \
00360         remove_wait_queue(&wq, &__wait);                                \
00361 } while (0)
00362 
00363 #endif  // version >= 2.4
00364 
00365 #define wait_event_interruptible_timeout(wq, condition, timeout)    \
00366 ({                    \
00367   long __ret = timeout;             \
00368   if (!(condition))             \
00369     __wait_event_interruptible_timeout(wq, condition, __ret); \
00370   __ret;                  \
00371 })
00372 
00373 #endif
00374 
00375 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,20))
00376 #ifdef _LINUX_LIST_H
00377 
00378 static inline void list_move_tail(struct list_head *list,
00379           struct list_head *head)
00380 {
00381         __list_del(list->prev, list->next);
00382         list_add_tail(list, head);
00383 }
00384 
00385 static inline void __list_splice(struct list_head *list,
00386          struct list_head *head)
00387 {
00388       struct list_head *first = list->next;
00389       struct list_head *last = list->prev;
00390       struct list_head *at = head->next;
00391 
00392       first->prev = head;
00393       head->next = first;
00394 
00395       last->next = at;
00396       at->prev = last;
00397 }
00398 
00399 static inline void list_move(struct list_head *list, struct list_head *head)
00400 {
00401       __list_del(list->prev, list->next);
00402       list_add(list, head);
00403 }
00404 
00405 static inline void list_splice_init(struct list_head *list,
00406             struct list_head *head)
00407 {
00408   if (!list_empty(list)) {
00409     __list_splice(list, head);
00410     INIT_LIST_HEAD(list);     
00411   }
00412 }
00413 
00414 
00415 #endif  // LIST_H
00416 #endif
00417 
00418 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,90))
00419 #define spin_lock(l)            do { } while (0)
00420 #define spin_unlock(l)          do { } while (0)
00421 #define spin_lock_irqsave(l,f)  do { save_flags(f); cli(); } while (0)
00422 #define spin_unlock_irqrestore(l,f) do { restore_flags(f); } while (0)
00423 #define spin_lock_init(s)       do { } while (0)
00424 #define spin_trylock(l)         (1)
00425 typedef int spinlock_t;
00426 #endif
00427 
00428 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)) // XXX ???
00429 #define spin_lock_bh         spin_lock
00430 #endif
00431 
00432 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
00433 #ifdef CONFIG_SMP
00434 #define spin_is_locked(x)       (*(volatile char *)(&(x)->lock) <= 0)
00435 #else
00436 #define spin_is_locked(l)       (0)
00437 #endif
00438 #endif
00439 
00440 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,28))
00441 #define __user
00442 #define __iomem
00443 #endif
00444 
00445 #ifdef _LINUX_PROC_FS_H
00446 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,25))
00447 
00448 extern inline struct proc_dir_entry *
00449 create_proc_read_entry(const char *name, mode_t mode,
00450                        struct proc_dir_entry *base,
00451                        read_proc_t *read_proc, void *data)
00452 {
00453     struct proc_dir_entry *res = create_proc_entry(name, mode, base);
00454     if (res) {
00455         res->read_proc = read_proc;  
00456         res->data = data;
00457     }
00458     return res;
00459 }
00460 #endif
00461 
00462 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,29))
00463 #ifndef proc_mkdir
00464 #define proc_mkdir(name, root) create_proc_entry(name, S_IFDIR, root)
00465 #endif
00466 #endif
00467 #endif /* _LINUX_PROC_FS_H */
00468 
00469 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
00470 #ifndef INIT_TQUEUE
00471 #define PREPARE_TQUEUE(_tq, _routine, _data)                    \
00472         do {                                                    \
00473                 (_tq)->routine = _routine;                      \
00474                 (_tq)->data = _data;                            \
00475         } while (0)
00476 #define INIT_TQUEUE(_tq, _routine, _data)                       \
00477         do {                                                    \
00478                 INIT_LIST_HEAD(&(_tq)->list);                   \
00479                 (_tq)->sync = 0;                                \
00480                 PREPARE_TQUEUE((_tq), (_routine), (_data));     \
00481         } while (0)
00482 #endif
00483 
00484 #ifndef INIT_WORK
00485 #define work_struct tq_struct
00486 
00487 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
00488 #define schedule_work(a)   queue_task(a, &tq_scheduler)
00489 #else
00490 #define schedule_work(a)  schedule_task(a)
00491 #endif
00492 
00493 #define flush_scheduled_work  flush_scheduled_tasks
00494 #define INIT_WORK(_wq, _routine, _data)  INIT_TQUEUE(_wq, _routine, _data)
00495 #define PREPARE_WORK(_wq, _routine, _data)  PREPARE_TQUEUE(_wq, _routine, _data)
00496 #endif
00497 #endif // < 2.5 kernel
00498 
00499 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38))
00500 typedef struct device netdevice_t;
00501 #elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,4))
00502 typedef struct net_device netdevice_t;
00503 #else
00504 #undef netdevice_t
00505 typedef struct net_device netdevice_t;
00506 #endif
00507 
00508 #ifdef WIRELESS_EXT
00509 #if (WIRELESS_EXT < 13)
00510 struct iw_request_info
00511 {
00512         __u16           cmd;            /* Wireless Extension command */
00513         __u16           flags;          /* More to come ;-) */
00514 };
00515 #endif
00516 #endif
00517 
00518 
00519 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,18))
00520 #define MODULE_PARM(a,b)        extern int __bogus_decl
00521 #define MODULE_AUTHOR(a)        extern int __bogus_decl
00522 #define MODULE_DESCRIPTION(a)   extern int __bogus_decl
00523 #define MODULE_SUPPORTED_DEVICE(a) extern int __bogus_decl
00524 #undef  GET_USE_COUNT
00525 #define GET_USE_COUNT(m)        mod_use_count_
00526 #endif
00527 
00528 #ifndef MODULE_OWNER
00529 #define MODULE_OWNER(a)         extern int __bogus_decl
00530 #define ANCIENT_MODULE_CODE
00531 #endif
00532 
00533 #ifndef MODULE_LICENSE
00534 #define MODULE_LICENSE(m)       extern int __bogus_decl
00535 #endif
00536 
00537 /* TODO:  Do we care about this? */
00538 #ifndef MODULE_DEVICE_TABLE
00539 #define MODULE_DEVICE_TABLE(foo,bar)
00540 #endif
00541 
00542 #define wlan_minutes2ticks(a) ((a)*(wlan_ticks_per_sec *  60))
00543 #define wlan_seconds2ticks(a) ((a)*(wlan_ticks_per_sec))
00544 
00545 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,47))
00546 #define NEW_MODULE_CODE
00547 #ifdef ANCIENT_MODULE_CODE
00548 #undef ANCIENT_MODULE_CODE
00549 #endif
00550 #elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,25))
00551 #define module_param(name, type, perm)                                       \
00552         static inline void *__check_existence_##name(void) { return &name; } \
00553         MODULE_PARM(name, _MODULE_PARM_STRING_ ## type)
00554 
00555 #define _MODULE_PARM_STRING_byte "b"
00556 #define _MODULE_PARM_STRING_short "h"
00557 #define _MODULE_PARM_STRING_ushort "h"
00558 #define _MODULE_PARM_STRING_int "i"
00559 #define _MODULE_PARM_STRING_uint "i"
00560 #define _MODULE_PARM_STRING_long "l"
00561 #define _MODULE_PARM_STRING_ulong "l"
00562 #define _MODULE_PARM_STRING_bool "i"
00563 #endif
00564 
00565 /* linux < 2.5.69 */
00566 #ifndef IRQ_NONE
00567 typedef void irqreturn_t;
00568 #define IRQ_NONE
00569 #define IRQ_HANDLED
00570 #define IRQ_RETVAL(x)
00571 #endif
00572 
00573 #ifndef in_atomic
00574 #define in_atomic()  0
00575 #endif
00576 
00577 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13)) 
00578 #define URB_ASYNC_UNLINK 0
00579 #endif
00580 
00581 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7))
00582 #define URB_ASYNC_UNLINK  USB_ASYNC_UNLINK
00583 #define usb_fill_bulk_urb  FILL_BULK_URB
00584 #define usb_kill_urb  usb_unlink_urb
00585 #else
00586 #define USB_QUEUE_BULK 0
00587 #endif
00588 
00589 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)) 
00590 typedef u32 pm_message_t;
00591 #endif
00592 
00593 #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)) 
00594 #define hotplug_path  "/etc/hotplug/wlan.agent"
00595 #endif
00596 
00597 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
00598 #define free_netdev(x)       kfree(x) 
00599 #endif
00600 
00601 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9))
00602 #define eth_hdr(x)           (x)->mac.ethernet
00603 #endif
00604 
00605 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
00606 #define del_timer_sync(a)       del_timer(a)
00607 #endif
00608 
00609 #ifndef might_sleep
00610 #define might_sleep(a)   do { } while (0)
00611 #endif
00612 
00613 /* Apparently 2.4.2 ethtool is quite different, maybe newer too? */
00614 #if (defined(SIOETHTOOL) && !defined(ETHTOOL_GDRVINFO))
00615 #undef SIOETHTOOL
00616 #endif
00617 
00618 // pcmcia-cs stuff
00619 #if ((LINUX_VERSION_CODE < KERNEL_VERSION(2,5,68)) && \
00620      !defined(pcmcia_access_configuration_register))
00621 #define pcmcia_access_configuration_register(handle, reg) \
00622         CardServices(AccessConfigurationRegister, handle, reg)
00623 #define pcmcia_register_client(handle, reg) \
00624         CardServices(RegisterClient, handle, reg)
00625 #define pcmcia_deregister_client(handle) \
00626         CardServices(DeregisterClient, handle)
00627 #define pcmcia_get_first_tuple(handle, tuple) \
00628         CardServices(GetFirstTuple, handle, tuple)
00629 #define pcmcia_get_next_tuple(handle, tuple) \
00630         CardServices(GetNextTuple, handle, tuple)
00631 #define pcmcia_get_tuple_data(handle, tuple) \
00632         CardServices(GetTupleData, handle, tuple)
00633 #define pcmcia_parse_tuple(handle, tuple, parse) \
00634         CardServices(ParseTuple, handle, tuple, parse)
00635 #define pcmcia_get_configuration_info(handle, config) \
00636         CardServices(GetConfigurationInfo, handle, config)
00637 #define pcmcia_request_io(handle, req) \
00638         CardServices(RequestIO, handle, req)
00639 #define pcmcia_request_irq(handle, req) \
00640         CardServices(RequestIRQ, handle, req)
00641 #define pcmcia_request_configuration(handle, req) \
00642         CardServices(RequestConfiguration, handle, req)
00643 #define pcmcia_release_configuration(handle) \
00644         CardServices(ReleaseConfiguration, handle)
00645 #define pcmcia_release_io(handle, req) \
00646         CardServices(ReleaseIO, handle, req)
00647 #define pcmcia_release_irq(handle, req) \
00648         CardServices(ReleaseIRQ, handle, req)
00649 #define pcmcia_release_window(win) \
00650         CardServices(ReleaseWindow, win)
00651 #define pcmcia_get_card_services_info(info) \
00652         CardServices(GetCardServicesInfo, info)
00653 #define pcmcia_report_error(handle, err) \
00654         CardServices(ReportError, handle, err)
00655 #endif
00656 
00657 #endif /* __KERNEL__ */
00658 
00659 /*=============================================================*/
00660 /*------ Hardware Portability Macros --------------------------*/
00661 /*=============================================================*/
00662 
00663 #define ieee2host16(n)  __le16_to_cpu(n)
00664 #define ieee2host32(n)  __le32_to_cpu(n)
00665 #define host2ieee16(n)  __cpu_to_le16(n)
00666 #define host2ieee32(n)  __cpu_to_le32(n)
00667 
00668 #if (WLAN_CPU_FAMILY != WLAN_MIPS)
00669 typedef UINT32 phys_t;
00670 #endif
00671 
00672 #if (WLAN_CPU_FAMILY == WLAN_PPC)
00673        #define wlan_inw(a)                     in_be16((unsigned short *)((a)+_IO_BASE))
00674        #define wlan_inw_le16_to_cpu(a)         inw((a))
00675        #define wlan_outw(v,a)                  out_be16((unsigned short *)((a)+_IO_BASE), (v))
00676        #define wlan_outw_cpu_to_le16(v,a)      outw((v),(a))
00677 #else
00678        #define wlan_inw(a)                     inw((a))
00679        #define wlan_inw_le16_to_cpu(a)         __cpu_to_le16(inw((a)))
00680        #define wlan_outw(v,a)                  outw((v),(a))
00681        #define wlan_outw_cpu_to_le16(v,a)      outw(__cpu_to_le16((v)),(a))
00682 #endif
00683 
00684 /*=============================================================*/
00685 /*--- General Macros ------------------------------------------*/
00686 /*=============================================================*/
00687 
00688 #define wlan_max(a, b) (((a) > (b)) ? (a) : (b))
00689 #define wlan_min(a, b) (((a) < (b)) ? (a) : (b))
00690 
00691 #define wlan_isprint(c) (((c) > (0x19)) && ((c) < (0x7f)))
00692 
00693 #define wlan_hexchar(x) (((x) < 0x0a) ? ('0' + (x)) : ('a' + ((x) - 0x0a)))
00694 
00695 /* Create a string of printable chars from something that might not be */
00696 /* It's recommended that the str be 4*len + 1 bytes long */
00697 #define wlan_mkprintstr(buf, buflen, str, strlen) \
00698 { \
00699   int i = 0; \
00700   int j = 0; \
00701   memset(str, 0, (strlen)); \
00702   for (i = 0; i < (buflen); i++) { \
00703     if ( wlan_isprint((buf)[i]) ) { \
00704       (str)[j] = (buf)[i]; \
00705       j++; \
00706     } else { \
00707       (str)[j] = '\\'; \
00708       (str)[j+1] = 'x'; \
00709       (str)[j+2] = wlan_hexchar(((buf)[i] & 0xf0) >> 4); \
00710       (str)[j+3] = wlan_hexchar(((buf)[i] & 0x0f)); \
00711       j += 4; \
00712     } \
00713   } \
00714 }
00715 
00716 /*=============================================================*/
00717 /*--- Variables -----------------------------------------------*/
00718 /*=============================================================*/
00719 
00720 #ifdef WLAN_INCLUDE_DEBUG
00721 extern int wlan_debug;
00722 #endif
00723 
00724 extern int wlan_ethconv;    /* What's the default ethconv? */
00725 
00726 /*=============================================================*/
00727 /*--- Functions -----------------------------------------------*/
00728 /*=============================================================*/
00729 #endif /* _WLAN_COMPAT_H */
00730 

Generated on Fri Jul 25 17:10:37 2008 for WifiScanner by  doxygen 1.5.5