| 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 | void OS_Init(void); |
|---|
| 46 | |
|---|
| 47 | // ================ Thread API ======================= |
|---|
| 48 | #ifndef OS_SpawnTask |
|---|
| 49 | DS_U32 OS_SpawnTask (void (*func)(DS_U32), char *name, DS_U16 prio, DS_U16 stacksize, DS_U32 arg); |
|---|
| 50 | #endif |
|---|
| 51 | |
|---|
| 52 | #if !defined(OS_DeleteTask) |
|---|
| 53 | DS_U32 OS_DeleteTask(DS_U32 TaskId); |
|---|
| 54 | #endif |
|---|
| 55 | |
|---|
| 56 | #if !defined(OS_SelfDeleteTask) |
|---|
| 57 | void OS_SelfDeleteTask(void); |
|---|
| 58 | #endif |
|---|
| 59 | |
|---|
| 60 | #ifndef OS_SuspendTask |
|---|
| 61 | DS_U32 OS_SuspendTask(DS_U32 TaskId); |
|---|
| 62 | #endif |
|---|
| 63 | |
|---|
| 64 | #ifndef OS_ResumeTask |
|---|
| 65 | DS_U32 OS_ResumeTask(DS_U32 TaskId); |
|---|
| 66 | #endif |
|---|
| 67 | |
|---|
| 68 | #ifndef OS_GetSelfTaskId |
|---|
| 69 | OS_TASK_ID OS_GetSelfTaskId(void); |
|---|
| 70 | #endif |
|---|
| 71 | |
|---|
| 72 | // ================ Time API ======================== |
|---|
| 73 | #ifndef OS_GetTicksPerSecond |
|---|
| 74 | DS_U32 OS_GetTicksPerSecond (void); |
|---|
| 75 | #endif |
|---|
| 76 | |
|---|
| 77 | #ifndef OS_Delay |
|---|
| 78 | void OS_Delay(DS_U32 Ticks); |
|---|
| 79 | #endif |
|---|
| 80 | |
|---|
| 81 | #ifndef OS_mDelay |
|---|
| 82 | void OS_mDelay(DS_U32 milliseconds); |
|---|
| 83 | #endif |
|---|
| 84 | |
|---|
| 85 | #ifndef OS_uDelay |
|---|
| 86 | void OS_uDelay(DS_U32 useconds); |
|---|
| 87 | #endif |
|---|
| 88 | |
|---|
| 89 | |
|---|
| 90 | #ifndef OS_GetTickCount |
|---|
| 91 | DS_U32 OS_GetTickCount(void); |
|---|
| 92 | #endif |
|---|
| 93 | |
|---|
| 94 | // ================ Semaphore ======================== |
|---|
| 95 | #ifndef OS_CreateCountingSemaphore |
|---|
| 96 | DS_U32 OS_CreateCountingSemaphore (const char *name, DS_U32 options, DS_U32 count); |
|---|
| 97 | #endif |
|---|
| 98 | |
|---|
| 99 | #ifndef OS_CreateBinarySemaphore |
|---|
| 100 | DS_U32 OS_CreateBinarySemaphore(const char *name, DS_U32 options, DS_U32 count); |
|---|
| 101 | #endif |
|---|
| 102 | |
|---|
| 103 | #ifndef OS_DeleteSemaphore |
|---|
| 104 | DS_U32 OS_DeleteSemaphore (DS_U32 SemId); |
|---|
| 105 | #endif |
|---|
| 106 | |
|---|
| 107 | #ifndef OS_TakeSemaphore |
|---|
| 108 | DS_U32 OS_TakeSemaphore (DS_U32 SemId); |
|---|
| 109 | #endif |
|---|
| 110 | |
|---|
| 111 | #ifndef OS_TakeSemaphore_Wait |
|---|
| 112 | DS_U32 OS_TakeSemaphore_Wait(DS_U32 SemId, DS_U32 timeout); |
|---|
| 113 | #endif |
|---|
| 114 | |
|---|
| 115 | #ifndef OS_TakeSemaphore_NoWait |
|---|
| 116 | DS_U32 OS_TakeSemaphore_NoWait(DS_U32 SemId); |
|---|
| 117 | #endif |
|---|
| 118 | |
|---|
| 119 | #ifndef OS_GiveSemaphore |
|---|
| 120 | DS_U32 OS_GiveSemaphore(DS_U32 SemId); |
|---|
| 121 | #endif |
|---|
| 122 | |
|---|
| 123 | #ifndef OS_FlushSemaphore |
|---|
| 124 | DS_U32 OS_FlushSemaphore(DS_U32 SemId); |
|---|
| 125 | #endif |
|---|
| 126 | |
|---|
| 127 | // ================ Mutex API =========================== |
|---|
| 128 | #ifndef OS_CreateMutex |
|---|
| 129 | OS_MUTEX_ID OS_CreateMutex(const char *name); |
|---|
| 130 | #endif |
|---|
| 131 | |
|---|
| 132 | #ifndef OS_DeleteMutex |
|---|
| 133 | DS_U32 OS_DeleteMutex(OS_MUTEX_ID mutexId); |
|---|
| 134 | #endif |
|---|
| 135 | |
|---|
| 136 | #ifndef OS_TakeMutex |
|---|
| 137 | DS_U32 OS_TakeMutex(OS_MUTEX_ID mutexId); |
|---|
| 138 | #endif |
|---|
| 139 | |
|---|
| 140 | #ifndef OS_TakeMutex_NoWait |
|---|
| 141 | DS_U32 OS_TakeMutex_NoWait(DS_U32 mutexId); |
|---|
| 142 | #endif |
|---|
| 143 | |
|---|
| 144 | #ifndef OS_GiveMutex |
|---|
| 145 | DS_U32 OS_GiveMutex(DS_U32 mutexId); |
|---|
| 146 | #endif |
|---|
| 147 | |
|---|
| 148 | |
|---|
| 149 | // ================ Message Queue API ==================== |
|---|
| 150 | #ifndef OS_CreateMessageQueue |
|---|
| 151 | DS_U32 OS_CreateMessageQueue (const char *name, DS_U32 option, DS_U32 maxMessage, DS_U32 messageLength); |
|---|
| 152 | #endif |
|---|
| 153 | |
|---|
| 154 | #ifndef OS_SendMessage |
|---|
| 155 | DS_U32 OS_SendMessage (DS_U32 qId, DS_U32 *pBuffer, DS_U32 nBytes); |
|---|
| 156 | #endif |
|---|
| 157 | |
|---|
| 158 | #ifndef OS_ReceiveMessage |
|---|
| 159 | DS_U32 OS_ReceiveMessage(DS_U32 qId, DS_U32 *msgBuf, DS_U32 maxLen, DS_U32 *retLen); |
|---|
| 160 | #endif |
|---|
| 161 | |
|---|
| 162 | #ifndef OS_ReceiveMessage_Wait |
|---|
| 163 | DS_U32 OS_ReceiveMessage_Wait(DS_U32 qId, DS_U32 *msgBuf, DS_U32 maxLen, DS_U32 *retLen, DS_U32 timeOut); |
|---|
| 164 | #endif |
|---|
| 165 | |
|---|
| 166 | #ifndef OS_ReceiveMessage_NoWait |
|---|
| 167 | DS_U32 OS_ReceiveMessage_NoWait(DS_U32 qId, DS_U32 *msgBuf, DS_U32 maxLen, DS_U32 *retLen); |
|---|
| 168 | #endif |
|---|
| 169 | |
|---|
| 170 | #ifndef OS_DeleteMessageQueue |
|---|
| 171 | DS_U32 OS_DeleteMessageQueue(DS_U32 qId); |
|---|
| 172 | #endif |
|---|
| 173 | |
|---|
| 174 | // ================ Dynamic Memory API ==================== |
|---|
| 175 | #define OS_malloc(a) _OS_malloc(a, __func__, __LINE__) |
|---|
| 176 | #define OS_calloc(a, b) _OS_calloc(a, b, __func__, __LINE__) |
|---|
| 177 | #define OS_realloc(a, b) _OS_realloc(a, b, __func__, __LINE__) |
|---|
| 178 | #define OS_free(a) _OS_free(a, __func__, __LINE__) |
|---|
| 179 | |
|---|
| 180 | void *_OS_malloc(unsigned int size, const char* func, int nLine); |
|---|
| 181 | void *_OS_calloc(unsigned int count, unsigned int size, const char* func, int nLine); |
|---|
| 182 | void *_OS_realloc(void* memory, unsigned int size, const char* func, int nLine); |
|---|
| 183 | void _OS_free(void *where, const char* func, int nLine); |
|---|
| 184 | |
|---|
| 185 | void *OS_malloc2(unsigned int size); |
|---|
| 186 | void *OS_calloc2(unsigned int count, unsigned int size); |
|---|
| 187 | void *OS_realloc2(void* memory, unsigned int size); |
|---|
| 188 | void OS_free2(void *where); |
|---|
| 189 | |
|---|
| 190 | DS_U32 OS_ReadRegister( DS_U32 Address ); |
|---|
| 191 | DS_U32 OS_ReadRegisterWord( DS_U32 Address ); |
|---|
| 192 | DS_U32 OS_ReadRegisterByte( DS_U32 Address ); |
|---|
| 193 | DS_U32 OS_WriteRegister( DS_U32 Address, DS_U32 Value ); |
|---|
| 194 | DS_U32 OS_WriteRegisterWord( DS_U32 Address, DS_U32 Value ); |
|---|
| 195 | DS_U32 OS_WriteRegisterByte( DS_U32 Address, DS_U32 Value ); |
|---|
| 196 | DS_U32 OS_GetLoaderVer(void); |
|---|
| 197 | #ifdef __cplusplus |
|---|
| 198 | } |
|---|
| 199 | #endif |
|---|
| 200 | |
|---|
| 201 | #endif /* __DST_OSLAYER_H__ */ |
|---|