1 /******************************************************************************
\r
3 * Copyright(c) 2007 - 2013 Realtek Corporation. All rights reserved.
\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
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
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
19 ******************************************************************************/
\r
20 #ifndef __OSDEP_LINUX_SERVICE_H_
\r
21 #define __OSDEP_LINUX_SERVICE_H_
\r
25 #include <ntddndis.h>
\r
28 #ifdef CONFIG_USB_HCI
\r
30 #include <usbioctl.h>
\r
31 #include <usbdlib.h>
\r
34 typedef KSEMAPHORE _sema;
\r
35 typedef LIST_ENTRY _list;
\r
36 typedef NDIS_STATUS _OS_STATUS;
\r
39 typedef NDIS_SPIN_LOCK _lock;
\r
41 typedef KMUTEX _mutex;
\r
43 typedef KIRQL _irqL;
\r
45 // USB_PIPE for WINCE , but handle can be use just integer under windows
\r
46 typedef NDIS_HANDLE _nic_hdl;
\r
49 typedef NDIS_MINIPORT_TIMER _timer;
\r
56 typedef NDIS_PACKET _pkt;
\r
57 typedef NDIS_BUFFER _buffer;
\r
58 typedef struct __queue _queue;
\r
60 typedef PKTHREAD _thread_hdl_;
\r
61 typedef void thread_return;
\r
62 typedef void* thread_context;
\r
64 typedef NDIS_WORK_ITEM _workitem;
\r
66 #define thread_exit() PsTerminateSystemThread(STATUS_SUCCESS);
\r
69 #define SEMA_UPBND (0x7FFFFFFF) //8192
\r
71 __inline static _list *get_next(_list *list)
\r
76 __inline static _list *get_list_head(_queue *queue)
\r
78 return (&(queue->queue));
\r
82 #define LIST_CONTAINOR(ptr, type, member) CONTAINING_RECORD(ptr, type, member)
\r
85 __inline static _enter_critical(_lock *plock, _irqL *pirqL)
\r
87 NdisAcquireSpinLock(plock);
\r
90 __inline static _exit_critical(_lock *plock, _irqL *pirqL)
\r
92 NdisReleaseSpinLock(plock);
\r
96 __inline static _enter_critical_ex(_lock *plock, _irqL *pirqL)
\r
98 NdisDprAcquireSpinLock(plock);
\r
101 __inline static _exit_critical_ex(_lock *plock, _irqL *pirqL)
\r
103 NdisDprReleaseSpinLock(plock);
\r
106 __inline static void _enter_critical_bh(_lock *plock, _irqL *pirqL)
\r
108 NdisDprAcquireSpinLock(plock);
\r
111 __inline static void _exit_critical_bh(_lock *plock, _irqL *pirqL)
\r
113 NdisDprReleaseSpinLock(plock);
\r
116 __inline static _enter_critical_mutex(_mutex *pmutex, _irqL *pirqL)
\r
118 KeWaitForSingleObject(pmutex, Executive, KernelMode, FALSE, NULL);
\r
122 __inline static _exit_critical_mutex(_mutex *pmutex, _irqL *pirqL)
\r
124 KeReleaseMutex(pmutex, FALSE);
\r
128 __inline static void rtw_list_delete(_list *plist)
\r
130 RemoveEntryList(plist);
\r
131 InitializeListHead(plist);
\r
134 #define RTW_TIMER_HDL_ARGS IN PVOID SystemSpecific1, IN PVOID FunctionContext, IN PVOID SystemSpecific2, IN PVOID SystemSpecific3
\r
136 __inline static void _init_timer(_timer *ptimer,_nic_hdl nic_hdl,void *pfunc,PVOID cntx)
\r
138 NdisMInitializeTimer(ptimer, nic_hdl, pfunc, cntx);
\r
141 __inline static void _set_timer(_timer *ptimer,u32 delay_time)
\r
143 NdisMSetTimer(ptimer,delay_time);
\r
146 __inline static void _cancel_timer(_timer *ptimer,u8 *bcancelled)
\r
148 NdisMCancelTimer(ptimer,bcancelled);
\r
151 __inline static void _init_workitem(_workitem *pwork, void *pfunc, PVOID cntx)
\r
154 NdisInitializeWorkItem(pwork, pfunc, cntx);
\r
157 __inline static void _set_workitem(_workitem *pwork)
\r
159 NdisScheduleWorkItem(pwork);
\r
163 #define ATOMIC_INIT(i) { (i) }
\r
166 // Global Mutex: can only be used at PASSIVE level.
\r
169 #define ACQUIRE_GLOBAL_MUTEX(_MutexCounter) \
\r
171 while (NdisInterlockedIncrement((PULONG)&(_MutexCounter)) != 1)\
\r
173 NdisInterlockedDecrement((PULONG)&(_MutexCounter)); \
\r
174 NdisMSleep(10000); \
\r
178 #define RELEASE_GLOBAL_MUTEX(_MutexCounter) \
\r
180 NdisInterlockedDecrement((PULONG)&(_MutexCounter)); \
\r
183 // limitation of path length
\r
184 #define PATH_LENGTH_MAX MAX_PATH
\r
186 //Atomic integer operations
\r
187 #define ATOMIC_T LONG
\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
199 #define STRUCT_PACKED
\r