1 /******************************************************************************
3 * Copyright(c) 2007 - 2011 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 ******************************************************************************/
\r
21 #ifndef __OSDEP_CE_SERVICE_H_
\r
22 #define __OSDEP_CE_SERVICE_H_
\r
26 #include <ntddndis.h>
\r
28 #ifdef CONFIG_SDIO_HCI
\r
29 #include "SDCardDDK.h"
\r
32 #ifdef CONFIG_USB_HCI
\r
36 typedef HANDLE _sema;
\r
37 typedef LIST_ENTRY _list;
\r
38 typedef NDIS_STATUS _OS_STATUS;
\r
40 typedef NDIS_SPIN_LOCK _lock;
\r
42 typedef HANDLE _rwlock; //Mutex
\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 HANDLE _thread_hdl_;
\r
61 typedef DWORD thread_return;
\r
62 typedef void* thread_context;
\r
63 typedef NDIS_WORK_ITEM _workitem;
\r
65 #define thread_exit() ExitThread(STATUS_SUCCESS); return 0;
\r
68 #define SEMA_UPBND (0x7FFFFFFF) //8192
\r
70 __inline static _list *get_prev(_list *list)
\r
75 __inline static _list *get_next(_list *list)
\r
80 __inline static _list *get_list_head(_queue *queue)
\r
82 return (&(queue->queue));
\r
85 #define LIST_CONTAINOR(ptr, type, member) CONTAINING_RECORD(ptr, type, member)
\r
87 __inline static void _enter_critical(_lock *plock, _irqL *pirqL)
\r
89 NdisAcquireSpinLock(plock);
\r
92 __inline static void _exit_critical(_lock *plock, _irqL *pirqL)
\r
94 NdisReleaseSpinLock(plock);
\r
97 __inline static _enter_critical_ex(_lock *plock, _irqL *pirqL)
\r
99 NdisDprAcquireSpinLock(plock);
\r
102 __inline static _exit_critical_ex(_lock *plock, _irqL *pirqL)
\r
104 NdisDprReleaseSpinLock(plock);
\r
108 __inline static void _enter_hwio_critical(_rwlock *prwlock, _irqL *pirqL)
\r
110 WaitForSingleObject(*prwlock, INFINITE );
\r
114 __inline static void _exit_hwio_critical(_rwlock *prwlock, _irqL *pirqL)
\r
116 ReleaseMutex(*prwlock);
\r
119 __inline static void rtw_list_delete(_list *plist)
\r
121 RemoveEntryList(plist);
\r
122 InitializeListHead(plist);
\r
125 #define RTW_TIMER_HDL_ARGS IN PVOID SystemSpecific1, IN PVOID FunctionContext, IN PVOID SystemSpecific2, IN PVOID SystemSpecific3
\r
127 __inline static void _init_timer(_timer *ptimer,_nic_hdl nic_hdl,void *pfunc,PVOID cntx)
\r
129 NdisMInitializeTimer(ptimer, nic_hdl, pfunc, cntx);
\r
132 __inline static void _set_timer(_timer *ptimer,u32 delay_time)
\r
134 NdisMSetTimer(ptimer,delay_time);
\r
137 __inline static void _cancel_timer(_timer *ptimer,u8 *bcancelled)
\r
139 NdisMCancelTimer(ptimer,bcancelled);
\r
142 __inline static void _init_workitem(_workitem *pwork, void *pfunc, PVOID cntx)
\r
145 NdisInitializeWorkItem(pwork, pfunc, cntx);
\r
148 __inline static void _set_workitem(_workitem *pwork)
\r
150 NdisScheduleWorkItem(pwork);
\r
153 #define ATOMIC_INIT(i) { (i) }
\r
156 // Global Mutex: can only be used at PASSIVE level.
\r
159 #define ACQUIRE_GLOBAL_MUTEX(_MutexCounter) \
\r
161 while (NdisInterlockedIncrement((PULONG)&(_MutexCounter)) != 1)\
\r
163 NdisInterlockedDecrement((PULONG)&(_MutexCounter)); \
\r
164 NdisMSleep(10000); \
\r
168 #define RELEASE_GLOBAL_MUTEX(_MutexCounter) \
\r
170 NdisInterlockedDecrement((PULONG)&(_MutexCounter)); \
\r
173 // limitation of path length
\r
174 #define PATH_LENGTH_MAX MAX_PATH
\r
176 //Atomic integer operations
\r
177 #define ATOMIC_T LONG
\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
188 #define STRUCT_PACKED
\r