osdep_service_xp.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. /******************************************************************************
  2. *
  3. * Copyright(c) 2007 - 2013 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. ******************************************************************************/
  20. #ifndef __OSDEP_LINUX_SERVICE_H_
  21. #define __OSDEP_LINUX_SERVICE_H_
  22. #include <ndis.h>
  23. #include <ntddk.h>
  24. #include <ntddndis.h>
  25. #include <ntdef.h>
  26. #ifdef CONFIG_USB_HCI
  27. #include <usb.h>
  28. #include <usbioctl.h>
  29. #include <usbdlib.h>
  30. #endif
  31. typedef KSEMAPHORE _sema;
  32. typedef LIST_ENTRY _list;
  33. typedef NDIS_STATUS _OS_STATUS;
  34. typedef NDIS_SPIN_LOCK _lock;
  35. typedef KMUTEX _mutex;
  36. typedef KIRQL _irqL;
  37. // USB_PIPE for WINCE , but handle can be use just integer under windows
  38. typedef NDIS_HANDLE _nic_hdl;
  39. typedef NDIS_MINIPORT_TIMER _timer;
  40. struct __queue {
  41. LIST_ENTRY queue;
  42. _lock lock;
  43. };
  44. typedef NDIS_PACKET _pkt;
  45. typedef NDIS_BUFFER _buffer;
  46. typedef struct __queue _queue;
  47. typedef PKTHREAD _thread_hdl_;
  48. typedef void thread_return;
  49. typedef void* thread_context;
  50. typedef NDIS_WORK_ITEM _workitem;
  51. #define thread_exit() PsTerminateSystemThread(STATUS_SUCCESS);
  52. #define HZ 10000000
  53. #define SEMA_UPBND (0x7FFFFFFF) //8192
  54. __inline static _list *get_next(_list *list)
  55. {
  56. return list->Flink;
  57. }
  58. __inline static _list *get_list_head(_queue *queue)
  59. {
  60. return (&(queue->queue));
  61. }
  62. #define LIST_CONTAINOR(ptr, type, member) CONTAINING_RECORD(ptr, type, member)
  63. __inline static _enter_critical(_lock *plock, _irqL *pirqL)
  64. {
  65. NdisAcquireSpinLock(plock);
  66. }
  67. __inline static _exit_critical(_lock *plock, _irqL *pirqL)
  68. {
  69. NdisReleaseSpinLock(plock);
  70. }
  71. __inline static _enter_critical_ex(_lock *plock, _irqL *pirqL)
  72. {
  73. NdisDprAcquireSpinLock(plock);
  74. }
  75. __inline static _exit_critical_ex(_lock *plock, _irqL *pirqL)
  76. {
  77. NdisDprReleaseSpinLock(plock);
  78. }
  79. __inline static void _enter_critical_bh(_lock *plock, _irqL *pirqL)
  80. {
  81. NdisDprAcquireSpinLock(plock);
  82. }
  83. __inline static void _exit_critical_bh(_lock *plock, _irqL *pirqL)
  84. {
  85. NdisDprReleaseSpinLock(plock);
  86. }
  87. __inline static _enter_critical_mutex(_mutex *pmutex, _irqL *pirqL)
  88. {
  89. KeWaitForSingleObject(pmutex, Executive, KernelMode, FALSE, NULL);
  90. }
  91. __inline static _exit_critical_mutex(_mutex *pmutex, _irqL *pirqL)
  92. {
  93. KeReleaseMutex(pmutex, FALSE);
  94. }
  95. __inline static void rtw_list_delete(_list *plist)
  96. {
  97. RemoveEntryList(plist);
  98. InitializeListHead(plist);
  99. }
  100. #define RTW_TIMER_HDL_ARGS IN PVOID SystemSpecific1, IN PVOID FunctionContext, IN PVOID SystemSpecific2, IN PVOID SystemSpecific3
  101. __inline static void _init_timer(_timer *ptimer,_nic_hdl nic_hdl,void *pfunc,PVOID cntx)
  102. {
  103. NdisMInitializeTimer(ptimer, nic_hdl, pfunc, cntx);
  104. }
  105. __inline static void _set_timer(_timer *ptimer,u32 delay_time)
  106. {
  107. NdisMSetTimer(ptimer,delay_time);
  108. }
  109. __inline static void _cancel_timer(_timer *ptimer,u8 *bcancelled)
  110. {
  111. NdisMCancelTimer(ptimer,bcancelled);
  112. }
  113. __inline static void _init_workitem(_workitem *pwork, void *pfunc, PVOID cntx)
  114. {
  115. NdisInitializeWorkItem(pwork, pfunc, cntx);
  116. }
  117. __inline static void _set_workitem(_workitem *pwork)
  118. {
  119. NdisScheduleWorkItem(pwork);
  120. }
  121. #define ATOMIC_INIT(i) { (i) }
  122. //
  123. // Global Mutex: can only be used at PASSIVE level.
  124. //
  125. #define ACQUIRE_GLOBAL_MUTEX(_MutexCounter) \
  126. { \
  127. while (NdisInterlockedIncrement((PULONG)&(_MutexCounter)) != 1)\
  128. { \
  129. NdisInterlockedDecrement((PULONG)&(_MutexCounter)); \
  130. NdisMSleep(10000); \
  131. } \
  132. }
  133. #define RELEASE_GLOBAL_MUTEX(_MutexCounter) \
  134. { \
  135. NdisInterlockedDecrement((PULONG)&(_MutexCounter)); \
  136. }
  137. // limitation of path length
  138. #define PATH_LENGTH_MAX MAX_PATH
  139. //Atomic integer operations
  140. #define ATOMIC_T LONG
  141. #define NDEV_FMT "%s"
  142. #define NDEV_ARG(ndev) ""
  143. #define ADPT_FMT "%s"
  144. #define ADPT_ARG(adapter) ""
  145. #define FUNC_NDEV_FMT "%s"
  146. #define FUNC_NDEV_ARG(ndev) __func__
  147. #define FUNC_ADPT_FMT "%s"
  148. #define FUNC_ADPT_ARG(adapter) __func__
  149. #define STRUCT_PACKED
  150. #endif