/**************************************************************************** DHL_OSAL_Impl.c - private header ****************************************************************************/ #ifndef __DHL_OSAL_IMPL_H__ #define __DHL_OSAL_IMPL_H__ #ifdef _cplusplus extern "C" { #endif #include "bos.h" #include "ucos_ii.h" #include "ministd.h" #include "string.h" //#include "libc.h" #include "bkni.h" /* platform dependent settings */ typedef UINT32 os_task_id; typedef void *os_semaphore_id; typedef void *os_messagequeue_id; typedef void (*os_taskfunction)(void *); /** SemaphoreÀÇ option. °¢Á¾ CreateXXXSemaphoreÀÇ optionÀ¸·Î »ç¿ëµÈ´Ù. ÀϹÝÀûÀ¸·Î´Â priority ¹æ½ÄÀ¸·Î »ç¿ëÇÏ¸é µÈ´Ù. --> uCOS-II¿¡¼­´Â µ¿ÀÏÇÑ priority¸¦ °¡Áø task´Â ¾øÀ½. »ç¿ëÇÏÁö ¾Ê´Â ¿É¼Ç */ enum { OS_SEM_PRIO=0x0, ///< ´ë±âÁßÀÎ taskÁß¿¡¼­ highest priority task°¡ ¸ÕÀú ±ú¾î³². OS_SEM_FIFO=0x1, ///< ¸Ç ¸ÕÀú suspend µÈ task°¡ ¸ÕÀú ±ú¾î³² }; #ifdef BCM_DEBUG // because we use broadcom heap debug function, // OSAL heap code depends on broadcom make flag. #define OSAL_HEAP_DEBUG 1 #endif typedef struct { UINT32 size_heap; // size of entire heap UINT32 num_alloc_chunk; // number of alloc chunk UINT32 size_alloc; // total byte size alloc chunk UINT32 num_free_chunk; // number of free chunk UINT32 size_free; // total byte size free chunk } dhl_heap_status; #if OSAL_HEAP_DEBUG // heap debugging void *os_dbg_malloc(int size, char *file, int line); void *os_dbg_calloc(int n, int m, char *file, int line); void os_dbg_free(void *ptr, char *file, int line); // we need file/line info of the caller. #define OS_Malloc(n) os_dbg_malloc((n), __FILE__, __LINE__) #define OS_Calloc(n,m) os_dbg_calloc((n),(m), __FILE__, __LINE__) #define OS_Free(p) os_dbg_free((p), __FILE__, __LINE__) #else // this is normal function. void *OS_Malloc(int size); void *OS_Calloc(int n, int m); void OS_Free(void *pp); void OS_FreeDirect(void *ptr); #endif void os_heap_status(dhl_heap_status *pstat); int osi_dbgprint(char *fmt, ...); UINT32 osi_gettickcount(); UINT32 osi_gettickspersecond(); void osi_delay(UINT32 millisec); BOOL osi_in_interrupt(void); UINT32 osi_disableint(); void osi_enableint(UINT32 mask); BOOL osi_in_tasklock(void); UINT32 osi_locktask(); void osi_unlocktask(UINT32 mask); char *osi_taskname(os_task_id tid); int osi_taskpriority(); os_task_id osi_taskid(); os_task_id osi_taskidfromname(char *tname); void osi_changetaskpriority(os_task_id tid, UINT32 newPrio, UINT32 *oldPrioPtr); void osi_deletetask(os_task_id tid); void osi_selfdeletetask(void); os_task_id osi_spawntask(os_taskfunction func, const char *name, int priority, UINT32 stackSize, UINT32 arg1); int osi_takesemaphore(os_semaphore_id sid); int osi_takesemaphore_wait(os_semaphore_id sid, int ticks); int osi_takesemaphore_nowait(os_semaphore_id sid); int osi_givesemaphore(os_semaphore_id sid); int osi_flushsemaphore(os_semaphore_id sid); void osi_deletesemaphore(os_semaphore_id sid); int osi_takemutexsemaphore_wait(os_semaphore_id sid, int ticks); void osi_givemutexsemaphore(os_semaphore_id sid); void osi_deletemutexsemaphore(os_semaphore_id sid); os_semaphore_id osi_createcountingsemaphore(const char *name, UINT32 options, UINT32 count); os_semaphore_id osi_createbinarysemaphore(const char *name, UINT32 options, BOOL flag); os_semaphore_id osi_createmutexsemaphore(const char *name); int osi_free_reuse_sem_count(void); os_semaphore_id osi_create_reuse_semaphore(char *name, int count); void osi_delete_reuse_semaphore(os_semaphore_id sid); void osi_deletemessagequeue(os_messagequeue_id qid); os_messagequeue_id osi_createmessagequeue(const char *name, UINT32 options, UINT32 maxMessages, UINT32 maxMessageLength); int osi_sendmessage(os_messagequeue_id qid, void *buffer, int nBytes); int osi_receivemessage(os_messagequeue_id qid, void *msgBuf); int osi_receivemessage_wait(os_messagequeue_id qid, void *msgBuf, int ticks); int osi_receivemessage_nowait(os_messagequeue_id qid, void *msgBuf); void osi_show_taskinfo(int level); #ifdef _cplusplus extern } /* extern "C" */ #endif #endif /* __DHL_OSAL_IMPL_H__ */ /* end of file */