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