OSDN Git Service

Add rtl8723bu driver version 4.4.5
[android-x86/external-kernel-drivers.git] / rtl8723bu / include / osdep_service_xp.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2013 Realtek Corporation. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of version 2 of the GNU General Public License as
7  * published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12  * more details.
13  *
14  * You should have received a copy of the GNU General Public License along with
15  * this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17  *
18  *
19  ******************************************************************************/
20 #ifndef __OSDEP_LINUX_SERVICE_H_
21 #define __OSDEP_LINUX_SERVICE_H_
22
23         #include <ndis.h>
24         #include <ntddk.h>
25         #include <ntddndis.h>
26         #include <ntdef.h>
27
28 #ifdef CONFIG_USB_HCI
29         #include <usb.h>
30         #include <usbioctl.h>
31         #include <usbdlib.h>
32 #endif
33
34         typedef KSEMAPHORE      _sema;
35         typedef LIST_ENTRY      _list;
36         typedef NDIS_STATUS _OS_STATUS;
37
38
39         typedef NDIS_SPIN_LOCK  _lock;
40
41         typedef KMUTEX                  _mutex;
42
43         typedef KIRQL   _irqL;
44
45         // USB_PIPE for WINCE , but handle can be use just integer under windows
46         typedef NDIS_HANDLE  _nic_hdl;
47
48
49         typedef NDIS_MINIPORT_TIMER    _timer;
50
51         struct  __queue {
52                 LIST_ENTRY      queue;
53                 _lock   lock;
54         };
55
56         typedef NDIS_PACKET     _pkt;
57         typedef NDIS_BUFFER     _buffer;
58         typedef struct  __queue _queue;
59
60         typedef PKTHREAD _thread_hdl_;
61         typedef void    thread_return;
62         typedef void* thread_context;
63
64         typedef NDIS_WORK_ITEM _workitem;
65
66         #define thread_exit() PsTerminateSystemThread(STATUS_SUCCESS);
67
68         #define HZ                      10000000
69         #define SEMA_UPBND      (0x7FFFFFFF)   //8192
70
71 __inline static _list *get_next(_list   *list)
72 {
73         return list->Flink;
74 }
75
76 __inline static _list   *get_list_head(_queue   *queue)
77 {
78         return (&(queue->queue));
79 }
80
81
82 #define LIST_CONTAINOR(ptr, type, member) CONTAINING_RECORD(ptr, type, member)
83
84
85 __inline static _enter_critical(_lock *plock, _irqL *pirqL)
86 {
87         NdisAcquireSpinLock(plock);
88 }
89
90 __inline static _exit_critical(_lock *plock, _irqL *pirqL)
91 {
92         NdisReleaseSpinLock(plock);
93 }
94
95
96 __inline static _enter_critical_ex(_lock *plock, _irqL *pirqL)
97 {
98         NdisDprAcquireSpinLock(plock);
99 }
100
101 __inline static _exit_critical_ex(_lock *plock, _irqL *pirqL)
102 {
103         NdisDprReleaseSpinLock(plock);
104 }
105
106 __inline static void _enter_critical_bh(_lock *plock, _irqL *pirqL)
107 {
108         NdisDprAcquireSpinLock(plock);
109 }
110
111 __inline static void _exit_critical_bh(_lock *plock, _irqL *pirqL)
112 {
113         NdisDprReleaseSpinLock(plock);
114 }
115
116 __inline static _enter_critical_mutex(_mutex *pmutex, _irqL *pirqL)
117 {
118         KeWaitForSingleObject(pmutex, Executive, KernelMode, FALSE, NULL);
119 }
120
121
122 __inline static _exit_critical_mutex(_mutex *pmutex, _irqL *pirqL)
123 {
124         KeReleaseMutex(pmutex, FALSE);
125 }
126
127
128 __inline static void rtw_list_delete(_list *plist)
129 {
130         RemoveEntryList(plist);
131         InitializeListHead(plist);
132 }
133
134 #define RTW_TIMER_HDL_ARGS IN PVOID SystemSpecific1, IN PVOID FunctionContext, IN PVOID SystemSpecific2, IN PVOID SystemSpecific3
135
136 __inline static void _init_timer(_timer *ptimer,_nic_hdl nic_hdl,void *pfunc,PVOID cntx)
137 {
138         NdisMInitializeTimer(ptimer, nic_hdl, pfunc, cntx);
139 }
140
141 __inline static void _set_timer(_timer *ptimer,u32 delay_time)
142 {
143         NdisMSetTimer(ptimer,delay_time);
144 }
145
146 __inline static void _cancel_timer(_timer *ptimer,u8 *bcancelled)
147 {
148         NdisMCancelTimer(ptimer,bcancelled);
149 }
150
151 __inline static void _init_workitem(_workitem *pwork, void *pfunc, PVOID cntx)
152 {
153
154         NdisInitializeWorkItem(pwork, pfunc, cntx);
155 }
156
157 __inline static void _set_workitem(_workitem *pwork)
158 {
159         NdisScheduleWorkItem(pwork);
160 }
161
162
163 #define ATOMIC_INIT(i)  { (i) }
164
165 //
166 // Global Mutex: can only be used at PASSIVE level.
167 //
168
169 #define ACQUIRE_GLOBAL_MUTEX(_MutexCounter)                              \
170 {                                                               \
171     while (NdisInterlockedIncrement((PULONG)&(_MutexCounter)) != 1)\
172     {                                                           \
173         NdisInterlockedDecrement((PULONG)&(_MutexCounter));        \
174         NdisMSleep(10000);                          \
175     }                                                           \
176 }
177
178 #define RELEASE_GLOBAL_MUTEX(_MutexCounter)                              \
179 {                                                               \
180     NdisInterlockedDecrement((PULONG)&(_MutexCounter));              \
181 }
182
183 // limitation of path length
184 #define PATH_LENGTH_MAX MAX_PATH
185
186 //Atomic integer operations
187 #define ATOMIC_T LONG
188
189
190 #define NDEV_FMT "%s"
191 #define NDEV_ARG(ndev) ""
192 #define ADPT_FMT "%s"
193 #define ADPT_ARG(adapter) ""
194 #define FUNC_NDEV_FMT "%s"
195 #define FUNC_NDEV_ARG(ndev) __func__
196 #define FUNC_ADPT_FMT "%s"
197 #define FUNC_ADPT_ARG(adapter) __func__
198
199 #define STRUCT_PACKED
200
201 #endif