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

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