osdep_service_ce.h 4.7 KB

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