video: rockchip: tve: support rk3228
[firefly-linux-kernel-4.4.55.git] / drivers / net / wireless / rockchip_wlan / rtl8723bu / include / osdep_service_ce.h
1 /******************************************************************************
2  *
3  * Copyright(c) 2007 - 2011 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  ******************************************************************************/\r
20 \r
21 #ifndef __OSDEP_CE_SERVICE_H_\r
22 #define __OSDEP_CE_SERVICE_H_\r
23 \r
24 \r
25 #include <ndis.h>\r
26 #include <ntddndis.h>\r
27 \r
28 #ifdef CONFIG_SDIO_HCI\r
29 #include "SDCardDDK.h"\r
30 #endif\r
31 \r
32 #ifdef CONFIG_USB_HCI\r
33 #include <usbdi.h>\r
34 #endif\r
35 \r
36 typedef HANDLE  _sema;\r
37 typedef LIST_ENTRY      _list;\r
38 typedef NDIS_STATUS _OS_STATUS;\r
39 \r
40 typedef NDIS_SPIN_LOCK  _lock;\r
41 \r
42 typedef HANDLE          _rwlock; //Mutex\r
43 \r
44 typedef u32     _irqL;\r
45 \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 HANDLE  _thread_hdl_;\r
61 typedef DWORD thread_return;\r
62 typedef void*   thread_context;\r
63 typedef NDIS_WORK_ITEM _workitem;\r
64 \r
65 #define thread_exit() ExitThread(STATUS_SUCCESS); return 0;\r
66 \r
67 \r
68 #define SEMA_UPBND      (0x7FFFFFFF)   //8192\r
69 \r
70 __inline static _list *get_prev(_list   *list)\r
71 {\r
72         return list->Blink;\r
73 }\r
74         \r
75 __inline static _list *get_next(_list   *list)\r
76 {\r
77         return list->Flink;\r
78 }\r
79 \r
80 __inline static _list   *get_list_head(_queue   *queue)\r
81 {\r
82         return (&(queue->queue));\r
83 }\r
84 \r
85 #define LIST_CONTAINOR(ptr, type, member) CONTAINING_RECORD(ptr, type, member)\r
86 \r
87 __inline static void _enter_critical(_lock *plock, _irqL *pirqL)\r
88 {\r
89         NdisAcquireSpinLock(plock);\r
90 }\r
91 \r
92 __inline static void _exit_critical(_lock *plock, _irqL *pirqL)\r
93 {\r
94         NdisReleaseSpinLock(plock);\r
95 }\r
96 \r
97 __inline static _enter_critical_ex(_lock *plock, _irqL *pirqL)\r
98 {\r
99         NdisDprAcquireSpinLock(plock);  \r
100 }\r
101 \r
102 __inline static _exit_critical_ex(_lock *plock, _irqL *pirqL)\r
103 {\r
104         NdisDprReleaseSpinLock(plock);  \r
105 }\r
106 \r
107 \r
108 __inline static void _enter_hwio_critical(_rwlock *prwlock, _irqL *pirqL)\r
109 {\r
110         WaitForSingleObject(*prwlock, INFINITE );\r
111 \r
112 }\r
113 \r
114 __inline static void _exit_hwio_critical(_rwlock *prwlock, _irqL *pirqL)\r
115 {\r
116         ReleaseMutex(*prwlock);\r
117 }\r
118 \r
119 __inline static void rtw_list_delete(_list *plist)\r
120 {\r
121         RemoveEntryList(plist);\r
122         InitializeListHead(plist);\r
123 }\r
124 \r
125 #define RTW_TIMER_HDL_ARGS IN PVOID SystemSpecific1, IN PVOID FunctionContext, IN PVOID SystemSpecific2, IN PVOID SystemSpecific3\r
126 \r
127 __inline static void _init_timer(_timer *ptimer,_nic_hdl nic_hdl,void *pfunc,PVOID cntx)\r
128 {\r
129         NdisMInitializeTimer(ptimer, nic_hdl, pfunc, cntx);\r
130 }\r
131 \r
132 __inline static void _set_timer(_timer *ptimer,u32 delay_time)\r
133 {\r
134         NdisMSetTimer(ptimer,delay_time);\r
135 }\r
136 \r
137 __inline static void _cancel_timer(_timer *ptimer,u8 *bcancelled)\r
138 {\r
139         NdisMCancelTimer(ptimer,bcancelled);\r
140 }\r
141 \r
142 __inline static void _init_workitem(_workitem *pwork, void *pfunc, PVOID cntx)\r
143 {\r
144 \r
145         NdisInitializeWorkItem(pwork, pfunc, cntx);\r
146 }\r
147 \r
148 __inline static void _set_workitem(_workitem *pwork)\r
149 {\r
150         NdisScheduleWorkItem(pwork);\r
151 }\r
152 \r
153 #define ATOMIC_INIT(i)  { (i) }\r
154 \r
155 //\r
156 // Global Mutex: can only be used at PASSIVE level.\r
157 //\r
158 \r
159 #define ACQUIRE_GLOBAL_MUTEX(_MutexCounter)                              \\r
160 {                                                               \\r
161     while (NdisInterlockedIncrement((PULONG)&(_MutexCounter)) != 1)\\r
162     {                                                           \\r
163         NdisInterlockedDecrement((PULONG)&(_MutexCounter));        \\r
164         NdisMSleep(10000);                          \\r
165     }                                                           \\r
166 }\r
167 \r
168 #define RELEASE_GLOBAL_MUTEX(_MutexCounter)                              \\r
169 {                                                               \\r
170     NdisInterlockedDecrement((PULONG)&(_MutexCounter));              \\r
171 }\r
172 \r
173 // limitation of path length\r
174 #define PATH_LENGTH_MAX MAX_PATH\r
175 \r
176 //Atomic integer operations\r
177 #define ATOMIC_T LONG\r
178 \r
179 #define NDEV_FMT "%s"\r
180 #define NDEV_ARG(ndev) ""\r
181 #define ADPT_FMT "%s"\r
182 #define ADPT_ARG(adapter) ""\r
183 #define FUNC_NDEV_FMT "%s"\r
184 #define FUNC_NDEV_ARG(ndev) __func__\r
185 #define FUNC_ADPT_FMT "%s"\r
186 #define FUNC_ADPT_ARG(adapter) __func__\r
187 \r
188 #define STRUCT_PACKED\r
189 \r
190 \r
191 #endif\r
192 \r