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