FreeCalypso > hg > tcs211-c139
comparison chipsetsw/riviera/rvf/rvf_api.h @ 0:509db1a7b7b8
initial import: leo2moko-r1
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 01 Jun 2015 03:24:05 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:509db1a7b7b8 |
---|---|
1 /****************************************************************************/ | |
2 /* */ | |
3 /* Name rvf_api.h */ | |
4 /* */ | |
5 /* Function this file contains rvf public definitions. */ | |
6 /* */ | |
7 /* Version 0.1 */ | |
8 /* */ | |
9 /* Date Modification */ | |
10 /* ------------------------------------ */ | |
11 /* 3/12/99 Create */ | |
12 /* 11/15/99 remove useless functions, */ | |
13 /* change tasks priority and time_slicing */ | |
14 /* 11/15/1999 compliant to RV coding guidelines */ | |
15 /* 12/23/1999 change buffer management, add memory bank handling */ | |
16 /* */ | |
17 /* Author David Lamy-Charrier (dlamy@tif.ti.com) */ | |
18 /* */ | |
19 /* (C) Copyright 1999 by Texas Instruments Incorporated, All Rights Reserved*/ | |
20 /****************************************************************************/ | |
21 | |
22 #ifndef _RVF_API_H | |
23 #define _RVF_API_H | |
24 | |
25 #include "rv/general.h" | |
26 #include "rv/rv_general.h" | |
27 #include "rvf/rvf_target.h" | |
28 | |
29 #ifndef _WINDOWS | |
30 #include "config/swconfig.cfg" | |
31 #endif | |
32 | |
33 #ifdef __cplusplus | |
34 extern "C" { | |
35 #endif | |
36 | |
37 | |
38 /* macros used to trace messages */ | |
39 | |
40 // WCP patch: default config is no RV trace for WCP | |
41 #if (OP_WCP == 0) | |
42 #define DEBUG_ENABLE 1 | |
43 #endif | |
44 | |
45 | |
46 #ifndef DEBUG_ENABLE | |
47 #define rvf_send_trace | |
48 #else | |
49 void rvf_send_trace1(char * msg, UINT8 msg_length, UINT32 val, UINT8 trace_level, UINT32 swe_use_id); | |
50 #define rvf_send_trace rvf_send_trace1 | |
51 #endif | |
52 | |
53 #define T_RVF_GD_ID UINT8 | |
54 | |
55 /* return parameters definition */ | |
56 typedef T_RV_RET T_RVF_RET; | |
57 | |
58 #define RVF_OK RV_OK | |
59 #define RVF_NOT_SUPPORTED RV_NOT_SUPPORTED | |
60 #define RVF_NOT_READY RV_NOT_READY | |
61 #define RVF_MEMORY_ERR RV_MEMORY_ERR | |
62 #define RVF_INTERNAL_ERR RV_INTERNAL_ERR | |
63 #define RVF_INVALID_PARAMETER RV_INVALID_PARAMETER | |
64 | |
65 /* memeory bank state definition */ | |
66 typedef enum{ | |
67 RVF_GREEN, | |
68 RVF_YELLOW, | |
69 RVF_RED | |
70 }T_RVF_MB_STATUS; | |
71 | |
72 /* task state */ | |
73 typedef enum { SUSPEND, RUNNING} T_RVF_TASK_STATE; | |
74 | |
75 /************************************************************************ | |
76 ** Mailbox definitions. Each task has 4 mailboxes that are used to | |
77 ** send buffers to the task. | |
78 */ | |
79 #define RVF_TASK_MBOX_0 0 | |
80 #define RVF_TASK_MBOX_1 1 | |
81 #define RVF_TASK_MBOX_2 2 | |
82 #define RVF_TASK_MBOX_3 3 | |
83 | |
84 #define RVF_NUM_TASK_MBOX 4 | |
85 | |
86 #define RVF_TASK_MBOX_0_EVT_MASK 0x0001 | |
87 #define RVF_TASK_MBOX_1_EVT_MASK 0x0002 | |
88 #define RVF_TASK_MBOX_2_EVT_MASK 0x0004 | |
89 #define RVF_TASK_MBOX_3_EVT_MASK 0x0008 | |
90 | |
91 /************************************************************************ | |
92 ** Event definitions. | |
93 ** | |
94 ** There are 4 reserved events used to signal messages rcvd in task mailboxes. | |
95 ** There are 4 reserved events used to signal timeout events. | |
96 ** There are 8 general purpose events available for applications. | |
97 */ | |
98 #define RVF_MAX_EVENTS 16 | |
99 | |
100 #define RVF_NUM_TASK_TIMERS 4 | |
101 | |
102 #define RVF_TIMER_0 0 | |
103 #define RVF_TIMER_1 1 | |
104 #define RVF_TIMER_2 2 | |
105 #define RVF_TIMER_3 3 | |
106 | |
107 #define RVF_TIMER_0_EVT_MASK 0x0010 | |
108 #define RVF_TIMER_1_EVT_MASK 0x0020 | |
109 #define RVF_TIMER_2_EVT_MASK 0x0040 | |
110 #define RVF_TIMER_3_EVT_MASK 0x0080 | |
111 | |
112 #define RVF_APPL_EVT_0 8 | |
113 #define RVF_APPL_EVT_1 9 | |
114 #define RVF_APPL_EVT_2 10 | |
115 #define RVF_APPL_EVT_3 11 | |
116 #define RVF_APPL_EVT_4 12 | |
117 #define RVF_APPL_EVT_5 13 | |
118 #define RVF_APPL_EVT_6 14 | |
119 #define RVF_APPL_EVT_7 15 | |
120 | |
121 #define EVENT_MASK(evt) ((UINT16)0x0001 << evt) | |
122 | |
123 #define MAX_HOSTING_TASKS 10 | |
124 #define MAX_PARASITES 10 | |
125 | |
126 | |
127 /* define memory bank related types */ | |
128 typedef UINT16 T_RVF_MB_ID; | |
129 //typedef UINT8 T_RVF_MB_NAME[RVF_MAX_MB_LEN]; | |
130 typedef char T_RVF_MB_NAME[RVF_MAX_MB_LEN]; | |
131 #define T_RVF_BUFFER void | |
132 typedef void (*CALLBACK_FUNC)(void *); | |
133 typedef void (*MB_CALLBACK_FUNC)(T_RVF_MB_ID); | |
134 | |
135 typedef struct{ | |
136 UINT32 size; | |
137 UINT32 watermark; | |
138 } T_RVF_MB_PARAM; | |
139 | |
140 | |
141 | |
142 /* Define a timer list entry | |
143 */ | |
144 typedef struct _tle | |
145 { | |
146 T_RV_HDR hdr; | |
147 struct _tle *p_next; | |
148 struct _tle *p_prev; | |
149 UINT32 ticks; | |
150 UINT16 event; /* event & param must be revised possibily */ | |
151 UINT32 param; /* sub struct pointed to by p_data if required */ | |
152 UINT32 t_init; | |
153 void* p_data; | |
154 } T_RVF_TIMER_LIST_ENT; | |
155 | |
156 typedef T_RVF_TIMER_LIST_ENT* P_NODE; | |
157 | |
158 /* Define a timer list queue ?? QUEUE or LIST ?? | |
159 */ | |
160 typedef struct | |
161 { | |
162 T_RVF_TIMER_LIST_ENT *p_first; | |
163 T_RVF_TIMER_LIST_ENT *p_last; | |
164 UINT32 last_ticks; | |
165 UINT16 timerCnt; | |
166 } T_RVF_TIMER_LIST_Q; | |
167 | |
168 | |
169 /*********************************************************************** | |
170 ** This queue is a general purpose buffer queue, for application use. | |
171 */ | |
172 typedef struct | |
173 { void *p_first; | |
174 void *p_last; | |
175 UINT16 count; | |
176 } T_RVF_BUFFER_Q; | |
177 | |
178 #define RVF_IS_QUEUE_EMPTY(p_q) (p_q.count == 0) | |
179 | |
180 /******************************************************* | |
181 * Message parameter of "handle_timer()" | |
182 ********************************************************/ | |
183 #define T_RVF_TIMER_ID UINT32 | |
184 | |
185 typedef struct { | |
186 T_RV_HDR hdr; | |
187 T_RVF_TIMER_ID tm_id; | |
188 UINT8 cont; | |
189 void* action; | |
190 } T_RVF_TMS_MSG; | |
191 | |
192 /* define a mutex structure */ | |
193 typedef struct | |
194 { UINT32 words[11]; | |
195 }T_RVF_MUTEX; | |
196 | |
197 /*********************************************************************** | |
198 ** Define the basic message header that RVF expects on all inter-computer | |
199 ** communications. Applications should use this in their own definitions | |
200 ** and add on their own message contents. | |
201 */ | |
202 /*typedef struct { | |
203 UINT16 prim; // Message Type | |
204 UINT16 len; // Message Length (including header) | |
205 } msg_hdr_t; | |
206 | |
207 typedef struct { | |
208 msg_hdr_t hdr; | |
209 UINT8 data[1]; | |
210 } msg_type1; | |
211 */ | |
212 | |
213 /* Task constants | |
214 */ | |
215 #ifndef TASKPTR | |
216 typedef void (*TASKPTR)(UINT32); | |
217 #endif | |
218 | |
219 | |
220 #define RVF_INVALID_TASK (0xFF) | |
221 #define RVF_INVALID_MB_ID (0xFFFF) | |
222 #define RVF_INVALID_MAILBOX (0xFF) | |
223 #define RVF_INVALID_ADDR_ID (0xFF) | |
224 | |
225 /* Define the value that create pool will return if it fails | |
226 */ | |
227 | |
228 | |
229 /************************************************************************/ | |
230 /* Function prototypes */ | |
231 | |
232 | |
233 /* Task management*/ | |
234 void rvf_init(void); | |
235 T_RVF_RET rvf_create_legacy_task (TASKPTR task_entry, UINT8 task_id, char *taskname, UINT8 *stack, UINT16 stacksize, UINT8 priority, UINT8 time_slicing, T_RVF_TASK_STATE is_suspend) ; | |
236 T_RVF_RET rvf_create_task (TASKPTR task_entry, T_RVF_G_ADDR_ID task_id, char *taskname, UINT8 *stack, UINT16 stacksize, UINT8 priority, UINT8 tcode, UINT8 time_slicing, T_RVF_TASK_STATE is_suspend); | |
237 T_RVF_RET rvf_resume_task( T_RVF_G_ADDR_ID taskid); | |
238 void rvf_exit_task(T_RVF_G_ADDR_ID vtask); | |
239 T_RVF_RET rvf_suspend_task(T_RVF_G_ADDR_ID vtask); | |
240 T_RVF_G_ADDR_ID rvf_get_taskid(void); | |
241 char * rvf_get_taskname(void); | |
242 T_RVF_G_ADDR_ID rvf_get_context(); | |
243 | |
244 /* Message Handling */ | |
245 typedef T_RV_HDR T_RVF_MSG ; | |
246 typedef UINT32 T_RVF_MSG_ID; | |
247 | |
248 T_RVF_RET rvf_send_msg (T_RVF_G_ADDR_ID addr_id, void * p_msg); | |
249 T_RVF_MB_STATUS rvf_get_msg_buf (T_RVF_MB_ID mb_id, | |
250 UINT32 message_size, | |
251 T_RVF_MSG_ID msg_id, | |
252 T_RVF_MSG ** pp_msg); | |
253 T_RVF_RET rvf_free_msg (T_RVF_MSG * p_msg); | |
254 T_RVF_RET rvf_free_timer_msg (T_RVF_MSG *p_msg); | |
255 | |
256 | |
257 | |
258 /* To send buffers and events between tasks*/ | |
259 void * rvf_read_mbox (UINT8 mbox); | |
260 void * rvf_read_addr_mbox (T_RVF_G_ADDR_ID task_id, UINT8 mbox); | |
261 UINT8 rvf_send_event (T_RVF_G_ADDR_ID task_id, UINT16 event); | |
262 | |
263 /* task synchronization */ | |
264 T_RVF_RET rvf_initialize_mutex( T_RVF_MUTEX * mutex); | |
265 T_RVF_RET rvf_lock_mutex( T_RVF_MUTEX * mutex); | |
266 T_RVF_RET rvf_unlock_mutex( T_RVF_MUTEX * mutex); | |
267 T_RVF_RET rvf_delete_mutex( T_RVF_MUTEX * mutex); | |
268 | |
269 | |
270 /* To manage memory */ | |
271 T_RVF_RET rvf_create_mb(T_RVF_MB_NAME mb_name, T_RVF_MB_PARAM mb_param, T_RVF_MB_ID *mb_id); | |
272 T_RVF_RET rvf_delete_mb(T_RVF_MB_NAME mb_name); | |
273 T_RVF_RET rvf_get_mb_id(T_RVF_MB_NAME mb_name, T_RVF_MB_ID *mb_id); | |
274 T_RVF_MB_STATUS rvf_get_mb_status(T_RVF_MB_ID mb_id); | |
275 T_RVF_RET rvf_mb_is_used(T_RVF_MB_NAME mb_name, UINT8* isUsed) ; | |
276 | |
277 T_RVF_MB_STATUS rvf_get_buf(T_RVF_MB_ID mb_id, UINT32 buffer_size, T_RVF_BUFFER** p_buffer); | |
278 T_RVF_MB_STATUS rvf_count_buf(T_RVF_MB_ID mb_id, T_RVF_BUFFER * p_buffer); | |
279 T_RVF_RET rvf_free_buf( T_RVF_BUFFER * p_buffer); | |
280 T_RVF_RET rvf_set_callback_func(T_RVF_MB_ID mb_id, MB_CALLBACK_FUNC func); | |
281 T_RVF_RET rvf_change_callback_func(T_RVF_MB_ID mb_id, MB_CALLBACK_FUNC func); | |
282 | |
283 void rvf_get_protected_buf(T_RVF_MB_ID mb_id, UINT32 buffer_size, T_RVF_BUFFER** p_buffer); | |
284 | |
285 | |
286 UINT32 rvf_get_buf_size (void *bptr); | |
287 /* get the parameters of a specific memory bank */ | |
288 T_RVF_RET rvf_get_mb_param( T_RVF_MB_NAME mb_name, T_RVF_MB_PARAM * param); | |
289 /* change the parameters of a specific memory bank */ | |
290 T_RVF_RET rvf_set_mb_param( T_RVF_MB_NAME mb_name, T_RVF_MB_PARAM * param); | |
291 | |
292 | |
293 /* User buffer queue management*/ | |
294 T_RVF_RET rvf_enqueue (T_RVF_BUFFER_Q *p_q, void *p_buf); | |
295 T_RVF_RET rvf_enqueue_head (T_RVF_BUFFER_Q *p_q, void *p_buf); | |
296 void * rvf_dequeue (T_RVF_BUFFER_Q *p_q); | |
297 T_RVF_BUFFER * rvf_scan_next (T_RVF_BUFFER_Q * p_q, T_RVF_BUFFER * p_buf); | |
298 T_RVF_RET rvf_remove_from_queue (T_RVF_BUFFER_Q * p_q, T_RVF_BUFFER * p_buf); | |
299 | |
300 /* Timer management*/ | |
301 | |
302 UINT16 rvf_wait(UINT16 flag, UINT32 ticks); | |
303 UINT16 rvf_evt_wait(T_RVF_G_ADDR_ID rtask, UINT16 flag, UINT32 timeout) ; | |
304 void rvf_delay(UINT32 ticks); | |
305 | |
306 void rvf_start_timer(UINT8 tnum, UINT32 ticks, BOOLEAN is_continuous); | |
307 void rvf_stop_timer (UINT8 tnum); | |
308 char * rvf_get_time_stamp(char *tbuf); | |
309 UINT32 rvf_get_tick_count(void); | |
310 void rvf_init_timer_list (T_RVF_TIMER_LIST_Q *p_timer_listq); | |
311 void rvf_init_timer_list_entry (T_RVF_TIMER_LIST_ENT *p_tle); | |
312 UINT16 rvf_update_timer_list (T_RVF_TIMER_LIST_Q *p_timer_listq); | |
313 void rvf_add_to_timer_list (T_RVF_TIMER_LIST_Q *p_timer_listq, T_RVF_TIMER_LIST_ENT *p_tle); | |
314 void rvf_remove_from_timer_list (T_RVF_TIMER_LIST_Q *p_timer_listq, T_RVF_TIMER_LIST_ENT *p_tle); | |
315 T_RVF_TIMER_LIST_ENT* rvf_get_expired_entry (T_RVF_TIMER_LIST_Q *p_timer_listq); | |
316 | |
317 | |
318 #define T_RV_TM_ID UINT32 | |
319 | |
320 /*************************************************************************/ | |
321 /* :) USER FRIENDLY TIMER MANAGEMENT API consisting of add, delete and modify timer */ | |
322 /*************************************************************************/ | |
323 /* Returns 0 on failure */ | |
324 T_RVF_TIMER_ID rvf_create_timer( T_RVF_G_ADDR_ID g_addrId, | |
325 UINT32 timerDuration, | |
326 BOOLEAN isContinuous, | |
327 void* p_action); | |
328 | |
329 void rvf_del_timer ( T_RV_TM_ID tm_id) ; | |
330 | |
331 void rvf_reset_timer ( T_RV_TM_ID tm_id, UINT32 new_duration, | |
332 BOOLEAN isContinuous); | |
333 | |
334 | |
335 /* Disable Interrupts, Enable Interrupts*/ | |
336 void rvf_enable(void); | |
337 void rvf_disable(UINT8 who); | |
338 | |
339 /* Trace for debug purposes*/ | |
340 void rvf_dump_mem(); | |
341 void rvf_dump_tasks(); | |
342 void rvf_dump_pool(); | |
343 | |
344 /* specific function */ | |
345 T_RVF_BUFFER * rvf_wait_for_specific_msg(UINT16 msg_code, UINT8 mbox, UINT32 timeout); | |
346 | |
347 /* Trace definitions */ | |
348 #define NULL_PARAM 4294967295 /* this value will not be displayed in rvf_send_trace function */ | |
349 #define TRACE_MB_ID (RVF_MAX_REAL_MB -1) | |
350 | |
351 #ifdef __cplusplus | |
352 } | |
353 #endif | |
354 | |
355 #endif /* _RVF_API_H */ | |
356 |