source: svn/newcon3bcm2_21bu/dst/dhl/src/DHL_OSAL_Impl.h @ 45

Last change on this file since 45 was 45, checked in by megakiss, 11 years ago
  • Property svn:executable set to *
File size: 4.3 KB
Line 
1/****************************************************************************
2  DHL_OSAL_Impl.c - private header
3         
4
5
6
7****************************************************************************/
8
9
10#ifndef __DHL_OSAL_IMPL_H__
11#define __DHL_OSAL_IMPL_H__
12
13#ifdef _cplusplus
14extern "C" {
15#endif
16
17#include "bos.h"
18#include "ucos_ii.h"
19#include "ministd.h"
20#include "string.h"
21//#include "libc.h"
22#include "bkni.h"
23
24/* platform dependent settings */
25typedef UINT32 os_task_id;
26typedef void *os_semaphore_id;
27typedef void *os_messagequeue_id;
28typedef void (*os_taskfunction)(void *);
29
30
31/**
32        SemaphoreÀÇ option.
33
34        °¢Á¾ CreateXXXSemaphoreÀÇ optionÀ¸·Î »ç¿ëµÈ´Ù.
35        ÀϹÝÀûÀ¸·Î´Â priority ¹æ½ÄÀ¸·Î »ç¿ëÇÏ¸é µÈ´Ù.
36        --> uCOS-II¿¡¼­´Â µ¿ÀÏÇÑ priority¸¦ °¡Áø task´Â ¾øÀ½. »ç¿ëÇÏÁö ¾Ê´Â ¿É¼Ç
37*/
38enum {
39        OS_SEM_PRIO=0x0, ///< ´ë±âÁßÀÎ taskÁß¿¡¼­ highest priority task°¡ ¸ÕÀú ±ú¾î³².
40        OS_SEM_FIFO=0x1, ///< ¸Ç ¸ÕÀú suspend µÈ task°¡ ¸ÕÀú ±ú¾î³²
41};
42
43
44#ifdef BCM_DEBUG
45        // because we use broadcom heap debug function,
46        // OSAL heap code depends on broadcom make flag.
47        #define OSAL_HEAP_DEBUG 1
48#endif
49
50
51typedef struct 
52{
53        UINT32 size_heap; // size of entire heap
54       
55        UINT32 num_alloc_chunk; // number of alloc chunk
56        UINT32 size_alloc;       // total byte size alloc chunk
57
58        UINT32 num_free_chunk;  // number of free chunk
59        UINT32 size_free;        // total byte size free chunk
60       
61} dhl_heap_status;
62
63
64#if OSAL_HEAP_DEBUG // heap debugging
65
66        void *os_dbg_malloc(int size, char *file, int line);
67        void *os_dbg_calloc(int n, int m, char *file, int line);
68        void os_dbg_free(void *ptr, char *file, int line);
69
70        // we need file/line info of the caller.
71        #define OS_Malloc(n) os_dbg_malloc((n), __FILE__, __LINE__)
72        #define OS_Calloc(n,m) os_dbg_calloc((n),(m), __FILE__, __LINE__)
73        #define OS_Free(p) os_dbg_free((p), __FILE__, __LINE__)
74       
75#else
76        // this is normal function.
77        void *OS_Malloc(int size);
78        void *OS_Calloc(int n, int m);
79        void  OS_Free(void *pp);
80        void OS_FreeDirect(void *ptr);
81#endif
82
83void os_heap_status(dhl_heap_status *pstat);
84
85
86
87int osi_dbgprint(char *fmt, ...);
88
89UINT32 osi_gettickcount();
90UINT32 osi_gettickspersecond();
91void osi_delay(UINT32 millisec);
92
93BOOL osi_in_interrupt(void);
94
95UINT32 osi_disableint();
96void osi_enableint(UINT32 mask);
97
98BOOL osi_in_tasklock(void);
99
100UINT32 osi_locktask();
101void osi_unlocktask(UINT32 mask);
102char *osi_taskname(os_task_id tid);
103int osi_taskpriority();
104os_task_id osi_taskid();
105os_task_id osi_taskidfromname(char *tname);
106void osi_changetaskpriority(os_task_id tid, UINT32 newPrio, UINT32 *oldPrioPtr);
107void osi_deletetask(os_task_id tid);
108void osi_selfdeletetask(void);
109
110os_task_id osi_spawntask(os_taskfunction func, const char *name, int priority, UINT32 stackSize,
111                         UINT32 arg1);
112
113
114int osi_takesemaphore(os_semaphore_id sid);
115int osi_takesemaphore_wait(os_semaphore_id sid, int ticks);
116int osi_takesemaphore_nowait(os_semaphore_id sid);
117int osi_givesemaphore(os_semaphore_id sid);
118int osi_flushsemaphore(os_semaphore_id sid);
119void osi_deletesemaphore(os_semaphore_id sid);
120int osi_takemutexsemaphore_wait(os_semaphore_id sid, int ticks);
121void osi_givemutexsemaphore(os_semaphore_id sid);
122void osi_deletemutexsemaphore(os_semaphore_id sid);     
123os_semaphore_id osi_createcountingsemaphore(const char *name, UINT32 options, UINT32 count);
124os_semaphore_id osi_createbinarysemaphore(const char *name, UINT32 options, BOOL flag);
125os_semaphore_id osi_createmutexsemaphore(const char *name);
126
127int osi_free_reuse_sem_count(void);
128os_semaphore_id osi_create_reuse_semaphore(char *name, int count);
129void osi_delete_reuse_semaphore(os_semaphore_id sid);
130
131
132void osi_deletemessagequeue(os_messagequeue_id qid);
133os_messagequeue_id osi_createmessagequeue(const char *name, UINT32 options, 
134                      UINT32 maxMessages, UINT32 maxMessageLength);
135int     osi_sendmessage(os_messagequeue_id qid, void *buffer, int nBytes);
136int osi_receivemessage(os_messagequeue_id qid, void *msgBuf);
137int osi_receivemessage_wait(os_messagequeue_id qid, void *msgBuf, int ticks);
138int osi_receivemessage_nowait(os_messagequeue_id qid, void *msgBuf);
139
140
141void osi_show_taskinfo(int level);
142
143
144#ifdef _cplusplus
145extern } /* extern "C" */
146#endif
147
148
149
150#endif /* __DHL_OSAL_IMPL_H__ */
151
152/* end of file */
Note: See TracBrowser for help on using the repository browser.