osdep.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. /*
  2. * Copyright (c) 2013-2016 The Linux Foundation. All rights reserved.
  3. *
  4. * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  5. *
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for
  8. * any purpose with or without fee is hereby granted, provided that the
  9. * above copyright notice and this permission notice appear in all
  10. * copies.
  11. *
  12. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
  13. * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
  14. * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
  15. * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
  16. * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
  17. * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  18. * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  19. * PERFORMANCE OF THIS SOFTWARE.
  20. */
  21. /*
  22. * This file was originally distributed by Qualcomm Atheros, Inc.
  23. * under proprietary terms before Copyright ownership was assigned
  24. * to the Linux Foundation.
  25. */
  26. /**
  27. * DOC: osdep
  28. * This file provides OS abstraction for osdependent APIs.
  29. */
  30. #ifndef _OSDEP_H
  31. #define _OSDEP_H
  32. #include <qdf_types.h>
  33. #include <qdf_mem.h>
  34. #include <qdf_lock.h>
  35. #include <qdf_time.h>
  36. #include <qdf_timer.h>
  37. #include <qdf_defer.h>
  38. #include <qdf_nbuf.h>
  39. #include <i_osdep.h>
  40. /*
  41. * ATH_DEBUG -
  42. * Control whether debug features (printouts, assertions) are compiled
  43. * into the driver.
  44. */
  45. #ifndef ATH_DEBUG
  46. #define ATH_DEBUG 1 /* default: include debug code */
  47. #endif
  48. #if ATH_DEBUG
  49. #ifndef ASSERT
  50. #define ASSERT(expr) qdf_assert(expr)
  51. #endif
  52. #else
  53. #define ASSERT(expr)
  54. #endif /* ATH_DEBUG */
  55. /*
  56. * Need to define byte order based on the CPU configuration.
  57. */
  58. #ifndef _LITTLE_ENDIAN
  59. #define _LITTLE_ENDIAN 1234
  60. #endif
  61. #ifndef _BIG_ENDIAN
  62. #define _BIG_ENDIAN 4321
  63. #endif
  64. #ifdef __BIG_ENDIAN
  65. #define _BYTE_ORDER _BIG_ENDIAN
  66. #else
  67. #define _BYTE_ORDER _LITTLE_ENDIAN
  68. #endif
  69. /*
  70. * Deduce if tasklets are available. If not then
  71. * fall back to using the immediate work queue.
  72. */
  73. #define qdf_sysctl_decl(f, ctl, write, filp, buffer, lenp, ppos) \
  74. f(struct ctl_table *ctl, int32_t write, void *buffer, \
  75. size_t *lenp, loff_t *ppos)
  76. #define QDF_SYSCTL_PROC_DOINTVEC(ctl, write, filp, buffer, lenp, ppos) \
  77. __QDF_SYSCTL_PROC_DOINTVEC(ctl, write, filp, buffer, lenp, ppos)
  78. #define QDF_SYSCTL_PROC_DOSTRING(ctl, write, filp, buffer, lenp, ppos) \
  79. __QDF_SYSCTL_PROC_DOSTRING(ctl, write, filp, buffer, lenp, ppos)
  80. #define EOK (0)
  81. #ifndef false
  82. #define false 0
  83. #endif
  84. #ifndef true
  85. #define true 1
  86. #endif
  87. #ifndef ARPHRD_IEEE80211
  88. #define ARPHRD_IEEE80211 801 /* IEEE 802.11. */
  89. #endif
  90. /*
  91. * Normal Delay functions. Time specified in microseconds.
  92. */
  93. #define OS_DELAY(_us) qdf_udelay(_us)
  94. /*
  95. * memory data manipulation functions.
  96. */
  97. #define OS_MEMCPY(_dst, _src, _len) qdf_mem_copy(_dst, _src, _len)
  98. #define OS_MEMMOVE(_dst, _src, _len) qdf_mem_move(_dst, _src, _len)
  99. #define OS_MEMZERO(_buf, _len) qdf_mem_zero(_buf, _len)
  100. #define OS_MEMSET(_buf, _ch, _len) qdf_mem_set(_buf, _len, _ch)
  101. #define OS_MEMCMP(_mem1, _mem2, _len) qdf_mem_cmp(_mem1, _mem2, _len)
  102. /*
  103. * System time interface
  104. */
  105. typedef qdf_time_t systime_t;
  106. typedef qdf_time_t systick_t;
  107. /**
  108. * os_get_timestamp() - gives the timestamp in ticks
  109. * Return: unsigned long
  110. */
  111. static inline qdf_time_t os_get_timestamp(void)
  112. {
  113. /* Fix double conversion from jiffies to ms */
  114. return qdf_system_ticks();
  115. }
  116. struct _NIC_DEV;
  117. static inline unsigned char *os_malloc(osdev_t nic_dev,
  118. unsigned long size_in_bytes,
  119. int32_t gfp)
  120. {
  121. return qdf_mem_malloc(size_in_bytes);
  122. }
  123. #define OS_FREE(_p) qdf_mem_free(_p)
  124. #define OS_DMA_MEM_CONTEXT(context) \
  125. dma_addr_t context;
  126. #define OS_GET_DMA_MEM_CONTEXT(var, field) \
  127. &(var->field)
  128. #define OS_COPY_DMA_MEM_CONTEXT(dst, src) \
  129. *dst = *src
  130. #define OS_ZERO_DMA_MEM_CONTEXT(context) \
  131. *context = 0
  132. /*
  133. * Timer Interfaces. Use these macros to declare timer
  134. * and retrieve timer argument. This is mainly for resolving
  135. * different argument types for timer function in different OS.
  136. */
  137. #define os_timer_func(_fn) \
  138. void _fn(void *timer_arg)
  139. #define OS_GET_TIMER_ARG(_arg, _type) \
  140. ((_arg) = (_type)(timer_arg))
  141. #define OS_DECLARE_TIMER(_fn) void _fn(void *)
  142. #define OS_INIT_TIMER(_osdev, _timer, _fn, _ctx, type) \
  143. qdf_timer_init(_osdev, _timer, _fn, _ctx, type)
  144. #define OS_SET_TIMER(_timer, _ms) qdf_timer_mod(_timer, _ms)
  145. #define OS_CANCEL_TIMER(_timer) qdf_timer_stop(_timer)
  146. #define OS_FREE_TIMER(_timer) qdf_timer_stop(_timer)
  147. /*
  148. * These are required for network manager support
  149. */
  150. #ifndef SET_NETDEV_DEV
  151. #define SET_NETDEV_DEV(ndev, pdev)
  152. #endif
  153. #endif /* end of _OSDEP_H */