You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

wlan_compat.h 20KB

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