home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / src / linux-headers-2.6.17-6 / include / wlan / wlan_compat.h < prev   
Encoding:
C/C++ Source or Header  |  2006-08-11  |  23.5 KB  |  727 lines

  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. #ifndef _WLAN_COMPAT_H
  49. #define _WLAN_COMPAT_H
  50.  
  51. /*=============================================================*/
  52. /*------ Establish Platform Identity --------------------------*/
  53. /*=============================================================*/
  54. /* Key macros: */
  55. /* WLAN_CPU_FAMILY */
  56.     #define WLAN_Ix86            1
  57.     #define WLAN_PPC            2
  58.     #define WLAN_Ix96            3
  59.     #define WLAN_ARM            4
  60.     #define WLAN_ALPHA            5
  61.     #define WLAN_MIPS            6
  62.     #define WLAN_HPPA            7
  63.     #define WLAN_SPARC            8
  64.     #define WLAN_SH                9
  65.     #define WLAN_x86_64                     10
  66. /* WLAN_SYSARCH */
  67.     #define WLAN_PCAT            1
  68.     #define WLAN_MBX            2
  69.     #define WLAN_RPX            3
  70.     #define WLAN_LWARCH            4
  71.     #define WLAN_PMAC            5
  72.     #define WLAN_SKIFF            6
  73.     #define WLAN_BITSY            7
  74.     #define WLAN_ALPHAARCH            7
  75.     #define WLAN_MIPSARCH            9
  76.     #define WLAN_HPPAARCH            10
  77.     #define WLAN_SPARCARCH            11
  78.     #define WLAN_SHARCH               12
  79.  
  80. /* Note: the PLX HOSTIF above refers to some vendors implementations for */
  81. /*       PCI.  It's a PLX chip that is a PCI to PCMCIA adapter, but it   */
  82. /*       isn't a real PCMCIA host interface adapter providing all the    */
  83. /*       card&socket services.                                           */
  84.  
  85. #if (defined(CONFIG_PPC) || defined(CONFIG_8xx) || defined(__powerpc__))
  86. #ifndef __ppc__
  87. #define __ppc__
  88. #endif
  89. #endif
  90.  
  91. #if defined(__KERNEL__)
  92. #if defined(__x86_64__)
  93.     #define WLAN_CPU_FAMILY        WLAN_x86_64
  94.     #define WLAN_SYSARCH        WLAN_PCAT
  95. #elif defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) || defined(__ia64__)
  96.     #define WLAN_CPU_FAMILY        WLAN_Ix86
  97.     #define WLAN_SYSARCH        WLAN_PCAT
  98. #elif defined(__ppc__)
  99.     #define WLAN_CPU_FAMILY        WLAN_PPC
  100.     #if defined(CONFIG_MBX)
  101.         #define WLAN_SYSARCH    WLAN_MBX
  102.     #elif defined(CONFIG_RPXLITE)
  103.         #define WLAN_SYSARCH    WLAN_RPX
  104.     #elif defined(CONFIG_RPXCLASSIC)
  105.         #define WLAN_SYSARCH    WLAN_RPX
  106.     #else
  107.         #define WLAN_SYSARCH    WLAN_PMAC
  108.     #endif
  109. #elif defined(__arm__)
  110.     #define WLAN_CPU_FAMILY        WLAN_ARM
  111.     #define WLAN_SYSARCH        WLAN_SKIFF
  112. #elif defined(__alpha__)
  113.     #define WLAN_CPU_FAMILY        WLAN_ALPHA
  114.     #define WLAN_SYSARCH        WLAN_ALPHAARCH
  115. #elif defined(__mips__)
  116.     #define WLAN_CPU_FAMILY        WLAN_MIPS
  117.     #define WLAN_SYSARCH        WLAN_MIPSARCH
  118. #elif defined(__hppa__)
  119.     #define WLAN_CPU_FAMILY        WLAN_HPPA
  120.     #define WLAN_SYSARCH        WLAN_HPPAARCH
  121. #elif defined(__sparc__)
  122.         #define WLAN_CPU_FAMILY         WLAN_SPARC
  123.         #define WLAN_SYSARCH            WLAN_SPARC
  124. #elif defined(__sh__)
  125.         #define WLAN_CPU_FAMILY         WLAN_SH    
  126.         #define WLAN_SYSARCH            WLAN_SHARCH
  127.         #ifndef __LITTLE_ENDIAN__
  128.         #define __LITTLE_ENDIAN__
  129.         #endif
  130. #else
  131.     #error "No CPU identified!"
  132. #endif
  133. #endif /* __KERNEL__ */
  134.  
  135. /*
  136.    Some big endian machines implicitly do all I/O in little endian mode.
  137.  
  138.    In particular:
  139.           Linux/PPC on PowerMacs (PCI)
  140.       Arm/Intel Xscale (PCI)
  141.  
  142.    This may also affect PLX boards and other BE &| PPC platforms; 
  143.    as new ones are discovered, add them below. 
  144. */
  145.  
  146. #if ((WLAN_HOSTIF == WLAN_PCI) || (WLAN_HOSTIF == WLAN_PLX))
  147. #if ((WLAN_SYSARCH == WLAN_SKIFF) || (WLAN_SYSARCH == WLAN_PMAC) || (WLAN_SYSARCH == WLAN_SPARC))
  148. #define REVERSE_ENDIAN
  149. #endif
  150. #endif
  151.  
  152. /*=============================================================*/
  153. /*------ Bit settings -----------------------------------------*/
  154. /*=============================================================*/
  155.  
  156. #define BIT0    0x00000001
  157. #define BIT1    0x00000002
  158. #define BIT2    0x00000004
  159. #define BIT3    0x00000008
  160. #define BIT4    0x00000010
  161. #define BIT5    0x00000020
  162. #define BIT6    0x00000040
  163. #define BIT7    0x00000080
  164. #define BIT8    0x00000100
  165. #define BIT9    0x00000200
  166. #define BIT10    0x00000400
  167. #define BIT11    0x00000800
  168. #define BIT12    0x00001000
  169. #define BIT13    0x00002000
  170. #define BIT14    0x00004000
  171. #define BIT15    0x00008000
  172. #define BIT16    0x00010000
  173. #define BIT17    0x00020000
  174. #define BIT18    0x00040000
  175. #define BIT19    0x00080000
  176. #define BIT20    0x00100000
  177. #define BIT21    0x00200000
  178. #define BIT22    0x00400000
  179. #define BIT23    0x00800000
  180. #define BIT24    0x01000000
  181. #define BIT25    0x02000000
  182. #define BIT26    0x04000000
  183. #define BIT27    0x08000000
  184. #define BIT28    0x10000000
  185. #define BIT29    0x20000000
  186. #define BIT30    0x40000000
  187. #define BIT31    0x80000000
  188.  
  189. #include <linux/types.h>
  190.  
  191. typedef u_int8_t    UINT8;
  192. typedef u_int16_t    UINT16;
  193. typedef u_int32_t    UINT32;
  194.  
  195. typedef int8_t        INT8;
  196. typedef int16_t        INT16;
  197. typedef int32_t        INT32;
  198.  
  199. typedef unsigned int    UINT;
  200. typedef signed int      INT;
  201.  
  202. typedef u_int64_t    UINT64;
  203. typedef int64_t        INT64;
  204.  
  205. #define UINT8_MAX    (0xffUL)
  206. #define UINT16_MAX    (0xffffUL)
  207. #define UINT32_MAX    (0xffffffffUL)
  208.  
  209. #define INT8_MAX    (0x7fL)
  210. #define INT16_MAX    (0x7fffL)
  211. #define INT32_MAX    (0x7fffffffL)
  212.  
  213. /*=============================================================*/
  214. /*------ Compiler Portability Macros --------------------------*/
  215. /*=============================================================*/
  216. #define __WLAN_ATTRIB_PACK__        __attribute__ ((packed))
  217.  
  218. /*=============================================================*/
  219. /*------ OS Portability Macros --------------------------------*/
  220. /*=============================================================*/
  221.  
  222. #ifndef WLAN_DBVAR
  223. #define WLAN_DBVAR    wlan_debug
  224. #endif
  225.  
  226. #ifndef KERNEL_VERSION
  227. #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
  228. #endif
  229.  
  230. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
  231. #  if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,8))
  232. #    include <linux/hardirq.h>
  233. #  else 
  234. #    include <asm/hardirq.h>
  235. #  endif
  236. #elif defined(__KERNEL__)
  237. #  define PREEMPT_MASK  (0x000000FFUL)
  238. #  define preempt_count() (0UL)
  239. #endif
  240.  
  241. #define WLAN_LOG_ERROR(x,args...) printk(KERN_ERR "%s: " x , __FUNCTION__ , ##args);
  242.  
  243. #define WLAN_LOG_WARNING(x,args...) printk(KERN_WARNING "%s: " x , __FUNCTION__ , ##args);
  244.  
  245. #define WLAN_LOG_NOTICE(x,args...) printk(KERN_NOTICE "%s: " x , __FUNCTION__ , ##args);
  246.  
  247. #define WLAN_LOG_INFO(args... ) printk(KERN_INFO args)
  248.  
  249. #if defined(WLAN_INCLUDE_DEBUG)
  250.     #define WLAN_ASSERT(c) if ((!(c)) && WLAN_DBVAR >= 1) { \
  251.         WLAN_LOG_DEBUG(1, "Assertion failure!\n"); }
  252.     #define WLAN_HEX_DUMP( l, x, p, n)    if( WLAN_DBVAR >= (l) ){ \
  253.         int __i__; \
  254.         printk(KERN_DEBUG x ":"); \
  255.         for( __i__=0; __i__ < (n); __i__++) \
  256.             printk( " %02x", ((UINT8*)(p))[__i__]); \
  257.         printk("\n"); }
  258.     #define DBFENTER { if ( WLAN_DBVAR >= 5 ){ WLAN_LOG_DEBUG(3,"---->\n"); } }
  259.     #define DBFEXIT  { if ( WLAN_DBVAR >= 5 ){ WLAN_LOG_DEBUG(3,"<----\n"); } }
  260.  
  261.     #define WLAN_LOG_DEBUG(l,x,args...) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s(%lu): " x ,  __FUNCTION__, (preempt_count() & PREEMPT_MASK), ##args );
  262. #else
  263.     #define WLAN_ASSERT(c) 
  264.     #define WLAN_HEX_DUMP( l, s, p, n)
  265.     #define DBFENTER 
  266.     #define DBFEXIT 
  267.  
  268.     #define WLAN_LOG_DEBUG(l, s, args...)
  269. #endif
  270.  
  271. #ifdef CONFIG_SMP
  272. #define __SMP__            1
  273. #endif    
  274.  
  275. #if defined(__KERNEL__)
  276.  
  277. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7))
  278. #  define del_singleshot_timer_sync(a)  del_timer_sync(a)
  279. #endif
  280.  
  281. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,17))
  282. #define CONFIG_NETLINK        1
  283. #endif
  284.  
  285. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0))
  286. #define kfree_s(a, b)    kfree((a))
  287. #endif
  288.  
  289. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18))
  290. #ifndef init_waitqueue_head
  291. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,0,16))
  292. #define init_waitqueue_head(p)  (*(p) = NULL)
  293. #else
  294. #define init_waitqueue_head(p)  init_waitqueue(p)
  295. #endif
  296. typedef struct wait_queue *wait_queue_head_t;
  297. typedef struct wait_queue wait_queue_t;
  298. #define set_current_state(b)  { current->state = (b); mb(); }
  299. #define init_waitqueue_entry(a, b) { (a)->task = current; }
  300. #endif
  301. #endif
  302.  
  303. #ifndef wait_event_interruptible_timeout
  304. // retval == 0; signal met; we're good.
  305. // retval < 0; interrupted by signal.
  306. // retval > 0; timed out.
  307.  
  308. #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0))  // fixme?
  309.  
  310. #define __wait_event_interruptible_timeout(wq, condition, ret)            \
  311. do {                                                                      \
  312.           wait_queue_t __wait;                                            \
  313.           init_waitqueue_entry(&__wait, current);                         \
  314.                                                                       \
  315.           add_wait_queue(&wq, &__wait);                                   \
  316.           for (;;) {                                                      \
  317.                   set_current_state(TASK_INTERRUPTIBLE);                  \
  318.                   if (condition)                                          \
  319.                           break;                                          \
  320.                   if (!signal_pending(current)) {                         \
  321.                           ret = schedule_timeout(ret)    ;                \
  322.                           if (!ret)                                       \
  323.                                  break;                                   \
  324.                           continue;                                       \
  325.                   }                                                       \
  326.                   ret = -ERESTARTSYS;                                     \
  327.                   break;                                                  \
  328.           }                                                               \
  329.           set_current_state(TASK_RUNNING);                                \
  330.           remove_wait_queue(&wq, &__wait);                                \
  331. } while (0)
  332.  
  333. #else // 2.2
  334.  
  335.  
  336. #define __wait_event_interruptible_timeout(wq, condition, ret)          \
  337. do {                                                                    \
  338.         struct wait_queue __wait;                                       \
  339.                                                                         \
  340.         __wait.task = current;                                          \
  341.         add_wait_queue(&wq, &__wait);                                   \
  342.         for (;;) {                                                      \
  343.                 current->state = TASK_INTERRUPTIBLE;                    \
  344.                 if (condition)                                          \
  345.                         break;                                          \
  346.                 if (!signal_pending(current)) {                         \
  347.                         ret = schedule_timeout(ret);                    \
  348.                         if (!ret)                                       \
  349.                                break;                                   \
  350.                         continue;                                       \
  351.                 }                                                       \
  352.                 ret = -ERESTARTSYS;                                     \
  353.                 break;                                                  \
  354.         }                                                               \
  355.         current->state = TASK_RUNNING;                                  \
  356.         remove_wait_queue(&wq, &__wait);                                \
  357. } while (0)
  358.  
  359. #endif  // version >= 2.4
  360.  
  361. #define wait_event_interruptible_timeout(wq, condition, timeout)      \
  362. ({                                      \
  363.     long __ret = timeout;                          \
  364.     if (!(condition))                          \
  365.         __wait_event_interruptible_timeout(wq, condition, __ret); \
  366.     __ret;                                  \
  367. })
  368.  
  369. #endif
  370.  
  371. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,20))
  372. #ifdef _LINUX_LIST_H
  373.  
  374. static inline void list_move_tail(struct list_head *list,
  375.           struct list_head *head)
  376. {
  377.         __list_del(list->prev, list->next);
  378.         list_add_tail(list, head);
  379. }
  380.  
  381. static inline void __list_splice(struct list_head *list,
  382.                  struct list_head *head)
  383. {
  384.       struct list_head *first = list->next;
  385.       struct list_head *last = list->prev;
  386.       struct list_head *at = head->next;
  387.  
  388.       first->prev = head;
  389.       head->next = first;
  390.  
  391.       last->next = at;
  392.       at->prev = last;
  393. }
  394.  
  395. static inline void list_move(struct list_head *list, struct list_head *head)
  396. {
  397.       __list_del(list->prev, list->next);
  398.       list_add(list, head);
  399. }
  400.  
  401. static inline void list_splice_init(struct list_head *list,
  402.             struct list_head *head)
  403. {
  404.     if (!list_empty(list)) {
  405.         __list_splice(list, head);
  406.         INIT_LIST_HEAD(list);     
  407.     }
  408. }
  409.  
  410.  
  411. #endif  // LIST_H
  412. #endif
  413.  
  414. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,90))
  415. #define spin_lock(l)            do { } while (0)
  416. #define spin_unlock(l)          do { } while (0)
  417. #define spin_lock_irqsave(l,f)  do { save_flags(f); cli(); } while (0)
  418. #define spin_unlock_irqrestore(l,f) do { restore_flags(f); } while (0)
  419. #define spin_lock_init(s)       do { } while (0)
  420. #define spin_trylock(l)         (1)
  421. typedef int spinlock_t;
  422. #endif
  423.  
  424. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)) // XXX ???
  425. #define spin_lock_bh         spin_lock
  426. #endif
  427.  
  428. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
  429. #ifdef CONFIG_SMP
  430. #define spin_is_locked(x)       (*(volatile char *)(&(x)->lock) <= 0)
  431. #else
  432. #define spin_is_locked(l)       (0)
  433. #endif
  434. #endif
  435.  
  436. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,28))
  437. #define __user
  438. #define __iomem
  439. #endif
  440.  
  441. #ifdef _LINUX_PROC_FS_H
  442. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,25))
  443.  
  444. extern inline struct proc_dir_entry *
  445. create_proc_read_entry(const char *name, mode_t mode,
  446.                        struct proc_dir_entry *base,
  447.                        read_proc_t *read_proc, void *data)
  448. {
  449.     struct proc_dir_entry *res = create_proc_entry(name, mode, base);
  450.     if (res) {
  451.         res->read_proc = read_proc;  
  452.         res->data = data;
  453.     }
  454.     return res;
  455. }
  456. #endif
  457.  
  458. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,29))
  459. #ifndef proc_mkdir
  460. #define proc_mkdir(name, root) create_proc_entry(name, S_IFDIR, root)
  461. #endif
  462. #endif
  463. #endif /* _LINUX_PROC_FS_H */
  464.  
  465. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
  466. #ifndef INIT_TQUEUE
  467. #define PREPARE_TQUEUE(_tq, _routine, _data)                    \
  468.         do {                                                    \
  469.                 (_tq)->routine = _routine;                      \
  470.                 (_tq)->data = _data;                            \
  471.         } while (0)
  472. #define INIT_TQUEUE(_tq, _routine, _data)                       \
  473.         do {                                                    \
  474.                 INIT_LIST_HEAD(&(_tq)->list);                   \
  475.                 (_tq)->sync = 0;                                \
  476.                 PREPARE_TQUEUE((_tq), (_routine), (_data));     \
  477.         } while (0)
  478. #endif
  479.  
  480. #ifndef INIT_WORK
  481. #define work_struct tq_struct
  482.  
  483. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
  484. #define schedule_work(a)   queue_task(a, &tq_scheduler)
  485. #else
  486. #define schedule_work(a)  schedule_task(a)
  487. #endif
  488.  
  489. #define flush_scheduled_work  flush_scheduled_tasks
  490. #define INIT_WORK(_wq, _routine, _data)  INIT_TQUEUE(_wq, _routine, _data)
  491. #define PREPARE_WORK(_wq, _routine, _data)  PREPARE_TQUEUE(_wq, _routine, _data)
  492. #endif
  493. #endif // < 2.5 kernel
  494.  
  495. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38))
  496. typedef struct device netdevice_t;
  497. #elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,4))
  498. typedef struct net_device netdevice_t;
  499. #else
  500. #undef netdevice_t
  501. typedef struct net_device netdevice_t;
  502. #endif
  503.  
  504. #ifdef WIRELESS_EXT
  505. #if (WIRELESS_EXT < 13)
  506. struct iw_request_info
  507. {
  508.         __u16           cmd;            /* Wireless Extension command */
  509.         __u16           flags;          /* More to come ;-) */
  510. };
  511. #endif
  512. #endif
  513.  
  514.  
  515. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,18))
  516. #define MODULE_PARM(a,b)        extern int __bogus_decl
  517. #define MODULE_AUTHOR(a)        extern int __bogus_decl
  518. #define MODULE_DESCRIPTION(a)   extern int __bogus_decl
  519. #define MODULE_SUPPORTED_DEVICE(a) extern int __bogus_decl
  520. #undef  GET_USE_COUNT
  521. #define GET_USE_COUNT(m)        mod_use_count_
  522. #endif
  523.  
  524. #ifndef MODULE_OWNER
  525. #define MODULE_OWNER(a)         extern int __bogus_decl
  526. #define ANCIENT_MODULE_CODE
  527. #endif
  528.  
  529. #ifndef MODULE_LICENSE
  530. #define MODULE_LICENSE(m)       extern int __bogus_decl
  531. #endif
  532.  
  533. /* TODO:  Do we care about this? */
  534. #ifndef MODULE_DEVICE_TABLE
  535. #define MODULE_DEVICE_TABLE(foo,bar)
  536. #endif
  537.  
  538. #define wlan_minutes2ticks(a) ((a)*(wlan_ticks_per_sec *  60))
  539. #define wlan_seconds2ticks(a) ((a)*(wlan_ticks_per_sec))
  540.  
  541. #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,5,47))
  542. #define NEW_MODULE_CODE
  543. #ifdef ANCIENT_MODULE_CODE
  544. #undef ANCIENT_MODULE_CODE
  545. #endif
  546. #elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,25))
  547. #define module_param(name, type, perm)                                       \
  548.         static inline void *__check_existence_##name(void) { return &name; } \
  549.         MODULE_PARM(name, _MODULE_PARM_STRING_ ## type)
  550.  
  551. #define _MODULE_PARM_STRING_byte "b"
  552. #define _MODULE_PARM_STRING_short "h"
  553. #define _MODULE_PARM_STRING_ushort "h"
  554. #define _MODULE_PARM_STRING_int "i"
  555. #define _MODULE_PARM_STRING_uint "i"
  556. #define _MODULE_PARM_STRING_long "l"
  557. #define _MODULE_PARM_STRING_ulong "l"
  558. #define _MODULE_PARM_STRING_bool "i"
  559. #endif
  560.  
  561. /* linux < 2.5.69 */
  562. #ifndef IRQ_NONE
  563. typedef void irqreturn_t;
  564. #define IRQ_NONE
  565. #define IRQ_HANDLED
  566. #define IRQ_RETVAL(x)
  567. #endif
  568.  
  569. #ifndef in_atomic
  570. #define in_atomic()  0
  571. #endif
  572.  
  573. #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,13)) 
  574. #define URB_ASYNC_UNLINK 0
  575. #endif
  576.  
  577. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,7))
  578. #define URB_ASYNC_UNLINK  USB_ASYNC_UNLINK
  579. #define usb_fill_bulk_urb  FILL_BULK_URB
  580. #define usb_kill_urb  usb_unlink_urb
  581. #else
  582. #define USB_QUEUE_BULK 0
  583. #endif
  584.  
  585. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)) 
  586. typedef u32 pm_message_t;
  587. #endif
  588.  
  589. #if (LINUX_VERSION_CODE > KERNEL_VERSION(2,6,9)) 
  590. #define hotplug_path  "/etc/hotplug/wlan.agent"
  591. #endif
  592.  
  593. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0))
  594. #define free_netdev(x)       kfree(x) 
  595. #endif
  596.  
  597. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,9))
  598. #define eth_hdr(x)           (x)->mac.ethernet
  599. #endif
  600.  
  601. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
  602. #define del_timer_sync(a)       del_timer(a)
  603. #endif
  604.  
  605. #ifndef might_sleep
  606. #define might_sleep(a)   do { } while (0)
  607. #endif
  608.  
  609. /* Apparently 2.4.2 ethtool is quite different, maybe newer too? */
  610. #if (defined(SIOETHTOOL) && !defined(ETHTOOL_GDRVINFO))
  611. #undef SIOETHTOOL
  612. #endif
  613.  
  614. // pcmcia-cs stuff
  615. #if ((LINUX_VERSION_CODE < KERNEL_VERSION(2,5,68)) && \
  616.      !defined(pcmcia_access_configuration_register))
  617. #define pcmcia_access_configuration_register(handle, reg) \
  618.         CardServices(AccessConfigurationRegister, handle, reg)
  619. #define pcmcia_register_client(handle, reg) \
  620.         CardServices(RegisterClient, handle, reg)
  621. #define pcmcia_deregister_client(handle) \
  622.         CardServices(DeregisterClient, handle)
  623. #define pcmcia_get_first_tuple(handle, tuple) \
  624.         CardServices(GetFirstTuple, handle, tuple)
  625. #define pcmcia_get_next_tuple(handle, tuple) \
  626.         CardServices(GetNextTuple, handle, tuple)
  627. #define pcmcia_get_tuple_data(handle, tuple) \
  628.         CardServices(GetTupleData, handle, tuple)
  629. #define pcmcia_parse_tuple(handle, tuple, parse) \
  630.         CardServices(ParseTuple, handle, tuple, parse)
  631. #define pcmcia_get_configuration_info(handle, config) \
  632.         CardServices(GetConfigurationInfo, handle, config)
  633. #define pcmcia_request_io(handle, req) \
  634.         CardServices(RequestIO, handle, req)
  635. #define pcmcia_request_irq(handle, req) \
  636.         CardServices(RequestIRQ, handle, req)
  637. #define pcmcia_request_configuration(handle, req) \
  638.         CardServices(RequestConfiguration, handle, req)
  639. #define pcmcia_release_configuration(handle) \
  640.         CardServices(ReleaseConfiguration, handle)
  641. #define pcmcia_release_io(handle, req) \
  642.         CardServices(ReleaseIO, handle, req)
  643. #define pcmcia_release_irq(handle, req) \
  644.         CardServices(ReleaseIRQ, handle, req)
  645. #define pcmcia_release_window(win) \
  646.         CardServices(ReleaseWindow, win)
  647. #define pcmcia_get_card_services_info(info) \
  648.         CardServices(GetCardServicesInfo, info)
  649. #define pcmcia_report_error(handle, err) \
  650.         CardServices(ReportError, handle, err)
  651. #endif
  652.  
  653. #endif /* __KERNEL__ */
  654.  
  655. /*=============================================================*/
  656. /*------ Hardware Portability Macros --------------------------*/
  657. /*=============================================================*/
  658.  
  659. #define ieee2host16(n)    __le16_to_cpu(n)
  660. #define ieee2host32(n)    __le32_to_cpu(n)
  661. #define host2ieee16(n)    __cpu_to_le16(n)
  662. #define host2ieee32(n)    __cpu_to_le32(n)
  663.  
  664. #if (WLAN_CPU_FAMILY != WLAN_MIPS)
  665. typedef UINT32 phys_t;
  666. #endif
  667.  
  668. #if (WLAN_CPU_FAMILY == WLAN_PPC)
  669.        #define wlan_inw(a)                     in_be16((unsigned short *)((a)+_IO_BASE))
  670.        #define wlan_inw_le16_to_cpu(a)         inw((a))
  671.        #define wlan_outw(v,a)                  out_be16((unsigned short *)((a)+_IO_BASE), (v))
  672.        #define wlan_outw_cpu_to_le16(v,a)      outw((v),(a))
  673. #else
  674.        #define wlan_inw(a)                     inw((a))
  675.        #define wlan_inw_le16_to_cpu(a)         __cpu_to_le16(inw((a)))
  676.        #define wlan_outw(v,a)                  outw((v),(a))
  677.        #define wlan_outw_cpu_to_le16(v,a)      outw(__cpu_to_le16((v)),(a))
  678. #endif
  679.  
  680. /*=============================================================*/
  681. /*--- General Macros ------------------------------------------*/
  682. /*=============================================================*/
  683.  
  684. #define wlan_max(a, b) (((a) > (b)) ? (a) : (b))
  685. #define wlan_min(a, b) (((a) < (b)) ? (a) : (b))
  686.  
  687. #define wlan_isprint(c)    (((c) > (0x19)) && ((c) < (0x7f)))
  688.  
  689. #define wlan_hexchar(x) (((x) < 0x0a) ? ('0' + (x)) : ('a' + ((x) - 0x0a)))
  690.  
  691. /* Create a string of printable chars from something that might not be */
  692. /* It's recommended that the str be 4*len + 1 bytes long */
  693. #define wlan_mkprintstr(buf, buflen, str, strlen) \
  694. { \
  695.     int i = 0; \
  696.     int j = 0; \
  697.     memset(str, 0, (strlen)); \
  698.     for (i = 0; i < (buflen); i++) { \
  699.         if ( wlan_isprint((buf)[i]) ) { \
  700.             (str)[j] = (buf)[i]; \
  701.             j++; \
  702.         } else { \
  703.             (str)[j] = '\\'; \
  704.             (str)[j+1] = 'x'; \
  705.             (str)[j+2] = wlan_hexchar(((buf)[i] & 0xf0) >> 4); \
  706.             (str)[j+3] = wlan_hexchar(((buf)[i] & 0x0f)); \
  707.             j += 4; \
  708.         } \
  709.     } \
  710. }
  711.  
  712. /*=============================================================*/
  713. /*--- Variables -----------------------------------------------*/
  714. /*=============================================================*/
  715.  
  716. #ifdef WLAN_INCLUDE_DEBUG
  717. extern int wlan_debug;
  718. #endif
  719.  
  720. extern int wlan_ethconv;        /* What's the default ethconv? */
  721.  
  722. /*=============================================================*/
  723. /*--- Functions -----------------------------------------------*/
  724. /*=============================================================*/
  725. #endif /* _WLAN_COMPAT_H */
  726.  
  727.