comparison chipsetsw/system/Main/create_RVtasks.c @ 15:abe969a9b145

contortions for rebuilding create_RVtasks.c from source (pulled from LoCosto)
author Space Falcon <falcon@ivan.Harhan.ORG>
date Sun, 06 Sep 2015 02:17:08 +0000
parents
children
comparison
equal deleted inserted replaced
14:91fb52ecb228 15:abe969a9b145
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 #ifndef _WINDOWS
28 #include "rv.cfg"
29 #endif
30
31 #include "rv/rv_general.h"
32 #include "rvf/rvf_api.h"
33 #include "rvm/rvm_api.h"
34 #include "rvm/rvm_use_id_list.h"
35 #include "rvt/rvt_gen.h"
36 //sys_types.h is necessary for function prototypes in buzzer.h
37 #include "sys_types.h"
38 #include "buzzer/buzzer.h"
39 #include "rv/rv_defined_swe.h"
40 #include "chipset.cfg"
41
42 #ifndef _WINDOWS
43 # include "power/power.h"
44 #endif
45
46 #include <stdio.h>
47 #include <string.h>
48
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 #if (CHIPSET!=15) || (REMU==0)
168 BOOLEAN rv_start_swe_and_check (T_RVM_USE_ID swe_use_id, T_RVM_NAME swe_name)
169 {
170 T_RV_RETURN return_path = {0};
171 T_RV_HDR *msg_ptr = NULL;
172 UINT16 rec_evt = 0;
173 char error_msg[150] = "";
174
175 /* temporary initialization of addr_id */
176 return_path.addr_id = START_TASK_ID;
177 return_path.callback_func = NULL;
178
179 /* attempt to initialize the required SWE */
180 if (rvm_start_swe (swe_use_id, return_path) != RVM_OK)
181 {
182 sprintf (error_msg,
183 "create_RVtasks: Unable to start %s (0x%.8x). Error in rvm_start_swe",
184 (char *)swe_name,
185 swe_use_id);
186 rvf_send_trace ((char *)error_msg,
187 strlen((char *)error_msg),
188 NULL_PARAM,
189 RV_TRACE_LEVEL_WARNING, RVM_USE_ID);
190 return FALSE;
191 }
192
193 /*
194 * wait for the SWE to be actually started.
195 * note that the 'RVM_EVT_TO_APPLI' notification is sent back
196 * once xxx_start () is invoked.
197 */
198 while (rec_evt = rvf_evt_wait (START_TASK_ID, \
199 0xFFFF, \
200 0xFFFFFFFFL))
201 {
202 if (rec_evt & ~RVF_TASK_MBOX_0_EVT_MASK)
203 {
204 sprintf (error_msg,
205 "create_RVtasks: Starting %s (0x%.8x). Event ",
206 (char *)swe_name,
207 swe_use_id);
208 rvf_send_trace ((char *)error_msg,
209 strlen((char *)error_msg),
210 (UINT32)rec_evt,
211 RV_TRACE_LEVEL_WARNING,
212 RVM_USE_ID);
213 }
214 if (rec_evt & RVF_TASK_MBOX_0_EVT_MASK)
215 {
216 if ((msg_ptr = (T_RV_HDR *) rvf_read_addr_mbox (START_TASK_ID, \
217 RVF_TASK_MBOX_0)) == NULL)
218 {
219 sprintf (error_msg,
220 "create_RVtasks: Starting %s (0x%.8x). Message NULL",
221 (char *)swe_name,
222 swe_use_id);
223 rvf_send_trace ((char *)error_msg,
224 strlen((char *)error_msg),
225 NULL_PARAM,
226 RV_TRACE_LEVEL_WARNING,
227 RVM_USE_ID);
228 continue;
229 }
230 if (msg_ptr->msg_id != RVM_EVT_TO_APPLI)
231 {
232 sprintf (error_msg,
233 "create_RVtasks: Starting %s (0x%.8x). Message ID ",
234 (char *)swe_name,
235 swe_use_id);
236 rvf_send_trace ((char *)error_msg,
237 strlen((char *)error_msg),
238 msg_ptr->msg_id,
239 RV_TRACE_LEVEL_WARNING,
240 RVM_USE_ID);
241 rvf_free_buf (msg_ptr);
242 continue;
243 }
244 break;
245 }
246 }
247 switch (((T_RVM_APPLI_RESULT *)msg_ptr)->result)
248 {
249 case RVM_OK:
250 {
251 sprintf (error_msg,
252 "create_RVtasks: %s (0x%.8x) started",
253 (char *)swe_name,
254 swe_use_id);
255 rvf_send_trace ((char *)error_msg,
256 strlen ((char *)error_msg),
257 NULL_PARAM,
258 RV_TRACE_LEVEL_DEBUG_HIGH,
259 RVM_USE_ID);
260 rvf_free_buf (msg_ptr);
261 return TRUE;
262 }
263 case RVM_NOT_READY:
264 {
265 sprintf (error_msg,
266 "create_RVtasks: %s (0x%.8x) already started",
267 (char *)swe_name,
268 swe_use_id);
269 rvf_send_trace ((char *)error_msg,
270 strlen ((char *)error_msg),
271 NULL_PARAM,
272 RV_TRACE_LEVEL_DEBUG_MEDIUM,
273 RVM_USE_ID);
274 rvf_free_buf (msg_ptr);
275 return TRUE;
276 }
277 default:
278 {
279 break;
280 }
281 }
282 sprintf (error_msg,
283 "create_RVtasks: Unable to start %s (0x%.8x). Error ",
284 (char *)swe_name,
285 swe_use_id);
286 rvf_send_trace ((char *)error_msg,
287 strlen ((char *)error_msg),
288 ((T_RVM_APPLI_RESULT *)msg_ptr)->result,
289 RV_TRACE_LEVEL_WARNING,
290 RVM_USE_ID);
291 rvf_free_buf (msg_ptr);
292 return FALSE;
293 }
294
295 #endif
296 /*******************************************************************************
297 **
298 ** Function rv_start
299 **
300 ** Description This function is called by the RV_START task. It starts the
301 ** Riviera environment and the TRACE task. This start must be
302 ** done after Application_initialize().
303 **
304 ** Returns void
305 **
306 *******************************************************************************/
307 void rv_start (void)
308 {
309 #if (TEST==1)
310 T_RVF_MB_ID mb_id = RVF_INVALID_MB_ID;
311 T_RVF_MB_PARAM mb_requirements = {0};
312 volatile UINT16 result = 0;
313 #endif
314
315 /* initialize the RVM and the RVF at the same time */
316 #if (CHIPSET!=15) || (REMU==0)
317 rvm_start_environment ();
318 #endif
319 /*
320 ** Init trace module
321 */
322 rvt_init_trace ();
323 #ifdef RVM_ETM_SWE
324 etm_init_trace ();
325 #endif
326
327 #if (_GSM==1)
328 #ifdef MIXED_TRACE
329 l23_init_trace ();
330 #endif
331 #endif // if (_GSM==1)
332
333 #ifdef RVM_RNET_BR_SWE
334 rnet_init_trace ();
335 #endif
336
337 #if (REMU==1)
338 #ifdef RVM_LLS_SWE
339 /* initialize LLS SWE */
340 lls_init();
341 #endif
342
343 #ifdef RVM_RNG_SWE
344 /* initialize RNG SWE */
345 rng_init ();
346 #endif
347 #endif
348
349 #if (CHIPSET!=15) || (REMU==0)
350 #ifdef RVM_RVT_SWE
351 /* initialize TRACE SWE */
352 rv_start_swe_and_check (RVT_USE_ID, "RVT");
353 #endif
354
355 #ifdef RVM_I2C_SWE
356 rv_start_swe_and_check (I2C_USE_ID, "I2C");
357 #endif
358
359 #ifdef RVM_DMA_SWE
360 rv_start_swe_and_check (DMA_USE_ID, "DMA");
361 #endif
362
363 #ifdef RVM_DMG_SWE
364 rv_start_swe_and_check (DMG_USE_ID, "DMG");
365 #endif
366
367 #ifdef RVM_NAN_SWE
368 rv_start_swe_and_check (NAN_USE_ID, "NAN");
369 #endif
370
371 #ifdef RVM_MC_SWE
372 rv_start_swe_and_check (MC_USE_ID, "MC");
373 #endif
374
375 #ifdef RVM_FFS_SWE
376 /* initialize FFS SWE */
377 rv_start_swe_and_check (FFS_USE_ID, "FFS");
378 #endif
379
380 #ifdef RVM_SPI_SWE
381 /* initialize SPI SWE */
382 rv_start_swe_and_check (SPI_USE_ID, "SPI");
383 #endif
384
385 #ifdef RVM_PWR_SWE
386 /* initialize PWR SWE */
387 rv_start_swe_and_check (PWR_USE_ID, "PWR");
388 #endif
389
390 #ifdef RVM_LCC_SWE
391 /* initialize LCC(PWR) SWE */
392 rv_start_swe_and_check (LCC_USE_ID, "LCC");
393 #endif
394
395 #ifdef RVM_KPD_SWE
396 /* initialize KPD SWE */
397 rv_start_swe_and_check (KPD_USE_ID, "KPD");
398 #endif
399
400 #ifdef RVM_DAR_SWE
401 /* initialize DAR SWE */
402 rv_start_swe_and_check (DAR_USE_ID, "DAR");
403 #endif
404
405 #ifdef RVM_R2D_SWE
406 /* initialize R2D SWE */
407 rv_start_swe_and_check (R2D_USE_ID, "R2D");
408 #endif
409
410 #ifdef RVM_LCD_SWE
411 /* initialize LCD SWE */
412 rv_start_swe_and_check (LCD_USE_ID, "LCD");
413 #endif
414
415
416 #ifdef RVM_ETM_SWE
417 /* initialize ETM SWE */
418 rv_start_swe_and_check (ETM_USE_ID, "ETM");
419 #endif
420
421 #ifdef RVM_TTY_SWE
422 /* initialize TTY SWE */
423 rv_start_swe_and_check (TTY_USE_ID, "TTY");
424 #endif
425
426
427 #ifdef RVM_AUDIO_MAIN_SWE
428 /* initialize AUDIO SWE */
429 rv_start_swe_and_check (AUDIO_USE_ID, "AUDIO");
430 #endif
431
432 #if (PSP_STANDALONE==0)
433 #ifdef RVM_AUDIO_BGD_SWE
434 /* initialize AUDIO BACKGROUND SWE */
435 rv_start_swe_and_check (AUDIO_BGD_USE_ID, "AUDIO_BGD");
436 #endif
437 #endif
438
439 #if (PSP_STANDALONE==0)
440 #ifdef RVM_BAE_SWE
441 /* initialize BAE SWE */
442 rv_start_swe_and_check (BAE_USE_ID, "BAE");
443 #endif
444 #endif
445
446 #ifdef RVM_AS_SWE
447 /* initialize AS (Audio Services) SWE */
448 rv_start_swe_and_check (AS_USE_ID, "AS");
449 #endif
450
451 #if (PSP_STANDALONE==0)
452 #ifdef RVM_BPR_SWE
453 /* initialize sample BPR SWE */
454 rv_start_swe_and_check (BPR_USE_ID, "BPR");
455 #endif
456
457 #endif /* PSP_STANDALONE */
458
459 #ifdef RVM_RTC_SWE
460 /* initialize RTC SWE */
461 rv_start_swe_and_check (RTC_USE_ID, "RTC");
462 #endif
463
464 #ifdef RVM_LLS_SWE
465 /* initialize LLS SWE */
466 rv_start_swe_and_check (LLS_USE_ID, "LLS");
467 #endif
468
469 #ifdef RVM_TUT_SWE
470 /* initialize TUT SWE */
471 // rv_start_swe_and_check (TUT_USE_ID, "TUT");
472 #endif
473
474 #ifdef RVM_RGUI_SWE
475 /* initialize RGUI SWE */
476 rv_start_swe_and_check (RGUI_USE_ID, "RGUI");
477 #endif
478
479 #ifdef RVM_ATP_SWE
480 /* initialize ATP SWE */
481 rv_start_swe_and_check (ATP_USE_ID, "ATP");
482 #endif
483
484 /*
485 * FreeCalypso: the main.lib:Create_RVtasks.obj binary blob we got with our
486 * TCS211 semi-src does not start MKS, even though the SWE itself is enabled
487 * in the build system and pulled into the link.
488 */
489 #if 0
490 #ifdef RVM_MKS_SWE
491 rv_start_swe_and_check (MKS_USE_ID, "MKS");
492 #endif
493 #endif
494
495 #ifdef RVM_IMG_SWE
496 rv_start_swe_and_check (IMG_USE_ID, "IMG");
497 #endif
498
499 #ifdef RVM_GBI_SWE
500 rv_start_swe_and_check (GBI_USE_ID, "GBI");
501 #endif
502
503 #ifdef RVM_CAMD_SWE
504 rv_start_swe_and_check (CAMD_USE_ID, "CAMD");
505 #endif
506
507 #ifdef RVM_USB_SWE
508 /* initialize USB SWE */
509 rv_start_swe_and_check (USB_USE_ID, "USB");
510 #endif
511
512 #ifdef RVM_CAMA_SWE
513 rv_start_swe_and_check (CAMA_USE_ID, "CAMA");
514 #endif
515
516 #ifdef RVM_MFW_SWE
517 /* initialize MFW SWE */
518 rv_start_swe_and_check (MFW_USE_ID, "MFW");
519 #endif
520
521 #ifdef RVM_SMBS_SWE
522 /* initialize SMBS SWE */
523 rv_start_swe_and_check (SMBS_USE_ID, "SMBS");
524 #endif
525
526 #ifdef RVM_USBFAX_SWE
527 /* initialize USB SWE */
528 rv_start_swe_and_check (USBFAX_USE_ID, "USBFAX");
529 #endif
530
531 #ifdef RVM_USBTRC_SWE
532 /* initialize USBTRC SWE */
533 rv_start_swe_and_check (USBTRC_USE_ID, "USBTRC");
534 #endif
535
536 #ifdef RVM_USBMS_SWE
537 /* initialize USBMS SWE */
538 rv_start_swe_and_check (USBMS_USE_ID, "USBMS");
539 #endif
540
541 #ifdef RVM_RFS_SWE
542 /* initialize RFS SWE */
543 rv_start_swe_and_check (RFS_USE_ID, "RFS");
544 #endif
545
546
547 #ifdef RVM_CCI_SWE
548 /* initialize CCI SWE */
549 rv_start_swe_and_check (CCI_USE_ID, "CCI");
550 #endif
551
552 #ifdef RVM_BTUI_SWE
553 /* initialize sample BTUI SWE */
554 rv_start_swe_and_check (BTUI_USE_ID, "BTUI");
555 #endif
556 #ifdef RVM_JPEG_SWE
557 /* initialize sample JPEG SWE */
558 rv_start_swe_and_check (JPEG_USE_ID, "JPEG");
559 #endif
560 #ifdef RVM_JPEG_SWE
561 /* initialize sample JPEG SWE */
562 rv_start_swe_and_check (JPEG_USE_ID, "JPEG");
563 #endif
564 #endif
565 // WARNING WARNING ----------------------------------------------------
566 // Do not perform any SWE initialization after this line !
567 // WARNING WARNING ----------------------------------------------------
568
569 #if (REMU==0) /* moved this to kpd start function. rv_start function for REMU. rv_start is called from Application Initialize
570 context. Since this is a blocking call, we cannot afford to block in Application_Initialization. */
571 #ifndef _WINDOWS
572 // Perform switch ON processing.
573 Switch_ON();
574 #endif
575
576 #if (_GSM==1)
577 BZ_KeyBeep_ON (); // Audio feedback if ON/OFF pushed
578 #endif // if (_GSM==1)
579
580 #endif
581 #if (CHIPSET!=15) || (REMU==0)
582 /* dump the Riviera memory state */
583 rvf_delay (RVF_MS_TO_TICKS (300)) ;
584 rvf_dump_mem ();
585 rvf_dump_pool();
586 rvf_dump_tasks();
587 #endif
588 #if (TEST==1)
589 #if (PSP_STANDALONE == 1)
590 /* Just For Testing Reset of UICC */
591 // bspUicc_reset(1,0);
592
593 /* Just For Testing GEA */
594 // bspTest_Gea3_ciph_req(1);
595
596 #endif
597 #if (CHIPSET!=15) || (REMU==0)
598 // create a Memory Bank for the 'Test Selection Menu'.
599 mb_requirements.size = RVTEST_MENU_MB_SIZE;
600 mb_requirements.watermark = RVTEST_MENU_MB_WATERMARK;
601 mb_requirements.pool_id = RVF_POOL_EXTERNAL_MEM;
602 if (rvf_create_mb (RVTEST_MENU_MB_NAME,
603 mb_requirements,
604 &mb_id) != RVF_OK)
605 {
606 // error case.
607 result++;
608 }
609
610 #if (PSP_STANDALONE == 1)
611 /* Just For Testing Reset of UICC */
612 bspUicc_reset(1,0); /* Just For Testing GEA */
613 bspTest_Gea3_ciph_req(1);
614 #endif
615
616 // Go to the 'Test Selection Menu' (using rv_test ()).
617 rv_test (0);
618 #endif
619 #endif // (TEST==1)
620
621 #if (CHIPSET!=15) || (REMU==0)
622 // infinite wait
623 rvf_evt_wait (START_TASK_ID,
624 0xFFFF,
625 0xFFFFFFFFL);
626 #endif
627 }
628
629 #if (TEST==1)
630 #define RV_START_TASK_STACK (4096)
631 #else
632 #define RV_START_TASK_STACK (1024)
633 #endif
634 #if (CHIPSET!=15) || (REMU==0)
635 UINT8 stack_start[RV_START_TASK_STACK];
636
637
638 /*******************************************************************************
639 **
640 ** Function create_tasks
641 **
642 ** Description This function is called once at startup to allow task
643 ** creation thanks to Riviera environment.
644 **
645 ** Returns void
646 **
647 *******************************************************************************/
648 void create_tasks (void)
649 {
650
651 // Tasks creation
652 rvf_create_legacy_task ((TASKPTR) rv_start, START_TASK_ID,
653 "RV_START", stack_start,
654 RV_START_TASK_STACK, RV_START_TASK_PRIO, 0, RUNNING);
655
656 }
657 #endif
658
659
660