comparison gsm-fw/riviera/init/create_RVtasks.c @ 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/init/create_RVtasks.c@3b5c3f3646fb
children 60afcd233b04
comparison
equal deleted inserted replaced
142:15d5977390c2 143:afceeeb2cba1
1 /*************************************************************************************
2 * *
3 * Name create_RVtasks.c *
4 * *
5 * Function this file contains functions allowing tasks creation in *
6 * the Riviera environment *
7 * *
8 * Version 0.1 *
9 * *
10 * Date Modification *
11 * ------------------------------------ *
12 * 03 August 2000 Create *
13 * *
14 * Author Pascal Puel *
15 * *
16 * (C) Copyright 2000 by Texas Instruments Incorporated, All Rights Reserved *
17 * *
18 * --------------------------------------------------------------------------------- *
19 * *
20 * History: *
21 * *
22 * 10/18/2001 - Updated for R2D by Christophe Favergeon *
23 * 08/28/2002 - Clean-Up by Gerard Cauvy *
24 * *
25 ************************************************************************************/
26
27 #include "../../include/config.h"
28
29 #include "../rv/rv_general.h"
30 #include "../rvf/rvf_api.h"
31 #include "../rvm/rvm_api.h"
32 #include "../rvm/rvm_use_id_list.h"
33 #include "../rvt/rvt_gen.h"
34
35 #if 0
36 //sys_types.h is necessary for function prototypes in buzzer.h
37 #include "sys_types.h"
38 #include "buzzer/buzzer.h"
39 #endif
40
41 #include "../rv/rv_defined_swe.h"
42
43 #if 0 //#ifndef _WINDOWS
44 # include "power/power.h"
45 #endif
46
47 #include <stdio.h>
48 #include <string.h>
49
50 #define START_TASK_ID (MAX_RVF_TASKS-1)
51 #define RV_START_TASK_PRIO (249)
52
53 T_RVT_USER_ID rv_trace_user_id = 0xff;
54 T_RVT_USER_ID etm_trace_user_id;
55
56 extern void etm_receive(unsigned char *inbuf, unsigned short size);
57
58 #ifdef MIXED_TRACE
59 T_RVT_USER_ID l23_trace_user_id;
60 extern void ext_processExtInput (T_RVT_BUFFER, UINT16);
61 #endif
62
63 #ifdef RVM_RNET_BR_SWE
64 T_RVT_USER_ID rnet_trace_user_id;
65 extern void rnet_receive (UINT8 *inbuf, UINT16 size);
66 #endif
67
68 #if (TEST==1)
69
70 // The name that uniquely identifies the Memory Bank MUST be
71 // 'TEST1', whereas it might be used by some other software
72 // entity for testing purpose.
73 #define RVTEST_MENU_MB_NAME ("TEST1")
74
75 // Memory requirements.
76 #define RVTEST_MENU_MB_SIZE (5000)
77 #define RVTEST_MENU_MB_WATERMARK (4000)
78
79 extern void rv_test (UINT32 p);
80 #endif
81
82
83 /*******************************************************************************
84 **
85 ** Function rvt_init_trace
86 **
87 ** Description This function is called by the RV_START task to register
88 ** the Riviera Frame in the trace module
89 **
90 ** Returns void
91 **
92 *******************************************************************************/
93 void rvt_init_trace (void)
94 {
95 rvt_register_id ("RV", &rv_trace_user_id, rvt_set_trace_level);
96 }
97
98 #ifdef RVM_ETM_SWE
99 /*******************************************************************************
100 **
101 ** Function etm_init_trace
102 **
103 ** Description This function is called by the RV_START task to register
104 ** the ETM in the trace module
105 **
106 ** Returns void
107 **
108 *******************************************************************************/
109 void etm_init_trace (void)
110 {
111 extern T_RVT_USER_ID tm_trace_user_id;
112
113 rvt_register_id("TM", &etm_trace_user_id, etm_receive);
114
115 #if (PSP_STANDALONE != 1)
116 tm_trace_user_id = etm_trace_user_id; // TML1 use the tm_trace_user_id
117 #endif
118 }
119 #endif
120
121 #ifdef MIXED_TRACE
122 /*******************************************************************************
123 **
124 ** Function l23_init_trace
125 **
126 ** Description This function is called by the RV_START task to register
127 ** the Protocol Stack (Layers 2 & 3) in the trace module
128 **
129 ** Returns void
130 **
131 *******************************************************************************/
132 void l23_init_trace (void)
133 {
134 rvt_register_id ("L23", &l23_trace_user_id, ext_processExtInput);
135 }
136 #endif
137
138 #ifdef RVM_RNET_BR_SWE
139 /*******************************************************************************
140 **
141 ** Function rnet_init_trace
142 **
143 ** Description This function is called by the RV_START task to register
144 ** RNET in the trace module
145 **
146 ** Returns void
147 **
148 *******************************************************************************/
149 void rnet_init_trace (void)
150 {
151 rvt_register_id ("RNET", &rnet_trace_user_id, rnet_receive);
152 }
153 #endif
154
155
156 /*******************************************************************************
157 **
158 ** Function rv_start_swe_and_check
159 **
160 ** Description This internal function is called by the stater task to
161 ** start the basic SWEs in the system and to check if
162 ** they started successfully or not.
163 **
164 ** Returns void
165 **
166 *******************************************************************************/
167 BOOLEAN rv_start_swe_and_check (T_RVM_USE_ID swe_use_id, T_RVM_NAME swe_name)
168 {
169 T_RV_RETURN return_path = {0};
170 T_RV_HDR *msg_ptr = NULL;
171 UINT16 rec_evt = 0;
172 char error_msg[150] = "";
173
174 /* temporary initialization of addr_id */
175 return_path.addr_id = START_TASK_ID;
176 return_path.callback_func = NULL;
177
178 /* attempt to initialize the required SWE */
179 if (rvm_start_swe (swe_use_id, return_path) != RVM_OK)
180 {
181 sprintf (error_msg,
182 "create_RVtasks: Unable to start %s (0x%.8x). Error in rvm_start_swe",
183 (char *)swe_name,
184 swe_use_id);
185 rvf_send_trace ((char *)error_msg,
186 strlen((char *)error_msg),
187 NULL_PARAM,
188 RV_TRACE_LEVEL_WARNING, RVM_USE_ID);
189 return FALSE;
190 }
191
192 /*
193 * wait for the SWE to be actually started.
194 * note that the 'RVM_EVT_TO_APPLI' notification is sent back
195 * once xxx_start () is invoked.
196 */
197 while (rec_evt = rvf_evt_wait (START_TASK_ID, \
198 0xFFFF, \
199 0xFFFFFFFFL))
200 {
201 if (rec_evt & ~RVF_TASK_MBOX_0_EVT_MASK)
202 {
203 sprintf (error_msg,
204 "create_RVtasks: Starting %s (0x%.8x). Event ",
205 (char *)swe_name,
206 swe_use_id);
207 rvf_send_trace ((char *)error_msg,
208 strlen((char *)error_msg),
209 (UINT32)rec_evt,
210 RV_TRACE_LEVEL_WARNING,
211 RVM_USE_ID);
212 }
213 if (rec_evt & RVF_TASK_MBOX_0_EVT_MASK)
214 {
215 if ((msg_ptr = (T_RV_HDR *) rvf_read_addr_mbox (START_TASK_ID, \
216 RVF_TASK_MBOX_0)) == NULL)
217 {
218 sprintf (error_msg,
219 "create_RVtasks: Starting %s (0x%.8x). Message NULL",
220 (char *)swe_name,
221 swe_use_id);
222 rvf_send_trace ((char *)error_msg,
223 strlen((char *)error_msg),
224 NULL_PARAM,
225 RV_TRACE_LEVEL_WARNING,
226 RVM_USE_ID);
227 continue;
228 }
229 if (msg_ptr->msg_id != RVM_EVT_TO_APPLI)
230 {
231 sprintf (error_msg,
232 "create_RVtasks: Starting %s (0x%.8x). Message ID ",
233 (char *)swe_name,
234 swe_use_id);
235 rvf_send_trace ((char *)error_msg,
236 strlen((char *)error_msg),
237 msg_ptr->msg_id,
238 RV_TRACE_LEVEL_WARNING,
239 RVM_USE_ID);
240 rvf_free_buf (msg_ptr);
241 continue;
242 }
243 break;
244 }
245 }
246 switch (((T_RVM_APPLI_RESULT *)msg_ptr)->result)
247 {
248 case RVM_OK:
249 {
250 sprintf (error_msg,
251 "create_RVtasks: %s (0x%.8x) started",
252 (char *)swe_name,
253 swe_use_id);
254 rvf_send_trace ((char *)error_msg,
255 strlen ((char *)error_msg),
256 NULL_PARAM,
257 RV_TRACE_LEVEL_DEBUG_HIGH,
258 RVM_USE_ID);
259 rvf_free_buf (msg_ptr);
260 return TRUE;
261 }
262 case RVM_NOT_READY:
263 {
264 sprintf (error_msg,
265 "create_RVtasks: %s (0x%.8x) already started",
266 (char *)swe_name,
267 swe_use_id);
268 rvf_send_trace ((char *)error_msg,
269 strlen ((char *)error_msg),
270 NULL_PARAM,
271 RV_TRACE_LEVEL_DEBUG_MEDIUM,
272 RVM_USE_ID);
273 rvf_free_buf (msg_ptr);
274 return TRUE;
275 }
276 default:
277 {
278 break;
279 }
280 }
281 sprintf (error_msg,
282 "create_RVtasks: Unable to start %s (0x%.8x). Error ",
283 (char *)swe_name,
284 swe_use_id);
285 rvf_send_trace ((char *)error_msg,
286 strlen ((char *)error_msg),
287 ((T_RVM_APPLI_RESULT *)msg_ptr)->result,
288 RV_TRACE_LEVEL_WARNING,
289 RVM_USE_ID);
290 rvf_free_buf (msg_ptr);
291 return FALSE;
292 }
293
294 /*******************************************************************************
295 **
296 ** Function rv_start
297 **
298 ** Description This function is called by the RV_START task. It starts the
299 ** Riviera environment and the TRACE task. This start must be
300 ** done after Application_initialize().
301 **
302 ** Returns void
303 **
304 *******************************************************************************/
305 void rv_start (void)
306 {
307 #if (TEST==1)
308 T_RVF_MB_ID mb_id = RVF_INVALID_MB_ID;
309 T_RVF_MB_PARAM mb_requirements = {0};
310 volatile UINT16 result = 0;
311 #endif
312
313 /* initialize the RVM and the RVF at the same time */
314 rvm_start_environment ();
315 /*
316 ** Init trace module
317 */
318 rvt_init_trace ();
319 #ifdef RVM_ETM_SWE
320 etm_init_trace ();
321 #endif
322
323 #if CONFIG_GSM
324 #ifdef MIXED_TRACE
325 l23_init_trace ();
326 #endif
327 #endif // if (_GSM==1)
328
329 #ifdef RVM_RNET_BR_SWE
330 rnet_init_trace ();
331 #endif
332
333 #if (REMU==1)
334 #ifdef RVM_LLS_SWE
335 /* initialize LLS SWE */
336 lls_init();
337 #endif
338
339 #ifdef RVM_RNG_SWE
340 /* initialize RNG SWE */
341 rng_init ();
342 #endif
343 #endif
344
345 #ifdef RVM_RVT_SWE
346 /* initialize TRACE SWE */
347 rv_start_swe_and_check (RVT_USE_ID, "RVT");
348 #endif
349
350 #ifdef RVM_I2C_SWE
351 rv_start_swe_and_check (I2C_USE_ID, "I2C");
352 #endif
353
354 #ifdef RVM_DMA_SWE
355 rv_start_swe_and_check (DMA_USE_ID, "DMA");
356 #endif
357
358 #ifdef RVM_DMG_SWE
359 rv_start_swe_and_check (DMG_USE_ID, "DMG");
360 #endif
361
362 #ifdef RVM_NAN_SWE
363 rv_start_swe_and_check (NAN_USE_ID, "NAN");
364 #endif
365
366 #ifdef RVM_MC_SWE
367 rv_start_swe_and_check (MC_USE_ID, "MC");
368 #endif
369
370 #ifdef RVM_FFS_SWE
371 /* initialize FFS SWE */
372 rv_start_swe_and_check (FFS_USE_ID, "FFS");
373 #endif
374
375 #ifdef RVM_SPI_SWE
376 /* initialize SPI SWE */
377 rv_start_swe_and_check (SPI_USE_ID, "SPI");
378 #endif
379
380 #ifdef RVM_PWR_SWE
381 /* initialize PWR SWE */
382 rv_start_swe_and_check (PWR_USE_ID, "PWR");
383 #endif
384
385 #ifdef RVM_LCC_SWE
386 /* initialize LCC(PWR) SWE */
387 rv_start_swe_and_check (LCC_USE_ID, "LCC");
388 #endif
389
390 #ifdef RVM_KPD_SWE
391 /* initialize KPD SWE */
392 rv_start_swe_and_check (KPD_USE_ID, "KPD");
393 #endif
394
395 #ifdef RVM_DAR_SWE
396 /* initialize DAR SWE */
397 rv_start_swe_and_check (DAR_USE_ID, "DAR");
398 #endif
399
400 #ifdef RVM_R2D_SWE
401 /* initialize R2D SWE */
402 rv_start_swe_and_check (R2D_USE_ID, "R2D");
403 #endif
404
405 #ifdef RVM_LCD_SWE
406 /* initialize LCD SWE */
407 rv_start_swe_and_check (LCD_USE_ID, "LCD");
408 #endif
409
410
411 #ifdef RVM_ETM_SWE
412 /* initialize ETM SWE */
413 rv_start_swe_and_check (ETM_USE_ID, "ETM");
414 #endif
415
416 #ifdef RVM_TTY_SWE
417 /* initialize TTY SWE */
418 rv_start_swe_and_check (TTY_USE_ID, "TTY");
419 #endif
420
421
422 #ifdef RVM_AUDIO_MAIN_SWE
423 /* initialize AUDIO SWE */
424 rv_start_swe_and_check (AUDIO_USE_ID, "AUDIO");
425 #endif
426
427 #if 1 //(PSP_STANDALONE==0)
428 #ifdef RVM_AUDIO_BGD_SWE
429 /* initialize AUDIO BACKGROUND SWE */
430 rv_start_swe_and_check (AUDIO_BGD_USE_ID, "AUDIO_BGD");
431 #endif
432 #endif
433
434 #if 1 //(PSP_STANDALONE==0)
435 #ifdef RVM_BAE_SWE
436 /* initialize BAE SWE */
437 rv_start_swe_and_check (BAE_USE_ID, "BAE");
438 #endif
439 #endif
440
441 #ifdef RVM_AS_SWE
442 /* initialize AS (Audio Services) SWE */
443 rv_start_swe_and_check (AS_USE_ID, "AS");
444 #endif
445
446 #if 1 //(PSP_STANDALONE==0)
447 #ifdef RVM_BPR_SWE
448 /* initialize sample BPR SWE */
449 rv_start_swe_and_check (BPR_USE_ID, "BPR");
450 #endif
451 #endif /* PSP_STANDALONE */
452
453 #ifdef RVM_RTC_SWE
454 /* initialize RTC SWE */
455 rv_start_swe_and_check (RTC_USE_ID, "RTC");
456 #endif
457
458 #ifdef RVM_LLS_SWE
459 /* initialize LLS SWE */
460 rv_start_swe_and_check (LLS_USE_ID, "LLS");
461 #endif
462
463 #ifdef RVM_TUT_SWE
464 /* initialize TUT SWE */
465 // rv_start_swe_and_check (TUT_USE_ID, "TUT");
466 #endif
467
468 #ifdef RVM_RGUI_SWE
469 /* initialize RGUI SWE */
470 rv_start_swe_and_check (RGUI_USE_ID, "RGUI");
471 #endif
472
473 #ifdef RVM_ATP_SWE
474 /* initialize ATP SWE */
475 rv_start_swe_and_check (ATP_USE_ID, "ATP");
476 #endif
477
478 #ifdef RVM_MKS_SWE
479 rv_start_swe_and_check (MKS_USE_ID, "MKS");
480 #endif
481
482 #ifdef RVM_IMG_SWE
483 rv_start_swe_and_check (IMG_USE_ID, "IMG");
484 #endif
485
486 #ifdef RVM_GBI_SWE
487 rv_start_swe_and_check (GBI_USE_ID, "GBI");
488 #endif
489
490 #ifdef RVM_CAMD_SWE
491 rv_start_swe_and_check (CAMD_USE_ID, "CAMD");
492 #endif
493
494 #ifdef RVM_USB_SWE
495 /* initialize USB SWE */
496 rv_start_swe_and_check (USB_USE_ID, "USB");
497 #endif
498
499 #ifdef RVM_CAMA_SWE
500 rv_start_swe_and_check (CAMA_USE_ID, "CAMA");
501 #endif
502
503 #ifdef RVM_MFW_SWE
504 /* initialize MFW SWE */
505 rv_start_swe_and_check (MFW_USE_ID, "MFW");
506 #endif
507
508 #ifdef RVM_SMBS_SWE
509 /* initialize SMBS SWE */
510 rv_start_swe_and_check (SMBS_USE_ID, "SMBS");
511 #endif
512
513 #ifdef RVM_USBFAX_SWE
514 /* initialize USB SWE */
515 rv_start_swe_and_check (USBFAX_USE_ID, "USBFAX");
516 #endif
517
518 #ifdef RVM_USBTRC_SWE
519 /* initialize USBTRC SWE */
520 rv_start_swe_and_check (USBTRC_USE_ID, "USBTRC");
521 #endif
522
523 #ifdef RVM_USBMS_SWE
524 /* initialize USBMS SWE */
525 rv_start_swe_and_check (USBMS_USE_ID, "USBMS");
526 #endif
527
528 #ifdef RVM_RFS_SWE
529 /* initialize RFS SWE */
530 rv_start_swe_and_check (RFS_USE_ID, "RFS");
531 #endif
532
533
534 #ifdef RVM_CCI_SWE
535 /* initialize CCI SWE */
536 rv_start_swe_and_check (CCI_USE_ID, "CCI");
537 #endif
538
539 #ifdef RVM_BTUI_SWE
540 /* initialize sample BTUI SWE */
541 rv_start_swe_and_check (BTUI_USE_ID, "BTUI");
542 #endif
543 #ifdef RVM_JPEG_SWE
544 /* initialize sample JPEG SWE */
545 rv_start_swe_and_check (JPEG_USE_ID, "JPEG");
546 #endif
547 #ifdef RVM_JPEG_SWE
548 /* initialize sample JPEG SWE */
549 rv_start_swe_and_check (JPEG_USE_ID, "JPEG");
550 #endif
551 // WARNING WARNING ----------------------------------------------------
552 // Do not perform any SWE initialization after this line !
553 // WARNING WARNING ----------------------------------------------------
554
555 #if 0 //(REMU==0)
556 /* moved this to kpd start function. rv_start function for REMU. rv_start is called from Application Initialize
557 context. Since this is a blocking call, we cannot afford to block in Application_Initialization. */
558 #ifndef _WINDOWS
559 // Perform switch ON processing.
560 Switch_ON();
561 #endif
562
563 #if (_GSM==1)
564 BZ_KeyBeep_ON (); // Audio feedback if ON/OFF pushed
565 #endif // if (_GSM==1)
566
567 #endif
568
569 #if 1 //(CHIPSET!=15) || (REMU==0)
570 /* dump the Riviera memory state */
571 rvf_delay (RVF_MS_TO_TICKS (300)) ;
572 rvf_dump_mem ();
573 rvf_dump_pool();
574 rvf_dump_tasks();
575 #endif
576
577 #if (TEST==1)
578 // create a Memory Bank for the 'Test Selection Menu'.
579 mb_requirements.size = RVTEST_MENU_MB_SIZE;
580 mb_requirements.watermark = RVTEST_MENU_MB_WATERMARK;
581 mb_requirements.pool_id = RVF_POOL_EXTERNAL_MEM;
582 if (rvf_create_mb (RVTEST_MENU_MB_NAME,
583 mb_requirements,
584 &mb_id) != RVF_OK)
585 {
586 // error case.
587 result++;
588 }
589
590 // Go to the 'Test Selection Menu' (using rv_test ()).
591 rv_test (0);
592 #endif // (TEST==1)
593
594 // infinite wait
595 rvf_evt_wait (START_TASK_ID,
596 0xFFFF,
597 0xFFFFFFFFL);
598 }
599
600 #if (TEST==1)
601 #define RV_START_TASK_STACK (4096)
602 #else
603 #define RV_START_TASK_STACK (1024)
604 #endif
605 UINT8 stack_start[RV_START_TASK_STACK];
606
607
608 /*******************************************************************************
609 **
610 ** Function create_tasks
611 **
612 ** Description This function is called once at startup to allow task
613 ** creation thanks to Riviera environment.
614 **
615 ** Returns void
616 **
617 *******************************************************************************/
618 void create_tasks (void)
619 {
620
621 // Tasks creation
622 rvf_create_legacy_task ((TASKPTR) rv_start, START_TASK_ID,
623 "RV_START", stack_start,
624 RV_START_TASK_STACK, RV_START_TASK_PRIO, 0, RUNNING);
625
626 }