osdep.h 4.5 KB

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