2 * ---------------------------------------------------------------------------
4 * FILE: os_linux/unifi_os.h
7 * This header file provides the OS-dependent facilities for a linux
10 * Copyright (C) 2005-2008 by Cambridge Silicon Radio Ltd.
12 * Refer to LICENSE.txt included with this source code for details on
15 * ---------------------------------------------------------------------------
17 #ifndef __UNIFI_OS_LINUX_H__
18 #define __UNIFI_OS_LINUX_H__ 1
20 #include <linux/kernel.h>
21 #include <linux/time.h>
22 #include <linux/list.h>
23 #include <linux/delay.h>
24 #include <linux/string.h>
27 * Needed for core/signals.c
32 /* Define INLINE directive*/
36 CsrResult unifi_net_data_malloc(void *ospriv, bulk_data_desc_t *bulk_data_slot, unsigned int size);
37 void unifi_net_data_free(void *ospriv, bulk_data_desc_t *bulk_data_slot);
38 #define CSR_WIFI_ALIGN_BYTES 4
39 CsrResult unifi_net_dma_align(void *ospriv, bulk_data_desc_t *bulk_data_slot);
43 * Note that __le*_to_cpu and __cpu_to_le* return an unsigned value!
46 #define unifi2host_16(n) (__le16_to_cpu((n)))
47 #define unifi2host_32(n) (__le32_to_cpu((n)))
48 #define host2unifi_16(n) (__cpu_to_le16((n)))
49 #define host2unifi_32(n) (__cpu_to_le32((n)))
52 /* Module parameters */
53 extern int unifi_debug;
58 * unifi_debug is a verbosity level for debug messages
59 * UDBG0 msgs are always printed if UNIFI_DEBUG is defined
60 * UDBG1 msgs are printed if UNIFI_DEBUG is defined and unifi_debug > 0
64 #define ASSERT(cond) \
67 printk("Assertion failed in %s at %s:%d: %s\n", \
68 __FUNCTION__, __FILE__, __LINE__, #cond); \
73 void unifi_dump(void *ospriv, int lvl, const char *msg, void *mem, u16 len);
74 void dump(void *mem, u16 len);
75 void dump16(void *mem, u16 len);
76 #ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
77 void dump_str(void *mem, u16 len);
78 #endif /* CSR_WIFI_HIP_DEBUG_OFFLINE */
80 void unifi_error(void* ospriv, const char *fmt, ...);
81 void unifi_warning(void* ospriv, const char *fmt, ...);
82 void unifi_notice(void* ospriv, const char *fmt, ...);
83 void unifi_info(void* ospriv, const char *fmt, ...);
85 void unifi_trace(void* ospriv, int level, const char *fmt, ...);
93 static inline void unifi_dump(void *ospriv, int lvl, const char *msg, void *mem, u16 len) {}
94 static inline void dump(void *mem, u16 len) {}
95 static inline void dump16(void *mem, u16 len) {}
96 #ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
97 static inline void dump_str(void *mem, u16 len) {}
98 #endif /* CSR_WIFI_HIP_DEBUG_OFFLINE */
100 void unifi_error_nop(void* ospriv, const char *fmt, ...);
101 void unifi_trace_nop(void* ospriv, int level, const char *fmt, ...);
102 #define unifi_error if(1);else unifi_error_nop
103 #define unifi_warning if(1);else unifi_error_nop
104 #define unifi_notice if(1);else unifi_error_nop
105 #define unifi_info if(1);else unifi_error_nop
106 #define unifi_trace if(1);else unifi_trace_nop
108 #endif /* UNIFI_DEBUG */
111 /* Different levels of diagnostic detail... */
112 #define UDBG0 0 /* always prints in debug build */
122 #endif /* __UNIFI_OS_LINUX_H__ */