comparison nuc-fw/riviera/init/create_RVtasks.c @ 129:7d7950d7f924

Riviera should be ready for the first TI fw build attempt
author Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
date Fri, 01 Nov 2013 06:13:58 +0000
parents
children 3b5c3f3646fb
comparison
equal deleted inserted replaced
128:789a9a95533f 129:7d7950d7f924
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
51 #define START_TASK_ID (MAX_RVF_TASKS-1)
52 #define RV_START_TASK_PRIO (249)
53
54 T_RVT_USER_ID rv_trace_user_id = 0xff;
55 T_RVT_USER_ID etm_trace_user_id;
56
57 extern void etm_receive(unsigned char *inbuf, unsigned short size);
58
59 #ifdef MIXED_TRACE
60 T_RVT_USER_ID l23_trace_user_id;
61 extern void ext_processExtInput (T_RVT_BUFFER, UINT16);
62 #endif
63
64 #ifdef RVM_RNET_BR_SWE
65 T_RVT_USER_ID rnet_trace_user_id;
66 extern void rnet_receive (UINT8 *inbuf, UINT16 size);
67 #endif
68
69 #if (TEST==1)
70
71 // The name that uniquely identifies the Memory Bank MUST be
72 // 'TEST1', whereas it might be used by some other software
73 // entity for testing purpose.
74 #define RVTEST_MENU_MB_NAME ("TEST1")
75
76 // Memory requirements.
77 #define RVTEST_MENU_MB_SIZE (5000)
78 #define RVTEST_MENU_MB_WATERMARK (4000)
79
80 extern void rv_test (UINT32 p);
81 #endif
82
83
84 /*******************************************************************************
85 **
86 ** Function rvt_init_trace
87 **
88 ** Description This function is called by the RV_START task to register
89 ** the Riviera Frame in the trace module
90 **
91 ** Returns void
92 **
93 *******************************************************************************/
94 void rvt_init_trace (void)
95 {
96 rvt_register_id ("RV", &rv_trace_user_id, rvt_set_trace_level);
97 }
98
99 #ifdef RVM_ETM_SWE
100 /*******************************************************************************
101 **
102 ** Function etm_init_trace
103 **
104 ** Description This function is called by the RV_START task to register
105 ** the ETM in the trace module
106 **
107 ** Returns void
108 **
109 *******************************************************************************/
110 void etm_init_trace (void)
111 {
112 extern T_RVT_USER_ID tm_trace_user_id;
113
114 rvt_register_id("TM", &etm_trace_user_id, etm_receive);
115
116 #if (PSP_STANDALONE != 1)
117 tm_trace_user_id = etm_trace_user_id; // TML1 use the tm_trace_user_id
118 #endif
119 }
120 #endif
121
122 #ifdef MIXED_TRACE
123 /*******************************************************************************
124 **
125 ** Function l23_init_trace
126 **
127 ** Description This function is called by the RV_START task to register
128 ** the Protocol Stack (Layers 2 & 3) in the trace module
129 **
130 ** Returns void
131 **
132 *******************************************************************************/
133 void l23_init_trace (void)
134 {
135 rvt_register_id ("L23", &l23_trace_user_id, ext_processExtInput);
136 }
137 #endif
138
139 #ifdef RVM_RNET_BR_SWE
140 /*******************************************************************************
141 **
142 ** Function rnet_init_trace
143 **
144 ** Description This function is called by the RV_START task to register
145 ** RNET in the trace module
146 **
147 ** Returns void
148 **
149 *******************************************************************************/
150 void rnet_init_trace (void)
151 {
152 rvt_register_id ("RNET", &rnet_trace_user_id, rnet_receive);
153 }
154 #endif
155
156
157 /*******************************************************************************
158 **
159 ** Function rv_start_swe_and_check
160 **
161 ** Description This internal function is called by the stater task to
162 ** start the basic SWEs in the system and to check if
163 ** they started successfully or not.
164 **
165 ** Returns void
166 **
167 *******************************************************************************/
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 /*******************************************************************************
296 **
297 ** Function rv_start
298 **
299 ** Description This function is called by the RV_START task. It starts the
300 ** Riviera environment and the TRACE task. This start must be
301 ** done after Application_initialize().
302 **
303 ** Returns void
304 **
305 *******************************************************************************/
306 void rv_start (void)
307 {
308 #if (TEST==1)
309 T_RVF_MB_ID mb_id = RVF_INVALID_MB_ID;
310 T_RVF_MB_PARAM mb_requirements = {0};
311 volatile UINT16 result = 0;
312 #endif
313
314 /* initialize the RVM and the RVF at the same time */
315 rvm_start_environment ();
316 /*
317 ** Init trace module
318 */
319 rvt_init_trace ();
320 #ifdef RVM_ETM_SWE
321 etm_init_trace ();
322 #endif
323
324 #if CONFIG_GSM
325 #ifdef MIXED_TRACE
326 l23_init_trace ();
327 #endif
328 #endif // if (_GSM==1)
329
330 #ifdef RVM_RNET_BR_SWE
331 rnet_init_trace ();
332 #endif
333
334 #if (REMU==1)
335 #ifdef RVM_LLS_SWE
336 /* initialize LLS SWE */
337 lls_init();
338 #endif
339
340 #ifdef RVM_RNG_SWE
341 /* initialize RNG SWE */
342 rng_init ();
343 #endif
344 #endif
345
346 #ifdef RVM_RVT_SWE
347 /* initialize TRACE SWE */
348 rv_start_swe_and_check (RVT_USE_ID, "RVT");
349 #endif
350
351 #ifdef RVM_I2C_SWE
352 rv_start_swe_and_check (I2C_USE_ID, "I2C");
353 #endif
354
355 #ifdef RVM_DMA_SWE
356 rv_start_swe_and_check (DMA_USE_ID, "DMA");
357 #endif
358
359 #ifdef RVM_DMG_SWE
360 rv_start_swe_and_check (DMG_USE_ID, "DMG");
361 #endif
362
363 #ifdef RVM_NAN_SWE
364 rv_start_swe_and_check (NAN_USE_ID, "NAN");
365 #endif
366
367 #ifdef RVM_MC_SWE
368 rv_start_swe_and_check (MC_USE_ID, "MC");
369 #endif
370
371 #ifdef RVM_FFS_SWE
372 /* initialize FFS SWE */
373 rv_start_swe_and_check (FFS_USE_ID, "FFS");
374 #endif
375
376 #ifdef RVM_SPI_SWE
377 /* initialize SPI SWE */
378 rv_start_swe_and_check (SPI_USE_ID, "SPI");
379 #endif
380
381 #ifdef RVM_PWR_SWE
382 /* initialize PWR SWE */
383 rv_start_swe_and_check (PWR_USE_ID, "PWR");
384 #endif
385
386 #ifdef RVM_LCC_SWE
387 /* initialize LCC(PWR) SWE */
388 rv_start_swe_and_check (LCC_USE_ID, "LCC");
389 #endif
390
391 #ifdef RVM_KPD_SWE
392 /* initialize KPD SWE */
393 rv_start_swe_and_check (KPD_USE_ID, "KPD");
394 #endif
395
396 #ifdef RVM_DAR_SWE
397 /* initialize DAR SWE */
398 rv_start_swe_and_check (DAR_USE_ID, "DAR");
399 #endif
400
401 #ifdef RVM_R2D_SWE
402 /* initialize R2D SWE */
403 rv_start_swe_and_check (R2D_USE_ID, "R2D");
404 #endif
405
406 #ifdef RVM_LCD_SWE
407 /* initialize LCD SWE */
408 rv_start_swe_and_check (LCD_USE_ID, "LCD");
409 #endif
410
411
412 #ifdef RVM_ETM_SWE
413 /* initialize ETM SWE */
414 rv_start_swe_and_check (ETM_USE_ID, "ETM");
415 #endif
416
417 #ifdef RVM_TTY_SWE
418 /* initialize TTY SWE */
419 rv_start_swe_and_check (TTY_USE_ID, "TTY");
420 #endif
421
422
423 #ifdef RVM_AUDIO_MAIN_SWE
424 /* initialize AUDIO SWE */
425 rv_start_swe_and_check (AUDIO_USE_ID, "AUDIO");
426 #endif
427
428 #if 1 //(PSP_STANDALONE==0)
429 #ifdef RVM_AUDIO_BGD_SWE
430 /* initialize AUDIO BACKGROUND SWE */
431 rv_start_swe_and_check (AUDIO_BGD_USE_ID, "AUDIO_BGD");
432 #endif
433 #endif
434
435 #if 1 //(PSP_STANDALONE==0)
436 #ifdef RVM_BAE_SWE
437 /* initialize BAE SWE */
438 rv_start_swe_and_check (BAE_USE_ID, "BAE");
439 #endif
440 #endif
441
442 #ifdef RVM_AS_SWE
443 /* initialize AS (Audio Services) SWE */
444 rv_start_swe_and_check (AS_USE_ID, "AS");
445 #endif
446
447 #if 1 //(PSP_STANDALONE==0)
448 #ifdef RVM_BPR_SWE
449 /* initialize sample BPR SWE */
450 rv_start_swe_and_check (BPR_USE_ID, "BPR");
451 #endif
452 #endif /* PSP_STANDALONE */
453
454 #ifdef RVM_RTC_SWE
455 /* initialize RTC SWE */
456 rv_start_swe_and_check (RTC_USE_ID, "RTC");
457 #endif
458
459 #ifdef RVM_LLS_SWE
460 /* initialize LLS SWE */
461 rv_start_swe_and_check (LLS_USE_ID, "LLS");
462 #endif
463
464 #ifdef RVM_TUT_SWE
465 /* initialize TUT SWE */
466 // rv_start_swe_and_check (TUT_USE_ID, "TUT");
467 #endif
468
469 #ifdef RVM_RGUI_SWE
470 /* initialize RGUI SWE */
471 rv_start_swe_and_check (RGUI_USE_ID, "RGUI");
472 #endif
473
474 #ifdef RVM_ATP_SWE
475 /* initialize ATP SWE */
476 rv_start_swe_and_check (ATP_USE_ID, "ATP");
477 #endif
478
479 #ifdef RVM_MKS_SWE
480 rv_start_swe_and_check (MKS_USE_ID, "MKS");
481 #endif
482
483 #ifdef RVM_IMG_SWE
484 rv_start_swe_and_check (IMG_USE_ID, "IMG");
485 #endif
486
487 #ifdef RVM_GBI_SWE
488 rv_start_swe_and_check (GBI_USE_ID, "GBI");
489 #endif
490
491 #ifdef RVM_CAMD_SWE
492 rv_start_swe_and_check (CAMD_USE_ID, "CAMD");
493 #endif
494
495 #ifdef RVM_USB_SWE
496 /* initialize USB SWE */
497 rv_start_swe_and_check (USB_USE_ID, "USB");
498 #endif
499
500 #ifdef RVM_CAMA_SWE
501 rv_start_swe_and_check (CAMA_USE_ID, "CAMA");
502 #endif
503
504 #ifdef RVM_MFW_SWE
505 /* initialize MFW SWE */
506 rv_start_swe_and_check (MFW_USE_ID, "MFW");
507 #endif
508
509 #ifdef RVM_SMBS_SWE
510 /* initialize SMBS SWE */
511 rv_start_swe_and_check (SMBS_USE_ID, "SMBS");
512 #endif
513
514 #ifdef RVM_USBFAX_SWE
515 /* initialize USB SWE */
516 rv_start_swe_and_check (USBFAX_USE_ID, "USBFAX");
517 #endif
518
519 #ifdef RVM_USBTRC_SWE
520 /* initialize USBTRC SWE */
521 rv_start_swe_and_check (USBTRC_USE_ID, "USBTRC");
522 #endif
523
524 #ifdef RVM_USBMS_SWE
525 /* initialize USBMS SWE */
526 rv_start_swe_and_check (USBMS_USE_ID, "USBMS");
527 #endif
528
529 #ifdef RVM_RFS_SWE
530 /* initialize RFS SWE */
531 rv_start_swe_and_check (RFS_USE_ID, "RFS");
532 #endif
533
534
535 #ifdef RVM_CCI_SWE
536 /* initialize CCI SWE */
537 rv_start_swe_and_check (CCI_USE_ID, "CCI");
538 #endif
539
540 #ifdef RVM_BTUI_SWE
541 /* initialize sample BTUI SWE */
542 rv_start_swe_and_check (BTUI_USE_ID, "BTUI");
543 #endif
544 #ifdef RVM_JPEG_SWE
545 /* initialize sample JPEG SWE */
546 rv_start_swe_and_check (JPEG_USE_ID, "JPEG");
547 #endif
548 #ifdef RVM_JPEG_SWE
549 /* initialize sample JPEG SWE */
550 rv_start_swe_and_check (JPEG_USE_ID, "JPEG");
551 #endif
552 // WARNING WARNING ----------------------------------------------------
553 // Do not perform any SWE initialization after this line !
554 // WARNING WARNING ----------------------------------------------------
555
556 #if 0 //(REMU==0)
557 /* moved this to kpd start function. rv_start function for REMU. rv_start is called from Application Initialize
558 context. Since this is a blocking call, we cannot afford to block in Application_Initialization. */
559 #ifndef _WINDOWS
560 // Perform switch ON processing.
561 Switch_ON();
562 #endif
563
564 #if (_GSM==1)
565 BZ_KeyBeep_ON (); // Audio feedback if ON/OFF pushed
566 #endif // if (_GSM==1)
567
568 #endif
569
570 #if 1 //(CHIPSET!=15) || (REMU==0)
571 /* dump the Riviera memory state */
572 rvf_delay (RVF_MS_TO_TICKS (300)) ;
573 rvf_dump_mem ();
574 rvf_dump_pool();
575 rvf_dump_tasks();
576 #endif
577
578 #if (TEST==1)
579 // create a Memory Bank for the 'Test Selection Menu'.
580 mb_requirements.size = RVTEST_MENU_MB_SIZE;
581 mb_requirements.watermark = RVTEST_MENU_MB_WATERMARK;
582 mb_requirements.pool_id = RVF_POOL_EXTERNAL_MEM;
583 if (rvf_create_mb (RVTEST_MENU_MB_NAME,
584 mb_requirements,
585 &mb_id) != RVF_OK)
586 {
587 // error case.
588 result++;
589 }
590
591 // Go to the 'Test Selection Menu' (using rv_test ()).
592 rv_test (0);
593 #endif // (TEST==1)
594
595 // infinite wait
596 rvf_evt_wait (START_TASK_ID,
597 0xFFFF,
598 0xFFFFFFFFL);
599 }
600
601 #if (TEST==1)
602 #define RV_START_TASK_STACK (4096)
603 #else
604 #define RV_START_TASK_STACK (1024)
605 #endif
606 UINT8 stack_start[RV_START_TASK_STACK];
607
608
609 /*******************************************************************************
610 **
611 ** Function create_tasks
612 **
613 ** Description This function is called once at startup to allow task
614 ** creation thanks to Riviera environment.
615 **
616 ** Returns void
617 **
618 *******************************************************************************/
619 void create_tasks (void)
620 {
621
622 // Tasks creation
623 rvf_create_legacy_task ((TASKPTR) rv_start, START_TASK_ID,
624 "RV_START", stack_start,
625 RV_START_TASK_STACK, RV_START_TASK_PRIO, 0, RUNNING);
626
627 }