comparison gsm-fw/riviera/rvf/rvf_api.h @ 143:afceeeb2cba1

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