90 #ifndef _CL_OSAL_API_H_
91 #define _CL_OSAL_API_H_
123 #define CL_OSAL_MIN_STACK_SIZE 196608
128 #define CL_OSAL_NAME_MAX 32
133 #define clOsalPrintf printk
138 #define MEM_LEAK_DETECT
140 #ifdef MEM_LEAK_DETECT
141 # define kmalloc(x,y) clHeapAllocate(x)
142 # define kfree clHeapFree
151 #include <clArchHeaders.h>
152 #include <semaphore.h>
159 CL_OSAL_SHARED_INVALID = 0x0,
160 CL_OSAL_SHARED_NORMAL = 0x1,
161 CL_OSAL_SHARED_SYSV_SEM = 0x2,
162 CL_OSAL_SHARED_POSIX_SEM = 0x4,
163 CL_OSAL_SHARED_RECURSIVE = 0x8,
164 CL_OSAL_SHARED_PROCESS = 0x10,
165 CL_OSAL_SHARED_ERROR_CHECK = 0x20,
168 typedef struct ClOsalMutex
171 #define CL_OSAL_DEBUG_MAGIC 0xDEADBEEF
174 const ClCharT *creatorFile;
175 ClInt32T creatorLine;
176 const ClCharT *ownerFile;
183 pthread_mutex_t mutex;
193 typedef pthread_mutexattr_t ClOsalMutexAttrT;
194 typedef pthread_condattr_t ClOsalCondAttrT;
195 typedef enum ClOsalSharedType
197 CL_OSAL_PROCESS_PRIVATE = 0,
198 CL_OSAL_PROCESS_SHARED = 1
255 typedef struct timespec ClNanoTimeT;
342 CL_OSAL_SHM_PRIVATE = BIT0,
347 CL_OSAL_SHM_PUBLIC = BIT1
370 #define CL_OSAL_SHM_EXCEPTION_LENGTH 2048
483 void* (*fpTaskFunction)(
void*),
484 void* pTaskFuncArgument);
541 void* (*fpTaskFunction)(
void*),
542 void* pTaskFuncArgument,
706 ClUint32T* pTaskPriority);
733 ClUint32T taskPriority);
840 #ifndef CL_OSAL_DEBUG
846 extern ClRcT clOsalMutexInitDebug(ClOsalMutexT *pMutex,
const ClCharT *file, ClInt32T line);
847 #define clOsalMutexInit(mutex) clOsalMutexInitDebug(mutex, __FILE__, __LINE__)
851 ClRcT clOsalMutexErrorCheckInit (ClOsalMutexT* pMutex);
883 #define clOsalMutexIdGet(pClOsalMutexT) ((ClOsalMutexIdT)(pClOsalMutexT))
906 #ifndef CL_OSAL_DEBUG
912 extern ClRcT clOsalRecursiveMutexInitDebug(ClOsalMutexT *pMutex,
const ClCharT *file, ClInt32T line);
913 #define clOsalRecursiveMutexInit(mutex) clOsalRecursiveMutexInitDebug(mutex, __FILE__, __LINE__)
937 #ifndef CL_OSAL_DEBUG
943 extern ClRcT clOsalMutexCreateDebug(
ClOsalMutexIdT *pMutexId,
const ClCharT *file, ClInt32T line);
944 #define clOsalMutexCreate(mutexId) clOsalMutexCreateDebug(mutexId, __FILE__, __LINE__)
970 #ifndef CL_OSAL_DEBUG
976 extern ClRcT clOsalMutexCreateAndLockDebug(
ClOsalMutexIdT *pMutexId,
const ClCharT *file, ClInt32T line);
977 #define clOsalMutexCreateAndLock(mutexId) clOsalMutexCreateAndLockDebug(mutexId, __FILE__, __LINE__)
998 #ifndef CL_OSAL_DEBUG
1004 extern ClRcT clOsalMutexLockDebug(
ClOsalMutexIdT mutexId,
const ClCharT *file, ClInt32T line);
1005 #define clOsalMutexLock(mutexId) clOsalMutexLockDebug(mutexId, __FILE__, __LINE__)
1034 #ifndef CL_OSAL_DEBUG
1040 extern ClRcT clOsalMutexUnlockDebug(
ClOsalMutexIdT mutexId,
const ClCharT *file, ClInt32T line);
1041 #define clOsalMutexUnlock(mutexId) clOsalMutexUnlockDebug(mutexId, __FILE__, __LINE__)
1064 #ifndef CL_OSAL_DEBUG
1070 extern ClRcT clOsalMutexDeleteDebug(
ClOsalMutexIdT mutexId,
const ClCharT *file, ClInt32T line);
1071 #define clOsalMutexDelete(mutexId) clOsalMutexDeleteDebug(mutexId, __FILE__, __LINE__)
1094 #ifndef CL_OSAL_DEBUG
1100 extern ClRcT clOsalMutexDestroyDebug(ClOsalMutexT *pMutex,
const ClCharT *file, ClInt32T line);
1101 #define clOsalMutexDestroy(mutex) clOsalMutexDestroyDebug(mutex, __FILE__, __LINE__)
1103 extern ClRcT clOsalBustLocks(
void);
1252 #ifndef CL_OSAL_DEBUG
1260 const ClCharT *file, ClInt32T line);
1261 #define clOsalCondWait(cond, mutex, time) clOsalCondWaitDebug(cond, mutex, time, __FILE__, __LINE__)
1565 ClUint32T* pSemValue);
1922 ClRcT clOsalFileClose (ClFdT *fd);
1926 ClRcT clOsalMmap(ClPtrT start, ClUint32T length, ClInt32T prot, ClInt32T flags,
1927 ClHandleT fd, ClHandleT offset, ClPtrT *mmapped);
1930 ClRcT clOsalMunmap(ClPtrT start, ClUint32T length);
1933 ClRcT clOsalMsync (ClPtrT start, ClUint32T length, ClInt32T flags);
1936 ClRcT clOsalFtruncate (ClFdT fd, off_t length);
1938 ClRcT clOsalShmOpen (
const ClCharT *name, ClInt32T oflag, ClUint32T mode, ClFdT *fd);
1939 ClRcT clOsalShmClose (ClFdT *fd);
1941 ClRcT clOsalShmUnlink (
const ClCharT *name);
1977 ClRcT clOsalMaxPathGet(
const ClCharT* path, ClInt32T* pLength);
2014 void clOsalErrorReportHandler(
void *info) CL_DEPRECATED;
2016 ClPtrT clOsalMalloc(ClUint32T size) CL_DEPRECATED;
2018 ClPtrT clOsalCalloc(ClUint32T size) CL_DEPRECATED;
2020 void clOsalFree(ClPtrT pAddress) CL_DEPRECATED;
2024 ClRcT clOsalMutexAttrInit(ClOsalMutexAttrT *pAttr) CL_DEPRECATED;
2026 ClRcT clOsalMutexAttrDestroy(ClOsalMutexAttrT *pAttr) CL_DEPRECATED;
2028 ClRcT clOsalMutexAttrPSharedSet(ClOsalMutexAttrT *pAttr, ClOsalSharedTypeT type) CL_DEPRECATED;
2030 ClRcT clOsalMutexInitEx(ClOsalMutexT *pMutex, ClOsalMutexAttrT *pAttr) CL_DEPRECATED;
2033 ClRcT clOsalCondInitEx(
ClOsalCondT *pCond, ClOsalCondAttrT *pAttr) CL_DEPRECATED;
2035 ClRcT clOsalCondAttrInit(ClOsalCondAttrT *pAttr) CL_DEPRECATED;
2037 ClRcT clOsalCondAttrDestroy(ClOsalCondAttrT *pAttr) CL_DEPRECATED;
2039 ClRcT clOsalCondAttrPSharedSet(ClOsalCondAttrT *pAttr, ClOsalSharedTypeT type) CL_DEPRECATED;
Typical defines found in any software project.
Header file of Heap Management related APIs.
ClUint32T ClRcT
Clovis return code type.
Definition: clCommon.h:168
ClInt64T ClTimeT
Time duration specified in nanoseconds.
Definition: clCommon.h:154
ClRcT clOsalProcessSelfIdGet(ClOsalPidT *pProcessId)
Retrieves the processId.
ClRcT clOsalCondCreate(ClOsalCondIdT *pConditionId)
Creates a condition variable.
ClRcT clOsalTaskJoin(ClOsalTaskIdT taskId)
Joins a task.
pthread_cond_t ClOsalCondT
The thread condition type wrapped.
Definition: clOsalApi.h:204
ClRcT clOsalShmIdGet(ClUint8T *pName, ClOsalShmIdT *pShmId)
Retrieves a shared memory Id.
ClRcT clOsalShmSizeGet(ClOsalShmIdT shmId, ClUint32T *pSize)
Retrieves the size of shared memory.
ClRcT clOsalSemUnlock(ClOsalSemIdT semId)
Unlocks a semaphore.
ClOsalShmAreaDefT * gpClShmArea
Shared memory associated with the component.
ClRcT clOsalShmAttach(ClOsalShmIdT shmId, void *pInMem, void **ppOutMem)
Attaches a shared memory.
ClRcT clOsalCondWait(ClOsalCondIdT conditionId, ClOsalMutexIdT mutexId, ClTimerTimeOutT time)
Waits for a condition.
ClRcT clOsalCondInit(ClOsalCondT *pCond)
Initializes a condition variable.
ClRcT clOsalTaskKeyDelete(ClUint32T key)
Deletes the key for thread-specific data.
ClRcT clOsalShmSecurityModeSet(ClOsalShmIdT shmId, ClUint32T mode)
Sets permissions to shared memory.
ClTimeT clOsalStopWatchTimeGet(void)
Retrieves the time since the machine is up.
ClRcT clOsalMutexLock(ClOsalMutexIdT mutexId)
Locks a mutex.
ClRcT clOsalTaskDelete(ClOsalTaskIdT taskId)
Deletes a task.
ClRcT clOsalProcessCreate(ClOsalProcessFuncT fpFunction, void *functionArg, ClOsalProcessFlagT creationFlags, ClOsalPidT *pProcessId)
Creates a process.
ClOsalThreadPriorityT
The following enumeration type contains the various thread priorities.
Definition: clOsalApi.h:295
ClRcT clOsalProcessSharedMutexInit(ClOsalMutexT *pMutex, ClOsalSharedMutexFlagsT flags, ClUint8T *pKey, ClUint32T keyLen, ClInt32T value)
Initializes a process-shared mutex.
ClRcT clOsalTaskCreateAttached(const ClCharT *taskName, ClOsalSchedulePolicyT schedulePolicy, ClUint32T priority, ClUint32T stackSize, void *(*fpTaskFunction)(void *), void *pTaskFuncArgument, ClOsalTaskIdT *pTaskId)
Creates a task.
ClRcT clOsalSemCreate(ClUint8T *pName, ClUint32T value, ClOsalSemIdT *pSemId)
Creates a semaphore.
ClRcT clOsalShmDetach(void *pMem)
Detaches a shared memory.
ClRcT clOsalSemLock(ClOsalSemIdT semId)
Locks a semaphore.
ClRcT clOsalTaskDetach(ClOsalTaskIdT taskId)
No longer interested in the task's alive/dead state.
void(* ClOsalTaskKeyDeleteCallBackT)(void *)
CAllback type of callback function invoked when the task specific private key is destruyed.
Definition: clOsalApi.h:268
ClRcT clOsalTaskDelay(ClTimerTimeOutT timeOut)
Delays a task.
ClUint32T ClOsalShmIdT
The type of an identifier to the OSAL Shared Memory ID.
Definition: clOsalApi.h:243
ClRcT clOsalRecursiveMutexInit(ClOsalMutexT *pMutex)
Initializes a mutex.
ClRcT clOsalSelfTaskIdGet(ClOsalTaskIdT *pTaskId)
Retrieves task id.
ClRcT clOsalSemTryLock(ClOsalSemIdT semId)
Locks a semaphore if it is available.
ClRcT clOsalShmDelete(ClOsalShmIdT shmId)
Deletes a shared memory.
ClRcT clOsalMutexCreate(ClOsalMutexIdT *pMutexId)
Creates a mutex.
ClRcT clOsalSemValueGet(ClOsalSemIdT semId, ClUint32T *pSemValue)
Retrieves the value of a semaphore.
ClRcT clOsalPageSizeGet(ClInt32T *pSize)
ClRcT clOsalSemIdGet(ClUint8T *pName, ClOsalSemIdT *pSemId)
Retrieves the semaphore id.
ClOsalSchedulePolicyT
The following enumeration type contains schedule policy of the tasks that will be created.
Definition: clOsalApi.h:278
ClRcT clOsalTaskKeyCreate(ClUint32T *pKey, ClOsalTaskKeyDeleteCallBackT pCallbackFunc)
Creates a key for thread-specific data.
ClRcT clOsalProcessDelete(ClOsalPidT processId)
Deletes a process.
ClRcT clOsalMutexCreateAndLock(ClOsalMutexIdT *pMutexId)
Creates a mutex in locked state.
ClOsalProcessFlagT
Process creation flags.
Definition: clOsalApi.h:322
ClRcT clOsalMutexDelete(ClOsalMutexIdT mutexId)
Deletes a mutex.
ClRcT clOsalCondBroadcast(ClOsalCondIdT conditionId)
Broadcasts a condition.
ClRcT clOsalFinalize(void)
ClRcT clOsalCondDelete(ClOsalCondIdT conditionId)
Deletes a condition variable.
ClRcT clOsalTaskDataSet(ClUint32T key, ClOsalTaskDataT threadData)
Sets the thread-specific data.
ClOsalCondT * ClOsalCondIdT
The type of an identifier to the OSAL condition ID.
Definition: clOsalApi.h:227
ClUint32T ClOsalPidT
The type of an identifier to the OSAL Process ID.
Definition: clOsalApi.h:248
ClRcT clOsalTaskPriorityGet(ClOsalTaskIdT taskId, ClUint32T *pTaskPriority)
Retrieves the priority of the task.
ClRcT clOsalMutexUnlock(ClOsalMutexIdT mutexId)
Unlocks a mutex.
ClRcT clOsalProcessWait(ClOsalPidT processId)
Waits for a process to exit.
ClRcT clOsalTimeOfDayGet(ClTimerTimeOutT *pTime)
Retrieves the current time.
ClHandleT ClOsalSemIdT
The type of an identifier to the OSAL Semaphore ID.
Definition: clOsalApi.h:235
ClRcT clOsalMutexInit(ClOsalMutexT *pMutex)
Initializes a mutex.
ClRcT clOsalTaskCreateDetached(const ClCharT *taskName, ClOsalSchedulePolicyT schedulePolicy, ClUint32T priority, ClUint32T stackSize, void *(*fpTaskFunction)(void *), void *pTaskFuncArgument)
Creates a task.
ClRcT clOsalInitialize(const ClPtrT pConfig)
Initializes the Operating System Abstraction Layer (OSAL).
ClOsalSharedMutexFlags
The mutex type to be initialized.
Definition: clOsalApi.h:158
ClRcT clOsalPrintf(const ClCharT *fmt,...)
Prints to the standard output.
ClRcT clOsalShmSecurityModeGet(ClOsalShmIdT shmId, ClUint32T *pMode)
Retrieves permissions of shared memory.
ClRcT clOsalMutexDestroy(ClOsalMutexT *pMutex)
Destroys a mutex.
ClPtrT ClOsalTaskDataT
The type of an identifier to the OSAL Task Data type.
Definition: clOsalApi.h:253
ClOsalMutexT * ClOsalMutexIdT
The type of an identifier to the OSAL Mutex ID.
Definition: clOsalApi.h:216
ClOsalShmSecurityModeFlagT
Shared memory security options.
Definition: clOsalApi.h:352
ClRcT clOsalProcessSharedCondInit(ClOsalCondT *pCond)
Initializes a condition variable that can be used in multiple processes.
ClRcT clOsalCondSignal(ClOsalCondIdT conditionId)
Signals a condition.
ClRcT clOsalSemDelete(ClOsalSemIdT semId)
Deletes a semaphore.
ClRcT clOsalTaskNameGet(ClOsalTaskIdT taskId, ClCharT **ppTaskName)
Retrieves task name.
ClRcT clOsalTaskKill(ClOsalTaskIdT taskId, ClInt32T sig)
Kills a task by sending a signal.
enum ClOsalSharedMutexFlags ClOsalSharedMutexFlagsT
The mutex type to be initialized.
ClRcT clOsalTaskPrioritySet(ClOsalTaskIdT taskId, ClUint32T taskPriority)
Sets the priority of the task.
#define CL_OSAL_SHM_EXCEPTION_LENGTH
Shared memory area definition.
Definition: clOsalApi.h:370
void clOsalSigHandlerInitialize(void)
Installs and initializes the signal handler.
ClRcT clOsalNanoTimeGet(ClNanoTimeT *pTime)
Returns the time since Epoch, with a best resolution of 1 nanosecond.
void(* ClOsalProcessFuncT)(void *)
CAllback type of callback function invoked when a process is created.
Definition: clOsalApi.h:261
ClRcT clOsalTaskDataGet(ClUint32T key, ClOsalTaskDataT *pThreadData)
Retrieves the thread-specific data.
ClUint64T ClOsalTaskIdT
The type of an identifier to the OSAL Task ID.
Definition: clOsalApi.h:210
ClRcT clOsalCondDestroy(ClOsalCondT *pCond)
Destroys a condition variable.
ClOsalShmIdT gClCompUniqueShmId
Shared memory ID associated with the component.
ClRcT clOsalShmCreate(ClUint8T *pName, ClUint32T size, ClOsalShmIdT *pShmId)
Creates a shared memory.
@ CL_OSAL_THREAD_PRI_MEDIUM
Medium thread priority.
Definition: clOsalApi.h:309
@ CL_OSAL_THREAD_PRI_NOT_APPLICABLE
When the scheduling is CL_OSAL_SCHED_OTHER, priority is not used.
Definition: clOsalApi.h:299
@ CL_OSAL_THREAD_PRI_LOW
Lowest thread priority.
Definition: clOsalApi.h:314
@ CL_OSAL_THREAD_PRI_HIGH
Highest thread priority.
Definition: clOsalApi.h:304
@ CL_OSAL_SCHED_FIFO
First-in-first-out.
Definition: clOsalApi.h:284
@ CL_OSAL_SCHED_OTHER
Default scheduling mechanism.
Definition: clOsalApi.h:281
@ CL_OSAL_SCHED_RR
Roundrobin.
Definition: clOsalApi.h:287
@ CL_OSAL_PROCESS_WITH_NEW_GROUP
This would create a new process group.
Definition: clOsalApi.h:326
@ CL_OSAL_PROCESS_WITH_NEW_SESSION
This will create a process with new session.
Definition: clOsalApi.h:324
@ CL_OSAL_SHM_MODE_READ_OTHERS
read-only by everyone
Definition: clOsalApi.h:358
@ CL_OSAL_SHM_MODE_READ_USER
read-only by this user
Definition: clOsalApi.h:354
@ CL_OSAL_SHM_MODE_WRITE_OTHERS
read/write by everyone
Definition: clOsalApi.h:364
@ CL_OSAL_SHM_MODE_WRITE_GROUP
read/write by the group
Definition: clOsalApi.h:362
@ CL_OSAL_SHM_MODE_WRITE_USER
read/write by this user
Definition: clOsalApi.h:360
@ CL_OSAL_SHM_MODE_READ_GROUP
read-only by the group
Definition: clOsalApi.h:356
The timeout value in seconds and milliseconds.
Definition: clTimerApi.h:87