Wolfgang Denk | 4646d2a | 2006-05-30 15:56:48 +0200 | [diff] [blame] | 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 | |
| 48 | #ifndef IX_OSAL_BACKWARD_OSSL_H |
| 49 | #define IX_OSAL_BACKWARD_OSSL_H |
| 50 | |
| 51 | |
| 52 | typedef IxOsalThread ix_ossl_thread_t; |
| 53 | |
| 54 | typedef IxOsalSemaphore ix_ossl_sem_t; |
| 55 | |
| 56 | typedef IxOsalMutex ix_ossl_mutex_t; |
| 57 | |
| 58 | typedef IxOsalTimeval ix_ossl_time_t; |
| 59 | |
| 60 | |
| 61 | /* Map sub-fields for ix_ossl_time_t */ |
| 62 | #define tv_sec secs |
| 63 | #define tv_nec nsecs |
| 64 | |
| 65 | |
| 66 | typedef IX_STATUS ix_error; |
| 67 | |
| 68 | typedef UINT32 ix_ossl_thread_priority; |
| 69 | |
| 70 | typedef UINT32 ix_uint32; |
| 71 | |
| 72 | |
| 73 | #define IX_OSSL_ERROR_SUCCESS IX_SUCCESS |
| 74 | |
| 75 | #define IX_ERROR_SUCCESS IX_SUCCESS |
| 76 | |
| 77 | |
| 78 | typedef enum |
| 79 | { |
| 80 | IX_OSSL_SEM_UNAVAILABLE = 0, |
| 81 | IX_OSSL_SEM_AVAILABLE |
| 82 | } ix_ossl_sem_state; |
| 83 | |
| 84 | |
| 85 | typedef enum |
| 86 | { |
| 87 | IX_OSSL_MUTEX_UNLOCK = 0, |
| 88 | IX_OSSL_MUTEX_LOCK |
| 89 | } ix_ossl_mutex_state; |
| 90 | |
| 91 | |
| 92 | typedef IxOsalVoidFnVoidPtr ix_ossl_thread_entry_point_t; |
| 93 | |
| 94 | |
| 95 | #define IX_OSSL_THREAD_PRI_HIGH 90 |
| 96 | #define IX_OSSL_THREAD_PRI_MEDIUM 160 |
| 97 | #define IX_OSSL_THREAD_PRI_LOW 240 |
| 98 | |
| 99 | |
| 100 | #define IX_OSSL_WAIT_FOREVER IX_OSAL_WAIT_FOREVER |
| 101 | |
| 102 | #define IX_OSSL_WAIT_NONE IX_OSAL_WAIT_NONE |
| 103 | |
| 104 | #define BILLION IX_OSAL_BILLION |
| 105 | |
| 106 | #define IX_OSSL_TIME_EQ(a,b) IX_OSAL_TIME_EQ(a,b) |
| 107 | |
| 108 | #define IX_OSSL_TIME_GT(a,b) IX_OSAL_TIME_GT(a,b) |
| 109 | |
| 110 | #define IX_OSSL_TIME_LT(a,b) IX_OSAL_TIME_LT(a,b) |
| 111 | |
| 112 | #define IX_OSSL_TIME_ADD(a,b) IX_OSAL_TIME_ADD(a,b) |
| 113 | |
| 114 | #define IX_OSSL_TIME_SUB(a,b) IX_OSAL_TIME_SUB(a,b) |
| 115 | |
| 116 | |
| 117 | /* a is tick, b is timeval */ |
| 118 | #define IX_OSSL_TIME_CONVERT_TO_TICK(a,b) \ |
| 119 | (a) = IX_OSAL_TIMEVAL_TO_TICKS(b) |
| 120 | |
| 121 | |
| 122 | |
| 123 | |
| 124 | PUBLIC IX_STATUS |
| 125 | ixOsalOsIxp400BackwardOsslThreadCreate (IxOsalVoidFnVoidPtr entryPoint, |
| 126 | void *arg, IxOsalThread * ptrThread); |
| 127 | |
| 128 | #define ix_ossl_thread_create(entryPoint, arg, ptrTid) \ |
| 129 | ixOsalOsIxp400BackwardOsslThreadCreate(entryPoint, arg, ptrTid) |
| 130 | |
| 131 | |
| 132 | /* void ix_ossl_thread_exit(ix_error retError, void* retObj) */ |
| 133 | #define ix_ossl_thread_exit(retError, retObj) \ |
| 134 | ixOsalThreadExit() |
| 135 | |
| 136 | |
| 137 | PUBLIC IX_STATUS ixOsalOsIxp400BackwardOsslThreadKill (IxOsalThread tid); |
| 138 | |
| 139 | /* ix_error ix_ossl_thread_kill(tid) */ |
| 140 | #define ix_ossl_thread_kill(tid) \ |
| 141 | ixOsalOsIxp400BackwardOsslThreadKill(tid) |
| 142 | |
| 143 | |
| 144 | PUBLIC IX_STATUS |
| 145 | ixOsalOsIxp400BackwardOsslThreadSetPriority (IxOsalThread tid, |
| 146 | UINT32 priority); |
| 147 | |
| 148 | |
| 149 | /* |
| 150 | * ix_error ix_ossl_thread_set_priority(ix_ossl_thread_t tid, |
| 151 | * ix_ossl_thread_priority priority |
| 152 | * ); |
| 153 | */ |
| 154 | |
| 155 | #define ix_ossl_thread_set_priority(tid, priority) \ |
| 156 | ixOsalOsIxp400BackwardOsslThreadSetPriority(tid, priority) |
| 157 | |
| 158 | |
| 159 | PUBLIC IX_STATUS ixOsalOsIxp400BackwardOsslTickGet (int *pticks); |
| 160 | |
| 161 | #define ix_ossl_tick_get(pticks) \ |
| 162 | ixOsalOsIxp400BackwardOsslTickGet(pticks) |
| 163 | |
| 164 | PUBLIC IX_STATUS ixOsalOsIxp400BackwardOsslThreadDelay (int ticks); |
| 165 | |
| 166 | #define ix_ossl_thread_delay(ticks) ixOsalOsIxp400BackwardOsslThreadDelay(ticks) |
| 167 | |
| 168 | |
| 169 | |
| 170 | /* ix_error ix_ossl_sem_init(int start_value, ix_ossl_sem_t* sid); */ |
| 171 | /* Note sid is a pointer to semaphore */ |
| 172 | #define ix_ossl_sem_init(value, sid) \ |
| 173 | ixOsalSemaphoreInit(sid, value) |
| 174 | |
| 175 | |
| 176 | PUBLIC IX_STATUS |
| 177 | ixOsalOsIxp400BackwardOsslSemaphoreWait (IxOsalSemaphore semaphore, |
| 178 | INT32 timeout); |
| 179 | |
| 180 | |
| 181 | /* |
| 182 | ix_error ix_ossl_sem_take( |
| 183 | ix_ossl_sem_t sid, |
| 184 | ix_uint32 timeout |
| 185 | ); |
| 186 | */ |
| 187 | |
| 188 | #define ix_ossl_sem_take( sid, timeout) \ |
| 189 | ixOsalOsIxp400BackwardOsslSemaphoreWait(sid, timeout) |
| 190 | |
| 191 | |
| 192 | |
| 193 | PUBLIC IX_STATUS |
| 194 | ixOsalOsIxp400BackwardOsslSemaphorePost (IxOsalSemaphore sid); |
| 195 | |
| 196 | /*ix_error ix_ossl_sem_give(ix_ossl_sem_t sid); */ |
| 197 | #define ix_ossl_sem_give(sid) \ |
| 198 | ixOsalOsIxp400BackwardOsslSemaphorePost(sid); |
| 199 | |
| 200 | |
| 201 | PUBLIC IX_STATUS ixOsalOsIxp400BackwardSemaphoreDestroy (IxOsalSemaphore sid); |
| 202 | |
| 203 | #define ix_ossl_sem_fini(sid) \ |
| 204 | ixOsalOsIxp400BackwardSemaphoreDestroy(sid) |
| 205 | |
| 206 | |
| 207 | PUBLIC IX_STATUS |
| 208 | ixOsalOsIxp400BackwardOsslMutexInit (ix_ossl_mutex_state start_state, |
| 209 | IxOsalMutex * pMutex); |
| 210 | |
| 211 | |
| 212 | /* ix_error ix_ossl_mutex_init(ix_ossl_mutex_state start_state, ix_ossl_mutex_t* mid); */ |
| 213 | #define ix_ossl_mutex_init(start_state, pMutex) \ |
| 214 | ixOsalOsIxp400BackwardOsslMutexInit(start_state, pMutex) |
| 215 | |
| 216 | |
| 217 | PUBLIC IX_STATUS |
| 218 | ixOsalOsIxp400BackwardOsslMutexLock (IxOsalMutex mid, INT32 timeout); |
| 219 | |
| 220 | /* |
| 221 | ix_error ix_ossl_mutex_lock( |
| 222 | ix_ossl_mutex_t mid, |
| 223 | ix_uint32 timeout |
| 224 | ); |
| 225 | */ |
| 226 | #define ix_ossl_mutex_lock(mid, timeout) \ |
| 227 | ixOsalOsIxp400BackwardOsslMutexLock(mid, timout) |
| 228 | |
| 229 | |
| 230 | PUBLIC IX_STATUS ixOsalOsIxp400BackwardOsslMutexUnlock (IxOsalMutex mid); |
| 231 | |
| 232 | /* ix_error ix_ossl_mutex_unlock(ix_ossl_mutex_t mid); */ |
| 233 | #define ix_ossl_mutex_unlock(mid) \ |
| 234 | ixOsalOsIxp400BackwardOsslMutexUnlock(mid) |
| 235 | |
| 236 | PUBLIC IX_STATUS ixOsalOsIxp400BackwardOsslMutexDestroy (IxOsalMutex mid); |
| 237 | |
| 238 | #define ix_ossl_mutex_fini(mid) \ |
| 239 | ixOsalOsIxp400BackwardOsslMutexDestroy(mid); |
| 240 | |
| 241 | #define ix_ossl_sleep(sleeptime_ms) \ |
| 242 | ixOsalSleep(sleeptime_ms) |
| 243 | |
| 244 | PUBLIC IX_STATUS ixOsalOsIxp400BackwardOsslSleepTick (UINT32 ticks); |
| 245 | |
| 246 | #define ix_ossl_sleep_tick(sleeptime_ticks) \ |
| 247 | ixOsalOsIxp400BackwardOsslSleepTick(sleeptime_ticks) |
| 248 | |
| 249 | |
| 250 | PUBLIC IX_STATUS ixOsalOsIxp400BackwardOsslTimeGet (IxOsalTimeval * pTv); |
| 251 | |
| 252 | #define ix_ossl_time_get(pTv) \ |
| 253 | ixOsalOsIxp400BackwardOsslTimeGet(pTv) |
| 254 | |
| 255 | |
| 256 | typedef UINT32 ix_ossl_size_t; |
| 257 | |
| 258 | #define ix_ossl_malloc(arg_size) \ |
| 259 | ixOsalMemAlloc(arg_size) |
| 260 | |
| 261 | #define ix_ossl_free(arg_pMemory) \ |
| 262 | ixOsalMemFree(arg_pMemory) |
| 263 | |
| 264 | |
| 265 | #define ix_ossl_memcpy(arg_pDest, arg_pSrc,arg_Count) \ |
| 266 | ixOsalMemCopy(arg_pDest, arg_pSrc,arg_Count) |
| 267 | |
| 268 | #define ix_ossl_memset(arg_pDest, arg_pChar, arg_Count) \ |
| 269 | ixOsalMemSet(arg_pDest, arg_pChar, arg_Count) |
| 270 | |
| 271 | |
| 272 | #endif /* IX_OSAL_BACKWARD_OSSL_H */ |