Adding debian version 3.70~pre8+dfsg-1.
[syslinux-debian/hramrach.git] / gpxe / src / drivers / net / wlan_compat.h
bloba4f75e3abc2ecee04f047a5114a95617abd2a679
1 /* src/include/wlan/wlan_compat.h
3 * Types and macros to aid in portability
5 * Copyright (C) 1999 AbsoluteValue Systems, Inc. All Rights Reserved.
6 * --------------------------------------------------------------------
8 * linux-wlan
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/
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.
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.
31 * --------------------------------------------------------------------
33 * Inquiries regarding the linux-wlan Open Source project can be
34 * made directly to:
36 * AbsoluteValue Systems Inc.
37 * info@linux-wlan.com
38 * http://www.linux-wlan.com
40 * --------------------------------------------------------------------
42 * Portions of the development of this software were funded by
43 * Intersil Corporation as part of PRISM(R) chipset product development.
45 * --------------------------------------------------------------------
48 #ifndef _WLAN_COMPAT_H
49 #define _WLAN_COMPAT_H
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 /* WLAN_CPU_CORE */
64 #define WLAN_I386CORE 1
65 #define WLAN_PPCCORE 2
66 #define WLAN_I296 3
67 #define WLAN_ARMCORE 4
68 #define WLAN_ALPHACORE 5
69 #define WLAN_MIPSCORE 6
70 #define WLAN_HPPACORE 7
71 /* WLAN_CPU_PART */
72 #define WLAN_I386PART 1
73 #define WLAN_MPC860 2
74 #define WLAN_MPC823 3
75 #define WLAN_I296SA 4
76 #define WLAN_PPCPART 5
77 #define WLAN_ARMPART 6
78 #define WLAN_ALPHAPART 7
79 #define WLAN_MIPSPART 8
80 #define WLAN_HPPAPART 9
81 /* WLAN_SYSARCH */
82 #define WLAN_PCAT 1
83 #define WLAN_MBX 2
84 #define WLAN_RPX 3
85 #define WLAN_LWARCH 4
86 #define WLAN_PMAC 5
87 #define WLAN_SKIFF 6
88 #define WLAN_BITSY 7
89 #define WLAN_ALPHAARCH 7
90 #define WLAN_MIPSARCH 9
91 #define WLAN_HPPAARCH 10
92 /* WLAN_OS */
93 #define WLAN_LINUX_KERNEL 1
94 #define WLAN_LINUX_USER 2
95 /* WLAN_HOSTIF (generally set on the command line, not detected) */
96 #define WLAN_PCMCIA 1
97 #define WLAN_ISA 2
98 #define WLAN_PCI 3
99 #define WLAN_USB 4
100 #define WLAN_PLX 5
102 /* Note: the PLX HOSTIF above refers to some vendors implementations for */
103 /* PCI. It's a PLX chip that is a PCI to PCMCIA adapter, but it */
104 /* isn't a real PCMCIA host interface adapter providing all the */
105 /* card&socket services. */
107 /* Lets try to figure out what we've got. Kernel mode or User mode? */
108 #if defined(__KERNEL__)
109 #define WLAN_OS WLAN_LINUX_KERNEL
110 #else
111 #define WLAN_OS WLAN_LINUX_USER
112 #endif
114 #ifdef __powerpc__
115 #ifndef __ppc__
116 #define __ppc__
117 #endif
118 #endif
120 #if (defined(CONFIG_PPC) || defined(CONFIG_8xx))
121 #ifndef __ppc__
122 #define __ppc__
123 #endif
124 #endif
126 #if defined(__KERNEL__)
127 #if defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__)
128 #define WLAN_CPU_FAMILY WLAN_Ix86
129 #define WLAN_CPU_CORE WLAN_I386CORE
130 #define WLAN_CPU_PART WLAN_I386PART
131 #define WLAN_SYSARCH WLAN_PCAT
132 #elif defined(__ppc__)
133 #define WLAN_CPU_FAMILY WLAN_PPC
134 #define WLAN_CPU_CORE WLAN_PPCCORE
135 #if defined(CONFIG_MBX)
136 #define WLAN_CPU_PART WLAN_MPC860
137 #define WLAN_SYSARCH WLAN_MBX
138 #elif defined(CONFIG_RPXLITE)
139 #define WLAN_CPU_PART WLAN_MPC823
140 #define WLAN_SYSARCH WLAN_RPX
141 #elif defined(CONFIG_RPXCLASSIC)
142 #define WLAN_CPU_PART WLAN_MPC860
143 #define WLAN_SYSARCH WLAN_RPX
144 #else
145 #define WLAN_CPU_PART WLAN_PPCPART
146 #define WLAN_SYSARCH WLAN_PMAC
147 #endif
148 #elif defined(__arm__)
149 #define WLAN_CPU_FAMILY WLAN_ARM
150 #define WLAN_CPU_CORE WLAN_ARMCORE
151 #define WLAN_CPU_PART WLAN_ARM_PART
152 #define WLAN_SYSARCH WLAN_SKIFF
153 #elif defined(__alpha__)
154 #define WLAN_CPU_FAMILY WLAN_ALPHA
155 #define WLAN_CPU_CORE WLAN_ALPHACORE
156 #define WLAN_CPU_PART WLAN_ALPHAPART
157 #define WLAN_SYSARCH WLAN_ALPHAARCH
158 #elif defined(__mips__)
159 #define WLAN_CPU_FAMILY WLAN_MIPS
160 #define WLAN_CPU_CORE WLAN_MIPSCORE
161 #define WLAN_CPU_PART WLAN_MIPSPART
162 #define WLAN_SYSARCH WLAN_MIPSARCH
163 #elif defined(__hppa__)
164 #define WLAN_CPU_FAMILY WLAN_HPPA
165 #define WLAN_CPU_CORE WLAN_HPPACORE
166 #define WLAN_CPU_PART WLAN_HPPAPART
167 #define WLAN_SYSARCH WLAN_HPPAARCH
168 #else
169 #error "No CPU identified!"
170 #endif
171 #endif /* __KERNEL__ */
174 Some big endian machines implicitly do all I/O in little endian mode.
176 In particular:
177 Linux/PPC on PowerMacs (PCI)
178 Arm/Intel Xscale (PCI)
180 This may also affect PLX boards and other BE &| PPC platforms;
181 as new ones are discovered, add them below.
184 #if (WLAN_HOSTIF == WLAN_PCI)
185 #if ((WLAN_SYSARCH == WLAN_SKIFF) || (WLAN_SYSARCH == WLAN_PMAC))
186 #define REVERSE_ENDIAN
187 #endif
188 #endif
190 /*=============================================================*/
191 /*------ Bit settings -----------------------------------------*/
192 /*=============================================================*/
194 #define BIT0 0x00000001
195 #define BIT1 0x00000002
196 #define BIT2 0x00000004
197 #define BIT3 0x00000008
198 #define BIT4 0x00000010
199 #define BIT5 0x00000020
200 #define BIT6 0x00000040
201 #define BIT7 0x00000080
202 #define BIT8 0x00000100
203 #define BIT9 0x00000200
204 #define BIT10 0x00000400
205 #define BIT11 0x00000800
206 #define BIT12 0x00001000
207 #define BIT13 0x00002000
208 #define BIT14 0x00004000
209 #define BIT15 0x00008000
210 #define BIT16 0x00010000
211 #define BIT17 0x00020000
212 #define BIT18 0x00040000
213 #define BIT19 0x00080000
214 #define BIT20 0x00100000
215 #define BIT21 0x00200000
216 #define BIT22 0x00400000
217 #define BIT23 0x00800000
218 #define BIT24 0x01000000
219 #define BIT25 0x02000000
220 #define BIT26 0x04000000
221 #define BIT27 0x08000000
222 #define BIT28 0x10000000
223 #define BIT29 0x20000000
224 #define BIT30 0x40000000
225 #define BIT31 0x80000000
227 typedef unsigned char UINT8;
228 typedef unsigned short UINT16;
229 typedef unsigned long UINT32;
231 typedef signed char INT8;
232 typedef signed short INT16;
233 typedef signed long INT32;
235 typedef unsigned int UINT;
236 typedef signed int INT;
238 typedef unsigned long long UINT64;
239 typedef signed long long INT64;
241 #define UINT8_MAX (0xffUL)
242 #define UINT16_MAX (0xffffUL)
243 #define UINT32_MAX (0xffffffffUL)
245 #define INT8_MAX (0x7fL)
246 #define INT16_MAX (0x7fffL)
247 #define INT32_MAX (0x7fffffffL)
249 /*=============================================================*/
250 /*------ Compiler Portability Macros --------------------------*/
251 /*=============================================================*/
252 #define __WLAN_ATTRIB_PACK__ __attribute__ ((packed))
253 #define __WLAN_PRAGMA_PACK1__
254 #define __WLAN_PRAGMA_PACKDFLT__
255 #define __WLAN_INLINE__ inline
256 #define WLAN_MIN_ARRAY 0
258 /*=============================================================*/
259 /*------ OS Portability Macros --------------------------------*/
260 /*=============================================================*/
262 #ifndef WLAN_DBVAR
263 #define WLAN_DBVAR wlan_debug
264 #endif
266 #if (WLAN_OS == WLAN_LINUX_KERNEL)
267 #define WLAN_LOG_ERROR0(x) printk(KERN_ERR "%s: " x , __FUNCTION__ );
268 #define WLAN_LOG_ERROR1(x,n) printk(KERN_ERR "%s: " x , __FUNCTION__ , (n));
269 #define WLAN_LOG_ERROR2(x,n1,n2) printk(KERN_ERR "%s: " x , __FUNCTION__ , (n1), (n2));
270 #define WLAN_LOG_ERROR3(x,n1,n2,n3) printk(KERN_ERR "%s: " x , __FUNCTION__, (n1), (n2), (n3));
271 #define WLAN_LOG_ERROR4(x,n1,n2,n3,n4) printk(KERN_ERR "%s: " x , __FUNCTION__, (n1), (n2), (n3), (n4));
273 #define WLAN_LOG_WARNING0(x) printk(KERN_WARNING "%s: " x , __FUNCTION__);
274 #define WLAN_LOG_WARNING1(x,n) printk(KERN_WARNING "%s: " x , __FUNCTION__, (n));
275 #define WLAN_LOG_WARNING2(x,n1,n2) printk(KERN_WARNING "%s: " x , __FUNCTION__, (n1), (n2));
276 #define WLAN_LOG_WARNING3(x,n1,n2,n3) printk(KERN_WARNING "%s: " x , __FUNCTION__, (n1), (n2), (n3));
277 #define WLAN_LOG_WARNING4(x,n1,n2,n3,n4) printk(KERN_WARNING "%s: " x , __FUNCTION__ , (n1), (n2), (n3), (n4));
279 #define WLAN_LOG_NOTICE0(x) printk(KERN_NOTICE "%s: " x , __FUNCTION__);
280 #define WLAN_LOG_NOTICE1(x,n) printk(KERN_NOTICE "%s: " x , __FUNCTION__, (n));
281 #define WLAN_LOG_NOTICE2(x,n1,n2) printk(KERN_NOTICE "%s: " x , __FUNCTION__, (n1), (n2));
282 #define WLAN_LOG_NOTICE3(x,n1,n2,n3) printk(KERN_NOTICE "%s: " x , __FUNCTION__, (n1), (n2), (n3));
283 #define WLAN_LOG_NOTICE4(x,n1,n2,n3,n4) printk(KERN_NOTICE "%s: " x , __FUNCTION__, (n1), (n2), (n3), (n4));
285 #define WLAN_LOG_INFO0(x) printk(KERN_INFO x);
286 #define WLAN_LOG_INFO1(x,n) printk(KERN_INFO x, (n));
287 #define WLAN_LOG_INFO2(x,n1,n2) printk(KERN_INFO x, (n1), (n2));
288 #define WLAN_LOG_INFO3(x,n1,n2,n3) printk(KERN_INFO x, (n1), (n2), (n3));
289 #define WLAN_LOG_INFO4(x,n1,n2,n3,n4) printk(KERN_INFO x, (n1), (n2), (n3), (n4));
290 #define WLAN_LOG_INFO5(x,n1,n2,n3,n4,n5) printk(KERN_INFO x, (n1), (n2), (n3), (n4), (n5));
292 #if defined(WLAN_INCLUDE_DEBUG)
293 #define WLAN_ASSERT(c) if ((!(c)) && WLAN_DBVAR >= 1) { \
294 WLAN_LOG_DEBUG0(1, "Assertion failure!\n"); }
295 #define WLAN_HEX_DUMP( l, x, p, n) if( WLAN_DBVAR >= (l) ){ \
296 int __i__; \
297 printk(KERN_DEBUG x ":"); \
298 for( __i__=0; __i__ < (n); __i__++) \
299 printk( " %02x", ((UINT8*)(p))[__i__]); \
300 printk("\n"); }
302 #define DBFENTER { if ( WLAN_DBVAR >= 4 ){ WLAN_LOG_DEBUG0(3,"Enter\n"); } }
303 #define DBFEXIT { if ( WLAN_DBVAR >= 4 ){ WLAN_LOG_DEBUG0(3,"Exit\n"); } }
305 #define WLAN_LOG_DEBUG0(l,x) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s: " x , __FUNCTION__ );
306 #define WLAN_LOG_DEBUG1(l,x,n) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s: " x , __FUNCTION__ , (n));
307 #define WLAN_LOG_DEBUG2(l,x,n1,n2) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s: " x , __FUNCTION__ , (n1), (n2));
308 #define WLAN_LOG_DEBUG3(l,x,n1,n2,n3) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s: " x , __FUNCTION__ , (n1), (n2), (n3));
309 #define WLAN_LOG_DEBUG4(l,x,n1,n2,n3,n4) if ( WLAN_DBVAR >= (l)) printk(KERN_DEBUG "%s: " x , __FUNCTION__ , (n1), (n2), (n3), (n4));
310 #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));
311 #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));
312 #else
313 #define WLAN_ASSERT(c)
314 #define WLAN_HEX_DUMP( l, s, p, n)
316 #define DBFENTER
317 #define DBFEXIT
319 #define WLAN_LOG_DEBUG0(l, s)
320 #define WLAN_LOG_DEBUG1(l, s,n)
321 #define WLAN_LOG_DEBUG2(l, s,n1,n2)
322 #define WLAN_LOG_DEBUG3(l, s,n1,n2,n3)
323 #define WLAN_LOG_DEBUG4(l, s,n1,n2,n3,n4)
324 #define WLAN_LOG_DEBUG5(l, s,n1,n2,n3,n4,n5)
325 #endif
326 #else
327 #define WLAN_LOG_ERROR0(s)
328 #define WLAN_LOG_ERROR1(s,n)
329 #define WLAN_LOG_ERROR2(s,n1,n2)
330 #define WLAN_LOG_ERROR3(s,n1,n2,n3)
331 #define WLAN_LOG_ERROR4(s,n1,n2,n3,n4)
333 #define WLAN_LOG_WARNING0(s)
334 #define WLAN_LOG_WARNING1(s,n)
335 #define WLAN_LOG_WARNING2(s,n1,n2)
336 #define WLAN_LOG_WARNING3(s,n1,n2,n3)
337 #define WLAN_LOG_WARNING4(s,n1,n2,n3,n4)
339 #define WLAN_LOG_NOTICE0(s)
340 #define WLAN_LOG_NOTICE1(s,n)
341 #define WLAN_LOG_NOTICE2(s,n1,n2)
342 #define WLAN_LOG_NOTICE3(s,n1,n2,n3)
343 #define WLAN_LOG_NOTICE4(s,n1,n2,n3,n4)
345 #define WLAN_ASSERT(c)
346 #define WLAN_HEX_DUMP( l, s, p, n)
348 #define DBFENTER
349 #define DBFEXIT
351 #define WLAN_LOG_INFO0(s)
352 #define WLAN_LOG_INFO1(s,n)
353 #define WLAN_LOG_INFO2(s,n1,n2)
354 #define WLAN_LOG_INFO3(s,n1,n2,n3)
355 #define WLAN_LOG_INFO4(s,n1,n2,n3,n4)
356 #define WLAN_LOG_INFO5(s,n1,n2,n3,n4,n5)
358 #define WLAN_LOG_DEBUG0(l, s)
359 #define WLAN_LOG_DEBUG1(l, s,n)
360 #define WLAN_LOG_DEBUG2(l, s,n1,n2)
361 #define WLAN_LOG_DEBUG3(l, s,n1,n2,n3)
362 #define WLAN_LOG_DEBUG4(l, s,n1,n2,n3,n4)
363 #define WLAN_LOG_DEBUG5(l, s,n1,n2,n3,n4,n5)
364 #endif
366 #define wlan_ms_per_tick (1000UL / (wlan_ticks_per_sec))
367 #define wlan_ms_to_ticks(n) ( (n) / (wlan_ms_per_tick))
368 #define wlan_tu2ticks(n) ( (n) / (wlan_ms_per_tick))
369 #define WLAN_INT_DISABLE(n) { save_flags((n)); cli(); }
370 #define WLAN_INT_ENABLE(n) { sti(); restore_flags((n)); }
372 #ifdef CONFIG_MODVERSIONS
373 #define MODVERSIONS 1
374 #include <linux/modversions.h>
375 #endif
377 #ifdef CONFIG_SMP
378 #define __SMP__ 1
379 #endif
381 #ifndef KERNEL_VERSION
382 #define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))
383 #endif
385 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,17))
386 #define CONFIG_NETLINK 1
387 #endif
389 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0))
390 #define kfree_s(a, b) kfree((a))
391 #endif
393 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,2,18))
394 #ifndef init_waitqueue_head
395 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,0,16))
396 #define init_waitqueue_head(p) (*(p) = NULL)
397 #else
398 #define init_waitqueue_head(p) init_waitqueue(p)
399 #endif
400 typedef struct wait_queue *wait_queue_head_t;
401 typedef struct wait_queue wait_queue_t;
402 #define set_current_state(b) { current->state = (b); mb(); }
403 #define init_waitqueue_entry(a, b) { (a)->task = current; }
404 #endif
405 #endif
407 #ifndef wait_event_interruptible_timeout
408 // retval == 0; signal met; we're good.
409 // retval < 0; interrupted by signal.
410 // retval > 0; timed out.
411 #define __wait_event_interruptible_timeout(wq, condition, timeout, ret) \
412 do { \
413 int __ret = 0; \
414 if (!(condition)) { \
415 wait_queue_t __wait; \
416 unsigned long expire; \
417 init_waitqueue_entry(&__wait, current); \
419 expire = timeout + jiffies; \
420 add_wait_queue(&wq, &__wait); \
421 for (;;) { \
422 set_current_state(TASK_INTERRUPTIBLE); \
423 if (condition) \
424 break; \
425 if (jiffies > expire) { \
426 ret = jiffies - expire; \
427 break; \
429 if (!signal_pending(current)) { \
430 schedule_timeout(timeout); \
431 continue; \
433 ret = -ERESTARTSYS; \
434 break; \
436 set_current_state(TASK_RUNNING); \
437 remove_wait_queue(&wq, &__wait); \
439 } while (0)
441 #define wait_event_interruptible_timeout(wq, condition, timeout) \
442 ({ \
443 int __ret = 0; \
444 if (!(condition)) \
445 __wait_event_interruptible_timeout(wq, condition, \
446 timeout, __ret); \
447 __ret; \
450 #endif
452 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,90))
453 #define spin_lock(l) do { } while (0)
454 #define spin_unlock(l) do { } while (0)
455 #define spin_lock_irqsave(l,f) do { save_flags(f); cli(); } while (0)
456 #define spin_unlock_irqrestore(l,f) do { restore_flags(f); } while (0)
457 #define spin_lock_init(s) do { } while (0)
458 #define spin_trylock(l) (1)
459 typedef int spinlock_t;
460 #endif
462 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0))
463 #ifdef CONFIG_SMP
464 #define spin_is_locked(x) (*(volatile char *)(&(x)->lock) <= 0)
465 #else
466 #define spin_is_locked(l) (0)
467 #endif
468 #endif
470 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,3,38))
471 typedef struct device netdevice_t;
472 #elif (LINUX_VERSION_CODE < KERNEL_VERSION(2,4,4))
473 typedef struct net_device netdevice_t;
474 #else
475 #undef netdevice_t
476 typedef struct net_device netdevice_t;
477 #endif
479 #ifdef WIRELESS_EXT
480 #if (WIRELESS_EXT < 13)
481 struct iw_request_info
483 __u16 cmd; /* Wireless Extension command */
484 __u16 flags; /* More to come ;-) */
486 #endif
487 #endif
490 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,1,18))
491 #define MODULE_PARM(a,b) extern int __bogus_decl
492 #define MODULE_AUTHOR(a) extern int __bogus_decl
493 #define MODULE_DESCRIPTION(a) extern int __bogus_decl
494 #define MODULE_SUPPORTED_DEVICE(a) extern int __bogus_decl
495 #undef GET_USE_COUNT
496 #define GET_USE_COUNT(m) mod_use_count_
497 #endif
499 #ifndef MODULE_LICENSE
500 #define MODULE_LICENSE(m) extern int __bogus_decl
501 #endif
503 /* TODO: Do we care about this? */
504 #ifndef MODULE_DEVICE_TABLE
505 #define MODULE_DEVICE_TABLE(foo,bar)
506 #endif
508 #define wlan_minutes2ticks(a) ((a)*(wlan_ticks_per_sec * 60))
509 #define wlan_seconds2ticks(a) ((a)*(wlan_ticks_per_sec))
511 /*=============================================================*/
512 /*------ Hardware Portability Macros --------------------------*/
513 /*=============================================================*/
515 #define ieee2host16(n) __le16_to_cpu(n)
516 #define ieee2host32(n) __le32_to_cpu(n)
517 #define host2ieee16(n) __cpu_to_le16(n)
518 #define host2ieee32(n) __cpu_to_le32(n)
520 #if (WLAN_CPU_FAMILY == WLAN_PPC)
521 #define wlan_inw(a) in_be16((unsigned short *)((a)+_IO_BASE))
522 #define wlan_inw_le16_to_cpu(a) inw((a))
523 #define wlan_outw(v,a) out_be16((unsigned short *)((a)+_IO_BASE), (v))
524 #define wlan_outw_cpu_to_le16(v,a) outw((v),(a))
525 #else
526 #define wlan_inw(a) inw((a))
527 #define wlan_inw_le16_to_cpu(a) __cpu_to_le16(inw((a)))
528 #define wlan_outw(v,a) outw((v),(a))
529 #define wlan_outw_cpu_to_le16(v,a) outw(__cpu_to_le16((v)),(a))
530 #endif
532 /*=============================================================*/
533 /*--- General Macros ------------------------------------------*/
534 /*=============================================================*/
536 #define wlan_max(a, b) (((a) > (b)) ? (a) : (b))
537 #define wlan_min(a, b) (((a) < (b)) ? (a) : (b))
539 #define wlan_isprint(c) (((c) > (0x19)) && ((c) < (0x7f)))
541 #define wlan_hexchar(x) (((x) < 0x0a) ? ('0' + (x)) : ('a' + ((x) - 0x0a)))
543 /* Create a string of printable chars from something that might not be */
544 /* It's recommended that the str be 4*len + 1 bytes long */
545 #define wlan_mkprintstr(buf, buflen, str, strlen) \
547 int i = 0; \
548 int j = 0; \
549 memset(str, 0, (strlen)); \
550 for (i = 0; i < (buflen); i++) { \
551 if ( wlan_isprint((buf)[i]) ) { \
552 (str)[j] = (buf)[i]; \
553 j++; \
554 } else { \
555 (str)[j] = '\\'; \
556 (str)[j+1] = 'x'; \
557 (str)[j+2] = wlan_hexchar(((buf)[i] & 0xf0) >> 4); \
558 (str)[j+3] = wlan_hexchar(((buf)[i] & 0x0f)); \
559 j += 4; \
564 /*=============================================================*/
565 /*--- Variables -----------------------------------------------*/
566 /*=============================================================*/
568 extern int wlan_debug;
569 extern int wlan_ethconv; /* What's the default ethconv? */
571 /*=============================================================*/
572 /*--- Functions -----------------------------------------------*/
573 /*=============================================================*/
574 #endif /* _WLAN_COMPAT_H */