FreeCalypso > hg > tcs211-c139
comparison chipsetsw/riviera/rvm/rvm_task.c @ 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 * @file rvm_task.c | |
4 * | |
5 * This file contains the main RVN function: rvm_task. | |
6 It will initialize the RVM and then wait for messages. | |
7 * | |
8 * @author Cristian Livadiotti (c-livadiotti@ti.com) | |
9 * @version 0.2 | |
10 * | |
11 */ | |
12 | |
13 /* | |
14 * Revision History: | |
15 * | |
16 * 06/04/2000 Cristian Livadiotti Create. | |
17 * 10/22/2001 David Lamy-Charrier Update for new Riviera 1.6. | |
18 * | |
19 * (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved | |
20 */ | |
21 # include <stdio.h> | |
22 | |
23 #include "rvf/rvf_api.h" | |
24 | |
25 #include "rvm/rvm_gen.h" | |
26 #include "rvm/rvm_api.h" | |
27 #include "rvm/rvm_i.h" | |
28 #include "rvf/rvf_i.h" /* only for pRtAddrIdTable[] */ | |
29 #include "rvm/rvm_use_id_list.h" | |
30 | |
31 | |
32 extern T_RVM_KNOWN_SWE * rvm_swe_array; /* for start() */ | |
33 | |
34 #ifdef _CONSOLE | |
35 void _callerProxy(T_RVM_APPLI_RESULT *p_msg_res) ; //A-M-E-N-D-E-D! | |
36 #endif | |
37 | |
38 T_RVM_RETURN _start_group(T_RVF_G_ADDR_ID gid, UINT8* grp); | |
39 T_RVM_RETURN _t3_start(T_RVF_G_ADDR_ID gid); | |
40 T_RVM_RETURN _stop_t2_swe(T_RVM_STOP_MSG* p_msg); | |
41 T_RVM_RETURN _stop_t3_swe(T_RVM_STOP_MSG* p_msg); | |
42 | |
43 /******************************************************************************* | |
44 ** Function rvm_init | |
45 ** | |
46 ** Description Initialize all the RVM | |
47 ** | |
48 *******************************************************************************/ | |
49 BOOLEAN rvm_init() | |
50 { | |
51 T_RVF_MB_PARAM mb_params; | |
52 mb_params.size = RVM_PRIM_MB_SIZE; | |
53 mb_params.watermark = RVM_PRIM_MB_WATERMARK; | |
54 | |
55 if(rvm_mem_bank!=RVF_INVALID_MB_ID) return TRUE; | |
56 /* create rvm main Memory Bank */ | |
57 if ( rvf_create_mb( RVM_PRIM_MB, mb_params, &rvm_mem_bank) != RVF_OK) | |
58 { | |
59 // TO DO: remove this call since the RVT software entity has not been started yet. | |
60 RVM_TRACE_ERROR( "RVM_init: unable to create the RVM Main mem bank"); | |
61 return FALSE; | |
62 } | |
63 | |
64 mb_params.size = RVM_STACK_MB_SIZE; | |
65 mb_params.watermark = RVM_STACK_MB_WATERMARK; | |
66 | |
67 /* create a second Memory Bank used for stack allocation */ | |
68 if ( rvf_create_mb( RVM_STACK_MB, mb_params, &rvm_stack_mem_bank) != RVF_OK) | |
69 { | |
70 // TO DO: remove this call since the RVT software entity has not been started yet. | |
71 RVM_TRACE_ERROR( "RVM_init: unable to create the RVM stacks mem bank"); | |
72 return FALSE; | |
73 } | |
74 | |
75 mb_params.size = RVM_SYS_MB_SIZE; | |
76 mb_params.watermark = RVM_SYS_MB_WATERMARK; | |
77 | |
78 if(rvm_sys_mem_bank!=RVF_INVALID_MB_ID) return TRUE; | |
79 /* create rvm main Memory Bank */ | |
80 if ( rvf_create_mb( RVM_SYS_MB, mb_params, &rvm_sys_mem_bank) != RVF_OK) | |
81 { | |
82 // TO DO: remove this call since the RVT software entity has not been started yet. | |
83 RVM_TRACE_ERROR( "RVM_init: unable to create the RVM SYSTEM mem bank"); | |
84 return FALSE; | |
85 } | |
86 | |
87 mb_params.size = RVM_TIMER_MB_SIZE; | |
88 mb_params.watermark = RVM_TIMER_MB_WATERMARK; | |
89 | |
90 if(rvm_timer_mem_bank!=RVF_INVALID_MB_ID) return TRUE; | |
91 // create rvm main Memory Bank | |
92 if ( rvf_create_mb( RVM_TIMER_MB, mb_params, &rvm_timer_mem_bank) != RVF_OK) | |
93 { | |
94 // TO DO: remove this call since the RVT software entity has not been started yet. | |
95 RVM_TRACE_ERROR( "RVM_init: unable to create the RVM TIMER mem bank"); | |
96 return FALSE; | |
97 } | |
98 | |
99 mb_params.size = RVM_NOTIFY_MB_SIZE; | |
100 mb_params.watermark = RVM_NOTIFY_MB_WATERMARK; | |
101 | |
102 if(rvm_tm_notify_mem_bank!=RVF_INVALID_MB_ID) return TRUE; | |
103 // create rvm main Memory Bank | |
104 if ( rvf_create_mb( RVM_NOTIFY_MB, mb_params, &rvm_tm_notify_mem_bank) != RVF_OK) | |
105 { | |
106 // TO DO: remove this call since the RVT software entity has not been started yet. | |
107 RVM_TRACE_ERROR( "RVM_init: unable to create the RVM TIMER NOTIFY MSG mem bank"); | |
108 return FALSE; | |
109 } | |
110 | |
111 return TRUE; | |
112 } | |
113 | |
114 /******************************************************************************* | |
115 ** Function rvm_task | |
116 ** | |
117 ** Description Core of the RVM task, which initiliazes the RVM and | |
118 ** waits for messages. | |
119 ** | |
120 *******************************************************************************/ | |
121 void rvm_task (UINT32 param) | |
122 { BOOLEAN detectedError = FALSE; | |
123 T_RV_HDR * msgPtr; | |
124 | |
125 /* init the SWEs database */ | |
126 if ( rvm_init_swe_db() != RVM_OK) | |
127 { /* lack of memory */ | |
128 detectedError = TRUE; | |
129 } | |
130 //printf("RVManager core: %d %s\n", rvf_get_taskid(), rvf_get_taskname()); | |
131 | |
132 /* loop to process messages */ | |
133 while (detectedError == FALSE) | |
134 { | |
135 /* Wait for the necessary event (msg in the rve mailbox and no timeout). */ | |
136 UINT16 recEvent = rvf_wait ( RVM_EXPECTED_EVENT, 0); | |
137 | |
138 /* If the expected event is received, then */ | |
139 if (recEvent & RVM_EXPECTED_EVENT) { | |
140 /* Read the message in the rve mailbox */ | |
141 msgPtr = (T_RV_HDR *) rvf_read_mbox (RVM_MAILBOX); | |
142 if(msgPtr) { | |
143 /* Determine the input message type */ | |
144 switch (msgPtr->msg_id) { | |
145 case (RVM_START_APPLI): { | |
146 rvm_launch_appli((T_RVM_MSG*)msgPtr); | |
147 rvf_free_buf(msgPtr); | |
148 break; | |
149 } | |
150 case (RVM_STOP_APPLI): { // still keep original concept | |
151 rvm_shut_down_appli((T_RVM_MSG*)msgPtr); | |
152 rvf_free_buf(msgPtr); | |
153 break; | |
154 } | |
155 case (RVM_STOP_MSG): { // new concept, eg. reverse init/start concept | |
156 if(((T_RVM_STOP_MSG*)msgPtr)->status==SWE_RUNNING) { | |
157 rvm_stop_appli((T_RVM_STOP_MSG*) msgPtr); | |
158 rvf_free_buf(msgPtr); | |
159 } else { | |
160 rvm_swe_has_stopped((T_RVM_STOP_MSG*) msgPtr); | |
161 rvf_free_buf(msgPtr); | |
162 } | |
163 | |
164 break; | |
165 } | |
166 #ifdef _CONSOLE | |
167 case (RVM_EVT_TO_APPLI): { /*A-M-E-N-D-E-D! */ | |
168 /* proxy msg's sent by "rvm_snd_to_upper()" | |
169 /* There arrival here is evident that no parent or | |
170 /* calling process, ie. No MMI exists and they were | |
171 /* started by RVM itself. */ | |
172 RVM_TRACE_WARNING_PARAM("RVM: caller response msg", msgPtr->msg_id); | |
173 | |
174 _callerProxy((T_RVM_APPLI_RESULT*)msgPtr); | |
175 rvf_free_buf(msgPtr); | |
176 break; | |
177 } | |
178 #endif | |
179 default: { | |
180 RVM_TRACE_WARNING_PARAM("rvm_Task: [switch()] unrecognized msg", msgPtr->msg_id); | |
181 | |
182 rvf_free_buf(msgPtr); | |
183 break; | |
184 } | |
185 } | |
186 } | |
187 /* free the received msg */ | |
188 // rvf_free_buf(msgPtr); // may be used when STOP is completed | |
189 } else { | |
190 RVM_TRACE_WARNING_PARAM("RVM_task: unrecognized event", recEvent); | |
191 } | |
192 } | |
193 RVM_TRACE_ERROR("RVM_task: unrecoverable error --> stopping RVM"); | |
194 } | |
195 | |
196 T_RVM_RETURN rvm_t2_proxy() { | |
197 T_RVM_RETURN error_status=RVM_OK; | |
198 T_RV_HDR* p_msg = NULL ; | |
199 UINT16 rec_event; | |
200 T_RVF_G_ADDR_ID gid=RVF_INVALID_ADDR_ID; | |
201 UINT16 nbTmExp=0; | |
202 UINT8 y=0,F_PRI=0, yield; | |
203 | |
204 RVM_TRACE_WARNING_PARAM("T2PROXY TACHE DE DEV", RV_TRACE_LEVEL_DEBUG_HIGH); | |
205 | |
206 rvf_start_timer(0, RVM_YIELD_T2_PS_TM, 1); | |
207 yield=MAX_PARASITES; | |
208 gid=rvf_get_taskid(); | |
209 | |
210 while (error_status == RVM_OK) { | |
211 | |
212 rec_event = rvf_evt_wait(gid, 0xffff, 0xFFFFFFFFL); /* Wait (infinite) for all events. */ | |
213 | |
214 if (rec_event & RVF_TASK_MBOX_1_EVT_MASK) { | |
215 F_PRI=1; | |
216 for(y=0; (p_msg=(T_RV_HDR *)rvf_read_addr_mbox (gid, 1)) && (y<yield); y++) { | |
217 //RVM_TRACE_WARNING_PARAM("T2 PRI MAILBOX !!!\n", RV_TRACE_LEVEL_DEBUG_HIGH); | |
218 rvf_setRDV(gid, p_msg->dest_addr_id); | |
219 switch(p_msg->msg_id) { | |
220 case RVM_TMS_MSG: | |
221 if(pRtAddrIdTable[p_msg->dest_addr_id] && pRtAddrIdTable[p_msg->dest_addr_id]->handle_timer) { | |
222 pRtAddrIdTable[p_msg->dest_addr_id]->handle_timer(p_msg); | |
223 } else rvf_free_timer_msg(p_msg); | |
224 break; | |
225 case RVM_START_T2_MSG: | |
226 yield=MAX_PARASITES; | |
227 _start_group(gid, ((T_RVM_START_T2_MSG*)p_msg)->grp); | |
228 rvf_free_buf(p_msg); | |
229 break; | |
230 case RVM_STOP_MSG: | |
231 _stop_t2_swe((T_RVM_STOP_MSG*)p_msg); | |
232 break; | |
233 case RVM_RT_MOD_YIELD_T2_MSG: | |
234 if(((T_RVM_RT_MOD_YIELD_T2_MSG*)p_msg)->val > 1) | |
235 rvf_start_timer(0, ((T_RVM_RT_MOD_YIELD_T2_MSG*)p_msg)->val, 1); | |
236 rvf_free_buf(p_msg); | |
237 break; | |
238 default: | |
239 if(pRtAddrIdTable[p_msg->dest_addr_id] && pRtAddrIdTable[p_msg->dest_addr_id]->handle_message) { | |
240 pRtAddrIdTable[p_msg->dest_addr_id]->handle_message(p_msg); | |
241 } else rvf_free_msg(p_msg); | |
242 break; | |
243 } | |
244 rvf_setRDV(gid, RVF_INVALID_ADDR_ID); | |
245 } | |
246 yield=RVM_YIELD_T2_PRI_MSG_CNT; | |
247 } | |
248 if (rec_event & RVF_TASK_MBOX_0_EVT_MASK ) { | |
249 //RVM_TRACE_WARNING_PARAM("T2 STND MAILBOX !!!\n", RV_TRACE_LEVEL_DEBUG_HIGH); | |
250 if(p_msg=(T_RV_HDR *) rvf_read_mbox (0)) { | |
251 rvf_setRDV(gid, p_msg->dest_addr_id); | |
252 switch(p_msg->msg_id) { | |
253 case RVM_TMS_MSG: | |
254 if(pRtAddrIdTable[p_msg->dest_addr_id] && pRtAddrIdTable[p_msg->dest_addr_id]->handle_timer) { | |
255 pRtAddrIdTable[p_msg->dest_addr_id]->handle_timer(p_msg); | |
256 } else rvf_free_timer_msg(p_msg); | |
257 | |
258 //rvf_free_buf(p_msg); | |
259 break; | |
260 case RVM_START_T2_MSG: | |
261 _start_group(gid, ((T_RVM_START_T2_MSG*)p_msg)->grp); | |
262 rvf_free_buf(p_msg); | |
263 break; | |
264 case RVM_STOP_MSG: | |
265 _stop_t2_swe((T_RVM_STOP_MSG*)p_msg); // preserve | |
266 break; | |
267 default: | |
268 if(pRtAddrIdTable[p_msg->dest_addr_id] && pRtAddrIdTable[p_msg->dest_addr_id]->handle_message) { | |
269 pRtAddrIdTable[p_msg->dest_addr_id]->handle_message(p_msg); | |
270 } else rvf_free_msg(p_msg); | |
271 break; | |
272 } | |
273 rvf_setRDV(gid, RVF_INVALID_ADDR_ID); | |
274 } | |
275 } | |
276 if( rec_event & RVF_TIMER_0_EVT_MASK ) { | |
277 //RVM_TRACE_WARNING_PARAM("T2 YIELD !!!\n", RV_TRACE_LEVEL_DEBUG_HIGH); | |
278 rvf_yield(); | |
279 } | |
280 if( rec_event & RVF_TIMER_1_EVT_MASK || rec_event & RVF_TIMER_2_EVT_MASK ) { | |
281 | |
282 RVM_TRACE_WARNING_PARAM("RVM: Forbidden timer usage for type 2 entities!\n Please use rvf_add_timer()", RV_TRACE_LEVEL_DEBUG_HIGH); | |
283 } | |
284 if(rec_event & RVF_TIMER_3_EVT_MASK) { | |
285 | |
286 /*nbTmExp=0; //rvf_update_timer_list((pRtAddrIdTable[gid]->p_tm_q)); | |
287 | |
288 while(nbTmExp-- > 0) { | |
289 p_msg=0;//(T_RV_HDR*)rvf_get_expired_entry((pRtAddrIdTable[gid]->p_tm_q)); | |
290 if(p_msg->dest_addr_id) | |
291 pRtAddrIdTable[p_msg->dest_addr_id]->handle_timer(p_msg); | |
292 else RVM_TRACE_WARNING_PARAM("T3PROXY NO TM DESTINATION", RV_TRACE_LEVEL_DEBUG_HIGH); | |
293 }*/ | |
294 } | |
295 F_PRI=0; | |
296 } | |
297 | |
298 /*if (error_status == INVKR_MEMORY_ERR) { | |
299 invkr_env_ctrl_blk_p->error_ft("INVKR", RVM_MEMORY_ERR, 0, | |
300 " Memory Error : the INVKR primitive memory bank is RED "); | |
301 }*/ | |
302 | |
303 RVM_TRACE_WARNING_PARAM("T2PROXY ERROR: CORE TERMINATION", RV_TRACE_LEVEL_DEBUG_HIGH); | |
304 | |
305 /* BEFORE returning free resources !!! */ | |
306 return RVM_OK; | |
307 } | |
308 | |
309 T_RVM_RETURN rvm_t3_proxy() { | |
310 T_RVM_RETURN error_status=RVM_OK; | |
311 T_RV_HDR* p_msg = NULL ; | |
312 UINT16 rec_event; | |
313 T_RVF_G_ADDR_ID gid; | |
314 UINT8 swe_i=0; | |
315 UINT16 nbTmExp=0; | |
316 T_RV_HDR* p_hdr=NULL; | |
317 UINT8 yield=250, y=0; /* arguable whether T3 needs Yield. Hence, high nb */ | |
318 UINT8 F_PRI=0; | |
319 | |
320 RVM_TRACE_WARNING_PARAM("T3PROXY TACHE DE DEV", RV_TRACE_LEVEL_DEBUG_HIGH); | |
321 //printf("t2proxy: %d %s\n", rvf_get_taskid(), rvf_get_taskname()); | |
322 gid=rvf_get_taskid(); | |
323 if(gid) _t3_start(gid); | |
324 | |
325 RVM_TRACE_WARNING_PARAM("T3PROXY START()", RV_TRACE_LEVEL_DEBUG_HIGH); | |
326 | |
327 while (error_status == RVM_OK) { | |
328 | |
329 rec_event = rvf_evt_wait(gid, 0xffff, 0xFFFFFFFFL); /* Wait (infinite) for all events. */ | |
330 | |
331 if (rec_event & RVF_TASK_MBOX_1_EVT_MASK) { | |
332 F_PRI=1; | |
333 for(y=0; (p_msg=(T_RV_HDR *)rvf_read_addr_mbox (gid, 1)) && (y<yield); y++) { | |
334 if(p_msg->msg_id==RVM_TMS_MSG) { | |
335 if(pRtAddrIdTable[p_msg->dest_addr_id] && pRtAddrIdTable[p_msg->dest_addr_id]->handle_timer) { | |
336 pRtAddrIdTable[p_msg->dest_addr_id]->handle_timer(p_msg); | |
337 } else rvf_free_timer_msg(p_msg); | |
338 } else if(p_msg->msg_id==RVM_STOP_MSG) { | |
339 _stop_t3_swe((T_RVM_STOP_MSG*)p_msg); | |
340 } else { | |
341 if(pRtAddrIdTable[p_msg->dest_addr_id] && pRtAddrIdTable[p_msg->dest_addr_id]->handle_message) { | |
342 pRtAddrIdTable[p_msg->dest_addr_id]->handle_message(p_msg); | |
343 } else rvf_free_msg(p_msg); | |
344 } | |
345 } | |
346 } | |
347 if (rec_event & RVF_TASK_MBOX_0_EVT_MASK && !F_PRI) { | |
348 if(p_msg=(T_RV_HDR *) rvf_read_addr_mbox (gid, 0)) { | |
349 if(p_msg->msg_id==RVM_TMS_MSG) { | |
350 if(pRtAddrIdTable[p_msg->dest_addr_id] && pRtAddrIdTable[p_msg->dest_addr_id]->handle_timer) { | |
351 pRtAddrIdTable[p_msg->dest_addr_id]->handle_timer(p_msg); | |
352 } else rvf_free_timer_msg(p_msg); | |
353 } else if(p_msg->msg_id==RVM_STOP_MSG) { | |
354 _stop_t3_swe((T_RVM_STOP_MSG*)p_msg); | |
355 } else { | |
356 if(pRtAddrIdTable[p_msg->dest_addr_id] && pRtAddrIdTable[p_msg->dest_addr_id]->handle_message) { | |
357 pRtAddrIdTable[p_msg->dest_addr_id]->handle_message(p_msg); | |
358 } else rvf_free_msg(p_msg); | |
359 } | |
360 } | |
361 } | |
362 if(rec_event & RVF_TIMER_0_EVT_MASK) { | |
363 if(rvf_get_buf(rvm_mem_bank,sizeof(T_RV_HDR),(T_RVF_BUFFER**) &p_hdr)!=RVF_RED) { | |
364 p_hdr->msg_id=RVF_TIMER_0_EVT_MASK; | |
365 p_hdr->dest_addr_id=0; | |
366 pRtAddrIdTable[resolveHostAddrId(gid)]->handle_timer(p_hdr); | |
367 } else RVM_TRACE_WARNING_PARAM("RVM: T3 PROXY TM 0 EVENT DISPATCH MEM ERROR!", RV_TRACE_LEVEL_DEBUG_HIGH); | |
368 } | |
369 if(rec_event & RVF_TIMER_1_EVT_MASK) { | |
370 if(rvf_get_buf(rvm_mem_bank,sizeof(T_RV_HDR),(T_RVF_BUFFER**) &p_hdr)!=RVF_RED) { | |
371 p_hdr->msg_id=RVF_TIMER_1_EVT_MASK; | |
372 p_hdr->dest_addr_id=0; | |
373 pRtAddrIdTable[resolveHostAddrId(gid)]->handle_timer(p_hdr); | |
374 } else RVM_TRACE_WARNING_PARAM("RVM: T3 PROXY TM 1 EVENT DISPATCH MEM ERROR!", RV_TRACE_LEVEL_DEBUG_HIGH); | |
375 | |
376 } | |
377 if(rec_event & RVF_TIMER_2_EVT_MASK) { | |
378 if(rvf_get_buf(rvm_mem_bank,sizeof(T_RV_HDR),(T_RVF_BUFFER**) &p_hdr)!=RVF_RED) { | |
379 p_hdr->msg_id=RVF_TIMER_2_EVT_MASK; | |
380 p_hdr->dest_addr_id=0; | |
381 pRtAddrIdTable[resolveHostAddrId(gid)]->handle_timer(p_hdr); | |
382 } else RVM_TRACE_WARNING_PARAM("RVM: T3 PROXY TM 2 EVENT DISPATCH MEM ERROR!", RV_TRACE_LEVEL_DEBUG_HIGH); | |
383 | |
384 } | |
385 if(rec_event & RVF_TIMER_3_EVT_MASK) { | |
386 | |
387 nbTmExp=0; //rvf_update_timer_list((pRtAddrIdTable[gid]->p_tm_q)); | |
388 //printf("T3 POLL TIMER Id %d ---------------------------------------------> %d!\n",gid, nbTmExp); | |
389 | |
390 while(nbTmExp-- > 0) { | |
391 p_msg=0; //(T_RV_HDR*)rvf_get_expired_entry(pRtAddrIdTable[gid]->p_tm_q); | |
392 if(p_msg->dest_addr_id) | |
393 pRtAddrIdTable[p_msg->dest_addr_id]->handle_timer(p_msg); | |
394 else RVM_TRACE_WARNING_PARAM("T3PROXY NO TM DESTINATION", RV_TRACE_LEVEL_DEBUG_HIGH); | |
395 } | |
396 } | |
397 F_PRI=0; | |
398 } | |
399 | |
400 /*if (error_status == INVKR_MEMORY_ERR) { | |
401 invkr_env_ctrl_blk_p->error_ft("INVKR", RVM_MEMORY_ERR, 0, | |
402 " Memory Error : the INVKR primitive memory bank is RED "); | |
403 }*/ | |
404 | |
405 RVM_TRACE_WARNING_PARAM("T3PROXY ERROR: CORE TERMINATION", RV_TRACE_LEVEL_DEBUG_HIGH); | |
406 | |
407 /* BEFORE returning free resources !!! */ | |
408 return RVM_OK; | |
409 } | |
410 | |
411 T_RVM_RETURN rvm_start_group_req(T_RVF_G_ADDR_ID addrId, UINT8* grp) { | |
412 T_RVM_START_T2_MSG * p_msg; | |
413 T_RVF_MB_STATUS mb_status; | |
414 UINT8 i=0; | |
415 | |
416 mb_status = rvf_get_msg_buf(rvm_mem_bank, | |
417 sizeof(T_RVM_START_T2_MSG), | |
418 RVM_START_T2_MSG, | |
419 (T_RVF_MSG**) &p_msg); | |
420 | |
421 if (mb_status == RVF_RED) { | |
422 RVM_TRACE_WARNING_PARAM("rvm_start_group(): Error to get memory ",RV_TRACE_LEVEL_ERROR); | |
423 return RVM_MEMORY_ERR; | |
424 } else if (mb_status == RVF_YELLOW) { | |
425 RVM_TRACE_WARNING_PARAM("rvm_start_group(): Getting short on memory ", RV_TRACE_LEVEL_WARNING); | |
426 } | |
427 | |
428 for(i=0;i<10; i++) p_msg->grp[i]=0; // DEFINE MAX !!! | |
429 | |
430 p_msg->hdr.msg_id = RVM_START_T2_MSG; | |
431 for(i=0; i<10 && grp[i]!=0; i++) p_msg->grp[i]=grp[i]; | |
432 | |
433 return rvf_send_priority_msg(addrId, p_msg); //? cast (void*) i/p | |
434 } | |
435 | |
436 T_RVM_RETURN _start_group(T_RVF_G_ADDR_ID gid, UINT8* grp) { | |
437 T_RVM_INFO_SWE swe_info; | |
438 UINT8 i=0; | |
439 // for each k_swe_entry, IF NOT started get_info and call start() | |
440 for(i=0; i<10 && grp[i]!=0; i++ ) { | |
441 // printf("INDEXES %d\n", grp[i]); | |
442 rvm_swe_array[grp[i]].swe_get_info(&swe_info); | |
443 rvf_setRDV(gid, rvm_swe_array[grp[i]].swe_addr_id); | |
444 if(swe_info.type_info.type2.start) { | |
445 swe_info.type_info.type2.start(); | |
446 rvm_swe_array[grp[i]].swe_state = SWE_RUNNING; | |
447 } | |
448 rvf_setRDV(gid, RVF_INVALID_ADDR_ID); | |
449 } | |
450 | |
451 return RVM_OK; /* ERROR case To do */ | |
452 } | |
453 | |
454 T_RVM_RETURN _t3_start(T_RVF_G_ADDR_ID gid) { | |
455 T_RVM_INFO_SWE swe_info; | |
456 | |
457 rvm_swe_array[pRtAddrIdTable[gid]->swe_db_index].swe_get_info(&swe_info); | |
458 if(swe_info.type_info.type3.start) { | |
459 swe_info.type_info.type3.start(); | |
460 rvm_swe_array[pRtAddrIdTable[gid]->\ | |
461 swe_db_index].swe_state = SWE_RUNNING; | |
462 } | |
463 | |
464 return RVM_OK; /* ERROR case To do */ | |
465 } | |
466 | |
467 T_RVM_RETURN _stop_t2_swe(T_RVM_STOP_MSG* p_msg) { | |
468 T_RVM_INFO_SWE swe_info; | |
469 | |
470 rvm_swe_array[p_msg->swe_num].swe_get_info(&swe_info); | |
471 if(swe_info.type_info.type2.stop) swe_info.type_info.type2.stop((T_RV_HDR*)p_msg); | |
472 | |
473 return RVM_OK; /* ERROR case To do */ | |
474 } | |
475 | |
476 T_RVM_RETURN _stop_t3_swe(T_RVM_STOP_MSG* p_msg) { | |
477 T_RVM_INFO_SWE swe_info; | |
478 | |
479 rvm_swe_array[p_msg->swe_num].swe_get_info(&swe_info); | |
480 if(swe_info.type_info.type3.stop) swe_info.type_info.type3.stop((T_RV_HDR*)p_msg); | |
481 | |
482 return RVM_OK; /* ERROR case To do */ | |
483 } | |
484 | |
485 T_RVM_RETURN rvm_mod_rt_t2_yield(T_RVF_G_ADDR_ID addrId, UINT16 val) { | |
486 T_RVM_RT_MOD_YIELD_T2_MSG * p_msg; | |
487 T_RVF_MB_STATUS mb_status; | |
488 | |
489 mb_status = rvf_get_msg_buf(rvm_sys_mem_bank, | |
490 sizeof(T_RVM_RT_MOD_YIELD_T2_MSG), | |
491 RVM_RT_MOD_YIELD_T2_MSG, | |
492 (T_RVF_MSG**) &p_msg); | |
493 | |
494 if (mb_status == RVF_RED) { | |
495 RVM_TRACE_WARNING_PARAM("rvm_start_group(): Error to get memory ",RV_TRACE_LEVEL_ERROR); | |
496 return RVM_MEMORY_ERR; | |
497 } else if (mb_status == RVF_YELLOW) { | |
498 RVM_TRACE_WARNING_PARAM("rvm_start_group(): Getting short on memory ", RV_TRACE_LEVEL_WARNING); | |
499 } | |
500 | |
501 p_msg->hdr.msg_id = RVM_RT_MOD_YIELD_T2_MSG; /* from internal header */ | |
502 p_msg->val = val; | |
503 | |
504 /* Send the message using mailbox. */ | |
505 return rvf_send_priority_msg(addrId, p_msg); //? cast (void*) i/p | |
506 } | |
507 | |
508 /* ONLY used for return path msgs from entities started/stopped by the RVM */ | |
509 #ifdef _CONSOLE | |
510 void _callerProxy(T_RVM_APPLI_RESULT *p_msg_res) { /*A-M-E-N-D-E-D! */ | |
511 char *ret_val=NULL; | |
512 | |
513 switch(p_msg_res->result) { | |
514 case RV_OK: ret_val="RVM: Successful entity start or stop:"; | |
515 break; | |
516 case RV_NOT_SUPPORTED: ret_val="RVM: Not Supported:"; | |
517 break; | |
518 case RV_NOT_READY: ret_val="RVM: Not Ready:"; | |
519 break; | |
520 case RV_MEMORY_ERR: ret_val="RVM: Memory Alloc. Error:"; | |
521 break; | |
522 case RV_MEMORY_REMAINING: ret_val="RVM: Memory REMAINING AFTER STOP & KILL!: "; | |
523 break; | |
524 case RV_INTERNAL_ERR: ret_val="RVM: Memory Alloc. Error:"; | |
525 break; | |
526 case RV_INVALID_PARAMETER: ret_val="RVM: Invalid Parameter:"; | |
527 break; | |
528 default: ret_val="RVM: Not recognised:n"; | |
529 break; | |
530 } | |
531 RVM_TRACE_WARNING_PARAM(ret_val, p_msg_res->swe_index); | |
532 } | |
533 #endif |