IxOsalBackwardOssl.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. /**
  2. * This file is intended to provide backward
  3. * compatibility for main osService/OSSL
  4. * APIs.
  5. *
  6. * It shall be phased out gradually and users
  7. * are strongly recommended to use IX_OSAL API.
  8. *
  9. * @par
  10. * IXP400 SW Release version 2.0
  11. *
  12. * -- Copyright Notice --
  13. *
  14. * @par
  15. * Copyright 2001-2005, Intel Corporation.
  16. * All rights reserved.
  17. *
  18. * @par
  19. * Redistribution and use in source and binary forms, with or without
  20. * modification, are permitted provided that the following conditions
  21. * are met:
  22. * 1. Redistributions of source code must retain the above copyright
  23. * notice, this list of conditions and the following disclaimer.
  24. * 2. Redistributions in binary form must reproduce the above copyright
  25. * notice, this list of conditions and the following disclaimer in the
  26. * documentation and/or other materials provided with the distribution.
  27. * 3. Neither the name of the Intel Corporation nor the names of its contributors
  28. * may be used to endorse or promote products derived from this software
  29. * without specific prior written permission.
  30. *
  31. * @par
  32. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS''
  33. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  34. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  35. * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
  36. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  37. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  38. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  39. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  40. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  41. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  42. * SUCH DAMAGE.
  43. *
  44. * @par
  45. * -- End of Copyright Notice --
  46. */
  47. #ifndef IX_OSAL_BACKWARD_OSSL_H
  48. #define IX_OSAL_BACKWARD_OSSL_H
  49. typedef IxOsalThread ix_ossl_thread_t;
  50. typedef IxOsalSemaphore ix_ossl_sem_t;
  51. typedef IxOsalMutex ix_ossl_mutex_t;
  52. typedef IxOsalTimeval ix_ossl_time_t;
  53. /* Map sub-fields for ix_ossl_time_t */
  54. #define tv_sec secs
  55. #define tv_nec nsecs
  56. typedef IX_STATUS ix_error;
  57. typedef UINT32 ix_ossl_thread_priority;
  58. typedef UINT32 ix_uint32;
  59. #define IX_OSSL_ERROR_SUCCESS IX_SUCCESS
  60. #define IX_ERROR_SUCCESS IX_SUCCESS
  61. typedef enum
  62. {
  63. IX_OSSL_SEM_UNAVAILABLE = 0,
  64. IX_OSSL_SEM_AVAILABLE
  65. } ix_ossl_sem_state;
  66. typedef enum
  67. {
  68. IX_OSSL_MUTEX_UNLOCK = 0,
  69. IX_OSSL_MUTEX_LOCK
  70. } ix_ossl_mutex_state;
  71. typedef IxOsalVoidFnVoidPtr ix_ossl_thread_entry_point_t;
  72. #define IX_OSSL_THREAD_PRI_HIGH 90
  73. #define IX_OSSL_THREAD_PRI_MEDIUM 160
  74. #define IX_OSSL_THREAD_PRI_LOW 240
  75. #define IX_OSSL_WAIT_FOREVER IX_OSAL_WAIT_FOREVER
  76. #define IX_OSSL_WAIT_NONE IX_OSAL_WAIT_NONE
  77. #define BILLION IX_OSAL_BILLION
  78. #define IX_OSSL_TIME_EQ(a,b) IX_OSAL_TIME_EQ(a,b)
  79. #define IX_OSSL_TIME_GT(a,b) IX_OSAL_TIME_GT(a,b)
  80. #define IX_OSSL_TIME_LT(a,b) IX_OSAL_TIME_LT(a,b)
  81. #define IX_OSSL_TIME_ADD(a,b) IX_OSAL_TIME_ADD(a,b)
  82. #define IX_OSSL_TIME_SUB(a,b) IX_OSAL_TIME_SUB(a,b)
  83. /* a is tick, b is timeval */
  84. #define IX_OSSL_TIME_CONVERT_TO_TICK(a,b) \
  85. (a) = IX_OSAL_TIMEVAL_TO_TICKS(b)
  86. PUBLIC IX_STATUS
  87. ixOsalOsIxp400BackwardOsslThreadCreate (IxOsalVoidFnVoidPtr entryPoint,
  88. void *arg, IxOsalThread * ptrThread);
  89. #define ix_ossl_thread_create(entryPoint, arg, ptrTid) \
  90. ixOsalOsIxp400BackwardOsslThreadCreate(entryPoint, arg, ptrTid)
  91. /* void ix_ossl_thread_exit(ix_error retError, void* retObj) */
  92. #define ix_ossl_thread_exit(retError, retObj) \
  93. ixOsalThreadExit()
  94. PUBLIC IX_STATUS ixOsalOsIxp400BackwardOsslThreadKill (IxOsalThread tid);
  95. /* ix_error ix_ossl_thread_kill(tid) */
  96. #define ix_ossl_thread_kill(tid) \
  97. ixOsalOsIxp400BackwardOsslThreadKill(tid)
  98. PUBLIC IX_STATUS
  99. ixOsalOsIxp400BackwardOsslThreadSetPriority (IxOsalThread tid,
  100. UINT32 priority);
  101. /*
  102. * ix_error ix_ossl_thread_set_priority(ix_ossl_thread_t tid,
  103. * ix_ossl_thread_priority priority
  104. * );
  105. */
  106. #define ix_ossl_thread_set_priority(tid, priority) \
  107. ixOsalOsIxp400BackwardOsslThreadSetPriority(tid, priority)
  108. PUBLIC IX_STATUS ixOsalOsIxp400BackwardOsslTickGet (int *pticks);
  109. #define ix_ossl_tick_get(pticks) \
  110. ixOsalOsIxp400BackwardOsslTickGet(pticks)
  111. PUBLIC IX_STATUS ixOsalOsIxp400BackwardOsslThreadDelay (int ticks);
  112. #define ix_ossl_thread_delay(ticks) ixOsalOsIxp400BackwardOsslThreadDelay(ticks)
  113. /* ix_error ix_ossl_sem_init(int start_value, ix_ossl_sem_t* sid); */
  114. /* Note sid is a pointer to semaphore */
  115. #define ix_ossl_sem_init(value, sid) \
  116. ixOsalSemaphoreInit(sid, value)
  117. PUBLIC IX_STATUS
  118. ixOsalOsIxp400BackwardOsslSemaphoreWait (IxOsalSemaphore semaphore,
  119. INT32 timeout);
  120. /*
  121. ix_error ix_ossl_sem_take(
  122. ix_ossl_sem_t sid,
  123. ix_uint32 timeout
  124. );
  125. */
  126. #define ix_ossl_sem_take( sid, timeout) \
  127. ixOsalOsIxp400BackwardOsslSemaphoreWait(sid, timeout)
  128. PUBLIC IX_STATUS
  129. ixOsalOsIxp400BackwardOsslSemaphorePost (IxOsalSemaphore sid);
  130. /*ix_error ix_ossl_sem_give(ix_ossl_sem_t sid); */
  131. #define ix_ossl_sem_give(sid) \
  132. ixOsalOsIxp400BackwardOsslSemaphorePost(sid);
  133. PUBLIC IX_STATUS ixOsalOsIxp400BackwardSemaphoreDestroy (IxOsalSemaphore sid);
  134. #define ix_ossl_sem_fini(sid) \
  135. ixOsalOsIxp400BackwardSemaphoreDestroy(sid)
  136. PUBLIC IX_STATUS
  137. ixOsalOsIxp400BackwardOsslMutexInit (ix_ossl_mutex_state start_state,
  138. IxOsalMutex * pMutex);
  139. /* ix_error ix_ossl_mutex_init(ix_ossl_mutex_state start_state, ix_ossl_mutex_t* mid); */
  140. #define ix_ossl_mutex_init(start_state, pMutex) \
  141. ixOsalOsIxp400BackwardOsslMutexInit(start_state, pMutex)
  142. PUBLIC IX_STATUS
  143. ixOsalOsIxp400BackwardOsslMutexLock (IxOsalMutex mid, INT32 timeout);
  144. /*
  145. ix_error ix_ossl_mutex_lock(
  146. ix_ossl_mutex_t mid,
  147. ix_uint32 timeout
  148. );
  149. */
  150. #define ix_ossl_mutex_lock(mid, timeout) \
  151. ixOsalOsIxp400BackwardOsslMutexLock(mid, timout)
  152. PUBLIC IX_STATUS ixOsalOsIxp400BackwardOsslMutexUnlock (IxOsalMutex mid);
  153. /* ix_error ix_ossl_mutex_unlock(ix_ossl_mutex_t mid); */
  154. #define ix_ossl_mutex_unlock(mid) \
  155. ixOsalOsIxp400BackwardOsslMutexUnlock(mid)
  156. PUBLIC IX_STATUS ixOsalOsIxp400BackwardOsslMutexDestroy (IxOsalMutex mid);
  157. #define ix_ossl_mutex_fini(mid) \
  158. ixOsalOsIxp400BackwardOsslMutexDestroy(mid);
  159. #define ix_ossl_sleep(sleeptime_ms) \
  160. ixOsalSleep(sleeptime_ms)
  161. PUBLIC IX_STATUS ixOsalOsIxp400BackwardOsslSleepTick (UINT32 ticks);
  162. #define ix_ossl_sleep_tick(sleeptime_ticks) \
  163. ixOsalOsIxp400BackwardOsslSleepTick(sleeptime_ticks)
  164. PUBLIC IX_STATUS ixOsalOsIxp400BackwardOsslTimeGet (IxOsalTimeval * pTv);
  165. #define ix_ossl_time_get(pTv) \
  166. ixOsalOsIxp400BackwardOsslTimeGet(pTv)
  167. typedef UINT32 ix_ossl_size_t;
  168. #define ix_ossl_malloc(arg_size) \
  169. ixOsalMemAlloc(arg_size)
  170. #define ix_ossl_free(arg_pMemory) \
  171. ixOsalMemFree(arg_pMemory)
  172. #define ix_ossl_memcpy(arg_pDest, arg_pSrc,arg_Count) \
  173. ixOsalMemCopy(arg_pDest, arg_pSrc,arg_Count)
  174. #define ix_ossl_memset(arg_pDest, arg_pChar, arg_Count) \
  175. ixOsalMemSet(arg_pDest, arg_pChar, arg_Count)
  176. #endif /* IX_OSAL_BACKWARD_OSSL_H */