osdep.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * Copyright (c) 2013-2018 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 EOK (0)
  71. #ifndef ARPHRD_IEEE80211
  72. #define ARPHRD_IEEE80211 801 /* IEEE 802.11. */
  73. #endif
  74. /*
  75. * Normal Delay functions. Time specified in microseconds.
  76. */
  77. #define OS_DELAY(_us) qdf_udelay(_us)
  78. /*
  79. * memory data manipulation functions.
  80. */
  81. #define OS_MEMCPY(_dst, _src, _len) qdf_mem_copy(_dst, _src, _len)
  82. #define OS_MEMMOVE(_dst, _src, _len) qdf_mem_move(_dst, _src, _len)
  83. #define OS_MEMZERO(_buf, _len) qdf_mem_zero(_buf, _len)
  84. #define OS_MEMSET(_buf, _ch, _len) qdf_mem_set(_buf, _len, _ch)
  85. #define OS_MEMCMP(_mem1, _mem2, _len) qdf_mem_cmp(_mem1, _mem2, _len)
  86. /*
  87. * System time interface
  88. */
  89. typedef qdf_time_t systime_t;
  90. /**
  91. * os_get_timestamp() - gives the timestamp in ticks
  92. * Return: unsigned long
  93. */
  94. static inline qdf_time_t os_get_timestamp(void)
  95. {
  96. /* Fix double conversion from jiffies to ms */
  97. return qdf_system_ticks();
  98. }
  99. struct _NIC_DEV;
  100. #define OS_FREE(_p) qdf_mem_free(_p)
  101. #define OS_DMA_MEM_CONTEXT(context) \
  102. dma_addr_t context
  103. #define OS_GET_DMA_MEM_CONTEXT(var, field) \
  104. &(var->field)
  105. /*
  106. * Timer Interfaces. Use these macros to declare timer
  107. * and retrieve timer argument. This is mainly for resolving
  108. * different argument types for timer function in different OS.
  109. */
  110. #define os_timer_func(_fn) \
  111. void _fn(void *timer_arg)
  112. #define OS_GET_TIMER_ARG(_arg, _type) \
  113. ((_arg) = (_type)(timer_arg))
  114. #define OS_SET_TIMER(_timer, _ms) qdf_timer_mod(_timer, _ms)
  115. /*
  116. * These are required for network manager support
  117. */
  118. #ifndef SET_NETDEV_DEV
  119. #define SET_NETDEV_DEV(ndev, pdev)
  120. #endif
  121. #endif /* end of _OSDEP_H */