Merge branch '2.6.36-fixes' of git://github.com/schandinat/linux-2.6
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / staging / otus / oal_marc.h
1 /*
2 * Copyright (c) 2007-2008 Atheros Communications Inc.
3 *
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16 /* Module Name : oal_marc.h */
17 /* */
18 /* Abstract */
19 /* This module contains warpper definitions. */
20 /* */
21 /* NOTES */
22 /* Platform dependent. */
23 /* */
24 /************************************************************************/
25
26 #ifndef _OAL_MARC_H
27 #define _OAL_MARC_H
28
29 #include "oal_dt.h"
30 #include "usbdrv.h"
31
32 #define ZM_OS_LINUX_FUNC
33
34 /***** Critical section *****/
35 /* Declare for critical section */
36 #ifndef ZM_HALPLUS_LOCK
37 #define zmw_get_wlan_dev(dev) struct zsWlanDev *wd = (struct zsWlanDev *) \
38 ((((struct usbdrv_private *)dev->priv)->wd))
39
40 #define zmw_declare_for_critical_section() unsigned long irqFlag;
41
42 /* Enter critical section */
43 #define zmw_enter_critical_section(dev) spin_lock_irqsave( \
44 &(((struct usbdrv_private *)(dev->priv))->cs_lock), irqFlag);
45
46 /* leave critical section */
47 #define zmw_leave_critical_section(dev) \
48 spin_unlock_irqrestore(&(((struct usbdrv_private *) \
49 (dev->priv))->cs_lock), irqFlag);
50 #else
51 #define zmw_get_wlan_dev(dev) struct zsWlanDev *wd = zfwGetWlanDev(dev);
52
53 /* Declare for critical section */
54 #define zmw_declare_for_critical_section()
55
56 /* Enter critical section */
57 #define zmw_enter_critical_section(dev) zfwEnterCriticalSection(dev);
58
59 /* leave critical section */
60 #define zmw_leave_critical_section(dev) zfwLeaveCriticalSection(dev);
61 #endif
62
63 /***** Byte order converting *****/
64 #ifdef ZM_CONFIG_BIG_ENDIAN
65 #define zmw_cpu_to_le32(v) (((v & 0xff000000) >> 24) | \
66 ((v & 0x00ff0000) >> 8) | \
67 ((v & 0x0000ff00) << 8) | \
68 ((v & 0x000000ff) << 24))
69
70 #define zmw_le32_to_cpu(v) (((v & 0xff000000) >> 24) | \
71 ((v & 0x00ff0000) >> 8) | \
72 ((v & 0x0000ff00) << 8) | \
73 ((v & 0x000000ff) << 24))
74
75 #define zmw_cpu_to_le16(v) (((v & 0xff00) >> 8) | \
76 ((v & 0x00ff) << 8))
77
78 #define zmw_le16_to_cpu(v) (((v & 0xff00) >> 8) | \
79 ((v & 0x00ff) << 8))
80 #else
81 #define zmw_cpu_to_le32(v) (v)
82 #define zmw_le32_to_cpu(v) (v)
83 #define zmw_cpu_to_le16(v) (v)
84 #define zmw_le16_to_cpu(v) (v)
85 #endif
86
87 /***** Buffer access *****/
88 /* Called to read/write buffer */
89 #ifndef ZM_HALPLUS_LOCK
90
91 #define zmw_buf_readb(dev, buf, offset) (*(u8_t *)((u8_t *)buf->data+offset))
92 #define zmw_buf_readh(dev, buf, offset) zmw_cpu_to_le16(*(u16_t *) \
93 ((u8_t *)buf->data+offset))
94 #define zmw_buf_writeb(dev, buf, offset, value) (*(u8_t *) \
95 ((u8_t *)buf->data+offset) = value)
96 #define zmw_buf_writeh(dev, buf, offset, value) (*(u16_t *) \
97 ((u8_t *)buf->data+offset) = zmw_cpu_to_le16(value))
98 #define zmw_buf_get_buffer(dev, buf) (u8_t *)(buf->data)
99
100 #else
101
102 #define zmw_buf_readb(dev, buf, offset) zfwBufReadByte(dev, buf, offset)
103 #define zmw_buf_readh(dev, buf, offset) zfwBufReadHalfWord(dev, buf, offset)
104 #define zmw_buf_writeb(dev, buf, offset, value) \
105 zfwBufWriteByte(dev, buf, offset, value)
106 #define zmw_buf_writeh(dev, buf, offset, value) \
107 zfwBufWriteHalfWord(dev, buf, offset, value)
108 #define zmw_buf_get_buffer(dev, buf) zfwGetBuffer(dev, buf)
109
110 #endif
111
112 /***** Debug message *****/
113 #if 0
114 #define zm_debug_msg0(msg) printk(KERN_DEBUG "%s:%s\n", __func__, msg);
115 #define zm_debug_msg1(msg, val) printk(KERN_DEBUG "%s:%s%ld\n", __func__, \
116 msg, (u32_t)val);
117 #define zm_debug_msg2(msg, val) printk(KERN_DEBUG "%s:%s%lxh\n", __func__, \
118 msg, (u32_t)val);
119 #define zm_debug_msg_s(msg, val) printk(KERN_DEBUG "%s:%s%s\n", __func__, \
120 msg, val);
121 #define zm_debug_msg_p(msg, val1, val2) do { \
122 printk(KERN_DEBUG "%s:%s%01ld.%02ld\n", \
123 __func__, \
124 msg, (val1/val2), (((val1*100)/val2)%100));
125 } while (0)
126 #define zm_dbg(S) printk S
127 #else
128 #define zm_debug_msg0(msg)
129 #define zm_debug_msg1(msg, val)
130 #define zm_debug_msg2(msg, val)
131 #define zm_debug_msg_s(msg, val)
132 #define zm_debug_msg_p(msg, val1, val2)
133 #define zm_dbg(S)
134 #endif
135
136 #define zm_assert(expr) if (!(expr)) { \
137 printk(KERN_ERR "Atheors Assertion failed! %s, %s, %s,line=%d\n",\
138 #expr, __FILE__, __func__, __LINE__); \
139 }
140
141 #define DbgPrint printk
142
143 #endif /* #ifndef _OAL_MARC_H */