| 1 | #ifndef __DST_OSLAYER_H__ |
|---|
| 2 | #define __DST_OSLAYER_H__ |
|---|
| 3 | |
|---|
| 4 | #include "dsthallocal.h" |
|---|
| 5 | #include <pthread.h> |
|---|
| 6 | |
|---|
| 7 | typedef void (*OS_TASKFUNCTION)(DS_U32 arg1); |
|---|
| 8 | #define OS_TASK_ID DS_U32 |
|---|
| 9 | #define OS_MESSAGEQUEUE_ID DS_U32 |
|---|
| 10 | #define OS_SEMAPHORE_ID DS_U32 |
|---|
| 11 | #define OS_MUTEX_ID DS_U32 |
|---|
| 12 | |
|---|
| 13 | #ifndef OS_WAIT_FOREVER |
|---|
| 14 | #define OS_WAIT_FOREVER 0xFFFFFFFF |
|---|
| 15 | #endif |
|---|
| 16 | |
|---|
| 17 | // |
|---|
| 18 | // ¿©±â¼ Á¤ÀÇµÈ DefinitionÀº °°Àº À̸§ÀÇ API°¡ ¼±¾ðµÇÁö ¾ÊÀ½. |
|---|
| 19 | // |
|---|
| 20 | |
|---|
| 21 | //#define OS_DeleteTask gmCL_ThreadKill |
|---|
| 22 | //#define OS_SelfDeleteTask() gmCL_ThreadExit(0) |
|---|
| 23 | |
|---|
| 24 | |
|---|
| 25 | #define OS_GetTicksPerSecond() (100) |
|---|
| 26 | //#define OS_Delay(tick) usleep((tick) * (1000000/OS_GetTicksPerSecond())) |
|---|
| 27 | //#define OS_mDelay(mil) usleep((mil) * 1000) |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | //#define OS_DeleteSemaphore gmCL_SemaphoreDelete |
|---|
| 31 | //#define OS_TakeSemaphore gmCL_SemaphoreWait |
|---|
| 32 | //#define OS_GiveSemaphore gmCL_SemaphorePost |
|---|
| 33 | |
|---|
| 34 | |
|---|
| 35 | //#define OS_TakeMutex gmCL_MutexLock |
|---|
| 36 | //#define OS_TakeMutex_NoWait gmCL_MutexTryLock |
|---|
| 37 | //#define OS_GiveMutex gmCL_MutexUnlock |
|---|
| 38 | |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | #ifdef __cplusplus |
|---|
| 42 | extern "C"{ |
|---|
| 43 | #endif |
|---|
| 44 | |
|---|
| 45 | // ================ Thread API ======================= |
|---|
| 46 | #ifndef OS_SpawnTask |
|---|
| 47 | DS_U32 OS_SpawnTask (void (*func)(DS_U32), char *name, DS_U16 prio, DS_U16 stacksize, DS_U32 arg); |
|---|
| 48 | #endif |
|---|
| 49 | |
|---|
| 50 | #if !defined(OS_DeleteTask) |
|---|
| 51 | DS_U32 OS_DeleteTask(DS_U32 TaskId); |
|---|
| 52 | #endif |
|---|
| 53 | |
|---|
| 54 | #if !defined(OS_SelfDeleteTask) |
|---|
| 55 | void OS_SelfDeleteTask(void); |
|---|
| 56 | #endif |
|---|
| 57 | |
|---|
| 58 | #ifndef OS_SuspendTask |
|---|
| 59 | DS_U32 OS_SuspendTask(DS_U32 TaskId); |
|---|
| 60 | #endif |
|---|
| 61 | |
|---|
| 62 | #ifndef OS_ResumeTask |
|---|
| 63 | DS_U32 OS_ResumeTask(DS_U32 TaskId); |
|---|
| 64 | #endif |
|---|
| 65 | |
|---|
| 66 | #ifndef OS_GetSelfTaskId |
|---|
| 67 | OS_TASK_ID OS_GetSelfTaskId(void); |
|---|
| 68 | #endif |
|---|
| 69 | |
|---|
| 70 | // ================ Time API ======================== |
|---|
| 71 | #ifndef OS_GetTicksPerSecond |
|---|
| 72 | DS_U32 OS_GetTicksPerSecond (void); |
|---|
| 73 | #endif |
|---|
| 74 | |
|---|
| 75 | #ifndef OS_Delay |
|---|
| 76 | void OS_Delay(DS_U32 Ticks); |
|---|
| 77 | #endif |
|---|
| 78 | |
|---|
| 79 | #ifndef OS_mDelay |
|---|
| 80 | void OS_mDelay(DS_U32 milliseconds); |
|---|
| 81 | #endif |
|---|
| 82 | |
|---|
| 83 | #ifndef OS_uDelay |
|---|
| 84 | void OS_uDelay(DS_U32 useconds); |
|---|
| 85 | #endif |
|---|
| 86 | |
|---|
| 87 | |
|---|
| 88 | #ifndef OS_GetTickCount |
|---|
| 89 | DS_U32 OS_GetTickCount(void); |
|---|
| 90 | #endif |
|---|
| 91 | |
|---|
| 92 | // ================ Semaphore ======================== |
|---|
| 93 | #ifndef OS_CreateCountingSemaphore |
|---|
| 94 | DS_U32 OS_CreateCountingSemaphore (const char *name, DS_U32 options, DS_U32 count); |
|---|
| 95 | #endif |
|---|
| 96 | |
|---|
| 97 | #ifndef OS_CreateBinarySemaphore |
|---|
| 98 | DS_U32 OS_CreateBinarySemaphore(const char *name, DS_U32 options, DS_U32 count); |
|---|
| 99 | #endif |
|---|
| 100 | |
|---|
| 101 | #ifndef OS_DeleteSemaphore |
|---|
| 102 | DS_U32 OS_DeleteSemaphore (DS_U32 SemId); |
|---|
| 103 | #endif |
|---|
| 104 | |
|---|
| 105 | #ifndef OS_TakeSemaphore |
|---|
| 106 | DS_U32 OS_TakeSemaphore (DS_U32 SemId); |
|---|
| 107 | #endif |
|---|
| 108 | |
|---|
| 109 | #ifndef OS_TakeSemaphore_Wait |
|---|
| 110 | DS_U32 OS_TakeSemaphore_Wait(DS_U32 SemId, DS_U32 timeout); |
|---|
| 111 | #endif |
|---|
| 112 | |
|---|
| 113 | #ifndef OS_TakeSemaphore_NoWait |
|---|
| 114 | DS_U32 OS_TakeSemaphore_NoWait(DS_U32 SemId); |
|---|
| 115 | #endif |
|---|
| 116 | |
|---|
| 117 | #ifndef OS_GiveSemaphore |
|---|
| 118 | DS_U32 OS_GiveSemaphore(DS_U32 SemId); |
|---|
| 119 | #endif |
|---|
| 120 | |
|---|
| 121 | #ifndef OS_FlushSemaphore |
|---|
| 122 | DS_U32 OS_FlushSemaphore(DS_U32 SemId); |
|---|
| 123 | #endif |
|---|
| 124 | |
|---|
| 125 | // ================ Mutex API =========================== |
|---|
| 126 | #ifndef OS_CreateMutex |
|---|
| 127 | OS_MUTEX_ID OS_CreateMutex(const char *name); |
|---|
| 128 | #endif |
|---|
| 129 | |
|---|
| 130 | #ifndef OS_DeleteMutex |
|---|
| 131 | DS_U32 OS_DeleteMutex(OS_MUTEX_ID mutexId); |
|---|
| 132 | #endif |
|---|
| 133 | |
|---|
| 134 | #ifndef OS_TakeMutex |
|---|
| 135 | DS_U32 OS_TakeMutex(OS_MUTEX_ID mutexId); |
|---|
| 136 | #endif |
|---|
| 137 | |
|---|
| 138 | #ifndef OS_TakeMutex_NoWait |
|---|
| 139 | DS_U32 OS_TakeMutex_NoWait(DS_U32 mutexId); |
|---|
| 140 | #endif |
|---|
| 141 | |
|---|
| 142 | #ifndef OS_GiveMutex |
|---|
| 143 | DS_U32 OS_GiveMutex(DS_U32 mutexId); |
|---|
| 144 | #endif |
|---|
| 145 | |
|---|
| 146 | |
|---|
| 147 | // ================ Message Queue API ==================== |
|---|
| 148 | #ifndef OS_CreateMessageQueue |
|---|
| 149 | DS_U32 OS_CreateMessageQueue (const char *name, DS_U32 option, DS_U32 maxMessage, DS_U32 messageLength); |
|---|
| 150 | #endif |
|---|
| 151 | |
|---|
| 152 | #ifndef OS_SendMessage |
|---|
| 153 | DS_U32 OS_SendMessage (DS_U32 qId, DS_U32 *pBuffer, DS_U32 nBytes); |
|---|
| 154 | #endif |
|---|
| 155 | |
|---|
| 156 | #ifndef OS_ReceiveMessage |
|---|
| 157 | DS_U32 OS_ReceiveMessage(DS_U32 qId, DS_U32 *msgBuf, DS_U32 maxLen, DS_U32 *retLen); |
|---|
| 158 | #endif |
|---|
| 159 | |
|---|
| 160 | #ifndef OS_ReceiveMessage_Wait |
|---|
| 161 | DS_U32 OS_ReceiveMessage_Wait(DS_U32 qId, DS_U32 *msgBuf, DS_U32 maxLen, DS_U32 *retLen, DS_U32 timeOut); |
|---|
| 162 | #endif |
|---|
| 163 | |
|---|
| 164 | #ifndef OS_ReceiveMessage_NoWait |
|---|
| 165 | DS_U32 OS_ReceiveMessage_NoWait(DS_U32 qId, DS_U32 *msgBuf, DS_U32 maxLen, DS_U32 *retLen); |
|---|
| 166 | #endif |
|---|
| 167 | |
|---|
| 168 | #ifndef OS_DeleteMessageQueue |
|---|
| 169 | DS_U32 OS_DeleteMessageQueue(DS_U32 qId); |
|---|
| 170 | #endif |
|---|
| 171 | |
|---|
| 172 | |
|---|
| 173 | DS_U32 OS_ReadRegister( DS_U32 Address ); |
|---|
| 174 | DS_U32 OS_ReadRegisterWord( DS_U32 Address ); |
|---|
| 175 | DS_U32 OS_ReadRegisterByte( DS_U32 Address ); |
|---|
| 176 | DS_U32 OS_WriteRegister( DS_U32 Address, DS_U32 Value ); |
|---|
| 177 | DS_U32 OS_WriteRegisterWord( DS_U32 Address, DS_U32 Value ); |
|---|
| 178 | DS_U32 OS_WriteRegisterByte( DS_U32 Address, DS_U32 Value ); |
|---|
| 179 | DS_U32 OS_GetLoaderVer(void); |
|---|
| 180 | #ifdef __cplusplus |
|---|
| 181 | } |
|---|
| 182 | #endif |
|---|
| 183 | |
|---|
| 184 | #endif /* __DST_OSLAYER_H__ */ |
|---|