Full support for Ginger Console
[linux-ginger.git] / drivers / staging / otus / oal_marc.h
blob206111616a0354921b14a37314897e618baa0aed
1 /*
2 * Copyright (c) 2007-2008 Atheros Communications Inc.
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.
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.
16 /* Module Name : oal_marc.h */
17 /* */
18 /* Abstract */
19 /* This module contains warpper definitions. */
20 /* */
21 /* NOTES */
22 /* Platform dependent. */
23 /* */
24 /************************************************************************/
26 #ifndef _OAL_MARC_H
27 #define _OAL_MARC_H
29 #include "oal_dt.h"
30 #include "usbdrv.h"
32 #define ZM_OS_LINUX_FUNC
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*) ((((struct usbdrv_private*)dev->priv)->wd))
39 #define zmw_declare_for_critical_section() unsigned long irqFlag;
41 /* Enter critical section */
42 #define zmw_enter_critical_section(dev) \
43 spin_lock_irqsave(&(((struct usbdrv_private *)(dev->priv))->cs_lock), irqFlag);
45 /* leave critical section */
46 #define zmw_leave_critical_section(dev) \
47 spin_unlock_irqrestore(&(((struct usbdrv_private *)(dev->priv))->cs_lock), irqFlag);
48 #else
49 #define zmw_get_wlan_dev(dev) struct zsWlanDev *wd = zfwGetWlanDev(dev);
51 /* Declare for critical section */
52 #define zmw_declare_for_critical_section()
54 /* Enter critical section */
55 #define zmw_enter_critical_section(dev) \
56 zfwEnterCriticalSection(dev);
58 /* leave critical section */
59 #define zmw_leave_critical_section(dev) \
60 zfwLeaveCriticalSection(dev);
61 #endif
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))
70 #define zmw_le32_to_cpu(v) (((v & 0xff000000) >> 24) | \
71 ((v & 0x00ff0000) >> 8) | \
72 ((v & 0x0000ff00) << 8) | \
73 ((v & 0x000000ff) << 24))
75 #define zmw_cpu_to_le16(v) (((v & 0xff00) >> 8) | \
76 ((v & 0x00ff) << 8))
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
87 /***** Buffer access *****/
88 /* Called to read/write buffer */
89 #ifndef ZM_HALPLUS_LOCK
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*)((u8_t*)buf->data+offset))
93 #define zmw_buf_writeb(dev, buf, offset, value) *(u8_t*)((u8_t*)buf->data+offset) = value
94 #define zmw_buf_writeh(dev, buf, offset, value) *(u16_t*)((u8_t*)buf->data+offset) = zmw_cpu_to_le16(value)
95 #define zmw_buf_get_buffer(dev, buf) (u8_t*)(buf->data)
97 #else
99 #define zmw_buf_readb(dev, buf, offset) zfwBufReadByte(dev, buf, offset)
100 #define zmw_buf_readh(dev, buf, offset) zfwBufReadHalfWord(dev, buf, offset)
101 #define zmw_buf_writeb(dev, buf, offset, value) zfwBufWriteByte(dev, buf, offset, value)
102 #define zmw_buf_writeh(dev, buf, offset, value) zfwBufWriteHalfWord(dev, buf, offset, value)
103 #define zmw_buf_get_buffer(dev, buf) zfwGetBuffer(dev, buf)
105 #endif
107 /***** Debug message *****/
108 #if 0
109 #define zm_debug_msg0(msg) printk("%s:%s\n", __func__, msg);
110 #define zm_debug_msg1(msg, val) printk("%s:%s%ld\n", __func__, \
111 msg, (u32_t)val);
112 #define zm_debug_msg2(msg, val) printk("%s:%s%lxh\n", __func__, \
113 msg, (u32_t)val);
114 #define zm_debug_msg_s(msg, val) printk("%s:%s%s\n", __func__, \
115 msg, val);
116 #define zm_debug_msg_p(msg, val1, val2) printk("%s:%s%01ld.%02ld\n", __func__, \
117 msg, (val1/val2), (((val1*100)/val2)%100));
118 #define zm_dbg(S) printk S
119 #else
120 #define zm_debug_msg0(msg)
121 #define zm_debug_msg1(msg, val)
122 #define zm_debug_msg2(msg, val)
123 #define zm_debug_msg_s(msg, val)
124 #define zm_debug_msg_p(msg, val1, val2)
125 #define zm_dbg(S)
126 #endif
128 #define zm_assert(expr) if(!(expr)) { \
129 printk( "Atheors Assertion failed! %s,%s,%s,line=%d\n", \
130 #expr,__FILE__,__func__,__LINE__); \
133 #define DbgPrint printk
135 #endif /* #ifndef _OAL_MARC_H */