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 func_enter() \
66 if (unifi_debug >= 5) { \
67 printk("unifi: => %s\n", __FUNCTION__); \
72 if (unifi_debug >= 5) { \
73 printk("unifi: <= %s\n", __FUNCTION__); \
76 #define func_exit_r(_rc) \
78 if (unifi_debug >= 5) { \
79 printk("unifi: <= %s %d\n", __FUNCTION__, (int)(_rc)); \
84 #define ASSERT(cond) \
87 printk("Assertion failed in %s at %s:%d: %s\n", \
88 __FUNCTION__, __FILE__, __LINE__, #cond); \
93 void unifi_dump(void *ospriv, int lvl, const char *msg, void *mem, u16 len);
94 void dump(void *mem, u16 len);
95 void dump16(void *mem, u16 len);
96 #ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
97 void dump_str(void *mem, u16 len);
98 #endif /* CSR_WIFI_HIP_DEBUG_OFFLINE */
100 void unifi_error(void* ospriv, const char *fmt, ...);
101 void unifi_warning(void* ospriv, const char *fmt, ...);
102 void unifi_notice(void* ospriv, const char *fmt, ...);
103 void unifi_info(void* ospriv, const char *fmt, ...);
105 void unifi_trace(void* ospriv, int level, const char *fmt, ...);
112 #define func_exit_r(_rc)
116 static inline void unifi_dump(void *ospriv, int lvl, const char *msg, void *mem, u16 len) {}
117 static inline void dump(void *mem, u16 len) {}
118 static inline void dump16(void *mem, u16 len) {}
119 #ifdef CSR_WIFI_HIP_DEBUG_OFFLINE
120 static inline void dump_str(void *mem, u16 len) {}
121 #endif /* CSR_WIFI_HIP_DEBUG_OFFLINE */
123 void unifi_error_nop(void* ospriv, const char *fmt, ...);
124 void unifi_trace_nop(void* ospriv, int level, const char *fmt, ...);
125 #define unifi_error if(1);else unifi_error_nop
126 #define unifi_warning if(1);else unifi_error_nop
127 #define unifi_notice if(1);else unifi_error_nop
128 #define unifi_info if(1);else unifi_error_nop
129 #define unifi_trace if(1);else unifi_trace_nop
131 #endif /* UNIFI_DEBUG */
134 /* Different levels of diagnostic detail... */
135 #define UDBG0 0 /* always prints in debug build */
145 #endif /* __UNIFI_OS_LINUX_H__ */