comparison src/cs/system/main/create_RVtasks.c @ 0:4e78acac3d88

src/{condat,cs,gpf,nucleus}: import from Selenite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:23:26 +0000
parents
children 8d5373b24f5f
comparison
equal deleted inserted replaced
-1:000000000000 0:4e78acac3d88
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_FCHG_SWE
396 /* initialize FCHG (new PWR) SWE */
397 rv_start_swe_and_check (FCHG_USE_ID, "FCHG");
398 #endif
399
400 #ifdef RVM_KPD_SWE
401 /* initialize KPD SWE */
402 rv_start_swe_and_check (KPD_USE_ID, "KPD");
403 #endif
404
405 #ifdef RVM_DAR_SWE
406 /* initialize DAR SWE */
407 rv_start_swe_and_check (DAR_USE_ID, "DAR");
408 #endif
409
410 #ifdef RVM_R2D_SWE
411 /* initialize R2D SWE */
412 rv_start_swe_and_check (R2D_USE_ID, "R2D");
413 #endif
414
415 #ifdef RVM_LCD_SWE
416 /* initialize LCD SWE */
417 rv_start_swe_and_check (LCD_USE_ID, "LCD");
418 #endif
419
420
421 #ifdef RVM_ETM_SWE
422 /* initialize ETM SWE */
423 rv_start_swe_and_check (ETM_USE_ID, "ETM");
424 #endif
425
426 #ifdef RVM_TTY_SWE
427 /* initialize TTY SWE */
428 rv_start_swe_and_check (TTY_USE_ID, "TTY");
429 #endif
430
431
432 #ifdef RVM_AUDIO_MAIN_SWE
433 /* initialize AUDIO SWE */
434 rv_start_swe_and_check (AUDIO_USE_ID, "AUDIO");
435 #endif
436
437 #if (PSP_STANDALONE==0)
438 #ifdef RVM_AUDIO_BGD_SWE
439 /* initialize AUDIO BACKGROUND SWE */
440 rv_start_swe_and_check (AUDIO_BGD_USE_ID, "AUDIO_BGD");
441 #endif
442 #endif
443
444 #if (PSP_STANDALONE==0)
445 #ifdef RVM_BAE_SWE
446 /* initialize BAE SWE */
447 rv_start_swe_and_check (BAE_USE_ID, "BAE");
448 #endif
449 #endif
450
451 #ifdef RVM_AS_SWE
452 /* initialize AS (Audio Services) SWE */
453 rv_start_swe_and_check (AS_USE_ID, "AS");
454 #endif
455
456 #if (PSP_STANDALONE==0)
457 #ifdef RVM_BPR_SWE
458 /* initialize sample BPR SWE */
459 rv_start_swe_and_check (BPR_USE_ID, "BPR");
460 #endif
461
462 #endif /* PSP_STANDALONE */
463
464 #ifdef RVM_RTC_SWE
465 /* initialize RTC SWE */
466 rv_start_swe_and_check (RTC_USE_ID, "RTC");
467 #endif
468
469 #ifdef RVM_LLS_SWE
470 /* initialize LLS SWE */
471 rv_start_swe_and_check (LLS_USE_ID, "LLS");
472 #endif
473
474 #ifdef RVM_TUT_SWE
475 /* initialize TUT SWE */
476 // rv_start_swe_and_check (TUT_USE_ID, "TUT");
477 #endif
478
479 #ifdef RVM_RGUI_SWE
480 /* initialize RGUI SWE */
481 rv_start_swe_and_check (RGUI_USE_ID, "RGUI");
482 #endif
483
484 #ifdef RVM_ATP_SWE
485 /* initialize ATP SWE */
486 rv_start_swe_and_check (ATP_USE_ID, "ATP");
487 #endif
488
489 /*
490 * FreeCalypso: the main.lib:Create_RVtasks.obj binary blob we got with our
491 * TCS211 semi-src does not start MKS, even though the SWE itself is enabled
492 * in the build system and pulled into the link.
493 */
494 #if 0
495 #ifdef RVM_MKS_SWE
496 rv_start_swe_and_check (MKS_USE_ID, "MKS");
497 #endif
498 #endif
499
500 #ifdef RVM_IMG_SWE
501 rv_start_swe_and_check (IMG_USE_ID, "IMG");
502 #endif
503
504 #ifdef RVM_GBI_SWE
505 rv_start_swe_and_check (GBI_USE_ID, "GBI");
506 #endif
507
508 #ifdef RVM_CAMD_SWE
509 rv_start_swe_and_check (CAMD_USE_ID, "CAMD");
510 #endif
511
512 #ifdef RVM_USB_SWE
513 /* initialize USB SWE */
514 rv_start_swe_and_check (USB_USE_ID, "USB");
515 #endif
516
517 #ifdef RVM_CAMA_SWE
518 rv_start_swe_and_check (CAMA_USE_ID, "CAMA");
519 #endif
520
521 #ifdef RVM_MFW_SWE
522 /* initialize MFW SWE */
523 rv_start_swe_and_check (MFW_USE_ID, "MFW");
524 #endif
525
526 #ifdef RVM_SMBS_SWE
527 /* initialize SMBS SWE */
528 rv_start_swe_and_check (SMBS_USE_ID, "SMBS");
529 #endif
530
531 #ifdef RVM_USBFAX_SWE
532 /* initialize USB SWE */
533 rv_start_swe_and_check (USBFAX_USE_ID, "USBFAX");
534 #endif
535
536 #ifdef RVM_USBTRC_SWE
537 /* initialize USBTRC SWE */
538 rv_start_swe_and_check (USBTRC_USE_ID, "USBTRC");
539 #endif
540
541 #ifdef RVM_USBMS_SWE
542 /* initialize USBMS SWE */
543 rv_start_swe_and_check (USBMS_USE_ID, "USBMS");
544 #endif
545
546 #ifdef RVM_RFS_SWE
547 /* initialize RFS SWE */
548 rv_start_swe_and_check (RFS_USE_ID, "RFS");
549 #endif
550
551
552 #ifdef RVM_CCI_SWE
553 /* initialize CCI SWE */
554 rv_start_swe_and_check (CCI_USE_ID, "CCI");
555 #endif
556
557 #ifdef RVM_BTUI_SWE
558 /* initialize sample BTUI SWE */
559 rv_start_swe_and_check (BTUI_USE_ID, "BTUI");
560 #endif
561 #ifdef RVM_JPEG_SWE
562 /* initialize sample JPEG SWE */
563 rv_start_swe_and_check (JPEG_USE_ID, "JPEG");
564 #endif
565 #ifdef RVM_JPEG_SWE
566 /* initialize sample JPEG SWE */
567 rv_start_swe_and_check (JPEG_USE_ID, "JPEG");
568 #endif
569 #endif
570 // WARNING WARNING ----------------------------------------------------
571 // Do not perform any SWE initialization after this line !
572 // WARNING WARNING ----------------------------------------------------
573
574 #if (REMU==0) /* moved this to kpd start function. rv_start function for REMU. rv_start is called from Application Initialize
575 context. Since this is a blocking call, we cannot afford to block in Application_Initialization. */
576 #ifndef _WINDOWS
577 // Perform switch ON processing.
578 Switch_ON();
579 #endif
580
581 #if (_GSM==1)
582 BZ_KeyBeep_ON (); // Audio feedback if ON/OFF pushed
583 #endif // if (_GSM==1)
584
585 #endif
586 #if (CHIPSET!=15) || (REMU==0)
587 /* dump the Riviera memory state */
588 rvf_delay (RVF_MS_TO_TICKS (300)) ;
589 rvf_dump_mem ();
590 rvf_dump_pool();
591 rvf_dump_tasks();
592 #endif
593 #if (TEST==1)
594 #if (PSP_STANDALONE == 1)
595 /* Just For Testing Reset of UICC */
596 // bspUicc_reset(1,0);
597
598 /* Just For Testing GEA */
599 // bspTest_Gea3_ciph_req(1);
600
601 #endif
602 #if (CHIPSET!=15) || (REMU==0)
603 // create a Memory Bank for the 'Test Selection Menu'.
604 mb_requirements.size = RVTEST_MENU_MB_SIZE;
605 mb_requirements.watermark = RVTEST_MENU_MB_WATERMARK;
606 mb_requirements.pool_id = RVF_POOL_EXTERNAL_MEM;
607 if (rvf_create_mb (RVTEST_MENU_MB_NAME,
608 mb_requirements,
609 &mb_id) != RVF_OK)
610 {
611 // error case.
612 result++;
613 }
614
615 #if (PSP_STANDALONE == 1)
616 /* Just For Testing Reset of UICC */
617 bspUicc_reset(1,0); /* Just For Testing GEA */
618 bspTest_Gea3_ciph_req(1);
619 #endif
620
621 // Go to the 'Test Selection Menu' (using rv_test ()).
622 rv_test (0);
623 #endif
624 #endif // (TEST==1)
625
626 #if (CHIPSET!=15) || (REMU==0)
627 // infinite wait
628 rvf_evt_wait (START_TASK_ID,
629 0xFFFF,
630 0xFFFFFFFFL);
631 #endif
632 }
633
634 #if (TEST==1)
635 #define RV_START_TASK_STACK (4096)
636 #else
637 #define RV_START_TASK_STACK (1024)
638 #endif
639 #if (CHIPSET!=15) || (REMU==0)
640 UINT8 stack_start[RV_START_TASK_STACK];
641
642
643 /*******************************************************************************
644 **
645 ** Function create_tasks
646 **
647 ** Description This function is called once at startup to allow task
648 ** creation thanks to Riviera environment.
649 **
650 ** Returns void
651 **
652 *******************************************************************************/
653 void create_tasks (void)
654 {
655
656 // Tasks creation
657 rvf_create_legacy_task ((TASKPTR) rv_start, START_TASK_ID,
658 "RV_START", stack_start,
659 RV_START_TASK_STACK, RV_START_TASK_PRIO, 0, RUNNING);
660
661 }
662 #endif
663
664
665